diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..435b7250ba --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,11 @@ +version: 2.1 +jobs: + build: + docker: + - image: cimg/openjdk:11.0 + steps: + - checkout + - run: + name: Build + command: mvn -B -DskipTests clean package -Dcheckstyle.skip=true + diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index d87b6c73fa..ced7d6de0c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,10 +8,11 @@ assignees: '' --- # 提问前,请确保阅读过项目首页说明以及wiki开发文档相关内容,尤其是常见问题部分。完成内容后,请务必移除包括本句在内的无用内容,以免影响阅读,否则直接关闭,谢谢合作~ -# 另外如果确认属于bug,而且已明确如何修复,请参考贡献指南直接提交PR,省的浪费时间在这里描述问题,非常感谢配合 + +## 另外如果确认属于bug,而且已明确如何修复,请参考贡献指南直接提交PR,省的浪费时间在这里描述问题,非常感谢配合 ### 简要描述 -__简单概括描述下你所遇到的问题。__ +__请简单概括描述下你所遇到的问题。__ ### 模块版本情况 * WxJava 模块名: @@ -21,4 +22,7 @@ __简单概括描述下你所遇到的问题。__ __尽量详细描述。请不要使用截图,尽量使用文字描述,代码直接贴上来,日志则请附在后面所示区域。__ ### 日志 -__将日志放在 [pastebin](https://paste.ubuntu.com/) 或者其他地方,并将其url地址贴在这里__ +__如果日志不多,直接使用md代码引用格式贴在此处,否则如果太长,请将日志放在 [pastebin](https://paste.ubuntu.com/) 或者其他地方,然后将其url地址贴在这里__ +``` +日志请写于此处 +``` diff --git a/.github/workflows b/.github/workflows new file mode 100644 index 0000000000..e420c7d44d --- /dev/null +++ b/.github/workflows @@ -0,0 +1,4 @@ +- name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.travis.yml b/.travis.yml index 2b128c8a08..99850df729 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: java - jdk: - openjdk8 script: "mvn clean package -DskipTests=true -Dcheckstyle.skip=true" @@ -15,4 +14,4 @@ cache: notifications: email: - - binarywang@vip.qq.com + - a@binarywang.com diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba8e495afb..c703964824 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ # 代码贡献指南 -1. 首先非常欢迎和感谢对本项目发起`Pull Request`的同学。 +1. 首先非常欢迎和感谢对本项目发起 `Pull Request` 的热心小伙伴们。 1. **特别提示:请务必在 `develop` 分支提交 `PR`,`release` 分支目前仅是正式版的代码,即发布正式版本后才会从 `develop` 分支进行合并。** 1. 本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。 1. 为了便于设置,本项目引入`editorconfig`支持,请使用Eclipse的同学在贡献代码前安装相关插件,而`IntelliJ IDEA`新版本自带支持,如果没有可自行安装插件。 @@ -24,7 +24,7 @@ $ #do some change on the content $ git commit -am "Fix issue #1: change something" $ git push ``` -* 在 GitHub 网站上提交 Pull Request。 +* 在 `GitHub` 或 `Gitee` 网站上提交 `Pull Request`。 * 定期使用项目仓库内容更新自己仓库内容。 ```bash diff --git a/LICENSE b/LICENSE index 0c8a80022e..7783de532a 100644 --- a/LICENSE +++ b/LICENSE @@ -37,7 +37,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. diff --git a/README.md b/README.md index 8f0a4f95b6..8232e535c0 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,74 @@ -## WxJava - 微信开发 Java SDK(开发工具包) [![LICENSE](https://img.shields.io/badge/License-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![Badge](https://img.shields.io/badge/Link-996.icu-red.svg)](https://996.icu/#/zh_CN) +## WxJava - 微信开发 Java SDK [![码云Gitee](https://gitee.com/binary/weixin-java-tools/badge/star.svg?theme=blue)](https://gitee.com/binary/weixin-java-tools) [![Github](https://img.shields.io/github/stars/Wechat-Group/WxJava?logo=github&style=flat)](https://github.com/Wechat-Group/WxJava) [![GitHub release](https://img.shields.io/github/release/Wechat-Group/WxJava.svg)](https://github.com/Wechat-Group/WxJava/releases) [![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/wx-java.svg)](http://mvnrepository.com/artifact/com.github.binarywang/wx-java) -[![Build Status](https://travis-ci.com/Wechat-Group/WxJava.svg?branch=develop)](https://travis-ci.com/Wechat-Group/WxJava) -[![使用IntelliJ IDEA开发维护](https://img.shields.io/badge/IntelliJ%20IDEA-提供支持-blue.svg)](https://www.jetbrains.com/?from=WxJava-weixin-java-tools) +[![Build Status](https://img.shields.io/circleci/project/github/Wechat-Group/WxJava/develop.svg?sanitize=true)](https://circleci.com/gh/Wechat-Group/WxJava/tree/develop) +[![使用IntelliJ IDEA开发维护](https://img.shields.io/badge/IntelliJ%20IDEA-支持-blue.svg)](https://www.jetbrains.com/?from=WxJava-weixin-java-tools) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -#### 支持包括微信支付、开放平台、公众号、企业微信/企业号、小程序等微信功能的后端开发。 +#### 微信`Java`开发工具包,支持包括微信支付、开放平台、公众号、企业微信/企业号、小程序等微信功能模块的后端开发。 -

+

特别赞助 -

-
- - - - - - - + +
- - - - - - - - - -

1. 驰骋快速开发平台、工作流引擎、表单引擎采用GPL协议.

-

2. 驰骋.net版称为ccflow, java版称为jflow,代码100%开源.

-

3. 支持10多个国内外数据库. 单机版\集团版\SAAS版本.

-
-
+ + + + + + + + + + +
+ + ccflow + +
+ + 计全支付Jeepay,开源支付系统 + +
+ + mp qrcode + + + + diboot低代码开发平台 + + + + aliyun ad + +
### 重要信息 -1. **2021-06-02 发布 [【4.1.0正式版】](https://mp.weixin.qq.com/s/nIk_xOf6dxkhKfqq830Cuw)**! -1. 新手重要提示:本项目仅是一个SDK开发工具包,未提供Web实现,建议使用 `maven` 或 `gradle` 引用本项目即可使用本SDK提供的各种功能,详情可参考 **[【Demo项目】](demo.md)** 或本项目中的部分单元测试代码;另外微信开发新手请务必阅读[【开发文档 Wiki 首页】](https://github.com/Wechat-Group/WxJava/wiki)的常见问题部分,可以少走很多弯路,节省不少时间。 -1. 技术交流群:想获得QQ群/微信群/钉钉企业群等信息的同学,请使用微信扫描上面的微信公众号二维码关注 `WxJava` 后点击相关菜单即可获取加入方式,同时也可以在微信中搜索 `weixin-java-tools` 或 `WxJava` 后选择正确的公众号进行关注,该公众号会及时通知SDK相关更新信息,并不定期分享微信Java开发相关技术知识; -1. 钉钉技术交流群:`32206329`(技术交流2群), `30294972`(技术交流1群,目前已满),`35724728`(通知群,实时通知Github项目变更记录)。 -1. 微信开发新手或者Java开发新手在群内提问或新开Issue提问前,请先阅读[【提问的智慧】](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md),并确保已查阅过 [【开发文档Wiki】](https://github.com/wechat-group/WxJava/wiki) ,避免浪费大家的宝贵时间; -1. 寻求帮助时需贴代码或大长串异常信息的,请利用 http://paste.ubuntu.com +1. 项目合作洽谈请联系微信`binary0000`(在微信里自行搜索并添加好友,请注明来意,如有关于SDK问题需讨论请参考下文入群讨论,不要加此微信)。 +2. **2023-4-23 发布 [【4.5.0正式版】](https://mp.weixin.qq.com/s/4ZYKJnIwP9YNDvbyOhW_3A)**! +3. 贡献源码可以参考视频:[【贡献源码全过程(上集)】](https://mp.weixin.qq.com/s/3xUZSATWwHR_gZZm207h7Q)、[【贡献源码全过程(下集)】](https://mp.weixin.qq.com/s/nyzJwVVoYSJ4hSbwyvTx9A) ,友情提供:[程序员小山与Bug](https://space.bilibili.com/473631007) +4. 新手重要提示:本项目仅是一个SDK开发工具包,未提供Web实现,建议使用 `maven` 或 `gradle` 引用本项目即可使用本SDK提供的各种功能,详情可参考 **[【Demo项目】](demo.md)** 或本项目中的部分单元测试代码; +5. 微信开发新手请务必阅读【开发文档】([Gitee Wiki](https://gitee.com/binary/weixin-java-tools/wikis/Home) 或者 [Github Wiki](https://github.com/Wechat-Group/WxJava/wiki))的常见问题部分,可以少走很多弯路,节省不少时间。 +6. 技术交流群:想获得QQ群/微信群/钉钉企业群等信息的同学,请使用微信扫描上面的微信公众号二维码关注 `WxJava` 后点击相关菜单即可获取加入方式,同时也可以在微信中搜索 `weixin-java-tools` 或 `WxJava` 后选择正确的公众号进行关注,该公众号会及时通知SDK相关更新信息,并不定期分享微信Java开发相关技术知识; +7. 钉钉技术交流群:`32206329`(技术交流2群), `30294972`(技术交流1群,目前已满),`35724728`(通知群,实时通知Github项目变更记录)。 +8. 微信开发新手或者Java开发新手在群内提问或新开Issue提问前,请先阅读[【提问的智慧】](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md),并确保已查阅过 [【开发文档Wiki】](https://github.com/wechat-group/WxJava/wiki) ,避免浪费大家的宝贵时间; +9. 寻求帮助时需贴代码或大长串异常信息的,请利用 http://paste.ubuntu.com -------------------------------- ### 其他说明 1. **阅读源码的同学请注意,本SDK为简化代码编译时加入了`lombok`支持,如果不了解`lombok`的话,请先学习下相关知识,比如可以阅读[此文章](https://mp.weixin.qq.com/s/cUc-bUcprycADfNepnSwZQ);** -1. 如有新功能需求,发现BUG,或者由于微信官方接口调整导致的代码问题,可以直接在[【Issues】](https://github.com/Wechat-Group/WxJava/issues)页提出issue,便于讨论追踪问题; -1. 如果需要贡献代码,请务必在提交PR之前先仔细阅读[【代码贡献指南】](CONTRIBUTING.md),谢谢理解配合; -1. 目前本`SDK`最新版本要求的`JDK`最低版本是`8`,使用`7`的同学可以使用`WxJava` `3.8.0`及以前版本,而还在使用`JDK`6的用户请参考[【此项目】]( https://github.com/binarywang/weixin-java-tools-for-jdk6) ,而其他更早的JDK版本则需要自己改造实现。 -1. [本项目在开源中国的页面](https://www.oschina.net/p/weixin-java-tools-new),欢迎大家积极留言评分 🙂 -1. SDK开发文档请查阅 [【开发文档Wiki】](https://github.com/wechat-group/WxJava/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。 -1. **如果本开发工具包对您有所帮助,欢迎对我们的努力进行肯定,可以直接前往[【托管于码云的项目首页】](http://gitee.com/binary/weixin-java-tools),在页尾部分找到“捐助”按钮进行打赏,多多益善 😄。非常感谢各位打赏和捐助的同学!** -1. 各个模块的Javadoc可以在线查看:[weixin-java-miniapp](http://binary.ac.cn/weixin-java-miniapp-javadoc/)、[weixin-java-pay](http://binary.ac.cn/weixin-java-pay-javadoc/)、[weixin-java-mp](http://binary.ac.cn/weixin-java-mp-javadoc/)、[weixin-java-common](http://binary.ac.cn/weixin-java-common-javadoc/)、[weixin-java-cp](http://binary.ac.cn/weixin-java-cp-javadoc/)、[weixin-java-open](http://binary.ac.cn/weixin-java-open-javadoc/) -1. 本SDK项目在以下代码托管网站同步更新: +2. 如有新功能需求,发现BUG,或者由于微信官方接口调整导致的代码问题,可以直接在[【Issues】](https://github.com/Wechat-Group/WxJava/issues)页提出issue,便于讨论追踪问题; +3. 如果需要贡献代码,请务必在提交PR之前先仔细阅读[【代码贡献指南】](CONTRIBUTING.md),谢谢理解配合; +4. 目前本`SDK`最新版本要求的`JDK`最低版本是`8`,使用`7`的同学可以使用`WxJava` `3.8.0`及以前版本,而还在使用`JDK`6的用户请参考[【此项目】]( https://github.com/binarywang/weixin-java-tools-for-jdk6) ,而其他更早的JDK版本则需要自己改造实现。 +5. [本项目在开源中国的页面](https://www.oschina.net/p/weixin-java-tools-new),欢迎大家积极留言评分 🙂 +6. SDK开发文档请查阅 [【开发文档Wiki】](https://github.com/wechat-group/WxJava/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。 +7. **如果本开发工具包对您有所帮助,欢迎对我们的努力进行肯定,可以直接前往[【托管于码云的项目首页】](http://gitee.com/binary/weixin-java-tools),在页尾部分找到“捐助”按钮进行打赏,多多益善 😄。非常感谢各位打赏和捐助的同学!** +8. 各个模块的Javadoc可以在线查看:[weixin-java-miniapp](http://binary.ac.cn/weixin-java-miniapp-javadoc/)、[weixin-java-pay](http://binary.ac.cn/weixin-java-pay-javadoc/)、[weixin-java-mp](http://binary.ac.cn/weixin-java-mp-javadoc/)、[weixin-java-common](http://binary.ac.cn/weixin-java-common-javadoc/)、[weixin-java-cp](http://binary.ac.cn/weixin-java-cp-javadoc/)、[weixin-java-open](http://binary.ac.cn/weixin-java-open-javadoc/) +9. 本SDK项目在以下代码托管网站同步更新: * 码云:https://gitee.com/binary/weixin-java-tools * GitHub:https://github.com/wechat-group/WxJava @@ -67,7 +80,7 @@ com.github.binarywang (不同模块参考下文) - 4.1.0 + 4.5.0 ``` @@ -85,8 +98,8 @@ 点此展开查看 1. 本项目定为大约每两个月发布一次正式版(同时 `develop` 分支代码合并进入 `master` 分支),版本号格式为 `X.X.0`(如`2.1.0`,`2.2.0`等),遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; -1. BUG修复和新特性一般会先发布成小版本作为临时测试版本(如`3.6.8.B`,即尾号不为0,并添加B,以区别于正式版),代码仅存在于 `develop` 分支中; -1. 目前最新版本号为 [![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/wx-java.svg)](http://mvnrepository.com/artifact/com.github.binarywang/wx-java) ,也可以通过访问链接 [【微信支付】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-pay%22) 、[【微信小程序】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-miniapp%22) 、[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业微信】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)、[【开放平台】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-open%22) +2. BUG修复和新特性一般会先发布成小版本作为临时测试版本(如`3.6.8.B`,即尾号不为0,并添加B,以区别于正式版),代码仅存在于 `develop` 分支中; +3. 目前最新版本号为 [![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/wx-java.svg)](http://mvnrepository.com/artifact/com.github.binarywang/wx-java) ,也可以通过访问链接 [【微信支付】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-pay%22) 、[【微信小程序】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-miniapp%22) 、[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业微信】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)、[【开放平台】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-open%22) 分别查看所有最新的版本。 @@ -165,16 +178,17 @@ 点击此处展开查看贡献次数最多的几位小伙伴 1. [chanjarster (Daniel Qian)](https://github.com/chanjarster) -1. [binarywang (Binary Wang)](https://github.com/binarywang) -1. [007gzs](https://github.com/007gzs) -1. [Silloy](https://github.com/silloy) -1. [mgcnrx11](https://github.com/mgcnrx11) -1. [yuanqixun](https://github.com/yuanqixun) -1. [kakotor](https://github.com/kakotor) -1. [aimilin6688 (Jonk)](https://github.com/aimilin6688) -1. [lkqm (Mario Luo)](https://github.com/lkqm) -1. [kareanyi (MillerLin)](https://github.com/kareanyi) - +2. [binarywang (Binary Wang)](https://github.com/binarywang) +3. [007gzs](https://github.com/007gzs) +4. [Silloy](https://github.com/silloy) +5. [mgcnrx11](https://github.com/mgcnrx11) +6. [0katekate0 (Wang_Wong)](https://github.com/0katekate0) +7. [yuanqixun](https://github.com/yuanqixun) +8. [kakotor](https://github.com/kakotor) +9. [aimilin6688 (Jonk)](https://github.com/aimilin6688) +10. [lkqm (Mario Luo)](https://github.com/lkqm) +11. [kareanyi (MillerLin)](https://github.com/kareanyi) +12. [Bincent (Hongbin.hsu)](https://gitee.com/bincent) ### GitHub Stargazers over time diff --git a/demo.md b/demo.md index de5e462099..d6b55b89e2 100644 --- a/demo.md +++ b/demo.md @@ -14,12 +14,12 @@ - [使用该 `starter` 实现的小程序 `Demo`](https://github.com/binarywang/wx-java-miniapp-demo) ### Demo 列表 -1. 微信支付 Demo:[GitHub](http://github.com/binarywang/weixin-java-pay-demo)、[码云](http://gitee.com/binary/weixin-java-pay-demo) [![Build Status](https://travis-ci.org/binarywang/weixin-java-pay-demo.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-pay-demo) -1. 企业号/企业微信 Demo:[GitHub](http://github.com/binarywang/weixin-java-cp-demo)、[码云](http://gitee.com/binary/weixin-java-cp-demo) [![Build Status](https://travis-ci.org/binarywang/weixin-java-cp-demo.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-cp-demo) -1. 微信小程序 Demo:[GitHub](http://github.com/binarywang/weixin-java-miniapp-demo)、[码云](http://gitee.com/binary/weixin-java-miniapp-demo) [![Build Status](https://travis-ci.org/binarywang/weixin-java-miniapp-demo.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-miniapp-demo) -1. 开放平台 Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-open-demo)、[码云](http://gitee.com/binary/weixin-java-open-demo) [![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-open-demo.svg?branch=master)](https://travis-ci.org/Wechat-Group/weixin-java-open-demo) -1. 公众号 Demo: - - 使用 `Spring MVC` 实现的公众号 Demo:[GitHub](http://github.com/binarywang/weixin-java-mp-demo-springmvc)、[码云](https://gitee.com/binary/weixin-java-mp-demo) [![Build Status](https://travis-ci.org/binarywang/weixin-java-mp-demo-springmvc.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-mp-demo-springmvc) - - 使用 `Spring Boot` 实现的公众号 Demo(支持多公众号):[GitHub](http://github.com/binarywang/weixin-java-mp-demo)、[码云](http://gitee.com/binary/weixin-java-mp-demo-springboot) [![Build Status](https://travis-ci.org/binarywang/weixin-java-mp-demo.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-mp-demo) - - 含公众号和部分微信支付代码的 Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-demo-springmvc)、[码云](http://gitee.com/binary/weixin-java-tools-springmvc) [![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-demo-springmvc.svg?branch=master)](https://travis-ci.org/Wechat-Group/weixin-java-demo-springmvc) +1. 微信支付 Demo:[GitHub](http://github.com/binarywang/weixin-java-pay-demo)、[码云](http://gitee.com/binary/weixin-java-pay-demo) [![Build Status](https://app.travis-ci.com/binarywang/weixin-java-pay-demo.svg?branch=master)](https://app.travis-ci.com/binarywang/weixin-java-pay-demo) +1. 企业号/企业微信 Demo:[GitHub](http://github.com/binarywang/weixin-java-cp-demo)、[码云](http://gitee.com/binary/weixin-java-cp-demo) [![Build Status](https://app.travis-ci.com/binarywang/weixin-java-cp-demo.svg?branch=master)](https://app.travis-ci.com/binarywang/weixin-java-cp-demo) +1. 微信小程序 Demo:[GitHub](http://github.com/binarywang/weixin-java-miniapp-demo)、[码云](http://gitee.com/binary/weixin-java-miniapp-demo) [![Build Status](https://app.travis-ci.com/binarywang/weixin-java-miniapp-demo.svg?branch=master)](https://app.travis-ci.com/binarywang/weixin-java-miniapp-demo) +1. 开放平台 Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-open-demo)、[码云](http://gitee.com/binary/weixin-java-open-demo) [![Build Status](https://app.travis-ci.com/Wechat-Group/weixin-java-open-demo.svg?branch=master)](https://app.travis-ci.com/Wechat-Group/weixin-java-open-demo) +1. 微信公众号 Demo: + - 使用 `Spring MVC` 实现的公众号 Demo:[GitHub](http://github.com/binarywang/weixin-java-mp-demo-springmvc)、[码云](https://gitee.com/binary/weixin-java-mp-demo) [![Build Status](https://app.travis-ci.com/binarywang/weixin-java-mp-demo-springmvc.svg?branch=master)](https://app.travis-ci.com/binarywang/weixin-java-mp-demo-springmvc) + - 使用 `Spring Boot` 实现的公众号 Demo(支持多公众号):[GitHub](http://github.com/binarywang/weixin-java-mp-demo)、[码云](http://gitee.com/binary/weixin-java-mp-demo-springboot) [![Build Status](https://app.travis-ci.com/binarywang/weixin-java-mp-demo.svg?branch=master)](https://app.travis-ci.com/binarywang/weixin-java-mp-demo) + - 含公众号和部分微信支付代码的 Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-demo-springmvc)、[码云](http://gitee.com/binary/weixin-java-tools-springmvc) [![Build Status](https://app.travis-ci.com/Wechat-Group/weixin-java-demo-springmvc.svg?branch=master)](https://app.travis-ci.com/Wechat-Group/weixin-java-demo-springmvc) diff --git a/images/banners/ccflow.png b/images/banners/ccflow.png new file mode 100644 index 0000000000..1209739f6a Binary files /dev/null and b/images/banners/ccflow.png differ diff --git a/images/banners/diboot.png b/images/banners/diboot.png new file mode 100644 index 0000000000..c22d0b8ed8 Binary files /dev/null and b/images/banners/diboot.png differ diff --git a/images/banners/vultr.jpg b/images/banners/vultr.jpg deleted file mode 100644 index 80cf3c2b5e..0000000000 Binary files a/images/banners/vultr.jpg and /dev/null differ diff --git a/others/weixin-java-config/README.md b/others/weixin-java-config/README.md new file mode 100644 index 0000000000..aa70de9579 --- /dev/null +++ b/others/weixin-java-config/README.md @@ -0,0 +1,424 @@ +# weixin-java-config +1.目录说明:多配置文件目录 + +2.项目多配置集锦 +```yml +wechat: + pay: #微信服务商支付 + configs: + - appId: wxe97b2x9c2b3d #spAppId + mchId: 16486610 #服务商商户 + subAppId: wx118cexxe3c07679 #子appId + subMchId: 16496705 #子商户 + apiV3Key: Dc1DBwSc094jAKDGR5aqqb7PTHr #apiV3密钥 + privateKeyPath: classpath:cert/apiclient_key.pem #服务商证书文件,apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径(可以配置绝对路径) + privateCertPath: classpath:cert/apiclient_cert.pem #apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径 + miniapp: #小程序 + configs: + - appid: wx118ce3xxc76ccg + secret: 8a132a276ee2f8fb58b1ed8f2 + token: #微信小程序消息服务器配置的token + aesKey: #微信小程序消息服务器配置的EncodingAESKey + msgDataFormat: JSON + cp: #企业微信 + corpId: wwa3be8efd2addfgj + appConfigs: + - agentId: 10001 #客户联系 + secret: T5fTj1n-sBAT4rKNW5c9IYNfPdXZ8-oGol5tX + token: 2bSNqTcLtFYBUa1u2 + aesKey: AXazu2Xyw44SNY1x8go2phn9p9B2O9oiEfqPN + - agentId: 10003 #会话内容存档 + secret: xIpum7Yt4NMXcyxdzcQ2l_46BG4QIQDR57MhA + token: + aesKey: + - agentId: 3010011 #打卡 + secret: 3i2Mhfusifaw_-04bMYI8OoKGxPe9mDALbUxV + token: + aesKey: + - agentId: 19998 #通讯录同步 + secret: rNyDae0Pg-3d-wqTd_ozMSJfF0DEjTCz3b_pr + token: xUke8yZciAZqImGZ + aesKey: EUTVyArqJcfnpFiudxjRpuOexNqBoPbwrNG3R + - agentId: 20000 #微盘 + secret: D-TVMvUji7PZZdjhZOSgiy2MTuBd0OCdvI_zi + token: + aesKey: +``` + +3.主要代码 +###### 1)微信服务商支付 +```java +@Data +@ConfigurationProperties(prefix = "wechat.pay") +public class WxPayProperties { + + private List configs; + + @Getter + @Setter + public static class Config { + + private String appId; + private String mchId; + private String subAppId; + private String subMchId; + private String apiV3Key; + private String privateKeyPath; + private String privateCertPath; + + } + +} +``` +```java +@Configuration +@EnableConfigurationProperties(WxPayProperties.class) +@AllArgsConstructor +public class WxPayConfiguration { + + private WxPayProperties properties; + + @Bean + public WxPayService wxPayService() { + + // 多配置 + WxPayService wxPayService = new WxPayServiceImpl(); + Map payConfigs = this.properties.getConfigs().stream().map(config -> { + WxPayConfig payConfig = new WxPayConfig(); + payConfig.setAppId(StringUtils.trimToNull(config.getAppId())); + payConfig.setMchId(StringUtils.trimToNull(config.getMchId())); + payConfig.setSubAppId(StringUtils.trimToNull(config.getSubAppId())); + payConfig.setSubMchId(StringUtils.trimToNull(config.getSubMchId())); + payConfig.setApiV3Key(StringUtils.trimToNull(config.getApiV3Key())); + payConfig.setPrivateKeyPath(StringUtils.trimToNull(config.getPrivateKeyPath())); + payConfig.setPrivateCertPath(StringUtils.trimToNull(config.getPrivateCertPath())); + + // 可以指定是否使用沙箱环境 + payConfig.setUseSandboxEnv(false); + return payConfig; + }).collect(Collectors.toMap(config -> config.getSubMchId(), a -> a)); + + wxPayService.setMultiConfig(payConfigs); + return wxPayService; + } + +} +``` +###### 2)微信小程序 +```java +@Setter +@Getter +@ConfigurationProperties(prefix = "wechat.miniapp") +public class WxMaProperties { + + private List configs; + + @Data + public static class Config { + + /** + * 设置微信小程序的appid + */ + private String appid; + + /** + * 设置微信小程序的Secret + */ + private String secret; + + /** + * 设置微信小程序消息服务器配置的token + */ + private String token; + + /** + * 设置微信小程序消息服务器配置的EncodingAESKey + */ + private String aesKey; + + /** + * 消息格式,XML或者JSON + */ + private String msgDataFormat; + + } + +} +``` +```java +@Configuration +@EnableConfigurationProperties(WxMaProperties.class) +public class WxMaConfiguration { + + private WxMaProperties properties; + private static Map maServices; + private static final Map routers = Maps.newHashMap(); + + @Autowired + public WxMaConfiguration(WxMaProperties properties) { + this.properties = properties; + } + + public static WxMaService getMaService(String appId) { + WxMaService wxService = maServices.get(appId); + Optional.ofNullable(wxService).orElseThrow(() -> new RuntimeException("没有配置appId")); + return wxService; + } + + public static WxMaMessageRouter getRouter(String appId) { + return routers.get(appId); + } + + @PostConstruct + public void init() { + List configs = this.properties.getConfigs(); + if (configs == null) { + return; + } + + maServices = configs.stream().map(a -> { + // 多配置 + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setAppid(a.getAppid()); + config.setSecret(a.getSecret()); + config.setToken(a.getToken()); + config.setAesKey(a.getAesKey()); + config.setMsgDataFormat(a.getMsgDataFormat()); + + WxMaService service = new WxMaServiceImpl(); + service.setWxMaConfig(config); + + routers.put(a.getAppid(), this.newRouter(service)); + return service; + }).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a)); + } + + private WxMaMessageRouter newRouter(WxMaService service) { + final WxMaMessageRouter router = new WxMaMessageRouter(service); + router + .rule().handler(logHandler).next() + .rule().async(false).content("订阅消息").handler(subscribeMsgHandler).end() + .rule().async(false).content("文本").handler(textHandler).end() + .rule().async(false).content("图片").handler(picHandler).end() + .rule().async(false).content("二维码").handler(qrcodeHandler).end(); + return router; + } + + private final WxMaMessageHandler subscribeMsgHandler = (wxMessage, context, service, sessionManager) -> { + service.getMsgService().sendSubscribeMsg(WxMaSubscribeMessage.builder() + .templateId("此处更换为自己的模板id") + .data(Lists.newArrayList( + new WxMaSubscribeMessage.MsgData("keyword1", "339208499"))) + .toUser(wxMessage.getFromUser()) + .build()); + return null; + }; + + private final WxMaMessageHandler logHandler = (wxMessage, context, service, sessionManager) -> { + log.info("收到logHandler消息:" + wxMessage.toString()); + service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("收到信息为:" + wxMessage.toJson()) + .toUser(wxMessage.getFromUser()).build()); + return null; + }; + + private final WxMaMessageHandler textHandler = (wxMessage, context, service, sessionManager) -> { + log.info("收到textHandler消息:" + wxMessage.toString()); + service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("回复文本消息") + .toUser(wxMessage.getFromUser()).build()); + return null; + }; + + private final WxMaMessageHandler picHandler = (wxMessage, context, service, sessionManager) -> { + log.info("收到picHandler消息:" + wxMessage.toString()); + try { + WxMediaUploadResult uploadResult = service.getMediaService() + .uploadMedia("image", "png", + ClassLoader.getSystemResourceAsStream("tmp.png")); + service.getMsgService().sendKefuMsg( + WxMaKefuMessage + .newImageBuilder() + .mediaId(uploadResult.getMediaId()) + .toUser(wxMessage.getFromUser()) + .build()); + } catch (WxErrorException e) { + e.printStackTrace(); + } + + return null; + }; + + private final WxMaMessageHandler qrcodeHandler = (wxMessage, context, service, sessionManager) -> { + log.info("收到qrcodeHandler消息:" + wxMessage.toString()); + try { + final File file = service.getQrcodeService().createQrcode("123", 430); + WxMediaUploadResult uploadResult = service.getMediaService().uploadMedia("image", file); + service.getMsgService().sendKefuMsg( + WxMaKefuMessage + .newImageBuilder() + .mediaId(uploadResult.getMediaId()) + .toUser(wxMessage.getFromUser()) + .build()); + } catch (WxErrorException e) { + e.printStackTrace(); + } + + return null; + }; + +} +``` +###### 3)企业微信 +```java +@Getter +@Setter +@ConfigurationProperties(prefix = "wechat.cp") +public class WxCpProperties { + + /** + * 设置企业微信的corpId + */ + private String corpId; + + private List appConfigs; + + @Getter + @Setter + public static class AppConfig { + /** + * 设置企业微信应用的AgentId + */ + private Integer agentId; + + /** + * 设置企业微信应用的Secret + */ + private String secret; + + /** + * 设置企业微信应用的token + */ + private String token; + + /** + * 设置企业微信应用的EncodingAESKey + */ + private String aesKey; + + } + +} +``` +```java +@Configuration +@EnableConfigurationProperties(WxCpProperties.class) +public class WxCpConfiguration { + + private LogHandler logHandler; + private NullHandler nullHandler; + private LocationHandler locationHandler; + private MenuHandler menuHandler; + private MsgHandler msgHandler; + private UnsubscribeHandler unsubscribeHandler; + private SubscribeHandler subscribeHandler; + + private WxCpProperties properties; + + private static Map routers = Maps.newHashMap(); + private static Map cpServices = Maps.newHashMap(); + + @Autowired + public WxCpConfiguration(LogHandler logHandler, NullHandler nullHandler, LocationHandler locationHandler, + MenuHandler menuHandler, MsgHandler msgHandler, UnsubscribeHandler unsubscribeHandler, + SubscribeHandler subscribeHandler, WxCpProperties properties) { + this.logHandler = logHandler; + this.nullHandler = nullHandler; + this.locationHandler = locationHandler; + this.menuHandler = menuHandler; + this.msgHandler = msgHandler; + this.unsubscribeHandler = unsubscribeHandler; + this.subscribeHandler = subscribeHandler; + this.properties = properties; + } + + + public static Map getRouters() { + return routers; + } + + + public static WxCpService getCpService(Integer agentId) { + WxCpService cpService = cpServices.get(agentId); + Optional.ofNullable(cpService).orElseThrow(() -> new RuntimeException("cpService不能为空")); + return cpService; + } + + @PostConstruct + public void initServices() { + cpServices = this.properties.getAppConfigs().stream().map(a -> { + val configStorage = new WxCpDefaultConfigImpl(); + configStorage.setCorpId(this.properties.getCorpId()); + configStorage.setAgentId(a.getAgentId()); + configStorage.setCorpSecret(a.getSecret()); + configStorage.setToken(a.getToken()); + configStorage.setAesKey(a.getAesKey()); + + val service = new WxCpServiceImpl(); + service.setWxCpConfigStorage(configStorage); + + routers.put(a.getAgentId(), this.newRouter(service)); + return service; + }).collect(Collectors.toMap(service -> service.getWxCpConfigStorage().getAgentId(), a -> a)); + } + + private WxCpMessageRouter newRouter(WxCpService wxCpService) { + final val newRouter = new WxCpMessageRouter(wxCpService); + + // 记录所有事件的日志 (异步执行) + newRouter.rule().handler(this.logHandler).next(); + + // 自定义菜单事件 + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxConsts.MenuButtonType.CLICK).handler(this.menuHandler).end(); + + // 点击菜单链接事件(这里使用了一个空的处理器,可以根据自己需要进行扩展) + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxConsts.MenuButtonType.VIEW).handler(this.nullHandler).end(); + + // 关注事件 + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxConsts.EventType.SUBSCRIBE).handler(this.subscribeHandler) + .end(); + + // 取消关注事件 + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxConsts.EventType.UNSUBSCRIBE) + .handler(this.unsubscribeHandler).end(); + + // 上报地理位置事件 + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxConsts.EventType.LOCATION).handler(this.locationHandler) + .end(); + + // 接收地理位置消息 + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION) + .handler(this.locationHandler).end(); + + // 扫码事件(这里使用了一个空的处理器,可以根据自己需要进行扩展) + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxConsts.EventType.SCAN).handler(this.nullHandler).end(); + + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxCpConsts.EventType.CHANGE_CONTACT).handler(new ContactChangeHandler()).end(); + + newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) + .event(WxCpConsts.EventType.ENTER_AGENT).handler(new EnterAgentHandler()).end(); + + // 默认 + newRouter.rule().async(false).handler(this.msgHandler).end(); + + return newRouter; + } + +} +``` +4.其他请移步wiki:[GitHub wiki](https://github.com/Wechat-Group/WxJava/wiki) diff --git a/others/weixin-java-osgi/pom.xml b/others/weixin-java-osgi/pom.xml index 7207e9b99d..0018b73e5e 100644 --- a/others/weixin-java-osgi/pom.xml +++ b/others/weixin-java-osgi/pom.xml @@ -28,7 +28,7 @@ com.thoughtworks.xstream xstream - 1.4.18 + 1.4.19 provided diff --git a/pom.xml b/pom.xml index 842aae46f1..dd4d91bb9b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B pom WxJava - Weixin/Wechat Java SDK 微信开发Java SDK @@ -12,7 +12,7 @@ The Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt @@ -92,6 +92,21 @@ huangxm129@163.com https://github.com/huangxm129 + + xiaohe + xiaohe@53jy.net + https://github.com/xiaohe-53 + + + Wang_Wong + wangkaikate@163.com + https://github.com/0katekate0 + + + Bincent + hongbin.hsu@qq.com + https://gitee.com/bincent + @@ -109,6 +124,7 @@ weixin-java-miniapp weixin-java-open weixin-java-qidian + weixin-java-channel spring-boot-starters @@ -119,7 +135,8 @@ UTF-8 4.5.13 - 9.4.41.v20210516 + 9.4.51.v20230217 + @@ -127,12 +144,12 @@ com.github.binarywang qrcode-utils - 1.1 + 1.3 org.jodd jodd-http - 5.2.0 + 6.3.0 provided @@ -155,7 +172,7 @@ commons-codec commons-codec - 1.10 + 1.13 commons-io @@ -175,17 +192,22 @@ com.thoughtworks.xstream xstream - 1.4.18 + 1.4.20 com.google.guava guava - 30.0-jre + 32.1.2-jre com.google.code.gson gson - 2.8.0 + 2.10.1 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.15.2 @@ -198,7 +220,7 @@ ch.qos.logback logback-classic - 1.2.3 + 1.3.12 test @@ -210,8 +232,19 @@ org.testng testng - 7.1.0 + 7.5.1 + test + + + guice + com.google.inject + + + org.yaml + snakeyaml + + org.mockito @@ -247,7 +280,7 @@ redis.clients jedis - 3.3.0 + 4.3.2 provided @@ -259,9 +292,23 @@ org.redisson redisson - 3.12.0 + 3.23.3 true provided + + + com.fasterxml.jackson.core + jackson-core + + + org.jodd + jodd-core + + + org.reactivestreams + reactive-streams + + org.springframework.data @@ -273,13 +320,13 @@ org.projectlombok lombok - 1.18.8 + 1.18.24 provided org.bouncycastle bcpkix-jdk15on - 1.68 + 1.70 @@ -313,7 +360,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.1.0 attach-sources @@ -344,7 +391,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.1.0 sign-artifacts diff --git a/spring-boot-starters/pom.xml b/spring-boot-starters/pom.xml index 85fe5094b0..2a0abc777b 100644 --- a/spring-boot-starters/pom.xml +++ b/spring-boot-starters/pom.xml @@ -1,10 +1,12 @@ - + 4.0.0 com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B pom wx-java-spring-boot-starters @@ -12,7 +14,7 @@ WxJava 各个模块的 Spring Boot Starter - 2.5.3 + 2.5.15 @@ -21,6 +23,9 @@ wx-java-pay-spring-boot-starter wx-java-open-spring-boot-starter wx-java-qidian-spring-boot-starter + wx-java-cp-multi-spring-boot-starter + wx-java-cp-spring-boot-starter + wx-java-channel-spring-boot-starter diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-channel-spring-boot-starter/pom.xml new file mode 100644 index 0000000000..4477d79e09 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/pom.xml @@ -0,0 +1,59 @@ + + + wx-java-spring-boot-starters + com.github.binarywang + 4.5.7.B + + 4.0.0 + + wx-java-channel-spring-boot-starter + WxJava - Spring Boot Starter for Channel + 微信视频号开发的 Spring Boot Starter + + + + com.github.binarywang + weixin-java-channel + ${project.version} + + + redis.clients + jedis + provided + + + org.redisson + redisson + provided + + + org.springframework.data + spring-data-redis + provided + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelAutoConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelAutoConfiguration.java new file mode 100644 index 0000000000..ad9d90b28d --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelAutoConfiguration.java @@ -0,0 +1,20 @@ +package com.binarywang.spring.starter.wxjava.channel.config; + +import com.binarywang.spring.starter.wxjava.channel.properties.WxChannelProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * 自动配置 + * + * @author Zeyes + */ +@Configuration +@EnableConfigurationProperties(WxChannelProperties.class) +@Import({ + WxChannelStorageAutoConfiguration.class, + WxChannelServiceAutoConfiguration.class +}) +public class WxChannelAutoConfiguration { +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelServiceAutoConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelServiceAutoConfiguration.java new file mode 100644 index 0000000000..5276a803e7 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelServiceAutoConfiguration.java @@ -0,0 +1,37 @@ +package com.binarywang.spring.starter.wxjava.channel.config; + + +import com.binarywang.spring.starter.wxjava.channel.properties.WxChannelProperties; +import lombok.AllArgsConstructor; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.impl.WxChannelServiceImpl; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 微信小程序平台相关服务自动注册 + * + * @author Zeyes + */ +@Configuration +@AllArgsConstructor +public class WxChannelServiceAutoConfiguration { + private final WxChannelProperties properties; + + /** + * Channel Service + * + * @return Channel Service + */ + @Bean + @ConditionalOnMissingBean(WxChannelService.class) + @ConditionalOnBean(WxChannelConfig.class) + public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig) { + WxChannelService wxChannelService = new WxChannelServiceImpl(); + wxChannelService.setConfig(wxChannelConfig); + return wxChannelService; + } +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelStorageAutoConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelStorageAutoConfiguration.java new file mode 100644 index 0000000000..66f2276a35 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/WxChannelStorageAutoConfiguration.java @@ -0,0 +1,23 @@ +package com.binarywang.spring.starter.wxjava.channel.config; + +import com.binarywang.spring.starter.wxjava.channel.config.storage.WxChannelInJedisConfigStorageConfiguration; +import com.binarywang.spring.starter.wxjava.channel.config.storage.WxChannelInMemoryConfigStorageConfiguration; +import com.binarywang.spring.starter.wxjava.channel.config.storage.WxChannelInRedisTemplateConfigStorageConfiguration; +import com.binarywang.spring.starter.wxjava.channel.config.storage.WxChannelInRedissonConfigStorageConfiguration; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * 微信小程序存储策略自动配置 + * + * @author Zeyes + */ +@Configuration +@Import({ + WxChannelInMemoryConfigStorageConfiguration.class, + WxChannelInJedisConfigStorageConfiguration.class, + WxChannelInRedisTemplateConfigStorageConfiguration.class, + WxChannelInRedissonConfigStorageConfiguration.class +}) +public class WxChannelStorageAutoConfiguration { +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/AbstractWxChannelConfigStorageConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/AbstractWxChannelConfigStorageConfiguration.java new file mode 100644 index 0000000000..a87028a1cd --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/AbstractWxChannelConfigStorageConfiguration.java @@ -0,0 +1,39 @@ +package com.binarywang.spring.starter.wxjava.channel.config.storage; + +import com.binarywang.spring.starter.wxjava.channel.properties.WxChannelProperties; +import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; +import org.apache.commons.lang3.StringUtils; + +/** + * @author Zeyes + */ +public abstract class AbstractWxChannelConfigStorageConfiguration { + + protected WxChannelDefaultConfigImpl config(WxChannelDefaultConfigImpl config, WxChannelProperties properties) { + config.setAppid(StringUtils.trimToNull(properties.getAppid())); + config.setSecret(StringUtils.trimToNull(properties.getSecret())); + config.setToken(StringUtils.trimToNull(properties.getToken())); + config.setAesKey(StringUtils.trimToNull(properties.getAesKey())); + config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat())); + + WxChannelProperties.ConfigStorage configStorageProperties = properties.getConfigStorage(); + config.setHttpProxyHost(configStorageProperties.getHttpProxyHost()); + config.setHttpProxyUsername(configStorageProperties.getHttpProxyUsername()); + config.setHttpProxyPassword(configStorageProperties.getHttpProxyPassword()); + if (configStorageProperties.getHttpProxyPort() != null) { + config.setHttpProxyPort(configStorageProperties.getHttpProxyPort()); + } + + int maxRetryTimes = configStorageProperties.getMaxRetryTimes(); + if (configStorageProperties.getMaxRetryTimes() < 0) { + maxRetryTimes = 0; + } + int retrySleepMillis = configStorageProperties.getRetrySleepMillis(); + if (retrySleepMillis < 0) { + retrySleepMillis = 1000; + } + config.setRetrySleepMillis(retrySleepMillis); + config.setMaxRetryTimes(maxRetryTimes); + return config; + } +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInJedisConfigStorageConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInJedisConfigStorageConfiguration.java new file mode 100644 index 0000000000..f88548c3e9 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInJedisConfigStorageConfiguration.java @@ -0,0 +1,73 @@ +package com.binarywang.spring.starter.wxjava.channel.config.storage; + + +import com.binarywang.spring.starter.wxjava.channel.properties.RedisProperties; +import com.binarywang.spring.starter.wxjava.channel.properties.WxChannelProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.channel.config.impl.WxChannelRedisConfigImpl; +import me.chanjar.weixin.common.redis.JedisWxRedisOps; +import me.chanjar.weixin.common.redis.WxRedisOps; +import org.apache.commons.lang3.StringUtils; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; + +/** + * @author Zeyes + */ +@Configuration +@ConditionalOnProperty(prefix = WxChannelProperties.PREFIX + ".config-storage", name = "type", havingValue = "jedis") +@ConditionalOnClass({JedisPool.class, JedisPoolConfig.class}) +@RequiredArgsConstructor +public class WxChannelInJedisConfigStorageConfiguration extends AbstractWxChannelConfigStorageConfiguration { + private final WxChannelProperties properties; + private final ApplicationContext applicationContext; + + @Bean + @ConditionalOnMissingBean(WxChannelConfig.class) + public WxChannelConfig wxChannelConfig() { + WxChannelRedisConfigImpl config = getWxChannelRedisConfig(); + return this.config(config, properties); + } + + private WxChannelRedisConfigImpl getWxChannelRedisConfig() { + RedisProperties redisProperties = properties.getConfigStorage().getRedis(); + JedisPool jedisPool; + if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { + jedisPool = getJedisPool(); + } else { + jedisPool = applicationContext.getBean(JedisPool.class); + } + WxRedisOps redisOps = new JedisWxRedisOps(jedisPool); + return new WxChannelRedisConfigImpl(redisOps, properties.getConfigStorage().getKeyPrefix()); + } + + private JedisPool getJedisPool() { + WxChannelProperties.ConfigStorage storage = properties.getConfigStorage(); + RedisProperties redis = storage.getRedis(); + + JedisPoolConfig config = new JedisPoolConfig(); + if (redis.getMaxActive() != null) { + config.setMaxTotal(redis.getMaxActive()); + } + if (redis.getMaxIdle() != null) { + config.setMaxIdle(redis.getMaxIdle()); + } + if (redis.getMaxWaitMillis() != null) { + config.setMaxWaitMillis(redis.getMaxWaitMillis()); + } + if (redis.getMinIdle() != null) { + config.setMinIdle(redis.getMinIdle()); + } + config.setTestOnBorrow(true); + config.setTestWhileIdle(true); + + return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), redis.getDatabase()); + } +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInMemoryConfigStorageConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInMemoryConfigStorageConfiguration.java new file mode 100644 index 0000000000..deb586ae7b --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInMemoryConfigStorageConfiguration.java @@ -0,0 +1,29 @@ +package com.binarywang.spring.starter.wxjava.channel.config.storage; + + +import com.binarywang.spring.starter.wxjava.channel.properties.WxChannelProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author Zeyes + */ +@Configuration +@ConditionalOnProperty(prefix = WxChannelProperties.PREFIX + ".config-storage", name = "type", + matchIfMissing = true, havingValue = "memory") +@RequiredArgsConstructor +public class WxChannelInMemoryConfigStorageConfiguration extends AbstractWxChannelConfigStorageConfiguration { + private final WxChannelProperties properties; + + @Bean + @ConditionalOnMissingBean(WxChannelProperties.class) + public WxChannelConfig wxChannelConfig() { + WxChannelDefaultConfigImpl config = new WxChannelDefaultConfigImpl(); + return this.config(config, properties); + } +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInRedisTemplateConfigStorageConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInRedisTemplateConfigStorageConfiguration.java new file mode 100644 index 0000000000..e190fbd755 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInRedisTemplateConfigStorageConfiguration.java @@ -0,0 +1,40 @@ +package com.binarywang.spring.starter.wxjava.channel.config.storage; + +import com.binarywang.spring.starter.wxjava.channel.properties.WxChannelProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.channel.config.impl.WxChannelRedisConfigImpl; +import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; +import me.chanjar.weixin.common.redis.WxRedisOps; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.core.StringRedisTemplate; + +/** + * @author Zeyes + */ +@Configuration +@ConditionalOnProperty(prefix = WxChannelProperties.PREFIX + ".config-storage", name = "type", havingValue = "redistemplate") +@ConditionalOnClass(StringRedisTemplate.class) +@RequiredArgsConstructor +public class WxChannelInRedisTemplateConfigStorageConfiguration extends AbstractWxChannelConfigStorageConfiguration { + private final WxChannelProperties properties; + private final ApplicationContext applicationContext; + + @Bean + @ConditionalOnMissingBean(WxChannelConfig.class) + public WxChannelConfig wxChannelConfig() { + WxChannelRedisConfigImpl config = getWxChannelInRedisTemplateConfig(); + return this.config(config, properties); + } + + private WxChannelRedisConfigImpl getWxChannelInRedisTemplateConfig() { + StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class); + WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate); + return new WxChannelRedisConfigImpl(redisOps, properties.getConfigStorage().getKeyPrefix()); + } +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInRedissonConfigStorageConfiguration.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInRedissonConfigStorageConfiguration.java new file mode 100644 index 0000000000..16db4395a7 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/WxChannelInRedissonConfigStorageConfiguration.java @@ -0,0 +1,62 @@ +package com.binarywang.spring.starter.wxjava.channel.config.storage; + + +import com.binarywang.spring.starter.wxjava.channel.properties.RedisProperties; +import com.binarywang.spring.starter.wxjava.channel.properties.WxChannelProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.channel.config.impl.WxChannelRedissonConfigImpl; +import org.apache.commons.lang3.StringUtils; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.redisson.config.TransportMode; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author Zeyes + */ +@Configuration +@ConditionalOnProperty(prefix = WxChannelProperties.PREFIX + ".config-storage", name = "type", havingValue = "redisson") +@ConditionalOnClass({Redisson.class, RedissonClient.class}) +@RequiredArgsConstructor +public class WxChannelInRedissonConfigStorageConfiguration extends AbstractWxChannelConfigStorageConfiguration { + private final WxChannelProperties properties; + private final ApplicationContext applicationContext; + + @Bean + @ConditionalOnMissingBean(WxChannelConfig.class) + public WxChannelConfig wxChannelConfig() { + WxChannelRedissonConfigImpl config = getWxChannelRedissonConfig(); + return this.config(config, properties); + } + + private WxChannelRedissonConfigImpl getWxChannelRedissonConfig() { + RedisProperties redisProperties = properties.getConfigStorage().getRedis(); + RedissonClient redissonClient; + if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { + redissonClient = getRedissonClient(); + } else { + redissonClient = applicationContext.getBean(RedissonClient.class); + } + return new WxChannelRedissonConfigImpl(redissonClient, properties.getConfigStorage().getKeyPrefix()); + } + + private RedissonClient getRedissonClient() { + WxChannelProperties.ConfigStorage storage = properties.getConfigStorage(); + RedisProperties redis = storage.getRedis(); + + Config config = new Config(); + config.useSingleServer() + .setAddress("redis://" + redis.getHost() + ":" + redis.getPort()) + .setDatabase(redis.getDatabase()) + .setPassword(redis.getPassword()); + config.setTransportMode(TransportMode.NIO); + return Redisson.create(config); + } +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/enums/HttpClientType.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/enums/HttpClientType.java new file mode 100644 index 0000000000..63a7bf0c24 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/enums/HttpClientType.java @@ -0,0 +1,13 @@ +package com.binarywang.spring.starter.wxjava.channel.enums; + +/** + * httpclient类型 + * + * @author Zeyes + */ +public enum HttpClientType { + /** + * HttpClient + */ + HttpClient +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/enums/StorageType.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/enums/StorageType.java new file mode 100644 index 0000000000..59b27fc022 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/enums/StorageType.java @@ -0,0 +1,25 @@ +package com.binarywang.spring.starter.wxjava.channel.enums; + +/** + * storage类型 + * + * @author Zeyes + */ +public enum StorageType { + /** + * 内存 + */ + Memory, + /** + * redis(JedisClient) + */ + Jedis, + /** + * redis(Redisson) + */ + Redisson, + /** + * redis(RedisTemplate) + */ + RedisTemplate +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/properties/RedisProperties.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/properties/RedisProperties.java new file mode 100644 index 0000000000..19f27d0682 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/properties/RedisProperties.java @@ -0,0 +1,42 @@ +package com.binarywang.spring.starter.wxjava.channel.properties; + +import lombok.Data; + +/** + * redis 配置 + * + * @author Zeyes + */ +@Data +public class RedisProperties { + + /** + * 主机地址,不填则从spring容器内获取JedisPool + */ + private String host; + + /** + * 端口号 + */ + private int port = 6379; + + /** + * 密码 + */ + private String password; + + /** + * 超时 + */ + private int timeout = 2000; + + /** + * 数据库 + */ + private int database = 0; + + private Integer maxActive; + private Integer maxIdle; + private Integer maxWaitMillis; + private Integer minIdle; +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/properties/WxChannelProperties.java b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/properties/WxChannelProperties.java new file mode 100644 index 0000000000..98f1f3b723 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/properties/WxChannelProperties.java @@ -0,0 +1,109 @@ +package com.binarywang.spring.starter.wxjava.channel.properties; + +import com.binarywang.spring.starter.wxjava.channel.enums.HttpClientType; +import com.binarywang.spring.starter.wxjava.channel.enums.StorageType; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * 属性配置类 + * + * @author Zeyes + */ +@Data +@ConfigurationProperties(prefix = WxChannelProperties.PREFIX) +public class WxChannelProperties { + public static final String PREFIX = "wx.channel"; + + /** + * 设置视频号小店的appid + */ + private String appid; + + /** + * 设置视频号小店的Secret + */ + private String secret; + + /** + * 设置视频号小店消息服务器配置的token. + */ + private String token; + + /** + * 设置视频号小店消息服务器配置的EncodingAESKey + */ + private String aesKey; + + /** + * 消息格式,XML或者JSON + */ + private String msgDataFormat = "JSON"; + + /** + * 存储策略 + */ + private final ConfigStorage configStorage = new ConfigStorage(); + + @Data + public static class ConfigStorage { + + /** + * 存储类型 + */ + private StorageType type = StorageType.Memory; + + /** + * 指定key前缀 + */ + private String keyPrefix = "wh"; + + /** + * redis连接配置 + */ + @NestedConfigurationProperty + private final RedisProperties redis = new RedisProperties(); + + /** + * http客户端类型 + */ + private HttpClientType httpClientType = HttpClientType.HttpClient; + + /** + * http代理主机 + */ + private String httpProxyHost; + + /** + * http代理端口 + */ + private Integer httpProxyPort; + + /** + * http代理用户名 + */ + private String httpProxyUsername; + + /** + * http代理密码 + */ + private String httpProxyPassword; + + /** + * http 请求重试间隔 + *
+     *   {@link me.chanjar.weixin.channel.api.BaseWxChannelService#setRetrySleepMillis(int)}
+     * 
+ */ + private int retrySleepMillis = 1000; + /** + * http 请求最大重试次数 + *
+     *   {@link me.chanjar.weixin.channel.api.BaseWxChannelService#setMaxRetryTimes(int)}
+     * 
+ */ + private int maxRetryTimes = 5; + } + +} diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/resources/META-INF/spring.factories b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000..a9401752a0 --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.binarywang.spring.starter.wxjava.channel.config.WxChannelAutoConfiguration diff --git a/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..99ccbadbbc --- /dev/null +++ b/spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.channel.config.WxChannelAutoConfiguration diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/README.md b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/README.md new file mode 100644 index 0000000000..6b1ddaeb3b --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/README.md @@ -0,0 +1,96 @@ +# wx-java-cp-multi-spring-boot-starter + +企业微信多账号配置 + +- 实现多 WxCpService 初始化。 +- 未实现 WxCpTpService 初始化,需要的小伙伴可以参考多 WxCpService 配置的实现。 +- 未实现 WxCpCgService 初始化,需要的小伙伴可以参考多 WxCpService 配置的实现。 + +## 快速开始 + +1. 引入依赖 + ```xml + + com.github.binarywang + wx-java-cp-multi-spring-boot-starter + ${version} + + ``` +2. 添加配置(application.properties) + ```properties + # 应用 1 配置 + wx.cp.corps.tenantId1.corp-id = @corp-id + wx.cp.corps.tenantId1.corp-secret = @corp-secret + ## 选填 + wx.cp.corps.tenantId1.agent-id = @agent-id + wx.cp.corps.tenantId1.token = @token + wx.cp.corps.tenantId1.aes-key = @aes-key + wx.cp.corps.tenantId1.msg-audit-priKey = @msg-audit-priKey + wx.cp.corps.tenantId1.msg-audit-lib-path = @msg-audit-lib-path + + # 应用 2 配置 + wx.cp.corps.tenantId2.corp-id = @corp-id + wx.cp.corps.tenantId2.corp-secret = @corp-secret + ## 选填 + wx.cp.corps.tenantId2.agent-id = @agent-id + wx.cp.corps.tenantId2.token = @token + wx.cp.corps.tenantId2.aes-key = @aes-key + wx.cp.corps.tenantId2.msg-audit-priKey = @msg-audit-priKey + wx.cp.corps.tenantId2.msg-audit-lib-path = @msg-audit-lib-path + + # 公共配置 + ## ConfigStorage 配置(选填) + wx.cp.config-storage.type=memory # 配置类型: memory(默认), jedis, redisson, redistemplate + ## http 客户端配置(选填) + wx.cp.config-storage.http-proxy-host= + wx.cp.config-storage.http-proxy-port= + wx.cp.config-storage.http-proxy-username= + wx.cp.config-storage.http-proxy-password= + ## 最大重试次数,默认:5 次,如果小于 0,则为 0 + wx.cp.config-storage.max-retry-times=5 + ## 重试时间间隔步进,默认:1000 毫秒,如果小于 0,则为 1000 + wx.cp.config-storage.retry-sleep-millis=1000 + ``` +3. 支持自动注入的类型: `WxCpMultiServices` + +4. 使用样例 + +```java +import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; +import com.binarywang.spring.starter.wxjava.cp.service.WxCpServices; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.api.WxCpUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class DemoService { + @Autowired + private WxCpMultiServices wxCpMultiServices; + + public void test() { + // 应用 1 的 WxCpService + WxCpService wxCpService1 = wxCpMultiServices.getWxCpService("tenantId1"); + WxCpUserService userService1 = wxCpService1.getUserService(); + userService1.getUserId("xxx"); + // todo ... + + // 应用 2 的 WxCpService + WxCpService wxCpService2 = wxCpMultiServices.getWxCpService("tenantId2"); + WxCpUserService userService2 = wxCpService2.getUserService(); + userService2.getUserId("xxx"); + // todo ... + + // 应用 3 的 WxCpService + WxCpService wxCpService3 = wxCpMultiServices.getWxCpService("tenantId3"); + // 判断是否为空 + if (wxCpService3 == null) { + // todo wxCpService3 为空,请先配置 tenantId3 企业微信应用参数 + return; + } + WxCpUserService userService3 = wxCpService3.getUserService(); + userService3.getUserId("xxx"); + // todo ... + } +} +``` diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/pom.xml new file mode 100644 index 0000000000..693dd1624c --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/pom.xml @@ -0,0 +1,60 @@ + + + + wx-java-spring-boot-starters + com.github.binarywang + 4.5.7.B + + 4.0.0 + + wx-java-cp-multi-spring-boot-starter + WxJava - Spring Boot Starter for WxCp::支持多账号配置 + 微信企业号开发的 Spring Boot Starter::支持多账号配置 + + + + com.github.binarywang + weixin-java-cp + ${project.version} + + + redis.clients + jedis + provided + + + org.redisson + redisson + provided + + + org.springframework.data + spring-data-redis + provided + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiAutoConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiAutoConfiguration.java new file mode 100644 index 0000000000..8977b214ba --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiAutoConfiguration.java @@ -0,0 +1,20 @@ +package com.binarywang.spring.starter.wxjava.cp.autoconfigure; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * 企业微信自动注册 + * + * @author yl + * created on 2023/10/16 + */ +@Configuration +@EnableConfigurationProperties(WxCpMultiProperties.class) +@Import({ + WxCpMultiServicesAutoConfiguration.class +}) +public class WxCpMultiAutoConfiguration { +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiServicesAutoConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiServicesAutoConfiguration.java new file mode 100644 index 0000000000..743888cad5 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiServicesAutoConfiguration.java @@ -0,0 +1,26 @@ +package com.binarywang.spring.starter.wxjava.cp.autoconfigure; + +import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInJedisConfiguration; +import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInMemoryConfiguration; +import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInRedisTemplateConfiguration; +import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInRedissonConfiguration; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * 企业微信平台相关服务自动注册 + * + * @author yl + * created on 2023/10/16 + */ +@Configuration +@RequiredArgsConstructor +@Import({ + WxCpInJedisConfiguration.class, + WxCpInMemoryConfiguration.class, + WxCpInRedissonConfiguration.class, + WxCpInRedisTemplateConfiguration.class +}) +public class WxCpMultiServicesAutoConfiguration { +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/AbstractWxCpConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/AbstractWxCpConfiguration.java new file mode 100644 index 0000000000..ec45ceaa2f --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/AbstractWxCpConfiguration.java @@ -0,0 +1,145 @@ +package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; + +import com.binarywang.spring.starter.wxjava.cp.properties.CorpProperties; +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; +import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServicesImpl; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * WxCpConfigStorage 抽象配置类 + * + * @author yl + * created on 2023/10/16 + */ +@RequiredArgsConstructor +@Slf4j +public abstract class AbstractWxCpConfiguration { + + protected WxCpMultiServices configWxCpServices(WxCpMultiProperties wxCpMultiProperties) { + Map corps = wxCpMultiProperties.getCorps(); + if (corps == null || corps.isEmpty()) { + log.warn("企业微信应用参数未配置,通过 WxCpMultiServices#getWxCpService(\"tenantId\")获取实例将返回空"); + return new WxCpMultiServicesImpl(); + } + /** + * 校验同一个企业下,agentId 是否唯一,避免使用 redis 缓存 token、ticket 时错乱。 + * + * 查看 {@link me.chanjar.weixin.cp.config.impl.AbstractWxCpInRedisConfigImpl#setAgentId(Integer)} + */ + Collection corpList = corps.values(); + if (corpList.size() > 1) { + // 先按 corpId 分组统计 + Map> corpsMap = corpList.stream() + .collect(Collectors.groupingBy(CorpProperties::getCorpId)); + Set>> entries = corpsMap.entrySet(); + for (Map.Entry> entry : entries) { + String corpId = entry.getKey(); + // 校验每个企业下,agentId 是否唯一 + boolean multi = entry.getValue().stream() + // 通讯录没有 agentId,如果不判断是否为空,这里会报 NPE 异常 + .collect(Collectors.groupingBy(c -> c.getAgentId() == null ? 0 : c.getAgentId(), Collectors.counting())) + .entrySet().stream().anyMatch(e -> e.getValue() > 1); + if (multi) { + throw new RuntimeException("请确保企业微信配置唯一性[" + corpId + "]"); + } + } + } + WxCpMultiServicesImpl services = new WxCpMultiServicesImpl(); + + Set> entries = corps.entrySet(); + for (Map.Entry entry : entries) { + String tenantId = entry.getKey(); + CorpProperties corpProperties = entry.getValue(); + WxCpDefaultConfigImpl storage = this.configWxCpDefaultConfigImpl(wxCpMultiProperties); + this.configCorp(storage, corpProperties); + this.configHttp(storage, wxCpMultiProperties.getConfigStorage()); + WxCpService wxCpService = this.configWxCpService(storage, wxCpMultiProperties.getConfigStorage()); + services.addWxCpService(tenantId, wxCpService); + } + return services; + } + + /** + * 配置 WxCpDefaultConfigImpl + * + * @param wxCpMultiProperties 参数 + * @return WxCpDefaultConfigImpl + */ + protected abstract WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties); + + private WxCpService configWxCpService(WxCpConfigStorage wxCpConfigStorage, WxCpMultiProperties.ConfigStorage storage) { + WxCpService wxCpService = new WxCpServiceImpl(); + wxCpService.setWxCpConfigStorage(wxCpConfigStorage); + + int maxRetryTimes = storage.getMaxRetryTimes(); + if (maxRetryTimes < 0) { + maxRetryTimes = 0; + } + int retrySleepMillis = storage.getRetrySleepMillis(); + if (retrySleepMillis < 0) { + retrySleepMillis = 1000; + } + wxCpService.setRetrySleepMillis(retrySleepMillis); + wxCpService.setMaxRetryTimes(maxRetryTimes); + return wxCpService; + } + + private void configCorp(WxCpDefaultConfigImpl config, CorpProperties corpProperties) { + String corpId = corpProperties.getCorpId(); + String corpSecret = corpProperties.getCorpSecret(); + Integer agentId = corpProperties.getAgentId(); + String token = corpProperties.getToken(); + String aesKey = corpProperties.getAesKey(); + // 企业微信,私钥,会话存档路径 + String msgAuditPriKey = corpProperties.getMsgAuditPriKey(); + String msgAuditLibPath = corpProperties.getMsgAuditLibPath(); + + config.setCorpId(corpId); + config.setCorpSecret(corpSecret); + config.setAgentId(agentId); + if (StringUtils.isNotBlank(token)) { + config.setToken(token); + } + if (StringUtils.isNotBlank(aesKey)) { + config.setAesKey(aesKey); + } + if (StringUtils.isNotBlank(msgAuditPriKey)) { + config.setMsgAuditPriKey(msgAuditPriKey); + } + if (StringUtils.isNotBlank(msgAuditLibPath)) { + config.setMsgAuditLibPath(msgAuditLibPath); + } + } + + private void configHttp(WxCpDefaultConfigImpl config, WxCpMultiProperties.ConfigStorage storage) { + String httpProxyHost = storage.getHttpProxyHost(); + Integer httpProxyPort = storage.getHttpProxyPort(); + String httpProxyUsername = storage.getHttpProxyUsername(); + String httpProxyPassword = storage.getHttpProxyPassword(); + if (StringUtils.isNotBlank(httpProxyHost)) { + config.setHttpProxyHost(httpProxyHost); + if (httpProxyPort != null) { + config.setHttpProxyPort(httpProxyPort); + } + if (StringUtils.isNotBlank(httpProxyUsername)) { + config.setHttpProxyUsername(httpProxyUsername); + } + if (StringUtils.isNotBlank(httpProxyPassword)) { + config.setHttpProxyPassword(httpProxyPassword); + } + } + } +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInJedisConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInJedisConfiguration.java new file mode 100644 index 0000000000..3e49a5024a --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInJedisConfiguration.java @@ -0,0 +1,76 @@ +package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiRedisProperties; +import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpJedisConfigImpl; +import org.apache.commons.lang3.StringUtils; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; + +/** + * 自动装配基于 jedis 策略配置 + * + * @author yl + * created on 2023/10/16 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpMultiProperties.PREFIX + ".config-storage", name = "type", havingValue = "jedis" +) +@RequiredArgsConstructor +public class WxCpInJedisConfiguration extends AbstractWxCpConfiguration { + private final WxCpMultiProperties wxCpMultiProperties; + private final ApplicationContext applicationContext; + + @Bean + public WxCpMultiServices wxCpMultiServices() { + return this.configWxCpServices(wxCpMultiProperties); + } + + @Override + protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + return this.configRedis(wxCpMultiProperties); + } + + private WxCpDefaultConfigImpl configRedis(WxCpMultiProperties wxCpMultiProperties) { + WxCpMultiRedisProperties wxCpMultiRedisProperties = wxCpMultiProperties.getConfigStorage().getRedis(); + JedisPool jedisPool; + if (wxCpMultiRedisProperties != null && StringUtils.isNotEmpty(wxCpMultiRedisProperties.getHost())) { + jedisPool = getJedisPool(wxCpMultiProperties); + } else { + jedisPool = applicationContext.getBean(JedisPool.class); + } + return new WxCpJedisConfigImpl(jedisPool, wxCpMultiProperties.getConfigStorage().getKeyPrefix()); + } + + private JedisPool getJedisPool(WxCpMultiProperties wxCpMultiProperties) { + WxCpMultiProperties.ConfigStorage storage = wxCpMultiProperties.getConfigStorage(); + WxCpMultiRedisProperties redis = storage.getRedis(); + + JedisPoolConfig config = new JedisPoolConfig(); + if (redis.getMaxActive() != null) { + config.setMaxTotal(redis.getMaxActive()); + } + if (redis.getMaxIdle() != null) { + config.setMaxIdle(redis.getMaxIdle()); + } + if (redis.getMaxWaitMillis() != null) { + config.setMaxWaitMillis(redis.getMaxWaitMillis()); + } + if (redis.getMinIdle() != null) { + config.setMinIdle(redis.getMinIdle()); + } + config.setTestOnBorrow(true); + config.setTestWhileIdle(true); + + return new JedisPool(config, redis.getHost(), redis.getPort(), + redis.getTimeout(), redis.getPassword(), redis.getDatabase()); + } +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInMemoryConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInMemoryConfiguration.java new file mode 100644 index 0000000000..dd0946fc53 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInMemoryConfiguration.java @@ -0,0 +1,38 @@ +package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 自动装配基于内存策略配置 + * + * @author yl + * created on 2023/10/16 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpMultiProperties.PREFIX + ".config-storage", name = "type", havingValue = "memory", matchIfMissing = true +) +@RequiredArgsConstructor +public class WxCpInMemoryConfiguration extends AbstractWxCpConfiguration { + private final WxCpMultiProperties wxCpMultiProperties; + + @Bean + public WxCpMultiServices wxCpMultiServices() { + return this.configWxCpServices(wxCpMultiProperties); + } + + @Override + protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + return this.configInMemory(); + } + + private WxCpDefaultConfigImpl configInMemory() { + return new WxCpDefaultConfigImpl(); + } +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedisTemplateConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedisTemplateConfiguration.java new file mode 100644 index 0000000000..103956fed3 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedisTemplateConfiguration.java @@ -0,0 +1,43 @@ +package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpRedisTemplateConfigImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.core.StringRedisTemplate; + +/** + * 自动装配基于 redisTemplate 策略配置 + * + * @author yl + * created on 2023/10/16 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpMultiProperties.PREFIX + ".config-storage", name = "type", havingValue = "redistemplate" +) +@RequiredArgsConstructor +public class WxCpInRedisTemplateConfiguration extends AbstractWxCpConfiguration { + private final WxCpMultiProperties wxCpMultiProperties; + private final ApplicationContext applicationContext; + + @Bean + public WxCpMultiServices wxCpMultiServices() { + return this.configWxCpServices(wxCpMultiProperties); + } + + @Override + protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + return this.configRedisTemplate(wxCpMultiProperties); + } + + private WxCpDefaultConfigImpl configRedisTemplate(WxCpMultiProperties wxCpMultiProperties) { + StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class); + return new WxCpRedisTemplateConfigImpl(redisTemplate, wxCpMultiProperties.getConfigStorage().getKeyPrefix()); + } +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedissonConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedissonConfiguration.java new file mode 100644 index 0000000000..b8fc3a83ac --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedissonConfiguration.java @@ -0,0 +1,67 @@ +package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiRedisProperties; +import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpRedissonConfigImpl; +import org.apache.commons.lang3.StringUtils; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.redisson.config.TransportMode; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 自动装配基于 redisson 策略配置 + * + * @author yl + * created on 2023/10/16 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpMultiProperties.PREFIX + ".config-storage", name = "type", havingValue = "redisson" +) +@RequiredArgsConstructor +public class WxCpInRedissonConfiguration extends AbstractWxCpConfiguration { + private final WxCpMultiProperties wxCpMultiProperties; + private final ApplicationContext applicationContext; + + @Bean + public WxCpMultiServices wxCpMultiServices() { + return this.configWxCpServices(wxCpMultiProperties); + } + + @Override + protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + return this.configRedisson(wxCpMultiProperties); + } + + private WxCpDefaultConfigImpl configRedisson(WxCpMultiProperties wxCpMultiProperties) { + WxCpMultiRedisProperties redisProperties = wxCpMultiProperties.getConfigStorage().getRedis(); + RedissonClient redissonClient; + if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { + redissonClient = getRedissonClient(wxCpMultiProperties); + } else { + redissonClient = applicationContext.getBean(RedissonClient.class); + } + return new WxCpRedissonConfigImpl(redissonClient, wxCpMultiProperties.getConfigStorage().getKeyPrefix()); + } + + private RedissonClient getRedissonClient(WxCpMultiProperties wxCpMultiProperties) { + WxCpMultiProperties.ConfigStorage storage = wxCpMultiProperties.getConfigStorage(); + WxCpMultiRedisProperties redis = storage.getRedis(); + + Config config = new Config(); + config.useSingleServer() + .setAddress("redis://" + redis.getHost() + ":" + redis.getPort()) + .setDatabase(redis.getDatabase()) + .setPassword(redis.getPassword()); + config.setTransportMode(TransportMode.NIO); + return Redisson.create(config); + } +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/CorpProperties.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/CorpProperties.java new file mode 100644 index 0000000000..354078d053 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/CorpProperties.java @@ -0,0 +1,43 @@ +package com.binarywang.spring.starter.wxjava.cp.properties; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 企业微信企业相关配置属性 + * + * @author yl + * created on 2023/10/16 + */ +@Data +@NoArgsConstructor +public class CorpProperties { + /** + * 微信企业号 corpId + */ + private String corpId; + /** + * 微信企业号 corpSecret + */ + private String corpSecret; + /** + * 微信企业号应用 token + */ + private String token; + /** + * 微信企业号应用 ID + */ + private Integer agentId; + /** + * 微信企业号应用 EncodingAESKey + */ + private String aesKey; + /** + * 微信企业号应用 会话存档私钥 + */ + private String msgAuditPriKey; + /** + * 微信企业号应用 会话存档类库路径 + */ + private String msgAuditLibPath; +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiProperties.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiProperties.java new file mode 100644 index 0000000000..2d2b418ade --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiProperties.java @@ -0,0 +1,108 @@ +package com.binarywang.spring.starter.wxjava.cp.properties; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * 企业微信多企业接入相关配置属性 + * + * @author yl + * created on 2023/10/16 + */ +@Data +@NoArgsConstructor +@ConfigurationProperties(prefix = WxCpMultiProperties.PREFIX) +public class WxCpMultiProperties { + public static final String PREFIX = "wx.cp"; + + private Map corps = new HashMap<>(); + + /** + * 配置存储策略,默认内存 + */ + private ConfigStorage configStorage = new ConfigStorage(); + + @Data + @NoArgsConstructor + public static class ConfigStorage implements Serializable { + private static final long serialVersionUID = 4815731027000065434L; + /** + * 存储类型 + */ + private StorageType type = StorageType.memory; + + /** + * 指定key前缀 + */ + private String keyPrefix = "wx:cp"; + + /** + * redis连接配置 + */ + @NestedConfigurationProperty + private WxCpMultiRedisProperties redis = new WxCpMultiRedisProperties(); + + /** + * http代理主机 + */ + private String httpProxyHost; + + /** + * http代理端口 + */ + private Integer httpProxyPort; + + /** + * http代理用户名 + */ + private String httpProxyUsername; + + /** + * http代理密码 + */ + private String httpProxyPassword; + + /** + * http 请求最大重试次数 + *
+     *   {@link me.chanjar.weixin.cp.api.WxCpService#setMaxRetryTimes(int)}
+     *   {@link me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl#setMaxRetryTimes(int)}
+     * 
+ */ + private int maxRetryTimes = 5; + + /** + * http 请求重试间隔 + *
+     *   {@link me.chanjar.weixin.cp.api.WxCpService#setRetrySleepMillis(int)}
+     *   {@link me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl#setRetrySleepMillis(int)}
+     * 
+ */ + private int retrySleepMillis = 1000; + } + + public enum StorageType { + /** + * 内存 + */ + memory, + /** + * jedis + */ + jedis, + /** + * redisson + */ + redisson, + /** + * redistemplate + */ + redistemplate + } +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiRedisProperties.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiRedisProperties.java new file mode 100644 index 0000000000..e684333aea --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiRedisProperties.java @@ -0,0 +1,46 @@ +package com.binarywang.spring.starter.wxjava.cp.properties; + +import lombok.Data; + +import java.io.Serializable; + +/** + * Redis配置. + * + * @author yl + * created on 2023/10/16 + */ +@Data +public class WxCpMultiRedisProperties implements Serializable { + private static final long serialVersionUID = -5924815351660074401L; + + /** + * 主机地址. + */ + private String host; + + /** + * 端口号. + */ + private int port = 6379; + + /** + * 密码. + */ + private String password; + + /** + * 超时. + */ + private int timeout = 2000; + + /** + * 数据库. + */ + private int database = 0; + + private Integer maxActive; + private Integer maxIdle; + private Integer maxWaitMillis; + private Integer minIdle; +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/service/WxCpMultiServices.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/service/WxCpMultiServices.java new file mode 100644 index 0000000000..dfcb25631d --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/service/WxCpMultiServices.java @@ -0,0 +1,26 @@ +package com.binarywang.spring.starter.wxjava.cp.service; + +import me.chanjar.weixin.cp.api.WxCpService; + +/** + * 企业微信 {@link WxCpService} 所有实例存放类. + * + * @author yl + * created on 2023/10/16 + */ +public interface WxCpMultiServices { + /** + * 通过租户 Id 获取 WxCpService + * + * @param tenantId 租户 Id + * @return WxCpService + */ + WxCpService getWxCpService(String tenantId); + + /** + * 根据租户 Id,从列表中移除一个 WxCpService 实例 + * + * @param tenantId 租户 Id + */ + void removeWxCpService(String tenantId); +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/service/WxCpMultiServicesImpl.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/service/WxCpMultiServicesImpl.java new file mode 100644 index 0000000000..19eae24159 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/service/WxCpMultiServicesImpl.java @@ -0,0 +1,42 @@ +package com.binarywang.spring.starter.wxjava.cp.service; + +import me.chanjar.weixin.cp.api.WxCpService; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 企业微信 {@link WxCpMultiServices} 默认实现 + * + * @author yl + * created on 2023/10/16 + */ +public class WxCpMultiServicesImpl implements WxCpMultiServices { + private final Map services = new ConcurrentHashMap<>(); + + /** + * 通过租户 Id 获取 WxCpService + * + * @param tenantId 租户 Id + * @return WxCpService + */ + @Override + public WxCpService getWxCpService(String tenantId) { + return this.services.get(tenantId); + } + + /** + * 根据租户 Id,添加一个 WxCpService 到列表 + * + * @param tenantId 租户 Id + * @param wxCpService WxCpService 实例 + */ + public void addWxCpService(String tenantId, WxCpService wxCpService) { + this.services.put(tenantId, wxCpService); + } + + @Override + public void removeWxCpService(String tenantId) { + this.services.remove(tenantId); + } +} diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/resources/META-INF/spring.factories b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000..6010561a96 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.binarywang.spring.starter.wxjava.cp.autoconfigure.WxCpMultiAutoConfiguration diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..3c48ec34e1 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.cp.autoconfigure.WxCpMultiAutoConfiguration diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/README.md b/spring-boot-starters/wx-java-cp-spring-boot-starter/README.md new file mode 100644 index 0000000000..d6c1abc945 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/README.md @@ -0,0 +1,41 @@ +# wx-java-cp-spring-boot-starter + +## 快速开始 + +1. 引入依赖 + ```xml + + com.github.binarywang + wx-java-cp-spring-boot-starter + ${version} + + ``` +2. 添加配置(application.properties) + ```properties + # 企业微信号配置(必填) + wx.cp.corp-id = @corp-id + wx.cp.corp-secret = @corp-secret + # 选填 + wx.cp.agent-id = @agent-id + wx.cp.token = @token + wx.cp.aes-key = @aes-key + wx.cp.msg-audit-priKey = @msg-audit-priKey + wx.cp.msg-audit-lib-path = @msg-audit-lib-path + # ConfigStorage 配置(选填) + wx.cp.config-storage.type=memory # 配置类型: memory(默认), jedis, redisson, redistemplate + # http 客户端配置(选填) + wx.cp.config-storage.http-proxy-host= + wx.cp.config-storage.http-proxy-port= + wx.cp.config-storage.http-proxy-username= + wx.cp.config-storage.http-proxy-password= + # 最大重试次数,默认:5 次,如果小于 0,则为 0 + wx.cp.config-storage.max-retry-times=5 + # 重试时间间隔步进,默认:1000 毫秒,如果小于 0,则为 1000 + wx.cp.config-storage.retry-sleep-millis=1000 + ``` +3. 支持自动注入的类型: `WxCpService`, `WxCpConfigStorage` + +4. 覆盖自动配置: 自定义注入的bean会覆盖自动注入的 + +- WxCpService +- WxCpConfigStorage diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-cp-spring-boot-starter/pom.xml new file mode 100644 index 0000000000..d64aec432c --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/pom.xml @@ -0,0 +1,57 @@ + + + + wx-java-spring-boot-starters + com.github.binarywang + 4.5.7.B + + 4.0.0 + + wx-java-cp-spring-boot-starter + WxJava - Spring Boot Starter for WxCp + 微信企业号开发的 Spring Boot Starter + + + + com.github.binarywang + weixin-java-cp + ${project.version} + + + redis.clients + jedis + + + org.redisson + redisson + + + org.springframework.data + spring-data-redis + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpAutoConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpAutoConfiguration.java new file mode 100644 index 0000000000..f78c39dd45 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpAutoConfiguration.java @@ -0,0 +1,21 @@ +package com.binarywang.spring.starter.wxjava.cp.config; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * 企业微信自动注册 + * + * @author yl + * created on 2021/12/6 + */ +@Configuration +@EnableConfigurationProperties(WxCpProperties.class) +@Import({ + WxCpStorageAutoConfiguration.class, + WxCpServiceAutoConfiguration.class +}) +public class WxCpAutoConfiguration { +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpServiceAutoConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpServiceAutoConfiguration.java new file mode 100644 index 0000000000..70c4045259 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpServiceAutoConfiguration.java @@ -0,0 +1,44 @@ +package com.binarywang.spring.starter.wxjava.cp.config; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 企业微信平台相关服务自动注册 + * + * @author yl + * created on 2021/12/6 + */ +@Configuration +@RequiredArgsConstructor +public class WxCpServiceAutoConfiguration { + private final WxCpProperties wxCpProperties; + + @Bean + @ConditionalOnMissingBean + @ConditionalOnBean(WxCpConfigStorage.class) + public WxCpService wxCpService(WxCpConfigStorage wxCpConfigStorage) { + WxCpService wxCpService = new WxCpServiceImpl(); + wxCpService.setWxCpConfigStorage(wxCpConfigStorage); + + WxCpProperties.ConfigStorage storage = wxCpProperties.getConfigStorage(); + int maxRetryTimes = storage.getMaxRetryTimes(); + if (maxRetryTimes < 0) { + maxRetryTimes = 0; + } + int retrySleepMillis = storage.getRetrySleepMillis(); + if (retrySleepMillis < 0) { + retrySleepMillis = 1000; + } + wxCpService.setRetrySleepMillis(retrySleepMillis); + wxCpService.setMaxRetryTimes(maxRetryTimes); + return wxCpService; + } +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpStorageAutoConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpStorageAutoConfiguration.java new file mode 100644 index 0000000000..1c7d80b84e --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/config/WxCpStorageAutoConfiguration.java @@ -0,0 +1,24 @@ +package com.binarywang.spring.starter.wxjava.cp.config; + +import com.binarywang.spring.starter.wxjava.cp.storage.WxCpInJedisConfigStorageConfiguration; +import com.binarywang.spring.starter.wxjava.cp.storage.WxCpInMemoryConfigStorageConfiguration; +import com.binarywang.spring.starter.wxjava.cp.storage.WxCpInRedisTemplateConfigStorageConfiguration; +import com.binarywang.spring.starter.wxjava.cp.storage.WxCpInRedissonConfigStorageConfiguration; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * 企业微信存储策略自动配置 + * + * @author yl + * created on 2021/12/6 + */ +@Configuration +@Import({ + WxCpInMemoryConfigStorageConfiguration.class, + WxCpInJedisConfigStorageConfiguration.class, + WxCpInRedissonConfigStorageConfiguration.class, + WxCpInRedisTemplateConfigStorageConfiguration.class +}) +public class WxCpStorageAutoConfiguration { +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpProperties.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpProperties.java new file mode 100644 index 0000000000..b87ddc2454 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpProperties.java @@ -0,0 +1,133 @@ +package com.binarywang.spring.starter.wxjava.cp.properties; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +import java.io.Serializable; + +/** + * 企业微信接入相关配置属性 + * + * @author yl + * created on 2021/12/6 + */ +@Data +@NoArgsConstructor +@ConfigurationProperties(prefix = WxCpProperties.PREFIX) +public class WxCpProperties { + public static final String PREFIX = "wx.cp"; + + /** + * 微信企业号 corpId + */ + private String corpId; + /** + * 微信企业号 corpSecret + */ + private String corpSecret; + /** + * 微信企业号应用 token + */ + private String token; + /** + * 微信企业号应用 ID + */ + private Integer agentId; + /** + * 微信企业号应用 EncodingAESKey + */ + private String aesKey; + /** + * 微信企业号应用 会话存档私钥 + */ + private String msgAuditPriKey; + /** + * 微信企业号应用 会话存档类库路径 + */ + private String msgAuditLibPath; + + /** + * 配置存储策略,默认内存 + */ + private ConfigStorage configStorage = new ConfigStorage(); + + @Data + @NoArgsConstructor + public static class ConfigStorage implements Serializable { + private static final long serialVersionUID = 4815731027000065434L; + /** + * 存储类型 + */ + private StorageType type = StorageType.memory; + + /** + * 指定key前缀 + */ + private String keyPrefix = "wx:cp"; + + /** + * redis连接配置 + */ + @NestedConfigurationProperty + private WxCpRedisProperties redis = new WxCpRedisProperties(); + + /** + * http代理主机 + */ + private String httpProxyHost; + + /** + * http代理端口 + */ + private Integer httpProxyPort; + + /** + * http代理用户名 + */ + private String httpProxyUsername; + + /** + * http代理密码 + */ + private String httpProxyPassword; + + /** + * http 请求最大重试次数 + *
+     *   {@link me.chanjar.weixin.cp.api.WxCpService#setMaxRetryTimes(int)}
+     *   {@link me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl#setMaxRetryTimes(int)}
+     * 
+ */ + private int maxRetryTimes = 5; + + /** + * http 请求重试间隔 + *
+     *   {@link me.chanjar.weixin.cp.api.WxCpService#setRetrySleepMillis(int)}
+     *   {@link me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl#setRetrySleepMillis(int)}
+     * 
+ */ + private int retrySleepMillis = 1000; + } + + public enum StorageType { + /** + * 内存 + */ + memory, + /** + * jedis + */ + jedis, + /** + * redisson + */ + redisson, + /** + * redistemplate + */ + redistemplate + } +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpRedisProperties.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpRedisProperties.java new file mode 100644 index 0000000000..63a7fe01e0 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpRedisProperties.java @@ -0,0 +1,46 @@ +package com.binarywang.spring.starter.wxjava.cp.properties; + +import lombok.Data; + +import java.io.Serializable; + +/** + * Redis配置. + * + * @author yl + * created on 2023/04/23 + */ +@Data +public class WxCpRedisProperties implements Serializable { + private static final long serialVersionUID = -5924815351660074401L; + + /** + * 主机地址. + */ + private String host; + + /** + * 端口号. + */ + private int port = 6379; + + /** + * 密码. + */ + private String password; + + /** + * 超时. + */ + private int timeout = 2000; + + /** + * 数据库. + */ + private int database = 0; + + private Integer maxActive; + private Integer maxIdle; + private Integer maxWaitMillis; + private Integer minIdle; +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java new file mode 100644 index 0000000000..0f2995e967 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java @@ -0,0 +1,61 @@ +package com.binarywang.spring.starter.wxjava.cp.storage; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import org.apache.commons.lang3.StringUtils; + +/** + * WxCpConfigStorage 抽象配置类 + * + * @author yl & Wang_Wong + * created on 2021/12/6 + */ +public abstract class AbstractWxCpConfigStorageConfiguration { + + protected WxCpDefaultConfigImpl config(WxCpDefaultConfigImpl config, WxCpProperties properties) { + String corpId = properties.getCorpId(); + String corpSecret = properties.getCorpSecret(); + Integer agentId = properties.getAgentId(); + String token = properties.getToken(); + String aesKey = properties.getAesKey(); + // 企业微信,私钥,会话存档路径 + String msgAuditPriKey = properties.getMsgAuditPriKey(); + String msgAuditLibPath = properties.getMsgAuditLibPath(); + + config.setCorpId(corpId); + config.setCorpSecret(corpSecret); + config.setAgentId(agentId); + if (StringUtils.isNotBlank(token)) { + config.setToken(token); + } + if (StringUtils.isNotBlank(aesKey)) { + config.setAesKey(aesKey); + } + if (StringUtils.isNotBlank(msgAuditPriKey)) { + config.setMsgAuditPriKey(msgAuditPriKey); + } + if (StringUtils.isNotBlank(msgAuditLibPath)) { + config.setMsgAuditLibPath(msgAuditLibPath); + } + + WxCpProperties.ConfigStorage storage = properties.getConfigStorage(); + String httpProxyHost = storage.getHttpProxyHost(); + Integer httpProxyPort = storage.getHttpProxyPort(); + String httpProxyUsername = storage.getHttpProxyUsername(); + String httpProxyPassword = storage.getHttpProxyPassword(); + if (StringUtils.isNotBlank(httpProxyHost)) { + config.setHttpProxyHost(httpProxyHost); + if (httpProxyPort != null) { + config.setHttpProxyPort(httpProxyPort); + } + if (StringUtils.isNotBlank(httpProxyUsername)) { + config.setHttpProxyUsername(httpProxyUsername); + } + if (StringUtils.isNotBlank(httpProxyPassword)) { + config.setHttpProxyPassword(httpProxyPassword); + } + } + return config; + } + +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInJedisConfigStorageConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInJedisConfigStorageConfiguration.java new file mode 100644 index 0000000000..246971baed --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInJedisConfigStorageConfiguration.java @@ -0,0 +1,74 @@ +package com.binarywang.spring.starter.wxjava.cp.storage; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpRedisProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpJedisConfigImpl; +import org.apache.commons.lang3.StringUtils; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; + +/** + * 自动装配基于 jedis 策略配置 + * + * @author yl + * created on 2023/04/23 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpProperties.PREFIX + ".config-storage", name = "type", havingValue = "jedis" +) +@RequiredArgsConstructor +public class WxCpInJedisConfigStorageConfiguration extends AbstractWxCpConfigStorageConfiguration { + private final WxCpProperties wxCpProperties; + private final ApplicationContext applicationContext; + + @Bean + @ConditionalOnMissingBean(WxCpConfigStorage.class) + public WxCpConfigStorage wxCpConfigStorage() { + WxCpDefaultConfigImpl config = getConfigStorage(); + return this.config(config, wxCpProperties); + } + + private WxCpJedisConfigImpl getConfigStorage() { + WxCpRedisProperties wxCpRedisProperties = wxCpProperties.getConfigStorage().getRedis(); + JedisPool jedisPool; + if (wxCpRedisProperties != null && StringUtils.isNotEmpty(wxCpRedisProperties.getHost())) { + jedisPool = getJedisPool(); + } else { + jedisPool = applicationContext.getBean(JedisPool.class); + } + return new WxCpJedisConfigImpl(jedisPool, wxCpProperties.getConfigStorage().getKeyPrefix()); + } + + private JedisPool getJedisPool() { + WxCpProperties.ConfigStorage storage = wxCpProperties.getConfigStorage(); + WxCpRedisProperties redis = storage.getRedis(); + + JedisPoolConfig config = new JedisPoolConfig(); + if (redis.getMaxActive() != null) { + config.setMaxTotal(redis.getMaxActive()); + } + if (redis.getMaxIdle() != null) { + config.setMaxIdle(redis.getMaxIdle()); + } + if (redis.getMaxWaitMillis() != null) { + config.setMaxWaitMillis(redis.getMaxWaitMillis()); + } + if (redis.getMinIdle() != null) { + config.setMinIdle(redis.getMinIdle()); + } + config.setTestOnBorrow(true); + config.setTestWhileIdle(true); + + return new JedisPool(config, redis.getHost(), redis.getPort(), + redis.getTimeout(), redis.getPassword(), redis.getDatabase()); + } +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInMemoryConfigStorageConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInMemoryConfigStorageConfiguration.java new file mode 100644 index 0000000000..3722bd07d1 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInMemoryConfigStorageConfiguration.java @@ -0,0 +1,33 @@ +package com.binarywang.spring.starter.wxjava.cp.storage; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 自动装配基于内存策略配置 + * + * @author yl + * created on 2021/12/6 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpProperties.PREFIX + ".config-storage", name = "type", + matchIfMissing = true, havingValue = "memory" +) +@RequiredArgsConstructor +public class WxCpInMemoryConfigStorageConfiguration extends AbstractWxCpConfigStorageConfiguration { + private final WxCpProperties wxCpProperties; + + @Bean + @ConditionalOnMissingBean(WxCpConfigStorage.class) + public WxCpConfigStorage wxCpConfigStorage() { + WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl(); + return this.config(config, wxCpProperties); + } +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInRedisTemplateConfigStorageConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInRedisTemplateConfigStorageConfiguration.java new file mode 100644 index 0000000000..879568b16a --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInRedisTemplateConfigStorageConfiguration.java @@ -0,0 +1,41 @@ +package com.binarywang.spring.starter.wxjava.cp.storage; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpRedisTemplateConfigImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.core.StringRedisTemplate; + +/** + * 自动装配基于 redisTemplate 策略配置 + * + * @author yl + * created on 2023/04/23 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpProperties.PREFIX + ".config-storage", name = "type", havingValue = "redistemplate" +) +@RequiredArgsConstructor +public class WxCpInRedisTemplateConfigStorageConfiguration extends AbstractWxCpConfigStorageConfiguration { + private final WxCpProperties wxCpProperties; + private final ApplicationContext applicationContext; + + @Bean + @ConditionalOnMissingBean(WxCpConfigStorage.class) + public WxCpConfigStorage wxCpConfigStorage() { + WxCpDefaultConfigImpl config = getConfigStorage(); + return this.config(config, wxCpProperties); + } + + private WxCpRedisTemplateConfigImpl getConfigStorage() { + StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class); + return new WxCpRedisTemplateConfigImpl(redisTemplate, wxCpProperties.getConfigStorage().getKeyPrefix()); + } +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInRedissonConfigStorageConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInRedissonConfigStorageConfiguration.java new file mode 100644 index 0000000000..060b894fd1 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/WxCpInRedissonConfigStorageConfiguration.java @@ -0,0 +1,65 @@ +package com.binarywang.spring.starter.wxjava.cp.storage; + +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpRedisProperties; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpRedissonConfigImpl; +import org.apache.commons.lang3.StringUtils; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.redisson.config.TransportMode; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 自动装配基于 redisson 策略配置 + * + * @author yl + * created on 2023/04/23 + */ +@Configuration +@ConditionalOnProperty( + prefix = WxCpProperties.PREFIX + ".config-storage", name = "type", havingValue = "redisson" +) +@RequiredArgsConstructor +public class WxCpInRedissonConfigStorageConfiguration extends AbstractWxCpConfigStorageConfiguration { + private final WxCpProperties wxCpProperties; + private final ApplicationContext applicationContext; + + @Bean + @ConditionalOnMissingBean(WxCpConfigStorage.class) + public WxCpConfigStorage wxCpConfigStorage() { + WxCpDefaultConfigImpl config = getConfigStorage(); + return this.config(config, wxCpProperties); + } + + private WxCpRedissonConfigImpl getConfigStorage() { + WxCpRedisProperties redisProperties = wxCpProperties.getConfigStorage().getRedis(); + RedissonClient redissonClient; + if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { + redissonClient = getRedissonClient(); + } else { + redissonClient = applicationContext.getBean(RedissonClient.class); + } + return new WxCpRedissonConfigImpl(redissonClient, wxCpProperties.getConfigStorage().getKeyPrefix()); + } + + private RedissonClient getRedissonClient() { + WxCpProperties.ConfigStorage storage = wxCpProperties.getConfigStorage(); + WxCpRedisProperties redis = storage.getRedis(); + + Config config = new Config(); + config.useSingleServer() + .setAddress("redis://" + redis.getHost() + ":" + redis.getPort()) + .setDatabase(redis.getDatabase()) + .setPassword(redis.getPassword()); + config.setTransportMode(TransportMode.NIO); + return Redisson.create(config); + } +} diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/resources/META-INF/spring.factories b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000..c2ef7f6354 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.binarywang.spring.starter.wxjava.cp.config.WxCpAutoConfiguration diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..0beff3f862 --- /dev/null +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.cp.config.WxCpAutoConfiguration diff --git a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml index 743650b256..6149c253e7 100644 --- a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml +++ b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml @@ -1,11 +1,10 @@ - wx-java-spring-boot-starters com.github.binarywang - 4.1.9.B + 4.5.7.B 4.0.0 @@ -32,7 +31,16 @@ org.springframework.data spring-data-redis - ${spring.boot.version} + provided + + + org.jodd + jodd-http + provided + + + com.squareup.okhttp3 + okhttp provided
diff --git a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/config/WxMaAutoConfiguration.java b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/config/WxMaAutoConfiguration.java index fbfae6dfe0..67a7efaecf 100644 --- a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/config/WxMaAutoConfiguration.java +++ b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/config/WxMaAutoConfiguration.java @@ -9,7 +9,7 @@ * 自动配置. * * @author Binary Wang - * @date 2019-08-10 + * created on 2019-08-10 */ @Configuration @EnableConfigurationProperties(WxMaProperties.class) diff --git a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/HttpClientType.java b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/HttpClientType.java index 52a53debdc..b3e4b464fe 100644 --- a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/HttpClientType.java +++ b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/HttpClientType.java @@ -4,7 +4,7 @@ * httpclient类型. * * @author Binary Wang - * @date 2020-05-25 + * created on 2020-05-25 */ public enum HttpClientType { /** diff --git a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/StorageType.java b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/StorageType.java index 9328980bb2..31c6e4b602 100644 --- a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/StorageType.java +++ b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/enums/StorageType.java @@ -4,7 +4,7 @@ * storage类型. * * @author Binary Wang - * @date 2020-05-25 + * created on 2020-05-25 */ public enum StorageType { /** @@ -15,6 +15,10 @@ public enum StorageType { * redis(JedisClient). */ Jedis, + /** + * redis(Redisson). + */ + Redisson, /** * redis(RedisTemplate). */ diff --git a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/RedisProperties.java b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/RedisProperties.java index 9cfaf80e8d..75e3740a19 100644 --- a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/RedisProperties.java +++ b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/RedisProperties.java @@ -6,7 +6,7 @@ * redis 配置. * * @author Binary Wang - * @date 2020-08-30 + * created on 2020-08-30 */ @Data public class RedisProperties { diff --git a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/WxMaProperties.java b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/WxMaProperties.java index 280330e928..b7ccb45374 100644 --- a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/WxMaProperties.java +++ b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/WxMaProperties.java @@ -12,7 +12,7 @@ * 属性配置类. * * @author Binary Wang - * @date 2019-08-10 + * created on 2019-08-10 */ @Data @ConfigurationProperties(prefix = PREFIX) diff --git a/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..6644fa9701 --- /dev/null +++ b/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.miniapp.config.WxMaAutoConfiguration diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml index e62e70040c..c24a097c14 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ wx-java-spring-boot-starters com.github.binarywang - 4.1.9.B + 4.5.7.B 4.0.0 @@ -27,7 +27,6 @@ org.springframework.data spring-data-redis - ${spring.boot.version} provided diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java index 145c663efe..912b902624 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java @@ -14,23 +14,23 @@ import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.core.StringRedisTemplate; +import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolAbstract; import redis.clients.jedis.JedisPoolConfig; import redis.clients.jedis.JedisSentinelPool; +import redis.clients.jedis.util.Pool; import java.util.Set; /** * 微信公众号存储策略自动配置. * - * @author someone + * @author Luo */ @Slf4j @Configuration @@ -40,12 +40,6 @@ public class WxMpStorageAutoConfiguration { private final WxMpProperties wxMpProperties; - @Value("${wx.mp.config-storage.redis.host:") - private String redisHost; - - @Value("${wx.mp.configStorage.redis.host:") - private String redisHost2; - @Bean @ConditionalOnMissingBean(WxMpConfigStorage.class) public WxMpConfigStorage wxMpConfigStorage() { @@ -80,15 +74,16 @@ private WxMpConfigStorage defaultConfigStorage() { } private WxMpConfigStorage jedisConfigStorage() { - JedisPoolAbstract jedisPool; - if (StringUtils.isNotEmpty(redisHost) || StringUtils.isNotEmpty(redisHost2)) { + Pool jedisPool; + if (wxMpProperties.getConfigStorage() != null && wxMpProperties.getConfigStorage().getRedis() != null + && StringUtils.isNotEmpty(wxMpProperties.getConfigStorage().getRedis().getHost())) { jedisPool = getJedisPool(); } else { jedisPool = applicationContext.getBean(JedisPool.class); } WxRedisOps redisOps = new JedisWxRedisOps(jedisPool); WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps, - wxMpProperties.getConfigStorage().getKeyPrefix()); + wxMpProperties.getConfigStorage().getKeyPrefix()); setWxMpInfo(wxMpRedisConfig); return wxMpRedisConfig; } @@ -114,7 +109,7 @@ private WxMpConfigStorage redisTemplateConfigStorage() { WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate); WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps, - wxMpProperties.getConfigStorage().getKeyPrefix()); + wxMpProperties.getConfigStorage().getKeyPrefix()); setWxMpInfo(wxMpRedisConfig); return wxMpRedisConfig; @@ -136,7 +131,7 @@ private void setWxMpInfo(WxMpDefaultConfigImpl config) { } } - private JedisPoolAbstract getJedisPool() { + private Pool getJedisPool() { RedisProperties redis = wxMpProperties.getConfigStorage().getRedis(); JedisPoolConfig config = new JedisPoolConfig(); @@ -160,6 +155,6 @@ private JedisPoolAbstract getJedisPool() { } return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), - redis.getDatabase()); + redis.getDatabase()); } } diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/HttpClientType.java b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/HttpClientType.java index 1fa235e4af..f67ef97c2e 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/HttpClientType.java +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/HttpClientType.java @@ -4,7 +4,7 @@ * httpclient类型. * * @author Binary Wang - * @date 2020-08-30 + * created on 2020-08-30 */ public enum HttpClientType { /** diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/StorageType.java b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/StorageType.java index 7dcb5a1157..05ed6ce393 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/StorageType.java +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/StorageType.java @@ -4,7 +4,7 @@ * storage类型. * * @author Binary Wang - * @date 2020-08-30 + * created on 2020-08-30 */ public enum StorageType { /** @@ -15,6 +15,10 @@ public enum StorageType { * redis(JedisClient). */ Jedis, + /** + * redis(Redisson). + */ + Redisson, /** * redis(RedisTemplate). */ diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/RedisProperties.java b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/RedisProperties.java index 59f82558d7..573c87630f 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/RedisProperties.java +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/RedisProperties.java @@ -8,7 +8,7 @@ * redis 配置属性. * * @author Binary Wang - * @date 2020-08-30 + * created on 2020-08-30 */ @Data public class RedisProperties implements Serializable { diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..cdffb05c9e --- /dev/null +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.mp.config.WxMpAutoConfiguration diff --git a/spring-boot-starters/wx-java-open-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-open-spring-boot-starter/pom.xml index 9545eb445f..d537af929b 100644 --- a/spring-boot-starters/wx-java-open-spring-boot-starter/pom.xml +++ b/spring-boot-starters/wx-java-open-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ wx-java-spring-boot-starters com.github.binarywang - 4.1.9.B + 4.5.7.B 4.0.0 @@ -22,18 +22,14 @@ redis.clients jedis - provided org.redisson redisson - provided org.springframework.data spring-data-redis - ${spring.boot.version} - provided diff --git a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/AbstractWxOpenConfigStorageConfiguration.java b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/AbstractWxOpenConfigStorageConfiguration.java index 0f77633e4d..ee0443c9ae 100644 --- a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/AbstractWxOpenConfigStorageConfiguration.java +++ b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/AbstractWxOpenConfigStorageConfiguration.java @@ -9,19 +9,20 @@ public abstract class AbstractWxOpenConfigStorageConfiguration { protected WxOpenInMemoryConfigStorage config(WxOpenInMemoryConfigStorage config, WxOpenProperties properties) { - WxOpenProperties.ConfigStorage configStorageProperties = properties.getConfigStorage(); + WxOpenProperties.ConfigStorage storage = properties.getConfigStorage(); config.setWxOpenInfo(properties.getAppId(), properties.getSecret(), properties.getToken(), properties.getAesKey()); - config.setHttpProxyHost(configStorageProperties.getHttpProxyHost()); - config.setHttpProxyUsername(configStorageProperties.getHttpProxyUsername()); - config.setHttpProxyPassword(configStorageProperties.getHttpProxyPassword()); - if (configStorageProperties.getHttpProxyPort() != null) { - config.setHttpProxyPort(configStorageProperties.getHttpProxyPort()); + config.setHttpProxyHost(storage.getHttpProxyHost()); + config.setHttpProxyUsername(storage.getHttpProxyUsername()); + config.setHttpProxyPassword(storage.getHttpProxyPassword()); + Integer httpProxyPort = storage.getHttpProxyPort(); + if (httpProxyPort != null) { + config.setHttpProxyPort(httpProxyPort); } - int maxRetryTimes = configStorageProperties.getMaxRetryTimes(); - if (configStorageProperties.getMaxRetryTimes() < 0) { + int maxRetryTimes = storage.getMaxRetryTimes(); + if (maxRetryTimes < 0) { maxRetryTimes = 0; } - int retrySleepMillis = configStorageProperties.getRetrySleepMillis(); + int retrySleepMillis = storage.getRetrySleepMillis(); if (retrySleepMillis < 0) { retrySleepMillis = 1000; } diff --git a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInJedisConfigStorageConfiguration.java b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInJedisConfigStorageConfiguration.java index 353b670e6a..73a0183d72 100644 --- a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInJedisConfigStorageConfiguration.java +++ b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInJedisConfigStorageConfiguration.java @@ -1,10 +1,8 @@ package com.binarywang.spring.starter.wxjava.open.config.storage; -import com.binarywang.spring.starter.wxjava.open.properties.RedisProperties; import com.binarywang.spring.starter.wxjava.open.properties.WxOpenProperties; +import com.binarywang.spring.starter.wxjava.open.properties.WxOpenRedisProperties; import lombok.RequiredArgsConstructor; -import me.chanjar.weixin.common.redis.JedisWxRedisOps; -import me.chanjar.weixin.common.redis.WxRedisOps; import me.chanjar.weixin.open.api.WxOpenConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage; @@ -39,20 +37,19 @@ public WxOpenConfigStorage wxOpenConfigStorage() { } private WxOpenInRedisConfigStorage getWxOpenInRedisConfigStorage() { - RedisProperties redisProperties = properties.getConfigStorage().getRedis(); + WxOpenRedisProperties wxOpenRedisProperties = properties.getConfigStorage().getRedis(); JedisPool jedisPool; - if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { + if (wxOpenRedisProperties != null && StringUtils.isNotEmpty(wxOpenRedisProperties.getHost())) { jedisPool = getJedisPool(); } else { jedisPool = applicationContext.getBean(JedisPool.class); } - WxRedisOps redisOps = new JedisWxRedisOps(jedisPool); - return new WxOpenInRedisConfigStorage(redisOps, properties.getConfigStorage().getKeyPrefix()); + return new WxOpenInRedisConfigStorage(jedisPool, properties.getConfigStorage().getKeyPrefix()); } private JedisPool getJedisPool() { WxOpenProperties.ConfigStorage storage = properties.getConfigStorage(); - RedisProperties redis = storage.getRedis(); + WxOpenRedisProperties redis = storage.getRedis(); JedisPoolConfig config = new JedisPoolConfig(); if (redis.getMaxActive() != null) { diff --git a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInRedissonConfigStorageConfiguration.java b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInRedissonConfigStorageConfiguration.java index 85aa1d20e0..ea1dce3670 100644 --- a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInRedissonConfigStorageConfiguration.java +++ b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/config/storage/WxOpenInRedissonConfigStorageConfiguration.java @@ -1,13 +1,11 @@ package com.binarywang.spring.starter.wxjava.open.config.storage; -import com.binarywang.spring.starter.wxjava.open.properties.RedisProperties; import com.binarywang.spring.starter.wxjava.open.properties.WxOpenProperties; +import com.binarywang.spring.starter.wxjava.open.properties.WxOpenRedisProperties; import lombok.RequiredArgsConstructor; -import me.chanjar.weixin.common.redis.RedissonWxRedisOps; -import me.chanjar.weixin.common.redis.WxRedisOps; import me.chanjar.weixin.open.api.WxOpenConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; -import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage; +import me.chanjar.weixin.open.api.impl.WxOpenInRedissonConfigStorage; import org.apache.commons.lang3.StringUtils; import org.redisson.Redisson; import org.redisson.api.RedissonClient; @@ -40,21 +38,20 @@ public WxOpenConfigStorage wxOpenConfigStorage() { return this.config(config, properties); } - private WxOpenInRedisConfigStorage getWxOpenInRedissonConfigStorage() { - RedisProperties redisProperties = properties.getConfigStorage().getRedis(); + private WxOpenInRedissonConfigStorage getWxOpenInRedissonConfigStorage() { + WxOpenRedisProperties wxOpenRedisProperties = properties.getConfigStorage().getRedis(); RedissonClient redissonClient; - if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { + if (wxOpenRedisProperties != null && StringUtils.isNotEmpty(wxOpenRedisProperties.getHost())) { redissonClient = getRedissonClient(); } else { redissonClient = applicationContext.getBean(RedissonClient.class); } - WxRedisOps redisOps = new RedissonWxRedisOps(redissonClient); - return new WxOpenInRedisConfigStorage(redisOps, properties.getConfigStorage().getKeyPrefix()); + return new WxOpenInRedissonConfigStorage(redissonClient, properties.getConfigStorage().getKeyPrefix()); } private RedissonClient getRedissonClient() { WxOpenProperties.ConfigStorage storage = properties.getConfigStorage(); - RedisProperties redis = storage.getRedis(); + WxOpenRedisProperties redis = storage.getRedis(); Config config = new Config(); config.useSingleServer() diff --git a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenProperties.java b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenProperties.java index adb35c2fa3..641c57b005 100644 --- a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenProperties.java +++ b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenProperties.java @@ -58,13 +58,13 @@ public static class ConfigStorage implements Serializable { /** * 指定key前缀. */ - private String keyPrefix = "wx"; + private String keyPrefix = "wx:open"; /** * redis连接配置. */ @NestedConfigurationProperty - private RedisProperties redis = new RedisProperties(); + private WxOpenRedisProperties redis = new WxOpenRedisProperties(); /** * http客户端类型. diff --git a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/RedisProperties.java b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenRedisProperties.java similarity index 91% rename from spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/RedisProperties.java rename to spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenRedisProperties.java index a03d3a47f6..0aafc73da6 100644 --- a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/RedisProperties.java +++ b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenRedisProperties.java @@ -10,7 +10,7 @@ * @author someone */ @Data -public class RedisProperties implements Serializable { +public class WxOpenRedisProperties implements Serializable { private static final long serialVersionUID = -5924815351660074401L; /** diff --git a/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..ce327ba462 --- /dev/null +++ b/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.open.config.WxOpenAutoConfiguration diff --git a/spring-boot-starters/wx-java-pay-spring-boot-starter/README.md b/spring-boot-starters/wx-java-pay-spring-boot-starter/README.md index a4d91fade0..d87a38fb9c 100644 --- a/spring-boot-starters/wx-java-pay-spring-boot-starter/README.md +++ b/spring-boot-starters/wx-java-pay-spring-boot-starter/README.md @@ -8,20 +8,36 @@ ``` 2. 添加配置(application.yml) +###### 1)V2版本 ```yml wx: pay: appId: mchId: mchKey: - subAppId: - subMchId: keyPath: ``` - - - - - - - +###### 2)V3版本 +```yml +wx: + pay: + appId: xxxxxxxxxxx + mchId: 15xxxxxxxxx #商户id + apiV3Key: Dc1DBwSc094jACxxxxxxxxxxxxxxx #V3密钥 + certSerialNo: 62C6CEAA360BCxxxxxxxxxxxxxxx + privateKeyPath: classpath:cert/apiclient_key.pem #apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径 + privateCertPath: classpath:cert/apiclient_cert.pem #apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径 +``` +###### 3)V3服务商版本 +```yml +wx: + pay: #微信服务商支付 + configs: + - appId: wxe97b2x9c2b3d #spAppId + mchId: 16486610 #服务商商户 + subAppId: wx118cexxe3c07679 #子appId + subMchId: 16496705 #子商户 + apiV3Key: Dc1DBwSc094jAKDGR5aqqb7PTHr #apiV3密钥 + privateKeyPath: classpath:cert/apiclient_key.pem #服务商证书文件,apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径(可以配置绝对路径) + privateCertPath: classpath:cert/apiclient_cert.pem #apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径 +``` diff --git a/spring-boot-starters/wx-java-pay-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-pay-spring-boot-starter/pom.xml index 074e202146..5c3fc0df26 100644 --- a/spring-boot-starters/wx-java-pay-spring-boot-starter/pom.xml +++ b/spring-boot-starters/wx-java-pay-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ wx-java-spring-boot-starters com.github.binarywang - 4.1.9.B + 4.5.7.B 4.0.0 diff --git a/spring-boot-starters/wx-java-pay-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-pay-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..28cbbace5f --- /dev/null +++ b/spring-boot-starters/wx-java-pay-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.pay.config.WxPayAutoConfiguration diff --git a/spring-boot-starters/wx-java-qidian-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-qidian-spring-boot-starter/pom.xml index fe8b29ecaa..b1da6f2505 100644 --- a/spring-boot-starters/wx-java-qidian-spring-boot-starter/pom.xml +++ b/spring-boot-starters/wx-java-qidian-spring-boot-starter/pom.xml @@ -3,7 +3,7 @@ wx-java-spring-boot-starters com.github.binarywang - 4.1.9.B + 4.5.7.B 4.0.0 @@ -25,7 +25,6 @@ org.springframework.data spring-data-redis - ${spring.boot.version} provided diff --git a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/config/WxQidianStorageAutoConfiguration.java b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/config/WxQidianStorageAutoConfiguration.java index 84163b005a..80809fefce 100644 --- a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/config/WxQidianStorageAutoConfiguration.java +++ b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/config/WxQidianStorageAutoConfiguration.java @@ -21,9 +21,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.core.StringRedisTemplate; import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolAbstract; import redis.clients.jedis.JedisPoolConfig; import redis.clients.jedis.JedisSentinelPool; +import redis.clients.jedis.util.Pool; import java.util.Set; @@ -80,7 +80,7 @@ private WxQidianConfigStorage defaultConfigStorage() { } private WxQidianConfigStorage jedisConfigStorage() { - JedisPoolAbstract jedisPool; + Pool jedisPool; if (StringUtils.isNotEmpty(redisHost) || StringUtils.isNotEmpty(redisHost2)) { jedisPool = getJedisPool(); } else { @@ -136,7 +136,7 @@ private void setWxMpInfo(WxQidianDefaultConfigImpl config) { } } - private JedisPoolAbstract getJedisPool() { + private Pool getJedisPool() { WxQidianProperties.ConfigStorage storage = wxQidianProperties.getConfigStorage(); RedisProperties redis = storage.getRedis(); @@ -156,8 +156,9 @@ private JedisPoolAbstract getJedisPool() { config.setTestOnBorrow(true); config.setTestWhileIdle(true); if (StringUtils.isNotEmpty(redis.getSentinelIps())) { + Set sentinels = Sets.newHashSet(redis.getSentinelIps().split(",")); - return new JedisSentinelPool(redis.getSentinelName(), sentinels); + return new JedisSentinelPool(redis.getSentinelName(), sentinels,config); } return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), diff --git a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/HttpClientType.java b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/HttpClientType.java index 9418a8bec5..1a927211cc 100644 --- a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/HttpClientType.java +++ b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/HttpClientType.java @@ -4,7 +4,7 @@ * httpclient类型. * * @author Binary Wang - * @date 2020-08-30 + * created on 2020-08-30 */ public enum HttpClientType { /** diff --git a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/StorageType.java b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/StorageType.java index 0a7a6b85df..f4e26bc156 100644 --- a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/StorageType.java +++ b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/enums/StorageType.java @@ -4,7 +4,7 @@ * storage类型. * * @author Binary Wang - * @date 2020-08-30 + * created on 2020-08-30 */ public enum StorageType { /** @@ -15,6 +15,10 @@ public enum StorageType { * redis(JedisClient). */ Jedis, + /** + * redis(Redisson). + */ + Redisson, /** * redis(RedisTemplate). */ diff --git a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/properties/RedisProperties.java b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/properties/RedisProperties.java index b055b63fe9..abfad572e7 100644 --- a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/properties/RedisProperties.java +++ b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/qidian/properties/RedisProperties.java @@ -8,7 +8,7 @@ * redis 配置属性. * * @author Binary Wang - * @date 2020-08-30 + * created on 2020-08-30 */ @Data public class RedisProperties implements Serializable { diff --git a/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..6e7e511448 --- /dev/null +++ b/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.binarywang.spring.starter.wxjava.qidian.config.WxQidianAutoConfiguration diff --git a/weixin-graal/pom.xml b/weixin-graal/pom.xml index 896a812b5a..66a177f87b 100644 --- a/weixin-graal/pom.xml +++ b/weixin-graal/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B weixin-graal diff --git a/weixin-java-channel/pom.xml b/weixin-java-channel/pom.xml new file mode 100644 index 0000000000..e797a03da1 --- /dev/null +++ b/weixin-java-channel/pom.xml @@ -0,0 +1,163 @@ + + + 4.0.0 + + com.github.binarywang + wx-java + 4.5.7.B + + + weixin-java-channel + WxJava - Channel Java SDK + 微信视频号 Java SDK + + + 2.15.0 + + + + + com.github.binarywang + weixin-java-common + ${project.version} + + + + org.jodd + jodd-http + provided + + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson.version} + true + + + + org.bouncycastle + bcpkix-jdk15on + + + org.projectlombok + lombok + + + org.redisson + redisson + + + + com.squareup.okhttp3 + okhttp + provided + + + + org.testng + testng + test + + + ch.qos.logback + logback-classic + test + + + com.google.inject + guice + test + + + org.eclipse.jetty + jetty-server + test + + + org.eclipse.jetty + jetty-servlet + test + + + org.assertj + assertj-guava + test + + + redis.clients + jedis + + + + com.github.jedis-lock + jedis-lock + true + + + org.mockito + mockito-core + 3.3.3 + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/testng.xml + + + + + + + + + native-image + + false + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + + com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor + + + + com.github.binarywang + weixin-graal + ${project.version} + + + + + + + + + + + diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java new file mode 100644 index 0000000000..211024d33a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java @@ -0,0 +1,372 @@ +package me.chanjar.weixin.channel.api; + +import java.util.Map; +import me.chanjar.weixin.channel.bean.message.after.AfterSaleMessage; +import me.chanjar.weixin.channel.bean.message.after.ComplaintMessage; +import me.chanjar.weixin.channel.bean.message.coupon.CouponActionMessage; +import me.chanjar.weixin.channel.bean.message.coupon.CouponReceiveMessage; +import me.chanjar.weixin.channel.bean.message.coupon.UserCouponExpireMessage; +import me.chanjar.weixin.channel.bean.message.fund.AccountNotifyMessage; +import me.chanjar.weixin.channel.bean.message.fund.QrNotifyMessage; +import me.chanjar.weixin.channel.bean.message.fund.WithdrawNotifyMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderCancelMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderConfirmMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderDeliveryMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderExtMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderIdMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderPayMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderSettleMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderStatusMessage; +import me.chanjar.weixin.channel.bean.message.product.BrandMessage; +import me.chanjar.weixin.channel.bean.message.product.CategoryAuditMessage; +import me.chanjar.weixin.channel.bean.message.product.SpuAuditMessage; +import me.chanjar.weixin.channel.bean.message.supplier.SupplierItemMessage; +import me.chanjar.weixin.channel.message.WxChannelMessage; +import me.chanjar.weixin.channel.message.WxChannelMessageRouterRule; +import me.chanjar.weixin.common.session.WxSessionManager; + +/** + * @author Zeyes + */ +public interface BaseWxChannelMessageService { + + /** + * 路由微信消息 + * + * @param message 消息 + * @param content 消息原始内容 + * @param appId appId + * @param service 服务实例 + * @return Object + */ + Object route(final WxChannelMessage message, final String content, final String appId, + final WxChannelService service); + + /** + * 添加一条规则进入路由器 + * + * @param rule 规则 + */ + void addRule(WxChannelMessageRouterRule rule); + + /** + * 订单下单 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderNew(final OrderIdMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 订单取消 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderCancel(OrderCancelMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 订单支付成功 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderPay(OrderPayMessage message, final String content, final String appId, final Map context, + final WxSessionManager sessionManager); + + /** + * 订单发货 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderDelivery(OrderDeliveryMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 订单确认收货 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderConfirm(OrderConfirmMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 订单结算成功 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderSettle(OrderSettleMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 订单其他信息更新 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderExtInfoUpdate(OrderExtMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 订单状态更新 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void orderStatusUpdate(OrderStatusMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 商品审核结果 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void spuAudit(SpuAuditMessage message, final String content, final String appId, final Map context, + final WxSessionManager sessionManager); + + /** + * 商品系统下架通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void spuStatusUpdate(SpuAuditMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 商品更新通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void spuUpdate(SpuAuditMessage message, final String content, final String appId, final Map context, + final WxSessionManager sessionManager); + + /** + * 类目审核结果 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void categoryAudit(CategoryAuditMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 品牌更新 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void brandUpdate(BrandMessage message, final String content, final String appId, final Map context, + final WxSessionManager sessionManager); + + /** + * 售后单状态更新 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void afterSaleStatusUpdate(AfterSaleMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 纠纷回调 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void complaintNotify(ComplaintMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 用户领券通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void couponReceive(CouponReceiveMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 创建优惠券通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void couponCreate(CouponActionMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 优惠券删除通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void couponDelete(CouponActionMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 优惠券过期通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void couponExpire(CouponActionMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 更新优惠券信息通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void couponUpdate(CouponActionMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 优惠券作废通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void couponInvalid(CouponActionMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 用户优惠券过期通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void userCouponExpire(UserCouponExpireMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 用户优惠券使用通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void userCouponUse(UserCouponExpireMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 用户优惠券返还通知 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void userCouponUnuse(UserCouponExpireMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 结算账户变更回调 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void accountNotify(AccountNotifyMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 提现回调 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void withdrawNotify(WithdrawNotifyMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 提现二维码回调 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void qrNotify(QrNotifyMessage message, final String content, final String appId, final Map context, + final WxSessionManager sessionManager); + + /** + * 团长商品变更 + * + * @param message 消息 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + */ + void supplierItemUpdate(SupplierItemMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); + + /** + * 默认消息处理 + * + * @param message 消息 + * @param content 内容 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + * @return Object + */ + Object defaultMessageHandler(WxChannelMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelService.java new file mode 100644 index 0000000000..f745ff3e41 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelService.java @@ -0,0 +1,136 @@ +package me.chanjar.weixin.channel.api; + +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.service.WxService; +import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; + +/** + * The interface Wx Channel service + * + * @author Zeyes + */ +public interface BaseWxChannelService extends WxService { + + /** + *
+   * 验证消息的确来自微信服务器.
+   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN
+   * 
+ * + * @param timestamp the timestamp + * @param nonce the nonce + * @param signature the signature + * @return the boolean + */ + boolean checkSignature(String timestamp, String nonce, String signature); + + /** + * 获取access_token, 不强制刷新access_token. + * + * @return the access token + * + * @throws WxErrorException the wx error exception + * @see #getAccessToken(boolean) #getAccessToken(boolean) + */ + 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
+   * 
+ * + * @param forceRefresh 强制刷新 + * @return the access token + * + * @throws WxErrorException the wx error exception + */ + String getAccessToken(boolean forceRefresh) throws WxErrorException; + + /** + *
+   * Service没有实现某个API的时候,可以用这个,
+   * 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。
+   * 可以参考,{@link MediaUploadRequestExecutor}的实现方法
+   * 
+ * + * @param . + * @param . + * @param executor 执行器 + * @param uri 接口请求地址 + * @param data 参数或请求数据 + * @return . t + * + * @throws WxErrorException the wx error exception + */ + T execute(RequestExecutor executor, String uri, E data) throws WxErrorException; + + /** + * 执行器 + * + * @param . + * @param . + * @param executor 执行器 + * @param uri 接口请求地址 + * @param data 参数或请求数据 + * @return T + * + * @throws WxErrorException the wx error exception + */ + T executeWithoutLog(RequestExecutor executor, String uri, E data) throws WxErrorException; + + /** + *
+   * 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试.
+   * 默认:1000ms
+   * 
+ * + * @param retrySleepMillis 重试等待毫秒数 + */ + void setRetrySleepMillis(int retrySleepMillis); + + /** + *
+   * 设置当微信系统响应系统繁忙时,最大重试次数.
+   * 默认:5次
+   * 
+ * + * @param maxRetryTimes 最大重试次数 + */ + void setMaxRetryTimes(int maxRetryTimes); + + /** + * WxChannelConfig对象 + * + * @return WxMaConfig wx channel config + */ + WxChannelConfig getConfig(); + + /** + * 注入 {@link WxChannelConfig} 的实现. + * + * @param config config + */ + void setConfig(WxChannelConfig config); + + /** + * 初始化http请求对象. + */ + void initHttp(); + + /** + * 请求http请求相关信息. + * + * @return . request http + */ + RequestHttp getRequestHttp(); +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAddressService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAddressService.java new file mode 100644 index 0000000000..063dd53948 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAddressService.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.channel.api; + + +import me.chanjar.weixin.channel.bean.address.AddressDetail; +import me.chanjar.weixin.channel.bean.address.AddressIdResponse; +import me.chanjar.weixin.channel.bean.address.AddressInfoResponse; +import me.chanjar.weixin.channel.bean.address.AddressListResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 地址管理服务 + * + * @author Zeyes + */ +public interface WxChannelAddressService { + + /** + * 获取地址列表 + * + * @param offset 起始位置 + * @param limit 拉取个数 + * @return 列表 + * + * @throws WxErrorException 异常 + */ + AddressListResponse listAddress(Integer offset, Integer limit) throws WxErrorException; + + /** + * 获取地址详情 + * + * @param addressId 地址id + * @return 地址详情 + * + * @throws WxErrorException 异常 + */ + AddressInfoResponse getAddress(String addressId) throws WxErrorException; + + /** + * 添加地址 + * + * @param addressDetail 地址 + * @return AddressIdResponse + * + * @throws WxErrorException 异常 + */ + AddressIdResponse addAddress(AddressDetail addressDetail) throws WxErrorException; + + /** + * 更新地址 + * + * @param addressDetail 地址 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateAddress(AddressDetail addressDetail) throws WxErrorException; + + /** + * 删除地址 + * + * @param addressId 地址id + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse deleteAddress(String addressId) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java new file mode 100644 index 0000000000..ac1e61729b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java @@ -0,0 +1,111 @@ +package me.chanjar.weixin.channel.api; + + +import java.util.List; +import me.chanjar.weixin.channel.bean.after.AfterSaleInfoResponse; +import me.chanjar.weixin.channel.bean.after.AfterSaleListResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.complaint.ComplaintOrderResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 售后服务接口 + * + * @author Zeyes + */ +public interface WxChannelAfterSaleService { + + /** + * 获取售后单列表 + * + * @param beginCreateTime 订单创建启始时间 unix时间戳 + * @param endCreateTime 订单创建结束时间,end_create_time减去begin_create_time不得大于24小时 + * @param nextKey 翻页参数,从第二页开始传,来源于上一页的返回值 + * @return 售后单列表 + * + * @throws WxErrorException 异常 + */ + AfterSaleListResponse listIds(Long beginCreateTime, Long endCreateTime, String nextKey) + throws WxErrorException; + + /** + * 获取售后单详情 + * + * @param afterSaleOrderId 售后单号 + * @return 售后单信息 + * + * @throws WxErrorException 异常 + */ + AfterSaleInfoResponse get(String afterSaleOrderId) throws WxErrorException; + + /** + * 同意退款 + * + * @param afterSaleOrderId 售后单号 + * @param addressId 同意退货时传入地址id + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse accept(String afterSaleOrderId, String addressId) throws WxErrorException; + + /** + * 拒绝售后 + * + * @param afterSaleOrderId 售后单号 + * @param rejectReason 拒绝原因 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse reject(String afterSaleOrderId, String rejectReason) throws WxErrorException; + + /** + * 上传退款凭证 + * + * @param afterSaleOrderId 售后单号 + * @param desc 退款凭证描述 + * @param certificates 退款凭证图片列表 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse uploadRefundEvidence(String afterSaleOrderId, String desc, List certificates) + throws WxErrorException; + + /** + * 商家补充纠纷单留言 + * + * @param complaintId 纠纷单号 + * @param content 留言内容,最多500字 + * @param mediaIds 图片media_id列表,所有留言总图片数量最多20张 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse addComplaintMaterial(String complaintId, String content, List mediaIds) + throws WxErrorException; + + /** + * 商家举证 + * + * @param complaintId 纠纷单号 + * @param content 举证内容,最多500字 + * @param mediaIds 图片media_id列表,所有留言总图片数量最多20张 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse addComplaintEvidence(String complaintId, String content, List mediaIds) + throws WxErrorException; + + /** + * 获取纠纷单 + * + * @param complaintId 纠纷单号 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + ComplaintOrderResponse getComplaint(String complaintId) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelBasicService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelBasicService.java new file mode 100644 index 0000000000..a687aaeb5c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelBasicService.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.channel.api; + +import java.io.File; +import me.chanjar.weixin.channel.bean.address.AddressCodeResponse; +import me.chanjar.weixin.channel.bean.image.ChannelImageInfo; +import me.chanjar.weixin.channel.bean.image.ChannelImageResponse; +import me.chanjar.weixin.channel.bean.image.QualificationFileResponse; +import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 基础接口 + * + * @author Zeyes + */ +public interface WxChannelBasicService { + + /** + * 获取店铺基本信息 + * + * @return 店铺基本信息 + */ + ShopInfoResponse getShopInfo() throws WxErrorException; + + /** + * 上传图片 + * + * @param respType 0:media_id和pay_media_id;1:图片链接(商品信息相关图片请务必使用此参数得到链接) + * @param imgUrl 图片url + * @return 图片信息 + * + * @throws WxErrorException 异常 + */ + ChannelImageInfo uploadImg(int respType, String imgUrl) throws WxErrorException; + + /** + * 上传图片 + * + * @param respType 0:media_id和pay_media_id;1:图片链接(商品信息相关图片请务必使用此参数得到链接) + * @param file 图片文件 + * @param height 图片的高,单位:像素 + * @param width 图片的宽,单位:像素 + * @return 图片信息 + * + * @throws WxErrorException 异常 + */ + ChannelImageInfo uploadImg(int respType, File file, int height, int width) throws WxErrorException; + + /** + * 上传资质图片 + * + * @param file 资质图片 + * @return 结果 + * + * @throws WxErrorException 异常 + */ + QualificationFileResponse uploadQualificationFile(File file) throws WxErrorException; + + /** + * 根据media_id获取图片 + * + * @param mediaId media_id + */ + ChannelImageResponse getImg(String mediaId) throws WxErrorException; + + /** + * 获取地址编码(最多获取4级) + * + * @param code 地址行政编码,不填或者填0时,拉取全国的省级行政编码 + * @return AddressCodeResponse + */ + AddressCodeResponse getAddressCode(Integer code) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelBrandService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelBrandService.java new file mode 100644 index 0000000000..905d354955 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelBrandService.java @@ -0,0 +1,103 @@ +package me.chanjar.weixin.channel.api; + + +import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.brand.Brand; +import me.chanjar.weixin.channel.bean.brand.BrandApplyListResponse; +import me.chanjar.weixin.channel.bean.brand.BrandInfoResponse; +import me.chanjar.weixin.channel.bean.brand.BrandListResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 品牌服务接口 + * + * @author Zeyes + */ +public interface WxChannelBrandService { + + /** + * 获取品牌库列表 + * + * @param pageSize 每页数量(默认10, 不超过50) + * @param nextKey 由上次请求返回, 记录翻页的上下文, 传入时会从上次返回的结果往后翻一页, 不传默认拉取第一页数据 + * @return 品牌库列表 + * + * @throws WxErrorException 异常 + */ + BrandListResponse listAllBrand(Integer pageSize, String nextKey) throws WxErrorException; + + /** + * 新增品牌资质 + * + * @param brand 品牌参数 + * @return 审核id + * + * @throws WxErrorException 异常 + */ + AuditApplyResponse addBrandApply(Brand brand) throws WxErrorException; + + /** + * 修改品牌资质 + * + * @param brand 品牌参数 + * @return 审核id + * + * @throws WxErrorException 异常 + */ + AuditApplyResponse updateBrandApply(Brand brand) throws WxErrorException; + + /** + * 撤回品牌资质审核 + * + * @param brandId 品牌id + * @param auditId 审核id + * @return 审核id + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse cancelBrandApply(String brandId, String auditId) throws WxErrorException; + + /** + * 删除品牌资质 + * + * @param brandId 品牌id + * @return 结果 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse deleteBrandApply(String brandId) throws WxErrorException; + + /** + * 获取品牌资质申请详情 + * + * @param brandId 品牌id + * @return 品牌信息 + * + * @throws WxErrorException 异常 + */ + BrandInfoResponse getBrandApply(String brandId) throws WxErrorException; + + /** + * 获取品牌资质申请列表 + * + * @param pageSize 每页数量(默认10, 不超过50) + * @param nextKey 由上次请求返回, 记录翻页的上下文, 传入时会从上次返回的结果往后翻一页, 不传默认拉取第一页数据 + * @param status 审核单状态, 不填默认拉全部商品 + * @return 品牌列表 + * + * @throws WxErrorException 异常 + */ + BrandApplyListResponse listBrandApply(Integer pageSize, String nextKey, Integer status) throws WxErrorException; + + /** + * 获取生效中的品牌资质列表 + * + * @param pageSize 每页数量(默认10, 不超过50) + * @param nextKey 由上次请求返回, 记录翻页的上下文, 传入时会从上次返回的结果往后翻一页, 不传默认拉取第一页数据 + * @return 品牌列表 + * + * @throws WxErrorException 异常 + */ + BrandApplyListResponse listValidBrandApply(Integer pageSize, String nextKey) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelCategoryService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelCategoryService.java new file mode 100644 index 0000000000..ddbc99e5d4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelCategoryService.java @@ -0,0 +1,93 @@ +package me.chanjar.weixin.channel.api; + +import java.io.File; +import java.util.List; +import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse; +import me.chanjar.weixin.channel.bean.audit.AuditResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.category.CategoryDetailResult; +import me.chanjar.weixin.channel.bean.category.CategoryQualificationResponse; +import me.chanjar.weixin.channel.bean.category.PassCategoryResponse; +import me.chanjar.weixin.channel.bean.category.ShopCategory; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 商品类目相关接口 + * + * @author Zeyes + */ +public interface WxChannelCategoryService { + + /** + * 获取所有的类目 + * + * @return 所有类目以及资质信息 + * + * @throws WxErrorException 异常 + */ + CategoryQualificationResponse listAllCategory() throws WxErrorException; + + /** + * 获取商品类目列表(全量) 有频率限制 + * + * @param parentId 类目父id + * @return 类目列表 + * + * @throws WxErrorException 异常 + */ + List listAvailableCategory(String parentId) throws WxErrorException; + + /** + * 获取类目信息 + * + * @param id 三级类目id + * @return 类目信息 + * + * @throws WxErrorException 异常 + */ + CategoryDetailResult getCategoryDetail(String id) throws WxErrorException; + + /** + * 上传类目资质 + * + * @param level1 一级类目ID + * @param level2 二级类目ID + * @param level3 三级类目ID + * @param certificate 资质材料,图片mediaid,图片类型,最多不超过10张 + * @return 审核id + * + * @throws WxErrorException 异常 + * @see WxChannelBasicService#uploadQualificationFile(File) + */ + AuditApplyResponse addCategory(String level1, String level2, String level3, List certificate) + throws WxErrorException; + + /** + * 取消类目提审 + * + * @param auditId 提交审核时返回的id + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse cancelCategoryAudit(String auditId) throws WxErrorException; + + /** + * 查询类目审核结果 + * + * @param auditId 审核id + * @return 审核结果 + * + * @throws WxErrorException 异常 + */ + AuditResponse getAudit(String auditId) throws WxErrorException; + + /** + * 获取账号申请通过的类目和资质信息 + * + * @return 类目和资质信息 + * + * @throws WxErrorException 异常 + */ + PassCategoryResponse listPassCategory() throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelCouponService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelCouponService.java new file mode 100644 index 0000000000..df59fdc8b9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelCouponService.java @@ -0,0 +1,92 @@ +package me.chanjar.weixin.channel.api; + +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponIdResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponInfoResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponListParam; +import me.chanjar.weixin.channel.bean.coupon.CouponListResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponParam; +import me.chanjar.weixin.channel.bean.coupon.UserCouponListParam; +import me.chanjar.weixin.channel.bean.coupon.UserCouponListResponse; +import me.chanjar.weixin.channel.bean.coupon.UserCouponResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 优惠券服务 + * + * @author Zeyes + */ +public interface WxChannelCouponService { + + /** + * 创建优惠券 + * + * @param coupon 优惠券 + * @return 优惠券ID + * + * @throws WxErrorException 异常 + */ + CouponIdResponse createCoupon(CouponParam coupon) throws WxErrorException; + + /** + * 更新优惠券 + * + * @param coupon 优惠券 + * @return 优惠券ID + * + * @throws WxErrorException 异常 + */ + CouponIdResponse updateCoupon(CouponParam coupon) throws WxErrorException; + + /** + * 更新优惠券状态 + * + * @param couponId 优惠券ID + * @param status 状态 2生效 4已作废 5删除 {@link me.chanjar.weixin.channel.enums.WxCouponStatus} + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateCouponStatus(String couponId, Integer status) throws WxErrorException; + + /** + * 获取优惠券详情 + * + * @param couponId 优惠券ID + * @return CouponInfoResponse + * + * @throws WxErrorException 异常 + */ + CouponInfoResponse getCoupon(String couponId) throws WxErrorException; + + /** + * 获取优惠券ID列表 + * + * @param param 条件参数 + * @return 优惠券ID列表 + * + * @throws WxErrorException 异常 + */ + CouponListResponse getCouponList(CouponListParam param) throws WxErrorException; + + /** + * 获取用户优惠券 + * + * @param openId 用户openid + * @param userCouponId 用户优惠券ID + * @return UserCouponResponse + * + * @throws WxErrorException 异常 + */ + UserCouponResponse getUserCoupon(String openId, String userCouponId) throws WxErrorException; + + /** + * 获取用户优惠券ID列表 + * + * @param param 条件参数 + * @return UserCouponListResponse + * + * @throws WxErrorException 异常 + */ + UserCouponListResponse getUserCouponList(UserCouponListParam param) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelFreightTemplateService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelFreightTemplateService.java new file mode 100644 index 0000000000..188b33464b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelFreightTemplateService.java @@ -0,0 +1,57 @@ +package me.chanjar.weixin.channel.api; + + +import me.chanjar.weixin.channel.bean.freight.FreightTemplate; +import me.chanjar.weixin.channel.bean.freight.TemplateIdResponse; +import me.chanjar.weixin.channel.bean.freight.TemplateInfoResponse; +import me.chanjar.weixin.channel.bean.freight.TemplateListResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 运费模板服务接口 + * + * @author Zeyes + */ +public interface WxChannelFreightTemplateService { + + /** + * 获取运费模板列表 + * + * @param offset 起始位置 + * @param limit 拉取个数 + * @return 列表 + * + * @throws WxErrorException 异常 + */ + TemplateListResponse listTemplate(Integer offset, Integer limit) throws WxErrorException; + + /** + * 获取运费模板 + * + * @param templateId 模板id + * @return 运费模板 + * + * @throws WxErrorException 异常 + */ + TemplateInfoResponse getTemplate(String templateId) throws WxErrorException; + + /** + * 添加运费模板 + * + * @param template 运费模板 + * @return TemplateIdResponse + * + * @throws WxErrorException 异常 + */ + TemplateIdResponse addTemplate(FreightTemplate template) throws WxErrorException; + + /** + * 更新运费模板 + * + * @param template 运费模板 + * @return TemplateIdResponse + * + * @throws WxErrorException 异常 + */ + TemplateIdResponse updateTemplate(FreightTemplate template) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelFundService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelFundService.java new file mode 100644 index 0000000000..cb0f5aab79 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelFundService.java @@ -0,0 +1,189 @@ +package me.chanjar.weixin.channel.api; + + +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.fund.AccountInfo; +import me.chanjar.weixin.channel.bean.fund.AccountInfoResponse; +import me.chanjar.weixin.channel.bean.fund.BalanceInfoResponse; +import me.chanjar.weixin.channel.bean.fund.FlowListResponse; +import me.chanjar.weixin.channel.bean.fund.FundsFlowResponse; +import me.chanjar.weixin.channel.bean.fund.FundsListParam; +import me.chanjar.weixin.channel.bean.fund.WithdrawDetailResponse; +import me.chanjar.weixin.channel.bean.fund.WithdrawListResponse; +import me.chanjar.weixin.channel.bean.fund.WithdrawSubmitResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankCityResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankInfoResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankListResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankProvinceResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BranchInfoResponse; +import me.chanjar.weixin.channel.bean.fund.qrcode.QrCheckResponse; +import me.chanjar.weixin.channel.bean.fund.qrcode.QrCodeResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 资金相关服务 + * + * @author Zeyes + */ +public interface WxChannelFundService { + + /** + * 获取账户余额 + * + * @return 账户余额 + * + * @throws WxErrorException 异常 + */ + BalanceInfoResponse getBalance() throws WxErrorException; + + /** + * 获取结算账户 + * + * @return 结算账户 + * + * @throws WxErrorException 异常 + */ + AccountInfoResponse getBankAccount() throws WxErrorException; + + /** + * 获取资金流水详情 + * + * @param flowId 资金流水号 + * @return 资金流水详情 + * + * @throws WxErrorException 异常 + */ + FundsFlowResponse getFundsFlowDetail(String flowId) throws WxErrorException; + + /** + * 获取资金流水列表 + * + * @param param 资金流水列表参数 + * @return 资金流水列表 + * + * @throws WxErrorException 异常 + */ + FlowListResponse listFundsFlow(FundsListParam param) throws WxErrorException; + + /** + * 获取提现记录 + * + * @param withdrawId 提现单号 + * @return 提现记录 + * + * @throws WxErrorException 异常 + */ + WithdrawDetailResponse getWithdrawDetail(String withdrawId) throws WxErrorException; + + /** + * 获取提现记录列表 + * + * @param pageNum 页码 + * @param pageSize 每页大小 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 提现记录列表 + * + * @throws WxErrorException 异常 + */ + WithdrawListResponse listWithdraw(Integer pageNum, Integer pageSize, Long startTime, Long endTime) + throws WxErrorException; + + /** + * 修改结算账户 + * + * @param accountInfo 结算账户信息 + * @return 修改结果 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse setBankAccount(AccountInfo accountInfo) throws WxErrorException; + + /*** + * 商户提现 + * + * @param amount 提现金额(单位:分) + * @param remark 提现备注 + * @param bankMemo 银行附言 + * @return 提现结果 + * @throws WxErrorException 异常 + */ + WithdrawSubmitResponse submitWithdraw(Integer amount, String remark, String bankMemo) throws WxErrorException; + + /** + * 根据卡号查银行信息 + * + * @param accountNumber 卡号 + * @return 银行信息 + * + * @throws WxErrorException 异常 + */ + BankInfoResponse getBankInfoByCardNo(String accountNumber) throws WxErrorException; + + /** + * 搜索银行列表 + * + * @param offset 偏移量 + * @param limit 每页数据大小 + * @param keywords 银行关键字 + * @param bankType 银行类型(1:对私银行,2:对公银行; 默认对公) + * @return 银行列表 + * + * @throws WxErrorException 异常 + */ + BankListResponse searchBankList(Integer offset, Integer limit, String keywords, Integer bankType) + throws WxErrorException; + + /** + * 查询城市列表 + * + * @param provinceCode 省份编码 + * @return 城市列表 + * + * @throws WxErrorException 异常 + */ + BankCityResponse searchCityList(String provinceCode) throws WxErrorException; + + /** + * 查询大陆银行省份列表 + * + * @return 省份列表 + * + * @throws WxErrorException 异常 + */ + BankProvinceResponse getProvinceList() throws WxErrorException; + + /** + * 查询支行列表 + * + * @param bankCode 银行编码 + * @param cityCode 城市编码 + * @param offset 偏移量 + * @param limit 每页数据大小 + * @return 支行列表 + * + * @throws WxErrorException 异常 + */ + BranchInfoResponse searchBranchList(String bankCode, String cityCode, Integer offset, Integer limit) + throws WxErrorException; + + /** + * 获取二维码 + * + * @param qrcodeTicket 二维码ticket + * @return 二维码响应 + * + * @throws WxErrorException 异常 + */ + QrCodeResponse getQrCode(String qrcodeTicket) throws WxErrorException; + + /** + * 查询扫码状态 + * + * @param qrcodeTicket 二维码ticket + * @return 扫码状态 + * + * @throws WxErrorException 异常 + */ + QrCheckResponse checkQrStatus(String qrcodeTicket) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelOrderService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelOrderService.java new file mode 100644 index 0000000000..6179510e78 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelOrderService.java @@ -0,0 +1,146 @@ +package me.chanjar.weixin.channel.api; + +import java.util.List; +import me.chanjar.weixin.channel.bean.base.AddressInfo; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.delivery.DeliveryCompanyResponse; +import me.chanjar.weixin.channel.bean.delivery.DeliveryInfo; +import me.chanjar.weixin.channel.bean.order.ChangeOrderInfo; +import me.chanjar.weixin.channel.bean.order.DeliveryUpdateParam; +import me.chanjar.weixin.channel.bean.order.OrderInfoResponse; +import me.chanjar.weixin.channel.bean.order.OrderListParam; +import me.chanjar.weixin.channel.bean.order.OrderListResponse; +import me.chanjar.weixin.channel.bean.order.OrderSearchParam; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 订单服务接口 + * + * @author Zeyes + * @link 订单接口文档 + */ +public interface WxChannelOrderService { + + /** + * 获取订单 + * + * @param orderId 订单id + * @return 订单详情 + * + * @throws WxErrorException 异常 + */ + OrderInfoResponse getOrder(String orderId) throws WxErrorException; + + /** + * 获取订单列表 + * + * @param param 搜索条件 + * @return 订单列表 + * + * @throws WxErrorException 异常 + */ + OrderListResponse getOrders(OrderListParam param) throws WxErrorException; + + /** + * 订单搜索 + * + * @param param 搜索条件 + * @return 订单列表 + * + * @throws WxErrorException 异常 + */ + OrderListResponse searchOrder(OrderSearchParam param) throws WxErrorException; + + /** + * 更改订单价格 + * + * @param orderId 订单id + * @param expressFee 运费价格(以分为单位)(不填不改) + * @param changeOrderInfos 改价列表 + * @return 结果 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updatePrice(String orderId, Integer expressFee, List changeOrderInfos) + throws WxErrorException; + + /** + * 更改订单备注 + * + * @param orderId 订单id + * @param merchantNotes 备注 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateRemark(String orderId, String merchantNotes) throws WxErrorException; + + /** + * 更新订单地址 + * + * @param orderId 订单id + * @param userAddress 用户地址 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateAddress(String orderId, AddressInfo userAddress) throws WxErrorException; + + /** + * 修改物流信息
发货完成的订单可以修改,最多修改1次 拆包发货的订单暂不允许修改物流 虚拟商品订单暂不允许修改物流 + * + * @param param 物流信息 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateDelivery(DeliveryUpdateParam param) throws WxErrorException; + + /** + * 同意用户修改收货地址请求 + * + * @param orderId 订单id + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse acceptAddressModify(String orderId) throws WxErrorException; + + /** + * 拒接用户修改收货地址请求 + * + * @param orderId 订单id + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse rejectAddressModify(String orderId) throws WxErrorException; + + /** + * 关闭订单 (需要订单状态为未付款状态) + * + * @param orderId 订单id + * @return BaseResponse + */ + WxChannelBaseResponse closeOrder(String orderId); + + /** + * 获取快递公司列表 + * + * @return 快递公司列表 + * + * @throws WxErrorException 异常 + */ + DeliveryCompanyResponse listDeliveryCompany() throws WxErrorException; + + /** + * 订单发货 + * + * @param orderId 订单id + * @param deliveryList 物流信息 + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse deliveryOrder(String orderId, List deliveryList) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java new file mode 100644 index 0000000000..b962b9ec85 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java @@ -0,0 +1,171 @@ +package me.chanjar.weixin.channel.api; + + +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskParam; +import me.chanjar.weixin.channel.bean.product.SkuStockResponse; +import me.chanjar.weixin.channel.bean.product.SpuGetResponse; +import me.chanjar.weixin.channel.bean.product.SpuInfo; +import me.chanjar.weixin.channel.bean.product.SpuListResponse; +import me.chanjar.weixin.channel.bean.product.SpuUpdateResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 商品服务接口 + * + * @author Zeyes + */ +public interface WxChannelProductService { + + /** + * 添加商品 + * + * @param info 商品信息 + * @return 返回商品的状态和id + * + * @throws WxErrorException 异常 + */ + SpuUpdateResponse addProduct(SpuInfo info) throws WxErrorException; + + /** + * 更新商品 + * + * @param info 商品信息 + * @return 返回商品的状态和id + * + * @throws WxErrorException 异常 + */ + SpuUpdateResponse updateProduct(SpuInfo info) throws WxErrorException; + + /** + * 更新商品库存 (仅对edit_status != 2 的商品适用,其他状态的商品无法通过该接口修改库存) + * + * @param productId 内部商品ID + * @param skuId 内部sku_id + * @param diffType 修改类型 1增加 2减少 3设置 + * @param num 增加、减少或者设置的库存值 + * @return WxChannelBaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffType, Integer num) + throws WxErrorException; + + /** + * 删除商品 + * + * @param productId 商品ID + * @return 是否成功 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse deleteProduct(String productId) throws WxErrorException; + + /** + * 撤回商品审核 + * + * @param productId 商品ID + * @return 是否成功 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse cancelProductAudit(String productId) throws WxErrorException; + + /** + * 获取商品 + * + * @param productId 商品ID + * @param dataType 默认取1 1:获取线上数据 2:获取草稿数据 3:同时获取线上和草稿数据(注意:需成功上架后才有线上数据) + * @return 商品信息 + * + * @throws WxErrorException 异常 + */ + SpuGetResponse getProduct(String productId, Integer dataType) throws WxErrorException; + + /** + * 获取商品列表 + * + * @param pageSize 每页数量(默认10,不超过30) + * @param nextKey 由上次请求返回,记录翻页的上下文。传入时会从上次返回的结果往后翻一页,不传默认拉取第一页数据。 + * @param status 商品状态,不填默认拉全部商品(不包含回收站) {@link me.chanjar.weixin.channel.enums.SpuStatus} + * @return List + * + * @throws WxErrorException 异常 + */ + SpuListResponse listProduct(Integer pageSize, String nextKey, Integer status) throws WxErrorException; + + /** + * 上架商品 + * + * @param productId 商品ID + * @return 是否成功 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse upProduct(String productId) throws WxErrorException; + + /** + * 下架商品 + * + * @param productId 商品ID + * @return 是否成功 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse downProduct(String productId) throws WxErrorException; + + /** + * 获取商品实时库存 + * + * @param productId 商品ID + * @param skuId skuId + * @return SkuStockResponse + * + * @throws WxErrorException 异常 + */ + SkuStockResponse getSkuStock(String productId, String skuId) throws WxErrorException; + + /** + * 添加限时抢购任务 + * + * @param param 限时抢购任务 + * @return LimitTaskAddResponse + * + * @throws WxErrorException 异常 + */ + LimitTaskAddResponse addLimitTask(LimitTaskParam param) throws WxErrorException; + + /** + * 拉取限时抢购任务列表 + * + * @param pageSize 每页数量(默认10,不超过50) + * @param nextKey 由上次请求返回,记录翻页的上下文。传入时会从上次返回的结果往后翻一页,不传默认拉取第一页数据 + * @param status 抢购活动状态 + * @return LimitTaskListResponse + * + * @throws WxErrorException 异常 + */ + LimitTaskListResponse listLimitTask(Integer pageSize, String nextKey, Integer status) throws WxErrorException; + + /** + * 停止限时抢购任务 + * + * @param taskId 限时抢购任务ID + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse stopLimitTask(String taskId) throws WxErrorException; + + /** + * 停止限时抢购任务 + * + * @param taskId 限时抢购任务ID + * @return BaseResponse + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse deleteLimitTask(String taskId) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java new file mode 100644 index 0000000000..8f960f4795 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java @@ -0,0 +1,122 @@ +package me.chanjar.weixin.channel.api; + +/** + * The interface Wx Channel service + * + * @author Zeyes + */ +public interface WxChannelService extends BaseWxChannelService { + + /** + * 基础接口服务 + * + * @return 基础接口服务 + */ + WxChannelBasicService getBasicService(); + + /** + * 商品类目服务 + * + * @return 商品类目服务 + */ + WxChannelCategoryService getCategoryService(); + + /** + * 品牌服务 + * + * @return 品牌服务 + */ + WxChannelBrandService getBrandService(); + + /** + * 商品服务 + * + * @return 商品服务 + */ + WxChannelProductService getProductService(); + + /** + * 仓库服务 + * + * @return 仓库服务 + */ + WxChannelWarehouseService getWarehouseService(); + + /** + * 订单服务 + * + * @return 订单服务 + */ + WxChannelOrderService getOrderService(); + + /** + * 售后服务 + * + * @return 售后服务 + */ + WxChannelAfterSaleService getAfterSaleService(); + + /** + * 运费模板服务 + * + * @return 运费模板服务 + */ + WxChannelFreightTemplateService getFreightTemplateService(); + + /** + * 地址服务 + * + * @return 地址服务 + */ + WxChannelAddressService getAddressService(); + + /** + * 优惠券服务 + * + * @return 优惠券服务 + */ + WxChannelCouponService getCouponService(); + + /** + * 分享员服务 + * + * @return 分享员服务 + */ + WxChannelSharerService getSharerService(); + + /** + * 资金服务 + * + * @return 资金服务 + */ + WxChannelFundService getFundService(); + + /** + * 优选联盟-团长合作达人管理服务 + * + * @return 团长合作达人管理服务 + */ + WxLeagueWindowService getLeagueWindowService(); + + /** + * 优选联盟-团长服务 + * + * @return 团长服务 + */ + WxLeagueSupplierService getLeagueSupplierService(); + + /** + * 优选联盟-达人服务 + * + * @return 达人服务 + */ + WxLeaguePromoterService getLeaguePromoterService(); + + /** + * 优选联盟-商品服务 + * + * @return 商品服务 + */ + WxLeagueProductService getLeagueProductService(); + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSharerService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSharerService.java new file mode 100644 index 0000000000..300493158b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSharerService.java @@ -0,0 +1,71 @@ +package me.chanjar.weixin.channel.api; + +import java.util.List; +import me.chanjar.weixin.channel.bean.sharer.SharerBindResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerInfoResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerOrderParam; +import me.chanjar.weixin.channel.bean.sharer.SharerOrderResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerSearchResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerUnbindResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 分享员服务接口 + * + * @author Zeyes + */ +public interface WxChannelSharerService { + + /** + * 邀请分享员 + * + * @param username 邀请的用户微信号 + * @return SharerBindResponse + * + * @throws WxErrorException 异常 + */ + SharerBindResponse bindSharer(String username) throws WxErrorException; + + /** + * 获取绑定的分享员 + * + * @param openid 分享员openid + * @param username 分享员微信号(二选一) + * @return SharerSearchResponse + * + * @throws WxErrorException 异常 + */ + SharerSearchResponse searchSharer(String openid, String username) throws WxErrorException; + + /** + * 获取绑定的分享员列表 + * + * @param page 分页参数,页数 + * @param pageSize 分页参数,每页分享员数(不超过100 + * @param sharerType 分享员类型 + * @return 分享员列表 + * + * @throws WxErrorException 异常 + */ + SharerInfoResponse listSharer(Integer page, Integer pageSize, Integer sharerType) throws WxErrorException; + + /** + * 获取分享员订单列表 + * + * @param param 参数 + * @return 列表 + * + * @throws WxErrorException 异常 + */ + SharerOrderResponse listSharerOrder(SharerOrderParam param) throws WxErrorException; + + /** + * 解绑分享员 + * + * @param openIds openid列表 + * @return 状态 + * + * @throws WxErrorException 异常 + */ + SharerUnbindResponse unbindSharer(List openIds) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelWarehouseService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelWarehouseService.java new file mode 100644 index 0000000000..1bb00885f5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelWarehouseService.java @@ -0,0 +1,137 @@ +package me.chanjar.weixin.channel.api; + + +import java.util.List; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.warehouse.LocationPriorityResponse; +import me.chanjar.weixin.channel.bean.warehouse.PriorityLocationParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseIdsResponse; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseLocation; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseResponse; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockResponse; +import me.chanjar.weixin.common.error.WxErrorException; + + +/** + * 视频号小店 区域仓库服务 + * + * @author Zeyes + */ +public interface WxChannelWarehouseService { + + /** + * 创建仓库 + * + * @param param 仓库信息 + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse createWarehouse(WarehouseParam param) throws WxErrorException; + + /** + * 查询仓库列表 + * + * @param pageSize 每页数量(最大不超过10) + * @param nextKey 由上次请求返回,记录翻页的上下文。传入时会从上次返回的结果往后翻一页,不传默认拉取第一页数据 + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WarehouseIdsResponse listWarehouse(Integer pageSize, String nextKey) throws WxErrorException; + + /** + * 获取仓库详情 + * + * @param outWarehouseId 外部仓库ID + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WarehouseResponse getWarehouse(String outWarehouseId) throws WxErrorException; + + /** + * 修改仓库详情 + * + * @param outWarehouseId 外部仓库ID + * @param name 仓库名称 + * @param intro 仓库介绍 + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateWarehouse(String outWarehouseId, String name, String intro) throws WxErrorException; + + /** + * 批量增加覆盖区域 + * + * @param outWarehouseId 外部仓库ID + * @param coverLocations 覆盖区域 + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse addWarehouseArea(String outWarehouseId, List coverLocations) + throws WxErrorException; + + /** + * 批量删除覆盖区域 + * + * @param outWarehouseId 外部仓库ID + * @param coverLocations 覆盖区域 + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse deleteWarehouseArea(String outWarehouseId, List coverLocations) + throws WxErrorException; + + /** + * 设置指定地址下的仓的优先级 + * + * @param param 参数 + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse setWarehousePriority(PriorityLocationParam param) throws WxErrorException; + + /** + * 获取指定地址下的仓的优先级 + * + * @param addressId1 省份地址编码 + * @param addressId2 市地址编码 + * @param addressId3 区地址编码 + * @param addressId4 街道地址编码 + * @return 仓的优先级 + * + * @throws WxErrorException 异常 + */ + LocationPriorityResponse getWarehousePriority(Integer addressId1, Integer addressId2, Integer addressId3, + Integer addressId4) throws WxErrorException; + + /** + * 更新区域仓库存数量 + * + * @param param 参数 + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse updateWarehouseStock(WarehouseStockParam param) throws WxErrorException; + + /** + * 获取区域仓库存数量 + * + * @param productId 商品ID + * @param outWarehouseId 外部仓库ID + * @param skuId 商品skuId + * @return 响应 + * + * @throws WxErrorException 异常 + */ + WarehouseStockResponse getWarehouseStock(String productId, String skuId, String outWarehouseId) + throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueProductService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueProductService.java new file mode 100644 index 0000000000..d8d6781505 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueProductService.java @@ -0,0 +1,62 @@ +package me.chanjar.weixin.channel.api; + +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.product.BatchAddParam; +import me.chanjar.weixin.channel.bean.league.product.BatchAddResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductDetailParam; +import me.chanjar.weixin.channel.bean.league.product.ProductDetailResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductListParam; +import me.chanjar.weixin.channel.bean.league.product.ProductListResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductUpdateParam; +import me.chanjar.weixin.channel.bean.league.product.ProductUpdateResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 优选联盟 商品操作服务 + * + * @author Zeyes + */ +public interface WxLeagueProductService { + + /** + * 批量新增联盟商品 + * + * @param param 参数 + * @return 结果 + */ + BatchAddResponse batchAddProduct(BatchAddParam param) throws WxErrorException; + + /** + * 更新联盟商品信息 + * + * @param param 参数 + * @return 结果 + */ + ProductUpdateResponse updateProduct(ProductUpdateParam param) throws WxErrorException; + + /** + * 删除联盟商品 + * + * @param type 1普通推广商品 2定向推广商品 3专属推广商品 + * @param productId 商品id type为普通推广商品时必填 + * @param infoId 特殊推广商品计划id type为特殊推广商品时必填 + * @return + */ + WxChannelBaseResponse deleteProduct(Integer type, String productId, String infoId) throws WxErrorException; + + /** + * 拉取联盟商品详情 + * + * @param param 参数 + * @return 结果 + */ + ProductDetailResponse getProductDetail(ProductDetailParam param) throws WxErrorException; + + /** + * 拉取联盟商品推广列表 + * + * @param param 参数 + * @return 结果 + */ + ProductListResponse listProduct(ProductListParam param) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeaguePromoterService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeaguePromoterService.java new file mode 100644 index 0000000000..8a8ffb9acf --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeaguePromoterService.java @@ -0,0 +1,57 @@ +package me.chanjar.weixin.channel.api; + +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.promoter.PromoterInfoResponse; +import me.chanjar.weixin.channel.bean.league.promoter.PromoterListResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 优选联盟 达人服务 + * + * @author Zeyes + */ +public interface WxLeaguePromoterService { + + /** + * 新增达人 + * + * @param finderId 视频号finder_id + * @return 结果 + */ + WxChannelBaseResponse addPromoter(String finderId) throws WxErrorException; + + /** + * 编辑达人 + * + * @param finderId 视频号finder_id + * @param type 操作 1取消邀请 2结束合作 + * @return 结果 + */ + WxChannelBaseResponse updatePromoter(String finderId, int type) throws WxErrorException; + + /** + * 删除达人 + * + * @param finderId 视频号finder_id + * @return 结果 + */ + WxChannelBaseResponse deletePromoter(String finderId) throws WxErrorException; + + /** + * 获取达人详情信息 + * + * @param finderId 视频号finder_id + * @return 结果 + */ + PromoterInfoResponse getPromoterInfo(String finderId) throws WxErrorException; + + /** + * 获取达人列表 + * + * @param pageIndex 页面下标,下标从1开始,默认为1 + * @param pageSize 单页达人数(不超过200) + * @param status 拉取该状态下的达人列表 + * @return 结果 + */ + PromoterListResponse listPromoter(Integer pageIndex, Integer pageSize, Integer status) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueSupplierService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueSupplierService.java new file mode 100644 index 0000000000..cde96843f1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueSupplierService.java @@ -0,0 +1,98 @@ +package me.chanjar.weixin.channel.api; + +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListParam; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductResponse; +import me.chanjar.weixin.channel.bean.league.supplier.FlowListParam; +import me.chanjar.weixin.channel.bean.league.supplier.ShopDetailResponse; +import me.chanjar.weixin.channel.bean.league.supplier.ShopListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierBalanceResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowDetailResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowListResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 优选联盟 团长数据服务 + * + * @author Zeyes + */ +public interface WxLeagueSupplierService { + + /** + * 获取团长账户余额 + * + * @return 余额 + */ + SupplierBalanceResponse getBalanceInfo() throws WxErrorException; + + /** + * 获取资金流水详情 + * + * @param flowId 流水ID + * @return 流水详情 + */ + SupplierFlowDetailResponse getFlowDetail(String flowId) throws WxErrorException; + + /** + * 获取团长资金流水列表 + * + * @param param 查询参数 + * @return 流水列表 + */ + SupplierFlowListResponse getFlowList(FlowListParam param) throws WxErrorException; + + /** + * 获取合作商品详情 + * + * @param productId 商品ID + * @param appId 团长商品 所属小店appid + * @return 商品详情 + */ + CoopProductResponse getProductDetail(String productId, String appId) throws WxErrorException; + + /** + * 获取合作商品列表 + * + * @param appid 团长商品 所属小店appid + * @param pageSize 单页商品数(不超过30) + * @param nextKey 由上次请求返回,顺序翻页时需要传入, 会从上次返回的结果往后翻一页 + * @return 商品列表 + */ + CoopProductListResponse getProductList(String appid, Integer pageSize, String nextKey) throws WxErrorException; + + /** + * 获取佣金单详情 + * + * @param orderId 订单号,可从获取佣金单列表中获得 + * @param skuId 商品skuId + * @return 订单详情 + */ + CommissionOrderResponse getCommissionOrder(String orderId, String skuId) throws WxErrorException; + + /** + * 获取佣金单列表 + * + * @param param 查询参数 + * @return 佣金单列表 + */ + CommissionOrderListResponse getCommissionOrderList(CommissionOrderListParam param) throws WxErrorException; + + /** + * 获取合作小店详情 + * + * @param appid 小店appid + * @return 小店详情 + */ + ShopDetailResponse getShopDetail(String appid) throws WxErrorException; + + /** + * 获取合作小店列表 + * + * @param pageSize 单页小店数(不超过30) + * @param nextKey 由上次请求返回,顺序翻页时需要传入, 会从上次返回的结果往后翻一页 + * @return 小店列表 + */ + ShopListResponse getShopList(Integer pageSize, String nextKey) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueWindowService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueWindowService.java new file mode 100644 index 0000000000..c4af1571d0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxLeagueWindowService.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.channel.api; + +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.window.AuthInfoResponse; +import me.chanjar.weixin.channel.bean.league.window.AuthStatusResponse; +import me.chanjar.weixin.channel.bean.league.window.ProductSearchParam; +import me.chanjar.weixin.channel.bean.league.window.WindowProductListResponse; +import me.chanjar.weixin.channel.bean.league.window.WindowProductResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 优选联盟 团长合作达人管理服务 + * + * @author Zeyes + */ +public interface WxLeagueWindowService { + + /** + * 添加团长商品到橱窗 + * + * @param appid 团长appid + * @param openfinderid 视频号openfinderid + * @param productId 团长商品ID + * @return 结果 + */ + WxChannelBaseResponse addProduct(String appid, String openfinderid, String productId) throws WxErrorException; + + /** + * 查询橱窗上团长商品列表 + * + * @param param 查询参数 + * @return 团长商品列表 + */ + WindowProductListResponse listProduct(ProductSearchParam param) throws WxErrorException; + + /** + * 从橱窗移除团长商品 + * + * @param appid 团长appid + * @param openfinderid 视频号openfinderid + * @param productId 团长商品ID + * @return 结果 + */ + WxChannelBaseResponse removeProduct(String appid, String openfinderid, String productId) throws WxErrorException; + + /** + * 查询橱窗上团长商品详情 + * + * @param appid 团长appid + * @param openfinderid 视频号openfinderid + * @param productId 团长商品ID + * @return 结果 + */ + WindowProductResponse getProductDetail(String appid, String openfinderid, String productId) + throws WxErrorException; + + /** + * 获取达人橱窗授权链接 + * + * @param finderId 视频号finder_id + * @return 授权链接 + */ + AuthInfoResponse getWindowAuthInfo(String finderId) throws WxErrorException; + + /** + * 获取达人橱窗授权状态 + * + * @param finderId 视频号finder_id + * @return 授权链接 + */ + AuthStatusResponse getWindowAuthStatus(String finderId) throws WxErrorException; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java new file mode 100644 index 0000000000..008da958a9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java @@ -0,0 +1,343 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ACCOUNT_NOTIFY; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.AFTER_SALE_UPDATE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.BRAND; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.COMPLAINT_NOTIFY; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.CREATE_COUPON; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.DELETE_COUPON; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.EXPIRE_COUPON; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.INVALID_COUPON; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_CANCEL; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_CONFIRM; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_DELIVER; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_EXT_INFO_UPDATE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_NEW; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_PAY; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_SETTLE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.ORDER_STATUS_UPDATE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.PRODUCT_CATEGORY_AUDIT; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.PRODUCT_SPU_AUDIT; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.PRODUCT_SPU_STATUS_UPDATE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.PRODUCT_SPU_UPDATE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.QRCODE_STATUS; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.RECEIVE_COUPON; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.SUPPLIER_ITEM_UPDATE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.UPDATE_COUPON_INFO; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.USER_COUPON_EXPIRE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.USER_COUPON_UNUSE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.USER_COUPON_USE; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.WITHDRAW_NOTIFY; + +import java.util.Map; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.BaseWxChannelMessageService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.message.after.AfterSaleMessage; +import me.chanjar.weixin.channel.bean.message.after.ComplaintMessage; +import me.chanjar.weixin.channel.bean.message.coupon.CouponActionMessage; +import me.chanjar.weixin.channel.bean.message.coupon.CouponReceiveMessage; +import me.chanjar.weixin.channel.bean.message.coupon.UserCouponExpireMessage; +import me.chanjar.weixin.channel.bean.message.fund.AccountNotifyMessage; +import me.chanjar.weixin.channel.bean.message.fund.QrNotifyMessage; +import me.chanjar.weixin.channel.bean.message.fund.WithdrawNotifyMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderCancelMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderConfirmMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderDeliveryMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderExtMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderIdMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderPayMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderSettleMessage; +import me.chanjar.weixin.channel.bean.message.order.OrderStatusMessage; +import me.chanjar.weixin.channel.bean.message.product.BrandMessage; +import me.chanjar.weixin.channel.bean.message.product.CategoryAuditMessage; +import me.chanjar.weixin.channel.bean.message.product.SpuAuditMessage; +import me.chanjar.weixin.channel.bean.message.supplier.SupplierItemMessage; +import me.chanjar.weixin.channel.message.WxChannelMessage; +import me.chanjar.weixin.channel.message.WxChannelMessageRouter; +import me.chanjar.weixin.channel.message.WxChannelMessageRouterRule; +import me.chanjar.weixin.channel.message.rule.HandlerConsumer; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.common.session.WxSessionManager; + +/** + * @author Zeyes + */ +@Slf4j +public class BaseWxChannelMessageServiceImpl implements BaseWxChannelMessageService { + + /** 消息路由器 */ + protected WxChannelMessageRouter router; + + public BaseWxChannelMessageServiceImpl(WxChannelMessageRouter router) { + this.router = router; + this.addDefaultRule(); + } + + /** + * 添加默认的回调规则 + */ + protected void addDefaultRule() { + /* 品牌资质事件回调 */ + this.addRule(BrandMessage.class, BRAND, this::brandUpdate); + /* 商品审核结果 */ + this.addRule(SpuAuditMessage.class, PRODUCT_SPU_AUDIT, this::spuAudit); + /* 商品上下架 */ + this.addRule(SpuAuditMessage.class, PRODUCT_SPU_STATUS_UPDATE, this::spuStatusUpdate); + /* 商品更新 */ + this.addRule(SpuAuditMessage.class, PRODUCT_SPU_UPDATE, this::spuUpdate); + /* 类目审核结果 */ + this.addRule(CategoryAuditMessage.class, PRODUCT_CATEGORY_AUDIT, this::categoryAudit); + /* 订单下单 */ + this.addRule(OrderIdMessage.class, ORDER_NEW, this::orderNew); + /* 订单取消 */ + this.addRule(OrderCancelMessage.class, ORDER_CANCEL, this::orderCancel); + /* 订单支付成功 */ + this.addRule(OrderPayMessage.class, ORDER_PAY, this::orderPay); + /* 订单发货 */ + this.addRule(OrderDeliveryMessage.class, ORDER_DELIVER, this::orderDelivery); + /* 订单确认收货 */ + this.addRule(OrderConfirmMessage.class, ORDER_CONFIRM, this::orderConfirm); + /* 订单结算成功 */ + this.addRule(OrderSettleMessage.class, ORDER_SETTLE, this::orderSettle); + /* 订单其他信息更新 */ + this.addRule(OrderExtMessage.class, ORDER_EXT_INFO_UPDATE, this::orderExtInfoUpdate); + /* 订单状态更新 */ + this.addRule(OrderStatusMessage.class, ORDER_STATUS_UPDATE, this::orderStatusUpdate); + /* 售后单更新通知 */ + this.addRule(AfterSaleMessage.class, AFTER_SALE_UPDATE, this::afterSaleStatusUpdate); + /* 纠纷更新通知 */ + this.addRule(ComplaintMessage.class, COMPLAINT_NOTIFY, this::complaintNotify); + /* 优惠券领取通知 */ + this.addRule(CouponReceiveMessage.class, RECEIVE_COUPON, this::couponReceive); + /* 优惠券使用通知 */ + this.addRule(CouponActionMessage.class, CREATE_COUPON, this::couponCreate); + /* 优惠券删除通知 */ + this.addRule(CouponActionMessage.class, DELETE_COUPON, this::couponDelete); + /* 优惠券过期通知 */ + this.addRule(CouponActionMessage.class, EXPIRE_COUPON, this::couponExpire); + /* 更新优惠券信息通知 */ + this.addRule(CouponActionMessage.class, UPDATE_COUPON_INFO, this::couponUpdate); + /* 更新优惠券信息通知 */ + this.addRule(CouponActionMessage.class, INVALID_COUPON, this::couponInvalid); + /* 用户优惠券过期通知 */ + this.addRule(UserCouponExpireMessage.class, USER_COUPON_EXPIRE, this::userCouponExpire); + /* 用户优惠券过期通知 */ + this.addRule(UserCouponExpireMessage.class, USER_COUPON_UNUSE, this::userCouponUnuse); + /* 优惠券返还通知 */ + this.addRule(UserCouponExpireMessage.class, USER_COUPON_USE, this::userCouponUse); + /* 结算账户变更回调 */ + this.addRule(AccountNotifyMessage.class, ACCOUNT_NOTIFY, this::accountNotify); + /* 提现回调 */ + this.addRule(WithdrawNotifyMessage.class, WITHDRAW_NOTIFY, this::withdrawNotify); + /* 提现二维码回调 */ + this.addRule(QrNotifyMessage.class, QRCODE_STATUS, this::qrNotify); + /* 团长 */ + this.addRule(SupplierItemMessage.class, SUPPLIER_ITEM_UPDATE, this::supplierItemUpdate); + } + + /** + * 添加一条规则进入路由器 + * + * @param clazz 消息类型 + * @param event 事件类型 + * @param consumer 处理器 + * @param 消息类型 + */ + protected void addRule(Class clazz, String event, + HandlerConsumer, WxSessionManager> consumer) { + WxChannelMessageRouterRule rule = new WxChannelMessageRouterRule<>(); + rule.setMessageClass(clazz).setEvent(event).setAsync(true); + rule.getHandlers().add((message, content, appId, context, sessionManager) -> { + consumer.accept(message, content, appId, context, sessionManager); + return "success"; + }); + this.addRule(rule); + } + + @Override + public void addRule(WxChannelMessageRouterRule rule) { + router.getRules().add(rule); + } + + @Override + public Object route(WxChannelMessage message, String content, String appId, final WxChannelService service) { + return router.route(message, content, appId, service); + } + + + @Override + public void orderNew(OrderIdMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单下单:{}", JsonUtils.encode(message)); + } + + @Override + public void orderCancel(OrderCancelMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单取消:{}", JsonUtils.encode(message)); + } + + @Override + public void orderPay(OrderPayMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单支付成功:{}", JsonUtils.encode(message)); + } + + @Override + public void orderDelivery(OrderDeliveryMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单发货:{}", JsonUtils.encode(message)); + } + + @Override + public void orderConfirm(OrderConfirmMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单确认收货:{}", JsonUtils.encode(message)); + } + + @Override + public void orderSettle(OrderSettleMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单结算:{}", JsonUtils.encode(message)); + } + + @Override + public void orderExtInfoUpdate(OrderExtMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单其他信息更新:{}", JsonUtils.encode(message)); + } + + @Override + public void orderStatusUpdate(OrderStatusMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("订单状态更新:{}", JsonUtils.encode(message)); + } + + @Override + public void spuAudit(SpuAuditMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("商品审核:{}", JsonUtils.encode(message)); + } + + @Override + public void spuStatusUpdate(SpuAuditMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("商品状态更新:{}", JsonUtils.encode(message)); + } + + @Override + public void spuUpdate(SpuAuditMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("商品更新:{}", JsonUtils.encode(message)); + } + + @Override + public void categoryAudit(CategoryAuditMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("分类审核:{}", JsonUtils.encode(message)); + } + + @Override + public void brandUpdate(BrandMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("品牌更新:{}", JsonUtils.encode(message)); + } + + @Override + public void afterSaleStatusUpdate(AfterSaleMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("售后状态更新:{}", JsonUtils.encode(message)); + } + + @Override + public void complaintNotify(ComplaintMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("投诉通知:{}", JsonUtils.encode(message)); + } + + @Override + public void couponReceive(CouponReceiveMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("优惠券领取:{}", JsonUtils.encode(message)); + } + + @Override + public void couponCreate(CouponActionMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("优惠券创建:{}", JsonUtils.encode(message)); + } + + @Override + public void couponDelete(CouponActionMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("优惠券删除:{}", JsonUtils.encode(message)); + } + + @Override + public void couponExpire(CouponActionMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("优惠券过期:{}", JsonUtils.encode(message)); + } + + @Override + public void couponUpdate(CouponActionMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("优惠券更新:{}", JsonUtils.encode(message)); + } + + @Override + public void couponInvalid(CouponActionMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("优惠券失效:{}", JsonUtils.encode(message)); + } + + @Override + public void userCouponExpire(UserCouponExpireMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("用户优惠券过期:{}", JsonUtils.encode(message)); + } + + @Override + public void userCouponUse(UserCouponExpireMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("用户优惠券使用:{}", JsonUtils.encode(message)); + } + + @Override + public void userCouponUnuse(UserCouponExpireMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("用户优惠券取消使用:{}", JsonUtils.encode(message)); + } + + @Override + public void accountNotify(AccountNotifyMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("账户通知:{}", JsonUtils.encode(message)); + } + + @Override + public void withdrawNotify(WithdrawNotifyMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("提现通知:{}", JsonUtils.encode(message)); + } + + @Override + public void qrNotify(QrNotifyMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("二维码通知:{}", JsonUtils.encode(message)); + } + + @Override + public void supplierItemUpdate(SupplierItemMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("供应商商品更新:{}", JsonUtils.encode(message)); + } + + @Override + public Object defaultMessageHandler(WxChannelMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("默认消息处理:{}", JsonUtils.encode(message)); + return null; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java new file mode 100644 index 0000000000..6dd12a5b51 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java @@ -0,0 +1,389 @@ +package me.chanjar.weixin.channel.api.impl; + + +import com.google.gson.JsonObject; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelAddressService; +import me.chanjar.weixin.channel.api.WxChannelAfterSaleService; +import me.chanjar.weixin.channel.api.WxChannelBasicService; +import me.chanjar.weixin.channel.api.WxChannelBrandService; +import me.chanjar.weixin.channel.api.WxChannelCategoryService; +import me.chanjar.weixin.channel.api.WxChannelCouponService; +import me.chanjar.weixin.channel.api.WxChannelFreightTemplateService; +import me.chanjar.weixin.channel.api.WxChannelFundService; +import me.chanjar.weixin.channel.api.WxChannelOrderService; +import me.chanjar.weixin.channel.api.WxChannelProductService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.WxChannelSharerService; +import me.chanjar.weixin.channel.api.WxChannelWarehouseService; +import me.chanjar.weixin.channel.api.WxLeagueProductService; +import me.chanjar.weixin.channel.api.WxLeaguePromoterService; +import me.chanjar.weixin.channel.api.WxLeagueSupplierService; +import me.chanjar.weixin.channel.api.WxLeagueWindowService; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.error.WxRuntimeException; +import me.chanjar.weixin.common.util.DataUtils; +import me.chanjar.weixin.common.util.crypto.SHA1; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; +import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; +import org.apache.commons.lang3.StringUtils; + +/** + * @author Zeyes + * @see #doGetAccessTokenRequest + */ +@Slf4j +public abstract class BaseWxChannelServiceImpl implements WxChannelService, RequestHttp { + + private final WxChannelBasicService basicService = new WxChannelBasicServiceImpl(this); + private final WxChannelCategoryService categoryService = new WxChannelCategoryServiceImpl(this); + private final WxChannelBrandService brandService = new WxChannelBrandServiceImpl(this); + private final WxChannelProductService productService = new WxChannelProductServiceImpl(this); + private final WxChannelWarehouseService warehouseService = new WxChannelWarehouseServiceImpl(this); + private final WxChannelOrderService orderService = new WxChannelOrderServiceImpl(this); + private final WxChannelAfterSaleService afterSaleService = new WxChannelAfterSaleServiceImpl(this); + private final WxChannelFreightTemplateService freightTemplateService = + new WxChannelFreightTemplateServiceImpl(this); + private final WxChannelAddressService addressService = new WxChannelAddressServiceImpl(this); + private final WxChannelCouponService couponService = new WxChannelCouponServiceImpl(this); + private final WxChannelSharerService sharerService = new WxChannelSharerServiceImpl(this); + private final WxChannelFundService fundService = new WxChannelFundServiceImpl(this); + private WxLeagueWindowService leagueWindowService = null; + private WxLeagueSupplierService leagueSupplierService = null; + private WxLeaguePromoterService leaguePromoterService = null; + private WxLeagueProductService leagueProductService = null; + + protected WxChannelConfig config; + private int retrySleepMillis = 1000; + private int maxRetryTimes = 5; + + @Override + public RequestHttp getRequestHttp() { + return this; + } + + @Override + public boolean checkSignature(String timestamp, String nonce, String signature) { + try { + return SHA1.gen(this.getConfig().getToken(), timestamp, nonce).equals(signature); + } catch (Exception e) { + log.error("Checking signature failed, and the reason is :" + e.getMessage()); + return false; + } + } + + @Override + public String getAccessToken() throws WxErrorException { + return getAccessToken(false); + } + + @Override + public String getAccessToken(boolean forceRefresh) throws WxErrorException { + if (!forceRefresh && !this.getConfig().isAccessTokenExpired()) { + return this.getConfig().getAccessToken(); + } + + Lock lock = this.getConfig().getAccessTokenLock(); + boolean locked = false; + try { + do { + locked = lock.tryLock(100, TimeUnit.MILLISECONDS); + if (!forceRefresh && !this.getConfig().isAccessTokenExpired()) { + return this.getConfig().getAccessToken(); + } + } while (!locked); + String response = doGetAccessTokenRequest(); + return extractAccessToken(response); + } catch (IOException | InterruptedException e) { + throw new WxRuntimeException(e); + } finally { + if (locked) { + lock.unlock(); + } + } + } + + /** + * 通过网络请求获取AccessToken + * + * @return . + * + * @throws IOException . + */ + protected abstract String doGetAccessTokenRequest() throws IOException; + + @Override + public String get(String url, String queryParam) throws WxErrorException { + return execute(SimpleGetRequestExecutor.create(this), url, queryParam); + } + + @Override + public String post(String url, String postData) throws WxErrorException { + return execute(SimplePostRequestExecutor.create(this), url, postData); + } + + @Override + public String post(String url, Object obj) throws WxErrorException { + // 此处用JsonUtils.encode, 不用Gson + return this.execute(SimplePostRequestExecutor.create(this), url, JsonUtils.encode(obj)); + } + + @Override + public String post(String url, ToJson obj) throws WxErrorException { + return this.post(url, obj.toJson()); + } + + @Override + public String post(String url, JsonObject jsonObject) throws WxErrorException { + return this.post(url, jsonObject.toString()); + } + + /** + * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求 + */ + @Override + public T execute(RequestExecutor executor, String uri, E data) throws WxErrorException { + return execute0(executor, uri, data, true); + } + + @Override + public T executeWithoutLog(RequestExecutor executor, String uri, E data) throws WxErrorException { + return execute0(executor, uri, data, false); + } + + protected T execute0(RequestExecutor executor, String uri, E data, boolean printResult) + throws WxErrorException { + int retryTimes = 0; + do { + try { + return this.executeInternal(executor, uri, data, false, printResult); + } catch (WxErrorException e) { + if (retryTimes + 1 > this.maxRetryTimes) { + log.warn("重试达到最大次数【{}】", maxRetryTimes); + //最后一次重试失败后,直接抛出异常,不再等待 + throw new WxErrorException(WxError.builder() + .errorCode(e.getError().getErrorCode()) + .errorMsg("微信服务端异常,超出重试次数!") + .build()); + } + + WxError error = e.getError(); + // -1 系统繁忙, 1000ms后重试 + if (error.getErrorCode() == -1) { + int sleepMillis = this.retrySleepMillis * (1 << retryTimes); + try { + log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); + Thread.sleep(sleepMillis); + } catch (InterruptedException e1) { + Thread.currentThread().interrupt(); + } + } else { + throw e; + } + } + } while (retryTimes++ < this.maxRetryTimes); + + log.warn("重试达到最大次数【{}】", this.maxRetryTimes); + throw new WxRuntimeException("微信服务端异常,超出重试次数"); + } + + protected T executeInternal(RequestExecutor executor, String uri, E data, boolean doNotAutoRefreshToken, + boolean printResult) throws WxErrorException { + E dataForLog = DataUtils.handleDataWithSecret(data); + + if (uri.contains("access_token=")) { + throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri); + } + String accessToken = getAccessToken(false); + + WxChannelConfig config = this.getConfig(); + if (StringUtils.isNotEmpty(config.getApiHostUrl())) { + uri = uri.replace("https://api.weixin.qq.com", config.getApiHostUrl()); + } + + String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; + + try { + T result = executor.execute(uriWithAccessToken, data, WxType.Channel); + log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, + printResult ? result : "..."); + return result; + } catch (WxErrorException e) { + WxError error = e.getError(); + if (WxConsts.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) { + // 强制设置WxMaConfig的access token过期了,这样在下一次请求里就会刷新access token + Lock lock = config.getAccessTokenLock(); + lock.lock(); + try { + if (StringUtils.equals(config.getAccessToken(), accessToken)) { + config.expireAccessToken(); + } + } catch (Exception ex) { + config.expireAccessToken(); + } finally { + lock.unlock(); + } + if (config.autoRefreshToken() && !doNotAutoRefreshToken) { + log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg()); + //下一次不再自动重试 + //当小程序误调用第三方平台专属接口时,第三方无法使用小程序的access token,如果可以继续自动获取token会导致无限循环重试,直到栈溢出 + return this.executeInternal(executor, uri, data, true, printResult); + } + } + + if (error.getErrorCode() != 0) { + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); + throw new WxErrorException(error, e); + } + return null; + } catch (IOException e) { + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); + throw new WxRuntimeException(e); + } + } + + /** + * 设置当前的AccessToken + * + * @param resultContent 响应内容 + * @return access token + * + * @throws WxErrorException 异常 + */ + protected String extractAccessToken(String resultContent) throws WxErrorException { + log.info("resultContent: " + resultContent); + WxChannelConfig config = this.getConfig(); + WxError error = WxError.fromJson(resultContent, WxType.MiniApp); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + WxAccessToken accessToken = WxAccessToken.fromJson(resultContent); + config.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); + return accessToken.getAccessToken(); + } + + @Override + public WxChannelConfig getConfig() { + return config; + } + + @Override + public void setConfig(WxChannelConfig config) { + this.config = config; + initHttp(); + } + + @Override + public void setRetrySleepMillis(int retrySleepMillis) { + this.retrySleepMillis = retrySleepMillis; + } + + @Override + public void setMaxRetryTimes(int maxRetryTimes) { + this.maxRetryTimes = maxRetryTimes; + } + + @Override + public WxChannelBasicService getBasicService() { + return basicService; + } + + @Override + public WxChannelCategoryService getCategoryService() { + return categoryService; + } + + @Override + public WxChannelBrandService getBrandService() { + return brandService; + } + + @Override + public WxChannelProductService getProductService() { + return productService; + } + + @Override + public WxChannelWarehouseService getWarehouseService() { + return warehouseService; + } + + @Override + public WxChannelOrderService getOrderService() { + return orderService; + } + + @Override + public WxChannelAfterSaleService getAfterSaleService() { + return afterSaleService; + } + + @Override + public WxChannelFreightTemplateService getFreightTemplateService() { + return freightTemplateService; + } + + @Override + public WxChannelAddressService getAddressService() { + return addressService; + } + + @Override + public WxChannelCouponService getCouponService() { + return couponService; + } + + @Override + public WxChannelSharerService getSharerService() { + return sharerService; + } + + @Override + public WxChannelFundService getFundService() { + return fundService; + } + + @Override + public synchronized WxLeagueWindowService getLeagueWindowService() { + if (leagueWindowService == null) { + leagueWindowService = new WxLeagueWindowServiceImpl(this); + } + return leagueWindowService; + } + + @Override + public synchronized WxLeagueSupplierService getLeagueSupplierService() { + if (leagueSupplierService == null) { + leagueSupplierService = new WxLeagueSupplierServiceImpl(this); + } + return leagueSupplierService; + } + + @Override + public synchronized WxLeaguePromoterService getLeaguePromoterService() { + if (leaguePromoterService == null) { + leaguePromoterService = new WxLeaguePromoterServiceImpl(this); + } + return leaguePromoterService; + } + + @Override + public synchronized WxLeagueProductService getLeagueProductService() { + if (leagueProductService == null) { + leagueProductService = new WxLeagueProductServiceImpl(this); + } + return leagueProductService; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAddressServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAddressServiceImpl.java new file mode 100644 index 0000000000..53b9eb4d7a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAddressServiceImpl.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Address.ADD_ADDRESS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Address.DELETE_ADDRESS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Address.GET_ADDRESS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Address.LIST_ADDRESS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Address.UPDATE_ADDRESS_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelAddressService; +import me.chanjar.weixin.channel.bean.address.AddressAddParam; +import me.chanjar.weixin.channel.bean.address.AddressDetail; +import me.chanjar.weixin.channel.bean.address.AddressIdParam; +import me.chanjar.weixin.channel.bean.address.AddressIdResponse; +import me.chanjar.weixin.channel.bean.address.AddressInfoResponse; +import me.chanjar.weixin.channel.bean.address.AddressListParam; +import me.chanjar.weixin.channel.bean.address.AddressListResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 地址管理服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelAddressServiceImpl implements WxChannelAddressService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelAddressServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public AddressListResponse listAddress(Integer offset, Integer limit) throws WxErrorException { + AddressListParam param = new AddressListParam(offset, limit); + String resJson = shopService.post(LIST_ADDRESS_URL, param); + return ResponseUtils.decode(resJson, AddressListResponse.class); + } + + @Override + public AddressInfoResponse getAddress(String addressId) throws WxErrorException { + AddressIdParam param = new AddressIdParam(addressId); + String resJson = shopService.post(GET_ADDRESS_URL, param); + return ResponseUtils.decode(resJson, AddressInfoResponse.class); + } + + @Override + public AddressIdResponse addAddress(AddressDetail addressDetail) throws WxErrorException { + AddressAddParam param = new AddressAddParam(addressDetail); + String resJson = shopService.post(ADD_ADDRESS_URL, param); + return ResponseUtils.decode(resJson, AddressIdResponse.class); + } + + @Override + public WxChannelBaseResponse updateAddress(AddressDetail addressDetail) throws WxErrorException { + AddressAddParam param = new AddressAddParam(addressDetail); + String resJson = shopService.post(UPDATE_ADDRESS_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse deleteAddress(String addressId) throws WxErrorException { + AddressIdParam param = new AddressIdParam(addressId); + String resJson = shopService.post(DELETE_ADDRESS_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImpl.java new file mode 100644 index 0000000000..c29ea49b34 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImpl.java @@ -0,0 +1,103 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.AFTER_SALE_ACCEPT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.AFTER_SALE_GET_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.AFTER_SALE_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.AFTER_SALE_REJECT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.AFTER_SALE_UPLOAD_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Complaint.ADD_COMPLAINT_MATERIAL_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Complaint.ADD_COMPLAINT_PROOF_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Complaint.GET_COMPLAINT_ORDER_URL; + +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelAfterSaleService; +import me.chanjar.weixin.channel.bean.after.AfterSaleAcceptParam; +import me.chanjar.weixin.channel.bean.after.AfterSaleIdParam; +import me.chanjar.weixin.channel.bean.after.AfterSaleInfoResponse; +import me.chanjar.weixin.channel.bean.after.AfterSaleListParam; +import me.chanjar.weixin.channel.bean.after.AfterSaleListResponse; +import me.chanjar.weixin.channel.bean.after.AfterSaleRejectParam; +import me.chanjar.weixin.channel.bean.after.RefundEvidenceParam; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.complaint.ComplaintOrderResponse; +import me.chanjar.weixin.channel.bean.complaint.ComplaintParam; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 售后服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelAfterSaleServiceImpl implements WxChannelAfterSaleService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelAfterSaleServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public AfterSaleListResponse listIds(Long beginCreateTime, Long endCreateTime, String nextKey) + throws WxErrorException { + AfterSaleListParam param = new AfterSaleListParam(beginCreateTime, endCreateTime, nextKey); + String resJson = shopService.post(AFTER_SALE_LIST_URL, param); + return ResponseUtils.decode(resJson, AfterSaleListResponse.class); + } + + @Override + public AfterSaleInfoResponse get(String afterSaleOrderId) throws WxErrorException { + AfterSaleIdParam param = new AfterSaleIdParam(afterSaleOrderId); + String resJson = shopService.post(AFTER_SALE_GET_URL, param); + return ResponseUtils.decode(resJson, AfterSaleInfoResponse.class); + } + + @Override + public WxChannelBaseResponse accept(String afterSaleOrderId, String addressId) throws WxErrorException { + AfterSaleAcceptParam param = new AfterSaleAcceptParam(afterSaleOrderId, addressId); + String resJson = shopService.post(AFTER_SALE_ACCEPT_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse reject(String afterSaleOrderId, String rejectReason) throws WxErrorException { + AfterSaleRejectParam param = new AfterSaleRejectParam(afterSaleOrderId, rejectReason); + String resJson = shopService.post(AFTER_SALE_REJECT_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse uploadRefundEvidence(String afterSaleOrderId, String desc, List certificates) + throws WxErrorException { + RefundEvidenceParam param = new RefundEvidenceParam(afterSaleOrderId, desc, certificates); + String resJson = shopService.post(AFTER_SALE_UPLOAD_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse addComplaintMaterial(String complaintId, String content, List mediaIds) + throws WxErrorException { + ComplaintParam param = new ComplaintParam(complaintId, content, mediaIds); + String resJson = shopService.post(ADD_COMPLAINT_MATERIAL_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + + } + + @Override + public WxChannelBaseResponse addComplaintEvidence(String complaintId, String content, List mediaIds) + throws WxErrorException { + ComplaintParam param = new ComplaintParam(complaintId, content, mediaIds); + String resJson = shopService.post(ADD_COMPLAINT_PROOF_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public ComplaintOrderResponse getComplaint(String complaintId) throws WxErrorException { + String reqJson = "{\"complaint_id\":\"" + complaintId + "\"}"; + String resJson = shopService.post(GET_COMPLAINT_ORDER_URL, reqJson); + return ResponseUtils.decode(resJson, ComplaintOrderResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelBasicServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelBasicServiceImpl.java new file mode 100644 index 0000000000..cac5e9e513 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelBasicServiceImpl.java @@ -0,0 +1,96 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_ADDRESS_CODE; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_IMG_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_INFO; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.IMG_UPLOAD_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.UPLOAD_QUALIFICATION_FILE; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelBasicService; +import me.chanjar.weixin.channel.bean.address.AddressCodeResponse; +import me.chanjar.weixin.channel.bean.image.ChannelImageInfo; +import me.chanjar.weixin.channel.bean.image.ChannelImageResponse; +import me.chanjar.weixin.channel.bean.image.QualificationFileResponse; +import me.chanjar.weixin.channel.bean.image.UploadImageResponse; +import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse; +import me.chanjar.weixin.channel.executor.ChannelFileUploadRequestExecutor; +import me.chanjar.weixin.channel.executor.ChannelMediaDownloadRequestExecutor; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestExecutor; + +/** + * @author Zeyes + */ +@Slf4j +public class WxChannelBasicServiceImpl implements WxChannelBasicService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelBasicServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public ShopInfoResponse getShopInfo() throws WxErrorException { + String resJson = shopService.get(GET_SHOP_INFO, null); + return ResponseUtils.decode(resJson, ShopInfoResponse.class); + } + + @Override + public ChannelImageInfo uploadImg(int respType, String imgUrl) throws WxErrorException { + String url = IMG_UPLOAD_URL + "?upload_type=1&resp_type=" + respType; + String reqJson = "{\"img_url\":\"" + imgUrl + "\"}"; + String resJson = shopService.post(url, reqJson); + UploadImageResponse response = ResponseUtils.decode(resJson, UploadImageResponse.class); + return response.getImgInfo(); + } + + @Override + public ChannelImageInfo uploadImg(int respType, File file, int height, int width) throws WxErrorException { + String url = IMG_UPLOAD_URL + "?upload_type=0&resp_type=" + respType + "&height=" + height + "&width=" + width; + RequestExecutor executor = ChannelFileUploadRequestExecutor.create(shopService); + String resJson = (String) shopService.execute(executor, url, file); + UploadImageResponse response = ResponseUtils.decode(resJson, UploadImageResponse.class); + return response.getImgInfo(); + } + + @Override + public QualificationFileResponse uploadQualificationFile(File file) throws WxErrorException { + RequestExecutor executor = ChannelFileUploadRequestExecutor.create(shopService); + String resJson = (String) shopService.execute(executor, UPLOAD_QUALIFICATION_FILE, file); + return ResponseUtils.decode(resJson, QualificationFileResponse.class); + } + + @Override + public ChannelImageResponse getImg(String mediaId) throws WxErrorException { + String appId = shopService.getConfig().getAppid(); + ChannelImageResponse rs = null; + try { + String url = GET_IMG_URL + "?media_id=" + mediaId; + RequestExecutor executor = ChannelMediaDownloadRequestExecutor.create(shopService, + Files.createTempDirectory("wxjava-channel-" + appId).toFile()); + rs = (ChannelImageResponse) shopService.execute(executor, url, null); + } catch (IOException e) { + throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); + } + if (rs == null) { + rs = ResponseUtils.internalError(ChannelImageResponse.class); + } + return rs; + } + + @Override + public AddressCodeResponse getAddressCode(Integer code) throws WxErrorException { + String reqJson = "{\"addr_code\": " + code + "}"; + String resJson = shopService.post(GET_ADDRESS_CODE, reqJson); + return ResponseUtils.decode(resJson, AddressCodeResponse.class); + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelBrandServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelBrandServiceImpl.java new file mode 100644 index 0000000000..19aadcc06e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelBrandServiceImpl.java @@ -0,0 +1,98 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.ADD_BRAND_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.ALL_BRAND_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.CANCEL_BRAND_AUDIT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.DELETE_BRAND_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.GET_BRAND_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.LIST_BRAND_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.LIST_BRAND_VALID_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Brand.UPDATE_BRAND_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelBrandService; +import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.brand.Brand; +import me.chanjar.weixin.channel.bean.brand.BrandApplyListResponse; +import me.chanjar.weixin.channel.bean.brand.BrandInfoResponse; +import me.chanjar.weixin.channel.bean.brand.BrandListResponse; +import me.chanjar.weixin.channel.bean.brand.BrandParam; +import me.chanjar.weixin.channel.bean.brand.BrandSearchParam; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 品牌服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelBrandServiceImpl implements WxChannelBrandService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelBrandServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public BrandListResponse listAllBrand(Integer pageSize, String nextKey) throws WxErrorException { + StreamPageParam param = new StreamPageParam(pageSize, nextKey); + String resJson = shopService.post(ALL_BRAND_URL, param); + return ResponseUtils.decode(resJson, BrandListResponse.class); + } + + @Override + public AuditApplyResponse addBrandApply(Brand brand) throws WxErrorException { + BrandParam param = new BrandParam(brand); + String resJson = shopService.post(ADD_BRAND_URL, param); + return ResponseUtils.decode(resJson, AuditApplyResponse.class); + } + + @Override + public AuditApplyResponse updateBrandApply(Brand brand) throws WxErrorException { + BrandParam param = new BrandParam(brand); + String resJson = shopService.post(UPDATE_BRAND_URL, param); + return ResponseUtils.decode(resJson, AuditApplyResponse.class); + } + + @Override + public WxChannelBaseResponse cancelBrandApply(String brandId, String auditId) throws WxErrorException { + String reqJson = "{\"brand_id\":\"" + brandId + "\",\"audit_id\":\"" + auditId + "\"}"; + String resJson = shopService.post(CANCEL_BRAND_AUDIT_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse deleteBrandApply(String brandId) throws WxErrorException { + String reqJson = "{\"brand_id\":\"" + brandId + "\"}"; + String resJson = shopService.post(DELETE_BRAND_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public BrandInfoResponse getBrandApply(String brandId) throws WxErrorException { + String reqJson = "{\"brand_id\":\"" + brandId + "\"}"; + String resJson = shopService.post(GET_BRAND_URL, reqJson); + return ResponseUtils.decode(resJson, BrandInfoResponse.class); + } + + @Override + public BrandApplyListResponse listBrandApply(Integer pageSize, String nextKey, Integer status) + throws WxErrorException { + BrandSearchParam param = new BrandSearchParam(pageSize, nextKey, status); + String resJson = shopService.post(LIST_BRAND_URL, param); + return ResponseUtils.decode(resJson, BrandApplyListResponse.class); + } + + @Override + public BrandApplyListResponse listValidBrandApply(Integer pageSize, String nextKey) throws WxErrorException { + StreamPageParam param = new StreamPageParam(pageSize, nextKey); + String resJson = shopService.post(LIST_BRAND_VALID_URL, param); + return ResponseUtils.decode(resJson, BrandApplyListResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelCategoryServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelCategoryServiceImpl.java new file mode 100644 index 0000000000..52fdf3cdf8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelCategoryServiceImpl.java @@ -0,0 +1,119 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Category.ADD_CATEGORY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Category.AVAILABLE_CATEGORY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Category.CANCEL_CATEGORY_AUDIT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Category.GET_CATEGORY_AUDIT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Category.GET_CATEGORY_DETAIL_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Category.LIST_ALL_CATEGORY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Category.LIST_PASS_CATEGORY_URL; + +import java.util.Collections; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelCategoryService; +import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse; +import me.chanjar.weixin.channel.bean.audit.AuditResponse; +import me.chanjar.weixin.channel.bean.audit.CategoryAuditInfo; +import me.chanjar.weixin.channel.bean.audit.CategoryAuditRequest; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.category.CategoryDetailResult; +import me.chanjar.weixin.channel.bean.category.CategoryQualificationResponse; +import me.chanjar.weixin.channel.bean.category.PassCategoryResponse; +import me.chanjar.weixin.channel.bean.category.ShopCategory; +import me.chanjar.weixin.channel.bean.category.ShopCategoryResponse; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; +import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; + +/** + * 视频号小店 商品类目相关接口 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelCategoryServiceImpl implements WxChannelCategoryService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelCategoryServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public CategoryQualificationResponse listAllCategory() throws WxErrorException { + // 数据量太大了,不记录日志 + String resJson = (String) shopService.executeWithoutLog(SimpleGetRequestExecutor.create(shopService), + LIST_ALL_CATEGORY_URL, null); + return ResponseUtils.decode(resJson, CategoryQualificationResponse.class); + } + + public List listAvailableCategory(String parentId) throws WxErrorException { + Long pid = null; + try { + pid = Long.parseLong(parentId); + } catch (Throwable e) { + log.error("parentId必须为数字, " + parentId, e); + return Collections.emptyList(); + } + String reqJson = "{\"f_cat_id\": " + pid + "}"; + String resJson = (String) shopService.executeWithoutLog(SimplePostRequestExecutor.create(shopService), + AVAILABLE_CATEGORY_URL, reqJson); + ShopCategoryResponse response = ResponseUtils.decode(resJson, ShopCategoryResponse.class); + return response.getCategories(); + } + + @Override + public CategoryDetailResult getCategoryDetail(String id) throws WxErrorException { + Long catId = null; + try { + catId = Long.parseLong(id); + } catch (Throwable e) { + log.error("id必须为数字, " + id, e); + return ResponseUtils.internalError(CategoryDetailResult.class); + } + String reqJson = "{\"cat_id\": " + catId + "}"; + String resJson = (String) shopService.executeWithoutLog(SimplePostRequestExecutor.create(shopService), + GET_CATEGORY_DETAIL_URL, reqJson); + return ResponseUtils.decode(resJson, CategoryDetailResult.class); + } + + @Override + public AuditApplyResponse addCategory(String level1, String level2, String level3, List certificate) + throws WxErrorException { + String reqJson = null; + try { + Long l1 = Long.parseLong(level1); + Long l2 = Long.parseLong(level2); + Long l3 = Long.parseLong(level3); + CategoryAuditInfo categoryInfo = new CategoryAuditInfo(l1, l2, l3, certificate); + reqJson = JsonUtils.encode(new CategoryAuditRequest(categoryInfo)); + } catch (Throwable e) { + log.error("微信请求异常", e); + } + String resJson = shopService.post(ADD_CATEGORY_URL, reqJson); + return ResponseUtils.decode(resJson, AuditApplyResponse.class); + } + + @Override + public WxChannelBaseResponse cancelCategoryAudit(String auditId) throws WxErrorException { + String resJson = shopService.post(CANCEL_CATEGORY_AUDIT_URL, "{\"audit_id\": \"" + auditId + "\"}"); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public AuditResponse getAudit(String auditId) throws WxErrorException { + String resJson = shopService.post(GET_CATEGORY_AUDIT_URL, "{\"audit_id\": \"" + auditId + "\"}"); + return ResponseUtils.decode(resJson, AuditResponse.class); + } + + @Override + public PassCategoryResponse listPassCategory() throws WxErrorException { + String resJson = shopService.get(LIST_PASS_CATEGORY_URL, null); + return ResponseUtils.decode(resJson, PassCategoryResponse.class); + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelCouponServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelCouponServiceImpl.java new file mode 100644 index 0000000000..174626f4a9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelCouponServiceImpl.java @@ -0,0 +1,88 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Coupon.CREATE_COUPON_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Coupon.GET_COUPON_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Coupon.GET_USER_COUPON_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Coupon.LIST_COUPON_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Coupon.LIST_USER_COUPON_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Coupon.UPDATE_COUPON_STATUS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Coupon.UPDATE_COUPON_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelCouponService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponIdInfo; +import me.chanjar.weixin.channel.bean.coupon.CouponIdResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponInfoResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponListParam; +import me.chanjar.weixin.channel.bean.coupon.CouponListResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponParam; +import me.chanjar.weixin.channel.bean.coupon.CouponStatusParam; +import me.chanjar.weixin.channel.bean.coupon.UserCouponIdParam; +import me.chanjar.weixin.channel.bean.coupon.UserCouponListParam; +import me.chanjar.weixin.channel.bean.coupon.UserCouponListResponse; +import me.chanjar.weixin.channel.bean.coupon.UserCouponResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 优惠券服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelCouponServiceImpl implements WxChannelCouponService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelCouponServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public CouponIdResponse createCoupon(CouponParam coupon) throws WxErrorException { + String resJson = shopService.post(CREATE_COUPON_URL, coupon); + return ResponseUtils.decode(resJson, CouponIdResponse.class); + } + + @Override + public CouponIdResponse updateCoupon(CouponParam coupon) throws WxErrorException { + String resJson = shopService.post(UPDATE_COUPON_URL, coupon); + return ResponseUtils.decode(resJson, CouponIdResponse.class); + } + + @Override + public WxChannelBaseResponse updateCouponStatus(String couponId, Integer status) throws WxErrorException { + CouponStatusParam param = new CouponStatusParam(couponId, status); + String resJson = shopService.post(UPDATE_COUPON_STATUS_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public CouponInfoResponse getCoupon(String couponId) throws WxErrorException { + CouponIdInfo param = new CouponIdInfo(couponId); + String resJson = shopService.post(GET_COUPON_URL, param); + return ResponseUtils.decode(resJson, CouponInfoResponse.class); + } + + @Override + public CouponListResponse getCouponList(CouponListParam param) throws WxErrorException { + String resJson = shopService.post(LIST_COUPON_URL, param); + return ResponseUtils.decode(resJson, CouponListResponse.class); + } + + @Override + public UserCouponResponse getUserCoupon(String openId, String userCouponId) throws WxErrorException { + UserCouponIdParam param = new UserCouponIdParam(openId, userCouponId); + String resJson = shopService.post(GET_USER_COUPON_URL, param); + return ResponseUtils.decode(resJson, UserCouponResponse.class); + } + + @Override + public UserCouponListResponse getUserCouponList(UserCouponListParam param) throws WxErrorException { + String resJson = shopService.post(LIST_USER_COUPON_URL, param); + return ResponseUtils.decode(resJson, UserCouponListResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelFreightTemplateServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelFreightTemplateServiceImpl.java new file mode 100644 index 0000000000..8fbfbd09c3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelFreightTemplateServiceImpl.java @@ -0,0 +1,61 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FreightTemplate.ADD_TEMPLATE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FreightTemplate.GET_TEMPLATE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FreightTemplate.LIST_TEMPLATE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FreightTemplate.UPDATE_TEMPLATE_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelFreightTemplateService; +import me.chanjar.weixin.channel.bean.freight.FreightTemplate; +import me.chanjar.weixin.channel.bean.freight.TemplateAddParam; +import me.chanjar.weixin.channel.bean.freight.TemplateIdResponse; +import me.chanjar.weixin.channel.bean.freight.TemplateInfoResponse; +import me.chanjar.weixin.channel.bean.freight.TemplateListParam; +import me.chanjar.weixin.channel.bean.freight.TemplateListResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 运费模板服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelFreightTemplateServiceImpl implements WxChannelFreightTemplateService { + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelFreightTemplateServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public TemplateListResponse listTemplate(Integer offset, Integer limit) throws WxErrorException { + TemplateListParam param = new TemplateListParam(offset, limit); + String resJson = shopService.post(LIST_TEMPLATE_URL, param); + return ResponseUtils.decode(resJson, TemplateListResponse.class); + + } + + @Override + public TemplateInfoResponse getTemplate(String templateId) throws WxErrorException { + String reqJson = "{\"template_id\": \"" + templateId + "\"}"; + String resJson = shopService.post(GET_TEMPLATE_URL, reqJson); + return ResponseUtils.decode(resJson, TemplateInfoResponse.class); + } + + @Override + public TemplateIdResponse addTemplate(FreightTemplate template) throws WxErrorException { + TemplateAddParam param = new TemplateAddParam(template); + String resJson = shopService.post(ADD_TEMPLATE_URL, param); + return ResponseUtils.decode(resJson, TemplateIdResponse.class); + } + + @Override + public TemplateIdResponse updateTemplate(FreightTemplate template) throws WxErrorException { + TemplateAddParam param = new TemplateAddParam(template); + String resJson = shopService.post(UPDATE_TEMPLATE_URL, param); + return ResponseUtils.decode(resJson, TemplateIdResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelFundServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelFundServiceImpl.java new file mode 100644 index 0000000000..050a19f44d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelFundServiceImpl.java @@ -0,0 +1,167 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.CHECK_QRCODE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_BALANCE_FLOW_DETAIL_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_BALANCE_FLOW_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_BALANCE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_BANK_ACCOUNT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_BANK_BY_NUM_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_BANK_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_CITY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_PROVINCE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_QRCODE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_SUB_BANK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_WITHDRAW_DETAIL_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.GET_WITHDRAW_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.SET_BANK_ACCOUNT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Fund.WITHDRAW_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelFundService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.fund.AccountInfo; +import me.chanjar.weixin.channel.bean.fund.AccountInfoParam; +import me.chanjar.weixin.channel.bean.fund.AccountInfoResponse; +import me.chanjar.weixin.channel.bean.fund.BalanceInfoResponse; +import me.chanjar.weixin.channel.bean.fund.FlowListResponse; +import me.chanjar.weixin.channel.bean.fund.FundsFlowResponse; +import me.chanjar.weixin.channel.bean.fund.FundsListParam; +import me.chanjar.weixin.channel.bean.fund.WithdrawDetailResponse; +import me.chanjar.weixin.channel.bean.fund.WithdrawListParam; +import me.chanjar.weixin.channel.bean.fund.WithdrawListResponse; +import me.chanjar.weixin.channel.bean.fund.WithdrawSubmitParam; +import me.chanjar.weixin.channel.bean.fund.WithdrawSubmitResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankCityResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankInfoResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankListResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankProvinceResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankSearchParam; +import me.chanjar.weixin.channel.bean.fund.bank.BranchInfoResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BranchSearchParam; +import me.chanjar.weixin.channel.bean.fund.qrcode.QrCheckResponse; +import me.chanjar.weixin.channel.bean.fund.qrcode.QrCodeResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 资金服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelFundServiceImpl implements WxChannelFundService { + + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelFundServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public BalanceInfoResponse getBalance() throws WxErrorException { + String resJson = shopService.post(GET_BALANCE_URL, "{}"); + return ResponseUtils.decode(resJson, BalanceInfoResponse.class); + } + + @Override + public AccountInfoResponse getBankAccount() throws WxErrorException { + String resJson = shopService.post(GET_BANK_ACCOUNT_URL, "{}"); + return ResponseUtils.decode(resJson, AccountInfoResponse.class); + } + + @Override + public FundsFlowResponse getFundsFlowDetail(String flowId) throws WxErrorException { + String reqJson = "{\"flow_id\":\"" + flowId + "\"}"; + String resJson = shopService.post(GET_BALANCE_FLOW_DETAIL_URL, reqJson); + return ResponseUtils.decode(resJson, FundsFlowResponse.class); + } + + @Override + public FlowListResponse listFundsFlow(FundsListParam param) throws WxErrorException { + String resJson = shopService.post(GET_BALANCE_FLOW_LIST_URL, param); + return ResponseUtils.decode(resJson, FlowListResponse.class); + } + + @Override + public WithdrawDetailResponse getWithdrawDetail(String withdrawId) throws WxErrorException { + String reqJson = "{\"withdraw_id\":\"" + withdrawId + "\"}"; + String resJson = shopService.post(GET_WITHDRAW_DETAIL_URL, reqJson); + return ResponseUtils.decode(resJson, WithdrawDetailResponse.class); + } + + @Override + public WithdrawListResponse listWithdraw(Integer pageNum, Integer pageSize, Long startTime, Long endTime) + throws WxErrorException { + WithdrawListParam param = new WithdrawListParam(pageNum, pageSize, startTime, endTime); + String resJson = shopService.post(GET_WITHDRAW_LIST_URL, param); + return ResponseUtils.decode(resJson, WithdrawListResponse.class); + } + + @Override + public WxChannelBaseResponse setBankAccount(AccountInfo accountInfo) throws WxErrorException { + AccountInfoParam param = new AccountInfoParam(accountInfo); + String resJson = shopService.post(SET_BANK_ACCOUNT_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WithdrawSubmitResponse submitWithdraw(Integer amount, String remark, String bankMemo) + throws WxErrorException { + WithdrawSubmitParam param = new WithdrawSubmitParam(amount, remark, bankMemo); + String resJson = shopService.post(WITHDRAW_URL, param); + return ResponseUtils.decode(resJson, WithdrawSubmitResponse.class); + } + + @Override + public BankInfoResponse getBankInfoByCardNo(String accountNumber) throws WxErrorException { + String reqJson = "{\"account_number\":\"" + accountNumber + "\"}"; + String resJson = shopService.post(GET_BANK_BY_NUM_URL, reqJson); + return ResponseUtils.decode(resJson, BankInfoResponse.class); + } + + @Override + public BankListResponse searchBankList(Integer offset, Integer limit, String keywords, Integer bankType) + throws WxErrorException { + BankSearchParam param = new BankSearchParam(offset, limit, keywords, bankType); + String resJson = shopService.post(GET_BANK_LIST_URL, param); + return ResponseUtils.decode(resJson, BankListResponse.class); + } + + @Override + public BankCityResponse searchCityList(String provinceCode) throws WxErrorException { + String reqJson = "{\"province_code\":\"" + provinceCode + "\"}"; + String resJson = shopService.post(GET_CITY_URL, reqJson); + return ResponseUtils.decode(resJson, BankCityResponse.class); + } + + @Override + public BankProvinceResponse getProvinceList() throws WxErrorException { + String resJson = shopService.post(GET_PROVINCE_URL, "{}"); + return ResponseUtils.decode(resJson, BankProvinceResponse.class); + } + + @Override + public BranchInfoResponse searchBranchList(String bankCode, String cityCode, Integer offset, Integer limit) + throws WxErrorException { + BranchSearchParam param = new BranchSearchParam(bankCode, cityCode, offset, limit); + String resJson = shopService.post(GET_SUB_BANK_URL, param); + return ResponseUtils.decode(resJson, BranchInfoResponse.class); + } + + @Override + public QrCodeResponse getQrCode(String qrcodeTicket) throws WxErrorException { + String reqJson = "{\"qrcode_ticket\":\"" + qrcodeTicket + "\"}"; + String resJson = shopService.post(GET_QRCODE_URL, reqJson); + return ResponseUtils.decode(resJson, QrCodeResponse.class); + } + + @Override + public QrCheckResponse checkQrStatus(String qrcodeTicket) throws WxErrorException { + String reqJson = "{\"qrcode_ticket\":\"" + qrcodeTicket + "\"}"; + String resJson = shopService.post(CHECK_QRCODE_URL, reqJson); + return ResponseUtils.decode(resJson, QrCheckResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelOrderServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelOrderServiceImpl.java new file mode 100644 index 0000000000..65eec5dd29 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelOrderServiceImpl.java @@ -0,0 +1,125 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Delivery.DELIVERY_SEND_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Delivery.GET_DELIVERY_COMPANY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.*; + +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelOrderService; +import me.chanjar.weixin.channel.bean.base.AddressInfo; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.delivery.DeliveryCompanyResponse; +import me.chanjar.weixin.channel.bean.delivery.DeliveryInfo; +import me.chanjar.weixin.channel.bean.delivery.DeliverySendParam; +import me.chanjar.weixin.channel.bean.order.ChangeOrderInfo; +import me.chanjar.weixin.channel.bean.order.DeliveryUpdateParam; +import me.chanjar.weixin.channel.bean.order.OrderAddressParam; +import me.chanjar.weixin.channel.bean.order.OrderIdParam; +import me.chanjar.weixin.channel.bean.order.OrderInfoResponse; +import me.chanjar.weixin.channel.bean.order.OrderListParam; +import me.chanjar.weixin.channel.bean.order.OrderListResponse; +import me.chanjar.weixin.channel.bean.order.OrderPriceParam; +import me.chanjar.weixin.channel.bean.order.OrderRemarkParam; +import me.chanjar.weixin.channel.bean.order.OrderSearchParam; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + + +/** + * 视频号小店订单服务 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelOrderServiceImpl implements WxChannelOrderService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelOrderServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public OrderInfoResponse getOrder(String orderId) throws WxErrorException { + OrderIdParam param = new OrderIdParam(orderId); + String resJson = shopService.post(ORDER_GET_URL, param); + return ResponseUtils.decode(resJson, OrderInfoResponse.class); + } + + @Override + public OrderListResponse getOrders(OrderListParam param) throws WxErrorException { + String resJson = shopService.post(ORDER_LIST_URL, param); + return ResponseUtils.decode(resJson, OrderListResponse.class); + } + + @Override + public OrderListResponse searchOrder(OrderSearchParam param) throws WxErrorException { + String resJson = shopService.post(ORDER_SEARCH_URL, param); + return ResponseUtils.decode(resJson, OrderListResponse.class); + } + + @Override + public WxChannelBaseResponse updatePrice(String orderId, Integer expressFee, List changeOrderInfos) + throws WxErrorException { + OrderPriceParam param = new OrderPriceParam(orderId, expressFee, changeOrderInfos); + String resJson = shopService.post(UPDATE_PRICE_URL, param); + ; + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse updateRemark(String orderId, String merchantNotes) throws WxErrorException { + OrderRemarkParam param = new OrderRemarkParam(orderId, merchantNotes); + String resJson = shopService.post(UPDATE_REMARK_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse updateAddress(String orderId, AddressInfo userAddress) throws WxErrorException { + OrderAddressParam param = new OrderAddressParam(orderId, userAddress); + String resJson = shopService.post(UPDATE_ADDRESS_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse updateDelivery(DeliveryUpdateParam param) throws WxErrorException { + String resJson = shopService.post(UPDATE_EXPRESS_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse acceptAddressModify(String orderId) throws WxErrorException { + OrderIdParam param = new OrderIdParam(orderId); + String resJson = shopService.post(ACCEPT_ADDRESS_MODIFY_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse rejectAddressModify(String orderId) throws WxErrorException { + OrderIdParam param = new OrderIdParam(orderId); + String resJson = shopService.post(REJECT_ADDRESS_MODIFY_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse closeOrder(String orderId) { + // 暂不支持 + return ResponseUtils.internalError(WxChannelBaseResponse.class); + } + + @Override + public DeliveryCompanyResponse listDeliveryCompany() throws WxErrorException { + String resJson = shopService.post(GET_DELIVERY_COMPANY_URL, "{}"); + return ResponseUtils.decode(resJson, DeliveryCompanyResponse.class); + } + + @Override + public WxChannelBaseResponse deliveryOrder(String orderId, List deliveryList) + throws WxErrorException { + DeliverySendParam param = new DeliverySendParam(orderId, deliveryList); + String resJson = shopService.post(DELIVERY_SEND_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java new file mode 100644 index 0000000000..eb168a09e3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java @@ -0,0 +1,180 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.ADD_LIMIT_TASK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.CANCEL_AUDIT_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.DELETE_LIMIT_TASK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.LIST_LIMIT_TASK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DELISTING_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DEL_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LISTING_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_STOCK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.STOP_LIMIT_TASK_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelProductService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskListParam; +import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskParam; +import me.chanjar.weixin.channel.bean.product.SkuStockParam; +import me.chanjar.weixin.channel.bean.product.SkuStockResponse; +import me.chanjar.weixin.channel.bean.product.SpuGetResponse; +import me.chanjar.weixin.channel.bean.product.SpuInfo; +import me.chanjar.weixin.channel.bean.product.SpuListParam; +import me.chanjar.weixin.channel.bean.product.SpuListResponse; +import me.chanjar.weixin.channel.bean.product.SpuUpdateResponse; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店商品服务 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelProductServiceImpl implements WxChannelProductService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelProductServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public SpuUpdateResponse addProduct(SpuInfo info) throws WxErrorException { + String reqJson = JsonUtils.encode(info); + String resJson = shopService.post(SPU_ADD_URL, reqJson); + return ResponseUtils.decode(resJson, SpuUpdateResponse.class); + } + + @Override + public SpuUpdateResponse updateProduct(SpuInfo info) throws WxErrorException { + String reqJson = JsonUtils.encode(info); + String resJson = shopService.post(SPU_UPDATE_URL, reqJson); + return ResponseUtils.decode(resJson, SpuUpdateResponse.class); + } + + @Override + public WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffType, Integer num) + throws WxErrorException { + SkuStockParam param = new SkuStockParam(productId, skuId, diffType, num); + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_UPDATE_STOCK_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + /** + * 生成商品id Json + * + * @param productId 商品ID + * @param dataType 默认取1。1:获取线上数据, 2:获取草稿数据, 3:同时获取线上和草稿数据(注意:需成功上架后才有线上数据) + * @return json + */ + protected String generateProductIdJson(String productId, Integer dataType) { + StringBuilder sb = new StringBuilder(); + sb.append('{'); + if (productId != null) { + sb.append("\"product_id\":").append(productId); + } + + if (dataType != null) { + sb.append(",").append("\"data_type\":").append(dataType); + } + sb.append('}'); + return sb.toString(); + } + + /** + * 简单的商品请求 参数是商品id 只返回基本结果 + * + * @param url 资源路径 + * @param productId 商品ID + * @return 是否成功 + */ + protected WxChannelBaseResponse simpleProductRequest(String url, String productId) throws WxErrorException { + String reqJson = this.generateProductIdJson(productId, null); + String resJson = shopService.post(url, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse deleteProduct(String productId) throws WxErrorException { + return simpleProductRequest(SPU_DEL_URL, productId); + } + + @Override + public WxChannelBaseResponse cancelProductAudit(String productId) throws WxErrorException { + return simpleProductRequest(CANCEL_AUDIT_URL, productId); + } + + @Override + public SpuGetResponse getProduct(String productId, Integer dataType) throws WxErrorException { + String reqJson = this.generateProductIdJson(productId, dataType); + String resJson = shopService.post(SPU_GET_URL, reqJson); + return ResponseUtils.decode(resJson, SpuGetResponse.class); + } + + @Override + public SpuListResponse listProduct(Integer pageSize, String nextKey, Integer status) throws WxErrorException { + SpuListParam param = new SpuListParam(pageSize, nextKey, status); + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_LIST_URL, reqJson); + return ResponseUtils.decode(resJson, SpuListResponse.class); + } + + @Override + public WxChannelBaseResponse upProduct(String productId) throws WxErrorException { + return simpleProductRequest(SPU_LISTING_URL, productId); + } + + @Override + public WxChannelBaseResponse downProduct(String productId) throws WxErrorException { + return simpleProductRequest(SPU_DELISTING_URL, productId); + } + + @Override + public SkuStockResponse getSkuStock(String productId, String skuId) throws WxErrorException { + String reqJson = "{\"product_id\":\"" + productId + "\",\"sku_id\":\"" + skuId + "\"}"; + String resJson = shopService.post(SPU_GET_STOCK_URL, reqJson); + return ResponseUtils.decode(resJson, SkuStockResponse.class); + } + + @Override + public LimitTaskAddResponse addLimitTask(LimitTaskParam param) throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(ADD_LIMIT_TASK_URL, reqJson); + return ResponseUtils.decode(resJson, LimitTaskAddResponse.class); + } + + @Override + public LimitTaskListResponse listLimitTask(Integer pageSize, String nextKey, Integer status) + throws WxErrorException { + LimitTaskListParam param = new LimitTaskListParam(pageSize, nextKey, status); + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(LIST_LIMIT_TASK_URL, reqJson); + return ResponseUtils.decode(resJson, LimitTaskListResponse.class); + } + + @Override + public WxChannelBaseResponse stopLimitTask(String taskId) throws WxErrorException { + String reqJson = "{\"task_id\": \"" + taskId + "\"}"; + String resJson = shopService.post(STOP_LIMIT_TASK_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse deleteLimitTask(String taskId) throws WxErrorException { + String reqJson = "{\"task_id\": \"" + taskId + "\"}"; + String resJson = shopService.post(DELETE_LIMIT_TASK_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelServiceHttpClientImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelServiceHttpClientImpl.java new file mode 100644 index 0000000000..bbe8865269 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelServiceHttpClientImpl.java @@ -0,0 +1,100 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.GET_ACCESS_TOKEN_URL; + +import java.io.IOException; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.common.util.http.HttpType; +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; +import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpHost; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.CloseableHttpClient; + +/** + * @author Zeyes + */ +@Slf4j +public class WxChannelServiceHttpClientImpl extends BaseWxChannelServiceImpl { + + private CloseableHttpClient httpClient; + private HttpHost httpProxy; + + public WxChannelServiceHttpClientImpl() { + + } + + @Override + public void initHttp() { + WxChannelConfig config = this.getConfig(); + ApacheHttpClientBuilder apacheHttpClientBuilder = config.getApacheHttpClientBuilder(); + if (null == apacheHttpClientBuilder) { + apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get(); + } + + apacheHttpClientBuilder.httpProxyHost(config.getHttpProxyHost()) + .httpProxyPort(config.getHttpProxyPort()) + .httpProxyUsername(config.getHttpProxyUsername()) + .httpProxyPassword(config.getHttpProxyPassword()); + + if (config.getHttpProxyHost() != null && config.getHttpProxyPort() > 0) { + this.httpProxy = new HttpHost(config.getHttpProxyHost(), config.getHttpProxyPort()); + } + + this.httpClient = apacheHttpClientBuilder.build(); + } + + @Override + public CloseableHttpClient getRequestHttpClient() { + return httpClient; + } + + @Override + public HttpHost getRequestHttpProxy() { + return httpProxy; + } + + @Override + public HttpType getRequestType() { + return HttpType.APACHE_HTTP; + } + + @Override + protected String doGetAccessTokenRequest() throws IOException { + WxChannelConfig config = this.getConfig(); + String url = StringUtils.isNotEmpty(config.getAccessTokenUrl()) ? config.getAccessTokenUrl() : + StringUtils.isNotEmpty(config.getApiHostUrl()) ? + GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", config.getApiHostUrl()) : GET_ACCESS_TOKEN_URL; + + url = String.format(url, config.getAppid(), config.getSecret()); + + HttpGet httpGet = null; + CloseableHttpResponse response = null; + try { + httpGet = new HttpGet(url); + if (this.getRequestHttpProxy() != null) { + RequestConfig requestConfig = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); + httpGet.setConfig(requestConfig); + } + response = getRequestHttpClient().execute(httpGet); + return new BasicResponseHandler().handleResponse(response); + } finally { + if (httpGet != null) { + httpGet.releaseConnection(); + } + if (response != null) { + try { + response.close(); + } catch (IOException ignored) { + } + } + } + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelServiceImpl.java new file mode 100644 index 0000000000..e3e749dca5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelServiceImpl.java @@ -0,0 +1,13 @@ +package me.chanjar.weixin.channel.api.impl; + +import lombok.extern.slf4j.Slf4j; + +/** + * 视频号小店服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelServiceImpl extends WxChannelServiceHttpClientImpl { + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSharerServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSharerServiceImpl.java new file mode 100644 index 0000000000..676b310288 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSharerServiceImpl.java @@ -0,0 +1,76 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Share.BIND_SHARER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Share.LIST_SHARER_ORDER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Share.LIST_SHARER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Share.SEARCH_SHARER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Share.UNBIND_SHARER_URL; + +import com.google.gson.JsonObject; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelSharerService; +import me.chanjar.weixin.channel.bean.sharer.SharerBindResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerInfoResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerListParam; +import me.chanjar.weixin.channel.bean.sharer.SharerOrderParam; +import me.chanjar.weixin.channel.bean.sharer.SharerOrderResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerSearchParam; +import me.chanjar.weixin.channel.bean.sharer.SharerSearchResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerUnbindParam; +import me.chanjar.weixin.channel.bean.sharer.SharerUnbindResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonHelper; + +/** + * 视频号小店 分享员服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelSharerServiceImpl implements WxChannelSharerService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelSharerServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public SharerBindResponse bindSharer(String username) throws WxErrorException { + JsonObject jsonObject = GsonHelper.buildJsonObject("username", username); + + String resJson = shopService.post(BIND_SHARER_URL, jsonObject); + return ResponseUtils.decode(resJson, SharerBindResponse.class); + } + + @Override + public SharerSearchResponse searchSharer(String openid, String username) throws WxErrorException { + SharerSearchParam param = new SharerSearchParam(openid, username); + String resJson = shopService.post(SEARCH_SHARER_URL, param); + return ResponseUtils.decode(resJson, SharerSearchResponse.class); + } + + @Override + public SharerInfoResponse listSharer(Integer page, Integer pageSize, Integer sharerType) throws WxErrorException { + SharerListParam param = new SharerListParam(page, pageSize, sharerType); + String resJson = shopService.post(LIST_SHARER_URL, param); + return ResponseUtils.decode(resJson, SharerInfoResponse.class); + } + + @Override + public SharerOrderResponse listSharerOrder(SharerOrderParam param) throws WxErrorException { + String resJson = shopService.post(LIST_SHARER_ORDER_URL, param); + return ResponseUtils.decode(resJson, SharerOrderResponse.class); + } + + @Override + public SharerUnbindResponse unbindSharer(List openIds) throws WxErrorException { + SharerUnbindParam param = new SharerUnbindParam(openIds); + String resJson = shopService.post(UNBIND_SHARER_URL, param); + return ResponseUtils.decode(resJson, SharerUnbindResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelWarehouseServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelWarehouseServiceImpl.java new file mode 100644 index 0000000000..b9609e5c6b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelWarehouseServiceImpl.java @@ -0,0 +1,123 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.ADD_COVER_AREA_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.ADD_WAREHOUSE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.DELETE_COVER_AREA_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.GET_WAREHOUSE_PRIORITY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.GET_WAREHOUSE_STOCK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.GET_WAREHOUSE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.LIST_WAREHOUSE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.SET_WAREHOUSE_PRIORITY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.UPDATE_WAREHOUSE_STOCK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Warehouse.UPDATE_WAREHOUSE_URL; + +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelWarehouseService; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.warehouse.LocationPriorityResponse; +import me.chanjar.weixin.channel.bean.warehouse.PriorityLocationParam; +import me.chanjar.weixin.channel.bean.warehouse.StockGetParam; +import me.chanjar.weixin.channel.bean.warehouse.UpdateLocationParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseIdsResponse; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseLocation; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseLocationParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseResponse; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 区域仓库服务实现 + * + * @author Zeyes + */ +@Slf4j +public class WxChannelWarehouseServiceImpl implements WxChannelWarehouseService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxChannelWarehouseServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public WxChannelBaseResponse createWarehouse(WarehouseParam param) throws WxErrorException { + String resJson = shopService.post(ADD_WAREHOUSE_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WarehouseIdsResponse listWarehouse(Integer pageSize, String nextKey) throws WxErrorException { + StreamPageParam param = new StreamPageParam(pageSize, nextKey); + String resJson = shopService.post(LIST_WAREHOUSE_URL, param); + return ResponseUtils.decode(resJson, WarehouseIdsResponse.class); + } + + @Override + public WarehouseResponse getWarehouse(String outWarehouseId) throws WxErrorException { + String reqJson = "{\"out_warehouse_id\":\"" + outWarehouseId + "\"}"; + String resJson = shopService.post(GET_WAREHOUSE_URL, reqJson); + return ResponseUtils.decode(resJson, WarehouseResponse.class); + } + + @Override + public WxChannelBaseResponse updateWarehouse(String outWarehouseId, String name, String intro) + throws WxErrorException { + String reqJson = "{\"out_warehouse_id\":\"" + outWarehouseId + + "\",\"name\":\"" + name + "\",\"intro\":\"" + intro + "\"}"; + String resJson = shopService.post(UPDATE_WAREHOUSE_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse addWarehouseArea(String outWarehouseId, List coverLocations) + throws WxErrorException { + UpdateLocationParam param = new UpdateLocationParam(outWarehouseId, coverLocations); + String resJson = shopService.post(ADD_COVER_AREA_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse deleteWarehouseArea(String outWarehouseId, List coverLocations) + throws WxErrorException { + UpdateLocationParam param = new UpdateLocationParam(outWarehouseId, coverLocations); + String resJson = shopService.post(DELETE_COVER_AREA_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + + } + + @Override + public WxChannelBaseResponse setWarehousePriority(PriorityLocationParam param) throws WxErrorException { + String resJson = shopService.post(SET_WAREHOUSE_PRIORITY_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + + } + + @Override + public LocationPriorityResponse getWarehousePriority(Integer addressId1, Integer addressId2, Integer addressId3, + Integer addressId4) throws WxErrorException { + WarehouseLocationParam param = new WarehouseLocationParam(addressId1, addressId2, addressId3, addressId4); + String resJson = shopService.post(GET_WAREHOUSE_PRIORITY_URL, param); + return ResponseUtils.decode(resJson, LocationPriorityResponse.class); + } + + @Override + public WxChannelBaseResponse updateWarehouseStock(WarehouseStockParam param) throws WxErrorException { + String resJson = shopService.post(UPDATE_WAREHOUSE_STOCK_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WarehouseStockResponse getWarehouseStock(String productId, String skuId, String outWarehouseId) + throws WxErrorException { + StockGetParam param = new StockGetParam(productId, skuId, outWarehouseId); + String resJson = shopService.post(GET_WAREHOUSE_STOCK_URL, param); + return ResponseUtils.decode(resJson, WarehouseStockResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueProductServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueProductServiceImpl.java new file mode 100644 index 0000000000..29620874e2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueProductServiceImpl.java @@ -0,0 +1,71 @@ +package me.chanjar.weixin.channel.api.impl; + + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.BATCH_ADD_LEAGUE_ITEM_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.DELETE_LEAGUE_ITEM_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_LEAGUE_ITEM_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_LEAGUE_ITEM_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.UPDATE_LEAGUE_ITEM_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxLeagueProductService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.product.BatchAddParam; +import me.chanjar.weixin.channel.bean.league.product.BatchAddResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductDeleteParam; +import me.chanjar.weixin.channel.bean.league.product.ProductDetailParam; +import me.chanjar.weixin.channel.bean.league.product.ProductDetailResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductListParam; +import me.chanjar.weixin.channel.bean.league.product.ProductListResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductUpdateParam; +import me.chanjar.weixin.channel.bean.league.product.ProductUpdateResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + + +/** + * 视频号小店 商品服务 + * + * @author Zeyes + */ +@Slf4j +public class WxLeagueProductServiceImpl implements WxLeagueProductService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxLeagueProductServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public BatchAddResponse batchAddProduct(BatchAddParam param) throws WxErrorException { + String resJson = shopService.post(BATCH_ADD_LEAGUE_ITEM_URL, param); + return ResponseUtils.decode(resJson, BatchAddResponse.class); + } + + @Override + public ProductUpdateResponse updateProduct(ProductUpdateParam param) throws WxErrorException { + String resJson = shopService.post(UPDATE_LEAGUE_ITEM_URL, param); + return ResponseUtils.decode(resJson, ProductUpdateResponse.class); + } + + @Override + public WxChannelBaseResponse deleteProduct(Integer type, String productId, String infoId) throws WxErrorException { + ProductDeleteParam param = new ProductDeleteParam(type, productId, infoId); + String resJson = shopService.post(DELETE_LEAGUE_ITEM_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public ProductDetailResponse getProductDetail(ProductDetailParam param) throws WxErrorException { + String resJson = shopService.post(GET_LEAGUE_ITEM_URL, param); + return ResponseUtils.decode(resJson, ProductDetailResponse.class); + } + + @Override + public ProductListResponse listProduct(ProductListParam param) throws WxErrorException { + String resJson = shopService.post(GET_LEAGUE_ITEM_LIST_URL, param); + return ResponseUtils.decode(resJson, ProductListResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeaguePromoterServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeaguePromoterServiceImpl.java new file mode 100644 index 0000000000..a6bfddfbef --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeaguePromoterServiceImpl.java @@ -0,0 +1,69 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.ADD_PROMOTER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.DELETE_PROMOTER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.EDIT_PROMOTER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_PROMOTER_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_PROMOTER_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxLeaguePromoterService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.promoter.PromoterInfoResponse; +import me.chanjar.weixin.channel.bean.league.promoter.PromoterListParam; +import me.chanjar.weixin.channel.bean.league.promoter.PromoterListResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 达人服务 + * + * @author Zeyes + */ +@Slf4j +public class WxLeaguePromoterServiceImpl implements WxLeaguePromoterService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxLeaguePromoterServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public WxChannelBaseResponse addPromoter(String finderId) throws WxErrorException { + String reqJson = "{\"finder_id\":\"" + finderId + "\"}"; + String resJson = shopService.post(ADD_PROMOTER_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse updatePromoter(String finderId, int type) throws WxErrorException { + String reqJson = "{\"finder_id\":\"" + finderId + "\",\"type\":" + type + "}"; + String resJson = shopService.post(EDIT_PROMOTER_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse deletePromoter(String finderId) throws WxErrorException { + String reqJson = "{\"finder_id\":\"" + finderId + "\"}"; + String resJson = shopService.post(DELETE_PROMOTER_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public PromoterInfoResponse getPromoterInfo(String finderId) throws WxErrorException { + String reqJson = "{\"finder_id\":\"" + finderId + "\"}"; + String resJson = shopService.post(GET_PROMOTER_URL, reqJson); + return ResponseUtils.decode(resJson, PromoterInfoResponse.class); + } + + @Override + public PromoterListResponse listPromoter(Integer pageIndex, Integer pageSize, Integer status) + throws WxErrorException { + PromoterListParam param = new PromoterListParam(pageIndex, pageSize, status); + String resJson = shopService.post(GET_PROMOTER_LIST_URL, param); + return ResponseUtils.decode(resJson, PromoterListResponse.class); + + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueSupplierServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueSupplierServiceImpl.java new file mode 100644 index 0000000000..d69296bd0f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueSupplierServiceImpl.java @@ -0,0 +1,107 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_BALANCE_FLOW_DETAIL_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_BALANCE_FLOW_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_BALANCE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_ITEM_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_ITEM_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_ORDER_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_ORDER_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_SHOP_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_SHOP_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxLeagueSupplierService; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListParam; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductDetailParam; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductListParam; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductResponse; +import me.chanjar.weixin.channel.bean.league.supplier.FlowListParam; +import me.chanjar.weixin.channel.bean.league.supplier.ShopDetailResponse; +import me.chanjar.weixin.channel.bean.league.supplier.ShopListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierBalanceResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowDetailResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowListResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 视频号小店 优选联盟 团长数据服务 + * + * @author Zeyes + */ +@Slf4j +public class WxLeagueSupplierServiceImpl implements WxLeagueSupplierService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxLeagueSupplierServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public SupplierBalanceResponse getBalanceInfo() throws WxErrorException { + String resJson = shopService.post(GET_SUPPLIER_BALANCE_URL, "{}"); + return ResponseUtils.decode(resJson, SupplierBalanceResponse.class); + } + + @Override + public SupplierFlowDetailResponse getFlowDetail(String flowId) throws WxErrorException { + String reqJson = "{\"flow_id\":\"" + flowId + "\"}"; + String resJson = shopService.post(GET_SUPPLIER_BALANCE_FLOW_DETAIL_URL, reqJson); + return ResponseUtils.decode(resJson, SupplierFlowDetailResponse.class); + } + + @Override + public SupplierFlowListResponse getFlowList(FlowListParam param) throws WxErrorException { + String resJson = shopService.post(GET_SUPPLIER_BALANCE_FLOW_LIST_URL, param); + return ResponseUtils.decode(resJson, SupplierFlowListResponse.class); + } + + @Override + public CoopProductResponse getProductDetail(String productId, String appId) throws WxErrorException { + CoopProductDetailParam param = new CoopProductDetailParam(productId, appId); + String resJson = shopService.post(GET_SUPPLIER_ITEM_URL, param); + return ResponseUtils.decode(resJson, CoopProductResponse.class); + } + + @Override + public CoopProductListResponse getProductList(String appid, Integer pageSize, String nextKey) + throws WxErrorException { + CoopProductListParam param = new CoopProductListParam(appid, pageSize, nextKey); + String resJson = shopService.post(GET_SUPPLIER_ITEM_LIST_URL, param); + return ResponseUtils.decode(resJson, CoopProductListResponse.class); + } + + @Override + public CommissionOrderResponse getCommissionOrder(String orderId, String skuId) throws WxErrorException { + String reqJson = "{\"order_id\":\"" + orderId + "\",\"sku_id\":\"" + skuId + "\"}"; + String resJson = shopService.post(GET_SUPPLIER_ORDER_URL, reqJson); + return ResponseUtils.decode(resJson, CommissionOrderResponse.class); + } + + @Override + public CommissionOrderListResponse getCommissionOrderList(CommissionOrderListParam param) throws WxErrorException { + String resJson = shopService.post(GET_SUPPLIER_ORDER_LIST_URL, param); + return ResponseUtils.decode(resJson, CommissionOrderListResponse.class); + } + + @Override + public ShopDetailResponse getShopDetail(String appid) throws WxErrorException { + String reqJson = "{\"appid\":\"" + appid + "\"}"; + String resJson = shopService.post(GET_SUPPLIER_SHOP_URL, reqJson); + return ResponseUtils.decode(resJson, ShopDetailResponse.class); + } + + @Override + public ShopListResponse getShopList(Integer pageSize, String nextKey) throws WxErrorException { + StreamPageParam param = new StreamPageParam(pageSize, nextKey); + String resJson = shopService.post(GET_SUPPLIER_SHOP_LIST_URL, param); + return ResponseUtils.decode(resJson, ShopListResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueWindowServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueWindowServiceImpl.java new file mode 100644 index 0000000000..a59fc6efa5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxLeagueWindowServiceImpl.java @@ -0,0 +1,81 @@ +package me.chanjar.weixin.channel.api.impl; + +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.ADD_SUPPLIER_GOODS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_AUTH_STATUS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_AUTH_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.GET_SUPPLIER_GOODS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.LIST_SUPPLIER_GOODS_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.League.REMOVE_SUPPLIER_GOODS_URL; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxLeagueWindowService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.window.AuthInfoResponse; +import me.chanjar.weixin.channel.bean.league.window.AuthStatusResponse; +import me.chanjar.weixin.channel.bean.league.window.ProductSearchParam; +import me.chanjar.weixin.channel.bean.league.window.WindowProductListResponse; +import me.chanjar.weixin.channel.bean.league.window.WindowProductParam; +import me.chanjar.weixin.channel.bean.league.window.WindowProductResponse; +import me.chanjar.weixin.channel.util.ResponseUtils; +import me.chanjar.weixin.common.error.WxErrorException; + + +/** + * 视频号小店 优选联盟 团长合作达人管理服务 + * + * @author Zeyes + */ +@Slf4j +public class WxLeagueWindowServiceImpl implements WxLeagueWindowService { + + /** 微信商店服务 */ + private final BaseWxChannelServiceImpl shopService; + + public WxLeagueWindowServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public WxChannelBaseResponse addProduct(String appid, String openfinderid, String productId) + throws WxErrorException { + WindowProductParam param = new WindowProductParam(appid, openfinderid, productId); + String resJson = shopService.post(ADD_SUPPLIER_GOODS_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WindowProductListResponse listProduct(ProductSearchParam param) throws WxErrorException { + String resJson = shopService.post(LIST_SUPPLIER_GOODS_URL, param); + return ResponseUtils.decode(resJson, WindowProductListResponse.class); + } + + @Override + public WxChannelBaseResponse removeProduct(String appid, String openfinderid, String productId) + throws WxErrorException { + WindowProductParam param = new WindowProductParam(appid, openfinderid, productId); + String resJson = shopService.post(REMOVE_SUPPLIER_GOODS_URL, param); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WindowProductResponse getProductDetail(String appid, String openfinderid, String productId) + throws WxErrorException { + WindowProductParam param = new WindowProductParam(appid, openfinderid, productId); + String resJson = shopService.post(GET_SUPPLIER_GOODS_URL, param); + return ResponseUtils.decode(resJson, WindowProductResponse.class); + } + + @Override + public AuthInfoResponse getWindowAuthInfo(String finderId) throws WxErrorException { + String reqJson = "{\"finder_id\":\"" + finderId + "\"}"; + String resJson = shopService.post(GET_SUPPLIER_AUTH_URL, reqJson); + return ResponseUtils.decode(resJson, AuthInfoResponse.class); + } + + @Override + public AuthStatusResponse getWindowAuthStatus(String finderId) throws WxErrorException { + String reqJson = "{\"finder_id\":\"" + finderId + "\"}"; + String resJson = shopService.post(GET_SUPPLIER_AUTH_STATUS_URL, reqJson); + return ResponseUtils.decode(resJson, AuthStatusResponse.class); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressAddParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressAddParam.java new file mode 100644 index 0000000000..a831de6655 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressAddParam.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 地址 请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class AddressAddParam implements Serializable { + + private static final long serialVersionUID = 6778585213498438738L; + + /** 地址id */ + @JsonProperty("address_detail") + private AddressDetail addressDetail; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressCode.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressCode.java new file mode 100644 index 0000000000..c7c885f0ab --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressCode.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 地址编码 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AddressCode implements Serializable { + + private static final long serialVersionUID = -6782328785056142627L; + + /** 地址名称 */ + @JsonProperty("name") + private String name; + + /** 地址行政编码 */ + @JsonProperty("code") + private Integer code; + + /** 地址级别 1-省级 2-市级 3-区县级 4-街道 */ + @JsonProperty("level") + private Integer level; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressCodeResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressCodeResponse.java new file mode 100644 index 0000000000..09ede50c38 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressCodeResponse.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 地址编码 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AddressCodeResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -8994407971295563982L; + + /** 本行政编码地址信息 */ + @JsonProperty("addrs_msg") + private AddressCode current; + + /** 下一级所有地址信息 */ + @JsonProperty("next_level_addrs") + private List list; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressDetail.java new file mode 100644 index 0000000000..88f4945e20 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressDetail.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AddressInfo; + +/** + * 用户地址 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AddressDetail implements Serializable { + + private static final long serialVersionUID = -7839578838482198641L; + + /** 地址id */ + @JsonProperty("address_id") + private String addressId; + + /** 联系人姓名 */ + @JsonProperty("name") + private String name; + + /** 地区信息 */ + @JsonProperty("address_info") + private AddressInfo addressInfo; + + /** 座机 */ + @JsonProperty("landline") + private String landline; + + /** 是否为发货地址 */ + @JsonProperty("send_addr") + private Boolean sendAddr; + + /** 是否为收货地址 */ + @JsonProperty("recv_addr") + private Boolean recvAddr; + + /** 是否为默认发货地址 */ + @JsonProperty("default_send") + private Boolean defaultSend; + + /** 是否为默认收货地址 */ + @JsonProperty("default_recv") + private Boolean defaultRecv; + + /** 创建时间戳(秒) */ + @JsonProperty("create_time") + private Long createTime; + + /** 更新时间戳(秒) */ + @JsonProperty("update_time") + private Long updateTime; + + /** 线下配送地址类型 */ + @JsonProperty("address_type") + private OfflineAddressType addressType; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressIdParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressIdParam.java new file mode 100644 index 0000000000..d1eb7e0b46 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressIdParam.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 地址id 请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class AddressIdParam implements Serializable { + + private static final long serialVersionUID = -7001183932180608746L; + + /** 地址id */ + @JsonProperty("address_id") + private String addressId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressIdResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressIdResponse.java new file mode 100644 index 0000000000..f6505efa15 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressIdResponse.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 地址id 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AddressIdResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -9218327846685744008L; + + /** 地址id */ + @JsonProperty("address_id") + private String addressId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressInfoResponse.java new file mode 100644 index 0000000000..957d0162a8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressInfoResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 地址id 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AddressInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 8203853673226715673L; + + /** 地址详情 */ + @JsonProperty("address_detail") + private AddressDetail addressDetail; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressListParam.java new file mode 100644 index 0000000000..c62cf39fb8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressListParam.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.OffsetParam; + +/** + * 用户地址 列表 请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(Include.NON_NULL) +public class AddressListParam extends OffsetParam { + + private static final long serialVersionUID = -4434287264623932176L; + + public AddressListParam(Integer offset, Integer limit) { + super(offset, limit); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressListResponse.java new file mode 100644 index 0000000000..b8846f9aa3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/AddressListResponse.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 地址列表 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AddressListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -3997164605170764105L; + + /** 地址详情 */ + @JsonProperty("address_id_list") + private List ids; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/OfflineAddressType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/OfflineAddressType.java new file mode 100644 index 0000000000..81dd169399 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/address/OfflineAddressType.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.address; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 线下配送地址类型 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OfflineAddressType implements Serializable { + + private static final long serialVersionUID = 636850757572901377L; + + /** 1表示同城配送 */ + @JsonProperty("same_city") + private Integer sameCity; + + /** 1表示用户自提 */ + @JsonProperty("pickup") + private Integer pickup; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleAcceptParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleAcceptParam.java new file mode 100644 index 0000000000..ebc63a2190 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleAcceptParam.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * 售后单同意信息 + * + * @author Zeyes + */ +@Data +@JsonInclude(Include.NON_NULL) +public class AfterSaleAcceptParam extends AfterSaleIdParam { + + private static final long serialVersionUID = -4352801757159074950L; + /** 同意退货时传入地址id */ + @JsonProperty("address_id") + private String addressId; + + public AfterSaleAcceptParam() { + } + + public AfterSaleAcceptParam(String afterSaleOrderId, String addressId) { + super(afterSaleOrderId); + this.addressId = addressId; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleDetail.java new file mode 100644 index 0000000000..aa1e7b400f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleDetail.java @@ -0,0 +1,42 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后详情 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AfterSaleDetail implements Serializable { + + private static final long serialVersionUID = -8130659179770831047L; + /** 售后描述 */ + @JsonProperty("desc") + private String desc; + + /** 是否已经收到货 */ + @JsonProperty("receive_product") + private Boolean receiveProduct; + + /** 是否已经收到货 */ + @JsonProperty("cancel_time") + private Long cancelTime; + + /** 举证图片media_id列表,根据mediaid获取文件内容接口 */ + @JsonProperty("prove_imgs") + private List proveImgs; + + /** 联系电话 */ + @JsonProperty("tel_number") + private String telNumber; + + /** 举证图片media_id列表,根据mediaid获取文件内容接口 */ + @JsonProperty("media_id_list") + private List mediaIdList; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleIdParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleIdParam.java new file mode 100644 index 0000000000..1e16a72395 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleIdParam.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后单id信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class AfterSaleIdParam implements Serializable { + + private static final long serialVersionUID = 4974332291476116540L; + /** 售后单号 */ + @JsonProperty("after_sale_order_id") + private String afterSaleOrderId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleInfo.java new file mode 100644 index 0000000000..b0d668b30e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleInfo.java @@ -0,0 +1,85 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后单信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AfterSaleInfo implements Serializable { + + private static final long serialVersionUID = 6595670817781635247L; + /** 售后单号 */ + @JsonProperty("after_sale_order_id") + private String afterSaleOrderId; + + /** 售后状态 {@link me.chanjar.weixin.channel.enums.AfterSaleStatus} */ + @JsonProperty("status") + private String status; + + /** 订单id */ + @JsonProperty("order_id") + private String orderId; + + /** 买家身份标识 */ + @JsonProperty("openid") + private String openid; + + /** 买家在开放平台的唯一标识符,若当前视频号小店已绑定到微信开放平台帐号下会返回 */ + @JsonProperty("unionid") + private String unionid; + + /** 售后相关商品信息 */ + @JsonProperty("product_info") + private AfterSaleProductInfo productInfo; + + /** 售后详情 */ + @JsonProperty("details") + private AfterSaleDetail details; + + /** 退款详情 */ + @JsonProperty("refund_info") + private RefundInfo refundInfo; + + /** 用户退货信息 */ + @JsonProperty("return_info") + private ReturnInfo returnInfo; + + /** 商家上传的信息 */ + @JsonProperty("merchant_upload_info") + private MerchantUploadInfo merchantUploadInfo; + + /** 创建时间 时间戳 秒 */ + @JsonProperty("create_time") + private Long createTime; + + /** 更新时间 时间戳 秒 */ + @JsonProperty("update_time") + private Long updateTime; + + /** 退款原因(后续新增的原因将不再有字面含义,请参考reason_text) */ + @JsonProperty("reason") + private String reason; + + /** 退款原因解释 */ + @JsonProperty("reason_text") + private String reasonText; + + /** 退款结果 */ + @JsonProperty("refund_resp") + private RefundResp refundResp; + + /** 售后类型。REFUND:退款;RETURN:退货退款 */ + @JsonProperty("type") + private String type; + + /** 纠纷id,该字段可用于获取纠纷信息 */ + @JsonProperty("complaint_id") + private String complaintId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleInfoResponse.java new file mode 100644 index 0000000000..adedf72f03 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleInfoResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 售后单 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AfterSaleInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -752661975153491902L; + /** 售后单 */ + @JsonProperty("after_sale_order") + private AfterSaleInfo info; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleListParam.java new file mode 100644 index 0000000000..78cc394085 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleListParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后单列表 请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class AfterSaleListParam implements Serializable { + + private static final long serialVersionUID = -103549981452112069L; + /** 订单创建启始时间 unix时间戳 */ + @JsonProperty("begin_create_time") + private Long beginCreateTime; + + /** 订单创建结束时间,end_create_time减去begin_create_time不得大于24小时 unix时间戳 */ + @JsonProperty("end_create_time") + private Long endCreateTime; + + /** 翻页参数,从第二页开始传,来源于上一页的返回值 */ + @JsonProperty("next_key") + private String nextKey; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleListResponse.java new file mode 100644 index 0000000000..3ad67cffcf --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleListResponse.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 售后单列表 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode +public class AfterSaleListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5033313416948732123L; + /** 售后单号列表 */ + @JsonProperty("after_sale_order_id_list") + private List ids; + + /** 翻页参数 */ + private String nextKey; + + /** 是否还有数据 */ + @JsonProperty("has_more") + private Boolean hasMore; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleProductInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleProductInfo.java new file mode 100644 index 0000000000..ffcaf320ca --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleProductInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后相关商品信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AfterSaleProductInfo implements Serializable { + + private static final long serialVersionUID = 4205179093262757775L; + /** 商品spu id */ + @JsonProperty("product_id") + private String productId; + + /** 商品sku id */ + @JsonProperty("sku_id") + private String skuId; + + /** 售后数量 */ + @JsonProperty("count") + private Integer count; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleRejectParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleRejectParam.java new file mode 100644 index 0000000000..080665ac00 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleRejectParam.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * 售后单拒绝信息 + * + * @author Zeyes + */ +@Data +@JsonInclude(Include.NON_NULL) +public class AfterSaleRejectParam extends AfterSaleIdParam { + + private static final long serialVersionUID = -7507483859864253314L; + /** 拒绝原因 */ + @JsonProperty("reject_reason") + private String rejectReason; + + public AfterSaleRejectParam() { + } + + public AfterSaleRejectParam(String afterSaleOrderId, String rejectReason) { + super(afterSaleOrderId); + this.rejectReason = rejectReason; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleReturnParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleReturnParam.java new file mode 100644 index 0000000000..47e815c8dd --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/AfterSaleReturnParam.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import me.chanjar.weixin.channel.bean.base.AddressInfo; + +/** + * 退货信息 + * + * @author Zeyes + */ +@Data +public class AfterSaleReturnParam implements Serializable { + + private static final long serialVersionUID = -1101993925465293521L; + /** 微信侧售后单号 */ + @JsonProperty("aftersale_id") + private Long afterSaleId; + + /** 外部售后单号,和aftersale_id二选一 */ + @JsonProperty("out_aftersale_id") + private String outAfterSaleId; + + /** 商家收货地址 */ + @JsonProperty("address_info") + private AddressInfo addressInfo; + + public AfterSaleReturnParam() { + } + + public AfterSaleReturnParam(Long afterSaleId, String outAfterSaleId) { + this.outAfterSaleId = outAfterSaleId; + this.afterSaleId = afterSaleId; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/MerchantUploadInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/MerchantUploadInfo.java new file mode 100644 index 0000000000..805c3a3f6e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/MerchantUploadInfo.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商家上传的信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class MerchantUploadInfo implements Serializable { + + private static final long serialVersionUID = 373513419356603563L; + /** 拒绝原因 */ + @JsonProperty("reject_reason") + private String rejectReason; + + /** 退款凭证 */ + @JsonProperty("refund_certificates") + private List refundCertificates; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundEvidenceParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundEvidenceParam.java new file mode 100644 index 0000000000..c81ae042d4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundEvidenceParam.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 退款凭证信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RefundEvidenceParam implements Serializable { + + private static final long serialVersionUID = 2117305897849528009L; + /** 售后单号 */ + @JsonProperty("after_sale_order_id") + private String afterSaleOrderId; + + /** 描述 */ + @JsonProperty("desc") + private String desc; + + /** 凭证图片列表 */ + @JsonProperty("refund_certificates") + private List certificates; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundInfo.java new file mode 100644 index 0000000000..9837b72b28 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundInfo.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 退款信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class RefundInfo implements Serializable { + + private static final long serialVersionUID = -6994243947898889309L; + /** 退款金额(分) */ + @JsonProperty("amount") + private Integer amount; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundResp.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundResp.java new file mode 100644 index 0000000000..83b7039a77 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/RefundResp.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 退款结果 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class RefundResp implements Serializable { + + private static final long serialVersionUID = 6549707043779644156L; + /** code */ + @JsonProperty("code") + private String code; + + /** ret */ + @JsonProperty("ret") + private Integer ret; + + /** message */ + @JsonProperty("message") + private String message; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/ReturnInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/ReturnInfo.java new file mode 100644 index 0000000000..08238d5484 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/ReturnInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 用户退货信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ReturnInfo implements Serializable { + + private static final long serialVersionUID = 1643844664701376892L; + /** 快递单号 */ + @JsonProperty("waybill_id") + private String waybillId; + + /** 物流公司id */ + @JsonProperty("delivery_id") + private String deliveryId; + + /** 物流公司名称 */ + @JsonProperty("delivery_name") + private String deliveryName; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditApplyResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditApplyResponse.java new file mode 100644 index 0000000000..547207c82b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditApplyResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.audit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 审核提交结果响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AuditApplyResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -3950614749162384497L; + + /** 类目列表 */ + @JsonProperty("audit_id") + private String auditId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditResponse.java new file mode 100644 index 0000000000..3ef07387d1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.audit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 审核结果响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AuditResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 9218713381520774914L; + + /** 审核结果 1:审核中,3:审核成功,2:审核拒绝,12:主动取消申请单 */ + @JsonProperty("data") + private AuditResult data; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditResult.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditResult.java new file mode 100644 index 0000000000..89aaa8a267 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/AuditResult.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.audit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 审核结果 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AuditResult implements Serializable { + + private static final long serialVersionUID = 1846416634865665240L; + + /** 审核状态, 0:审核中,1:审核成功,9:审核拒绝, 12:主动取消 */ + @JsonProperty("status") + private Integer status; + + /** 如果审核拒绝,返回拒绝原因 */ + @JsonProperty("reject_reason") + private String rejectReason; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/CategoryAuditInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/CategoryAuditInfo.java new file mode 100644 index 0000000000..72a84bc922 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/CategoryAuditInfo.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.channel.bean.audit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 类目审核信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CategoryAuditInfo implements Serializable { + + private static final long serialVersionUID = -8792967130645424788L; + + /** 一级类目,字符类型,最长不超过10 */ + @JsonProperty("level1") + private Long level1; + + /** 二级类目,字符类型,最长不超过10 */ + @JsonProperty("level2") + private Long level2; + + /** 三级类目,字符类型,最长不超过10 */ + @JsonProperty("level3") + private Long level3; + + /** 资质材料,图片url,图片类型,最多不超过10张 */ + @JsonProperty("certificate") + private List certificates; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/CategoryAuditRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/CategoryAuditRequest.java new file mode 100644 index 0000000000..a311bf0d2f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/CategoryAuditRequest.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.audit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 类目审核信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CategoryAuditRequest implements Serializable { + + private static final long serialVersionUID = -1151634735247657643L; + + @JsonProperty("category_info") + private CategoryAuditInfo categoryInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/ProductAuditInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/ProductAuditInfo.java new file mode 100644 index 0000000000..7693f23ed3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/audit/ProductAuditInfo.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.channel.bean.audit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品审核信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ProductAuditInfo implements Serializable { + + private static final long serialVersionUID = -5264206679057480206L; + + /** 审核单id */ + @JsonProperty("audit_id") + private String auditId; + + /** 上一次提交时间, yyyy-MM-dd HH:mm:ss */ + @JsonProperty("submit_time") + private String submitTime; + + /** 上一次审核时间, yyyy-MM-dd HH:mm:ss */ + @JsonProperty("audit_time") + private String auditTime; + + /** 拒绝理由,只有edit_status为3时出现 */ + @JsonProperty("reject_reason") + private String rejectReason; + + @JsonProperty("func_type") + private Integer funcType; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/AddressInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/AddressInfo.java new file mode 100644 index 0000000000..3c713840a4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/AddressInfo.java @@ -0,0 +1,70 @@ +package me.chanjar.weixin.channel.bean.base; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 地址信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +public class AddressInfo implements Serializable { + + private static final long serialVersionUID = 6928300709804576100L; + + /** 收件人姓名 */ + @JsonProperty("user_name") + private String userName; + + /** 收件人手机号码 */ + @JsonProperty("tel_number") + private String telNumber; + + /** 邮编 */ + @JsonProperty("postal_code") + private String postalCode; + + /** 省份 */ + @JsonProperty("province_name") + private String provinceName; + + /** 城市 */ + @JsonProperty("city_name") + private String cityName; + + /** 区 */ + @JsonProperty("county_name") + private String countyName; + + /** 详细地址 */ + @JsonProperty("detail_info") + private String detailInfo; + + /** 国家码 */ + @JsonProperty("national_code") + private String nationalCode; + + /** 门牌号码 */ + @JsonProperty("house_number") + private String houseNumber; + + /** 纬度 */ + @JsonProperty("lat") + private Double lat; + + /** 经度 */ + @JsonProperty("lng") + private Double lng; + + public AddressInfo(String provinceName, String cityName, String countyName) { + this.provinceName = provinceName; + this.cityName = cityName; + this.countyName = countyName; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/AttrInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/AttrInfo.java new file mode 100644 index 0000000000..ca6ce7a750 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/AttrInfo.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.base; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 属性 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AttrInfo implements Serializable { + + private static final long serialVersionUID = -790859309885311785L; + + /** 销售属性key(自定义),字符类型,最长不超过40 */ + @JsonProperty("attr_key") + private String key; + + /** 销售属性value(自定义),字符类型,最长不超过40,相同key下不能超过100个不同value */ + @JsonProperty("attr_value") + private String value; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/OffsetParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/OffsetParam.java new file mode 100644 index 0000000000..ebfad1bf21 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/OffsetParam.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.base; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 偏移参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class OffsetParam implements Serializable { + + private static final long serialVersionUID = -1268796871980541662L; + + /** 起始位置 */ + @JsonProperty("offset") + private Integer offset; + /** 拉取个数 */ + @JsonProperty("limit") + private Integer limit; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/PageParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/PageParam.java new file mode 100644 index 0000000000..d76e48d3b6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/PageParam.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.base; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分页参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PageParam implements Serializable { + + private static final long serialVersionUID = -2606033044242617845L; + + /** 页码 */ + @JsonProperty("page") + protected Integer page; + + /** 每页订单数,上限100 */ + @JsonProperty("page_size") + protected Integer pageSize; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/StreamPageParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/StreamPageParam.java new file mode 100644 index 0000000000..6f3fb76d71 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/StreamPageParam.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.base; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 流式分页参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class StreamPageParam implements Serializable { + + private static final long serialVersionUID = -4098060161712929196L; + + /** 每页订单数,上限100 */ + @JsonProperty("page_size") + protected Integer pageSize; + + /** 分页参数,上一页请求返回 */ + @JsonProperty("next_key") + protected String nextKey; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/TimeRange.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/TimeRange.java new file mode 100644 index 0000000000..f681794835 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/TimeRange.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.base; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 时间范围 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class TimeRange implements Serializable { + + private static final long serialVersionUID = -8149679871789511479L; + + /** 开始时间 秒级时间戳 */ + @JsonProperty("start_time") + private Long startTime; + + /** 结束时间 秒级时间戳 */ + @JsonProperty("end_time") + private Long endTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/WxChannelBaseResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/WxChannelBaseResponse.java new file mode 100644 index 0000000000..b20d7f4b33 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/base/WxChannelBaseResponse.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.channel.bean.base; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.StringJoiner; + +/** + * 视频号小店 基础响应 + * + * @author Zeyes + */ +public class WxChannelBaseResponse implements Serializable { + + private static final long serialVersionUID = 3141420881984171781L; + + /** 请求成功状态码 */ + public static final int SUCCESS_CODE = 0; + public static final int INTERNAL_ERROR_CODE = -99; + + /** + * 错误码 + */ + @JsonProperty("errcode") + protected int errCode; + + /** + * 错误消息 + */ + @JsonProperty("errmsg") + protected String errMsg; + + /** + * 错误代码 + 错误消息 + * + * @return String + */ + public String errorMessage() { + return "errcode: " + errCode + ", errmsg: " + errMsg; + } + + public boolean isSuccess() { + return errCode == SUCCESS_CODE; + } + + public int getErrCode() { + return errCode; + } + + public void setErrCode(int errCode) { + this.errCode = errCode; + } + + public String getErrMsg() { + return errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } + + @Override + public String toString() { + return new StringJoiner(", ", WxChannelBaseResponse.class.getSimpleName() + "[", "]") + .add("errCode=" + errCode) + .add("errMsg='" + errMsg + "'") + .toString(); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BasicBrand.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BasicBrand.java new file mode 100644 index 0000000000..714740f843 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BasicBrand.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 基础品牌信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BasicBrand implements Serializable { + + private static final long serialVersionUID = -1991771439710177859L; + + /** 品牌库中的品牌编号(Long) */ + @JsonProperty("brand_id") + private String brandId; + + /** 品牌商标中文名 */ + @JsonProperty("ch_name") + private String chName; + + /** 品牌商标英文名 */ + @JsonProperty("en_name") + private String enName; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/Brand.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/Brand.java new file mode 100644 index 0000000000..92f4f41acc --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/Brand.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 品牌信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Brand extends BasicBrand { + + private static final long serialVersionUID = 4648597514861057019L; + + /** 商标分类号, 取值范围1-45 */ + @JsonProperty("classification_no") + private String classificationNo; + + /** 商标类型, 取值1:R标; 2: TM标 */ + @JsonProperty("trade_mark_symbol") + private Integer tradeMarkSymbol; + + /** 商标注册信息 */ + @JsonProperty("register_details") + private BrandRegisterDetail registerDetail; + + /** 商标申请信息 */ + @JsonProperty("application_details") + private BrandApplicationDetail applicationDetail; + + /** 商标授权信息, 取值1:自有品牌; 2: 授权品牌 */ + @JsonProperty("grant_type") + private Integer grantType; + + /** 授权品牌信息 */ + @JsonProperty("grant_details") + private BrandGrantDetail grantDetail; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandApplicationDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandApplicationDetail.java new file mode 100644 index 0000000000..48575f27cd --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandApplicationDetail.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商标申请信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BrandApplicationDetail implements Serializable { + + private static final long serialVersionUID = 2145344855482129473L; + + /** 商标申请受理时间, TM标时必填 */ + @JsonProperty("acceptance_time") + private Long acceptanceTime; + + /** 商标注册申请受理书file_id, TM标时必填, 限制最多传1张, 需要先调用“资质上传”接口上传资质图片 */ + @JsonProperty("acceptance_certification") + private List acceptanceCertification; + + /** 商标申请号, TM标时必填 */ + @JsonProperty("acceptance_no") + private String acceptanceNo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandApplyListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandApplyListResponse.java new file mode 100644 index 0000000000..16e7f3ae82 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandApplyListResponse.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 品牌申请列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BrandApplyListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 243021267020609148L; + + /** 品牌资质申请信息 */ + @JsonProperty("brands") + private List brands; + + /** 本次翻页的上下文,用于请求下一页 */ + @JsonProperty("next_key") + private String nextKey; + + /** 品牌资质总数 */ + @JsonProperty("total_num") + private Integer totalNum; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandGrantDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandGrantDetail.java new file mode 100644 index 0000000000..6b4826fcd4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandGrantDetail.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商标授权信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BrandGrantDetail implements Serializable { + + private static final long serialVersionUID = 3537812707384823606L; + + /** 品牌销售授权书的file_id, 授权品牌必填, 限制最多传9张, 需要先调用“资质上传”接口上传资质图片 */ + @JsonProperty("grant_certifications") + private List grantCertifications; + + /** 授权级数, 授权品牌必填, 取值1-3 */ + @JsonProperty("grant_level") + private Integer grantLevel; + + /** 授权有效期, 开始时间, 长期有效可不填 */ + @JsonProperty("start_time") + private Long startTime; + + /** 授权有效期, 结束时间, 长期有效可不填 */ + @JsonProperty("end_time") + private Long endTime; + + /** 是否长期有效 */ + @JsonProperty("is_permanent") + private boolean permanent; + + /** 品牌权利人证件照的file_id, 限制最多传2张, 需要先调用“资质上传”接口上传资质图片 */ + @JsonProperty("brand_owner_id_photos") + private List brandOwnerIdPhotos; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandInfo.java new file mode 100644 index 0000000000..799002369d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandInfo.java @@ -0,0 +1,52 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 品牌信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BrandInfo extends Brand { + + private static final long serialVersionUID = 5464505958132626159L; + + /** 申请单状态 1审核中 2审核失败 3已生效 4已撤回 5即将过期(不影响商品售卖) 6已过期 */ + @JsonProperty("status") + private Integer status; + + /** 创建时间 */ + @JsonProperty("create_time") + private Long createTime; + + /** 更新时间 */ + @JsonProperty("update_time") + private Long updateTime; + + /** 审核结果 */ + @JsonProperty("audit_result") + private AuditResult auditResult; + + /** 审核结果 */ + @Data + @NoArgsConstructor + public static class AuditResult implements Serializable { + + private static final long serialVersionUID = 3936802571381636820L; + /** 提审的审核单ID */ + @JsonProperty("audit_id") + private String auditId; + + /** 审核不通过的原因, 审核成功不返回 */ + @JsonProperty("reject_reason") + private String rejectReason; + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandInfoResponse.java new file mode 100644 index 0000000000..20536b5a07 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandInfoResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 品牌响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BrandInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 2105745692451683517L; + + /** 品牌信息 */ + @JsonProperty("brand") + private BrandInfo brand; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandListResponse.java new file mode 100644 index 0000000000..c6cff6f317 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandListResponse.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 品牌列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BrandListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -5335449078706304920L; + + /** 品牌库中的品牌信息 */ + @JsonProperty("brands") + private List brands; + + /** 本次翻页的上下文,用于请求下一页 */ + @JsonProperty("next_key") + private String nextKey; + + /** 是否还有下一页内容 */ + @JsonProperty("continue_flag") + private boolean continueFlag; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandParam.java new file mode 100644 index 0000000000..05f8d89b42 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandParam.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 品牌参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BrandParam implements Serializable { + + private static final long serialVersionUID = -4894709391464428613L; + + /** 品牌信息 */ + @JsonProperty("brand") + private Brand brand; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandRegisterDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandRegisterDetail.java new file mode 100644 index 0000000000..28b417f38c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandRegisterDetail.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 品牌注册信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BrandRegisterDetail implements Serializable { + + private static final long serialVersionUID = 1169957179510362405L; + + /** 商标注册人, R标时必填 */ + @JsonProperty("registrant") + private String registrant; + + /** 商标注册号, R标时必填 */ + @JsonProperty("register_no") + private String registerNo; + + /** 商标注册有效期(时间戳秒), 开始时间, 长期有效可不填 */ + @JsonProperty("start_time") + private Long startTime; + + /** 商标注册有效期(时间戳秒), 结束时间, 长期有效可不填 */ + @JsonProperty("end_time") + private Long endTime; + + /** 是否长期有效 */ + @JsonProperty("is_permanent") + private boolean permanent; + + /** 商标注册证的file_id, R标时必填, 限制最多传1张, 需要先调用“资质上传”接口上传资质图片 */ + @JsonProperty("register_certifications") + private List registerCertifications; + + /** 变更/续展证明的file_id, 限制最多传5张, 需要先调用“资质上传”接口上传资质图片 */ + @JsonProperty("renew_certifications") + private List renewCertifications; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandSearchParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandSearchParam.java new file mode 100644 index 0000000000..e73ed4f54e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/brand/BrandSearchParam.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.brand; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; + +/** + * 品牌搜索参数 + * + * @author Zeyes + */ +@Data +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BrandSearchParam extends StreamPageParam { + + private static final long serialVersionUID = 5961201403338269712L; + /** 审核单状态, 不填默认拉全部商品 */ + @JsonProperty("status") + private Integer status; + + public BrandSearchParam() { + } + + public BrandSearchParam(Integer pageSize, String nextKey, Integer status) { + super(pageSize, nextKey); + this.status = status; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/AccountCategoryResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/AccountCategoryResponse.java new file mode 100644 index 0000000000..3db7c74cec --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/AccountCategoryResponse.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分类响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AccountCategoryResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 3486089711447908477L; + + /** 类目列表 */ + @JsonProperty("data") + private List categories; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryAndQualificationList.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryAndQualificationList.java new file mode 100644 index 0000000000..c9e973c8b8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryAndQualificationList.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分类资质响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class CategoryAndQualificationList implements Serializable { + + private static final long serialVersionUID = 4245906598437404655L; + + /** 分类列表 */ + @JsonProperty("cat_and_qua") + private List list; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryDetailResult.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryDetailResult.java new file mode 100644 index 0000000000..8819e94312 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryDetailResult.java @@ -0,0 +1,132 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class CategoryDetailResult extends WxChannelBaseResponse { + + private static final long serialVersionUID = 4657778764371047619L; + + @JsonProperty("info") + private Info info; + + @JsonProperty("attr") + private Attr attr; + + + @Data + @NoArgsConstructor + public static class Info implements Serializable { + + /** 类目ID */ + @JsonProperty("cat_id") + private String id; + /** 类目名称 */ + @JsonProperty("name") + private String name; + } + + @Data + @NoArgsConstructor + public static class Attr implements Serializable { + + /** 是否支持虚拟发货 */ + @JsonProperty("shop_no_shipment") + private Boolean shopNoShipment; + + /** 是否定向准入 */ + @JsonProperty("access_permit_required") + private Boolean accessPermitRequired; + + /** 是否支持预售 */ + @JsonProperty("pre_sale") + private Boolean preSale; + + /** 是否必须支持7天无理由退货 */ + @JsonProperty("seven_day_return") + private Boolean sevenDayReturn; + + /** 定准类目的品牌ID */ + @JsonProperty("brand_list") + private List brands; + + /** 类目关联的保证金,单位分 */ + @JsonProperty("deposit") + private Long deposit; + + /** 产品属性 */ + @JsonProperty("product_attr_list") + private List productAttrs; + + /** 销售属性 */ + @JsonProperty("sale_attr_list") + private List saleAttrs; + + /** 佣金信息 */ + @JsonProperty("transactionfee_info") + private FeeInfo feeInfo; + } + + @Data + @NoArgsConstructor + public static class BrandInfo implements Serializable { + + /** 定准类目的品牌ID */ + @JsonProperty("brand_id") + private String id; + } + + @Data + @NoArgsConstructor + public static class ProductAttr implements Serializable { + + /** 类目必填项名称 */ + @JsonProperty("name") + private String name; + + /** 类目必填项类型,string为自定义,select_one为多选一 */ + @JsonProperty("type") + private String type; + + /** 类目必填项值 */ + @JsonProperty("value") + private String value; + + /** 是否类目必填项 */ + @JsonProperty("is_required") + private Boolean required; + + + } + + @Data + @NoArgsConstructor + public static class FeeInfo implements Serializable { + + /** 类目实收的交易佣金比例,单位万分比 */ + @JsonProperty("basis_point") + private Integer basisPoint; + + /** 类目原始佣金比例,单位万分比 */ + @JsonProperty("original_basis_point") + private Integer originalBasisPoint; + + /** 佣金激励类型,0:无激励措施,1:新店佣金减免 */ + @JsonProperty("incentive_type") + private Integer incentiveType; + + } +} + + + + diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryQualification.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryQualification.java new file mode 100644 index 0000000000..f384eaae45 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryQualification.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分类资质信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class CategoryQualification implements Serializable { + + private static final long serialVersionUID = 6495550078851408381L; + + /** 类目 */ + @JsonProperty("cat") + private ShopCategory category; + + /** 资质信息 */ + @JsonProperty("qua") + private QualificationInfo info; + + /** 商品资质信息 */ + @JsonProperty("product_qua") + private QualificationInfo productInfo; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryQualificationResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryQualificationResponse.java new file mode 100644 index 0000000000..984a3ad79b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryQualificationResponse.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分类资质响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CategoryQualificationResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -7869091908852685830L; + + @JsonProperty("cats") + private List list; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/PassCategoryInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/PassCategoryInfo.java new file mode 100644 index 0000000000..82b16c0188 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/PassCategoryInfo.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 审核通过的分类和资质信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class PassCategoryInfo implements Serializable { + + private static final long serialVersionUID = 1152077957498898216L; + + /** 类目ID */ + @JsonProperty("cat_id") + private String catId; + + /** 资质ID */ + @JsonProperty("qua_id") + private String quaId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/PassCategoryResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/PassCategoryResponse.java new file mode 100644 index 0000000000..af6f484254 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/PassCategoryResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 审核通过的分类和资质信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class PassCategoryResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -3674591447273025743L; + + /** 类目和资质信息列表 */ + @JsonProperty("list") + private List list; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/QualificationInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/QualificationInfo.java new file mode 100644 index 0000000000..197ac46528 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/QualificationInfo.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 资质信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class QualificationInfo implements Serializable { + + /** 资质ID */ + @JsonProperty("qua_id") + private String id; + + /** 是否需要申请 */ + @JsonProperty("need_to_apply") + private Boolean needToApply; + + /** 资质信息 */ + @JsonProperty("tips") + private String tips; + + /** 该类目申请的时候是否一定要提交资质 */ + @JsonProperty("mandatory") + private Boolean mandatory; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/ShopCategory.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/ShopCategory.java new file mode 100644 index 0000000000..b36edfa9e2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/ShopCategory.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品类目 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ShopCategory implements Serializable { + + /** 类目ID */ + @JsonProperty("cat_id") + private String id; + + /** 类目父ID */ + @JsonProperty("f_cat_id") + private String parentId; + + /** 类目名称 */ + @JsonProperty("name") + private String name; + + /** 层级 */ + @JsonProperty("level") + private Integer level; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/ShopCategoryResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/ShopCategoryResponse.java new file mode 100644 index 0000000000..2af64ad1c3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/ShopCategoryResponse.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.category; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分类响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ShopCategoryResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 3871098948660947422L; + + /** 类目列表 */ + @JsonProperty("cat_list") + private List categories; + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintHistory.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintHistory.java new file mode 100644 index 0000000000..4570fdc615 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintHistory.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.channel.bean.complaint; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 纠纷历史 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ComplaintHistory implements Serializable { + + private static final long serialVersionUID = -4706637116597650133L; + /** 历史操作类型,见 {@link me.chanjar.weixin.channel.enums.ComplaintItemType } */ + @JsonProperty("item_type") + private Integer itemType; + + /** 操作时间,Unix时间戳 */ + @JsonProperty("time") + private Long time; + + /** 用户联系电话 */ + @JsonProperty("phone_number") + private Integer phoneNumber; + + /** 相关文本内容 */ + @JsonProperty("content") + private String content; + + /** 相关图片media_id列表 */ + @JsonProperty("media_id_list") + private List mediaIds; + + /** 售后类型, 1-仅退款 2-退货退款 */ + @JsonProperty("after_sale_type") + private Integer afterSaleType; + + /** 售后原因,见 {@link me.chanjar.weixin.channel.enums.AfterSalesReason} */ + @JsonProperty("after_sale_reason") + private Integer afterSaleReason; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintOrderResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintOrderResponse.java new file mode 100644 index 0000000000..a0a8ec1e18 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintOrderResponse.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.channel.bean.complaint; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 纠纷单响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ComplaintOrderResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1968530826349555367L; + /** 售后单号 */ + @JsonProperty("after_sale_order_id") + private String afterSaleOrderId; + + /** 订单号 */ + @JsonProperty("order_id") + private String orderId; + + /** 纠纷历史 */ + @JsonProperty("history") + private List history; + + /** 纠纷单状态, 见 {@link me.chanjar.weixin.channel.enums.ComplaintStatus} */ + @JsonProperty("status") + private Integer status; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintParam.java new file mode 100644 index 0000000000..0090348efe --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/complaint/ComplaintParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.complaint; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 纠纷单留言 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ComplaintParam implements Serializable { + + private static final long serialVersionUID = 6146118590005718327L; + /** 纠纷单号 */ + @JsonProperty("complaint_id") + private String complaintId; + + /** 留言内容,最多500字 */ + @JsonProperty("content") + private String content; + + /** 图片media_id列表,所有留言总图片数量最多20张 */ + @JsonProperty("media_id_list") + private List mediaIds; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/AutoValidInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/AutoValidInfo.java new file mode 100644 index 0000000000..73c09def1e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/AutoValidInfo.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 自动生效信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AutoValidInfo implements Serializable { + + private static final long serialVersionUID = 1702505613539861103L; + /** 优惠券开启自动生效类型 0不启用自动生效 1启用自动生效,按领券开始时间(自动生效时间为 receive_info.start_time) */ + @JsonProperty("auto_valid_type") + private Integer autoValidType; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponDetailInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponDetailInfo.java new file mode 100644 index 0000000000..34f76716f9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponDetailInfo.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 优惠券信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor + +public class CouponDetailInfo implements Serializable { + + private static final long serialVersionUID = 5994815232349181577L; + /** 优惠券名称 **/ + @JsonProperty("name") + private String name; + + /** 优惠券有效信息 **/ + @JsonProperty("valid_info") + private ValidInfo validInfo; + + /** 推广信息 **/ + @JsonProperty("promote_info") + private PromoteInfo promoteInfo; + + /** 优惠信息 **/ + @JsonProperty("discount_info") + private DiscountInfo discountInfo; + + /** 额外信息 **/ + @JsonProperty("ext_info") + private ExtInfo extInfo; + + /** 领取信息 **/ + @JsonProperty("receive_info") + private ReceiveInfo receiveInfo; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponIdInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponIdInfo.java new file mode 100644 index 0000000000..b787016a09 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponIdInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 优惠券id + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CouponIdInfo implements Serializable { + + private static final long serialVersionUID = 6284609705855608275L; + /** 优惠券ID */ + @JsonProperty("coupon_id") + private String couponId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponIdResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponIdResponse.java new file mode 100644 index 0000000000..7556fa6f11 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponIdResponse.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CouponIdResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -3263189706802013651L; + @JsonProperty("data") + private CouponIdInfo data; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponInfo.java new file mode 100644 index 0000000000..cd247f9d71 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponInfo.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class CouponInfo extends CouponIdInfo { + + private static final long serialVersionUID = -5862063828870424262L; + /** 优惠券类型 **/ + @JsonProperty("type") + private Integer type; + + /** 优惠券状态 **/ + @JsonProperty("status") + private Integer status; + + /** 优惠券创建时间 */ + @JsonProperty("create_time") + private Long createTime; + + /** 优惠券更新时间 */ + @JsonProperty("update_time") + private Long updateTime; + + /** 优惠券信息 */ + @JsonProperty("coupon_info") + private CouponDetailInfo detail; + + /** 库存信息 */ + @JsonProperty("stock_info") + private StockInfo stockInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponInfoResponse.java new file mode 100644 index 0000000000..801843025e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponInfoResponse.java @@ -0,0 +1,20 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CouponInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5261320058699488529L; + @JsonProperty("coupon") + private CouponInfo coupon; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponListParam.java new file mode 100644 index 0000000000..6c7fc03a6e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponListParam.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 获取优惠券ID列表接口的请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(Include.NON_NULL) +public class CouponListParam implements Serializable { + private static final long serialVersionUID = 7123047113279657365L; + + /** + * 优惠券状态 {@link me.chanjar.weixin.channel.enums.WxCouponStatus} + */ + @JsonProperty("status") + private Integer status; + + /** + * 第几页(最小填1) + */ + @JsonProperty("page") + private Integer page; + + /** + * 每页数量(不超过200) + */ + @JsonProperty("page_size") + private Integer pageSize; + + /** + * 分页上下文 + */ + @JsonProperty("page_ctx") + private String pageCtx; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponListResponse.java new file mode 100644 index 0000000000..66d6f63eef --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponListResponse.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CouponListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -5330296358041282751L; + /** 优惠券id列表 */ + @JsonProperty("coupons") + private List coupons; + + /** 优惠券总数 */ + @JsonProperty("total_num") + private Integer totalNum; + + /** 优惠券上下文 */ + @JsonProperty("page_ctx") + private String pageCtx; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponParam.java new file mode 100644 index 0000000000..fa89b0a1e4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponParam.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 优惠券参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CouponParam extends CouponIdInfo { + + private static final long serialVersionUID = -3663331372622943337L; + /** 优惠券类型 **/ + @JsonProperty("type") + private Integer type; + + /** 优惠券名称,最长10个中文字符 */ + @JsonProperty("name") + private String name; + + /** 优惠信息 **/ + @JsonProperty("discount_info") + private DiscountInfo discountInfo; + + /** 额外信息 **/ + @JsonProperty("ext_info") + private ExtInfo extInfo; + + /** 推广信息 **/ + @JsonProperty("promote_info") + private PromoteInfo promoteInfo; + + /** 领取信息 **/ + @JsonProperty("receive_info") + private ReceiveInfo receiveInfo; + + /** 优惠券有效信息 **/ + @JsonProperty("valid_info") + private ValidInfo validInfo; + + /** 优惠券自动生效信息 **/ + @JsonProperty("auto_valid_info") + private AutoValidInfo autoValidInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponStatusParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponStatusParam.java new file mode 100644 index 0000000000..405ad52400 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/CouponStatusParam.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author Zeyes + */ +@Data +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CouponStatusParam extends CouponIdInfo { + + private static final long serialVersionUID = -7108348049925634704L; + /** 状态 */ + @JsonProperty("status") + private Integer status; + + public CouponStatusParam() { + } + + public CouponStatusParam(String couponId, Integer status) { + super(couponId); + this.status = status; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/DiscountCondition.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/DiscountCondition.java new file mode 100644 index 0000000000..e249455526 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/DiscountCondition.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 折扣条件 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DiscountCondition implements Serializable { + + private static final long serialVersionUID = 3250293381093835082L; + /** 优惠券使用条件, 满 x 件商品可用 */ + @JsonProperty("product_cnt") + private Integer productCnt; + + /** 优惠券使用条件, 价格满 x 可用,单位分 */ + @JsonProperty("product_price") + private Integer productPrice; + + /** 优惠券使用条件, 指定商品 id 可用 */ + @JsonProperty("product_ids") + private List productIds; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/DiscountInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/DiscountInfo.java new file mode 100644 index 0000000000..7988e47ce6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/DiscountInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 优惠信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DiscountInfo implements Serializable { + + private static final long serialVersionUID = 3660070880545144112L; + /** 优惠券折扣数 * 1000, 例如 5.1折-> 5100 */ + @JsonProperty("discount_num") + private Integer discountNum; + + /** 优惠券减少金额, 单位分, 例如0.5元-> 50 */ + @JsonProperty("discount_fee") + private Integer discountFee; + + /** 优惠条件 */ + @JsonProperty("discount_condition") + private DiscountCondition discountCondition; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ExtInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ExtInfo.java new file mode 100644 index 0000000000..69cf3dc073 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ExtInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 额外信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ExtInfo implements Serializable { + + private static final long serialVersionUID = 9053035437087423233L; + /** 商品折扣券领取后跳转的商品id **/ + @JsonProperty("jump_product_id") + private String jumpProductId; + + /** 备注信息 **/ + @JsonProperty("notes") + private String notes; + + /** 优惠券有效时间 **/ + @JsonProperty("valid_time") + private Long validTime; + + /** 优惠券失效时间戳 **/ + @JsonProperty("invalid_time") + private Long invalidTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/PromoteInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/PromoteInfo.java new file mode 100644 index 0000000000..75d48e6d3e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/PromoteInfo.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 推广信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class PromoteInfo implements Serializable { + + private static final long serialVersionUID = -3030639750899957382L; + /** 推广类型 {@link me.chanjar.weixin.channel.enums.PromoteType} */ + @JsonProperty("promote_type") + private Integer promoteType; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ReceiveInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ReceiveInfo.java new file mode 100644 index 0000000000..9a602ac390 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ReceiveInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 领取信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ReceiveInfo implements Serializable { + + private static final long serialVersionUID = 755956808504040633L; + /** 优惠券领用结束时间 **/ + @JsonProperty("end_time") + private Long endTime; + + /** 单人限领张数 **/ + @JsonProperty("limit_num_one_person") + private Integer limitNumOnePerson; + + /** 优惠券领用开始时间 **/ + @JsonProperty("start_time") + private Long startTime; + + /** 优惠券领用总数 **/ + @JsonProperty("total_num") + private Integer totalNum; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/StockInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/StockInfo.java new file mode 100644 index 0000000000..07aaf4a1ec --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/StockInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 库存信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class StockInfo implements Serializable { + + private static final long serialVersionUID = -6078383881065929862L; + /** 优惠券剩余量 */ + @JsonProperty("issued_num") + private Integer issuedNum; + + /** 优惠券领用量 */ + @JsonProperty("receive_num") + private Integer receiveNum; + + /** 优惠券已用量 */ + @JsonProperty("used_num") + private Integer usedNum; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCoupon.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCoupon.java new file mode 100644 index 0000000000..06436a9e73 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCoupon.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 用户优惠券 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class UserCoupon extends UserCouponIdInfo { + + private static final long serialVersionUID = -4777537717885622888L; + /** 优惠券状态 {@link me.chanjar.weixin.channel.enums.UserCouponStatus} */ + @JsonProperty("status") + private Integer status; + + /** 优惠券派发时间 */ + @JsonProperty("create_time") + private Long createTime; + + /** 优惠券更新时间 */ + @JsonProperty("update_time") + private Long updateTime; + + /** 优惠券生效时间 */ + @JsonProperty("start_time") + private Long startTime; + + /** 优惠券失效时间 */ + @JsonProperty("end_time") + private Long endTime; + + /** 附加信息 */ + @JsonProperty("ext_info") + private UserExtInfo extInfo; + + /** 优惠券使用的订单id */ + @JsonProperty("order_id") + private String orderId; + + /** 优惠券金额 */ + @JsonProperty("discount_fee") + private Integer discountFee; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponIdInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponIdInfo.java new file mode 100644 index 0000000000..d68d881c98 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponIdInfo.java @@ -0,0 +1,20 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 用户优惠券id + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class UserCouponIdInfo extends CouponIdInfo { + + private static final long serialVersionUID = -8285585134793264542L; + /** 用户优惠券ID */ + @JsonProperty("user_coupon_id") + private String userCouponId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponIdParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponIdParam.java new file mode 100644 index 0000000000..aa2eb15421 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponIdParam.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; + +/** + * @author Zeyes + */ +@Data +public class UserCouponIdParam implements Serializable { + + private static final long serialVersionUID = 3967276158727848348L; + /** 用户openid */ + @JsonProperty("openid") + private String openid; + + /** 用户优惠券ID */ + @JsonProperty("user_coupon_id") + private String userCouponId; + + public UserCouponIdParam() { + } + + public UserCouponIdParam(String openid, String userCouponId) { + this.openid = openid; + this.userCouponId = userCouponId; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponListParam.java new file mode 100644 index 0000000000..f14f5d7f6e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponListParam.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UserCouponListParam extends CouponListParam { + private static final long serialVersionUID = -1056132009327357435L; + + /** + * openId + */ + @JsonProperty("openid") + private String openId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponListResponse.java new file mode 100644 index 0000000000..2c3582e678 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponListResponse.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class UserCouponListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5201633937239352879L; + /** 优惠券id列表 */ + @JsonProperty("user_coupon_list") + private List coupons; + + /** 优惠券总数 */ + @JsonProperty("total_num") + private Integer totalNum; + + /** 优惠券上下文 */ + @JsonProperty("page_ctx") + private String pageCtx; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponResponse.java new file mode 100644 index 0000000000..aeb9d89afb --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserCouponResponse.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class UserCouponResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1434098386857953234L; + @JsonProperty("user_coupon") + private UserCoupon coupon; + + @JsonProperty("openid") + private String openid; + + @JsonProperty("unionid") + private String unionid; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserExtInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserExtInfo.java new file mode 100644 index 0000000000..18962361ec --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/UserExtInfo.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 用户优惠券附加信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class UserExtInfo implements Serializable { + + private static final long serialVersionUID = 8304922825230343409L; + /** 优惠券核销时间 */ + @JsonProperty("use_time") + private Long useTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ValidInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ValidInfo.java new file mode 100644 index 0000000000..10df794324 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/coupon/ValidInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 优惠券有效信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ValidInfo implements Serializable { + + private static final long serialVersionUID = -4550516248380285635L; + /** 优惠券有效期类型 {@link me.chanjar.weixin.channel.enums.CouponValidType} */ + @JsonProperty("valid_type") + private Integer validType; + + /** 优惠券有效天数,valid_type=2时才有意义 */ + @JsonProperty("valid_day_num") + private Integer validDayNum; + + /** 优惠券有效期开始时间,valid_type=1时才有意义 */ + @JsonProperty("start_time") + private Long startTime; + + /** 优惠券有效期结束时间,valid_type=1时才有意义 */ + @JsonProperty("end_time") + private Long endTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryCompanyInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryCompanyInfo.java new file mode 100644 index 0000000000..349d70cbb1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryCompanyInfo.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.delivery; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 快递公司信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DeliveryCompanyInfo implements Serializable { + + private static final long serialVersionUID = 4225666604513570564L; + /** 快递公司id */ + @JsonProperty("delivery_id") + private String id; + + /** 快递公司名称 */ + @JsonProperty("delivery_name") + private String name; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryCompanyResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryCompanyResponse.java new file mode 100644 index 0000000000..d74a9439ea --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryCompanyResponse.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.delivery; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 快递公司列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DeliveryCompanyResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -7695903997951385166L; + /** 快递公司 */ + @JsonProperty("company_list") + private List companyList; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryInfo.java new file mode 100644 index 0000000000..23ab8dad2c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliveryInfo.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.delivery; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 物流信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DeliveryInfo implements Serializable { + + private static final long serialVersionUID = -6205626967305385248L; + /** 快递单号 */ + @JsonProperty("waybill_id") + private String waybillId; + + /** 快递公司id,通过【获取快递公司列表】接口获得,非主流快递公司可以填OTHER */ + @JsonProperty("delivery_id") + private String deliveryId; + + /** 发货方式,1:自寄快递发货,3:虚拟商品无需物流发货(只有deliver_method=1的订单可以使用虚拟发货) */ + @JsonProperty("deliver_type") + private Integer deliverType; + + /** 包裹中商品信息 */ + @JsonProperty("product_infos") + private List productInfos; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliverySendParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliverySendParam.java new file mode 100644 index 0000000000..f486032bc4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/DeliverySendParam.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.delivery; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单发货信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class DeliverySendParam implements Serializable { + + private static final long serialVersionUID = 4555821308266899135L; + /** 订单ID */ + @JsonProperty("order_id") + private String orderId; + + /** 物流信息 */ + @JsonProperty("delivery_list") + private List deliveryList; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/FreightProductInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/FreightProductInfo.java new file mode 100644 index 0000000000..2a7c7dd3c6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/delivery/FreightProductInfo.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.delivery; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 包裹中商品信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FreightProductInfo implements Serializable { + private static final long serialVersionUID = -3751269707150372172L; + + /** + * 商品id + */ + @JsonProperty("product_id") + private String productId; + + /** + * sku_id + */ + @JsonProperty("sku_id") + private String skuId; + + /** + * 商品数量 + */ + @JsonProperty("product_cnt") + private Integer productCnt; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AddressInfoList.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AddressInfoList.java new file mode 100644 index 0000000000..4d8c7ec4a5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AddressInfoList.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AddressInfo; + +/** + * 地址列表 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AddressInfoList implements Serializable { + + private static final long serialVersionUID = 5923805297331862706L; + /** 地址列表 */ + @JsonProperty("address_infos") + private List addressInfos; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AllConditionFreeDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AllConditionFreeDetail.java new file mode 100644 index 0000000000..fd9aee451d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AllConditionFreeDetail.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 计费规则列表 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AllConditionFreeDetail implements Serializable { + + private static final long serialVersionUID = -1649520737632417036L; + /** 计费规则列表 */ + @JsonProperty("condition_free_detail_list") + private List list; + + @JsonIgnore + public void addDetail(ConditionFreeDetail detail) { + if (list == null) { + list = new ArrayList<>(16); + } + list.add(detail); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AllFreightCalcMethod.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AllFreightCalcMethod.java new file mode 100644 index 0000000000..2c5523ebe4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/AllFreightCalcMethod.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import lombok.Data; + +/** + * 具体计费方法,默认运费,指定地区运费等 + * + * @author Zeyes + */ +@Data +public class AllFreightCalcMethod implements Serializable { + + private static final long serialVersionUID = 6330919525271991949L; + /** 计算方法列表 */ + @JsonProperty("freight_calc_method_list") + private List list; + + public AllFreightCalcMethod() { + } + + public void addDetail(FreightCalcMethod detail) { + if (list == null) { + list = new ArrayList<>(16); + } + list.add(detail); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/ConditionFreeDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/ConditionFreeDetail.java new file mode 100644 index 0000000000..68cb3b146e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/ConditionFreeDetail.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 计费规则 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ConditionFreeDetail extends AddressInfoList { + + private static final long serialVersionUID = 9204578767029379142L; + /** 最低件数 */ + @JsonProperty("min_piece") + private Integer minPiece; + + /** 最低重量 */ + @JsonProperty("min_weight") + private Double minWeight; + + /** 最低金额 */ + @JsonProperty("min_amount") + private Integer minAmount; + + /** 计费方式对应的选项是否已设置 */ + @JsonProperty("valuation_flag") + private Integer valuationFlag; + + /** 金额是否设置 */ + @JsonProperty("amount_flag") + private Integer amountFlag; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/FreightCalcMethod.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/FreightCalcMethod.java new file mode 100644 index 0000000000..aab949bc44 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/FreightCalcMethod.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 运费计算方法 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class FreightCalcMethod extends AddressInfoList { + + private static final long serialVersionUID = -8857987538121721376L; + /** 是否默认运费 */ + @JsonProperty("is_default") + private Boolean isDefault; + + /** 快递公司 */ + @JsonProperty("delivery_id") + private String deliveryId; + + /** 首段运费需要满足的数量 */ + @JsonProperty("first_val_amount") + private Integer firstValAmount; + + /** 首段运费的金额 */ + @JsonProperty("first_price") + private Integer firstPrice; + + /** 续费的数量 */ + @JsonProperty("second_val_amount") + private Integer secondValAmount; + + /** 续费的金额 */ + @JsonProperty("second_price") + private Integer secondPrice; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/FreightTemplate.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/FreightTemplate.java new file mode 100644 index 0000000000..e28f90ad41 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/FreightTemplate.java @@ -0,0 +1,71 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AddressInfo; + +/** + * 运费模板 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FreightTemplate implements Serializable { + + private static final long serialVersionUID = -7876281924385999053L; + /** 模板id */ + @JsonProperty("template_id") + private String templateId; + + /** 模板名称 */ + @JsonProperty("name") + private String name; + + /** 计费类型,PIECE:按件数,WEIGHT:按重量 */ + @JsonProperty("valuation_type") + private String valuationType; + + /** 发货时间期限 {@link me.chanjar.weixin.channel.enums.SendTime} */ + @JsonProperty("send_time") + private String sendTime; + + /** 发货地址 */ + @JsonProperty("address_info") + private AddressInfo addressInfo; + + /** 运输方式,EXPRESS:快递 */ + @JsonProperty("delivery_type") + private String deliveryType; + + /** 计费方式:FREE包邮 CONDITION_FREE条件包邮 NO_FREE不包邮 */ + @JsonProperty("shipping_method") + private String shippingMethod; + + /** 条件包邮详情 */ + @JsonProperty("all_condition_free_detail") + private AllConditionFreeDetail allConditionFreeDetail; + + /** 具体计费方法,默认运费,指定地区运费等 */ + @JsonProperty("all_freight_calc_method") + private AllFreightCalcMethod allFreightCalcMethod; + + /** 创建时间戳 */ + @JsonProperty("create_time") + private Long createTime; + + /** 更新时间戳 */ + @JsonProperty("update_time") + private Long updateTime; + + /** 是否默认模板 */ + @JsonProperty("is_default") + private Boolean isDefault; + + /** 不发货区域 */ + @JsonProperty("not_send_area") + private NotSendArea notSendArea; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/NotSendArea.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/NotSendArea.java new file mode 100644 index 0000000000..1c480fc227 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/NotSendArea.java @@ -0,0 +1,18 @@ +package me.chanjar.weixin.channel.bean.freight; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 不发货区域 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class NotSendArea extends AddressInfoList { + + private static final long serialVersionUID = -1836467830293286560L; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateAddParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateAddParam.java new file mode 100644 index 0000000000..9c400533bf --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateAddParam.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 运费模板 请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class TemplateAddParam implements Serializable { + + private static final long serialVersionUID = 2602919369418149309L; + /** 起始位置 */ + @JsonProperty("freight_template") + private FreightTemplate template; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateIdResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateIdResponse.java new file mode 100644 index 0000000000..e895d066cb --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateIdResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 运费模板 列表 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TemplateIdResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5179651364165620640L; + /** 运费模板id */ + @JsonProperty("template_id") + private String templateId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateInfoResponse.java new file mode 100644 index 0000000000..f37e3dc2d1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateInfoResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 运费模板 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TemplateInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -8381510839783330617L; + /** 运费模板id */ + @JsonProperty("freight_template") + private FreightTemplate template; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateListParam.java new file mode 100644 index 0000000000..628d907eb1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateListParam.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.channel.bean.base.OffsetParam; + +/** + * 运费模板 列表 请求参数 + * + * @author Zeyes + */ +@Data +@JsonInclude(Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) +public class TemplateListParam extends OffsetParam { + + private static final long serialVersionUID = -6716154891499581562L; + + public TemplateListParam() { + } + + public TemplateListParam(Integer offset, Integer limit) { + super(offset, limit); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateListResponse.java new file mode 100644 index 0000000000..a6fcd7d3e3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/freight/TemplateListResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.freight; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 运费模板 列表 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TemplateListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5375602442595264719L; + /** 运费模板 id 列表 */ + @JsonProperty("template_id_list") + private List ids; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfo.java new file mode 100644 index 0000000000..f6248f96ba --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfo.java @@ -0,0 +1,53 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 账户信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AccountInfo implements Serializable { + + private static final long serialVersionUID = -2107134853480093451L; + /** 账户类型 {@link me.chanjar.weixin.channel.enums.AccountType} */ + @JsonProperty("bank_account_type") + private String bankAccountType; + + /** 开户银行 */ + @JsonProperty("account_bank") + private String accountBank; + + /** 开户银行省市编码 */ + @JsonProperty("bank_address_code") + private String bankAddressCode; + + /** 开户银行联行号 */ + @JsonProperty("bank_branch_id") + private String bankBranchId; + + /** 开户银行全称 */ + @JsonProperty("bank_name") + private String bankName; + + /** 银行账号 */ + @JsonProperty("account_number") + private String accountNumber; + + /** 开户银行名称前端展示值 */ + @JsonProperty("account_bank4show") + private String accountBank4show; + + /** 账户名称 */ + @JsonProperty("account_name") + private String accountName; + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfoParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfoParam.java new file mode 100644 index 0000000000..ec6010bd07 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfoParam.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 账户信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AccountInfoParam implements Serializable { + + private static final long serialVersionUID = 1689204583402779134L; + @JsonProperty("account_info") + private AccountInfo accountInfo; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfoResponse.java new file mode 100644 index 0000000000..b54a34a2e7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/AccountInfoResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 账户信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AccountInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -8316068503468969533L; + /** 账户信息 */ + @JsonProperty("account_info") + private AccountInfo accountInfo; + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/BalanceInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/BalanceInfoResponse.java new file mode 100644 index 0000000000..def7e86675 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/BalanceInfoResponse.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 账户余额信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BalanceInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 4480496860612566921L; + /** 可提现余额 */ + @JsonProperty("available_amount") + private Integer availableAmount; + + /** 待结算余额 */ + @JsonProperty("pending_amount") + private Integer pendingAmount; + + /** 二级商户号 */ + @JsonProperty("sub_mchid") + private String subMchid; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FlowListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FlowListResponse.java new file mode 100644 index 0000000000..9306b4516a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FlowListResponse.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 流水列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FlowListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 8017827444308973489L; + /** 流水单号列表 */ + @JsonProperty("flow_ids") + private List flowIds; + + /** 是否还有下一页 */ + @JsonProperty("has_more") + private boolean hasMore; + + /** 分页参数,深翻页时使用 */ + @JsonProperty("next_key") + private String nextKey; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FlowRelatedInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FlowRelatedInfo.java new file mode 100644 index 0000000000..4edecbb3b1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FlowRelatedInfo.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 流水关联信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FlowRelatedInfo implements Serializable { + + private static final long serialVersionUID = 3757839018198212504L; + /** 关联类型, 1 订单, 2售后,3 提现,4 运费险 */ + @JsonProperty("related_type") + private Integer relatedType; + + /** 关联订单号 */ + @JsonProperty("order_id") + private String orderId; + + /** 关联售后单号 */ + @JsonProperty("aftersale_id") + private String afterSaleId; + + /** 关联提现单号 */ + @JsonProperty("withdraw_id") + private String withdrawId; + + /** 记账时间 */ + @JsonProperty("bookkeeping_time") + private String bookkeepingTime; + + /** 关联运费险单号 */ + @JsonProperty("insurance_id") + private String insuranceId; + + /** 关联支付单号 */ + @JsonProperty("transaction_id") + private String transactionId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsFlow.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsFlow.java new file mode 100644 index 0000000000..9b01e820fa --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsFlow.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 资金流水 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FundsFlow implements Serializable { + + private static final long serialVersionUID = -2785498655066305510L; + /** 流水id */ + @JsonProperty("flow_id") + private String flowId; + + /** 资金类型,见 {@link me.chanjar.weixin.channel.enums.FundsType} */ + @JsonProperty("funds_type") + private Integer fundsType; + + /** 流水类型, 1 收入,2 支出 */ + @JsonProperty("flow_type") + private Integer flowType; + + /** 流水金额 */ + @JsonProperty("amount") + private Integer amount; + + /** 余额 */ + @JsonProperty("balance") + private Integer balance; + + /** 流水关联信息 */ + @JsonProperty("related_info_list") + private List relatedInfos; + + /** 记账时间 */ + @JsonProperty("bookkeeping_time") + private String bookkeepingTime; + + /** 备注 */ + @JsonProperty("remark") + private String remark; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsFlowResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsFlowResponse.java new file mode 100644 index 0000000000..7db351263f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsFlowResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 资金流水响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class FundsFlowResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -1130785908352355914L; + /** 流水信息 */ + @JsonProperty("funds_flow") + private FundsFlow fundsFlow; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsListParam.java new file mode 100644 index 0000000000..b5312e3a2a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/FundsListParam.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 资金流水参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FundsListParam implements Serializable { + + private static final long serialVersionUID = 2998955690332382229L; + /** 页码,从1开始 */ + @JsonProperty("page") + private Integer page; + + /** 页数,不填默认为10 */ + @JsonProperty("page_size") + protected Integer pageSize; + + /** 流水产生的开始时间,uinx时间戳 */ + @JsonProperty("start_time") + private Long startTime; + + /** 流水产生的结束时间,unix时间戳 */ + @JsonProperty("end_time") + private Long endTime; + + /** 流水类型, 1 收入,2 支出 */ + @JsonProperty("flow_type") + private Integer flowType; + + /** 关联支付单号 */ + @JsonProperty("transaction_id") + private String transactionId; + + /** + * 分页参数,翻页时写入上一页返回的next_key(page为上一页加一, 并且page_size与上一页相同的时候才生效),page * page_size >= 10000时必填 + */ + @JsonProperty("next_key") + private String nextKey; + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawDetailResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawDetailResponse.java new file mode 100644 index 0000000000..a1e726fb51 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawDetailResponse.java @@ -0,0 +1,55 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 提现详情响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class WithdrawDetailResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1473346677401168323L; + /** 金额 */ + @JsonProperty("amount") + private Integer amount; + + /** 创建时间 */ + @JsonProperty("create_time") + private Long createTime; + + /** 更新时间 */ + @JsonProperty("update_time") + private Long updateTime; + + /** 失败原因 */ + @JsonProperty("reason") + private String reason; + + /** 备注 */ + @JsonProperty("remark") + private String remark; + + /** 银行附言 */ + @JsonProperty("bank_memo") + private String bankMemo; + + /** 银行名称 */ + @JsonProperty("bank_name") + private String bankName; + + /** 银行账户 */ + @JsonProperty("bank_num") + private String bankNum; + + /** 提现状态 {@link me.chanjar.weixin.channel.enums.WithdrawStatus} */ + @JsonProperty("status") + private String status; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawListParam.java new file mode 100644 index 0000000000..a44b68567d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawListParam.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 提现列表参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WithdrawListParam implements Serializable { + + private static final long serialVersionUID = -672422656564313999L; + /** 页码,从1开始 */ + @JsonProperty("page_num") + private Integer pageNum; + + /** 页数 */ + @JsonProperty("page_size") + private Integer pageSize; + + /** 开始时间 */ + @JsonProperty("start_time") + private Long startTime; + + /** 结束时间 */ + @JsonProperty("end_time") + private Long endTime; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawListResponse.java new file mode 100644 index 0000000000..b1dabc2a4b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawListResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 提现列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class WithdrawListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -7950467108750325235L; + /** 提现单号列表 */ + @JsonProperty("withdraw_ids") + private List withdrawIds; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawSubmitParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawSubmitParam.java new file mode 100644 index 0000000000..65b8cdd12c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawSubmitParam.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 提现提交参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WithdrawSubmitParam implements Serializable { + + private static final long serialVersionUID = 5801338663530567830L; + /** 提现金额(单位:分) */ + @JsonProperty("amount") + private Integer amount; + + /** 提现备注 */ + @JsonProperty("remark") + private String remark; + + /** 银行附言 */ + @JsonProperty("bank_memo") + private String bankMemo; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawSubmitResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawSubmitResponse.java new file mode 100644 index 0000000000..0002b158d2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/WithdrawSubmitResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 提现提交响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class WithdrawSubmitResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -8269579250564427758L; + /** 二维码ticket,可用于获取二维码和查询二维码状态 */ + @JsonProperty("qrcode_ticket") + private String qrcodeTicket; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankCityInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankCityInfo.java new file mode 100644 index 0000000000..04a69a8e87 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankCityInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 银行城市信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BankCityInfo implements Serializable { + + private static final long serialVersionUID = 374087891799491196L; + /** 城市名称 */ + @JsonProperty("city_name") + private String cityName; + + /** 城市编号 */ + @JsonProperty("city_code") + private Integer cityCode; + + /** 开户银行省市编码 */ + @JsonProperty("bank_address_code") + private String bankAddressCode; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankCityResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankCityResponse.java new file mode 100644 index 0000000000..5cb148c79b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankCityResponse.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 银行城市信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BankCityResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -6212360101083304631L; + /** 银行城市信息列表 */ + @JsonProperty("data") + private List data; + + /** 总数 */ + @JsonProperty("total_count") + private Integer totalCount; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankInfo.java new file mode 100644 index 0000000000..1bb58badb4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankInfo.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 银行信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BankInfo implements Serializable { + + private static final long serialVersionUID = -4837989875996346711L; + /** 开户银行 */ + @JsonProperty("account_bank") + private String accountBank; + + /** 银行编码 */ + @JsonProperty("bank_code") + private String bankCode; + + /** 银行联号 */ + @JsonProperty("bank_id") + private String bankId; + + /** 银行名称(不包括支行) */ + @JsonProperty("bank_name") + private String bankName; + + /** 银行类型(1.对公,2.对私) */ + @JsonProperty("bank_type") + private Integer bankType; + + /** 是否需要填写支行信息 */ + @JsonProperty("need_branch") + private Boolean needBranch; + + /** 支行联号 */ + @JsonProperty("branch_id") + private String branchId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankInfoResponse.java new file mode 100644 index 0000000000..499d9fcbb5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankInfoResponse.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 银行信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BankInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 8583893898929290526L; + /** 银行信息列表 */ + @JsonProperty("data") + private List data; + + /** 总数 */ + @JsonProperty("total_count") + private Integer totalCount; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankListResponse.java new file mode 100644 index 0000000000..9517859c42 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankListResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 银行信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BankListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 7912035853286944260L; + /** 银行信息列表 */ + @JsonProperty("data") + private List data; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankProvinceInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankProvinceInfo.java new file mode 100644 index 0000000000..955a25e8ad --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankProvinceInfo.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 银行省份信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BankProvinceInfo implements Serializable { + + private static final long serialVersionUID = -3409931656361300144L; + /** 省份名称 */ + @JsonProperty("province_name") + private String provinceName; + + /** 省份编码 */ + @JsonProperty("province_code") + private Integer provinceCode; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankProvinceResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankProvinceResponse.java new file mode 100644 index 0000000000..f509d24304 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankProvinceResponse.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 银行省份信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BankProvinceResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -6187805847136359892L; + /** 银行省份信息列表 */ + @JsonProperty("data") + private List data; + + /** 总数 */ + @JsonProperty("total_count") + private Integer totalCount; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankSearchParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankSearchParam.java new file mode 100644 index 0000000000..abc9c1ec77 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BankSearchParam.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 银行查询参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BankSearchParam implements Serializable { + + private static final long serialVersionUID = 6070269209439188188L; + /** 偏移量 */ + @JsonProperty("offset") + private Integer offset; + + /** 每页数据大小 */ + @JsonProperty("limit") + private Integer limit; + + /** 银行关键字 */ + @JsonProperty("key_words") + private String keyWords; + + /** 银行类型(1:对私银行,2:对公银行; 默认对公) */ + @JsonProperty("bank_type") + private Integer bankType; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchInfo.java new file mode 100644 index 0000000000..c4cec9bc76 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchInfo.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分店信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BranchInfo implements Serializable { + + private static final long serialVersionUID = -2744729367131146892L; + /** 支行联号 */ + @JsonProperty("branch_id") + private Integer branchId; + + /** 银行全称(含支行) */ + @JsonProperty("branch_name") + private String branchName; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchInfoResponse.java new file mode 100644 index 0000000000..c7cfda4646 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchInfoResponse.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 支行信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BranchInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -1419832502854175767L; + /** 总数 */ + @JsonProperty("total_count") + private Integer totalCount; + + /** 当前分页数量 */ + @JsonProperty("count") + private Integer count; + + /** 银行名称 */ + @JsonProperty("account_bank") + private String accountBank; + + /** 银行编码 */ + @JsonProperty("account_bank_code") + private String accountBankCode; + + /** 银行别名 */ + @JsonProperty("bank_alias") + private String bankAlias; + + /** 银行别名编码 */ + @JsonProperty("bank_alias_code") + private String bankAliasCode; + + /** 支行信息列表 */ + @JsonProperty("data") + private List data; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchSearchParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchSearchParam.java new file mode 100644 index 0000000000..47527efe1e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/bank/BranchSearchParam.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.channel.bean.fund.bank; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 银行支行信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BranchSearchParam implements Serializable { + + private static final long serialVersionUID = -8800316690160248833L; + /** 银行编码,通过查询银行信息或者搜索银行信息获取 */ + @JsonProperty("bank_code") + private String bankCode; + + /** 城市编号,通过查询城市列表获取 */ + @JsonProperty("city_code") + private String cityCode; + + /** 偏移量 */ + @JsonProperty("offset") + private Integer offset; + + /** 限制个数 */ + @JsonProperty("limit") + private Integer limit; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/qrcode/QrCheckResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/qrcode/QrCheckResponse.java new file mode 100644 index 0000000000..e1a52ab9a3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/qrcode/QrCheckResponse.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.fund.qrcode; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 二维码校验响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class QrCheckResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -3860756719827268969L; + /** 扫码状态 {@link me.chanjar.weixin.channel.enums.QrCheckStatus} */ + @JsonProperty("status") + private Integer status; + + /** 业务返回错误码 */ + @JsonProperty("self_check_err_code") + private Integer selfCheckErrCode; + + /** 业务返回错误信息 */ + @JsonProperty("self_check_err_msg") + private String selfCheckErrMsg; + + /** 扫码者身份 0非管理员 1管理员 2次管理员 */ + @JsonProperty("scan_user_type") + private Integer scanUserType; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/qrcode/QrCodeResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/qrcode/QrCodeResponse.java new file mode 100644 index 0000000000..d6c015c0cd --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/fund/qrcode/QrCodeResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.fund.qrcode; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 二维码响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class QrCodeResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 4521008628337929496L; + /** 二维码(base64编码二进制,需要base64解码) */ + @JsonProperty("qrcode_buf") + private String qrcodeBuf; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/ChannelImageInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/ChannelImageInfo.java new file mode 100644 index 0000000000..3e12c7e830 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/ChannelImageInfo.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.image; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 微信图片信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ChannelImageInfo implements Serializable { + + private static final long serialVersionUID = 8883519290965944530L; + + /** 开放平台media_id */ + @JsonProperty("media_id") + private String mediaId; + + /** 图片链接,有访问频率限制 */ + @JsonProperty("img_url") + private String url; + + /** 微信支付media_id */ + @JsonProperty("pay_media_id") + private String payMediaId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/ChannelImageResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/ChannelImageResponse.java new file mode 100644 index 0000000000..903af375af --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/ChannelImageResponse.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.image; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.io.File; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class ChannelImageResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -4163511427507976489L; + + @JsonIgnore + private File file; + + private String contentType; + + public ChannelImageResponse() { + } + + public ChannelImageResponse(File file, String contentType) { + this.errCode = SUCCESS_CODE; + this.errMsg = "ok"; + this.file = file; + this.contentType = contentType; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/QualificationFileId.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/QualificationFileId.java new file mode 100644 index 0000000000..905720a8dc --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/QualificationFileId.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.image; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 资质文件id + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class QualificationFileId implements Serializable { + + private static final long serialVersionUID = -546135264746778249L; + + /** 文件id */ + @JsonProperty("file_id") + private String id; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/QualificationFileResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/QualificationFileResponse.java new file mode 100644 index 0000000000..5a4332885c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/QualificationFileResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.image; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 资质文件id响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class QualificationFileResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5172377567441096813L; + + /** 文件数据 */ + @JsonProperty("data") + private QualificationFileId data; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/UploadImageResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/UploadImageResponse.java new file mode 100644 index 0000000000..f1625bd3c4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/image/UploadImageResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.image; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 微信图片信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class UploadImageResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -609315696774437877L; + + /** 图片信息 */ + @JsonProperty("pic_file") + private ChannelImageInfo imgInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/AddressInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/AddressInfo.java new file mode 100644 index 0000000000..1ffb01677c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/AddressInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.league; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 地址信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AddressInfo implements Serializable { + + private static final long serialVersionUID = -5719456688033731919L; + /** 邮编 */ + @JsonProperty("postal_code") + private String postalCode; + + /** 国标收货地址第一级地址 */ + @JsonProperty("province_name") + private String provinceName; + + /** 国标收货地址第二级地址 */ + @JsonProperty("city_name") + private String cityName; + + /** 国标收货地址第三级地址 */ + @JsonProperty("county_name") + private String countyName; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/CatInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/CatInfo.java new file mode 100644 index 0000000000..4fc2cfc95b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/CatInfo.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.league; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品分类信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class CatInfo implements Serializable { + + private static final long serialVersionUID = 8449223922139383888L; + /** 类目id */ + @JsonProperty("cat_id") + private String catId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/DescInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/DescInfo.java new file mode 100644 index 0000000000..a29b07a294 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/DescInfo.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.league; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商详信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DescInfo implements Serializable { + + private static final long serialVersionUID = 5319244341160446531L; + /** 商品详情图片(最多20张)。如果添加时没录入,回包可能不包含该字段 */ + @JsonProperty("imgs") + private List imgs; + + /** 商品详情文字。如果添加时没录入,回包可能不包含该字 */ + @JsonProperty("desc") + private String desc; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/ExpressInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/ExpressInfo.java new file mode 100644 index 0000000000..6fbecac866 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/ExpressInfo.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.league; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 物流信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ExpressInfo implements Serializable { + + private static final long serialVersionUID = -4604691645808459334L; + /** 发货时间期限 */ + @JsonProperty("send_time") + private String sendTime; + + /** 发货地址 */ + @JsonProperty("address_info") + private AddressInfo addressInfo; + + /** 计费方式:FREE:包邮CONDITION_FREE:条件包邮NO_FREE:不包邮 */ + @JsonProperty("shipping_method") + private String shippingMethod; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/SimpleProductInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/SimpleProductInfo.java new file mode 100644 index 0000000000..9de16b849e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/SimpleProductInfo.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.channel.bean.league; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SimpleProductInfo implements Serializable { + + private static final long serialVersionUID = -2444641123422095497L; + /** 标题 */ + @JsonProperty("title") + protected String title; + + /** 副标题 */ + @JsonProperty("sub_title") + protected String subTitle; + + /** 主图,多张,列表,最多9张,每张不超过2MB */ + @JsonProperty("head_imgs") + protected List headImgs; + + /** 商详信息 */ + @JsonProperty("desc_info") + protected DescInfo descInfo; + + /** 类目信息 */ + @JsonProperty("cats") + protected List cats; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/BatchAddParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/BatchAddParam.java new file mode 100644 index 0000000000..c22563359a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/BatchAddParam.java @@ -0,0 +1,63 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 批量添加商品参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchAddParam implements Serializable { + + private static final long serialVersionUID = -87989229725625901L; + /** 商品推广类别 */ + @JsonProperty("type") + private Integer type; + + /** 商品列表 */ + @JsonProperty("list") + private List list; + + /** 推广达人列表 */ + @JsonProperty("finder_ids") + private List finderIds; + + /** 推广开始时间戳 */ + @JsonProperty("begin_time") + private Long beginTime; + + /** 推广结束时间戳 */ + @JsonProperty("end_time") + private Long endTime; + + /** 是否永久推广 */ + @JsonProperty("is_forerver") + private Boolean forever; + + + @Data + @NoArgsConstructor + @AllArgsConstructor + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Product implements Serializable { + + private static final long serialVersionUID = 9025105293896488093L; + /** 商品id,不可重复数量不超过20 */ + @JsonProperty("product_id") + private String productId; + + /** 推广佣金[0, 90]% */ + @JsonProperty("ratio") + private Integer ratio; + + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/BatchAddResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/BatchAddResponse.java new file mode 100644 index 0000000000..7a2f4f6840 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/BatchAddResponse.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 批量添加商品响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class BatchAddResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 2686612709939873527L; + /** 商品id信息 */ + @JsonProperty("result_info_list") + private List resultInfoList; + + + @Data + @NoArgsConstructor + @EqualsAndHashCode(callSuper = true) + public static class ResultInfo extends WxChannelBaseResponse { + + private static final long serialVersionUID = -534890760974302155L; + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 特殊推广商品计划id */ + @JsonProperty("info_id") + private String infoId; + + /** 推广失败达人列表 */ + @JsonProperty("fail_finder_ids") + private List failFinderIds; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDeleteParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDeleteParam.java new file mode 100644 index 0000000000..ccdf3ef0b4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDeleteParam.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品删除请求 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProductDeleteParam implements Serializable { + + private static final long serialVersionUID = 9129737170370664633L; + /** 获取商品推广类别 */ + @JsonProperty("type") + private Integer type; + + /** 商品id type为普通推广商品时必填 */ + @JsonProperty("product_id") + private String productId; + + /** 特殊推广商品计划id type为特殊推广商品时必填 */ + @JsonProperty("info_id") + private String infoId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDetailParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDetailParam.java new file mode 100644 index 0000000000..7b2c6ae6f7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDetailParam.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品详情请求 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProductDetailParam implements Serializable { + + private static final long serialVersionUID = 7624234965127527565L; + /** 获取商品推广类别 */ + @JsonProperty("type") + private Integer type; + + /** 商品id type为普通推广商品时必填 */ + @JsonProperty("product_id") + private String productId; + + /** 特殊推广商品计划id type为特殊推广商品时必填 */ + @JsonProperty("info_id") + private String infoId; + + /** 是否获取特殊推广商品绑定的达人列表, type为特殊推广商品时有效 */ + @JsonProperty("need_relation") + private Boolean needRelation; + + /** 拉取达人数 need_relation为真时必填 不超过50 */ + @JsonProperty("page_size") + private Integer pageSize; + + /** need_relation为真时有效,页面下标,下标从1开始,默认为1 */ + @JsonProperty("page_index") + private Integer pageIndex; + + /** need_relation为真时有效,是否需要返回该计划绑定达人总数 */ + @JsonProperty("need_total_num") + private Boolean needTotalNum; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDetailResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDetailResponse.java new file mode 100644 index 0000000000..05ea00c055 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductDetailResponse.java @@ -0,0 +1,96 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 商品详情响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ProductDetailResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5306524707144232861L; + /** 推广商品信息 */ + @JsonProperty("item") + private Item item; + + + @Data + @NoArgsConstructor + public static class Item implements Serializable { + + private static final long serialVersionUID = 9112142704638318861L; + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 商品推广类别 1普通推广商品 2定向推广商品 3专属推广商品 */ + @JsonProperty("type") + private Integer type; + + /** 商品推广状态 1已上架推广 2已下架推广 4已删除 5未达到准入标准 10待生效 */ + @JsonProperty("status") + private Integer status; + + /** 推广佣金[0, 90]% */ + @JsonProperty("ratio") + private Integer ratio; + + /** 特殊推广信息 */ + @JsonProperty("exclusive_info") + private ExclusiveInfo exclusiveInfo; + + /** 扩展信息 */ + @JsonProperty("ext_info") + private ExtInfo extInfo; + } + + @Data + @NoArgsConstructor + public static class ExclusiveInfo implements Serializable { + + private static final long serialVersionUID = 6583124869090013797L; + /** 特殊推广商品计划id */ + @JsonProperty("info_id") + private String infoId; + + /** 推广开始时间戳 */ + @JsonProperty("begin_time") + private Long beginTime; + + /** 推广结束时间戳 */ + @JsonProperty("end_time") + private Long endTime; + + /** 是否永久推广 */ + @JsonProperty("is_forerver") + private Boolean forever; + + /** 推广达人视频号列表 */ + @JsonProperty("finder_ids") + private List finderIds; + + } + + @Data + @NoArgsConstructor + public static class ExtInfo implements Serializable { + + /** 是否类目禁售 */ + @JsonProperty("is_sale_forbidden") + private Boolean saleForbidden; + + /** 是否被官方封禁 */ + @JsonProperty("is_banned") + private Boolean banned; + + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductListParam.java new file mode 100644 index 0000000000..18d52c82d6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductListParam.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品列表请求 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProductListParam implements Serializable { + + private static final long serialVersionUID = -1914139382459786057L; + /** 商品推广类别 */ + @JsonProperty("type") + private Integer type; + + /** 单页商品数(不超过100) */ + @JsonProperty("page_size") + private Integer pageSize; + + /** 页面下标,下标从1开始,默认为1 */ + @JsonProperty("page_index") + private Integer pageIndex; + + /** 商品id,拉取特殊推广商品时有效 */ + @JsonProperty("product_id") + private String productId; + + /** 视频号id,拉取特殊推广商品时有效 */ + @JsonProperty("finder_id") + private String finderId; + + /** 由上次请求返回,顺序翻页时需要传入, 会从上次返回的结果往后翻一页(填了该值后page_index不生效) */ + @JsonProperty("last_buffer") + private String lastBuffer; + + /** 是否需要返回满足筛选条件的商品总数(填last_buffer后该值无效) */ + @JsonProperty("need_total_num") + private Boolean needTotalNum; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductListResponse.java new file mode 100644 index 0000000000..642884ce63 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductListResponse.java @@ -0,0 +1,52 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 商品更新响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ProductListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -6192518391380515045L; + /** 商品列表 */ + @JsonProperty("items") + private List items; + + /** 本次翻页的上下文,用于顺序翻页请求 */ + @JsonProperty("last_buffer") + private String lastBuffer; + + /** 商品总数 */ + @JsonProperty("total_num") + private Integer totalNum; + + /** 是否还有剩余商品 */ + @JsonProperty("has_more") + private Boolean hasMore; + + @Data + @NoArgsConstructor + public static class Item implements Serializable { + + private static final long serialVersionUID = 5094378518992196239L; + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 特殊推广商品计划id */ + @JsonProperty("info_id") + private String infoId; + + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductUpdateParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductUpdateParam.java new file mode 100644 index 0000000000..8188911519 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductUpdateParam.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品更新请求 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProductUpdateParam implements Serializable { + + private static final long serialVersionUID = -3519313269193693460L; + /** 获取商品推广类别 */ + @JsonProperty("type") + private Integer type; + + /** 商品id type为普通推广商品时必填 */ + @JsonProperty("product_id") + private String productId; + + /** 特殊推广商品计划id type为特殊推广商品时必填 */ + @JsonProperty("info_id") + private String infoId; + + /** 更新操作类别 */ + @JsonProperty("operate_type") + private Integer operateType; + + /** 推广佣金[0, 90]% */ + @JsonProperty("ratio") + private Integer ratio; + + /** 特殊推广信息 */ + @JsonProperty("exclusive_info") + private ExclusiveInfo exclusiveInfo; + + + /** 特殊推广信息 */ + @Data + @NoArgsConstructor + public static class ExclusiveInfo implements Serializable { + + private static final long serialVersionUID = -8120260214345369170L; + /** 推广开始时间戳 */ + @JsonProperty("begin_time") + private Long beginTime; + + /** 推广结束时间戳 */ + @JsonProperty("end_time") + private Long endTime; + + /** 是否永久推广 */ + @JsonProperty("is_forerver") + private Boolean forever; + + /** 新增推广达人视频号列表,不超过30个 */ + @JsonProperty("add_finder_ids") + private List addFinderIds; + + /** 删除推广达人视频号列表,不超过30个 */ + @JsonProperty("del_finder_ids") + private List delFinderIds; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductUpdateResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductUpdateResponse.java new file mode 100644 index 0000000000..7dae90569e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/product/ProductUpdateResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.league.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 商品更新响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ProductUpdateResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 2144233059960259829L; + /** 特殊推广商品计划id */ + @JsonProperty("info_id") + private String infoId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterInfo.java new file mode 100644 index 0000000000..7f817c6633 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterInfo.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.channel.bean.league.promoter; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 达人 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class PromoterInfo implements Serializable { + + private static final long serialVersionUID = -8851711325343107780L; + /** 视频号finder_id */ + @JsonProperty("finder_id") + private String finderId; + + /** 合作状态 0初始值 1邀请中 2达人已接受邀请 3达人已拒绝邀请 4已取消邀请 5已取消合作 10已删除 */ + @JsonProperty("status") + private Integer status; + + /** 达人邀请秒级时间戳 */ + @JsonProperty("invite_time") + private Long inviteTime; + + /** 累计合作商品数 */ + @JsonProperty("sale_product_number") + private Integer saleProductNumber; + + /** 合作动销GMV */ + @JsonProperty("sale_gmv") + private Integer saleGmv; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterInfoResponse.java new file mode 100644 index 0000000000..bebe6a6fcc --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterInfoResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.league.promoter; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 达人信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class PromoterInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 6475158486029216487L; + /** 达人信息 */ + @JsonProperty("promoter") + private PromoterInfo promoter; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterListParam.java new file mode 100644 index 0000000000..128797bda8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterListParam.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.league.promoter; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 达人列表请求 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PromoterListParam implements Serializable { + + private static final long serialVersionUID = -6179472484874537538L; + /** 页面下标,下标从1开始,默认为1 */ + @JsonProperty("page_index") + protected Integer pageIndex; + + /** 页面下标,下标从1开始,默认为1 */ + @JsonProperty("page_size") + protected Integer pageSize; + + /** 拉取该状态下的达人列表 */ + private Integer status; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterListResponse.java new file mode 100644 index 0000000000..c193550369 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/promoter/PromoterListResponse.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.league.promoter; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 达人列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class PromoterListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1411870432999885996L; + /** 达人finder_id列表 */ + @JsonProperty("finder_ids") + private List finderIds; + + /** 达人总数 */ + @JsonProperty("total_num") + private Integer totalNum; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/BizBaseInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/BizBaseInfo.java new file mode 100644 index 0000000000..39b77daa32 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/BizBaseInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 小店基础信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BizBaseInfo implements Serializable { + + private static final long serialVersionUID = 3713638025924977002L; + /** 小店appid */ + @JsonProperty("appid") + private String appid; + + /** 小店头像 */ + @JsonProperty("headimg_url") + private String headimgUrl; + + /** 小店昵称 */ + @JsonProperty("nickname") + private String nickname; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionInfo.java new file mode 100644 index 0000000000..356a058684 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionInfo.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 跟佣信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class CommissionInfo implements Serializable { + + private static final long serialVersionUID = 3027131215096984236L; + /** 商品带货状态 1已上架推广 2已下架推广 5已清退 */ + @JsonProperty("status") + private Integer status; + + /** 服务费率[0, 1000000] */ + @JsonProperty("service_ratio") + private Integer serviceRatio; + + /** 佣金费率[0, 1000000] */ + @JsonProperty("ratio") + private Integer ratio; + + /** unix时间戳,合作开始时间 */ + @JsonProperty("start_time") + private Long startTime; + + /** unix时间戳,合作结束时间 */ + @JsonProperty("end_time") + private Long endTime; + + /** 带货链接 */ + @JsonProperty("link") + private String link; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderListParam.java new file mode 100644 index 0000000000..2f8d27f52e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderListParam.java @@ -0,0 +1,53 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.TimeRange; + +/** + * 佣金单列表请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CommissionOrderListParam implements Serializable { + + private static final long serialVersionUID = 2805783646567362357L; + /** 佣金单所属小店appid */ + @JsonProperty("appid") + private String appid; + + /** 视频号finder_id */ + @JsonProperty("finder_id") + private String finderId; + + /** 视频号openfinderid */ + @JsonProperty("openfinderid") + private String openfinderid; + + /** 佣金单创建时间范围 */ + @JsonProperty("create_time_range") + private TimeRange createTimeRange; + + /** 佣金单更新时间范围 */ + @JsonProperty("update_time_range") + private TimeRange updateTimeRange; + + /** 订单ID,填此参数后其他过滤参数无效 */ + @JsonProperty("order_id") + private String orderId; + + /** 单页佣金单数(不超过30) */ + @JsonProperty("page_size") + private Integer pageSize; + + /** 由上次请求返回,顺序翻页时需要传入, 会从上次返回的结果往后翻一页 */ + @JsonProperty("next_key") + private String nextKey; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderListResponse.java new file mode 100644 index 0000000000..6d7e1be4f8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderListResponse.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + + +/** + * 团长订单列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CommissionOrderListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1143184321517598592L; + /** 商品id信息 */ + @JsonProperty("list") + private List list; + + /** 本次翻页的上下文,用于顺序翻页请求 */ + @JsonProperty("next_key") + private String nextKey; + + /** 是否还有剩余商品 */ + @JsonProperty("has_more") + private Boolean hasMore; + + + @Data + @NoArgsConstructor + public static class ProductIdInfo implements Serializable { + + private static final long serialVersionUID = -691189837681217282L; + /** 商品id */ + @JsonProperty("order_id") + private String orderId; + + /** skuid */ + @JsonProperty("sku_id") + private String skuId; + + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderResponse.java new file mode 100644 index 0000000000..d8c84e1473 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CommissionOrderResponse.java @@ -0,0 +1,174 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 佣金订单响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CommissionOrderResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 7004553990771819977L; + /** 佣金单 */ + @JsonProperty("commssion_order") + private CommissionOrder commissionOrder; + + + /** 佣金单 */ + @Data + @NoArgsConstructor + public static class CommissionOrder implements Serializable { + + private static final long serialVersionUID = 735931726521944716L; + /** 订单号 */ + @JsonProperty("order_id") + private String orderId; + + /** 商品skuid */ + @JsonProperty("sku_id") + private String skuId; + + /** 秒级时间戳 */ + @JsonProperty("create_time") + private Long createTime; + + /** 秒级时间戳 */ + @JsonProperty("update_time") + private Long updateTime; + + /** 佣金单状态,见{@link me.chanjar.weixin.channel.enums.CommissionOrderStatus} */ + @JsonProperty("status") + private Integer status; + + /** 订单详情 */ + @JsonProperty("order_detail") + private OrderDetail orderDetail; + } + + /** 订单详情 */ + @Data + @NoArgsConstructor + public static class OrderDetail implements Serializable { + + private static final long serialVersionUID = 8349635368396073000L; + /** 小店商家信息 */ + @JsonProperty("shop_info") + private BizInfo shopInfo; + + /** 佣金单商品信息 */ + @JsonProperty("product_info") + private ProductInfo productInfo; + + /** 订单信息 */ + @JsonProperty("order_info") + private OrderInfo orderInfo; + + /** 分佣信息 */ + @JsonProperty("commission_info") + private CommissionInfo commissionInfo; + + } + + /** 小店商家信息 */ + @Data + @NoArgsConstructor + public static class BizInfo implements Serializable { + + private static final long serialVersionUID = -8229584987720782974L; + /** 所属小店appid */ + @JsonProperty("appid") + private String appid; + + } + + /** 佣金单商品信息 */ + @Data + @NoArgsConstructor + public static class ProductInfo implements Serializable { + + private static final long serialVersionUID = -2790410903073956864L; + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** sku小图 */ + @JsonProperty("thumb_img") + private String thumbImg; + + /** 可分佣金额 */ + @JsonProperty("actual_payment") + private Integer actualPayment; + + /** 商品标题 */ + @JsonProperty("title") + private String title; + + } + + /** 订单信息 */ + @Data + @NoArgsConstructor + public static class OrderInfo implements Serializable { + + private static final long serialVersionUID = 7610425518539999170L; + /** 订单状态,枚举值见OrderStatus */ + @JsonProperty("order_status") + private Integer status; + + } + + /** 分佣信息 */ + @Data + @NoArgsConstructor + public static class CommissionInfo implements Serializable { + + private static final long serialVersionUID = -2114290318872427720L; + /** 带货达人信息 */ + @JsonProperty("finder_info") + private FinderInfo finderInfo; + + /** 服务费率[0, 1000000] */ + @JsonProperty("service_ratio") + private Integer serviceRatio; + + /** 服务费金额 */ + @JsonProperty("service_amount") + private Integer serviceAmount; + + /** 服务费结算时间 */ + @JsonProperty("profit_sharding_suc_time") + private Long profitShardingSucTime; + + } + + /** 带货达人信息 */ + @Data + @NoArgsConstructor + public static class FinderInfo implements Serializable { + + private static final long serialVersionUID = 7383486670949864257L; + /** 达人昵称 */ + @JsonProperty("nickname") + private String nickname; + + /** 佣金率[0, 1000000] */ + @JsonProperty("ratio") + private Integer ratio; + /** 佣金 */ + @JsonProperty("amount") + private Integer amount; + + /** 视频号openfinderid */ + @JsonProperty("openfinderid") + private String openfinderid; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductDetailParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductDetailParam.java new file mode 100644 index 0000000000..494e86f999 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductDetailParam.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 合作商品详情请求 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CoopProductDetailParam implements Serializable { + + private static final long serialVersionUID = 3515221514742929207L; + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 团长商品 所属小店appid */ + @JsonProperty("appid") + private String appId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductListParam.java new file mode 100644 index 0000000000..81743b51f2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductListParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 合作商品详情请求 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CoopProductListParam implements Serializable { + + private static final long serialVersionUID = -9023029707828535352L; + /** 团长商品 所属小店appid */ + @JsonProperty("appid") + private String appid; + + /** 单页商品数(不超过30) */ + @JsonProperty("page_size") + private Integer pageSize; + + /** 由上次请求返回,顺序翻页时需要传入, 会从上次返回的结果往后翻一页 */ + @JsonProperty("next_key") + private String nextKey; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductListResponse.java new file mode 100644 index 0000000000..39bf2bb96e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductListResponse.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 团长商品列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CoopProductListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -5440144076389135839L; + /** 商品id信息 */ + @JsonProperty("list") + private List list; + + /** 本次翻页的上下文,用于顺序翻页请求 */ + @JsonProperty("next_key") + private String nextKey; + + /** 是否还有剩余商品 */ + @JsonProperty("has_more") + private Boolean hasMore; + + + @Data + @NoArgsConstructor + public static class ProductIdInfo implements Serializable { + + private static final long serialVersionUID = -7136011408769169462L; + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 所属小店appid */ + @JsonProperty("appid") + private String appid; + + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductResponse.java new file mode 100644 index 0000000000..eee78937b2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/CoopProductResponse.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 合作商品详情响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CoopProductResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -4066427847985394479L; + /** 商品信息 */ + @JsonProperty("item") + private Item item; + + + @Data + @NoArgsConstructor + public static class Item implements Serializable { + + private static final long serialVersionUID = 6123572874440025928L; + /** 所属小店appid */ + @JsonProperty("appid") + private String appid; + + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 商品信息 */ + @JsonProperty("product_info") + private ProductInfo productInfo; + + /** 跟佣信息 */ + @JsonProperty("commission_info") + private CommissionInfo commissionInfo; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/FlowListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/FlowListParam.java new file mode 100644 index 0000000000..99d2bf107f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/FlowListParam.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 团长流水列表请求参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class FlowListParam implements Serializable { + + private static final long serialVersionUID = 3128695806885851134L; + /** 页码,从1开始 */ + @JsonProperty("page") + private Integer page; + + /** 页数,不填默认为10 */ + @JsonProperty("page_size") + private Integer pageSize; + + /** 资金类型, 见 {@link me.chanjar.weixin.channel.enums.FundsType} */ + @JsonProperty("funds_type") + private Integer fundsType; + + /** 流水产生的开始时间,uinx时间戳 */ + @JsonProperty("start_time") + private Long startTime; + + /** 流水产生的结束时间,unix时间戳 */ + @JsonProperty("end_time") + private Long endTime; + + /** 分页参数,翻页时写入上一页返回的next_key(page为上一页加一,并且page_size与上一页相同的时候才生效),page * page_size >= 5000时必填 */ + @JsonProperty("next_key") + private String nextKey; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/FundsFlowInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/FundsFlowInfo.java new file mode 100644 index 0000000000..089c7048d5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/FundsFlowInfo.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * 团长资金流水详情 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FundsFlowInfo implements Serializable { + + private static final long serialVersionUID = 102705878551490327L; + /** 流水id */ + @JsonProperty("flow_id") + private String flowId; + + /** 资金类型, 1提现 2分账 */ + @JsonProperty("funds_type") + private Integer fundsType; + + /** 流水金额 单位:分 */ + @JsonProperty("amount") + private Integer amount; + + /** 余额 单位:分 */ + @JsonProperty("balance") + private Integer balance; + + /** 记账时间 */ + @JsonProperty("bookkeeping_time") + private String bookkeepingTime; + + /** 备注 */ + @JsonProperty("remark") + private String remark; + + /** 关联订单号 */ + @JsonProperty("order_id") + private String orderId; + + /** 关联提现单号 */ + @JsonProperty("withdraw_id") + private String withdrawId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ProductInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ProductInfo.java new file mode 100644 index 0000000000..0c2dcae7a6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ProductInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.league.ExpressInfo; +import me.chanjar.weixin.channel.bean.league.SimpleProductInfo; + +/** + * 商品信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ProductInfo extends SimpleProductInfo { + + private static final long serialVersionUID = 5352334936089828219L; + /** 快递信息 */ + @JsonProperty("express_info") + private ExpressInfo expressInfo; + + /** sku信息 */ + @JsonProperty("skus") + private List skus; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ShopDetailResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ShopDetailResponse.java new file mode 100644 index 0000000000..14eaacb567 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ShopDetailResponse.java @@ -0,0 +1,89 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 合作小店详情响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ShopDetailResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 188954608418544735L; + /** 小店详情 */ + @JsonProperty("shop_detail") + private ShopDetail shopDetail; + + /** 本次翻页的上下文,用于顺序翻页请求 */ + @JsonProperty("next_key") + private String nextKey; + + /** 是否还有剩余小店 */ + @JsonProperty("has_more") + private Boolean hasMore; + + /** 小店详情 */ + @Data + @NoArgsConstructor + public static class ShopDetail implements Serializable { + + private static final long serialVersionUID = -3454074422563804378L; + /** 小店基础信息 */ + @JsonProperty("base_info") + private BizBaseInfo baseInfo; + + /** 小店数据信息 */ + @JsonProperty("data_info") + private ShopDataInfo dataInfo; + + /** 合作状态Status 1邀请中 2已接受邀请 3已拒绝邀请 4取消邀请 5取消合作 */ + @JsonProperty("status") + private Integer status; + + /** 开始合作时间戳 */ + @JsonProperty("approved_time") + private Long approvedTime; + + } + + + /** 小店数据信息 */ + @Data + @NoArgsConstructor + public static class ShopDataInfo implements Serializable { + + private static final long serialVersionUID = 6603460255046252283L; + /** 合作动销GMV,单位:分 */ + @JsonProperty("gmv") + private Integer gmv; + + /** 历史合作商品数 */ + @JsonProperty("product_number") + private Integer productNumber; + + /** 已结算服务费,单位:分 */ + @JsonProperty("settle_amount") + private Integer settleAmount; + + /** 预计待结算服务费,单位:分 */ + @JsonProperty("unsettle_amount") + private Integer unsettleAmount; + + /** 今日新增合作商品数 */ + @JsonProperty("product_number_today") + private Integer productNumberToday; + + /** 今日动销商品数 */ + @JsonProperty("product_number_sold_today") + private Integer productNumberSoldToday; + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ShopListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ShopListResponse.java new file mode 100644 index 0000000000..1c7de7c4a7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/ShopListResponse.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 合作小店列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ShopListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1736467471867767456L; + /** 小店详情 */ + @JsonProperty("shop_list") + private List shopList; + + /** 本次翻页的上下文,用于顺序翻页请求 */ + @JsonProperty("next_key") + private String nextKey; + + /** 是否还有剩余小店 */ + @JsonProperty("has_more") + private Boolean hasMore; + + /** 小店详情 */ + @Data + @NoArgsConstructor + public static class ShopDetail implements Serializable { + + private static final long serialVersionUID = 8421286426372052694L; + /** 小店基础信息 */ + @JsonProperty("base_info") + private BizBaseInfo baseInfo; + + /** 小店状态 */ + @JsonProperty("status") + private Integer status; + } + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SkuInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SkuInfo.java new file mode 100644 index 0000000000..6c51910d47 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SkuInfo.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AttrInfo; + + +/** + * SkuInfo + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SkuInfo implements Serializable { + + private static final long serialVersionUID = 197261426211990640L; + /** skuID */ + @JsonProperty("sku_id") + private String skuId; + + /** sku小图。如果添加时没录入,回包可能不包含该字段 */ + @JsonProperty("thumb_img") + private String thumbImg; + + /** 售卖价格,以分为单位 */ + @JsonProperty("sale_price") + private Integer salePrice; + + /** sku库存 */ + @JsonProperty("stock_num") + private Integer stockNum; + + /** sku属性 */ + @JsonProperty("sku_attrs") + private List skuAttrs; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierBalanceResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierBalanceResponse.java new file mode 100644 index 0000000000..eaa45027da --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierBalanceResponse.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 团长余额响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SupplierBalanceResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5584817726976222436L; + /** 可提现余额 */ + @JsonProperty("available_amount") + private Integer availableAmount; + + /** 待结算余额 */ + @JsonProperty("pending_amount") + private Integer pendingAmount; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierFlowDetailResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierFlowDetailResponse.java new file mode 100644 index 0000000000..5ab0745fab --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierFlowDetailResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 团长流水明细响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SupplierFlowDetailResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -3962482396458765234L; + /** 流水信息 */ + @JsonProperty("funds_flow") + private FundsFlowInfo fundsFlow; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierFlowListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierFlowListResponse.java new file mode 100644 index 0000000000..468985fe3e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/supplier/SupplierFlowListResponse.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.league.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 资金流水列表 响应 + * + * @author LiXiZe + * @since 2023-04-16 + */ +@Data +@NoArgsConstructor +public class SupplierFlowListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -2954427554226407544L; + /** 流水单号列表 */ + @JsonProperty("funds_flow_ids") + private List ids; + + /** 是否还有下一页 */ + @JsonProperty("has_more") + private Boolean hasMore; + + /** 分页参数,深翻页时使用 */ + @JsonProperty("next_key") + private String nextKey; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthInfo.java new file mode 100644 index 0000000000..22facd7a84 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.league.window; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 授权信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AuthInfo implements Serializable { + + private static final long serialVersionUID = 6265034296219892453L; + /** 授权链接 */ + @JsonProperty("auth_url") + private String authUrl; + + /** 授权路径 */ + @JsonProperty("auth_wxa_path") + private String authWxaPath; + + /** appid */ + @JsonProperty("auth_wxa_appid") + private String authWxaAppid; + + /** 小程序name */ + @JsonProperty("auth_wxa_username") + private String authWxaUsername; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthInfoResponse.java new file mode 100644 index 0000000000..941762aecd --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthInfoResponse.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.league.window; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 授权信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AuthInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 8336998502585278489L; + /** 授权链接信息 */ + @JsonProperty("auth_info") + private AuthInfo authInfo; + + /** 视频号openfinderid */ + @JsonProperty("openfinderid") + private String openfinderid; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthStatusResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthStatusResponse.java new file mode 100644 index 0000000000..b42bb0d179 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/AuthStatusResponse.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.league.window; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 授权状态响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class AuthStatusResponse extends WxChannelBaseResponse { + + /** 是否授权,0: 未授权, 1: 已授权 */ + @JsonProperty("window_auth_status") + private Integer windowAuthStatus; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/ProductSearchParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/ProductSearchParam.java new file mode 100644 index 0000000000..e43d450c6d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/ProductSearchParam.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.channel.bean.league.window; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 团长商品搜索参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProductSearchParam implements Serializable { + + private static final long serialVersionUID = -4771046746777827382L; + /** 团长appid */ + @JsonProperty("appid") + private String appid; + + /** 视频号openfinderid */ + @JsonProperty("openfinderid") + private String openfinderid; + + /** 起始位置(从0开始) */ + @JsonProperty("offset") + private Integer offset; + + /** page_size(默认100, 最大500) */ + @JsonProperty("page_size") + private Integer pageSize; + + /** 默认为false */ + @JsonProperty("need_total_num") + private Boolean needTotalNum; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductListResponse.java new file mode 100644 index 0000000000..60b5a4a44d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductListResponse.java @@ -0,0 +1,56 @@ +package me.chanjar.weixin.channel.bean.league.window; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 商品列表响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class WindowProductListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -1160519267422259848L; + /** 商品概要列表 */ + @JsonProperty("list") + private List list; + + /** 下一页的位置 */ + @JsonProperty("next_offset") + private Integer nextOffset; + + /** 后面是否还有商品 */ + @JsonProperty("have_more") + private Boolean haveMore; + + /** 商品总数 */ + @JsonProperty("total_num") + private Integer totalNum; + + /** 商品概要列表 */ + @Data + @NoArgsConstructor + public static class ItemKey implements Serializable { + + /** 团长appid */ + @JsonProperty("appid") + private String appid; + + /** 团长商品ID */ + @JsonProperty("product_id") + private String productId; + + /** 团长ID */ + @JsonProperty("head_supplier_id") + private String headSupplierId; + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductParam.java new file mode 100644 index 0000000000..c0e062fd2a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.league.window; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 团长商品 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class WindowProductParam implements Serializable { + + private static final long serialVersionUID = 363738166094927337L; + /** 团长appid */ + @JsonProperty("appid") + private String appid; + + /** 视频号openfinderid */ + @JsonProperty("openfinderid") + private String openfinderid; + + /** 团长商品ID */ + @JsonProperty("product_id") + private String productId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductResponse.java new file mode 100644 index 0000000000..071e0b2350 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/league/window/WindowProductResponse.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.channel.bean.league.window; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.SimpleProductInfo; + +/** + * 商品详情响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class WindowProductResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -4671578350314241014L; + /** 商品详情 */ + @JsonProperty("product_detail") + private ProductDetail productDetail; + + + /** + * 商品详情 + */ + @Data + @NoArgsConstructor + public static class ProductDetail implements Serializable { + + private static final long serialVersionUID = -6574563870972328273L; + /** 所属小店appid */ + @JsonProperty("appid") + private String appid; + + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 商品信息 */ + @JsonProperty("product_info") + private SimpleProductInfo productInfo; + + + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitSku.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitSku.java new file mode 100644 index 0000000000..29ffbf921e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitSku.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.limit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LimitSku implements Serializable { + + private static final long serialVersionUID = -1819737633227427482L; + + /** 参与抢购的商品 ID 下,不同规格(SKU)的商品信息 */ + @JsonProperty("sku_id") + private String skuId; + + /** SKU的抢购价格,必须小于原价(原价为1分钱的商品无法创建抢购任务) */ + @JsonProperty("sale_price") + private Integer salePrice; + + /** 参与抢购的商品库存,必须小于等于现有库存 */ + @JsonProperty("sale_stock") + private Integer saleStock; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskAddResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskAddResponse.java new file mode 100644 index 0000000000..35ea00d68d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskAddResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.limit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class LimitTaskAddResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -4742165348862157618L; + + /** 限时抢购任务ID 创建成功后返回 */ + @JsonProperty("task_id") + private String taskId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskInfo.java new file mode 100644 index 0000000000..aefc4b8136 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskInfo.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.channel.bean.limit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class LimitTaskInfo implements Serializable { + + private static final long serialVersionUID = 3032226931637189351L; + + /** 限时抢购任务ID */ + @JsonProperty("task_id") + private String taskId; + + /** 抢购商品ID */ + @JsonProperty("product_id") + private String productId; + + /** 限时抢购任务状态 */ + @JsonProperty("status") + private Integer status; + + /** 限时抢购任务创建时间(秒级时间戳) */ + @JsonProperty("create_time") + private Long createTime; + + /** 限时抢购任务开始时间(秒级时间戳) */ + @JsonProperty("start_time") + private Long startTime; + + /** 限时抢购任务结束时间(秒级时间戳) */ + @JsonProperty("end_time") + private Long endTime; + + /** sku列表 */ + @JsonProperty("limited_discount_skus") + private List skus; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskListParam.java new file mode 100644 index 0000000000..d608c8231e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskListParam.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.limit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; + +/** + * @author Zeyes + */ +@Data +public class LimitTaskListParam extends StreamPageParam { + + private static final long serialVersionUID = -7227161890365102302L; + + + /** 抢购活动状态 */ + @JsonProperty("status") + private Integer status; + + public LimitTaskListParam() { + } + + public LimitTaskListParam(Integer pageSize, String nextKey, Integer status) { + this.pageSize = pageSize; + this.nextKey = nextKey; + this.status = status; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskListResponse.java new file mode 100644 index 0000000000..688fd158dc --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskListResponse.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.limit; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class LimitTaskListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 3604657299385130217L; + + + /** 限时抢购任务 */ + @JsonProperty("limited_discount_tasks") + private List tasks; + + /** 本次翻页的上下文,用于请求下一页 */ + @JsonProperty("next_key") + private String nextKey; + + /** 商品总数 */ + @JsonProperty("total_num") + private Integer totalNum; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskParam.java new file mode 100644 index 0000000000..b89c072944 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskParam.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.limit; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class LimitTaskParam implements Serializable { + + private static final long serialVersionUID = 3885409806249022528L; + + /** 抢购商品ID */ + @JsonProperty("product_id") + private String productId; + + /** 限时抢购任务开始时间(秒级时间戳) */ + @JsonProperty("start_time") + private Date startTime; + + /** 限时抢购任务结束时间(秒级时间戳) */ + @JsonProperty("end_time") + private Date endTime; + + /** sku列表 */ + @JsonProperty("limited_discount_skus") + private List skus; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/SessionMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/SessionMessage.java new file mode 100644 index 0000000000..9b97cbf09d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/SessionMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 会话消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class SessionMessage extends WxChannelMessage { + + private static final long serialVersionUID = -429381568555605309L; + + @JsonProperty("SessionFrom") + @JacksonXmlProperty(localName = "SessionFrom") + private String from; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/AfterSaleMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/AfterSaleMessage.java new file mode 100644 index 0000000000..52beec7932 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/AfterSaleMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 售后消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class AfterSaleMessage extends WxChannelMessage { + + private static final long serialVersionUID = -7263404451639198126L; + /** 状态信息 */ + @JsonProperty("finder_shop_aftersale_status_update") + @JacksonXmlProperty(localName = "finder_shop_aftersale_status_update") + private AfterSaleStatusInfo info; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/AfterSaleStatusInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/AfterSaleStatusInfo.java new file mode 100644 index 0000000000..06fd349da8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/AfterSaleStatusInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.message.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AfterSaleStatusInfo implements Serializable { + + private static final long serialVersionUID = -7309656340583314591L; + /** 售后单号 */ + @JsonProperty("after_sale_order_id") + @JacksonXmlProperty(localName = "after_sale_order_id") + private String afterSaleOrderId; + + /** 售后单状态 */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private String status; + + /** 订单id */ + @JsonProperty("order_id") + @JacksonXmlProperty(localName = "order_id") + private String orderId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/ComplaintInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/ComplaintInfo.java new file mode 100644 index 0000000000..adb0b7b392 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/ComplaintInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.message.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 纠纷信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ComplaintInfo implements Serializable { + + private static final long serialVersionUID = 3988395560953978239L; + /** 纠纷单号 */ + @JsonProperty("complaint_id") + @JacksonXmlProperty(localName = "complaint_id") + private String complaintId; + + /** 小店售后单号 */ + @JsonProperty("after_sale_order_id") + @JacksonXmlProperty(localName = "after_sale_order_id") + private String afterSaleOrderId; + + /** 纠纷单状态 */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private Integer status; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/ComplaintMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/ComplaintMessage.java new file mode 100644 index 0000000000..e10a9b365a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/after/ComplaintMessage.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.message.after; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 纠纷消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class ComplaintMessage extends WxChannelMessage { + + private static final long serialVersionUID = 5358093415172409157L; + /** 状态信息 */ + @JsonProperty("finder_shop_complaint") + @JacksonXmlProperty(localName = "finder_shop_complaint") + private ComplaintInfo info; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponActionInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponActionInfo.java new file mode 100644 index 0000000000..f7a55ce0fb --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponActionInfo.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.channel.bean.message.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 优惠券操作消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class CouponActionInfo implements Serializable { + + private static final long serialVersionUID = -4456716511656569552L; + /** 优惠券ID */ + @JsonProperty("coupon_id") + @JacksonXmlProperty(localName = "coupon_id") + private String couponId; + + /** 领券时间 */ + @JsonProperty("create_time") + @JacksonXmlProperty(localName = "create_time") + private String createTime; + + /** 删除时间 */ + @JsonProperty("delete_time") + @JacksonXmlProperty(localName = "delete_time") + private String deleteTime; + + /** 过期时间 */ + @JsonProperty("expire_time") + @JacksonXmlProperty(localName = "expire_time") + private String expireTime; + + /** 更新时间 */ + @JsonProperty("change_time") + @JacksonXmlProperty(localName = "change_time") + private String changeTime; + + /** 作废时间 */ + @JsonProperty("invalid_time") + @JacksonXmlProperty(localName = "invalid_time") + private String invalidTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponActionMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponActionMessage.java new file mode 100644 index 0000000000..7433b7a6c2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponActionMessage.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.message.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + + +/** + * 卡券操作 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class CouponActionMessage extends WxChannelMessage { + + private static final long serialVersionUID = 4910461800721504462L; + /** 优惠券信息 */ + @JsonProperty("coupon_info") + @JacksonXmlProperty(localName = "coupon_info") + private CouponActionInfo couponInfo; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponReceiveMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponReceiveMessage.java new file mode 100644 index 0000000000..448d815a58 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/CouponReceiveMessage.java @@ -0,0 +1,60 @@ +package me.chanjar.weixin.channel.bean.message.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + + +/** + * 用户领券 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class CouponReceiveMessage extends WxChannelMessage { + + private static final long serialVersionUID = 5121347165246528730L; + /** 领取的优惠券ID */ + @JsonProperty("coupon_id") + @JacksonXmlProperty(localName = "coupon_id") + private String couponId; + + /** 生成的用户券ID */ + @JsonProperty("user_coupon_id") + @JacksonXmlProperty(localName = "user_coupon_id") + private String userCouponId; + + /** 领券时间 */ + @JsonProperty("receive_time") + @JacksonXmlProperty(localName = "receive_time") + private String receiveTime; + + @JsonProperty("receive_info") + @JacksonXmlProperty(localName = "receive_info") + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = null; + obj = map.get("coupon_id"); + if (obj != null) { + this.couponId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("user_coupon_id"); + if (obj != null) { + this.userCouponId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("receive_time"); + if (obj != null) { + this.receiveTime = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponActionInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponActionInfo.java new file mode 100644 index 0000000000..1356c47fca --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponActionInfo.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.channel.bean.message.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 用户优惠券操作消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class UserCouponActionInfo implements Serializable { + + private static final long serialVersionUID = -5948836918972669529L; + /** 优惠券ID */ + @JsonProperty("coupon_id") + @JacksonXmlProperty(localName = "coupon_id") + private String couponId; + + /** 用户券ID */ + @JsonProperty("user_coupon_id") + @JacksonXmlProperty(localName = "user_coupon_id") + private String userCouponId; + + /** 过期时间 */ + @JsonProperty("expire_time") + @JacksonXmlProperty(localName = "expire_time") + private String expireTime; + + /** 使用时间 */ + @JsonProperty("use_time") + @JacksonXmlProperty(localName = "use_time") + private String useTime; + + /** 返还时间 */ + @JsonProperty("unuse_time") + @JacksonXmlProperty(localName = "unuse_time") + private String unuseTime; + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponExpireMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponExpireMessage.java new file mode 100644 index 0000000000..26370e5142 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponExpireMessage.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.message.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + + +/** + * 用户卡券过期 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class UserCouponExpireMessage extends WxChannelMessage { + + private static final long serialVersionUID = -2557475297107588372L; + /** 用户优惠券信息 */ + @JsonProperty("user_coupon_info") + @JacksonXmlProperty(localName = "user_coupon_info") + private UserCouponActionInfo userCouponInfo; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponUseMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponUseMessage.java new file mode 100644 index 0000000000..7b436743c3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/coupon/UserCouponUseMessage.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.message.coupon; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + + +/** + * 用户卡券使用 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class UserCouponUseMessage extends WxChannelMessage { + + private static final long serialVersionUID = -1051142666438578628L; + /** 用户优惠券信息 */ + @JsonProperty("user_info") + @JacksonXmlProperty(localName = "user_info") + private UserCouponActionInfo userCouponInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/AccountNotifyMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/AccountNotifyMessage.java new file mode 100644 index 0000000000..b5a02ac834 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/AccountNotifyMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 账户变更通知 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class AccountNotifyMessage extends WxChannelMessage { + + private static final long serialVersionUID = 3846692537729725664L; + /** 账户信息 */ + @JsonProperty("account_info") + @JacksonXmlProperty(localName = "account_info") + private BankNotifyInfo accountInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/BankNotifyInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/BankNotifyInfo.java new file mode 100644 index 0000000000..44ef398f8b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/BankNotifyInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.message.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 账户信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class BankNotifyInfo implements Serializable { + + private static final long serialVersionUID = 4192569196686180014L; + /** 结算账户变更事件, 1.修改结算账户 */ + @JsonProperty("event") + @JacksonXmlProperty(localName = "event") + private Integer event; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/QrNotifyInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/QrNotifyInfo.java new file mode 100644 index 0000000000..83b466f07e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/QrNotifyInfo.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.message.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 提现二维码回调 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class QrNotifyInfo implements Serializable { + + private static final long serialVersionUID = 2470016408300157273L; + /** 二维码ticket */ + @JsonProperty("ticket") + @JacksonXmlProperty(localName = "ticket") + private String ticket; + + /** 二维码状态,1.已确认 2.已取消 3.已失效 4.已扫码 */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private Integer status; + + /** 扫码者身份, 0.非管理员 1.管理员 */ + @JsonProperty("scan_user_type") + @JacksonXmlProperty(localName = "scan_user_type") + private Integer scanUserType; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/QrNotifyMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/QrNotifyMessage.java new file mode 100644 index 0000000000..56e906a641 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/QrNotifyMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 提现二维码回调 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class QrNotifyMessage extends WxChannelMessage { + + private static final long serialVersionUID = -4705790895359679423L; + /** 账户信息 */ + @JsonProperty("qrcode_info") + @JacksonXmlProperty(localName = "qrcode_info") + private QrNotifyInfo qrcodeInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/WithdrawNotifyInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/WithdrawNotifyInfo.java new file mode 100644 index 0000000000..810f40c95c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/WithdrawNotifyInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.message.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 提现通知信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class WithdrawNotifyInfo implements Serializable { + + private static final long serialVersionUID = 2987401114254821956L; + /** 1.发起提现,生成二维码 2.扫码验证成功,申请提现 3.提现成功 4.提现失败 */ + @JsonProperty("event") + @JacksonXmlProperty(localName = "event") + private Integer event; + + /** 提现单号 */ + @JsonProperty("withdraw_id") + @JacksonXmlProperty(localName = "withdraw_id") + private String withdrawId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/WithdrawNotifyMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/WithdrawNotifyMessage.java new file mode 100644 index 0000000000..ff45e73ec6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/fund/WithdrawNotifyMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.fund; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 账户变更通知 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class WithdrawNotifyMessage extends WxChannelMessage { + + private static final long serialVersionUID = -2504086242143523430L; + /** 账户信息 */ + @JsonProperty("withdraw_info") + @JacksonXmlProperty(localName = "withdraw_info") + private WithdrawNotifyInfo withdrawInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderCancelInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderCancelInfo.java new file mode 100644 index 0000000000..8ff3ead54e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderCancelInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 订单取消信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderCancelInfo extends OrderIdInfo { + + private static final long serialVersionUID = -8022876997578127873L; + /** 1:用户取消;2:超时取消;3:全部商品售后完成,订单取消;4:超卖商家取消订单 */ + @JsonProperty("cancel_type") + @JacksonXmlProperty(localName = "cancel_type") + private Integer cancelType; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderCancelMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderCancelMessage.java new file mode 100644 index 0000000000..8e6b33c2ee --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderCancelMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单取消消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderCancelMessage extends WxChannelMessage { + + private static final long serialVersionUID = 5389546516473919310L; + /** 订单信息 */ + @JsonProperty("order_info") + @JacksonXmlProperty(localName = "order_info") + private OrderCancelInfo orderInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderConfirmInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderConfirmInfo.java new file mode 100644 index 0000000000..bd212092a5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderConfirmInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 订单确认收货信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderConfirmInfo extends OrderIdInfo { + + private static final long serialVersionUID = -2569494642832261346L; + /** 1:用户确认收货;2:超时自动确认收货 */ + @JsonProperty("confirm_type") + @JacksonXmlProperty(localName = "confirm_type") + private Integer confirmType; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderConfirmMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderConfirmMessage.java new file mode 100644 index 0000000000..dda35041b2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderConfirmMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单确认收货消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderConfirmMessage extends WxChannelMessage { + + private static final long serialVersionUID = 4219477394934480425L; + /** 订单信息 */ + @JsonProperty("order_info") + @JacksonXmlProperty(localName = "order_info") + private OrderConfirmInfo orderInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderDeliveryInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderDeliveryInfo.java new file mode 100644 index 0000000000..ca3d26736a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderDeliveryInfo.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 订单发货信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderDeliveryInfo extends OrderIdInfo { + + private static final long serialVersionUID = 117962754344887556L; + /** 0:尚未全部发货;1:全部商品发货完成 */ + @JsonProperty("finish_delivery") + @JacksonXmlProperty(localName = "finish_delivery") + private Integer finishDelivery; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderDeliveryMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderDeliveryMessage.java new file mode 100644 index 0000000000..25d79e2c4d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderDeliveryMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单发货消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderDeliveryMessage extends WxChannelMessage { + + private static final long serialVersionUID = -1440834047566984402L; + /** 订单信息 */ + @JsonProperty("order_info") + @JacksonXmlProperty(localName = "order_info") + private OrderDeliveryInfo orderInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderExtInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderExtInfo.java new file mode 100644 index 0000000000..b4986f35c4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderExtInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 订单其他信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderExtInfo extends OrderIdInfo { + + private static final long serialVersionUID = 4723533858047219828L; + /** 类型 1:联盟佣金信息 */ + @JsonProperty("type") + @JacksonXmlProperty(localName = "type") + private Integer type; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderExtMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderExtMessage.java new file mode 100644 index 0000000000..c5ede6c6bd --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderExtMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单状态消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderExtMessage extends WxChannelMessage { + + private static final long serialVersionUID = -3183077256476798756L; + /** 订单信息 */ + @JsonProperty("order_info") + @JacksonXmlProperty(localName = "order_info") + private OrderExtInfo orderInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderIdInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderIdInfo.java new file mode 100644 index 0000000000..b9ac33b376 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderIdInfo.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单id信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderIdInfo implements Serializable { + + private static final long serialVersionUID = 5547544436235032051L; + /** 订单ID */ + @JsonProperty("order_id") + @JacksonXmlProperty(localName = "order_id") + private String orderId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderIdMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderIdMessage.java new file mode 100644 index 0000000000..398c29bde4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderIdMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单id消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderIdMessage extends WxChannelMessage { + + private static final long serialVersionUID = 3793987364799712798L; + /** 订单信息 */ + @JsonProperty("order_info") + @JacksonXmlProperty(localName = "order_info") + private OrderIdInfo orderInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderPayInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderPayInfo.java new file mode 100644 index 0000000000..d916c14a21 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderPayInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 订单支付信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderPayInfo extends OrderIdInfo { + + private static final long serialVersionUID = -3502786073769735831L; + /** 支付时间,秒级时间戳 */ + @JsonProperty("pay_time") + @JacksonXmlProperty(localName = "pay_time") + private Long payTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderPayMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderPayMessage.java new file mode 100644 index 0000000000..ee1f458aba --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderPayMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单支付成功消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderPayMessage extends WxChannelMessage { + + private static final long serialVersionUID = 1083018549119427808L; + /** 订单信息 */ + @JsonProperty("order_info") + @JacksonXmlProperty(localName = "order_info") + private OrderPayInfo orderInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderSettleInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderSettleInfo.java new file mode 100644 index 0000000000..b4f48b6fb8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderSettleInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 订单结算信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderSettleInfo extends OrderIdInfo { + + private static final long serialVersionUID = -1817955568383872053L; + /** 结算时间 */ + @JsonProperty("settle_time") + @JacksonXmlProperty(localName = "settle_time") + private Long settleTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderSettleMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderSettleMessage.java new file mode 100644 index 0000000000..2d3d1d96d6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderSettleMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单结算消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderSettleMessage extends WxChannelMessage { + + private static final long serialVersionUID = -4001189226630840548L; + /** 订单信息 */ + @JsonProperty("order_info") + @JacksonXmlProperty(localName = "order_info") + private OrderSettleInfo orderInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderStatusMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderStatusMessage.java new file mode 100644 index 0000000000..4a06ccc99c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/order/OrderStatusMessage.java @@ -0,0 +1,54 @@ +package me.chanjar.weixin.channel.bean.message.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 订单状态消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class OrderStatusMessage extends WxChannelMessage { + + private static final long serialVersionUID = -356717038344749283L; + /** 订单ID */ + @JsonProperty("order_id") + @JacksonXmlProperty(localName = "order_id") + private String orderId; + + /** 订单状态 {@link me.chanjar.weixin.channel.enums.WxOrderStatus} */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private Integer status; + + @JsonProperty("ProductOrderStatusUpdate") + @JacksonXmlProperty(localName = "ProductOrderStatusUpdate") + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = null; + obj = map.get("order_id"); + if (obj != null) { + this.orderId = obj.toString(); + } + obj = map.get("status"); + if (obj != null) { + if (obj instanceof Integer) { + this.status = (Integer) obj; + } else if (obj instanceof String) { + this.status = Integer.parseInt((String) obj); + } + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/BrandMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/BrandMessage.java new file mode 100644 index 0000000000..9a7c021c9d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/BrandMessage.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.channel.bean.message.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 品牌消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class BrandMessage extends WxChannelMessage { + + private static final long serialVersionUID = -3773902704930003105L; + /** 品牌库中的品牌编号 */ + @JsonProperty("brand_id") + @JacksonXmlProperty(localName = "brand_id") + private String brandId; + + /** 审核id */ + @JsonProperty("audit_id") + @JacksonXmlProperty(localName = "audit_id") + private String auditId; + + /** 审核状态, 1新增品牌 2更新品牌 3撤回品牌审核 4审核成功 5审核失败 6删除品牌 7品牌资质被系统撤销 */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private Integer status; + + /** 相关信息 */ + @JsonProperty("reason") + @JacksonXmlProperty(localName = "reason") + private String reason; + + @JsonProperty("BrandEvent") + @JacksonXmlProperty(localName = "BrandEvent") + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = null; + obj = map.get("brand_id"); + if (obj != null) { + this.brandId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("audit_id"); + if (obj != null) { + this.auditId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("status"); + if (obj != null) { + if (obj instanceof Integer) { + this.status = (Integer) obj; + } else if (obj instanceof String) { + this.status = Integer.parseInt((String) obj); + } + } + obj = map.get("reason"); + if (obj != null) { + this.reason = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/CategoryAuditMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/CategoryAuditMessage.java new file mode 100644 index 0000000000..f6d696d5c1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/CategoryAuditMessage.java @@ -0,0 +1,63 @@ +package me.chanjar.weixin.channel.bean.message.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 类目审核消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class CategoryAuditMessage extends WxChannelMessage { + + private static final long serialVersionUID = 3192582751919917223L; + /** 审核id */ + @JsonProperty("audit_id") + @JacksonXmlProperty(localName = "audit_id") + private String auditId; + + /** 审核状态, 1:审核中, 2:审核拒绝, 3:审核通过, 12:主动取消申请单 */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private Integer status; + + /** 相关信息 */ + @JsonProperty("reason") + @JacksonXmlProperty(localName = "reason") + private String reason; + + @JsonProperty("ProductCategoryAudit") + @JacksonXmlProperty(localName = "ProductCategoryAudit") + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = null; + obj = map.get("audit_id"); + if (obj != null) { + this.auditId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("status"); + if (obj != null) { + if (obj instanceof Integer) { + this.status = (Integer) obj; + } else if (obj instanceof String) { + this.status = Integer.parseInt((String) obj); + } + } + obj = map.get("reason"); + if (obj != null) { + this.reason = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/SpuAuditMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/SpuAuditMessage.java new file mode 100644 index 0000000000..569b53781e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/SpuAuditMessage.java @@ -0,0 +1,83 @@ +package me.chanjar.weixin.channel.bean.message.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * SPU审核消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class SpuAuditMessage extends WxChannelMessage { + + private static final long serialVersionUID = 1763291928383078102L; + /** 商品id */ + @JsonProperty("product_id") + @JacksonXmlProperty(localName = "product_id") + private String productId; + + /** + * 审核状态, 2:审核不通过;3:审核通过 商品状态, 5:上架;11:自主下架;13:系统下架 + */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private Integer status; + + /** 审核/下架原因,非必填字段 */ + @JsonProperty("reason") + @JacksonXmlProperty(localName = "reason") + private String reason; + + + + @JsonProperty("ProductSpuAudit") + @JacksonXmlProperty(localName = "ProductSpuAudit") + public void ProductSpuAudit(Map map) { + this.unpackNameFromNestedObject(map); + } + + @JsonProperty("ProductSpuUpdate") + @JacksonXmlProperty(localName = "ProductSpuUpdate") + public void ProductSpuUpdate(Map map) { + this.unpackNameFromNestedObject(map); + } + + @JsonProperty("ProductSpuListing") + @JacksonXmlProperty(localName = "ProductSpuListing") + public void ProductSpuListing(Map map) { + this.unpackNameFromNestedObject(map); + } + + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = null; + obj = map.get("product_id"); + if (obj != null) { + this.productId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("status"); + if (obj != null) { + if (obj instanceof Integer) { + this.status = (Integer) obj; + } else if (obj instanceof String) { + this.status = Integer.parseInt((String) obj); + } + } + obj = map.get("reason"); + if (obj != null) { + this.reason = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/SpuStatusMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/SpuStatusMessage.java new file mode 100644 index 0000000000..7fb9f272e8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/product/SpuStatusMessage.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.channel.bean.message.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * SPU状态消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class SpuStatusMessage extends WxChannelMessage { + + private static final long serialVersionUID = 6872830451279856492L; + /** 商家自定义商品id */ + @JsonProperty("out_product_id") + @JacksonXmlProperty(localName = "out_product_id") + private String outProductId; + + /** 平台商品id */ + @JsonProperty("product_id") + @JacksonXmlProperty(localName = "product_id") + private String productId; + + /** 当前商品上下架状态 参考 {@link me.chanjar.weixin.channel.enums.SpuStatus } */ + @JsonProperty("status") + @JacksonXmlProperty(localName = "status") + private Integer status; + + /** 相关信息 */ + @JsonProperty("reason") + @JacksonXmlProperty(localName = "reason") + private String reason; + + @JsonProperty("OpenProductSpuStatusUpdate") + @JacksonXmlProperty(localName = "OpenProductSpuStatusUpdate") + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = null; + obj = map.get("out_product_id"); + if (obj != null) { + this.outProductId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("product_id"); + if (obj != null) { + this.productId = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + obj = map.get("status"); + if (obj != null) { + if (obj instanceof Integer) { + this.status = (Integer) obj; + } else if (obj instanceof String) { + this.status = Integer.parseInt((String) obj); + } + } + obj = map.get("reason"); + if (obj != null) { + this.reason = (obj instanceof String ? (String) obj : String.valueOf(obj)); + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/supplier/SupplierItemInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/supplier/SupplierItemInfo.java new file mode 100644 index 0000000000..49bbb0548b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/supplier/SupplierItemInfo.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.channel.bean.message.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 团长商品变更信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SupplierItemInfo implements Serializable { + + private static final long serialVersionUID = -1971161027976024360L; + /** 商品变更类型,1:新增商品;2:更新商品 */ + @JsonProperty("event_type") + @JacksonXmlProperty(localName = "event_type") + private Integer eventType; + + /** 团长商品所属小店appid */ + @JsonProperty("appid") + @JacksonXmlProperty(localName = "appid") + private String appid; + + /** 商品id */ + @JsonProperty("product_id") + @JacksonXmlProperty(localName = "product_id") + private String productId; + + /** 商品版本号 */ + @JsonProperty("version") + @JacksonXmlProperty(localName = "version") + private String version; + + /** 商品更新字段,当event_type = 2时有值。commission_ratio、service_ratio、status、active_time分别表示佣金、服务费、商品状态和合作生效时间有变更 */ + @JsonProperty("update_fields") + @JacksonXmlProperty(localName = "update_fields") + private List updateFields; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/supplier/SupplierItemMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/supplier/SupplierItemMessage.java new file mode 100644 index 0000000000..2403aa0c60 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/supplier/SupplierItemMessage.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.message.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 团长商品变更 消息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class SupplierItemMessage extends WxChannelMessage { + + private static final long serialVersionUID = -4520611382070764349L; + /** 账户信息 */ + @JsonProperty("item_info") + @JacksonXmlProperty(localName = "item_info") + private SupplierItemInfo itemInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/AfterSaleDetail.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/AfterSaleDetail.java new file mode 100644 index 0000000000..5401a588bf --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/AfterSaleDetail.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后信息详情 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AfterSaleDetail implements Serializable { + + private static final long serialVersionUID = -3786573982841041144L; + + /** 正在售后流程的售后单数 */ + @JsonProperty("on_aftersale_order_cnt") + private Integer onAfterSaleOrderCnt; + + /** 售后单列表 */ + @JsonProperty("aftersale_order_list") + private List afterSaleOrderList; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/AfterSaleOrderInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/AfterSaleOrderInfo.java new file mode 100644 index 0000000000..118feba35b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/AfterSaleOrderInfo.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 售后信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class AfterSaleOrderInfo implements Serializable { + + private static final long serialVersionUID = 3938545222231426455L; + + /** 售后单ID */ + @JsonProperty("aftersale_order_id") + private String afterSaleOrderId; + + public String getAfterSaleOrderId() { + return afterSaleOrderId; + } + + public void setAfterSaleOrderId(String afterSaleOrderId) { + this.afterSaleOrderId = afterSaleOrderId; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/ChangeOrderInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/ChangeOrderInfo.java new file mode 100644 index 0000000000..f6485085bb --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/ChangeOrderInfo.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单修改信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ChangeOrderInfo implements Serializable { + + private static final long serialVersionUID = 4932726847720452340L; + + /** 商品id */ + @JsonProperty("product_id") + private String productId; + + /** 商品sku */ + @JsonProperty("sku_id") + private String skuId; + + /** 订单中该商品修改后的总价,以分为单位 */ + @JsonProperty("change_price") + private String changePrice; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/DeliveryProductInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/DeliveryProductInfo.java new file mode 100644 index 0000000000..5427a49839 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/DeliveryProductInfo.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.delivery.FreightProductInfo; + +/** + * 发货物流信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DeliveryProductInfo implements Serializable { + + private static final long serialVersionUID = -8110532854439612471L; + /** 快递单号 */ + @JsonProperty("waybill_id") + private String waybillId; + + /** 快递公司编码 */ + @JsonProperty("delivery_id") + private String deliveryId; + + /** 包裹中商品信息 */ + @JsonProperty("product_infos") + private List productInfos; + + /** 快递公司名称 */ + @JsonProperty("delivery_name") + private String deliveryName; + + /** 发货时间,秒级时间戳 */ + @JsonProperty("delivery_time") + private Long deliveryTime; + + /** 配送方式,枚举值见DeliveryType {@link me.chanjar.weixin.channel.enums.DeliveryType} */ + @JsonProperty("deliver_type") + private Integer deliverType; + + /** 发货地址 */ + @JsonProperty("delivery_address") + private OrderAddressInfo deliveryAddress; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/DeliveryUpdateParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/DeliveryUpdateParam.java new file mode 100644 index 0000000000..6aca6feed4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/DeliveryUpdateParam.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.delivery.FreightProductInfo; + +/** + * 修改物流参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeliveryUpdateParam implements Serializable { + + /** 订单ID */ + @JsonProperty("order_id") + private String orderId; + + /** 物流公司ID */ + @JsonProperty("delivery_list") + private List deliveryList; + + @Data + @NoArgsConstructor + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class DeliveryInfo implements Serializable { + + private static final long serialVersionUID = 1348000697768633889L; + /** 快递单号 */ + @JsonProperty("waybill_id") + private String waybillId; + + /** 快递公司编码 */ + @JsonProperty("delivery_id") + private String deliveryId; + + /** 配送方式,枚举值见DeliveryType {@link me.chanjar.weixin.channel.enums.DeliveryType} */ + @JsonProperty("deliver_type") + private Integer deliverType; + + /** 包裹中商品信息 */ + @JsonProperty("product_infos") + private List productInfos; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderAddressInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderAddressInfo.java new file mode 100644 index 0000000000..ff3e1ba332 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderAddressInfo.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AddressInfo; + +/** + * 地址信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderAddressInfo extends AddressInfo { + + private static final long serialVersionUID = 3062707865189774795L; + /** 虚拟发货订单联系方式(deliver_method=1时返回) */ + @JsonProperty("virtual_order_tel_number") + private String virtualOrderTelNumber; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderAddressParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderAddressParam.java new file mode 100644 index 0000000000..55eb6a8655 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderAddressParam.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AddressInfo; + +/** + * 订单地址参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class OrderAddressParam implements Serializable { + + private static final long serialVersionUID = 2277618297276466650L; + + /** 订单id */ + @JsonProperty("order_id") + private String orderId; + + /** 地址信息 */ + @JsonProperty("user_address") + private AddressInfo userAddress; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderCommissionInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderCommissionInfo.java new file mode 100644 index 0000000000..78e391e774 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderCommissionInfo.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分佣信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderCommissionInfo implements Serializable { + + private static final long serialVersionUID = -3046852309683467272L; + /** 商品skuid */ + @JsonProperty("sku_id") + private String skuId; + + /** 分账方昵称 */ + @JsonProperty("nickname") + private String nickname; + + /** 分账方类型,0:达人,1:团长 */ + @JsonProperty("type") + private Integer type; + + /** 分账状态, 1:未结算,2:已结算 */ + @JsonProperty("status") + private Integer status; + + /** 分账金额 */ + @JsonProperty("amount") + private Integer amount; + + /** 达人视频号id */ + @JsonProperty("finder_id") + private String finderId; + + /** 达人openfinderid */ + @JsonProperty("openfinderid") + private String openFinderId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderCouponInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderCouponInfo.java new file mode 100644 index 0000000000..a8f020c0ef --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderCouponInfo.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 卡券信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderCouponInfo implements Serializable { + + private static final long serialVersionUID = -2033350505767196339L; + /** 用户优惠券id */ + @JsonProperty("user_coupon_id") + private String userCouponId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderDeliveryInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderDeliveryInfo.java new file mode 100644 index 0000000000..9f3d72feac --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderDeliveryInfo.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 物流信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderDeliveryInfo implements Serializable { + + private static final long serialVersionUID = -5348922760017557397L; + /** 地址信息 */ + @JsonProperty("address_info") + private OrderAddressInfo addressInfo; + + /** 发货物流信息 */ + @JsonProperty("delivery_product_info") + private List deliveryProductInfos; + + /** 发货完成时间,秒级时间戳 */ + @JsonProperty("ship_done_time") + private Long shipDoneTime; + + /** 订单发货方式,0普通物流 1虚拟发货,由商品的同名字段决定 */ + @JsonProperty("deliver_method") + private Integer deliverMethod; + + /** 用户下单后申请修改收货地址,商家同意后该字段会覆盖订单地址信息 */ + @JsonProperty("address_under_review") + private OrderAddressInfo addressUnderReview; + + /** 修改地址申请时间,秒级时间戳 */ + @JsonProperty("address_apply_time") + private Long addressApplyTime; + + /** 电子面单代发时的订单密文 */ + @JsonProperty("ewaybill_order_code") + private String ewaybillOrderCode; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderDetailInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderDetailInfo.java new file mode 100644 index 0000000000..8a17140cc1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderDetailInfo.java @@ -0,0 +1,59 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单详细数据 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderDetailInfo implements Serializable { + + private static final long serialVersionUID = 3916307299998005676L; + /** 商品列表 */ + @JsonProperty("product_infos") + private List productInfos; + + /** 支付信息 */ + @JsonProperty("pay_info") + private OrderPayInfo payInfo; + + /** 价格信息 */ + @JsonProperty("price_info") + private OrderPriceInfo priceInfo; + + /** 配送信息 */ + @JsonProperty("delivery_info") + private OrderDeliveryInfo deliveryInfo; + + /** 优惠券信息 */ + @JsonProperty("coupon_info") + private OrderCouponInfo couponInfo; + + /** 额外信息 */ + @JsonProperty("ext_info") + private OrderExtInfo extInfo; + + /** 分佣信息 */ + @JsonProperty("commission_infos") + private List commissionInfos; + + /** 分享信息 */ + @JsonProperty("sharer_info") + private OrderSharerInfo sharerInfo; + + /** 结算信息 */ + @JsonProperty("settle_info") + private OrderSettleInfo settleInfo; + + /** 分享员信息 */ + @JsonProperty("sku_sharer_infos") + private List skuSharerInfos; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderExtInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderExtInfo.java new file mode 100644 index 0000000000..3338d1a428 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderExtInfo.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单备注信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderExtInfo implements Serializable { + + private static final long serialVersionUID = 4568097877621455429L; + /** 用户备注 */ + @JsonProperty("customer_notes") + private String customerNotes; + + /** 商家备注 */ + @JsonProperty("merchant_notes") + private String merchantNotes; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderIdParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderIdParam.java new file mode 100644 index 0000000000..f1e92e1339 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderIdParam.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单id参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class OrderIdParam implements Serializable { + + private static final long serialVersionUID = -8616582197963359789L; + /** 订单ID */ + @JsonProperty("order_id") + private String orderId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderInfo.java new file mode 100644 index 0000000000..894b36f7af --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderInfo.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 视频号小店订单 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderInfo implements Serializable { + + private static final long serialVersionUID = -4562618835611282016L; + /** 订单号 */ + @JsonProperty("order_id") + protected String orderId; + + /** 订单状态,枚举值见 {@link me.chanjar.weixin.channel.enums.WxOrderStatus} */ + @JsonProperty("status") + protected Integer status; + + /** 买家身份标识 */ + @JsonProperty("openid") + protected String openid; + + /** union id */ + @JsonProperty("unionid") + protected String unionid; + + /** 订单详细数据信息 */ + @JsonProperty("order_detail") + protected OrderDetailInfo orderDetail; + + /** 售后信息 */ + @JsonProperty("aftersale_detail") + protected AfterSaleDetail afterSaleDetail; + + /** 创建时间 秒级时间戳 */ + @JsonProperty("create_time") + protected Integer createTime; + + /** 更新时间 秒级时间戳 */ + @JsonProperty("update_time") + protected Integer updateTime; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderInfoResponse.java new file mode 100644 index 0000000000..0b6fd53c17 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderInfoResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 订单信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 935829924760021624L; + /** 订单信息 */ + @JsonProperty("order") + private OrderInfo order; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderListParam.java new file mode 100644 index 0000000000..a84da3d2e8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderListParam.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; +import me.chanjar.weixin.channel.bean.base.TimeRange; + +/** + * 获取订单列表参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(Include.NON_NULL) +public class OrderListParam extends StreamPageParam { + + private static final long serialVersionUID = 3780097459964746890L; + /** 订单创建时间范围 */ + @JsonProperty("create_time_range") + private TimeRange createTimeRange; + + /** 订单更新时间范围 */ + @JsonProperty("update_time_range") + private TimeRange updateTimeRange; + + /** 订单状态,枚举值见 {@link me.chanjar.weixin.channel.enums.WxOrderStatus} */ + @JsonProperty("status") + private Integer status; + + /** 买家身份标识 */ + @JsonProperty("openid") + private Integer openid; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderListResponse.java new file mode 100644 index 0000000000..454abc59d9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderListResponse.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 订单列表 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class OrderListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -6198624448684807852L; + /** 订单id列表 */ + @JsonProperty("order_id_list") + private List ids; + + /** 分页参数,下一页请求回传 */ + @JsonProperty("next_key") + private String nextKey; + + /** 是否还有下一页,true:有下一页;false:已经结束,没有下一页。 */ + @JsonProperty("has_more") + private Boolean hasMore; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPayInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPayInfo.java new file mode 100644 index 0000000000..6c912f7c45 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPayInfo.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 支付信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderPayInfo implements Serializable { + + private static final long serialVersionUID = -5085386252699113948L; + /** 预支付id */ + @JsonProperty("prepayId") + private String prepayId; + + /** 预支付时间,秒级时间戳 */ + @JsonProperty("prepay_time") + private Long prepayTime; + + /** 支付时间,秒级时间戳 */ + @JsonProperty("pay_time") + private Long payTime; + + /** 支付单号 */ + @JsonProperty("transaction_id") + private String transactionId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPriceInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPriceInfo.java new file mode 100644 index 0000000000..64e6690a66 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPriceInfo.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商店订单价格信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderPriceInfo implements Serializable { + + private static final long serialVersionUID = 5216506688949493432L; + /** 商品总价,单位为分 */ + @JsonProperty("product_price") + private Integer productPrice; + + /** 订单金额,单位为分 */ + @JsonProperty("order_price") + private Integer orderPrice; + + /** 运费,单位为分 */ + @JsonProperty("freight") + private Integer freight; + + /** 优惠金额,单位为分 */ + @JsonProperty("discounted_price") + private Integer discountedPrice; + + /** 是否有优惠 */ + @JsonProperty("is_discounted") + private Boolean isDiscounted; + + /** 订单原始价格,单位为分 */ + @JsonProperty("original_order_price") + private Integer originalOrderPrice; + + /** 商品预估价格,单位为分 */ + @JsonProperty("estimate_product_price") + private Integer estimateProductPrice; + + /** 改价后降低金额,单位为分 */ + @JsonProperty("change_down_price") + private Integer changeDownPrice; + + /** 改价后运费,单位为分 */ + @JsonProperty("change_freight") + private Integer changeFreight; + + /** 是否修改运费 */ + @JsonProperty("is_change_freight") + private Boolean changeFreighted; + + /** 是否使用了会员积分抵扣 */ + @JsonProperty("use_deduction") + private Boolean useDeduction; + + /** 会员积分抵扣金额,单位为分 */ + @JsonProperty("deduction_price") + private Integer deductionPrice; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPriceParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPriceParam.java new file mode 100644 index 0000000000..30f74501c4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderPriceParam.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * 订单价格参数 + * + * @author Zeyes + */ +@Data +@JsonInclude(Include.NON_NULL) +public class OrderPriceParam implements Serializable { + + private static final long serialVersionUID = -7925819981481556218L; + /** 订单id */ + @JsonProperty("order_id") + private String orderId; + + /** 是否修改运费 */ + @JsonProperty("change_express") + private Boolean changeExpress; + + /** 修改后的运费价格(change_express=true时必填),以分为单位 */ + @JsonProperty("express_fee") + private Integer expressFee; + + /** 改价列表 */ + @JsonProperty("change_order_infos") + private List changeOrderInfos; + + public OrderPriceParam() { + } + + public OrderPriceParam(String orderId, Integer expressFee, List changeOrderInfos) { + this.orderId = orderId; + // expressFee不为空时,表示修改运费 + this.changeExpress = (expressFee != null); + this.expressFee = expressFee; + this.changeOrderInfos = changeOrderInfos; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderProductExtraService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderProductExtraService.java new file mode 100644 index 0000000000..ff413a9646 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderProductExtraService.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 商品额外服务信息 + * + * @author 北鹤M + */ +@Data +@NoArgsConstructor +public class OrderProductExtraService implements Serializable { + + private static final long serialVersionUID = -8752053507170277156L; + + /** 7天无理由:0:不支持,1:支持 */ + @JsonProperty("seven_day_return") + private Integer sevenDayReturn; + + /** 商家运费险:0:不支持,1:支持 */ + @JsonProperty("freight_insurance") + private Integer freightInsurance; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderProductInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderProductInfo.java new file mode 100644 index 0000000000..acef8cc4f6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderProductInfo.java @@ -0,0 +1,112 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AttrInfo; + +/** + * 订单商品信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderProductInfo implements Serializable { + + private static final long serialVersionUID = -2193536732955185928L; + /** 商品spu id */ + @JsonProperty("product_id") + private String productId; + + /** sku_id */ + @JsonProperty("sku_id") + private String skuId; + + /** sku小图 */ + @JsonProperty("thumb_img") + private String thumbImg; + + /** sku数量 */ + @JsonProperty("sku_cnt") + private Integer skuCnt; + + /** 售卖价格(单位:分) */ + @JsonProperty("sale_price") + private Integer salePrice; + + /** 商品标题 */ + @JsonProperty("title") + private String title; + + /** 正在售后/退款流程中的 sku 数量 */ + @JsonProperty("on_aftersale_sku_cnt") + private Integer onAfterSaleSkuCnt; + + /** 完成售后/退款的 sku 数量 */ + @JsonProperty("finish_aftersale_sku_cnt") + private Integer finishAfterSaleSkuCnt; + + /** 商品编码 */ + @JsonProperty("sku_code") + private String skuCode; + + /** 市场价格(单位:分) */ + @JsonProperty("market_price") + private Integer marketPrice; + + /** sku属性 */ + @JsonProperty("sku_attrs") + private List skuAttrs; + + /** sku实付价格 */ + @JsonProperty("real_price") + private Integer realPrice; + + /** 商品外部spu id */ + @JsonProperty("out_product_id") + private String outProductId; + + /** 商品外部sku id */ + @JsonProperty("out_sku_id") + private String outSkuId; + + /** 是否有优惠金额,非必填,默认为false */ + @JsonProperty("is_discounted") + private Boolean isDiscounted; + + /** 优惠后 sku 价格,非必填,is_discounted为 true 时有值 */ + @JsonProperty("estimate_price") + private Integer estimatePrice; + + /** 是否修改过价格,非必填,默认为false */ + @JsonProperty("is_change_price") + private Boolean changePriced; + + /** 改价后 sku 价格,非必填,is_change_price为 true 时有值 */ + @JsonProperty("change_price") + private Integer changePrice; + + /** 区域库存id */ + @JsonProperty("out_warehouse_id") + private String outWarehouseId; + + /** 商品发货信息 */ + @JsonProperty("sku_deliver_info") + private OrderSkuDeliverInfo skuDeliverInfo; + + /** 商品额外服务信息 */ + @JsonProperty("extra_service") + private OrderProductExtraService extraService; + + /** 是否使用了会员积分抵扣 */ + @JsonProperty("use_deduction") + private Boolean useDeduction; + + /** 会员积分抵扣金额,单位为分 */ + @JsonProperty("deduction_price") + private Integer deductionPrice; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderRemarkParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderRemarkParam.java new file mode 100644 index 0000000000..707ec0d96b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderRemarkParam.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单备注 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OrderRemarkParam implements Serializable { + + private static final long serialVersionUID = 2285714780419948468L; + /** 订单id */ + @JsonProperty("order_id") + private String orderId; + + /** 备注内容 */ + @JsonProperty("merchant_notes") + private String merchantNotes; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSearchCondition.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSearchCondition.java new file mode 100644 index 0000000000..012b0fca49 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSearchCondition.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 订单 搜索条件 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(Include.NON_EMPTY) +public class OrderSearchCondition implements Serializable { + + private static final long serialVersionUID = 5492584333971883140L; + /** 商品标题关键词 */ + @JsonProperty("title") + private String title; + + /** 商品编码 */ + @JsonProperty("sku_code") + private String skuCode; + + /** 收件人 */ + @JsonProperty("user_name") + private String userName; + + /** 收件人电话 */ + @JsonProperty("tel_number") + private String telNumber; + + /** 选填,只搜一个订单时使用 */ + @JsonProperty("order_id") + private String orderId; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSearchParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSearchParam.java new file mode 100644 index 0000000000..0a9483e0d5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSearchParam.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@JsonInclude(Include.NON_EMPTY) +public class OrderSearchParam extends StreamPageParam { + + private static final long serialVersionUID = 5737520097455135218L; + /** 商品标题关键词 */ + @JsonProperty("search_condition") + private OrderSearchCondition searchCondition; + + /** 不填该参数:全部订单 0:没有正在售后的订单, 1:正在售后单数量大于等于1的订单 */ + @JsonProperty("on_aftersale_order_exist") + private Integer onAfterSaleOrderExist; + + /** 订单状态 {@link me.chanjar.weixin.channel.enums.WxOrderStatus} */ + @JsonProperty("on_aftersale_order_exist") + private Integer status; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSettleInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSettleInfo.java new file mode 100644 index 0000000000..c264a6289a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSettleInfo.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 结算信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderSettleInfo implements Serializable { + + private static final long serialVersionUID = 2140632631448343656L; + /** 预计技术服务费(单位为分) */ + @JsonProperty("predict_commission_fee") + private Integer predictCommissionFee; + + /** 实际技术服务费(单位为分)(未结算时本字段为空) */ + @JsonProperty("commission_fee") + private Integer commissionFee; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSharerInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSharerInfo.java new file mode 100644 index 0000000000..be66463445 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSharerInfo.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分享信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class OrderSharerInfo implements Serializable { + + private static final long serialVersionUID = 7183259072254660971L; + /** 分享员openid */ + @JsonProperty("sharer_openid") + private String sharerOpenid; + + /** 分享员unionid */ + @JsonProperty("sharer_unionid") + private String sharerUnionid; + + /** 分享员类型,0:普通分享员,1:店铺分享员 */ + @JsonProperty("sharer_type") + private Integer sharerType; + + /** 分享场景 {@link me.chanjar.weixin.channel.enums.ShareScene} */ + @JsonProperty("share_scene") + private Integer shareScene; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSkuDeliverInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSkuDeliverInfo.java new file mode 100644 index 0000000000..6dd46c9a39 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSkuDeliverInfo.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 商品发货信息 + * + * @author 北鹤M + */ +@Data +@NoArgsConstructor +public class OrderSkuDeliverInfo implements Serializable { + + private static final long serialVersionUID = 4075897806362929800L; + + /** 商品发货类型:0:现货,1:全款预售 */ + @JsonProperty("stock_type") + private Integer stockType; + + /** 预计发货时间(stock_type=1时返回该字段) */ + @JsonProperty("predict_delivery_time") + private String predictDeliveryTime; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSkuShareInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSkuShareInfo.java new file mode 100644 index 0000000000..7912e53348 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/order/OrderSkuShareInfo.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.channel.bean.order; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * Sku层分享信息 + * + * @author 北鹤M + */ +@Data +@NoArgsConstructor +public class OrderSkuShareInfo implements Serializable { + + private static final long serialVersionUID = 705312408112124476L; + + /** 分享员openid */ + @JsonProperty("sharer_openid") + private String sharerOpenid; + + /** 分享员unionid */ + @JsonProperty("sharer_unionid") + private String sharerUnionid; + + /** 分享员类型,0:普通分享员,1:店铺分享员 */ + @JsonProperty("sharer_type") + private Integer sharerType; + + /** 分享场景 {@link me.chanjar.weixin.channel.enums.ShareScene} */ + @JsonProperty("share_scene") + private Integer shareScene; + + /** 商品skuid */ + @JsonProperty("sku_id") + private String skuId; + + /** 是否来自企微分享 */ + @JsonProperty("from_wecom") + private Boolean fromWecom; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/DescriptionInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/DescriptionInfo.java new file mode 100644 index 0000000000..b97473e3d3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/DescriptionInfo.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品详情 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class DescriptionInfo implements Serializable { + + private static final long serialVersionUID = 3402153796734747882L; + + /** 商品详情图文,字符类型,最长不超过2000 */ + @JsonProperty("desc") + private String desc; + + /** 商品详情图片,图片类型,最多不超过50张 */ + @JsonProperty("imgs") + private List imgs; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExpressInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExpressInfo.java new file mode 100644 index 0000000000..0c21d9610e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExpressInfo.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 运费信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ExpressInfo implements Serializable { + + private static final long serialVersionUID = 3274035362148612426L; + + /** 运费模板ID(先通过获取运费模板接口merchant/getfreighttemplatelist拿到),若deliver_method=1,则不用填写 */ + @JsonProperty("template_id") + private String templateId; + + /** 商品重量,单位克,若当前运费模版计价方式为[按重量],则必填 */ + @JsonProperty("weight") + private Integer weight; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExtraServiceInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExtraServiceInfo.java new file mode 100644 index 0000000000..aeaf1a8cd6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExtraServiceInfo.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ExtraServiceInfo implements Serializable { + + private static final long serialVersionUID = -5517806977282063174L; + + /** + * 是否支持七天无理由退货,0-不支持七天无理由, 1-支持七天无理由, 2-支持七天无理由(定制商品除外)。 管理规则请参见七天无理由退货管理规则。类目是否必须支持七天无理由退货, + * 可参考文档获取类目信息中的字段attr.seven_day_return + */ + @JsonProperty("seven_day_return") + private Integer sevenDayReturn; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/LimitInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/LimitInfo.java new file mode 100644 index 0000000000..389773d5e7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/LimitInfo.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 限时购信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LimitInfo implements Serializable { + + private static final long serialVersionUID = -4670198322237114719L; + + /** 限购周期类型,0无限购(默认),1按自然日限购,2按自然周限购,3按自然月限购 */ + @JsonProperty("period_type") + private Integer periodType; + + /** 限购周期类型,0无限购(默认),1按自然日限购,2按自然周限购,3按自然月限购 */ + @JsonProperty("limited_buy_num") + private Integer num; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuDeliverInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuDeliverInfo.java new file mode 100644 index 0000000000..d1f10dc5f8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuDeliverInfo.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * sku发货信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SkuDeliverInfo implements Serializable { + + private static final long serialVersionUID = 8046963723772755406L; + + /** sku库存情况。0:现货(默认),1:全款预售。部分类目支持全款预售,具体参考文档获取类目信息中的字段attr.pre_sale */ + @JsonProperty("stock_type") + private Integer stockType; + + /** sku发货节点,该字段仅对stock_type=1有效。0:付款后n天发货,1:预售结束后n天发货 */ + @JsonProperty("full_payment_presale_delivery_type") + private Integer fullPaymentPresaleDeliveryType; + + /** sku预售周期开始时间,秒级时间戳,该字段仅对delivery_type=1有效。 */ + @JsonProperty("presale_begin_time") + private Long presaleBeginTime; + + /** + * sku预售周期结束时间,秒级时间戳,该字段仅对delivery_type=1有效。限制:预售结束时间距离现在<=30天, 即presale_end_time - now <= 2592000。预售时间区间<=15天, + * 即presale_end_time - presale_begin_time <= 1296000 + */ + @JsonProperty("presale_end_time") + private Long presaleEndTime; + + /** + * sku发货时效,即付款后/预售结束后{full_payment_presale_delivery_time}天内发货, 该字段仅对stock_type=1时有效。范围是[4, 15]的整数。 + */ + @JsonProperty("full_payment_presale_delivery_time") + private Integer fullPaymentPresaleDeliveryTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuInfo.java new file mode 100644 index 0000000000..3b46708039 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuInfo.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import me.chanjar.weixin.channel.bean.base.AttrInfo; + +/** + * SKU信息 + * + * @author Zeyes + */ +@Data +public class SkuInfo implements Serializable { + + private static final long serialVersionUID = -8734396136299597845L; + + /** 商家自定义商品ID */ + @JsonProperty("out_product_id") + private String outProductId; + + /** 商家自定义skuID */ + @JsonProperty("out_sku_id") + private String outSkuId; + + /** sku小图 */ + @JsonProperty("thumb_img") + private String thumbImg; + + /** 售卖价格,以分为单位,数字类型,最大不超过10000000(1000万元) */ + @JsonProperty("sale_price") + private Integer salePrice; + + /** 市场价格,以分为单位,数字类型,最大不超过10000000(1000万元),且必须比sale_price大 */ + @JsonProperty("market_price") + private Integer marketPrice; + + /** 库存,数字类型,最大不超过10000000(1000万) */ + @JsonProperty("stock_num") + private Integer stockNum; + + /** 商品编码,字符类型,最长不超过20 */ + @JsonProperty("sku_code") + private String skuCode; + + /** SKU属性 */ + @JsonProperty("sku_attrs") + private List attrs; + + /** sku发货信息 */ + @JsonProperty("sku_deliver_info") + private SkuDeliverInfo skuDeliverInfo; + + /** skuID */ + @JsonProperty("sku_id") + private Long skuId; + + public SkuInfo() { + } + + public SkuInfo(String outProductId, String outSkuId) { + this.outProductId = outProductId; + this.outSkuId = outSkuId; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockInfo.java new file mode 100644 index 0000000000..a0dccb1329 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockInfo.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品库存 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SkuStockInfo implements Serializable { + + private static final long serialVersionUID = 4719729125885685958L; + + /** 通用库存数量 */ + @JsonProperty("normal_stock_num") + private Integer normalStockNum; + + /** 限时抢购库存数量 */ + @JsonProperty("limited_discount_stock_num") + private Integer limitedDiscountStockNum; + + /** 区域库存 */ + @JsonProperty("warehouse_stocks") + private List warehouseStocks; + + /** 库存总量:通用库存数量 + 限时抢购库存数量 + 区域库存总量 */ + @JsonProperty("total_stock_num") + private Integer totalStockNum; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockParam.java new file mode 100644 index 0000000000..cf7374e75e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SkuStockParam implements Serializable { + + private static final long serialVersionUID = -5542939078361208816L; + + /** 内部商品ID */ + @JsonProperty("product_id") + protected String productId; + + /** 内部sku_id */ + @JsonProperty("sku_id") + protected String skuId; + + /** 修改类型。1: 增加;2:减少;3:设置 */ + @JsonProperty("diff_type") + protected Integer diffType; + + /** 增加、减少或者设置的库存值 */ + @JsonProperty("num") + protected Integer num; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockResponse.java new file mode 100644 index 0000000000..9cbd6f18c0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SkuStockResponse.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.product; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 库存信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SkuStockResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -2156342792354605826L; + + /** 库存信息 */ + private SkuStockInfo data; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuCategory.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuCategory.java new file mode 100644 index 0000000000..8adc311f95 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuCategory.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品类目id + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SpuCategory implements Serializable { + + private static final long serialVersionUID = -8500610555473351789L; + + /** 类目id */ + @JsonProperty("cat_id") + private String id; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuGetResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuGetResponse.java new file mode 100644 index 0000000000..b01682802f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuGetResponse.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 商品信息 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SpuGetResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -8955745006296226140L; + + /** 商品线上数据,入参data_type==2时不返回该字段;入参data_type==3且商品未处于上架状态,不返回该字段 */ + @JsonProperty("product") + private SpuInfo product; + + /** 商品草稿数据,入参data_type==1时不返回该字段 */ + @JsonProperty("edit_product") + private SpuInfo editProduct; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuInfo.java new file mode 100644 index 0000000000..7e3834f10e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuInfo.java @@ -0,0 +1,97 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.AttrInfo; + +/** + * Spu信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SpuInfo extends SpuSimpleInfo { + + private static final long serialVersionUID = -1183209029245287297L; + + /** 标题,字符类型,最少不低于3,最长不超过60。商品标题不得仅为数字、字母、字符或上述三种的组合 */ + @JsonProperty("title") + private String title; + + /** 副标题,最多18字符 */ + @JsonProperty("sub_title") + private String subTitle; + + /** 主图,多张,列表,图片类型,最多不超过9张 */ + @JsonProperty("head_imgs") + private List headImgs; + + /** 发货方式,若为无需快递(仅对部分类目开放),则无需填写运费模版id。0:快递发货;1:无需快递;默认0 */ + @JsonProperty("deliver_method") + private Integer deliverMethod; + + /** 商品详情 */ + @JsonProperty("desc_info") + private DescriptionInfo descInfo; + + /** 商品类目,大小恒等于3(一二三级类目) */ + @JsonProperty("cats") + private List cats; + + /** 商品参数 */ + @JsonProperty("attrs") + private List attrs; + + /** 商品编码 */ + @JsonProperty("spu_code") + private String spuCode; + + /** 品牌id,无品牌为2100000000 */ + @JsonProperty("brand_id") + private String brandId; + + /** 商品资质图片(最多5张) */ + @JsonProperty("qualifications") + private List qualifications; + + /** 运费信息 */ + @JsonProperty("express_info") + private ExpressInfo expressInfo; + + /** 售后说明 */ + @JsonProperty("aftersale_desc") + private String afterSaleDesc; + + /** 限购信息 */ + @JsonProperty("limited_info") + @JsonInclude(Include.NON_EMPTY) + private LimitInfo limitInfo; + + /** 附加服务 */ + @JsonProperty("extra_service") + private ExtraServiceInfo extraService; + + /** 商品线上状态 {@link me.chanjar.weixin.channel.enums.SpuStatus } */ + @JsonProperty("status") + private Integer status; + + /** 商品草稿状态 */ + @JsonProperty("edit_status") + private Integer editStatus; + + /** 最低价格 */ + @JsonProperty("min_price") + private Integer minPrice; + + /** 创建时间 yyyy-MM-dd HH:mm:ss */ + @JsonProperty("create_time") + private String createTime; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuListParam.java new file mode 100644 index 0000000000..775bdf990d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuListParam.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; + +/** + * 商品列表查询参数 + * + * @author Zeyes + */ +@Data +@JsonInclude(Include.NON_NULL) +public class SpuListParam extends StreamPageParam { + + private static final long serialVersionUID = -242932365961748404L; + + /** 商品状态 */ + @JsonProperty("status") + private Integer status; + + public SpuListParam() { + } + + public SpuListParam(Integer pageSize, String nextKey, Integer status) { + this.pageSize = pageSize; + this.nextKey = nextKey; + this.status = status; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuListResponse.java new file mode 100644 index 0000000000..421725c04b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuListResponse.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 商品列表信息 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SpuListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -7448819335418389308L; + + /** 总数 */ + @JsonProperty("total_num") + private Integer totalNum; + + /** 本次翻页的上下文,用于请求下一页 */ + @JsonProperty("next_key") + private String nextKey; + + /** 商品 id 列表 */ + @JsonProperty("product_ids") + private List ids; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuSimpleInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuSimpleInfo.java new file mode 100644 index 0000000000..b1ab3febe7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuSimpleInfo.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SpuSimpleInfo implements Serializable { + + private static final long serialVersionUID = 5583726432139404883L; + + /** 交易组件平台内部商品ID */ + @JsonProperty("product_id") + protected String productId; + + /** 商家自定义商品ID */ + @JsonProperty("out_product_id") + protected String outProductId; + + /** sku数组 */ + @JsonProperty("skus") + protected List skus; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuUpdateResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuUpdateResponse.java new file mode 100644 index 0000000000..815ee4412c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/SpuUpdateResponse.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 商品信息 响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SpuUpdateResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -7072796795527767292L; + + /** 商品信息 */ + @JsonProperty("data") + private SpuInfo data; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/WarehouseStockInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/WarehouseStockInfo.java new file mode 100644 index 0000000000..bb239c9492 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/WarehouseStockInfo.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class WarehouseStockInfo implements Serializable { + + private static final long serialVersionUID = 3184902895765107425L; + + /** 区域库存外部id */ + @JsonProperty("out_warehouse_id") + private String outWarehouseId; + + /** 区域库存数量 */ + @JsonProperty("num") + private Integer num; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/FinderSceneInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/FinderSceneInfo.java new file mode 100644 index 0000000000..76d54d90c9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/FinderSceneInfo.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 视频号场景信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class FinderSceneInfo implements Serializable { + + private static final long serialVersionUID = 5298261857489231549L; + /** 视频号唯一标识 */ + @JsonProperty("promoter_id") + private String promoterId; + + /** 视频号昵称 */ + @JsonProperty("finder_nickname") + private String finderNickname; + + /** 直播间唯一标识 */ + @JsonProperty("live_export_id") + private String liveExportId; + + /** 短视频唯一标识 */ + @JsonProperty("video_export_id") + private String videoExportId; + + /** 短视频标题 */ + @JsonProperty("video_title") + private String videoTitle; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerBindResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerBindResponse.java new file mode 100644 index 0000000000..4a0f8f2bb4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerBindResponse.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分享员绑定响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SharerBindResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 7078787380791500161L; + /** 邀请二维码的图片二进制base64编码,3天有效 */ + @JsonProperty("qrcode_img_base64") + private String qrcodeImgBase64; + + public String getQrcodeImgBase64() { + return qrcodeImgBase64; + } + + public void setQrcodeImgBase64(String qrcodeImgBase64) { + this.qrcodeImgBase64 = qrcodeImgBase64; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerInfo.java new file mode 100644 index 0000000000..73aaeddbd4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerInfo.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * 分享员信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SharerInfo implements Serializable { + + private static final long serialVersionUID = -4373597470611742887L; + /** 分享员openid */ + @JsonProperty("openid") + private String openid; + + /** 分享员unionid */ + @JsonProperty("unionid") + private String unionid; + + /** 分享员openid */ + @JsonProperty("nickname") + private String nickname; + + /** 绑定时间 */ + @JsonProperty("bind_time") + private Long bindTime; + + /** 分享员类型 {@link me.chanjar.weixin.channel.enums.SharerType} */ + @JsonProperty("sharer_type") + private Integer sharerType; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerInfoResponse.java new file mode 100644 index 0000000000..554109c1a9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerInfoResponse.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分享员信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SharerInfoResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1090517907546557929L; + /** 分享员信息 */ + @JsonProperty("sharer_info_list") + private List list; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerListParam.java new file mode 100644 index 0000000000..97ab2797b8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerListParam.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.channel.bean.base.PageParam; + +/** + * @author Zeyes + */ +@Data +@EqualsAndHashCode(callSuper = true) +@JsonInclude(Include.NON_NULL) +public class SharerListParam extends PageParam { + + private static final long serialVersionUID = -2454284952706596246L; + /** 分享员类型 {@link me.chanjar.weixin.channel.enums.SharerType} */ + @JsonProperty("sharer_type") + private Integer sharerType; + + public SharerListParam() { + } + + public SharerListParam(Integer page, Integer pageSize, Integer sharerType) { + super(page, pageSize); + this.sharerType = sharerType; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrder.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrder.java new file mode 100644 index 0000000000..682753e64f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrder.java @@ -0,0 +1,70 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分享员订单 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class SharerOrder implements Serializable { + + private static final long serialVersionUID = 1528673402572025670L; + /** + * 订单号 + */ + @JsonProperty("order_id") + private String orderId; + + /** + * 分享场景 {@link me.chanjar.weixin.channel.enums.ShareScene} + */ + @JsonProperty("share_scene") + private Integer sharerScene; + + /** + * 分享员openid + */ + @JsonProperty("sharer_openid") + private String sharerOpenid; + + /** + * 分享员类型 {@link me.chanjar.weixin.channel.enums.SharerType} + */ + @JsonProperty("sharer_type") + private Integer sharerType; + + /** + * 商品sku_id + */ + @JsonProperty("sku_id") + private String skuId; + + + /** + * 商品唯一id + */ + @JsonProperty("product_id") + private String productId; + + + /** + * 是否从企微分享 + */ + @JsonProperty("from_wecom") + private Boolean fromWxWork; + + + /** + * 视频号场景信息 + */ + @JsonProperty("finder_scene_info") + private FinderSceneInfo sceneInfo; + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrderParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrderParam.java new file mode 100644 index 0000000000..5ada6e3bcf --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrderParam.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.PageParam; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(Include.NON_NULL) +public class SharerOrderParam extends PageParam { + + private static final long serialVersionUID = 5240085870008898601L; + /** 分享员openid */ + @JsonProperty("openid") + private String openid; + + /** 分享场景 */ + @JsonProperty("share_scene") + private Integer shareScene; + + /** 订单创建开始时间 */ + @JsonProperty("start_time") + private Long startTime; + + /** 订单创建结束时间 */ + @JsonProperty("end_time") + private Long endTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrderResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrderResponse.java new file mode 100644 index 0000000000..c84da4114b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerOrderResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分享员订单响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SharerOrderResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 2807417719466178508L; + /** 分享员订单 */ + @JsonProperty("order_list") + private List list; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerSearchParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerSearchParam.java new file mode 100644 index 0000000000..a2669775cb --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerSearchParam.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; + +/** + * @author Zeyes + */ +@Data +@JsonInclude(Include.NON_NULL) +public class SharerSearchParam implements Serializable { + + private static final long serialVersionUID = -6763899740755735718L; + /** 分享员openid */ + @JsonProperty("openid") + private String openid; + + /** 微信号 */ + @JsonProperty("username") + private String username; + + public SharerSearchParam() { + } + + public SharerSearchParam(String openid, String username) { + this.openid = openid; + this.username = username; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerSearchResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerSearchResponse.java new file mode 100644 index 0000000000..52631521df --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerSearchResponse.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分享员绑定响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SharerSearchResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -5346019069466917659L; + /** 分享员openid */ + @JsonProperty("openid") + private String openid; + + /** 分享员unionid */ + @JsonProperty("unionid") + private String unionid; + + /** 分享员openid */ + @JsonProperty("nickname") + private String nickname; + + /** 绑定时间 */ + @JsonProperty("bind_time") + private Long bindTime; + + /** 分享员类型 {@link me.chanjar.weixin.channel.enums.SharerType} */ + @JsonProperty("sharer_type") + private Integer sharerType; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerUnbindParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerUnbindParam.java new file mode 100644 index 0000000000..cd8f21d409 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerUnbindParam.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(Include.NON_NULL) +public class SharerUnbindParam implements Serializable { + + private static final long serialVersionUID = -4515654492511136037L; + /** openid列表 */ + @JsonProperty("openid_list") + private List openIds; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerUnbindResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerUnbindResponse.java new file mode 100644 index 0000000000..9166bc0b58 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/sharer/SharerUnbindResponse.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 分享员解绑响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SharerUnbindResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -2395560383862569445L; + /** 成功列表 */ + @JsonProperty("success_openid") + private List successList; + + /** 失败列表,可重试 */ + @JsonProperty("fail_openid") + private List failList; + + /** 拒绝列表,不可重试(openid错误,未到解绑时间等) */ + @JsonProperty("refuse_openid") + private List refuseList; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/shop/ShopInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/shop/ShopInfo.java new file mode 100644 index 0000000000..b2209a4309 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/shop/ShopInfo.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.shop; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 店铺信息 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ShopInfo implements Serializable { + + /** 店铺名称 */ + @JsonProperty("nickname") + private String nickname; + + /** 店铺头像URL */ + @JsonProperty("headimg_url") + private String headImgUrl; + + /** 店铺类型,目前为"企业"或"个体工商户" */ + @JsonProperty("subject_type") + private String subjectType; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/shop/ShopInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/shop/ShopInfoResponse.java new file mode 100644 index 0000000000..b4317ad3c0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/shop/ShopInfoResponse.java @@ -0,0 +1,19 @@ +package me.chanjar.weixin.channel.bean.shop; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 店铺基本信息响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class ShopInfoResponse extends WxChannelBaseResponse { + + @JsonProperty("info") + private ShopInfo info; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/LocationPriorityResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/LocationPriorityResponse.java new file mode 100644 index 0000000000..5959cb746d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/LocationPriorityResponse.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 仓库优先级响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class LocationPriorityResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -4037484169497319150L; + + /** 按照out_warehouse_id排序优先级从高到低 */ + @JsonProperty("priority_sort") + private List prioritySort; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/PriorityLocationParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/PriorityLocationParam.java new file mode 100644 index 0000000000..0b304487a7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/PriorityLocationParam.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 带优先级的仓库区域 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class PriorityLocationParam extends WarehouseLocation { + + private static final long serialVersionUID = -3087702364669180903L; + + /** 按照out_warehouse_id排序优先级从高到低 */ + @JsonProperty("priority_sort") + private List prioritySort; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/StockGetParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/StockGetParam.java new file mode 100644 index 0000000000..99e00a4801 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/StockGetParam.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class StockGetParam implements Serializable { + + private static final long serialVersionUID = -4144913434092446664L; + /** 商品ID */ + @JsonProperty("product_id") + private String productId; + + /** skuID */ + @JsonProperty("sku_id") + private String skuId; + + /** 外部仓库ID */ + @JsonProperty("out_warehouse_id") + private String outWarehouseId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/UpdateLocationParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/UpdateLocationParam.java new file mode 100644 index 0000000000..5b71c0a4b4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/UpdateLocationParam.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 仓库区域 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UpdateLocationParam implements Serializable { + + private static final long serialVersionUID = 6102771485047925091L; + + /** 外部仓库ID */ + @JsonProperty("out_warehouse_id") + private String outWarehouseId; + + /** 覆盖区域 */ + @JsonProperty("cover_locations") + private List coverLocations; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/Warehouse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/Warehouse.java new file mode 100644 index 0000000000..7ca07e637f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/Warehouse.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 仓库 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class Warehouse implements Serializable { + + private static final long serialVersionUID = -2322154583471063637L; + + /** 外部仓库ID,一个店铺下,同一个外部ID只能创建一个仓库,最大32字符 */ + @JsonProperty("out_warehouse_id") + private String outWarehouseId; + + /** 仓库名称 */ + @JsonProperty("name") + private String name; + + /** 仓库介绍 */ + @JsonProperty("intro") + private String intro; + + /** 覆盖区域,可以在创建后添加 */ + @JsonProperty("cover_locations") + private List coverLocations; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseIdsResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseIdsResponse.java new file mode 100644 index 0000000000..57c989a56b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseIdsResponse.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 仓库id列表响应 + * + * @author Zeyes + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WarehouseIdsResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 3974529583232187473L; + + /** 外部仓库ID列表 */ + @JsonProperty("out_warehouse_ids") + private List ids; + + /** 本次翻页的上下文,用于请求下一页,如果是空,则当前是最后一页 */ + @JsonProperty("next_key") + private String nextKey; + + public WarehouseIdsResponse() { + } + + @JsonProperty("data") + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = map.get("out_warehouse_ids"); + if (obj != null) { + if (obj instanceof List) { + this.ids = (List) obj; + } + } + obj = map.get("next_key"); + if (obj != null) { + this.nextKey = (String) obj; + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseLocation.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseLocation.java new file mode 100644 index 0000000000..33309522bb --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseLocation.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 仓库区域 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WarehouseLocation implements Serializable { + + private static final long serialVersionUID = 1626579682640060352L; + + /** 省份地址编码 */ + @JsonProperty("address_id1") + private Integer addressId1; + + /** 市地址编码 */ + @JsonProperty("address_id2") + private Integer addressId2; + + /** 区地址编码 */ + @JsonProperty("address_id3") + private Integer addressId3; + + /** 街道地址编码 */ + @JsonProperty("address_id4") + private Integer addressId4; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseLocationParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseLocationParam.java new file mode 100644 index 0000000000..2b64e55dea --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseLocationParam.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +/** + * @author Zeyes + */ +@Data +@JsonInclude(Include.NON_NULL) +public class WarehouseLocationParam extends WarehouseLocation { + + private static final long serialVersionUID = 3347484433136057123L; + + public WarehouseLocationParam() { + } + + public WarehouseLocationParam(Integer addressId1, Integer addressId2, Integer addressId3, Integer addressId4) { + super(addressId1, addressId2, addressId3, addressId4); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseParam.java new file mode 100644 index 0000000000..77ac1a8134 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseParam.java @@ -0,0 +1,20 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 仓库 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class WarehouseParam extends Warehouse { + + private static final long serialVersionUID = -3412047348380785225L; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseResponse.java new file mode 100644 index 0000000000..fa96771d67 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseResponse.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 仓库响应 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class WarehouseResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 3206095869486573824L; + /** 仓库库存 */ + @JsonProperty("data") + private Warehouse data; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseStockParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseStockParam.java new file mode 100644 index 0000000000..5a4354504d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseStockParam.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.product.SkuStockParam; + +/** + * 库存参数 + * + * @author Zeyes + */ +@Data +@NoArgsConstructor +public class WarehouseStockParam extends SkuStockParam { + + private static final long serialVersionUID = -5121207621628542490L; + + /** 外部仓库ID */ + @JsonProperty("out_warehouse_id") + private String outWarehouseId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseStockResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseStockResponse.java new file mode 100644 index 0000000000..64d0d2b5b0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/warehouse/WarehouseStockResponse.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.warehouse; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; +import lombok.Data; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 仓库库存响应 + * + * @author Zeyes + */ +@Data +public class WarehouseStockResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 1810645965041317763L; + /** 仓库库存 */ + @JsonProperty("num") + private Integer num; + + public WarehouseStockResponse() { + } + + @JsonProperty("data") + private void unpackNameFromNestedObject(Map map) { + if (map == null) { + return; + } + Object obj = map.get("num"); + if (obj != null) { + this.num = (Integer) obj; + } + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/common/ChannelWxError.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/common/ChannelWxError.java new file mode 100644 index 0000000000..eb8cda4996 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/common/ChannelWxError.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.channel.common; + +import me.chanjar.weixin.channel.enums.WxChannelErrorMsgEnum; +import me.chanjar.weixin.common.error.WxError; + +/** + * 微信视频号错误码 + * + * @author Zeyes + */ +public class ChannelWxError extends WxError { + + private static final long serialVersionUID = -2638512715814977441L; + + public ChannelWxError() { + } + + public ChannelWxError(int errorCode, String errorMsgEn) { + super(errorCode, errorMsgEn); + if (WxChannelErrorMsgEnum.findMsgByCode(errorCode) != null) { + this.setErrorMsg(WxChannelErrorMsgEnum.findMsgByCode(errorCode)); + } + this.setErrorMsgEn(errorMsgEn); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/WxChannelConfig.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/WxChannelConfig.java new file mode 100644 index 0000000000..ad24234fb0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/WxChannelConfig.java @@ -0,0 +1,185 @@ +package me.chanjar.weixin.channel.config; + +import java.util.concurrent.locks.Lock; +import me.chanjar.weixin.channel.api.BaseWxChannelService; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; + +/** + * 视频号小店配置 + * + * @author Zeyes + */ +public interface WxChannelConfig { + + /** + * Gets access token. + * + * @return the access token + */ + String getAccessToken(); + + /** + * Gets access token lock. + * + * @return the access token lock + */ + Lock getAccessTokenLock(); + + /** + * Is access token expired boolean. + * + * @return the boolean + */ + boolean isAccessTokenExpired(); + + /** + * 强制将access token过期掉 + */ + void expireAccessToken(); + + /** + * 应该是线程安全的 + * + * @param accessToken 要更新的WxAccessToken对象 + */ + void updateAccessToken(WxAccessToken accessToken); + + /** + * 应该是线程安全的 + * + * @param accessToken 新的accessToken值 + * @param expiresInSeconds 过期时间,以秒为单位 + */ + void updateAccessToken(String accessToken, int expiresInSeconds); + + /** + * Gets appid. + * + * @return the appid + */ + String getAppid(); + + /** + * Gets secret. + * + * @return the secret + */ + String getSecret(); + + /** + * Gets token. + * + * @return the token + */ + String getToken(); + + /** + * Gets aes key. + * + * @return the aes key + */ + String getAesKey(); + + /** + * Gets msg data format. + * + * @return the msg data format + */ + String getMsgDataFormat(); + + /** + * Gets expires time. + * + * @return the expires time + */ + long getExpiresTime(); + + /** + * Gets http proxy host. + * + * @return the http proxy host + */ + String getHttpProxyHost(); + + /** + * Gets http proxy port. + * + * @return the http proxy port + */ + int getHttpProxyPort(); + + /** + * Gets http proxy username. + * + * @return the http proxy username + */ + String getHttpProxyUsername(); + + /** + * Gets http proxy password. + * + * @return the http proxy password + */ + String getHttpProxyPassword(); + + /** + * http 请求重试间隔 + *
+   *  {@link BaseWxChannelService#setRetrySleepMillis(int)(int)}
+   * 
+ */ + int getRetrySleepMillis(); + + /** + * http 请求最大重试次数 + *
+   *   {@link BaseWxChannelService#setMaxRetryTimes(int)}
+   * 
+ */ + int getMaxRetryTimes(); + + /** + * http client builder + * + * @return ApacheHttpClientBuilder apache http client builder + */ + ApacheHttpClientBuilder getApacheHttpClientBuilder(); + + /** + * 是否自动刷新token + * + * @return the boolean + */ + boolean autoRefreshToken(); + + /** + * 设置自定义的apiHost地址 + * 具体取值,可以参考https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html + * + * @param apiHostUrl api域名地址 + */ + void setApiHostUrl(String apiHostUrl); + + /** + * 获取自定义的apiHost地址,用于替换原请求中的https://api.weixin.qq.com + * 具体取值,可以参考https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html + * + * @return 自定义的api域名地址 + */ + String getApiHostUrl(); + + /** + * 获取自定义的获取accessToken地址,用于向自定义统一服务获取accessToken + * + * @return 自定义的获取accessToken地址 + */ + String getAccessTokenUrl(); + + /** + * 设置自定义的获取accessToken地址 可用于设置获取accessToken的自定义服务 + * + * @param accessTokenUrl 自定义的获取accessToken地址 + */ + void setAccessTokenUrl(String accessTokenUrl); +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelDefaultConfigImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelDefaultConfigImpl.java new file mode 100644 index 0000000000..e32bcad83e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelDefaultConfigImpl.java @@ -0,0 +1,233 @@ +package me.chanjar.weixin.channel.config.impl; + +import java.io.File; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import lombok.Getter; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; + +/** + * 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化 + * + * @author Zeyes + */ +@Getter +public class WxChannelDefaultConfigImpl implements WxChannelConfig { + + protected volatile String appid; + protected volatile String token; + protected Lock accessTokenLock = new ReentrantLock(); + /** + * 临时文件目录. + */ + protected volatile File tmpDirFile; + private volatile String msgDataFormat; + private volatile String secret; + private volatile String accessToken; + private volatile String aesKey; + private volatile long expiresTime; + private volatile String httpProxyHost; + private volatile int httpProxyPort; + private volatile String httpProxyUsername; + private volatile String httpProxyPassword; + + private volatile int retrySleepMillis = 1000; + private volatile int maxRetryTimes = 5; + private volatile ApacheHttpClientBuilder apacheHttpClientBuilder; + private String apiHostUrl; + private String accessTokenUrl; + + /** + * 会过期的数据提前过期时间,默认预留200秒的时间 + */ + protected long expiresAheadInMillis(int expiresInSeconds) { + return System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; + } + + /** + * 判断 expiresTime 是否已经过期 + */ + protected boolean isExpired(long expiresTime) { + return System.currentTimeMillis() > expiresTime; + } + + @Override + public String getAccessToken() { + return this.accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + @Override + public Lock getAccessTokenLock() { + return this.accessTokenLock; + } + + public void setAccessTokenLock(Lock accessTokenLock) { + this.accessTokenLock = accessTokenLock; + } + + @Override + public boolean isAccessTokenExpired() { + return isExpired(this.expiresTime); + } + + @Override + public synchronized void updateAccessToken(WxAccessToken accessToken) { + updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); + } + + @Override + public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { + setAccessToken(accessToken); + setExpiresTime(expiresAheadInMillis(expiresInSeconds)); + } + + + @Override + public void expireAccessToken() { + this.expiresTime = 0; + } + + @Override + public String getSecret() { + return this.secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } + + @Override + public String getToken() { + return this.token; + } + + public void setToken(String token) { + this.token = token; + } + + @Override + public long getExpiresTime() { + return this.expiresTime; + } + + public void setExpiresTime(long expiresTime) { + this.expiresTime = expiresTime; + } + + @Override + public String getAesKey() { + return this.aesKey; + } + + public void setAesKey(String aesKey) { + this.aesKey = aesKey; + } + + @Override + public String getMsgDataFormat() { + return this.msgDataFormat; + } + + public void setMsgDataFormat(String msgDataFormat) { + this.msgDataFormat = msgDataFormat; + } + + @Override + public String getHttpProxyHost() { + return this.httpProxyHost; + } + + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } + + @Override + public int getHttpProxyPort() { + return this.httpProxyPort; + } + + public void setHttpProxyPort(int httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } + + @Override + public String getHttpProxyUsername() { + return this.httpProxyUsername; + } + + public void setHttpProxyUsername(String httpProxyUsername) { + this.httpProxyUsername = httpProxyUsername; + } + + @Override + public String getHttpProxyPassword() { + return this.httpProxyPassword; + } + + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } + + @Override + public int getRetrySleepMillis() { + return this.retrySleepMillis; + } + + public void setRetrySleepMillis(int retrySleepMillis) { + this.retrySleepMillis = retrySleepMillis; + } + + @Override + public int getMaxRetryTimes() { + return this.maxRetryTimes; + } + + public void setMaxRetryTimes(int maxRetryTimes) { + this.maxRetryTimes = maxRetryTimes; + } + + @Override + public String toString() { + return JsonUtils.encode(this); + } + + @Override + public ApacheHttpClientBuilder getApacheHttpClientBuilder() { + return this.apacheHttpClientBuilder; + } + + public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { + this.apacheHttpClientBuilder = apacheHttpClientBuilder; + } + + @Override + public boolean autoRefreshToken() { + return true; + } + + @Override + public void setApiHostUrl(String apiHostUrl) { + this.apiHostUrl = apiHostUrl; + } + + @Override + public void setAccessTokenUrl(String accessTokenUrl) { + this.accessTokenUrl = accessTokenUrl; + } + + @Override + public String getAppid() { + return appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelRedisConfigImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelRedisConfigImpl.java new file mode 100644 index 0000000000..cbb289c899 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelRedisConfigImpl.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.channel.config.impl; + +import java.util.concurrent.TimeUnit; +import me.chanjar.weixin.common.redis.WxRedisOps; + +/** + * 基于redis存储的微信视频号小店配置类 + * + * @author Zeyes + */ +public class WxChannelRedisConfigImpl extends WxChannelDefaultConfigImpl { + + private static final String ACCESS_TOKEN_KEY_TPL = "%s:access_token:%s"; + private static final String LOCK_KEY_TPL = "%s:lock:%s:"; + + private final WxRedisOps redisOps; + private final String keyPrefix; + + private volatile String accessTokenKey; + private volatile String lockKey; + + public WxChannelRedisConfigImpl(WxRedisOps redisOps, String keyPrefix) { + this.redisOps = redisOps; + this.keyPrefix = keyPrefix; + } + + @Override + public void setAppid(String appId) { + super.setAppid(appId); + this.accessTokenKey = String.format(ACCESS_TOKEN_KEY_TPL, this.keyPrefix, appId); + this.lockKey = String.format(LOCK_KEY_TPL, this.keyPrefix, appId); + super.accessTokenLock = this.redisOps.getLock(lockKey.concat("accessTokenLock")); + } + + //------------------------------------------------------------------------ + // token相关 + //------------------------------------------------------------------------ + @Override + public String getAccessToken() { + return redisOps.getValue(this.accessTokenKey); + } + + @Override + public boolean isAccessTokenExpired() { + Long expire = redisOps.getExpire(this.accessTokenKey); + return expire == null || expire < 2; + } + + @Override + public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { + redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds - 200, TimeUnit.SECONDS); + } + + @Override + public void expireAccessToken() { + redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); + } + + + @Override + public String toString() { + return "WxChannelRedisConfigImpl{" + + "appid='" + appid + '\'' + + ", token='" + token + '\'' + + ", accessTokenLock=" + accessTokenLock + + ", tmpDirFile=" + tmpDirFile + + ", redisOps=" + redisOps + + ", keyPrefix='" + keyPrefix + '\'' + + ", accessTokenKey='" + accessTokenKey + '\'' + + ", lockKey='" + lockKey + '\'' + + '}'; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelRedissonConfigImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelRedissonConfigImpl.java new file mode 100644 index 0000000000..d5de517163 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/config/impl/WxChannelRedissonConfigImpl.java @@ -0,0 +1,89 @@ +package me.chanjar.weixin.channel.config.impl; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import lombok.NonNull; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.redis.RedissonWxRedisOps; +import me.chanjar.weixin.common.redis.WxRedisOps; +import org.apache.commons.lang3.StringUtils; +import org.redisson.api.RedissonClient; + +/** + * 基于Redisson的实现 + * + * @author yuanqixun + * created on 2020/5/3 + */ +public class WxChannelRedissonConfigImpl extends WxChannelDefaultConfigImpl { + + protected static final String LOCK_KEY = "wx_channel_lock:"; + protected static final String MA_ACCESS_TOKEN_KEY = "wx_channel_access_token_key:"; + + /** + * redis 存储的 key 的前缀,可为空 + */ + protected String keyPrefix; + protected String accessTokenKey; + protected String lockKey; + + private final WxRedisOps redisOps; + + public WxChannelRedissonConfigImpl(@NonNull RedissonClient redissonClient, String keyPrefix) { + this(new RedissonWxRedisOps(redissonClient), keyPrefix); + } + + public WxChannelRedissonConfigImpl(@NonNull RedissonClient redissonClient) { + this(redissonClient, null); + } + + private WxChannelRedissonConfigImpl(@NonNull WxRedisOps redisOps, String keyPrefix) { + this.redisOps = redisOps; + this.keyPrefix = keyPrefix; + } + + @Override + public void setAppid(String appid) { + super.setAppid(appid); + String prefix = StringUtils.isBlank(keyPrefix) ? "" : + (StringUtils.endsWith(keyPrefix, ":") ? keyPrefix : (keyPrefix + ":")); + lockKey = prefix + LOCK_KEY.concat(appid); + accessTokenKey = prefix + MA_ACCESS_TOKEN_KEY.concat(appid); + } + + protected Lock getLockByKey(String key) { + return redisOps.getLock(key); + } + + @Override + public Lock getAccessTokenLock() { + return getLockByKey(this.lockKey.concat(":").concat("accessToken")); + } + + @Override + public String getAccessToken() { + return redisOps.getValue(this.accessTokenKey); + } + + @Override + public boolean isAccessTokenExpired() { + Long expire = redisOps.getExpire(this.accessTokenKey); + return expire == null || expire < 2; + } + + @Override + public void updateAccessToken(WxAccessToken accessToken) { + redisOps.setValue(this.accessTokenKey, accessToken.getAccessToken(), accessToken.getExpiresIn(), TimeUnit.SECONDS); + } + + @Override + public void updateAccessToken(String accessToken, int expiresInSeconds) { + redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds, TimeUnit.SECONDS); + } + + @Override + public void expireAccessToken() { + redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/MessageEventConstants.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/MessageEventConstants.java new file mode 100644 index 0000000000..e0e419efc6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/MessageEventConstants.java @@ -0,0 +1,70 @@ +package me.chanjar.weixin.channel.constant; + +/** + * 消息回调 + * + * @author Zeyes + */ +public interface MessageEventConstants { + /** 品牌资质事件回调 */ + String BRAND = "channels_ec_brand"; + /** 商品审核结果 */ + String PRODUCT_SPU_AUDIT = "product_spu_audit"; + /** 商品上下架 */ + String PRODUCT_SPU_STATUS_UPDATE = "product_spu_listing"; + /** 商品更新 */ + String PRODUCT_SPU_UPDATE = "product_spu_update"; + /** 类目审核结果 */ + String PRODUCT_CATEGORY_AUDIT = "product_category_audit"; + /** 订单下单 */ + String ORDER_NEW = "channels_ec_order_new"; + /** 订单取消 */ + String ORDER_CANCEL = "channels_ec_order_cancel"; + /** 订单支付成功 */ + String ORDER_PAY = "channels_ec_order_pay"; + /** 订单发货 */ + String ORDER_DELIVER = "channels_ec_order_deliver"; + /** 订单确认收货 */ + String ORDER_CONFIRM = "channels_ec_order_confirm"; + /** 订单结算成功 */ + String ORDER_SETTLE = "channels_ec_order_settle"; + /** 订单其他信息更新 */ + String ORDER_EXT_INFO_UPDATE = "channels_ec_order_ext_info_update"; + /** 订单状态更新 */ + String ORDER_STATUS_UPDATE = "product_order_status_update"; + /** 售后单更新通知 */ + String AFTER_SALE_UPDATE = "channels_ec_aftersale_update"; + /** 纠纷更新通知 */ + String COMPLAINT_NOTIFY = "channels_ec_complaint_update"; + // 优惠券相关 + /** 优惠券领取通知 */ + String RECEIVE_COUPON = "channels_ec_coupon_receive"; + /** 创建优惠券通知 */ + String CREATE_COUPON = "channels_ec_coupon_create"; + /** 优惠券删除通知 */ + String DELETE_COUPON = "channels_ec_coupon_delete"; + /** 优惠券过期通知 */ + String EXPIRE_COUPON = "channels_ec_coupon_expire"; + /** 更新优惠券信息通知 */ + String UPDATE_COUPON_INFO = "channels_ec_coupon_info_change"; + /** 优惠券作废通知 */ + String INVALID_COUPON = "channels_ec_coupon_invalid"; + /** 用户优惠券过期通知 */ + String USER_COUPON_EXPIRE = "channels_ec_user_coupon_expire"; + /** 优惠券返还通知 */ + String USER_COUPON_UNUSE = "channels_ec_user_coupon_unuse"; + /** 优惠券核销通知 */ + String USER_COUPON_USE = "channels_ec_user_coupon_use"; + // 资金相关 + /** 结算账户变更回调 */ + String ACCOUNT_NOTIFY = "channels_ec_acct_notify"; + /** 提现回调 */ + String WITHDRAW_NOTIFY = "channels_ec_withdraw_notify"; + /** 提现二维码回调 */ + String QRCODE_STATUS = "qrcode_status"; + // 团长 + String SUPPLIER_ITEM_UPDATE = "head_supplier_item_update"; + // 其他 + /** 进入会话事件 */ + String USER_ENTER_TEMP_SESSION = "user_enter_tempsession"; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java new file mode 100644 index 0000000000..cb29cfda39 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java @@ -0,0 +1,354 @@ +package me.chanjar.weixin.channel.constant; + +import lombok.experimental.UtilityClass; + +/** + * 视频号小店接口地址常量 + * + * @author Zeyes + */ +@UtilityClass +public class WxChannelApiUrlConstants { + + /** + * 获取access_token. + */ + public static final String GET_ACCESS_TOKEN_URL = + "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"; + + /** 基础接口 */ + public interface Basics { + + /** 获取店铺基本信息 */ + String GET_SHOP_INFO = "https://api.weixin.qq.com/channels/ec/basics/info/get"; + /** 上传图片 */ + String IMG_UPLOAD_URL = "https://api.weixin.qq.com/channels/ec/basics/img/upload"; + /** 上传资质图片 */ + String UPLOAD_QUALIFICATION_FILE = "https://api.weixin.qq.com/channels/ec/basics/qualification/upload"; + /** 下载图片 */ + String GET_IMG_URL = "https://api.weixin.qq.com/channels/ec/basics/media/get"; + /** 获取地址编码 */ + String GET_ADDRESS_CODE = "https://api.weixin.qq.com/channels/ec/basics/addresscode/get"; + } + + /** 商品类目相关接口 */ + public interface Category { + + /** 获取所有的类目 */ + String LIST_ALL_CATEGORY_URL = "https://api.weixin.qq.com/channels/ec/category/all"; + /** 获取类目详情 */ + String GET_CATEGORY_DETAIL_URL = "https://api.weixin.qq.com/channels/ec/category/detail"; + /** 获取可用的子类目详情 */ + String AVAILABLE_CATEGORY_URL = "https://api.weixin.qq.com/channels/ec/category/availablesoncategories/get"; + /** 上传类目资质 */ + String ADD_CATEGORY_URL = "https://api.weixin.qq.com/channels/ec/category/add"; + /** 获取类目审核结果 */ + String GET_CATEGORY_AUDIT_URL = "https://api.weixin.qq.com/channels/ec/category/audit/get"; + /** 取消类目提审 */ + String CANCEL_CATEGORY_AUDIT_URL = "https://api.weixin.qq.com/channels/ec/category/audit/cancel"; + /** 获取账号申请通过的类目和资质信息 */ + String LIST_PASS_CATEGORY_URL = "https://api.weixin.qq.com/channels/ec/category/list/get"; + } + + /** 品牌资质相关接口 */ + public interface Brand { + + /** 获取品牌库列表 */ + String ALL_BRAND_URL = "https://api.weixin.qq.com/channels/ec/brand/all"; + /** 新增品牌资质 */ + String ADD_BRAND_URL = "https://api.weixin.qq.com/channels/ec/brand/add"; + /** 更新品牌资质 */ + String UPDATE_BRAND_URL = "https://api.weixin.qq.com/channels/ec/brand/update"; + /** 撤回品牌资质审核 */ + String CANCEL_BRAND_AUDIT_URL = "https://api.weixin.qq.com/channels/ec/brand/audit/cancel"; + /** 删除品牌资质 */ + String DELETE_BRAND_URL = "https://api.weixin.qq.com/channels/ec/brand/delete"; + /** 获取品牌资质申请详情 */ + String GET_BRAND_URL = "https://api.weixin.qq.com/channels/ec/brand/get"; + /** 获取品牌资质申请列表 */ + String LIST_BRAND_URL = "https://api.weixin.qq.com/channels/ec/brand/list/get"; + /** 获取生效中的品牌资质列表 */ + String LIST_BRAND_VALID_URL = "https://api.weixin.qq.com/channels/ec/brand/valid/list/get"; + } + + /** 商品操作相关接口 */ + public interface Spu { + + /** 添加商品 */ + String SPU_ADD_URL = "https://api.weixin.qq.com/channels/ec/product/add"; + /** 删除商品 */ + String SPU_DEL_URL = "https://api.weixin.qq.com/channels/ec/product/delete"; + /** 获取商品详情 */ + String SPU_GET_URL = "https://api.weixin.qq.com/channels/ec/product/get"; + /** 获取商品列表 */ + String SPU_LIST_URL = "https://api.weixin.qq.com/channels/ec/product/list/get"; + /** 更新商品 */ + String SPU_UPDATE_URL = "https://api.weixin.qq.com/channels/ec/product/update"; + /** 上架商品 */ + String SPU_LISTING_URL = "https://api.weixin.qq.com/channels/ec/product/listing"; + /** 下架商品 */ + String SPU_DELISTING_URL = "https://api.weixin.qq.com/channels/ec/product/delisting"; + /** 撤回商品审核 */ + String CANCEL_AUDIT_URL = "https://api.weixin.qq.com/channels/ec/product/audit/cancel"; + /** 获取实时库存 */ + String SPU_GET_STOCK_URL = "https://api.weixin.qq.com/channels/ec/product/stock/get"; + /** 更新商品库存 */ + String SPU_UPDATE_STOCK_URL = "https://api.weixin.qq.com/channels/ec/product/stock/update"; + /** 添加限时抢购任务 */ + String ADD_LIMIT_TASK_URL = "https://api.weixin.qq.com/channels/ec/product/limiteddiscounttask/add"; + /** 拉取限时抢购任务列表 */ + String LIST_LIMIT_TASK_URL = "https://api.weixin.qq.com/channels/ec/product/limiteddiscounttask/list/get"; + /** 停止限时抢购任务 */ + String STOP_LIMIT_TASK_URL = "https://api.weixin.qq.com/channels/ec/product/limiteddiscounttask/stop"; + /** 删除限时抢购任务 */ + String DELETE_LIMIT_TASK_URL = "https://api.weixin.qq.com/channels/ec/product/limiteddiscounttask/delete"; + } + + /** 区域仓库 */ + public interface Warehouse { + + /** 添加区域仓库 */ + String ADD_WAREHOUSE_URL = "https://api.weixin.qq.com/channels/ec/warehouse/create"; + /** 获取区域仓库列表 */ + String LIST_WAREHOUSE_URL = "https://api.weixin.qq.com/channels/ec/warehouse/list/get"; + /** 获取区域仓库详情 */ + String GET_WAREHOUSE_URL = "https://api.weixin.qq.com/channels/ec/warehouse/get"; + /** 更新区域仓库详情 */ + String UPDATE_WAREHOUSE_URL = "https://api.weixin.qq.com/channels/ec/warehouse/detail/update"; + /** 批量增加覆盖区域 */ + String ADD_COVER_AREA_URL = "https://api.weixin.qq.com/channels/ec/warehouse/coverlocations/add"; + /** 批量删除覆盖区域 */ + String DELETE_COVER_AREA_URL = "https://api.weixin.qq.com/channels/ec/warehouse/coverlocations/del"; + /** 设置指定地址下的仓的优先级 */ + String SET_WAREHOUSE_PRIORITY_URL = "https://api.weixin.qq.com/channels/ec/warehouse/address/prioritysort/set"; + /** 获取指定地址下的仓的优先级 */ + String GET_WAREHOUSE_PRIORITY_URL = "https://api.weixin.qq.com/channels/ec/warehouse/address/prioritysort/get"; + /** 更新区域仓库存 */ + String UPDATE_WAREHOUSE_STOCK_URL = "https://api.weixin.qq.com/channels/ec/warehouse/stock/update"; + /** 获取区域仓库存 */ + String GET_WAREHOUSE_STOCK_URL = "https://api.weixin.qq.com/channels/ec/warehouse/stock/get"; + } + + /** 订单相关接口 */ + public interface Order { + + /** 获取订单列表 */ + String ORDER_LIST_URL = "https://api.weixin.qq.com/channels/ec/order/list/get"; + /** 获取订单详情 */ + String ORDER_GET_URL = "https://api.weixin.qq.com/channels/ec/order/get"; + /** 更改订单价格 */ + String UPDATE_PRICE_URL = "https://api.weixin.qq.com/channels/ec/order/price/update"; + /** 修改订单备注 */ + String UPDATE_REMARK_URL = "https://api.weixin.qq.com/channels/ec/order/merchantnotes/update"; + /** 更修改订单地址 */ + String UPDATE_ADDRESS_URL = "https://api.weixin.qq.com/channels/ec/order/address/update"; + /** 修改物流信息 */ + String UPDATE_EXPRESS_URL = "https://api.weixin.qq.com/channels/ec/order/deliveryinfo/update"; + /** 同意用户修改收货地址申请 */ + String ACCEPT_ADDRESS_MODIFY_URL = "https://api.weixin.qq.com/channels/ec/order/addressmodify/accept"; + /** 拒绝用户修改收货地址申请 */ + String REJECT_ADDRESS_MODIFY_URL = "https://api.weixin.qq.com/channels/ec/order/addressmodify/reject"; + /** 订单搜索 */ + String ORDER_SEARCH_URL = "https://api.weixin.qq.com/channels/ec/order/search"; + } + + /** 售后相关接口 */ + public interface AfterSale { + + /** 获取售后列表 */ + String AFTER_SALE_LIST_URL = "https://api.weixin.qq.com/channels/ec/aftersale/getaftersalelist"; + /** 获取售后单 */ + String AFTER_SALE_GET_URL = "https://api.weixin.qq.com/channels/ec/aftersale/getaftersaleorder"; + /** 同意售后 */ + String AFTER_SALE_ACCEPT_URL = "https://api.weixin.qq.com/channels/ec/aftersale/acceptapply"; + /** 拒绝售后 */ + String AFTER_SALE_REJECT_URL = "https://api.weixin.qq.com/channels/ec/aftersale/rejectapply"; + /** 上传退款凭证 */ + String AFTER_SALE_UPLOAD_URL = "https://api.weixin.qq.com/channels/ec/aftersale/uploadrefundcertificate"; + } + + /** 纠纷相关接口 */ + public interface Complaint { + + /** 商家补充纠纷单留言 */ + String ADD_COMPLAINT_MATERIAL_URL = "https://api.weixin.qq.com/channels/ec/aftersale/addcomplaintmaterial"; + /** 商家举证 */ + String ADD_COMPLAINT_PROOF_URL = "https://api.weixin.qq.com/channels/ec/aftersale/addcomplaintproof"; + /** 获取纠纷单 */ + String GET_COMPLAINT_ORDER_URL = "https://api.weixin.qq.com/channels/ec/aftersale/getcomplaintorder"; + } + + /** 物流相关接口 */ + public interface Delivery { + + /** 获取快递公司列表 */ + String GET_DELIVERY_COMPANY_URL = "https://api.weixin.qq.com/channels/ec/order/deliverycompanylist/get"; + /** 订单发货 */ + String DELIVERY_SEND_URL = "https://api.weixin.qq.com/channels/ec/order/delivery/send"; + } + + /** 运费模板相关接口 */ + public interface FreightTemplate { + + /** 获取运费模板列表 */ + String LIST_TEMPLATE_URL = "https://api.weixin.qq.com/channels/ec/merchant/getfreighttemplatelist"; + /** 查询运费模版 */ + String GET_TEMPLATE_URL = "https://api.weixin.qq.com/channels/ec/merchant/getfreighttemplatedetail"; + /** 增加运费模版 */ + String ADD_TEMPLATE_URL = "https://api.weixin.qq.com/channels/ec/merchant/addfreighttemplate"; + /** 更新运费模版 */ + String UPDATE_TEMPLATE_URL = "https://api.weixin.qq.com/channels/ec/merchant/updatefreighttemplate"; + } + + /** 地址管理相关接口 */ + public interface Address { + + /** 增加地址 */ + String ADD_ADDRESS_URL = "https://api.weixin.qq.com/channels/ec/merchant/address/add"; + /** 获取地址列表 */ + String LIST_ADDRESS_URL = "https://api.weixin.qq.com/channels/ec/merchant/address/list"; + /** 获取地址详情 */ + String GET_ADDRESS_URL = "https://api.weixin.qq.com/channels/ec/merchant/address/get"; + /** 更新地址 */ + String UPDATE_ADDRESS_URL = "https://api.weixin.qq.com/channels/ec/merchant/address/update"; + /** 删除地址 */ + String DELETE_ADDRESS_URL = "https://api.weixin.qq.com/channels/ec/merchant/address/delete"; + } + + /** 优惠券相关接口 */ + public interface Coupon { + + /** 创建优惠券 */ + String CREATE_COUPON_URL = "https://api.weixin.qq.com/channels/ec/coupon/create"; + /** 更新优惠券 */ + String UPDATE_COUPON_URL = "https://api.weixin.qq.com/channels/ec/coupon/update"; + /** 更新优惠券状态 */ + String UPDATE_COUPON_STATUS_URL = "https://api.weixin.qq.com/channels/ec/coupon/update_status"; + /** 获取优惠券详情 */ + String GET_COUPON_URL = "https://api.weixin.qq.com/channels/ec/coupon/get"; + /** 获取优惠券ID列表 */ + String LIST_COUPON_URL = "https://api.weixin.qq.com/channels/ec/coupon/get_list"; + /** 获取用户优惠券ID列表 */ + String LIST_USER_COUPON_URL = "https://api.weixin.qq.com/channels/ec/coupon/get_user_coupon_list"; + /** 获取用户优惠券详情 */ + String GET_USER_COUPON_URL = "https://api.weixin.qq.com/channels/ec/coupon/get_user_coupon"; + } + + /** 分享员相关接口 */ + public interface Share { + + /** 邀请分享员 */ + String BIND_SHARER_URL = "https://api.weixin.qq.com/channels/ec/sharer/bind"; + /** 获取绑定的分享员 */ + String SEARCH_SHARER_URL = "https://api.weixin.qq.com/channels/ec/sharer/search_sharer"; + /** 获取绑定的分享员列表 */ + String LIST_SHARER_URL = "https://api.weixin.qq.com/channels/ec/sharer/get_sharer_list"; + /** 获取分享员订单列表 */ + String LIST_SHARER_ORDER_URL = "https://api.weixin.qq.com/channels/ec/sharer/get_sharer_order_list"; + /** 解绑分享员 */ + String UNBIND_SHARER_URL = "https://api.weixin.qq.com/channels/ec/sharer/unbind"; + } + + /** 资金相关接口 */ + public interface Fund { + + /** 获取账户余额 */ + String GET_BALANCE_URL = "https://api.weixin.qq.com/channels/ec/funds/getbalance"; + /** 获取结算账户 */ + String GET_BANK_ACCOUNT_URL = "https://api.weixin.qq.com/channels/ec/funds/getbankacct"; + /** 获取资金流水详情 */ + String GET_BALANCE_FLOW_DETAIL_URL = "https://api.weixin.qq.com/channels/ec/league/funds/getfundsflowdetail"; + /** 获取资金流水列表 */ + String GET_BALANCE_FLOW_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/funds/getfundsflowlist"; + /** 获取提现记录 */ + String GET_WITHDRAW_DETAIL_URL = "https://api.weixin.qq.com/channels/ec/funds/getwithdrawdetail"; + /** 获取提现记录列表 */ + String GET_WITHDRAW_LIST_URL = "https://api.weixin.qq.com/channels/ec/funds/getwithdrawlist"; + /** 修改结算账户 */ + String SET_BANK_ACCOUNT_URL = "https://api.weixin.qq.com/channels/ec/funds/setbankacct"; + /** 商户提现 */ + String WITHDRAW_URL = "https://api.weixin.qq.com/channels/ec/funds/submitwithdraw"; + /** 根据卡号查银行信息 */ + String GET_BANK_BY_NUM_URL = "https://api.weixin.qq.com/shop/funds/getbankbynum"; + /** 搜索银行列表 */ + String GET_BANK_LIST_URL = "https://api.weixin.qq.com/shop/funds/getbanklist"; + /** 查询城市列表 */ + String GET_CITY_URL = "https://api.weixin.qq.com/shop/funds/getcity"; + /** 查询大陆银行省份列表 */ + String GET_PROVINCE_URL = "https://api.weixin.qq.com/shop/funds/getprovince"; + /** 查询支行列表 */ + String GET_SUB_BANK_URL = "https://api.weixin.qq.com/shop/funds/getsubbranch"; + /** 获取二维码 */ + String GET_QRCODE_URL = "https://api.weixin.qq.com/shop/funds/qrcode/get"; + /** 查询扫码状态 */ + String CHECK_QRCODE_URL = "https://api.weixin.qq.com/shop/funds/qrcode/check"; + } + + /** 优选联盟相关接口 */ + public interface League { + + /** 添加团长商品到橱窗 */ + String ADD_SUPPLIER_GOODS_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/window/add"; + /** 查询橱窗上团长商品列表 */ + String LIST_SUPPLIER_GOODS_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/window/getall"; + /** 从橱窗移除团长商品 */ + String REMOVE_SUPPLIER_GOODS_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/window/remove"; + /** 查询橱窗上团长商品详情 */ + String GET_SUPPLIER_GOODS_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/window/getdetail"; + /** 获取达人橱窗授权链接 */ + String GET_SUPPLIER_AUTH_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/windowauth/get"; + /** 获取达人橱窗授权状态 */ + String GET_SUPPLIER_AUTH_STATUS_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/windowauth/status/get"; + /** 获取团长账户余额 */ + String GET_SUPPLIER_BALANCE_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/funds/balance/get"; + /** 获取资金流水详情 */ + String GET_SUPPLIER_BALANCE_FLOW_DETAIL_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/funds/flowdetail/get"; + /** 获取资金流水列表 */ + String GET_SUPPLIER_BALANCE_FLOW_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/funds/flowlist/get"; + /** 获取合作商品详情 */ + String GET_SUPPLIER_ITEM_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/item/get"; + /** 获取合作商品列表 */ + String GET_SUPPLIER_ITEM_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/item/list/get"; + /** 获取佣金单详情 */ + String GET_SUPPLIER_ORDER_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/order/get"; + /** 获取佣金单列表 */ + String GET_SUPPLIER_ORDER_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/order/list/get"; + /** 获取合作小店详情 */ + String GET_SUPPLIER_SHOP_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/shop/get"; + /** 获取合作小店列表 */ + String GET_SUPPLIER_SHOP_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/headsupplier/shop/list/get"; + /** 新增达人 */ + String ADD_PROMOTER_URL = "https://api.weixin.qq.com/channels/ec/league/promoter/add"; + /** 编辑达人 */ + String EDIT_PROMOTER_URL = "https://api.weixin.qq.com/channels/ec/league/promoter/upd"; + /** 删除达人 */ + String DELETE_PROMOTER_URL = "https://api.weixin.qq.com/channels/ec/league/promoter/delete"; + /** 获取达人详情信息 */ + String GET_PROMOTER_URL = "https://api.weixin.qq.com/channels/ec/league/promoter/get"; + /** 拉取商店达人列表 */ + String GET_PROMOTER_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/promoter/list/get"; + /** 批量新增联盟商品 */ + String BATCH_ADD_LEAGUE_ITEM_URL = "https://api.weixin.qq.com/channels/ec/league/item/batchadd"; + /** 更新联盟商品信息 */ + String UPDATE_LEAGUE_ITEM_URL = "https://api.weixin.qq.com/channels/ec/league/item/upd"; + /** 删除联盟商品 */ + String DELETE_LEAGUE_ITEM_URL = "https://api.weixin.qq.com/channels/ec/league/item/delete"; + /** 拉取联盟商品详情 */ + String GET_LEAGUE_ITEM_URL = "https://api.weixin.qq.com/channels/ec/league/item/get"; + /** 拉取联盟商品推广列表 */ + String GET_LEAGUE_ITEM_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/item/list/get"; + } + + /** 视频号助手开放接口 */ + public interface Assistant { + + /** 上架商品到橱窗 */ + String ADD_WINDOW_PRODUCT_URL = "https://api.weixin.qq.com/channels/ec/window/product/add"; + /** 获取橱窗商品详情 */ + String GET_WINDOW_PRODUCT_URL = "https://api.weixin.qq.com/channels/ec/window/product/get"; + /** 获取已添加到橱窗的商品列表 */ + String LIST_WINDOW_PRODUCT_URL = "https://api.weixin.qq.com/channels/ec/window/product/list/get"; + /** 下架橱窗商品 */ + String OFF_WINDOW_PRODUCT_URL = "https://api.weixin.qq.com/channels/ec/window/product/off"; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AccountType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AccountType.java new file mode 100644 index 0000000000..96cfc43956 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AccountType.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 账户类型 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum AccountType { + /** 对公银行账户 */ + ACCOUNT_TYPE_BUSINESS("ACCOUNT_TYPE_BUSINESS", "对公银行账户"), + /** 经营者个人银行卡 */ + ACCOUNT_TYPE_PRIVATE("ACCOUNT_TYPE_PRIVATE", "经营者个人银行卡"), + + ; + + private final String key; + private final String value; + + AccountType(String key, String value) { + this.key = key; + this.value = value; + } + + public static AccountType getByKey(String key) { + for (AccountType reason : AccountType.values()) { + if (reason.getKey().equals(key)) { + return reason; + } + } + return ACCOUNT_TYPE_PRIVATE; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSaleStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSaleStatus.java new file mode 100644 index 0000000000..60e77d9e53 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSaleStatus.java @@ -0,0 +1,60 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 售后单状态 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum AfterSaleStatus { + /** 用户取消申请 */ + USER_CANCELD("USER_CANCELD", "用户取消申请"), + /** 商家受理中 */ + MERCHANT_PROCESSING("MERCHANT_PROCESSING", "商家受理中"), + /** 商家拒绝退款 */ + MERCHANT_REJECT_REFUND("MERCHANT_REJECT_REFUND", "商家拒绝退款"), + /** 商家拒绝退货退款 */ + MERCHANT_REJECT_RETURN("MERCHANT_REJECT_RETURN", "商家拒绝退货退款"), + /** 待买家退货 */ + USER_WAIT_RETURN("USER_WAIT_RETURN", "待买家退货"), + /** 7 售后单关闭 */ + RETURN_CLOSED("RETURN_CLOSED", "退货退款关闭"), + /** 8 待商家收货 */ + MERCHANT_WAIT_RECEIPT("MERCHANT_WAIT_RECEIPT", "待商家收货"), + /** 商家逾期未退款 */ + MERCHANT_OVERDUE_REFUND("MERCHANT_OVERDUE_REFUND", "商家逾期未退款"), + /** 退款完成 */ + MERCHANT_REFUND_SUCCESS("MERCHANT_REFUND_SUCCESS", "退款完成"), + /** 退货退款完成 */ + MERCHANT_RETURN_SUCCESS("MERCHANT_RETURN_SUCCESS", "退货退款完成"), + /** 11 平台退款中 */ + PLATFORM_REFUNDING("PLATFORM_REFUNDING", "平台退款中"), + /** 25 平台退款失败 */ + PLATFORM_REFUND_FAIL("PLATFORM_REFUND_FAIL", "平台退款失败"), + /** 待用户确认 */ + USER_WAIT_CONFIRM("USER_WAIT_CONFIRM", "待用户确认"), + /** 商家打款失败,客服关闭售后 */ + MERCHANT_REFUND_RETRY_FAIL("MERCHANT_REFUND_RETRY_FAIL", "商家打款失败,客服关闭售后"), + /** 售后关闭 */ + MERCHANT_FAIL("MERCHANT_FAIL", "售后关闭"), + ; + + private final String key; + private final String value; + + AfterSaleStatus(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSaleType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSaleType.java new file mode 100644 index 0000000000..8cbdf521f5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSaleType.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 售后类型 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum AfterSaleType { + /** 1 仅退款 */ + REFUND_ONLY("REFUND", "仅退款"), + /** 2 退货退款 */ + REFUND_GOODS("RETURN", "退货退款"); + + private final String key; + private final String value; + + AfterSaleType(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSalesReason.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSalesReason.java new file mode 100644 index 0000000000..c3409a05cd --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/AfterSalesReason.java @@ -0,0 +1,63 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 售后原因 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum AfterSalesReason { + /** 拍错/多拍 */ + INCORRECT_SELECTION("INCORRECT_SELECTION", "拍错/多拍"), + /** 不想要了 */ + NO_LONGER_WANT("NO_LONGER_WANT", "不想要了"), + /** 无快递信息 */ + NO_EXPRESS_INFO("NO_EXPRESS_INFO", "无快递信息"), + /** 包裹为空 */ + EMPTY_PACKAGE("EMPTY_PACKAGE", "包裹为空"), + /** 已拒签包裹 */ + REJECT_RECEIVE_PACKAGE("REJECT_RECEIVE_PACKAGE", "已拒签包裹"), + /** 快递长时间未送达 */ + NOT_DELIVERED_TOO_LONG("NOT_DELIVERED_TOO_LONG", "快递长时间未送达了"), + /** 与商品描述不符 */ + NOT_MATCH_PRODUCT_DESC("NOT_MATCH_PRODUCT_DESC", "与商品描述不符"), + /** 质量问题 */ + QUALITY_ISSUE("QUALITY_ISSUE", "质量问题"), + /** 卖家发错货 */ + SEND_WRONG_GOODS("SEND_WRONG_GOODS", "卖家发错货"), + /** 三无产品 */ + THREE_NO_PRODUCT("THREE_NO_PRODUCT", "三无产品"), + /** 假冒产品 */ + FAKE_PRODUCT("FAKE_PRODUCT", "假冒产品"), + /** 其它 */ + OTHERS("OTHERS", "其它"), + ; + + private final String key; + private final String value; + + AfterSalesReason(String key, String value) { + this.key = key; + this.value = value; + } + + public static AfterSalesReason getByKey(String key) { + for (AfterSalesReason reason : AfterSalesReason.values()) { + if (reason.getKey().equals(key)) { + return reason; + } + } + // 找不到就返回其他了 + return OTHERS; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CommissionOrderStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CommissionOrderStatus.java new file mode 100644 index 0000000000..bdf29d2765 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CommissionOrderStatus.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 佣金订单状态 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum CommissionOrderStatus { + + /** 20 未结算 */ + NOT_SETTLED(20, "未结算"), + /** 100 已结算 */ + SETTLED(100, "已结算"), + /** 200 取消结算 */ + CANCEL_SETTLED(200, "取消结算"), + + ; + + private final int key; + private final String val; + + CommissionOrderStatus(int key, String val) { + this.key = key; + this.val = val; + } + + public int getKey() { + return key; + } + + public String getVal() { + return val; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ComplaintItemType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ComplaintItemType.java new file mode 100644 index 0000000000..d7f1aae8ec --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ComplaintItemType.java @@ -0,0 +1,112 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 纠纷历史操作类型 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum ComplaintItemType { + /** 1 申请平台介入 */ + APPLY_PLATFORM_INTERVENTION(1, "申请平台介入"), + /** 2 用户留言 */ + USER_MESSAGE(2, "用户留言"), + /** 3 商家留言 */ + MERCHANT_MESSAGE(3, "商家留言"), + /** 4 提交投诉成功 */ + SUBMIT_COMPLAINT_SUCCESS(4, "提交投诉成功"), + /** 5 投诉已取消 */ + COMPLAINT_CANCELLED(5, "投诉已取消"), + /** 6 商家已超时 */ + MERCHANT_TIMEOUT(6, "商家已超时"), + /** 7 用户补充凭证 */ + USER_SUPPLEMENTARY_EVIDENCE(7, "用户补充凭证"), + /** 8 商家补充凭证 */ + MERCHANT_SUPPLEMENTARY_EVIDENCE(8, "商家补充凭证"), + /** 10 待商家处理纠纷 */ + WAIT_MERCHANT_HANDLE_DISPUTE(10, "待商家处理纠纷"), + /** 11 待平台处理 */ + WAIT_PLATFORM_HANDLE(11, "待平台处理"), + /** 12 取消平台介入 */ + CANCEL_PLATFORM_INTERVENTION(12, "取消平台介入"), + /** 13 平台处理中 */ + PLATFORM_PROCESSING(13, "平台处理中"), + /** 14 待用户补充凭证 */ + WAIT_USER_SUPPLEMENTARY_EVIDENCE(14, "待用户补充凭证"), + /** 16 待商家补充凭证 */ + WAIT_MERCHANT_SUPPLEMENTARY_EVIDENCE(16, "待商家补充凭证"), + /** 18 待双方补充凭证 */ + WAIT_BOTH_PARTIES_SUPPLEMENTARY_EVIDENCE(18, "待双方补充凭证"), + /** 20 待商家确认 */ + WAIT_MERCHANT_CONFIRM(20, "待商家确认"), + /** 21 商家申诉中 */ + MERCHANT_APPEALING(21, "商家申诉中"), + /** 22 调解完成 */ + MEDIATION_COMPLETE(22, "调解完成"), + /** 23 待平台核实 */ + WAIT_PLATFORM_VERIFY(23, "待平台核实"), + /** 24 重新退款中 */ + REFUNDING_AGAIN(24, "重新退款中"), + /** 26 调解关闭 */ + MEDIATION_CLOSED(26, "调解关闭"), + /** 30 平台判定用户责任 */ + PLATFORM_JUDGMENT_USER_RESPONSIBILITY(30, "平台判定用户责任"), + /** 31 平台判定商家责任 */ + PLATFORM_JUDGMENT_MERCHANT_RESPONSIBILITY(31, "平台判定商家责任"), + /** 32 平台判定双方责任 */ + PLATFORM_JUDGMENT_BOTH_PARTIES_RESPONSIBILITY(32, "平台判定双方责任"), + /** 33 平台判定无责任 */ + PLATFORM_JUDGMENT_NO_RESPONSIBILITY(33, "平台判定无责任"), + /** 34 平台判定申诉无效 */ + PLATFORM_JUDGMENT_APPEAL_INVALID(34, "平台判定申诉无效"), + /** 35 平台判定申诉生效 */ + PLATFORM_JUDGMENT_APPEAL_EFFECTIVE(35, "平台判定申诉生效"), + /** 36 平台判定退款有效 */ + PLATFORM_JUDGMENT_REFUND_EFFECTIVE(36, "平台判定退款有效"), + /** 37 平台判定退款无效 */ + PLATFORM_JUDGMENT_REFUND_INVALID(37, "平台判定退款无效"), + /** 50 用户发起退款 */ + USER_INITIATE_REFUND(50, "用户发起退款"), + /** 51 商家拒绝退款 */ + MERCHANT_REFUSE_REFUND(51, "商家拒绝退款"), + /** 52 用户取消申请 */ + USER_CANCEL_APPLICATION(52, "用户取消申请"), + /** 56 待买家退货 */ + WAIT_BUYER_RETURN_GOODS(56, "待买家退货"), + /** 57 退货退款关闭 */ + REFUND_CLOSED(57, "退货退款关闭"), + /** 58 待商家收货 */ + WAIT_MERCHANT_RECEIVE_GOODS(58, "待商家收货"), + /** 59 商家逾期未退款 */ + MERCHANT_OVERDUE_REFUND(59, "商家逾期未退款"), + /** 60 退款完成 */ + REFUND_COMPLETE(60, "退款完成"), + /** 61 退货退款完成 */ + REFUND_GOODS_COMPLETE(61, "退货退款完成"), + /** 62 平台退款中 */ + PLATFORM_REFUNDING(62, "平台退款中"), + /** 63 平台退款失败 */ + PLATFORM_REFUND_FAILED(63, "平台退款失败"), + /** 64 待用户确认 */ + WAIT_USER_CONFIRM(64, "待用户确认"), + + ; + + private final int key; + private final String value; + + ComplaintItemType(int key, String value) { + this.key = key; + this.value = value; + } + + public int getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ComplaintStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ComplaintStatus.java new file mode 100644 index 0000000000..c11c5fc432 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ComplaintStatus.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 纠纷单状态 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum ComplaintStatus { + + ; + + private final int key; + private final String value; + + ComplaintStatus(int key, String value) { + this.key = key; + this.value = value; + } + + public int getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CouponType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CouponType.java new file mode 100644 index 0000000000..9001f286ab --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CouponType.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 优惠券 推广类型 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum CouponType { + /** 1 商品条件折券 */ + C_1(1, "商品条件折券"), + /** 2 商品满减券 */ + C_2(2, "商品满减券"), + /** 3 商品统一折扣券 */ + C_3(3, "商品统一折扣券"), + /** 4 商品直减券 */ + C_4(4, "商品直减券"), + /** 101 店铺条件折扣券 */ + C_101(101, "店铺条件折扣券"), + /** 102 店铺满减券 */ + C_102(102, "店铺满减券"), + /** 103 店铺统一折扣券 */ + C_103(103, "店铺统一折扣券"), + /** 104 店铺直减券 */ + C_104(104, "店铺直减券"), + ; + + private final int key; + private final String val; + + CouponType(int key, String val) { + this.key = key; + this.val = val; + } + + public int getKey() { + return key; + } + + public String getVal() { + return val; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CouponValidType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CouponValidType.java new file mode 100644 index 0000000000..bb037cbbdf --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/CouponValidType.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 优惠券 推广类型 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum CouponValidType { + /** 指定时间范围生效 */ + COUPON_VALID_TYPE_TIME(1, "指定时间范围生效"), + /** 生效天数 */ + COUPON_VALID_TYPE_DAY(2, "生效天数"), + + ; + + private final int key; + private final String val; + + CouponValidType(int key, String val) { + this.key = key; + this.val = val; + } + + public int getKey() { + return key; + } + + public String getVal() { + return val; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/DeliveryType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/DeliveryType.java new file mode 100644 index 0000000000..8a024ca6f7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/DeliveryType.java @@ -0,0 +1,42 @@ +package me.chanjar.weixin.channel.enums; + +/** + * 快递类型 + * + * @author Zeyes + */ +public enum DeliveryType { + /** 1 自寄快递 */ + SELF_DELIVERY(1, "自寄快递"), + /** 2 在线签约快递单 */ + ONLINE_DELIVERY(2, "在线签约快递单"), + /** 3 虚拟商品无需物流发货 */ + VIRTUAL_DELIVERY(3, "虚拟商品无需物流发货"), + /** 4 在线快递散单 */ + ONLINE_DELIVERY_SCATTER(4, "在线快递散单"); + + private final Integer key; + private final String value; + + DeliveryType(Integer key, String value) { + this.key = key; + this.value = value; + } + + public static DeliveryType getDeliveryType(Integer key) { + for (DeliveryType deliveryType : DeliveryType.values()) { + if (deliveryType.getKey().equals(key)) { + return deliveryType; + } + } + return null; + } + + public Integer getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/FundsType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/FundsType.java new file mode 100644 index 0000000000..ea3f8873ec --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/FundsType.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.channel.enums; + +/** + * 资金类型 + * + * @author Zeyes + */ +public enum FundsType { + + /** 1 订单支付收入 */ + ORDER_PAY_INCOME(1, "订单支付收入"), + /** 2 订单手续费 */ + ORDER_FEE(2, "订单手续费"), + /** 3 退款 */ + REFUND(3, "退款"), + /** 4 提现 */ + WITHDRAW(4, "提现"), + /** 5 提现失败退票 */ + WITHDRAW_FAIL(5, "提现失败退票"), + /** 6 导购分账 */ + GUIDE_SHARE(6, "导购分账"), + /** 7 联盟分账 */ + LEAGUE_SHARE(7, "联盟分账"), + /** 8 运费险分账 */ + FREIGHT_SHARE(8, "运费险分账"), + /** 9 联盟平台抽佣 */ + LEAGUE_COMMISSION(9, "联盟平台抽佣"), + /** 10 小店抽佣 */ + SHOP_COMMISSION(10, "小店抽佣"), + /** 99 分账 */ + SHARE(99, "分账"), + + ; + + private final int key; + private final String value; + + FundsType(int key, String value) { + this.key = key; + this.value = value; + } + + public int getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/MessageType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/MessageType.java new file mode 100644 index 0000000000..4406104d9f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/MessageType.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.channel.enums; + +/** + * 消息类型 + * + * @author Zeyes + */ +public enum MessageType { + EVENT("event"), + ; + + private final String key; + + MessageType(String key) { + this.key = key; + } + + public String getKey() { + return key; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/PromoteType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/PromoteType.java new file mode 100644 index 0000000000..fa0bd60913 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/PromoteType.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 优惠券 推广类型 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum PromoteType { + PROMOTE_TYPE_SHOP(1, "小店内推广"); + + private final int key; + private final String val; + + PromoteType(int key, String val) { + this.key = key; + this.val = val; + } + + public int getKey() { + return key; + } + + public String getVal() { + return val; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/QrCheckStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/QrCheckStatus.java new file mode 100644 index 0000000000..b0b2d64e31 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/QrCheckStatus.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.channel.enums; + +/** + * 二维码核销状态 + * + * @author Zeyes + */ +public enum QrCheckStatus { + /** 0 未扫码 */ + NOT_SCAN(0, "未扫码"), + /** 1 已确认 */ + CONFIRMED(1, "已确认"), + /** 2 已取消 */ + CANCEL(2, "已取消"), + /** 3 已失效 */ + INVALID(3, "已失效"), + /** 4 已扫码 */ + SCAN(4, "已扫码"), + + ; + + private final int key; + private final String value; + + QrCheckStatus(int key, String value) { + this.key = key; + this.value = value; + } + + public static QrCheckStatus getByKey(Integer key) { + for (QrCheckStatus status : QrCheckStatus.values()) { + if (status.getKey() == key) { + return status; + } + } + return NOT_SCAN; + } + + public int getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SendTime.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SendTime.java new file mode 100644 index 0000000000..85e4d4f0d6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SendTime.java @@ -0,0 +1,67 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 发货时间 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum SendTime { +// /** 4小时内发货 */ +// FOUR_HOUR("SendTime_FOUR_HOUR", "4小时内发货"), +// /** 8小时内发货 */ +// EIGHT_HOUR("SendTime_EIGHT_HOUR", "8小时内发货"), +// /** 12小时内发货 */ +// TWELVE_HOUR("SendTime_TWELVE_HOUR", "12小时内发货"), +// /** 16小时内发货 */ +// SIXTEEN_HOUR("SendTime_SIXTEEN_HOUR", "16小时内发货"), +// /** 20小时内发货 */ +// TWENTY_HOUR("SendTime_TWENTY_HOUR", "20小时内发货"), + /** 24小时内发货 */ + TWENTYFOUR_HOUR("SendTime_TWENTYFOUR_HOUR", "24小时内发货"), + /** 48小时内发货 */ + FOUTYEIGHT_HOUR("SendTime_FOUTYEIGHT_HOUR", "48小时内发货"), + /** 3天内发货 */ + THREE_DAY("SendTime_THREE_DAY", "3天内发货"), +// /** 5天内发货 */ +// FIVE_DAY("SendTime_FIVE_DAY", "5天内发货"), +// /** 7天内发货 */ +// SEVEN_DAY("SendTime_SEVEN_DAY", "7天内发货"), +// /** 10天内发货 */ +// TEN_DAY("SendTime_TEN_DAY", "10天内发货"), +// /** 12天内发货 */ +// TWELVE_DAY("SendTime_TWELVE_DAY", "12天内发货"), +// /** 14天内发货 */ +// FOUTEEN_DAY("SendTime_FOUTEEN_DAY", "14天内发货"), +// /** 16天内发货 */ +// SIXTEEN_DAY("SendTime_SIXTEEN_DAY", "16天内发货"), +// /** 20天内发货 */ +// TWENTY_DAY("SendTime_TWENTY_DAY", "20天内发货"), +// /** 25天内发货 */ +// TWENTYFIVE_DAY("SendTime_TWENTYFIVE_DAY", "25天内发货"), +// /** 30天内发货 */ +// THIRY_DAY("SendTime_THIRY_DAY", "30天内发货"), +// /** 35天内发货 */ +// THIRYFIVE_DAY("SendTime_THIRYFIVE_DAY", "35天内发货"), +// /** 45天内发货 */ +// FOURTYFIVE_DAY("SendTime_FOURTYFIVE_DAY", "45天内发货"), + ; + + private final String key; + private final String value; + + SendTime(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ShareScene.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ShareScene.java new file mode 100644 index 0000000000..b4428dbb24 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/ShareScene.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 分享场景 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum ShareScene { + /** 1 直播间 */ + LIVE_ROOM(1, "直播间"), + /** 2 橱窗 */ + WINDOW(2, "橱窗"), + /** 3 短视频 */ + SHORT_VIDEO(3, "短视频"), + /** 4 视频号主页 */ + CHANNEL_HOME(4, "视频号主页"), + /** 5 商品详情页 */ + PRODUCT_DETAIL(5, "商品详情页"), + + ; + + + private final Integer key; + private final String value; + + ShareScene(Integer key, String value) { + this.key = key; + this.value = value; + } + + public Integer getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SharerType.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SharerType.java new file mode 100644 index 0000000000..8f0da3d760 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SharerType.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 分享员类型 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum SharerType { + /** 0 普通分享员 */ + NORMAL(0, "普通分享员"), + /** 1 企业分享员 */ + ENTERPRISE(1, "企业分享员"), + + ; + + + private final Integer key; + private final String value; + + SharerType(Integer key, String value) { + this.key = key; + this.value = value; + } + + public Integer getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SpuEditStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SpuEditStatus.java new file mode 100644 index 0000000000..3d6063b8cf --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SpuEditStatus.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 商品编辑状态 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum SpuEditStatus { + /** 0 初始值 */ + INIT(0, "初始值"), + /** 1 编辑中 */ + SUBMIT(1, "编辑中"), + /** 2 审核中 */ + ING(2, "审核中"), + /** 3 审核失败 */ + FAIL(3, "审核失败"), + /** 4 审核成功 */ + SUCCESS(4, "审核成功"), + /** 5 商品信息写入中 */ + WRITING(5, "商品信息写入中"); + + private final int status; + private final String desc; + + SpuEditStatus(int status, String desc) { + this.status = status; + this.desc = desc; + } + + public int getStatus() { + return status; + } + + public String getDesc() { + return desc; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SpuStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SpuStatus.java new file mode 100644 index 0000000000..a74fee6b07 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/SpuStatus.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 商品上下架状态 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum SpuStatus { + + /** 0 初始值 */ + INIT(0, "未上架"), + /** 5 上架 */ + UP(5, "上架"), + /** 6 回收站 */ + TRASH(6, "回收站"), + /** 11 自主下架 */ + DOWN(11, "自主下架"), + /** 13 违规下架/风控系统下架 */ + SYSTEM_DOWN(13, "违规下架"); + + private final int status; + private final String desc; + + SpuStatus(int status, String desc) { + this.status = status; + this.desc = desc; + } + + public int getStatus() { + return status; + } + + public String getDesc() { + return desc; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/UserCouponStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/UserCouponStatus.java new file mode 100644 index 0000000000..ce7e97df6c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/UserCouponStatus.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.enums; + +/** + * 视频号小店 用户优惠券状态 + * + * @author Zeyes + */ +public enum UserCouponStatus { + /** 100 生效中 */ + VALID(100, "生效中"), + /** 101 已过期 */ + EXPIRED(101, "已过期"), + /** 102 已使用 */ + USED(102, "已使用"), + + ; + + private final int key; + private final String val; + + UserCouponStatus(int key, String val) { + this.key = key; + this.val = val; + } + + public int getKey() { + return key; + } + + public String getVal() { + return val; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WithdrawStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WithdrawStatus.java new file mode 100644 index 0000000000..2d1737cbd0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WithdrawStatus.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.channel.enums; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 视频号小店 提现状态 + * + * @author Zeyes + */ +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WithdrawStatus { + /** 受理成功 */ + CREATE_SUCCESS("CREATE_SUCCESS", "受理成功"), + /** 提现成功 */ + SUCCESS("SUCCESS", "提现成功"), + /** 提现失败 */ + FAIL("FAIL", "提现失败"), + /** 提现退票 */ + REFUND("REFUND", "提现退票"), + /** 关单 */ + CLOSE("CLOSE", "关单"), + /** 业务单已创建 */ + INIT("INIT", "业务单已创建"), + ; + + private final String key; + private final String value; + + WithdrawStatus(String key, String value) { + this.key = key; + this.value = value; + } + + public static WithdrawStatus getByKey(String key) { + for (WithdrawStatus reason : WithdrawStatus.values()) { + if (reason.getKey().equals(key)) { + return reason; + } + } + // 找不到就返回其他了 + return FAIL; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxChannelErrorMsgEnum.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxChannelErrorMsgEnum.java new file mode 100644 index 0000000000..4a699c20d0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxChannelErrorMsgEnum.java @@ -0,0 +1,63 @@ +package me.chanjar.weixin.channel.enums; + +import com.google.common.collect.Maps; +import java.util.Map; +import lombok.Getter; + +/** + * 微信视频号全局返回码 + * + * @author Zeyes + */ +@Getter +public enum WxChannelErrorMsgEnum { + /** + * 系统繁忙,此时请开发者稍候再试 system error + */ + CODE_1(-1, "系统繁忙,此时请开发者稍候再试"), + + /** + * 请求成功 ok + */ + CODE_0(0, "请求成功"), + + /** + * AppSecret 错误或者 AppSecret 不属于这个小店,请开发者确认 AppSecret 的正确性 + */ + CODE_40001(40001, "AppSecret 错误或者 AppSecret 不属于这个小店,请开发者确认 AppSecret 的正确性"), + + /** + * 请确保 grant_type 字段值为 client_credential + */ + CODE_40002(40002, "请确保 grant_type 字段值为 client_credential"), + + /** + * 不合法的 AppID,请开发者检查 AppID 的正确性,避免异常字符,注意大小写 + */ + CODE_40013(40013, "不合法的 AppID,请开发者检查 AppID 的正确性,避免异常字符,注意大小写"), + + ; + + private final int code; + private final String msg; + + WxChannelErrorMsgEnum(int code, String msg) { + this.code = code; + this.msg = msg; + } + + static final Map valueMap = Maps.newHashMap(); + + static { + for (WxChannelErrorMsgEnum value : WxChannelErrorMsgEnum.values()) { + valueMap.put(value.code, value.msg); + } + } + + /** + * 通过错误代码查找其中文含义. + */ + public static String findMsgByCode(int code) { + return valueMap.getOrDefault(code, null); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxCouponStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxCouponStatus.java new file mode 100644 index 0000000000..593873fbe4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxCouponStatus.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.channel.enums; + +/** + * 视频号小店 优惠券状态 + * + * @author Zeyes + */ +public enum WxCouponStatus { + /** 1 初始 */ + INIT(1, "初始"), + /** 2 生效 */ + VALID(2, "生效"), + /** 4 已作废 */ + INVALID(4, "已作废"), + /** 5 删除 */ + DELETE(5, "删除"), + + ; + + private final int key; + private final String val; + + WxCouponStatus(int key, String val) { + this.key = key; + this.val = val; + } + + public int getKey() { + return key; + } + + public String getVal() { + return val; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxOrderStatus.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxOrderStatus.java new file mode 100644 index 0000000000..b064335221 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/enums/WxOrderStatus.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.channel.enums; + +/** + * 视频号小店 订单状态 + * + * @author Zeyes + */ +public enum WxOrderStatus { + /** 10 待付款 */ + UNPAID(10, "待付款"), + /** 20 待发货(已付款/用户已付尾款) */ + PAID(20, "待发货"), + /** 21 部分发货 */ + PART_DELIVERY(21, "部分发货"), + /** 30 待收货 */ + DELIVERY(30, "待收货"), + /** 100 完成 */ + COMPLETED(100, "已完成"), + /** 190 商品超卖商家取消订单 */ + UNPAID_CANCEL(190, "已取消"), + /** 200 全部商品售后之后,订单取消 */ + ALL_AFTER_SALE(200, "已取消"), + /** 250 用户主动取消/待付款超时取消/商家取消 */ + CANCEL(250, "已取消"); + + private final int key; + + private final String val; + + WxOrderStatus(int key, String val) { + this.key = key; + this.val = val; + } + + public int getKey() { + return key; + } + + public String getVal() { + return val; + } + + /** + * 获取状态中文 + * + * @param key 状态码 + * @return 状态 + */ + public static String getStatusStr(Integer key) { + if (key == null) { + return "未知"; + } + for (WxOrderStatus status : WxOrderStatus.values()) { + if (key.equals(status.getKey())) { + return status.getVal(); + } + } + return String.valueOf(key); + } + + /** + * 判断是否在取消状态 + * + * @param key key + * @return boolean + */ + public static boolean isCancel(Integer key) { + if (key == null) { + return false; + } + return key.equals(UNPAID_CANCEL.key) || key.equals(ALL_AFTER_SALE.key) || key.equals(CANCEL.key); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelFileUploadRequestExecutor.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelFileUploadRequestExecutor.java new file mode 100644 index 0000000000..576f1c286a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelFileUploadRequestExecutor.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.channel.executor; + + +import java.io.File; +import java.io.IOException; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.ResponseHandler; +import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; + +/** + * 视频号小店 图片上传接口 请求的参数是File, 返回的结果是String + * + * @author Zeyes + */ +public class ChannelFileUploadRequestExecutor implements RequestExecutor { + + protected RequestHttp requestHttp; + + public ChannelFileUploadRequestExecutor(RequestHttp requestHttp) { + this.requestHttp = requestHttp; + } + + @Override + public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { + HttpPost httpPost = new HttpPost(uri); + if (requestHttp.getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); + httpPost.setConfig(config); + } + if (file != null) { + HttpEntity entity = MultipartEntityBuilder + .create() + .addBinaryBody("media", file) + .setMode(HttpMultipartMode.RFC6532) + .build(); + httpPost.setEntity(entity); + } + try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { + return Utf8ResponseHandler.INSTANCE.handleResponse(response); + } finally { + httpPost.releaseConnection(); + } + } + + @Override + public void execute(String uri, File data, ResponseHandler handler, WxType wxType) + throws WxErrorException, IOException { + handler.handle(this.execute(uri, data, wxType)); + } + + public static RequestExecutor create(RequestHttp requestHttp) { + return new ChannelFileUploadRequestExecutor(requestHttp); + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelMediaDownloadRequestExecutor.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelMediaDownloadRequestExecutor.java new file mode 100644 index 0000000000..1b81dc6d15 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelMediaDownloadRequestExecutor.java @@ -0,0 +1,151 @@ +package me.chanjar.weixin.channel.executor; + +import static org.apache.commons.io.FileUtils.openOutputStream; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.bean.image.ChannelImageResponse; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.ResponseHandler; +import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler; +import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.Header; +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.CloseableHttpClient; + +/** + * 下载媒体文件请求执行器 + * + * @author Zeyes + */ +@Slf4j +public class ChannelMediaDownloadRequestExecutor implements RequestExecutor { + + protected RequestHttp requestHttp; + protected File tmpDirFile; + + private static final Pattern PATTERN = Pattern.compile(".*filename=\"(.*)\""); + + public ChannelMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { + this.requestHttp = requestHttp; + this.tmpDirFile = tmpDirFile; + } + + @Override + public ChannelImageResponse execute(String uri, String data, WxType wxType) throws WxErrorException, IOException { + if (data != null) { + if (uri.indexOf('?') == -1) { + uri += '?'; + } + uri += uri.endsWith("?") ? data : '&' + data; + } + + HttpGet httpGet = new HttpGet(uri); + if (requestHttp.getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); + httpGet.setConfig(config); + } + + try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet); + InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response)) { + Header[] contentTypeHeader = response.getHeaders("Content-Type"); + String contentType = null; + if (contentTypeHeader != null && contentTypeHeader.length > 0) { + contentType = contentTypeHeader[0].getValue(); + if (contentType.startsWith(ContentType.APPLICATION_JSON.getMimeType())) { + // application/json; encoding=utf-8 下载媒体文件出错 + String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + return JsonUtils.decode(responseContent, ChannelImageResponse.class); + } + } + + String fileName = this.getFileName(response); + if (StringUtils.isBlank(fileName)) { + fileName = String.valueOf(System.currentTimeMillis()); + } + + String baseName = FilenameUtils.getBaseName(fileName); + if (StringUtils.isBlank(fileName) || baseName.length() < 3) { + baseName = String.valueOf(System.currentTimeMillis()); + } + String extension = FilenameUtils.getExtension(fileName); + if (StringUtils.isBlank(extension)) { + extension = "unknown"; + } + File file = createTmpFile(inputStream, baseName, extension, tmpDirFile); + ChannelImageResponse result = new ChannelImageResponse(file, contentType); + return result; + } finally { + httpGet.releaseConnection(); + } + } + + @Override + public void execute(String uri, String data, ResponseHandler handler, WxType wxType) + throws WxErrorException, IOException { + handler.handle(this.execute(uri, data, wxType)); + } + + public static RequestExecutor create(RequestHttp requestHttp, File tmpDirFile) { + return new ChannelMediaDownloadRequestExecutor(requestHttp, tmpDirFile); + } + + /** + * 创建临时文件 + * + * @param inputStream 输入文件流 + * @param name 文件名 + * @param ext 扩展名 + * @param tmpDirFile 临时文件夹目录 + */ + public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) + throws IOException { + File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile); + resultFile.deleteOnExit(); + try (InputStream in = inputStream; OutputStream out = openOutputStream(resultFile)) { + IOUtils.copy(in, out); + } + return resultFile; + } + + private String getFileName(CloseableHttpResponse response) throws WxErrorException { + Header[] contentDispositionHeader = response.getHeaders("Content-disposition"); + if (contentDispositionHeader == null || contentDispositionHeader.length == 0) { + return createDefaultFileName(); + } + return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue()); + } + + private String createDefaultFileName() { + return UUID.randomUUID().toString(); + } + + private String extractFileNameFromContentString(String content) throws WxErrorException { + if (content == null || content.length() == 0) { + return createDefaultFileName(); + } + Matcher m = PATTERN.matcher(content); + if (m.matches()) { + return m.group(1); + } + return createDefaultFileName(); + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessage.java new file mode 100644 index 0000000000..f6e3386a5a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessage.java @@ -0,0 +1,125 @@ +package me.chanjar.weixin.channel.message; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.io.Serializable; +import me.chanjar.weixin.channel.util.JsonUtils; + +/** + * 视频号 消息 兼容Json和xml + * + * @author Zeyes + */ +@JacksonXmlRootElement(localName = "xml") +public class WxChannelMessage implements Serializable { + + private static final long serialVersionUID = -6929595548318897649L; + + @JsonProperty("ToUserName") + @JacksonXmlProperty(localName = "ToUserName") + @JacksonXmlCData + private String toUser; + + @JsonProperty("FromUserName") + @JacksonXmlProperty(localName = "FromUserName") + @JacksonXmlCData + private String fromUser; + + @JsonProperty("CreateTime") + @JacksonXmlProperty(localName = "CreateTime") + private Long createTime; + + @JsonProperty("MsgType") + @JacksonXmlProperty(localName = "MsgType") + @JacksonXmlCData + private String msgType; + + @JsonProperty("Event") + @JacksonXmlProperty(localName = "Event") + @JacksonXmlCData + private String event; + + @JsonProperty("Encrypt") + @JacksonXmlProperty(localName = "Encrypt") + @JacksonXmlCData + private String encrypt; + + @JsonProperty("MsgId") + @JacksonXmlProperty(localName = "MsgId") + private Long msgId; + + @JsonProperty("MsgID") + @JacksonXmlProperty(localName = "MsgID") + private void msgIdFill(Long msgId) { + if (msgId != null) { + this.msgId = msgId; + } + } + + @Override + public String toString() { + return this.toJson(); + } + + public String toJson() { + return JsonUtils.encode(this); + } + + public String getToUser() { + return toUser; + } + + public String getFromUser() { + return fromUser; + } + + public Long getCreateTime() { + return createTime; + } + + public String getMsgType() { + return msgType; + } + + public String getEvent() { + return event; + } + + public String getEncrypt() { + return encrypt; + } + + public Long getMsgId() { + return msgId; + } + + public void setToUser(String toUser) { + this.toUser = toUser; + } + + public void setFromUser(String fromUser) { + this.fromUser = fromUser; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public void setMsgType(String msgType) { + this.msgType = msgType; + } + + public void setEvent(String event) { + this.event = event; + } + + public void setEncrypt(String encrypt) { + this.encrypt = encrypt; + } + + public void setMsgId(Long msgId) { + this.msgId = msgId; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessageRouter.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessageRouter.java new file mode 100644 index 0000000000..8ccc2c5050 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessageRouter.java @@ -0,0 +1,225 @@ +package me.chanjar.weixin.channel.message; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.common.api.WxErrorExceptionHandler; +import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; +import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateCheckerSingleton; +import me.chanjar.weixin.common.session.InternalSession; +import me.chanjar.weixin.common.session.InternalSessionManager; +import me.chanjar.weixin.common.session.StandardSessionManager; +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.common.util.LogExceptionHandler; +import org.apache.commons.lang3.StringUtils; + +/** + * 消息路由器 + * + * @author Zeyes + */ +@Data +@Slf4j +public class WxChannelMessageRouter { + /** 规则列表 */ + private final List> rules = new ArrayList<>(); + /** 线程池 */ + private ExecutorService executorService; + /** 异常处理器 */ + private WxErrorExceptionHandler exceptionHandler; + /** 消息重复检查器 */ + private WxMessageDuplicateChecker messageDuplicateChecker; + + public WxChannelMessageRouter() { + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxChMsgRouter-pool-%d").build(); + this.executorService = new ThreadPoolExecutor(2, 100, + 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); + //this.sessionManager = new StandardSessionManager(); + this.exceptionHandler = new LogExceptionHandler(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); + } + + /** + * 使用自定义的 {@link ExecutorService}. + */ + public WxChannelMessageRouter(ExecutorService executorService) { + this.executorService = executorService; + this.exceptionHandler = new LogExceptionHandler(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); + } + + /** + * 系统退出前,应该调用该方法 + */ + public void shutDownExecutorService() { + this.executorService.shutdown(); + } + + /** + * 系统退出前,应该调用该方法,增加了超时时间检测 + */ + public void shutDownExecutorService(Integer second) { + this.executorService.shutdown(); + try { + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { + this.executorService.shutdownNow(); + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { + log.error("线程池未关闭!"); + } + } + } catch (InterruptedException ie) { + this.executorService.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + + /** + *
+   * 设置自定义的 {@link ExecutorService}
+   * 如果不调用该方法,默认使用内置的
+   * 
+ */ + public void setExecutorService(ExecutorService executorService) { + this.executorService = executorService; + } + + /** + * 消息路由入口 + * + * @param message 消息 + * @param content 原始消息(解密之后的) + * @param appId appId + * @param service 服务实例 + * @return 返回值 + */ + public Object route(final WxChannelMessage message, final String content, final String appId, + final WxChannelService service) { + return this.route(message, content, appId, new HashMap<>(2), service, new StandardSessionManager()); + } + + /** + * 路由微信消息 + * + * @param message 消息 + * @param content 消息原始内容 + * @param context 上下文 + * @return Object + */ + public Object route(final WxChannelMessage message, final String content, final String appId, + final Map context, final WxChannelService service, final WxSessionManager sessionManager) { + // 如果是重复消息,那么就不做处理 + if (isMsgDuplicated(message)) { + return null; + } + + final List> matchRules = new ArrayList<>(); + + // 收集匹配的规则 + for (final WxChannelMessageRouterRule rule : this.rules) { + if (rule.isMatch(message)) { + matchRules.add(rule); + if (!rule.isNext()) { + break; + } + } + } + + if (matchRules.size() == 0) { + return null; + } + final List> futures = new ArrayList<>(); + Object result = null; + for (final WxChannelMessageRouterRule rule : matchRules) { + // 返回最后一个非异步的rule的执行结果 + if (rule.isAsync()) { + futures.add( + this.executorService.submit(() -> { + rule.process(message, content, appId, context, service, sessionManager, exceptionHandler); + }) + ); + } else { + result = rule.process(message, content, appId, context, service, sessionManager, exceptionHandler); + // 在同步操作结束,session访问结束 + sessionEndAccess(sessionManager, message, false); + } + } + + if (futures.size() > 0) { + this.executorService.submit(() -> { + for (Future future : futures) { + try { + future.get(); + // 异步操作结束,session访问结束 + sessionEndAccess(sessionManager, message, true); + } catch (InterruptedException | ExecutionException e) { + log.error("Error happened when wait task finish", e); + } + } + }); + } + return result; + } + + /** + * 判断消息是否重复 + * + * @param wxMessage 消息 + * @return 是否重复 + */ + private boolean isMsgDuplicated(WxChannelMessage wxMessage) { + String messageId = this.generateMessageId(wxMessage); + return this.messageDuplicateChecker.isDuplicate(messageId); + } + + /** + * 生成消息id + * + * @return 消息id + */ + private String generateMessageId(WxChannelMessage wxMessage) { + StringBuilder sb = new StringBuilder(); + if (wxMessage.getMsgId() == null) { + sb.append(wxMessage.getCreateTime()) + .append("-").append(wxMessage.getFromUser()) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent())); + } else { + sb.append(wxMessage.getMsgId()) + .append("-").append(wxMessage.getCreateTime()) + .append("-").append(wxMessage.getFromUser()); + } + + if (StringUtils.isNotEmpty(wxMessage.getToUser())) { + sb.append("-").append(wxMessage.getToUser()); + } + return sb.toString(); + } + + /** + * 对session的访问结束 + * + * @param sessionManager session管理器 + * @param message 消息 + * @param sync 是否同步 打印log用 + */ + private void sessionEndAccess(WxSessionManager sessionManager, WxChannelMessage message, boolean sync) { + log.debug("End session access: async={}, sessionId={}", sync, message.getFromUser()); + InternalSession session = ((InternalSessionManager) sessionManager).findSession(message.getFromUser()); + if (session != null) { + session.endAccess(); + } + } + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterRule.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterRule.java new file mode 100644 index 0000000000..60c5e9f83e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterRule.java @@ -0,0 +1,172 @@ +package me.chanjar.weixin.channel.message; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.Singular; +import lombok.experimental.Accessors; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.enums.MessageType; +import me.chanjar.weixin.channel.message.rule.WxChannelMessageHandler; +import me.chanjar.weixin.channel.message.rule.WxChannelMessageInterceptor; +import me.chanjar.weixin.channel.message.rule.WxChannelMessageMatcher; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.channel.util.XmlUtils; +import me.chanjar.weixin.common.api.WxErrorExceptionHandler; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.session.WxSessionManager; +import org.apache.commons.lang3.StringUtils; + +/** + * @author Zeyes + */ +@Data +@Accessors(chain = true) +@Slf4j +public class WxChannelMessageRouterRule { + /** 是否异步, 默认是true */ + private boolean async = true; + /** 消息类型 */ + private String msgType; + /** 事件类型 */ + private String event; + /** 自定义匹配器 */ + private WxChannelMessageMatcher matcher; + /** 进入下一个rule,默认是false */ + private boolean next = false; + /** 消息处理器 */ + @Singular + private List> handlers = new ArrayList<>(4); + /** 消息拦截器 */ + @Singular + private List interceptors = new ArrayList<>(4); + /** 消息类型 */ + private Class messageClass; + + public WxChannelMessageRouterRule() { + } + + /** + * 设置事件 + * + * @param event 事件 + * @return this + */ + public WxChannelMessageRouterRule setEvent(String event) { + this.msgType = MessageType.EVENT.getKey(); + this.event = event; + return this; + } + + /** + * 测试消息是否匹配规则 + * + * @param message 消息 + * @return 是否匹配 + */ + protected boolean isMatch(WxChannelMessage message) { + String msgType = message.getMsgType() == null ? null : message.getMsgType().toLowerCase(); + String event = message.getEvent() == null ? null : message.getEvent().toLowerCase(); + + boolean matchMsgType = this.msgType == null || this.msgType.toLowerCase().equals(msgType); + boolean matchEvent = this.event == null || this.event.toLowerCase().equals(event); + boolean matchMatcher = this.matcher == null || this.matcher.match(message); + + return matchMsgType && matchEvent && matchMatcher; + } + + /** + * 处理微信推送过来的消息 + * + * @param message 消息 + * @param content 消息原始内容 + * @param appId appId + * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 + * @param service 服务实例 + * @param sessionManager session管理器 + * @param exceptionHandler 异常处理器 + * @return 返回消息 + */ + protected Object process(WxChannelMessage message, String content, String appId, Map context, + WxChannelService service, WxSessionManager sessionManager, WxErrorExceptionHandler exceptionHandler) { + if (context == null) { + context = new HashMap<>(16); + } + // 重新反序列化消息 + T tempMessage = deserialize(content, messageClass, service); + if (tempMessage == null) { + log.error("消息重新反序列化失败,请检查消息格式是否正确或者指定正确的messageClass"); + return null; + } + + Object outMessage = null; + try { + // 如果拦截器不通过,返回null + for (WxChannelMessageInterceptor interceptor : this.interceptors) { + if (!interceptor.intercept(message, content, context, service, sessionManager)) { + return null; + } + } + + // 交给handler处理 + for (WxChannelMessageHandler handler : this.handlers) { + // 返回最后handler的结果 + if (handler == null) { + continue; + } + + outMessage = handler.handle(tempMessage, content, appId, context, sessionManager); + } + } catch (WxErrorException e) { + exceptionHandler.handle(e); + } + return outMessage; + } + + /** + * 重新反序列化消息 + * + * @param content 消息内容 + * @param clazz 消息类型 + * @param service 服务实例 + * @return T + */ + private T deserialize(String content, Class clazz, WxChannelService service) { + String msgFormat = service.getConfig().getMsgDataFormat(); + T t = deserialize(content, clazz, msgFormat); + if (t != null) { + return t; + } + // 如果指定的消息格式不正确,根据内容猜猜格式 + if (StringUtils.isNotBlank(content)) { + if (content.startsWith("")) { + t = deserialize(content, clazz, "XML"); + } else if (content.startsWith("{")){ + t = deserialize(content, clazz, "JSON"); + } + } + return t; + } + + /** + * 重新反序列化消息 + * + * @param content 消息内容 + * @param clazz 消息类型 + * @param msgFormat 消息格式 + * @return T + */ + private T deserialize(String content, Class clazz, String msgFormat) { + T message = null; + // 重新反序列化原始消息 + if (msgFormat == null || msgFormat.equalsIgnoreCase("JSON")) { + message = JsonUtils.decode(content, clazz); + } else { + message = XmlUtils.decode(content, clazz); + } + return message; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/HandlerConsumer.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/HandlerConsumer.java new file mode 100644 index 0000000000..522290b178 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/HandlerConsumer.java @@ -0,0 +1,12 @@ +package me.chanjar.weixin.channel.message.rule; + +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * @author Zeyes + */ +@FunctionalInterface +public interface HandlerConsumer { + + void accept(T t, U u, V v, W w, X x); +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageHandler.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageHandler.java new file mode 100644 index 0000000000..4918365bf9 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageHandler.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.message.rule; + +import java.util.Map; +import me.chanjar.weixin.channel.message.WxChannelMessage; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.session.WxSessionManager; + +/** + * 处理视频号推送消息的处理器 + * + * @author Zeyes + */ +public interface WxChannelMessageHandler { + + /** + * 处理消息 + * + * @param message 消息 + * @param content 消息原始内容 + * @param appId appId + * @param context 上下文 + * @param sessionManager session管理器 + * @return 输出消息 格式可能是String/Xml/Json,视情况而定 + * + * @throws WxErrorException 异常 + */ + Object handle(T message, String content, String appId, Map context, WxSessionManager sessionManager) + throws WxErrorException; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageInterceptor.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageInterceptor.java new file mode 100644 index 0000000000..dbb06cb6cc --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageInterceptor.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.message.rule; + +import java.util.Map; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.message.WxChannelMessage; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.session.WxSessionManager; + +/** + * 微信消息拦截器,可以用来做验证 + * + * @author Zeyes + */ +public interface WxChannelMessageInterceptor { + + /** + * 拦截微信消息 + * + * @param message 消息 + * @param content 消息原始内容 + * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 + * @param service 服务实例 + * @param sessionManager session管理器 + * @return true代表OK,false代表不OK + * + * @throws WxErrorException 异常 + */ + boolean intercept(WxChannelMessage message, String content, Map context, WxChannelService service, + WxSessionManager sessionManager) throws WxErrorException; + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageMatcher.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageMatcher.java new file mode 100644 index 0000000000..c6e6824ca0 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/message/rule/WxChannelMessageMatcher.java @@ -0,0 +1,20 @@ +package me.chanjar.weixin.channel.message.rule; + +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 消息匹配器,用在消息路由的时候 + * + * @author Zeyes + */ +public interface WxChannelMessageMatcher { + + /** + * 消息是否匹配某种模式 + * + * @param message 消息 + * @return 是否匹配 + */ + boolean match(WxChannelMessage message); + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/JsonUtils.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/JsonUtils.java new file mode 100644 index 0000000000..ce7e754e00 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/JsonUtils.java @@ -0,0 +1,100 @@ +package me.chanjar.weixin.channel.util; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.json.JsonReadFeature; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.json.JsonMapper; +import java.io.IOException; +import lombok.extern.slf4j.Slf4j; + +/** + * Json序列化/反序列化工具类 + * + * @author Zeyes + */ +@Slf4j +public class JsonUtils { + + private static final JsonMapper JSON_MAPPER = new JsonMapper(); + + static { + JSON_MAPPER.enable(JsonReadFeature.ALLOW_JAVA_COMMENTS.mappedFeature()); + JSON_MAPPER.enable(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES.mappedFeature()); + JSON_MAPPER.enable(JsonReadFeature.ALLOW_SINGLE_QUOTES.mappedFeature()); + JSON_MAPPER.enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature()); + JSON_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + JSON_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + JSON_MAPPER.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); + } + + private JsonUtils() { + } + + /** + * 对象序列化 + * + * @param obj 对象 + * @return json + */ + public static String encode(Object obj) { + try { + return JSON_MAPPER.writeValueAsString(obj); + } catch (IOException e) { + log.error("encode(Object)", e); + } + return null; + } + + /** + * 对象序列化 + * + * @param objectMapper ObjectMapper + * @param obj obj + * @return json + */ + public static String encode(ObjectMapper objectMapper, Object obj) { + try { + return objectMapper.writeValueAsString(obj); + } catch (IOException e) { + log.error("encode(Object)", e); + } + return null; + } + + /** + * 将json反序列化成对象 + * + * @param json json + * @param valueType Class + * @return T + */ + public static T decode(String json, Class valueType) { + if (json == null || json.length() <= 0) { + return null; + } + try { + return JSON_MAPPER.readValue(json, valueType); + } catch (IOException e) { + log.info("decode(String, Class)", e); + } + return null; + } + + /** + * 将json反序列化为对象 + * + * @param json json + * @param typeReference TypeReference + * @return T + */ + public static T decode(String json, TypeReference typeReference) { + try { + return (T) JSON_MAPPER.readValue(json, typeReference); + } catch (IOException e) { + log.info("decode(String, JsonTypeReference)", e); + } + return null; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/ResponseUtils.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/ResponseUtils.java new file mode 100644 index 0000000000..865eab6354 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/ResponseUtils.java @@ -0,0 +1,63 @@ +package me.chanjar.weixin.channel.util; + + +import static me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse.INTERNAL_ERROR_CODE; + +import java.lang.reflect.InvocationTargetException; +import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import org.apache.commons.lang3.StringUtils; + +/** + * 响应工具类 + * + * @author Zeyes + */ +@Slf4j +@UtilityClass +public class ResponseUtils { + + /** + * 将json反序列化成对象 + * + * @param json json + * @param valueType Class + * @return T + */ + public static T decode(String json, Class valueType) { + T t = null; + try { + if (StringUtils.isNotBlank(json)) { + t = JsonUtils.decode(json, valueType); + } + } catch (Exception e) { + log.error("decode", e); + } + if (t == null) { + t = internalError(valueType); + } + return t; + } + + /** + * 设置系统内部错误 + * + * @param clazz 类 + * @param T + * @return 错误 + */ + public static T internalError(Class clazz) { + try { + T t = clazz.getDeclaredConstructor().newInstance(); + t.setErrCode(INTERNAL_ERROR_CODE); + t.setErrMsg("内部错误"); + return t; + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + log.error("internalError", e); + } + // 正常情况下不会执行到这里 + return null; + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/WxChCryptUtils.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/WxChCryptUtils.java new file mode 100644 index 0000000000..3e6062f308 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/WxChCryptUtils.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.channel.util; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.AlgorithmParameters; +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.config.WxChannelConfig; +import me.chanjar.weixin.common.util.crypto.PKCS7Encoder; +import me.chanjar.weixin.common.util.crypto.WxCryptUtil; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; + +/** + * @author Zeyes + */ +@Slf4j +public class WxChCryptUtils extends WxCryptUtil { + + protected static final Charset UTF_8 = StandardCharsets.UTF_8; + + public WxChCryptUtils(WxChannelConfig config) { + this.appidOrCorpid = config.getAppid(); + this.token = config.getToken(); + this.aesKey = Base64.decodeBase64(StringUtils.trim(config.getAesKey()) + "="); + } + + /** + * AES解密 + * + * @param sessionKey session_key + * @param encryptedData 消息密文 + * @param ivStr iv字符串 + */ + public static String decrypt(String sessionKey, String encryptedData, String ivStr) { + try { + AlgorithmParameters params = AlgorithmParameters.getInstance("AES"); + params.init(new IvParameterSpec(Base64.decodeBase64(ivStr))); + + Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(Base64.decodeBase64(sessionKey), "AES"), params); + + return new String(PKCS7Encoder.decode(cipher.doFinal(Base64.decodeBase64(encryptedData))), UTF_8); + } catch (Exception e) { + throw new RuntimeException("AES解密失败!", e); + } + } + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/XmlUtils.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/XmlUtils.java new file mode 100644 index 0000000000..2e34fef571 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/util/XmlUtils.java @@ -0,0 +1,113 @@ +package me.chanjar.weixin.channel.util; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; +import java.io.IOException; +import java.io.InputStream; +import lombok.extern.slf4j.Slf4j; + +/** + * Xml序列化/反序列化工具类 + * + * @author Zeyes + */ +@Slf4j +public class XmlUtils { + + private static final XmlMapper XML_MAPPER = new XmlMapper(); + + static { + XML_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + XML_MAPPER.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); + // 带有xml文件头, + XML_MAPPER.disable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION); + } + + private XmlUtils() { + } + + /** + * 对象序列化 + * + * @param obj 对象 + * @return json + */ + public static String encode(Object obj) { + try { + return XML_MAPPER.writeValueAsString(obj); + } catch (IOException e) { + log.error("encode(Object)", e); + } + return null; + } + + /** + * 对象序列化 + * + * @param objectMapper ObjectMapper + * @param obj obj + * @return json + */ + public static String encode(ObjectMapper objectMapper, Object obj) { + try { + return objectMapper.writeValueAsString(obj); + } catch (IOException e) { + log.error("encode(Object)", e); + } + return null; + } + + /** + * 将xml反序列化成对象 + * + * @param xml xml + * @param valueType Class + * @return T + */ + public static T decode(String xml, Class valueType) { + if (xml == null || xml.length() <= 0) { + return null; + } + try { + return XML_MAPPER.readValue(xml, valueType); + } catch (IOException e) { + log.info("decode(String, Class)", e); + } + return null; + } + + /** + * 将xml反序列化为对象 + * + * @param xml xml + * @param typeReference TypeReference + * @return T + */ + public static T decode(String xml, TypeReference typeReference) { + try { + return (T) XML_MAPPER.readValue(xml, typeReference); + } catch (IOException e) { + log.info("decode(String, TypeReference)", e); + } + return null; + } + + /** + * 将xml反序列化为对象 + * + * @param is InputStream + * @param valueType Class + * @return T + */ + public static T decode(InputStream is, Class valueType) { + try { + return (T) XML_MAPPER.readValue(is, valueType); + } catch (IOException e) { + log.info("decode(InputStream, Class)", e); + } + return null; + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAddressServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAddressServiceImplTest.java new file mode 100644 index 0000000000..04c08bf698 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAddressServiceImplTest.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelAddressService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.address.AddressDetail; +import me.chanjar.weixin.channel.bean.address.AddressIdResponse; +import me.chanjar.weixin.channel.bean.address.AddressInfoResponse; +import me.chanjar.weixin.channel.bean.address.AddressListResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelAddressServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testListAddress() throws WxErrorException { + WxChannelAddressService addressService = channelService.getAddressService(); + AddressListResponse response = addressService.listAddress(0, 10); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetAddress() throws WxErrorException { + WxChannelAddressService addressService = channelService.getAddressService(); + String addressId = ""; + AddressInfoResponse response = addressService.getAddress(addressId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAddAddress() throws WxErrorException { + WxChannelAddressService addressService = channelService.getAddressService(); + AddressDetail addressDetail = new AddressDetail(); + // ... + AddressIdResponse response = addressService.addAddress(addressDetail); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateAddress() throws WxErrorException { + WxChannelAddressService addressService = channelService.getAddressService(); + AddressDetail addressDetail = new AddressDetail(); + // ... + WxChannelBaseResponse response = addressService.updateAddress(addressDetail); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeleteAddress() throws WxErrorException { + WxChannelAddressService addressService = channelService.getAddressService(); + String addressId = ""; + WxChannelBaseResponse response = addressService.deleteAddress(addressId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplTest.java new file mode 100644 index 0000000000..7e54a9eaae --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplTest.java @@ -0,0 +1,112 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.List; +import me.chanjar.weixin.channel.api.WxChannelAfterSaleService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.after.AfterSaleInfoResponse; +import me.chanjar.weixin.channel.bean.after.AfterSaleListResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.complaint.ComplaintOrderResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelAfterSaleServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testListIds() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + Long beginCreateTime = LocalDateTime.now().minusDays(7).atZone(ZoneId.systemDefault()).toEpochSecond(); + Long endCreateTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toEpochSecond(); + String nextKey = null; + AfterSaleListResponse response = afterSaleService.listIds(beginCreateTime, endCreateTime, nextKey); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGet() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + String afterSaleOrderId = ""; + AfterSaleInfoResponse response = afterSaleService.get(afterSaleOrderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAccept() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + String afterSaleOrderId = ""; + String addressId = "123"; + WxChannelBaseResponse response = afterSaleService.accept(afterSaleOrderId, addressId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testReject() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + String afterSaleOrderId = ""; + String rejectReason = "123"; + WxChannelBaseResponse response = afterSaleService.reject(afterSaleOrderId, rejectReason); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUploadRefundEvidence() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + String afterSaleOrderId = ""; + String desc = ""; + List certificates = new ArrayList<>(4); + WxChannelBaseResponse response = afterSaleService.uploadRefundEvidence(afterSaleOrderId, desc, certificates); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAddComplaintMaterial() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + String complaintId = ""; + String content = ""; + List mediaIds = new ArrayList<>(4); + WxChannelBaseResponse response = afterSaleService.addComplaintMaterial(complaintId, content, mediaIds); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAddComplaintEvidence() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + String complaintId = ""; + String content = ""; + List mediaIds = new ArrayList<>(4); + WxChannelBaseResponse response = afterSaleService.addComplaintEvidence(complaintId, content, mediaIds); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetComplaint() throws WxErrorException { + WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService(); + String complaintId = ""; + ComplaintOrderResponse response = afterSaleService.getComplaint(complaintId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelBasicServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelBasicServiceImplTest.java new file mode 100644 index 0000000000..5673d85439 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelBasicServiceImplTest.java @@ -0,0 +1,108 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.UUID; +import me.chanjar.weixin.channel.api.WxChannelBasicService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.address.AddressCodeResponse; +import me.chanjar.weixin.channel.bean.image.ChannelImageInfo; +import me.chanjar.weixin.channel.bean.image.ChannelImageResponse; +import me.chanjar.weixin.channel.bean.image.QualificationFileResponse; +import me.chanjar.weixin.channel.bean.shop.ShopInfo; +import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.common.error.WxErrorException; +import org.apache.commons.io.FileUtils; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelBasicServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testGetShopInfo() throws WxErrorException { + WxChannelBasicService basicService = channelService.getBasicService(); + ShopInfoResponse response = basicService.getShopInfo(); + assertNotNull(response); + assertTrue(response.isSuccess()); + ShopInfo info = response.getInfo(); + assertNotNull(info); + System.out.println(JsonUtils.encode(response)); + } + + @Test + public void testUploadImg() throws WxErrorException, IOException { + String imgUrl = "https://github.githubassets.com/images/icons/emoji/octocat.png"; + WxChannelBasicService basicService = channelService.getBasicService(); + // 获取mediaId + ChannelImageInfo info = basicService.uploadImg(0, imgUrl); + assertNotNull(info); + assertNotNull(info.getMediaId()); + System.out.println(info.getMediaId()); + // 获取临时链接 + info = basicService.uploadImg(1, imgUrl); + assertNotNull(info); + assertNotNull(info.getUrl()); + System.out.println(info.getUrl()); + // 本地文件的格式上传 + String fileName = "tmp.png"; + URL url = ClassLoader.getSystemResource(fileName); + File f = File.createTempFile(UUID.randomUUID().toString(), ".png"); + FileUtils.copyURLToFile(url, f); + info = basicService.uploadImg(1, f, 253, 253); + assertNotNull(info); + assertNotNull(info.getUrl()); + System.out.println(info.getUrl()); + FileUtils.forceDeleteOnExit(f); + } + + @Test + public void testUploadQualificationFile() throws IOException, WxErrorException { + WxChannelBasicService basicService = channelService.getBasicService(); + // 本地文件的格式上传 + String fileName = "tmp.png"; + URL url = ClassLoader.getSystemResource(fileName); + File f = File.createTempFile(UUID.randomUUID().toString(), ".png"); + FileUtils.copyURLToFile(url, f); + QualificationFileResponse response = basicService.uploadQualificationFile(f); + assertNotNull(response); + assertTrue(response.isSuccess()); + assertNotNull(response.getData()); + assertNotNull(response.getData().getId()); + System.out.println(response.getData().getId()); + FileUtils.forceDeleteOnExit(f); + } + + @Test + public void testGetImg() throws WxErrorException { + WxChannelBasicService basicService = channelService.getBasicService(); + String mediaId = "ttRiex0K2utmlhR-IWcfaWP6deE5Gzo48Hq8abLEoVtTY618jAGtEmDDRPimKpTP8vlgTMwZokXHgm4fBVw82Q"; + ChannelImageResponse response = basicService.getImg(mediaId); + assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response.getContentType()); + } + + @Test + public void testGetAddressCode() throws WxErrorException { + WxChannelBasicService basicService = channelService.getBasicService(); + Integer rootCode = 0; + AddressCodeResponse response = basicService.getAddressCode(rootCode); + assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelBrandServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelBrandServiceImplTest.java new file mode 100644 index 0000000000..f944a3b197 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelBrandServiceImplTest.java @@ -0,0 +1,108 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import java.util.List; +import me.chanjar.weixin.channel.api.WxChannelBrandService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.brand.BasicBrand; +import me.chanjar.weixin.channel.bean.brand.Brand; +import me.chanjar.weixin.channel.bean.brand.BrandApplyListResponse; +import me.chanjar.weixin.channel.bean.brand.BrandInfoResponse; +import me.chanjar.weixin.channel.bean.brand.BrandListResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; +import org.testng.collections.CollectionUtils; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelBrandServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testListAllBrand() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + + BrandListResponse response = brandService.listAllBrand(100, null); + assertNotNull(response); + assertTrue(response.isSuccess()); + List brands = response.getBrands(); + assertTrue(CollectionUtils.hasElements(brands)); + System.out.println(JsonUtils.encode(response)); + } + + @Test + public void testAddBrandApply() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + Brand brand = new Brand(); + // ... + AuditApplyResponse response = brandService.addBrandApply(brand); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateBrandApply() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + Brand brand = new Brand(); + // ... + AuditApplyResponse response = brandService.updateBrandApply(brand); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testCancelBrandApply() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + String brandId = "10000000"; + String auditId = "12345566"; + WxChannelBaseResponse response = brandService.cancelBrandApply(brandId, auditId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeleteBrandApply() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + String brandId = "10000000"; + WxChannelBaseResponse response = brandService.deleteBrandApply(brandId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetBrandApply() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + String brandId = "10000000"; + BrandInfoResponse response = brandService.getBrandApply(brandId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListBrandApply() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + BrandApplyListResponse response = brandService.listBrandApply(10, null, null); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListValidBrandApply() throws WxErrorException { + WxChannelBrandService brandService = channelService.getBrandService(); + BrandApplyListResponse response = brandService.listValidBrandApply(10, null); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelCategoryServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelCategoryServiceImplTest.java new file mode 100644 index 0000000000..9b1a62ada3 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelCategoryServiceImplTest.java @@ -0,0 +1,99 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import java.util.ArrayList; +import java.util.List; +import me.chanjar.weixin.channel.api.WxChannelCategoryService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse; +import me.chanjar.weixin.channel.bean.audit.AuditResponse; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.category.CategoryDetailResult; +import me.chanjar.weixin.channel.bean.category.CategoryQualificationResponse; +import me.chanjar.weixin.channel.bean.category.PassCategoryResponse; +import me.chanjar.weixin.channel.bean.category.ShopCategory; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; +import org.testng.collections.CollectionUtils; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelCategoryServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testListAllCategory() throws WxErrorException { + WxChannelCategoryService categoryService = channelService.getCategoryService(); + CategoryQualificationResponse response = categoryService.listAllCategory(); + assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response); + } + + @Test + public void testListAvailableCategory() throws WxErrorException { + WxChannelCategoryService categoryService = channelService.getCategoryService(); + List shopCategories = categoryService.listAvailableCategory("0"); + assertTrue(CollectionUtils.hasElements(shopCategories)); + shopCategories.forEach(System.out::println); + } + + @Test + public void testGetCategoryDetail() throws WxErrorException { + WxChannelCategoryService categoryService = channelService.getCategoryService(); + CategoryDetailResult categoryDetail = categoryService.getCategoryDetail("1602"); + assertNotNull(categoryDetail); + assertTrue(categoryDetail.isSuccess()); + System.out.println(categoryDetail); + } + + @Test + public void testAddCategory() throws WxErrorException { + WxChannelCategoryService categoryService = channelService.getCategoryService(); + List certificates = new ArrayList<>(); + certificates.add( + "hWNith8iZSrxfN7W2tXOoWSXYWi1qADRJxwImvQl2DC6wqqJrl4g8i/UEZfd59yiiEKAnqy0WETFrOcGZFcJDfpH2ccmNZddzesR1/OpAC7bbfmEiDFBK2QL7MBjhR2m"); + AuditApplyResponse response = categoryService.addCategory("1001", "1002", "1005", certificates); + assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response); + } + + @Test + public void testCancelCategoryAudit() throws WxErrorException { + WxChannelCategoryService categoryService = channelService.getCategoryService(); + String auditId = "4403159413"; + WxChannelBaseResponse response = categoryService.cancelCategoryAudit(auditId); + assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response); + } + + @Test + public void testGetAudit() throws WxErrorException { + WxChannelCategoryService categoryService = channelService.getCategoryService(); + String auditId = "4403159413"; + AuditResponse response = categoryService.getAudit(auditId); + assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response); + } + + @Test + public void testListPassCategory() throws WxErrorException { + WxChannelCategoryService categoryService = channelService.getCategoryService(); + PassCategoryResponse response = categoryService.listPassCategory(); + assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelCouponServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelCouponServiceImplTest.java new file mode 100644 index 0000000000..2885e2e007 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelCouponServiceImplTest.java @@ -0,0 +1,97 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.*; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelCouponService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponIdResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponInfoResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponListParam; +import me.chanjar.weixin.channel.bean.coupon.CouponListResponse; +import me.chanjar.weixin.channel.bean.coupon.CouponParam; +import me.chanjar.weixin.channel.bean.coupon.UserCouponListParam; +import me.chanjar.weixin.channel.bean.coupon.UserCouponListResponse; +import me.chanjar.weixin.channel.bean.coupon.UserCouponResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelCouponServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testCreateCoupon() throws WxErrorException { + WxChannelCouponService couponService = channelService.getCouponService(); + CouponParam param = new CouponParam(); + // ... + CouponIdResponse response = couponService.createCoupon(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateCoupon() throws WxErrorException { + WxChannelCouponService couponService = channelService.getCouponService(); + CouponParam param = new CouponParam(); + // ... + CouponIdResponse response = couponService.updateCoupon(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateCouponStatus() throws WxErrorException { + WxChannelCouponService couponService = channelService.getCouponService(); + String couponId = ""; + Integer status = 2; + WxChannelBaseResponse response = couponService.updateCouponStatus(couponId, status); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetCoupon() throws WxErrorException { + WxChannelCouponService couponService = channelService.getCouponService(); + String couponId = ""; + CouponInfoResponse response = couponService.getCoupon(couponId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetCouponList() throws WxErrorException { + WxChannelCouponService couponService = channelService.getCouponService(); + CouponListParam param = new UserCouponListParam(); + CouponListResponse response = couponService.getCouponList(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetUserCoupon() throws WxErrorException { + WxChannelCouponService couponService = channelService.getCouponService(); + String couponId = ""; + String userCouponId = ""; + UserCouponResponse response = couponService.getUserCoupon(couponId, userCouponId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetUserCouponList() throws WxErrorException { + WxChannelCouponService couponService = channelService.getCouponService(); + UserCouponListParam param = new UserCouponListParam(); + UserCouponListResponse response = couponService.getUserCouponList(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelFreightTemplateServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelFreightTemplateServiceImplTest.java new file mode 100644 index 0000000000..a936a9299e --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelFreightTemplateServiceImplTest.java @@ -0,0 +1,64 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.*; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelFreightTemplateService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.freight.FreightTemplate; +import me.chanjar.weixin.channel.bean.freight.TemplateIdResponse; +import me.chanjar.weixin.channel.bean.freight.TemplateInfoResponse; +import me.chanjar.weixin.channel.bean.freight.TemplateListResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelFreightTemplateServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testListTemplate() throws WxErrorException { + WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService(); + Integer offset = 0; + Integer limit = 20; + TemplateListResponse response = freightTemplateService.listTemplate(offset, limit); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetTemplate() throws WxErrorException { + WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService(); + String templateId = ""; + TemplateInfoResponse response = freightTemplateService.getTemplate(templateId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAddTemplate() throws WxErrorException { + WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService(); + FreightTemplate template = new FreightTemplate(); + // ... + TemplateIdResponse response = freightTemplateService.addTemplate(template); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateTemplate() throws WxErrorException { + WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService(); + FreightTemplate template = new FreightTemplate(); + // ... + TemplateIdResponse response = freightTemplateService.updateTemplate(template); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelFundServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelFundServiceImplTest.java new file mode 100644 index 0000000000..5bf86e3e25 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelFundServiceImplTest.java @@ -0,0 +1,184 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.*; + +import com.google.inject.Inject; +import java.time.LocalDateTime; +import java.time.ZoneId; +import me.chanjar.weixin.channel.api.WxChannelFundService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.fund.AccountInfo; +import me.chanjar.weixin.channel.bean.fund.AccountInfoResponse; +import me.chanjar.weixin.channel.bean.fund.BalanceInfoResponse; +import me.chanjar.weixin.channel.bean.fund.FlowListResponse; +import me.chanjar.weixin.channel.bean.fund.FundsFlowResponse; +import me.chanjar.weixin.channel.bean.fund.FundsListParam; +import me.chanjar.weixin.channel.bean.fund.WithdrawDetailResponse; +import me.chanjar.weixin.channel.bean.fund.WithdrawListResponse; +import me.chanjar.weixin.channel.bean.fund.WithdrawSubmitResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankCityResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankInfoResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankListResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BankProvinceResponse; +import me.chanjar.weixin.channel.bean.fund.bank.BranchInfoResponse; +import me.chanjar.weixin.channel.bean.fund.qrcode.QrCheckResponse; +import me.chanjar.weixin.channel.bean.fund.qrcode.QrCodeResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelFundServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testGetBalance() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + BalanceInfoResponse response = fundService.getBalance(); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetBankAccount() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + AccountInfoResponse response = fundService.getBankAccount(); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetFundsFlowDetail() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + String flowId = ""; + FundsFlowResponse response = fundService.getFundsFlowDetail(flowId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListFundsFlow() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + FundsListParam param = new FundsListParam(); + FlowListResponse response = fundService.listFundsFlow(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetWithdrawDetail() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + String withdrawId = ""; + WithdrawDetailResponse response = fundService.getWithdrawDetail(withdrawId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListWithdraw() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + Integer pageNum = 1; + Integer pageSize = 10; + Long startTime = LocalDateTime.now().minusDays(7).atZone(ZoneId.systemDefault()).toEpochSecond(); + Long endTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toEpochSecond(); + WithdrawListResponse response = fundService.listWithdraw(pageNum, pageSize, startTime, endTime); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSetBankAccount() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + AccountInfo accountInfo = new AccountInfo(); + // ... + WxChannelBaseResponse response = fundService.setBankAccount(accountInfo); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSubmitWithdraw() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + Integer amount = 1; + String remark = "test"; + String bankMemo = "-"; + WithdrawSubmitResponse response = fundService.submitWithdraw(amount, remark, bankMemo); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetBankInfoByCardNo() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + String accountNumber = ""; + BankInfoResponse response = fundService.getBankInfoByCardNo(accountNumber); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSearchBankList() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + Integer offset = 0; + Integer limit = 20; + String keywords = ""; + Integer bankType = 1; + BankListResponse response = fundService.searchBankList(offset, limit, keywords, bankType); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSearchCityList() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + String provinceCode = "0"; + BankCityResponse response = fundService.searchCityList(provinceCode); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetProvinceList() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + BankProvinceResponse response = fundService.getProvinceList(); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSearchBranchList() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + String bankCode = ""; + String cityCode = ""; + Integer offset = 0; + Integer limit = 20; + BranchInfoResponse response = fundService.searchBranchList(bankCode, cityCode, offset, limit); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetQrCode() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + String qrcodeTicket = ""; + QrCodeResponse response = fundService.getQrCode(qrcodeTicket); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testCheckQrStatus() throws WxErrorException { + WxChannelFundService fundService = channelService.getFundService(); + String qrcodeTicket = ""; + QrCheckResponse response = fundService.checkQrStatus(qrcodeTicket); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelOrderServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelOrderServiceImplTest.java new file mode 100644 index 0000000000..2eb14b062e --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelOrderServiceImplTest.java @@ -0,0 +1,151 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import java.util.ArrayList; +import java.util.List; +import me.chanjar.weixin.channel.api.WxChannelOrderService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.base.AddressInfo; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.delivery.DeliveryCompanyResponse; +import me.chanjar.weixin.channel.bean.delivery.DeliveryInfo; +import me.chanjar.weixin.channel.bean.order.ChangeOrderInfo; +import me.chanjar.weixin.channel.bean.order.DeliveryUpdateParam; +import me.chanjar.weixin.channel.bean.order.OrderAddressInfo; +import me.chanjar.weixin.channel.bean.order.OrderInfoResponse; +import me.chanjar.weixin.channel.bean.order.OrderListParam; +import me.chanjar.weixin.channel.bean.order.OrderListResponse; +import me.chanjar.weixin.channel.bean.order.OrderSearchParam; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelOrderServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testGetOrder() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + OrderInfoResponse response = orderService.getOrder(orderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetOrders() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + OrderListParam param = new OrderListParam(); + OrderListResponse response = orderService.getOrders(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSearchOrder() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + OrderSearchParam param = new OrderSearchParam(); + OrderListResponse response = orderService.searchOrder(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdatePrice() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + Integer expressFee = 0; + List changeOrderInfos = new ArrayList<>(4); + ChangeOrderInfo changeOrderInfo = new ChangeOrderInfo(); + changeOrderInfos.add(changeOrderInfo); + WxChannelBaseResponse response = orderService.updatePrice(orderId, expressFee, changeOrderInfos); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateRemark() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + String merchantNotes = ""; + WxChannelBaseResponse response = orderService.updateRemark(orderId, merchantNotes); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateAddress() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + AddressInfo addressInfo = new OrderAddressInfo(); + WxChannelBaseResponse response = orderService.updateAddress(orderId, addressInfo); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateDelivery() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + DeliveryUpdateParam param = new DeliveryUpdateParam(); + WxChannelBaseResponse response = orderService.updateDelivery(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAcceptAddressModify() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + WxChannelBaseResponse response = orderService.acceptAddressModify(orderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testRejectAddressModify() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + WxChannelBaseResponse response = orderService.rejectAddressModify(orderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testCloseOrder() { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + WxChannelBaseResponse response = orderService.closeOrder(orderId); + assertNotNull(response); + //assertTrue(response.isSuccess()); + } + + @Test + public void testListDeliveryCompany() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + DeliveryCompanyResponse response = orderService.listDeliveryCompany(); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeliveryOrder() throws WxErrorException { + WxChannelOrderService orderService = channelService.getOrderService(); + String orderId = ""; + List deliveryList = new ArrayList<>(4); + DeliveryInfo deliveryInfo = new DeliveryInfo(); + deliveryList.add(deliveryInfo); + WxChannelBaseResponse response = orderService.deliveryOrder(orderId, deliveryList); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImplTest.java new file mode 100644 index 0000000000..b14bc9b3fc --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImplTest.java @@ -0,0 +1,169 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelProductService; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse; +import me.chanjar.weixin.channel.bean.limit.LimitTaskParam; +import me.chanjar.weixin.channel.bean.product.SkuStockResponse; +import me.chanjar.weixin.channel.bean.product.SpuGetResponse; +import me.chanjar.weixin.channel.bean.product.SpuInfo; +import me.chanjar.weixin.channel.bean.product.SpuListResponse; +import me.chanjar.weixin.channel.bean.product.SpuUpdateResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelProductServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testAddProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + SpuInfo spuInfo = new SpuInfo(); + // ... + SpuUpdateResponse response = productService.addProduct(spuInfo); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + SpuInfo spuInfo = new SpuInfo(); + // ... + SpuUpdateResponse response = productService.updateProduct(spuInfo); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateStock() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String productId = ""; + String skuId = ""; + Integer diffType = 1; + Integer num = 10; + WxChannelBaseResponse response = productService.updateStock(productId, skuId, diffType, num); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeleteProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String productId = ""; + WxChannelBaseResponse response = productService.deleteProduct(productId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testCancelProductAudit() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String productId = ""; + WxChannelBaseResponse response = productService.cancelProductAudit(productId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String productId = "10000029995861"; + Integer dataType = 3; + SpuGetResponse response = productService.getProduct(productId, dataType); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + Integer pageSize = 10; + String nextKey = null; + Integer status = null; + SpuListResponse response = productService.listProduct(pageSize, nextKey, status); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String productId = ""; + WxChannelBaseResponse response = productService.upProduct(productId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDownProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String productId = ""; + WxChannelBaseResponse response = productService.downProduct(productId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetSkuStock() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String productId = ""; + String skuId = ""; + SkuStockResponse response = productService.getSkuStock(productId, skuId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAddLimitTask() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + LimitTaskParam param = new LimitTaskParam(); + // ... + LimitTaskAddResponse response = productService.addLimitTask(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListLimitTask() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + Integer pageSize = 1; + String nextKey = ""; + Integer status = null; + LimitTaskListResponse response = productService.listLimitTask(pageSize, nextKey, status); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testStopLimitTask() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String taskId = ""; + WxChannelBaseResponse response = productService.stopLimitTask(taskId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeleteLimitTask() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + String taskId = ""; + WxChannelBaseResponse response = productService.deleteLimitTask(taskId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelSharerServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelSharerServiceImplTest.java new file mode 100644 index 0000000000..91eceac3ac --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelSharerServiceImplTest.java @@ -0,0 +1,78 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.*; + +import com.google.inject.Inject; +import java.util.ArrayList; +import java.util.List; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.WxChannelSharerService; +import me.chanjar.weixin.channel.bean.sharer.SharerBindResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerInfoResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerOrderParam; +import me.chanjar.weixin.channel.bean.sharer.SharerOrderResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerSearchResponse; +import me.chanjar.weixin.channel.bean.sharer.SharerUnbindResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelSharerServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testBindSharer() throws WxErrorException { + WxChannelSharerService sharerService = channelService.getSharerService(); + String username = ""; + SharerBindResponse response = sharerService.bindSharer(username); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSearchSharer() throws WxErrorException { + WxChannelSharerService sharerService = channelService.getSharerService(); + String openid = ""; + String username = ""; + SharerSearchResponse response = sharerService.searchSharer(openid, username); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListSharer() throws WxErrorException { + WxChannelSharerService sharerService = channelService.getSharerService(); + Integer page = 1; + Integer pageSize = 10; + Integer sharerType = 1; + SharerInfoResponse response = sharerService.listSharer(page, pageSize, sharerType); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListSharerOrder() throws WxErrorException { + WxChannelSharerService sharerService = channelService.getSharerService(); + SharerOrderParam param = new SharerOrderParam(); + SharerOrderResponse response = sharerService.listSharerOrder(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUnbindSharer() throws WxErrorException { + WxChannelSharerService sharerService = channelService.getSharerService(); + List openIds = new ArrayList<>(4); + openIds.add(""); + SharerUnbindResponse response = sharerService.unbindSharer(openIds); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelWarehouseServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelWarehouseServiceImplTest.java new file mode 100644 index 0000000000..2210f765a2 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelWarehouseServiceImplTest.java @@ -0,0 +1,138 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import java.util.ArrayList; +import java.util.List; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.WxChannelWarehouseService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.warehouse.LocationPriorityResponse; +import me.chanjar.weixin.channel.bean.warehouse.PriorityLocationParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseIdsResponse; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseLocation; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseResponse; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockParam; +import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxChannelWarehouseServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testCreateWarehouse() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + WarehouseParam param = new WarehouseParam(); + // ... + WxChannelBaseResponse response = warehouseService.createWarehouse(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListWarehouse() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + Integer pageSize = 10; + WarehouseIdsResponse response = warehouseService.listWarehouse(pageSize, null); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetWarehouse() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + String warehouseId = "123"; + WarehouseResponse response = warehouseService.getWarehouse(warehouseId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateWarehouse() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + String outWarehouseId = ""; + String name = ""; + String intro = ""; + WxChannelBaseResponse response = warehouseService.updateWarehouse(outWarehouseId, name, intro); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testAddWarehouseArea() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + String outWarehouseId = ""; + List coverLocations = new ArrayList<>(4); + WarehouseLocation location = new WarehouseLocation(); + coverLocations.add(location); + WxChannelBaseResponse response = warehouseService.addWarehouseArea(outWarehouseId, coverLocations); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeleteWarehouseArea() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + String outWarehouseId = ""; + List coverLocations = new ArrayList<>(4); + WarehouseLocation location = new WarehouseLocation(); + coverLocations.add(location); + WxChannelBaseResponse response = warehouseService.deleteWarehouseArea(outWarehouseId, coverLocations); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testSetWarehousePriority() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + PriorityLocationParam param = new PriorityLocationParam(); + WxChannelBaseResponse response = warehouseService.setWarehousePriority(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetWarehousePriority() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + Integer addressId1 = 1; + Integer addressId2 = 2; + Integer addressId3 = 3; + Integer addressId4 = 4; + LocationPriorityResponse response = warehouseService + .getWarehousePriority(addressId1, addressId2, addressId3, addressId4); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateWarehouseStock() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + WarehouseStockParam param = new WarehouseStockParam(); + WxChannelBaseResponse response = warehouseService.updateWarehouseStock(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetWarehouseStock() throws WxErrorException { + WxChannelWarehouseService warehouseService = channelService.getWarehouseService(); + String productId = ""; + String skuId = ""; + String outWarehouseId = ""; + WarehouseStockResponse response = warehouseService.getWarehouseStock(productId, skuId, outWarehouseId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueProductServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueProductServiceImplTest.java new file mode 100644 index 0000000000..762a7f45d6 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueProductServiceImplTest.java @@ -0,0 +1,76 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.*; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.WxLeagueProductService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.product.BatchAddParam; +import me.chanjar.weixin.channel.bean.league.product.BatchAddResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductDetailParam; +import me.chanjar.weixin.channel.bean.league.product.ProductDetailResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductListParam; +import me.chanjar.weixin.channel.bean.league.product.ProductListResponse; +import me.chanjar.weixin.channel.bean.league.product.ProductUpdateParam; +import me.chanjar.weixin.channel.bean.league.product.ProductUpdateResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxLeagueProductServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testBatchAddProduct() throws WxErrorException { + WxLeagueProductService leagueProductService = channelService.getLeagueProductService(); + BatchAddParam param = new BatchAddParam(); + BatchAddResponse response = leagueProductService.batchAddProduct(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateProduct() throws WxErrorException { + WxLeagueProductService leagueProductService = channelService.getLeagueProductService(); + ProductUpdateParam param = new ProductUpdateParam(); + ProductUpdateResponse response = leagueProductService.updateProduct(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeleteProduct() throws WxErrorException { + WxLeagueProductService leagueProductService = channelService.getLeagueProductService(); + Integer type = 1; + String productId = ""; + WxChannelBaseResponse response = leagueProductService.deleteProduct(type, productId, null); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetProductDetail() throws WxErrorException { + WxLeagueProductService leagueProductService = channelService.getLeagueProductService(); + ProductDetailParam param = new ProductDetailParam(); + ProductDetailResponse response = leagueProductService.getProductDetail(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListProduct() throws WxErrorException { + WxLeagueProductService leagueProductService = channelService.getLeagueProductService(); + ProductListParam param = new ProductListParam(); + ProductListResponse response = leagueProductService.listProduct(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeaguePromoterServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeaguePromoterServiceImplTest.java new file mode 100644 index 0000000000..aae33fdb46 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeaguePromoterServiceImplTest.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.WxLeaguePromoterService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.promoter.PromoterInfoResponse; +import me.chanjar.weixin.channel.bean.league.promoter.PromoterListResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxLeaguePromoterServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testAddPromoter() throws WxErrorException { + WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService(); + String finderId = ""; + WxChannelBaseResponse response = leaguePromoterService.addPromoter(finderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdatePromoter() throws WxErrorException { + WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService(); + String finderId = ""; + int type = 1; + WxChannelBaseResponse response = leaguePromoterService.updatePromoter(finderId, type); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testDeletePromoter() throws WxErrorException { + WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService(); + String finderId = ""; + WxChannelBaseResponse response = leaguePromoterService.deletePromoter(finderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetPromoterInfo() throws WxErrorException { + WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService(); + String finderId = ""; + PromoterInfoResponse response = leaguePromoterService.getPromoterInfo(finderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListPromoter() throws WxErrorException { + WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService(); + Integer pageIndex = 1; + Integer pageSize = 10; + Integer status = null; + PromoterListResponse response = leaguePromoterService.listPromoter(pageIndex, pageSize, status); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueSupplierServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueSupplierServiceImplTest.java new file mode 100644 index 0000000000..798aac3560 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueSupplierServiceImplTest.java @@ -0,0 +1,118 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.WxLeagueSupplierService; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListParam; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.CoopProductResponse; +import me.chanjar.weixin.channel.bean.league.supplier.FlowListParam; +import me.chanjar.weixin.channel.bean.league.supplier.ShopDetailResponse; +import me.chanjar.weixin.channel.bean.league.supplier.ShopListResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierBalanceResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowDetailResponse; +import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowListResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxLeagueSupplierServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testGetBalanceInfo() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + SupplierBalanceResponse response = leagueSupplierService.getBalanceInfo(); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetFlowDetail() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + String flowId = ""; + SupplierFlowDetailResponse response = leagueSupplierService.getFlowDetail(flowId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetFlowList() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + FlowListParam param = new FlowListParam(); + SupplierFlowListResponse response = leagueSupplierService.getFlowList(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetProductDetail() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + String productId = ""; + String appId = ""; + CoopProductResponse response = leagueSupplierService.getProductDetail(productId, appId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetProductList() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + String appId = ""; + Integer pageSize = 10; + String nextKey = null; + CoopProductListResponse response = leagueSupplierService.getProductList(appId, pageSize, nextKey); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetCommissionOrder() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + String orderId = ""; + String skuId = ""; + CommissionOrderResponse response = leagueSupplierService.getCommissionOrder(orderId, skuId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetCommissionOrderList() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + CommissionOrderListParam param = new CommissionOrderListParam(); + CommissionOrderListResponse response = leagueSupplierService.getCommissionOrderList(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetShopDetail() throws WxErrorException { + WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + String appId = ""; + ShopDetailResponse response = leagueSupplierService.getShopDetail(appId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetShopList() throws WxErrorException { +WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService(); + Integer pageSize = 10; + String nextKey = null; + ShopListResponse response = leagueSupplierService.getShopList(pageSize, nextKey); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueWindowServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueWindowServiceImplTest.java new file mode 100644 index 0000000000..3546b50b47 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxLeagueWindowServiceImplTest.java @@ -0,0 +1,90 @@ +package me.chanjar.weixin.channel.api.impl; + +import static org.testng.Assert.*; + +import com.google.inject.Inject; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.WxLeagueProductService; +import me.chanjar.weixin.channel.api.WxLeagueWindowService; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; +import me.chanjar.weixin.channel.bean.league.product.BatchAddParam; +import me.chanjar.weixin.channel.bean.league.product.BatchAddResponse; +import me.chanjar.weixin.channel.bean.league.window.AuthInfoResponse; +import me.chanjar.weixin.channel.bean.league.window.AuthStatusResponse; +import me.chanjar.weixin.channel.bean.league.window.ProductSearchParam; +import me.chanjar.weixin.channel.bean.league.window.WindowProductListResponse; +import me.chanjar.weixin.channel.bean.league.window.WindowProductResponse; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +@Guice(modules = ApiTestModule.class) +public class WxLeagueWindowServiceImplTest { + + @Inject + private WxChannelService channelService; + + @Test + public void testAddProduct() throws WxErrorException { + WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService(); + String appid = ""; + String openfinderid = ""; + String productId = ""; + WxChannelBaseResponse response = leagueWindowService.addProduct(appid, openfinderid, productId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testListProduct() throws WxErrorException { + WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService(); + ProductSearchParam param = new ProductSearchParam(); + WindowProductListResponse response = leagueWindowService.listProduct(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testRemoveProduct() throws WxErrorException { + WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService(); + String appid = ""; + String openfinderid = ""; + String productId = ""; + WxChannelBaseResponse response = leagueWindowService.removeProduct(appid, openfinderid, productId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetProductDetail() throws WxErrorException { + WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService(); + String appid = ""; + String openfinderid = ""; + String productId = ""; + WindowProductResponse response = leagueWindowService.getProductDetail(appid, openfinderid, productId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetWindowAuthInfo() throws WxErrorException { + WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService(); + String finderId = ""; + AuthInfoResponse response = leagueWindowService.getWindowAuthInfo(finderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testGetWindowAuthStatus() throws WxErrorException { + WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService(); + String finderId = ""; + AuthStatusResponse response = leagueWindowService.getWindowAuthStatus(finderId); + assertNotNull(response); + assertTrue(response.isSuccess()); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterRuleTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterRuleTest.java new file mode 100644 index 0000000000..d1e2f72174 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterRuleTest.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.message; + +import static org.testng.Assert.assertEquals; + +import me.chanjar.weixin.channel.bean.message.order.OrderPayMessage; +import org.testng.annotations.Test; + +/** + * @author LiXiZe + * @since 2023-04-20 + */ +public class WxChannelMessageRouterRuleTest { + + @Test + public void testResolveMessageClass() { + WxChannelMessageRouterRule rule = new WxChannelMessageRouterRule<>(); + rule.setMessageClass(OrderPayMessage.class); + assertEquals(rule.getMessageClass(), OrderPayMessage.class); + + + } + + + + +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterTest.java new file mode 100644 index 0000000000..755886fa4b --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/message/WxChannelMessageRouterTest.java @@ -0,0 +1,89 @@ +package me.chanjar.weixin.channel.message; + +import static me.chanjar.weixin.channel.constant.MessageEventConstants.BRAND; +import static me.chanjar.weixin.channel.constant.MessageEventConstants.PRODUCT_SPU_AUDIT; +import static org.testng.Assert.*; + +import com.google.inject.Inject; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.bean.message.product.BrandMessage; +import me.chanjar.weixin.channel.bean.message.product.SpuAuditMessage; +import me.chanjar.weixin.channel.message.rule.HandlerConsumer; +import me.chanjar.weixin.channel.test.ApiTestModule; +import me.chanjar.weixin.channel.util.JsonUtils; +import me.chanjar.weixin.common.session.WxSessionManager; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author LiXiZe + * @since 2023-04-21 + */ +@Slf4j +@Guice(modules = ApiTestModule.class) +public class WxChannelMessageRouterTest { + + @Inject + private WxChannelService channelService; + + @Test + public void test1() { + WxChannelMessageRouter router = new WxChannelMessageRouter(); + /* 品牌资质事件回调 */ + this.addRule(router, BrandMessage.class, BRAND, this::brandUpdate); + /* 商品审核结果 */ + this.addRule(router, SpuAuditMessage.class, PRODUCT_SPU_AUDIT, this::spuAudit); + String spuAuditJson = "{\n" + + " \"ToUserName\":\"gh_*\",\n" + + " \"FromUserName\":\"OPENID\",\n" + + " \"CreateTime\":1662480000,\n" + + " \"MsgType\":\"event\",\n" + + " \"Event\":\"product_spu_audit\",\n" + + " \"ProductSpuAudit\": {\n" + + " \"product_id\":\"12345678\",\n" + + " \"status\":3,\n" + + " \"reason\":\"abc\"\n" + + " }\n" + + "}"; + WxChannelMessage message = JsonUtils.decode(spuAuditJson, WxChannelMessage.class); + Object result = router.route(message, spuAuditJson, "xxxWWQQxxx", channelService); + if (result != null) { + log.info("result:{}", result); + } else { + log.info("return null"); + } + } + + public void brandUpdate(BrandMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("品牌更新:{}", JsonUtils.encode(message)); + } + + + public void spuAudit(SpuAuditMessage message, String content, String appId, + Map context, WxSessionManager sessionManager) { + log.info("商品审核:{}", JsonUtils.encode(message)); + } + + /** + * 添加一条规则进入路由器 + * + * @param clazz 消息类型 + * @param event 事件类型 + * @param consumer 处理器 + * @param 消息类型 + */ + protected void addRule(WxChannelMessageRouter router, Class clazz, String event, + HandlerConsumer, WxSessionManager> consumer) { + WxChannelMessageRouterRule rule = new WxChannelMessageRouterRule<>(); + rule.setMessageClass(clazz).setEvent(event).setAsync(false); + rule.getHandlers().add((message, content, appId, context, sessionManager) -> { + consumer.accept(message, content, appId, context, sessionManager); + return "success"; + }); + router.getRules().add(rule); + } + +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/test/ApiTestModule.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/test/ApiTestModule.java new file mode 100644 index 0000000000..8eba81a07e --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/test/ApiTestModule.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.channel.test; + +import com.google.inject.Binder; +import com.google.inject.Module; +import java.io.IOException; +import java.io.InputStream; +import me.chanjar.weixin.channel.api.WxChannelService; +import me.chanjar.weixin.channel.api.impl.WxChannelServiceImpl; +import me.chanjar.weixin.channel.util.XmlUtils; +import me.chanjar.weixin.common.error.WxRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 测试模块 + * + * @author Zeyes + */ +public class ApiTestModule implements Module { + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + private static final String TEST_CONFIG_XML = "test-config.xml"; + + @Override + public void configure(Binder binder) { + try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) { + if (inputStream == null) { + throw new WxRuntimeException( + "测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成"); + } + + TestConfig config = this.fromXml(TestConfig.class, inputStream); + WxChannelService service = new WxChannelServiceImpl(); + + service.setConfig(config); + + binder.bind(TestConfig.class).toInstance(config); + binder.bind(WxChannelService.class).toInstance(service); + } catch (IOException e) { + this.log.error(e.getMessage(), e); + } + } + + private T fromXml(Class clazz, InputStream is) { + return XmlUtils.decode(is, clazz); + } + +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/test/TestConfig.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/test/TestConfig.java new file mode 100644 index 0000000000..5f4dd76770 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/test/TestConfig.java @@ -0,0 +1,11 @@ +package me.chanjar.weixin.channel.test; + +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; + +@Getter +@Setter +public class TestConfig extends WxChannelDefaultConfigImpl { + +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/util/JsonUtilsTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/util/JsonUtilsTest.java new file mode 100644 index 0000000000..ca515a3b5c --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/util/JsonUtilsTest.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.util; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import me.chanjar.weixin.channel.bean.base.AttrInfo; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +public class JsonUtilsTest { + + @Test + public void testEncode() { + AttrInfo info = new AttrInfo("这是Key", "这是Value"); + String json = JsonUtils.encode(info); + System.out.println(json); + assertNotNull(json); + } + + @Test + public void testDecode() { + String json = "{\"attr_key\": \"这是Key\",\"attr_value\": \"这是Value\"}"; + AttrInfo info = JsonUtils.decode(json, AttrInfo.class); + assertNotNull(info); + assertEquals(info.getKey(), "这是Key"); + } +} diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/util/ResponseUtilsTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/util/ResponseUtilsTest.java new file mode 100644 index 0000000000..036cac29e1 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/util/ResponseUtilsTest.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.util; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse; +import org.testng.annotations.Test; + +/** + * @author Zeyes + */ +public class ResponseUtilsTest { + + @Test + public void testDecode() { + String json = "{\"errcode\":0,\"errmsg\":\"ok\",\"info\":{\"nickname\":\"某某视频号\"," + + "\"headimg_url\":\"http://wx.qlogo.cn/xxx\",\"subject_type\":\"企业\"}}"; + ShopInfoResponse response = ResponseUtils.decode(json, ShopInfoResponse.class); + assertNotNull(response); + assertEquals(response.getErrCode(), 0); + assertEquals(response.getErrMsg(), "ok"); + assertEquals(response.getInfo().getNickname(), "某某视频号"); + assertEquals(response.getInfo().getHeadImgUrl(), "http://wx.qlogo.cn/xxx"); + assertEquals(response.getInfo().getSubjectType(), "企业"); + } + + @Test + public void testInternalError() { + ShopInfoResponse response = ResponseUtils.internalError(ShopInfoResponse.class); + assertNotNull(response); + assertEquals(response.getErrCode(), -99); + } +} diff --git a/weixin-java-channel/src/test/resources/logback-test.xml b/weixin-java-channel/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..e4a33acd88 --- /dev/null +++ b/weixin-java-channel/src/test/resources/logback-test.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %replace(%caller{1}){'Caller', ''} - %msg%n + + + + + + + + diff --git a/weixin-java-channel/src/test/resources/test-config.sample.xml b/weixin-java-channel/src/test/resources/test-config.sample.xml new file mode 100644 index 0000000000..b04a50e5a7 --- /dev/null +++ b/weixin-java-channel/src/test/resources/test-config.sample.xml @@ -0,0 +1,9 @@ + + JSON或者XML + appid + secret + Token + EncodingAESKey + 可以不填写 + 可以不填写 + diff --git a/weixin-java-channel/src/test/resources/testng.xml b/weixin-java-channel/src/test/resources/testng.xml new file mode 100644 index 0000000000..afa0aa32f2 --- /dev/null +++ b/weixin-java-channel/src/test/resources/testng.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/weixin-java-channel/src/test/resources/tmp.png b/weixin-java-channel/src/test/resources/tmp.png new file mode 100644 index 0000000000..7c3a48838d Binary files /dev/null and b/weixin-java-channel/src/test/resources/tmp.png differ diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 665f0d7b87..ceab4048fd 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B weixin-java-common @@ -50,7 +50,7 @@ org.slf4j jcl-over-slf4j - 1.7.30 + 1.7.36 @@ -117,6 +117,12 @@ org.dom4j dom4j 2.1.3 + + + pull-parser + pull-parser + + redis.clients diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java index 3e08462017..3d2f62affe 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java @@ -1,5 +1,7 @@ package me.chanjar.weixin.common.api; +import lombok.experimental.UtilityClass; + import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -10,8 +12,9 @@ /** * 微信开发所使用到的常量类. * - * @author Daniel Qian & binarywang + * @author Daniel Qian & binarywang & Wang_Wong */ +@UtilityClass public class WxConsts { /** * access_token 相关错误代码 @@ -25,9 +28,15 @@ public class WxConsts { public static final List ACCESS_TOKEN_ERROR_CODES = Arrays.asList(CODE_40001.getCode(), CODE_40014.getCode(), CODE_42001.getCode()); + /** + * 微信接口返回的参数errcode. + */ + public static final String ERR_CODE = "errcode"; + /** * 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型. */ + @UtilityClass public static class XmlMsgType { public static final String TEXT = "text"; public static final String IMAGE = "image"; @@ -45,11 +54,13 @@ public static class XmlMsgType { public static final String HARDWARE = "hardware"; public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; public static final String UPDATE_TASKCARD = "update_taskcard"; + public static final String UPDATE_BUTTON = "update_button"; } /** * 主动发送消息(即客服消息)的消息类型. */ + @UtilityClass public static class KefuMsgType { /** * 文本消息. @@ -120,11 +131,98 @@ public static class KefuMsgType { * 小程序通知消息. */ public static final String MINIPROGRAM_NOTICE = "miniprogram_notice"; + + /** + * 模板卡片消息. + */ + public static final String TEMPLATE_CARD = "template_card"; + + /** + * 发送图文消息(点击跳转到图文消息页面)使用通过 “发布” 系列接口得到的 article_id(草稿箱功能上线后不再支持客服接口中带 media_id 的 mpnews 类型的图文消息) + */ + public static final String MP_NEWS_ARTICLE = "mpnewsarticle"; + } + + /** + * 发送「学校通知」类型 + * https://developer.work.weixin.qq.com/document/path/92321 + */ + @UtilityClass + public static class SchoolContactMsgType { + + /** + * 文本消息. + */ + public static final String TEXT = "text"; + + /** + * 图片消息. + */ + public static final String IMAGE = "image"; + + /** + * 语音消息. + */ + public static final String VOICE = "voice"; + + /** + * 视频消息. + */ + public static final String VIDEO = "video"; + + /** + * 文件消息 + */ + public static final String FILE = "file"; + + /** + * 图文消息 + */ + public static final String NEWS = "news"; + + /** + * 图文消息(mpnews) + */ + public static final String MPNEWS = "mpnews"; + + /** + * 小程序消息 + */ + public static final String MINIPROGRAM = "miniprogram"; + + } + + /** + * 企业微信模板卡片消息的卡片类型 + */ + @UtilityClass + public static class TemplateCardType { + /** + * 文本通知型卡片 + */ + public static final String TEXT_NOTICE = "text_notice"; + /** + * 图文展示型卡片 + */ + public static final String NEWS_NOTICE = "news_notice"; + /** + * 按钮交互型卡片 + */ + public static final String BUTTON_INTERACTION = "button_interaction"; + /** + * 投票选择型卡片 + */ + public static final String VOTE_INTERACTION = "vote_interaction"; + /** + * 多项选择型卡片 + */ + public static final String MULTIPLE_INTERACTION = "multiple_interaction"; } /** * 表示是否是保密消息,0表示否,1表示是,默认0. */ + @UtilityClass public static class KefuMsgSafe { public static final String NO = "0"; public static final String YES = "1"; @@ -133,17 +231,20 @@ public static class KefuMsgSafe { /** * 群发消息的消息类型. */ + @UtilityClass public static class MassMsgType { public static final String MPNEWS = "mpnews"; public static final String TEXT = "text"; public static final String VOICE = "voice"; public static final String IMAGE = "image"; + public static final String IMAGES = "images"; public static final String MPVIDEO = "mpvideo"; } /** * 群发消息后微信端推送给服务器的反馈消息. */ + @UtilityClass public static class MassMsgStatus { public static final String SEND_SUCCESS = "send success"; public static final String SEND_FAIL = "send fail"; @@ -191,6 +292,7 @@ public static class MassMsgStatus { /** * 微信端推送过来的事件类型. */ + @UtilityClass public static class EventType { public static final String SUBSCRIBE = "subscribe"; public static final String UNSUBSCRIBE = "unsubscribe"; @@ -224,7 +326,23 @@ public static class EventType { */ public static final String LOCATION_SELECT = "location_select"; + /** + * 授权用户资料变更事件 + * 1、 当部分用户的资料存在风险时,平台会对用户资料进行清理,并通过消息推送服务器通知最近30天授权过的公众号开发者,我们建议开发者留意响应该事件,及时主动更新或清理用户的头像及昵称,降低风险。 + * 2、 当用户撤回授权信息时,平台会通过消息推送服务器通知给公众号开发者,请开发者注意及时删除用户信息。 + */ + public static final String USER_INFO_MODIFIED = "user_info_modified"; + + /** + * 用户撤回授权事件 + */ + public static final String USER_AUTHORIZATION_REVOKE = "user_authorization_revoke"; + + /** + * 群发模板回调事件 + */ public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH"; + /** * 微信小店 订单付款通知. */ @@ -250,6 +368,10 @@ public static class EventType { */ public static final String CARD_USER_GIFTING_CARD = "user_gifting_card"; + /** + * 异步安全校验事件 + */ + public static final String WXA_MEDIA_CHECK = "wxa_media_check"; /** * 卡券事件:用户核销卡券 @@ -308,6 +430,29 @@ public static class EventType { */ public static final String WEAPP_AUDIT_FAIL = "weapp_audit_fail"; + /** + * 小程序自定义交易组件支付通知 + */ + public static final String OPEN_PRODUCT_ORDER_PAY = "open_product_order_pay"; + /** + * 点击菜单跳转小程序的事件推送 + */ + public static final String VIEW_MINIPROGRAM = "view_miniprogram"; + + /** + * 订阅通知事件:用户操作订阅通知弹窗 + */ + public static final String SUBSCRIBE_MSG_POPUP_EVENT = "subscribe_msg_popup_event"; + + /** + * 订阅通知事件:用户管理订阅通知 + */ + public static final String SUBSCRIBE_MSG_CHANGE_EVENT = "subscribe_msg_change_event"; + + /** + * 订阅通知事件:发送订阅通知回调 + */ + public static final String SUBSCRIBE_MSG_SENT_EVENT = "subscribe_msg_sent_event"; } /** @@ -324,6 +469,7 @@ public static class MediaFileType { /** * 自定义菜单的按钮类型. */ + @UtilityClass public static class MenuButtonType { /** * 点击推事件. @@ -374,6 +520,7 @@ public static class MenuButtonType { /** * oauth2网页授权的scope. */ + @UtilityClass public static class OAuth2Scope { /** * 不弹出授权页面,直接跳转,只能获取用户openid. @@ -394,6 +541,7 @@ public static class OAuth2Scope { /** * 网页应用登录授权作用域. */ + @UtilityClass public static class QrConnectScope { public static final String SNSAPI_LOGIN = "snsapi_login"; } @@ -401,6 +549,7 @@ public static class QrConnectScope { /** * 永久素材类型. */ + @UtilityClass public static class MaterialType { public static final String NEWS = "news"; public static final String VOICE = "voice"; @@ -412,6 +561,7 @@ public static class MaterialType { /** * 网络检测入参. */ + @UtilityClass public static class NetCheckArgs { public static final String ACTIONDNS = "dns"; public static final String ACTIONPING = "ping"; @@ -425,6 +575,7 @@ public static class NetCheckArgs { /** * appId 类型 */ + @UtilityClass public static class AppIdType { /** * 公众号appId类型 diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java index 465f35434b..88c3aeae69 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java @@ -8,10 +8,12 @@ *
  * 默认消息重复检查器.
  * 将每个消息id保存在内存里,每隔5秒清理已经过期的消息id,每个消息id的过期时间是15秒
+ * 替换类WxMessageInMemoryDuplicateCheckerSingleton
  * 
* * @author Daniel Qian */ +@Deprecated public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChecker { /** diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingleton.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingleton.java new file mode 100644 index 0000000000..befd367fe0 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingleton.java @@ -0,0 +1,91 @@ +package me.chanjar.weixin.common.api; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import lombok.extern.slf4j.Slf4j; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * @author jiangby + * @version 1.0 + *

+ * 消息去重,记录消息ID首次出现时的时间戳, + * 15S后定时任务触发时废除该记录消息ID + *

+ * created on 2022/5/26 1:32 + */ +@Slf4j +public class WxMessageInMemoryDuplicateCheckerSingleton implements WxMessageDuplicateChecker { + + /** + * 一个消息ID在内存的过期时间:15秒. + */ + private static final Long TIME_TO_LIVE = 15L; + + /** + * 每隔多少周期检查消息ID是否过期:5秒. + */ + private static final Long CLEAR_PERIOD = 5L; + + /** + * 线程池 + */ + private static final ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(1, + new ThreadFactoryBuilder().setNameFormat("wxMessage-memory-pool-%d").setDaemon(true).build(), new ThreadPoolExecutor.AbortPolicy()); + + /** + * 消息id->消息时间戳的map. + */ + private static final ConcurrentHashMap MSG_ID_2_TIMESTAMP = new ConcurrentHashMap<>(); + + static { + SCHEDULED_THREAD_POOL_EXECUTOR.scheduleAtFixedRate(() -> { + try { + Long now = System.currentTimeMillis(); + MSG_ID_2_TIMESTAMP.entrySet().removeIf(entry -> now - entry.getValue() > TIME_TO_LIVE * 1000); + } catch (Exception ex) { + log.error("重复消息去重任务出现异常", ex); + } + }, 1, CLEAR_PERIOD, TimeUnit.SECONDS); + } + + /** + * 私有化构造方法,避免外部调用 + */ + private WxMessageInMemoryDuplicateCheckerSingleton() { + } + + /** + * 获取单例 + * + * @return 单例对象 + */ + public static WxMessageInMemoryDuplicateCheckerSingleton getInstance() { + return WxMessageInnerClass.CHECKER_SINGLETON; + } + + /** + * 内部类实现单例 + */ + private static class WxMessageInnerClass { + static final WxMessageInMemoryDuplicateCheckerSingleton CHECKER_SINGLETON = new WxMessageInMemoryDuplicateCheckerSingleton(); + } + + /** + * messageId是否重复 + * + * @param messageId messageId + * @return 是否 + */ + @Override + public boolean isDuplicate(String messageId) { + if (messageId == null) { + return false; + } + Long timestamp = MSG_ID_2_TIMESTAMP.putIfAbsent(messageId, System.currentTimeMillis()); + return timestamp != null; + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateChecker.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateChecker.java new file mode 100644 index 0000000000..88c5e9a4e5 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateChecker.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.common.api; + +import lombok.RequiredArgsConstructor; +import org.redisson.api.RBucket; +import org.redisson.api.RedissonClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +/** + * 利用redis检查消息是否重复 + * + */ +@RequiredArgsConstructor +public class WxMessageInRedisDuplicateChecker implements WxMessageDuplicateChecker { + + /** + * 过期时间 + */ + private int expire = 10; + + private final Logger log = LoggerFactory.getLogger(getClass()); + + private final RedissonClient redissonClient; + + /** + * messageId是否重复 + * + * @param messageId messageId + * @return 是否 + */ + @Override + public boolean isDuplicate(String messageId) { + RBucket r = redissonClient.getBucket("wx:message:duplicate:check:" + messageId); + boolean setSuccess = r.trySet("1", expire, TimeUnit.SECONDS); + return !setSuccess; + } + + public int getExpire() { + return expire; + } + + public void setExpire(int expire) { + this.expire = expire; + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ToJson.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ToJson.java index b8bfaabb01..6f10e60b71 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ToJson.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ToJson.java @@ -4,7 +4,7 @@ * 包含toJson()方法的接口. * * @author Binary Wang - * @date 2020-10-05 + * created on 2020-10-05 */ public interface ToJson { /** diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessTokenEntity.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessTokenEntity.java new file mode 100644 index 0000000000..fe19817b2b --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessTokenEntity.java @@ -0,0 +1,19 @@ +package me.chanjar.weixin.common.bean; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * token + * + * @author cn + */ +@Getter +@Setter +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxAccessTokenEntity extends WxAccessToken { + private String appid; +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxOAuth2UserInfo.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxOAuth2UserInfo.java index e647560026..906e9de2b1 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxOAuth2UserInfo.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxOAuth2UserInfo.java @@ -11,7 +11,7 @@ * oauth2用户个人信息. * * @author Binary Wang - * @date 2020-10-11 + * created on 2020-10-11 */ @Data public class WxOAuth2UserInfo implements Serializable { @@ -53,13 +53,13 @@ public class WxOAuth2UserInfo implements Serializable { */ @SerializedName("unionid") private String unionId; - /** * privilege 用户特权信息,json数组,如微信沃卡用户为(chinaunicom) */ @SerializedName("privilege") private String[] privileges; + public static WxOAuth2UserInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxOAuth2UserInfo.class); } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java index 114e267d41..344f544bad 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java @@ -58,6 +58,15 @@ public class WxMenuButton implements Serializable { @SerializedName("media_id") private String mediaId; + /** + *
+   * 调用发布图文接口获得的article_id.
+   * article_id类型和article_view_limited类型必须
+   * 
+ */ + @SerializedName("article_id") + private String articleId; + /** *
    * 小程序的appid.
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/oauth2/WxOAuth2AccessToken.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/oauth2/WxOAuth2AccessToken.java
index 0ab32d6574..c08a49063d 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/oauth2/WxOAuth2AccessToken.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/oauth2/WxOAuth2AccessToken.java
@@ -29,6 +29,11 @@ public class WxOAuth2AccessToken implements Serializable {
 
   @SerializedName("scope")
   private String scope;
+  /**
+   * 是否为快照页模式虚拟账号,只有当用户是快照页模式虚拟账号时返回,值为1
+   */
+  @SerializedName("is_snapshotuser")
+  private Integer snapshotUser;
 
   /**
    * https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11513156443eZYea&version=&lang=zh_CN.
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrIdCardResult.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrIdCardResult.java
index 0b1e0ff838..a50bd96e55 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrIdCardResult.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrIdCardResult.java
@@ -10,7 +10,7 @@
  * OCR身份证识别结果.
  *
  * @author Binary Wang
- * @date 2019-06-23
+ * created on  2019-06-23
  */
 @Data
 public class WxOcrIdCardResult implements Serializable {
@@ -22,6 +22,12 @@ public class WxOcrIdCardResult implements Serializable {
   private String name;
   @SerializedName("id")
   private String id;
+  @SerializedName("addr")
+  private String addr;
+  @SerializedName("gender")
+  private String gender;
+  @SerializedName("nationality")
+  private String nationality;
   @SerializedName("valid_date")
   private String validDate;
 
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadCustomizeResult.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadCustomizeResult.java
index 515189e469..cd700be7c1 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadCustomizeResult.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadCustomizeResult.java
@@ -3,6 +3,7 @@
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import lombok.Data;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.json.WxGsonBuilder;
 
 import java.io.Serializable;
@@ -17,7 +18,7 @@ public class WxMinishopImageUploadCustomizeResult implements Serializable {
   public static WxMinishopImageUploadCustomizeResult fromJson(String json) {
     JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
     WxMinishopImageUploadCustomizeResult result = new WxMinishopImageUploadCustomizeResult();
-    result.setErrcode(jsonObject.get("errcode").getAsNumber().toString());
+    result.setErrcode(jsonObject.get(WxConsts.ERR_CODE).getAsNumber().toString());
     if (result.getErrcode().equals("0")) {
       WxMinishopPicFileCustomizeResult picFileResult = new WxMinishopPicFileCustomizeResult();
       JsonObject picObject = jsonObject.get("img_info").getAsJsonObject();
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadResult.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadResult.java
index 9aa7a81e2f..324232d0ee 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadResult.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadResult.java
@@ -1,8 +1,10 @@
 package me.chanjar.weixin.common.bean.result;
 
+import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import lombok.Data;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.json.WxGsonBuilder;
 
 import java.io.Serializable;
@@ -21,12 +23,16 @@ public class WxMinishopImageUploadResult  implements Serializable {
   public static WxMinishopImageUploadResult fromJson(String json) {
     JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
     WxMinishopImageUploadResult result = new WxMinishopImageUploadResult();
-    result.setErrcode(jsonObject.get("errcode").getAsNumber().toString());
+    result.setErrcode(jsonObject.get(WxConsts.ERR_CODE).getAsNumber().toString());
     if (result.getErrcode().equals("0")) {
       WxMinishopPicFileResult picFileResult = new WxMinishopPicFileResult();
       JsonObject picObject = jsonObject.get("pic_file").getAsJsonObject();
-      picFileResult.setMediaId(picObject.get("media_id").getAsString());
-      picFileResult.setPayMediaId(picObject.get("pay_media_id").getAsString());
+      JsonElement mediaId = picObject.get("media_id");
+      picFileResult.setMediaId(mediaId==null ? "" : mediaId.getAsString());
+      JsonElement payMediaId = picObject.get("pay_media_id");
+      picFileResult.setPayMediaId(payMediaId==null ? "" : payMediaId.getAsString());
+      JsonElement tempImgUrl = picObject.get("temp_img_url");
+      picFileResult.setTempImgUrl(tempImgUrl==null ? "" : tempImgUrl.getAsString());
       result.setPicFile(picFileResult);
 
     }
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopPicFileResult.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopPicFileResult.java
index 1f77a1e6ab..2ae2e2320b 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopPicFileResult.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopPicFileResult.java
@@ -8,4 +8,5 @@
 public class WxMinishopPicFileResult implements Serializable {
   private String mediaId;
   private String payMediaId;
+  private String tempImgUrl;
 }
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/CategoryData.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/CategoryData.java
index 3b2f332932..997beb91ac 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/CategoryData.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/CategoryData.java
@@ -8,7 +8,7 @@
  * .
  *
  * @author Binary Wang
- * @date 2021-01-27
+ * created on  2021-01-27
  */
 @Data
 public class CategoryData implements Serializable {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/PubTemplateKeyword.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/PubTemplateKeyword.java
index c44f2b0bdb..3f4681047b 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/PubTemplateKeyword.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/PubTemplateKeyword.java
@@ -8,7 +8,7 @@
  * .
  *
  * @author Binary Wang
- * @date 2021-01-27
+ * created on  2021-01-27
  */
 @Data
 public class PubTemplateKeyword implements Serializable {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/TemplateInfo.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/TemplateInfo.java
index b42924aa77..64222480ad 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/TemplateInfo.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/subscribemsg/TemplateInfo.java
@@ -8,7 +8,7 @@
  * .
  *
  * @author Binary Wang
- * @date 2021-01-27
+ * created on  2021-01-27
  */
 @Data
 public class TemplateInfo implements Serializable {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/enums/WxType.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/enums/WxType.java
index de047beb1d..9d7d601a0a 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/enums/WxType.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/enums/WxType.java
@@ -28,5 +28,10 @@ public enum WxType {
   /**
    * 微信支付.
    */
-  Pay;
+  Pay,
+  /**
+   * 微信视频号
+   */
+  Channel,
+  ;
 }
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxCpErrorMsgEnum.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxCpErrorMsgEnum.java
index c742959bb6..ea1e9e7c68 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxCpErrorMsgEnum.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxCpErrorMsgEnum.java
@@ -1,7 +1,10 @@
 package me.chanjar.weixin.common.error;
 
+import com.google.common.collect.Maps;
 import lombok.Getter;
 
+import java.util.Map;
+
 /**
  * 
  * 企业微信全局错误码.
@@ -245,6 +248,10 @@ public enum WxCpErrorMsgEnum {
    * 不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头).
    */
   CODE_40094(40094, "不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头)"),
+  /**
+   * 不合法的外部联系人userid
+   */
+  CODE_40096(40096,"不合法的外部联系人userid"),
   /**
    * 缺少access_token参数.
    */
@@ -1072,7 +1079,7 @@ public enum WxCpErrorMsgEnum {
   /**
    * 提交审批单请求参数错误
    */
-  CODE_301025(301025,"提交审批单请求参数错误"),
+  CODE_301025(301025, "提交审批单请求参数错误"),
   /**
    * 不允许更新该用户的userid.
    */
@@ -1080,15 +1087,35 @@ public enum WxCpErrorMsgEnum {
   /**
    * 无审批应用权限,或者提单者不在审批应用/自建应用的可见范围
    */
-  CODE_301055(301055,"无审批应用权限,或者提单者不在审批应用/自建应用的可见范围"),
+  CODE_301055(301055, "无审批应用权限,或者提单者不在审批应用/自建应用的可见范围"),
   /**
    * 审批应用已停用
    */
-  CODE_301056(301056,"审批应用已停用"),
+  CODE_301056(301056, "审批应用已停用"),
   /**
    * 通用错误码,提交审批单内部接口失败
    */
-  CODE_301057(301057,"通用错误码,提交审批单内部接口失败"),
+  CODE_301057(301057, "通用错误码,提交审批单内部接口失败"),
+  /**
+   * 输入userid无对应成员
+   */
+  CODE_301069(301069,"输入userid无对应成员"),
+  /**
+   * 系统错误,请稍后再试
+   */
+  CODE_301070(301070,"系统错误,请稍后再试"),
+  /**
+   * 企业内有其他人员有相似人脸,此情况下人脸仍然会录入成功
+   */
+  CODE_301071(301071,"企业内有其他人员有相似人脸,此情况下人脸仍然会录入成功"),
+  /**
+   * 人脸图像数据错误请更换图片
+   */
+  CODE_301072(301072,"企业内有其他人员有相似人脸,此情况下人脸仍然会录入成功"),
+  /**
+   * 输入参数错误
+   */
+  CODE_301075(301075,"输入参数错误"),
   /**
    * 批量导入任务的文件中userid有重复.
    */
@@ -1114,24 +1141,26 @@ public enum WxCpErrorMsgEnum {
    */
   CODE_2000002(2000002, "CorpId参数无效;指定的CorpId不存在");
 
-  private int code;
-  private String msg;
+  private final int code;
+  private final String msg;
 
   WxCpErrorMsgEnum(int code, String msg) {
     this.code = code;
     this.msg = msg;
   }
 
+  static final Map valueMap = Maps.newHashMap();
+
+  static {
+    for (WxCpErrorMsgEnum value : WxCpErrorMsgEnum.values()) {
+      valueMap.put(value.code, value.msg);
+    }
+  }
+
   /**
    * 通过错误代码查找其中文含义..
    */
   public static String findMsgByCode(int code) {
-    for (WxCpErrorMsgEnum value : WxCpErrorMsgEnum.values()) {
-      if (value.code == code) {
-        return value.msg;
-      }
-    }
-
-    return null;
+    return valueMap.getOrDefault(code, null);
   }
 }
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxError.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxError.java
index f1be843827..1156636ea3 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxError.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxError.java
@@ -1,7 +1,9 @@
 package me.chanjar.weixin.common.error;
 
+import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import me.chanjar.weixin.common.enums.WxType;
 import me.chanjar.weixin.common.util.json.WxGsonBuilder;
 import org.apache.commons.lang3.StringUtils;
@@ -11,12 +13,14 @@
 /**
  * 微信错误码.
  * 请阅读:
- * 公众平台:全局返回码说明
+ * 公众平台:全局返回码说明
  * 企业微信:全局错误码
  *
  * @author Daniel Qian & Binary Wang
  */
 @Data
+@NoArgsConstructor
+@AllArgsConstructor
 @Builder
 public class WxError implements Serializable {
   private static final long serialVersionUID = 7869786563361406291L;
@@ -39,6 +43,11 @@ public class WxError implements Serializable {
 
   private String json;
 
+  public WxError(int errorCode, String errorMsg) {
+    this.errorCode = errorCode;
+    this.errorMsg = errorMsg;
+  }
+
   public static WxError fromJson(String json) {
     return fromJson(json, null);
   }
@@ -75,6 +84,13 @@ public static WxError fromJson(String json, WxType type) {
         }
         break;
       }
+      case Open: {
+        final String msg = WxOpenErrorMsgEnum.findMsgByCode(wxError.getErrorCode());
+        if (msg != null) {
+          wxError.setErrorMsg(msg);
+        }
+        break;
+      }
       default:
         return wxError;
     }
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMaErrorMsgEnum.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMaErrorMsgEnum.java
index 2a9fe01845..46c1d3d3d2 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMaErrorMsgEnum.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMaErrorMsgEnum.java
@@ -1,7 +1,10 @@
 package me.chanjar.weixin.common.error;
 
+import com.google.common.collect.Maps;
 import lombok.Getter;
 
+import java.util.Map;
+
 /**
  * 微信小程序错误码
  *
@@ -67,11 +70,10 @@ public enum WxMaErrorMsgEnum {
    * appid不正确,或者不符合绑定关系要求.
    * 对应操作:sendUniformMessage
    * 对应地址:
-   * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?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/OpenApiDoc/openApi-mgnt/clearQuota.html
    * 
*/ - CODE_40013(40013, "appid不正确,或者不符合绑定关系要求"), + CODE_40013(40013, "appid不正确/不合法(避免异常字符,注意大小写),或者不符合绑定关系要求"), /** *
    * template_id 不正确.
@@ -264,6 +266,50 @@ public enum WxMaErrorMsgEnum {
    * activity_id 过期.
    */
   CODE_47504(47504, "activity_id 过期"),
+  /**
+   * api 禁止清零调用次数,因为清零次数达到上限
+   *
+   * @see 参考文档
+   */
+  CODE_48006(48006, "api 禁止清零调用次数,因为清零次数达到上限"),
+
+  /**
+   * rid不存在
+   *
+   * @see 参考文档
+   */
+  CODE_76001(76001, "rid不存在"),
+  /**
+   * rid为空或者格式错误
+   *
+   * @see 参考文档
+   */
+  CODE_76002(76002, "rid为空或者格式错误"),
+  /**
+   * 当前账号无权查询该rid,该rid属于其他账号调用所产生
+   *
+   * @see 参考文档
+   */
+  CODE_76003(76003, "当前账号无权查询该rid,该rid属于其他账号调用所产生"),
+  /**
+   * rid过期
+   *
+   * @see 参考文档
+   */
+  CODE_76004(76004, "rid过期,仅支持持续7天内的rid"),
+  /**
+   * cgi_path填错了
+   *
+   * @see 参考文档
+   */
+  CODE_76021(76021, "cgi_path填错了"),
+  /**
+   * 当前调用接口使用的token与api所属账号不符
+   *
+   * @see 参考文档
+   */
+  CODE_76022(76022, "当前调用接口使用的token与api所属账号不符,详情可看注意事项的说明"),
+
   /**
    * 没有绑定开放平台帐号.
    */
@@ -340,6 +386,17 @@ public enum WxMaErrorMsgEnum {
   CODE_91017(91017, "+号规则 不同类型关联名主体不一致"),
 
   CODE_40097(40097, "参数错误"),
+  /**
+   * 缺少 appid 参数
+   * 参考文档
+   */
+  CODE_41002(41002, "缺少 appid 参数"),
+  /**
+   * 缺少 secret 参数
+   * 参考文档
+   */
+  CODE_41004(41004, "缺少 secret 参数"),
+
 
   CODE_41006(41006, "media_id 不能为空"),
 
@@ -409,7 +466,7 @@ public enum WxMaErrorMsgEnum {
 
   CODE_85012(85012, "无效的审核 id"),
 
-  CODE_87013(87013, "撤回次数达到上限(每天一次,每个月 10 次)"),
+  CODE_87013(87013, "撤回次数达到上限(每天5次,每个月 10 次)"),
 
   CODE_85019(85019, "没有审核版本"),
 
@@ -664,16 +721,18 @@ public enum WxMaErrorMsgEnum {
     this.msg = msg;
   }
 
+  static final Map valueMap = Maps.newHashMap();
+
+  static {
+    for (WxMaErrorMsgEnum value : WxMaErrorMsgEnum.values()) {
+      valueMap.put(value.code, value.msg);
+    }
+  }
+
   /**
    * 通过错误代码查找其中文含义.
    */
   public static String findMsgByCode(int code) {
-    for (WxMaErrorMsgEnum value : WxMaErrorMsgEnum.values()) {
-      if (value.code == code) {
-        return value.msg;
-      }
-    }
-
-    return null;
+    return valueMap.getOrDefault(code, null);
   }
 }
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMpErrorMsgEnum.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMpErrorMsgEnum.java
index 486791986b..fdfb397cb3 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMpErrorMsgEnum.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMpErrorMsgEnum.java
@@ -1,11 +1,14 @@
 package me.chanjar.weixin.common.error;
 
+import com.google.common.collect.Maps;
 import lombok.Getter;
 
+import java.util.Map;
+
 /**
  * 
  * 微信公众平台全局返回码.
- * 参考文档:公众平台全局返回码
+ * 参考文档:公众平台全局返回码
  * Created by Binary Wang on 2018/5/13.
  * 
* @@ -209,6 +212,10 @@ public enum WxMpErrorMsgEnum { * 请勿添加其他公众号的主页链接. */ CODE_40155(40155, "请勿添加其他公众号的主页链接"), + /** + * oauth_code已使用 + */ + CODE_40163(40163, "oauth_code已使用"), /** * 缺少 access_token 参数. */ @@ -369,6 +376,18 @@ public enum WxMpErrorMsgEnum { * 非法的tag_id. */ CODE_45159(45159, "非法的tag_id"), + /** + * 相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid + */ + CODE_45065(45065, "相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid"), + /** + * 相同 clientmsgid 重试速度过快,请间隔1分钟重试 + */ + CODE_45066(45066, "相同 clientmsgid 重试速度过快,请间隔1分钟重试"), + /** + * clientmsgid 长度超过限制 + */ + CODE_45067(45067, "clientmsgid 长度超过限制"), /** * 不存在媒体数据. */ @@ -644,24 +663,26 @@ public enum WxMpErrorMsgEnum { */ CODE_45084(45084, "没有设置 speed 参数"); - private int code; - private String msg; + private final int code; + private final String msg; WxMpErrorMsgEnum(int code, String msg) { this.code = code; this.msg = msg; } + static final Map valueMap = Maps.newHashMap(); + + static { + for (WxMpErrorMsgEnum value : WxMpErrorMsgEnum.values()) { + valueMap.put(value.code, value.msg); + } + } + /** * 通过错误代码查找其中文含义.. */ public static String findMsgByCode(int code) { - for (WxMpErrorMsgEnum value : WxMpErrorMsgEnum.values()) { - if (value.code == code) { - return value.msg; - } - } - - return null; + return valueMap.getOrDefault(code, null); } } 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 new file mode 100644 index 0000000000..28fb5de8ad --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxOpenErrorMsgEnum.java @@ -0,0 +1,9207 @@ +package me.chanjar.weixin.common.error; + +import com.google.common.collect.Maps; +import lombok.Getter; + +import java.util.Map; + +/** + *
+ *     微信开放平台全局返回码.
+ *     参考文档:开放平台全局返回码
+ * 
+ * + * @author Lam Jerry + */ + +@Getter +public enum WxOpenErrorMsgEnum { + /** + * 系统繁忙,此时请开发者稍候再试 system error + */ + CODE_1(-1, "系统繁忙,此时请开发者稍候再试"), + + /** + * 请求成功 ok + */ + CODE_0(0, "请求成功"), + + /** + * POST参数非法 + */ + CODE_1003(1003, "POST参数非法"), + + /** + * 商品id不存在 + */ + CODE_20002(20002, "商品id不存在"), + + /** + * 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口 invalid credential, access_token is invalid or not latest + */ + CODE_40001(40001, "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口"), + + /** + * 不合法的凭证类型 invalid grant_type + */ + CODE_40002(40002, "不合法的凭证类型"), + + /** + * 不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID invalid openid + */ + CODE_40003(40003, "不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID"), + + /** + * 不合法的媒体文件类型 invalid media type + */ + CODE_40004(40004, "不合法的媒体文件类型"), + + /** + * 上传素材文件格式不对 invalid file type + */ + CODE_40005(40005, "上传素材文件格式不对"), + + /** + * 上传素材文件大小超出限制 invalid meida size + */ + CODE_40006(40006, "上传素材文件大小超出限制"), + + /** + * 不合法的媒体文件 id invalid media_id + */ + CODE_40007(40007, "不合法的媒体文件 id"), + + /** + * 不合法的消息类型 invalid message type + */ + CODE_40008(40008, "不合法的消息类型"), + + /** + * 图片尺寸太大 invalid image size + */ + CODE_40009(40009, "图片尺寸太大"), + + /** + * 不合法的语音文件大小 invalid voice size + */ + CODE_40010(40010, "不合法的语音文件大小"), + + /** + * 不合法的视频文件大小 invalid video size + */ + CODE_40011(40011, "不合法的视频文件大小"), + + /** + * 不合法的缩略图文件大小 invalid thumb size + */ + CODE_40012(40012, "不合法的缩略图文件大小"), + + /** + * 不合法的appid invalid appid + */ + CODE_40013(40013, "不合法的appid"), + + /** + * 不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口 invalid access_token + */ + CODE_40014(40014, "不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口"), + + /** + * 不合法的菜单类型 invalid menu type + */ + CODE_40015(40015, "不合法的菜单类型"), + + /** + * 不合法的按钮个数 invalid button size + */ + CODE_40016(40016, "不合法的按钮个数"), + + /** + * 不合法的按钮类型 invalid button type + */ + CODE_40017(40017, "不合法的按钮类型"), + + /** + * 不合法的按钮名字长度 invalid button name size + */ + CODE_40018(40018, "不合法的按钮名字长度"), + + /** + * 不合法的按钮 KEY 长度 invalid button key size + */ + CODE_40019(40019, "不合法的按钮 KEY 长度"), + + /** + * 不合法的按钮 URL 长度 invalid button url size + */ + CODE_40020(40020, "不合法的按钮 URL 长度"), + + /** + * 不合法的菜单版本号 invalid menu version + */ + CODE_40021(40021, "不合法的菜单版本号"), + + /** + * 不合法的子菜单级数 invalid sub_menu level + */ + CODE_40022(40022, "不合法的子菜单级数"), + + /** + * 不合法的子菜单按钮个数 invalid sub button size + */ + CODE_40023(40023, "不合法的子菜单按钮个数"), + + /** + * 不合法的子菜单按钮类型 invalid sub button type + */ + CODE_40024(40024, "不合法的子菜单按钮类型"), + + /** + * 不合法的子菜单按钮名字长度 invalid sub button name size + */ + CODE_40025(40025, "不合法的子菜单按钮名字长度"), + + /** + * 不合法的子菜单按钮 KEY 长度 invalid sub button key size + */ + CODE_40026(40026, "不合法的子菜单按钮 KEY 长度"), + + /** + * 不合法的子菜单按钮 URL 长度 invalid sub button url size + */ + CODE_40027(40027, "不合法的子菜单按钮 URL 长度"), + + /** + * 不合法的自定义菜单使用用户 invalid menu api user + */ + CODE_40028(40028, "不合法的自定义菜单使用用户"), + + /** + * 无效的 oauth_code invalid code + */ + CODE_40029(40029, "无效的 oauth_code"), + + /** + * 不合法的 refresh_token invalid refresh_token + */ + CODE_40030(40030, "不合法的 refresh_token"), + + /** + * 不合法的 openid 列表 invalid openid list + */ + CODE_40031(40031, "不合法的 openid 列表"), + + /** + * 不合法的 openid 列表长度 invalid openid list size + */ + CODE_40032(40032, "不合法的 openid 列表长度"), + + /** + * 不合法的请求字符,不能包含 \\uxxxx 格式的字符 invalid charset. please check your request, if include \\uxxxx will create fail! + */ + CODE_40033(40033, "不合法的请求字符,不能包含 \\uxxxx 格式的字符"), + + /** + * invalid template size + */ + CODE_40034(40034, "invalid template size"), + + /** + * 不合法的参数 invalid args size + */ + CODE_40035(40035, "不合法的参数"), + + /** + * 不合法的 template_id 长度 invalid template_id size + */ + CODE_40036(40036, "不合法的 template_id 长度"), + + /** + * 不合法的 template_id invalid template_id + */ + CODE_40037(40037, "不合法的 template_id"), + + /** + * 不合法的请求格式 invalid packaging type + */ + CODE_40038(40038, "不合法的请求格式"), + + /** + * 不合法的 URL 长度 invalid url size + */ + CODE_40039(40039, "不合法的 URL 长度"), + + /** + * invalid plugin token + */ + CODE_40040(40040, "invalid plugin token"), + + /** + * invalid plugin id + */ + CODE_40041(40041, "invalid plugin id"), + + /** + * invalid plugin session + */ + CODE_40042(40042, "invalid plugin session"), + + /** + * invalid fav type + */ + CODE_40043(40043, "invalid fav type"), + + /** + * invalid size in link.title + */ + CODE_40044(40044, "invalid size in link.title"), + + /** + * invalid size in link.description + */ + CODE_40045(40045, "invalid size in link.description"), + + /** + * invalid size in link.iconurl + */ + CODE_40046(40046, "invalid size in link.iconurl"), + + /** + * invalid size in link.url + */ + CODE_40047(40047, "invalid size in link.url"), + + /** + * 无效的url invalid url domain + */ + CODE_40048(40048, "无效的url"), + + /** + * invalid score report type + */ + CODE_40049(40049, "invalid score report type"), + + /** + * 不合法的分组 id invalid timeline type + */ + CODE_40050(40050, "不合法的分组 id"), + + /** + * 分组名字不合法 invalid group name + */ + CODE_40051(40051, "分组名字不合法"), + + /** + * invalid action name + */ + CODE_40052(40052, "invalid action name"), + + /** + * invalid action info, please check document + */ + CODE_40053(40053, "invalid action info, please check document"), + + /** + * 不合法的子菜单按钮 url 域名 invalid sub button url domain + */ + CODE_40054(40054, "不合法的子菜单按钮 url 域名"), + + /** + * 不合法的菜单按钮 url 域名 invalid button url domain + */ + CODE_40055(40055, "不合法的菜单按钮 url 域名"), + + /** + * invalid serial code + */ + CODE_40056(40056, "invalid serial code"), + + /** + * invalid tabbar size + */ + CODE_40057(40057, "invalid tabbar size"), + + /** + * invalid tabbar name size + */ + CODE_40058(40058, "invalid tabbar name size"), + + /** + * invalid msg id + */ + CODE_40059(40059, "invalid msg id"), + + /** + * 删除单篇图文时,指定的 article_idx 不合法 invalid article idx + */ + CODE_40060(40060, "删除单篇图文时,指定的 article_idx 不合法"), + + /** + * invalid title size + */ + CODE_40062(40062, "invalid title size"), + + /** + * invalid message_ext size + */ + CODE_40063(40063, "invalid message_ext size"), + + /** + * invalid app type + */ + CODE_40064(40064, "invalid app type"), + + /** + * invalid msg status + */ + CODE_40065(40065, "invalid msg status"), + + /** + * 不合法的 url ,递交的页面被sitemap标记为拦截 invalid url + */ + CODE_40066(40066, "不合法的 url ,递交的页面被sitemap标记为拦截"), + + /** + * invalid tvid + */ + CODE_40067(40067, "invalid tvid"), + + /** + * contain mailcious url + */ + CODE_40068(40068, "contain mailcious url"), + + /** + * invalid hardware type + */ + CODE_40069(40069, "invalid hardware type"), + + /** + * invalid sku info + */ + CODE_40070(40070, "invalid sku info"), + + /** + * invalid card type + */ + CODE_40071(40071, "invalid card type"), + + /** + * invalid location id + */ + CODE_40072(40072, "invalid location id"), + + /** + * invalid card id + */ + CODE_40073(40073, "invalid card id"), + + /** + * invalid pay template id + */ + CODE_40074(40074, "invalid pay template id"), + + /** + * invalid encrypt code + */ + CODE_40075(40075, "invalid encrypt code"), + + /** + * invalid color id + */ + CODE_40076(40076, "invalid color id"), + + /** + * invalid score type + */ + CODE_40077(40077, "invalid score type"), + + /** + * invalid card status + */ + CODE_40078(40078, "invalid card status"), + + /** + * invalid time + */ + CODE_40079(40079, "invalid time"), + + /** + * invalid card ext + */ + CODE_40080(40080, "invalid card ext"), + + /** + * invalid template_id + */ + CODE_40081(40081, "invalid template_id"), + + /** + * invalid banner picture size + */ + CODE_40082(40082, "invalid banner picture size"), + + /** + * invalid banner url size + */ + CODE_40083(40083, "invalid banner url size"), + + /** + * invalid button desc size + */ + CODE_40084(40084, "invalid button desc size"), + + /** + * invalid button url size + */ + CODE_40085(40085, "invalid button url size"), + + /** + * invalid sharelink logo size + */ + CODE_40086(40086, "invalid sharelink logo size"), + + /** + * invalid sharelink desc size + */ + CODE_40087(40087, "invalid sharelink desc size"), + + /** + * invalid sharelink title size + */ + CODE_40088(40088, "invalid sharelink title size"), + + /** + * invalid platform id + */ + CODE_40089(40089, "invalid platform id"), + + /** + * invalid request source (bad client ip) + */ + CODE_40090(40090, "invalid request source (bad client ip)"), + + /** + * invalid component ticket + */ + CODE_40091(40091, "invalid component ticket"), + + /** + * invalid remark name + */ + CODE_40092(40092, "invalid remark name"), + + /** + * not completely ok, err_item will return location_id=-1,check your required_fields in json. + */ + CODE_40093(40093, "not completely ok, err_item will return location_id=-1,check your required_fields in json."), + + /** + * invalid component credential + */ + CODE_40094(40094, "invalid component credential"), + + /** + * bad source of caller + */ + CODE_40095(40095, "bad source of caller"), + + /** + * invalid biztype + */ + CODE_40096(40096, "invalid biztype"), + + /** + * 参数错误 invalid args + */ + CODE_40097(40097, "参数错误"), + + /** + * invalid poiid + */ + CODE_40098(40098, "invalid poiid"), + + /** + * invalid code, this code has consumed. + */ + CODE_40099(40099, "invalid code, this code has consumed."), + + /** + * invalid DateInfo, Make Sure OldDateInfoType==NewDateInfoType && NewBeginTime<=OldBeginTime && OldEndTime<= NewEndTime + */ + CODE_40100(40100, "invalid DateInfo, Make Sure OldDateInfoType==NewDateInfoType && NewBeginTime<=OldBeginTime && OldEndTime<= NewEndTime"), + + /** + * missing parameter + */ + CODE_40101(40101, "missing parameter"), + + /** + * invalid industry id + */ + CODE_40102(40102, "invalid industry id"), + + /** + * invalid industry index + */ + CODE_40103(40103, "invalid industry index"), + + /** + * invalid category id + */ + CODE_40104(40104, "invalid category id"), + + /** + * invalid view type + */ + CODE_40105(40105, "invalid view type"), + + /** + * invalid user name + */ + CODE_40106(40106, "invalid user name"), + + /** + * invalid card id! 1,card status must verify ok; 2,this card must have location_id + */ + CODE_40107(40107, "invalid card id! 1,card status must verify ok; 2,this card must have location_id"), + + /** + * invalid client version + */ + CODE_40108(40108, "invalid client version"), + + /** + * too many code size, must <= 100 + */ + CODE_40109(40109, "too many code size, must <= 100"), + + /** + * have empty code + */ + CODE_40110(40110, "have empty code"), + + /** + * have same code + */ + CODE_40111(40111, "have same code"), + + /** + * can not set bind openid + */ + CODE_40112(40112, "can not set bind openid"), + + /** + * unsupported file type + */ + CODE_40113(40113, "unsupported file type"), + + /** + * invalid index value + */ + CODE_40114(40114, "invalid index value"), + + /** + * invalid session from + */ + CODE_40115(40115, "invalid session from"), + + /** + * invalid code + */ + CODE_40116(40116, "invalid code"), + + /** + * 分组名字不合法 invalid button media_id size + */ + CODE_40117(40117, "分组名字不合法"), + + /** + * media_id 大小不合法 invalid sub button media_id size + */ + CODE_40118(40118, "media_id 大小不合法"), + + /** + * button 类型错误 invalid use button type + */ + CODE_40119(40119, "button 类型错误"), + + /** + * 子 button 类型错误 invalid use sub button type + */ + CODE_40120(40120, "子 button 类型错误"), + + /** + * 不合法的 media_id 类型 invalid media type in view_limited + */ + CODE_40121(40121, "不合法的 media_id 类型"), + + /** + * invalid card quantity + */ + CODE_40122(40122, "invalid card quantity"), + + /** + * invalid task_id + */ + CODE_40123(40123, "invalid task_id"), + + /** + * too many custom field! + */ + CODE_40124(40124, "too many custom field!"), + + /** + * 不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写 invalid appsecret + */ + CODE_40125(40125, "不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写"), + + /** + * invalid text size + */ + CODE_40126(40126, "invalid text size"), + + /** + * invalid user-card status! Hint: the card was given to user, but may be deleted or expired or set unavailable ! + */ + CODE_40127(40127, "invalid user-card status! Hint: the card was given to user, but may be deleted or expired or set unavailable !"), + + /** + * invalid media id! must be uploaded by api(cgi-bin/material/add_material) + */ + CODE_40128(40128, "invalid media id! must be uploaded by api(cgi-bin/material/add_material)"), + + /** + * invalid scene + */ + CODE_40129(40129, "invalid scene"), + + /** + * invalid openid list size, at least two openid + */ + CODE_40130(40130, "invalid openid list size, at least two openid"), + + /** + * out of limit of ticket + */ + CODE_40131(40131, "out of limit of ticket"), + + /** + * 微信号不合法 invalid username + */ + CODE_40132(40132, "微信号不合法"), + + /** + * invalid encryt data + */ + CODE_40133(40133, "invalid encryt data"), + + /** + * invalid not supply bonus, can not change card_id which supply bonus to be not supply + */ + 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_40136(40136, "invalid use DepositCodeMode, make sure sku.quantity>DepositCode.quantity"), + + /** + * 不支持的图片格式 invalid image format + */ + CODE_40137(40137, "不支持的图片格式"), + + /** + * emphasis word can not be first neither remark + */ + CODE_40138(40138, "emphasis word can not be first neither remark"), + + /** + * invalid sub merchant id + */ + CODE_40139(40139, "invalid sub merchant id"), + + /** + * invalid sub merchant status + */ + CODE_40140(40140, "invalid sub merchant status"), + + /** + * invalid image url + */ + CODE_40141(40141, "invalid image url"), + + /** + * invalid sharecard parameters + */ + CODE_40142(40142, "invalid sharecard parameters"), + + /** + * invalid least cost info, should be 0 + */ + CODE_40143(40143, "invalid least cost info, should be 0"), + + /** + * 1)maybe share_card_list.num or consume_share_self_num too big; 2)maybe card_id_list also has self-card_id;3)maybe card_id_list has many different card_id;4)maybe both consume_share_self_num and share_card_list.num bigger than 0 + */ + CODE_40144(40144, "1)maybe share_card_list.num or consume_share_self_num too big; 2)maybe card_id_list also has self-card_id;3)maybe card_id_list has many different card_id;4)maybe both consume_share_self_num and share_card_list.num bigger than 0"), + + /** + * invalid update! Can not both set PayCell and CenterCellInfo(include: center_title, center_sub_title, center_url). + */ + CODE_40145(40145, "invalid update! Can not both set PayCell and CenterCellInfo(include: center_title, center_sub_title, center_url)."), + + /** + * invalid openid! card may be marked by other user! + */ + CODE_40146(40146, "invalid openid! card may be marked by other user!"), + + /** + * invalid consume! Consume time overranging restricts. + */ + CODE_40147(40147, "invalid consume! Consume time overranging restricts."), + + /** + * invalid friends card type + */ + CODE_40148(40148, "invalid friends card type"), + + /** + * invalid use time limit + */ + CODE_40149(40149, "invalid use time limit"), + + /** + * invalid card parameters + */ + CODE_40150(40150, "invalid card parameters"), + + /** + * invalid card info, text/pic hit antispam + */ + CODE_40151(40151, "invalid card info, text/pic hit antispam"), + + /** + * invalid group id + */ + CODE_40152(40152, "invalid group id"), + + /** + * self consume cell for friends card must need verify code + */ + CODE_40153(40153, "self consume cell for friends card must need verify code"), + + /** + * invalid voip parameters + */ + CODE_40154(40154, "invalid voip parameters"), + + /** + * 请勿添加其他公众号的主页链接 please don't contain other home page url + */ + CODE_40155(40155, "请勿添加其他公众号的主页链接"), + + /** + * invalid face recognize parameters + */ + CODE_40156(40156, "invalid face recognize parameters"), + + /** + * invalid picture, has no face + */ + CODE_40157(40157, "invalid picture, has no face"), + + /** + * invalid use_custom_code, need be false + */ + CODE_40158(40158, "invalid use_custom_code, need be false"), + + /** + * invalid length for path, or the data is not json string + */ + CODE_40159(40159, "invalid length for path, or the data is not json string"), + + /** + * invalid image file + */ + CODE_40160(40160, "invalid image file"), + + /** + * image file not match + */ + CODE_40161(40161, "image file not match"), + + /** + * invalid lifespan + */ + CODE_40162(40162, "invalid lifespan"), + + /** + * oauth_code已使用 code been used + */ + CODE_40163(40163, "oauth_code已使用"), + + /** + * invalid ip, not in whitelist + */ + CODE_40164(40164, "invalid ip, not in whitelist"), + + /** + * invalid weapp pagepath + */ + CODE_40165(40165, "invalid weapp pagepath"), + + /** + * invalid weapp appid + */ + CODE_40166(40166, "invalid weapp appid"), + + /** + * there is no relation with plugin appid + */ + CODE_40167(40167, "there is no relation with plugin appid"), + + /** + * unlinked weapp card + */ + CODE_40168(40168, "unlinked weapp card"), + + /** + * invalid length for scene, or the data is not json string + */ + CODE_40169(40169, "invalid length for scene, or the data is not json string"), + + /** + * args count exceed count limit + */ + CODE_40170(40170, "args count exceed count limit"), + + /** + * product id can not empty and the length cannot exceed 32 + */ + CODE_40171(40171, "product id can not empty and the length cannot exceed 32"), + + /** + * can not have same product id + */ + CODE_40172(40172, "can not have same product id"), + + /** + * there is no bind relation + */ + CODE_40173(40173, "there is no bind relation"), + + /** + * not card user + */ + CODE_40174(40174, "not card user"), + + /** + * invalid material id + */ + CODE_40175(40175, "invalid material id"), + + /** + * invalid template id + */ + CODE_40176(40176, "invalid template id"), + + /** + * invalid product id + */ + CODE_40177(40177, "invalid product id"), + + /** + * invalid sign + */ + CODE_40178(40178, "invalid sign"), + + /** + * Function is adjusted, rules are not allowed to add or update + */ + CODE_40179(40179, "Function is adjusted, rules are not allowed to add or update"), + + /** + * invalid client tmp token + */ + CODE_40180(40180, "invalid client tmp token"), + + /** + * invalid opengid + */ + CODE_40181(40181, "invalid opengid"), + + /** + * invalid pack_id + */ + CODE_40182(40182, "invalid pack_id"), + + /** + * invalid product_appid, product_appid should bind with wxa_appid + */ + CODE_40183(40183, "invalid product_appid, product_appid should bind with wxa_appid"), + + /** + * invalid url path + */ + CODE_40184(40184, "invalid url path"), + + /** + * invalid auth_token, or auth_token is expired + */ + CODE_40185(40185, "invalid auth_token, or auth_token is expired"), + + /** + * invalid delegate + */ + CODE_40186(40186, "invalid delegate"), + + /** + * invalid ip + */ + CODE_40187(40187, "invalid ip"), + + /** + * invalid scope + */ + CODE_40188(40188, "invalid scope"), + + /** + * invalid width + */ + CODE_40189(40189, "invalid width"), + + /** + * invalid delegate time + */ + CODE_40190(40190, "invalid delegate time"), + + /** + * invalid pic_url + */ + CODE_40191(40191, "invalid pic_url"), + + /** + * invalid author in news + */ + CODE_40192(40192, "invalid author in news"), + + /** + * invalid recommend length + */ + CODE_40193(40193, "invalid recommend length"), + + /** + * illegal recommend + */ + CODE_40194(40194, "illegal recommend"), + + /** + * invalid show_num + */ + CODE_40195(40195, "invalid show_num"), + + /** + * invalid smartmsg media_id + */ + CODE_40196(40196, "invalid smartmsg media_id"), + + /** + * invalid smartmsg media num + */ + CODE_40197(40197, "invalid smartmsg media num"), + + /** + * invalid default msg article size, must be same as show_num + */ + CODE_40198(40198, "invalid default msg article size, must be same as show_num"), + + /** + * 运单 ID 不存在,未查到运单 waybill_id not found + */ + CODE_40199(40199, "运单 ID 不存在,未查到运单"), + + /** + * invalid account type + */ + CODE_40200(40200, "invalid account type"), + + /** + * invalid check url + */ + CODE_40201(40201, "invalid check url"), + + /** + * invalid check action + */ + CODE_40202(40202, "invalid check action"), + + /** + * invalid check operator + */ + CODE_40203(40203, "invalid check operator"), + + /** + * can not delete wash or rumor article + */ + CODE_40204(40204, "can not delete wash or rumor article"), + + /** + * invalid check keywords string + */ + CODE_40205(40205, "invalid check keywords string"), + + /** + * invalid check begin stamp + */ + CODE_40206(40206, "invalid check begin stamp"), + + /** + * invalid check alive seconds + */ + CODE_40207(40207, "invalid check alive seconds"), + + /** + * invalid check notify id + */ + CODE_40208(40208, "invalid check notify id"), + + /** + * invalid check notify msg + */ + CODE_40209(40209, "invalid check notify msg"), + + /** + * pages 中的path参数不存在或为空 invalid check wxa path + */ + CODE_40210(40210, "pages 中的path参数不存在或为空"), + + /** + * invalid scope_data + */ + CODE_40211(40211, "invalid scope_data"), + + /** + * paegs 当中存在不合法的query,query格式遵循URL标准,即k1=v1&k2=v2 invalid query + */ + CODE_40212(40212, "paegs 当中存在不合法的query,query格式遵循URL标准,即k1=v1&k2=v2"), + + /** + * invalid href tag + */ + CODE_40213(40213, "invalid href tag"), + + /** + * invalid href text + */ + CODE_40214(40214, "invalid href text"), + + /** + * invalid image count + */ + CODE_40215(40215, "invalid image count"), + + /** + * invalid desc + */ + CODE_40216(40216, "invalid desc"), + + /** + * invalid video count + */ + CODE_40217(40217, "invalid video count"), + + /** + * invalid video id + */ + CODE_40218(40218, "invalid video id"), + + /** + * pages不存在或者参数为空 pages is empty + */ + CODE_40219(40219, "pages不存在或者参数为空"), + + /** + * data_list is empty + */ + CODE_40220(40220, "data_list is empty"), + + /** + * invalid Content-Encoding + */ + CODE_40221(40221, "invalid Content-Encoding"), + + /** + * invalid request idc domain + */ + CODE_40222(40222, "invalid request idc domain"), + + /** + * empty media cover, please check the media + */ + CODE_40229(40229, "媒体封面为空,请添加媒体封面"), + + /** + * 缺少 access_token 参数 access_token missing + */ + CODE_41001(41001, "缺少 access_token 参数"), + + /** + * 缺少 appid 参数 appid missing + */ + CODE_41002(41002, "缺少 appid 参数"), + + /** + * 缺少 refresh_token 参数 refresh_token missing + */ + CODE_41003(41003, "缺少 refresh_token 参数"), + + /** + * 缺少 secret 参数 appsecret missing + */ + CODE_41004(41004, "缺少 secret 参数"), + + /** + * 缺少多媒体文件数据,传输素材无视频或图片内容 media data missing + */ + CODE_41005(41005, "缺少多媒体文件数据,传输素材无视频或图片内容"), + + /** + * 缺少 media_id 参数 media_id missing + */ + CODE_41006(41006, "缺少 media_id 参数"), + + /** + * 缺少子菜单数据 sub_menu data missing + */ + CODE_41007(41007, "缺少子菜单数据"), + + /** + * 缺少 oauth code missing code + */ + CODE_41008(41008, "缺少 oauth code"), + + /** + * 缺少 openid missing openid + */ + CODE_41009(41009, "缺少 openid"), + + /** + * 缺失 url 参数 missing url + */ + CODE_41010(41010, "缺失 url 参数"), + + /** + * missing required fields! please check document and request json! + */ + CODE_41011(41011, "missing required fields! please check document and request json!"), + + /** + * missing card id + */ + CODE_41012(41012, "missing card id"), + + /** + * missing code + */ + CODE_41013(41013, "missing code"), + + /** + * missing ticket_class + */ + CODE_41014(41014, "missing ticket_class"), + + /** + * missing show_time + */ + CODE_41015(41015, "missing show_time"), + + /** + * missing screening_room + */ + CODE_41016(41016, "missing screening_room"), + + /** + * missing seat_number + */ + CODE_41017(41017, "missing seat_number"), + + /** + * missing component_appid + */ + CODE_41018(41018, "missing component_appid"), + + /** + * missing platform_secret + */ + CODE_41019(41019, "missing platform_secret"), + + /** + * missing platform_ticket + */ + CODE_41020(41020, "missing platform_ticket"), + + /** + * missing component_access_token + */ + CODE_41021(41021, "missing component_access_token"), + + /** + * missing "display" field + */ + CODE_41024(41024, "missing \"display\" field"), + + /** + * poi_list empty + */ + CODE_41025(41025, "poi_list empty"), + + /** + * missing image list info, text maybe empty + */ + CODE_41026(41026, "missing image list info, text maybe empty"), + + /** + * missing voip call key + */ + CODE_41027(41027, "missing voip call key"), + + /** + * invalid form id + */ + CODE_41028(41028, "invalid form id"), + + /** + * form id used count reach limit + */ + CODE_41029(41029, "form id used count reach limit"), + + /** + * page路径不正确,需要保证在现网版本小程序中存在,与app.json保持一致 invalid page + */ + CODE_41030(41030, "page路径不正确,需要保证在现网版本小程序中存在,与app.json保持一致"), + + /** + * the form id have been blocked! + */ + CODE_41031(41031, "the form id have been blocked!"), + + /** + * not allow to send message with submitted form id, for punishment + */ + CODE_41032(41032, "not allow to send message with submitted form id, for punishment"), + + /** + * 只允许通过api创建的小程序使用 invaid register type + */ + CODE_41033(41033, "只允许通过api创建的小程序使用"), + + /** + * not allow to send message with submitted form id, for punishment + */ + CODE_41034(41034, "not allow to send message with submitted form id, for punishment"), + + /** + * not allow to send message with prepay id, for punishment + */ + CODE_41035(41035, "not allow to send message with prepay id, for punishment"), + + /** + * appid ad cid + */ + CODE_41036(41036, "appid ad cid"), + + /** + * appid ad_mch_appid + */ + CODE_41037(41037, "appid ad_mch_appid"), + + /** + * appid pos_type + */ + CODE_41038(41038, "appid pos_type"), + + /** + * access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明 access_token expired + */ + CODE_42001(42001, "access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明"), + + /** + * refresh_token 超时 refresh_token expired + */ + CODE_42002(42002, "refresh_token 超时"), + + /** + * oauth_code 超时 code expired + */ + CODE_42003(42003, "oauth_code 超时"), + + /** + * plugin token expired + */ + CODE_42004(42004, "plugin token expired"), + + /** + * api usage expired + */ + CODE_42005(42005, "api usage expired"), + + /** + * component_access_token expired + */ + CODE_42006(42006, "component_access_token expired"), + + /** + * 用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权 access_token and refresh_token exception + */ + CODE_42007(42007, "用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权"), + + /** + * voip call key expired + */ + CODE_42008(42008, "voip call key expired"), + + /** + * client tmp token expired + */ + CODE_42009(42009, "client tmp token expired"), + + /** + * 需要 GET 请求 require GET method + */ + CODE_43001(43001, "需要 GET 请求"), + + /** + * 需要 POST 请求 require POST method + */ + CODE_43002(43002, "需要 POST 请求"), + + /** + * 需要 HTTPS 请求 require https + */ + CODE_43003(43003, "需要 HTTPS 请求"), + + /** + * 需要接收者关注 require subscribe + */ + CODE_43004(43004, "需要接收者关注"), + + /** + * 需要好友关系 require friend relations + */ + CODE_43005(43005, "需要好友关系"), + + /** + * require not block + */ + CODE_43006(43006, "require not block"), + + /** + * require bizuser authorize + */ + CODE_43007(43007, "require bizuser authorize"), + + /** + * require biz pay auth + */ + CODE_43008(43008, "require biz pay auth"), + + /** + * can not use custom code, need authorize + */ + CODE_43009(43009, "can not use custom code, need authorize"), + + /** + * can not use balance, need authorize + */ + CODE_43010(43010, "can not use balance, need authorize"), + + /** + * can not use bonus, need authorize + */ + CODE_43011(43011, "can not use bonus, need authorize"), + + /** + * can not use custom url, need authorize + */ + CODE_43012(43012, "can not use custom url, need authorize"), + + /** + * can not use shake card, need authorize + */ + CODE_43013(43013, "can not use shake card, need authorize"), + + /** + * require check agent + */ + CODE_43014(43014, "require check agent"), + + /** + * require authorize by wechat team to use this function! + */ + CODE_43015(43015, "require authorize by wechat team to use this function!"), + + /** + * 小程序未认证 require verify + */ + CODE_43016(43016, "小程序未认证"), + + /** + * require location id! + */ + CODE_43017(43017, "require location id!"), + + /** + * code has no been mark! + */ + CODE_43018(43018, "code has no been mark!"), + + /** + * 需要将接收者从黑名单中移除 require remove blacklist + */ + CODE_43019(43019, "需要将接收者从黑名单中移除"), + + /** + * change template too frequently + */ + CODE_43100(43100, "change template too frequently"), + + /** + * 用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系 user refuse to accept the msg + */ + CODE_43101(43101, "用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系"), + + /** + * the tempalte is not subscriptiontype + */ + CODE_43102(43102, "the tempalte is not subscriptiontype"), + + /** + * the api only can cancel the subscription + */ + CODE_43103(43103, "the api only can cancel the subscription"), + + /** + * this appid does not have permission + */ + CODE_43104(43104, "this appid does not have permission"), + + /** + * news has no binding relation with template_id + */ + CODE_43105(43105, "news has no binding relation with template_id"), + + /** + * not allow to add template, for punishment + */ + CODE_43106(43106, "not allow to add template, for punishment"), + + /** + * 多媒体文件为空 empty media data + */ + CODE_44001(44001, "多媒体文件为空"), + + /** + * POST 的数据包为空 empty post data + */ + CODE_44002(44002, "POST 的数据包为空"), + + /** + * 图文消息内容为空 empty news data + */ + CODE_44003(44003, "图文消息内容为空"), + + /** + * 文本消息内容为空 empty content + */ + CODE_44004(44004, "文本消息内容为空"), + + /** + * 空白的列表 empty list size + */ + CODE_44005(44005, "空白的列表"), + + /** + * empty file data + */ + CODE_44006(44006, "empty file data"), + + /** + * repeated msg id + */ + CODE_44007(44007, "repeated msg id"), + + /** + * image url size out of limit + */ + CODE_44997(44997, "image url size out of limit"), + + /** + * keyword string media size out of limit + */ + CODE_44998(44998, "keyword string media size out of limit"), + + /** + * keywords list size out of limit + */ + CODE_44999(44999, "keywords list size out of limit"), + + /** + * msg_id size out of limit + */ + CODE_45000(45000, "msg_id size out of limit"), + + /** + * 多媒体文件大小超过限制 media size out of limit + */ + CODE_45001(45001, "多媒体文件大小超过限制"), + + /** + * 消息内容超过限制 content size out of limit + */ + CODE_45002(45002, "消息内容超过限制"), + + /** + * 标题字段超过限制 title size out of limit + */ + CODE_45003(45003, "标题字段超过限制"), + + /** + * 描述字段超过限制 description size out of limit + */ + CODE_45004(45004, "描述字段超过限制"), + + /** + * 链接字段超过限制 url size out of limit + */ + CODE_45005(45005, "链接字段超过限制"), + + /** + * 图片链接字段超过限制 picurl size out of limit + */ + CODE_45006(45006, "图片链接字段超过限制"), + + /** + * 语音播放时间超过限制 playtime out of limit + */ + CODE_45007(45007, "语音播放时间超过限制"), + + /** + * 图文消息超过限制 article size out of limit + */ + CODE_45008(45008, "图文消息超过限制"), + + /** + * 接口调用超过限制 reach max api daily quota limit + */ + CODE_45009(45009, "接口调用超过限制"), + + /** + * 创建菜单个数超过限制 create menu limit + */ + CODE_45010(45010, "创建菜单个数超过限制"), + + /** + * API 调用太频繁,请稍候再试 api minute-quota reach limit, must slower, retry next minute + */ + CODE_45011(45011, "API 调用太频繁,请稍候再试"), + + /** + * 模板大小超过限制 template size out of limit + */ + CODE_45012(45012, "模板大小超过限制"), + + /** + * too many template args + */ + CODE_45013(45013, "too many template args"), + + /** + * template message size out of limit + */ + CODE_45014(45014, "template message size out of limit"), + + /** + * 回复时间超过限制 response out of time limit or subscription is canceled + */ + CODE_45015(45015, "回复时间超过限制"), + + /** + * 系统分组,不允许修改 can't modify sys group + */ + CODE_45016(45016, "系统分组,不允许修改"), + + /** + * 分组名字过长 can't set group name too long sys group + */ + CODE_45017(45017, "分组名字过长"), + + /** + * 分组数量超过上限 too many group now, no need to add new + */ + CODE_45018(45018, "分组数量超过上限"), + + /** + * too many openid, please input less + */ + CODE_45019(45019, "too many openid, please input less"), + + /** + * too many image, please input less + */ + CODE_45020(45020, "too many image, please input less"), + + /** + * some argument may be out of length limit! please check document and request json! + */ + CODE_45021(45021, "some argument may be out of length limit! please check document and request json!"), + + /** + * bonus is out of limit + */ + CODE_45022(45022, "bonus is out of limit"), + + /** + * balance is out of limit + */ + CODE_45023(45023, "balance is out of limit"), + + /** + * rank template number is out of limit + */ + CODE_45024(45024, "rank template number is out of limit"), + + /** + * poiid count is out of limit + */ + CODE_45025(45025, "poiid count is out of limit"), + + /** + * template num exceeds limit + */ + CODE_45026(45026, "template num exceeds limit"), + + /** + * template conflict with industry + */ + CODE_45027(45027, "template conflict with industry"), + + /** + * has no masssend quota + */ + CODE_45028(45028, "has no masssend quota"), + + /** + * qrcode count out of limit + */ + CODE_45029(45029, "qrcode count out of limit"), + + /** + * limit cardid, not support this function + */ + CODE_45030(45030, "limit cardid, not support this function"), + + /** + * stock is out of limit + */ + CODE_45031(45031, "stock is out of limit"), + + /** + * not inner ip for special acct in white-list + */ + CODE_45032(45032, "not inner ip for special acct in white-list"), + + /** + * user get card num is out of get_limit + */ + CODE_45033(45033, "user get card num is out of get_limit"), + + /** + * media file count is out of limit + */ + CODE_45034(45034, "media file count is out of limit"), + + /** + * access clientip is not registered, not in ip-white-list + */ + CODE_45035(45035, "access clientip is not registered, not in ip-white-list"), + + /** + * User receive announcement limit + */ + CODE_45036(45036, "User receive announcement limit"), + + /** + * user out of time limit or never talked in tempsession + */ + CODE_45037(45037, "user out of time limit or never talked in tempsession"), + + /** + * user subscribed, cannot use tempsession api + */ + CODE_45038(45038, "user subscribed, cannot use tempsession api"), + + /** + * card_list_size out of limit + */ + CODE_45039(45039, "card_list_size out of limit"), + + /** + * reach max monthly quota limit + */ + CODE_45040(45040, "reach max monthly quota limit"), + + /** + * this card reach total sku quantity limit! + */ + CODE_45041(45041, "this card reach total sku quantity limit!"), + + /** + * limit card type, this card type can NOT create by sub merchant + */ + CODE_45042(45042, "limit card type, this card type can NOT create by sub merchant"), + + /** + * can not set share_friends=true because has no Abstract Or Text_Img_List has no img Or image url not valid + */ + CODE_45043(45043, "can not set share_friends=true because has no Abstract Or Text_Img_List has no img Or image url not valid"), + + /** + * icon url size in abstract is out of limit + */ + CODE_45044(45044, "icon url size in abstract is out of limit"), + + /** + * unauthorized friends card, please contact administrator + */ + CODE_45045(45045, "unauthorized friends card, please contact administrator"), + + /** + * operate field conflict, CenterCell, PayCell, SelfConsumeCell conflict + */ + CODE_45046(45046, "operate field conflict, CenterCell, PayCell, SelfConsumeCell conflict"), + + /** + * 客服接口下行条数超过上限 out of response count limit + */ + CODE_45047(45047, "客服接口下行条数超过上限"), + + /** + * menu use invalid type + */ + CODE_45048(45048, "menu use invalid type"), + + /** + * ivr use invalid type + */ + CODE_45049(45049, "ivr use invalid type"), + + /** + * custom msg use invalid type + */ + CODE_45050(45050, "custom msg use invalid type"), + + /** + * template msg use invalid link + */ + CODE_45051(45051, "template msg use invalid link"), + + /** + * masssend msg use invalid type + */ + CODE_45052(45052, "masssend msg use invalid type"), + + /** + * exceed consume verify code size + */ + CODE_45053(45053, "exceed consume verify code size"), + + /** + * below consume verify code size + */ + CODE_45054(45054, "below consume verify code size"), + + /** + * the code is not in consume verify code charset + */ + CODE_45055(45055, "the code is not in consume verify code charset"), + + /** + * too many tag now, no need to add new + */ + CODE_45056(45056, "too many tag now, no need to add new"), + + /** + * can't delete the tag that has too many fans + */ + CODE_45057(45057, "can't delete the tag that has too many fans"), + + /** + * can't modify sys tag + */ + CODE_45058(45058, "can't modify sys tag"), + + /** + * can not tagging one user too much + */ + CODE_45059(45059, "can not tagging one user too much"), + + /** + * media is applied in ivr or menu, can not be deleted + */ + CODE_45060(45060, "media is applied in ivr or menu, can not be deleted"), + + /** + * maybe the update frequency is too often, please try again + */ + CODE_45061(45061, "maybe the update frequency is too often, please try again"), + + /** + * has agreement ad. please use mp.weixin.qq.com + */ + CODE_45062(45062, "has agreement ad. please use mp.weixin.qq.com"), + + /** + * accesstoken is not xiaochengxu + */ + CODE_45063(45063, "accesstoken is not xiaochengxu"), + + /** + * 创建菜单包含未关联的小程序 no permission to use weapp in menu + */ + CODE_45064(45064, "创建菜单包含未关联的小程序"), + + /** + * 相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid clientmsgid exist + */ + CODE_45065(45065, "相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid"), + + /** + * 相同 clientmsgid 重试速度过快,请间隔1分钟重试 same clientmsgid retry too fast + */ + CODE_45066(45066, "相同 clientmsgid 重试速度过快,请间隔1分钟重试"), + + /** + * clientmsgid 长度超过限制 clientmsgid size out of limit + */ + CODE_45067(45067, "clientmsgid 长度超过限制"), + + /** + * file size out of limit + */ + CODE_45068(45068, "file size out of limit"), + + /** + * product list size out of limit + */ + CODE_45069(45069, "product list size out of limit"), + + /** + * the business account have been created + */ + CODE_45070(45070, "the business account have been created"), + + /** + * business account not found + */ + CODE_45071(45071, "business account not found"), + + /** + * command字段取值不对 invalid command + */ + CODE_45072(45072, "command字段取值不对"), + + /** + * not inner vip for sns in white list + */ + CODE_45073(45073, "not inner vip for sns in white list"), + + /** + * material list size out of limit, you should delete the useless material + */ + CODE_45074(45074, "material list size out of limit, you should delete the useless material"), + + /** + * invalid keyword id + */ + CODE_45075(45075, "invalid keyword id"), + + /** + * invalid count + */ + CODE_45076(45076, "invalid count"), + + /** + * number of business account reach limit + */ + CODE_45077(45077, "number of business account reach limit"), + + /** + * nickname is illegal! + */ + CODE_45078(45078, "nickname is illegal!"), + + /** + * nickname is forbidden!(matched forbidden keyword) + */ + CODE_45079(45079, "nickname is forbidden!(matched forbidden keyword)"), + + /** + * 下发输入状态,需要之前30秒内跟用户有过消息交互 need sending message to user, or recving message from user in the last 30 seconds before typing + */ + CODE_45080(45080, "下发输入状态,需要之前30秒内跟用户有过消息交互"), + + /** + * 已经在输入状态,不可重复下发 you are already typing + */ + CODE_45081(45081, "已经在输入状态,不可重复下发"), + + /** + * need icp license for the url domain + */ + CODE_45082(45082, "need icp license for the url domain"), + + /** + * the speed out of range + */ + CODE_45083(45083, "the speed out of range"), + + /** + * No speed message + */ + CODE_45084(45084, "No speed message"), + + /** + * speed server err + */ + CODE_45085(45085, "speed server err"), + + /** + * invalid attrbute 'data-miniprogram-appid' + */ + CODE_45086(45086, "invalid attrbute 'data-miniprogram-appid'"), + + /** + * customer service message from this account have been blocked! + */ + CODE_45087(45087, "customer service message from this account have been blocked!"), + + /** + * action size out of limit + */ + CODE_45088(45088, "action size out of limit"), + + /** + * expired + */ + CODE_45089(45089, "expired"), + + /** + * invalid group msg ticket + */ + CODE_45090(45090, "invalid group msg ticket"), + + /** + * account_name is illegal! + */ + CODE_45091(45091, "account_name is illegal!"), + + /** + * no voice data + */ + CODE_45092(45092, "no voice data"), + + /** + * no quota to send msg + */ + CODE_45093(45093, "no quota to send msg"), + + /** + * not allow to send custom message when user enter session, for punishment + */ + CODE_45094(45094, "not allow to send custom message when user enter session, for punishment"), + + /** + * not allow to modify stock for the advertisement batch + */ + CODE_45095(45095, "not allow to modify stock for the advertisement batch"), + + /** + * invalid qrcode + */ + CODE_45096(45096, "invalid qrcode"), + + /** + * invalid qrcode prefix + */ + CODE_45097(45097, "invalid qrcode prefix"), + + /** + * msgmenu list size is out of limit + */ + CODE_45098(45098, "msgmenu list size is out of limit"), + + /** + * msgmenu item content size is out of limit + */ + CODE_45099(45099, "msgmenu item content size is out of limit"), + + /** + * invalid size of keyword_id_list + */ + CODE_45100(45100, "invalid size of keyword_id_list"), + + /** + * hit upload limit + */ + CODE_45101(45101, "hit upload limit"), + + /** + * this api have been blocked temporarily. + */ + CODE_45102(45102, "this api have been blocked temporarily."), + + /** + * This API has been unsupported + */ + CODE_45103(45103, "This API has been unsupported"), + + /** + * reach max domain quota limit + */ + CODE_45104(45104, "reach max domain quota limit"), + + /** + * the consume verify code not found + */ + CODE_45154(45154, "the consume verify code not found"), + + /** + * the consume verify code is existed + */ + CODE_45155(45155, "the consume verify code is existed"), + + /** + * the consume verify code's length not invalid + */ + CODE_45156(45156, "the consume verify code's length not invalid"), + + /** + * invalid tag name + */ + CODE_45157(45157, "invalid tag name"), + + /** + * tag name too long + */ + CODE_45158(45158, "tag name too long"), + + /** + * invalid tag id + */ + CODE_45159(45159, "invalid tag id"), + + /** + * invalid category to create card + */ + CODE_45160(45160, "invalid category to create card"), + + /** + * this video id must be generated by calling upload api + */ + CODE_45161(45161, "this video id must be generated by calling upload api"), + + /** + * invalid type + */ + CODE_45162(45162, "invalid type"), + + /** + * invalid sort_method + */ + CODE_45163(45163, "invalid sort_method"), + + /** + * invalid offset + */ + CODE_45164(45164, "invalid offset"), + + /** + * invalid limit + */ + CODE_45165(45165, "invalid limit"), + + /** + * invalid content + */ + CODE_45166(45166, "invalid content"), + + /** + * invalid voip call key + */ + CODE_45167(45167, "invalid voip call key"), + + /** + * keyword in blacklist + */ + CODE_45168(45168, "keyword in blacklist"), + + /** + * part or whole of the requests from the very app is temporary blocked by supervisor + */ + CODE_45501(45501, "part or whole of the requests from the very app is temporary blocked by supervisor"), + + /** + * 不存在媒体数据,media_id 不存在 media data no exist + */ + CODE_46001(46001, "不存在媒体数据,media_id 不存在"), + + /** + * 不存在的菜单版本 menu version no exist + */ + CODE_46002(46002, "不存在的菜单版本"), + + /** + * 不存在的菜单数据 menu no exist + */ + CODE_46003(46003, "不存在的菜单数据"), + + /** + * 不存在的用户 user no exist + */ + CODE_46004(46004, "不存在的用户"), + + /** + * poi no exist + */ + CODE_46005(46005, "poi no exist"), + + /** + * voip file not exist + */ + CODE_46006(46006, "voip file not exist"), + + /** + * file being transcoded, please try later + */ + CODE_46007(46007, "file being transcoded, please try later"), + + /** + * result id not exist + */ + CODE_46008(46008, "result id not exist"), + + /** + * there is no user data + */ + CODE_46009(46009, "there is no user data"), + + /** + * this api have been not supported since 2020-01-11 00:00:00, please use new api(subscribeMessage)! + */ + CODE_46101(46101, "this api have been not supported since 2020-01-11 00:00:00, please use new api(subscribeMessage)!"), + + /** + * 解析 JSON/XML 内容错误 data format error + */ + CODE_47001(47001, "解析 JSON/XML 内容错误"), + + /** + * data format error, do NOT use json unicode encode (\\uxxxx\\uxxxx), please use utf8 encoded text! + */ + CODE_47002(47002, "data format error, do NOT use json unicode encode (\\uxxxx\\uxxxx), please use utf8 encoded text!"), + + /** + * 模板参数不准确,可能为空或者不满足规则,errmsg会提示具体是哪个字段出错 argument invalid! + */ + CODE_47003(47003, "模板参数不准确,可能为空或者不满足规则,errmsg会提示具体是哪个字段出错"), + + /** + * 每次提交的页面数超过1000(备注:每次提交页面数应小于或等于1000) submit pages count more than each quota + */ + CODE_47004(47004, "每次提交的页面数超过1000(备注:每次提交页面数应小于或等于1000)"), + + /** + * tabbar no exist + */ + CODE_47005(47005, "tabbar no exist"), + + /** + * 当天提交页面数达到了配额上限,请明天再试 submit pages count reach daily limit, please try tomorrow + */ + CODE_47006(47006, "当天提交页面数达到了配额上限,请明天再试"), + + /** + * 搜索结果总数超过了1000条 search results count more than limit + */ + CODE_47101(47101, "搜索结果总数超过了1000条"), + + /** + * next_page_info参数错误 next_page_info error + */ + CODE_47102(47102, "next_page_info参数错误"), + + /** + * 参数 activity_id 错误 activity_id error + */ + CODE_47501(47501, "参数 activity_id 错误"), + + /** + * 参数 target_state 错误 target_state error + */ + CODE_47502(47502, "参数 target_state 错误"), + + /** + * 参数 version_type 错误 version_type error + */ + CODE_47503(47503, "参数 version_type 错误"), + + /** + * activity_id activity_id expired time + */ + CODE_47504(47504, "activity_id"), + + /** + * api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限 api unauthorized + */ + CODE_48001(48001, "api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限"), + + /** + * 粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” ) user block receive message + */ + CODE_48002(48002, "粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” )"), + + /** + * user not agree mass-send protocol + */ + CODE_48003(48003, "user not agree mass-send protocol"), + + /** + * api 接口被封禁,请登录 mp.weixin.qq.com 查看详情 api forbidden for irregularities, view detail on mp.weixin.qq.com + */ + CODE_48004(48004, "api 接口被封禁,请登录 mp.weixin.qq.com 查看详情"), + + /** + * api 禁止删除被自动回复和自定义菜单引用的素材 forbid to delete material used by auto-reply or menu + */ + CODE_48005(48005, "api 禁止删除被自动回复和自定义菜单引用的素材"), + + /** + * api 禁止清零调用次数,因为清零次数达到上限 forbid to clear quota because of reaching the limit + */ + CODE_48006(48006, "api 禁止清零调用次数,因为清零次数达到上限"), + + /** + * forbid to use other's voip call key + */ + CODE_48007(48007, "forbid to use other's voip call key"), + + /** + * 没有该类型消息的发送权限 no permission for this msgtype + */ + CODE_48008(48008, "没有该类型消息的发送权限"), + + /** + * this api is expired + */ + CODE_48009(48009, "this api is expired"), + + /** + * forbid to modify the material, please see more information on mp.weixin.qq.com + */ + CODE_48010(48010, "forbid to modify the material, please see more information on mp.weixin.qq.com"), + + /** + * disabled template id + */ + CODE_48011(48011, "disabled template id"), + + /** + * invalid token + */ + CODE_48012(48012, "invalid token"), + + /** + * 该视频非新接口上传,不能用于视频消息群发 + */ + CODE_48013(48013, "该视频非新接口上传,不能用于视频消息群发"), + + /** + * 该视频审核状态异常,请检查后重试 + */ + CODE_48014(48014, "该视频审核状态异常,请检查后重试"), + + /** + * 该账号无留言功能权限 + */ + CODE_48015(48015, "该账号无留言功能权限"), + + /** + * 该账号不满足智能配置"观看更多"视频条件 + */ + CODE_48016(48016, "该账号不满足智能配置\"观看更多\"视频条件"), + + /** + * not same appid with appid of access_token + */ + CODE_49001(49001, "not same appid with appid of access_token"), + + /** + * empty openid or transid + */ + CODE_49002(49002, "empty openid or transid"), + + /** + * not match openid with appid + */ + CODE_49003(49003, "not match openid with appid"), + + /** + * not match signature + */ + CODE_49004(49004, "not match signature"), + + /** + * not existed transid + */ + CODE_49005(49005, "not existed transid"), + + /** + * missing arg two_dim_code + */ + CODE_49006(49006, "missing arg two_dim_code"), + + /** + * invalid two_dim_code + */ + CODE_49007(49007, "invalid two_dim_code"), + + /** + * invalid qrcode + */ + CODE_49008(49008, "invalid qrcode"), + + /** + * missing arg qrcode + */ + CODE_49009(49009, "missing arg qrcode"), + + /** + * invalid partner id + */ + CODE_49010(49010, "invalid partner id"), + + /** + * not existed feedbackid + */ + CODE_49300(49300, "not existed feedbackid"), + + /** + * feedback exist + */ + CODE_49301(49301, "feedback exist"), + + /** + * feedback status already changed + */ + CODE_49302(49302, "feedback status already changed"), + + /** + * 用户未授权该 api api unauthorized or user unauthorized + */ + CODE_50001(50001, "用户未授权该 api"), + + /** + * 用户受限,可能是用户帐号被冻结或注销 user limited + */ + CODE_50002(50002, "用户受限,可能是用户帐号被冻结或注销"), + + /** + * user unexpected, maybe not in white list + */ + CODE_50003(50003, "user unexpected, maybe not in white list"), + + /** + * user not allow to use accesstoken, maybe for punishment + */ + CODE_50004(50004, "user not allow to use accesstoken, maybe for punishment"), + + /** + * 用户未关注公众号 user is unsubscribed + */ + CODE_50005(50005, "用户未关注公众号"), + + /** + * user has switched off friends authorization + */ + CODE_50006(50006, "user has switched off friends authorization"), + + /** + * enterprise father account not exist + */ + CODE_51000(51000, "enterprise father account not exist"), + + /** + * enterprise child account not belong to the father + */ + CODE_51001(51001, "enterprise child account not belong to the father"), + + /** + * enterprise verify message not correct + */ + CODE_51002(51002, "enterprise verify message not correct"), + + /** + * invalid enterprise child list size + */ + CODE_51003(51003, "invalid enterprise child list size"), + + /** + * not a enterprise father account + */ + CODE_51004(51004, "not a enterprise father account"), + + /** + * not a enterprise child account + */ + CODE_51005(51005, "not a enterprise child account"), + + /** + * invalid nick name + */ + CODE_51006(51006, "invalid nick name"), + + /** + * not a enterprise account + */ + CODE_51007(51007, "not a enterprise account"), + + /** + * invalid email + */ + CODE_51008(51008, "invalid email"), + + /** + * invalid pwd + */ + CODE_51009(51009, "invalid pwd"), + + /** + * repeated email + */ + CODE_51010(51010, "repeated email"), + + /** + * access deny + */ + CODE_51011(51011, "access deny"), + + /** + * need verify code + */ + CODE_51012(51012, "need verify code"), + + /** + * wrong verify code + */ + CODE_51013(51013, "wrong verify code"), + + /** + * need modify pwd + */ + CODE_51014(51014, "need modify pwd"), + + /** + * user not exist + */ + CODE_51015(51015, "user not exist"), + + /** + * tv info not exist + */ + CODE_51020(51020, "tv info not exist"), + + /** + * stamp crossed + */ + CODE_51021(51021, "stamp crossed"), + + /** + * invalid stamp range + */ + CODE_51022(51022, "invalid stamp range"), + + /** + * stamp not match date + */ + CODE_51023(51023, "stamp not match date"), + + /** + * empty program name + */ + CODE_51024(51024, "empty program name"), + + /** + * empty action url + */ + CODE_51025(51025, "empty action url"), + + /** + * program name size out of limit + */ + CODE_51026(51026, "program name size out of limit"), + + /** + * action url size out of limit + */ + CODE_51027(51027, "action url size out of limit"), + + /** + * invalid program name + */ + CODE_51028(51028, "invalid program name"), + + /** + * invalid action url + */ + CODE_51029(51029, "invalid action url"), + + /** + * invalid action id + */ + CODE_51030(51030, "invalid action id"), + + /** + * invalid action offset + */ + CODE_51031(51031, "invalid action offset"), + + /** + * empty action title + */ + CODE_51032(51032, "empty action title"), + + /** + * action title size out of limit + */ + CODE_51033(51033, "action title size out of limit"), + + /** + * empty action icon url + */ + CODE_51034(51034, "empty action icon url"), + + /** + * action icon url out of limit + */ + CODE_51035(51035, "action icon url out of limit"), + + /** + * pic is not from cdn + */ + CODE_52000(52000, "pic is not from cdn"), + + /** + * wechat price is not less than origin price + */ + CODE_52001(52001, "wechat price is not less than origin price"), + + /** + * category/sku is wrong + */ + CODE_52002(52002, "category/sku is wrong"), + + /** + * product id not existed + */ + CODE_52003(52003, "product id not existed"), + + /** + * category id is not exist, or doesn't has sub category + */ + CODE_52004(52004, "category id is not exist, or doesn't has sub category"), + + /** + * quantity is zero + */ + CODE_52005(52005, "quantity is zero"), + + /** + * area code is invalid + */ + CODE_52006(52006, "area code is invalid"), + + /** + * express template param is error + */ + CODE_52007(52007, "express template param is error"), + + /** + * express template id is not existed + */ + CODE_52008(52008, "express template id is not existed"), + + /** + * group name is empty + */ + CODE_52009(52009, "group name is empty"), + + /** + * group id is not existed + */ + CODE_52010(52010, "group id is not existed"), + + /** + * mod_action is invalid + */ + CODE_52011(52011, "mod_action is invalid"), + + /** + * shelf components count is greater than 20 + */ + CODE_52012(52012, "shelf components count is greater than 20"), + + /** + * shelf component is empty + */ + CODE_52013(52013, "shelf component is empty"), + + /** + * shelf id is not existed + */ + CODE_52014(52014, "shelf id is not existed"), + + /** + * order id is not existed + */ + CODE_52015(52015, "order id is not existed"), + + /** + * order filter param is invalid + */ + CODE_52016(52016, "order filter param is invalid"), + + /** + * order express param is invalid + */ + CODE_52017(52017, "order express param is invalid"), + + /** + * order delivery param is invalid + */ + CODE_52018(52018, "order delivery param is invalid"), + + /** + * brand name empty + */ + CODE_52019(52019, "brand name empty"), + + /** + * principal limit exceed + */ + CODE_53000(53000, "principal limit exceed"), + + /** + * principal in black list + */ + CODE_53001(53001, "principal in black list"), + + /** + * mobile limit exceed + */ + CODE_53002(53002, "mobile limit exceed"), + + /** + * idcard limit exceed + */ + CODE_53003(53003, "idcard limit exceed"), + + /** + * 名称格式不合法 nickname invalid + */ + CODE_53010(53010, "名称格式不合法"), + + /** + * 名称检测命中频率限制 check nickname too frequently + */ + CODE_53011(53011, "名称检测命中频率限制"), + + /** + * 禁止使用该名称 nickname ban + */ + CODE_53012(53012, "禁止使用该名称"), + + /** + * 公众号:名称与已有公众号名称重复;小程序:该名称与已有小程序名称重复 nickname has been occupied + */ + CODE_53013(53013, "公众号:名称与已有公众号名称重复;小程序:该名称与已有小程序名称重复"), + + /** + * 公众号:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A} + */ + CODE_53014(53014, "公众号:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A}"), + + /** + * 公众号:该名称与已有小程序名称重复,需与该小程序帐号相同主体才可申请;小程序:该名称与已有公众号名称重复,需与该公众号帐号相同主体才可申请 + */ + CODE_53015(53015, "公众号:该名称与已有小程序名称重复,需与该小程序帐号相同主体才可申请;小程序:该名称与已有公众号名称重复,需与该公众号帐号相同主体才可申请"), + + /** + * 公众号:该名称与已有多个小程序名称重复,暂不支持申请;小程序:该名称与已有多个公众号名称重复,暂不支持申请 + */ + CODE_53016(53016, "公众号:该名称与已有多个小程序名称重复,暂不支持申请;小程序:该名称与已有多个公众号名称重复,暂不支持申请"), + + /** + * 公众号:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A} + */ + CODE_53017(53017, "公众号:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A}"), + + /** + * 名称命中微信号 nickname hit alias + */ + CODE_53018(53018, "名称命中微信号"), + + /** + * 名称在保护期内 nickname protected by infringement + */ + CODE_53019(53019, "名称在保护期内"), + + /** + * order not found + */ + CODE_53100(53100, "订单不存在"), + + /** + * order already paid + */ + CODE_53101(53101, "已经支付的订单"), + + /** + * already has checking order, can not apply + */ + CODE_53102(53102, "已有检查单,不能申请"), + + /** + * order can not do refill + */ + CODE_53103(53103, "order can not do refill"), + + /** + * 本月功能介绍修改次数已用完 modify signature quota limit exceed + */ + CODE_53200(53200, "本月功能介绍修改次数已用完"), + + /** + * 功能介绍内容命中黑名单关键字 signature in black list, can not use + */ + CODE_53201(53201, "功能介绍内容命中黑名单关键字"), + + /** + * 本月头像修改次数已用完 modify avatar quota limit exceed + */ + CODE_53202(53202, "本月头像修改次数已用完"), + + /** + * can't be modified for the time being + */ + CODE_53203(53203, "暂时还不能修改"), + + /** + * signature invalid + */ + CODE_53204(53204, "无效签名"), + + /** + * 超出每月次数限制 + */ + CODE_53300(53300, "超出每月次数限制"), + + /** + * 超出可配置类目总数限制 + */ + CODE_53301(53301, "超出可配置类目总数限制"), + + /** + * 当前账号主体类型不允许设置此种类目 + */ + CODE_53302(53302, "当前账号主体类型不允许设置此种类目"), + + /** + * 提交的参数不合法 + */ + CODE_53303(53303, "提交的参数不合法"), + + /** + * 与已有类目重复 + */ + CODE_53304(53304, "与已有类目重复"), + + /** + * 包含未通过IPC校验的类目 + */ + CODE_53305(53305, "包含未通过IPC校验的类目"), + + /** + * 修改类目只允许修改类目资质,不允许修改类目ID + */ + CODE_53306(53306, "修改类目只允许修改类目资质,不允许修改类目ID"), + + /** + * 只有审核失败的类目允许修改 + */ + CODE_53307(53307, "只有审核失败的类目允许修改"), + + /** + * 审核中的类目不允许删除 + */ + CODE_53308(53308, "审核中的类目不允许删除"), + + /** + * 社交红包不允许删除 + */ + CODE_53309(53309, "社交红包不允许删除"), + + /** + * 类目超过上限,但是可以添加apply_reason参数申请更多类目 + */ + CODE_53310(53310, "类目超过上限,但是可以添加apply_reason参数申请更多类目"), + + /** + * 需要提交资料信息 + */ + CODE_53311(53311, "需要提交资料信息"), + + /** + * empty jsapi name + */ + CODE_60005(60005, "空的jsapi名称"), + + /** + * user cancel the auth + */ + CODE_60006(60006, "用户取消该授权"), + + /** + * invalid component type + */ + CODE_61000(61000, "无效的第三方类型"), + + /** + * component type and component appid is not match + */ + CODE_61001(61001, "第三方类型与第三方APPID不匹配"), + + /** + * the third appid is not open KF + */ + CODE_61002(61002, "第三方APPID没有开放客服"), + + /** + * component is not authorized by this account + */ + CODE_61003(61003, "帐号未授权"), + + /** + * api 功能未授权,请确认公众号/小程序已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限 access clientip is not registered + */ + CODE_61004(61004, "api 功能未授权,请确认公众号/小程序已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限"), + + /** + * component ticket is expired + */ + CODE_61005(61005, "ticket 已过期"), + + /** + * component ticket is invalid + */ + CODE_61006(61006, "无效 ticket"), + + /** + * api is unauthorized to component + */ + CODE_61007(61007, "接口未授权给第三方平台"), + + /** + * component req key is duplicated + */ + CODE_61008(61008, "第三方请求的key存在重复"), + + /** + * code is invalid + */ + CODE_61009(61009, "无效code"), + + /** + * code is expired + */ + CODE_61010(61010, "code已过期"), + + /** + * invalid component + */ + CODE_61011(61011, "无效的第三方平台"), + + /** + * invalid option name + */ + CODE_61012(61012, "无效的选项名称"), + + /** + * invalid option value + */ + CODE_61013(61013, "无效的选项值"), + + /** + * must use component token for component api + */ + CODE_61014(61014, "必须使用component接口的token"), + + /** + * must use biz account token for not component api + */ + CODE_61015(61015, "必须使用商业帐号token,而不是component api"), + + /** + * function category of API need be confirmed by component + */ + CODE_61016(61016, "function category of API need be confirmed by component"), + + /** + * function category is not authorized + */ + CODE_61017(61017, "function category is not authorized"), + + /** + * already confirm + */ + CODE_61018(61018, "已确认"), + + /** + * not need confirm + */ + CODE_61019(61019, "不需要确认"), + + /** + * err parameter + */ + CODE_61020(61020, "err parameter"), + + /** + * can't confirm + */ + CODE_61021(61021, "can't confirm"), + + /** + * can't resubmit + */ + CODE_61022(61022, "can't resubmit"), + + /** + * refresh_token is invalid + */ + CODE_61023(61023, "refresh_token is invalid"), + + /** + * must use api(api_component_token) to get token for component acct + */ + CODE_61024(61024, "must use api(api_component_token) to get token for component acct"), + + /** + * read-only option + */ + CODE_61025(61025, "read-only option"), + + /** + * register access deny + */ + CODE_61026(61026, "register access deny"), + + /** + * register limit exceed + */ + CODE_61027(61027, "register limit exceed"), + + /** + * component is unpublished + */ + CODE_61028(61028, "component is unpublished"), + + /** + * component need republish with base category + */ + CODE_61029(61029, "component need republish with base category"), + + /** + * component cancel authorization not allowed + */ + CODE_61030(61030, "component cancel authorization not allowed"), + + /** + * invalid realname type + */ + CODE_61051(61051, "invalid realname type"), + + /** + * need to be certified + */ + CODE_61052(61052, "need to be certified"), + + /** + * realname exceed limits + */ + CODE_61053(61053, "realname exceed limits"), + + /** + * realname in black list + */ + CODE_61054(61054, "realname in black list"), + + /** + * exceed quota per month + */ + CODE_61055(61055, "exceed quota per month"), + + /** + * copy_wx_verify is required option + */ + CODE_61056(61056, "copy_wx_verify is required option"), + + /** + * invalid ticket + */ + CODE_61058(61058, "invalid ticket"), + + /** + * overseas access deny + */ + CODE_61061(61061, "overseas access deny"), + + /** + * admin exceed limits + */ + CODE_61063(61063, "admin exceed limits"), + + /** + * admin in black list + */ + CODE_61064(61064, "admin in black list"), + + /** + * idcard exceed limits + */ + CODE_61065(61065, "idcard exceed limits"), + + /** + * idcard in black list + */ + CODE_61066(61066, "idcard in black list"), + + /** + * mobile exceed limits + */ + CODE_61067(61067, "mobile exceed limits"), + + /** + * mobile in black list + */ + CODE_61068(61068, "mobile in black list"), + + /** + * invalid admin + */ + CODE_61069(61069, "invalid admin"), + + /** + * name, idcard, wechat name not in accordance + */ + CODE_61070(61070, "name, idcard, wechat name not in accordance"), + + /** + * invalid url + */ + CODE_61100(61100, "invalid url"), + + /** + * invalid openid + */ + CODE_61101(61101, "invalid openid"), + + /** + * share relation not existed + */ + CODE_61102(61102, "share relation not existed"), + + /** + * product wording not set + */ + CODE_61200(61200, "product wording not set"), + + /** + * invalid base info + */ + CODE_61300(61300, "invalid base info"), + + /** + * invalid detail info + */ + CODE_61301(61301, "invalid detail info"), + + /** + * invalid action info + */ + CODE_61302(61302, "invalid action info"), + + /** + * brand info not exist + */ + CODE_61303(61303, "brand info not exist"), + + /** + * invalid product id + */ + CODE_61304(61304, "invalid product id"), + + /** + * invalid key info + */ + CODE_61305(61305, "invalid key info"), + + /** + * invalid appid + */ + CODE_61306(61306, "invalid appid"), + + /** + * invalid card id + */ + CODE_61307(61307, "invalid card id"), + + /** + * base info not exist + */ + CODE_61308(61308, "base info not exist"), + + /** + * detail info not exist + */ + CODE_61309(61309, "detail info not exist"), + + /** + * action info not exist + */ + CODE_61310(61310, "action info not exist"), + + /** + * invalid media info + */ + CODE_61311(61311, "invalid media info"), + + /** + * invalid buffer size + */ + CODE_61312(61312, "invalid buffer size"), + + /** + * invalid buffer + */ + CODE_61313(61313, "invalid buffer"), + + /** + * invalid qrcode extinfo + */ + CODE_61314(61314, "invalid qrcode extinfo"), + + /** + * invalid local ext info + */ + CODE_61315(61315, "invalid local ext info"), + + /** + * key conflict + */ + CODE_61316(61316, "key conflict"), + + /** + * ticket invalid + */ + CODE_61317(61317, "ticket invalid"), + + /** + * verify not pass + */ + CODE_61318(61318, "verify not pass"), + + /** + * category invalid + */ + CODE_61319(61319, "category invalid"), + + /** + * merchant info not exist + */ + CODE_61320(61320, "merchant info not exist"), + + /** + * cate id is a leaf node + */ + CODE_61321(61321, "cate id is a leaf node"), + + /** + * category id no permision + */ + CODE_61322(61322, "category id no permision"), + + /** + * barcode no permision + */ + CODE_61323(61323, "barcode no permision"), + + /** + * exceed max action num + */ + CODE_61324(61324, "exceed max action num"), + + /** + * brandinfo invalid store mgr type + */ + CODE_61325(61325, "brandinfo invalid store mgr type"), + + /** + * anti-spam blocked + */ + CODE_61326(61326, "anti-spam blocked"), + + /** + * comment reach limit + */ + CODE_61327(61327, "comment reach limit"), + + /** + * comment data is not the newest + */ + CODE_61328(61328, "comment data is not the newest"), + + /** + * comment hit ban word + */ + CODE_61329(61329, "comment hit ban word"), + + /** + * image already add + */ + CODE_61330(61330, "image already add"), + + /** + * image never add + */ + CODE_61331(61331, "image never add"), + + /** + * warning, image quanlity too low + */ + CODE_61332(61332, "warning, image quanlity too low"), + + /** + * warning, image simility too high + */ + CODE_61333(61333, "warning, image simility too high"), + + /** + * product not exists + */ + CODE_61334(61334, "product not exists"), + + /** + * key apply fail + */ + CODE_61335(61335, "key apply fail"), + + /** + * check status fail + */ + CODE_61336(61336, "check status fail"), + + /** + * product already exists + */ + CODE_61337(61337, "product already exists"), + + /** + * forbid delete + */ + CODE_61338(61338, "forbid delete"), + + /** + * firmcode claimed + */ + CODE_61339(61339, "firmcode claimed"), + + /** + * check firm info fail + */ + CODE_61340(61340, "check firm info fail"), + + /** + * too many white list uin + */ + CODE_61341(61341, "too many white list uin"), + + /** + * keystandard not match + */ + CODE_61342(61342, "keystandard not match"), + + /** + * keystandard error + */ + CODE_61343(61343, "keystandard error"), + + /** + * id map not exists + */ + CODE_61344(61344, "id map not exists"), + + /** + * invalid action code + */ + CODE_61345(61345, "invalid action code"), + + /** + * invalid actioninfo store + */ + CODE_61346(61346, "invalid actioninfo store"), + + /** + * invalid actioninfo media + */ + CODE_61347(61347, "invalid actioninfo media"), + + /** + * invalid actioninfo text + */ + CODE_61348(61348, "invalid actioninfo text"), + + /** + * invalid input data + */ + CODE_61350(61350, "invalid input data"), + + /** + * input data exceed max size + */ + CODE_61351(61351, "input data exceed max size"), + + /** + * kf_account error + */ + CODE_61400(61400, "kf_account error"), + + /** + * kf system alredy transfer + */ + CODE_61401(61401, "kf system alredy transfer"), + + /** + * 系统错误 (system error) + */ + CODE_61450(61450, "系统错误 (system error)"), + + /** + * 参数错误 (invalid parameter) + */ + CODE_61451(61451, "参数错误 (invalid parameter)"), + + /** + * 无效客服账号 (invalid kf_account) + */ + CODE_61452(61452, "无效客服账号 (invalid kf_account)"), + + /** + * 客服帐号已存在 (kf_account exsited) + */ + CODE_61453(61453, "客服帐号已存在 (kf_account exsited)"), + + /** + * 客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length) + */ + CODE_61454(61454, "客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length)"), + + /** + * 客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account) + */ + CODE_61455(61455, "客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account)"), + + /** + * 客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded) + */ + CODE_61456(61456, "客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded)"), + + /** + * 无效头像文件类型 (invalid file type) + */ + CODE_61457(61457, "无效头像文件类型 (invalid file type)"), + + /** + * 日期格式错误 date format error + */ + CODE_61500(61500, "日期格式错误"), + + /** + * date range error + */ + CODE_61501(61501, "date range error"), + + /** + * this is game miniprogram, data api is not supported + */ + CODE_61502(61502, "this is game miniprogram, data api is not supported"), + + /** + * data not ready, please try later + */ + CODE_61503(61503, "data not ready, please try later"), + + /** + * trying to access other's app + */ + CODE_62001(62001, "trying to access other's app"), + + /** + * app name already exists + */ + CODE_62002(62002, "app name already exists"), + + /** + * please provide at least one platform + */ + CODE_62003(62003, "please provide at least one platform"), + + /** + * invalid app name + */ + CODE_62004(62004, "invalid app name"), + + /** + * invalid app id + */ + CODE_62005(62005, "invalid app id"), + + /** + * 部分参数为空 some arguments is empty + */ + CODE_63001(63001, "部分参数为空"), + + /** + * 无效的签名 invalid signature + */ + CODE_63002(63002, "无效的签名"), + + /** + * invalid signature method + */ + CODE_63003(63003, "invalid signature method"), + + /** + * no authroize + */ + CODE_63004(63004, "no authroize"), + + /** + * gen ticket fail + */ + CODE_63149(63149, "gen ticket fail"), + + /** + * set ticket fail + */ + CODE_63152(63152, "set ticket fail"), + + /** + * shortid decode fail + */ + CODE_63153(63153, "shortid decode fail"), + + /** + * invalid status + */ + CODE_63154(63154, "invalid status"), + + /** + * invalid color + */ + CODE_63155(63155, "invalid color"), + + /** + * invalid tag + */ + CODE_63156(63156, "invalid tag"), + + /** + * invalid recommend + */ + CODE_63157(63157, "invalid recommend"), + + /** + * branditem out of limits + */ + CODE_63158(63158, "branditem out of limits"), + + /** + * retail_price empty + */ + CODE_63159(63159, "retail_price empty"), + + /** + * priceinfo invalid + */ + CODE_63160(63160, "priceinfo invalid"), + + /** + * antifake module num limit + */ + CODE_63161(63161, "antifake module num limit"), + + /** + * antifake native_type err + */ + CODE_63162(63162, "antifake native_type err"), + + /** + * antifake link not exists + */ + CODE_63163(63163, "antifake link not exists"), + + /** + * module type not exist + */ + CODE_63164(63164, "module type not exist"), + + /** + * module info not exist + */ + CODE_63165(63165, "module info not exist"), + + /** + * item is beding verified + */ + CODE_63166(63166, "item is beding verified"), + + /** + * item not published + */ + CODE_63167(63167, "item not published"), + + /** + * verify not pass + */ + CODE_63168(63168, "verify not pass"), + + /** + * already published + */ + CODE_63169(63169, "already published"), + + /** + * only banner or media + */ + CODE_63170(63170, "only banner or media"), + + /** + * card num limit + */ + CODE_63171(63171, "card num limit"), + + /** + * user num limit + */ + CODE_63172(63172, "user num limit"), + + /** + * text num limit + */ + CODE_63173(63173, "text num limit"), + + /** + * link card user sum limit + */ + CODE_63174(63174, "link card user sum limit"), + + /** + * detail info error + */ + CODE_63175(63175, "detail info error"), + + /** + * not this type + */ + CODE_63176(63176, "not this type"), + + /** + * src or secretkey or version or expired_time is wrong + */ + CODE_63177(63177, "src or secretkey or version or expired_time is wrong"), + + /** + * appid wrong + */ + CODE_63178(63178, "appid wrong"), + + /** + * openid num limit + */ + CODE_63179(63179, "openid num limit"), + + /** + * this app msg not found + */ + CODE_63180(63180, "this app msg not found"), + + /** + * get history app msg end + */ + CODE_63181(63181, "get history app msg end"), + + /** + * openid_list empty + */ + CODE_63182(63182, "openid_list empty"), + + /** + * unknown deeplink type + */ + CODE_65001(65001, "unknown deeplink type"), + + /** + * deeplink unauthorized + */ + CODE_65002(65002, "deeplink unauthorized"), + + /** + * bad deeplink + */ + CODE_65003(65003, "bad deeplink"), + + /** + * deeplinks of the very type are supposed to have short-life + */ + CODE_65004(65004, "deeplinks of the very type are supposed to have short-life"), + + /** + * invalid categories + */ + CODE_65104(65104, "invalid categories"), + + /** + * invalid photo url + */ + CODE_65105(65105, "invalid photo url"), + + /** + * poi audit state must be approved + */ + CODE_65106(65106, "poi audit state must be approved"), + + /** + * poi not allowed modify now + */ + CODE_65107(65107, "poi not allowed modify now"), + + /** + * invalid business name + */ + CODE_65109(65109, "invalid business name"), + + /** + * invalid address + */ + CODE_65110(65110, "invalid address"), + + /** + * invalid telephone + */ + CODE_65111(65111, "invalid telephone"), + + /** + * invalid city + */ + CODE_65112(65112, "invalid city"), + + /** + * invalid province + */ + CODE_65113(65113, "invalid province"), + + /** + * photo list empty + */ + CODE_65114(65114, "photo list empty"), + + /** + * poi_id is not exist + */ + CODE_65115(65115, "poi_id is not exist"), + + /** + * poi has been deleted + */ + CODE_65116(65116, "poi has been deleted"), + + /** + * cannot delete poi + */ + CODE_65117(65117, "cannot delete poi"), + + /** + * store status is invalid + */ + CODE_65118(65118, "store status is invalid"), + + /** + * lack of qualification for relevant principals + */ + CODE_65119(65119, "lack of qualification for relevant principals"), + + /** + * category info is not found + */ + CODE_65120(65120, "category info is not found"), + + /** + * room_name is empty, please check your input + */ + CODE_65201(65201, "room_name is empty, please check your input"), + + /** + * user_id is empty, please check your input + */ + CODE_65202(65202, "user_id is empty, please check your input"), + + /** + * invalid check ticket + */ + CODE_65203(65203, "invalid check ticket"), + + /** + * invalid check ticket opt code + */ + CODE_65204(65204, "invalid check ticket opt code"), + + /** + * check ticket out of time + */ + CODE_65205(65205, "check ticket out of time"), + + /** + * 不存在此 menuid 对应的个性化菜单 this menu is not conditionalmenu + */ + CODE_65301(65301, "不存在此 menuid 对应的个性化菜单"), + + /** + * 没有相应的用户 no such user + */ + CODE_65302(65302, "没有相应的用户"), + + /** + * 没有默认菜单,不能创建个性化菜单 there is no selfmenu, please create selfmenu first + */ + CODE_65303(65303, "没有默认菜单,不能创建个性化菜单"), + + /** + * MatchRule 信息为空 match rule empty + */ + CODE_65304(65304, "MatchRule 信息为空"), + + /** + * 个性化菜单数量受限 menu count limit + */ + CODE_65305(65305, "个性化菜单数量受限"), + + /** + * 不支持个性化菜单的帐号 conditional menu not support + */ + CODE_65306(65306, "不支持个性化菜单的帐号"), + + /** + * 个性化菜单信息为空 conditional menu is empty + */ + CODE_65307(65307, "个性化菜单信息为空"), + + /** + * 包含没有响应类型的 button exist empty button act + */ + CODE_65308(65308, "包含没有响应类型的 button"), + + /** + * 个性化菜单开关处于关闭状态 conditional menu switch is closed + */ + CODE_65309(65309, "个性化菜单开关处于关闭状态"), + + /** + * 填写了省份或城市信息,国家信息不能为空 region info: country is empty + */ + CODE_65310(65310, "填写了省份或城市信息,国家信息不能为空"), + + /** + * 填写了城市信息,省份信息不能为空 region info: province is empty + */ + CODE_65311(65311, "填写了城市信息,省份信息不能为空"), + + /** + * 不合法的国家信息 invalid country info + */ + CODE_65312(65312, "不合法的国家信息"), + + /** + * 不合法的省份信息 invalid province info + */ + CODE_65313(65313, "不合法的省份信息"), + + /** + * 不合法的城市信息 invalid city info + */ + CODE_65314(65314, "不合法的城市信息"), + + /** + * not fans + */ + CODE_65315(65315, "not fans"), + + /** + * 该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接) domain count reach limit + */ + CODE_65316(65316, "该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接)"), + + /** + * 不合法的 URL contain invalid url + */ + CODE_65317(65317, "不合法的 URL"), + + /** + * must use utf-8 charset + */ + CODE_65318(65318, "must use utf-8 charset"), + + /** + * not allow to create menu + */ + CODE_65319(65319, "not allow to create menu"), + + /** + * please enable new custom service, or wait for a while if you have enabled + */ + CODE_65400(65400, "please enable new custom service, or wait for a while if you have enabled"), + + /** + * invalid custom service account + */ + CODE_65401(65401, "invalid custom service account"), + + /** + * the custom service account need to bind a wechat user + */ + CODE_65402(65402, "the custom service account need to bind a wechat user"), + + /** + * illegal nickname + */ + CODE_65403(65403, "illegal nickname"), + + /** + * illegal custom service account + */ + CODE_65404(65404, "illegal custom service account"), + + /** + * custom service account number reach limit + */ + CODE_65405(65405, "custom service account number reach limit"), + + /** + * custom service account exists + */ + CODE_65406(65406, "custom service account exists"), + + /** + * the wechat user have been one of your workers + */ + CODE_65407(65407, "the wechat user have been one of your workers"), + + /** + * you have already invited the wechat user + */ + CODE_65408(65408, "you have already invited the wechat user"), + + /** + * wechat account invalid + */ + CODE_65409(65409, "wechat account invalid"), + + /** + * too many custom service accounts bound by the worker + */ + CODE_65410(65410, "too many custom service accounts bound by the worker"), + + /** + * a effective invitation to bind the custom service account exists + */ + CODE_65411(65411, "a effective invitation to bind the custom service account exists"), + + /** + * the custom service account have been bound by a wechat user + */ + CODE_65412(65412, "the custom service account have been bound by a wechat user"), + + /** + * no effective session for the customer + */ + CODE_65413(65413, "no effective session for the customer"), + + /** + * another worker is serving the customer + */ + CODE_65414(65414, "another worker is serving the customer"), + + /** + * the worker is not online + */ + CODE_65415(65415, "the worker is not online"), + + /** + * param invalid, please check + */ + CODE_65416(65416, "param invalid, please check"), + + /** + * it is too long from the starttime to endtime + */ + CODE_65417(65417, "it is too long from the starttime to endtime"), + + /** + * homepage not exists + */ + CODE_65450(65450, "homepage not exists"), + + /** + * invalid store type + */ + CODE_68002(68002, "invalid store type"), + + /** + * invalid store name + */ + CODE_68003(68003, "invalid store name"), + + /** + * invalid store wxa path + */ + CODE_68004(68004, "invalid store wxa path"), + + /** + * miss store wxa path + */ + CODE_68005(68005, "miss store wxa path"), + + /** + * invalid kefu type + */ + CODE_68006(68006, "invalid kefu type"), + + /** + * invalid kefu wxa path + */ + CODE_68007(68007, "invalid kefu wxa path"), + + /** + * invalid kefu phone number + */ + CODE_68008(68008, "invalid kefu phone number"), + + /** + * invalid sub mch id + */ + CODE_68009(68009, "invalid sub mch id"), + + /** + * store id has exist + */ + CODE_68010(68010, "store id has exist"), + + /** + * miss store name + */ + CODE_68011(68011, "miss store name"), + + /** + * miss create time + */ + CODE_68012(68012, "miss create time"), + + /** + * invalid status + */ + CODE_68013(68013, "invalid status"), + + /** + * invalid receiver info + */ + CODE_68014(68014, "invalid receiver info"), + + /** + * invalid product + */ + CODE_68015(68015, "invalid product"), + + /** + * invalid pay type + */ + CODE_68016(68016, "invalid pay type"), + + /** + * invalid fast mail no + */ + CODE_68017(68017, "invalid fast mail no"), + + /** + * invalid busi id + */ + CODE_68018(68018, "invalid busi id"), + + /** + * miss product sku + */ + CODE_68019(68019, "miss product sku"), + + /** + * invalid service type + */ + CODE_68020(68020, "invalid service type"), + + /** + * invalid service status + */ + CODE_68021(68021, "invalid service status"), + + /** + * invalid service_id + */ + CODE_68022(68022, "invalid service_id"), + + /** + * service_id has exist + */ + CODE_68023(68023, "service_id has exist"), + + /** + * miss service wxa path + */ + CODE_68024(68024, "miss service wxa path"), + + /** + * invalid product sku + */ + CODE_68025(68025, "invalid product sku"), + + /** + * invalid product spu + */ + CODE_68026(68026, "invalid product spu"), + + /** + * miss product spu + */ + CODE_68027(68027, "miss product spu"), + + /** + * can not find product spu and spu in order list + */ + CODE_68028(68028, "can not find product spu and spu in order list"), + + /** + * sku and spu duplicated + */ + CODE_68029(68029, "sku and spu duplicated"), + + /** + * busi_id has exist + */ + CODE_68030(68030, "busi_id has exist"), + + /** + * update fail + */ + CODE_68031(68031, "update fail"), + + /** + * busi_id not exist + */ + CODE_68032(68032, "busi_id not exist"), + + /** + * store no exist + */ + CODE_68033(68033, "store no exist"), + + /** + * miss product number + */ + CODE_68034(68034, "miss product number"), + + /** + * miss wxa order detail path + */ + CODE_68035(68035, "miss wxa order detail path"), + + /** + * there is no enough products to refund + */ + CODE_68036(68036, "there is no enough products to refund"), + + /** + * invalid refund info + */ + CODE_68037(68037, "invalid refund info"), + + /** + * shipped but no fast mail info + */ + CODE_68038(68038, "shipped but no fast mail info"), + + /** + * invalid wechat pay no + */ + CODE_68039(68039, "invalid wechat pay no"), + + /** + * all product has been refunded, the order can not be finished + */ + CODE_68040(68040, "all product has been refunded, the order can not be finished"), + + /** + * invalid service create time, it must bigger than the time of order + */ + CODE_68041(68041, "invalid service create time, it must bigger than the time of order"), + + /** + * invalid total cost, it must be smaller than the sum of product and shipping cost + */ + CODE_68042(68042, "invalid total cost, it must be smaller than the sum of product and shipping cost"), + + /** + * invalid role + */ + CODE_68043(68043, "invalid role"), + + /** + * invalid service_available args + */ + CODE_68044(68044, "invalid service_available args"), + + /** + * invalid order type + */ + CODE_68045(68045, "invalid order type"), + + /** + * invalid order deliver type + */ + CODE_68046(68046, "invalid order deliver type"), + + /** + * require store_id + */ + CODE_68500(68500, "require store_id"), + + /** + * invalid store_id + */ + CODE_68501(68501, "invalid store_id"), + + /** + * invalid parameter, parameter is zero or missing + */ + CODE_71001(71001, "invalid parameter, parameter is zero or missing"), + + /** + * invalid orderid, may be the other parameter not fit with orderid + */ + CODE_71002(71002, "invalid orderid, may be the other parameter not fit with orderid"), + + /** + * coin not enough + */ + CODE_71003(71003, "coin not enough"), + + /** + * card is expired + */ + CODE_71004(71004, "card is expired"), + + /** + * limit exe count + */ + CODE_71005(71005, "limit exe count"), + + /** + * limit coin count, 1 <= coin_count <= 100000 + */ + CODE_71006(71006, "limit coin count, 1 <= coin_count <= 100000"), + + /** + * order finish + */ + CODE_71007(71007, "order finish"), + + /** + * order time out + */ + CODE_71008(71008, "order time out"), + + /** + * no match card + */ + CODE_72001(72001, "no match card"), + + /** + * mchid is not bind appid + */ + CODE_72002(72002, "mchid is not bind appid"), + + /** + * invalid card type, need member card + */ + CODE_72003(72003, "invalid card type, need member card"), + + /** + * mchid is occupied by the other appid + */ + CODE_72004(72004, "mchid is occupied by the other appid"), + + /** + * out of mchid size limit + */ + CODE_72005(72005, "out of mchid size limit"), + + /** + * invald title + */ + CODE_72006(72006, "invald title"), + + /** + * invalid reduce cost, can not less than 100 + */ + CODE_72007(72007, "invalid reduce cost, can not less than 100"), + + /** + * invalid least cost, most larger than reduce cost + */ + CODE_72008(72008, "invalid least cost, most larger than reduce cost"), + + /** + * invalid get limit, can not over 50 + */ + CODE_72009(72009, "invalid get limit, can not over 50"), + + /** + * invalid mchid + */ + CODE_72010(72010, "invalid mchid"), + + /** + * invalid activate_ticket.Maybe this ticket is not belong this AppId + */ + CODE_72011(72011, "invalid activate_ticket.Maybe this ticket is not belong this AppId"), + + /** + * activate_ticket has been expired + */ + CODE_72012(72012, "activate_ticket has been expired"), + + /** + * unauthorized order_id or authorization is expired + */ + CODE_72013(72013, "unauthorized order_id or authorization is expired"), + + /** + * task card share stock can not modify stock + */ + CODE_72014(72014, "task card share stock can not modify stock"), + + /** + * unauthorized create invoice + */ + CODE_72015(72015, "unauthorized create invoice"), + + /** + * unauthorized create member card + */ + CODE_72016(72016, "unauthorized create member card"), + + /** + * invalid invoice title + */ + CODE_72017(72017, "invalid invoice title"), + + /** + * duplicate order id, invoice had inserted to user + */ + CODE_72018(72018, "duplicate order id, invoice had inserted to user"), + + /** + * limit msg operation card list size, must <= 5 + */ + CODE_72019(72019, "limit msg operation card list size, must <= 5"), + + /** + * limit consume in use limit + */ + CODE_72020(72020, "limit consume in use limit"), + + /** + * unauthorized create general card + */ + CODE_72021(72021, "unauthorized create general card"), + + /** + * user unexpected, please add user to white list + */ + CODE_72022(72022, "user unexpected, please add user to white list"), + + /** + * invoice has been lock by others + */ + CODE_72023(72023, "invoice has been lock by others"), + + /** + * invoice status error + */ + CODE_72024(72024, "invoice status error"), + + /** + * invoice token error + */ + CODE_72025(72025, "invoice token error"), + + /** + * need set wx_activate true + */ + CODE_72026(72026, "need set wx_activate true"), + + /** + * invoice action error + */ + CODE_72027(72027, "invoice action error"), + + /** + * invoice never set pay mch info + */ + CODE_72028(72028, "invoice never set pay mch info"), + + /** + * invoice never set auth field + */ + CODE_72029(72029, "invoice never set auth field"), + + /** + * invalid mchid + */ + CODE_72030(72030, "invalid mchid"), + + /** + * invalid params + */ + CODE_72031(72031, "invalid params"), + + /** + * pay gift card rule expired + */ + CODE_72032(72032, "pay gift card rule expired"), + + /** + * pay gift card rule status err + */ + CODE_72033(72033, "pay gift card rule status err"), + + /** + * invlid rule id + */ + CODE_72034(72034, "invlid rule id"), + + /** + * biz reject insert + */ + CODE_72035(72035, "biz reject insert"), + + /** + * invoice is busy, try again please + */ + CODE_72036(72036, "invoice is busy, try again please"), + + /** + * invoice owner error + */ + CODE_72037(72037, "invoice owner error"), + + /** + * invoice order never auth + */ + CODE_72038(72038, "invoice order never auth"), + + /** + * invoice must be lock first + */ + CODE_72039(72039, "invoice must be lock first"), + + /** + * invoice pdf error + */ + CODE_72040(72040, "invoice pdf error"), + + /** + * billing_code and billing_no invalid + */ + CODE_72041(72041, "billing_code and billing_no invalid"), + + /** + * billing_code and billing_no repeated + */ + CODE_72042(72042, "billing_code and billing_no repeated"), + + /** + * billing_code or billing_no size error + */ + CODE_72043(72043, "billing_code or billing_no size error"), + + /** + * scan text out of time + */ + CODE_72044(72044, "scan text out of time"), + + /** + * check_code is empty + */ + CODE_72045(72045, "check_code is empty"), + + /** + * pdf_url is invalid + */ + CODE_72046(72046, "pdf_url is invalid"), + + /** + * pdf billing_code or pdf billing_no is error + */ + CODE_72047(72047, "pdf billing_code or pdf billing_no is error"), + + /** + * insert too many invoice, need auth again + */ + CODE_72048(72048, "insert too many invoice, need auth again"), + + /** + * never auth + */ + CODE_72049(72049, "never auth"), + + /** + * auth expired, need auth again + */ + CODE_72050(72050, "auth expired, need auth again"), + + /** + * app type error + */ + CODE_72051(72051, "app type error"), + + /** + * get too many invoice + */ + CODE_72052(72052, "get too many invoice"), + + /** + * user never auth + */ + CODE_72053(72053, "user never auth"), + + /** + * invoices is inserting, wait a moment please + */ + CODE_72054(72054, "invoices is inserting, wait a moment please"), + + /** + * too many invoices + */ + CODE_72055(72055, "too many invoices"), + + /** + * order_id repeated, please check order_id + */ + CODE_72056(72056, "order_id repeated, please check order_id"), + + /** + * today insert limit + */ + CODE_72057(72057, "today insert limit"), + + /** + * callback biz error + */ + CODE_72058(72058, "callback biz error"), + + /** + * this invoice is giving to others, wait a moment please + */ + CODE_72059(72059, "this invoice is giving to others, wait a moment please"), + + /** + * this invoice has been cancelled, check the reimburse_status please + */ + CODE_72060(72060, "this invoice has been cancelled, check the reimburse_status please"), + + /** + * this invoice has been closed, check the reimburse_status please + */ + CODE_72061(72061, "this invoice has been closed, check the reimburse_status please"), + + /** + * this code_auth_key is limited, try other code_auth_key please + */ + CODE_72062(72062, "this code_auth_key is limited, try other code_auth_key please"), + + /** + * biz contact is empty, set contact first please + */ + CODE_72063(72063, "biz contact is empty, set contact first please"), + + /** + * tbc error + */ + CODE_72064(72064, "tbc error"), + + /** + * tbc logic error + */ + CODE_72065(72065, "tbc logic error"), + + /** + * the card is send for advertisement, not allow modify time and budget + */ + CODE_72066(72066, "the card is send for advertisement, not allow modify time and budget"), + + /** + * BatchInsertAuthKey_Expired + */ + CODE_72067(72067, "BatchInsertAuthKey_Expired"), + + /** + * BatchInsertAuthKey_Owner + */ + CODE_72068(72068, "BatchInsertAuthKey_Owner"), + + /** + * BATCHTASKRUN_ERROR + */ + CODE_72069(72069, "BATCHTASKRUN_ERROR"), + + /** + * BIZ_TITLE_KEY_OUT_TIME + */ + CODE_72070(72070, "BIZ_TITLE_KEY_OUT_TIME"), + + /** + * Discern_GaoPeng_Error + */ + CODE_72071(72071, "Discern_GaoPeng_Error"), + + /** + * Discern_Type_Error + */ + CODE_72072(72072, "Discern_Type_Error"), + + /** + * Fee_Error + */ + CODE_72073(72073, "Fee_Error"), + + /** + * HAS_Auth + */ + CODE_72074(72074, "HAS_Auth"), + + /** + * HAS_SEND + */ + CODE_72075(72075, "HAS_SEND"), + + /** + * INVOICESIGN + */ + CODE_72076(72076, "INVOICESIGN"), + + /** + * KEY_DELETED + */ + CODE_72077(72077, "KEY_DELETED"), + + /** + * KEY_EXPIRED + */ + CODE_72078(72078, "KEY_EXPIRED"), + + /** + * MOUNT_ERROR + */ + CODE_72079(72079, "MOUNT_ERROR"), + + /** + * NO_FOUND + */ + CODE_72080(72080, "NO_FOUND"), + + /** + * No_Pull_Pdf + */ + CODE_72081(72081, "No_Pull_Pdf"), + + /** + * PDF_CHECK_ERROR + */ + CODE_72082(72082, "PDF_CHECK_ERROR"), + + /** + * PULL_PDF_FAIL + */ + CODE_72083(72083, "PULL_PDF_FAIL"), + + /** + * PUSH_BIZ_EMPTY + */ + CODE_72084(72084, "PUSH_BIZ_EMPTY"), + + /** + * SDK_APPID_ERROR + */ + CODE_72085(72085, "SDK_APPID_ERROR"), + + /** + * SDK_BIZ_ERROR + */ + CODE_72086(72086, "SDK_BIZ_ERROR"), + + /** + * SDK_URL_ERROR + */ + CODE_72087(72087, "SDK_URL_ERROR"), + + /** + * Search_Title_Fail + */ + CODE_72088(72088, "Search_Title_Fail"), + + /** + * TITLE_BUSY + */ + CODE_72089(72089, "TITLE_BUSY"), + + /** + * TITLE_NO_FOUND + */ + CODE_72090(72090, "TITLE_NO_FOUND"), + + /** + * TOKEN_ERR + */ + CODE_72091(72091, "TOKEN_ERR"), + + /** + * USER_TITLE_NOT_FOUND + */ + CODE_72092(72092, "USER_TITLE_NOT_FOUND"), + + /** + * Verify_3rd_Fail + */ + CODE_72093(72093, "Verify_3rd_Fail"), + + /** + * sys error make out invoice failed + */ + CODE_73000(73000, "sys error make out invoice failed"), + + /** + * wxopenid error + */ + CODE_73001(73001, "wxopenid error"), + + /** + * ddh orderid empty + */ + CODE_73002(73002, "ddh orderid empty"), + + /** + * wxopenid empty + */ + CODE_73003(73003, "wxopenid empty"), + + /** + * fpqqlsh empty + */ + CODE_73004(73004, "fpqqlsh empty"), + + /** + * not a commercial + */ + CODE_73005(73005, "not a commercial"), + + /** + * kplx empty + */ + CODE_73006(73006, "kplx empty"), + + /** + * nsrmc empty + */ + CODE_73007(73007, "nsrmc empty"), + + /** + * nsrdz empty + */ + CODE_73008(73008, "nsrdz empty"), + + /** + * nsrdh empty + */ + CODE_73009(73009, "nsrdh empty"), + + /** + * ghfmc empty + */ + CODE_73010(73010, "ghfmc empty"), + + /** + * kpr empty + */ + CODE_73011(73011, "kpr empty"), + + /** + * jshj empty + */ + CODE_73012(73012, "jshj empty"), + + /** + * hjje empty + */ + CODE_73013(73013, "hjje empty"), + + /** + * hjse empty + */ + CODE_73014(73014, "hjse empty"), + + /** + * hylx empty + */ + CODE_73015(73015, "hylx empty"), + + /** + * nsrsbh empty + */ + CODE_73016(73016, "nsrsbh empty"), + + /** + * kaipiao plat error + */ + CODE_73100(73100, "kaipiao plat error"), + + /** + * nsrsbh not cmp + */ + CODE_73101(73101, "nsrsbh not cmp"), + + /** + * invalid wxa appid in url_cell, wxa appid is need to bind biz appid + */ + CODE_73103(73103, "invalid wxa appid in url_cell, wxa appid is need to bind biz appid"), + + /** + * reach frequency limit + */ + CODE_73104(73104, "reach frequency limit"), + + /** + * Kp plat make invoice timeout, please try again with the same fpqqlsh + */ + CODE_73105(73105, "Kp plat make invoice timeout, please try again with the same fpqqlsh"), + + /** + * Fpqqlsh exist with different ddh + */ + CODE_73106(73106, "Fpqqlsh exist with different ddh"), + + /** + * Fpqqlsh is processing, please wait and query later + */ + CODE_73107(73107, "Fpqqlsh is processing, please wait and query later"), + + /** + * This ddh with other fpqqlsh already exist + */ + CODE_73108(73108, "This ddh with other fpqqlsh already exist"), + + /** + * This Fpqqlsh not exist in kpplat + */ + CODE_73109(73109, "This Fpqqlsh not exist in kpplat"), + + /** + * get card detail by card id and code fail + */ + CODE_73200(73200, "get card detail by card id and code fail"), + + /** + * get cloud invoice record fail + */ + CODE_73201(73201, "get cloud invoice record fail"), + + /** + * get appinfo fail + */ + CODE_73202(73202, "get appinfo fail"), + + /** + * get invoice category or rule kv error + */ + CODE_73203(73203, "get invoice category or rule kv error"), + + /** + * request card not exist + */ + CODE_73204(73204, "request card not exist"), + + /** + * 朋友的券玩法升级中,当前暂停创建,请创建其他类型卡券 + */ + CODE_73205(73205, "朋友的券玩法升级中,当前暂停创建,请创建其他类型卡券"), + + /** + * 朋友的券玩法升级中,当前暂停券点充值,请创建其他类型卡券 + */ + CODE_73206(73206, "朋友的券玩法升级中,当前暂停券点充值,请创建其他类型卡券"), + + /** + * 朋友的券玩法升级中,当前暂停开通券点账户 + */ + CODE_73207(73207, "朋友的券玩法升级中,当前暂停开通券点账户"), + + /** + * 朋友的券玩法升级中,当前不支持修改库存 + */ + CODE_73208(73208, "朋友的券玩法升级中,当前不支持修改库存"), + + /** + * 朋友的券玩法升级中,当前不支持修改有效期 + */ + CODE_73209(73209, "朋友的券玩法升级中,当前不支持修改有效期"), + + /** + * 当前批次不支持修改卡券批次库存 + */ + CODE_73210(73210, "当前批次不支持修改卡券批次库存"), + + /** + * 不再支持配置网页链接跳转,请选择小程序替代 + */ + CODE_73211(73211, "不再支持配置网页链接跳转,请选择小程序替代"), + + /** + * unauthorized backup member + */ + CODE_73212(73212, "unauthorized backup member"), + + /** + * invalid code type + */ + CODE_73213(73213, "invalid code type"), + + /** + * the user is already a member + */ + CODE_73214(73214, "the user is already a member"), + + /** + * 支付打通券能力已下线,请直接使用微信支付代金券API:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/convention/chapter1_1.shtml + */ + CODE_73215(73215, "支付打通券能力已下线,请直接使用微信支付代金券API:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/convention/chapter1_1.shtml"), + + /** + * 不合法的按钮名字,请从中选择一个:使用礼品卡/立即使用/去点外卖 + */ + CODE_73216(73216, "不合法的按钮名字,请从中选择一个:使用礼品卡/立即使用/去点外卖"), + + /** + * 礼品卡本身没有设置appname和path,不允许在修改接口设置 + */ + CODE_73217(73217, "礼品卡本身没有设置appname和path,不允许在修改接口设置"), + + /** + * 未授权使用礼品卡落地页跳转小程序功能 + */ + CODE_73218(73218, "未授权使用礼品卡落地页跳转小程序功能"), + + /** + * not find this wx_hotel_id info + */ + CODE_74000(74000, "not find this wx_hotel_id info"), + + /** + * request some param empty + */ + CODE_74001(74001, "request some param empty"), + + /** + * request some param error + */ + CODE_74002(74002, "request some param error"), + + /** + * request some param error + */ + CODE_74003(74003, "request some param error"), + + /** + * datetime error + */ + CODE_74004(74004, "datetime error"), + + /** + * checkin mode error + */ + CODE_74005(74005, "checkin mode error"), + + /** + * carid from error + */ + CODE_74007(74007, "carid from error"), + + /** + * this hotel routecode not exist + */ + CODE_74008(74008, "this hotel routecode not exist"), + + /** + * this hotel routecode info error contract developer + */ + CODE_74009(74009, "this hotel routecode info error contract developer"), + + /** + * maybe not support report mode + */ + CODE_74010(74010, "maybe not support report mode"), + + /** + * pic deocde not ok maybe its not good picdata + */ + CODE_74011(74011, "pic deocde not ok maybe its not good picdata"), + + /** + * verify sys erro + */ + CODE_74021(74021, "verify sys erro"), + + /** + * inner police erro + */ + CODE_74022(74022, "inner police erro"), + + /** + * unable to detect the face + */ + CODE_74023(74023, "unable to detect the face"), + + /** + * report checkin 2 lvye sys erro + */ + CODE_74040(74040, "report checkin 2 lvye sys erro"), + + /** + * report checkou 2 lvye sys erro + */ + CODE_74041(74041, "report checkou 2 lvye sys erro"), + + /** + * some param emtpy please check + */ + CODE_75001(75001, "some param emtpy please check"), + + /** + * param illegal please check + */ + CODE_75002(75002, "param illegal please check"), + + /** + * sys error kv store error + */ + CODE_75003(75003, "sys error kv store error"), + + /** + * sys error kvstring store error + */ + CODE_75004(75004, "sys error kvstring store error"), + + /** + * product not exist please check your product_id + */ + CODE_75005(75005, "product not exist please check your product_id"), + + /** + * order not exist please check order_id and buyer_appid + */ + CODE_75006(75006, "order not exist please check order_id and buyer_appid"), + + /** + * do not allow this status to change please check this order_id status now + */ + CODE_75007(75007, "do not allow this status to change please check this order_id status now"), + + /** + * product has exist please use new id + */ + CODE_75008(75008, "product has exist please use new id"), + + /** + * notify order status failed + */ + CODE_75009(75009, "notify order status failed"), + + /** + * buyer bussiness info not exist + */ + CODE_75010(75010, "buyer bussiness info not exist"), + + /** + * you had registered + */ + CODE_75011(75011, "you had registered"), + + /** + * store image key to kv error, please try again + */ + CODE_75012(75012, "store image key to kv error, please try again"), + + /** + * get image fail, please check you image key + */ + CODE_75013(75013, "get image fail, please check you image key"), + + /** + * this key is not belong to you + */ + CODE_75014(75014, "this key is not belong to you"), + + /** + * this key is expired + */ + CODE_75015(75015, "this key is expired"), + + /** + * encrypt decode key fail + */ + CODE_75016(75016, "encrypt decode key fail"), + + /** + * encrypt encode key fail + */ + CODE_75017(75017, "encrypt encode key fail"), + + /** + * bind buyer business info fail please contact us + */ + CODE_75018(75018, "bind buyer business info fail please contact us"), + + /** + * this key is empty, user may not upload file + */ + CODE_75019(75019, "this key is empty, user may not upload file"), + + /** + * 系统错误,请稍后再试 + */ + CODE_80000(80000, "系统错误,请稍后再试"), + + /** + * 参数格式校验错误 + */ + CODE_80001(80001, "参数格式校验错误"), + + /** + * 签名失败 + */ + CODE_80002(80002, "签名失败"), + + /** + * 该日期订单未生成 + */ + CODE_80003(80003, "该日期订单未生成"), + + /** + * 用户未绑卡 + */ + CODE_80004(80004, "用户未绑卡"), + + /** + * 姓名不符 + */ + CODE_80005(80005, "姓名不符"), + + /** + * 身份证不符 + */ + CODE_80006(80006, "身份证不符"), + + /** + * 获取城市信息失败 + */ + CODE_80007(80007, "获取城市信息失败"), + + /** + * 未找到指定少儿信息 + */ + CODE_80008(80008, "未找到指定少儿信息"), + + /** + * 少儿身份证不符 + */ + CODE_80009(80009, "少儿身份证不符"), + + /** + * 少儿未绑定 + */ + CODE_80010(80010, "少儿未绑定"), + + /** + * 签约号不符 + */ + CODE_80011(80011, "签约号不符"), + + /** + * 该地区局方配置不存在 + */ + CODE_80012(80012, "该地区局方配置不存在"), + + /** + * 调用方appid与局方配置不匹配 + */ + CODE_80013(80013, "调用方appid与局方配置不匹配"), + + /** + * 获取消息账号失败 + */ + CODE_80014(80014, "获取消息账号失败"), + + /** + * 非法的插件版本 + */ + CODE_80066(80066, "非法的插件版本"), + + /** + * 找不到使用的插件 + */ + CODE_80067(80067, "找不到使用的插件"), + + /** + * 没有权限使用该插件 + */ + CODE_80082(80082, "没有权限使用该插件"), + + /** + * 商家未接入 + */ + CODE_80101(80101, "商家未接入"), + + /** + * 实名校验code不存在 + */ + CODE_80111(80111, "实名校验code不存在"), + + /** + * code并发冲突 + */ + CODE_80112(80112, "code并发冲突"), + + /** + * 无效code + */ + CODE_80113(80113, "无效code"), + + /** + * report_type无效 + */ + CODE_80201(80201, "report_type无效"), + + /** + * service_type无效 + */ + CODE_80202(80202, "service_type无效"), + + /** + * 申请单不存在 + */ + CODE_80300(80300, "申请单不存在"), + + /** + * 申请单不属于该账号 + */ + CODE_80301(80301, "申请单不属于该账号"), + + /** + * 激活号段有重叠 + */ + CODE_80302(80302, "激活号段有重叠"), + + /** + * 码格式错误 + */ + CODE_80303(80303, "码格式错误"), + + /** + * 该码未激活 + */ + CODE_80304(80304, "该码未激活"), + + /** + * 激活失败 + */ + CODE_80305(80305, "激活失败"), + + /** + * 码索引超出申请范围 + */ + CODE_80306(80306, "码索引超出申请范围"), + + /** + * 申请已存在 + */ + CODE_80307(80307, "申请已存在"), + + /** + * 子任务未完成 + */ + CODE_80308(80308, "子任务未完成"), + + /** + * 子任务文件过期 + */ + CODE_80309(80309, "子任务文件过期"), + + /** + * 子任务不存在 + */ + CODE_80310(80310, "子任务不存在"), + + /** + * 获取文件失败 + */ + CODE_80311(80311, "获取文件失败"), + + /** + * 加密数据失败 + */ + CODE_80312(80312, "加密数据失败"), + + /** + * 加密数据密钥不存在,请联系接口人申请 + */ + CODE_80313(80313, "加密数据密钥不存在,请联系接口人申请"), + + /** + * can not set page_id in AddGiftCardPage + */ + CODE_81000(81000, "can not set page_id in AddGiftCardPage"), + + /** + * card_list is empty + */ + CODE_81001(81001, "card_list is empty"), + + /** + * card_id is not giftcard + */ + CODE_81002(81002, "card_id is not giftcard"), + + /** + * banner_pic_url is empty + */ + CODE_81004(81004, "banner_pic_url is empty"), + + /** + * banner_pic_url is not from cdn + */ + CODE_81005(81005, "banner_pic_url is not from cdn"), + + /** + * giftcard_wrap_pic_url_list is empty + */ + CODE_81006(81006, "giftcard_wrap_pic_url_list is empty"), + + /** + * giftcard_wrap_pic_url_list is not from cdn + */ + CODE_81007(81007, "giftcard_wrap_pic_url_list is not from cdn"), + + /** + * address is empty + */ + CODE_81008(81008, "address is empty"), + + /** + * service_phone is invalid + */ + CODE_81009(81009, "service_phone is invalid"), + + /** + * biz_description is empty + */ + CODE_81010(81010, "biz_description is empty"), + + /** + * invalid page_id + */ + CODE_81011(81011, "invalid page_id"), + + /** + * invalid order_id + */ + CODE_81012(81012, "invalid order_id"), + + /** + * invalid TIME_RANGE, begin_time + 31day must less than end_time + */ + CODE_81013(81013, "invalid TIME_RANGE, begin_time + 31day must less than end_time"), + + /** + * invalid count! count must equal or less than 100 + */ + CODE_81014(81014, "invalid count! count must equal or less than 100"), + + /** + * invalid category_index OR category.title is empty OR is_banner but has_category_index + */ + CODE_81015(81015, "invalid category_index OR category.title is empty OR is_banner but has_category_index"), + + /** + * is_banner is more than 1 + */ + CODE_81016(81016, "is_banner is more than 1"), + + /** + * order status error, please check pay status or gifting_status + */ + CODE_81017(81017, "order status error, please check pay status or gifting_status"), + + /** + * refund reduplicate, the order is already refunded + */ + CODE_81018(81018, "refund reduplicate, the order is already refunded"), + + /** + * lock order fail! the order is refunding by another request + */ + CODE_81019(81019, "lock order fail! the order is refunding by another request"), + + /** + * Invalid Args! page_id.size!=0 but all==true, or page_id.size==0 but all==false. + */ + CODE_81020(81020, "Invalid Args! page_id.size!=0 but all==true, or page_id.size==0 but all==false."), + + /** + * Empty theme_pic_url. + */ + CODE_81021(81021, "Empty theme_pic_url."), + + /** + * Empty theme.title. + */ + CODE_81022(81022, "Empty theme.title."), + + /** + * Empty theme.title_title. + */ + CODE_81023(81023, "Empty theme.title_title."), + + /** + * Empty theme.item_list. + */ + CODE_81024(81024, "Empty theme.item_list."), + + /** + * Empty theme.pic_item_list. + */ + CODE_81025(81025, "Empty theme.pic_item_list."), + + /** + * Invalid theme.title.length . + */ + CODE_81026(81026, "Invalid theme.title.length ."), + + /** + * Empty background_pic_url. + */ + CODE_81027(81027, "Empty background_pic_url."), + + /** + * Empty default_gifting_msg. + */ + CODE_81028(81028, "Empty default_gifting_msg."), + + /** + * Duplicate order_id + */ + CODE_81029(81029, "Duplicate order_id"), + + /** + * PreAlloc code fail + */ + CODE_81030(81030, "PreAlloc code fail"), + + /** + * Too many theme participate_activity + */ + CODE_81031(81031, "Too many theme participate_activity"), + + /** + * biz_template_id not exist + */ + CODE_82000(82000, "biz_template_id not exist"), + + /** + * result_page_style_id not exist + */ + CODE_82001(82001, "result_page_style_id not exist"), + + /** + * deal_msg_style_id not exist + */ + CODE_82002(82002, "deal_msg_style_id not exist"), + + /** + * card_style_id not exist + */ + CODE_82003(82003, "card_style_id not exist"), + + /** + * biz template not audit OK + */ + CODE_82010(82010, "biz template not audit OK"), + + /** + * biz template banned + */ + CODE_82011(82011, "biz template banned"), + + /** + * user not use service first + */ + CODE_82020(82020, "user not use service first"), + + /** + * exceed long period + */ + CODE_82021(82021, "exceed long period"), + + /** + * exceed long period max send cnt + */ + CODE_82022(82022, "exceed long period max send cnt"), + + /** + * exceed short period max send cnt + */ + CODE_82023(82023, "exceed short period max send cnt"), + + /** + * exceed data size limit + */ + CODE_82024(82024, "exceed data size limit"), + + /** + * invalid url + */ + CODE_82025(82025, "invalid url"), + + /** + * service disabled + */ + CODE_82026(82026, "service disabled"), + + /** + * invalid miniprogram appid + */ + CODE_82027(82027, "invalid miniprogram appid"), + + /** + * wx_cs_code should not be empty. + */ + CODE_82100(82100, "wx_cs_code should not be empty."), + + /** + * wx_cs_code is invalid. + */ + CODE_82101(82101, "wx_cs_code is invalid."), + + /** + * wx_cs_code is expire. + */ + CODE_82102(82102, "wx_cs_code is expire."), + + /** + * user_ip should not be empty. + */ + CODE_82103(82103, "user_ip should not be empty."), + + /** + * 公众平台账号与服务id不匹配 + */ + CODE_82200(82200, "公众平台账号与服务id不匹配"), + + /** + * 该停车场已存在,请勿重复添加 + */ + CODE_82201(82201, "该停车场已存在,请勿重复添加"), + + /** + * 该停车场信息不存在,请先导入 + */ + CODE_82202(82202, "该停车场信息不存在,请先导入"), + + /** + * 停车场价格格式不正确 + */ + CODE_82203(82203, "停车场价格格式不正确"), + + /** + * appid与code不匹配 + */ + CODE_82204(82204, "appid与code不匹配"), + + /** + * wx_park_code字段为空 + */ + CODE_82205(82205, "wx_park_code字段为空"), + + /** + * wx_park_code无效或已过期 + */ + CODE_82206(82206, "wx_park_code无效或已过期"), + + /** + * 电话字段为空 + */ + CODE_82207(82207, "电话字段为空"), + + /** + * 关闭时间格式不正确 + */ + CODE_82208(82208, "关闭时间格式不正确"), + + /** + * 该appid不支持开通城市服务插件 + */ + CODE_82300(82300, "该appid不支持开通城市服务插件"), + + /** + * 添加插件失败 + */ + CODE_82301(82301, "添加插件失败"), + + /** + * 未添加城市服务插件 + */ + CODE_82302(82302, "未添加城市服务插件"), + + /** + * fileid无效 + */ + CODE_82303(82303, "fileid无效"), + + /** + * 临时文件过期 + */ + CODE_82304(82304, "临时文件过期"), + + /** + * there is some param not exist + */ + CODE_83000(83000, "there is some param not exist"), + + /** + * system error + */ + CODE_83001(83001, "system error"), + + /** + * create_url_sence_failed + */ + CODE_83002(83002, "create_url_sence_failed"), + + /** + * appid maybe error or retry + */ + CODE_83003(83003, "appid maybe error or retry"), + + /** + * create appid auth failed or retry + */ + CODE_83004(83004, "create appid auth failed or retry"), + + /** + * wxwebencrytoken errro + */ + CODE_83005(83005, "wxwebencrytoken errro"), + + /** + * wxwebencrytoken expired or no exist + */ + CODE_83006(83006, "wxwebencrytoken expired or no exist"), + + /** + * wxwebencrytoken expired + */ + CODE_83007(83007, "wxwebencrytoken expired"), + + /** + * wxwebencrytoken no auth + */ + CODE_83008(83008, "wxwebencrytoken no auth"), + + /** + * wxwebencrytoken not the mate with openid + */ + CODE_83009(83009, "wxwebencrytoken not the mate with openid"), + + /** + * no exist service + */ + CODE_83200(83200, "no exist service"), + + /** + * uin has not the service + */ + CODE_83201(83201, "uin has not the service"), + + /** + * params is not json or not json array + */ + CODE_83202(83202, "params is not json or not json array"), + + /** + * params num exceed 10 + */ + CODE_83203(83203, "params num exceed 10"), + + /** + * object has not key + */ + CODE_83204(83204, "object has not key"), + + /** + * key is not string + */ + CODE_83205(83205, "key is not string"), + + /** + * object has not value + */ + CODE_83206(83206, "object has not value"), + + /** + * value is not string + */ + CODE_83207(83207, "value is not string"), + + /** + * key or value is empty + */ + CODE_83208(83208, "key or value is empty"), + + /** + * key exist repeated + */ + CODE_83209(83209, "key exist repeated"), + + /** + * invalid identify id + */ + CODE_84001(84001, "invalid identify id"), + + /** + * user data expired + */ + CODE_84002(84002, "user data expired"), + + /** + * user data not exist + */ + CODE_84003(84003, "user data not exist"), + + /** + * video upload fail! + */ + CODE_84004(84004, "video upload fail!"), + + /** + * video download fail! please try again + */ + CODE_84005(84005, "video download fail! please try again"), + + /** + * name or id_card_number empty + */ + CODE_84006(84006, "name or id_card_number empty"), + + /** + * 微信号不存在或微信号设置为不可搜索 user not exist or user cannot be searched + */ + CODE_85001(85001, "微信号不存在或微信号设置为不可搜索"), + + /** + * 小程序绑定的体验者数量达到上限 number of tester reach bind limit + */ + CODE_85002(85002, "小程序绑定的体验者数量达到上限"), + + /** + * 微信号绑定的小程序体验者达到上限 user already bind too many weapps + */ + CODE_85003(85003, "微信号绑定的小程序体验者达到上限"), + + /** + * 微信号已经绑定 user already bind + */ + CODE_85004(85004, "微信号已经绑定"), + + /** + * appid not bind weapp + */ + CODE_85005(85005, "appid not bind weapp"), + + /** + * 标签格式错误 tag is in invalid format + */ + CODE_85006(85006, "标签格式错误"), + + /** + * 页面路径错误 page is in invalid format + */ + CODE_85007(85007, "页面路径错误"), + + /** + * 当前小程序没有已经审核通过的类目,请添加类目成功后重试 category is in invalid format + */ + CODE_85008(85008, "当前小程序没有已经审核通过的类目,请添加类目成功后重试"), + + /** + * 已经有正在审核的版本 already submit a version under auditing + */ + CODE_85009(85009, "已经有正在审核的版本"), + + /** + * item_list 有项目为空 missing required data + */ + CODE_85010(85010, "item_list 有项目为空"), + + /** + * 标题填写错误 title is in invalid format + */ + CODE_85011(85011, "标题填写错误"), + + /** + * 无效的审核 id invalid audit id + */ + CODE_85012(85012, "无效的审核 id"), + + /** + * 无效的自定义配置 invalid ext_json, parse fail or containing invalid path + */ + CODE_85013(85013, "无效的自定义配置"), + + /** + * 无效的模板编号 template not exist + */ + CODE_85014(85014, "无效的模板编号"), + + /** + * 该账号不是小程序账号/版本输入错误 + */ + CODE_85015(85015, "该账号不是小程序账号/版本输入错误"), + + /** + * 版本输入错误 + */ +// CODE_85015(85015, "版本输入错误"), + + /** + * 域名数量超过限制 ,总数不能超过1000 exceed valid domain count + */ + CODE_85016(85016, "域名数量超过限制 ,总数不能超过1000"), + + /** + * 没有新增域名,请确认小程序已经添加了域名或该域名是否没有在第三方平台添加 no domain to modify after filtered, please confirm the domain has been set in miniprogram or open + */ + CODE_85017(85017, "没有新增域名,请确认小程序已经添加了域名或该域名是否没有在第三方平台添加"), + + /** + * 域名没有在第三方平台设置 + */ + CODE_85018(85018, "域名没有在第三方平台设置"), + + /** + * 没有审核版本 no version is under auditing + */ + CODE_85019(85019, "没有审核版本"), + + /** + * 审核状态未满足发布 status not allowed + */ + CODE_85020(85020, "审核状态未满足发布"), + + /** + * status not allowed + */ + CODE_85021(85021, "status not allowed"), + + /** + * invalid action + */ + CODE_85022(85022, "invalid action"), + + /** + * 审核列表填写的项目数不在 1-5 以内 item size is not in valid range + */ + CODE_85023(85023, "审核列表填写的项目数不在 1-5 以内"), + + /** + * need complete material + */ + CODE_85024(85024, "need complete material"), + + /** + * this phone reach bind limit + */ + CODE_85025(85025, "this phone reach bind limit"), + + /** + * this wechat account reach bind limit + */ + CODE_85026(85026, "this wechat account reach bind limit"), + + /** + * this idcard reach bind limit + */ + CODE_85027(85027, "this idcard reach bind limit"), + + /** + * this contractor reach bind limit + */ + CODE_85028(85028, "this contractor reach bind limit"), + + /** + * nickname has used + */ + CODE_85029(85029, "nickname has used"), + + /** + * invalid nickname size(4-30) + */ + CODE_85030(85030, "invalid nickname size(4-30)"), + + /** + * nickname is forbidden + */ + CODE_85031(85031, "nickname is forbidden"), + + /** + * nickname is complained + */ + CODE_85032(85032, "nickname is complained"), + + /** + * nickname is illegal + */ + CODE_85033(85033, "nickname is illegal"), + + /** + * nickname is protected + */ + CODE_85034(85034, "nickname is protected"), + + /** + * nickname is forbidden for different contractor + */ + CODE_85035(85035, "nickname is forbidden for different contractor"), + + /** + * introduction is illegal + */ + CODE_85036(85036, "introduction is illegal"), + + /** + * store has added + */ + CODE_85038(85038, "store has added"), + + /** + * store has added by others + */ + CODE_85039(85039, "store has added by others"), + + /** + * store has added by yourseld + */ + CODE_85040(85040, "store has added by yourseld"), + + /** + * credential has used + */ + CODE_85041(85041, "credential has used"), + + /** + * nearby reach limit + */ + CODE_85042(85042, "nearby reach limit"), + + /** + * 模板错误 invalid template, something wrong? + */ + CODE_85043(85043, "模板错误"), + + /** + * 代码包超过大小限制 package exceed max limit + */ + CODE_85044(85044, "代码包超过大小限制"), + + /** + * ext_json 有不存在的路径 some path in ext_json not exist + */ + CODE_85045(85045, "ext_json 有不存在的路径"), + + /** + * tabBar 中缺少 path pagepath missing in tabbar list + */ + CODE_85046(85046, "tabBar 中缺少 path"), + + /** + * pages 字段为空 pages are empty + */ + CODE_85047(85047, "pages 字段为空"), + + /** + * ext_json 解析失败 parse ext_json fail + */ + CODE_85048(85048, "ext_json 解析失败"), + + /** + * reach headimg or introduction quota limit + */ + CODE_85049(85049, "reach headimg or introduction quota limit"), + + /** + * verifying, don't apply again + */ + CODE_85050(85050, "verifying, don't apply again"), + + /** + * version_desc或者preview_info超限 data too large + */ + CODE_85051(85051, "version_desc或者preview_info超限"), + + /** + * app is already released + */ + CODE_85052(85052, "app is already released"), + + /** + * please apply merchant first + */ + CODE_85053(85053, "please apply merchant first"), + + /** + * poi_id is null, please upgrade first + */ + CODE_85054(85054, "poi_id is null, please upgrade first"), + + /** + * map_poi_id is invalid + */ + CODE_85055(85055, "map_poi_id is invalid"), + + /** + * mediaid is invalid + */ + CODE_85056(85056, "mediaid is invalid"), + + /** + * invalid widget data format + */ + CODE_85057(85057, "invalid widget data format"), + + /** + * no valid audit_id exist + */ + CODE_85058(85058, "no valid audit_id exist"), + + /** + * overseas access deny + */ + CODE_85059(85059, "overseas access deny"), + + /** + * invalid taskid + */ + CODE_85060(85060, "invalid taskid"), + + /** + * this phone reach bind limit + */ + CODE_85061(85061, "this phone reach bind limit"), + + /** + * this phone in black list + */ + CODE_85062(85062, "this phone in black list"), + + /** + * idcard in black list + */ + CODE_85063(85063, "idcard in black list"), + + /** + * 找不到模板 template not found + */ + CODE_85064(85064, "找不到模板"), + + /** + * 模板库已满 template list is full + */ + CODE_85065(85065, "模板库已满"), + + /** + * 链接错误 illegal prefix + */ + CODE_85066(85066, "链接错误"), + + /** + * input data error + */ + CODE_85067(85067, "input data error"), + + /** + * 测试链接不是子链接 test url is not the sub prefix + */ + CODE_85068(85068, "测试链接不是子链接"), + + /** + * 校验文件失败 check confirm file fail + */ + CODE_85069(85069, "校验文件失败"), + + /** + * 个人类型小程序无法设置二维码规则 prefix in black list + */ + CODE_85070(85070, "个人类型小程序无法设置二维码规则"), + + /** + * 已添加该链接,请勿重复添加 prefix added repeated + */ + CODE_85071(85071, "已添加该链接,请勿重复添加"), + + /** + * 该链接已被占用 prefix owned by other + */ + CODE_85072(85072, "该链接已被占用"), + + /** + * 二维码规则已满 prefix beyond limit + */ + CODE_85073(85073, "二维码规则已满"), + + /** + * 小程序未发布, 小程序必须先发布代码才可以发布二维码跳转规则 not published + */ + CODE_85074(85074, "小程序未发布, 小程序必须先发布代码才可以发布二维码跳转规则"), + + /** + * 个人类型小程序无法设置二维码规则 can not access + */ + CODE_85075(85075, "个人类型小程序无法设置二维码规则"), + + /** + * 小程序类目信息失效(类目中含有官方下架的类目,请重新选择类目) some category you choose is no longger supported, please choose other category + */ + CODE_85077(85077, "小程序类目信息失效(类目中含有官方下架的类目,请重新选择类目)"), + + /** + * operator info error + */ + CODE_85078(85078, "operator info error"), + + /** + * 小程序没有线上版本,不能进行灰度 miniprogram has no online release + */ + CODE_85079(85079, "小程序没有线上版本,不能进行灰度"), + + /** + * 小程序提交的审核未审核通过 miniprogram commit not approved + */ + CODE_85080(85080, "小程序提交的审核未审核通过"), + + /** + * 无效的发布比例 invalid gray percentage + */ + CODE_85081(85081, "无效的发布比例"), + + /** + * 当前的发布比例需要比之前设置的高 gray percentage too low + */ + CODE_85082(85082, "当前的发布比例需要比之前设置的高"), + + /** + * 搜索标记位被封禁,无法修改 search status is banned + */ + CODE_85083(85083, "搜索标记位被封禁,无法修改"), + + /** + * 非法的 status 值,只能填 0 或者 1 search status invalid + */ + CODE_85084(85084, "非法的 status 值,只能填 0 或者 1"), + + /** + * 小程序提审数量已达本月上限,请点击查看 submit audit reach limit pleasetry later + */ + CODE_85085(85085, "小程序提审数量已达本月上限,请点击查看"), + + /** + * 提交代码审核之前需提前上传代码 must commit before submit audit + */ + CODE_85086(85086, "提交代码审核之前需提前上传代码"), + + /** + * 小程序已使用 api navigateToMiniProgram,请声明跳转 appid 列表后再次提交 navigatetominiprogram appid list empty + */ + CODE_85087(85087, "小程序已使用 api navigateToMiniProgram,请声明跳转 appid 列表后再次提交"), + + /** + * no qbase privilege + */ + CODE_85088(85088, "no qbase privilege"), + + /** + * config not found + */ + CODE_85089(85089, "config not found"), + + /** + * wait and commit for this exappid later + */ + CODE_85090(85090, "wait and commit for this exappid later"), + + /** + * 小程序的搜索开关被关闭。请访问设置页面打开开关再重试 search status was turned off + */ + CODE_85091(85091, "小程序的搜索开关被关闭。请访问设置页面打开开关再重试"), + + /** + * preview_info格式错误 invalid preview_info format + */ + CODE_85092(85092, "preview_info格式错误"), + + /** + * preview_info 视频或者图片个数超限 invalid preview_info size + */ + CODE_85093(85093, "preview_info 视频或者图片个数超限"), + + /** + * 需提供审核机制说明信息 need add ugc declare + */ + CODE_85094(85094, "需提供审核机制说明信息"), + + /** + * 小程序不能发送该运动类型或运动类型不存在 + */ + CODE_85101(85101, "小程序不能发送该运动类型或运动类型不存在"), + + /** + * 数值异常 + */ + CODE_85102(85102, "数值异常"), + + /** + * 不是由第三方代小程序进行调用 should be called only from third party + */ + CODE_86000(86000, "不是由第三方代小程序进行调用"), + + /** + * 不存在第三方的已经提交的代码 component experience version not exists + */ + CODE_86001(86001, "不存在第三方的已经提交的代码"), + + /** + * 小程序还未设置昵称、头像、简介。请先设置完后再重新提交 miniprogram have not completed init procedure + */ + CODE_86002(86002, "小程序还未设置昵称、头像、简介。请先设置完后再重新提交"), + + /** + * component do not has category mall + */ + CODE_86003(86003, "component do not has category mall"), + + /** + * invalid wechat + */ + CODE_86004(86004, "invalid wechat"), + + /** + * wechat limit frequency + */ + CODE_86005(86005, "wechat limit frequency"), + + /** + * has no quota to send group msg + */ + CODE_86006(86006, "has no quota to send group msg"), + + /** + * 小程序禁止提交 + */ + CODE_86007(86007, "小程序禁止提交"), + + /** + * 服务商被处罚,限制全部代码提审能力 + */ + CODE_86008(86008, "服务商被处罚,限制全部代码提审能力"), + + /** + * 服务商新增小程序代码提审能力被限制 + */ + CODE_86009(86009, "服务商新增小程序代码提审能力被限制"), + + /** + * 服务商迭代小程序代码提审能力被限制 + */ + CODE_86010(86010, "服务商迭代小程序代码提审能力被限制"), + + /** + * 小游戏不能提交 this is game miniprogram, submit audit is forbidden + */ + CODE_87006(87006, "小游戏不能提交"), + + /** + * session_key is not existd or expired + */ + CODE_87007(87007, "session_key is not existd or expired"), + + /** + * invalid sig_method + */ + CODE_87008(87008, "invalid sig_method"), + + /** + * 无效的签名 invalid signature + */ + CODE_87009(87009, "无效的签名"), + + /** + * invalid buffer size + */ + CODE_87010(87010, "invalid buffer size"), + + /** + * 现网已经在灰度发布,不能进行版本回退 wxa has a gray release plan, forbid revert release + */ + CODE_87011(87011, "现网已经在灰度发布,不能进行版本回退"), + + /** + * 该版本不能回退,可能的原因:1:无上一个线上版用于回退 2:此版本为已回退版本,不能回退 3:此版本为回退功能上线之前的版本,不能回退 forbid revert this version release + */ + CODE_87012(87012, "该版本不能回退,可能的原因:1:无上一个线上版用于回退 2:此版本为已回退版本,不能回退 3:此版本为回退功能上线之前的版本,不能回退"), + + /** + * 撤回次数达到上限(每天5次,每个月 10 次) no quota to undo code + */ + CODE_87013(87013, "撤回次数达到上限(每天5次,每个月 10 次)"), + + /** + * risky content + */ + CODE_87014(87014, "risky content"), + + /** + * query timeout, try a content with less size + */ + CODE_87015(87015, "query timeout, try a content with less size"), + + /** + * some key-value in list meet length exceed + */ + CODE_87016(87016, "some key-value in list meet length exceed"), + + /** + * user storage size exceed, delete some keys and try again + */ + CODE_87017(87017, "user storage size exceed, delete some keys and try again"), + + /** + * user has stored too much keys. delete some keys and try again + */ + CODE_87018(87018, "user has stored too much keys. delete some keys and try again"), + + /** + * some keys in list meet length exceed + */ + CODE_87019(87019, "some keys in list meet length exceed"), + + /** + * need friend + */ + CODE_87080(87080, "need friend"), + + /** + * invalid openid + */ + CODE_87081(87081, "invalid openid"), + + /** + * invalid key + */ + CODE_87082(87082, "invalid key"), + + /** + * invalid operation + */ + CODE_87083(87083, "invalid operation"), + + /** + * invalid opnum + */ + CODE_87084(87084, "invalid opnum"), + + /** + * check fail + */ + CODE_87085(87085, "check fail"), + + /** + * without comment privilege + */ + CODE_88000(88000, "without comment privilege"), + + /** + * msg_data is not exists + */ + CODE_88001(88001, "msg_data is not exists"), + + /** + * the article is limit for safety + */ + CODE_88002(88002, "the article is limit for safety"), + + /** + * elected comment upper limit + */ + CODE_88003(88003, "elected comment upper limit"), + + /** + * comment was deleted by user + */ + CODE_88004(88004, "comment was deleted by user"), + + /** + * already reply + */ + CODE_88005(88005, "already reply"), + + /** + * reply content beyond max len or content len is zero + */ + CODE_88007(88007, "reply content beyond max len or content len is zero"), + + /** + * comment is not exists + */ + CODE_88008(88008, "comment is not exists"), + + /** + * reply is not exists + */ + CODE_88009(88009, "reply is not exists"), + + /** + * count range error. cout <= 0 or count > 50 + */ + CODE_88010(88010, "count range error. cout <= 0 or count > 50"), + + /** + * the article is limit for safety + */ + CODE_88011(88011, "the article is limit for safety"), + + /** + * account has bound open,该公众号/小程序已经绑定了开放平台帐号 account has bound open + */ + CODE_89000(89000, "account has bound open,该公众号/小程序已经绑定了开放平台帐号"), + + /** + * not same contractor,Authorizer 与开放平台帐号主体不相同 not same contractor + */ + CODE_89001(89001, "not same contractor,Authorizer 与开放平台帐号主体不相同"), + + /** + * open not exists,该公众号/小程序未绑定微信开放平台帐号。 open not exists + */ + CODE_89002(89002, "open not exists,该公众号/小程序未绑定微信开放平台帐号。"), + + /** + * 该开放平台帐号并非通过 api 创建,不允许操作 open is not created by api + */ + CODE_89003(89003, "该开放平台帐号并非通过 api 创建,不允许操作"), + + /** + * 该开放平台帐号所绑定的公众号/小程序已达上限(100 个) + */ + CODE_89004(89004, "该开放平台帐号所绑定的公众号/小程序已达上限(100 个)"), + + /** + * without add video ability, the ability was banned + */ + CODE_89005(89005, "without add video ability, the ability was banned"), + + /** + * without upload video ability, the ability was banned + */ + CODE_89006(89006, "without upload video ability, the ability was banned"), + + /** + * wxa quota limit + */ + CODE_89007(89007, "wxa quota limit"), + + /** + * overseas account can not link + */ + CODE_89008(89008, "overseas account can not link"), + + /** + * wxa reach link limit + */ + CODE_89009(89009, "wxa reach link limit"), + + /** + * link message has sent + */ + CODE_89010(89010, "link message has sent"), + + /** + * can not unlink nearby wxa + */ + CODE_89011(89011, "can not unlink nearby wxa"), + + /** + * can not unlink store or mall + */ + CODE_89012(89012, "can not unlink store or mall"), + + /** + * wxa is banned + */ + CODE_89013(89013, "wxa is banned"), + + /** + * support version error + */ + CODE_89014(89014, "support version error"), + + /** + * has linked wxa + */ + CODE_89015(89015, "has linked wxa"), + + /** + * reach same realname quota + */ + CODE_89016(89016, "reach same realname quota"), + + /** + * reach different realname quota + */ + CODE_89017(89017, "reach different realname quota"), + + /** + * unlink message has sent + */ + CODE_89018(89018, "unlink message has sent"), + + /** + * 业务域名无更改,无需重复设置 webview domain not change + */ + CODE_89019(89019, "业务域名无更改,无需重复设置"), + + /** + * 尚未设置小程序业务域名,请先在第三方平台中设置小程序业务域名后在调用本接口 open's webview domain is null! Need to set open's webview domain first! + */ + CODE_89020(89020, "尚未设置小程序业务域名,请先在第三方平台中设置小程序业务域名后在调用本接口"), + + /** + * 请求保存的域名不是第三方平台中已设置的小程序业务域名或子域名 request domain is not open's webview domain! + */ + CODE_89021(89021, "请求保存的域名不是第三方平台中已设置的小程序业务域名或子域名"), + + /** + * delete domain is not exist! + */ + CODE_89022(89022, "delete domain is not exist!"), + + /** + * 业务域名数量超过限制,最多可以添加100个业务域名 webview domain exceed limit + */ + CODE_89029(89029, "业务域名数量超过限制,最多可以添加100个业务域名"), + + /** + * operation reach month limit + */ + CODE_89030(89030, "operation reach month limit"), + + /** + * user bind reach limit + */ + CODE_89031(89031, "user bind reach limit"), + + /** + * weapp bind members reach limit + */ + CODE_89032(89032, "weapp bind members reach limit"), + + /** + * empty wx or openid + */ + CODE_89033(89033, "empty wx or openid"), + + /** + * userstr is invalid + */ + CODE_89034(89034, "userstr is invalid"), + + /** + * linking from mp + */ + CODE_89035(89035, "linking from mp"), + + /** + * 个人小程序不支持调用 setwebviewdomain 接口 not support single + */ + CODE_89231(89231, "个人小程序不支持调用 setwebviewdomain 接口"), + + /** + * hit black contractor + */ + CODE_89235(89235, "hit black contractor"), + + /** + * 该插件不能申请 this plugin can not apply + */ + CODE_89236(89236, "该插件不能申请"), + + /** + * 已经添加该插件 plugin has send apply message or already bind + */ + CODE_89237(89237, "已经添加该插件"), + + /** + * 申请或使用的插件已经达到上限 plugin count reach limit + */ + CODE_89238(89238, "申请或使用的插件已经达到上限"), + + /** + * 该插件不存在 plugin no exist + */ + CODE_89239(89239, "该插件不存在"), + + /** + * only applying status can be agreed or refused + */ + CODE_89240(89240, "only applying status can be agreed or refused"), + + /** + * only refused status can be deleted, please refused first + */ + CODE_89241(89241, "only refused status can be deleted, please refused first"), + + /** + * appid is no in the apply list, make sure appid is right + */ + CODE_89242(89242, "appid is no in the apply list, make sure appid is right"), + + /** + * 该申请为“待确认”状态,不可删除 can not delete apply request in 24 hours + */ + CODE_89243(89243, "该申请为“待确认”状态,不可删除"), + + /** + * 不存在该插件 appid plugin appid is no in the plugin list, make sure plugin appid is right + */ + CODE_89244(89244, "不存在该插件 appid"), + + /** + * mini program forbidden to link + */ + CODE_89245(89245, "mini program forbidden to link"), + + /** + * plugins with special category are used only by specific apps + */ + CODE_89246(89246, "plugins with special category are used only by specific apps"), + + /** + * 系统内部错误 inner error, retry after some while + */ + CODE_89247(89247, "系统内部错误"), + + /** + * invalid code type + */ + CODE_89248(89248, "invalid code type"), + + /** + * task running + */ + CODE_89249(89249, "task running"), + + /** + * 内部错误 inner error, retry after some while + */ + CODE_89250(89250, "内部错误"), + + /** + * 模板消息已下发,待法人人脸核身校验 legal person checking + */ + CODE_89251(89251, "模板消息已下发,待法人人脸核身校验"), + + /** + * 法人&企业信息一致性校验中 front checking + */ + CODE_89253(89253, "法人&企业信息一致性校验中"), + + /** + * lack of some component rights + */ + CODE_89254(89254, "lack of some component rights"), + + /** + * code参数无效,请检查code长度以及内容是否正确;注意code_type的值不同需要传的code长度不一样 enterprise code invalid + */ + CODE_89255(89255, "code参数无效,请检查code长度以及内容是否正确;注意code_type的值不同需要传的code长度不一样"), + + /** + * token 信息有误 no component info + */ + CODE_89256(89256, "token 信息有误"), + + /** + * 该插件版本不支持快速更新 no such version + */ + CODE_89257(89257, "该插件版本不支持快速更新"), + + /** + * 当前小程序帐号存在灰度发布中的版本,不可操作快速更新 code is gray online + */ + CODE_89258(89258, "当前小程序帐号存在灰度发布中的版本,不可操作快速更新"), + + /** + * zhibo plugin is not allow to delete + */ + CODE_89259(89259, "zhibo plugin is not allow to delete"), + + /** + * 订单无效 invalid trade + */ + CODE_89300(89300, "订单无效"), + + /** + * 系统不稳定,请稍后再试,如多次失败请通过社区反馈 + */ + CODE_89401(89401, "系统不稳定,请稍后再试,如多次失败请通过社区反馈"), + + /** + * 该小程序不在待审核队列,请检查是否已提交审核或已审完 + */ + CODE_89402(89402, "该小程序不在待审核队列,请检查是否已提交审核或已审完"), + + /** + * 本单属于平台不支持加急种类,请等待正常审核流程 + */ + CODE_89403(89403, "本单属于平台不支持加急种类,请等待正常审核流程"), + + /** + * 本单已加速成功,请勿重复提交 + */ + CODE_89404(89404, "本单已加速成功,请勿重复提交"), + + /** + * 本月加急额度已用完,请提高提审质量以获取更多额度 + */ + CODE_89405(89405, "本月加急额度已用完,请提高提审质量以获取更多额度"), + + /** + * 公众号有未处理的确认请求,请稍候重试 + */ + CODE_89501(89501, "公众号有未处理的确认请求,请稍候重试"), + + /** + * 请耐心等待管理员确认 + */ + CODE_89502(89502, "请耐心等待管理员确认"), + + /** + * 此次调用需要管理员确认,请耐心等候 + */ + CODE_89503(89503, "此次调用需要管理员确认,请耐心等候"), + + /** + * 正在等管理员确认,请耐心等待 + */ + CODE_89504(89504, "正在等管理员确认,请耐心等待"), + + /** + * 正在等管理员确认,请稍候重试 + */ + CODE_89505(89505, "正在等管理员确认,请稍候重试"), + + /** + * 该IP调用求请求已被公众号管理员拒绝,请24小时后再试,建议调用前与管理员沟通确认 + */ + CODE_89506(89506, "该IP调用求请求已被公众号管理员拒绝,请24小时后再试,建议调用前与管理员沟通确认"), + + /** + * 该IP调用求请求已被公众号管理员拒绝,请1小时后再试,建议调用前与管理员沟通确认 + */ + CODE_89507(89507, "该IP调用求请求已被公众号管理员拒绝,请1小时后再试,建议调用前与管理员沟通确认"), + + /** + * invalid order id + */ + CODE_90001(90001, "invalid order id"), + + /** + * invalid busi id + */ + CODE_90002(90002, "invalid busi id"), + + /** + * invalid bill date + */ + CODE_90003(90003, "invalid bill date"), + + /** + * invalid bill type + */ + CODE_90004(90004, "invalid bill type"), + + /** + * invalid platform + */ + CODE_90005(90005, "invalid platform"), + + /** + * bill not exists + */ + CODE_90006(90006, "bill not exists"), + + /** + * invalid openid + */ + CODE_90007(90007, "invalid openid"), + + /** + * mp_sig error + */ + CODE_90009(90009, "mp_sig error"), + + /** + * no session + */ + CODE_90010(90010, "no session"), + + /** + * sig error + */ + CODE_90011(90011, "sig error"), + + /** + * order exist + */ + CODE_90012(90012, "order exist"), + + /** + * balance not enough + */ + CODE_90013(90013, "balance not enough"), + + /** + * order has been confirmed + */ + CODE_90014(90014, "order has been confirmed"), + + /** + * order has been canceled + */ + CODE_90015(90015, "order has been canceled"), + + /** + * order is being processed + */ + CODE_90016(90016, "order is being processed"), + + /** + * no privilege + */ + CODE_90017(90017, "no privilege"), + + /** + * invalid parameter + */ + CODE_90018(90018, "invalid parameter"), + + /** + * 不是公众号快速创建的小程序 not fast register + */ + CODE_91001(91001, "不是公众号快速创建的小程序"), + + /** + * 小程序发布后不可改名 has published + */ + CODE_91002(91002, "小程序发布后不可改名"), + + /** + * 改名状态不合法 invalid change stat + */ + CODE_91003(91003, "改名状态不合法"), + + /** + * 昵称不合法 invalid nickname + */ + CODE_91004(91004, "昵称不合法"), + + /** + * 昵称 15 天主体保护 nickname protected + */ + CODE_91005(91005, "昵称 15 天主体保护"), + + /** + * 昵称命中微信号 nickname used by username + */ + CODE_91006(91006, "昵称命中微信号"), + + /** + * 昵称已被占用 nickname used + */ + CODE_91007(91007, "昵称已被占用"), + + /** + * 昵称命中 7 天侵权保护期 nickname protected + */ + CODE_91008(91008, "昵称命中 7 天侵权保护期"), + + /** + * 需要提交材料 nickname need proof + */ + CODE_91009(91009, "需要提交材料"), + + /** + * 其他错误 + */ + CODE_91010(91010, "其他错误"), + + /** + * 查不到昵称修改审核单信息 + */ + CODE_91011(91011, "查不到昵称修改审核单信息"), + + /** + * 其它错误 + */ + CODE_91012(91012, "其它错误"), + + /** + * 占用名字过多 lock name too more + */ + CODE_91013(91013, "占用名字过多"), + + /** + * +号规则 同一类型关联名主体不一致 diff master plus + */ + CODE_91014(91014, "+号规则 同一类型关联名主体不一致"), + + /** + * 原始名不同类型主体不一致 diff master + */ + CODE_91015(91015, "原始名不同类型主体不一致"), + + /** + * 名称占用者 ≥2 name more owner + */ + CODE_91016(91016, "名称占用者 ≥2"), + + /** + * +号规则 不同类型关联名主体不一致 other diff master plus + */ + CODE_91017(91017, "+号规则 不同类型关联名主体不一致"), + + /** + * 组织类型小程序发布后,侵权被清空昵称,需走认证改名 + */ + CODE_91018(91018, "组织类型小程序发布后,侵权被清空昵称,需走认证改名"), + + /** + * 小程序正在审核中 + */ + CODE_91019(91019, "小程序正在审核中"), + + /** + * 该经营资质已添加,请勿重复添加 + */ + CODE_92000(92000, "该经营资质已添加,请勿重复添加"), + + /** + * 附近地点添加数量达到上线,无法继续添加 + */ + CODE_92002(92002, "附近地点添加数量达到上线,无法继续添加"), + + /** + * 地点已被其它小程序占用 + */ + CODE_92003(92003, "地点已被其它小程序占用"), + + /** + * 附近功能被封禁 + */ + CODE_92004(92004, "附近功能被封禁"), + + /** + * 地点正在审核中 + */ + CODE_92005(92005, "地点正在审核中"), + + /** + * 地点正在展示小程序 + */ + CODE_92006(92006, "地点正在展示小程序"), + + /** + * 地点审核失败 + */ + CODE_92007(92007, "地点审核失败"), + + /** + * 小程序未展示在该地点 + */ + CODE_92008(92008, "小程序未展示在该地点"), + + /** + * 小程序未上架或不可见 + */ + CODE_93009(93009, "小程序未上架或不可见"), + + /** + * 地点不存在 + */ + CODE_93010(93010, "地点不存在"), + + /** + * 个人类型小程序不可用 + */ + CODE_93011(93011, "个人类型小程序不可用"), + + /** + * 非普通类型小程序(门店小程序、小店小程序等)不可用 + */ + CODE_93012(93012, "非普通类型小程序(门店小程序、小店小程序等)不可用"), + + /** + * 从腾讯地图获取地址详细信息失败 + */ + CODE_93013(93013, "从腾讯地图获取地址详细信息失败"), + + /** + * 同一资质证件号重复添加 + */ + CODE_93014(93014, "同一资质证件号重复添加"), + + /** + * 附近类目审核中 + */ + CODE_93015(93015, "附近类目审核中"), + + /** + * 服务标签个数超限制(官方最多5个,自定义最多4个) + */ + CODE_93016(93016, "服务标签个数超限制(官方最多5个,自定义最多4个)"), + + /** + * 服务标签或者客服的名字不符合要求 + */ + CODE_93017(93017, "服务标签或者客服的名字不符合要求"), + + /** + * 服务能力中填写的小程序appid不是同主体小程序 + */ + CODE_93018(93018, "服务能力中填写的小程序appid不是同主体小程序"), + + /** + * 申请类目之后才能添加附近地点 + */ + CODE_93019(93019, "申请类目之后才能添加附近地点"), + + /** + * qualification_list无效 + */ + CODE_93020(93020, "qualification_list无效"), + + /** + * company_name字段为空 + */ + CODE_93021(93021, "company_name字段为空"), + + /** + * credential字段为空 + */ + CODE_93022(93022, "credential字段为空"), + + /** + * address字段为空 + */ + CODE_93023(93023, "address字段为空"), + + /** + * qualification_list字段为空 + */ + CODE_93024(93024, "qualification_list字段为空"), + + /** + * 服务appid对应的path不存在 + */ + CODE_93025(93025, "服务appid对应的path不存在"), + + /** + * missing cert_serialno + */ + CODE_94001(94001, "missing cert_serialno"), + + /** + * use not register wechat pay + */ + CODE_94002(94002, "use not register wechat pay"), + + /** + * invalid sign + */ + CODE_94003(94003, "invalid sign"), + + /** + * user do not has real name info + */ + CODE_94004(94004, "user do not has real name info"), + + /** + * invalid user token + */ + CODE_94005(94005, "invalid user token"), + + /** + * appid unauthorized + */ + CODE_94006(94006, "appid unauthorized"), + + /** + * appid unbind mchid + */ + CODE_94007(94007, "appid unbind mchid"), + + /** + * invalid timestamp + */ + CODE_94008(94008, "invalid timestamp"), + + /** + * invalid cert_serialno, cert_serialno's size should be 40 + */ + CODE_94009(94009, "invalid cert_serialno, cert_serialno's size should be 40"), + + /** + * invalid mch_id + */ + CODE_94010(94010, "invalid mch_id"), + + /** + * timestamp expired + */ + CODE_94011(94011, "timestamp expired"), + + /** + * appid和商户号的绑定关系不存在 + */ + CODE_94012(94012, "appid和商户号的绑定关系不存在"), + + /** + * wxcode decode fail + */ + CODE_95001(95001, "wxcode decode fail"), + + /** + * wxcode recognize unautuorized + */ + CODE_95002(95002, "wxcode recognize unautuorized"), + + /** + * get product by page args invalid + */ + CODE_95101(95101, "get product by page args invalid"), + + /** + * get product materials by cond args invalid + */ + CODE_95102(95102, "get product materials by cond args invalid"), + + /** + * material id list size out of limit + */ + CODE_95103(95103, "material id list size out of limit"), + + /** + * import product frequence out of limit + */ + CODE_95104(95104, "import product frequence out of limit"), + + /** + * mp is importing products, api is rejected to import + */ + CODE_95105(95105, "mp is importing products, api is rejected to import"), + + /** + * api is rejected to import, need to set commission ratio on mp first + */ + CODE_95106(95106, "api is rejected to import, need to set commission ratio on mp first"), + + /** + * invalid image url + */ + CODE_101000(101000, "无效图片链接"), + + /** + * certificate not found + */ + CODE_101001(101001, "未找到证书"), + + /** + * not enough market quota + */ + CODE_101002(101002, "not enough market quota"), + + /** + * 入参错误 + */ + CODE_200002(200002, "入参错误"), + + /** + * 此账号已被封禁,无法操作 + */ + CODE_200011(200011, "此账号已被封禁,无法操作"), + + /** + * 个人模板数已达上限,上限25个 + */ + CODE_200012(200012, "个人模板数已达上限,上限25个"), + + /** + * 此模板已被封禁,无法选用 + */ + CODE_200013(200013, "此模板已被封禁,无法选用"), + + /** + * 模板 tid 参数错误 + */ + CODE_200014(200014, "模板 tid 参数错误"), + + /** + * start 参数错误 + */ + CODE_200016(200016, "start 参数错误"), + + /** + * limit 参数错误 + */ + CODE_200017(200017, "limit 参数错误"), + + /** + * 类目 ids 缺失 + */ + CODE_200018(200018, "类目 ids 缺失"), + + /** + * 类目 ids 不合法 + */ + CODE_200019(200019, "类目 ids 不合法"), + + /** + * 关键词列表 kidList 参数错误 + */ + CODE_200020(200020, "关键词列表 kidList 参数错误"), + + /** + * 场景描述 sceneDesc 参数错误 + */ + CODE_200021(200021, "场景描述 sceneDesc 参数错误"), + + /** + * 禁止创建/更新商品(如商品创建功能被封禁) 或 禁止编辑&更新房间 + */ + CODE_300001(300001, "禁止创建/更新商品(如商品创建功能被封禁) 或 禁止编辑&更新房间"), + + /** + * 名称长度不符合规则 + */ + CODE_300002(300002, "名称长度不符合规则"), + + /** + * 价格输入不合规(如现价比原价大、传入价格非数字等) + */ + CODE_300003(300003, "价格输入不合规(如现价比原价大、传入价格非数字等)"), + + /** + * 商品名称存在违规违法内容 + */ + CODE_300004(300004, "商品名称存在违规违法内容"), + + /** + * 商品图片存在违规违法内容 + */ + CODE_300005(300005, "商品图片存在违规违法内容"), + + /** + * 图片上传失败(如mediaID过期) + */ + CODE_300006(300006, "图片上传失败(如mediaID过期)"), + + /** + * 线上小程序版本不存在该链接 + */ + CODE_300007(300007, "线上小程序版本不存在该链接"), + + /** + * 添加商品失败 + */ + CODE_300008(300008, "添加商品失败"), + + /** + * 商品审核撤回失败 + */ + CODE_300009(300009, "商品审核撤回失败"), + + /** + * 商品审核状态不对(如商品审核中) + */ + CODE_300010(300010, "商品审核状态不对(如商品审核中)"), + + /** + * 操作非法(API不允许操作非API创建的商品) + */ + CODE_300011(300011, "操作非法(API不允许操作非API创建的商品)"), + + /** + * 没有提审额度(每天500次提审额度) + */ + CODE_300012(300012, "没有提审额度(每天500次提审额度)"), + + /** + * 提审失败 + */ + CODE_300013(300013, "提审失败"), + + /** + * 审核中,无法删除(非零代表失败) + */ + CODE_300014(300014, "审核中,无法删除(非零代表失败)"), + + /** + * 商品未提审 + */ + CODE_300017(300017, "商品未提审"), + + /** + * 商品添加成功,审核失败 + */ + CODE_300021(300021, "商品添加成功,审核失败"), + + /** + * 此房间号不存在 + */ + CODE_300022(300022, "此房间号不存在"), + + /** + * 房间状态 拦截(当前房间状态不允许此操作) + */ + CODE_300023(300023, "房间状态 拦截(当前房间状态不允许此操作)"), + + /** + * 商品不存在 + */ + CODE_300024(300024, "商品不存在"), + + /** + * 商品审核未通过 + */ + CODE_300025(300025, "商品审核未通过"), + + /** + * 房间商品数量已经满额 + */ + CODE_300026(300026, "房间商品数量已经满额"), + + /** + * 导入商品失败 + */ + CODE_300027(300027, "导入商品失败"), + + /** + * 房间名称违规 + */ + CODE_300028(300028, "房间名称违规"), + + /** + * 主播昵称违规 + */ + CODE_300029(300029, "主播昵称违规"), + + /** + * 主播微信号不合法 + */ + CODE_300030(300030, "主播微信号不合法"), + + /** + * 直播间封面图不合规 + */ + CODE_300031(300031, "直播间封面图不合规"), + + /** + * 直播间分享图违规 + */ + CODE_300032(300032, "直播间分享图违规"), + + /** + * 添加商品超过直播间上限 + */ + CODE_300033(300033, "添加商品超过直播间上限"), + + /** + * 主播微信昵称长度不符合要求 + */ + CODE_300034(300034, "主播微信昵称长度不符合要求"), + + /** + * 主播微信号不存在 + */ + CODE_300035(300035, "主播微信号不存在"), + + /** + * 主播微信号未实名认证 + */ + CODE_300036(300036, "主播微信号未实名认证"), + + /** + * invalid file name + */ + CODE_600001(600001, "invalid file name"), + + /** + * no permission to upload file + */ + CODE_600002(600002, "no permission to upload file"), + + /** + * invalid size of source + */ + CODE_600003(600003, "invalid size of source"), + + /** + * 票据已存在 + */ + CODE_928000(928000, "票据已存在"), + + /** + * 票据不存在 + */ + CODE_928001(928001, "票据不存在"), + + /** + * sysem error + */ + CODE_930555(930555, "sysem error"), + + /** + * delivery timeout + */ + CODE_930556(930556, "delivery timeout"), + + /** + * delivery system error + */ + CODE_930557(930557, "delivery system error"), + + /** + * delivery logic error + */ + CODE_930558(930558, "delivery logic error"), + + /** + * 沙盒环境openid无效 invaild openid + */ + CODE_930559(930559, "沙盒环境openid无效"), + + /** + * shopid need bind first + */ + CODE_930560(930560, "shopid need bind first"), + + /** + * 参数错误 args error + */ + CODE_930561(930561, "参数错误"), + + /** + * order already exists + */ + CODE_930562(930562, "order already exists"), + + /** + * 订单不存在 order not exists + */ + CODE_930563(930563, "订单不存在"), + + /** + * 沙盒环境调用无配额 quota run out, try next day + */ + CODE_930564(930564, "沙盒环境调用无配额"), + + /** + * order finished + */ + CODE_930565(930565, "order finished"), + + /** + * not support, plz auth at mp.weixin.qq.com + */ + CODE_930566(930566, "not support, plz auth at mp.weixin.qq.com"), + + /** + * shop arg error + */ + CODE_930567(930567, "shop arg error"), + + /** + * 不支持个人类型小程序 not personal account + */ + CODE_930568(930568, "不支持个人类型小程序"), + + /** + * 已经开通不需要再开通 already open + */ + CODE_930569(930569, "已经开通不需要再开通"), + + /** + * cargo_first_class or cargo_second_class invalid + */ + CODE_930570(930570, "cargo_first_class or cargo_second_class invalid"), + + /** + * 该商户没有内测权限,请先申请权限: https://wj.qq.com/s2/7243532/fcfb/ + */ + CODE_930571(930571, "该商户没有内测权限,请先申请权限: https://wj.qq.com/s2/7243532/fcfb/"), + + /** + * fee already set + */ + CODE_931010(931010, "fee already set"), + + /** + * unbind download url + */ + CODE_6000100(6000100, "unbind download url"), + + /** + * no response data + */ + CODE_6000101(6000101, "no response data"), + + /** + * response data too big + */ + CODE_6000102(6000102, "response data too big"), + + /** + * POST 数据参数不合法 + */ + CODE_9001001(9001001, "POST 数据参数不合法"), + + /** + * 远端服务不可用 + */ + CODE_9001002(9001002, "远端服务不可用"), + + /** + * Ticket 不合法 + */ + CODE_9001003(9001003, "Ticket 不合法"), + + /** + * 获取摇周边用户信息失败 + */ + CODE_9001004(9001004, "获取摇周边用户信息失败"), + + /** + * 获取商户信息失败 + */ + CODE_9001005(9001005, "获取商户信息失败"), + + /** + * 获取 OpenID 失败 + */ + CODE_9001006(9001006, "获取 OpenID 失败"), + + /** + * 上传文件缺失 + */ + CODE_9001007(9001007, "上传文件缺失"), + + /** + * 上传素材的文件类型不合法 + */ + CODE_9001008(9001008, "上传素材的文件类型不合法"), + + /** + * 上传素材的文件尺寸不合法 + */ + CODE_9001009(9001009, "上传素材的文件尺寸不合法"), + + /** + * 上传失败 + */ + CODE_9001010(9001010, "上传失败"), + + /** + * 帐号不合法 + */ + CODE_9001020(9001020, "帐号不合法"), + + /** + * 已有设备激活率低于 50% ,不能新增设备 + */ + CODE_9001021(9001021, "已有设备激活率低于 50% ,不能新增设备"), + + /** + * 设备申请数不合法,必须为大于 0 的数字 + */ + CODE_9001022(9001022, "设备申请数不合法,必须为大于 0 的数字"), + + /** + * 已存在审核中的设备 ID 申请 + */ + CODE_9001023(9001023, "已存在审核中的设备 ID 申请"), + + /** + * 一次查询设备 ID 数量不能超过 50 + */ + CODE_9001024(9001024, "一次查询设备 ID 数量不能超过 50"), + + /** + * 设备 ID 不合法 + */ + CODE_9001025(9001025, "设备 ID 不合法"), + + /** + * 页面 ID 不合法 + */ + CODE_9001026(9001026, "页面 ID 不合法"), + + /** + * 页面参数不合法 + */ + CODE_9001027(9001027, "页面参数不合法"), + + /** + * 一次删除页面 ID 数量不能超过 10 + */ + CODE_9001028(9001028, "一次删除页面 ID 数量不能超过 10"), + + /** + * 页面已应用在设备中,请先解除应用关系再删除 + */ + CODE_9001029(9001029, "页面已应用在设备中,请先解除应用关系再删除"), + + /** + * 一次查询页面 ID 数量不能超过 50 + */ + CODE_9001030(9001030, "一次查询页面 ID 数量不能超过 50"), + + /** + * 时间区间不合法 + */ + CODE_9001031(9001031, "时间区间不合法"), + + /** + * 保存设备与页面的绑定关系参数错误 + */ + CODE_9001032(9001032, "保存设备与页面的绑定关系参数错误"), + + /** + * 门店 ID 不合法 + */ + CODE_9001033(9001033, "门店 ID 不合法"), + + /** + * 设备备注信息过长 + */ + CODE_9001034(9001034, "设备备注信息过长"), + + /** + * 设备申请参数不合法 + */ + CODE_9001035(9001035, "设备申请参数不合法"), + + /** + * 查询起始值 begin 不合法 + */ + CODE_9001036(9001036, "查询起始值 begin 不合法"), + + /** + * params invalid + */ + CODE_9002008(9002008, "params invalid"), + + /** + * shop id not exist + */ + CODE_9002009(9002009, "shop id not exist"), + + /** + * ssid or password should start with "WX" + */ + CODE_9002010(9002010, "ssid or password should start with \"WX\""), + + /** + * ssid can not include chinese + */ + CODE_9002011(9002011, "ssid can not include chinese"), + + /** + * passsword can not include chinese + */ + CODE_9002012(9002012, "passsword can not include chinese"), + + /** + * password must be between 8 and 24 characters + */ + CODE_9002013(9002013, "password must be between 8 and 24 characters"), + + /** + * device exist + */ + CODE_9002016(9002016, "device exist"), + + /** + * device not exist + */ + CODE_9002017(9002017, "device not exist"), + + /** + * the size of query list reach limit + */ + CODE_9002026(9002026, "the size of query list reach limit"), + + /** + * not allowed to modify, ensure you are an certified or component account + */ + CODE_9002041(9002041, "not allowed to modify, ensure you are an certified or component account"), + + /** + * invalid ssid, can not include none utf8 characters, and should be between 1 and 32 bytes + */ + CODE_9002044(9002044, "invalid ssid, can not include none utf8 characters, and should be between 1 and 32 bytes"), + + /** + * shop id has not be audited, this bar type is not enable + */ + CODE_9002052(9002052, "shop id has not be audited, this bar type is not enable"), + + /** + * protocol type is not same with the exist device + */ + CODE_9007003(9007003, "protocol type is not same with the exist device"), + + /** + * ssid not exist + */ + CODE_9007004(9007004, "ssid not exist"), + + /** + * device count limit + */ + CODE_9007005(9007005, "device count limit"), + + /** + * card info not exist + */ + CODE_9008001(9008001, "card info not exist"), + + /** + * card expiration time is invalid + */ + CODE_9008002(9008002, "card expiration time is invalid"), + + /** + * url size invalid, keep less than 255 + */ + CODE_9008003(9008003, "url size invalid, keep less than 255"), + + /** + * url can not include chinese + */ + CODE_9008004(9008004, "url can not include chinese"), + + /** + * order_id not exist + */ + CODE_9200001(9200001, "order_id not exist"), + + /** + * order of other biz + */ + CODE_9200002(9200002, "order of other biz"), + + /** + * blocked + */ + CODE_9200003(9200003, "blocked"), + + /** + * payment notice disabled + */ + CODE_9200211(9200211, "payment notice disabled"), + + /** + * payment notice not exist + */ + CODE_9200231(9200231, "payment notice not exist"), + + /** + * payment notice paid + */ + CODE_9200232(9200232, "payment notice paid"), + + /** + * payment notice canceled + */ + CODE_9200233(9200233, "payment notice canceled"), + + /** + * payment notice expired + */ + CODE_9200235(9200235, "payment notice expired"), + + /** + * bank not allow + */ + CODE_9200236(9200236, "bank not allow"), + + /** + * freq limit + */ + CODE_9200295(9200295, "freq limit"), + + /** + * suspend payment at current time + */ + CODE_9200297(9200297, "suspend payment at current time"), + + /** + * 3rd resp decrypt error + */ + CODE_9200298(9200298, "3rd resp decrypt error"), + + /** + * 3rd resp system error + */ + CODE_9200299(9200299, "3rd resp system error"), + + /** + * 3rd resp sign error + */ + CODE_9200300(9200300, "3rd resp sign error"), + + /** + * desc empty + */ + CODE_9201000(9201000, "desc empty"), + + /** + * fee not equal items' + */ + CODE_9201001(9201001, "fee not equal items'"), + + /** + * payment info incorrect + */ + CODE_9201002(9201002, "payment info incorrect"), + + /** + * fee is 0 + */ + CODE_9201003(9201003, "fee is 0"), + + /** + * payment expire date format error + */ + CODE_9201004(9201004, "payment expire date format error"), + + /** + * appid error + */ + CODE_9201005(9201005, "appid error"), + + /** + * payment order id error + */ + CODE_9201006(9201006, "payment order id error"), + + /** + * openid error + */ + CODE_9201007(9201007, "openid error"), + + /** + * return_url error + */ + CODE_9201008(9201008, "return_url error"), + + /** + * ip error + */ + CODE_9201009(9201009, "ip error"), + + /** + * order_id error + */ + CODE_9201010(9201010, "order_id error"), + + /** + * reason error + */ + CODE_9201011(9201011, "reason error"), + + /** + * mch_id error + */ + CODE_9201012(9201012, "mch_id error"), + + /** + * bill_date error + */ + CODE_9201013(9201013, "bill_date error"), + + /** + * bill_type error + */ + CODE_9201014(9201014, "bill_type error"), + + /** + * trade_type error + */ + CODE_9201015(9201015, "trade_type error"), + + /** + * bank_id error + */ + CODE_9201016(9201016, "bank_id error"), + + /** + * bank_account error + */ + CODE_9201017(9201017, "bank_account error"), + + /** + * payment_notice_no error + */ + CODE_9201018(9201018, "payment_notice_no error"), + + /** + * department_code error + */ + CODE_9201019(9201019, "department_code error"), + + /** + * payment_notice_type error + */ + CODE_9201020(9201020, "payment_notice_type error"), + + /** + * region_code error + */ + CODE_9201021(9201021, "region_code error"), + + /** + * department_name error + */ + CODE_9201022(9201022, "department_name error"), + + /** + * fee not equal finance's + */ + CODE_9201023(9201023, "fee not equal finance's"), + + /** + * refund_out_id error + */ + CODE_9201024(9201024, "refund_out_id error"), + + /** + * not combined order_id + */ + CODE_9201026(9201026, "not combined order_id"), + + /** + * partial sub order is test + */ + CODE_9201027(9201027, "partial sub order is test"), + + /** + * desc too long + */ + CODE_9201029(9201029, "desc too long"), + + /** + * sub order list size error + */ + CODE_9201031(9201031, "sub order list size error"), + + /** + * sub order repeated + */ + CODE_9201032(9201032, "sub order repeated"), + + /** + * auth_code empty + */ + CODE_9201033(9201033, "auth_code empty"), + + /** + * bank_id empty but mch_id not empty + */ + CODE_9201034(9201034, "bank_id empty but mch_id not empty"), + + /** + * sum of other fees exceed total fee + */ + CODE_9201035(9201035, "sum of other fees exceed total fee"), + + /** + * other user paying + */ + CODE_9202000(9202000, "other user paying"), + + /** + * pay process not finish + */ + CODE_9202001(9202001, "pay process not finish"), + + /** + * no refund permission + */ + CODE_9202002(9202002, "no refund permission"), + + /** + * ip limit + */ + CODE_9202003(9202003, "ip limit"), + + /** + * freq limit + */ + CODE_9202004(9202004, "freq limit"), + + /** + * user weixin account abnormal + */ + CODE_9202005(9202005, "user weixin account abnormal"), + + /** + * account balance not enough + */ + CODE_9202006(9202006, "account balance not enough"), + + /** + * refund request repeated + */ + CODE_9202010(9202010, "refund request repeated"), + + /** + * has refunded + */ + CODE_9202011(9202011, "has refunded"), + + /** + * refund exceed total fee + */ + CODE_9202012(9202012, "refund exceed total fee"), + + /** + * busi_id dup + */ + CODE_9202013(9202013, "busi_id dup"), + + /** + * not check sign + */ + CODE_9202016(9202016, "not check sign"), + + /** + * check sign failed + */ + CODE_9202017(9202017, "check sign failed"), + + /** + * sub order error + */ + CODE_9202018(9202018, "sub order error"), + + /** + * order status error + */ + CODE_9202020(9202020, "order status error"), + + /** + * unified order repeatedly + */ + CODE_9202021(9202021, "unified order repeatedly"), + + /** + * request to notification url fail + */ + CODE_9203000(9203000, "request to notification url fail"), + + /** + * http request fail + */ + CODE_9203001(9203001, "http request fail"), + + /** + * http response data error + */ + CODE_9203002(9203002, "http response data error"), + + /** + * http response data RSA decrypt fail + */ + CODE_9203003(9203003, "http response data RSA decrypt fail"), + + /** + * http response data AES decrypt fail + */ + CODE_9203004(9203004, "http response data AES decrypt fail"), + + /** + * system busy, please try again later + */ + CODE_9203999(9203999, "system busy, please try again later"), + + /** + * getrealname token error + */ + CODE_9204000(9204000, "getrealname token error"), + + /** + * getrealname user or token error + */ + CODE_9204001(9204001, "getrealname user or token error"), + + /** + * getrealname appid or token error + */ + CODE_9204002(9204002, "getrealname appid or token error"), + + /** + * finance conf not exist + */ + CODE_9205000(9205000, "finance conf not exist"), + + /** + * bank conf not exist + */ + CODE_9205001(9205001, "bank conf not exist"), + + /** + * wei ban ju conf not exist + */ + CODE_9205002(9205002, "wei ban ju conf not exist"), + + /** + * symmetric key conf not exist + */ + CODE_9205010(9205010, "symmetric key conf not exist"), + + /** + * out order id not exist + */ + CODE_9205101(9205101, "out order id not exist"), + + /** + * bill not exist + */ + CODE_9205201(9205201, "bill not exist"), + + /** + * 3rd resp pay_channel empty + */ + CODE_9206000(9206000, "3rd resp pay_channel empty"), + + /** + * 3rd resp order_id empty + */ + CODE_9206001(9206001, "3rd resp order_id empty"), + + /** + * 3rd resp bill_type_code empty + */ + CODE_9206002(9206002, "3rd resp bill_type_code empty"), + + /** + * 3rd resp bill_no empty + */ + CODE_9206003(9206003, "3rd resp bill_no empty"), + + /** + * 3rd resp empty + */ + CODE_9206200(9206200, "3rd resp empty"), + + /** + * 3rd resp not json + */ + CODE_9206201(9206201, "3rd resp not json"), + + /** + * connect 3rd error + */ + CODE_9206900(9206900, "connect 3rd error"), + + /** + * connect 3rd timeout + */ + CODE_9206901(9206901, "connect 3rd timeout"), + + /** + * read 3rd resp error + */ + CODE_9206910(9206910, "read 3rd resp error"), + + /** + * read 3rd resp timeout + */ + CODE_9206911(9206911, "read 3rd resp timeout"), + + /** + * boss error + */ + CODE_9207000(9207000, "boss error"), + + /** + * wechat pay error + */ + CODE_9207001(9207001, "wechat pay error"), + + /** + * boss param error + */ + CODE_9207002(9207002, "boss param error"), + + /** + * pay error + */ + CODE_9207003(9207003, "pay error"), + + /** + * auth_code expired + */ + CODE_9207004(9207004, "auth_code expired"), + + /** + * user balance not enough + */ + CODE_9207005(9207005, "user balance not enough"), + + /** + * card not support + */ + CODE_9207006(9207006, "card not support"), + + /** + * order reversed + */ + CODE_9207007(9207007, "order reversed"), + + /** + * user paying, need input password + */ + CODE_9207008(9207008, "user paying, need input password"), + + /** + * auth_code error + */ + CODE_9207009(9207009, "auth_code error"), + + /** + * auth_code invalid + */ + CODE_9207010(9207010, "auth_code invalid"), + + /** + * not allow to reverse when user paying + */ + CODE_9207011(9207011, "not allow to reverse when user paying"), + + /** + * order paid + */ + CODE_9207012(9207012, "order paid"), + + /** + * order closed + */ + CODE_9207013(9207013, "order closed"), + + /** + * vehicle not exists + */ + CODE_9207028(9207028, "vehicle not exists"), + + /** + * vehicle request blocked + */ + CODE_9207029(9207029, "vehicle request blocked"), + + /** + * vehicle auth error + */ + CODE_9207030(9207030, "vehicle auth error"), + + /** + * contract over limit + */ + CODE_9207031(9207031, "contract over limit"), + + /** + * trade error + */ + CODE_9207032(9207032, "trade error"), + + /** + * trade time invalid + */ + CODE_9207033(9207033, "trade time invalid"), + + /** + * channel type invalid + */ + CODE_9207034(9207034, "channel type invalid"), + + /** + * expire_time range error + */ + CODE_9207050(9207050, "expire_time range error"), + + /** + * query finance error + */ + CODE_9210000(9210000, "query finance error"), + + /** + * openid error + */ + CODE_9291000(9291000, "openid error"), + + /** + * openid appid not match + */ + CODE_9291001(9291001, "openid appid not match"), + + /** + * app_appid not exist + */ + CODE_9291002(9291002, "app_appid not exist"), + + /** + * app_appid not app + */ + CODE_9291003(9291003, "app_appid not app"), + + /** + * appid empty + */ + CODE_9291004(9291004, "appid empty"), + + /** + * appid not match access_token + */ + CODE_9291005(9291005, "appid not match access_token"), + + /** + * invalid sign + */ + CODE_9291006(9291006, "invalid sign"), + + /** + * backend logic error + */ + CODE_9299999(9299999, "backend logic error"), + + /** + * begin_time can not before now + */ + CODE_9300001(9300001, "begin_time can not before now"), + + /** + * end_time can not before now + */ + CODE_9300002(9300002, "end_time can not before now"), + + /** + * begin_time must less than end_time + */ + CODE_9300003(9300003, "begin_time must less than end_time"), + + /** + * end_time - begin_time > 1year + */ + CODE_9300004(9300004, "end_time - begin_time > 1year"), + + /** + * invalid max_partic_times + */ + CODE_9300005(9300005, "invalid max_partic_times"), + + /** + * invalid activity status + */ + CODE_9300006(9300006, "invalid activity status"), + + /** + * gift_num must >0 and <=15 + */ + CODE_9300007(9300007, "gift_num must >0 and <=15"), + + /** + * invalid tiny appid + */ + CODE_9300008(9300008, "invalid tiny appid"), + + /** + * activity can not finish + */ + CODE_9300009(9300009, "activity can not finish"), + + /** + * card_info_list must >= 2 + */ + CODE_9300010(9300010, "card_info_list must >= 2"), + + /** + * invalid card_id + */ + CODE_9300011(9300011, "invalid card_id"), + + /** + * card_id must belong this appid + */ + CODE_9300012(9300012, "card_id must belong this appid"), + + /** + * card_id is not swipe_card or pay.cash + */ + CODE_9300013(9300013, "card_id is not swipe_card or pay.cash"), + + /** + * some card_id is out of stock + */ + CODE_9300014(9300014, "some card_id is out of stock"), + + /** + * some card_id is invalid status + */ + CODE_9300015(9300015, "some card_id is invalid status"), + + /** + * membership or new/old tinyapp user only support one + */ + CODE_9300016(9300016, "membership or new/old tinyapp user only support one"), + + /** + * invalid logic for membership + */ + CODE_9300017(9300017, "invalid logic for membership"), + + /** + * invalid logic for tinyapp new/old user + */ + CODE_9300018(9300018, "invalid logic for tinyapp new/old user"), + + /** + * invalid activity type + */ + CODE_9300019(9300019, "invalid activity type"), + + /** + * invalid activity_id + */ + CODE_9300020(9300020, "invalid activity_id"), + + /** + * invalid help_max_times + */ + CODE_9300021(9300021, "invalid help_max_times"), + + /** + * invalid cover_url + */ + CODE_9300022(9300022, "invalid cover_url"), + + /** + * invalid gen_limit + */ + CODE_9300023(9300023, "invalid gen_limit"), + + /** + * card's end_time cannot early than act's end_time + */ + CODE_9300024(9300024, "card's end_time cannot early than act's end_time"), + + /** + * 快递侧逻辑错误,详细原因需要看 delivery_resultcode, 请先确认一下编码方式,python建议 json.dumps(b, ensure_ascii=False),php建议 json_encode($arr, JSON_UNESCAPED_UNICODE) Delivery side error + */ + CODE_9300501(9300501, "快递侧逻辑错误,详细原因需要看 delivery_resultcode, 请先确认一下编码方式,python建议 json.dumps(b, ensure_ascii=False),php建议 json_encode($arr, JSON_UNESCAPED_UNICODE)"), + + /** + * 快递公司系统错误 Delivery side sys error + */ + CODE_9300502(9300502, "快递公司系统错误"), + + /** + * delivery_id 不存在 Specified delivery id is not registerred + */ + CODE_9300503(9300503, "delivery_id 不存在"), + + /** + * service_type 不存在 Specified delivery id has beed banned + */ + CODE_9300504(9300504, "service_type 不存在"), + + /** + * Shop banned + */ + CODE_9300505(9300505, "Shop banned"), + + /** + * 运单 ID 已经存在轨迹,不可取消 Order can't cancel + */ + CODE_9300506(9300506, "运单 ID 已经存在轨迹,不可取消"), + + /** + * Token 不正确 invalid token, can't decryption or decryption result is different from the plaintext + */ + CODE_9300507(9300507, "Token 不正确"), + + /** + * order id has been used + */ + CODE_9300508(9300508, "order id has been used"), + + /** + * speed limit, retry too fast + */ + CODE_9300509(9300509, "speed limit, retry too fast"), + + /** + * invalid service type + */ + CODE_9300510(9300510, "invalid service type"), + + /** + * invalid branch id + */ + CODE_9300511(9300511, "invalid branch id"), + + /** + * 模板格式错误,渲染失败 invalid waybill template format + */ + CODE_9300512(9300512, "模板格式错误,渲染失败"), + + /** + * out of quota + */ + CODE_9300513(9300513, "out of quota"), + + /** + * add net branch fail, try update branch api + */ + CODE_9300514(9300514, "add net branch fail, try update branch api"), + + /** + * wxa appid not exist + */ + CODE_9300515(9300515, "wxa appid not exist"), + + /** + * wxa appid and current bizuin is not linked or not the same owner + */ + CODE_9300516(9300516, "wxa appid and current bizuin is not linked or not the same owner"), + + /** + * update_type 不正确,请使用"bind" 或者“unbind” invalid update_type, please use [bind] or [unbind] + */ + CODE_9300517(9300517, "update_type 不正确,请使用\"bind\" 或者“unbind”"), + + /** + * invalid delivery id + */ + CODE_9300520(9300520, "invalid delivery id"), + + /** + * the orderid is in our system, and waybill is generating + */ + CODE_9300521(9300521, "the orderid is in our system, and waybill is generating"), + + /** + * this orderid is repeated + */ + CODE_9300522(9300522, "this orderid is repeated"), + + /** + * quota is not enough; go to charge please + */ + CODE_9300523(9300523, "quota is not enough; go to charge please"), + + /** + * 订单已取消(一般为重复取消订单) order already canceled + */ + CODE_9300524(9300524, "订单已取消(一般为重复取消订单)"), + + /** + * bizid未绑定 biz id not bind + */ + CODE_9300525(9300525, "bizid未绑定"), + + /** + * 参数字段长度不正确 arg size exceed limit + */ + CODE_9300526(9300526, "参数字段长度不正确"), + + /** + * delivery does not support quota + */ + CODE_9300527(9300527, "delivery does not support quota"), + + /** + * invalid waybill_id + */ + CODE_9300528(9300528, "invalid waybill_id"), + + /** + * 账号已绑定过 biz_id already binded + */ + CODE_9300529(9300529, "账号已绑定过"), + + /** + * 解绑的biz_id不存在 biz_id is not exist + */ + CODE_9300530(9300530, "解绑的biz_id不存在"), + + /** + * bizid无效 或者密码错误 invalid biz_id or password + */ + CODE_9300531(9300531, "bizid无效 或者密码错误"), + + /** + * 绑定已提交,审核中 bind submit, and is checking + */ + CODE_9300532(9300532, "绑定已提交,审核中"), + + /** + * invalid tagid_list + */ + CODE_9300533(9300533, "invalid tagid_list"), + + /** + * add_source=2时,wx_appid和当前小程序不同主体 invalid appid, not same body + */ + CODE_9300534(9300534, "add_source=2时,wx_appid和当前小程序不同主体"), + + /** + * shop字段商品缩略图 url、商品名称为空或者非法,或者商品数量为0 invalid shop arg + */ + CODE_9300535(9300535, "shop字段商品缩略图 url、商品名称为空或者非法,或者商品数量为0"), + + /** + * add_source=2时,wx_appid无效 invalid wxa_appid + */ + CODE_9300536(9300536, "add_source=2时,wx_appid无效"), + + /** + * freq limit + */ + CODE_9300537(9300537, "freq limit"), + + /** + * input task empty + */ + CODE_9300538(9300538, "input task empty"), + + /** + * too many task + */ + CODE_9300539(9300539, "too many task"), + + /** + * task not exist + */ + CODE_9300540(9300540, "task not exist"), + + /** + * delivery callback error + */ + CODE_9300541(9300541, "delivery callback error"), + + /** + * id_card_no is invalid + */ + CODE_9300601(9300601, "id_card_no is invalid"), + + /** + * name is invalid + */ + CODE_9300602(9300602, "name is invalid"), + + /** + * plate_no is invalid + */ + CODE_9300603(9300603, "plate_no is invalid"), + + /** + * auth_key decode error + */ + CODE_9300604(9300604, "auth_key decode error"), + + /** + * auth_key is expired + */ + CODE_9300605(9300605, "auth_key is expired"), + + /** + * auth_key and appinfo not match + */ + CODE_9300606(9300606, "auth_key and appinfo not match"), + + /** + * user not confirm + */ + CODE_9300607(9300607, "user not confirm"), + + /** + * user confirm is expired + */ + CODE_9300608(9300608, "user confirm is expired"), + + /** + * api exceed limit + */ + CODE_9300609(9300609, "api exceed limit"), + + /** + * car license info is invalid + */ + CODE_9300610(9300610, "car license info is invalid"), + + /** + * varification type not support + */ + CODE_9300611(9300611, "varification type not support"), + + /** + * input param error + */ + CODE_9300701(9300701, "input param error"), + + /** + * this code has been used + */ + CODE_9300702(9300702, "this code has been used"), + + /** + * invalid date + */ + CODE_9300703(9300703, "invalid date"), + + /** + * not currently available + */ + CODE_9300704(9300704, "not currently available"), + + /** + * code not exist or expired + */ + CODE_9300705(9300705, "code not exist or expired"), + + /** + * code not exist or expired + */ + CODE_9300706(9300706, "code not exist or expired"), + + /** + * wxpay error + */ + CODE_9300707(9300707, "wxpay error"), + + /** + * wxpay overlimit + */ + CODE_9300708(9300708, "wxpay overlimit"), + + /** + * 无效的微信号 + */ + CODE_9300801(9300801, "无效的微信号"), + + /** + * 服务号未开通导购功能 + */ + CODE_9300802(9300802, "服务号未开通导购功能"), + + /** + * 微信号已经绑定为导购 + */ + CODE_9300803(9300803, "微信号已经绑定为导购"), + + /** + * 该微信号不是导购 + */ + CODE_9300804(9300804, "该微信号不是导购"), + + /** + * 微信号已经被其他账号绑定为导购 + */ + CODE_9300805(9300805, "微信号已经被其他账号绑定为导购"), + + /** + * 粉丝和导购不存在绑定关系 + */ + CODE_9300806(9300806, "粉丝和导购不存在绑定关系"), + + /** + * 标签值无效,不是可选标签值 + */ + CODE_9300807(9300807, "标签值无效,不是可选标签值"), + + /** + * 标签值不存在 + */ + CODE_9300808(9300808, "标签值不存在"), + + /** + * 展示标签值不存在 + */ + CODE_9300809(9300809, "展示标签值不存在"), + + /** + * 导购昵称太长,最多16个字符 + */ + CODE_9300810(9300810, "导购昵称太长,最多16个字符"), + + /** + * 只支持mmbiz.qpic.cn域名的图片 + */ + CODE_9300811(9300811, "只支持mmbiz.qpic.cn域名的图片"), + + /** + * 达到导购绑定个数限制 + */ + CODE_9300812(9300812, "达到导购绑定个数限制"), + + /** + * 达到导购粉丝绑定个数限制 + */ + CODE_9300813(9300813, "达到导购粉丝绑定个数限制"), + + /** + * 敏感词个数超过上限 + */ + CODE_9300814(9300814, "敏感词个数超过上限"), + + /** + * 快捷回复个数超过上限 + */ + CODE_9300815(9300815, "快捷回复个数超过上限"), + + /** + * 文字素材个数超过上限 + */ + CODE_9300816(9300816, "文字素材个数超过上限"), + + /** + * 小程序卡片素材个数超过上限 + */ + CODE_9300817(9300817, "小程序卡片素材个数超过上限"), + + /** + * 图片素材个数超过上限 + */ + CODE_9300818(9300818, "图片素材个数超过上限"), + + /** + * mediaid 有误 + */ + CODE_9300819(9300819, "mediaid 有误"), + + /** + * 可查询标签类别超过上限 + */ + CODE_9300820(9300820, "可查询标签类别超过上限"), + + /** + * 小程序卡片内appid不符合要求 + */ + CODE_9300821(9300821, "小程序卡片内appid不符合要求"), + + /** + * 标签类别的名字无效 + */ + CODE_9300822(9300822, "标签类别的名字无效"), + + /** + * 查询聊天记录时间参数有误 + */ + CODE_9300823(9300823, "查询聊天记录时间参数有误"), + + /** + * 自动回复字数太长 + */ + CODE_9300824(9300824, "自动回复字数太长"), + + /** + * 导购群组id错误 + */ + CODE_9300825(9300825, "导购群组id错误"), + + /** + * 维护中 + */ + CODE_9300826(9300826, "维护中"), + + /** + * invalid parameter + */ + CODE_9301001(9301001, "invalid parameter"), + + /** + * call api service failed + */ + CODE_9301002(9301002, "call api service failed"), + + /** + * internal exception + */ + CODE_9301003(9301003, "internal exception"), + + /** + * save data error + */ + CODE_9301004(9301004, "save data error"), + + /** + * invalid appid + */ + CODE_9301006(9301006, "invalid appid"), + + /** + * invalid api config + */ + CODE_9301007(9301007, "invalid api config"), + + /** + * invalid api info + */ + CODE_9301008(9301008, "invalid api info"), + + /** + * add result check failed + */ + CODE_9301009(9301009, "add result check failed"), + + /** + * consumption failure + */ + CODE_9301010(9301010, "consumption failure"), + + /** + * frequency limit reached + */ + CODE_9301011(9301011, "frequency limit reached"), + + /** + * service timeout + */ + CODE_9301012(9301012, "service timeout"), + + /** + * 该开发小程序已开通小程序直播权限,不支持发布版本。如需发版,请解绑开发小程序后再操作。 + */ + CODE_9400001(9400001, "该开发小程序已开通小程序直播权限,不支持发布版本。如需发版,请解绑开发小程序后再操作。"), + + /** + * 商品已存在 + */ + CODE_9401001(9401001, "商品已存在"), + + /** + * 商品不存在 + */ + CODE_9401002(9401002, "商品不存在"), + + /** + * 类目已存在 + */ + CODE_9401003(9401003, "类目已存在"), + + /** + * 类目不存在 + */ + CODE_9401004(9401004, "类目不存在"), + + /** + * SKU已存在 + */ + CODE_9401005(9401005, "SKU已存在"), + + /** + * SKU不存在 + */ + CODE_9401006(9401006, "SKU不存在"), + + /** + * 属性已存在 + */ + CODE_9401007(9401007, "属性已存在"), + + /** + * 属性不存在 + */ + CODE_9401008(9401008, "属性不存在"), + + /** + * 非法参数 + */ + CODE_9401020(9401020, "非法参数"), + + /** + * 没有商品权限 + */ + CODE_9401021(9401021, "没有商品权限"), + + /** + * SPU NOT ALLOW + */ + CODE_9401022(9401022, "SPU NOT ALLOW"), + + /** + * SPU_NOT_ALLOW_EDIT + */ + CODE_9401023(9401023, "SPU_NOT_ALLOW_EDIT"), + + /** + * SKU NOT ALLOW + */ + CODE_9401024(9401024, "SKU NOT ALLOW"), + + /** + * SKU_NOT_ALLOW_EDIT + */ + CODE_9401025(9401025, "SKU_NOT_ALLOW_EDIT"), + + /** + * limit too large + */ + CODE_9402001(9402001, "limit too large"), + + /** + * single send been blocked + */ + CODE_9402002(9402002, "single send been blocked"), + + /** + * all send been blocked + */ + CODE_9402003(9402003, "all send been blocked"), + + /** + * invalid msg id + */ + CODE_9402004(9402004, "invalid msg id"), + + /** + * send msg too quick + */ + CODE_9402005(9402005, "send msg too quick"), + + /** + * send to single user too quick + */ + CODE_9402006(9402006, "send to single user too quick"), + + /** + * send to all user too quick + */ + CODE_9402007(9402007, "send to all user too quick"), + + /** + * send type error + */ + CODE_9402008(9402008, "send type error"), + + /** + * can not send this msg + */ + CODE_9402009(9402009, "can not send this msg"), + + /** + * content too long or no content + */ + CODE_9402010(9402010, "content too long or no content"), + + /** + * path not exist + */ + CODE_9402011(9402011, "path not exist"), + + /** + * contain evil word + */ + CODE_9402012(9402012, "contain evil word"), + + /** + * path need html suffix + */ + CODE_9402013(9402013, "path need html suffix"), + + /** + * not open to personal body type + */ + CODE_9402014(9402014, "not open to personal body type"), + + /** + * not open to violation body type + */ + CODE_9402015(9402015, "not open to violation body type"), + + /** + * not open to low quality provider + */ + CODE_9402016(9402016, "not open to low quality provider"), + + /** + * invalid product_id + */ + CODE_9402101(9402101, "invalid product_id"), + + /** + * device_id count more than limit + */ + CODE_9402102(9402102, "device_id count more than limit"), + + /** + * 请勿频繁提交,待上一次操作完成后再提交 concurrent limit + */ + CODE_9402202(9402202, "请勿频繁提交,待上一次操作完成后再提交"), + + /** + * user not book this ad id + */ + CODE_9402301(9402301, "user not book this ad id"), + + /** + * 消息类型错误! + */ + CODE_9403000(9403000, "消息类型错误!"), + + /** + * 消息字段的内容过长! + */ + CODE_9403001(9403001, "消息字段的内容过长!"), + + /** + * 消息字段的内容违规! + */ + CODE_9403002(9403002, "消息字段的内容违规!"), + + /** + * 发送的微信号太多! + */ + CODE_9403003(9403003, "发送的微信号太多!"), + + /** + * 存在错误的微信号! + */ + CODE_9403004(9403004, "存在错误的微信号!"), + + /** + * 直播间列表为空 live room not exsits + */ + CODE_9410000(9410000, "直播间列表为空"), + + /** + * 获取房间失败 inner error: get room fail + */ + CODE_9410001(9410001, "获取房间失败"), + + /** + * 获取商品失败 inner error: get goods fail + */ + CODE_9410002(9410002, "获取商品失败"), + + /** + * 获取回放失败 inner error: get replay url fail + */ + CODE_9410003(9410003, "获取回放失败"); + + + private final int code; + private final String msg; + + WxOpenErrorMsgEnum(int code, String msg) { + this.code = code; + this.msg = msg; + } + + static final Map valueMap = Maps.newHashMap(); + + static { + for (WxOpenErrorMsgEnum value : WxOpenErrorMsgEnum.values()) { + valueMap.put(value.code, value.msg); + } + } + + /** + * 通过错误代码查找其中文含义. + */ + public static String findMsgByCode(int code) { + return valueMap.getOrDefault(code, null); + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxRuntimeException.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxRuntimeException.java index ccb8aecefb..e94e03db5d 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxRuntimeException.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxRuntimeException.java @@ -4,7 +4,7 @@ * WxJava专用的runtime exception. * * @author Binary Wang - * @date 2020-09-26 + * created on 2020-09-26 */ public class WxRuntimeException extends RuntimeException { private static final long serialVersionUID = 4881698471192264412L; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/JedisWxRedisOps.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/JedisWxRedisOps.java index 2b9849ff92..e6e3f28d7e 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/JedisWxRedisOps.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/JedisWxRedisOps.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.common.redis; +import com.github.jedis.lock.JedisLock; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.util.locks.JedisDistributedLock; import redis.clients.jedis.Jedis; @@ -8,6 +9,12 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; +/** + * @author Mario Luo + * + * @deprecated 该类底层使用过时的8年不维护的 {@link JedisLock}组件,不可靠,不建议继续使用。请 + * 使用:{@link RedisTemplateWxRedisOps}、{@link RedissonWxRedisOps} 替换 + */ @RequiredArgsConstructor public class JedisWxRedisOps implements WxRedisOps { private final Pool jedisPool; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/WxRedisOps.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/WxRedisOps.java index 5489165e74..4912cbc5d8 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/WxRedisOps.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/WxRedisOps.java @@ -8,6 +8,7 @@ *

* 该接口不承诺稳定, 外部实现请继承{@link BaseWxRedisOps} * + * @author Mario Luo * @see BaseWxRedisOps 实现需要继承该类 * @see JedisWxRedisOps jedis实现 * @see RedissonWxRedisOps redisson实现 diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernApacheHttpRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernApacheHttpRequestExecutor.java index 2a84ac0e8b..22cdab3f92 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernApacheHttpRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernApacheHttpRequestExecutor.java @@ -21,7 +21,7 @@ * . * * @author : zhayueran - * @date 2019/6/27 14:06 + * created on 2019/6/27 14:06 */ public class OcrDiscernApacheHttpRequestExecutor extends OcrDiscernRequestExecutor { public OcrDiscernApacheHttpRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java index 38926e72e5..870f77d2ed 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java @@ -13,7 +13,7 @@ * . * * @author zhayueran - * @date 2019/6/27 15:06 + * created on 2019/6/27 15:06 */ public abstract class OcrDiscernRequestExecutor implements RequestExecutor { protected RequestHttp requestHttp; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java index 5a53de010f..5dea04928e 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java @@ -8,13 +8,13 @@ * oauth2 相关接口. * * @author Binary Wang - * @date 2020-08-08 + * created on 2020-08-08 */ public interface WxOAuth2Service { /** *

    * 构造oauth2授权的url连接.
-   * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html
+   * 详情请见: 网页授权
    * 
* * @param redirectUri 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode @@ -27,7 +27,7 @@ public interface WxOAuth2Service { /** *
    * 用code换取oauth2的access token.
-   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息
+   * 详情请见: 网页授权获取用户基本信息
    * 
* * @param code code 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 7b4fe337e5..39a8a93754 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 @@ -15,7 +15,7 @@ * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21516712284rHWMX * * @author Binary Wang - * @date 2019-06-22 + * created on 2019-06-22 */ public interface WxOcrService { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxService.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxService.java index 24897561cc..497c1c0546 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxService.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxService.java @@ -8,7 +8,7 @@ * 微信服务接口. * * @author Binary Wang - * @date 2020-04-25 + * created on 2020-04-25 */ public interface WxService { /** diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java index 290a0c04f7..8d994b9c36 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java @@ -98,7 +98,7 @@ public WxSession getSession(String sessionId, boolean create) { // Create a new session if requested and the response is not committed if (!create) { - return (null); + return null; } session = createSession(sessionId); @@ -127,7 +127,7 @@ public void remove(InternalSession session, boolean update) { @Override public InternalSession findSession(String id) { if (id == null) { - return (null); + return null; } return this.sessions.get(id); } @@ -251,7 +251,7 @@ public void processExpires() { if (this.log.isDebugEnabled()) { this.log.debug("End expire sessions {} processingTime {} expired sessions: {}", getName(), timeEnd - timeNow, expireHere); } - this.processingTime += (timeEnd - timeNow); + this.processingTime += timeEnd - timeNow; } @@ -289,7 +289,7 @@ public void setBackgroundProcessorDelay(int backgroundProcessorDelay) { */ public String getName() { - return (name); + return name; } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/XmlUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/XmlUtils.java index 91c6b8f2ec..facf564e32 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/XmlUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/XmlUtils.java @@ -3,7 +3,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import org.dom4j.*; import org.dom4j.io.SAXReader; @@ -15,6 +14,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** *
@@ -39,7 +39,18 @@ public static Map xml2Map(String xmlString) {
       Element root = doc.getRootElement();
       List elements = root.elements();
       for (Element element : elements) {
-        map.put(element.getName(), element2MapOrString(element));
+        String elementName = element.getName();
+        if (map.containsKey(elementName)) {
+          if (map.get(elementName) instanceof List) {
+            ((List) map.get(elementName)).add(element2MapOrString(element));
+          } else {
+            List value = Lists.newArrayList(map.get(elementName));
+            value.add(element2MapOrString(element));
+            map.put(elementName, value);
+          }
+        } else {
+          map.put(elementName, element2MapOrString(element));
+        }
       }
     } catch (DocumentException | SAXException e) {
       throw new WxRuntimeException(e);
@@ -50,8 +61,8 @@ public static Map xml2Map(String xmlString) {
 
   private static Object element2MapOrString(Element element) {
 
-    final List content = element.content();
-    final Set names = names(content);
+    final List nodes = element.content();
+    final List names = names(nodes);
 
     // 判断节点下有无非文本节点(非Text和CDATA),如无,直接取Text文本内容
     if (names.size() < 1) {
@@ -59,10 +70,11 @@ private static Object element2MapOrString(Element element) {
     }
 
     Map result = Maps.newHashMap();
-    if (names.size() == 1) {
+    Set distinctNames = Sets.newHashSet(names);
+    if (distinctNames.size() == 1) {
       // 说明是个列表,各个子对象是相同的name
       List list = Lists.newArrayList();
-      for (Node node : content) {
+      for (Node node : nodes) {
         if (node instanceof DefaultText) {
           continue;
         }
@@ -73,8 +85,8 @@ private static Object element2MapOrString(Element element) {
       }
 
       result.put(names.iterator().next(), list);
-    } else {
-      for (Node node : content) {
+    } else if (distinctNames.size() == names.size()) {
+      for (Node node : nodes) {
         if (node instanceof DefaultText) {
           continue;
         }
@@ -83,13 +95,38 @@ private static Object element2MapOrString(Element element) {
           result.put(node.getName(), element2MapOrString((Element) node));
         }
       }
+    } else {
+      // 说明有重复name,但不是全部都相同
+      Map namesCountMap = names.stream().collect(Collectors.groupingBy(a -> a, Collectors.counting()));
+      for (Node node : nodes) {
+        if (node instanceof DefaultText) {
+          continue;
+        }
+
+        if (node instanceof Element) {
+          String nodeName = node.getName();
+          if (namesCountMap.get(nodeName) == 1) {
+            result.put(nodeName, element2MapOrString((Element) node));
+          } else {
+            List values;
+            if (result.containsKey(nodeName)) {
+              values = (List) result.get(nodeName);
+            } else {
+              values = Lists.newArrayList();
+              result.put(nodeName, values);
+            }
+
+            values.add(element2MapOrString((Element) node));
+          }
+        }
+      }
     }
 
     return result;
   }
 
-  private static Set names(List nodes) {
-    Set names = Sets.newHashSet();
+  private static List names(List nodes) {
+    List names = Lists.newArrayList();
     for (Node node : nodes) {
       // 如果节点类型是Text或CDATA跳过
       if (node instanceof DefaultText || node instanceof CDATA) {
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 c82f94d871..9b9f776768 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
@@ -8,7 +8,7 @@
 /**
  *
  * @author Daniel Qian
- * @date 14/10/19
+ * created on  14/10/19
  */
 public class SHA1 {
 
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 a73e01d0d5..f02d087b7d 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
@@ -1,25 +1,27 @@
 package me.chanjar.weixin.common.util.crypto;
 
-import java.io.StringReader;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Random;
-import javax.crypto.Cipher;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
 import com.google.common.base.CharMatcher;
-import com.google.common.io.BaseEncoding;
+import lombok.AllArgsConstructor;
+import lombok.Data;
 import me.chanjar.weixin.common.error.WxRuntimeException;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.StringUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
 
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.StringReader;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Random;
+
 /**
  * 
  * 对公众平台发送给公众账号的消息加解密示例代码.
@@ -64,7 +66,7 @@ public WxCryptUtil() {
   public WxCryptUtil(String token, String encodingAesKey, String appidOrCorpid) {
     this.token = token;
     this.appidOrCorpid = appidOrCorpid;
-    this.aesKey = Base64.decodeBase64(CharMatcher.whitespace().removeFrom(encodingAesKey));
+    this.aesKey = Base64.decodeBase64(StringUtils.remove(encodingAesKey, " "));
   }
 
   private static String extractEncryptPart(String xml) {
@@ -157,6 +159,29 @@ public String encrypt(String plainText) {
     return generateXml(encryptedXml, signature, timeStamp, nonce);
   }
 
+  /**
+   * 将公众平台回复用户的消息加密打包.
+   * 
    + *
  1. 对要发送的消息进行AES-CBC加密
  2. + *
  3. 生成安全签名
  4. + *
  5. 将消息密文和安全签名打包成xml格式
  6. + *
+ * + * @param plainText 公众平台待回复用户的消息,xml格式的字符串 + * @return 加密消息所需的值对象 + */ + public EncryptContext encryptContext(String plainText) { + // 加密 + String encryptedXml = encrypt(genRandomStr(), plainText); + + // 生成安全签名 + String timeStamp = Long.toString(System.currentTimeMillis() / 1000L); + String nonce = genRandomStr(); + + String signature = SHA1.gen(this.token, timeStamp, nonce, encryptedXml); + return new EncryptContext(encryptedXml, signature, timeStamp, nonce); + } + /** * 对明文进行加密. * @@ -211,22 +236,58 @@ public String encrypt(String randomStr, String plainText) { * @param msgSignature 签名串,对应URL参数的msg_signature * @param timeStamp 时间戳,对应URL参数的timestamp * @param nonce 随机串,对应URL参数的nonce - * @param encryptedXml 密文,对应POST请求的数据 + * @param encryptedXml 包含 Encrypt 密文的 xml,对应POST请求的数据 * @return 解密后的原文 */ - public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) { + public String decryptXml(String msgSignature, String timeStamp, String nonce, String encryptedXml) { // 密钥,公众账号的app corpSecret // 提取密文 String cipherText = extractEncryptPart(encryptedXml); + return decryptContent(msgSignature, timeStamp, nonce, cipherText); + } + /** + * 检验消息的真实性,并且获取解密后的明文. + *
    + *
  1. 利用收到的密文生成安全签名,进行签名验证
  2. + *
  3. 若验证通过,则提取xml中的加密消息
  4. + *
  5. 对消息进行解密
  6. + *
+ * + * @param msgSignature 签名串,对应URL参数的msg_signature + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param encryptedXml 包含 Encrypt 密文的 xml,对应POST请求的数据 + * @return 解密后的原文 + * @deprecated 由于语义不清晰,置为过时方法,请查看替代方法 {@link #decryptXml} + */ + @Deprecated + public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) { + return decryptXml(msgSignature, timeStamp, nonce, encryptedXml); + } + + /** + * 检验消息的真实性,并且获取解密后的明文. + *
    + *
  1. 利用收到的密文生成安全签名,进行签名验证
  2. + *
  3. 若验证通过,则提取xml中的加密消息
  4. + *
  5. 对消息进行解密
  6. + *
+ * + * @param msgSignature 签名串,对应URL参数的msg_signature + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param encryptedContent 加密文本体 + * @return 解密后的原文 + */ + public String decryptContent(String msgSignature, String timeStamp, String nonce, String encryptedContent) { // 验证安全签名 - String signature = SHA1.gen(this.token, timeStamp, nonce, cipherText); + String signature = SHA1.gen(this.token, timeStamp, nonce, encryptedContent); if (!signature.equals(msgSignature)) { throw new WxRuntimeException("加密消息签名校验失败"); } - // 解密 - return decrypt(cipherText); + return decrypt(encryptedContent); } /** @@ -271,12 +332,20 @@ public String decrypt(String cipherText) { } // appid不相同的情况 暂时忽略这段判断 -// if (!fromAppid.equals(this.appidOrCorpid)) { -// throw new WxRuntimeException("AppID不正确,请核实!"); -// } + // if (!fromAppid.equals(this.appidOrCorpid)) { + // throw new WxRuntimeException("AppID不正确,请核实!"); + // } return xmlContent; } + @Data + @AllArgsConstructor + public static class EncryptContext { + private String encrypt; + private String signature; + private String timeStamp; + private String nonce; + } } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java index d60f5cedd5..4a267153c6 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java @@ -11,6 +11,9 @@ import static org.apache.commons.io.FileUtils.openOutputStream; +/** + * @author Daniel Qian + */ public class FileUtils { /** @@ -21,7 +24,8 @@ public class FileUtils { * @param ext 扩展名 * @param tmpDirFile 临时文件夹目录 */ - public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { + public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) + throws IOException { File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile); resultFile.deleteOnExit(); @@ -43,7 +47,7 @@ private static void copyToFile(final InputStream source, final File destination) * @param ext 扩展名 */ public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { - return createTmpFile(inputStream, name, ext, Files.createTempDirectory("weixin-java-tools-temp").toFile()); + return createTmpFile(inputStream, name, ext, Files.createTempDirectory("wxjava-temp").toFile()); } /** 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 new file mode 100644 index 0000000000..d07873f3c4 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/InputStreamData.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.common.util.http; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.InputStream; +import java.io.Serializable; + +/** + * 输入流数据. + *

+ * InputStreamData + * + * @author zichuan.zhou91@gmail.com + * created on 2022/2/15 + */ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class InputStreamData implements Serializable { + private static final long serialVersionUID = -4627006604779378520L; + private InputStream inputStream; + private String filename; +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaInputStreamUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaInputStreamUploadRequestExecutor.java new file mode 100644 index 0000000000..de4be21709 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaInputStreamUploadRequestExecutor.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.common.util.http; + +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.apache.ApacheMediaInputStreamUploadRequestExecutor; +import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaInputStreamUploadRequestExecutor; +import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaInputStreamUploadRequestExecutor; + +import java.io.IOException; + +/** + * 上传媒体文件请求执行器. + * 请求的参数是File, 返回的结果是String + * + * @author Daniel Qian + */ +public abstract class MediaInputStreamUploadRequestExecutor implements RequestExecutor { + protected RequestHttp requestHttp; + + public MediaInputStreamUploadRequestExecutor(RequestHttp requestHttp) { + this.requestHttp = requestHttp; + } + + @Override + public void execute(String uri, InputStreamData data, ResponseHandler handler, WxType wxType) throws WxErrorException, IOException { + handler.handle(this.execute(uri, data, wxType)); + } + + public static RequestExecutor create(RequestHttp requestHttp) { + switch (requestHttp.getRequestType()) { + case APACHE_HTTP: + return new ApacheMediaInputStreamUploadRequestExecutor(requestHttp); + case JODD_HTTP: + return new JoddHttpMediaInputStreamUploadRequestExecutor(requestHttp); + case OK_HTTP: + return new OkHttpMediaInputStreamUploadRequestExecutor(requestHttp); + default: + return null; + } + } + +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MinishopUploadRequestCustomizeExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MinishopUploadRequestCustomizeExecutor.java index 23309202d7..e94b2d8d6a 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MinishopUploadRequestCustomizeExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MinishopUploadRequestCustomizeExecutor.java @@ -13,10 +13,19 @@ public abstract class MinishopUploadRequestCustomizeExecutor implements RequestExecutor { protected RequestHttp requestHttp; protected String respType; + protected String uploadType; + protected String imgUrl; - public MinishopUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType) { + public MinishopUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType, String imgUrl) { this.requestHttp = requestHttp; this.respType = respType; + if (imgUrl == null || imgUrl.isEmpty()) { + this.uploadType = "0"; + } + else { + this.uploadType = "1"; + this.imgUrl = imgUrl; + } } @Override @@ -24,14 +33,14 @@ public void execute(String uri, File data, ResponseHandler create(RequestHttp requestHttp, String respType) { + public static RequestExecutor create(RequestHttp requestHttp, String respType, String imgUrl) { switch (requestHttp.getRequestType()) { case APACHE_HTTP: - return new ApacheMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType); + return new ApacheMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType, imgUrl); case JODD_HTTP: - return new JoddHttpMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType); + return new JoddHttpMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType, imgUrl); case OK_HTTP: - return new OkHttpMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType); + return new OkHttpMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType, imgUrl); default: return null; } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java index da1292ba62..b5e394756e 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java @@ -37,4 +37,6 @@ public interface RequestExecutor { * @throws IOException io异常 */ void execute(String uri, E data, ResponseHandler handler, WxType wxType) throws WxErrorException, IOException; + + } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/WxDnsResolver.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/WxDnsResolver.java index 6c6137089a..ff0977e8d8 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/WxDnsResolver.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/WxDnsResolver.java @@ -18,8 +18,8 @@ */ public class WxDnsResolver implements DnsResolver { - private final static String WECHAT_API_URL = "api.weixin.qq.com"; - private static Map MAPPINGS = new HashMap(); + private static final String WECHAT_API_URL = "api.weixin.qq.com"; + private static Map MAPPINGS = new HashMap<>(); protected final Logger log = LoggerFactory.getLogger(WxDnsResolver.class); private String wxApiIp; @@ -38,7 +38,7 @@ private void init() { } catch (UnknownHostException e) { //如果初始化DNS配置失败则使用默认配置,不影响服务的启动 log.error("init WxDnsResolver error", e); - MAPPINGS = new HashMap(); + MAPPINGS = new HashMap<>(); } } 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 fcd56c48a7..0d5073de14 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 @@ -1,5 +1,7 @@ package me.chanjar.weixin.common.util.http.apache; +import org.apache.http.client.HttpRequestRetryHandler; +import org.apache.http.conn.ConnectionKeepAliveStrategy; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.CloseableHttpClient; @@ -37,6 +39,16 @@ public interface ApacheHttpClientBuilder { */ ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword); + /** + * 重试策略. + */ + ApacheHttpClientBuilder httpRequestRetryHandler(HttpRequestRetryHandler httpRequestRetryHandler ); + + /** + * 超时时间. + */ + ApacheHttpClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy); + /** * ssl连接socket工厂. */ diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java index af3a32ff71..6a136600e5 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java @@ -10,6 +10,7 @@ import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.config.SocketConfig; +import org.apache.http.conn.ConnectionKeepAliveStrategy; import org.apache.http.conn.DnsResolver; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.conn.socket.ConnectionSocketFactory; @@ -20,10 +21,12 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.protocol.HttpContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.concurrent.NotThreadSafe; +import java.io.IOException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -46,16 +49,19 @@ public class ApacheHttpDnsClientBuilder implements ApacheHttpClientBuilder { private int maxTotalConn = 50; private String userAgent; - private DnsResolver dnsResover; + private DnsResolver dnsResolver; - private HttpRequestRetryHandler httpRequestRetryHandler = (exception, executionCount, context) -> false; + private HttpRequestRetryHandler httpRequestRetryHandler = (IOException exception, int executionCount, HttpContext context) -> false; private SSLConnectionSocketFactory sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory(); private PlainConnectionSocketFactory plainConnectionSocketFactory = PlainConnectionSocketFactory.getSocketFactory(); private String httpProxyHost; + private ConnectionKeepAliveStrategy keepAliveStrategy; + private int httpProxyPort; private String httpProxyUsername; private String httpProxyPassword; + /** * 闲置连接监控线程. */ @@ -93,6 +99,18 @@ public ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword) { return this; } + @Override + public ApacheHttpClientBuilder httpRequestRetryHandler(HttpRequestRetryHandler httpRequestRetryHandler) { + this.httpRequestRetryHandler = httpRequestRetryHandler; + return this; + } + + @Override + public ApacheHttpClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) { + this.keepAliveStrategy = keepAliveStrategy; + return this; + } + @Override public ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory) { this.sslConnectionSocketFactory = sslConnectionSocketFactory; @@ -198,11 +216,11 @@ private synchronized void prepare() { @SuppressWarnings("resource") PoolingHttpClientConnectionManager connectionManager; - if (dnsResover != null) { + if (dnsResolver != null) { if (log.isDebugEnabled()) { log.debug("specified dns resolver."); } - connectionManager = new PoolingHttpClientConnectionManager(registry, dnsResover); + connectionManager = new PoolingHttpClientConnectionManager(registry, dnsResolver); } else { if (log.isDebugEnabled()) { log.debug("Not specified dns resolver."); @@ -250,12 +268,12 @@ public CloseableHttpClient build() { return this.httpClientBuilder.build(); } - public DnsResolver getDnsResover() { - return dnsResover; + public DnsResolver getDnsResolver() { + return dnsResolver; } - public void setDnsResover(DnsResolver dnsResover) { - this.dnsResover = dnsResover; + public void setDnsResolver(DnsResolver dnsResolver) { + this.dnsResolver = dnsResolver; } public static class IdleConnectionMonitorThread extends Thread { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java index 5bb4aeba90..e2f4611439 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java @@ -25,7 +25,7 @@ * . * * @author ecoolper - * @date 2017/5/5 + * created on 2017/5/5 */ public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor { public ApacheMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaInputStreamUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaInputStreamUploadRequestExecutor.java new file mode 100644 index 0000000000..ef09812cb2 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaInputStreamUploadRequestExecutor.java @@ -0,0 +1,59 @@ +package me.chanjar.weixin.common.util.http.apache; + +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.InputStreamData; +import me.chanjar.weixin.common.util.http.MediaInputStreamUploadRequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; + +import java.io.IOException; + +/** + * 文件输入流上传. + * + * @author meiqin.zhou91@gmail.com + * created on 2022/02/15 + */ +public class ApacheMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor { + public ApacheMediaInputStreamUploadRequestExecutor(RequestHttp requestHttp) { + super(requestHttp); + } + + @Override + public WxMediaUploadResult execute(String uri, InputStreamData data, WxType wxType) throws WxErrorException, IOException { + HttpPost httpPost = new HttpPost(uri); + if (requestHttp.getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); + httpPost.setConfig(config); + } + if (data != null) { + HttpEntity entity = MultipartEntityBuilder + .create() + .addBinaryBody("media", data.getInputStream(), ContentType.DEFAULT_BINARY, data.getFilename()) + .setMode(HttpMultipartMode.RFC6532) + .build(); + httpPost.setEntity(entity); + } + try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { + String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMediaUploadResult.fromJson(responseContent); + } finally { + httpPost.releaseConnection(); + } + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMinishopMediaUploadRequestCustomizeExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMinishopMediaUploadRequestCustomizeExecutor.java index 64888c08d6..9af02af5d0 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMinishopMediaUploadRequestCustomizeExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMinishopMediaUploadRequestCustomizeExecutor.java @@ -24,8 +24,8 @@ */ @Slf4j public class ApacheMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor { - public ApacheMinishopMediaUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType) { - super(requestHttp, respType); + public ApacheMinishopMediaUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType, String imgUrl) { + super(requestHttp, respType, imgUrl); } @Override @@ -35,15 +35,29 @@ public WxMinishopImageUploadCustomizeResult execute(String uri, File file, WxTyp RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); httpPost.setConfig(config); } - if (file != null) { + if (this.uploadType.equals("0")) { + if (file == null) { + throw new WxErrorException("上传文件为空"); + } HttpEntity entity = MultipartEntityBuilder .create() .addBinaryBody("media", file) .addTextBody("resp_type", this.respType) + .addTextBody("upload_type", this.uploadType) .setMode(HttpMultipartMode.RFC6532) .build(); httpPost.setEntity(entity); } + else { + HttpEntity entity = MultipartEntityBuilder + .create() + .addTextBody("resp_type", this.respType) + .addTextBody("upload_type", this.uploadType) + .addTextBody("img_url", this.imgUrl) + .setMode(HttpMultipartMode.RFC6532) + .build(); + httpPost.setEntity(entity); + } try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); WxError error = WxError.fromJson(responseContent, wxType); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimpleGetRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimpleGetRequestExecutor.java index 6b365edd09..be0784b076 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimpleGetRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimpleGetRequestExecutor.java @@ -16,7 +16,7 @@ * . * * @author ecoolper - * @date 2017/5/4 + * created on 2017/5/4 */ public class ApacheSimpleGetRequestExecutor extends SimpleGetRequestExecutor { public ApacheSimpleGetRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java index 4e6f31ec67..52c8caaf3d 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java @@ -18,7 +18,7 @@ * . * * @author ecoolper - * @date 2017/5/4 + * created on 2017/5/4 */ public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor { public ApacheSimplePostRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java index 3bb0d6114c..2a27697401 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java @@ -12,6 +12,7 @@ import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.config.SocketConfig; +import org.apache.http.conn.ConnectionKeepAliveStrategy; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory; @@ -92,12 +93,18 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder { */ private String userAgent; - private final HttpRequestRetryHandler httpRequestRetryHandler = new HttpRequestRetryHandler() { - @Override - public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { - return false; - } - }; + /** + * 自定义重试策略 + */ + private HttpRequestRetryHandler httpRequestRetryHandler; + + /** + * 自定义KeepAlive策略 + */ + private ConnectionKeepAliveStrategy connectionKeepAliveStrategy; + + private final HttpRequestRetryHandler defaultHttpRequestRetryHandler = (exception, executionCount, context) -> false; + private SSLConnectionSocketFactory sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory(); private final PlainConnectionSocketFactory plainConnectionSocketFactory = PlainConnectionSocketFactory.getSocketFactory(); private String httpProxyHost; @@ -144,6 +151,18 @@ public ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword) { return this; } + @Override + public ApacheHttpClientBuilder httpRequestRetryHandler(HttpRequestRetryHandler httpRequestRetryHandler) { + this.httpRequestRetryHandler = httpRequestRetryHandler; + return this; + } + + @Override + public ApacheHttpClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) { + this.connectionKeepAliveStrategy = keepAliveStrategy; + return this; + } + @Override public ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory) { this.sslConnectionSocketFactory = sslConnectionSocketFactory; @@ -163,7 +182,6 @@ private synchronized void prepare() { .register("https", this.sslConnectionSocketFactory) .build(); - @SuppressWarnings("resource") PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry); connectionManager.setMaxTotal(this.maxTotalConn); connectionManager.setDefaultMaxPerRoute(this.maxConnPerHost); @@ -187,7 +205,16 @@ private synchronized void prepare() { .setConnectTimeout(this.connectionTimeout) .setConnectionRequestTimeout(this.connectionRequestTimeout) .build() - ).setRetryHandler(this.httpRequestRetryHandler); + ); + + // 设置重试策略,没有则使用默认 + httpRequestRetryHandler = httpRequestRetryHandler == null ? defaultHttpRequestRetryHandler : httpRequestRetryHandler; + httpClientBuilder.setRetryHandler(httpRequestRetryHandler); + + // 设置KeepAliveStrategy,没有使用默认 + if (connectionKeepAliveStrategy != null) { + httpClientBuilder.setKeepAliveStrategy(connectionKeepAliveStrategy); + } if (StringUtils.isNotBlank(this.httpProxyHost) && StringUtils.isNotBlank(this.httpProxyUsername)) { // 使用代理服务器 需要用户认证的代理服务器 @@ -210,12 +237,7 @@ private SSLConnectionSocketFactory buildSSLConnectionSocketFactory() { try { SSLContext sslcontext = SSLContexts.custom() //忽略掉对服务器端证书的校验 - .loadTrustMaterial(new TrustStrategy() { - @Override - public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { - return true; - } - }).build(); + .loadTrustMaterial((TrustStrategy) (chain, authType) -> true).build(); return new SSLConnectionSocketFactory( sslcontext, diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java index 00df2a640a..920cf2d03b 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java @@ -25,7 +25,7 @@ * . * * @author ecoolper - * @date 2017/5/5 + * created on 2017/5/5 */ public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor { public JoddHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaInputStreamUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaInputStreamUploadRequestExecutor.java new file mode 100644 index 0000000000..311b7c49c5 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaInputStreamUploadRequestExecutor.java @@ -0,0 +1,61 @@ +package me.chanjar.weixin.common.util.http.jodd; + +import jodd.http.HttpConnectionProvider; +import jodd.http.HttpRequest; +import jodd.http.HttpResponse; +import jodd.http.ProxyInfo; +import jodd.http.upload.ByteArrayUploadable; +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.InputStreamData; +import me.chanjar.weixin.common.util.http.MediaInputStreamUploadRequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +/** + * 文件输入流上传. + * + * @author meiqin.zhou91@gmail.com + * created on 2022/02/15 + */ +public class JoddHttpMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor { + public JoddHttpMediaInputStreamUploadRequestExecutor(RequestHttp requestHttp) { + super(requestHttp); + } + + @Override + public WxMediaUploadResult execute(String uri, InputStreamData data, WxType wxType) throws WxErrorException, IOException { + HttpRequest request = HttpRequest.post(uri); + if (requestHttp.getRequestHttpProxy() != null) { + requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); + } + request.withConnectionProvider(requestHttp.getRequestHttpClient()); + request.form("media", new ByteArrayUploadable(this.toByteArray(data.getInputStream()), data.getFilename())); + HttpResponse response = request.send(); + response.charset(StandardCharsets.UTF_8.name()); + + String responseContent = response.bodyText(); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMediaUploadResult.fromJson(responseContent); + } + + public byte[] toByteArray(InputStream input) throws IOException { + try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { + byte[] buffer = new byte[4096]; + int n = 0; + while (-1 != (n = input.read(buffer))) { + output.write(buffer, 0, n); + } + return output.toByteArray(); + } + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaUploadRequestExecutor.java index 89ea05a029..876caa29fb 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaUploadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaUploadRequestExecutor.java @@ -20,7 +20,7 @@ * . * * @author ecoolper - * @date 2017/5/5 + * created on 2017/5/5 */ public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor { public JoddHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestCustomizeExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestCustomizeExecutor.java index a79eb8eda5..1d6f24fa2a 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestCustomizeExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestCustomizeExecutor.java @@ -18,12 +18,12 @@ /** * @author liming1019 - * @date 2021/8/10 + * created on 2021/8/10 */ @Slf4j public class JoddHttpMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor { - public JoddHttpMinishopMediaUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType) { - super(requestHttp, respType); + public JoddHttpMinishopMediaUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType, String imgUrl) { + super(requestHttp, respType, imgUrl); } @Override @@ -33,7 +33,16 @@ public WxMinishopImageUploadCustomizeResult execute(String uri, File file, WxTyp requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); } request.withConnectionProvider(requestHttp.getRequestHttpClient()); - request.form("media", file); + if (this.uploadType.equals("0")) { + request.form("resp_type", this.respType, + "upload_type", this.uploadType, + "media", file); + } + else { + request.form("resp_type", this.respType, + "upload_type", this.uploadType, + "img_url", this.imgUrl); + } HttpResponse response = request.send(); response.charset(StandardCharsets.UTF_8.name()); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestExecutor.java index 769153c59f..4cb9c50ee0 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestExecutor.java @@ -22,7 +22,7 @@ * . * * @author ecoolper - * @date 2017/5/5 + * created on 2017/5/5 */ @Slf4j public class JoddHttpMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimpleGetRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimpleGetRequestExecutor.java index 5960274eb6..869ea8c04e 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimpleGetRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimpleGetRequestExecutor.java @@ -17,7 +17,7 @@ * . * * @author ecoolper - * @date 2017/5/4 + * created on 2017/5/4 */ public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor { public JoddHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java index 50360cae56..654378271c 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java @@ -4,7 +4,6 @@ import jodd.http.HttpRequest; import jodd.http.HttpResponse; import jodd.http.ProxyInfo; -import jodd.util.StringPool; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.RequestHttp; @@ -17,7 +16,7 @@ * . * * @author ecoolper - * @date 2017/5/4 + * created on 2017/5/4 */ public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor { public JoddHttpSimplePostRequestExecutor(RequestHttp requestHttp) { @@ -35,6 +34,7 @@ public String execute(String uri, String postEntity, WxType wxType) throws WxErr } request.withConnectionProvider(provider); if (postEntity != null) { + request.contentType("application/json", "utf-8"); request.bodyText(postEntity); } HttpResponse response = request.send(); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilder.java new file mode 100644 index 0000000000..5ebe0ff1fa --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilder.java @@ -0,0 +1,263 @@ +package me.chanjar.weixin.common.util.http.okhttp; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import okhttp3.*; + +import javax.annotation.concurrent.NotThreadSafe; +import java.net.Proxy; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * @author wulang + **/ +@Slf4j +@Data +@NotThreadSafe +public class DefaultOkHttpClientBuilder implements OkHttpClientBuilder { + + private final AtomicBoolean prepared = new AtomicBoolean(false); + + /** + * 代理 + */ + private Proxy proxy; + + /** + * 授权 + */ + private Authenticator authenticator; + + /** + * 拦截器 + */ + private final List interceptorList = new ArrayList<>(); + + /** + * 请求调度管理 + */ + private Dispatcher dispatcher; + + /** + * 连接池 + */ + private ConnectionPool connectionPool; + + /** + * 监听网络请求过程 + */ + private EventListener.Factory eventListenerFactory; + + /** + * 是否支持失败重连 + */ + private Boolean retryOnConnectionFailure; + + /** + * 是否允许重定向操作 + */ + private Boolean followRedirects; + + /** + * 连接建立的超时时长 + */ + private Long connectTimeout; + + /** + * 连接建立的超时时间单位 + */ + private TimeUnit connectTimeUnit; + + /** + * 完整的请求过程超时时长 + */ + private Long callTimeout; + + /** + * 完整的请求过程超时时间单位 + */ + private TimeUnit callTimeUnit; + + /** + * 连接的IO读操作超时时长 + */ + private Long readTimeout; + + /** + * 连接的IO读操作超时时间单位 + */ + private TimeUnit readTimeUnit; + + /** + * 连接的IO写操作超时时长 + */ + private Long writeTimeout; + + /** + * 连接的IO写操作超时时间单位 + */ + private TimeUnit writeTimeUnit; + + /** + * ping的时间间隔 + */ + private Integer pingInterval; + + /** + * 持有client对象,仅初始化一次,避免多service实例的时候造成重复初始化的问题 + */ + private OkHttpClient okHttpClient; + + private DefaultOkHttpClientBuilder() { + + } + + public static DefaultOkHttpClientBuilder get() { + return DefaultOkHttpClientBuilder.SingletonHolder.INSTANCE; + } + + @Override + public OkHttpClient build() { + if (!prepared.get()) { + prepare(); + } + return this.okHttpClient; + } + + @Override + public OkHttpClientBuilder proxy(Proxy proxy) { + this.proxy = proxy; + return this; + } + + @Override + public OkHttpClientBuilder authenticator(Authenticator authenticator) { + this.authenticator = authenticator; + return this; + } + + @Override + public OkHttpClientBuilder addInterceptor(Interceptor interceptor) { + this.interceptorList.add(interceptor); + return this; + } + + @Override + public OkHttpClientBuilder setDispatcher(Dispatcher dispatcher) { + this.dispatcher = dispatcher; + return this; + } + + @Override + public OkHttpClientBuilder setConnectionPool(ConnectionPool connectionPool) { + this.connectionPool = connectionPool; + return this; + } + + @Override + public OkHttpClientBuilder setEventListenerFactory(EventListener.Factory eventListenerFactory) { + this.eventListenerFactory = eventListenerFactory; + return this; + } + + @Override + public OkHttpClientBuilder setRetryOnConnectionFailure(Boolean retryOnConnectionFailure) { + this.retryOnConnectionFailure = retryOnConnectionFailure; + return this; + } + + @Override + public OkHttpClientBuilder setFollowRedirects(Boolean followRedirects) { + this.followRedirects = followRedirects; + return this; + } + + @Override + public OkHttpClientBuilder connectTimeout(Long timeout, TimeUnit unit) { + this.connectTimeout = timeout; + this.connectTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder callTimeout(Long timeout, TimeUnit unit) { + this.callTimeout = timeout; + this.callTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder readTimeout(Long timeout, TimeUnit unit) { + this.readTimeout = timeout; + this.readTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder writeTimeout(Long timeout, TimeUnit unit) { + this.writeTimeout = timeout; + this.writeTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder setPingInterval(Integer pingInterval) { + this.pingInterval = pingInterval; + return this; + } + + private synchronized void prepare() { + if (prepared.get()) { + return; + } + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + if (this.authenticator != null) { + builder.authenticator(this.authenticator); + } + if (this.proxy != null) { + builder.proxy(this.proxy); + } + for (Interceptor interceptor : this.interceptorList) { + builder.addInterceptor(interceptor); + } + if (this.dispatcher != null) { + builder.dispatcher(dispatcher); + } + if (this.connectionPool != null) { + builder.connectionPool(connectionPool); + } + if (this.eventListenerFactory != null) { + builder.eventListenerFactory(this.eventListenerFactory); + } + if (this.retryOnConnectionFailure != null) { + builder.setRetryOnConnectionFailure$okhttp(this.retryOnConnectionFailure); + } + if (this.followRedirects != null) { + builder.followRedirects(this.followRedirects); + } + if (this.connectTimeout != null && this.connectTimeUnit != null) { + builder.connectTimeout(this.connectTimeout, this.connectTimeUnit); + } + if (this.callTimeout != null && this.callTimeUnit != null) { + builder.callTimeout(this.callTimeout, this.callTimeUnit); + } + if (this.readTimeout != null && this.readTimeUnit != null) { + builder.readTimeout(this.readTimeout, this.readTimeUnit); + } + if (this.writeTimeout != null && this.writeTimeUnit != null) { + builder.writeTimeout(this.writeTimeout, this.writeTimeUnit); + } + if (this.pingInterval != null) { + builder.setPingInterval$okhttp(this.pingInterval); + } + this.okHttpClient = builder.build(); + prepared.set(true); + } + + private static class SingletonHolder { + private static final DefaultOkHttpClientBuilder INSTANCE = new DefaultOkHttpClientBuilder(); + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpClientBuilder.java new file mode 100644 index 0000000000..0a2586a4bd --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpClientBuilder.java @@ -0,0 +1,126 @@ +package me.chanjar.weixin.common.util.http.okhttp; + +import okhttp3.*; + +import java.net.Proxy; +import java.util.concurrent.TimeUnit; + +/** + * @author wulang + **/ +public interface OkHttpClientBuilder { + /** + * 构建OkHttpClient实例. + * + * @return OkHttpClient + */ + OkHttpClient build(); + + /** + * 代理 + * + * @param proxy Proxy + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder proxy(Proxy proxy); + + /** + * 授权 + * + * @param authenticator Authenticator + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder authenticator(Authenticator authenticator); + + /** + * 拦截器 + * + * @param interceptor Interceptor + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder addInterceptor(Interceptor interceptor); + + /** + * 请求调度管理 + * + * @param dispatcher Dispatcher + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder setDispatcher(Dispatcher dispatcher); + + /** + * 连接池 + * + * @param connectionPool ConnectionPool + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder setConnectionPool(ConnectionPool connectionPool); + + /** + * 监听网络请求过程 + * + * @param eventListenerFactory EventListener + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder setEventListenerFactory(EventListener.Factory eventListenerFactory); + + /** + * 是否支持失败重连 + * + * @param retryOnConnectionFailure retryOnConnectionFailure + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder setRetryOnConnectionFailure(Boolean retryOnConnectionFailure); + + /** + * 是否允许重定向操作 + * + * @param followRedirects followRedirects + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder setFollowRedirects(Boolean followRedirects); + + /** + * 连接建立的超时时间 + * + * @param timeout 时长 + * @param unit 时间单位 + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder connectTimeout(Long timeout, TimeUnit unit); + + /** + * 完整的请求过程超时时间 + * + * @param timeout 时长 + * @param unit 时间单位 + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder callTimeout(Long timeout, TimeUnit unit); + + /** + * 连接的IO读操作超时时间 + * + * @param timeout 时长 + * @param unit 时间单位 + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder readTimeout(Long timeout, TimeUnit unit); + + /** + * 连接的IO写操作超时时间 + * + * @param timeout 时长 + * @param unit 时间单位 + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder writeTimeout(Long timeout, TimeUnit unit); + + /** + * ping的时间间隔 + * + * @param pingInterval ping的时间间隔 + * @return OkHttpClientBuilder + */ + OkHttpClientBuilder setPingInterval(Integer pingInterval); +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpDnsClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpDnsClientBuilder.java new file mode 100644 index 0000000000..c346747527 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpDnsClientBuilder.java @@ -0,0 +1,257 @@ +package me.chanjar.weixin.common.util.http.okhttp; + +import okhttp3.*; + +import java.net.Proxy; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * OkHttpClient 连接管理器 多一个DNS解析. + *

大部分代码拷贝自:DefaultOkHttpClientBuilder

+ * + * @author wulang + **/ +public class OkHttpDnsClientBuilder implements OkHttpClientBuilder { + + /** + * 代理 + */ + private Proxy proxy; + + /** + * 授权 + */ + private Authenticator authenticator; + + /** + * 拦截器 + */ + private final List interceptorList = new ArrayList<>(); + + /** + * 请求调度管理 + */ + private Dispatcher dispatcher; + + /** + * 连接池 + */ + private ConnectionPool connectionPool; + + /** + * 监听网络请求过程 + */ + private EventListener.Factory eventListenerFactory; + + /** + * 是否支持失败重连 + */ + private Boolean retryOnConnectionFailure; + + /** + * 是否允许重定向操作 + */ + private Boolean followRedirects; + + /** + * 连接建立的超时时长 + */ + private Long connectTimeout; + + /** + * 连接建立的超时时间单位 + */ + private TimeUnit connectTimeUnit; + + /** + * 完整的请求过程超时时长 + */ + private Long callTimeout; + + /** + * 完整的请求过程超时时间单位 + */ + private TimeUnit callTimeUnit; + + /** + * 连接的IO读操作超时时长 + */ + private Long readTimeout; + + /** + * 连接的IO读操作超时时间单位 + */ + private TimeUnit readTimeUnit; + + /** + * 连接的IO写操作超时时长 + */ + private Long writeTimeout; + + /** + * 连接的IO写操作超时时间单位 + */ + private TimeUnit writeTimeUnit; + + /** + * ping的时间间隔 + */ + private Integer pingInterval; + + private Dns dns; + + private OkHttpClient okHttpClient; + + private OkHttpDnsClientBuilder() { + + } + + public static OkHttpDnsClientBuilder get() { + return new OkHttpDnsClientBuilder(); + } + + public Dns getDns() { + return dns; + } + + public void setDns(Dns dns) { + this.dns = dns; + } + + @Override + public OkHttpClient build() { + prepare(); + return this.okHttpClient; + } + + @Override + public OkHttpClientBuilder proxy(Proxy proxy) { + this.proxy = proxy; + return this; + } + + @Override + public OkHttpClientBuilder authenticator(Authenticator authenticator) { + this.authenticator = authenticator; + return this; + } + + @Override + public OkHttpClientBuilder addInterceptor(Interceptor interceptor) { + this.interceptorList.add(interceptor); + return this; + } + + @Override + public OkHttpClientBuilder setDispatcher(Dispatcher dispatcher) { + this.dispatcher = dispatcher; + return this; + } + + @Override + public OkHttpClientBuilder setConnectionPool(ConnectionPool connectionPool) { + this.connectionPool = connectionPool; + return this; + } + + @Override + public OkHttpClientBuilder setEventListenerFactory(EventListener.Factory eventListenerFactory) { + this.eventListenerFactory = eventListenerFactory; + return this; + } + + @Override + public OkHttpClientBuilder setRetryOnConnectionFailure(Boolean retryOnConnectionFailure) { + this.retryOnConnectionFailure = retryOnConnectionFailure; + return this; + } + + @Override + public OkHttpClientBuilder setFollowRedirects(Boolean followRedirects) { + this.followRedirects = followRedirects; + return this; + } + + @Override + public OkHttpClientBuilder connectTimeout(Long timeout, TimeUnit unit) { + this.connectTimeout = timeout; + this.connectTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder callTimeout(Long timeout, TimeUnit unit) { + this.callTimeout = timeout; + this.callTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder readTimeout(Long timeout, TimeUnit unit) { + this.readTimeout = timeout; + this.readTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder writeTimeout(Long timeout, TimeUnit unit) { + this.writeTimeout = timeout; + this.writeTimeUnit = unit; + return this; + } + + @Override + public OkHttpClientBuilder setPingInterval(Integer pingInterval) { + this.pingInterval = pingInterval; + return this; + } + + private synchronized void prepare() { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + if (this.authenticator != null) { + builder.authenticator(this.authenticator); + } + if (this.proxy != null) { + builder.proxy(this.proxy); + } + for (Interceptor interceptor : this.interceptorList) { + builder.addInterceptor(interceptor); + } + if (this.dispatcher != null) { + builder.dispatcher(dispatcher); + } + if (this.connectionPool != null) { + builder.connectionPool(connectionPool); + } + if (this.eventListenerFactory != null) { + builder.eventListenerFactory(this.eventListenerFactory); + } + if (this.retryOnConnectionFailure != null) { + builder.setRetryOnConnectionFailure$okhttp(this.retryOnConnectionFailure); + } + if (this.followRedirects != null) { + builder.followRedirects(this.followRedirects); + } + if (this.dns != null) { + builder.dns(this.dns); + } + if (this.connectTimeout != null && this.connectTimeUnit != null) { + builder.connectTimeout(this.connectTimeout, this.connectTimeUnit); + } + if (this.callTimeout != null && this.callTimeUnit != null) { + builder.callTimeout(this.callTimeout, this.callTimeUnit); + } + if (this.readTimeout != null && this.readTimeUnit != null) { + builder.readTimeout(this.readTimeout, this.readTimeUnit); + } + if (this.writeTimeout != null && this.writeTimeUnit != null) { + builder.writeTimeout(this.writeTimeout, this.writeTimeUnit); + } + if (this.pingInterval != null) { + builder.setPingInterval$okhttp(this.pingInterval); + } + this.okHttpClient = builder.build(); + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java index ff0cea1c2b..dda52e2f7b 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java @@ -21,7 +21,7 @@ /** *. * @author ecoolper - * @date 2017/5/5 + * created on 2017/5/5 */ @Slf4j public class OkHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaInputStreamUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaInputStreamUploadRequestExecutor.java new file mode 100644 index 0000000000..613bd7ecfa --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaInputStreamUploadRequestExecutor.java @@ -0,0 +1,56 @@ +package me.chanjar.weixin.common.util.http.okhttp; + +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.InputStreamData; +import me.chanjar.weixin.common.util.http.MediaInputStreamUploadRequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import okhttp3.*; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * 文件输入流上传. + * + * @author meiqin.zhou91@gmail.com + * created on 2022/02/15 + */ +public class OkHttpMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor { + public OkHttpMediaInputStreamUploadRequestExecutor(RequestHttp requestHttp) { + super(requestHttp); + } + + @Override + public WxMediaUploadResult execute(String uri, InputStreamData data, WxType wxType) throws WxErrorException, IOException { + + RequestBody body = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("media", data.getFilename(), RequestBody.create(this.toByteArray(data.getInputStream()), MediaType.parse("application/octet-stream"))) + .build(); + Request request = new Request.Builder().url(uri).post(body).build(); + + Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); + String responseContent = response.body().string(); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMediaUploadResult.fromJson(responseContent); + } + + + public byte[] toByteArray(InputStream input) throws IOException { + try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { + byte[] buffer = new byte[4096]; + int n = 0; + while (-1 != (n = input.read(buffer))) { + output.write(buffer, 0, n); + } + return output.toByteArray(); + } + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java index 6d2602d3df..1b5241ff70 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java @@ -15,7 +15,7 @@ * . * * @author ecoolper - * @date 2017/5/5 + * created on 2017/5/5 */ public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor { public OkHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java index 45d112cd6c..a8b76321ca 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java @@ -14,23 +14,34 @@ /** * @author liming1019 - * @date 2021/8/10 + * created on 2021/8/10 */ @Slf4j public class OkHttpMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor { - public OkHttpMinishopMediaUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType) { - super(requestHttp, respType); + public OkHttpMinishopMediaUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType, String imgUrl) { + super(requestHttp, respType, imgUrl); } @Override public WxMinishopImageUploadCustomizeResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { - RequestBody body = new MultipartBody.Builder() - .setType(MediaType.parse("multipart/form-data")) - .addFormDataPart("media", - file.getName(), - RequestBody.create(MediaType.parse("application/octet-stream"), file)) - .build(); + RequestBody body = null; + if (this.uploadType.equals("0")) { + body = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("resp_type", this.respType) + .addFormDataPart("upload_type", this.uploadType) + .addFormDataPart("media", file.getName(), RequestBody.create(MediaType.parse("application/octet-stream"), file)) + .build(); + } + else { + body = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("resp_type", this.respType) + .addFormDataPart("upload_type", this.uploadType) + .addFormDataPart("img_url", this.imgUrl) + .build(); + } Request request = new Request.Builder().url(uri).post(body).build(); Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java index d8fd66baef..5c40b1f6ba 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java @@ -18,7 +18,7 @@ * . * * @author ecoolper - * @date 2017/5/5 + * created on 2017/5/5 */ @Slf4j public class OkHttpMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java index 9be073e38a..ec031d3afe 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java @@ -14,7 +14,7 @@ * . * * @author ecoolper - * @date 2017/5/4 + * created on 2017/5/4 */ public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor { public OkHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java index 788ea59260..a289f362e3 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java @@ -14,7 +14,7 @@ * . * * @author ecoolper - * @date 2017/5/4 + * created on 2017/5/4 */ @Slf4j public class OkHttpSimplePostRequestExecutor extends SimplePostRequestExecutor { @@ -24,7 +24,7 @@ public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) { @Override public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException { - RequestBody body = RequestBody.Companion.create(postEntity, MediaType.parse("text/plain; charset=utf-8")); + RequestBody body = RequestBody.Companion.create(postEntity, MediaType.parse("application/json; charset=utf-8")); Request request = new Request.Builder().url(uri).post(body).build(); Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); return this.handleResponse(wxType, Objects.requireNonNull(response.body()).string()); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonParser.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonParser.java index 53f51e0f3e..061a3cb2ee 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonParser.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonParser.java @@ -3,7 +3,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.stream.JsonReader; -import lombok.NoArgsConstructor; import java.io.Reader; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java index 0ea52b9a86..c9301a7750 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.common.util.json; import com.google.gson.*; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.error.WxError; import java.lang.reflect.Type; @@ -16,8 +17,8 @@ public WxError deserialize(JsonElement json, Type typeOfT, JsonDeserializationCo WxError.WxErrorBuilder errorBuilder = WxError.builder(); JsonObject wxErrorJsonObject = json.getAsJsonObject(); - if (wxErrorJsonObject.get("errcode") != null && !wxErrorJsonObject.get("errcode").isJsonNull()) { - errorBuilder.errorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get("errcode"))); + if (wxErrorJsonObject.get(WxConsts.ERR_CODE) != null && !wxErrorJsonObject.get(WxConsts.ERR_CODE).isJsonNull()) { + errorBuilder.errorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get(WxConsts.ERR_CODE))); } if (wxErrorJsonObject.get("errmsg") != null && !wxErrorJsonObject.get("errmsg").isJsonNull()) { errorBuilder.errorMsg(GsonHelper.getAsString(wxErrorJsonObject.get("errmsg"))); 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 0624923508..ff260c16fb 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 @@ -7,6 +7,7 @@ import me.chanjar.weixin.common.bean.menu.WxMenu; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import java.util.Objects; /** * . @@ -14,6 +15,7 @@ */ public class WxGsonBuilder { private static final GsonBuilder INSTANCE = new GsonBuilder(); + private static volatile Gson GSON_INSTANCE; static { INSTANCE.disableHtmlEscaping(); @@ -26,7 +28,14 @@ public class WxGsonBuilder { } public static Gson create() { - return INSTANCE.create(); + if (Objects.isNull(GSON_INSTANCE)) { + synchronized (INSTANCE) { + if (Objects.isNull(GSON_INSTANCE)) { + GSON_INSTANCE = INSTANCE.create(); + } + } + } + return GSON_INSTANCE; } } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java index 31c3c0204c..50d3b0d630 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java @@ -46,6 +46,7 @@ protected JsonObject convertToJson(WxMenuButton button) { buttonJson.addProperty("key", button.getKey()); buttonJson.addProperty("url", button.getUrl()); buttonJson.addProperty("media_id", button.getMediaId()); + buttonJson.addProperty("article_id", button.getArticleId()); buttonJson.addProperty("appid", button.getAppId()); buttonJson.addProperty("pagepath", button.getPagePath()); if (button.getSubButtons() != null && button.getSubButtons().size() > 0) { @@ -122,6 +123,7 @@ protected WxMenuButton convertFromJson(JsonObject json) { button.setUrl(GsonHelper.getString(json, "url")); button.setType(GsonHelper.getString(json, "type")); button.setMediaId(GsonHelper.getString(json, "media_id")); + button.setArticleId(GsonHelper.getString(json, "article_id")); button.setAppId(GsonHelper.getString(json, "appid")); button.setPagePath(GsonHelper.getString(json, "pagepath")); return button; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/locks/RedisTemplateSimpleDistributedLock.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/locks/RedisTemplateSimpleDistributedLock.java index 8c5ccc26fd..214b4547b0 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/locks/RedisTemplateSimpleDistributedLock.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/locks/RedisTemplateSimpleDistributedLock.java @@ -1,8 +1,6 @@ package me.chanjar.weixin.common.util.locks; import lombok.Getter; -import lombok.NonNull; -import org.jetbrains.annotations.NotNull; import org.springframework.data.redis.connection.RedisStringCommands; import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.StringRedisTemplate; @@ -34,11 +32,11 @@ public class RedisTemplateSimpleDistributedLock implements Lock { private final ThreadLocal valueThreadLocal = new ThreadLocal<>(); - public RedisTemplateSimpleDistributedLock(@NonNull StringRedisTemplate redisTemplate, int leaseMilliseconds) { + public RedisTemplateSimpleDistributedLock( StringRedisTemplate redisTemplate, int leaseMilliseconds) { this(redisTemplate, "lock:" + UUID.randomUUID().toString(), leaseMilliseconds); } - public RedisTemplateSimpleDistributedLock(@NonNull StringRedisTemplate redisTemplate, @NonNull String key, int leaseMilliseconds) { + public RedisTemplateSimpleDistributedLock( StringRedisTemplate redisTemplate, String key, int leaseMilliseconds) { if (leaseMilliseconds <= 0) { throw new IllegalArgumentException("Parameter 'leaseMilliseconds' must grate then 0: " + leaseMilliseconds); } @@ -84,7 +82,7 @@ public boolean tryLock() { } @Override - public boolean tryLock(long time, @NotNull TimeUnit unit) throws InterruptedException { + public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { long waitMs = unit.toMillis(time); boolean locked = tryLock(); while (!locked && waitMs > 0) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/IntegerArrayConverter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/IntegerArrayConverter.java index 3a82b213ca..3532fcab08 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/IntegerArrayConverter.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/IntegerArrayConverter.java @@ -9,7 +9,7 @@ * Integer型数组转换器. * * @author Binary Wang - * @date 2019-08-22 + * created on 2019-08-22 */ public class IntegerArrayConverter extends StringConverter { @Override @@ -24,6 +24,11 @@ public String toString(Object obj) { @Override public Object fromString(String str) { + + if (str == null || str.length() == 0) { + return null; + } + final Iterable iterable = Splitter.on(",").split(str); final String[] strings = Iterables.toArray(iterable, String.class); Integer[] result = new Integer[strings.length]; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/LongArrayConverter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/LongArrayConverter.java index a383c59674..ca5f8ac9a4 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/LongArrayConverter.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/LongArrayConverter.java @@ -9,7 +9,7 @@ * Long型数组转换器. * * @author Binary Wang - * @date 2019-08-22 + * created on 2019-08-22 */ public class LongArrayConverter extends StringConverter { @Override 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 6997eb490d..3fa91fa70e 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 @@ -11,7 +11,6 @@ import com.thoughtworks.xstream.io.xml.XppDriver; import com.thoughtworks.xstream.security.NoTypePermission; import com.thoughtworks.xstream.security.WildcardTypePermission; - import java.io.Writer; /** @@ -20,6 +19,13 @@ * @author Daniel Qian */ public class XStreamInitializer { + + public static ClassLoader classLoader; + + public static void setClassLoader(ClassLoader classLoaderInfo) { + classLoader = classLoaderInfo; + } + private static final XppDriver XPP_DRIVER = new XppDriver() { @Override public HierarchicalStreamWriter createWriter(Writer out) { @@ -80,7 +86,6 @@ protected void setupConverters() { }; xstream.ignoreUnknownElements(); xstream.setMode(XStream.NO_REFERENCES); - XStream.setupDefaultSecurity(xstream); xstream.autodetectAnnotations(true); // setup proper security by limiting which classes can be loaded by XStream @@ -88,7 +93,10 @@ protected void setupConverters() { xstream.addPermission(new WildcardTypePermission(new String[]{ "me.chanjar.weixin.**", "cn.binarywang.wx.**", "com.github.binarywang.**" })); - xstream.setClassLoader(Thread.currentThread().getContextClassLoader()); + if (null == classLoader) { + classLoader = Thread.currentThread().getContextClassLoader(); + } + xstream.setClassLoader(classLoader); return xstream; } diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingletonTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingletonTest.java new file mode 100644 index 0000000000..df1ee7e2bc --- /dev/null +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingletonTest.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.common.api; + +import org.testng.annotations.Test; + +import java.util.concurrent.TimeUnit; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +/** + * @author jiangby + * @version 1.0 + * created on 2022/5/26 1:46 + */ +@Test +public class WxMessageInMemoryDuplicateCheckerSingletonTest { + + private static WxMessageInMemoryDuplicateCheckerSingleton checkerSingleton = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); + + public void test() throws InterruptedException { + Long[] msgIds = new Long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L}; + + // 第一次检查 + for (Long msgId : msgIds) { + boolean result = checkerSingleton.isDuplicate(String.valueOf(msgId)); + assertFalse(result); + } + + // 初始化后1S进行检查 每五秒检查一次,过期时间为15秒,过15秒再检查 + TimeUnit.SECONDS.sleep(15); + for (Long msgId : msgIds) { + boolean result = checkerSingleton.isDuplicate(String.valueOf(msgId)); + assertTrue(result); + } + + // 过6秒再检查 + TimeUnit.SECONDS.sleep(6); + for (Long msgId : msgIds) { + boolean result = checkerSingleton.isDuplicate(String.valueOf(msgId)); + assertFalse(result); + } + + } +} diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateCheckerTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateCheckerTest.java new file mode 100644 index 0000000000..382618862a --- /dev/null +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateCheckerTest.java @@ -0,0 +1,57 @@ +package me.chanjar.weixin.common.api; + +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.redisson.config.TransportMode; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import java.util.concurrent.TimeUnit; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +@Test +public class WxMessageInRedisDuplicateCheckerTest { + + private RedissonClient redissonClient; + + @BeforeTest + public void init() { + Config config = new Config(); + config.useSingleServer().setAddress("redis://127.0.0.1:6379"); + config.setTransportMode(TransportMode.NIO); + this.redissonClient = Redisson.create(config); + checker = new WxMessageInRedisDuplicateChecker(redissonClient); + checker.setExpire(2); + } + + private WxMessageInRedisDuplicateChecker checker; + + public void test() throws InterruptedException { + Long[] msgIds = new Long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L}; + + // 第一次检查 + for (Long msgId : msgIds) { + boolean result = checker.isDuplicate(String.valueOf(msgId)); + assertFalse(result); + } + + // 过1秒再检查 + TimeUnit.SECONDS.sleep(1); + for (Long msgId : msgIds) { + boolean result = checker.isDuplicate(String.valueOf(msgId)); + assertTrue(result); + } + + // 过1.5秒再检查 + TimeUnit.MILLISECONDS.sleep(1500L); + for (Long msgId : msgIds) { + boolean result = checker.isDuplicate(String.valueOf(msgId)); + assertFalse(result); + } + + } + +} diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxNetCheckResultTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxNetCheckResultTest.java index 3f08b20bff..049b28227f 100644 --- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxNetCheckResultTest.java +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxNetCheckResultTest.java @@ -6,7 +6,7 @@ /** * * @author Binary Wang - * @date 2020-06-06 + * created on 2020-06-06 */ public class WxNetCheckResultTest { diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/XmlUtilsTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/XmlUtilsTest.java index 7b6bb536f4..ff34475ef2 100644 --- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/XmlUtilsTest.java +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/XmlUtilsTest.java @@ -63,27 +63,54 @@ public void testXml2Map() { assertThat(map).isNotNull(); final Map copyrightCheckResult = (Map) map.get("CopyrightCheckResult"); List> resultList = (List>) ((Map) copyrightCheckResult.get("ResultList")).get("item"); - assertThat(copyrightCheckResult).isNotNull(); - assertThat(copyrightCheckResult.get("Count")).isEqualTo("2"); - assertThat(copyrightCheckResult.get("CheckState")).isEqualTo("2"); + assertThat(copyrightCheckResult) + .isNotNull() + .containsEntry("Count", "2") + .containsEntry("CheckState", "2"); - assertThat(resultList.get(0).get("ArticleIdx")).isEqualTo("1"); - assertThat(resultList.get(0).get("UserDeclareState")).isEqualTo("0"); - assertThat(resultList.get(0).get("AuditState")).isEqualTo("2"); - assertThat(resultList.get(0).get("OriginalArticleUrl")).isEqualTo("Url_1"); - assertThat(resultList.get(0).get("OriginalArticleType")).isEqualTo("1"); - assertThat(resultList.get(0).get("CanReprint")).isEqualTo("1"); - assertThat(resultList.get(0).get("NeedReplaceContent")).isEqualTo("1"); - assertThat(resultList.get(0).get("NeedShowReprintSource")).isEqualTo("1"); + assertThat(resultList.get(0)).containsEntry("ArticleIdx", "1") + .containsEntry("UserDeclareState", "0") + .containsEntry("AuditState", "2") + .containsEntry("OriginalArticleUrl", "Url_1") + .containsEntry("OriginalArticleType", "1") + .containsEntry("CanReprint", "1") + .containsEntry("NeedReplaceContent", "1") + .containsEntry("NeedShowReprintSource", "1"); - assertThat(resultList.get(1).get("ArticleIdx")).isEqualTo("2"); - assertThat(resultList.get(1).get("UserDeclareState")).isEqualTo("0"); - assertThat(resultList.get(1).get("AuditState")).isEqualTo("2"); - assertThat(resultList.get(1).get("OriginalArticleUrl")).isEqualTo("Url_2"); - assertThat(resultList.get(1).get("OriginalArticleType")).isEqualTo("1"); - assertThat(resultList.get(1).get("CanReprint")).isEqualTo("1"); - assertThat(resultList.get(1).get("NeedReplaceContent")).isEqualTo("1"); - assertThat(resultList.get(1).get("NeedShowReprintSource")).isEqualTo("1"); + assertThat(resultList.get(1)).containsEntry("ArticleIdx", "2") + .containsEntry("UserDeclareState", "0") + .containsEntry("AuditState", "2") + .containsEntry("OriginalArticleUrl", "Url_2") + .containsEntry("OriginalArticleType", "1") + .containsEntry("CanReprint", "1") + .containsEntry("NeedReplaceContent", "1") + .containsEntry("NeedShowReprintSource", "1"); + } + + @Test + public void testXml2Map_another() { + String xml = " 1481013459 2247503051 0 1 1 2 "; + + final Map map = XmlUtils.xml2Map(xml); + assertThat(map).isNotNull() + .containsEntry("ToUserName", "gh_4d00ed8d6399") + .containsEntry("FromUserName", "oV5CrjpxgaGXNHIQigzNlgLTnwic") + .containsEntry("CreateTime", "1481013459") + .containsEntry("MsgType", "event"); + + Map publishEventInfo = (Map) map.get("PublishEventInfo"); + assertThat(publishEventInfo).containsEntry("publish_id", "2247503051") + .containsEntry("publish_status", "0") + .containsEntry("article_id", "b5O2OUs25HBxRceL7hfReg-U9QGeq9zQjiDvy WP4Hq4"); + + Map articleDetail = (Map) publishEventInfo.get("article_detail"); + assertThat(articleDetail).containsEntry("count", "1"); + List< Map> item = (List>) articleDetail.get("item"); + assertThat(item.get(0)).containsEntry("idx", "1") + .containsEntry("article_url", "ARTICLE_URL"); + + assertThat(item.get(1)).containsEntry("idx", "2") + .containsEntry("article_url", "ARTICLE_URL_2"); } } diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/WxCryptUtilTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/WxCryptUtilTest.java index 82cfa9d2d6..b61696c1ea 100755 --- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/WxCryptUtilTest.java +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/WxCryptUtilTest.java @@ -96,7 +96,7 @@ public void testValidateSignatureError() throws ParserConfigurationException, SA String encrypt = nodelist1.item(0).getTextContent(); String fromXML = String.format(this.xmlFormat, encrypt); - pc.decrypt("12345", this.timestamp, this.nonce, fromXML); // 这里签名错误 + pc.decryptXml("12345", this.timestamp, this.nonce, fromXML); // 这里签名错误 } catch (RuntimeException e) { assertEquals(e.getMessage(), "加密消息签名校验失败"); return; diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/fs/FileUtilsTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/fs/FileUtilsTest.java new file mode 100644 index 0000000000..5a25fb1493 --- /dev/null +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/fs/FileUtilsTest.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.common.util.fs; + +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class FileUtilsTest { + + @Test + public void testCreateTmpFile() throws IOException { + String strings = "abc"; + File tmpFile = FileUtils.createTmpFile(new ByteArrayInputStream(strings.getBytes()), "name", "txt"); + System.out.println(tmpFile); + List lines = IOUtils.readLines(Files.newInputStream(tmpFile.toPath()), Charset.defaultCharset()); + assertThat(lines).hasSize(1); + assertThat(lines.get(0)).isEqualTo(strings); + } + + @Test + public void testTestCreateTmpFile() { + } + + @Test + public void testImageToBase64ByStream() { + } +} diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilderTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilderTest.java new file mode 100644 index 0000000000..d742845b6c --- /dev/null +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilderTest.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.common.util.http.okhttp; + +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class DefaultOkHttpClientBuilderTest { + @Test + public void testBuild() throws Exception { + DefaultOkHttpClientBuilder builder1 = DefaultOkHttpClientBuilder.get(); + DefaultOkHttpClientBuilder builder2 = DefaultOkHttpClientBuilder.get(); + Assert.assertSame(builder1, builder2, "DefaultOkHttpClientBuilder为单例,获取到的对象应该相同"); + List threadList = new ArrayList<>(10); + for (int i = 0; i < 10; i++) { + DefaultOkHttpClientBuilderTest.TestThread thread = new DefaultOkHttpClientBuilderTest.TestThread(); + thread.start(); + threadList.add(thread); + } + for (DefaultOkHttpClientBuilderTest.TestThread testThread : threadList) { + testThread.join(); + Assert.assertNotEquals(-1, testThread.getRespState(), "请求响应code不应为-1"); + } + + for (int i = 1; i < threadList.size(); i++) { + DefaultOkHttpClientBuilderTest.TestThread thread1 = threadList.get(i - 1); + DefaultOkHttpClientBuilderTest.TestThread thread2 = threadList.get(i); + Assert.assertSame( + thread1.getClient(), + thread2.getClient(), + "DefaultOkHttpClientBuilderTest为单例,并持有了相同的OkHttpClient" + ); + } + } + + public static class TestThread extends Thread { + private OkHttpClient client; + private int respState = -1; + + @Override + public void run() { + client = DefaultOkHttpClientBuilder.get().build(); + Request request = new Request.Builder() + .url("http://www.sina.com.cn/") + .build(); + try (Response response = client.newCall(request).execute()) { + respState = response.code(); + } catch (IOException e) { + // ignore + } + } + + public OkHttpClient getClient() { + return client; + } + + public int getRespState() { + return respState; + } + } +} diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/json/GsonHelperTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/json/GsonHelperTest.java index 396862e708..bafe3c30d1 100644 --- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/json/GsonHelperTest.java +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/json/GsonHelperTest.java @@ -9,7 +9,7 @@ * GsonHelper 的单元测试. * * @author Binary Wang - * @date 2020-09-04 + * created on 2020-09-04 */ public class GsonHelperTest { diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 90edd559fb..0fb5ab62d2 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B weixin-java-cp @@ -43,6 +43,10 @@ org.redisson redisson + + org.springframework.data + spring-data-redis + org.testng testng @@ -88,6 +92,13 @@ moco-runner test + + + com.fasterxml.jackson.core + jackson-core + 2.13.4 + test + diff --git a/weixin-java-cp/src/main/java/com/tencent/wework/Finance.java b/weixin-java-cp/src/main/java/com/tencent/wework/Finance.java new file mode 100644 index 0000000000..4d6406bd18 --- /dev/null +++ b/weixin-java-cp/src/main/java/com/tencent/wework/Finance.java @@ -0,0 +1,252 @@ +package com.tencent.wework; + +import lombok.extern.slf4j.Slf4j; + +import java.util.List; + +/** + * 企业微信会话内容存档Finance类 + * 注意: + * 此类必须配置在com.tencent.wework路径底下,否则会报错:java.lang.UnsatisfiedLinkError: com.xxx.Finance.NewSdk() + *

+ * Q:JAVA版本的sdk报错UnsatisfiedLinkError? + * A:请检查是否修改了sdk的包名。 + *

+ * 官方文档 + * + * @author Wang_Wong created on 2022-01-17 + */ +@Slf4j +public class Finance { + + private static volatile long sdk = -1L; + private static Finance finance = null; + private static final String SO_FILE = "so"; + private static final String DLL_FILE = "dll"; + + /** + * New sdk long. + * + * @return the long + */ + public static native long NewSdk(); + + /** + * 初始化函数 + * Return值=0表示该API调用成功 + * + * @param sdk the sdk + * @param corpid the corpid + * @param secret the secret + * @return 返回是否初始化成功 0 - 成功 !=0 - 失败 + */ + public static native int Init(long sdk, String corpid, String secret); + + /** + * 拉取聊天记录函数 + * Return值=0表示该API调用成功 + * + * @param sdk the sdk + * @param seq the seq + * @param limit the limit + * @param proxy the proxy + * @param passwd the passwd + * @param timeout the timeout + * @param chatData the chat data + * @return 返回是否调用成功 0 - 成功 !=0 - 失败 + */ + public static native int GetChatData(long sdk, long seq, long limit, String proxy, String passwd, long timeout, long chatData); + + /** + * 拉取媒体消息函数 + * Return值=0表示该API调用成功 + * + * @param sdk the sdk + * @param indexbuf the indexbuf + * @param sdkField the sdk field + * @param proxy the proxy + * @param passwd the passwd + * @param timeout the timeout + * @param mediaData the media data + * @return 返回是否调用成功 0 - 成功 !=0 - 失败 + */ + public static native int GetMediaData(long sdk, String indexbuf, String sdkField, String proxy, String passwd, long timeout, long mediaData); + + /** + * 解析密文 + * + * @param sdk the sdk + * @param encrypt_key the encrypt key + * @param encrypt_msg the encrypt msg + * @param msg the msg + * @return 返回是否调用成功 0 - 成功 !=0 - 失败 + */ + public static native int DecryptData(long sdk, String encrypt_key, String encrypt_msg, long msg); + + /** + * Destroy sdk. + * + * @param sdk the sdk + */ + public static native void DestroySdk(long sdk); + + /** + * New slice long. + * + * @return the long + */ + public static native long NewSlice(); + + /** + * 释放slice ,和NewSlice成对使用 + * + * @param slice the slice + */ + public static native void FreeSlice(long slice); + + /** + * 获取slice内容 + * + * @param slice the slice + * @return 内容 string + */ + public static native String GetContentFromSlice(long slice); + + /** + * 获取slice内容长度 + * + * @param slice the slice + * @return 内容 int + */ + public static native int GetSliceLen(long slice); + + /** + * New media data long. + * + * @return the long + */ + public static native long NewMediaData(); + + /** + * Free media data. + * + * @param mediaData the media data + */ + public static native void FreeMediaData(long mediaData); + + /** + * 获取 mediadata outindex + * + * @param mediaData the media data + * @return outindex string + */ + public static native String GetOutIndexBuf(long mediaData); + + /** + * 获取 mediadata data数据 + * + * @param mediaData the media data + * @return data byte [ ] + */ + public static native byte[] GetData(long mediaData); + + /** + * Get index len int. + * + * @param mediaData the media data + * @return the int + */ + public static native int GetIndexLen(long mediaData); + + /** + * Get data len int. + * + * @param mediaData the media data + * @return the int + */ + public static native int GetDataLen(long mediaData); + + /** + * Is media data finish int. + * + * @param mediaData the media data + * @return 1完成 、0未完成 + * 判断mediadata是否结束 + */ + public static native int IsMediaDataFinish(long mediaData); + + /** + * 判断Windows环境 + * + * @return boolean boolean + */ + public static boolean isWindows() { + String osName = System.getProperties().getProperty("os.name"); + log.info("Loading System Libraries, Current OS Version Is: {}", osName); + return osName.toUpperCase().contains("WINDOWS"); + } + + /** + * 加载系统类库 + * + * @param libFiles 类库配置文件 + * @param prefixPath 类库文件的前缀路径 + */ + public Finance(List libFiles, String prefixPath) { + boolean isWindows = Finance.isWindows(); + for (String file : libFiles) { + String suffix = file.substring(file.lastIndexOf(".") + 1); + if (isWindows) { + // 加载dll文件 + if (suffix.equalsIgnoreCase(DLL_FILE)) { + System.load(prefixPath + file); + } + } else { + // 加载so文件 + if (suffix.equalsIgnoreCase(SO_FILE)) { + System.load(prefixPath + file); + } + } + } + + } + + /** + * 初始化类库文件 + * + * @param libFiles the lib files + * @param prefixPath the prefix path + * @return finance finance + */ + public static synchronized Finance loadingLibraries(List libFiles, String prefixPath) { + if (finance != null) { + return finance; + } + finance = new Finance(libFiles, prefixPath); + return finance; + } + + /** + * 单例sdk + * + * @return long + */ + public static synchronized long SingletonSDK() { + if (sdk > 0) { + return sdk; + } + sdk = Finance.NewSdk(); + return sdk; + } + + /** + * 销毁sdk,保证线程可见性 + * + * @param destroySDK the destroy sdk + */ + public static synchronized void DestroySingletonSDK(long destroySDK) { + sdk = 0L; + Finance.DestroySdk(destroySDK); + } + +} 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 d57ca56c21..0c5ccb3b0c 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 @@ -8,7 +8,7 @@ /** *

  *  管理企业号应用
- *  文档地址:https://work.weixin.qq.com/api/doc#10087
+ *  文档地址:...
  *  Created by huansinho on 2018/4/13.
  * 
* @@ -19,11 +19,12 @@ public interface WxCpAgentService { *
    * 获取企业号应用信息
    * 该API用于获取企业号某个应用的基本信息,包括头像、昵称、帐号类型、认证类型、可见范围等信息
-   * 详情请见: https://work.weixin.qq.com/api/doc#10087
+   * 详情请见: ...
    * 
* * @param agentId 企业应用的id - * @return 部门id + * @return wx cp agent + * @throws WxErrorException the wx error exception */ WxCpAgent get(Integer agentId) throws WxErrorException; @@ -31,10 +32,11 @@ public interface WxCpAgentService { *
    * 设置应用.
    * 仅企业可调用,可设置当前凭证对应的应用;第三方不可调用。
-   * 详情请见: https://work.weixin.qq.com/api/doc#10088
+   * 详情请见: ...
    * 
* * @param agentInfo 应用信息 + * @throws WxErrorException the wx error exception */ void set(WxCpAgent agentInfo) throws WxErrorException; @@ -42,9 +44,11 @@ public interface WxCpAgentService { *
    * 获取应用列表.
    * 企业仅可获取当前凭证对应的应用;第三方仅可获取被授权的应用。
-   * 详情请见: https://work.weixin.qq.com/api/doc#11214
+   * 详情请见: ...
    * 
* + * @return the list + * @throws WxErrorException the wx error exception */ List list() throws WxErrorException; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentWorkBenchService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentWorkBenchService.java index 7ee8210084..c50aa2f5fc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentWorkBenchService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentWorkBenchService.java @@ -4,15 +4,36 @@ import me.chanjar.weixin.cp.bean.WxCpAgentWorkBench; /** + * The interface Wx cp agent work bench service. + * 工作台自定义展示 + * * @author songshiyu - * @date : create in 16:16 2020/9/27 - * @description: 工作台自定义展示:https://work.weixin.qq.com/api/doc/90000/90135/92535 + * created on 16:16 2020/9/27 */ public interface WxCpAgentWorkBenchService { + /** + * Sets work bench template. + * + * @param wxCpAgentWorkBench the wx cp agent work bench + * @throws WxErrorException the wx error exception + */ void setWorkBenchTemplate(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException; + /** + * Gets work bench template. + * + * @param agentid the agentid + * @return the work bench template + * @throws WxErrorException the wx error exception + */ String getWorkBenchTemplate(Long agentid) throws WxErrorException; + /** + * Sets work bench data. + * + * @param wxCpAgentWorkBench the wx cp agent work bench + * @throws WxErrorException the wx error exception + */ void setWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java index 9c825d8917..6cbe2ec8ac 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java @@ -1,8 +1,8 @@ package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; import me.chanjar.weixin.cp.bean.WxCpChat; +import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; import java.util.List; @@ -19,7 +19,7 @@ public interface WxCpChatService { * @param owner 指定群主的id。如果不指定,系统会随机从userlist中选一人作为群主 * @param users 群成员id列表。至少2人,至多500人 * @param chatId 群聊的唯一标志,不能与已有的群重复;字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z。如果不填,系统会随机生成群id - * @return 创建的群聊会话chatId + * @return 创建的群聊会话chatId string * @throws WxErrorException 异常 */ String create(String name, String owner, List users, String chatId) throws WxErrorException; @@ -40,7 +40,7 @@ public interface WxCpChatService { * 获取群聊会话. * * @param chatId 群聊编号 - * @return 群聊会话 + * @return 群聊会话 wx cp chat * @throws WxErrorException 异常 */ WxCpChat get(String chatId) throws WxErrorException; @@ -49,7 +49,7 @@ public interface WxCpChatService { * 应用支持推送文本、图片、视频、文件、图文等类型. * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token=ACCESS_TOKEN - * 文档地址:https://work.weixin.qq.com/api/doc#90000/90135/90248 + * 文档地址:... * * @param message 要发送的消息内容对象 * @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 new file mode 100644 index 0000000000..4da13d3fde --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.cp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorp; + +import java.util.List; + +/** + * 企业互联相关接口 + * + * @author libo <422423229@qq.com> + * Created on 27/2/2023 9:57 PM + */ +public interface WxCpCorpGroupService { + /** + * List app share info list. + * + * @param agentId the agent id + * @param businessType the business type + * @param corpId the corp id + * @param limit the limit + * @param cursor the cursor + * @return the list + * @throws WxErrorException the wx error exception + */ + List listAppShareInfo(Integer agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpDepartmentService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpDepartmentService.java index c86816b7f2..75bf02a64b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpDepartmentService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpDepartmentService.java @@ -19,31 +19,55 @@ public interface WxCpDepartmentService { *
    * 部门管理接口 - 创建部门.
    * 最多支持创建500个部门
-   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90205
+   * 详情请见: ...
    * 
* * @param depart 部门 - * @return 部门id + * @return 部门id long * @throws WxErrorException 异常 */ Long create(WxCpDepart depart) throws WxErrorException; + /** + *
+   * 部门管理接口 - 获取单个部门详情.
+   * 详情请见: ...
+   * 
+ * + * @param id 部门id + * @return 部门信息 wx cp depart + * @throws WxErrorException 异常 + */ + WxCpDepart get(Long id) throws WxErrorException; + /** *
    * 部门管理接口 - 获取部门列表.
-   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90208
+   * 详情请见: ...
    * 
* * @param id 部门id。获取指定部门及其下的子部门。非必需,可为null - * @return 获取的部门列表 + * @return 获取的部门列表 list * @throws WxErrorException 异常 */ List list(Long id) throws WxErrorException; + /** + *
+   * 部门管理接口 - 获取子部门ID列表.
+   * 详情请见: ...
+   * 
+ * + * @param id 部门id。获取指定部门及其下的子部门(以及子部门的子部门等等,递归)。 如果不填,默认获取全量组织架构 + * @return 子部门ID列表 list + * @throws WxErrorException 异常 + */ + List simpleList(Long id) throws WxErrorException; + /** *
    * 部门管理接口 - 更新部门.
-   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90206
+   * 详情请见: ...
    * 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
    * 
* @@ -55,7 +79,7 @@ public interface WxCpDepartmentService { /** *
    * 部门管理接口 - 删除部门.
-   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90207
+   * 详情请见: ...
    * 应用须拥有指定部门的管理权限
    * 
* 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 new file mode 100644 index 0000000000..24c6ea9dc1 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExportService.java @@ -0,0 +1,99 @@ +package me.chanjar.weixin.cp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.export.WxCpExportRequest; +import me.chanjar.weixin.cp.bean.export.WxCpExportResult; + +/** + * 异步导出接口 + * + * @author zhongjun created on 2022/4/21 + */ +public interface WxCpExportService { + + /** + *
+   *
+   * 导出成员
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/export/simple_user?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/94849
+   * 
+ * + * @param params 导出参数 + * @return jobId 异步任务id + * @throws WxErrorException . + */ + String simpleUser(WxCpExportRequest params) throws WxErrorException; + + /** + *
+   *
+   * 导出成员详情
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/export/user?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/94851
+   * 
+ * + * @param params 导出参数 + * @return jobId 异步任务id + * @throws WxErrorException . + */ + String user(WxCpExportRequest params) throws WxErrorException; + + /** + *
+   *
+   * 导出部门
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/export/department?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/94852
+   * 
+ * + * @param params 导出参数 + * @return jobId 异步任务id + * @throws WxErrorException . + */ + String department(WxCpExportRequest params) throws WxErrorException; + + /** + *
+   *
+   * 导出标签成员
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/export/taguser?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/94853
+   * 
+ * + * @param params 导出参数 + * @return jobId 异步任务id + * @throws WxErrorException . + */ + String tagUser(WxCpExportRequest params) throws WxErrorException; + + /** + *
+   *
+   * 获取导出结果
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址: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
+   * 
+ * + * @param jobId 异步任务id + * @return 导出结果 result + * @throws WxErrorException . + */ + WxCpExportResult getResult(String jobId) throws WxErrorException; +} 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 2a6ffe218a..09d23db830 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 @@ -1,29 +1,17 @@ package me.chanjar.weixin.cp.api; -import lombok.NonNull; +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; -import me.chanjar.weixin.cp.bean.external.WxCpContactWayInfo; -import me.chanjar.weixin.cp.bean.external.WxCpContactWayResult; -import me.chanjar.weixin.cp.bean.external.WxCpMsgTemplate; -import me.chanjar.weixin.cp.bean.external.WxCpMsgTemplateAddResult; -import me.chanjar.weixin.cp.bean.external.WxCpUpdateRemarkRequest; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatInfo; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatList; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatStatistic; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatTransferResp; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalTagGroupInfo; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalTagGroupList; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalUnassignList; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalUserBehaviorStatistic; -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferCustomerReq; -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferCustomerResp; -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferResultResp; -import me.chanjar.weixin.cp.bean.external.WxCpWelcomeMsg; -import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo; -import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; -import org.jetbrains.annotations.NotNull; +import me.chanjar.weixin.cp.bean.external.*; +import me.chanjar.weixin.cp.bean.external.acquisition.*; +import me.chanjar.weixin.cp.bean.external.contact.*; +import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule; +import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.Date; import java.util.List; @@ -55,7 +43,7 @@ public interface WxCpExternalContactService { * @return wx cp contact way result * @throws WxErrorException the wx error exception */ - WxCpContactWayResult addContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException; + WxCpContactWayResult addContactWay(WxCpContactWayInfo info) throws WxErrorException; /** * 获取企业已配置的「联系我」方式 @@ -68,7 +56,7 @@ public interface WxCpExternalContactService { * @return contact way * @throws WxErrorException the wx error exception */ - WxCpContactWayInfo getContactWay(@NonNull String configId) throws WxErrorException; + WxCpContactWayInfo getContactWay(String configId) throws WxErrorException; /** * 更新企业已配置的「联系我」方式 @@ -81,7 +69,7 @@ public interface WxCpExternalContactService { * @return wx cp base resp * @throws WxErrorException the wx error exception */ - WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException; + WxCpBaseResp updateContactWay(WxCpContactWayInfo info) throws WxErrorException; /** * 删除企业已配置的「联系我」方式 @@ -94,7 +82,7 @@ public interface WxCpExternalContactService { * @return wx cp base resp * @throws WxErrorException the wx error exception */ - WxCpBaseResp deleteContactWay(@NonNull String configId) throws WxErrorException; + WxCpBaseResp deleteContactWay(String configId) throws WxErrorException; /** * 结束临时会话 @@ -110,7 +98,7 @@ public interface WxCpExternalContactService { * @return wx cp base resp * @throws WxErrorException the wx error exception */ - WxCpBaseResp closeTempChat(@NonNull String userId, @NonNull String externalUserId) throws WxErrorException; + WxCpBaseResp closeTempChat(String userId, String externalUserId) throws WxErrorException; /** @@ -122,13 +110,13 @@ public interface WxCpExternalContactService { * 第三方应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。 *
* - * @param userId 外部联系人的userid + * @param externalUserId 外部联系人的userid * @return . external contact * @throws WxErrorException the wx error exception - * @deprecated 建议使用 {@link #getContactDetail(String)} + * @deprecated 建议使用 {@link #getContactDetail(String, String)} */ @Deprecated - WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException; + WxCpExternalContactInfo getExternalContact(String externalUserId) throws WxErrorException; /** * 获取客户详情. @@ -145,17 +133,18 @@ public interface WxCpExternalContactService { * 第三方/自建应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。 * * - * @param userId 外部联系人的userid,注意不是企业成员的帐号 + * @param externalUserId 外部联系人的userid,注意不是企业成员的帐号 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 * @return . contact detail * @throws WxErrorException . */ - WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException; + WxCpExternalContactInfo getContactDetail(String externalUserId, String cursor) throws WxErrorException; /** * 企业和服务商可通过此接口,将微信外部联系人的userid转为微信openid,用于调用支付相关接口。暂不支持企业微信外部联系人(ExternalUserid为wo开头)的userid转openid。 * * @param externalUserid 微信外部联系人的userid - * @return 该企业的外部联系人openid + * @return 该企业的外部联系人openid string * @throws WxErrorException . */ String convertToOpenid(String externalUserid) throws WxErrorException; @@ -178,10 +167,192 @@ public interface WxCpExternalContactService { * * * @param unionid 微信客户的unionid - * @return 该企业的外部联系人ID + * @param openid the openid + * @return 该企业的外部联系人ID string * @throws WxErrorException . */ - String unionidToExternalUserid(String unionid) throws WxErrorException; + String unionidToExternalUserid(String unionid, String openid) throws WxErrorException; + + /** + * 配置客户群进群方式 + * 企业可以在管理后台-客户联系中配置「加入群聊」的二维码或者小程序按钮,客户通过扫描二维码或点击小程序上的按钮,即可加入特定的客户群。 + * 企业可通过此接口为具有客户联系功能的成员生成专属的二维码或者小程序按钮。 + * 如果配置的是小程序按钮,需要开发者的小程序接入小程序插件。 + * 注意: + * 通过API添加的配置不会在管理端进行展示,每个企业可通过API最多配置50万个「加入群聊」(与「联系我」共用50万的额度)。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 + * + * @param wxCpGroupJoinWayInfo the wx cp group join way info + * @return {@link WxCpGroupJoinWayResult} + * @throws WxErrorException the wx error exception + */ + WxCpGroupJoinWayResult addJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException; + + /** + * 更新客户群进群方式配置 + * 更新进群方式配置信息。注意:使用覆盖的方式更新。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 + * + * @param wxCpGroupJoinWayInfo the wx cp group join way info + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp updateJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException; + + /** + * 获取客户群进群方式配置 + * 获取企业配置的群二维码或小程序按钮。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 + * + * @param configId the config id + * @return join way + * @throws WxErrorException the wx error exception + */ + WxCpGroupJoinWayInfo getJoinWay(String configId) throws WxErrorException; + + /** + * 删除客户群进群方式配置 + * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 + * + * @param configId the config id + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp delJoinWay(String configId) throws WxErrorException; + + /** + * 代开发应用external_userid转换 + *
+   *
+   * 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/95195
+   *
+   * 企业同时安装服务商第三方应用以及授权代开发自建应用的时,服务商可使用该接口将代开发应用获取到的外部联系人id跟第三方应用的id进行关联,
+   * 该接口可将代开发自建应用获取到的external_userid转换为服务商第三方应用的external_userid。
+   *
+   * 权限说明:
+   *
+   * 该企业授权了该服务商第三方应用,且授权的第三方应用具备“企业客户权限->客户基础信息”权限
+   * 该客户的跟进人必须在应用的可见范围之内
+   * 应用需具备“企业客户权限->客户基础信息”权限
+   * 
+ * + * @param externalUserid 代开发自建应用获取到的外部联系人ID + * @return 该服务商第三方应用下的企业的外部联系人ID string + * @throws WxErrorException . + */ + String toServiceExternalUserid(String externalUserid) throws WxErrorException; + + /** + * 将代开发应用或第三方应用获取的externaluserid转换成自建应用的externaluserid + *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/95884#external-userid%E8%BD%AC%E6%8D%A2
+   *
+   * 权限说明:
+   *
+   * 需要使用自建应用或基础应用的access_token
+   * 客户的跟进人,或者用户所在客户群的群主,需要同时在access_token和source_agentid所对应应用的可见范围内
+   * 
+ * + * @param externalUserid 服务商主体的external_userid,必须是source_agentid对应的应用所获取 + * @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid + * @return + * @throws WxErrorException + */ + String fromServiceExternalUserid(String externalUserid, String sourceAgentId) throws WxErrorException; + + /** + * 企业客户微信unionid的升级 - unionid查询external_userid + *
+   *
+   * 文档地址:https://open.work.weixin.qq.com/api/doc/35863#4.2%20unionid%E6%9F%A5%E8%AF%A2external_userid
+   *
+   * 当微信用户在微信中使用第三方应用的小程序或公众号时,第三方可将获取到的unionid与openid,调用此接口转换为企业客户external_userid。
+   * 该接口调用频次有限,每个服务商每小时仅可调用1万次,仅用于微信用户主动使用第三方应用的场景来调用,服务商切不可滥用。
+   * 同时建议服务商的小程序路径或公众号页面链接带上corpid参数,如此可明确地转换出该企业对应的external_userid,以获得更好的性能。
+   *
+   * 权限说明:
+   *
+   * 该企业授权了该服务商第三方应用
+   * 调用频率最大为10000次/小时
+   * unionid和openid的主体需与服务商的主体一致
+   * openid与unionid必须是在同一个小程序或同一个公众号获取到的
+   * 
+ * + * @param unionid 微信客户的unionid + * @param openid 微信客户的openid + * @param corpid 需要换取的企业corpid,不填则拉取所有企业 + * @return 该服务商第三方应用下的企业的外部联系人ID wx cp external user id list + * @throws WxErrorException . + */ + WxCpExternalUserIdList unionidToExternalUserid3rd(String unionid, String openid, String corpid) throws WxErrorException; + + /** + * 转换external_userid + *
+   *
+   * 文档地址:https://open.work.weixin.qq.com/api/doc/35863#转换external_userid
+   *
+   * 对于历史已授权的企业,在2022年3月1号之前,所有接口与回调返回的external_userid仍然为旧的external_userid,
+   * 从2022年3月1号0点开始,所有输入与返回的external_userid字段,将启用升级后的external_userid。
+   * 所以服务商需要在此之前完成历史数据的迁移整改
+   *
+   * 权限说明:
+   *
+   * 该企业授权了该服务商第三方应用
+   * external_userid对应的跟进人需要在应用可见范围内
+   * 
+ * + * @param externalUserIdList 微信客户的unionid + * @return List 新外部联系人id + * @throws WxErrorException . + */ + WxCpNewExternalUserIdList getNewExternalUserId(String[] externalUserIdList) throws WxErrorException; + + /** + * 设置迁移完成 + *
+   *
+   * 文档地址:https://open.work.weixin.qq.com/api/doc/35863#转换external_userid
+   *
+   * 企业授权确认之后,且服务商完成了新旧external_userid的迁移,即可主动将该企业设置为“迁移完成”,
+   * 设置之后,从该企业获取到的将是新的external_userid。注意,该接口需要使用provider_access_token来调用,
+   * 对于有多个应用的服务商,可逐个应用进行external_userid的转换,最后再使用provider_access_token调用该接口完成设置。
+   *
+   * 权限说明:
+   *
+   * 该企业授权了该服务商第三方应用
+   * 
+ * + * @param corpid 企业corpid + * @return wx cp base resp + * @throws WxErrorException . + */ + WxCpBaseResp finishExternalUserIdMigration(String corpid) throws WxErrorException; + + /** + * 客户群opengid转换 + *
+   *
+   * 文档地址:https://open.work.weixin.qq.com/api/doc/90000/90135/94822
+   *
+   * 用户在微信里的客户群里打开小程序时,某些场景下可以获取到群的opengid,如果该群是企业微信的客户群,
+   * 则企业或第三方可以调用此接口将一个opengid转换为客户群chat_id
+   *
+   * 权限说明:
+   *
+   * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)
+   * 第三方应用需具有“企业客户权限->客户基础信息”权限
+   * 对于第三方/自建应用,群主必须在应用的可见范围
+   * 仅支持企业服务人员创建的客户群
+   * 仅可转换出自己企业下的客户群chat_id
+   * 
+ * + * @param opengid 小程序在微信获取到的群ID,参见wx.getGroupEnterInfo(https://developers.weixin.qq + * .com/miniprogram/dev/api/open-api/group/wx.getGroupEnterInfo.html) + * @return 客户群ID ,可以用来调用获取客户群详情 + * @throws WxErrorException . + */ + String opengidToChatid(String opengid) throws WxErrorException; /** * 批量获取客户详情. @@ -257,14 +428,19 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c List listFollowers() throws WxErrorException; /** - * 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用离职成员的外部联系人再分配接口将这些客户重新分配给其他企业成员。 + * 获取待分配的离职成员列表 + * 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用分配离职成员的客户接口将这些客户重新分配给其他企业成员。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_unassigned_list?access_token=ACCESS_TOKEN * - * @param page the page - * @param pageSize the page size + * @param pageId 分页查询,要查询页号,从0开始 + * @param cursor 分页查询游标,字符串类型,适用于数据量较大的情况,如果使用该参数则无需填写page_id,该参数由上一次调用返回 + * @param pageSize 每次返回的最大记录数,默认为1000,最大值为1000 * @return wx cp user external unassign list * @throws WxErrorException the wx error exception */ - WxCpUserExternalUnassignList listUnassignedList(Integer page, Integer pageSize) throws WxErrorException; + WxCpUserExternalUnassignList listUnassignedList(Integer pageId, String cursor, Integer pageSize) throws WxErrorException; /** * 企业可通过此接口,将已离职成员的外部联系人分配给另一个成员接替联系。 @@ -312,10 +488,11 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c * @param handOverUserid 原添加成员的userid * @param takeOverUserid 接替成员的userid * @param cursor 分页查询的cursor,每个分页返回的数据不会超过1000条;不填或为空表示获取第一个分页; - * @return 客户转接接口实体 + * @return 客户转接接口实体 wx cp user transfer result resp * @throws WxErrorException the wx error exception */ - WxCpUserTransferResultResp transferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException; + WxCpUserTransferResultResp transferResult(String handOverUserid, String takeOverUserid, + String cursor) throws WxErrorException; /** * 企业可通过此接口,分配离职成员的客户给其他成员。 @@ -352,10 +529,11 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c * @param handOverUserid 原添加成员的userid * @param takeOverUserid 接替成员的userid * @param cursor 分页查询的cursor,每个分页返回的数据不会超过1000条;不填或为空表示获取第一个分页; - * @return 客户转接接口实体 + * @return 客户转接接口实体 wx cp user transfer result resp * @throws WxErrorException the wx error exception */ - WxCpUserTransferResultResp resignedTransferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException; + WxCpUserTransferResultResp resignedTransferResult(String handOverUserid, String takeOverUserid, + String cursor) throws WxErrorException; /** *

@@ -375,7 +553,8 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
    * @deprecated 请使用 {@link WxCpExternalContactService#listGroupChat(Integer, String, int, String[])}
    */
   @Deprecated
-  WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds, String[] partyIds) throws WxErrorException;
+  WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds,
+                                              String[] partyIds) throws WxErrorException;
 
   /**
    * 
@@ -402,7 +581,8 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
    * 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92122
    * 
* - * @param chatId the chat id + * @param chatId the chat id + * @param needName the need name * @return group chat * @throws WxErrorException the wx error exception */ @@ -429,11 +609,30 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c * * @param chatIds 需要转群主的客户群ID列表。取值范围: 1 ~ 100 * @param newOwner 新群主ID - * @return 分配结果,主要是分配失败的群列表 + * @return 分配结果 ,主要是分配失败的群列表 * @throws WxErrorException the wx error exception */ WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds, String newOwner) throws WxErrorException; + + /** + * 企业可通过此接口,将在职成员为群主的群,分配给另一个客服成员。 + * + * 注意: + * 继承给的新群主,必须是配置了客户联系功能的成员 + * 继承给的新群主,必须有设置实名 + * 继承给的新群主,必须有激活企业微信 + * 同一个人的群,限制每天最多分配300个给新群主 + * 为保障客户服务体验,90个自然日内,在职成员的每个客户群仅可被转接2次。 + *
+ * + * @param chatIds 需要转群主的客户群ID列表。取值范围: 1 ~ 100 + * @param newOwner 新群主ID + * @return 分配结果 ,主要是分配失败的群列表 + * @throws WxErrorException the wx error exception + */ + WxCpUserExternalGroupChatTransferResp onjobTransferGroupChat(String[] chatIds, String newOwner) throws WxErrorException; + /** *
    * 企业可通过此接口获取成员联系客户的数据,包括发起申请数、新增客户数、聊天数、发送消息数和删除/拉黑成员的客户数等指标。
@@ -449,7 +648,8 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
    * @return user behavior statistic
    * @throws WxErrorException the wx error exception
    */
-  WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime, String[] userIds, String[] partyIds) throws WxErrorException;
+  WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime, String[] userIds,
+                                                                 String[] partyIds) throws WxErrorException;
 
   /**
    * 
@@ -468,7 +668,9 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
    * @return group chat statistic
    * @throws WxErrorException the wx error exception
    */
-  WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc, Integer pageIndex, Integer pageSize, String[] userIds, String[] partyIds) throws WxErrorException;
+  WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc,
+                                                           Integer pageIndex, Integer pageSize, String[] userIds,
+                                                           String[] partyIds) throws WxErrorException;
 
   /**
    * 添加企业群发消息任务
@@ -480,7 +682,7 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
    * 

* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=ACCESS_TOKEN *

- * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92135 + * 文档地址 * * @param wxCpMsgTemplate the wx cp msg template * @return the wx cp msg template add result @@ -488,6 +690,39 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c */ WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) throws WxErrorException; + + /** + * 提醒成员群发 + * 企业和第三方应用可调用此接口,重新触发群发通知,提醒成员完成群发任务,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 + */ + WxCpBaseResp remindGroupMsgSend(String msgId) throws WxErrorException; + + + /** + * 停止企业群发 + * 企业和第三方应用可调用此接口,停止无需成员继续发送的企业群发 + *

+ * 请求方式: 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 + */ + WxCpBaseResp cancelGroupMsgSend(String msgId) throws WxErrorException; + + /** * 发送新客户欢迎语 *

@@ -499,7 +734,7 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
    *
    * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/send_welcome_msg?access_token=ACCESS_TOKEN
    *
-   * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92137
+   * 文档地址
    * 
* * @param msg . @@ -574,7 +809,7 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c /** *
    * 企业可通过此接口为指定成员的客户添加上由企业统一配置的标签。
-   * https://work.weixin.qq.com/api/doc/90000/90135/92117
+   * 文档地址
    * 
* * @param userid the userid @@ -586,5 +821,474 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c */ WxCpBaseResp markTag(String userid, String externalUserid, String[] addTag, String[] removeTag) throws WxErrorException; + /** + *
+   *   企业和第三方应用可通过该接口创建客户朋友圈的发表任务。
+   *   文档地址
+   * 
+ * + * @param task the task + * @return wx cp add moment result + * @throws WxErrorException the wx error exception + */ + WxCpAddMomentResult addMomentTask(WxCpAddMomentTask task) throws WxErrorException; + + /** + *
+   * 由于发表任务的创建是异步执行的,应用需要再调用该接口以获取创建的结果。
+   * 文档地址
+   * 
+ * + * @param jobId 异步任务id,最大长度为64字节,由创建发表内容到客户朋友圈任务接口获取 + * @return moment task result + * @throws WxErrorException the wx error exception + */ + WxCpGetMomentTaskResult getMomentTaskResult(String jobId) throws WxErrorException; + + /** + *
+   * 获取客户朋友圈全部的发表记录 获取企业全部的发表列表
+   * 文档地址
+   * 
+ * + * @param startTime 朋友圈记录开始时间。Unix时间戳 + * @param endTime 朋友圈记录结束时间。Unix时间戳 + * @param creator 朋友圈创建人的userid + * @param filterType 朋友圈类型。0:企业发表 1:个人发表 2:所有,包括个人创建以及企业创建,默认情况下为所有类型 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @param limit 返回的最大记录数,整型,最大值100,默认值100,超过最大值时取默认值 + * @return moment list + * @throws WxErrorException the wx error exception + */ + WxCpGetMomentList getMomentList(Long startTime, Long endTime, String creator, Integer filterType, + String cursor, Integer limit) throws WxErrorException; + + /** + *
+   * 获取客户朋友圈全部的发表记录 获取客户朋友圈企业发表的列表
+   * 文档地址
+   * 
+ * + * @param momentId 朋友圈id,仅支持企业发表的朋友圈id + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值 + * @return moment task + * @throws WxErrorException the wx error exception + */ + WxCpGetMomentTask getMomentTask(String momentId, String cursor, Integer limit) + throws WxErrorException; + + /** + *
+   * 获取客户朋友圈全部的发表记录 获取客户朋友圈发表时选择的可见范围
+   * 文档地址
+   * 
+ * + * @param momentId 朋友圈id + * @param userId 企业发表成员userid,如果是企业创建的朋友圈,可以通过获取客户朋友圈企业发表的 + * 列表获取已发表成员userid,如果是个人创建的朋友圈,创建人userid就是企业发表成员userid + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值 + * @return moment customer list + * @throws WxErrorException the wx error exception + */ + WxCpGetMomentCustomerList getMomentCustomerList(String momentId, String userId, + String cursor, Integer limit) throws WxErrorException; + + /** + *
+   * 获取客户朋友圈全部的发表记录 获取客户朋友圈发表后的可见客户列表
+   * 文档地址
+   * 
+ * + * @param momentId 朋友圈id + * @param userId 企业发表成员userid,如果是企业创建的朋友圈,可以通过获取客户朋友圈企业发表的列表获取已发表成员userid, + * 如果是个人创建的朋友圈,创建人userid就是企业发表成员userid + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @param limit 返回的最大记录数,整型,最大值5000,默认值3000,超过最大值时取默认值 + * @return moment send result + * @throws WxErrorException the wx error exception + */ + WxCpGetMomentSendResult getMomentSendResult(String momentId, String userId, + String cursor, Integer limit) throws WxErrorException; + + /** + *
+   * 获取客户朋友圈全部的发表记录 获取客户朋友圈的互动数据
+   * 文档地址
+   * 
+ * + * @param momentId 朋友圈id + * @param userId 企业发表成员userid,如果是企业创建的朋友圈,可以通过获取客户朋友圈企业发表的列表获取已发表成员userid, + * 如果是个人创建的朋友圈,创建人userid就是企业发表成员userid + * @return moment comments + * @throws WxErrorException the wx error exception + */ + WxCpGetMomentComments getMomentComments(String momentId, String userId) + throws WxErrorException; + /** + *
+   * 企业和第三方应用可通过此接口获取企业与成员的群发记录。
+   * 文档地址
+   * 
+ * + * @param chatType 群发任务的类型,默认为single,表示发送给客户,group表示发送给客户群 + * @param startTime 群发任务记录开始时间 + * @param endTime 群发任务记录结束时间 + * @param creator 群发任务创建人企业账号id + * @param filterType 创建人类型。0:企业发表 1:个人发表 2:所有,包括个人创建以及企业创建,默认情况下为所有类型 + * @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date endTime, + String creator, Integer filterType, Integer limit, String cursor) throws WxErrorException; + + /** + *
+   * 企业和第三方应用可通过此接口获取企业与成员的群发记录。
+   * 获取企业群发成员执行结果
+   * 
+ * + * @param msgid 群发消息的id,通过获取群发记录列表接口返回 + * @param userid 发送成员userid,通过获取群发成员发送任务列表接口返回 + * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpGroupMsgSendResult getGroupMsgSendResult(String msgid, String userid, Integer limit, String cursor) throws WxErrorException; + + /** + *
+   * 企业跟第三方应用可通过该接口获取到创建企业群发的群发发送结果。
+   * 文档
+   * 
+ * + * @param msgid 群发消息的id,通过创建企业群发接口返回 + * @param limit 返回的最大记录数,整型,最大值10000,默认值10000 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpGroupMsgResult getGroupMsgResult(String msgid, Integer limit, String cursor) throws WxErrorException; + + /** + *
+   * 获取群发成员发送任务列表。
+   * 获取群发成员发送任务列表
+   * 
+ * + * @param msgid 群发消息的id,通过获取群发记录列表接口返回 + * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpGroupMsgTaskResult getGroupMsgTask(String msgid, Integer limit, String cursor) throws WxErrorException; + + /** + *
+   * 添加入群欢迎语素材。
+   * 添加入群欢迎语素材
+   * 
+ * + * @param template 素材内容 + * @return template_id 欢迎语素材id + * @throws WxErrorException the wx error exception + */ + String addGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException; + + /** + *
+   * 编辑入群欢迎语素材。
+   * 编辑入群欢迎语素材
+   * 
+ * + * @param template the template + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp editGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException; + + /** + *
+   * 获取入群欢迎语素材。
+   * 获取入群欢迎语素材
+   * 
+ * + * @param templateId 群欢迎语的素材id + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpGroupWelcomeTemplateResult getGroupWelcomeTemplate(String templateId) throws WxErrorException; + + /** + *
+   * 删除入群欢迎语素材。
+   * 企业可通过此API删除入群欢迎语素材,且仅能删除调用方自己创建的入群欢迎语素材。
+   * 删除入群欢迎语素材
+   * 
+ * + * @param templateId 群欢迎语的素材id + * @param agentId the agent id + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp delGroupWelcomeTemplate(String templateId, String agentId) throws WxErrorException; + + /** + *
+   * 获取商品图册
+   * 获取商品图册列表
+   * 
+ * + * @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpProductAlbumListResult getProductAlbumList(Integer limit, String cursor) throws WxErrorException; + + /** + *
+   * 获取商品图册
+   * 获取商品图册
+   * 
+ * + * @param productId 商品id + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpProductAlbumResult getProductAlbum(String productId) throws WxErrorException; + + /** + *
+   * 上传附件资源
+   * ...
+   * 
+ * + * @param mediaType the media type + * @param fileType the file type + * @param attachmentType the attachment type + * @param inputStream the input stream + * @return wx media upload result + * @throws WxErrorException the wx error exception + * @throws IOException the io exception + */ + WxMediaUploadResult uploadAttachment(String mediaType, String fileType, Integer attachmentType, + InputStream inputStream) throws WxErrorException, IOException; + + /** + *
+   * 上传附件资源
+   * ...
+   * 
+ * + * @param mediaType the media type + * @param attachmentType the attachment type + * @param file the file + * @return wx media upload result + * @throws WxErrorException the wx error exception + */ + WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, File file) + throws WxErrorException; + + /** + *
+   * 新建敏感词规则
+   * 企业和第三方应用可以通过此接口新建敏感词规则
+   * 请求方式: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
+   */
+  String addInterceptRule(WxCpInterceptRuleAddRequest ruleAddRequest) throws WxErrorException;
+
+  /**
+   * 
+   * 修改敏感词规则
+   * 文档地址
+   * 企业和第三方应用可以通过此接口修改敏感词规则
+   * 请求方式: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
+   */
+  void updateInterceptRule(WxCpInterceptRule interceptRule) throws WxErrorException;
+
+  /**
+   * 
+   * 删除敏感词规则
+   * 企业和第三方应用可以通过此接口修改敏感词规则
+   * 请求方式:POST(HTTPS)
+   * 请求地址
+   * 
+   * @param ruleId 规则id
+   * @throws WxErrorException the wx error exception
+   */
+  void delInterceptRule(String ruleId) throws WxErrorException;
+
+  /**
+   * 
+   * 创建商品图册
+   * 企业和第三方应用可以通过此接口增加商品
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * 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
+   */
+  String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException;
+
+  /**
+   * 
+   * 编辑商品图册
+   * 企业和第三方应用可以通过此接口修改商品信息
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_product_album?access_token=ACCESS_TOKEN
+   * 文档地址
+   * 
+   * @param wxCpProductAlbumInfo 商品图册信息
+   * @throws WxErrorException the wx error exception
+   */
+  void updateProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException;
+
+  /**
+   * 
+   * 删除商品图册
+   * 企业和第三方应用可以通过此接口删除商品信息
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://qyapi.weixin.qq.com/cgi-bin/externalcontact/delete_product_album?access_token=ACCESS_TOKEN
+   *
+   * 文档地址
+   * 
+   * @param productId 商品id
+   * @throws WxErrorException the wx error exception
+   */
+  void deleteProductAlbum(String productId) throws WxErrorException;
+
+  /**
+   * 
+   * 获取获客链接列表
+   * 企业可通过此接口获取当前仍然有效的获客链接。
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * 接口地址
+   *
+   * 文档地址
+   * 
+ * @param limit 商品id + * @param cursor 商品id + * @return 获客链接列表 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionList customerAcquisitionLinkList(Integer limit, String cursor) throws WxErrorException; + + /** + *
+   * 获取获客链接详情
+   * 企业可通过此接口根据获客链接id获取链接配置详情。。
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * 接口地址
+   *
+   * 文档地址
+   * 
+ * @param linkId 获客链接ID + * @return 获客链接详情 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionInfo customerAcquisitionLinkGet(String linkId) throws WxErrorException; + + /** + *
+   * 创建获客链接
+   * 企业可通过此接口创建新的获客链接。
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * 接口地址
+   * 文档地址
+   * 
+ * + * @param wxCpCustomerAcquisitionRequest 创建链接请求 + * @return 创建链接详情 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionCreateResult customerAcquisitionLinkCreate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException; + + /** + *
+   * 编辑获客链接
+   * 企业可通过此接口编辑获客链接,修改获客链接的关联范围或修改获客链接的名称。
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * 接口地址
+   * 文档地址
+   * 
+ * + * @param wxCpCustomerAcquisitionRequest 编辑链接请求 + * @return 编辑链接详情 + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp customerAcquisitionUpdate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException; + + /** + *
+   * 删除获客链接
+   * 企业可通过此接口删除获客链接,删除后的获客链接将无法继续使用。
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * 接口地址
+   * 文档地址
+   * 
+ * + * @param linkId 获客链接的id + * @return 删除结果 + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp customerAcquisitionLinkDelete(String linkId) throws WxErrorException; + + /** + *
+   * 获取获客客户列表
+   * 企业可通过此接口获取到由指定的获客链接添加的客户列表。
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * 接口地址
+   * 文档地址
+   * 
+ * + * @param linkId 获客链接id + * @param limit 返回的最大记录数,整型,最大值1000 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @return 由获客链接添加的客户信息列表 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionCustomerList customerAcquisitionCustomer(String linkId, Integer limit, String cursor) throws WxErrorException; + + /** + *
+   * 查询剩余使用量
+   * 企业可通过此接口查询当前剩余的使用量。
+   * 请求方式:GET(HTTPS)
+   * 请求地址:
+   * 接口地址
+   * 文档地址
+   * 
+ * + * @return 剩余使用量 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorException; } 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 b5a9579e0d..bc6e130548 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 @@ -2,6 +2,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.article.NewArticle; +import me.chanjar.weixin.cp.bean.message.WxCpGroupRobotMessage; import java.util.List; @@ -10,8 +11,7 @@ * 文档地址:https://work.weixin.qq.com/help?doc_id=13376 * 调用地址:https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key= * - * @author yr - * @date 2020-8-20 + * @author yr created on 2020-8-20 */ public interface WxCpGroupRobotService { @@ -88,4 +88,22 @@ public interface WxCpGroupRobotService { * @throws WxErrorException 异常 */ void sendNews(String webhookUrl, List articleList) throws WxErrorException; + + /** + * 发送文件类型的消息 + * + * @param webhookUrl webhook地址 + * @param mediaId 文件id + * @throws WxErrorException 异常 + */ + void sendFile(String webhookUrl, String mediaId) throws WxErrorException; + + /** + * 发送模板卡片消息 + * @param webhookUrl + * @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/WxCpKfService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java new file mode 100644 index 0000000000..86b342f2fc --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java @@ -0,0 +1,268 @@ +package me.chanjar.weixin.cp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.kf.*; + +import java.util.List; + +/** + * 微信客服接口 + *

+ * 微信客服由腾讯微信团队为企业打造,用于满足企业的客服需求,帮助企业做好客户服务。企业可以在微信内、外各个场景中接入微信客服, + * 用户可以发起咨询,企业可以进行回复。 + * 企业可在微信客服官网使用企业微信扫码开通微信客服,开通后即可使用。 + * + * @author Fu created on 2022/1/19 19:25 + */ +public interface WxCpKfService { + + /** + * 添加客服帐号,并可设置客服名称和头像。目前一家企业最多可添加10个客服帐号 + * + * @param add 客服帐号信息 + * @return result -新创建的客服帐号ID + * @throws WxErrorException 异常 + */ + WxCpKfAccountAddResp addAccount(WxCpKfAccountAdd add) throws WxErrorException; + + /** + * 修改已有的客服帐号,可修改客服名称和头像。 + * + * @param upd 新的客服账号信息 + * @return result wx cp base resp + * @throws WxErrorException 异常 + */ + WxCpBaseResp updAccount(WxCpKfAccountUpd upd) throws WxErrorException; + + /** + * 删除已有的客服帐号 + * + * @param del 要删除的客服帐号 + * @return result wx cp base resp + * @throws WxErrorException 异常 + */ + WxCpBaseResp delAccount(WxCpKfAccountDel del) throws WxErrorException; + + /** + * 获取客服帐号列表,包括所有的客服帐号的客服ID、名称和头像。 + * + * @param offset 分页,偏移量, 默认为0 + * @param limit 分页,预期请求的数据量,默认为100,取值范围 1 ~ 100 + * @return 客服帐号列表 wx cp kf account list resp + * @throws WxErrorException 异常 + */ + WxCpKfAccountListResp listAccount(Integer offset, Integer limit) throws WxErrorException; + + /** + * 企业可通过此接口获取带有不同参数的客服链接,不同客服帐号对应不同的客服链接。获取后,企业可将链接嵌入到网页等场景中, + * 微信用户点击链接即可向对应的客服帐号发起咨询。企业可依据参数来识别用户的咨询来源等 + * + * @param link 参数 + * @return 链接 account link + * @throws WxErrorException 异常 + */ + WxCpKfAccountLinkResp getAccountLink(WxCpKfAccountLink link) throws WxErrorException; + + /** + * 接待人员管理 + * 添加指定客服帐号的接待人员,每个客服帐号目前最多可添加500个接待人员。 + * + * @param openKfid 客服帐号ID + * @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 + * @return 添加客服账号结果 wx cp kf servicer op resp + * @throws WxErrorException 异常 + */ + WxCpKfServicerOpResp addServicer(String openKfid, List userIdList) throws WxErrorException; + + /** + * 接待人员管理 + * 从客服帐号删除接待人员 + * + * @param openKfid 客服帐号ID + * @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 + * @return 删除客服账号结果 wx cp kf servicer op resp + * @throws WxErrorException 异常 + */ + WxCpKfServicerOpResp delServicer(String openKfid, List userIdList) throws WxErrorException; + + /** + * 接待人员管理 + * 获取某个客服帐号的接待人员列表 + * + * @param openKfid 客服帐号ID + * @return 接待人员列表 wx cp kf servicer list resp + * @throws WxErrorException 异常 + */ + WxCpKfServicerListResp listServicer(String openKfid) throws WxErrorException; + + /** + * 分配客服会话 + * 获取会话状态 + * + * @param openKfid 客服帐号ID + * @param externalUserId 微信客户的external_userid + * @return service state + * @throws WxErrorException the wx error exception + */ + WxCpKfServiceStateResp getServiceState(String openKfid, String externalUserId) + throws WxErrorException; + + /** + * 分配客服会话 + * 变更会话状态 + * + * @param openKfid 客服帐号ID + * @param externalUserId 微信客户的external_userid + * @param serviceState 变更的目标状态,状态定义和所允许的变更可参考概述中的流程图和表格 + * @param servicerUserId 接待人员的userid。第三方应用填密文userid,即open_userid。当state=3时要求必填,接待人员须处于“正在接待”中。 + * @return 部分状态返回回复语code wx cp kf service state trans resp + * @throws WxErrorException the wx error exception + */ + WxCpKfServiceStateTransResp transServiceState(String openKfid, String externalUserId, + Integer serviceState, String servicerUserId) throws WxErrorException; + + /** + * 读取消息 + * 微信客户发送的消息、接待人员在企业微信回复的消息、发送消息接口发送失败事件(如被用户拒收)、客户点击菜单消息的回复消息, + * 可以通过该接口获取具体的消息内容和事件。不支持读取通过发送消息接口发送的消息。 + * 支持的消息类型:文本、图片、语音、视频、文件、位置、链接、名片、小程序、菜单、事件。 + * + * @param cursor 上一次调用时返回的next_cursor,第一次拉取可以不填。不多于64字节 + * @param token 回调事件返回的token字段,10分钟内有效;可不填,如果不填接口有严格的频率限制。不多于128字节 + * @param limit 期望请求的数据量,默认值和最大值都为1000。 注意:可能会出现返回条数少于limit的情况,需结合返回的has_more字段判断是否继续请求。 + * @param voiceFormat 语音消息类型,0-Amr 1-Silk,默认0。可通过该参数控制返回的语音格式 + * @return 微信消息 wx cp kf msg list resp + * @throws WxErrorException 异常 + */ + @Deprecated + WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat) + throws WxErrorException; + + WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat,String open_kfid) + throws WxErrorException; + + /** + * 发送消息 + * 当微信客户处于“新接入待处理”或“由智能助手接待”状态下,可调用该接口给用户发送消息。 + * 注意仅当微信客户在主动发送消息给客服后的48小时内,企业可发送消息给客户,最多可发送5条消息;若用户继续发送消息,企业可再次下发消息。 + * 支持发送消息类型:文本、图片、语音、视频、文件、图文、小程序、菜单消息、地理位置。 + * + * @param request 发送信息 + * @return 发送结果 wx cp kf msg send resp + * @throws WxErrorException 异常 + */ + WxCpKfMsgSendResp sendMsg(WxCpKfMsgSendRequest request) throws WxErrorException; + + /** + * 发送欢迎语等事件响应消息 + * 当特定的事件回调消息包含code字段,或通过接口变更到特定的会话状态,会返回code字段。 + * 开发者可以此code为凭证,调用该接口给用户发送相应事件场景下的消息,如客服欢迎语、客服提示语和会话结束语等。 + * 除"用户进入会话事件"以外,响应消息仅支持会话处于获取该code的会话状态时发送,如将会话转入待接入池时获得的code仅能在会话状态为”待接入池排队中“时发送。 + *

+ * 目前支持的事件场景和相关约束如下: + *

+ * 事件场景 允许下发条数 code有效期 支持的消息类型 获取code途径 + * 用户进入会话,用于发送客服欢迎语 1条 20秒 文本、菜单 事件回调 + * 进入接待池,用于发送排队提示语等 1条 48小时 文本 转接会话接口 + * 从接待池接入会话,用于发送非工作 + * 时间的提示语或超时未回复的提示语 + * 等 1条 48小时 文本 事件回调、转接会话接口 + * 结束会话,用于发送结束会话提示语 + * 或满意度评价等 1条 20秒 文本、菜单 事件回调、转接会话接口 + * + * @param request the request + * @return wx cp kf msg send resp + * @throws WxErrorException the wx error exception + */ + WxCpKfMsgSendResp sendMsgOnEvent(WxCpKfMsgSendRequest request) throws WxErrorException; + + /** + * 获取客户基础信息 + * + * @param externalUserIdList the external user id list + * @return wx cp kf customer batch get resp + * @throws WxErrorException the wx error exception + */ + WxCpKfCustomerBatchGetResp customerBatchGet(List externalUserIdList) + throws WxErrorException; + + /** + *

+   * 获取「客户数据统计」企业汇总数据
+   * 通过此接口,可以获取咨询会话数、咨询客户数等企业汇总统计数据
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://qyapi.weixin.qq.com/cgi-bin/kf/get_corp_statistic?access_token=ACCESS_TOKEN
+   * 文档地址:
+   * https://developer.work.weixin.qq.com/document/path/95489
+   * 
+   * @param request 查询参数
+   * @return 客户数据统计 -企业汇总数据
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpKfGetCorpStatisticResp getCorpStatistic(WxCpKfGetCorpStatisticRequest request) throws WxErrorException;
+
+  /**
+   * 
+   * 获取「客户数据统计」接待人员明细数据
+   * 通过此接口,可获取接入人工会话数、咨询会话数等与接待人员相关的统计信息
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://qyapi.weixin.qq.com/cgi-bin/kf/get_servicer_statistic?access_token=ACCESS_TOKEN
+   * 文档地址:
+   * https://developer.work.weixin.qq.com/document/path/95490
+   * 
+   * @param request 查询参数
+   * @return 客户数据统计 -企业汇总数据
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpKfGetServicerStatisticResp getServicerStatistic(WxCpKfGetServicerStatisticRequest request) throws WxErrorException;
+
+  // 「升级服务」配置
+
+  /**
+   * 获取配置的专员与客户群
+   *
+   * @return upgrade service config
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpKfServiceUpgradeConfigResp getUpgradeServiceConfig() throws WxErrorException;
+
+  /**
+   * 升级专员服务
+   *
+   * @param openKfid       客服帐号ID
+   * @param externalUserId 微信客户的external_userid
+   * @param userid         服务专员的userid
+   * @param wording        推荐语
+   * @return wx cp base resp
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpBaseResp upgradeMemberService(String openKfid, String externalUserId,
+                                    String userid, String wording) throws WxErrorException;
+
+  /**
+   * 升级客户群服务
+   *
+   * @param openKfid       客服帐号ID
+   * @param externalUserId 微信客户的external_userid
+   * @param chatId         客户群id
+   * @param wording        推荐语
+   * @return wx cp base resp
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpBaseResp upgradeGroupchatService(String openKfid, String externalUserId,
+                                       String chatId, String wording) throws WxErrorException;
+
+  /**
+   * 为客户取消推荐
+   *
+   * @param openKfid       客服帐号ID
+   * @param externalUserId 微信客户的external_userid
+   * @return wx cp base resp
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpBaseResp cancelUpgradeService(String openKfid, String externalUserId)
+    throws WxErrorException;
+}
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
new file mode 100644
index 0000000000..a2e2344190
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java
@@ -0,0 +1,124 @@
+package me.chanjar.weixin.cp.api;
+
+import lombok.NonNull;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.bean.living.*;
+
+/**
+ * 企业微信直播接口.
+ * 官方文档:https://work.weixin.qq.com/api/doc/90000/90135/93633
+ *
+ * @author Wang_Wong  created on  2021-12-21
+ */
+public interface WxCpLivingService {
+
+  /**
+   * 获取微信观看直播凭证
+   * 请求方式: POST(HTTPS)
+   * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/get_living_code?access_token=ACCESS_TOKEN
+   *
+   * @param openId   用户openid
+   * @param livingId 直播id
+   * @return living_code 微信观看直播凭证
+   * @throws WxErrorException the wx error exception
+   */
+  String getLivingCode(@NonNull String openId, @NonNull String livingId) throws WxErrorException;
+
+  /**
+   * 获取直播详情
+   * 请求方式:GET(HTTPS)
+   * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_living_info?access_token=ACCESS_TOKEN&livingid=LIVINGID
+   *
+   * @param livingId 直播id
+   * @return 获取的直播详情 living info
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpLivingInfo getLivingInfo(@NonNull String livingId) throws WxErrorException;
+
+  /**
+   * 获取直播观看明细
+   * 通过该接口可以获取所有观看直播的人员统计
+   * 

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_watch_stat?access_token=ACCESS_TOKEN + * + * @param livingId 直播id + * @param nextKey 上一次调用时返回的next_key,初次调用可以填”0” + * @return watch stat + * @throws WxErrorException the wx error exception + */ + WxCpWatchStat getWatchStat(@NonNull String livingId, String nextKey) throws WxErrorException; + + /** + * 获取成员直播ID列表 + * 通过此接口可以获取指定成员的所有直播ID + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_user_all_livingid?access_token=ACCESS_TOKEN + * + * @param userId 企业成员的userid + * @param cursor 上一次调用时返回的next_cursor,第一次拉取可以不填 + * @param limit 每次拉取的数据量,默认值和最大值都为100 + * @return user all living id + * @throws WxErrorException the wx error exception + */ + WxCpLivingResult.LivingIdResult getUserAllLivingId(@NonNull String userId, String cursor, Integer limit) throws WxErrorException; + + /** + * 获取跳转小程序商城的直播观众信息 + * 通过此接口,开发者可获取跳转小程序商城的直播间(“推广产品”直播)观众id、邀请人id及对应直播间id,以打通卖货直播的“人货场”信息闭环。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_living_share_info?access_token=ACCESS_TOKEN + * + * @param wwShareCode "推广产品"直播观众跳转小程序商城时会在小程序path中带上ww_share_code=xxxxx参数 + * @return living share info + * @throws WxErrorException the wx error exception + */ + WxCpLivingShareInfo getLivingShareInfo(@NonNull String wwShareCode) throws WxErrorException; + + /** + * 创建预约直播 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/create?access_token=ACCESS_TOKEN + * + * @param request 创建预约直播请求参数. + * @return livingId (直播id) + * @throws WxErrorException the wx error exception + */ + String livingCreate(WxCpLivingCreateRequest request) throws WxErrorException; + + /** + * 修改预约直播 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/modify?access_token=ACCESS_TOKEN + * + * @param request 修改预约直播请求参数. + * @return wx cp living result + * @throws WxErrorException the wx error exception + */ + WxCpLivingResult livingModify(WxCpLivingModifyRequest request) throws WxErrorException; + + /** + * 取消预约直播 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/cancel?access_token=ACCESS_TOKEN + * + * @param livingId 直播id,仅允许取消预约状态下的直播id + * @return wx cp living result + * @throws WxErrorException the wx error exception + */ + WxCpLivingResult livingCancel(@NonNull String livingId) throws WxErrorException; + + /** + * 删除直播回放 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/delete_replay_data?access_token=ACCESS_TOKEN + * + * @param livingId 直播id + * @return wx cp living result + * @throws WxErrorException the wx error exception + */ + WxCpLivingResult deleteReplayData(@NonNull String livingId) throws WxErrorException; + +} 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 a51e04e175..d0d4b661b0 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 @@ -31,16 +31,36 @@ public interface WxCpMediaService { * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} * @param inputStream 输入流,需要调用方控制关闭该输入流 + * @return the wx media upload result + * @throws WxErrorException the wx error exception + * @throws IOException the io exception */ WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException; + /** + *

+   *   上传多媒体文件.
+   * 
+ * + * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param filename 文件名.例如:wework.txt + * @param url 远程链接 + * @return wx media upload result + * @throws WxErrorException the wx error exception + * @throws IOException the io exception + */ + WxMediaUploadResult upload(String mediaType, String filename, String url) + throws WxErrorException, IOException; + /** * 上传多媒体文件. * * @param mediaType 媒体类型 * @param file 文件对象 - * @see #upload(String, String, InputStream) + * @return the wx media upload result + * @throws WxErrorException the wx error exception + * @see #upload(String, String, InputStream) #upload(String, String, InputStream) */ WxMediaUploadResult upload(String mediaType, File file) throws WxErrorException; @@ -52,7 +72,8 @@ WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputS *
* * @param mediaId 媒体id - * @return 保存到本地的临时文件 + * @return 保存到本地的临时文件 file + * @throws WxErrorException the wx error exception */ File download(String mediaId) throws WxErrorException; @@ -67,7 +88,8 @@ WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputS *
* * @param mediaId 媒体id - * @return 保存到本地的临时文件 + * @return 保存到本地的临时文件 jssdk file + * @throws WxErrorException the wx error exception */ File getJssdkFile(String mediaId) throws WxErrorException; @@ -81,7 +103,8 @@ WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputS *
* * @param file 上传的文件对象 - * @return 返回图片url + * @return 返回图片url string + * @throws WxErrorException the wx error exception */ String uploadImg(File file) throws WxErrorException; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMeetingService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMeetingService.java new file mode 100644 index 0000000000..e3ee866118 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMeetingService.java @@ -0,0 +1,97 @@ +package me.chanjar.weixin.cp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult; + +import java.util.List; + +/** + * 企业微信日程接口. + * 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。 + * 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。 + * 官方文档:https://developer.work.weixin.qq.com/document/path/93626 + * + * @author wangmeng3486 created on 2023-01-31 + */ +public interface WxCpMeetingService { + /** + * 创建预约会议 + *

+ * 该接口用于创建一个预约会议。 + *

+ * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/create?access_token=ACCESS_TOKEN + * + * @param meeting the meeting + * @return 会议ID string + * @throws WxErrorException the wx error exception + */ + String create(WxCpMeeting meeting) throws WxErrorException; + + /** + * 修改预约会议 + *

+ * 该接口用于修改一个指定的预约会议。。 + *

+ * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/update?access_token=ACCESS_TOKEN + * + * @param meeting the meeting + * @return wx cp meeting update result + * @throws WxErrorException the wx error exception + */ + WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException; + + + /** + * 取消预约会议 + * 该接口用于取消一个指定的预约会议。 + *

+ * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/cancel?access_token=ACCESS_TOKEN + * + * @param meetingId 会议ID + * @throws WxErrorException the wx error exception + */ + void cancel(String meetingId) throws WxErrorException; + + /** + * 获取会议详情 + *

+ * 该接口用于获取指定会议的详情内容。 + *

+ * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meeting/get?access_token=ACCESS_TOKEN + * + * @param meetingId the meeting ids + * @return the details + * @throws WxErrorException the wx error exception + */ + WxCpMeeting getDetail(String meetingId) throws WxErrorException; + + /** + * 获取成员会议ID列表 + * 该接口用于获取指定成员指定时间内的会议ID列表。 + *

+ * 权限说明: + * 只能拉取该应用创建的会议ID + * 自建应用需要配置在“可调用接口的应用”列表 + * 第三方服务商创建应用的时候,需要开启“会议接口权限” + * 代开发自建应用需要授权“会议接口权限” + *

+ * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/get_user_meetingid?access_token=ACCESS_TOKEN + * + * @param userId 企业成员的userid + * @param cursor 上一次调用时返回的cursor,初次调用可以填"0" + * @param limit 每次拉取的数据量,默认值和最大值都为100 + * @param beginTime 开始时间 + * @param endTime 结束时间,时间跨度不超过180天。如果begin_time和end_time都没填的话,默认end_time为当前时间 + * @return result of listUserMeetingIds + * @throws WxErrorException the wx error exception + */ + WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit, + Long beginTime, Long endTime) throws WxErrorException; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java index 309b981211..07f300dd14 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java @@ -22,7 +22,8 @@ public interface WxCpMenuService { *

* * @param menu 菜单对象 - * @see #create(Integer, WxMenu) + * @throws WxErrorException the wx error exception + * @see #create(Integer, WxMenu) #create(Integer, WxMenu) */ void create(WxMenu menu) throws WxErrorException; @@ -36,7 +37,8 @@ public interface WxCpMenuService { * * @param agentId 企业号应用的id * @param menu 菜单对象 - * @see #create(me.chanjar.weixin.common.bean.menu.WxMenu) + * @throws WxErrorException the wx error exception + * @see #create(me.chanjar.weixin.common.bean.menu.WxMenu) #create(me.chanjar.weixin.common.bean.menu.WxMenu) */ void create(Integer agentId, WxMenu menu) throws WxErrorException; @@ -48,7 +50,8 @@ public interface WxCpMenuService { * 注意: 这个方法使用WxCpConfigStorage里的agentId *
* - * @see #delete(Integer) + * @throws WxErrorException the wx error exception + * @see #delete(Integer) #delete(Integer) */ void delete() throws WxErrorException; @@ -61,7 +64,8 @@ public interface WxCpMenuService { *
* * @param agentId 企业号应用的id - * @see #delete() + * @throws WxErrorException the wx error exception + * @see #delete() #delete() */ void delete(Integer agentId) throws WxErrorException; @@ -73,7 +77,9 @@ public interface WxCpMenuService { * 注意: 这个方法使用WxCpConfigStorage里的agentId *
* - * @see #get(Integer) + * @return the wx menu + * @throws WxErrorException the wx error exception + * @see #get(Integer) #get(Integer) */ WxMenu get() throws WxErrorException; @@ -86,7 +92,9 @@ public interface WxCpMenuService { *
* * @param agentId 企业号应用的id - * @see #get() + * @return the wx menu + * @throws WxErrorException the wx error exception + * @see #get() #get() */ WxMenu get(Integer agentId) throws WxErrorException; } 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 1b66d00c07..e49a36ba50 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 @@ -6,8 +6,7 @@ /** * 消息推送接口. * - * @author Binary Wang - * @date 2020 -08-30 + * @author Binary Wang created on 2020 -08-30 */ public interface WxCpMessageService { /** @@ -32,7 +31,7 @@ public interface WxCpMessageService { *
* * @param timeType 查询哪天的数据,0:当天;1:昨天。默认为0。 - * @return 统计结果 + * @return 统计结果 statistics * @throws WxErrorException the wx error exception */ WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException; @@ -50,4 +49,32 @@ public interface WxCpMessageService { * @throws WxErrorException the wx error exception */ WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException; + + /** + * 发送「学校通知」 + * https://developer.work.weixin.qq.com/document/path/92321 + *

+ * 学校可以通过此接口来给家长发送不同类型的学校通知,来满足多种场景下的学校通知需求。目前支持的消息类型为文本、图片、语音、视频、文件、图文。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/externalcontact/message/send?access_token=ACCESS_TOKEN + * + * @param message 要发送的消息对象 + * @return wx cp school contact message send result + * @throws WxErrorException the wx error exception + */ + WxCpSchoolContactMessageSendResult sendSchoolContactMessage(WxCpSchoolContactMessage message) throws WxErrorException; + + /** + *

+   * 撤回应用消息
+   *
+   * 请求地址: 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 + */ + void recall(String msgId) throws WxErrorException; + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMsgAuditService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMsgAuditService.java new file mode 100644 index 0000000000..221caf2e70 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMsgAuditService.java @@ -0,0 +1,132 @@ +package me.chanjar.weixin.cp.api; + +import lombok.NonNull; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.msgaudit.*; + +import java.util.List; +import java.util.function.Consumer; + +/** + * 会话内容存档接口. + * 官方文档:https://developer.work.weixin.qq.com/document/path/91360 + *

+ * 如需自行实现,亦可调用Finance类库函数,进行实现: + * com.tencent.wework.Finance + * + * @author Wang_Wong created on 2022-01-14 + */ +public interface WxCpMsgAuditService { + + /** + * 拉取聊天记录函数 + * + * @param seq 从指定的seq开始拉取消息,注意的是返回的消息从seq+1开始返回,seq为之前接口返回的最大seq值。首次使用请使用seq:0 + * @param limit 一次拉取的消息条数,最大值1000条,超过1000条会返回错误 + * @param proxy 使用代理的请求,需要传入代理的链接。如:socks5://10.0.0.1:8081 或者 http://10.0.0.1:8081,如果没有传null + * @param passwd 代理账号密码,需要传入代理的账号密码。如 user_name:passwd_123,如果没有传null + * @param timeout 超时时间,根据实际需要填写 + * @return 返回是否调用成功 chat datas + * @throws Exception the exception + */ + WxCpChatDatas getChatDatas(long seq, @NonNull long limit, String proxy, String passwd, @NonNull long timeout) throws Exception; + + /** + * 获取解密的聊天数据Model + * + * @param sdk getChatDatas()获取到的sdk + * @param chatData getChatDatas()获取到的聊天数据 + * @param pkcs1 使用什么方式进行解密,1代表使用PKCS1进行解密,2代表PKCS8进行解密 ... + * @return 解密后的聊天数据 decrypt data + * @throws Exception the exception + */ + WxCpChatModel getDecryptData(@NonNull long sdk, @NonNull WxCpChatDatas.WxCpChatData chatData, + @NonNull Integer pkcs1) throws Exception; + + /** + * 获取解密的聊天数据明文 + * + * @param sdk getChatDatas()获取到的sdk + * @param chatData getChatDatas()获取到的聊天数据 + * @param pkcs1 使用什么方式进行解密,1代表使用PKCS1进行解密,2代表PKCS8进行解密 ... + * @return 解密后的明文 chat plain text + * @throws Exception the exception + */ + String getChatPlainText(@NonNull long sdk, @NonNull WxCpChatDatas.WxCpChatData chatData, @NonNull Integer pkcs1) throws Exception; + + /** + * 获取媒体文件 + * 针对图片、文件等媒体数据,提供sdk接口拉取数据内容。 + *

+ * 注意: + * 根据上面返回的文件类型,拼接好存放文件的绝对路径即可。此时绝对路径写入文件流,来达到获取媒体文件的目的。 + * 详情可以看官方文档,亦可阅读此接口源码。 + * + * @param sdk getChatDatas()获取到的sdk,注意,每次获取的sdk会不一样 + * @param sdkfileid 消息体内容中的sdkfileid信息 + * @param proxy 使用代理的请求,需要传入代理的链接。如:socks5://10.0.0.1:8081 或者 http://10.0.0.1:8081,如果没有传null + * @param passwd 代理账号密码,需要传入代理的账号密码。如 user_name:passwd_123,如果没有传null + * @param timeout 超时时间,分片数据需累加到文件存储。单次最大返回512K字节,如果文件比较大,自行设置长一点,比如timeout=10000 + * @param targetFilePath 目标文件绝对路径+实际文件名,比如:/usr/local/file/20220114/474f866b39d10718810d55262af82662.gif + * @throws WxErrorException the wx error exception + */ + void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, @NonNull long timeout, + @NonNull String targetFilePath) throws WxErrorException; + + /** + * 获取媒体文件 传入一个lambda,each所有的数据分片byte[],更加灵活 + * 针对图片、文件等媒体数据,提供sdk接口拉取数据内容。 + * 详情可以看官方文档,亦可阅读此接口源码。 + * + * @param sdk getChatDatas()获取到的sdk,注意,每次获取的sdk会不一样 + * @param sdkfileid 消息体内容中的sdkfileid信息 + * @param proxy 使用代理的请求,需要传入代理的链接。如:socks5://10.0.0.1:8081 或者 http://10.0.0.1:8081,如果没有传null + * @param passwd 代理账号密码,需要传入代理的账号密码。如 user_name:passwd_123,如果没有传null + * @param timeout 超时时间,分片数据需累加到文件存储。单次最大返回512K字节,如果文件比较大,自行设置长一点,比如timeout=10000 + * @param action 传入一个lambda,each所有的数据分片 + * @throws WxErrorException the wx error exception + */ + void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, @NonNull long timeout, + @NonNull Consumer action) throws WxErrorException; + + /** + * 获取会话内容存档开启成员列表 + * 企业可通过此接口,获取企业开启会话内容存档的成员列表 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_permit_user_list?access_token=ACCESS_TOKEN + * + * @param type 拉取对应版本的开启成员列表。1表示办公版;2表示服务版;3表示企业版。非必填,不填写的时候返回全量成员列表。 + * @return permit user list + * @throws WxErrorException the wx error exception + */ + List getPermitUserList(Integer type) throws WxErrorException; + + /** + * 获取会话内容存档内部群信息 + * 企业可通过此接口,获取会话内容存档本企业的内部群信息,包括群名称、群主id、公告、群创建时间以及所有群成员的id与加入时间。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/msgaudit/groupchat/get?access_token=ACCESS_TOKEN + * + * @param roomid 待查询的群id + * @return group chat + * @throws WxErrorException the wx error exception + */ + WxCpGroupChat getGroupChat(@NonNull String roomid) throws WxErrorException; + + /** + * 获取会话同意情况 + * 企业可通过下述接口,获取会话中外部成员的同意情况 + *

+ * 单聊请求地址:https://qyapi.weixin.qq.com/cgi-bin/msgaudit/check_single_agree?access_token=ACCESS_TOKEN + *

+ * 请求方式:POST(HTTPS) + * + * @param checkAgreeRequest 待查询的会话信息 + * @return wx cp agree info + * @throws WxErrorException the wx error exception + */ + WxCpAgreeInfo checkSingleAgree(@NonNull WxCpCheckAgreeRequest checkAgreeRequest) 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 7c42ea63fc..a2c47437b2 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 @@ -9,6 +9,8 @@ * OAuth2相关管理接口. * Created by BinaryWang on 2017/6/24. *

+ *

+ * 文档1:https://developer.work.weixin.qq.com/document/path/91856 * * @author Binary Wang */ @@ -20,7 +22,7 @@ public interface WxCpOAuth2Service { *

* * @param state 状态码 - * @return url + * @return url string */ String buildAuthorizationUrl(String state); @@ -32,7 +34,7 @@ public interface WxCpOAuth2Service { * * @param redirectUri 跳转链接地址 * @param state 状态码 - * @return url + * @return url string */ String buildAuthorizationUrl(String redirectUri, String state); @@ -45,7 +47,7 @@ public interface WxCpOAuth2Service { * @param redirectUri 跳转链接地址 * @param state 状态码 * @param scope 取值参考me.chanjar.weixin.common.api.WxConsts.OAuth2Scope类 - * @return url + * @return url string */ String buildAuthorizationUrl(String redirectUri, String state, String scope); @@ -59,9 +61,9 @@ public interface WxCpOAuth2Service { *
* * @param code 微信oauth授权返回的代码 - * @return WxCpOauth2UserInfo + * @return WxCpOauth2UserInfo user info * @throws WxErrorException 异常 - * @see #getUserInfo(Integer, String) + * @see #getUserInfo(Integer, String) #getUserInfo(Integer, String) */ WxCpOauth2UserInfo getUserInfo(String code) throws WxErrorException; @@ -78,12 +80,25 @@ public interface WxCpOAuth2Service { * * @param agentId 企业号应用的id * @param code 通过成员授权获取到的code,最大为512字节。每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。 - * @return WxCpOauth2UserInfo + * @return WxCpOauth2UserInfo user info * @throws WxErrorException 异常 - * @see #getUserInfo(String) + * @see #getUserInfo(String) #getUserInfo(String) */ WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException; + /** + * 获取家校访问用户身份 + * 该接口用于根据code获取家长或者学生信息 + *

+ * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE + * + * @param code the code + * @return school user info + * @throws WxErrorException the wx error exception + */ + WxCpOauth2UserInfo getSchoolUserInfo(String code) throws WxErrorException; + /** *

    * 使用user_ticket获取成员详情.
@@ -97,7 +112,7 @@ public interface WxCpOAuth2Service {
    * 
* * @param userTicket 成员票据 - * @return WxCpUserDetail + * @return WxCpUserDetail user detail * @throws WxErrorException 异常 */ WxCpUserDetail getUserDetail(String userTicket) throws WxErrorException; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java new file mode 100644 index 0000000000..6b8b98877b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.cp.api; + +import lombok.NonNull; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData; + +/** + * 企业微信自建应用接口. + * https://developer.work.weixin.qq.com/document/path/90269 + * + * @author Wang_Wong created on 2022-04-06 + */ +public interface WxCpOaAgentService { + + /** + * 查询第三方应用审批申请当前状态 + * 开发者也可主动查询审批单的当前审批状态。 + *

+ * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/corp/getopenapprovaldata?access_token=ACCESS_TOKEN + * + * @param thirdNo the third no + * @return open approval data + * @throws WxErrorException the wx error exception + */ + WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaCalendarService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaCalendarService.java index 91010ce212..50d5e8d946 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaCalendarService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaCalendarService.java @@ -8,8 +8,7 @@ /** * 企业微信日历接口. * - * @author Binary Wang - * @date 2020-09-20 + * @author Binary Wang created on 2020-09-20 */ public interface WxCpOaCalendarService { /** @@ -24,7 +23,7 @@ public interface WxCpOaCalendarService { *

* * @param calendar 日历对象 - * @return 日历ID + * @return 日历ID string * @throws WxErrorException . */ String add(WxCpOaCalendar calendar) throws WxErrorException; @@ -60,7 +59,7 @@ public interface WxCpOaCalendarService { *
* * @param calIds 日历id列表 - * @return 日历对象列表 + * @return 日历对象列表 list * @throws WxErrorException . */ List get(List calIds) 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 new file mode 100644 index 0000000000..94535fe1da --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java @@ -0,0 +1,75 @@ +package me.chanjar.weixin.cp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom; + +import java.util.List; + +/** + * 企业微信会议室接口. + * + * @author lm93129 created on 2022年8月12日22:33:36 + */ +public interface WxCpOaMeetingRoomService { + /** + * 创建会议室. + *
+   * 该接口用于通过应用在企业内创建一个会议室。
+   * 请求方式: POST(HTTPS)
+   * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/add?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/93619
+   * 
+ * + * @param meetingRoom 会议室对象 + * @return 会议室ID string + * @throws WxErrorException . + */ + String addMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException; + + /** + * 查询会议室. + *
+   * 该接口用于通过应用在企业内查询会议室列表。
+   * 请求方式: POST(HTTPS)
+   * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/list?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/93619
+   * 
+ * + * @param meetingRoomRequest 会议室查询对象 + * @return 会议室ID list + * @throws WxErrorException . + */ + List listMeetingRoom(WxCpOaMeetingRoom meetingRoomRequest) throws WxErrorException; + + /** + * 编辑会议室. + *
+   * 该接口用于通过应用在企业内编辑会议室。
+   * 请求方式: POST(HTTPS)
+   * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/edit?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/93619
+   * 
+ * + * @param meetingRoom 会议室对象 + * @throws WxErrorException . + */ + void editMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException; + + /** + * 编辑会议室. + *
+   * 该接口用于通过应用在企业内编辑会议室。
+   * 请求方式: POST(HTTPS)
+   * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/del?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/93619
+   * 
+ * + * @param meetingRoomId 会议室对象 + * @throws WxErrorException . + */ + void deleteMeetingRoom(Integer meetingRoomId) throws WxErrorException; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaScheduleService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaScheduleService.java index c5b75bce17..70c108a059 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaScheduleService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaScheduleService.java @@ -9,8 +9,7 @@ * 企业微信日程接口. * 官方文档:https://work.weixin.qq.com/api/doc/90000/90135/93648 * - * @author Binary Wang - * @date 2020 -12-25 + * @author Binary Wang created on 2020 -12-25 */ public interface WxCpOaScheduleService { /** 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 7eb986dbbb..fec2c08e55 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 @@ -2,6 +2,7 @@ import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.*; import java.util.Date; @@ -10,8 +11,7 @@ /** * 企业微信OA相关接口. * - * @author Element - * @date 2019-04-06 10:52 + * @author Element & Wang_Wong created on 2019-04-06 10:52 */ public interface WxCpOaService { @@ -67,7 +67,7 @@ List getCheckinData(Integer openCheckinDataType, Date startTime * API doc : https://work.weixin.qq.com/api/doc/90000/90135/93384 *
* - * @return 打卡规则列表 + * @return 打卡规则列表 crop checkin option * @throws WxErrorException the wx error exception */ List getCropCheckinOption() throws WxErrorException; @@ -103,10 +103,12 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, * @param endTime 结束时间 * @return WxCpApprovalInfo approval info * @throws WxErrorException . - * @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo + * @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo me.chanjar.weixin.cp.api + * .WxCpOaService#getApprovalInfome.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo */ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException; + /** *
    *   获取审批申请详情
@@ -122,6 +124,73 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime,
    */
   WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws WxErrorException;
 
+
+  /**
+   * 获取企业假期管理配置
+   * 企业可通过审批应用或自建应用Secret调用本接口,获取可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。
+   * 第三方应用可获取应用可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。
+   * 

+ * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getcorpconf?access_token=ACCESS_TOKEN + * + * @return corp conf + * @throws WxErrorException the wx error exception + */ + WxCpCorpConfInfo getCorpConf() throws WxErrorException; + + + /** + * 获取成员假期余额 + * 企业可通过审批应用或自建应用Secret调用本接口,获取可见范围内各个员工的假期余额数据。 + * 第三方应用可获取应用可见范围内各个员工的假期余额数据。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getuservacationquota?access_token=ACCESS_TOKEN + * + * @param userId 需要获取假期余额的成员的userid + * @return user vacation quota + * @throws WxErrorException the wx error exception + */ + WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException; + + + /** + * 获取审批数据(旧) + * 提示:推荐使用新接口“批量获取审批单号”及“获取审批申请详情”,此接口后续将不再维护、逐步下线。 + * 通过本接口来获取公司一段时间内的审批记录。一次拉取调用最多拉取100个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/getapprovaldata?access_token=ACCESS_TOKEN + * + * @param startTime 获取审批记录的开始时间。Unix时间戳 + * @param endTime 获取审批记录的结束时间。Unix时间戳 + * @param nextSpNum 第一个拉取的审批单号,不填从该时间段的第一个审批单拉取 + * @return approval data + * @throws WxErrorException the wx error exception + */ + WxCpGetApprovalData getApprovalData(@NonNull Long startTime, @NonNull Long endTime, Long nextSpNum) throws WxErrorException; + + + /** + * 修改成员假期余额 + * 企业可通过审批应用或自建应用Secret调用本接口,修改可见范围内员工的“假期余额”。 + * 第三方应用可通过应本接口修改应用可见范围内指定员工的“假期余额”。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/setoneuserquota?access_token=ACCESS_TOKEN + * + * @param userId 需要修改假期余额的成员的userid + * @param vacationId 假期id + * @param leftDuration 设置的假期余额,单位为秒,不能大于1000天或24000小时,当假期时间刻度为按小时请假时,必须为360整倍数,即0.1小时整倍数,按天请假时,必须为8640整倍数,即0.1天整倍数 + * @param timeAttr 假期时间刻度:0-按天请假;1-按小时请假 + * @param remarks 修改备注,用于显示在假期余额的修改记录当中,可对修改行为作说明,不超过200字符 + * @return one user quota + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp setOneUserQuota(@NonNull String userId, @NonNull Integer vacationId, @NonNull Integer leftDuration, + @NonNull Integer timeAttr, String remarks) throws WxErrorException; + + /** * 获取公费电话拨打记录 * @@ -142,8 +211,41 @@ List getDialRecord(Date startTime, Date endTime, Integer offset, * @return . template detail * @throws WxErrorException . */ - WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException; + WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException; + /** + * 创建审批模板 + *
+ * 可以调用此接口创建审批模板。创建新模板后,管理后台及审批应用内将生成对应模板,并生效默认流程和规则配置。 + *

+   *  文档地址: https://developer.work.weixin.qq.com/document/path/97437
+   *  权限说明
+   * • 仅『审批』系统应用、自建应用和代开发自建应用可调用。
+   * 
+ * + * @param cpTemplate cpTemplate + * @return templateId + * @throws WxErrorException . + */ + String createOaApprovalTemplate(WxCpOaApprovalTemplate cpTemplate) throws WxErrorException; + + /** + * 更新审批模板 + *
+ * 可调用本接口更新审批模板。更新模板后,管理后台及审批应用内将更新原模板的内容,已配置的审批流程和规则不变。 + *
+   *  文档地址: https://developer.work.weixin.qq.com/document/path/97438
+   *  权限说明
+   * • 仅『审批』系统应用,自建应用和代开发自建应用可调用
+   * • 所有应用都可以通过本接口更新自己的模板
+   * • 『审批』系统应用可以修改管理员手动创建的模板
+   * • 自建应用和代开发自建应用不可通过本接口更新其他应用创建的模板
+   * 
+ * + * @param wxCpTemplate wxCpTemplate + * @throws WxErrorException . + */ + void updateOaApprovalTemplate(WxCpOaApprovalTemplate wxCpTemplate) throws WxErrorException; /** * 获取打卡日报数据 @@ -163,7 +265,7 @@ List getDialRecord(Date startTime, Date endTime, Integer offset, * @param startTime 获取月报的开始时间 * @param endTime 获取月报的结束时间 * @param userIdList 获取月报的userid列表 - * @return 月报数据列表 + * @return 月报数据列表 checkin month data * @throws WxErrorException the wx error exception */ List getCheckinMonthData(Date startTime, Date endTime, List userIdList) throws WxErrorException; @@ -174,7 +276,7 @@ List getDialRecord(Date startTime, Date endTime, Integer offset, * @param startTime 获取排班信息的开始时间。Unix时间戳 * @param endTime 获取排班信息的结束时间。Unix时间戳(与starttime跨度不超过一个月) * @param userIdList 需要获取排班信息的用户列表(不超过100个) - * @return 排班表信息 + * @return 排班表信息 checkin schedule list * @throws WxErrorException the wx error exception */ List getCheckinScheduleList(Date startTime, Date endTime, List userIdList) throws WxErrorException; @@ -187,4 +289,21 @@ List getDialRecord(Date startTime, Date endTime, Integer offset, * @throws WxErrorException the wx error exception */ void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule) throws WxErrorException; + + /** + *
+   * 录入打卡人员人脸信息
+   * 企业可通过打卡应用Secret调用本接口,为企业打卡人员录入人脸信息,人脸信息仅用于人脸打卡。
+   * 上传图片大小限制:图片数据不超过1M
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://qyapi.weixin.qq.com/cgi-bin/checkin/addcheckinuserface?access_token=ACCESS_TOKEN
+   * 文档地址:
+   * https://developer.work.weixin.qq.com/document/path/93378
+   * 
+   * @param userId 需要录入的用户id
+   * @param userFace 需要录入的人脸图片数据,需要将图片数据base64处理后填入,对已录入的人脸会进行更新处理
+   * @throws WxErrorException the wx error exception
+   */
+  void addCheckInUserFace(String userId, String userFace) throws WxErrorException;
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java
new file mode 100644
index 0000000000..ad2dc635fc
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java
@@ -0,0 +1,295 @@
+package me.chanjar.weixin.cp.api;
+
+import lombok.NonNull;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.bean.WxCpBaseResp;
+import me.chanjar.weixin.cp.bean.oa.wedrive.*;
+
+import java.util.List;
+
+/**
+ * 企业微信微盘相关接口.
+ * https://developer.work.weixin.qq.com/document/path/93654
+ *
+ * @author Wang_Wong created on  2022-04-22
+ */
+public interface WxCpOaWeDriveService {
+
+  /**
+   * 新建空间
+   * 该接口用于在微盘内新建空间,可以指定人创建空间。
+   * 

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=ACCESS_TOKEN + * + * @param request 新建空间对应请求参数 + * @return spaceid (空间id) + * @throws WxErrorException the wx error exception + */ + WxCpSpaceCreateData spaceCreate(@NonNull WxCpSpaceCreateRequest request) throws WxErrorException; + + /** + * 重命名空间 + * 该接口用于重命名已有空间,接收userid参数,以空间管理员身份来重命名。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=ACCESS_TOKEN + * + * @param request 重命名空间的请求参数 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp spaceRename(@NonNull WxCpSpaceRenameRequest request) throws WxErrorException; + + /** + * 解散空间 + * 该接口用于解散已有空间,需要以空间管理员身份来解散。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param spaceId the space id + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp spaceDismiss(@NonNull String userId, @NonNull String spaceId) throws WxErrorException; + + /** + * 获取空间信息 + * 该接口用于获取空间成员列表、信息、权限等信息。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param spaceId the space id + * @return wx cp space info + * @throws WxErrorException the wx error exception + */ + WxCpSpaceInfo spaceInfo(@NonNull String userId, @NonNull String spaceId) throws WxErrorException; + + /** + * 添加成员/部门 + * 该接口用于对指定空间添加成员/部门,可一次性添加多个。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=ACCESS_TOKEN + * + * @param request 添加成员/部门请求参数 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException; + + /** + * 移除成员/部门 + * 该接口用于对指定空间移除成员/部门,操作者需要有移除权限。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=ACCESS_TOKEN + * + * @param request 移除成员/部门请求参数 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException; + + /** + * 权限管理 + * 该接口用于修改空间权限,需要传入userid,修改权限范围继承传入用户的权限范围。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_setting?access_token=ACCESS_TOKEN + * + * @param request 权限管理请求参数 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp spaceSetting(@NonNull WxCpSpaceSettingRequest request) throws WxErrorException; + + /** + * 获取邀请链接 + * 该接口用于获取空间邀请分享链接。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param spaceId the space id + * @return wx cp space share + * @throws WxErrorException the wx error exception + */ + WxCpSpaceShare spaceShare(@NonNull String userId, @NonNull String spaceId) throws WxErrorException; + + /** + * 获取文件列表 + * 该接口用于获取指定地址下的文件列表。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_list?access_token=ACCESS_TOKEN + * + * @param request 获取文件列表请求参数 + * @return wx cp file list + * @throws WxErrorException the wx error exception + */ + WxCpFileList fileList(@NonNull WxCpFileListRequest request) throws WxErrorException; + + /** + * 上传文件 + * 该接口用于向微盘中的指定位置上传文件。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload?access_token=ACCESS_TOKEN + * + * @param request 上传文件请求参数 + * @return wx cp file upload + * @throws WxErrorException the wx error exception + */ + WxCpFileUpload fileUpload(@NonNull WxCpFileUploadRequest request) throws WxErrorException; + + /** + * 下载文件 + * 该接口用于下载文件,请求的userid需有下载权限。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param fileId the file id + * @return wx cp file download + * @throws WxErrorException the wx error exception + */ + WxCpFileDownload fileDownload(@NonNull String userId, @NonNull String fileId) throws WxErrorException; + + /** + * 重命名文件 + * 该接口用于对指定文件进行重命名。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_rename?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param fileId the file id + * @param newName the new name + * @return wx cp file rename + * @throws WxErrorException the wx error exception + */ + WxCpFileRename fileRename(@NonNull String userId, @NonNull String fileId, @NonNull String newName) throws WxErrorException; + + /** + * 新建文件/微文档 + * 该接口用于在微盘指定位置新建文件、微文档。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=ACCESS_TOKEN + * + * @param userId 操作者userid + * @param spaceId 空间spaceid + * @param fatherId 父目录fileid, 在根目录时为空间spaceid + * @param fileType 文件类型, 1:文件夹 3:微文档(文档) 4:微文档(表格) + * @param fileName 文件名字 + * @return wx cp file create + * @throws WxErrorException the wx error exception + */ + WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId, + @NonNull String fatherId, @NonNull Integer fileType, @NonNull String fileName) throws WxErrorException; + + /** + * 移动文件 + * 该接口用于将文件移动到指定位置。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_move?access_token=ACCESS_TOKEN + * + * @param request 移动文件的请求参数 + * @return wx cp file move + * @throws WxErrorException the wx error exception + */ + WxCpFileMove fileMove(@NonNull WxCpFileMoveRequest request) throws WxErrorException; + + /** + * 删除文件 + * 该接口用于删除指定文件。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_delete?access_token=ACCESS_TOKEN + * + * @param userId 操作者userid + * @param fileId 文件fileid列表 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp fileDelete(@NonNull String userId, @NonNull List fileId) throws WxErrorException; + + /** + * 新增指定人 + * 该接口用于对指定文件添加指定人/部门。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_add?access_token=ACCESS_TOKEN + * + * @param request 新增指定人请求参数 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp fileAclAdd(@NonNull WxCpFileAclAddRequest request) throws WxErrorException; + + /** + * 删除指定人 + * 该接口用于删除指定文件的指定人/部门。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=ACCESS_TOKEN + * + * @param request 请求参数 + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException; + + /** + * 分享设置 + * 该接口用于文件的分享设置。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param fileId the file id + * @param authScope the auth scope + * @param auth the auth + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp fileSetting(@NonNull String userId, @NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException; + + /** + * 获取分享链接 + * 该接口用于获取文件的分享链接。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param fileId the file id + * @return wx cp file share + * @throws WxErrorException the wx error exception + */ + WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException; + + /** + * 文件信息 + * 该接口用于获取指定文件的信息。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_info?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param fileId the file id + * @return wx cp file info + * @throws WxErrorException the wx error exception + */ + WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthService.java new file mode 100644 index 0000000000..091f242820 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthService.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.cp.api; + +import lombok.NonNull; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetHealthReportStat; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportAnswer; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobIds; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobInfo; + +/** + * 企业微信家校应用 健康上报接口. + * https://developer.work.weixin.qq.com/document/path/93676 + * + * @author Wang_Wong created on : 2022/5/31 9:10 + */ +public interface WxCpSchoolHealthService { + + /** + * 获取健康上报使用统计 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_health_report_stat?access_token=ACCESS_TOKEN + * + * @param date 具体某天的使用统计,最长支持获取30天前数据 + * @return health report stat + * @throws WxErrorException the wx error exception + */ + WxCpGetHealthReportStat getHealthReportStat(@NonNull String date) throws WxErrorException; + + /** + * 获取健康上报任务ID列表 + * 通过此接口可以获取企业当前正在运行的上报任务ID列表。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_report_jobids?access_token=ACCESS_TOKEN + * + * @param offset 否 分页,偏移量, 默认为0 + * @param limit 否 分页,预期请求的数据量,默认为100,取值范围 1 ~ 100 + * @return report job ids + * @throws WxErrorException the wx error exception + */ + WxCpGetReportJobIds getReportJobIds(Integer offset, Integer limit) throws WxErrorException; + + /** + * 获取健康上报任务详情 + * 通过此接口可以获取指定的健康上报任务详情。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_report_job_info?access_token=ACCESS_TOKEN + * + * @param jobId 是 任务ID + * @param date 是 具体某天任务详情,仅支持获取最近14天数据 + * @return report job info + * @throws WxErrorException the wx error exception + */ + WxCpGetReportJobInfo getReportJobInfo(@NonNull String jobId, @NonNull String date) throws WxErrorException; + + /** + * 获取用户填写答案 + * 通过此接口可以获取指定的健康上报任务详情。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_report_answer?access_token=ACCESS_TOKEN + * + * @param jobId the job id + * @param date the date + * @param offset the offset + * @param limit the limit + * @return report answer + * @throws WxErrorException the wx error exception + */ + WxCpGetReportAnswer getReportAnswer(@NonNull String jobId, @NonNull String date, Integer offset, Integer limit) 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 new file mode 100644 index 0000000000..56687c9cb1 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java @@ -0,0 +1,147 @@ +package me.chanjar.weixin.cp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.living.WxCpLivingResult; +import me.chanjar.weixin.cp.bean.school.*; + +import java.util.List; + +/** + * 企业微信家校应用 复学码相关接口. + * https://developer.work.weixin.qq.com/document/path/93744 + *

+ * 权限说明: + * 仅复学码应用可以调用 + * + * @author Wang_Wong created on : 2022/5/31 9:10 + */ +public interface WxCpSchoolService { + + /** + * 获取老师健康信息 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/user/get_teacher_customize_health_info?access_token=ACCESS_TOKEN + * + * @param date the date + * @param nextKey the next key + * @param limit the limit + * @return teacher customize health info + * @throws WxErrorException the wx error exception + */ + WxCpCustomizeHealthInfo getTeacherCustomizeHealthInfo(String date, String nextKey, Integer limit) throws WxErrorException; + + /** + * 获取学生健康信息 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/user/get_student_customize_health_info?access_token=ACCESS_TOKEN + * + * @param date the date + * @param nextKey the next key + * @param limit the limit + * @return student customize health info + * @throws WxErrorException the wx error exception + */ + WxCpCustomizeHealthInfo getStudentCustomizeHealthInfo(String date, String nextKey, Integer limit) throws WxErrorException; + + /** + * 获取师生健康码 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get_health_qrcode?access_token=ACCESS_TOKEN + * + * @param userIds the user ids + * @param type the type + * @return health qr code + * @throws WxErrorException the wx error exception + */ + WxCpResultList getHealthQrCode(List userIds, Integer type) throws WxErrorException; + + /** + * 获取学生付款结果 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/get_payment_result?access_token=ACCESS_TOKEN + * + * @param paymentId the payment id + * @return payment result + * @throws WxErrorException the wx error exception + */ + WxCpPaymentResult getPaymentResult(String paymentId) throws WxErrorException; + + /** + * 获取订单详情 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/get_trade?access_token=ACCESS_TOKEN + * + * @param paymentId the payment id + * @param tradeNo the trade no + * @return trade + * @throws WxErrorException the wx error exception + */ + WxCpTrade getTrade(String paymentId, String tradeNo) throws WxErrorException; + + /** + * 获取直播详情 + * 请求方式:GET(HTTPS) + * 请求地址: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 + * @throws WxErrorException the wx error exception + */ + WxCpSchoolLivingInfo getLivingInfo(String livingId) throws WxErrorException; + + /** + * 获取老师直播ID列表 + * 通过此接口可以获取指定老师的所有直播ID + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_user_all_livingid?access_token=ACCESS_TOKEN + * + * @param userId the user id + * @param cursor the cursor + * @param limit the limit + * @return user all living id + * @throws WxErrorException the wx error exception + */ + WxCpLivingResult.LivingIdResult getUserAllLivingId(String userId, String cursor, Integer limit) throws WxErrorException; + + /** + * 获取观看直播统计 + * 通过该接口可以获取所有观看直播的人员统计 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_watch_stat?access_token=ACCESS_TOKEN + * + * @param livingId the living id + * @param nextKey the next key + * @return watch stat + * @throws WxErrorException the wx error exception + */ + WxCpSchoolWatchStat getWatchStat(String livingId, String nextKey) throws WxErrorException; + + /** + * 获取未观看直播统计 + * 通过该接口可以获取未观看直播的学生统计,学生的家长必须是已经关注「学校通知」才会纳入统计范围。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_unwatch_stat?access_token=ACCESS_TOKEN + * + * @param livingId the living id + * @param nextKey the next key + * @return unwatch stat + * @throws WxErrorException the wx error exception + */ + WxCpSchoolUnwatchStat getUnwatchStat(String livingId, String nextKey) throws WxErrorException; + + /** + * 删除直播回放 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/delete_replay_data?access_token=ACCESS_TOKEN + * + * @param livingId the living id + * @return wx cp living result + * @throws WxErrorException the wx error exception + */ + WxCpLivingResult deleteReplayData(String livingId) throws WxErrorException; + +} 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 new file mode 100644 index 0000000000..26cfe3a019 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolUserService.java @@ -0,0 +1,366 @@ +package me.chanjar.weixin.cp.api; + +import lombok.NonNull; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo; +import me.chanjar.weixin.cp.bean.school.user.*; + +import java.util.List; + +/** + * 企业微信家校沟通相关接口. + * https://developer.work.weixin.qq.com/document/path/91638 + * + * @author Wang_Wong created on : 2022/6/18 9:10 + */ +public interface WxCpSchoolUserService { + + /** + * 获取访问用户身份 + * 该接口用于根据code获取成员信息 + *

+ * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE + * + * @param code the code + * @return user info + * @throws WxErrorException the wx error exception + */ + WxCpOauth2UserInfo getUserInfo(@NonNull String code) throws WxErrorException; + + /** + * 获取家校访问用户身份 + * 该接口用于根据code获取家长或者学生信息 + *

+ * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE + * + * @param code the code + * @return school user info + * @throws WxErrorException the wx error exception + */ + WxCpOauth2UserInfo getSchoolUserInfo(@NonNull String code) throws WxErrorException; + + /** + * 创建学生 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/create_student?access_token=ACCESS_TOKEN + * + * @param studentUserId the student user id + * @param name the name + * @param departments the departments + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp createStudent(@NonNull String studentUserId, @NonNull String name, @NonNull List departments) throws WxErrorException; + + /** + * 批量创建学生 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_create_student?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp batch result list + * @throws WxErrorException the wx error exception + */ + WxCpBatchResultList batchCreateStudent(@NonNull WxCpBatchCreateStudentRequest request) throws WxErrorException; + + /** + * 批量删除学生 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_delete_student?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp batch result list + * @throws WxErrorException the wx error exception + */ + WxCpBatchResultList batchDeleteStudent(@NonNull WxCpBatchDeleteStudentRequest request) throws WxErrorException; + + /** + * 批量更新学生 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_update_student?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp batch result list + * @throws WxErrorException the wx error exception + */ + WxCpBatchResultList batchUpdateStudent(@NonNull WxCpBatchUpdateStudentRequest request) throws WxErrorException; + + /** + * 删除学生 + * 请求方式:GET(HTTPS) + * 请求地址: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 + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp deleteStudent(@NonNull String studentUserId) throws WxErrorException; + + /** + * 更新学生 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/update_student?access_token=ACCESS_TOKEN + * + * @param studentUserId the student user id + * @param newStudentUserId the new student user id + * @param name the name + * @param departments the departments + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserId, String name, + List departments) throws WxErrorException; + + /** + * 创建家长 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/create_parent?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp createParent(@NonNull WxCpCreateParentRequest request) throws WxErrorException; + + /** + * 批量创建家长 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_create_parent?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp batch result list + * @throws WxErrorException the wx error exception + */ + WxCpBatchResultList batchCreateParent(@NonNull WxCpBatchCreateParentRequest request) throws WxErrorException; + + /** + * 批量删除家长 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_delete_parent?access_token=ACCESS_TOKEN + * + * @param userIdList the user id list + * @return wx cp batch result list + * @throws WxErrorException the wx error exception + */ + WxCpBatchResultList batchDeleteParent(@NonNull String... userIdList) throws WxErrorException; + + /** + * 批量更新家长 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_update_parent?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp batch result list + * @throws WxErrorException the wx error exception + */ + WxCpBatchResultList batchUpdateParent(@NonNull WxCpBatchUpdateParentRequest request) throws WxErrorException; + + /** + * 读取学生或家长 + * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get?access_token=ACCESS_TOKEN&userid=USERID + * + * @param userId the user id + * @return user + * @throws WxErrorException the wx error exception + */ + WxCpUserResult getUser(@NonNull String userId) throws WxErrorException; + + /** + * 获取部门成员详情 + * 请求方式:GET(HTTPS) + * 请求地址: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:是否递归获取子部门下面的成员 + * @return user list + * @throws WxErrorException the wx error exception + */ + WxCpUserListResult getUserList(@NonNull Integer departmentId, Integer fetchChild) throws WxErrorException; + + /** + * 获取部门家长详情 + * 请求方式:GET(HTTPS) + * 请求地址: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 + * @throws WxErrorException the wx error exception + */ + WxCpListParentResult getUserListParent(@NonNull Integer departmentId) throws WxErrorException; + + /** + * 更新家长 + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/update_parent?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp updateParent(@NonNull WxCpUpdateParentRequest request) throws WxErrorException; + + /** + * 删除家长 + * 请求方式:GET(HTTPS) + * 请求地址: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 + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp deleteParent(@NonNull String userId) throws WxErrorException; + + /** + * 设置家校通讯录自动同步模式 + * 企业和第三方可通过此接口修改家校通讯录与班级标签之间的自动同步模式,注意,一旦设置禁止自动同步,将无法再次开启。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/set_arch_sync_mode?access_token=ACCESS_TOKEN + * + * @param archSyncMode 家校通讯录同步模式:1-禁止将标签同步至家校通讯录,2-禁止将家校通讯录同步至标签,3-禁止家校通讯录和标签相互同步 + * @return arch sync mode + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp setArchSyncMode(@NonNull Integer archSyncMode) throws WxErrorException; + + /** + * 创建部门 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/create?access_token=ACCESS_TOKEN + * + * @param request 请求参数对象 + * @return wx cp create department + * @throws WxErrorException the wx error exception + */ + WxCpCreateDepartment createDepartment(@NonNull WxCpCreateDepartmentRequest request) throws WxErrorException; + + /** + * 更新部门 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/update?access_token=ACCESS_TOKEN + * + * @param request the request + * @return wx cp base resp + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp updateDepartment(@NonNull WxCpUpdateDepartmentRequest request) throws WxErrorException; + + /** + * 删除部门 + * 请求方式:GET(HTTPS) + * 请求地址: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 + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp deleteDepartment(Integer id) throws WxErrorException; + + /** + * 设置关注「学校通知」的模式 + * 可通过此接口修改家长关注「学校通知」的模式:“可扫码填写资料加入”或“禁止扫码填写资料加入” + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/set_subscribe_mode?access_token=ACCESS_TOKEN + * + * @param subscribeMode 关注模式, 1:可扫码填写资料加入, 2:禁止扫码填写资料加入 + * @return subscribe mode + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp setSubscribeMode(@NonNull Integer subscribeMode) throws WxErrorException; + + /** + * 获取关注「学校通知」的模式 + * 可通过此接口获取家长关注「学校通知」的模式:“可扫码填写资料加入”或“禁止扫码填写资料加入” + *

+ * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_subscribe_mode?access_token=ACCESS_TOKEN + * + * @return subscribe mode + * @throws WxErrorException the wx error exception + */ + Integer getSubscribeMode() throws WxErrorException; + + /** + * 获取外部联系人详情 + * 学校可通过此接口,根据外部联系人的userid(如何获取?),拉取外部联系人详情。 + *

+ * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid + * =EXTERNAL_USERID + * + * @param externalUserId 外部联系人的userid,注意不是学校成员的帐号 + * @return external contact + * @throws WxErrorException the wx error exception + */ + WxCpExternalContact getExternalContact(@NonNull String externalUserId) throws WxErrorException; + + /** + * 获取可使用的家长范围 + * 获取可在微信「学校通知-学校应用」使用该应用的家长范围,以学生或部门列表的形式返回。应用只能给该列表下的家长发送「学校通知」。注意该范围只能由学校的系统管理员在「管理端-家校沟通-配置」配置。 + *

+ * 请求方式:GET(HTTPS) + * 请求地址: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 + * @throws WxErrorException the wx error exception + */ + WxCpAllowScope getAllowScope(@NonNull Integer agentId) throws WxErrorException; + + /** + * 外部联系人openid转换 + * 企业和服务商可通过此接口,将微信外部联系人的userid(如何获取?)转为微信openid,用于调用支付相关接口。暂不支持企业微信外部联系人(ExternalUserid为wo开头)的userid转openid。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/convert_to_openid?access_token=ACCESS_TOKEN + * + * @param externalUserId the external user id + * @return string + * @throws WxErrorException the wx error exception + */ + String convertToOpenId(@NonNull String externalUserId) throws WxErrorException; + + /** + * 获取部门列表 + * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/list?access_token=ACCESS_TOKEN&id=ID + * + * @param id the id + * @return wx cp department list + * @throws WxErrorException the wx error exception + */ + WxCpDepartmentList listDepartment(Integer id) throws WxErrorException; + + /** + * 获取「学校通知」二维码 + * 学校可通过此接口获取「学校通知」二维码,家长可通过扫描此二维码关注「学校通知」并接收学校推送的消息。 + * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_subscribe_qr_code?access_token=ACCESS_TOKEN + * + * @return subscribe qr code + * @throws WxErrorException the wx error exception + */ + WxCpSubscribeQrCode getSubscribeQrCode() throws WxErrorException; + + /** + * 修改自动升年级的配置 + * 请求方式: POST(HTTPS) + * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/set_upgrade_info?access_token=ACCESS_TOKEN + * + * @param upgradeTime the upgrade time + * @param upgradeSwitch the upgrade switch + * @return upgrade info + * @throws WxErrorException the wx error exception + */ + WxCpSetUpgradeInfo setUpgradeInfo(Long upgradeTime, Integer upgradeSwitch) throws WxErrorException; + +} 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 345b3bb344..4accc2f60b 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 @@ -8,6 +8,7 @@ import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature; import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; import me.chanjar.weixin.cp.bean.WxCpProviderToken; import me.chanjar.weixin.cp.config.WxCpConfigStorage; @@ -37,7 +38,7 @@ public interface WxCpService extends WxService { * * @return the access token * @throws WxErrorException the wx error exception - * @see #getAccessToken(boolean) #getAccessToken(boolean)#getAccessToken(boolean) + * @see #getAccessToken(boolean) #getAccessToken(boolean)#getAccessToken(boolean)#getAccessToken(boolean) */ String getAccessToken() throws WxErrorException; @@ -61,7 +62,7 @@ public interface WxCpService extends WxService { * * @return the jsapi ticket * @throws WxErrorException the wx error exception - * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean) + * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean)#getJsapiTicket(boolean) */ String getJsapiTicket() throws WxErrorException; @@ -88,7 +89,7 @@ public interface WxCpService extends WxService { * * @return the agent jsapi ticket * @throws WxErrorException the wx error exception - * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean) + * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean)#getJsapiTicket(boolean) */ String getAgentJsapiTicket() throws WxErrorException; @@ -124,6 +125,18 @@ public interface WxCpService extends WxService { */ WxJsapiSignature createJsapiSignature(String url) throws WxErrorException; + /** + *

+   *   创建调用wx.agentConfig时所需要的签名
+   *
+   * 详情请见:https://open.work.weixin.qq.com/api/doc/90000/90136/94313
+   * 
+ * + * @param url url + * @return the agent jsapi signature + * @throws WxErrorException the wx error exception + */ + WxCpAgentJsapiSignature createAgentJsapiSignature(String url) throws WxErrorException; /** * 小程序登录凭证校验 @@ -250,6 +263,15 @@ public interface WxCpService extends WxService { */ String replaceParty(String mediaId) throws WxErrorException; + /** + * 上传用户列表,增量更新成员 + * + * @param mediaId 媒体id + * @return jobId 异步任务id + * @throws WxErrorException the wx error exception + */ + String syncUser(String mediaId) throws WxErrorException; + /** * 上传用户列表覆盖企业号上的用户信息 * @@ -262,11 +284,11 @@ public interface WxCpService extends WxService { /** * 获取异步任务结果 * - * @param joinId the join id + * @param jobId 异步任务id * @return the task result * @throws WxErrorException the wx error exception */ - String getTaskResult(String joinId) throws WxErrorException; + String getTaskResult(String jobId) throws WxErrorException; /** * 初始化http请求对象 @@ -289,9 +311,10 @@ public interface WxCpService extends WxService { /** * 构造扫码登录链接 - 构造独立窗口登录二维码 + * * @param redirectUri 重定向地址,需要进行UrlEncode - * @param state 用于保持请求和回调的状态,授权请求后原样带回给企业。该参数可用于防止csrf攻击(跨站请求伪造攻击),建议企业带上该参数,可设置为简单的随机数加session进行校验 - * @return . + * @param state 用于保持请求和回调的状态,授权请求后原样带回给企业。该参数可用于防止csrf攻击(跨站请求伪造攻击),建议企业带上该参数,可设置为简单的随机数加session进行校验 + * @return . string */ String buildQrConnectUrl(String redirectUri, String state); @@ -373,12 +396,61 @@ public interface WxCpService extends WxService { WxCpMessageService getMessageService(); /** - * Gets oa service. + * 获取OA相关接口的服务类对象. * * @return the oa service */ WxCpOaService getOaService(); + /** + * 获取家校应用复学码相关接口的服务类对象 + * + * @return school service + */ + WxCpSchoolService getSchoolService(); + + /** + * 获取家校沟通相关接口的服务类对象 + * + * @return school user service + */ + WxCpSchoolUserService getSchoolUserService(); + + /** + * 获取家校应用健康上报的服务类对象 + * + * @return school health service + */ + WxCpSchoolHealthService getSchoolHealthService(); + + /** + * 获取直播相关接口的服务类对象 + * + * @return the Living service + */ + WxCpLivingService getLivingService(); + + /** + * 获取OA 自建应用相关接口的服务类对象 + * + * @return oa agent service + */ + WxCpOaAgentService getOaAgentService(); + + /** + * 获取OA效率工具 微盘的服务类对象 + * + * @return oa we drive service + */ + WxCpOaWeDriveService getOaWeDriveService(); + + /** + * 获取会话存档相关接口的服务类对象 + * + * @return msg audit service + */ + WxCpMsgAuditService getMsgAuditService(); + /** * 获取日历相关接口的服务类对象 * @@ -386,6 +458,13 @@ public interface WxCpService extends WxService { */ WxCpOaCalendarService getOaCalendarService(); + /** + * 获取会议室相关接口的服务类对象 + * + * @return the oa meetingroom service + */ + WxCpOaMeetingRoomService getOaMeetingRoomService(); + /** * 获取日程相关接口的服务类对象 * @@ -407,6 +486,13 @@ public interface WxCpService extends WxService { */ WxCpAgentWorkBenchService getWorkBenchService(); + /** + * 获取微信客服服务 + * + * @return 微信客服服务 kf service + */ + WxCpKfService getKfService(); + /** * http请求对象 * @@ -456,4 +542,38 @@ public interface WxCpService extends WxService { */ void setTagService(WxCpTagService tagService); + /** + * Sets kf service. + * + * @param kfService the kf service + */ + void setKfService(WxCpKfService kfService); + + /** + * 获取异步导出服务 + * + * @return 异步导出服务 export service + */ + WxCpExportService getExportService(); + + /** + * 设置异步导出服务 + * + * @param exportService 异步导出服务 + */ + void setExportService(WxCpExportService exportService); + + /** + * 相关接口的服务类对象 + * + * @return the meeting service + */ + WxCpMeetingService getMeetingService(); + + /** + * 企业互联的服务类对象 + * + * @return + */ + WxCpCorpGroupService getCorpGroupService(); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTagService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTagService.java index 045264f7d0..4469bcc9e9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTagService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTagService.java @@ -26,7 +26,7 @@ public interface WxCpTagService { * * @param name 标签名称,长度限制为32个字以内(汉字或英文字母),标签名不可与其他标签重名。 * @param id 标签id,非负整型,指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。 - * @return 标签id + * @return 标签id string * @throws WxErrorException . */ String create(String name, Integer id) throws WxErrorException; @@ -51,7 +51,7 @@ public interface WxCpTagService { /** * 获得标签列表. * - * @return 标签列表 + * @return 标签列表 list * @throws WxErrorException . */ List listAll() throws WxErrorException; @@ -60,7 +60,7 @@ public interface WxCpTagService { * 获取标签成员. * * @param tagId 标签ID - * @return 成员列表 + * @return 成员列表 list * @throws WxErrorException . */ List listUsersByTagId(String tagId) throws WxErrorException; @@ -70,7 +70,7 @@ public interface WxCpTagService { * 对应: http://qydev.weixin.qq.com/wiki/index.php?title=管理标签 中的get接口 * * @param tagId 标签id - * @return . + * @return . wx cp tag get result * @throws WxErrorException . */ WxCpTagGetResult get(String tagId) throws WxErrorException; @@ -81,7 +81,7 @@ public interface WxCpTagService { * @param tagId 标签id * @param userIds 用户ID 列表 * @param partyIds 企业部门ID列表 - * @return . + * @return . wx cp tag add or remove users result * @throws WxErrorException . */ WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List userIds, List partyIds) throws WxErrorException; @@ -92,7 +92,7 @@ public interface WxCpTagService { * @param tagId 标签id * @param userIds 用户id列表 * @param partyIds 企业部门ID列表 - * @return . + * @return . wx cp tag add or remove users result * @throws WxErrorException . */ WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List userIds, List partyIds) throws WxErrorException; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java index 3d97cb9283..303d22f692 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.message.TemplateCardMessage; import java.util.List; @@ -8,10 +9,10 @@ *
  *  任务卡片管理接口.
  *  Created by Jeff on 2019-05-16.
+ *  Updted by HeXiao on 2022-03-09.
  * 
* - * @author Jeff - * @date 2019-05-16 + * @author Jeff created on 2019-05-16 */ public interface WxCpTaskCardService { @@ -23,9 +24,30 @@ public interface WxCpTaskCardService { * 注意: 这个方法使用WxCpConfigStorage里的agentId *
* - * @param userIds 企业的成员ID列表 - * @param taskId 任务卡片ID + * @param userIds 企业的成员ID列表 + * @param taskId 任务卡片ID * @param replaceName 替换文案 + * @throws WxErrorException the wx error exception */ void update(List userIds, String taskId, String replaceName) throws WxErrorException; + + + /** + * 更新按钮为不可点击状态 + * 详情请见https://developer.work.weixin.qq.com/document/path/94888#%E6%9B%B4%E6%96%B0%E6%8C%89%E9%92%AE%E4%B8%BA%E4%B8 + * %8D%E5%8F%AF%E7%82%B9%E5%87%BB%E7%8A%B6%E6%80%81 + * + * @param userIds 企业的成员ID列表 + * @param partyIds 企业的部门ID列表 + * @param tagIds 企业的标签ID列表 + * @param atAll 更新整个任务接收人员 + * @param responseCode 更新卡片所需要消费的code,可通过发消息接口和回调接口返回值获取,一个code只能调用一次该接口,且只能在24小时内调用 + * @param replaceName 需要更新的按钮的文案 + * @throws WxErrorException the wx error exception + */ + void updateTemplateCardButton(List userIds, List partyIds, + List tagIds, Integer atAll, String responseCode, + String replaceName) throws WxErrorException; + + void updateTemplateCardButton(TemplateCardMessage templateCardMessage) throws WxErrorException; } 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 ede813a0a5..2368386b23 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 @@ -2,9 +2,14 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpInviteResult; +import me.chanjar.weixin.cp.bean.WxCpOpenUseridToUseridResult; import me.chanjar.weixin.cp.bean.WxCpUser; +import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult; import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; +import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -128,7 +133,8 @@ public interface WxCpUserService { * * @param userId 企业内的成员id * @param agentId 非必填,整型,仅用于发红包。其它场景该参数不要填,如微信支付、企业转账、电子发票 - * @return map对象 ,可能包含以下值: - openid 企业微信成员userid对应的openid,若有传参agentid,则是针对该agentid的openid。否则是针对企业微信corpid的openid - appid 应用的appid,若请求包中不包含agentid则不返回appid。该appid在使用微信红包时会用到 + * @return map对象 ,可能包含以下值: - openid 企业微信成员userid对应的openid,若有传参agentid,则是针对该agentid的openid。否则是针对企业微信corpid的openid - + * appid 应用的appid,若请求包中不包含agentid则不返回appid。该appid在使用微信红包时会用到 * @throws WxErrorException the wx error exception */ Map userId2Openid(String userId, Integer agentId) throws WxErrorException; @@ -168,6 +174,24 @@ public interface WxCpUserService { */ String getUserId(String mobile) throws WxErrorException; + /** + *
+   *
+   * 通过邮箱获取其所对应的userid。
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/get_userid_by_email?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/95895
+   * 
+ * + * @param email 邮箱 + * @param emailType 邮箱类型:1-企业邮箱;2-个人邮箱 + * @return userid email对应的成员userid + * @throws WxErrorException . + */ + String getUserIdByEmail(String email,int emailType) throws WxErrorException; + /** * 获取外部联系人详情. *
@@ -199,4 +223,65 @@ public interface WxCpUserService {
    * @throws WxErrorException .
    */
   String getJoinQrCode(int sizeType) throws WxErrorException;
+
+  /**
+   * 
+   *
+   * 获取企业活跃成员数。
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/get_active_stat?access_token=ACCESS_TOKEN
+   *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/92714
+   * 
+ * + * @param date 具体某天的活跃人数,最长支持获取30天前数据 + * @return join_qrcode 活跃成员数 + * @throws WxErrorException . + */ + Integer getActiveStat(Date date) throws WxErrorException; + + /** + * userid转换为open_userid + * 将自建应用或代开发应用获取的userid转换为第三方应用的userid + * https://developer.work.weixin.qq.com/document/path/95603 + * + * @param useridList the userid list + * @return the WxCpUseridToOpenUseridResult + * @throws WxErrorException the wx error exception + */ + WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList useridList) throws WxErrorException; + + /** + * open_userid转换为userid + * 将代开发应用或第三方应用获取的密文open_userid转换为明文userid + *
+   * 文档地址:https://developer.work.weixin.qq.com/document/path/95884#userid%E8%BD%AC%E6%8D%A2
+   *
+   * 权限说明:
+   *
+   * 需要使用自建应用或基础应用的access_token
+   * 成员需要同时在access_token和source_agentid所对应应用的可见范围内
+   * 
+ * @param openUseridList open_userid列表,最多不超过1000个。必须是source_agentid对应的应用所获取 + * @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid + * @return the WxCpOpenUseridToUseridResult + * @throws WxErrorException the wx error exception + */ + WxCpOpenUseridToUseridResult openUseridToUserid(List openUseridList, String sourceAgentId) throws WxErrorException; + + /** + * 获取成员ID列表 + * 获取企业成员的userid与对应的部门ID列表,预计于2022年8月8号发布。若需要获取其他字段,参见「适配建议」。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token=ACCESS_TOKEN + * + * @param cursor the cursor + * @param limit the limit + * @return user list id + * @throws WxErrorException the wx error exception + */ + WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException; + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java index 0a06571c97..0d43145488 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java @@ -20,9 +20,12 @@ import me.chanjar.weixin.common.util.http.*; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.*; +import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature; import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; import me.chanjar.weixin.cp.bean.WxCpProviderToken; import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.corpgroup.service.WxCpLinkedCorpService; +import me.chanjar.weixin.cp.corpgroup.service.impl.WxCpLinkedCorpServiceImpl; import org.apache.commons.lang3.StringUtils; import java.io.File; @@ -35,26 +38,42 @@ /** * . * + * @param the type parameter + * @param

the type parameter * @author chanjarster */ @Slf4j public abstract class BaseWxCpServiceImpl implements WxCpService, RequestHttp { private WxCpUserService userService = new WxCpUserServiceImpl(this); - private WxCpChatService chatService = new WxCpChatServiceImpl(this); + private final WxCpChatService chatService = new WxCpChatServiceImpl(this); private WxCpDepartmentService departmentService = new WxCpDepartmentServiceImpl(this); private WxCpMediaService mediaService = new WxCpMediaServiceImpl(this); private WxCpMenuService menuService = new WxCpMenuServiceImpl(this); private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this); private WxCpTagService tagService = new WxCpTagServiceImpl(this); private WxCpAgentService agentService = new WxCpAgentServiceImpl(this); - private WxCpOaService oaService = new WxCpOaServiceImpl(this); - private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this); - private WxCpExternalContactService externalContactService = new WxCpExternalContactServiceImpl(this); - private WxCpGroupRobotService groupRobotService = new WxCpGroupRobotServiceImpl(this); - private WxCpMessageService messageService = new WxCpMessageServiceImpl(this); - private WxCpOaCalendarService oaCalendarService = new WxCpOaCalendarServiceImpl(this); - private WxCpOaScheduleService oaScheduleService = new WxCpOaOaScheduleServiceImpl(this); - private WxCpAgentWorkBenchService workBenchService = new WxCpAgentWorkBenchServiceImpl(this); + private final WxCpOaService oaService = new WxCpOaServiceImpl(this); + private final WxCpSchoolService schoolService = new WxCpSchoolServiceImpl(this); + private final WxCpSchoolUserService schoolUserService = new WxCpSchoolUserServiceImpl(this); + private final WxCpSchoolHealthService schoolHealthService = new WxCpSchoolHealthServiceImpl(this); + private final WxCpLivingService livingService = new WxCpLivingServiceImpl(this); + private final WxCpOaAgentService oaAgentService = new WxCpOaAgentServiceImpl(this); + private final WxCpOaWeDriveService oaWeDriveService = new WxCpOaWeDriveServiceImpl(this); + private final WxCpMsgAuditService msgAuditService = new WxCpMsgAuditServiceImpl(this); + private final WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this); + private final WxCpExternalContactService externalContactService = new WxCpExternalContactServiceImpl(this); + private final WxCpGroupRobotService groupRobotService = new WxCpGroupRobotServiceImpl(this); + private final WxCpMessageService messageService = new WxCpMessageServiceImpl(this); + private final WxCpOaCalendarService oaCalendarService = new WxCpOaCalendarServiceImpl(this); + private final WxCpOaMeetingRoomService oaMeetingRoomService = new WxCpOaMeetingRoomServiceImpl(this); + private final WxCpOaScheduleService oaScheduleService = new WxCpOaOaScheduleServiceImpl(this); + private final WxCpAgentWorkBenchService workBenchService = new WxCpAgentWorkBenchServiceImpl(this); + private WxCpKfService kfService = new WxCpKfServiceImpl(this); + + private WxCpExportService exportService = new WxCpExportServiceImpl(this); + + private final WxCpMeetingService meetingService = new WxCpMeetingServiceImpl(this); + private final WxCpCorpGroupService corpGroupService = new WxCpCorpGroupServiceImpl(this); /** * 全局的是否正在刷新access token的锁. @@ -71,6 +90,9 @@ public abstract class BaseWxCpServiceImpl implements WxCpService, RequestH */ protected final Object globalAgentJsapiTicketRefreshLock = new Object(); + /** + * The Config storage. + */ protected WxCpConfigStorage configStorage; private WxSessionManager sessionManager = new StandardSessionManager(); @@ -171,6 +193,30 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException return jsapiSignature; } + @Override + public WxCpAgentJsapiSignature createAgentJsapiSignature(String url) throws WxErrorException { + long timestamp = System.currentTimeMillis() / 1000; + String noncestr = RandomUtils.getRandomStr(); + String jsapiTicket = getAgentJsapiTicket(false); + String signature = SHA1.genWithAmple( + "jsapi_ticket=" + jsapiTicket, + "noncestr=" + noncestr, + "timestamp=" + timestamp, + "url=" + url + ); + + WxCpAgentJsapiSignature jsapiSignature = new WxCpAgentJsapiSignature(); + jsapiSignature.setTimestamp(timestamp); + jsapiSignature.setNonceStr(noncestr); + jsapiSignature.setUrl(url); + jsapiSignature.setSignature(signature); + + jsapiSignature.setCorpid(this.configStorage.getCorpId()); + jsapiSignature.setAgentid(this.configStorage.getAgentId()); + + return jsapiSignature; + } + @Override public WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorException { Map params = new HashMap<>(2); @@ -198,7 +244,8 @@ public WxCpProviderToken getProviderToken(String corpId, String providerSecret) JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("corpid", corpId); jsonObject.addProperty("provider_secret", providerSecret); - return WxCpProviderToken.fromJson(this.post(this.configStorage.getApiUrl(Tp.GET_PROVIDER_TOKEN), jsonObject.toString())); + return WxCpProviderToken.fromJson(this.post(this.configStorage.getApiUrl(Tp.GET_PROVIDER_TOKEN), + jsonObject.toString())); } @Override @@ -269,6 +316,18 @@ public T execute(RequestExecutor executor, String uri, E data) thro throw new WxRuntimeException("微信服务端异常,超出重试次数"); } + /** + * Execute internal t. + * + * @param the type parameter + * @param the type parameter + * @param executor the executor + * @param uri the uri + * @param data the data + * @param doNotAutoRefresh the do not auto refresh + * @return the t + * @throws WxErrorException the wx error exception + */ protected T executeInternal(RequestExecutor executor, String uri, E data, boolean doNotAutoRefresh) throws WxErrorException { E dataForLog = DataUtils.handleDataWithSecret(data); @@ -298,12 +357,12 @@ protected T executeInternal(RequestExecutor executor, String uri, E } if (error.getErrorCode() != 0) { - log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); throw new WxErrorException(error, e); } return null; } catch (IOException e) { - log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); throw new WxRuntimeException(e); } } @@ -379,6 +438,15 @@ public String replaceParty(String mediaId) throws WxErrorException { return post(this.configStorage.getApiUrl(BATCH_REPLACE_PARTY), jsonObject.toString()); } + @Override + public String syncUser(String mediaId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("media_id", mediaId); + String responseContent = post(this.configStorage.getApiUrl(BATCH_SYNC_USER), jsonObject.toString()); + JsonObject tmpJson = GsonParser.parse(responseContent); + return tmpJson.get("jobid").getAsString(); + } + @Override public String replaceUser(String mediaId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); @@ -387,22 +455,33 @@ public String replaceUser(String mediaId) throws WxErrorException { } @Override - public String getTaskResult(String joinId) throws WxErrorException { - String url = this.configStorage.getApiUrl(BATCH_GET_RESULT + joinId); + public String getTaskResult(String jobId) throws WxErrorException { + String url = this.configStorage.getApiUrl(BATCH_GET_RESULT + jobId); return get(url, null); } @Override public String buildQrConnectUrl(String redirectUri, String state) { - return String.format("https://open.work.weixin.qq.com/wwopen/sso/qrConnect?appid=%s&agentid=%s&redirect_uri=%s&state=%s", + return String.format("https://open.work.weixin.qq.com/wwopen/sso/qrConnect?appid=%s&agentid=%s&redirect_uri=%s" + + "&state=%s", this.configStorage.getCorpId(), this.configStorage.getAgentId(), URIUtil.encodeURIComponent(redirectUri), StringUtils.trimToEmpty(state)); } + /** + * Gets tmp dir file. + * + * @return the tmp dir file + */ public File getTmpDirFile() { return this.tmpDirFile; } + /** + * Sets tmp dir file. + * + * @param tmpDirFile the tmp dir file + */ public void setTmpDirFile(File tmpDirFile) { this.tmpDirFile = tmpDirFile; } @@ -452,11 +531,51 @@ public WxCpOaService getOaService() { return oaService; } + @Override + public WxCpSchoolService getSchoolService() { + return schoolService; + } + + @Override + public WxCpSchoolUserService getSchoolUserService() { + return schoolUserService; + } + + @Override + public WxCpSchoolHealthService getSchoolHealthService() { + return schoolHealthService; + } + + @Override + public WxCpLivingService getLivingService() { + return livingService; + } + + @Override + public WxCpOaAgentService getOaAgentService() { + return oaAgentService; + } + + @Override + public WxCpOaWeDriveService getOaWeDriveService() { + return oaWeDriveService; + } + + @Override + public WxCpMsgAuditService getMsgAuditService() { + return msgAuditService; + } + @Override public WxCpOaCalendarService getOaCalendarService() { return this.oaCalendarService; } + @Override + public WxCpOaMeetingRoomService getOaMeetingRoomService() { + return this.oaMeetingRoomService; + } + @Override public WxCpGroupRobotService getGroupRobotService() { return groupRobotService; @@ -517,6 +636,11 @@ public WxCpMessageService getMessageService() { return this.messageService; } + /** + * Sets agent service. + * + * @param agentService the agent service + */ public void setAgentService(WxCpAgentService agentService) { this.agentService = agentService; } @@ -525,4 +649,35 @@ public void setAgentService(WxCpAgentService agentService) { public WxCpOaScheduleService getOaScheduleService() { return this.oaScheduleService; } + + @Override + public WxCpKfService getKfService() { + return kfService; + } + + @Override + public void setKfService(WxCpKfService kfService) { + this.kfService = kfService; + } + + + @Override + public WxCpExportService getExportService() { + return exportService; + } + + @Override + public void setExportService(WxCpExportService exportService) { + this.exportService = exportService; + } + + @Override + public WxCpMeetingService getMeetingService() { + return meetingService; + } + + @Override + public WxCpCorpGroupService getCorpGroupService() { + return corpGroupService; + } } 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 4dd661fbf0..81628fed82 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 @@ -3,6 +3,7 @@ import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; @@ -46,7 +47,7 @@ public void set(WxCpAgent agentInfo) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_SET); String responseContent = this.mainService.post(url, agentInfo.toJson()); JsonObject jsonObject = GsonParser.parse(responseContent); - if (jsonObject.get("errcode").getAsInt() != 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP)); } } @@ -56,7 +57,7 @@ public List list() throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_LIST); String responseContent = this.mainService.get(url, null); JsonObject jsonObject = GsonParser.parse(responseContent); - if (jsonObject.get("errcode").getAsInt() != 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP)); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchServiceImpl.java index 8c778197ce..bb5c191e96 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchServiceImpl.java @@ -7,14 +7,13 @@ import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpAgentWorkBench; -import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.WorkBench.WORKBENCH_DATA_SET; -import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.WorkBench.WORKBENCH_TEMPLATE_GET; -import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.WorkBench.WORKBENCH_TEMPLATE_SET; +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.WorkBench.*; /** + * 工作台自定义展示实现 + * * @author songshiyu - * @date : create in 11:24 2020/9/28 - * @description: 工作台自定义展示实现 + * created at 11:24 2020/9/28 */ @RequiredArgsConstructor public class WxCpAgentWorkBenchServiceImpl implements WxCpAgentWorkBenchService { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java index 7783422af9..c47785f6e5 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java @@ -6,8 +6,8 @@ import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.cp.api.WxCpChatService; import me.chanjar.weixin.cp.api.WxCpService; -import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; import me.chanjar.weixin.cp.bean.WxCpChat; +import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import org.apache.commons.lang3.StringUtils; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java new file mode 100644 index 0000000000..be754f229b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpCorpGroupService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorp; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpListAppShareInfoResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.LIST_SHARE_APP_INFO; + +/** + * 企业互联相关接口实现类 + * + * @author libo <422423229@qq.com> + * Created on 27/2/2023 9:57 PM + */ +@RequiredArgsConstructor +public class WxCpCorpGroupServiceImpl implements WxCpCorpGroupService { + private final WxCpService cpService; + + @Override + public List listAppShareInfo(Integer agentId, Integer businessType, String corpId, + Integer limit, String cursor) throws WxErrorException { + final String url = this.cpService.getWxCpConfigStorage().getApiUrl(LIST_SHARE_APP_INFO); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("agentid", agentId); + jsonObject.addProperty("corpid", corpId); + jsonObject.addProperty("business_type", businessType); + jsonObject.addProperty("limit", limit); + jsonObject.addProperty("cursor", cursor); + String responseContent = this.cpService.post(url, jsonObject); + JsonObject tmpJson = GsonParser.parse(responseContent); + + return WxCpGsonBuilder.create().fromJson(tmpJson.get("corp_list"), + new TypeToken>() { + }.getType() + ); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImpl.java index 3a5ef87985..b6d9cf29b1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImpl.java @@ -35,6 +35,18 @@ public Long create(WxCpDepart depart) throws WxErrorException { return GsonHelper.getAsLong(tmpJsonObject.get("id")); } + @Override + public WxCpDepart get(Long id) throws WxErrorException { + String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_GET), id); + String responseContent = this.mainService.get(url, null); + JsonObject tmpJsonObject = GsonParser.parse(responseContent); + return WxCpGsonBuilder.create() + .fromJson(tmpJsonObject.get("department"), + new TypeToken() { + }.getType() + ); + } + @Override public void update(WxCpDepart group) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_UPDATE); @@ -62,4 +74,20 @@ public List list(Long id) throws WxErrorException { }.getType() ); } + + @Override + public List simpleList(Long id) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_SIMPLE_LIST); + if (id != null) { + url += "?id=" + id; + } + + String responseContent = this.mainService.get(url, null); + JsonObject tmpJsonObject = GsonParser.parse(responseContent); + return WxCpGsonBuilder.create() + .fromJson(tmpJsonObject.get("department_id"), + new TypeToken>() { + }.getType() + ); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExportServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExportServiceImpl.java new file mode 100644 index 0000000000..638dd4e1c3 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExportServiceImpl.java @@ -0,0 +1,58 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpExportService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.export.WxCpExportRequest; +import me.chanjar.weixin.cp.bean.export.WxCpExportResult; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Export.*; + +/** + * 异步导出接口 + * + * @author zhongjun created on 2022/4/21 + */ +@RequiredArgsConstructor +public class WxCpExportServiceImpl implements WxCpExportService { + + private final WxCpService mainService; + + @Override + public String simpleUser(WxCpExportRequest params) throws WxErrorException { + return export(SIMPLE_USER, params); + } + + @Override + public String user(WxCpExportRequest params) throws WxErrorException { + return export(USER, params); + } + + @Override + public String department(WxCpExportRequest params) throws WxErrorException { + return export(DEPARTMENT, params); + } + + @Override + public String tagUser(WxCpExportRequest params) throws WxErrorException { + return export(TAG_USER, params); + } + + @Override + public WxCpExportResult getResult(String jobId) throws WxErrorException { + String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_RESULT), jobId); + String responseContent = this.mainService.get(url, null); + return WxCpGsonBuilder.create().fromJson(responseContent, WxCpExportResult.class); + } + + private String export(String path, WxCpExportRequest params) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(path); + String responseContent = this.mainService.post(url, params.toJson()); + JsonObject tmpJson = GsonParser.parse(responseContent); + return tmpJson.get("jobid").getAsString(); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java index d4b4e7db48..bef01ca777 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java @@ -2,79 +2,69 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; -import lombok.NonNull; import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxCpErrorMsgEnum; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.BeanUtils; +import me.chanjar.weixin.common.util.fs.FileUtils; +import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; +import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpExternalContactService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; -import me.chanjar.weixin.cp.bean.external.WxCpContactWayInfo; -import me.chanjar.weixin.cp.bean.external.WxCpContactWayResult; -import me.chanjar.weixin.cp.bean.external.WxCpMsgTemplate; -import me.chanjar.weixin.cp.bean.external.WxCpMsgTemplateAddResult; -import me.chanjar.weixin.cp.bean.external.WxCpUpdateRemarkRequest; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactList; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatInfo; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatList; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatStatistic; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatTransferResp; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalTagGroupInfo; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalTagGroupList; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalUnassignList; -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalUserBehaviorStatistic; -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferCustomerReq; -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferCustomerResp; -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferResultResp; -import me.chanjar.weixin.cp.bean.external.WxCpUserWithExternalPermission; -import me.chanjar.weixin.cp.bean.external.WxCpWelcomeMsg; -import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo; -import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; +import me.chanjar.weixin.cp.bean.external.*; +import me.chanjar.weixin.cp.bean.external.acquisition.*; +import me.chanjar.weixin.cp.bean.external.contact.*; +import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule; +import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.UUID; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*; /** - * @author 曹祖鹏 & yuanqixun + * The type Wx cp external contact service. + * + * @author 曹祖鹏 & yuanqixun & Mr.Pan & Wang_Wong */ @RequiredArgsConstructor public class WxCpExternalContactServiceImpl implements WxCpExternalContactService { private final WxCpService mainService; @Override - public WxCpContactWayResult addContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException { + public WxCpContactWayResult addContactWay(WxCpContactWayInfo info) throws WxErrorException { if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) { throw new WxRuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)"); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY); - String responseContent = this.mainService.post(url, info.getContactWay().toJson()); - return WxCpContactWayResult.fromJson(responseContent); + return WxCpContactWayResult.fromJson(this.mainService.post(url, info.getContactWay().toJson())); } @Override - public WxCpContactWayInfo getContactWay(@NonNull String configId) throws WxErrorException { + public WxCpContactWayInfo getContactWay(String configId) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("config_id", configId); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_WAY); - String responseContent = this.mainService.post(url, json.toString()); - return WxCpContactWayInfo.fromJson(responseContent); + return WxCpContactWayInfo.fromJson(this.mainService.post(url, json.toString())); } @Override - public WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException { + public WxCpBaseResp updateContactWay(WxCpContactWayInfo info) throws WxErrorException { if (StringUtils.isBlank(info.getContactWay().getConfigId())) { throw new WxRuntimeException("更新「联系我」方式需要指定configId"); } @@ -83,24 +73,22 @@ public WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) throws Wx } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_CONTACT_WAY); - String responseContent = this.mainService.post(url, info.getContactWay().toJson()); - return WxCpBaseResp.fromJson(responseContent); + return WxCpBaseResp.fromJson(this.mainService.post(url, info.getContactWay().toJson())); } @Override - public WxCpBaseResp deleteContactWay(@NonNull String configId) throws WxErrorException { + public WxCpBaseResp deleteContactWay(String configId) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("config_id", configId); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CONTACT_WAY); - String responseContent = this.mainService.post(url, json.toString()); - return WxCpBaseResp.fromJson(responseContent); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); } @Override - public WxCpBaseResp closeTempChat(@NonNull String userId, @NonNull String externalUserId) throws WxErrorException { + public WxCpBaseResp closeTempChat(String userId, String externalUserId) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("userid", userId); @@ -108,54 +96,110 @@ public WxCpBaseResp closeTempChat(@NonNull String userId, @NonNull String extern final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CLOSE_TEMP_CHAT); - String responseContent = this.mainService.post(url, json.toString()); - return WxCpBaseResp.fromJson(responseContent); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); } @Override - public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException { - final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId); - String responseContent = this.mainService.get(url, null); - return WxCpExternalContactInfo.fromJson(responseContent); + public WxCpExternalContactInfo getExternalContact(String externalUserId) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + externalUserId); + return WxCpExternalContactInfo.fromJson(this.mainService.get(url, null)); } @Override - public WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException { - final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + userId); - String responseContent = this.mainService.get(url, null); - return WxCpExternalContactInfo.fromJson(responseContent); + public WxCpExternalContactInfo getContactDetail(String externalUserId, String cursor) throws WxErrorException { + String params = externalUserId; + if (StringUtils.isNotEmpty(cursor)) { + params = params + "&cursor=" + cursor; + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + params); + return WxCpExternalContactInfo.fromJson(this.mainService.get(url, null)); } @Override - public String convertToOpenid(@NotNull String externalUserId) throws WxErrorException { + public String convertToOpenid(String externalUserId) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("external_userid", externalUserId); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CONVERT_TO_OPENID); String responseContent = this.mainService.post(url, json.toString()); - JsonObject tmpJson = GsonParser.parse(responseContent); - return tmpJson.get("openid").getAsString(); + return GsonParser.parse(responseContent).get("openid").getAsString(); } @Override - public String unionidToExternalUserid(@NotNull String unionid) throws WxErrorException { + public String unionidToExternalUserid(String unionid, String openid) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("unionid", unionid); + if (StringUtils.isNotEmpty(openid)) { + json.addProperty("openid", openid); + } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UNIONID_TO_EXTERNAL_USERID); String responseContent = this.mainService.post(url, json.toString()); - JsonObject tmpJson = GsonParser.parse(responseContent); - return tmpJson.get("external_userid").getAsString(); + return GsonParser.parse(responseContent).get("external_userid").getAsString(); + } + + @Override + public String toServiceExternalUserid(String externalUserid) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("external_userid", externalUserid); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TO_SERVICE_EXTERNAL_USERID); + String responseContent = this.mainService.post(url, json.toString()); + return GsonParser.parse(responseContent).get("external_userid").getAsString(); + } + + @Override + public String fromServiceExternalUserid(String externalUserid, String sourceAgentId) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("external_userid", externalUserid); + json.addProperty("source_agentid", sourceAgentId); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(FROM_SERVICE_EXTERNAL_USERID); + String responseContent = this.mainService.post(url, json.toString()); + return GsonParser.parse(responseContent).get("external_userid").getAsString(); + } + + @Override + public WxCpExternalUserIdList unionidToExternalUserid3rd(String unionid, String openid, + String corpid) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("unionid", unionid); + json.addProperty("openid", openid); + if (StringUtils.isNotEmpty(corpid)) { + json.addProperty("corpid", corpid); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UNIONID_TO_EXTERNAL_USERID_3RD); + return WxCpExternalUserIdList.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpNewExternalUserIdList getNewExternalUserId(String[] externalUserIdList) throws WxErrorException { + JsonObject json = new JsonObject(); + if (ArrayUtils.isNotEmpty(externalUserIdList)) { + json.add("external_userid_list", new Gson().toJsonTree(externalUserIdList).getAsJsonArray()); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_NEW_EXTERNAL_USERID); + return WxCpNewExternalUserIdList.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpBaseResp finishExternalUserIdMigration(String corpid) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("corpid", corpid); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(FINISH_EXTERNAL_USERID_MIGRATION); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public String opengidToChatid(String opengid) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("opengid", opengid); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(OPENID_TO_CHATID); + String responseContent = this.mainService.post(url, json.toString()); + return GsonParser.parse(responseContent).get("chat_id").getAsString(); } @Override - public WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, - String cursor, - Integer limit) + public WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String cursor, Integer limit) throws WxErrorException { - final String url = - this.mainService - .getWxCpConfigStorage() - .getApiUrl(GET_CONTACT_DETAIL_BATCH); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL_BATCH); JsonObject json = new JsonObject(); json.add("userid_list", new Gson().toJsonTree(userIdList).getAsJsonArray()); if (StringUtils.isNotBlank(cursor)) { @@ -197,13 +241,15 @@ public List listFollowers() throws WxErrorException { } @Override - public WxCpUserExternalUnassignList listUnassignedList(Integer pageIndex, Integer pageSize) throws WxErrorException { + public WxCpUserExternalUnassignList listUnassignedList(Integer pageIndex, String cursor, Integer pageSize) throws WxErrorException { JsonObject json = new JsonObject(); - json.addProperty("page_id", pageIndex == null ? 0 : pageIndex); - json.addProperty("page_size", pageSize == null ? 100 : pageSize); + if (pageIndex != null) { + json.addProperty("page_id", pageIndex); + } + json.addProperty("cursor", StringUtils.isEmpty(cursor) ? "" : cursor); + json.addProperty("page_size", pageSize == null ? 1000 : pageSize); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_UNASSIGNED_CONTACT); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalUnassignList.fromJson(result); + return WxCpUserExternalUnassignList.fromJson(this.mainService.post(url, json.toString())); } @Override @@ -213,8 +259,7 @@ public WxCpBaseResp transferExternalContact(String externalUserid, String handOv json.addProperty("handover_userid", handOverUserid); json.addProperty("takeover_userid", takeOverUserid); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_UNASSIGNED_CONTACT); - final String result = this.mainService.post(url, json.toString()); - return WxCpBaseResp.fromJson(result); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); } @Override @@ -226,37 +271,39 @@ public WxCpUserTransferCustomerResp transferCustomer(WxCpUserTransferCustomerReq } @Override - public WxCpUserTransferResultResp transferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException { + public WxCpUserTransferResultResp transferResult(String handOverUserid, String takeOverUserid, + String cursor) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("cursor", cursor); json.addProperty("handover_userid", handOverUserid); json.addProperty("takeover_userid", takeOverUserid); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_RESULT); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserTransferResultResp.fromJson(result); + return WxCpUserTransferResultResp.fromJson(this.mainService.post(url, json.toString())); } @Override - public WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException { + public WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req) + throws WxErrorException { BeanUtils.checkRequiredFields(req); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_CUSTOMER); - final String result = this.mainService.post(url, req.toJson()); - return WxCpUserTransferCustomerResp.fromJson(result); + return WxCpUserTransferCustomerResp.fromJson(this.mainService.post(url, req.toJson())); } @Override - public WxCpUserTransferResultResp resignedTransferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException { + public WxCpUserTransferResultResp resignedTransferResult(String handOverUserid, + String takeOverUserid, String cursor) + throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("cursor", cursor); json.addProperty("handover_userid", handOverUserid); json.addProperty("takeover_userid", takeOverUserid); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_RESULT); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserTransferResultResp.fromJson(result); + return WxCpUserTransferResultResp.fromJson(this.mainService.post(url, json.toString())); } @Override - public WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds, String[] partyIds) throws WxErrorException { + public WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, + String[] userIds, String[] partyIds) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("offset", pageIndex == null ? 0 : pageIndex); json.addProperty("limit", pageSize == null ? 100 : pageSize); @@ -272,8 +319,7 @@ public WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pa json.add("owner_filter", ownerFilter); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_LIST); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalGroupChatList.fromJson(result); + return WxCpUserExternalGroupChatList.fromJson(this.mainService.post(url, json.toString())); } @Override @@ -290,8 +336,7 @@ public WxCpUserExternalGroupChatList listGroupChat(Integer limit, String cursor, json.add("owner_filter", ownerFilter); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_LIST); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalGroupChatList.fromJson(result); + return WxCpUserExternalGroupChatList.fromJson(this.mainService.post(url, json.toString())); } @Override @@ -300,8 +345,7 @@ public WxCpUserExternalGroupChatInfo getGroupChat(String chatId, Integer needNam json.addProperty("chat_id", chatId); json.addProperty("need_name", needName); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_INFO); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalGroupChatInfo.fromJson(result); + return WxCpUserExternalGroupChatInfo.fromJson(this.mainService.post(url, json.toString())); } @Override @@ -312,12 +356,23 @@ public WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds, } json.addProperty("new_owner", newOwner); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_TRANSFER); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalGroupChatTransferResp.fromJson(result); + return WxCpUserExternalGroupChatTransferResp.fromJson(this.mainService.post(url, json.toString())); } @Override - public WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime, String[] userIds, String[] partyIds) throws WxErrorException { + public WxCpUserExternalGroupChatTransferResp onjobTransferGroupChat(String[] chatIds, String newOwner) throws WxErrorException { + JsonObject json = new JsonObject(); + if (ArrayUtils.isNotEmpty(chatIds)) { + json.add("chat_id_list", new Gson().toJsonTree(chatIds).getAsJsonArray()); + } + json.addProperty("new_owner", newOwner); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_ONJOB_TRANSFER); + return WxCpUserExternalGroupChatTransferResp.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime, + String[] userIds, String[] partyIds) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("start_time", startTime.getTime() / 1000); json.addProperty("end_time", endTime.getTime() / 1000); @@ -330,12 +385,13 @@ public WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date start } } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_USER_BEHAVIOR_DATA); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalUserBehaviorStatistic.fromJson(result); + return WxCpUserExternalUserBehaviorStatistic.fromJson(this.mainService.post(url, json.toString())); } @Override - public WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc, Integer pageIndex, Integer pageSize, String[] userIds, String[] partyIds) throws WxErrorException { + public WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc, + Integer pageIndex, Integer pageSize, + String[] userIds, String[] partyIds) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("day_begin_time", startTime.getTime() / 1000); json.addProperty("order_by", orderBy == null ? 1 : orderBy); @@ -353,15 +409,31 @@ public WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, json.add("owner_filter", ownerFilter); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_GROUP_CHAT_DATA); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalGroupChatStatistic.fromJson(result); + return WxCpUserExternalGroupChatStatistic.fromJson(this.mainService.post(url, json.toString())); } @Override public WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_MSG_TEMPLATE); - final String result = this.mainService.post(url, wxCpMsgTemplate.toJson()); - return WxCpMsgTemplateAddResult.fromJson(result); + return WxCpMsgTemplateAddResult.fromJson(this.mainService.post(url, wxCpMsgTemplate.toJson())); + } + + @Override + public WxCpBaseResp remindGroupMsgSend(String msgId) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("msgid", msgId); + final String url = this.mainService.getWxCpConfigStorage() + .getApiUrl(REMIND_GROUP_MSG_SEND); + return WxCpBaseResp.fromJson(this.mainService.post(url, params.toString())); + } + + @Override + public WxCpBaseResp cancelGroupMsgSend(String msgId) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("msgid", msgId); + final String url = this.mainService.getWxCpConfigStorage() + .getApiUrl(CANCEL_GROUP_MSG_SEND); + return WxCpBaseResp.fromJson(this.mainService.post(url, params.toString())); } @Override @@ -377,8 +449,7 @@ public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId) throws WxErro json.add("tag_id", new Gson().toJsonTree(tagId).getAsJsonArray()); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_TAG_LIST); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalTagGroupList.fromJson(result); + return WxCpUserExternalTagGroupList.fromJson(this.mainService.post(url, json.toString())); } @Override @@ -391,16 +462,14 @@ public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId, String[] grou json.add("group_id", new Gson().toJsonTree(groupId).getAsJsonArray()); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_TAG_LIST); - final String result = this.mainService.post(url, json.toString()); - return WxCpUserExternalTagGroupList.fromJson(result); + return WxCpUserExternalTagGroupList.fromJson(this.mainService.post(url, json.toString())); } @Override public WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CORP_TAG); - final String result = this.mainService.post(url, tagGroup.getTagGroup().toJson()); - return WxCpUserExternalTagGroupInfo.fromJson(result); + return WxCpUserExternalTagGroupInfo.fromJson(this.mainService.post(url, tagGroup.getTagGroup().toJson())); } @Override @@ -411,8 +480,7 @@ public WxCpBaseResp editCorpTag(String id, String name, Integer order) throws Wx json.addProperty("name", name); json.addProperty("order", order); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(EDIT_CORP_TAG); - final String result = this.mainService.post(url, json.toString()); - return WxCpBaseResp.fromJson(result); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); } @Override @@ -426,14 +494,11 @@ public WxCpBaseResp delCorpTag(String[] tagId, String[] groupId) throws WxErrorE } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CORP_TAG); - final String result = this.mainService.post(url, json.toString()); - return WxCpBaseResp.fromJson(result); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); } @Override public WxCpBaseResp markTag(String userid, String externalUserid, String[] addTag, String[] removeTag) throws WxErrorException { - - JsonObject json = new JsonObject(); json.addProperty("userid", userid); json.addProperty("external_userid", externalUserid); @@ -446,7 +511,345 @@ public WxCpBaseResp markTag(String userid, String externalUserid, String[] addTa } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(MARK_TAG); - final String result = this.mainService.post(url, json.toString()); - return WxCpBaseResp.fromJson(result); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpAddMomentResult addMomentTask(WxCpAddMomentTask task) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_MOMENT_TASK); + return WxCpAddMomentResult.fromJson(this.mainService.post(url, task.toJson())); + } + + @Override + public WxCpGetMomentTaskResult getMomentTaskResult(String jobId) throws WxErrorException { + String params = "&jobid=" + jobId; + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_TASK_RESULT); + return WxCpGetMomentTaskResult.fromJson(this.mainService.get(url, params)); + } + + @Override + public WxCpGetMomentList getMomentList(Long startTime, Long endTime, String creator, Integer filterType, + String cursor, Integer limit) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("start_time", startTime); + json.addProperty("end_time", endTime); + if (!StringUtils.isEmpty(creator)) { + json.addProperty("creator", creator); + } + if (filterType != null) { + json.addProperty("filter_type", filterType); + } + if (!StringUtils.isEmpty(cursor)) { + json.addProperty("cursor", cursor); + } + if (limit != null) { + json.addProperty("limit", limit); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_LIST); + return WxCpGetMomentList.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGetMomentTask getMomentTask(String momentId, String cursor, Integer limit) + throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("moment_id", momentId); + if (!StringUtils.isEmpty(cursor)) { + json.addProperty("cursor", cursor); + } + if (limit != null) { + json.addProperty("limit", limit); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_TASK); + return WxCpGetMomentTask.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGetMomentCustomerList getMomentCustomerList(String momentId, String userId, + String cursor, Integer limit) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("moment_id", momentId); + json.addProperty("userid", userId); + if (!StringUtils.isEmpty(cursor)) { + json.addProperty("cursor", cursor); + } + if (limit != null) { + json.addProperty("limit", limit); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_CUSTOMER_LIST); + return WxCpGetMomentCustomerList.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGetMomentSendResult getMomentSendResult(String momentId, String userId, + String cursor, Integer limit) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("moment_id", momentId); + json.addProperty("userid", userId); + if (!StringUtils.isEmpty(cursor)) { + json.addProperty("cursor", cursor); + } + if (limit != null) { + json.addProperty("limit", limit); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_SEND_RESULT); + return WxCpGetMomentSendResult.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGetMomentComments getMomentComments(String momentId, String userId) + throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("moment_id", momentId); + json.addProperty("userid", userId); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_COMMENTS); + return WxCpGetMomentComments.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date endTime, + String creator, Integer filterType, Integer limit, String cursor) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("chat_type", chatType); + json.addProperty("start_time", startTime.getTime() / 1000); + json.addProperty("end_time", endTime.getTime() / 1000); + json.addProperty("creator", creator); + json.addProperty("filter_type", filterType); + json.addProperty("limit", limit); + json.addProperty("cursor", cursor); + + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_LIST_V2); + return WxCpGroupMsgListResult.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGroupMsgSendResult getGroupMsgSendResult(String msgid, String userid, Integer limit, String cursor) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("msgid", msgid); + json.addProperty("userid", userid); + json.addProperty("limit", limit); + json.addProperty("cursor", cursor); + + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_SEND_RESULT); + return WxCpGroupMsgSendResult.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGroupMsgResult getGroupMsgResult(String msgid, Integer limit, String cursor) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("msgid", msgid); + json.addProperty("limit", limit); + json.addProperty("cursor", cursor); + + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_RESULT); + return WxCpGroupMsgResult.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpGroupMsgTaskResult getGroupMsgTask(String msgid, Integer limit, String cursor) throws WxErrorException { + + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_TASK); + return WxCpGroupMsgTaskResult.fromJson(this.mainService.post(url, + GsonHelper.buildJsonObject("msgid", msgid, + "limit", limit, + "cursor", cursor))); + } + + @Override + public String addGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_ADD); + final String responseContent = this.mainService.post(url, template.toJson()); + return GsonParser.parse(responseContent).get("template_id").getAsString(); + } + + @Override + public WxCpBaseResp editGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_EDIT); + return WxCpGroupWelcomeTemplateResult.fromJson(this.mainService.post(url, template.toJson())); + } + + @Override + public WxCpGroupWelcomeTemplateResult getGroupWelcomeTemplate(String templateId) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("template_id", templateId); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_GET); + return WxCpGroupWelcomeTemplateResult.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpBaseResp delGroupWelcomeTemplate(String templateId, String agentId) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("template_id", templateId); + if (!StringUtils.isEmpty(agentId)) { + json.addProperty("agentid", agentId); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_DEL); + return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpProductAlbumListResult getProductAlbumList(Integer limit, String cursor) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("limit", limit); + json.addProperty("cursor", cursor); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_PRODUCT_ALBUM_LIST); + return WxCpProductAlbumListResult.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxCpProductAlbumResult getProductAlbum(String productId) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("product_id", productId); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_PRODUCT_ALBUM); + return WxCpProductAlbumResult.fromJson(this.mainService.post(url, json.toString())); + } + + @Override + public WxMediaUploadResult uploadAttachment(String mediaType, String fileType, Integer attachmentType, + InputStream inputStream) throws WxErrorException, IOException { + return uploadAttachment(mediaType, attachmentType, FileUtils.createTmpFile(inputStream, + UUID.randomUUID().toString(), fileType)); + } + + @Override + public WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, File file) + throws WxErrorException { + String params = "?media_type=" + mediaType + "&attachment_type=" + attachmentType; + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPLOAD_ATTACHMENT + params); + return this.mainService.execute(MediaUploadRequestExecutor.create( + this.mainService.getRequestHttp()), url, file); + } + + @Override + public String addInterceptRule(WxCpInterceptRuleAddRequest ruleAddRequest) throws WxErrorException { + String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage() + .getApiUrl(ADD_INTERCEPT_RULE), ruleAddRequest); + return GsonParser.parse(responseContent).get("rule_id").getAsString(); + } + + @Override + public void updateInterceptRule(WxCpInterceptRule interceptRule) throws WxErrorException { + this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_INTERCEPT_RULE), + interceptRule); + } + + @Override + public void delInterceptRule(String ruleId) throws WxErrorException { + this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(DEL_INTERCEPT_RULE), + GsonHelper.buildJsonObject("rule_id", ruleId)); + } + + @Override + public String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_PRODUCT_ALBUM); + String responseContent = this.mainService.post(url, wxCpProductAlbumInfo.toJson()); + return GsonParser.parse(responseContent).get("product_id").getAsString(); + } + + @Override + public void updateProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_PRODUCT_ALBUM); + this.mainService.post(url, wxCpProductAlbumInfo.toJson()); + } + + @Override + public void deleteProductAlbum(String productId) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("product_id", productId); + String url = this.mainService.getWxCpConfigStorage().getApiUrl(DELETE_PRODUCT_ALBUM); + this.mainService.post(url, o.toString()); + } + + @Override + public WxCpCustomerAcquisitionList customerAcquisitionLinkList(Integer limit, String cursor) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("limit", limit); + o.addProperty("cursor", cursor); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_LIST); + return WxCpCustomerAcquisitionList.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionInfo customerAcquisitionLinkGet(String linkId) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("link_id", linkId); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_GET); + return WxCpCustomerAcquisitionInfo.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionCreateResult customerAcquisitionLinkCreate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_CREATE); + return WxCpCustomerAcquisitionCreateResult.fromJson(this.mainService.post(url, wxCpCustomerAcquisitionRequest.toJson())); + } + + @Override + public WxCpBaseResp customerAcquisitionUpdate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_UPDATE); + return WxCpBaseResp.fromJson(this.mainService.post(url, wxCpCustomerAcquisitionRequest.toJson())); + } + + @Override + public WxCpBaseResp customerAcquisitionLinkDelete(String linkId) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("link_id", linkId); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_DELETE); + return WxCpBaseResp.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionCustomerList customerAcquisitionCustomer(String linkId, Integer limit, String cursor) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("link_id", linkId); + o.addProperty("limit", limit); + o.addProperty("cursor", cursor); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_CUSTOMER); + return WxCpCustomerAcquisitionCustomerList.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_QUOTA); + return WxCpCustomerAcquisitionQuota.fromJson(this.mainService.get(url, null)); + } + + @Override + public WxCpGroupJoinWayResult addJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException { + if (wxCpGroupJoinWayInfo.getJoinWay().getChatIdList() != null && wxCpGroupJoinWayInfo.getJoinWay().getChatIdList().size() > 5) { + throw new WxRuntimeException("使用该配置的客户群ID列表,支持5个"); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_JOIN_WAY); + + return WxCpGroupJoinWayResult.fromJson(this.mainService.post(url, wxCpGroupJoinWayInfo.getJoinWay().toJson())); + } + + @Override + public WxCpBaseResp updateJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException { + if (wxCpGroupJoinWayInfo.getJoinWay().getChatIdList() != null && wxCpGroupJoinWayInfo.getJoinWay().getChatIdList().size() > 5) { + throw new WxRuntimeException("使用该配置的客户群ID列表,支持5个"); + } + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_JOIN_WAY); + return WxCpBaseResp.fromJson(this.mainService.post(url, wxCpGroupJoinWayInfo.getJoinWay().toJson())); + } + + @Override + public WxCpGroupJoinWayInfo getJoinWay(String configId) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("config_id", configId); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_JOIN_WAY); + + return WxCpGroupJoinWayInfo.fromJson(this.mainService.post(url, json)); + } + + @Override + public WxCpBaseResp delJoinWay(String configId) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("config_id", configId); + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_JOIN_WAY); + return WxCpBaseResp.fromJson(this.mainService.post(url, json)); } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImpl.java index 9661adf478..30e4474992 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImpl.java @@ -1,7 +1,6 @@ package me.chanjar.weixin.cp.api.impl; import lombok.RequiredArgsConstructor; -import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpGroupRobotService; import me.chanjar.weixin.cp.api.WxCpService; @@ -14,14 +13,11 @@ import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpConsts.GroupRobotMsgType; -import static me.chanjar.weixin.cp.constant.WxCpConsts.GroupRobotMsgType.MARKDOWN; -import static me.chanjar.weixin.cp.constant.WxCpConsts.GroupRobotMsgType.TEXT; /** * 企业微信群机器人消息发送api 实现 * - * @author yr - * @date 2020-08-20 + * @author yr created on 2020-08-20 */ @RequiredArgsConstructor public class WxCpGroupRobotServiceImpl implements WxCpGroupRobotService { @@ -59,7 +55,7 @@ public void sendNews(List articleList) throws WxErrorException { @Override public void sendText(String webhookUrl, String content, List mentionedList, List mobileList) throws WxErrorException { this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage() - .setMsgType(TEXT) + .setMsgType(GroupRobotMsgType.TEXT) .setContent(content) .setMentionedList(mentionedList) .setMentionedMobileList(mobileList) @@ -69,7 +65,7 @@ public void sendText(String webhookUrl, String content, List mentionedLi @Override public void sendMarkdown(String webhookUrl, String content) throws WxErrorException { this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage() - .setMsgType(MARKDOWN) + .setMsgType(GroupRobotMsgType.MARKDOWN) .setContent(content) .toJson()); } @@ -89,4 +85,16 @@ public void sendNews(String webhookUrl, List articleList) throws WxE .setArticles(articleList).toJson()); } + @Override + public void sendFile(String webhookUrl, String mediaId) throws WxErrorException { + this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage() + .setMsgType(GroupRobotMsgType.FILE) + .setMediaId(mediaId).toJson()); + } + + @Override + public void sendTemplateCardMessage(String webhookUrl, WxCpGroupRobotMessage wxCpGroupRobotMessage) throws WxErrorException { + this.cpService.postWithoutToken(webhookUrl, wxCpGroupRobotMessage.toJson()); + } + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java new file mode 100644 index 0000000000..29e84c516f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java @@ -0,0 +1,281 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpKfService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.kf.*; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Kf.*; + +/** + * 微信客服接口-服务实现 + * + * @author Fu created on 2022/1/19 19:41 + */ +@RequiredArgsConstructor +public class WxCpKfServiceImpl implements WxCpKfService { + private final WxCpService cpService; + private static final Gson GSON = new GsonBuilder().create(); + + @Override + public WxCpKfAccountAddResp addAccount(WxCpKfAccountAdd add) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_ADD); + String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(add)); + return WxCpKfAccountAddResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp updAccount(WxCpKfAccountUpd upd) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_UPD); + String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(upd)); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp delAccount(WxCpKfAccountDel del) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_DEL); + String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(del)); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpKfAccountListResp listAccount(Integer offset, Integer limit) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_LIST); + JsonObject json = new JsonObject(); + if (offset != null) { + json.addProperty("offset", offset); + } + if (limit != null) { + json.addProperty("limit", limit); + } + String responseContent = cpService.post(url, json.toString()); + return WxCpKfAccountListResp.fromJson(responseContent); + } + + @Override + public WxCpKfAccountLinkResp getAccountLink(WxCpKfAccountLink link) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY); + String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(link)); + return WxCpKfAccountLinkResp.fromJson(responseContent); + } + + @Override + public WxCpKfServicerOpResp addServicer(String openKfid, List userIdList) throws WxErrorException { + return servicerOp(openKfid, userIdList, SERVICER_ADD); + } + + @Override + public WxCpKfServicerOpResp delServicer(String openKfid, List userIdList) throws WxErrorException { + return servicerOp(openKfid, userIdList, SERVICER_DEL); + } + + private WxCpKfServicerOpResp servicerOp(String openKfid, List userIdList, String uri) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(uri); + + JsonObject json = new JsonObject(); + json.addProperty("open_kfid", openKfid); + JsonArray userIdArray = new JsonArray(); + userIdList.forEach(userIdArray::add); + json.add("userid_list", userIdArray); + + String responseContent = cpService.post(url, json.toString()); + return WxCpKfServicerOpResp.fromJson(responseContent); + } + + @Override + public WxCpKfServicerListResp listServicer(String openKfid) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(SERVICER_LIST + openKfid); + String responseContent = cpService.get(url, null); + return WxCpKfServicerListResp.fromJson(responseContent); + } + + @Override + public WxCpKfServiceStateResp getServiceState(String openKfid, String externalUserId) + throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(SERVICE_STATE_GET); + + JsonObject json = new JsonObject(); + json.addProperty("open_kfid", openKfid); + json.addProperty("external_userid", externalUserId); + + String responseContent = cpService.post(url, json.toString()); + return WxCpKfServiceStateResp.fromJson(responseContent); + } + + @Override + public WxCpKfServiceStateTransResp transServiceState(String openKfid, String externalUserId, + Integer serviceState, String servicerUserId) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(SERVICE_STATE_TRANS); + + JsonObject json = new JsonObject(); + json.addProperty("open_kfid", openKfid); + json.addProperty("external_userid", externalUserId); + json.addProperty("service_state", serviceState); + json.addProperty("servicer_userid", servicerUserId); + + String responseContent = cpService.post(url, json.toString()); + return WxCpKfServiceStateTransResp.fromJson(responseContent); + } + + @Override + public WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat) + throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(SYNC_MSG); + + JsonObject json = new JsonObject(); + if (cursor != null) { + json.addProperty("cursor", cursor); + } + if (token != null) { + json.addProperty("token", token); + } + if (limit != null) { + json.addProperty("limit", limit); + } + if (voiceFormat != null) { + json.addProperty("voice_format", voiceFormat); + } + + String responseContent = cpService.post(url, json); + return WxCpKfMsgListResp.fromJson(responseContent); + } + + @Override + public WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat, String openKfId) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(SYNC_MSG); + + JsonObject json = new JsonObject(); + if (cursor!=null) { + json.addProperty("cursor", cursor); + } + if (token!=null) { + json.addProperty("token", token); + } + if (limit!=null) { + json.addProperty("limit", limit); + } + if (voiceFormat!=null) { + json.addProperty("voice_format", voiceFormat); + } + if (openKfId != null) { + json.addProperty("open_kfid", openKfId); + } + + String responseContent = cpService.post(url, json); + return WxCpKfMsgListResp.fromJson(responseContent); + } + + @Override + public WxCpKfMsgSendResp sendMsg(WxCpKfMsgSendRequest request) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(SEND_MSG); + + String responseContent = cpService.post(url, GSON.toJson(request)); + + return WxCpKfMsgSendResp.fromJson(responseContent); + } + + @Override + public WxCpKfMsgSendResp sendMsgOnEvent(WxCpKfMsgSendRequest request) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(SEND_MSG_ON_EVENT); + + String responseContent = cpService.post(url, GSON.toJson(request)); + + return WxCpKfMsgSendResp.fromJson(responseContent); + } + + @Override + public WxCpKfCustomerBatchGetResp customerBatchGet(List externalUserIdList) + throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_BATCH_GET); + + JsonArray array = new JsonArray(); + + externalUserIdList.forEach(array::add); + JsonObject json = new JsonObject(); + json.add("external_userid_list", array); + String responseContent = cpService.post(url, json.toString()); + return WxCpKfCustomerBatchGetResp.fromJson(responseContent); + } + + @Override + public WxCpKfServiceUpgradeConfigResp getUpgradeServiceConfig() throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_GET_UPGRADE_SERVICE_CONFIG); + + String response = cpService.get(url, null); + return WxCpKfServiceUpgradeConfigResp.fromJson(response); + } + + @Override + public WxCpBaseResp upgradeMemberService(String openKfid, String externalUserId, + String userid, String wording) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_UPGRADE_SERVICE); + + JsonObject json = new JsonObject(); + json.addProperty("open_kfid", openKfid); + json.addProperty("external_userid", externalUserId); + json.addProperty("type", 1); + + JsonObject memberJson = new JsonObject(); + memberJson.addProperty("userid", userid); + memberJson.addProperty("wording", wording); + json.add("member", memberJson); + + String response = cpService.post(url, json); + return WxCpBaseResp.fromJson(response); + } + + @Override + public WxCpBaseResp upgradeGroupchatService(String openKfid, String externalUserId, + String chatId, String wording) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_UPGRADE_SERVICE); + + JsonObject json = new JsonObject(); + json.addProperty("open_kfid", openKfid); + json.addProperty("external_userid", externalUserId); + json.addProperty("type", 2); + + JsonObject groupchatJson = new JsonObject(); + groupchatJson.addProperty("chat_id", chatId); + groupchatJson.addProperty("wording", wording); + json.add("groupchat", groupchatJson); + + String response = cpService.post(url, json); + return WxCpBaseResp.fromJson(response); + } + + @Override + public WxCpBaseResp cancelUpgradeService(String openKfid, String externalUserId) + throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_CANCEL_UPGRADE_SERVICE); + + JsonObject json = new JsonObject(); + json.addProperty("open_kfid", openKfid); + json.addProperty("external_userid", externalUserId); + String response = cpService.post(url, json); + return WxCpBaseResp.fromJson(response); + } + + @Override + public WxCpKfGetCorpStatisticResp getCorpStatistic(WxCpKfGetCorpStatisticRequest request) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(GET_CORP_STATISTIC); + String responseContent = cpService.post(url, GSON.toJson(request)); + return WxCpKfGetCorpStatisticResp.fromJson(responseContent); + } + + @Override + public WxCpKfGetServicerStatisticResp getServicerStatistic(WxCpKfGetServicerStatisticRequest request) throws WxErrorException { + String url = cpService.getWxCpConfigStorage().getApiUrl(GET_SERVICER_STATISTIC); + String responseContent = cpService.post(url, GSON.toJson(request)); + return WxCpKfGetServicerStatisticResp.fromJson(responseContent); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java new file mode 100644 index 0000000000..b3d9e9a36e --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java @@ -0,0 +1,119 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpLivingService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.living.*; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.apache.commons.lang3.StringUtils; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Living.*; + +/** + * 企业微信直播接口实现类. + * https://developer.work.weixin.qq.com/document/path/93633 + * + * @author Wang_Wong created on 2021-12-21 + */ +@Slf4j +@RequiredArgsConstructor +public class WxCpLivingServiceImpl implements WxCpLivingService { + private final WxCpService cpService; + + @Override + public String getLivingCode(String openId, String livingId) throws WxErrorException { + final String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_CODE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("openid", openId); + jsonObject.addProperty("livingid", livingId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return GsonHelper.getString(GsonParser.parse(responseContent), "living_code"); + } + + @Override + public WxCpLivingInfo getLivingInfo(String livingId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_INFO) + livingId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpGsonBuilder.create() + .fromJson(GsonParser.parse(responseContent).get("living_info"), + new TypeToken() { + }.getType() + ); + } + + @Override + public WxCpWatchStat getWatchStat(String livingId, String nextKey) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_WATCH_STAT); + JsonObject jsonObject = new JsonObject(); + if (StringUtils.isNotBlank(nextKey)) { + jsonObject.addProperty("next_key", nextKey); + } + jsonObject.addProperty("livingid", livingId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpWatchStat.fromJson(responseContent); + } + + @Override + public WxCpLivingResult.LivingIdResult getUserAllLivingId(String userId, String cursor, Integer limit) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_ALL_LIVINGID); + JsonObject jsonObject = new JsonObject(); + if (cursor != null) { + jsonObject.addProperty("cursor", cursor); + } + if (limit != null) { + jsonObject.addProperty("limit", limit); + } + jsonObject.addProperty("userid", userId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpLivingResult.LivingIdResult.fromJson(responseContent); + } + + @Override + public WxCpLivingShareInfo getLivingShareInfo(String wwShareCode) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_SHARE_INFO); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("ww_share_code", wwShareCode); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpLivingShareInfo.fromJson(responseContent); + } + + @Override + public String livingCreate(WxCpLivingCreateRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CREATE); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return GsonHelper.getString(GsonParser.parse(responseContent), "livingid"); + } + + @Override + public WxCpLivingResult livingModify(WxCpLivingModifyRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(MODIFY); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpLivingResult.fromJson(responseContent); + } + + @Override + public WxCpLivingResult livingCancel(@NonNull String livingId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CANCEL); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("livingid", livingId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpLivingResult.fromJson(responseContent); + } + + @Override + public WxCpLivingResult deleteReplayData(@NonNull String livingId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DELETE_REPLAY_DATA); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("livingid", livingId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpLivingResult.fromJson(responseContent); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java index b83b6d39ab..7953d69e37 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java @@ -5,6 +5,8 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.InputStreamData; +import me.chanjar.weixin.common.util.http.MediaInputStreamUploadRequestExecutor; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.cp.api.WxCpMediaService; import me.chanjar.weixin.cp.api.WxCpService; @@ -12,6 +14,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.UUID; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Media.*; @@ -34,6 +38,35 @@ public WxMediaUploadResult upload(String mediaType, String fileType, InputStream return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); } + @Override + public WxMediaUploadResult upload(String mediaType, String filename, String url) throws WxErrorException, + IOException { + HttpURLConnection conn = null; + InputStream inputStream = null; + try { + URL remote = new URL(url); + conn = (HttpURLConnection) remote.openConnection(); + //设置超时间为3秒 + conn.setConnectTimeout(60 * 1000); + //防止屏蔽程序抓取而返回403错误 + conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); + inputStream = conn.getInputStream(); + return this.mainService.execute(MediaInputStreamUploadRequestExecutor.create(this.mainService.getRequestHttp()) + , this.mainService.getWxCpConfigStorage().getApiUrl(MEDIA_UPLOAD + mediaType), + new InputStreamData(inputStream, filename)); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + } + } + if (conn != null) { + conn.disconnect(); + } + } + } + @Override public WxMediaUploadResult upload(String mediaType, File file) throws WxErrorException { return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImpl.java new file mode 100644 index 0000000000..3fc9d8218f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImpl.java @@ -0,0 +1,78 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.common.collect.ImmutableMap; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpMeetingService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; + +/** + * 企业微信日程接口. + * 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。 + * 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。 + * 官方文档:https://developer.work.weixin.qq.com/document/path/93626 + * + * @author wangmeng3486 created on 2023-01-31 + */ +@RequiredArgsConstructor +public class WxCpMeetingServiceImpl implements WxCpMeetingService { + private final WxCpService cpService; + + @Override + public String create(WxCpMeeting meeting) throws WxErrorException { + return this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_ADD), + WxCpGsonBuilder.create().toJson(meeting)); + } + + @Override + public WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException { + final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_UPDATE), + WxCpGsonBuilder.create().toJson(meeting)); + return WxCpGsonBuilder.create().fromJson(response, WxCpMeetingUpdateResult.class); + } + + @Override + public void cancel(String meetingId) throws WxErrorException { + this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_CANCEL), + WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId))); + } + + @Override + public WxCpMeeting getDetail(String meetingId) throws WxErrorException { + final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_DETAIL), + WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId))); + return WxCpGsonBuilder.create().fromJson(response, WxCpMeeting.class); + } + + @Override + public WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit, + Long beginTime, Long endTime) throws WxErrorException { + final Map param = new HashMap<>(3); + param.put("userid", userId); + if (cursor != null) { + param.put("cursor", cursor); + } + if (limit != null) { + param.put("limit", limit); + } + if (beginTime != null) { + param.put("begin_time", beginTime); + } + if (endTime != null) { + param.put("end_time", endTime); + } + final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_MEETING_ID), + WxCpGsonBuilder.create().toJson(param)); + return WxCpGsonBuilder.create().fromJson(response, WxCpUserMeetingIdResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java index 9be2f60dfe..6daea8ef2f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.cp.api.impl; import com.google.common.collect.ImmutableMap; +import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpMessageService; @@ -12,8 +13,7 @@ /** * 消息推送接口实现类. * - * @author Binary Wang - * @date 2020-08-30 + * @author Binary Wang created on 2020-08-30 */ @RequiredArgsConstructor public class WxCpMessageServiceImpl implements WxCpMessageService { @@ -46,4 +46,23 @@ public WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessa return WxCpLinkedCorpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage() .getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson())); } + + @Override + public WxCpSchoolContactMessageSendResult sendSchoolContactMessage(WxCpSchoolContactMessage message) throws WxErrorException { + if (null == message.getAgentId()) { + message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId()); + } + + return WxCpSchoolContactMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage() + .getApiUrl(Message.EXTERNAL_CONTACT_MESSAGE_SEND), message.toJson())); + } + + @Override + public void recall(String msgId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("msgid", msgId); + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(Message.MESSAGE_RECALL); + this.cpService.post(apiUrl, jsonObject.toString()); + } + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMsgAuditServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMsgAuditServiceImpl.java new file mode 100644 index 0000000000..fc4f7cef64 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMsgAuditServiceImpl.java @@ -0,0 +1,269 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import com.tencent.wework.Finance; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpMsgAuditService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.msgaudit.*; +import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.function.Consumer; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.MsgAudit.*; + +/** + * 会话内容存档接口实现类. + * + * @author Wang_Wong created on 2022-01-17 + */ +@Slf4j +@RequiredArgsConstructor +public class WxCpMsgAuditServiceImpl implements WxCpMsgAuditService { + private final WxCpService cpService; + + @Override + public WxCpChatDatas getChatDatas(long seq, @NonNull long limit, String proxy, String passwd, + @NonNull long timeout) throws Exception { + String configPath = cpService.getWxCpConfigStorage().getMsgAuditLibPath(); + if (StringUtils.isEmpty(configPath)) { + throw new WxErrorException("请配置会话存档sdk文件的路径,不要配错了!!"); + } + + /** + * 完整的文件库路径: + * + * /www/osfile/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll,WeWorkFinanceSdk.dll, + * libWeWorkFinanceSdk_Java.so + */ + // 替换斜杠 + String replacePath = configPath.replace("\\", "/"); + // 获取最后一个斜杠的下标,用作分割路径 + int lastIndex = replacePath.lastIndexOf("/") + 1; + // 获取完整路径的前缀路径 + String prefixPath = replacePath.substring(0, lastIndex); + // 获取后缀的所有文件,目的遍历所有文件 + String suffixFiles = replacePath.substring(lastIndex); + + // 包含so文件 + String[] libFiles = suffixFiles.split(","); + if (libFiles.length <= 0) { + throw new WxErrorException("请仔细配置会话存档文件路径!!"); + } + + List libList = Arrays.asList(libFiles); + // 判断windows系统会话存档sdk中dll的加载,因为会互相依赖所以是有顺序的,否则会导致无法加载sdk #2598 + List osLib = new LinkedList(); + List fileLib = new ArrayList(); + libList.stream().forEach(s -> { + if (s.contains("lib")) { + osLib.add(s); + } else { + fileLib.add(s); + } + }); + osLib.addAll(fileLib); + + Finance.loadingLibraries(osLib, prefixPath); + long sdk = Finance.NewSdk(); + //因为会话存档单独有个secret,优先使用会话存档的secret + String msgAuditSecret = cpService.getWxCpConfigStorage().getMsgAuditSecret(); + if (StringUtils.isEmpty(msgAuditSecret)) { + msgAuditSecret = cpService.getWxCpConfigStorage().getCorpSecret(); + } + long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(), msgAuditSecret); + if (ret != 0) { + Finance.DestroySdk(sdk); + throw new WxErrorException("init sdk err ret " + ret); + } + + long slice = Finance.NewSlice(); + ret = Finance.GetChatData(sdk, seq, limit, proxy, passwd, timeout, slice); + if (ret != 0) { + Finance.FreeSlice(slice); + Finance.DestroySdk(sdk); + throw new WxErrorException("getchatdata err ret " + ret); + } + + // 拉取会话存档 + String content = Finance.GetContentFromSlice(slice); + Finance.FreeSlice(slice); + WxCpChatDatas chatDatas = WxCpChatDatas.fromJson(content); + if (chatDatas.getErrCode().intValue() != 0) { + Finance.DestroySdk(sdk); + throw new WxErrorException(chatDatas.toJson()); + } + + chatDatas.setSdk(sdk); + return chatDatas; + } + + @Override + public WxCpChatModel getDecryptData(@NonNull long sdk, @NonNull WxCpChatDatas.WxCpChatData chatData, + @NonNull Integer pkcs1) throws Exception { + String plainText = this.decryptChatData(sdk, chatData, pkcs1); + return WxCpChatModel.fromJson(plainText); + } + + /** + * Decrypt chat data string. + * + * @param sdk the sdk + * @param chatData the chat data + * @param pkcs1 the pkcs 1 + * @return the string + * @throws Exception the exception + */ + public String decryptChatData(long sdk, WxCpChatDatas.WxCpChatData chatData, Integer pkcs1) throws Exception { + /** + * 企业获取的会话内容,使用企业自行配置的消息加密公钥进行加密,企业可用自行保存的私钥解开会话内容数据。 + * msgAuditPriKey 会话存档私钥不能为空 + */ + String priKey = cpService.getWxCpConfigStorage().getMsgAuditPriKey(); + if (StringUtils.isEmpty(priKey)) { + throw new WxErrorException("请配置会话存档私钥【msgAuditPriKey】"); + } + + String decryptByPriKey = WxCpCryptUtil.decryptPriKey(chatData.getEncryptRandomKey(), priKey, pkcs1); + /** + * 每次使用DecryptData解密会话存档前需要调用NewSlice获取一个slice,在使用完slice中数据后,还需要调用FreeSlice释放。 + */ + long msg = Finance.NewSlice(); + + /** + * 解密会话存档内容 + * sdk不会要求用户传入rsa私钥,保证用户会话存档数据只有自己能够解密。 + * 此处需要用户先用rsa私钥解密encrypt_random_key后,作为encrypt_key参数传入sdk来解密encrypt_chat_msg获取会话存档明文。 + */ + int ret = Finance.DecryptData(sdk, decryptByPriKey, chatData.getEncryptChatMsg(), msg); + if (ret != 0) { + Finance.FreeSlice(msg); + Finance.DestroySdk(sdk); + throw new WxErrorException("msg err ret " + ret); + } + + /** + * 明文 + */ + String plainText = Finance.GetContentFromSlice(msg); + Finance.FreeSlice(msg); + return plainText; + } + + @Override + public String getChatPlainText(@NonNull long sdk, WxCpChatDatas.@NonNull WxCpChatData chatData, + @NonNull Integer pkcs1) throws Exception { + return this.decryptChatData(sdk, chatData, pkcs1); + } + + @Override + public void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, + @NonNull long timeout, @NonNull String targetFilePath) throws WxErrorException { + /** + * 1、媒体文件每次拉取的最大size为512k,因此超过512k的文件需要分片拉取。 + * 2、若该文件未拉取完整,sdk的IsMediaDataFinish接口会返回0,同时通过GetOutIndexBuf接口返回下次拉取需要传入GetMediaData的indexbuf。 + * 3、indexbuf一般格式如右侧所示,”Range:bytes=524288-1048575“:表示这次拉取的是从524288到1048575的分片。单个文件首次拉取填写的indexbuf + * 为空字符串,拉取后续分片时直接填入上次返回的indexbuf即可。 + */ + File targetFile = new File(targetFilePath); + if (!targetFile.getParentFile().exists()) { + targetFile.getParentFile().mkdirs(); + } + this.getMediaFile(sdk, sdkfileid, proxy, passwd, timeout, i -> { + try { + // 大于512k的文件会分片拉取,此处需要使用追加写,避免后面的分片覆盖之前的数据。 + FileOutputStream outputStream = new FileOutputStream(targetFile, true); + outputStream.write(i); + outputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + }); + } + + @Override + public void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, @NonNull long timeout, @NonNull Consumer action) throws WxErrorException { +/** + * 1、媒体文件每次拉取的最大size为512k,因此超过512k的文件需要分片拉取。 + * 2、若该文件未拉取完整,sdk的IsMediaDataFinish接口会返回0,同时通过GetOutIndexBuf接口返回下次拉取需要传入GetMediaData的indexbuf。 + * 3、indexbuf一般格式如右侧所示,”Range:bytes=524288-1048575“:表示这次拉取的是从524288到1048575的分片。单个文件首次拉取填写的indexbuf + * 为空字符串,拉取后续分片时直接填入上次返回的indexbuf即可。 + */ + String indexbuf = ""; + int ret, data_len = 0; + log.debug("正在分片拉取媒体文件 sdkFileId为{}", sdkfileid); + while (true) { + long mediaData = Finance.NewMediaData(); + ret = Finance.GetMediaData(sdk, indexbuf, sdkfileid, proxy, passwd, timeout, mediaData); + if (ret != 0) { + Finance.FreeMediaData(mediaData); + Finance.DestroySdk(sdk); + throw new WxErrorException("getmediadata err ret " + ret); + } + + data_len += Finance.GetDataLen(mediaData); + log.info("正在分片拉取媒体文件 len:{}, data_len:{}, is_finis:{} \n", Finance.GetIndexLen(mediaData), data_len, + Finance.IsMediaDataFinish(mediaData)); + + try { + // 大于512k的文件会分片拉取,此处需要使用追加写,避免后面的分片覆盖之前的数据。 + action.accept(Finance.GetData(mediaData)); + } catch (Exception e) { + e.printStackTrace(); + } + + if (Finance.IsMediaDataFinish(mediaData) == 1) { + // 已经拉取完成最后一个分片 + Finance.FreeMediaData(mediaData); + break; + } else { + // 获取下次拉取需要使用的indexbuf + indexbuf = Finance.GetOutIndexBuf(mediaData); + Finance.FreeMediaData(mediaData); + } + } + } + + @Override + public List getPermitUserList(Integer type) throws WxErrorException { + final String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_PERMIT_USER_LIST); + JsonObject jsonObject = new JsonObject(); + if (type != null) { + jsonObject.addProperty("type", type); + } + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpGsonBuilder.create().fromJson(GsonParser.parse(responseContent).getAsJsonArray("ids"), + new TypeToken>() { + }.getType()); + } + + @Override + public WxCpGroupChat getGroupChat(@NonNull String roomid) throws WxErrorException { + final String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_GROUP_CHAT); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("roomid", roomid); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpGroupChat.fromJson(responseContent); + } + + @Override + public WxCpAgreeInfo checkSingleAgree(@NonNull WxCpCheckAgreeRequest checkAgreeRequest) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CHECK_SINGLE_AGREE); + String responseContent = this.cpService.post(apiUrl, checkAgreeRequest.toJson()); + return WxCpAgreeInfo.fromJson(responseContent); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java index 8f989f23d8..f5bd61ba97 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java @@ -67,7 +67,9 @@ public WxCpOauth2UserInfo getUserInfo(String code) throws WxErrorException { @Override public WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException { - String responseText = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_INFO), code, agentId), null); + String responseText = + this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_INFO), code, + agentId), null); JsonObject jo = GsonParser.parse(responseText); return WxCpOauth2UserInfo.builder() @@ -77,6 +79,22 @@ public WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErr .userTicket(GsonHelper.getString(jo, "user_ticket")) .expiresIn(GsonHelper.getString(jo, "expires_in")) .externalUserId(GsonHelper.getString(jo, "external_userid")) + .parentUserId(GsonHelper.getString(jo, "parent_userid")) + .studentUserId(GsonHelper.getString(jo, "student_userid")) + .build(); + } + + @Override + public WxCpOauth2UserInfo getSchoolUserInfo(String code) throws WxErrorException { + String responseText = + this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_SCHOOL_USER_INFO), + code), null); + JsonObject jo = GsonParser.parse(responseText); + + return WxCpOauth2UserInfo.builder() + .deviceId(GsonHelper.getString(jo, "DeviceId")) + .parentUserId(GsonHelper.getString(jo, "parent_userid")) + .studentUserId(GsonHelper.getString(jo, "student_userid")) .build(); } @@ -84,7 +102,8 @@ public WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErr public WxCpUserDetail getUserDetail(String userTicket) throws WxErrorException { JsonObject param = new JsonObject(); param.addProperty("user_ticket", userTicket); - String responseText = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_DETAIL), param.toString()); + String responseText = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_DETAIL), + param.toString()); return WxCpGsonBuilder.create().fromJson(responseText, WxCpUserDetail.class); } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java new file mode 100644 index 0000000000..250ee0cb24 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpOaAgentService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.GET_OPEN_APPROVAL_DATA; + +/** + * 企业微信自建应用接口实现类. + * + * @author Wang_Wong created on 2022-04-06 + */ +@Slf4j +@RequiredArgsConstructor +public class WxCpOaAgentServiceImpl implements WxCpOaAgentService { + private final WxCpService cpService; + + @Override + public WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("thirdNo", thirdNo); + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_OPEN_APPROVAL_DATA); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpGsonBuilder.create() + .fromJson(GsonParser.parse(responseContent).get("data"), + new TypeToken() { + }.getType() + ); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImpl.java index 7e604934b9..ef24204493 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImpl.java @@ -17,8 +17,7 @@ /** * . * - * @author Binary Wang - * @date 2020-09-20 + * @author Binary Wang created on 2020-09-20 */ @RequiredArgsConstructor public class WxCpOaCalendarServiceImpl implements WxCpOaCalendarService { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImpl.java new file mode 100644 index 0000000000..f486028a0a --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImpl.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.reflect.TypeToken; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpOaMeetingRoomService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; + +/** + * The type Wx cp oa meeting room service. + * + * @author fcat + * @version 1.0 Create by 2022/8/12 23:49 + */ +@RequiredArgsConstructor +public class WxCpOaMeetingRoomServiceImpl implements WxCpOaMeetingRoomService { + private final WxCpService wxCpService; + + @Override + public String addMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException { + return this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_ADD), meetingRoom); + } + + @Override + public List listMeetingRoom(WxCpOaMeetingRoom meetingRoomRequest) throws WxErrorException { + String response = this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_LIST), + meetingRoomRequest); + return WxCpGsonBuilder.create().fromJson(GsonParser.parse(response).get("meetingroom_list").getAsJsonArray().toString(), + new TypeToken>() { + }.getType()); + } + + @Override + public void editMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException { + this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_EDIT), meetingRoom); + } + + @Override + public void deleteMeetingRoom(Integer meetingRoomId) throws WxErrorException { + this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_DEL), + GsonHelper.buildJsonObject("meetingroom_id", meetingRoomId)); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaOaScheduleServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaOaScheduleServiceImpl.java index ca33f7c66c..c9a6161b2e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaOaScheduleServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaOaScheduleServiceImpl.java @@ -21,8 +21,7 @@ /** * 企业微信日程接口实现类. * - * @author Binary Wang - * @date 2020-12-25 + * @author Binary Wang created on 2020-12-25 */ @Slf4j @RequiredArgsConstructor diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java index b921798e7b..43df95f300 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java @@ -11,8 +11,10 @@ import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpOaService; import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.*; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.apache.commons.lang3.StringUtils; import java.util.Date; import java.util.List; @@ -22,14 +24,13 @@ /** * 企业微信 OA 接口实现 * - * @author Element - * @date 2019-04-06 11:20 + * @author Element created on 2019-04-06 11:20 */ @RequiredArgsConstructor public class WxCpOaServiceImpl implements WxCpOaService { private final WxCpService mainService; - private static final int MONTH_SECONDS = 30 * 24 * 60 * 60; + private static final int MONTH_SECONDS = 31 * 24 * 60 * 60; private static final int USER_IDS_LIMIT = 100; @Override @@ -40,7 +41,8 @@ public String apply(WxCpOaApplyEventRequest request) throws WxErrorException { } @Override - public List getCheckinData(Integer openCheckinDataType, @NonNull Date startTime, @NonNull Date endTime, + public List getCheckinData(Integer openCheckinDataType, @NonNull Date startTime, + @NonNull Date endTime, List userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); @@ -49,7 +51,7 @@ public List getCheckinData(Integer openCheckinDataType, @NonNul long endTimestamp = endTime.getTime() / 1000L; long startTimestamp = startTime.getTime() / 1000L; - if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp >= MONTH_SECONDS) { + if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp > MONTH_SECONDS) { throw new WxRuntimeException("获取记录时间跨度不超过一个月"); } @@ -165,6 +167,51 @@ public WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws W return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDetailResult.class); } + @Override + public WxCpCorpConfInfo getCorpConf() throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_CONF); + String responseContent = this.mainService.get(url, null); + return WxCpCorpConfInfo.fromJson(responseContent); + } + + @Override + public WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_VACATION_QUOTA); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpUserVacationQuota.fromJson(responseContent); + } + + @Override + public WxCpGetApprovalData getApprovalData(@NonNull Long startTime, @NonNull Long endTime, Long nextSpNum) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DATA); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("starttime", startTime); + jsonObject.addProperty("endtime", endTime); + if (nextSpNum != null) { + jsonObject.addProperty("next_spnum", nextSpNum); + } + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpGetApprovalData.fromJson(responseContent); + } + + @Override + public WxCpBaseResp setOneUserQuota(@NonNull String userId, @NonNull Integer vacationId, + @NonNull Integer leftDuration, @NonNull Integer timeAttr, String remarks) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SET_ONE_USER_QUOTA); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("vacation_id", vacationId); + jsonObject.addProperty("leftduration", leftDuration); + jsonObject.addProperty("time_attr", timeAttr); + if (StringUtils.isNotEmpty(remarks)) { + jsonObject.addProperty("remarks", remarks); + } + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpBaseResp.fromJson(responseContent); + } + @Override public List getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit) throws WxErrorException { @@ -204,16 +251,31 @@ public List getDialRecord(Date startTime, Date endTime, Integer } @Override - public WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException { + public WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id", templateId); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL); String responseContent = this.mainService.post(url, jsonObject.toString()); - return WxCpGsonBuilder.create().fromJson(responseContent, WxCpTemplateResult.class); + return WxCpGsonBuilder.create().fromJson(responseContent, WxCpOaApprovalTemplateResult.class); + } + + @Override + public String createOaApprovalTemplate(WxCpOaApprovalTemplate cpTemplate) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CREATE_TEMPLATE); + String responseContent = this.mainService.post(url, WxCpGsonBuilder.create().toJson(cpTemplate)); + JsonObject tmpJson = GsonParser.parse(responseContent); + return tmpJson.get("template_id").getAsString(); } @Override - public List getCheckinDayData(@NonNull Date startTime, @NonNull Date endTime, List userIdList) + public void updateOaApprovalTemplate(WxCpOaApprovalTemplate wxCpTemplate) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE); + this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpTemplate)); + } + + @Override + public List getCheckinDayData(@NonNull Date startTime, @NonNull Date endTime, + List userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); @@ -243,7 +305,8 @@ public List getCheckinDayData(@NonNull Date startTime, @NonN } @Override - public List getCheckinMonthData(@NonNull Date startTime, @NonNull Date endTime, List userIdList) + public List getCheckinMonthData(@NonNull Date startTime, @NonNull Date endTime, + List userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); @@ -273,7 +336,8 @@ public List getCheckinMonthData(@NonNull Date startTime, @ } @Override - public List getCheckinScheduleList(@NonNull Date startTime, @NonNull Date endTime, List userIdList) + public List getCheckinScheduleList(@NonNull Date startTime, @NonNull Date endTime, + List userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); @@ -308,4 +372,13 @@ public void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SET_CHECKIN_SCHEDULE_DATA); this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpSetCheckinSchedule)); } + + @Override + public void addCheckInUserFace(String userId, String userFace) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("userface", userFace); + String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CHECK_IN_USER_FACE); + this.mainService.post(url, jsonObject.toString()); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java new file mode 100644 index 0000000000..979e86e55f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java @@ -0,0 +1,205 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpOaWeDriveService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.oa.wedrive.*; + +import java.util.List; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; + +/** + * 企业微信微盘接口实现类. + * + * @author Wang_Wong created on 2022-04-22 + */ +@Slf4j +@RequiredArgsConstructor +public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService { + private final WxCpService cpService; + + @Override + public WxCpSpaceCreateData spaceCreate(@NonNull WxCpSpaceCreateRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_CREATE); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpSpaceCreateData.fromJson(responseContent); + } + + @Override + public WxCpBaseResp spaceRename(@NonNull WxCpSpaceRenameRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_RENAME); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp spaceDismiss(@NonNull String userId, @NonNull String spaceId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_DISMISS); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("spaceid", spaceId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpSpaceInfo spaceInfo(@NonNull String userId, @NonNull String spaceId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_INFO); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("spaceid", spaceId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpSpaceInfo.fromJson(responseContent); + } + + @Override + public WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_ADD); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_DEL); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp spaceSetting(@NonNull WxCpSpaceSettingRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_SETTING); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpSpaceShare spaceShare(@NonNull String userId, @NonNull String spaceId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_SHARE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("spaceid", spaceId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpSpaceShare.fromJson(responseContent); + } + + @Override + public WxCpFileList fileList(@NonNull WxCpFileListRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_LIST); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpFileList.fromJson(responseContent); + } + + @Override + public WxCpFileUpload fileUpload(@NonNull WxCpFileUploadRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_UPLOAD); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpFileUpload.fromJson(responseContent); + } + + @Override + public WxCpFileDownload fileDownload(@NonNull String userId, @NonNull String fileId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_DOWNLOAD); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("fileid", fileId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpFileDownload.fromJson(responseContent); + } + + @Override + public WxCpFileRename fileRename(@NonNull String userId, @NonNull String fileId, @NonNull String newName) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_RENAME); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("fileid", fileId); + jsonObject.addProperty("new_name", newName); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpFileRename.fromJson(responseContent); + } + + @Override + public WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId, @NonNull String fatherId, + @NonNull Integer fileType, @NonNull String fileName) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_CREATE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("spaceid", spaceId); + jsonObject.addProperty("fatherid", fatherId); + jsonObject.addProperty("file_type", fileType); + jsonObject.addProperty("file_name", fileName); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpFileCreate.fromJson(responseContent); + } + + @Override + public WxCpFileMove fileMove(@NonNull WxCpFileMoveRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_MOVE); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpFileMove.fromJson(responseContent); + } + + @Override + public WxCpBaseResp fileDelete(@NonNull String userId, @NonNull List fileId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_DELETE); + WxCpFileDeleteRequest request = new WxCpFileDeleteRequest(userId, fileId); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp fileAclAdd(@NonNull WxCpFileAclAddRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_ACL_ADD); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_ACL_DEL); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp fileSetting(@NonNull String userId, @NonNull String fileId, @NonNull Integer authScope, + Integer auth) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SETTING); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("fileid", fileId); + jsonObject.addProperty("auth_scope", authScope); + if (auth != null) { + jsonObject.addProperty("auth", auth); + } + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SHARE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("fileid", fileId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpFileShare.fromJson(responseContent); + } + + @Override + public WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_INFO); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("fileid", fileId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpFileInfo.fromJson(responseContent); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolHealthServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolHealthServiceImpl.java new file mode 100644 index 0000000000..60f379da81 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolHealthServiceImpl.java @@ -0,0 +1,76 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpSchoolHealthService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetHealthReportStat; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportAnswer; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobIds; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobInfo; + +import java.util.Optional; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*; + +/** + * 企业微信家校应用 健康上报接口实现类. + * + * @author Wang_Wong created on : 2022/5/31 9:16 + */ +@Slf4j +@RequiredArgsConstructor +public class WxCpSchoolHealthServiceImpl implements WxCpSchoolHealthService { + + private final WxCpService cpService; + + @Override + public WxCpGetHealthReportStat getHealthReportStat(@NonNull String date) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_HEALTH_REPORT_STAT); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("date", date); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpGetHealthReportStat.fromJson(responseContent); + } + + @Override + public WxCpGetReportJobIds getReportJobIds(Integer offset, Integer limit) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_REPORT_JOBIDS); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("offset", Optional.ofNullable(offset).orElse(0)); + jsonObject.addProperty("limit", Optional.ofNullable(limit).orElse(100)); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpGetReportJobIds.fromJson(responseContent); + } + + @Override + public WxCpGetReportJobInfo getReportJobInfo(@NonNull String jobId, @NonNull String date) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_REPORT_JOB_INFO); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("jobid", jobId); + jsonObject.addProperty("date", date); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpGetReportJobInfo.fromJson(responseContent); + } + + @Override + public WxCpGetReportAnswer getReportAnswer(@NonNull String jobId, @NonNull String date, Integer offset, + Integer limit) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_REPORT_ANSWER); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("jobid", jobId); + jsonObject.addProperty("date", date); + if (offset != null) { + jsonObject.addProperty("offset", offset); + } + if (limit != null) { + jsonObject.addProperty("limit", limit); + } + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpGetReportAnswer.fromJson(responseContent); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java new file mode 100644 index 0000000000..c503aebdfd --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java @@ -0,0 +1,126 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpSchoolService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.living.WxCpLivingResult; +import me.chanjar.weixin.cp.bean.school.*; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Optional; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*; + +/** + * 企业微信家校应用 复学码相关接口实现类. + * https://developer.work.weixin.qq.com/document/path/93744 + * + * @author Wang_Wong created on : 2022/6/1 14:05 + */ +@Slf4j +@RequiredArgsConstructor +public class WxCpSchoolServiceImpl implements WxCpSchoolService { + + private final WxCpService cpService; + + @Override + public WxCpCustomizeHealthInfo getTeacherCustomizeHealthInfo(String date, String nextKey, Integer limit) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_TEACHER_CUSTOMIZE_HEALTH_INFO); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("date", date); + jsonObject.addProperty("limit", Optional.ofNullable(limit).orElse(100)); + if (nextKey != null) { + jsonObject.addProperty("next_key", nextKey); + } + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpCustomizeHealthInfo.fromJson(responseContent); + } + + @Override + public WxCpCustomizeHealthInfo getStudentCustomizeHealthInfo(String date, String nextKey, Integer limit) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_STUDENT_CUSTOMIZE_HEALTH_INFO); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("date", date); + jsonObject.addProperty("limit", Optional.ofNullable(limit).orElse(100)); + if (nextKey != null) { + jsonObject.addProperty("next_key", nextKey); + } + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpCustomizeHealthInfo.fromJson(responseContent); + } + + @Override + public WxCpResultList getHealthQrCode(List userIds, Integer type) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_HEALTH_QRCODE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("type", type); + jsonObject.addProperty("userids", userIds.toString()); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpResultList.fromJson(responseContent); + } + + @Override + public WxCpPaymentResult getPaymentResult(String paymentId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_PAYMENT_RESULT); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("payment_id", paymentId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpPaymentResult.fromJson(responseContent); + } + + @Override + public WxCpTrade getTrade(String paymentId, String tradeNo) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_TRADE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("payment_id", paymentId); + jsonObject.addProperty("trade_no", tradeNo); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpTrade.fromJson(responseContent); + } + + @Override + public WxCpSchoolLivingInfo getLivingInfo(String livingId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_INFO) + livingId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpSchoolLivingInfo.fromJson(responseContent); + } + + @Override + public WxCpLivingResult.LivingIdResult getUserAllLivingId(String userId, String cursor, Integer limit) throws WxErrorException { + return this.cpService.getLivingService().getUserAllLivingId(userId, cursor, limit); + } + + @Override + public WxCpSchoolWatchStat getWatchStat(String livingId, String nextKey) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_WATCH_STAT); + JsonObject jsonObject = new JsonObject(); + if (StringUtils.isNotBlank(nextKey)) { + jsonObject.addProperty("next_key", nextKey); + } + jsonObject.addProperty("livingid", livingId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpSchoolWatchStat.fromJson(responseContent); + } + + @Override + public WxCpSchoolUnwatchStat getUnwatchStat(String livingId, String nextKey) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_UNWATCH_STAT); + JsonObject jsonObject = new JsonObject(); + if (StringUtils.isNotBlank(nextKey)) { + jsonObject.addProperty("next_key", nextKey); + } + jsonObject.addProperty("livingid", livingId); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpSchoolUnwatchStat.fromJson(responseContent); + } + + @Override + public WxCpLivingResult deleteReplayData(String livingId) throws WxErrorException { + return cpService.getLivingService().deleteReplayData(livingId); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolUserServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolUserServiceImpl.java new file mode 100644 index 0000000000..fac1689e08 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolUserServiceImpl.java @@ -0,0 +1,275 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpSchoolUserService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo; +import me.chanjar.weixin.cp.bean.school.user.*; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*; +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*; + +/** + * 企业微信家校沟通相关接口. + * https://developer.work.weixin.qq.com/document/path/91638 + * + * @author Wang_Wong created on : 2022/6/18 9:10 + */ +@Slf4j +@RequiredArgsConstructor +public class WxCpSchoolUserServiceImpl implements WxCpSchoolUserService { + + private final WxCpService cpService; + + @Override + public WxCpOauth2UserInfo getUserInfo(@NonNull String code) throws WxErrorException { + return cpService.getOauth2Service().getUserInfo(code); + } + + @Override + public WxCpOauth2UserInfo getSchoolUserInfo(@NonNull String code) throws WxErrorException { + return cpService.getOauth2Service().getSchoolUserInfo(code); + } + + @Override + public WxCpBaseResp createStudent(@NonNull String studentUserId, @NonNull String name, + @NonNull List departments) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CREATE_STUDENT); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("student_userid", studentUserId); + jsonObject.addProperty("name", name); + JsonArray jsonArray = new JsonArray(); + for (Integer depart : departments) { + jsonArray.add(new JsonPrimitive(depart)); + } + jsonObject.add("department", jsonArray); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBatchResultList batchCreateStudent(@NonNull WxCpBatchCreateStudentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_CREATE_STUDENT); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBatchResultList.fromJson(responseContent); + } + + @Override + public WxCpBatchResultList batchDeleteStudent(@NonNull WxCpBatchDeleteStudentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_DELETE_STUDENT); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBatchResultList.fromJson(responseContent); + } + + @Override + public WxCpBatchResultList batchUpdateStudent(@NonNull WxCpBatchUpdateStudentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_UPDATE_STUDENT); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBatchResultList.fromJson(responseContent); + } + + @Override + public WxCpBaseResp deleteStudent(@NonNull String studentUserId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DELETE_STUDENT) + studentUserId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserId, String name, + List departments) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(UPDATE_STUDENT); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("student_userid", studentUserId); + if (StringUtils.isNotEmpty(newStudentUserId)) { + jsonObject.addProperty("new_student_userid", newStudentUserId); + } + if (StringUtils.isNotEmpty(name)) { + jsonObject.addProperty("name", name); + } + if (departments != null && departments.size() > 0) { + JsonArray jsonArray = new JsonArray(); + for (Integer depart : departments) { + jsonArray.add(new JsonPrimitive(depart)); + } + jsonObject.add("department", jsonArray); + } + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp createParent(@NonNull WxCpCreateParentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CREATE_PARENT); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBatchResultList batchCreateParent(@NonNull WxCpBatchCreateParentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_CREATE_PARENT); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBatchResultList.fromJson(responseContent); + } + + @Override + public WxCpBatchResultList batchDeleteParent(@NonNull String... userIdList) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_DELETE_PARENT); + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + for (String userId : userIdList) { + jsonArray.add(new JsonPrimitive(userId)); + } + jsonObject.add("useridlist", jsonArray); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpBatchResultList.fromJson(responseContent); + } + + @Override + public WxCpBatchResultList batchUpdateParent(@NonNull WxCpBatchUpdateParentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_UPDATE_PARENT); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBatchResultList.fromJson(responseContent); + } + + @Override + public WxCpUserResult getUser(@NonNull String userId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER) + userId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpUserResult.fromJson(responseContent); + } + + @Override + public WxCpUserListResult getUserList(@NonNull Integer departmentId, Integer fetchChild) throws WxErrorException { + String apiUrl = String.format(this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_LIST), departmentId, + fetchChild); + String responseContent = this.cpService.get(apiUrl, null); + return WxCpUserListResult.fromJson(responseContent); + } + + @Override + public WxCpListParentResult getUserListParent(@NonNull Integer departmentId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_LIST_PARENT) + departmentId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpListParentResult.fromJson(responseContent); + } + + @Override + public WxCpBaseResp updateParent(@NonNull WxCpUpdateParentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(UPDATE_PARENT); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp deleteParent(@NonNull String userId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DELETE_PARENT) + userId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp setArchSyncMode(@NonNull Integer archSyncMode) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_ARCH_SYNC_MODE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("arch_sync_mode", archSyncMode); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpCreateDepartment createDepartment(@NonNull WxCpCreateDepartmentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_CREATE); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpCreateDepartment.fromJson(responseContent); + } + + @Override + public WxCpBaseResp updateDepartment(@NonNull WxCpUpdateDepartmentRequest request) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_UPDATE); + String responseContent = this.cpService.post(apiUrl, request.toJson()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp deleteDepartment(Integer id) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_DELETE) + id; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public WxCpBaseResp setSubscribeMode(@NonNull Integer subscribeMode) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_SUBSCRIBE_MODE); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("subscribe_mode", subscribeMode); + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpBaseResp.fromJson(responseContent); + } + + @Override + public Integer getSubscribeMode() throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_SUBSCRIBE_MODE); + String responseContent = this.cpService.get(apiUrl, null); + return GsonParser.parse(responseContent).get("subscribe_mode").getAsInt(); + } + + @Override + public WxCpExternalContact getExternalContact(@NonNull String externalUserId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(EXTERNAL_CONTACT_GET) + externalUserId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpExternalContact.fromJson(responseContent); + } + + @Override + public WxCpAllowScope getAllowScope(@NonNull Integer agentId) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_ALLOW_SCOPE) + agentId; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpAllowScope.fromJson(responseContent); + } + + @Override + public String convertToOpenId(@NonNull String externalUserId) throws WxErrorException { + return cpService.getExternalContactService().convertToOpenid(externalUserId); + } + + @Override + public WxCpDepartmentList listDepartment(Integer id) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST) + id; + String responseContent = this.cpService.get(apiUrl, null); + return WxCpDepartmentList.fromJson(responseContent); + } + + @Override + public WxCpSubscribeQrCode getSubscribeQrCode() throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_SUBSCRIBE_QR_CODE); + String responseContent = this.cpService.get(apiUrl, null); + return WxCpSubscribeQrCode.fromJson(responseContent); + } + + @Override + public WxCpSetUpgradeInfo setUpgradeInfo(Long upgradeTime, Integer upgradeSwitch) throws WxErrorException { + String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_UPGRADE_INFO); + JsonObject jsonObject = new JsonObject(); + if (upgradeTime != null) { + jsonObject.addProperty("upgrade_time", upgradeTime); + } + if (upgradeSwitch != null) { + jsonObject.addProperty("upgrade_switch", upgradeSwitch); + } + String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); + return WxCpSetUpgradeInfo.fromJson(responseContent); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java index b428bc34aa..7e69152a17 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java @@ -1,8 +1,8 @@ package me.chanjar.weixin.cp.api.impl; -import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; @@ -21,6 +21,8 @@ import java.io.IOException; /** + * The type Wx cp service apache http client. + * * @author someone */ public class WxCpServiceApacheHttpClientImpl extends BaseWxCpServiceImpl { @@ -49,7 +51,8 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { } synchronized (this.globalAccessTokenRefreshLock) { - String url = String.format(this.configStorage.getApiUrl(WxCpApiPathConsts.GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); + String url = String.format(this.configStorage.getApiUrl(WxCpApiPathConsts.GET_TOKEN), + this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); try { HttpGet httpGet = new HttpGet(url); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java index 1b53630688..ec8a3624ac 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java @@ -5,8 +5,8 @@ import jodd.http.HttpResponse; import jodd.http.ProxyInfo; import jodd.http.net.SocketHttpConnectionProvider; -import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.HttpType; @@ -14,6 +14,8 @@ import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; /** + * The type Wx cp service jodd http. + * * @author someone */ public class WxCpServiceJoddHttpImpl extends BaseWxCpServiceImpl { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java index 5fb5a73756..73b933f646 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java @@ -1,11 +1,12 @@ package me.chanjar.weixin.cp.api.impl; import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.HttpType; +import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import okhttp3.*; @@ -15,6 +16,8 @@ import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.GET_TOKEN; /** + * The type Wx cp service ok http. + * * @author someone */ @Slf4j @@ -48,7 +51,8 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { OkHttpClient client = getRequestHttpClient(); //请求的request Request request = new Request.Builder() - .url(String.format(this.configStorage.getApiUrl(GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret())) + .url(String.format(this.configStorage.getApiUrl(GET_TOKEN), this.configStorage.getCorpId(), + this.configStorage.getCorpSecret())) .get() .build(); String resultContent = null; @@ -79,12 +83,8 @@ public void initHttp() { configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); - } - - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); - if (httpProxy != null) { + OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); clientBuilder.proxy(getRequestHttpProxy().getProxy()); - //设置授权 clientBuilder.authenticator(new Authenticator() { @Override @@ -95,8 +95,10 @@ public Request authenticate(Route route, Response response) throws IOException { .build(); } }); + httpClient = clientBuilder.build(); + } else { + httpClient = DefaultOkHttpClientBuilder.get().build(); } - httpClient = clientBuilder.build(); } @Override diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOnTpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOnTpImpl.java index aa30385d6c..207681c7ae 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOnTpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOnTpImpl.java @@ -24,7 +24,8 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { } //access token通过第三方应用service获取 //corpSecret对应企业永久授权码 - WxAccessToken accessToken = wxCpTpService.getCorpToken(this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); + WxAccessToken accessToken = wxCpTpService.getCorpToken(this.configStorage.getCorpId(), + this.configStorage.getCorpSecret()); this.configStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); return this.configStorage.getAccessToken(); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImpl.java index 0e079160fb..e73ef98a98 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImpl.java @@ -1,6 +1,8 @@ package me.chanjar.weixin.cp.api.impl; -import com.google.gson.*; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java index 384a3d30cd..4802c5549c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java @@ -5,12 +5,14 @@ import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpTaskCardService; +import me.chanjar.weixin.cp.bean.message.TemplateCardMessage; import java.util.HashMap; import java.util.List; import java.util.Map; -import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.TaskCard.*; +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.TaskCard.UPDATE_TASK_CARD; +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.TaskCard.UPDATE_TEMPLATE_CARD; /** *

@@ -18,8 +20,7 @@
  *  Created by Jeff on 2019-05-16.
  * 
* - * @author Jeff - * @date 2019-05-16 + * @author Jeff created on 2019-05-16 */ @RequiredArgsConstructor public class WxCpTaskCardServiceImpl implements WxCpTaskCardService { @@ -33,9 +34,37 @@ public void update(List userIds, String taskId, String replaceName) thro data.put("userids", userIds); data.put("agentid", agentId); data.put("task_id", taskId); - data.put("replace_name", replaceName); + // 文档地址:https://open.work.weixin.qq.com/wwopen/devtool/interface?doc_id=16386 + data.put("clicked_key", replaceName); String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TASK_CARD); this.mainService.post(url, WxGsonBuilder.create().toJson(data)); } + + @Override + public void updateTemplateCardButton(List userIds, List partyIds, + List tagIds, Integer atAll, + String responseCode, String replaceName) throws WxErrorException { + Integer agentId = this.mainService.getWxCpConfigStorage().getAgentId(); + Map data = new HashMap<>(7); + data.put("userids", userIds); + data.put("partyids", partyIds); + data.put("tagids", tagIds); + data.put("atall", atAll); + data.put("agentid", agentId); + data.put("response_code", responseCode); + Map btnMap = new HashMap<>(); + btnMap.put("replace_name", replaceName); + data.put("button", btnMap); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE_CARD); + this.mainService.post(url, WxGsonBuilder.create().toJson(data)); + + } + + @Override + public void updateTemplateCardButton(TemplateCardMessage templateCardMessage) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE_CARD); + this.mainService.post(url, WxGsonBuilder.create().toJson(templateCardMessage)); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java index d0648b21ec..f1556d4e31 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java @@ -11,10 +11,17 @@ import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpUserService; import me.chanjar.weixin.cp.bean.WxCpInviteResult; +import me.chanjar.weixin.cp.bean.WxCpOpenUseridToUseridResult; import me.chanjar.weixin.cp.bean.WxCpUser; +import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult; import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; +import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.apache.commons.lang3.time.FastDateFormat; +import java.text.Format; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -29,6 +36,8 @@ */ @RequiredArgsConstructor public class WxCpUserServiceImpl implements WxCpUserService { + private final Format dateFormat = FastDateFormat.getInstance("yyyy-MM-dd"); + private final WxCpService mainService; @Override @@ -194,6 +203,17 @@ public String getUserId(String mobile) throws WxErrorException { return tmpJson.get("userid").getAsString(); } + @Override + public String getUserIdByEmail(String email, int emailType) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("email", email); + jsonObject.addProperty("email_type", emailType); + String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_ID_BY_EMAIL); + String responseContent = this.mainService.post(url, jsonObject.toString()); + JsonObject tmpJson = GsonParser.parse(responseContent); + return tmpJson.get("userid").getAsString(); + } + @Override public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId); @@ -208,4 +228,57 @@ public String getJoinQrCode(int sizeType) throws WxErrorException { JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("join_qrcode").getAsString(); } + + @Override + public Integer getActiveStat(Date date) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("date", this.dateFormat.format(date)); + String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_ACTIVE_STAT); + String responseContent = this.mainService.post(url, jsonObject.toString()); + JsonObject tmpJson = GsonParser.parse(responseContent); + return tmpJson.get("active_cnt").getAsInt(); + } + + @Override + public WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList useridList) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + for (String userid : useridList) { + jsonArray.add(userid); + } + jsonObject.add("userid_list", jsonArray); + String url = this.mainService.getWxCpConfigStorage().getApiUrl(USERID_TO_OPEN_USERID); + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpUseridToOpenUseridResult.fromJson(responseContent); + } + + @Override + public WxCpOpenUseridToUseridResult openUseridToUserid(List openUseridList, String sourceAgentId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + for (String openUserid : openUseridList) { + jsonArray.add(openUserid); + } + jsonObject.add("open_userid_list", jsonArray); + jsonObject.addProperty("source_agentid", sourceAgentId); + String url = this.mainService.getWxCpConfigStorage().getApiUrl(OPEN_USERID_TO_USERID); + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpOpenUseridToUseridResult.fromJson(responseContent); + } + + @Override + public WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException { + String apiUrl = this.mainService.getWxCpConfigStorage().getApiUrl(USER_LIST_ID); + JsonObject jsonObject = new JsonObject(); + if (cursor != null) { + jsonObject.addProperty("cursor", cursor); + } + if (limit != null) { + jsonObject.addProperty("limit", limit); + } + String responseContent = this.mainService.post(apiUrl, jsonObject.toString()); + return WxCpDeptUserResult.fromJson(responseContent); + } + + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/Gender.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/Gender.java index d56bd57da9..b47697ffac 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/Gender.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/Gender.java @@ -30,9 +30,15 @@ public enum Gender { private final String genderName; private final String code; + /** + * From code gender. + * + * @param code the code + * @return the gender + */ public static Gender fromCode(String code) { - for(Gender a: Gender.values()){ - if(a.code.equals(code)){ + for (Gender a : Gender.values()) { + if (a.code.equals(code)) { return a; } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java index 614bc9791e..5d61b3a199 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java @@ -1,8 +1,5 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; -import java.util.List; - import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,6 +7,9 @@ import lombok.NoArgsConstructor; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import java.io.Serializable; +import java.util.List; + /** *
  * 企业号应用信息.
@@ -70,36 +70,64 @@ public class WxCpAgent implements Serializable {
   @SerializedName("home_url")
   private String homeUrl;
 
+  @SerializedName("customized_publish_status")
+  private Integer customizedPublishStatus;
+
+  /**
+   * From json wx cp agent.
+   *
+   * @param json the json
+   * @return the wx cp agent
+   */
   public static WxCpAgent fromJson(String json) {
     return WxCpGsonBuilder.create().fromJson(json, WxCpAgent.class);
   }
 
+  /**
+   * To json string.
+   *
+   * @return the string
+   */
   public String toJson() {
     return WxCpGsonBuilder.create().toJson(this);
   }
 
+  /**
+   * The type Users.
+   */
   @Data
   public static class Users implements Serializable {
     private static final long serialVersionUID = 8801100463558788565L;
+
     @SerializedName("user")
     private List users;
   }
 
+  /**
+   * The type User.
+   */
   @Data
-  public class User implements Serializable {
+  public static class User implements Serializable {
     private static final long serialVersionUID = 7287632514385508024L;
+
     @SerializedName("userid")
     private String userId;
   }
 
+  /**
+   * The type Parties.
+   */
   @Data
-  public class Parties {
+  public static class Parties {
     @SerializedName("partyid")
     private List partyIds = null;
   }
 
+  /**
+   * The type Tags.
+   */
   @Data
-  public class Tags {
+  public static class Tags {
     @SerializedName("tagid")
     private List tagIds = null;
   }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentJsapiSignature.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentJsapiSignature.java
new file mode 100644
index 0000000000..4562d9b9b0
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentJsapiSignature.java
@@ -0,0 +1,31 @@
+package me.chanjar.weixin.cp.bean;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 调用wx.agentConfig时所需要的签名信息
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class WxCpAgentJsapiSignature implements Serializable {
+  private static final long serialVersionUID = 2650119900835832545L;
+
+  private String url;
+
+  private String corpid;
+
+  private Integer agentid;
+
+  private long timestamp;
+
+  private String nonceStr;
+
+  private String signature;
+}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentWorkBench.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentWorkBench.java
index c97faa6364..a2737f7237 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentWorkBench.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentWorkBench.java
@@ -14,51 +14,55 @@
 import java.util.List;
 
 /**
- * @author songshiyu
- * @date : create in 16:09 2020/9/27
- * @description: 工作台自定义展示
+ * The type Wx cp agent work bench.
+ *
+ * @author songshiyu  created on  : create in 16:09 2020/9/27 工作台自定义展示
  */
 @Data
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
 public class WxCpAgentWorkBench implements Serializable {
-  private static final long serialVersionUid = 1L;
+  private static final long serialVersionUID = -4136604790232843229L;
 
-  /*
-  * 展示类型,目前支持 “keydata”、 “image”、 “list” 、”webview”
-  * */
+  /**
+   * 展示类型,目前支持 “keydata”、 “image”、 “list” 、”webview”
+   */
   private String type;
-  /*
-  * 用户的userid
-  * */
+  /**
+   * 用户的userid
+   */
   private String userId;
-  /*
-  * 应用id
-  * */
+  /**
+   * 应用id
+   */
   private Long agentId;
-  /*
-  * 点击跳转url,若不填且应用设置了主页url,则跳转到主页url,否则跳到应用会话窗口
-  * */
+  /**
+   * 点击跳转url,若不填且应用设置了主页url,则跳转到主页url,否则跳到应用会话窗口
+   */
   private String jumpUrl;
-  /*
-  * 若应用为小程序类型,该字段填小程序pagepath,若未设置,跳到小程序主页
-  * */
+  /**
+   * 若应用为小程序类型,该字段填小程序pagepath,若未设置,跳到小程序主页
+   */
   private String pagePath;
-  /*
-  * 图片url:图片的最佳比例为3.35:1;webview:渲染展示的url
-  * */
+  /**
+   * 图片url:图片的最佳比例为3.35:1;webview:渲染展示的url
+   */
   private String url;
-  /*
-  * 是否覆盖用户工作台的数据。设置为true的时候,会覆盖企业所有用户当前设置的数据。若设置为false,则不会覆盖用户当前设置的所有数据
-  * */
+  /**
+   * 是否覆盖用户工作台的数据。设置为true的时候,会覆盖企业所有用户当前设置的数据。若设置为false,则不会覆盖用户当前设置的所有数据
+   */
   private Boolean replaceUserData;
 
   private List keyDataList;
 
   private List lists;
 
-  // 生成模板Json字符串
+  /**
+   * 生成模板Json字符串
+   *
+   * @return the string
+   */
   public String toTemplateString() {
     JsonObject templateObject = new JsonObject();
     templateObject.addProperty("agentid", this.agentId);
@@ -70,7 +74,11 @@ public String toTemplateString() {
     return templateObject.toString();
   }
 
-  // 生成用户数据Json字符串
+  /**
+   * 生成用户数据Json字符串
+   *
+   * @return the string
+   */
   public String toUserDataString() {
     JsonObject userDataObject = new JsonObject();
     userDataObject.addProperty("agentid", this.agentId);
@@ -80,7 +88,9 @@ public String toUserDataString() {
     return userDataObject.toString();
   }
 
-  // 处理不用类型的工作台数据
+  /**
+   * 处理不用类型的工作台数据
+   */
   private void handle(JsonObject templateObject) {
     switch (this.getType()) {
       case WxCpConsts.WorkBenchType.KEYDATA: {
@@ -116,7 +126,7 @@ private void handle(JsonObject templateObject) {
           listObject.addProperty("pagepath", listItem.getPagePath());
           listArray.add(listObject);
         }
-        itemsObject.add("items",listArray);
+        itemsObject.add("items", listArray);
         templateObject.add("list", itemsObject);
         break;
       }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpBaseResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpBaseResp.java
index 254260ea36..6bf9a30aeb 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpBaseResp.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpBaseResp.java
@@ -8,25 +8,53 @@
 import java.io.Serializable;
 
 /**
- * @author yqx
- * @date 2020/3/16
+ * 返回结果
+ *
+ * @author yqx & WangWong created on  2020/3/16
  */
 @Getter
 @Setter
 public class WxCpBaseResp implements Serializable {
   private static final long serialVersionUID = -4301684507150486556L;
 
+  /**
+   * The Errcode.
+   */
   @SerializedName("errcode")
   protected Long errcode;
 
+  /**
+   * The Errmsg.
+   */
   @SerializedName("errmsg")
   protected String errmsg;
 
+  /**
+   * Success boolean.
+   *
+   * @return the boolean
+   */
   public boolean success() {
     return getErrcode() == 0;
   }
 
+  /**
+   * From json wx cp base resp.
+   *
+   * @param json the json
+   * @return the wx cp base resp
+   */
   public static WxCpBaseResp fromJson(String json) {
     return WxCpGsonBuilder.create().fromJson(json, WxCpBaseResp.class);
   }
+
+  /**
+   * To json string.
+   *
+   * @return the string
+   */
+  public String toJson() {
+    return WxCpGsonBuilder.create().toJson(this);
+  }
+
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpChat.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpChat.java
index 03b9aaa7d9..eb014c595a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpChat.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpChat.java
@@ -1,22 +1,22 @@
-package me.chanjar.weixin.cp.bean;
-
-import java.io.Serializable;
-import java.util.List;
-
-import lombok.Data;
-
-/**
- * 群聊
- *
- * @author gaigeshen
- */
-@Data
-public class WxCpChat implements Serializable {
-  private static final long serialVersionUID = -4301684507150486556L;
-  
-  private String id;
-  private String name;
-  private String owner;
-  private List users;
-
-}
+package me.chanjar.weixin.cp.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 群聊
+ *
+ * @author gaigeshen
+ */
+@Data
+public class WxCpChat implements Serializable {
+  private static final long serialVersionUID = -4301684507150486556L;
+
+  private String id;
+  private String name;
+  private String owner;
+  private List users;
+
+}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java
index f5b9b32592..bc54e7e806 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java
@@ -1,10 +1,10 @@
 package me.chanjar.weixin.cp.bean;
 
-import java.io.Serializable;
-
 import lombok.Data;
 import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
 
+import java.io.Serializable;
+
 /**
  * 企业微信的部门.
  *
@@ -17,13 +17,25 @@ public class WxCpDepart implements Serializable {
   private Long id;
   private String name;
   private String enName;
+  private String[] departmentLeader;
   private Long parentId;
   private Long order;
 
+  /**
+   * From json wx cp depart.
+   *
+   * @param json the json
+   * @return the wx cp depart
+   */
   public static WxCpDepart fromJson(String json) {
     return WxCpGsonBuilder.create().fromJson(json, WxCpDepart.class);
   }
 
+  /**
+   * To json string.
+   *
+   * @return the string
+   */
   public String toJson() {
     return WxCpGsonBuilder.create().toJson(this);
   }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpInviteResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpInviteResult.java
index f5a0a66bf1..3cbeb7ce7b 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpInviteResult.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpInviteResult.java
@@ -1,11 +1,11 @@
 package me.chanjar.weixin.cp.bean;
 
-import java.io.Serializable;
-
 import com.google.gson.annotations.SerializedName;
 import lombok.Data;
 import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
 
+import java.io.Serializable;
+
 /**
  * 邀请成员的结果对象类.
  * Created by Binary Wang on 2018-5-13.
@@ -21,6 +21,12 @@ public String toString() {
     return WxCpGsonBuilder.create().toJson(this);
   }
 
+  /**
+   * From json wx cp invite result.
+   *
+   * @param json the json
+   * @return the wx cp invite result
+   */
   public static WxCpInviteResult fromJson(String json) {
     return WxCpGsonBuilder.create().fromJson(json, WxCpInviteResult.class);
   }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMaJsCode2SessionResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMaJsCode2SessionResult.java
index 90f1ae840c..f4de0b988a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMaJsCode2SessionResult.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMaJsCode2SessionResult.java
@@ -11,6 +11,7 @@
  * 小程序登录凭证校验
  * 文档地址:https://work.weixin.qq.com/api/doc#90000/90136/90289/wx.qy.login
  * 
+ * * @author Binary Wang */ @Data @@ -26,6 +27,12 @@ public class WxCpMaJsCode2SessionResult implements Serializable { @SerializedName("corpid") private String corpId; + /** + * From json wx cp ma js code 2 session result. + * + * @param json the json + * @return the wx cp ma js code 2 session result + */ public static WxCpMaJsCode2SessionResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpMaJsCode2SessionResult.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOauth2UserInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOauth2UserInfo.java index 56e65b9008..433e54a680 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOauth2UserInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOauth2UserInfo.java @@ -1,18 +1,20 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +import java.io.Serializable; + /** *
  *  用oauth2获取用户信息的结果类
  *  Created by BinaryWang on 2019/5/26.
  * 
+ *

+ * 文档1:https://developer.work.weixin.qq.com/document/path/91707 * * @author Binary Wang */ @@ -23,11 +25,14 @@ @Builder public class WxCpOauth2UserInfo implements Serializable { private static final long serialVersionUID = -4301684507150486556L; - + private String openId; private String deviceId; private String userId; private String userTicket; private String expiresIn; private String externalUserId; + private String parentUserId; + private String studentUserId; + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOpenUseridToUserid.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOpenUseridToUserid.java new file mode 100644 index 0000000000..ec4d276e0a --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOpenUseridToUserid.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * userid转换 + * 将代开发应用或第三方应用获取的密文open_userid转换为明文userid + * 中间对象 + * @author yiyingcanfeng + */ +@Data +public class WxCpOpenUseridToUserid implements Serializable { + private static final long serialVersionUID = 1714909184316350423L; + + @Override + public String toString() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * From json wx cp open userid to userid result. + * + * @param json the json + * @return the wx cp open userid to userid result. + */ + public static WxCpOpenUseridToUserid fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpOpenUseridToUserid.class); + } + + @SerializedName("userid") + private String userid; + + @SerializedName("open_userid") + private String openUserid; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOpenUseridToUseridResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOpenUseridToUseridResult.java new file mode 100644 index 0000000000..122c3a0dc6 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpOpenUseridToUseridResult.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * userid转换 + * 将代开发应用或第三方应用获取的密文open_userid转换为明文userid + * @author yiyingcanfeng + */ +@Data +public class WxCpOpenUseridToUseridResult implements Serializable { + private static final long serialVersionUID = 5179329535139861515L; + + @Override + public String toString() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * From json wx cp open userid to userid result. + * + * @param json the json + * @return the wx cp open userid to userid result + */ + public static WxCpOpenUseridToUseridResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpOpenUseridToUseridResult.class); + } + + @SerializedName("errcode") + private Integer errCode; + + @SerializedName("errmsg") + private String errMsg; + + @SerializedName("userid_list") + private List useridList; + + @SerializedName("invalid_open_userid_list") + private List invalidOpenUseridList; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpProviderToken.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpProviderToken.java index 6a33f1c48c..872b96d93f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpProviderToken.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpProviderToken.java @@ -1,20 +1,20 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; - import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import java.io.Serializable; + /** * 服务商凭证. * - * @author Binary Wang - * @date 2019-11-02 + * @author Binary Wang created on 2019-11-02 */ @Data public class WxCpProviderToken implements Serializable { private static final long serialVersionUID = -4301684507150486556L; + /** * 服务商的access_token,最长为512字节。 */ @@ -27,6 +27,12 @@ public class WxCpProviderToken implements Serializable { @SerializedName("expires_in") private Integer expiresIn; + /** + * From json wx cp provider token. + * + * @param json the json + * @return the wx cp provider token + */ public static WxCpProviderToken fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpProviderToken.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java index f6b9fa0276..33d3d07b29 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java @@ -1,14 +1,15 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import java.io.Serializable; + /** * Created by Daniel Qian. + * * @author Daniel Qian */ @Data @@ -22,10 +23,21 @@ public class WxCpTag implements Serializable { private String name; + /** + * From json wx cp tag. + * + * @param json the json + * @return the wx cp tag + */ public static WxCpTag fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTag.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java index 037740ca96..c590c6c0e8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java @@ -1,15 +1,14 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; - import com.google.common.base.Splitter; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; /** * 为标签添加或移除用户结果对象类. @@ -26,6 +25,12 @@ public String toString() { return WxCpGsonBuilder.create().toJson(this); } + /** + * From json wx cp tag add or remove users result. + * + * @param json the json + * @return the wx cp tag add or remove users result + */ public static WxCpTagAddOrRemoveUsersResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTagAddOrRemoveUsersResult.class); } @@ -42,6 +47,11 @@ public static WxCpTagAddOrRemoveUsersResult fromJson(String json) { @SerializedName("invalidparty") private String[] invalidParty; + /** + * Gets invalid user list. + * + * @return the invalid user list + */ public List getInvalidUserList() { return this.content2List(this.invalidUsers); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagGetResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagGetResult.java index 244419b062..3dc34ab654 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagGetResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagGetResult.java @@ -46,10 +46,21 @@ public class WxCpTagGetResult implements Serializable { @SerializedName("tagname") private String tagname; + /** + * From json wx cp tag get result. + * + * @param json the json + * @return the wx cp tag get result + */ public static WxCpTagGetResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTagGetResult.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTaskCardUpdateResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTaskCardUpdateResult.java index c86b255b44..d4cee5549c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTaskCardUpdateResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTaskCardUpdateResult.java @@ -16,8 +16,7 @@ * Created by Jeff on 2019-05-16. *

* - * @author Jeff - * @date 2019-05-16 + * @author Jeff created on 2019-05-16 */ @Data @AllArgsConstructor @@ -36,6 +35,12 @@ public class WxCpTaskCardUpdateResult implements Serializable { @SerializedName("invaliduser") private List invalidUsers; + /** + * From json wx cp task card update result. + * + * @param json the json + * @return the wx cp task card update result + */ public static WxCpTaskCardUpdateResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTaskCardUpdateResult.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAdmin.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAdmin.java index 2aa89d2158..776726de80 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAdmin.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAdmin.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import me.chanjar.weixin.common.util.json.WxGsonBuilder; @@ -11,16 +12,20 @@ /** * 应用的管理员 + * * @author huangxiaoming */ @Data +@EqualsAndHashCode(callSuper = true) public class WxCpTpAdmin extends WxCpBaseResp { - private static final long serialVersionUID = -5028321625140879571L; @SerializedName("admin") private List admin; + /** + * The type Admin. + */ @Getter @Setter public static class Admin extends WxCpBaseResp { @@ -29,6 +34,9 @@ public static class Admin extends WxCpBaseResp { @SerializedName("userid") private String userId; + @SerializedName("open_userid") + private String openUserId; + @SerializedName("auth_type") private Integer authType; @@ -37,6 +45,12 @@ public String toJson() { } } + /** + * From json wx cp tp admin. + * + * @param json the json + * @return the wx cp tp admin + */ public static WxCpTpAdmin fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpAdmin.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAppQrcode.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAppQrcode.java new file mode 100644 index 0000000000..ada85c760c --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAppQrcode.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 应用的管理员 + * + * @author huangxiaoming + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpTpAppQrcode extends WxCpBaseResp { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("qrcode") + private String qrcode; + + /** + * From json wx cp tp admin. + * + * @param json the json + * @return the wx cp tp admin + */ + public static WxCpTpAppQrcode fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpAppQrcode.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java index 02d51095c8..fa50216153 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java @@ -36,6 +36,16 @@ public class WxCpTpAuthInfo extends WxCpBaseResp { @SerializedName("auth_info") private AuthInfo authInfo; + + /** + * 企业当前生效的版本信息 + */ + @SerializedName("edition_info") + private EditionInfo editionInfo; + + /** + * The type Dealer corp info. + */ @Getter @Setter public static class DealerCorpInfo extends WxCpBaseResp { @@ -48,6 +58,9 @@ public static class DealerCorpInfo extends WxCpBaseResp { private String corpName; } + /** + * The type Auth corp info. + */ @Getter @Setter public static class AuthCorpInfo implements Serializable { @@ -128,6 +141,25 @@ public static class AuthInfo implements Serializable { } + /** + * 企业当前生效的版本信息 + */ + @Getter + @Setter + public static class EditionInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + /** + * 授权的应用信息,注意是一个数组,但仅旧的多应用套件授权时会返回多个agent,对新的单应用授权,永远只返回一个agent + */ + @SerializedName("agent") + private List agents; + + } + + /** + * The type Agent. + */ @Getter @Setter public static class Agent implements Serializable { @@ -152,12 +184,86 @@ public static class Agent implements Serializable { @Deprecated private String appid; + /** + * 授权模式,0为管理员授权;1为成员授权 + */ + @SerializedName("auth_mode") + private Integer authMode; + + /** + * 是否为代开发自建应用 + */ + @SerializedName("is_customized_app") + private Boolean isCustomizedApp; + /** * 应用权限 */ @SerializedName("privilege") private Privilege privilege; + /** + * 版本id + */ + @SerializedName("edition_id") + private String editionId; + + /** + * 版本名称 + */ + @SerializedName("edition_name") + private String editionName; + + /** + * 付费状态 + *
+ *
    + *
  • 0-没有付费;
  • + *
  • 1-限时试用;
  • + *
  • 2-试用过期;
  • + *
  • 3-购买期内;
  • + *
  • 4-购买过期;
  • + *
  • 5-不限时试用;
  • + *
  • 6-购买期内,但是人数超标, 注意,超标后还可以用7天;
  • + *
  • 7-购买期内,但是人数超标, 且已经超标试用7天
  • + *
+ */ + @SerializedName("app_status") + private Integer appStatus; + + /** + * 用户上限。 + *

特别注意, 以下情况该字段无意义,可以忽略:

+ *
    + *
  • 1. 固定总价购买
  • + *
  • 2. app_status = 限时试用/试用过期/不限时试用
  • + *
  • 3. 在第2条“app_status=不限时试用”的情况下,如果该应用的配置为“小企业无使用限制”,user_limit有效,且为限制的人数
  • + *
+ */ + @SerializedName("user_limit") + private Long userLimit; + + /** + * 版本到期时间, 秒级时间戳, 根据需要自行乘以1000(根据购买版本,可能是试用到期时间或付费使用到期时间)。 + *

特别注意,以下情况该字段无意义,可以忽略:

+ *
    + *
  • 1. app_status = 不限时试用
  • + *
+ */ + @SerializedName("expired_time") + private Long expiredTime; + + /** + * 是否虚拟版本 + */ + @SerializedName("is_virtual_version") + private Boolean isVirtualVersion; + + /** + * 是否由互联企业分享安装。详见 企业互联 + */ + @SerializedName("is_shared_from_other_corp") + private Boolean isSharedFromOtherCorp; } /** @@ -200,10 +306,17 @@ public static class Privilege implements Serializable { } + /** + * From json wx cp tp auth info. + * + * @param json the json + * @return the wx cp tp auth info + */ public static WxCpTpAuthInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpAuthInfo.class); } + @Override public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearch.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearch.java index ee1de69f52..11c653a433 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearch.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearch.java @@ -1,65 +1,71 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; - import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.experimental.Accessors; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import java.io.Serializable; + /** + * The type Wx cp tp contact search. + * * @author uianz - * @description - * @since 2020/12/23 下午 02:43 + * @since 2020 /12/23 下午 02:43 */ @Data @Accessors(chain = true) public class WxCpTpContactSearch implements Serializable { - private static final long serialVersionUID = -4301684507150486556L; + private static final long serialVersionUID = -4301684507150486556L; - /** - * 查询的企业corpid - */ - @SerializedName("auth_corpid") - private String authCorpId; + /** + * 查询的企业corpid + */ + @SerializedName("auth_corpid") + private String authCorpId; - /** - * 搜索关键词。当查询用户时应为用户名称、名称拼音或者英文名;当查询部门时应为部门名称或者部门名称拼音 - */ - @SerializedName("query_word") - private String queryWord; + /** + * 搜索关键词。当查询用户时应为用户名称、名称拼音或者英文名;当查询部门时应为部门名称或者部门名称拼音 + */ + @SerializedName("query_word") + private String queryWord; - /** - * 查询类型 1:查询用户,返回用户userid列表 2:查询部门,返回部门id列表。 不填该字段或者填0代表同时查询部门跟用户 - */ - @SerializedName("query_type") - private Integer type; + /** + * 查询类型 1:查询用户,返回用户userid列表 2:查询部门,返回部门id列表。 不填该字段或者填0代表同时查询部门跟用户 + */ + @SerializedName("query_type") + private Integer type; - /** - * 应用id,若非0则只返回应用可见范围内的用户或者部门信息 - */ - @SerializedName("agentid") - private Integer agentId; + /** + * 应用id,若非0则只返回应用可见范围内的用户或者部门信息 + */ + @SerializedName("agentid") + private Integer agentId; - /** - * 查询的偏移量,每次调用的offset在上一次offset基础上加上limit - */ - @SerializedName("offset") - private Integer offset; + /** + * 查询返回的最大数量,默认为50,最多为200,查询返回的数量可能小于limit指定的值 + */ + @SerializedName("limit") + private Integer limit; - /** - * 查询返回的最大数量,默认为50,最多为200,查询返回的数量可能小于limit指定的值 - */ - @SerializedName("limit") - private Integer limit; + /** + * 如果需要精确匹配用户名称或者部门名称或者英文名,不填则默认为模糊匹配;1:匹配用户名称或者部门名称 2:匹配用户英文名 + */ + @SerializedName("full_match_field") + private Integer fullMatchField; - /** - * 如果需要精确匹配用户名称或者部门名称或者英文名,不填则默认为模糊匹配;1:匹配用户名称或者部门名称 2:匹配用户英文名 - */ - @SerializedName("full_match_field") - private Integer fullMatchField; + /** + * 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + */ + @SerializedName("cursor") + private String cursor; - public String toJson() { - return WxCpGsonBuilder.create().toJson(this); - } + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearchResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearchResp.java index 1998a4230f..074b30bc0e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearchResp.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpContactSearchResp.java @@ -9,50 +9,69 @@ import java.util.List; /** + * The type Wx cp tp contact search resp. + * * @author uianz - * @description - * @since 2020/12/23 下午 02:55 + * @since 2020 /12/23 下午 02:55 */ @EqualsAndHashCode(callSuper = true) @Data public class WxCpTpContactSearchResp extends WxCpBaseResp { - @SerializedName("is_last") - private Boolean isLast; + @SerializedName("is_last") + private Boolean isLast; - @SerializedName("query_result") - private QueryResult queryResult; + @SerializedName("query_result") + private QueryResult queryResult; - @Data - public static class QueryResult implements Serializable { - private static final long serialVersionUID = -4301684507150486556L; - - @SerializedName("user") - private User user; - @SerializedName("party") - private Party party; - - @Data - public static class User implements Serializable { - private static final long serialVersionUID = -4301684507150486556L; - @SerializedName("userid") - private List userid; - @SerializedName("open_userid") - private List openUserId; - } - - @Data - public static class Party implements Serializable { - private static final long serialVersionUID = -4301684507150486556L; - - @SerializedName("department_id") - private List departmentId; - } + @SerializedName("next_cursor") + private String nextCursor; + + /** + * The type Query result. + */ + @Data + public static class QueryResult implements Serializable { + private static final long serialVersionUID = -4301684507150486556L; + @SerializedName("user") + private User user; + @SerializedName("party") + private Party party; + + /** + * The type User. + */ + @Data + public static class User implements Serializable { + private static final long serialVersionUID = -4301684507150486556L; + @SerializedName("userid") + private List userid; + @SerializedName("open_userid") + private List openUserId; } - public static WxCpTpContactSearchResp fromJson(String json) { - return WxCpGsonBuilder.create().fromJson(json, WxCpTpContactSearchResp.class); + /** + * The type Party. + */ + @Data + public static class Party implements Serializable { + private static final long serialVersionUID = -4301684507150486556L; + + @SerializedName("department_id") + private List departmentId; } + } + + /** + * From json wx cp tp contact search resp. + * + * @param json the json + * @return the wx cp tp contact search resp + */ + public static WxCpTpContactSearchResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpContactSearchResp.class); + } + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpConvertTmpExternalUserIdResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpConvertTmpExternalUserIdResult.java new file mode 100644 index 0000000000..9bca31c2d0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpConvertTmpExternalUserIdResult.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +@Setter +@Getter +public class WxCpTpConvertTmpExternalUserIdResult extends WxCpBaseResp { + + + @SerializedName("invalid_tmp_external_userid_list") + private List results; + + @Getter + @Setter + public static class Results { + + @SerializedName("tmp_external_userid") + private String tmpExternalUserId; + + @SerializedName("external_userid") + private String externalUserId; + + @SerializedName("corpid") + private String corpId; + + @SerializedName("userid") + private String userId; + } + + @SerializedName("invalid_tmp_external_userid_list") + private List invalidTmpExternalUserIdList; + + public static WxCpTpConvertTmpExternalUserIdResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpConvertTmpExternalUserIdResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpCorp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpCorp.java index f77fdb78df..939a4eddf6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpCorp.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpCorp.java @@ -1,12 +1,11 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; - import com.google.gson.annotations.SerializedName; - import lombok.Data; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import java.io.Serializable; + /** * 微信部门. * @@ -33,10 +32,21 @@ public class WxCpTpCorp implements Serializable { @SerializedName("auth_info") private String authInfo; + /** + * From json wx cp tp corp. + * + * @param json the json + * @return the wx cp tp corp + */ public static WxCpTpCorp fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpCorp.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpCorpId2OpenCorpId.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpCorpId2OpenCorpId.java new file mode 100644 index 0000000000..73dfd49064 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpCorpId2OpenCorpId.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 应用的管理员 + * + * @author huangxiaoming + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpTpCorpId2OpenCorpId extends WxCpBaseResp { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("open_corpid") + private String openCorpId; + + /** + * From json wx cp tp admin. + * + * @param json the json + * @return the wx cp tp admin + */ + public static WxCpTpCorpId2OpenCorpId fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpCorpId2OpenCorpId.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpDepart.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpDepart.java index ab94a6b6b4..39d3601a2f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpDepart.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpDepart.java @@ -20,10 +20,21 @@ public class WxCpTpDepart implements Serializable { private Integer parentid; private Integer order; + /** + * From json wx cp tp depart. + * + * @param json the json + * @return the wx cp tp depart + */ public static WxCpTpDepart fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpDepart.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpOpenKfIdConvertResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpOpenKfIdConvertResult.java new file mode 100644 index 0000000000..b6b0e9ef82 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpOpenKfIdConvertResult.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +@Setter +@Getter +public class WxCpTpOpenKfIdConvertResult extends WxCpBaseResp { + + /** + * 微信客服ID转换结果 + */ + @SerializedName("items") + private List items; + + /** + * 无法转换的微信客服ID列表 + */ + @SerializedName("invalid_open_kfid_list") + private List invalidOpenKfIdList; + + @Getter + @Setter + public static class Item { + + /*** + * 企业主体下的微信客服ID + */ + @SerializedName("open_kfid") + private String openKfId; + + /** + * 服务商主体下的微信客服ID,如果传入的open_kfid已经是服务商主体下的ID,则new_open_kfid与open_kfid相同。 + */ + @SerializedName("new_open_kfid") + private String newOpenKfId; + } + + public static WxCpTpOpenKfIdConvertResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpOpenKfIdConvertResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java index 02793de14d..522e606a20 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java @@ -46,7 +46,30 @@ public class WxCpTpPermanentCodeInfo extends WxCpBaseResp { @SerializedName("auth_user_info") private AuthUserInfo authUserInfo; + /** + * 推广二维码安装相关信息 + */ + @SerializedName("register_code_info") + private RegisterCodeInfo registerCodeInfo; + + /** + * 企业当前生效的版本信息 + */ + @SerializedName("edition_info") + private EditionInfo editionInfo; + /** + * 安装应用时,扫码或者授权链接中带的state值。详见state说明 + * state说明: + * 目前会返回state包含以下几个场景。 + * (1)扫带参二维码授权代开发模版。 + */ + @SerializedName("state") + private String state; + + /** + * The type Auth corp info. + */ @Getter @Setter public static class AuthCorpInfo implements Serializable { @@ -127,6 +150,25 @@ public static class AuthInfo implements Serializable { } + /** + * 企业当前生效的版本信息 + */ + @Getter + @Setter + public static class EditionInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + /** + * 授权的应用信息,注意是一个数组,但仅旧的多应用套件授权时会返回多个agent,对新的单应用授权,永远只返回一个agent + */ + @SerializedName("agent") + private List agents; + + } + + /** + * The type Agent. + */ @Getter @Setter public static class Agent implements Serializable { @@ -151,12 +193,87 @@ public static class Agent implements Serializable { @Deprecated private String appid; + /** + * 授权模式,0为管理员授权;1为成员授权 + */ + @SerializedName("auth_mode") + private Integer authMode; + + /** + * 是否为代开发自建应用 + */ + @SerializedName("is_customized_app") + private Boolean isCustomizedApp; + /** * 应用权限 */ @SerializedName("privilege") private Privilege privilege; + /** + * 版本id + */ + @SerializedName("edition_id") + private String editionId; + + /** + * 版本名称 + */ + @SerializedName("edition_name") + private String editionName; + + /** + * 付费状态 + *
+ *
    + *
  • 0-没有付费;
  • + *
  • 1-限时试用;
  • + *
  • 2-试用过期;
  • + *
  • 3-购买期内;
  • + *
  • 4-购买过期;
  • + *
  • 5-不限时试用;
  • + *
  • 6-购买期内,但是人数超标, 注意,超标后还可以用7天;
  • + *
  • 7-购买期内,但是人数超标, 且已经超标试用7天
  • + *
+ */ + @SerializedName("app_status") + private Integer appStatus; + + /** + * 用户上限。 + *

特别注意, 以下情况该字段无意义,可以忽略:

+ *
    + *
  • 1. 固定总价购买
  • + *
  • 2. app_status = 限时试用/试用过期/不限时试用
  • + *
  • 3. 在第2条“app_status=不限时试用”的情况下,如果该应用的配置为“小企业无使用限制”,user_limit有效,且为限制的人数
  • + *
+ */ + @SerializedName("user_limit") + private Long userLimit; + + /** + * 版本到期时间, 秒级时间戳, 根据需要自行乘以1000(根据购买版本,可能是试用到期时间或付费使用到期时间)。 + *

特别注意,以下情况该字段无意义,可以忽略:

+ *
    + *
  • 1. app_status = 不限时试用
  • + *
+ */ + @SerializedName("expired_time") + private Long expiredTime; + + /** + * 是否虚拟版本 + */ + @SerializedName("is_virtual_version") + private Boolean isVirtualVersion; + + /** + * 是否由互联企业分享安装。详见 企业互联 + */ + @SerializedName("is_shared_from_other_corp") + private Boolean isSharedFromOtherCorp; + } /** @@ -175,6 +292,40 @@ public static class AuthUserInfo implements Serializable { @SerializedName("avatar") private String avatar; + + /** + * 授权管理员的open_userid,可能为空 + */ + @SerializedName("open_userid") + private String openUserid; + } + + /** + * 推广二维码安装相关信息 + */ + @Getter + @Setter + public static class RegisterCodeInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + /** + * 注册码 + */ + @SerializedName("register_code") + private String registerCode; + + /** + * 推广包ID + */ + @SerializedName("template_id") + private String templateId; + + /** + * 仅当获取注册码指定该字段时才返回 + */ + @SerializedName("state") + private String state; + } /** @@ -217,10 +368,17 @@ public static class Privilege implements Serializable { } + /** + * From json wx cp tp permanent code info. + * + * @param json the json + * @return the wx cp tp permanent code info + */ public static WxCpTpPermanentCodeInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpPermanentCodeInfo.class); } + @Override public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPreauthCode.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPreauthCode.java index 8c102ae4a2..31c61b3a2b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPreauthCode.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPreauthCode.java @@ -7,19 +7,31 @@ /** * 预授权码返回 - * @author yqx - * @date 2020/3/19 + * + * @author yqx created on 2020/3/19 */ @Getter @Setter public class WxCpTpPreauthCode extends WxCpBaseResp { + /** + * The Pre auth code. + */ @SerializedName("pre_auth_code") String preAuthCode; + /** + * The Expires in. + */ @SerializedName("expires_in") Long expiresIn; + /** + * From json wx cp tp preauth code. + * + * @param json the json + * @return the wx cp tp preauth code + */ public static WxCpTpPreauthCode fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpPreauthCode.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpProlongTryResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpProlongTryResult.java new file mode 100644 index 0000000000..427e020a2f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpProlongTryResult.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 应用市场延长试用期结果 + * + * @author leiguoqing created on 2022年4月24日 + */ +@Getter +@Setter +public class WxCpTpProlongTryResult extends WxCpBaseResp { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -5028321625140879571L; + + /** + * 延长后的试用到期时间(秒级时间戳) + */ + @SerializedName("try_end_time") + private Long tryEndTime; + + + /** + * From json wx cp tp order list get result. + * + * @param json the json + * @return the wx cp tp order list get result + */ + public static WxCpTpProlongTryResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpProlongTryResult.class); + } + + /** + * To json string. + * + * @return the string + */ + @Override + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTag.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTag.java index b584b31dd1..74e1fec3f8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTag.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTag.java @@ -7,13 +7,13 @@ import java.io.Serializable; /** + * The type Wx cp tp tag. * * @author zhangq - * @since 2021-02-14 16:15 16:15 + * @since 2021 -02-14 16:15 16:15 */ @Data public class WxCpTpTag implements Serializable { - private static final long serialVersionUID = 581740383760234134L; @SerializedName("tagid") @@ -22,6 +22,12 @@ public class WxCpTpTag implements Serializable { @SerializedName("tagname") private String tagName; + /** + * Deserialize wx cp tp tag. + * + * @param json the json + * @return the wx cp tp tag + */ public static WxCpTpTag deserialize(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpTag.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagAddOrRemoveUsersResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagAddOrRemoveUsersResult.java index 35319b1baf..dfbf250480 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagAddOrRemoveUsersResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagAddOrRemoveUsersResult.java @@ -4,12 +4,19 @@ /** * 企业微信第三方开发-增加标签成员成员api响应体 + * * @author zhangq - * @since 2021/2/14 16:44 + * @since 2021 /2/14 16:44 */ public class WxCpTpTagAddOrRemoveUsersResult extends WxCpTagAddOrRemoveUsersResult { private static final long serialVersionUID = 3490401800490702052L; + /** + * Deserialize wx cp tp tag add or remove users result. + * + * @param json the json + * @return the wx cp tp tag add or remove users result + */ public static WxCpTpTagAddOrRemoveUsersResult deserialize(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpTagAddOrRemoveUsersResult.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagGetResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagGetResult.java index d77e99b131..162030c956 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagGetResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagGetResult.java @@ -4,12 +4,19 @@ /** * 获取标签成员接口响应体 + * * @author zhangq - * @since 2021/2/14 16:28 + * @since 2021 /2/14 16:28 */ public class WxCpTpTagGetResult extends WxCpTagGetResult { private static final long serialVersionUID = 9051748686315562400L; + /** + * Deserialize wx cp tp tag get result. + * + * @param json the json + * @return the wx cp tp tag get result + */ public static WxCpTpTagGetResult deserialize(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpTagGetResult.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagIdListConvertResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagIdListConvertResult.java new file mode 100644 index 0000000000..e24d36d4d0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpTagIdListConvertResult.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.cp.bean; + + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +@Getter +@Setter +public class WxCpTpTagIdListConvertResult extends WxCpBaseResp { + + private static final long serialVersionUID = -6153589164415497369L; + + + /** + * 客户标签转换结果 + */ + @SerializedName("items") + private List items; + + /** + * 无法转换的客户标签ID列表 + */ + @SerializedName("invalid_external_tagid_list") + private List invalidExternalTagIdList; + + + @Getter + @Setter + public static class Item { + + /** + * 企业主体下的客户标签ID + */ + @SerializedName("external_tagid") + private String externalTagId; + + /** + * 服务商主体下的客户标签ID,如果传入的external_tagid已经是服务商主体下的ID,则open_external_tagid与external_tagid相同。 + */ + @SerializedName("open_external_tagid") + private String openExternalTagId; + } + + public static WxCpTpTagIdListConvertResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpTagIdListConvertResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUnionidToExternalUseridResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUnionidToExternalUseridResult.java new file mode 100644 index 0000000000..f14fa45f6a --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUnionidToExternalUseridResult.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.*; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + + +@Getter +@Setter +public class WxCpTpUnionidToExternalUseridResult extends WxCpBaseResp { + + + private static final long serialVersionUID = -6153589164415497369L; + + @SerializedName("external_userid") + private String externalUserid; + + @SerializedName("pending_id") + private String pendingId; + + + public static WxCpTpUnionidToExternalUseridResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpUnionidToExternalUseridResult.class); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserDetail.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserDetail.java index 440e7b4df5..7c59bdf91f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserDetail.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserDetail.java @@ -2,15 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; /** + * The type Wx cp tp user detail. * * @author huangxiaoming */ @Data +@EqualsAndHashCode(callSuper = true) public class WxCpTpUserDetail extends WxCpBaseResp { - private static final long serialVersionUID = -5028321625140879571L; /** * 用户所属企业的corpid @@ -48,6 +50,36 @@ public class WxCpTpUserDetail extends WxCpBaseResp { @SerializedName("qr_code") private String qrCode; + /** + * 手机,仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取 + */ + @SerializedName("mobile") + private String mobile; + + /** + * 邮箱,仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取 + */ + @SerializedName("email") + private String email; + + /** + * 企业邮箱,仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取 + */ + @SerializedName("biz_mail") + private String bizMail; + + /** + * 仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取 + */ + @SerializedName("address") + private String address; + + /** + * From json wx cp tp user detail. + * + * @param json the json + * @return the wx cp tp user detail + */ public static WxCpTpUserDetail fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpUserDetail.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserInfo.java index 6739082faf..c6664fd0ab 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUserInfo.java @@ -2,12 +2,16 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; /** + * The type Wx cp tp user info. + * * @author huangxiaoming */ @Data +@EqualsAndHashCode(callSuper = true) public class WxCpTpUserInfo extends WxCpBaseResp { private static final long serialVersionUID = -5028321625140879571L; @@ -50,6 +54,12 @@ public class WxCpTpUserInfo extends WxCpBaseResp { @SerializedName("open_userid") private String openUserId; + /** + * From json wx cp tp user info. + * + * @param json the json + * @return the wx cp tp user info + */ public static WxCpTpUserInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTpUserInfo.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackage.java index e7af1dd61a..cdba33229a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackage.java @@ -1,8 +1,5 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; -import java.util.Map; - import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; @@ -10,6 +7,9 @@ import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.cp.util.xml.XStreamTransformer; +import java.io.Serializable; +import java.util.Map; + /** * 回调消息包. * https://work.weixin.qq.com/api/doc#90001/90143/91116 @@ -26,18 +26,33 @@ public class WxCpTpXmlPackage implements Serializable { */ private Map allFieldsMap; + /** + * The To user name. + */ @XStreamAlias("ToUserName") @XStreamConverter(value = XStreamCDataConverter.class) protected String toUserName; + /** + * The Agent id. + */ @XStreamAlias("AgentID") @XStreamConverter(value = XStreamCDataConverter.class) protected String agentId; + /** + * The Msg encrypt. + */ @XStreamAlias("Encrypt") @XStreamConverter(value = XStreamCDataConverter.class) protected String msgEncrypt; + /** + * From xml wx cp tp xml package. + * + * @param xml the xml + * @return the wx cp tp xml package + */ public static WxCpTpXmlPackage fromXml(String xml) { //修改微信变态的消息内容格式,方便解析 //xml = xml.replace("", ""); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java index 18ef125ab2..dc522482c4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java @@ -28,9 +28,25 @@ public class WxCpUser implements Serializable { private Integer[] orders; private String position; private String[] positions; + /** + * 代开发自建应用类型于2022年6月20号后的新建应用将不再返回此字段,需要在【获取访问用户敏感信息】接口中获取 + */ private String mobile; + /** + * 代开发自建应用类型于2022年6月20号后的新建应用将不再返回此字段,需要在【获取访问用户敏感信息】接口中获取 + */ private Gender gender; + /** + * 代开发自建应用类型于2022年6月20号后的新建应用将不再返回此字段,需要在【获取访问用户敏感信息】接口中获取 + */ private String email; + /** + * 代开发自建应用类型于2022年6月20号后的新建应用将不再返回此字段,需要在【获取访问用户敏感信息】接口中获取 + */ + private String bizMail; + /** + * 代开发自建应用类型于2022年6月20号后的新建应用将不再返回此字段,需要在【获取访问用户敏感信息】接口中获取 + */ private String avatar; private String thumbAvatar; private String mainDepartment; @@ -40,7 +56,7 @@ public class WxCpUser implements Serializable { private String openUserId; /** - * 地址。长度最大128个字符 + * 地址。长度最大128个字符,代开发自建应用类型于2022年6月20号后的新建应用将不再返回此字段,需要在【获取访问用户敏感信息】接口中获取 */ private String address; private String avatarMediaId; @@ -60,6 +76,9 @@ public class WxCpUser implements Serializable { private Integer hideMobile; private String englishName; private String telephone; + /** + * 代开发自建应用类型于2022年6月20号后的新建应用将不再返回此字段,需要在【获取访问用户敏感信息】接口中获取 + */ private String qrCode; private Boolean toInvite; /** @@ -70,29 +89,59 @@ public class WxCpUser implements Serializable { private String externalCorpName; private WechatChannels wechatChannels; + private String[] directLeader; - + /** + * Add external attr. + * + * @param externalAttr the external attr + */ public void addExternalAttr(ExternalAttribute externalAttr) { this.externalAttrs.add(externalAttr); } + /** + * Add ext attr. + * + * @param name the name + * @param value the value + */ public void addExtAttr(String name, String value) { this.extAttrs.add(new Attr().setType(0).setName(name).setTextValue(value)); } + /** + * Add ext attr. + * + * @param attr the attr + */ public void addExtAttr(Attr attr) { this.extAttrs.add(attr); } + /** + * From json wx cp user. + * + * @param json the json + * @return the wx cp user + */ public static WxCpUser fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUser.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } + /** + * The type Attr. + */ @Data @Accessors(chain = true) @Builder @@ -111,6 +160,9 @@ public static class Attr implements Serializable { private String webTitle; } + /** + * The type External attribute. + */ @Data @Builder @NoArgsConstructor @@ -150,6 +202,9 @@ public static class ExternalAttribute implements Serializable { } + /** + * The type Wechat channels. + */ @Data @Builder @NoArgsConstructor diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserDetail.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserDetail.java index 7c4af4df68..07e2017e69 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserDetail.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserDetail.java @@ -1,14 +1,15 @@ package me.chanjar.weixin.cp.bean; -import java.io.Serializable; - import com.google.gson.annotations.SerializedName; import lombok.Data; +import java.io.Serializable; + /** *
  *  使用user_ticket获取成员详情接口返回类.
  *  Created by BinaryWang on 2018/4/22.
+ *  官方文档:https://developer.work.weixin.qq.com/document/path/91122
  * 
* * @author Binary Wang @@ -24,7 +25,7 @@ public class WxCpUserDetail implements Serializable { private String userId; /** - * 成员姓名 + * 成员姓名,2022年6月20号后的新应用将不再返回此字段,旧应用正常返回 */ private String name; @@ -54,4 +55,15 @@ public class WxCpUserDetail implements Serializable { @SerializedName("qr_code") private String qrCode; + /** + * 企业邮箱,仅在用户同意snsapi_privateinfo授权时返回,2022年6月20号后的新应用将返回 + */ + @SerializedName("biz_mail") + private String bizMail; + + /** + * 地址,仅在用户同意snsapi_privateinfo授权时返回,2022年6月20号后的新应用将返回 + */ + private String address; + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalContactInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalContactInfo.java index 6a9e2c8e74..562bf82ed6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalContactInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalContactInfo.java @@ -27,6 +27,9 @@ public class WxCpUserExternalContactInfo implements Serializable { @SerializedName("follow_user") private List followedUsers; + /** + * The type External contact. + */ @Getter @Setter public static class ExternalContact implements Serializable { @@ -63,6 +66,9 @@ public static class ExternalContact implements Serializable { private ExternalProfile externalProfile; } + /** + * The type External profile. + */ @Setter @Getter public static class ExternalProfile implements Serializable { @@ -72,12 +78,19 @@ public static class ExternalProfile implements Serializable { private List externalAttrs; } + /** + * The type External attribute. + */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class ExternalAttribute implements Serializable { private static final long serialVersionUID = -5696099236344075582L; + + /** + * The type Text. + */ @Setter @Getter public static class Text implements Serializable { @@ -86,6 +99,9 @@ public static class Text implements Serializable { private String value; } + /** + * The type Web. + */ @Setter @Getter public static class Web implements Serializable { @@ -95,6 +111,9 @@ public static class Web implements Serializable { private String url; } + /** + * The type Mini program. + */ @Setter @Getter public static class MiniProgram implements Serializable { @@ -118,11 +137,14 @@ public static class MiniProgram implements Serializable { private MiniProgram miniProgram; } + /** + * The type Followed user. + */ @Setter @Getter public static class FollowedUser implements Serializable { private static final long serialVersionUID = -5696099236344075582L; - + @SerializedName("userid") private String userId; private String remark; @@ -142,10 +164,19 @@ public static class FollowedUser implements Serializable { } + /** + * From json wx cp user external contact info. + * + * @param json the json + * @return the wx cp user external contact info + */ public static WxCpUserExternalContactInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalContactInfo.class); } + /** + * The type Tag. + */ @Setter @Getter public static class Tag implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUseridToOpenUserid.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUseridToOpenUserid.java new file mode 100644 index 0000000000..5f2f082a7d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUseridToOpenUserid.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * userid转换为open_userid + * 将自建应用或代开发应用获取的userid转换为第三方应用的userid + * 中间对象 + * Created by gxh0797 on 2022.07.26. + */ +@Data +public class WxCpUseridToOpenUserid implements Serializable { + private static final long serialVersionUID = 1420065684270213578L; + + @Override + public String toString() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * From json wx cp userid to open userid. + * + * @param json the json + * @return the wx cp userid to open userid + */ + public static WxCpUseridToOpenUserid fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpUseridToOpenUserid.class); + } + + @SerializedName("userid") + private String userid; + + @SerializedName("open_userid") + private String openUserid; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUseridToOpenUseridResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUseridToOpenUseridResult.java new file mode 100644 index 0000000000..360772883b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUseridToOpenUseridResult.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * userid转换为open_userid + * 将自建应用或代开发应用获取的userid转换为第三方应用的userid + * Created by gxh0797 on 2022.07.26. + */ +@Data +public class WxCpUseridToOpenUseridResult implements Serializable { + private static final long serialVersionUID = 1420065684270213578L; + + @Override + public String toString() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * From json wx cp userid to open userid result. + * + * @param json the json + * @return the wx cp userid to open userid result + */ + public static WxCpUseridToOpenUseridResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpUseridToOpenUseridResult.class); + } + + @SerializedName("errcode") + private Integer errCode; + + @SerializedName("errmsg") + private String errMsg; + + @SerializedName("open_userid_list") + private List openUseridList; + + @SerializedName("invalid_userid_list") + private List invalidUseridList; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxTpCustomizedAuthUrl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxTpCustomizedAuthUrl.java new file mode 100644 index 0000000000..daf8170956 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxTpCustomizedAuthUrl.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * @author freedom + * @since 2022/10/20 16:36 + */ +@Data +public class WxTpCustomizedAuthUrl extends WxCpBaseResp { + + /** + * 可用来生成二维码的授权url,需要开发者自行生成为二维码 + */ + @SerializedName("qrcode_url") + private String qrCodeURL; + + /** + * 有效期(秒)。10天过期。 + */ + @SerializedName("expires_in") + private Integer expiresIn; + + /** + * From json wx cp tp customized auth url. + * + * @param json the json + * @return the wx cp tp customized auth url + */ + public static WxTpCustomizedAuthUrl fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxTpCustomizedAuthUrl.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxTpLoginInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxTpLoginInfo.java index d3c21aa7be..5cadc6bca7 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxTpLoginInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxTpLoginInfo.java @@ -11,9 +11,8 @@ /** * 登录信息 * - * @author Jamie.shi - * @date 2020-08-03 17:18 - **/ + * @author Jamie.shi created on 2020-08-03 17:18 + */ @Data @EqualsAndHashCode(callSuper = true) public class WxTpLoginInfo extends WxCpBaseResp { @@ -29,10 +28,19 @@ public class WxTpLoginInfo extends WxCpBaseResp { private AuthInfo authInfo; private List agent; + /** + * From json wx tp login info. + * + * @param json the json + * @return the wx tp login info + */ public static WxTpLoginInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxTpLoginInfo.class); } + /** + * The type User info. + */ @Data public static class UserInfo implements Serializable { private static final long serialVersionUID = -4558358748587735192L; @@ -45,6 +53,9 @@ public static class UserInfo implements Serializable { private String avatar; } + /** + * The type Corp info bean. + */ @Data public static class CorpInfoBean implements Serializable { private static final long serialVersionUID = -3160146744148144984L; @@ -53,12 +64,18 @@ public static class CorpInfoBean implements Serializable { private String corpId; } + /** + * The type Auth info. + */ @Data public static class AuthInfo implements Serializable { private static final long serialVersionUID = -8697184659526210472L; private List department; + /** + * The type Department. + */ @Data public static class Department implements Serializable { private static final long serialVersionUID = -4389328276936557541L; @@ -68,6 +85,9 @@ public static class Department implements Serializable { } } + /** + * The type Agent. + */ @Data public static class Agent implements Serializable { private static final long serialVersionUID = 1461544500964159037L; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java index 854c0ca89a..f1e199939c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java @@ -20,18 +20,22 @@ @NoArgsConstructor public class NewArticle implements Serializable { private static final long serialVersionUID = 4087852055781140659L; + /** * 标题,不超过128个字节,超过会自动截断 */ private String title; + /** * 描述,不超过512个字节,超过会自动截断 */ private String description; + /** * 点击后跳转的链接。 */ private String url; + /** * 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图1068*455,小图150*150。 */ @@ -41,4 +45,15 @@ public class NewArticle implements Serializable { * 按钮文字,仅在图文数为1条时才生效。 默认为“阅读全文”, 不超过4个文字,超过自动截断。该设置只在企业微信上生效,微工作台(原企业号)上不生效。 */ private String btnText; + + /** + * 小程序appid,必须是与当前应用关联的小程序,appid和pagepath必须同时填写,填写后会忽略url字段 + */ + private String appid; + + /** + * 点击消息卡片后的小程序页面,仅限本小程序内的页面。appid和pagepath必须同时填写,填写后会忽略url字段 + */ + private String pagepath; + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorp.java new file mode 100644 index 0000000000..aa31ed2444 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorp.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.cp.bean.corpgroup; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * @author libo + */ +@NoArgsConstructor +@Data +public class WxCpCorpGroupCorp implements Serializable { + + private static final long serialVersionUID = 6842919838272832415L; + @SerializedName("corpid") + private String corpid; + @SerializedName("corp_name") + private String corpName; + @SerializedName("agentid") + private Integer agentid; + + public static WxCpCorpGroupCorp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCorpGroupCorp.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpGetTokenReq.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpGetTokenReq.java new file mode 100644 index 0000000000..6370fc7c11 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpGetTokenReq.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.cp.bean.corpgroup; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 获取下级/下游企业的access_token + * @author libo + */ +@Data +public class WxCpCorpGroupCorpGetTokenReq implements Serializable { + private static final long serialVersionUID = -1876754768932436524L; + @SerializedName("corpid") + private String corpId; + @SerializedName("business_type") + private int businessType; + @SerializedName("agentid") + private int agentId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpListAppShareInfoResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpListAppShareInfoResp.java new file mode 100644 index 0000000000..1f02307f87 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpListAppShareInfoResp.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.cp.bean.corpgroup; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; + +import java.io.Serializable; +import java.util.List; + +/** + * 获取应用共享信息返回类 + * @author libo + */ +@Data +public class WxCpCorpGroupCorpListAppShareInfoResp implements Serializable { + private static final long serialVersionUID = 7165788382879237583L; + @SerializedName("ending") + private int ending; + @SerializedName("corp_list") + private List corpList; + @SerializedName("next_cursor") + private String nextCursor; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpToken.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpToken.java new file mode 100644 index 0000000000..912ebd5edf --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpToken.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.cp.bean.corpgroup; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 获取下级/下游企业的access_token返回类 + * @author libo + */ +@Data +public class WxCpCorpGroupCorpToken implements Serializable { + private static final long serialVersionUID = -8139617060677460515L; + @SerializedName("access_token") + private String accessToken; + @SerializedName("expires_in") + private int expiresIn; + + public static WxCpCorpGroupCorpToken fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCorpGroupCorpToken.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpMaTransferSession.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpMaTransferSession.java new file mode 100644 index 0000000000..c88f0d31f2 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpMaTransferSession.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.cp.bean.corpgroup; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 获取下级/下游企业小程序session返回类 + * + * @author libo + */ +@Data +public class WxCpMaTransferSession implements Serializable { + + private static final long serialVersionUID = 4189407986285166516L; + @SerializedName("userid") + private String userId; + @SerializedName("session_key") + private String sessionKey; + + + /** + * From json WxCpMaTransferSession. + * + * @param json the json + * @return the WxCpMaTransferSession + */ + public static WxCpMaTransferSession fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpMaTransferSession.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/export/WxCpExportRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/export/WxCpExportRequest.java new file mode 100644 index 0000000000..c2b0bce03c --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/export/WxCpExportRequest.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.cp.bean.export; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 异步导出参数 + * + * @author zhongjun created on 2022/4/21 + */ +@Data +public class WxCpExportRequest implements Serializable { + private static final long serialVersionUID = -8127528999898984359L; + + /** + * base64encode的加密密钥,长度固定为43,base64decode之后即得到AESKey。加密方式采用AES-256-CBC方式,数据采用PKCS#7填充至32字节的倍数;IV初始向量大小为16字节,取AESKey + * 前16字节,详见:http://tools.ietf.org/html/rfc2315 + */ + @SerializedName("encoding_aeskey") + private String encodingAesKey; + + /** + * 每块数据的部门数,支持范围[104,106],默认值为10^6 + */ + @SerializedName("block_size") + private Integer blockSize; + + /** + * 需要导出的标签 + * 导出标签成员时使用 + */ + @SerializedName("tagid") + private Integer tagId; + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/export/WxCpExportResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/export/WxCpExportResult.java new file mode 100644 index 0000000000..86f52ab8c7 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/export/WxCpExportResult.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.cp.bean.export; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; + +import java.util.List; + +/** + * 异步导出响应 + * + * @author zhongjun created on 2022/4/21 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpExportResult extends WxCpBaseResp { + private static final long serialVersionUID = -8673839248829238966L; + + /** + * 任务状态:0-未处理,1-处理中,2-完成,3-异常失败 + */ + private Integer status; + + @SerializedName("data_list") + private List dataList; + + + /** + * The type Export data. + */ + @Data + public static class ExportData { + + /** + * 数据下载链接,支持指定Range头部分段下载。有效期2个小时 + */ + private String url; + + /** + * 密文数据大小 + */ + private Integer size; + + /** + * 密文数据md5 + */ + private String md5; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpAddMomentResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpAddMomentResult.java new file mode 100644 index 0000000000..1eb7ad1075 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpAddMomentResult.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean.external; + +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; + +/** + * 企业发表内容到客户的朋友圈 创建发表任务结果 + * + * @author leiin created on 2021-10-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpAddMomentResult extends WxCpBaseResp { + private static final long serialVersionUID = -7212260280504857210L; + + @SerializedName("jobid") + private String jobId; + + /** + * From json wx cp add moment result. + * + * @param json the json + * @return the wx cp add moment result + */ + public static WxCpAddMomentResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpAddMomentResult.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpAddMomentTask.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpAddMomentTask.java new file mode 100644 index 0000000000..005c4f3ded --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpAddMomentTask.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.external.moment.VisibleRange; +import me.chanjar.weixin.cp.bean.external.msg.Attachment; +import me.chanjar.weixin.cp.bean.external.msg.Text; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 企业发表内容到客户的朋友圈 创建发表任务 + * + * @author leiin created on 2021-10-29 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpAddMomentTask implements Serializable { + @SerializedName("visible_range") + private VisibleRange visibleRange; + + private Text text; + + private List attachments; + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayInfo.java index 35f6a6eaa0..3a6a61902c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayInfo.java @@ -25,6 +25,9 @@ public class WxCpContactWayInfo implements Serializable { @SerializedName("contact_way") private ContactWay contactWay; + /** + * The type Contact way. + */ @Getter @Setter public static class ContactWay implements Serializable { @@ -157,10 +160,21 @@ public static class ContactWay implements Serializable { */ private Conclusion conclusions; + /** + * From json wx cp contact way info . contact way. + * + * @param json the json + * @return the wx cp contact way info . contact way + */ public static WxCpContactWayInfo.ContactWay fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.ContactWay.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } @@ -189,14 +203,28 @@ public static class Conclusion implements Serializable { } + /** + * From json wx cp contact way info. + * + * @param json the json + * @return the wx cp contact way info + */ public static WxCpContactWayInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } + /** + * The enum Type. + */ public enum TYPE { /** * 单人 @@ -208,10 +236,13 @@ public enum TYPE { * 多人 */ @SerializedName("2") - MULTI; + MULTI } + /** + * The enum Scene. + */ public enum SCENE { /** @@ -224,7 +255,7 @@ public enum SCENE { * 通过二维码联系 */ @SerializedName("2") - QRCODE; + QRCODE } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayResult.java index 6bb9c41398..157a0ecacf 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayResult.java @@ -2,20 +2,32 @@ 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; /** * 「联系我」方式 处理结果 + * + * @author 爱因斯唐 */ @Data +@EqualsAndHashCode(callSuper = true) public class WxCpContactWayResult extends WxCpBaseResp { + private static final long serialVersionUID = -2612867517869192015L; + @SerializedName("config_id") private String configId; @SerializedName("qr_code") private String qrCode; + /** + * From json wx cp contact way result. + * + * @param json the json + * @return the wx cp contact way result + */ public static WxCpContactWayResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayResult.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpExternalUserIdList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpExternalUserIdList.java new file mode 100644 index 0000000000..693dd80018 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpExternalUserIdList.java @@ -0,0 +1,62 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 企业客户微信unionid的升级 - 企业客户external_userid列表 + * + * @author Mr.Pan created on 2021/11/18 + */ +@Getter +@Setter +public class WxCpExternalUserIdList extends WxCpBaseResp { + private static final long serialVersionUID = 3922210865083522513L; + + @SerializedName("external_userid_info") + private List externalUserIdInfo; + + /** + * The type External user id info. + */ + @Getter + @Setter + public static class ExternalUserIdInfo implements Serializable { + private static final long serialVersionUID = 8846290993790709261L; + + /** + * 所属企业id + */ + @SerializedName("corpid") + private String corpId; + + /** + * 外部联系人id + */ + @SerializedName("external_userid") + private String externalUserId; + + /** + * 新外部联系人id + */ + @SerializedName("new_external_userid") + private String newExternalUserId; + + } + + /** + * From json wx cp external user id list. + * + * @param json the json + * @return the wx cp external user id list + */ + public static WxCpExternalUserIdList fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpExternalUserIdList.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentComments.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentComments.java new file mode 100644 index 0000000000..b1c9149445 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentComments.java @@ -0,0 +1,55 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 企业发表内容到客户的朋友圈 获取客户朋友圈的互动数据 + * + * @author leiin created on 2021-10-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpGetMomentComments extends WxCpBaseResp { + private static final long serialVersionUID = -9056664072546234965L; + + @SerializedName("comment_list") + private List commentList; + @SerializedName("like_list") + private List likeList; + + /** + * The type Comment like item. + */ + @Getter + @Setter + public static class CommentLikeItem { + @SerializedName("external_userid") + private String externalUserId; + @SerializedName("userid") + private String userid; + @SerializedName("create_time") + private Long createTime; + } + + /** + * From json wx cp get moment comments. + * + * @param json the json + * @return the wx cp get moment comments + */ + public static WxCpGetMomentComments fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGetMomentComments.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentCustomerList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentCustomerList.java new file mode 100644 index 0000000000..c10c2f69da --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentCustomerList.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.external.moment.CustomerItem; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 企业发表内容到客户的朋友圈 获取客户朋友圈发表时选择的可见范围 + * + * @author leiin created on 2021-10-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpGetMomentCustomerList extends WxCpBaseResp { + private static final long serialVersionUID = -8792120670063917097L; + + @SerializedName("next_cursor") + private String nextCursor; + @SerializedName("customer_list") + private List customerList; + + /** + * From json wx cp get moment customer list. + * + * @param json the json + * @return the wx cp get moment customer list + */ + public static WxCpGetMomentCustomerList fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGetMomentCustomerList.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentList.java new file mode 100644 index 0000000000..46b17a1b5c --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentList.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.external.moment.MomentInfo; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 企业发表内容到客户的朋友圈 获取企业全部的发表列表 + * + * @author leiin created on 2021-10-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpGetMomentList extends WxCpBaseResp { + private static final long serialVersionUID = 106159971765109008L; + + @SerializedName("next_cursor") + private String nextCursor; + @SerializedName("moment_list") + private List momentList; + + /** + * From json wx cp get moment list. + * + * @param json the json + * @return the wx cp get moment list + */ + public static WxCpGetMomentList fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGetMomentList.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentSendResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentSendResult.java new file mode 100644 index 0000000000..80e4f144cf --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentSendResult.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.external.moment.CustomerItem; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 企业发表内容到客户的朋友圈 获取客户朋友圈发表后的可见客户列表 + * + * @author leiin created on 2021-10-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpGetMomentSendResult extends WxCpBaseResp { + private static final long serialVersionUID = -5782811995184523379L; + + @SerializedName("next_cursor") + private String nextCursor; + @SerializedName("customer_list") + private List customerList; + + /** + * From json wx cp get moment send result. + * + * @param json the json + * @return the wx cp get moment send result + */ + public static WxCpGetMomentSendResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGetMomentSendResult.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentTask.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentTask.java new file mode 100644 index 0000000000..46740d6e04 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentTask.java @@ -0,0 +1,54 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 企业发表内容到客户的朋友圈 获取客户朋友圈企业发表的列表 + * + * @author leiin created on 2021-10-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpGetMomentTask extends WxCpBaseResp { + private static final long serialVersionUID = 5621905029624794129L; + + @SerializedName("next_cursor") + private String nextCursor; + + @SerializedName("task_list") + private List taskList; + + /** + * The type Moment task item. + */ + @Getter + @Setter + public static class MomentTaskItem { + @SerializedName("userid") + private String userId; + @SerializedName("publish_status") + private String publishStatus; + } + + /** + * From json wx cp get moment task. + * + * @param json the json + * @return the wx cp get moment task + */ + public static WxCpGetMomentTask fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGetMomentTask.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentTaskResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentTaskResult.java new file mode 100644 index 0000000000..6f6a535044 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGetMomentTaskResult.java @@ -0,0 +1,70 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.external.moment.ExternalContactList; +import me.chanjar.weixin.cp.bean.external.moment.SenderList; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 企业发表内容到客户的朋友圈 获取任务创建结果 + * + * @author leiin created on 2021-10-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpGetMomentTaskResult extends WxCpBaseResp { + private static final long serialVersionUID = 2515140928288915077L; + + private Integer status; + private String type; + private TaskResult result; + + /** + * The type Task result. + */ + @Getter + @Setter + public static class TaskResult extends WxCpBaseResp { + private static final long serialVersionUID = 2162642873632126707L; + + @SerializedName("moment_id") + private String momentId; + @SerializedName("invalid_sender_list") + private SenderList invalidSenderList; + @SerializedName("invalid_external_contact_list") + private ExternalContactList invalidExternalContactList; + + /** + * From json task result. + * + * @param json the json + * @return the task result + */ + public static TaskResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, TaskResult.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + } + + /** + * From json wx cp get moment task result. + * + * @param json the json + * @return the wx cp get moment task result + */ + public static WxCpGetMomentTaskResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGetMomentTaskResult.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupJoinWayInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupJoinWayInfo.java new file mode 100644 index 0000000000..c181f82bd4 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupJoinWayInfo.java @@ -0,0 +1,120 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 客户群「加入群聊」对象 + * + * @author Jc + */ +@Data +@NoArgsConstructor +public class WxCpGroupJoinWayInfo implements Serializable { + private static final long serialVersionUID = 5621905029624794129L; + @SerializedName("join_way") + private JoinWay joinWay; + + /** + * The type Join way. + */ + @Getter + @Setter + public static class JoinWay implements Serializable { + private static final long serialVersionUID = 5621905029624794122L; + + /** + * 联系方式的配置id + */ + @SerializedName("config_id") + private String configId; + /** + * 场景。 + * 1 - 群的小程序插件 + * 2 - 群的二维码插件 + */ + @SerializedName("scene") + private Integer scene; + /** + * 联系方式的备注信息,用于助记,超过30个字符将被截断 + */ + @SerializedName("remark") + private String remark; + /** + * 当群满了后,是否自动新建群。0-否;1-是。 默认为1 + */ + @SerializedName("auto_create_room") + private Integer autoCreateRoom; + /** + * 自动建群的群名前缀,当auto_create_room为1时有效。最长40个utf8字符 + */ + @SerializedName("room_base_name") + private String roomBaseName; + /** + * 自动建群的群起始序号,当auto_create_room为1时有效 + */ + @SerializedName("room_base_id") + private Integer roomBaseId; + /** + * 使用该配置的客户群ID列表,支持5个。 + */ + @SerializedName("chat_id_list") + private List chatIdList; + /** + * 联系二维码的URL,仅在配置为群二维码时返回 + */ + @SerializedName("qr_code") + private String qrCode; + /** + * 企业自定义的state参数,用于区分不同的入群渠道。不超过30个UTF-8字符 + * 如果有设置此参数,在调用获取客户群详情接口时会返回每个群成员对应的该参数值 + */ + @SerializedName("state") + private String state; + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * From json wx cp group join way info . join way. + * + * @param json the json + * @return the wx cp group join way info . join way + */ + public static WxCpGroupJoinWayInfo.JoinWay fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupJoinWayInfo.JoinWay.class); + } + } + + /** + * From json wx cp group join way info. + * + * @param json the json + * @return the wx cp group join way info + */ + public static WxCpGroupJoinWayInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupJoinWayInfo.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupJoinWayResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupJoinWayResult.java new file mode 100644 index 0000000000..adfd90a3a3 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupJoinWayResult.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.cp.bean.external; + +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; + +/** + * 客户群「加入群聊」配置处理结果 + * + * @author Jc + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpGroupJoinWayResult extends WxCpBaseResp { + private static final long serialVersionUID = 5621905029624794129L; + @SerializedName("config_id") + private String configId; + + /** + * From json wx cp group join way result. + * + * @param json the json + * @return the wx cp group join way result + */ + public static WxCpGroupJoinWayResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupJoinWayResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupWelcomeTemplateResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupWelcomeTemplateResult.java new file mode 100644 index 0000000000..5f4fbe5696 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpGroupWelcomeTemplateResult.java @@ -0,0 +1,61 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.*; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.external.msg.*; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 入群欢迎语素材. + * + * @author Mr.Pan created on 2021-11-3 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class WxCpGroupWelcomeTemplateResult extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = -6406667238670580612L; + + private Text text; + + private Image image; + + private Link link; + + private MiniProgram miniprogram; + + private File file; + + private Video video; + + /** + * 欢迎语素材id + * https://developer.work.weixin.qq.com/document/path/92366 + */ + @SerializedName("template_id") + private String templateId; + + /** + * 是否通知成员将这条入群欢迎语应用到客户群中,0-不通知,1-通知, 不填则通知 + */ + private Integer notify; + + /** + * From json wx cp group welcome template result. + * + * @param json the json + * @return the wx cp group welcome template result + */ + public static WxCpGroupWelcomeTemplateResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupWelcomeTemplateResult.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplate.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplate.java index 295eecb636..6c546daa83 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplate.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplate.java @@ -5,9 +5,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import me.chanjar.weixin.cp.bean.external.msg.Image; -import me.chanjar.weixin.cp.bean.external.msg.Link; -import me.chanjar.weixin.cp.bean.external.msg.MiniProgram; +import me.chanjar.weixin.cp.bean.external.msg.Attachment; import me.chanjar.weixin.cp.bean.external.msg.Text; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; @@ -19,7 +17,7 @@ *

* Created by songfan on 2020/7/14. * - * @author songfan + * @author songfan & Mr.Pan */ @Data @Builder @@ -28,26 +26,60 @@ public class WxCpMsgTemplate implements Serializable { private static final long serialVersionUID = 3172331565173474358L; + /** + * 群发任务的类型,默认为single,表示发送给客户,group表示发送给客户群 + */ @SerializedName("chat_type") private String chatType; + /** + * 客户的外部联系人id列表,仅在chat_type为single时有效,不可与sender同时为空,最多可传入1万个客户 + */ @SerializedName("external_userid") private List externalUserid; - private String sender; + /** + * 客户群id列表,仅在chat_type为group时有效,最多可一次指定2000个客户群。指定群id之后,收到任务的群主无须再选择客户群,仅对4.1.10及以上版本的企业微信终端生效 + */ + @SerializedName("chat_id_list") + private List chatIdList; - private Text text; + /** + * 发送企业群发消息的成员userid,当类型为发送给客户群时必填 + */ + private String sender; - private Image image; + /** + * 是否允许成员在待发送客户列表中重新进行选择,默认为false,仅支持客户群发场景 + */ + @SerializedName("allow_select") + private Boolean allowSelect; - private Link link; + /** + * 消息文本内容,最多4000个字节 + */ + private Text text; - private MiniProgram miniprogram; + /** + * 附件,最多支持添加9个附件 + */ + private List attachments; + /** + * From json wx cp msg template. + * + * @param json the json + * @return the wx cp msg template + */ public static WxCpMsgTemplate fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpMsgTemplate.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplateAddResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplateAddResult.java index 87e0be4467..42f796c808 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplateAddResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpMsgTemplateAddResult.java @@ -28,10 +28,21 @@ public class WxCpMsgTemplateAddResult implements Serializable { @SerializedName("msgid") private String msgId; + /** + * From json wx cp msg template add result. + * + * @param json the json + * @return the wx cp msg template add result + */ public static WxCpMsgTemplateAddResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpMsgTemplateAddResult.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpNewExternalUserIdList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpNewExternalUserIdList.java new file mode 100644 index 0000000000..9f7a5c01e3 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpNewExternalUserIdList.java @@ -0,0 +1,55 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 企业客户微信unionid的升级 - 企业客户external_userid列表 + * + * @author Mr.Pan created on 2021/11/18 + */ +@Getter +@Setter +public class WxCpNewExternalUserIdList extends WxCpBaseResp { + + @SerializedName("items") + private List items; + + /** + * The type New external user id info. + */ + @Getter + @Setter + public static class NewExternalUserIdInfo implements Serializable { + private static final long serialVersionUID = 8846290993790709261L; + + /** + * 外部联系人id + */ + @SerializedName("external_userid") + private String externalUserId; + + /** + * 新外部联系人id + */ + @SerializedName("new_external_userid") + private String newExternalUserId; + + } + + /** + * From json wx cp new external user id list. + * + * @param json the json + * @return the wx cp new external user id list + */ + public static WxCpNewExternalUserIdList fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpNewExternalUserIdList.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumInfo.java new file mode 100644 index 0000000000..a30fb1600a --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumInfo.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.external.product.Attachment; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 获取商品图册
+ * 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
+ * 
+ * + * @author Lo_ading + */ +@Getter +@Setter +public class WxCpProductAlbumInfo implements Serializable { + private static final long serialVersionUID = -8338202601802366899L; + + @SerializedName("product_id") + private String productId; + + @SerializedName("product_sn") + private String productSn; + + @SerializedName("description") + private String description; + + /** + * NOTE: 20211110 价钱返回全部为0 + */ + @SerializedName("price") + private Integer price; + + /** + * NOTE: 20211110 商品列表接口不返回此字段, 商品详情接口返回 + */ + @SerializedName("create_time") + private Long createTime; + + @SerializedName("attachments") + private List attachments; + + /** + * From json wx cp product album info. + * + * @param json the json + * @return the wx cp product album info + */ + public static WxCpProductAlbumInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumInfo.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumListResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumListResult.java new file mode 100644 index 0000000000..895d132376 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumListResult.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 获取商品图册列表执行结果
+ * 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表
+ * 
+ * + * @author Lo_ading + */ +@Getter +@Setter +public class WxCpProductAlbumListResult extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 121265727802015428L; + + @SerializedName("product_list") + private List productList; + + @SerializedName("next_cursor") + private String nextCursor; + + /** + * From json wx cp product album list result. + * + * @param json the json + * @return the wx cp product album list result + */ + public static WxCpProductAlbumListResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumListResult.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumResult.java new file mode 100644 index 0000000000..8088b8405b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumResult.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.cp.bean.external; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + *
+ * 获取商品图册执行结果
+ * 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
+ * 
+ * + * @author Lo_ading + */ +@Getter +@Setter +public class WxCpProductAlbumResult extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 4076734101839851497L; + + @SerializedName("product") + private WxCpProductAlbumInfo product; + + /** + * From json wx cp product album result. + * + * @param json the json + * @return the wx cp product album result + */ + public static WxCpProductAlbumResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumResult.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequest.java index 678995590b..115e58f344 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequest.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequest.java @@ -13,8 +13,7 @@ /** * 修改客户备注信息请求. * - * @author Binary Wang - * @date 2020-09-19 + * @author Binary Wang created on 2020-09-19 */ @Data @Builder @@ -24,6 +23,11 @@ public class WxCpUpdateRemarkRequest implements Serializable { private static final long serialVersionUID = -4960239393895754138L; + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactList.java index 29e7e28e53..cc092b647f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactList.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactList.java @@ -30,31 +30,67 @@ public class WxCpUserExternalContactList implements Serializable { @Expose private List externalUserId = null; + /** + * Gets errcode. + * + * @return the errcode + */ public Long getErrcode() { return errcode; } + /** + * Sets errcode. + * + * @param errcode the errcode + */ public void setErrcode(Long errcode) { this.errcode = errcode; } + /** + * Gets errmsg. + * + * @return the errmsg + */ public String getErrmsg() { return errmsg; } + /** + * Sets errmsg. + * + * @param errmsg the errmsg + */ public void setErrmsg(String errmsg) { this.errmsg = errmsg; } + /** + * Gets external user id. + * + * @return the external user id + */ public List getExternalUserId() { return externalUserId; } + /** + * Sets external user id. + * + * @param externalUserId the external user id + */ public void setExternalUserId(List externalUserId) { this.externalUserId = externalUserId; } + /** + * From json wx cp user external contact list. + * + * @param json the json + * @return the wx cp user external contact list + */ public static WxCpUserExternalContactList fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalContactList.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatInfo.java index 053789f9c8..88f6c8a64b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatInfo.java @@ -10,8 +10,9 @@ import java.util.List; /** - * @author yqx - * @date 2020/3/116 + * The type Wx cp user external group chat info. + * + * @author yqx created on 2020/3/116 */ @Getter @Setter @@ -20,6 +21,9 @@ public class WxCpUserExternalGroupChatInfo extends WxCpBaseResp { @SerializedName("group_chat") private GroupChat groupChat; + /** + * The type Group chat. + */ @Getter @Setter public static class GroupChat implements Serializable { @@ -47,6 +51,9 @@ public static class GroupChat implements Serializable { private List adminList; } + /** + * The type Group member. + */ @Getter @Setter public static class GroupMember implements Serializable { @@ -83,6 +90,12 @@ public static class GroupMember implements Serializable { @SerializedName("join_scene") private int joinScene; + /** + * 该成员入群方式对应的state参数 + */ + @SerializedName("state") + private String state; + /** * 在群里的昵称 */ @@ -104,6 +117,9 @@ public static class GroupMember implements Serializable { private Invitor invitor; } + /** + * The type Invitor. + */ @Getter @Setter public static class Invitor { @@ -115,6 +131,9 @@ public static class Invitor { private String userId; } + /** + * The type Group admin. + */ @Getter @Setter public static class GroupAdmin { @@ -126,6 +145,12 @@ public static class GroupAdmin { private String userId; } + /** + * From json wx cp user external group chat info. + * + * @param json the json + * @return the wx cp user external group chat info + */ public static WxCpUserExternalGroupChatInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalGroupChatInfo.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatList.java index a9a9e6b48e..3727908949 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatList.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatList.java @@ -10,8 +10,9 @@ import java.util.List; /** - * @author yqx - * @date 2020/3/116 + * The type Wx cp user external group chat list. + * + * @author yqx created on 2020/3/116 */ @Getter @Setter @@ -24,6 +25,9 @@ public class WxCpUserExternalGroupChatList extends WxCpBaseResp { @SerializedName("next_cursor") private String nextCursor; + /** + * The type Chat status. + */ @Getter @Setter public static class ChatStatus implements Serializable { @@ -46,6 +50,12 @@ public static class ChatStatus implements Serializable { } + /** + * From json wx cp user external group chat list. + * + * @param json the json + * @return the wx cp user external group chat list + */ public static WxCpUserExternalGroupChatList fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalGroupChatList.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatStatistic.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatStatistic.java index 472f1a1648..e8e95d3b9f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatStatistic.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatStatistic.java @@ -12,8 +12,7 @@ /** * 联系客户群统计数据 * - * @author yqx - * @date 2020/3/16 + * @author yqx created on 2020/3/16 */ @Getter @Setter @@ -29,6 +28,9 @@ public class WxCpUserExternalGroupChatStatistic extends WxCpBaseResp { @SerializedName("items") private List itemList; + /** + * The type Statistic item. + */ @Getter @Setter public static class StatisticItem implements Serializable { @@ -41,6 +43,9 @@ public static class StatisticItem implements Serializable { private ItemData itemData; } + /** + * The type Item data. + */ @Getter @Setter public static class ItemData implements Serializable { @@ -89,6 +94,12 @@ public static class ItemData implements Serializable { private int msgTotal; } + /** + * From json wx cp user external group chat statistic. + * + * @param json the json + * @return the wx cp user external group chat statistic + */ public static WxCpUserExternalGroupChatStatistic fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalGroupChatStatistic.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatTransferResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatTransferResp.java index 4f4ee7ef1c..ea3ed39353 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatTransferResp.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalGroupChatTransferResp.java @@ -11,8 +11,7 @@ /** * 分配离职成员的客户群结果 * - * @author pg - * @date 2021年6月21日 + * @author pg created on 2021年6月21日 */ @Getter @Setter @@ -24,6 +23,12 @@ public class WxCpUserExternalGroupChatTransferResp extends WxCpBaseResp { @SerializedName("failed_chat_list") private List failedChatList; + /** + * From json wx cp user external group chat transfer resp. + * + * @param json the json + * @return the wx cp user external group chat transfer resp + */ public static WxCpUserExternalGroupChatTransferResp fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalGroupChatTransferResp.class); } @@ -32,6 +37,9 @@ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } + /** + * The type Group chat failed transfer. + */ @Getter @Setter public static class GroupChatFailedTransfer extends WxCpBaseResp { @@ -39,10 +47,18 @@ public static class GroupChatFailedTransfer extends WxCpBaseResp { /** * 没能成功继承的群ID */ + @SerializedName("chat_id") private String chatId; + /** + * From json wx cp user external group chat transfer resp . group chat failed transfer. + * + * @param json the json + * @return the wx cp user external group chat transfer resp . group chat failed transfer + */ public static WxCpUserExternalGroupChatTransferResp.GroupChatFailedTransfer fromJson(String json) { - return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalGroupChatTransferResp.GroupChatFailedTransfer.class); + return WxCpGsonBuilder.create().fromJson(json, + WxCpUserExternalGroupChatTransferResp.GroupChatFailedTransfer.class); } public String toJson() { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupInfo.java index 5893065962..59815ac8d9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupInfo.java @@ -11,7 +11,7 @@ import java.util.List; /** - * + * The type Wx cp user external tag group info. */ @Getter @Setter @@ -20,6 +20,9 @@ public class WxCpUserExternalTagGroupInfo extends WxCpBaseResp { @SerializedName("tag_group") private TagGroup tagGroup; + /** + * The type Tag group. + */ @Getter @Setter public static class TagGroup implements Serializable { @@ -35,7 +38,7 @@ public static class TagGroup implements Serializable { private Long createTime; @SerializedName("order") - private Integer order; + private Long order; @SerializedName("deleted") private Boolean deleted; @@ -43,11 +46,19 @@ public static class TagGroup implements Serializable { @SerializedName("tag") private List tag; + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxGsonBuilder.create().toJson(this); } } + /** + * The type Tag. + */ @Getter @Setter public static class Tag implements Serializable { @@ -67,7 +78,7 @@ public static class Tag implements Serializable { private Long createTime; @SerializedName("order") - private Integer order; + private Long order; @SerializedName("deleted") private Boolean deleted; @@ -78,6 +89,12 @@ public String toJson() { return WxGsonBuilder.create().toJson(this); } + /** + * From json wx cp user external tag group info. + * + * @param json the json + * @return the wx cp user external tag group info + */ public static WxCpUserExternalTagGroupInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalTagGroupInfo.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupList.java index a4d6257293..215eab2313 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupList.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalTagGroupList.java @@ -11,6 +11,8 @@ import java.util.List; /** + * The type Wx cp user external tag group list. + * * @author huangxm129 */ @Getter @@ -21,6 +23,9 @@ public class WxCpUserExternalTagGroupList extends WxCpBaseResp { @SerializedName("tag_group") private List tagGroupList; + /** + * The type Tag group. + */ @Getter @Setter public static class TagGroup implements Serializable { @@ -45,6 +50,9 @@ public static class TagGroup implements Serializable { @SerializedName("tag") private List tag; + /** + * The type Tag. + */ @Getter @Setter public static class Tag implements Serializable { @@ -75,6 +83,12 @@ public String toJson() { return WxGsonBuilder.create().toJson(this); } + /** + * From json wx cp user external tag group list. + * + * @param json the json + * @return the wx cp user external tag group list + */ public static WxCpUserExternalTagGroupList fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalTagGroupList.class); } 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 68d065a2d4..8605760fa7 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,8 +12,7 @@ /** * 离职员工外部联系人列表 * - * @author yqx - * @date 2020/3/15 + * @author yqx & Wang_Wong created on 2020/3/15 */ @Getter @Setter @@ -25,6 +24,12 @@ public class WxCpUserExternalUnassignList extends WxCpBaseResp { @SerializedName("is_last") private boolean isLast; + @SerializedName("next_cursor") + private String nextCursor; + + /** + * The type Unassign info. + */ @Getter @Setter public static class UnassignInfo implements Serializable { @@ -49,7 +54,18 @@ public static class UnassignInfo implements Serializable { private Long dimissionTime; } + /** + * From json wx cp user external unassign list. + * + * @param json the json + * @return the wx cp user external unassign list + */ public static WxCpUserExternalUnassignList fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalUnassignList.class); } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUserBehaviorStatistic.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUserBehaviorStatistic.java index 2e0325e307..b23208504b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUserBehaviorStatistic.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUserBehaviorStatistic.java @@ -12,8 +12,7 @@ /** * 联系客户统计数据 * - * @author yqx - * @date 2020/3/16 + * @author yqx created on 2020/3/16 */ @Getter @Setter @@ -22,6 +21,9 @@ public class WxCpUserExternalUserBehaviorStatistic extends WxCpBaseResp { @SerializedName("behavior_data") private List behaviorList; + /** + * The type Behavior. + */ @Getter @Setter public static class Behavior implements Serializable { @@ -37,45 +39,51 @@ public static class Behavior implements Serializable { * 聊天总数, 成员有主动发送过消息的聊天数,包括单聊和群聊。 */ @SerializedName("chat_cnt") - private int chatCnt; + private Integer chatCnt; /** * 发送消息数,成员在单聊和群聊中发送的消息总数。 */ @SerializedName("message_cnt") - private int messageCnt; + private Integer messageCnt; /** * 已回复聊天占比,客户主动发起聊天后,成员在一个自然日内有回复过消息的聊天数/客户主动发起的聊天数比例,不包括群聊,仅在确有回复时返回。 */ @SerializedName("reply_percentage") - private double replyPercentage; + private Double replyPercentage; /** * 平均首次回复时长,单位为分钟,即客户主动发起聊天后,成员在一个自然日内首次回复的时长间隔为首次回复时长,所有聊天的首次回复总时长/已回复的聊天总数即为平均首次回复时长,不包括群聊,仅在确有回复时返回。 */ @SerializedName("avg_reply_time") - private int avgReplyTime; + private Integer avgReplyTime; /** * 删除/拉黑成员的客户数,即将成员删除或加入黑名单的客户数。 */ @SerializedName("negative_feedback_cnt") - private int negativeFeedbackCnt; + private Integer negativeFeedbackCnt; /** * 发起申请数,成员通过「搜索手机号」、「扫一扫」、「从微信好友中添加」、「从群聊中添加」、「添加共享、分配给我的客户」、「添加单向、双向删除好友关系的好友」、「从新的联系人推荐中添加」等渠道主动向客户发起的好友申请数量。 */ @SerializedName("new_apply_cnt") - private int newApplyCnt; + private Integer newApplyCnt; /** * 新增客户数,成员新添加的客户数量。 */ @SerializedName("new_contact_cnt") - private int newContactCnt; + private Integer newContactCnt; } + /** + * From json wx cp user external user behavior statistic. + * + * @param json the json + * @return the wx cp user external user behavior statistic + */ public static WxCpUserExternalUserBehaviorStatistic fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalUserBehaviorStatistic.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerReq.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerReq.java index e8b8142cc6..3b14747d72 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerReq.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerReq.java @@ -12,8 +12,7 @@ /** * 转接在职成员的客户给其他成员,请求对象 * - * @author pg - * @date 2021年6月21日 + * @author pg created on 2021年6月21日 */ @Getter @Setter @@ -43,6 +42,11 @@ public class WxCpUserTransferCustomerReq implements Serializable { @SerializedName("transfer_success_msg") private String transferMsg; + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerResp.java index 27d1c0ad4c..dbb921ad09 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerResp.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferCustomerResp.java @@ -12,8 +12,7 @@ /** * 转接在职成员的客户给其他成员,返回对象 * - * @author pg - * @date 2021年6月21日 + * @author pg created on 2021年6月21日 */ @Getter @Setter @@ -24,6 +23,12 @@ public class WxCpUserTransferCustomerResp extends WxCpBaseResp { */ private List customer; + /** + * From json wx cp user transfer customer resp. + * + * @param json the json + * @return the wx cp user transfer customer resp + */ public static WxCpUserTransferCustomerResp fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserTransferCustomerResp.class); } @@ -49,10 +54,21 @@ public static class TransferCustomer implements Serializable { */ private Integer errcode; + /** + * From json wx cp user transfer customer resp . transfer customer. + * + * @param json the json + * @return the wx cp user transfer customer resp . transfer customer + */ public static WxCpUserTransferCustomerResp.TransferCustomer fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserTransferCustomerResp.TransferCustomer.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferResultResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferResultResp.java index 53380b55a3..948d267b42 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferResultResp.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserTransferResultResp.java @@ -12,8 +12,7 @@ /** * 在职成员的客户转接情况 * - * @author pg - * @date 2021年6月21日 + * @author pg created on 2021年6月21日 */ @Getter @Setter @@ -24,6 +23,12 @@ public class WxCpUserTransferResultResp extends WxCpBaseResp { private List customer; + /** + * From json wx cp user transfer result resp. + * + * @param json the json + * @return the wx cp user transfer result resp + */ public static WxCpUserTransferResultResp fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserTransferResultResp.class); } @@ -55,15 +60,29 @@ public static class TransferResult implements Serializable { @SerializedName("takeover_time") private Long takeOverTime; + /** + * From json wx cp user transfer result resp . transfer result. + * + * @param json the json + * @return the wx cp user transfer result resp . transfer result + */ public static WxCpUserTransferResultResp.TransferResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserTransferResultResp.TransferResult.class); } + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } } + /** + * The enum Status. + */ public enum STATUS { /** diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserWithExternalPermission.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserWithExternalPermission.java index d8366ff3f9..ca1fa8cdf3 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserWithExternalPermission.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserWithExternalPermission.java @@ -9,6 +9,8 @@ import java.util.List; /** + * The type Wx cp user with external permission. + * * @author 曹祖鹏 */ @Data @@ -26,6 +28,12 @@ public class WxCpUserWithExternalPermission implements Serializable { @Expose private List followers = null; + /** + * From json wx cp user with external permission. + * + * @param json the json + * @return the wx cp user with external permission + */ public static WxCpUserWithExternalPermission fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpUserWithExternalPermission.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpWelcomeMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpWelcomeMsg.java index ebe3634ef3..a0aae4b063 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpWelcomeMsg.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpWelcomeMsg.java @@ -15,8 +15,7 @@ /** * 新客户欢迎语. * - * @author Binary Wang - * @date 2020-08-16 + * @author Binary Wang created on 2020-08-16 */ @Data @Builder @@ -32,6 +31,11 @@ public class WxCpWelcomeMsg implements Serializable { private List attachments; + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCreateResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCreateResult.java new file mode 100644 index 0000000000..58739275f2 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCreateResult.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 创建获客助手链接结果 + * + * @author alien_zyl + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpCustomerAcquisitionCreateResult extends WxCpBaseResp { + private static final long serialVersionUID = -6301164294371861558L; + + private WxCpCustomerAcquisitionInfo.Link link; + + public static WxCpCustomerAcquisitionCreateResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionCreateResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCustomerList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCustomerList.java new file mode 100644 index 0000000000..728fde8944 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCustomerList.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 获取由获客链接添加的客户信息结果 + * + * @author alien_zyl + */ +@Data +public class WxCpCustomerAcquisitionCustomerList { + + @SerializedName("customer_list") + private List customerList; + + /** + * 分页游标,再下次请求时填写以获取之后分页的记录,如果已经没有更多的数据则返回空 + */ + @SerializedName("next_cursor") + private String nextCursor; + + + public static WxCpCustomerAcquisitionCustomerList fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionCustomerList.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + @Data + public static class Customer implements Serializable { + private static final long serialVersionUID = 4456053823277371278L; + + /** + * 客户external_userid + */ + @SerializedName("external_userid") + private String externalUserid; + + /** + * 通过获客链接添加此客户的跟进人userid + */ + @SerializedName("userid") + private String userid; + + /** + * 会话状态,0-客户未发消息 1-客户已发送消息 + */ + @SerializedName("chat_status") + private Integer chatStatus; + + /** + * 用于区分客户具体是通过哪个获客链接进行添加, + * 用户可在获客链接后拼接customer_channel=自定义字符串,字符串不超过64字节,超过会被截断。 + * 通过点击带有customer_channel参数的链接获取到的客户,调用获客信息接口或获取客户详情接口时,返回的state参数即为链接后拼接自定义字符串 + */ + @SerializedName("state") + private String state; + + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionInfo.java new file mode 100644 index 0000000000..2f1ea8a41c --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionInfo.java @@ -0,0 +1,103 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +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; +import java.util.List; + +/** + * 获客链接详情 + * + * @author alien_zyl + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpCustomerAcquisitionInfo extends WxCpBaseResp implements Serializable { + + private static final long serialVersionUID = -425354507473041229L; + /** + * link_id列表 + */ + @SerializedName("link") + private Link link; + + /** + * 分页游标,在下次请求时填写以获取之后分页的记录 + */ + @SerializedName("range") + private Range range; + + /** + * 是否无需验证,默认为true + */ + @SerializedName("skip_verify") + private Boolean skipVerify; + + public static WxCpCustomerAcquisitionInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionInfo.class); + } + + @Data + @EqualsAndHashCode(callSuper = true) + public static class Link extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 6750537220943228300L; + + /** + * 获客链接的id + */ + @SerializedName("link_id") + private String linkId; + + /** + * 获客链接的名称 + */ + @SerializedName("link_name") + private String linkName; + + /** + * 获客链接实际的url + */ + @SerializedName("url") + private String url; + + /** + * 创建时间 + */ + @SerializedName("create_time") + private Long createTime; + + public static Link fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Link.class); + } + } + + @Data + public static class Range implements Serializable { + private static final long serialVersionUID = -6343768645371744643L; + + /** + * 此获客链接关联的userid列表,最多可关联100个 + */ + @SerializedName("user_list") + private List userList; + + /** + * 此获客链接关联的部门id列表,部门覆盖总人数最多100个 + */ + @SerializedName("department_list") + private List departmentList; + + public static Range fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Range.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionList.java new file mode 100644 index 0000000000..8e391169fd --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionList.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +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; +import java.util.List; + +/** + * 获客链接列表 + * + * @author alien_zyl + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpCustomerAcquisitionList extends WxCpBaseResp implements Serializable { + + private static final long serialVersionUID = -4168552242409627573L; + + /** + * link_id列表 + */ + @SerializedName("link_id_list") + private List linkIdList; + + /** + * 分页游标,在下次请求时填写以获取之后分页的记录 + */ + @SerializedName("next_cursor") + private String nextCursor; + + public static WxCpCustomerAcquisitionList fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionList.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionQuota.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionQuota.java new file mode 100644 index 0000000000..feb83c02a3 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionQuota.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +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; + +/** + * 剩余使用量 + * + * @author alien_zyl + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpCustomerAcquisitionQuota extends WxCpBaseResp { + private static final long serialVersionUID = -3816540607590841079L; + + /** + * 历史累计使用量 + */ + @SerializedName("total") + private Integer total; + + /** + * 剩余使用量 + */ + @SerializedName("balance") + private Integer balance; + + public static WxCpCustomerAcquisitionQuota fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionQuota.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionRequest.java new file mode 100644 index 0000000000..d8d78bd3d6 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionRequest.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 创建/更新获客链接请求体 + * + * @author alien_zyl + */ +@Data +public class WxCpCustomerAcquisitionRequest { + + /** + * 获客链接的id + */ + @SerializedName("link_id") + private String linkId; + /** + * 链接名称 + */ + @SerializedName("link_name") + private String linkName; + + @SerializedName("range") + private WxCpCustomerAcquisitionInfo.Range range; + + /** + * 是否无需验证,默认为true + */ + @SerializedName("skip_verify") + private Boolean skipVerify; + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/ExternalContact.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/ExternalContact.java index 5b7f9e67b1..8129ee1818 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/ExternalContact.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/ExternalContact.java @@ -9,8 +9,7 @@ /** * 外部联系人. * - * @author Binary Wang - * @date 2020-11-04 + * @author Binary Wang created on 2020-11-04 */ @Getter @Setter @@ -26,6 +25,9 @@ public class ExternalContact implements Serializable { @SerializedName("name") private String name; + @SerializedName("nickname") + private String nickname; + @SerializedName("avatar") private String avatar; @@ -47,14 +49,43 @@ public class ExternalContact implements Serializable { @SerializedName("external_profile") private ExternalProfile externalProfile; + /** + * The type External profile. + */ @Data public static class ExternalProfile implements Serializable { private static final long serialVersionUID = -2899906589789022765L; + @SerializedName("external_corp_name") + private String externalCorpName; + + @SerializedName("wechat_channels") + private WechatChannel wechatChannels; + @SerializedName("external_attr") private List externalAttrs; } + /** + * The type Wechat channel. + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class WechatChannel implements Serializable { + + @SerializedName("nickname") + private String nickname; + + @SerializedName("status") + private Integer status; + + } + + /** + * The type External attribute. + */ @Data @Builder @NoArgsConstructor @@ -73,6 +104,9 @@ public static class ExternalAttribute implements Serializable { @SerializedName("miniprogram") private MiniProgram miniProgram; + /** + * The type Text. + */ @Data public static class Text implements Serializable { private static final long serialVersionUID = -8161579335600269094L; @@ -80,6 +114,9 @@ public static class Text implements Serializable { private String value; } + /** + * The type Web. + */ @Data public static class Web implements Serializable { private static final long serialVersionUID = 3664557135411521862L; @@ -88,6 +125,9 @@ public static class Web implements Serializable { private String url; } + /** + * The type Mini program. + */ @Data public static class MiniProgram implements Serializable { private static final long serialVersionUID = -5329210594501835796L; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/FollowedUser.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/FollowedUser.java index 541711e7e6..9517cf3d53 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/FollowedUser.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/FollowedUser.java @@ -8,8 +8,7 @@ /** * 添加了外部联系人的企业成员. * - * @author Binary Wang - * @date 2020-11-04 + * @author Binary Wang created on 2020-11-04 */ @Data public class FollowedUser implements Serializable { @@ -53,6 +52,15 @@ public class FollowedUser implements Serializable { @SerializedName("oper_userid") private String operatorUserId; + /** + * 该成员添加此客户的来源add_way为10时,对应的视频号信息 + */ + @SerializedName("wechat_channels") + private WechatChannels wechatChannels; + + /** + * The type Tag. + */ @Data public static class Tag implements Serializable { private static final long serialVersionUID = -7556237053703295482L; @@ -80,4 +88,22 @@ public static class Tag implements Serializable { */ private int type; } + + /** + * The type WechatChannels. + */ + @Data + public static class WechatChannels implements Serializable { + private static final long serialVersionUID = -7940080094561469369L; + + /** + * 视频号名称 + */ + private String nickname; + + /** + * 视频号添加场景,0-未知 1-视频号主页 2-视频号直播间 3-视频号留资服务(微信版本要求:iOS ≥ 8.0.20,Android ≥ 8.0.21,且添加时间不早于2022年4月21日。否则添加场景值为0) + */ + private Integer source; + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactBatchInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactBatchInfo.java index 65e3326132..de866fb306 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactBatchInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactBatchInfo.java @@ -28,6 +28,9 @@ public class WxCpExternalContactBatchInfo extends WxCpBaseResp implements Serial @SerializedName("next_cursor") private String nextCursor; + /** + * The type External contact info. + */ @Getter @Setter public static class ExternalContactInfo implements Serializable { @@ -41,6 +44,12 @@ public static class ExternalContactInfo implements Serializable { } + /** + * From json wx cp external contact batch info. + * + * @param json the json + * @return the wx cp external contact batch info + */ public static WxCpExternalContactBatchInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpExternalContactBatchInfo.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactInfo.java index cad105e711..1a58c7e1d7 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpExternalContactInfo.java @@ -29,6 +29,12 @@ public class WxCpExternalContactInfo implements Serializable { @SerializedName("next_cursor") private String nextCursor; + /** + * From json wx cp external contact info. + * + * @param json the json + * @return the wx cp external contact info + */ public static WxCpExternalContactInfo fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpExternalContactInfo.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgListResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgListResult.java new file mode 100644 index 0000000000..2b7879375e --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgListResult.java @@ -0,0 +1,69 @@ +package me.chanjar.weixin.cp.bean.external.contact; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.external.msg.Attachment; +import me.chanjar.weixin.cp.bean.external.msg.Text; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 获取企业群发成员执行结果
+ * 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/93338
+ * 
+ * + * @author Mr.Pan + */ +@Getter +@Setter +public class WxCpGroupMsgListResult extends WxCpBaseResp implements Serializable { + + private static final long serialVersionUID = 3464981991558716620L; + + @SerializedName("group_msg_list") + private List groupMsgList; + + @SerializedName("next_cursor") + private String nextCursor; + + /** + * The type External contact group msg info. + */ + @Getter + @Setter + public static class ExternalContactGroupMsgInfo implements Serializable { + + private static final long serialVersionUID = 3108435608725559381L; + @SerializedName("msgid") + private String msgId; + + private String creator; + + private Text text; + + private List attachments; + + @SerializedName("create_type") + private Integer createType; + + @SerializedName("create_time") + private Long createTime; + + } + + /** + * From json wx cp group msg list result. + * + * @param json the json + * @return the wx cp group msg list result + */ + public static WxCpGroupMsgListResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupMsgListResult.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResult.java new file mode 100644 index 0000000000..604700b3a2 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResult.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.cp.bean.external.contact; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 获取企业群发成员执行结果
+ * 参考文档:https://work.weixin.qq.com/api/doc/16251
+ * 
+ * + * @author Tim Sims + */ +@Getter +@Setter +public class WxCpGroupMsgResult extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = -5166048319463473186L; + + @SerializedName("detail_list") + private List detailList; + + @SerializedName("next_cursor") + private String nextCursor; + + /** + * The type External contact group msg detail info. + */ + @Getter + @Setter + public static class ExternalContactGroupMsgDetailInfo implements Serializable { + private static final long serialVersionUID = 1500416806087532531L; + + // 外部联系人userid,群发消息到企业的客户群不吐出该字段 + @SerializedName("external_userid") + private String externalUserId; + + // 外部客户群id,群发消息到客户不吐出该字段 + @SerializedName("chat_id") + private String chatId; + + // 企业服务人员的userid + @SerializedName("userid") + private String userId; + + // 发送状态 0-未发送 1-已发送 2-因客户不是好友导致发送失败 3-因客户已经收到其他群发消息导致发送失败 + private Integer status; + + // 发送时间,发送状态为1时返回 + @SerializedName("send_time") + private Long sendTime; + } + + /** + * From json wx cp group msg result. + * + * @param json the json + * @return the wx cp group msg result + */ + public static WxCpGroupMsgResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupMsgResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgSendResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgSendResult.java new file mode 100644 index 0000000000..657c12ff6c --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgSendResult.java @@ -0,0 +1,65 @@ +package me.chanjar.weixin.cp.bean.external.contact; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 获取企业群发成员执行结果
+ * 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/93338
+ * 
+ * + * @author Mr.Pan + */ +@Getter +@Setter +public class WxCpGroupMsgSendResult extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = -5166048319463473186L; + + @SerializedName("send_list") + private List sendList; + + @SerializedName("next_cursor") + private String nextCursor; + + /** + * The type External contact group msg send info. + */ + @Getter + @Setter + public static class ExternalContactGroupMsgSendInfo implements Serializable { + private static final long serialVersionUID = 1500416806087532531L; + + @SerializedName("external_userid") + private String externalUserId; + + @SerializedName("chat_id") + private String chatId; + + @SerializedName("userid") + private String userId; + + private Integer status; + + @SerializedName("send_time") + private Long sendTime; + + } + + /** + * From json wx cp group msg send result. + * + * @param json the json + * @return the wx cp group msg send result + */ + public static WxCpGroupMsgSendResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupMsgSendResult.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgTaskResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgTaskResult.java new file mode 100644 index 0000000000..f363fc2eeb --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgTaskResult.java @@ -0,0 +1,59 @@ +package me.chanjar.weixin.cp.bean.external.contact; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 获取群发成员发送任务列表
+ * 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/93338
+ * 
+ * + * @author Mr.Pan + */ +@Getter +@Setter +public class WxCpGroupMsgTaskResult extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = -5166048319463473186L; + + @SerializedName("task_list") + private List taskList; + + @SerializedName("next_cursor") + private String nextCursor; + + /** + * The type External contact group msg task info. + */ + @Getter + @Setter + public static class ExternalContactGroupMsgTaskInfo implements Serializable { + private static final long serialVersionUID = 1500416806087532531L; + + @SerializedName("userid") + private String userId; + + private Integer status; + + @SerializedName("send_time") + private Long sendTime; + + } + + /** + * From json wx cp group msg task result. + * + * @param json the json + * @return the wx cp group msg task result + */ + public static WxCpGroupMsgTaskResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupMsgTaskResult.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/ApplicableRange.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/ApplicableRange.java new file mode 100644 index 0000000000..cabab9e1d0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/ApplicableRange.java @@ -0,0 +1,42 @@ +package me.chanjar.weixin.cp.bean.external.interceptrule; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * The type Applicable range. + * + * @author didi + */ +@Data +public class ApplicableRange implements Serializable { + private static final long serialVersionUID = -2473660177998792887L; + + @SerializedName("user_list") + private List userList; + @SerializedName("department_list") + private List departmentList; + + /** + * From json applicable range. + * + * @param json the json + * @return the applicable range + */ + public static ApplicableRange fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, ApplicableRange.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRule.java new file mode 100644 index 0000000000..cd3cbab028 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRule.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.cp.bean.external.interceptrule; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 敏感词规则修改接口请求和详情接口响应共用的实体类 + * + * @author didi + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpInterceptRule implements Serializable, ToJson { + private static final long serialVersionUID = 7161086545769110431L; + + @SerializedName("rule_name") + private String ruleName; + @SerializedName("rule_id") + private String ruleId; + @SerializedName("word_list") + private List wordList; + @SerializedName("extra_rule") + private ExtraRule extraRule; + @SerializedName("intercept_type") + private int interceptType; + @SerializedName("add_applicable_range") + private ApplicableRange addApplicableRange; + @SerializedName("remove_applicable_range") + private ApplicableRange removeApplicableRange; + + @Data + public static class ExtraRule implements Serializable { + private static final long serialVersionUID = -6377386837586111671L; + + @SerializedName("semantics_list") + private List semanticsList; + } + + /** + * From json wx cp intercept rule resp. + * + * @param json the json + * @return the wx cp intercept rule resp + */ + public static WxCpInterceptRule fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRule.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleAddRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleAddRequest.java new file mode 100644 index 0000000000..a82c875a36 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleAddRequest.java @@ -0,0 +1,58 @@ +package me.chanjar.weixin.cp.bean.external.interceptrule; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 新增敏感词规则请求参数封装实体类 + * + * @author didi created on 2022-04-17 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpInterceptRuleAddRequest implements Serializable, ToJson { + private static final long serialVersionUID = 7161086545769110431L; + + @SerializedName("rule_name") + private String ruleName; + @SerializedName("rule_id") + private String ruleId; + @SerializedName("word_list") + private List wordList; + @SerializedName("semantics_list") + private List semanticsList; + @SerializedName("intercept_type") + private int interceptType; + @SerializedName("applicable_range") + private ApplicableRange applicableRange; + + /** + * From json wx cp intercept rule resp. + * + * @param json the json + * @return the wx cp intercept rule resp + */ + public static WxCpInterceptRuleAddRequest fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleAddRequest.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleAddResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleAddResult.java new file mode 100644 index 0000000000..b84de75e6f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleAddResult.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.cp.bean.external.interceptrule; + +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; + +/** + * 新建敏感词规则负返回结果 + * + * @author didi + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpInterceptRuleAddResult extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 8540187819417742703L; + + @SerializedName("rule_id") + private String ruleId; + + /** + * From json wx cp intercept rule result resp. + * + * @param json the json + * @return the wx cp intercept rule result resp + */ + public static WxCpInterceptRuleAddResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleAddResult.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/CustomerItem.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/CustomerItem.java new file mode 100644 index 0000000000..3504d9aed0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/CustomerItem.java @@ -0,0 +1,19 @@ +package me.chanjar.weixin.cp.bean.external.moment; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; + +/** + * The type Customer item. + * + * @author Boris + */ +@Getter +@Setter +public class CustomerItem { + @SerializedName("external_userid") + private String externalUserId; + @SerializedName("userid") + private String userId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/ExternalContactList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/ExternalContactList.java new file mode 100644 index 0000000000..2d9ac44713 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/ExternalContactList.java @@ -0,0 +1,17 @@ +package me.chanjar.weixin.cp.bean.external.moment; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The type External contact list. + */ +@Getter +@Setter +public class ExternalContactList { + @SerializedName("tag_list") + private List tagList; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/MomentInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/MomentInfo.java new file mode 100644 index 0000000000..1eabdc145b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/MomentInfo.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.cp.bean.external.moment; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.bean.external.msg.*; + +import java.util.List; + +/** + * The type Moment info. + * + * @author Borisg + */ +@Data +public class MomentInfo { + @SerializedName("moment_id") + private String momentId; + @SerializedName("creator") + private String creator; + @SerializedName("create_time") + private String createTime; + @SerializedName("create_type") + private Integer createType; + @SerializedName("visible_type") + private Integer visibleType; + private Text text; + private List image; + private Video video; + private Link link; + private Location location; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/SenderList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/SenderList.java new file mode 100644 index 0000000000..35924fbebe --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/SenderList.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.cp.bean.external.moment; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The type Sender list. + * + * @author Boris + */ +@Getter +@Setter +public class SenderList { + @SerializedName("user_list") + private List userList; + @SerializedName("department_list") + private List departmentList; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/VisibleRange.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/VisibleRange.java new file mode 100644 index 0000000000..5964087952 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/moment/VisibleRange.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.cp.bean.external.moment; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Visible range. + * + * @author Boris + */ +@Data +@Accessors(chain = true) +public class VisibleRange implements Serializable { + private static final long serialVersionUID = 5356285705365931051L; + + @SerializedName("sender_list") + private SenderList senderList; + @SerializedName("external_contact_list") + private ExternalContactList externalContactList; +} 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 7dce73ad03..be9dcc9dd0 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 @@ -7,6 +7,8 @@ import java.io.Serializable; /** + * The type Attachment. + * * @author chutian0124 */ @Data @@ -27,28 +29,58 @@ public class Attachment implements Serializable { private File file; - public void setImage(Image image) { + /** + * Sets image. + * + * @param image the image + */ + public Attachment setImage(Image image) { this.image = image; this.msgType = WxCpConsts.WelcomeMsgType.IMAGE; + return this; } - public void setLink(Link link) { + /** + * Sets link. + * + * @param link the link + */ + public Attachment setLink(Link link) { this.link = link; this.msgType = WxCpConsts.WelcomeMsgType.LINK; + return this; } - public void setMiniProgram(MiniProgram miniProgram) { + /** + * Sets mini program. + * + * @param miniProgram the mini program + */ + public Attachment setMiniProgram(MiniProgram miniProgram) { this.miniProgram = miniProgram; this.msgType = WxCpConsts.WelcomeMsgType.MINIPROGRAM; + return this; } - public void setVideo(Video video) { + /** + * Sets video. + * + * @param video the video + */ + public Attachment setVideo(Video video) { this.video = video; this.msgType = WxCpConsts.WelcomeMsgType.VIDEO; + return this; } - public void setFile(File file ) { + /** + * Sets file. + * + * @param file the file + */ + public Attachment setFile(File file) { this.file = file; this.msgType = WxCpConsts.WelcomeMsgType.FILE; + return this; } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/AttachmentBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/AttachmentBuilder.java new file mode 100644 index 0000000000..8f3d19832f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/AttachmentBuilder.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.external.msg; + +import lombok.Builder; + +/** + * @author codecrab + */ +public class AttachmentBuilder { + + @Builder(builderClassName = "ImageBuilder", builderMethodName = "imageBuilder") + private static Attachment image(String mediaId, String picUrl) { + Image image = new Image().setMediaId(mediaId).setPicUrl(picUrl); + return new Attachment().setImage(image); + } + + @Builder(builderClassName = "VideoBuilder", builderMethodName = "videoBuilder") + private static Attachment video(String mediaId) { + Video video = new Video().setMediaId(mediaId); + return new Attachment().setVideo(video); + } + + @Builder(builderClassName = "FileBuilder", builderMethodName = "fileBuilder") + private static Attachment file(String mediaId) { + File file = new File().setMediaId(mediaId); + return new Attachment().setFile(file); + } + + @Builder(builderClassName = "LinkBuilder", builderMethodName = "linkBuilder") + private static Attachment link(String title, String url, String picUrl, String desc) { + Link link = new Link().setTitle(title).setPicUrl(picUrl).setUrl(url).setDesc(desc); + return new Attachment().setLink(link); + } + + @Builder(builderClassName = "MiniProgramBuilder", builderMethodName = "miniProgramBuilder") + private static Attachment miniProgram(String title, String picMediaId, String appId, String page) { + MiniProgram miniProgram = new MiniProgram().setTitle(title).setPicMediaId(picMediaId).setAppid(appId).setPage(page); + return new Attachment().setMiniProgram(miniProgram); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/File.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/File.java index a9726322e6..cc94cf6076 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/File.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/File.java @@ -2,14 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serializable; /** - * @author Binary Wang - * @date 2021-08-23 + * The type File. + * + * @author Binary Wang created on 2021-08-23 */ @Data +@Accessors(chain = true) public class File implements Serializable { private static final long serialVersionUID = 2794189478198329090L; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Image.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Image.java index 084de7fcf2..fd2f388097 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Image.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Image.java @@ -2,16 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serializable; /** * 图片消息. * - * @author Binary Wang - * @date 2020-08-16 + * @author Binary Wang created on 2020-08-16 */ @Data +@Accessors(chain = true) public class Image implements Serializable { private static final long serialVersionUID = -606286372867787121L; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Link.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Link.java index a949a1a0f1..feea6cacd3 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Link.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Link.java @@ -2,16 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serializable; /** * 图文消息. * - * @author Binary Wang - * @date 2020-08-16 + * @author Binary Wang created on 2020-08-16 */ @Data +@Accessors(chain = true) public class Link implements Serializable { private static final long serialVersionUID = -8041816740881163875L; private String title; @@ -19,4 +20,6 @@ public class Link implements Serializable { private String picUrl; private String desc; private String url; + @SerializedName("media_id") + private String mediaId; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Location.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Location.java new file mode 100644 index 0000000000..e10f2bd567 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Location.java @@ -0,0 +1,17 @@ +package me.chanjar.weixin.cp.bean.external.msg; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 地理位置 + * + * @author leiin created on 2021-10-29 + */ +@Data +@Accessors(chain = true) +public class Location { + private String latitude; + private String longitude; + private String name; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/MiniProgram.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/MiniProgram.java index 1c5940c7d6..46e10b33c2 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/MiniProgram.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/MiniProgram.java @@ -2,16 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serializable; /** * 小程序消息. * - * @author Binary Wang - * @date 2020-08-16 + * @author Binary Wang created on 2020-08-16 */ @Data +@Accessors(chain = true) public class MiniProgram implements Serializable { private static final long serialVersionUID = 4242074162638170679L; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Text.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Text.java index 2b5ae5fc63..5aeeb4565a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Text.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Text.java @@ -1,16 +1,17 @@ package me.chanjar.weixin.cp.bean.external.msg; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serializable; /** * 消息文本消息. * - * @author Binary Wang - * @date 2020-08-16 + * @author Binary Wang created on 2020-08-16 */ @Data +@Accessors(chain = true) public class Text implements Serializable { private static final long serialVersionUID = 6608288753719551600L; private String content; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Video.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Video.java index 237fb75cfe..76315af9a5 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Video.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Video.java @@ -2,18 +2,21 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serializable; /** * 视频消息 * - * @author pg - * @date 2021-6-21 + * @author pg created on 2021-6-21 */ @Data +@Accessors(chain = true) public class Video implements Serializable { private static final long serialVersionUID = -6048642921382867138L; @SerializedName("media_id") private String mediaId; + @SerializedName("thumb_media_id") + private String thumbMediaId; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/product/Attachment.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/product/Attachment.java new file mode 100644 index 0000000000..960800e11f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/product/Attachment.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.cp.bean.external.product; + +import lombok.Data; +import me.chanjar.weixin.cp.constant.WxCpConsts; + +import java.io.Serializable; + +/** + * 商品画册附件 + * + * @author Lo_ading + */ +@Data +public class Attachment implements Serializable { + private static final long serialVersionUID = -4545283630169056262L; + + /** + * NOTE: 20211110 字段接口未返回 + */ + private String type; + + /** + * 附件类型,目前仅支持image + */ + private Image image; + + /** + * Sets image. + * + * @param image the image + */ + public void setImage(Image image) { + this.image = image; + this.type = WxCpConsts.ProductAttachmentType.IMAGE; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/product/Image.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/product/Image.java new file mode 100644 index 0000000000..7628a63671 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/product/Image.java @@ -0,0 +1,20 @@ +package me.chanjar.weixin.cp.bean.external.product; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 商品画册图片 + * + * @author Lo_ading + */ +@Data +public class Image implements Serializable { + private static final long serialVersionUID = -2737415903252627814L; + + @SerializedName("media_id") + private String mediaId; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountAdd.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountAdd.java new file mode 100644 index 0000000000..b1ea05fad9 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountAdd.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 添加客服帐号-请求参数 + * + * @author Fu created on 2022/1/19 18:59 + */ +@NoArgsConstructor +@Data +public class WxCpKfAccountAdd implements Serializable { + + private static final long serialVersionUID = 3565729481246537411L; + + /** + * 客服名称;不多于16个字符 + */ + @SerializedName("name") + private String name; + + /** + * 客服头像临时素材。可以调用上传临时素材接口获取。 + * 不多于128个字节 + */ + @SerializedName("media_id") + private String mediaId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountAddResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountAddResp.java new file mode 100644 index 0000000000..c218494137 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountAddResp.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 添加客服帐号-返回结果 + * + * @author Fu created on 2022/1/19 19:04 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfAccountAddResp extends WxCpBaseResp { + + private static final long serialVersionUID = -6649323005421772827L; + + /** + * 新创建的客服帐号ID + */ + @SerializedName("open_kfid") + private String openKfid; + + /** + * From json wx cp kf account add resp. + * + * @param json the json + * @return the wx cp kf account add resp + */ + public static WxCpKfAccountAddResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfAccountAddResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountDel.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountDel.java new file mode 100644 index 0000000000..bd4bdf30c9 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountDel.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 删除客服帐号-请求参数 + * + * @author Fu created on 2022/1/19 19:09 + */ +@NoArgsConstructor +@Data +public class WxCpKfAccountDel implements Serializable { + + private static final long serialVersionUID = 1997221467585676772L; + + /** + * 客服帐号ID。 + * 不多于64字节 + */ + @SerializedName("open_kfid") + private String openKfid; + +} 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 new file mode 100644 index 0000000000..a903d0fa54 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLink.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 获取客服帐号链接-请求参数 + * + * @author Fu created on 2022/1/19 19:18 + */ +@NoArgsConstructor +@Data +public class WxCpKfAccountLink implements Serializable { + + private static final long serialVersionUID = -1920926948347984256L; + + /** + * 客服帐号ID + */ + @SerializedName("open_kfid") + private String openKfid; + + /** + * 场景值,字符串类型,由开发者自定义。 + * 不多于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 + * 2. 历史调用接口返回的客服链接(包含encScene=XXX参数),不支持scene_param参数。 + * 3. 返回的客服链接,不能修改或复制参数到其他链接使用。否则进入会话事件参数校验不通过,导致无法回调。 + */ + @SerializedName("scene") + private String scene; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLinkResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLinkResp.java new file mode 100644 index 0000000000..e04a8f56a9 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLinkResp.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 获取客服帐号链接-结果 + * + * @author Fu created on 2022/1/19 19:18 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfAccountLinkResp extends WxCpBaseResp { + + private static final long serialVersionUID = 910205439597092481L; + + /** + * 客服链接,开发者可将该链接嵌入到H5页面中,用户点击链接即可向对应的微信客服帐号发起咨询。开发者也可根据该url自行生成需要的二维码图片 + */ + @SerializedName("url") + private String url; + + /** + * From json wx cp kf account link resp. + * + * @param json the json + * @return the wx cp kf account link resp + */ + public static WxCpKfAccountLinkResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfAccountLinkResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountListResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountListResp.java new file mode 100644 index 0000000000..a7ec3c909a --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountListResp.java @@ -0,0 +1,64 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 获取客服帐号列表-结果 + * + * @author Fu created on 2022/1/19 19:13 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfAccountListResp extends WxCpBaseResp { + + private static final long serialVersionUID = -1317201649692262217L; + + /** + * 帐号信息列表 + */ + @SerializedName("account_list") + private List accountList; + + /** + * The type Account list dto. + */ + @NoArgsConstructor + @Data + public static class AccountListDTO { + /** + * 客服帐号ID + */ + @SerializedName("open_kfid") + private String openKfid; + + /** + * 客服名称 + */ + @SerializedName("name") + private String name; + + /** + * 客服头像URL + */ + @SerializedName("avatar") + private String avatar; + } + + /** + * From json wx cp kf account list resp. + * + * @param json the json + * @return the wx cp kf account list resp + */ + public static WxCpKfAccountListResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfAccountListResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountUpd.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountUpd.java new file mode 100644 index 0000000000..fa375c8723 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountUpd.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 修改客服帐号-请求参数 + * + * @author Fu created on 2022/1/19 19:10 + */ +@NoArgsConstructor +@Data +public class WxCpKfAccountUpd implements Serializable { + + private static final long serialVersionUID = -900712046553752529L; + + /** + * 要修改的客服帐号ID。 + * 不多于64字节 + */ + @SerializedName("open_kfid") + private String openKfid; + + /** + * 新的客服名称,如不需要修改可不填。 + * 不多于16个字符 + */ + @SerializedName("name") + private String name; + + /** + * 新的客服头像临时素材,如不需要修改可不填。可以调用上传临时素材接口获取。 + * 不多于128个字节 + */ + @SerializedName("media_id") + private String mediaId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfCustomerBatchGetResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfCustomerBatchGetResp.java new file mode 100644 index 0000000000..72b6b1044f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfCustomerBatchGetResp.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.external.contact.ExternalContact; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * The type Wx cp kf customer batch get resp. + * + * @author leiin created on 2022/1/26 7:56 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfCustomerBatchGetResp extends WxCpBaseResp { + + private static final long serialVersionUID = -3697709507605389887L; + + @SerializedName("customer_list") + private List customerList; + + @SerializedName("invalid_external_userid") + private List invalidExternalUserId; + + /** + * From json wx cp kf customer batch get resp. + * + * @param json the json + * @return the wx cp kf customer batch get resp + */ + public static WxCpKfCustomerBatchGetResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfCustomerBatchGetResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetCorpStatisticRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetCorpStatisticRequest.java new file mode 100644 index 0000000000..d447fb6494 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetCorpStatisticRequest.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取「客户数据统计」企业汇总数据 + * + * @author zhongjun created on 2022/4/25 + */ +@NoArgsConstructor +@Data +public class WxCpKfGetCorpStatisticRequest { + + /** + * 客服帐号ID。不传入时返回的数据为企业维度汇总的数据 + */ + @SerializedName("open_kfid") + private String openKfId; + + /** + * 起始日期的时间戳,填这一天的0时0分0秒(否则系统自动处理为当天的0分0秒)。取值范围:昨天至前180天 + */ + @SerializedName("start_time") + private Long startTime; + /** + * 结束日期的时间戳,填这一天的0时0分0秒(否则系统自动处理为当天的0分0秒)。取值范围:昨天至前180天 + */ + @SerializedName("end_time") + private Long endTime; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetCorpStatisticResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetCorpStatisticResp.java new file mode 100644 index 0000000000..193cb78846 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetCorpStatisticResp.java @@ -0,0 +1,114 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 获取「客户数据统计」企业汇总数据 + * + * @author zhongjun created on 2022/4/25 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfGetCorpStatisticResp extends WxCpBaseResp { + private static final long serialVersionUID = -89898989898989898L; + + /** + * 统计数据列表 + */ + @SerializedName("statistic_list") + private List statisticList; + + /** + * The type Statistic list. + */ + @NoArgsConstructor + @Data + public static class StatisticList { + /** + * 数据统计日期,为当日0点的时间戳 + */ + @SerializedName("stat_time") + private Long statTime; + + /** + * 一天的统计数据。若当天未产生任何下列统计数据或统计数据还未计算完成则不会返回此项 + */ + @SerializedName("statistic") + private Statistic statistic; + } + + /** + * The type Statistic. + */ + @NoArgsConstructor + @Data + public static class Statistic { + + /** + * 咨询会话数。客户发过消息并分配给接待人员或智能助手的客服会话数,转接不会产生新的会话 + */ + @SerializedName("session_cnt") + private Integer sessionCnt; + + /** + * 咨询客户数。在会话中发送过消息的客户数量,若客户多次咨询只计算一个客户 + */ + @SerializedName("customer_cnt") + private Integer customerCnt; + + /** + * 咨询消息总数。客户在会话中发送的消息的数量 + */ + @SerializedName("customer_msg_cnt") + private Integer customerMsgCnt; + + /** + * 升级服务客户数。通过「升级服务」功能成功添加专员或加入客户群的客户数,若同一个客户添加多个专员或客户群,只计算一个客户。在2022年3月10日以后才会有对应统计数据 + */ + @SerializedName("upgrade_service_customer_cnt") + private Integer upgradeServiceCustomerCnt; + + /** + * 智能回复会话数。客户发过消息并分配给智能助手的咨询会话数。通过API发消息或者开启智能回复功能会将客户分配给智能助手 + */ + @SerializedName("ai_session_reply_cnt") + private Integer aiSessionReplyCnt; + + /** + * 转人工率。一个自然日内,客户给智能助手发消息的会话中,转人工的会话的占比。 + */ + @SerializedName("ai_transfer_rate") + private Float aiTransferRate; + + /** + * 知识命中率。一个自然日内,客户给智能助手发送的消息中,命中知识库的占比。只有在开启了智能回复原生功能并配置了知识库的情况下,才会产生该项统计数据。当api + * 托管了会话分配,智能回复原生功能失效。若不返回,代表没有向配置知识库的智能接待助手发送消息,该项无法计算 + */ + @SerializedName("ai_knowledge_hit_rate") + private Float aiKnowledgeHitRate; + + /** + * 被拒收消息的客户数。被接待人员设置了“不再接收消息”的客户数 + */ + @SerializedName("msg_rejected_customer_cnt") + private Integer msgRejectedCustomerCnt; + } + + /** + * From json wx cp kf get corp statistic resp. + * + * @param json the json + * @return the wx cp kf get corp statistic resp + */ + public static WxCpKfGetCorpStatisticResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfGetCorpStatisticResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetServicerStatisticRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetServicerStatisticRequest.java new file mode 100644 index 0000000000..89b93eab1c --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetServicerStatisticRequest.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取「客户数据统计」接待人员明细数据 + * + * @author MsThink created on 2023/5/13 + */ +@NoArgsConstructor +@Data +public class WxCpKfGetServicerStatisticRequest { + /** + * 客服帐号ID + */ + @SerializedName("open_kfid") + private String openKfId; + + /** + * 接待人员的userid。第三方应用为密文userid,即open_userid + */ + @SerializedName("servicer_userid") + private String servicerUserid; + + /** + * 起始日期的时间戳,填这一天的0时0分0秒(否则系统自动处理为当天的0分0秒)。取值范围:昨天至前180天 + */ + @SerializedName("start_time") + private Long startTime; + /** + * 结束日期的时间戳,填这一天的0时0分0秒(否则系统自动处理为当天的0分0秒)。取值范围:昨天至前180天 + */ + @SerializedName("end_time") + private Long endTime; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetServicerStatisticResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetServicerStatisticResp.java new file mode 100644 index 0000000000..f6e8d18094 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfGetServicerStatisticResp.java @@ -0,0 +1,159 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 获取「客户数据统计」接待人员明细数据 + * + * @author MsThink created on 2023/5/13 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfGetServicerStatisticResp extends WxCpBaseResp { + /** + * 统计数据列表 + */ + @SerializedName("statistic_list") + private List statisticList; + + /** + * The type Statistic list. + */ + @NoArgsConstructor + @Data + public static class StatisticList { + /** + * 数据统计日期,为当日0点的时间戳 + */ + @SerializedName("stat_time") + private Long statTime; + + /** + * 一天的统计数据。若当天未产生任何下列统计数据或统计数据还未计算完成则不会返回此项 + */ + @SerializedName("statistic") + private WxCpKfGetServicerStatisticResp.Statistic statistic; + } + + /** + * The type Statistic. + */ + @NoArgsConstructor + @Data + public static class Statistic { + + /** + * 接入人工会话数。客户发过消息并分配给接待人员的咨询会话数 + */ + @SerializedName("session_cnt") + private Integer sessionCnt; + + /** + * 咨询客户数。在会话中发送过消息且接入了人工会话的客户数量,若客户多次咨询只计算一个客户 + */ + @SerializedName("customer_cnt") + private Integer customerCnt; + + /** + * 咨询消息总数。客户在会话中发送的消息的数量 + */ + @SerializedName("customer_msg_cnt") + private Integer customerMsgCnt; + + /** + * 人工回复率。一个自然日内,客户给接待人员发消息的会话中,接待人员回复了的会话的占比。若数据项不返回,代表没有给接待人员发送消息的客户,此项无法计算。 + */ + @SerializedName("reply_rate") + private Float replyRate; + + /** + * 平均首次响应时长,单位:秒。一个自然日内,客户给接待人员发送的第一条消息至接待人员回复之间的时长,为首次响应时长。所有的首次回复总时长/已回复的咨询会话数, + * 即为平均首次响应时长 。若数据项不返回,代表没有给接待人员发送消息的客户,此项无法计算 + */ + @SerializedName("first_reply_average_sec") + private Float firstReplyAverageSec; + + /** + * 满意度评价发送数。当api托管了会话分配,满意度原生功能失效,满意度评价发送数为0 + */ + @SerializedName("satisfaction_investgate_cnt") + private Integer satisfactionInvestgateCnt; + + /** + * 满意度参评率 。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有发送满意度评价,此项无法计算 + */ + @SerializedName("satisfaction_participation_rate") + private Float satisfactionParticipationRate; + + /** + * “满意”评价占比 。在客户参评的满意度评价中,评价是“满意”的占比。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有客户参评的满意度评价,此项无法计算 + */ + @SerializedName("satisfied_rate") + private Float satisfiedRate; + + /** + * “一般”评价占比 。在客户参评的满意度评价中,评价是“一般”的占比。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有客户参评的满意度评价,此项无法计算 + */ + @SerializedName("middling_rate") + private Float middlingRate; + + /** + * “不满意”评价占比。在客户参评的满意度评价中,评价是“不满意”的占比。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有客户参评的满意度评价,此项无法计算 + */ + @SerializedName("dissatisfied_rate") + private Float dissatisfiedRate; + + /** + * 升级服务客户数。通过「升级服务」功能成功添加专员或加入客户群的客户数,若同一个客户添加多个专员或客户群,只计算一个客户。在2022年3月10日以后才会有对应统计数据 + */ + @SerializedName("upgrade_service_customer_cnt") + private Integer upgradeServiceCustomerCnt; + + /** + * 专员服务邀请数。接待人员通过「升级服务-专员服务」向客户发送服务专员名片的次数。在2022年3月10日以后才会有对应统计数据 + */ + @SerializedName("upgrade_service_member_invite_cnt") + private Integer upgradeServiceMemberInviteCnt; + + /** + * 添加专员的客户数 。客户成功添加专员为好友的数量,若同一个客户添加多个专员,则计算多个客户数。在2022年3月10日以后才会有对应统计数据 + */ + @SerializedName("upgrade_service_member_customer_cnt") + private Integer upgradeServiceMemberCustomerCnt; + + /** + * 客户群服务邀请数。接待人员通过「升级服务-客户群服务」向客户发送客户群二维码的次数。在2022年3月10日以后才会有对应统计数据 + */ + @SerializedName("upgrade_service_groupchat_invite_cnt") + private Integer upgradeServiceGroupchatInviteCnt; + + /** + * 加入客户群的客户数。客户成功加入客户群的数量,若同一个客户加多个客户群,则计算多个客户数。在2022年3月10日以后才会有对应统计数据 + */ + @SerializedName("upgrade_service_groupchat_customer_cnt") + private Integer upgradeServiceGroupchatCustomerCnt; + + /** + * 被拒收消息的客户数。被接待人员设置了“不再接收消息”的客户数 + */ + @SerializedName("msg_rejected_customer_cnt") + private Integer msgRejectedCustomerCnt; + } + /** + * From json wx cp kf get servicer statistic resp. + * + * @param json the json + * @return the wx cp kf get servicer statistic resp + */ + public static WxCpKfGetServicerStatisticResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfGetServicerStatisticResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgListResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgListResp.java new file mode 100644 index 0000000000..f8f3275c46 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgListResp.java @@ -0,0 +1,81 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.kf.msg.*; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * The type Wx cp kf msg list resp. + * + * @author leiin created on 2022/1/26 5:24 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfMsgListResp extends WxCpBaseResp { + + private static final long serialVersionUID = -3115552079069452091L; + @SerializedName("next_cursor") + private String nextCursor; + + @SerializedName("has_more") + private Integer hasMore; + + @SerializedName("msg_list") + private List msgList; + + /** + * The type Wx cp kf msg item. + */ + @NoArgsConstructor + @Data + public static class WxCpKfMsgItem { + @SerializedName("msgid") + private String msgId; + @SerializedName("open_kfid") + private String openKfid; + @SerializedName("external_userid") + private String externalUserId; + @SerializedName("send_time") + private Long sendTime; + private Integer origin; + @SerializedName("servicer_userid") + private String servicerUserId; + @SerializedName("msgtype") + private String msgType; + private WxCpKfTextMsg text; + private WxCpKfResourceMsg image; + private WxCpKfResourceMsg voice; + private WxCpKfResourceMsg video; + private WxCpKfResourceMsg file; + private WxCpKfLocationMsg location; + private WxCpKfLinkMsg link; + @SerializedName("business_card") + private WxCpKfBusinessCardMsg businessCard; + @SerializedName("miniprogram") + private WxCpKfMiniProgramMsg miniProgram; + @SerializedName("msgmenu") + private WxCpKfMenuMsg msgMenu; + private WxCpKfEventMsg event; + @SerializedName("channels_shop_product") + private WxCpKfChannelsShopProductMsg channelsShopProduct; + @SerializedName("channels_shop_order") + private WxCpKfChannelsShopOrderMsg channelsShopOrder; + } + + /** + * From json wx cp kf msg list resp. + * + * @param json the json + * @return the wx cp kf msg list resp + */ + public static WxCpKfMsgListResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfMsgListResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgSendRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgSendRequest.java new file mode 100644 index 0000000000..ba451813e0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgSendRequest.java @@ -0,0 +1,147 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.kf.msg.*; + +/** + * The type Wx cp kf msg send request. + * + * @author leiin created on 2022/1/26 7:00 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfMsgSendRequest { + /** + * (发送欢迎语等事件响应消息) 事件响应消息对应的code。通过事件回调下发,仅可使用一次。 + */ + private String code; + /** + *

+   *   参数:touser
+   *   是否必须:是
+   *   类型:string
+   *   说明:指定接收消息的客户UserID
+   * 
+ */ + @SerializedName("touser") + private String toUser; + /** + *
+   *   参数:open_kfid
+   *   是否必须:是
+   *   类型:string
+   *   说明:指定发送消息的客服帐号ID
+   * 
+ */ + @SerializedName("open_kfid") + private String openKfid; + /** + *
+   *   参数:msgid
+   *   是否必须:否
+   *   类型:string
+   *   说明:指定消息ID
+   * 
+ */ + @SerializedName("msgid") + private String msgId; + /** + *
+   *   参数:msgtype
+   *   是否必须:是
+   *   类型:string
+   *   说明:消息类型,(text,image,voice,video,file,link,miniprogram,msgmenu,location)
+   * 
+ */ + @SerializedName("msgtype") + private String msgType; + /** + *
+   *   参数:text
+   *   是否必须:是
+   *   类型:obj
+   *   说明:文本消息
+   * 
+ */ + private WxCpKfTextMsg text; + + /** + *
+   *   参数:image
+   *   是否必须:是
+   *   类型:obj
+   *   说明:图片消息
+   * 
+ */ + private WxCpKfResourceMsg image; + /** + *
+   *   参数:voice
+   *   是否必须:是
+   *   类型:obj
+   *   说明:语音消息
+   * 
+ */ + private WxCpKfResourceMsg voice; + /** + *
+   *   参数:video
+   *   是否必须:是
+   *   类型:obj
+   *   说明:视频消息
+   * 
+ */ + private WxCpKfResourceMsg video; + /** + *
+   *   参数:file
+   *   是否必须:是
+   *   类型:obj
+   *   说明:文件消息
+   * 
+ */ + private WxCpKfResourceMsg file; + /** + *
+   *   参数:link
+   *   是否必须:是
+   *   类型:obj
+   *   说明:链接消息
+   * 
+ */ + private WxCpKfLinkMsg link; + /** + *
+   *   参数:miniprogram
+   *   是否必须:是
+   *   类型:obj
+   *   说明:小程序消息
+   * 
+ */ + @SerializedName("miniprogram") + private WxCpKfMiniProgramMsg miniProgram; + + /** + *
+   *   参数:msgmenu
+   *   是否必须:是
+   *   类型:obj
+   *   说明:菜单消息
+   * 
+ */ + @SerializedName("msgmenu") + private WxCpKfMenuMsg msgMenu; + + /** + *
+   *   参数:location
+   *   是否必须:是
+   *   类型:obj
+   *   说明:菜单消息
+   * 
+ */ + @SerializedName("location") + private WxCpKfLocationMsg location; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgSendResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgSendResp.java new file mode 100644 index 0000000000..62bd624d8b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfMsgSendResp.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * The type Wx cp kf msg send resp. + * + * @author leiin created on 2022/1/26 7:41 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfMsgSendResp extends WxCpBaseResp { + @SerializedName("msgid") + private String msgId; + + /** + * From json wx cp kf msg send resp. + * + * @param json the json + * @return the wx cp kf msg send resp + */ + public static WxCpKfMsgSendResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfMsgSendResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceStateResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceStateResp.java new file mode 100644 index 0000000000..d273cc32d4 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceStateResp.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * The type Wx cp kf service state resp. + * + * @author leiin created on 2022/1/26 5:00 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfServiceStateResp extends WxCpBaseResp { + + private static final long serialVersionUID = 8077134413448067090L; + @SerializedName("service_state") + private Integer serviceState; + @SerializedName("servicer_userid") + private String servicerUserId; + + /** + * From json wx cp kf service state resp. + * + * @param json the json + * @return the wx cp kf service state resp + */ + public static WxCpKfServiceStateResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfServiceStateResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceStateTransResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceStateTransResp.java new file mode 100644 index 0000000000..604efb12ac --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceStateTransResp.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * The type Wx cp kf service state trans resp. + * + * @author leiin created on 2022/1/26 5:03 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfServiceStateTransResp extends WxCpBaseResp { + + private static final long serialVersionUID = -7874378445629022791L; + + @SerializedName("msg_code") + private String msgCode; + + /** + * From json wx cp kf service state trans resp. + * + * @param json the json + * @return the wx cp kf service state trans resp + */ + public static WxCpKfServiceStateTransResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfServiceStateTransResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceUpgradeConfigResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceUpgradeConfigResp.java new file mode 100644 index 0000000000..61eb1b775b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServiceUpgradeConfigResp.java @@ -0,0 +1,62 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * The type Wx cp kf service upgrade config resp. + * + * @author leiin created on 2022/4/26 5:21 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfServiceUpgradeConfigResp extends WxCpBaseResp { + + private static final long serialVersionUID = -3212550906238196617L; + + @SerializedName("member_range") + private MemberRange memberRange; + + @SerializedName("groupchat_range") + private GroupchatRange groupchatRange; + + /** + * From json wx cp kf service upgrade config resp. + * + * @param json the json + * @return the wx cp kf service upgrade config resp + */ + public static WxCpKfServiceUpgradeConfigResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfServiceUpgradeConfigResp.class); + } + + /** + * The type Member range. + */ + @Data + @NoArgsConstructor + public static class MemberRange { + @SerializedName("userid_list") + private List useridList; + + @SerializedName("department_id_list") + private List departmentIdList; + } + + /** + * The type Groupchat range. + */ + @Data + @NoArgsConstructor + public static class GroupchatRange { + @SerializedName("chat_id_list") + private List chatIdList; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServicerListResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServicerListResp.java new file mode 100644 index 0000000000..0b3e4636c1 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServicerListResp.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.cp.bean.kf; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * The type Wx cp kf servicer list resp. + * + * @author leiin created on 2022/1/26 4:29 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfServicerListResp extends WxCpBaseResp { + + private static final long serialVersionUID = -5079770046571012449L; + @SerializedName("servicer_list") + private List servicerList; + + /** + * The type Wx cp kf servicer status. + */ + @NoArgsConstructor + @Data + public static class WxCpKfServicerStatus { + @SerializedName("userid") + private String userId; + private Integer status; + } + + /** + * From json wx cp kf servicer list resp. + * + * @param json the json + * @return the wx cp kf servicer list resp + */ + public static WxCpKfServicerListResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfServicerListResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServicerOpResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServicerOpResp.java new file mode 100644 index 0000000000..4e48e02348 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfServicerOpResp.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.cp.bean.kf; + + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 添加/删除客服接待人员返回结果 + * + * @author leiin created on 2022/1/26 4:11 下午 + */ +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@Data +public class WxCpKfServicerOpResp extends WxCpBaseResp { + + private static final long serialVersionUID = -4082459764202987034L; + + @SerializedName("result_list") + private List resultList; + + /** + * The type Wx cp kf servicer resp. + */ + @Data + @NoArgsConstructor + public static class WxCpKfServicerResp extends WxCpBaseResp { + + @SerializedName("userid") + private String userId; + } + + /** + * From json wx cp kf servicer op resp. + * + * @param json the json + * @return the wx cp kf servicer op resp + */ + public static WxCpKfServicerOpResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpKfServicerOpResp.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfBusinessCardMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfBusinessCardMsg.java new file mode 100644 index 0000000000..95fe7f72b4 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfBusinessCardMsg.java @@ -0,0 +1,17 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf business card msg. + * + * @author leiin created on 2022/1/26 5:35 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfBusinessCardMsg { + @SerializedName("userid") + private String userId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfChannelsShopOrderMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfChannelsShopOrderMsg.java new file mode 100644 index 0000000000..165b4ceba4 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfChannelsShopOrderMsg.java @@ -0,0 +1,53 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf channels shop order msg. + * + * @author dalin created on 2023/1/10 17:28 + * + */ +@NoArgsConstructor +@Data +public class WxCpKfChannelsShopOrderMsg { + + /** + * 订单号 + */ + @SerializedName("order_id") + private String orderId; + + /** + * 商品标题 + */ + @SerializedName("product_titles") + private String productTitles; + + /** + * 订单价格描述 + */ + @SerializedName("price_wording") + private String priceWording; + + /** + * 订单状态 + */ + @SerializedName("state") + private String state; + + /** + * 订单缩略图 + */ + @SerializedName("image_url") + private String imageUrl; + + /** + * 店铺名称 + */ + @SerializedName("shop_nickname") + private String shopNickname; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfChannelsShopProductMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfChannelsShopProductMsg.java new file mode 100644 index 0000000000..b9e05af677 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfChannelsShopProductMsg.java @@ -0,0 +1,53 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf channels shop product msg. + * + * @author dalin created on 2023/1/10 17:26 + * + */ +@NoArgsConstructor +@Data +public class WxCpKfChannelsShopProductMsg { + + /** + * 商品ID + */ + @SerializedName("product_id") + private String productId; + + /** + * 商品图片 + */ + @SerializedName("head_img") + private String headImg; + + /** + * 商品标题 + */ + @SerializedName("title") + private String title; + + /** + * 商品价格,以分为单位 + */ + @SerializedName("sales_price") + private String salesPrice; + + /** + * 店铺名称 + */ + @SerializedName("shop_nickname") + private String shopNickname; + + /** + * 店铺头像 + */ + @SerializedName("shop_head_img") + private String shopHeadImg; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfEventMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfEventMsg.java new file mode 100644 index 0000000000..25439dabbd --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfEventMsg.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf event msg. + * + * @author leiin created on 2022/1/26 6:44 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfEventMsg { + @SerializedName("event_type") + private String eventType; + @SerializedName("open_kfid") + private String openKfid; + @SerializedName("external_userid") + private String externalUserId; + @SerializedName("servicer_userid") + private String servicerUserId; + @SerializedName("old_servicer_userid") + private String oldServicerUserId; + @SerializedName("new_servicer_userid") + private String newServicerUserId; + private String scene; + @SerializedName("scene_param") + private String sceneParam; + @SerializedName("welcome_code") + private String welcomeCode; + @SerializedName("fail_msgid") + private String failMsgId; + @SerializedName("fail_type") + private Integer failType; + private Integer status; + @SerializedName("change_type") + private Integer changeType; + @SerializedName("msg_code") + private String msgCode; + @SerializedName("recall_msgid") + private String recallMsgId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfLinkMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfLinkMsg.java new file mode 100644 index 0000000000..64809f1eb8 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfLinkMsg.java @@ -0,0 +1,54 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf link msg. + * + * @author leiin created on 2022/1/26 5:33 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfLinkMsg { + + /** + * 参数:title + * 是否必须:是 + * 类型:string + * 说明:标题,不超过128个字节,超过会自动截断 + */ + @SerializedName("title") + private String title; + /** + * 参数:desc + * 是否必须:否 + * 类型:string + * 说明:描述,不超过512个字节,超过会自动截断 + */ + @SerializedName("desc") + private String desc; + /** + * 参数:url + * 是否必须:是 + * 类型:string + * 说明:点击后跳转的链接。 最长2048字节,请确保包含了协议头(http/https) + */ + @SerializedName("url") + private String url; + /** + * 参数:thumb_media_id + * 是否必须:是 + * 类型:string + * 说明:发送消息参数,缩略图的media_id, 可以通过素材管理接口获得。此处thumb_media_id即上传接口返回的media_id + */ + @SerializedName("thumb_media_id") + private String thumb_media_id; + + /** + * 返回消息参数 + */ + @SerializedName("pic_url") + private String picUrl; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfLocationMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfLocationMsg.java new file mode 100644 index 0000000000..6e7fa9ab74 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfLocationMsg.java @@ -0,0 +1,42 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf location msg. + * + * @author leiin created on 2022/1/26 5:32 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfLocationMsg { + /** + * 参数:name + * 是否必须:否 + * 类型:string + * 说明:位置名 + */ + private String name; + /** + * 参数:address + * 是否必须:否 + * 类型:string + * 说明:地址详情说明 + */ + private String address; + /** + * 参数:latitude + * 是否必须:是 + * 类型:float + * 说明:纬度,浮点数,范围为90 ~ -90 + */ + private Float latitude; + /** + * 参数:longitude + * 是否必须:是 + * 类型:float + * 说明:经度,浮点数,范围为180 ~ -180 + */ + private Float longitude; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfMenuMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfMenuMsg.java new file mode 100644 index 0000000000..32ee53faf0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfMenuMsg.java @@ -0,0 +1,164 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; + +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +/** + * The type Wx cp kf menu msg. + * + * @author leiin created on 2022/1/26 6:33 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfMenuMsg { + + /** + * 参数:head_content + * 是否必须:否 + * 类型:string + * 说明:起始文本 不多于1024字节 + */ + @SerializedName("head_content") + private String headContent; + + private List list; + + /** + * 参数:tail_content + * 是否必须:否 + * 类型:string + * 说明:结束文本 不多于1024字节 + */ + @SerializedName("tail_content") + private String tailContent; + + /** + * The type Wx cp kf menu item. + */ + @NoArgsConstructor + @Data + public static class WxCpKfMenuItem { + /** + * 参数:type + * 是否必须:是 + * 类型:string + * 说明:菜单类型。click-回复菜单 view-超链接菜单 miniprogram-小程序菜单 + */ + private String type; + + /** + * type为click的菜单项 + */ + private MenuClick click; + /** + * type为view的菜单项 + */ + private MenuView view; + /** + * type为miniprogram的菜单项 + */ + @SerializedName("miniprogram") + private MiniProgram miniProgram; + /** + * type为text的菜单项 + */ + private MenuText text; + } + + /** + * The type Menu click. + */ + @Getter + @Setter + public static class MenuClick { + + /** + *
+     *   是否必须:否
+     *   说明:菜单ID。不少于1字节 不多于128字节
+     * 
+ */ + private String id; + /** + *
+     *   是否必须:是
+     *   说明:菜单显示内容。不少于1字节 不多于128字节
+     * 
+ */ + private String content; + } + + /** + * The type Menu view. + */ + @Getter + @Setter + public static class MenuView { + /** + *
+     *   是否必须:是
+     *   说明:点击后跳转的链接。不少于1字节 不多于2048字节
+     * 
+ */ + private String url; + /** + *
+     *   是否必须:是
+     *   说明:菜单显示内容。不少于1字节 不多于1024字节
+     * 
+ */ + private String content; + } + + /** + * The type Mini program. + */ + @Getter + @Setter + public static class MiniProgram { + /** + *
+     *   是否必须:是
+     *   说明:小程序appid。
+     * 
+ */ + @SerializedName("appid") + private String appId; + /** + *
+     *   点击后进入的小程序页面。
+     * 
+ */ + @SerializedName("pagepath") + private String pagePath; + /** + *
+     *   菜单显示内容。不多于1024字节
+     * 
+ */ + private String content; + } + + /** + * + * The type Menu text. + * + */ + @Getter + @Setter + public static class MenuText { + /** + *
+     *   是否必须:是
+     *   说明:文本内容,支持\n(\和n两个字符)换行。不少于1字节 不多于256字节
+     * 
+ */ + private String content; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfMiniProgramMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfMiniProgramMsg.java new file mode 100644 index 0000000000..49829a729f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfMiniProgramMsg.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf mini program msg. + * + * @author leiin created on 2022/1/26 6:22 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfMiniProgramMsg { + /** + * 参数:appid + * 是否必须:是 + * 类型:string + * 说明:小程序appid + */ + @SerializedName("appid") + private String appId; + /** + * 参数:title + * 是否必须:否 + * 类型:string + * 说明:小程序消息标题,最多64个字节,超过会自动截断 + */ + @SerializedName("title") + private String title; + /** + * 参数:thumb_media_id + * 是否必须:是 + * 类型:string + * 说明:小程序消息封面的mediaid,封面图建议尺寸为520*416 + */ + @SerializedName("thumb_media_id") + private String thumbMediaId; + /** + * 参数:pagepath + * 是否必须:是 + * 类型:string + * 说明:点击消息卡片后进入的小程序页面路径。注意路径要以.html为后缀,否则在微信中打开会提示找不到页面 + */ + @SerializedName("pagepath") + private String pagePath; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfResourceMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfResourceMsg.java new file mode 100644 index 0000000000..fd25095b5f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfResourceMsg.java @@ -0,0 +1,17 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf resource msg. + * + * @author leiin created on 2022/1/26 5:31 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfResourceMsg { + @SerializedName("media_id") + private String mediaId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfTextMsg.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfTextMsg.java new file mode 100644 index 0000000000..22c8eb548d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/msg/WxCpKfTextMsg.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.cp.bean.kf.msg; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The type Wx cp kf text msg. + * + * @author leiin created on 2022/1/26 5:30 下午 + */ +@NoArgsConstructor +@Data +public class WxCpKfTextMsg { + + /** + *
+   *   参数:content
+   *   是否必须:是
+   *   类型:string
+   *   说明:消息内容,最长不超过2048个字节
+   * 
+ */ + private String content; + @SerializedName("menu_id") + private String menuId; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccount.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccount.java new file mode 100644 index 0000000000..60975f5441 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccount.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + + +/** + * 订单账号信息 + * + * @author Totoro created on 2022/6/27 14:04 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseAccount extends WxCpTpLicenseBaseAccount { + private static final long serialVersionUID = 8225061160406054730L; + + /** + * 激活码 + */ + @SerializedName("active_code") + private String activeCode; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccountCount.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccountCount.java new file mode 100644 index 0000000000..68e8d784d9 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccountCount.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * The type Wx cp tp license account count. + * + * @author Totoro created on 2022/6/27 11:54 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseAccountCount implements Serializable { + private static final long serialVersionUID = 8521389670723004989L; + + @SerializedName("base_count") + private Integer baseCount; + @SerializedName("external_contact_count") + private Integer externalContactCount; + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccountDuration.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccountDuration.java new file mode 100644 index 0000000000..ebc58f1ec7 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseAccountDuration.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.cp.bean.license; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * The type Wx cp tp license account duration. + * + * @author Totoro created on 2022-6-27 11:22:53 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseAccountDuration implements Serializable { + private static final long serialVersionUID = 7960912263908286975L; + + private Integer months; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseActiveAccount.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseActiveAccount.java new file mode 100644 index 0000000000..2493c657ce --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseActiveAccount.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * The type Wx cp tp license active account. + * + * @author Totoro created on 2022-6-27 16:26:35 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseActiveAccount implements Serializable { + private static final long serialVersionUID = -2382681430861137803L; + + /** + * 用户ID + */ + private String userid; + + /** + * 激活码 + */ + @SerializedName("active_code") + private String activeCode; + + /** + * 激活状态 0为成功 + * 此值在请求激活时无需传入 + */ + @SerializedName("errcode") + private Integer errCode; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseActiveCodeInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseActiveCodeInfo.java new file mode 100644 index 0000000000..86d70ed8ae --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseActiveCodeInfo.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * 激活码信息 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95553 + * + * @author Totoro created on 2022/6/27 14:34 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseActiveCodeInfo extends WxCpTpLicenseBaseAccount { + private static final long serialVersionUID = 7696395903786956694L; + + @SerializedName("active_code") + private String activeCode; + + private Integer status; + + @SerializedName("create_time") + private Long createTime; + + @SerializedName("active_time") + private Long activeTime; + + @SerializedName("expire_time") + private Long expireTime; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseBaseAccount.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseBaseAccount.java new file mode 100644 index 0000000000..7e363f4fdf --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseBaseAccount.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.cp.bean.license; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 许可证账号基础类 + * + * @author Totoro created on 2022/6/27 14:39 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseBaseAccount implements Serializable { + private static final long serialVersionUID = 7075253491688740047L; + + + /** + * 用户ID + */ + private String userid; + + /** + * 类型 + */ + private Integer type; + + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseCorpAccount.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseCorpAccount.java new file mode 100644 index 0000000000..05b523ec94 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseCorpAccount.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * The type Wx cp tp license corp account. + * + * @author Totoro created on 2022/6/27 15:21 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseCorpAccount extends WxCpTpLicenseBaseAccount { + + private static final long serialVersionUID = -5856054486686123753L; + + @SerializedName("active_time") + private Long activeTime; + + @SerializedName("expire_time") + private Long expireTime; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseInvalidAccount.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseInvalidAccount.java new file mode 100644 index 0000000000..85994d7ed7 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseInvalidAccount.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * The type Wx cp tp license invalid account. + * + * @author Totoro created on 2022-6-27 15:35:30 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseInvalidAccount extends WxCpTpLicenseBaseAccount { + private static final long serialVersionUID = -3706481243147500720L; + + @SerializedName("errcode") + private Integer errorCode; + @SerializedName("errmsg") + private String errMsg; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseOrder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseOrder.java new file mode 100644 index 0000000000..0cfbe5b028 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseOrder.java @@ -0,0 +1,57 @@ +package me.chanjar.weixin.cp.bean.license; + +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/95648 + * + * @author Totoro created on 2022/6/27 11:38 + */ +@Data +public class WxCpTpLicenseOrder implements Serializable { + + private static final long serialVersionUID = -4094302825442292644L; + + @SerializedName("order_id") + private String orderId; + + @SerializedName("order_type") + private Integer orderType; + + @SerializedName("order_status") + private Integer orderStatus; + + @SerializedName("corpid") + private String corpId; + + @SerializedName("price") + private Long price; + + @SerializedName("account_count") + private WxCpTpLicenseAccountCount accountCount; + + @SerializedName("account_duration") + private WxCpTpLicenseAccountDuration accountDuration; + + @SerializedName("create_time") + private Long createTime; + + @SerializedName("pay_time") + private Long payTime; + + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseSimpleOrder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseSimpleOrder.java new file mode 100644 index 0000000000..f994fd7a42 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseSimpleOrder.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * The type Wx cp tp license simple order. + * + * @author Totoro created on 2022/6/27 11:38 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseSimpleOrder implements Serializable { + + private static final long serialVersionUID = -4094302825442292644L; + + @SerializedName("order_id") + private String orderId; + @SerializedName("order_type") + private Integer orderType; + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseTransfer.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseTransfer.java new file mode 100644 index 0000000000..6be49008bb --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/WxCpTpLicenseTransfer.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.cp.bean.license; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 基础的信息 + * + * @author Totoro created on 2022/6/27 15:50 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseTransfer implements Serializable { + private static final long serialVersionUID = -5194757640985570778L; + + + /** + * 转移成员加密的userid + */ + @SerializedName("handover_userid") + private String handoverUserId; + + /** + * 接收成员加密的userid + */ + @SerializedName("takeover_userid") + private String takeoverUserId; + + /** + * 基础成功标识符,在请求继承的时候无需传入该参数,参数为企业微信返回 + * 0为成功 + */ + @SerializedName("errcode") + private Integer errCode; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseActiveInfoByUserResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseActiveInfoByUserResp.java new file mode 100644 index 0000000000..a9284d9d6e --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseActiveInfoByUserResp.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.cp.bean.license.account; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveCodeInfo; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 某个企业成员的激活情况 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95555 + * + * @author Totoro created on 2022-6-27 14:51:19 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseActiveInfoByUserResp extends WxCpBaseResp { + private static final long serialVersionUID = -5172901191911873330L; + + + @SerializedName("active_status") + private Integer activeStatus; + + @SerializedName("active_info_list") + private List activeInfoList; + + + /** + * From json wx cp tp license active info by user resp. + * + * @param json the json + * @return the wx cp tp license active info by user resp + */ + public static WxCpTpLicenseActiveInfoByUserResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseActiveInfoByUserResp.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchActiveResultResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchActiveResultResp.java new file mode 100644 index 0000000000..f1336af5a1 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchActiveResultResp.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.cp.bean.license.account; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 批量激活帐号结果 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95553 + * + * @author Totoro created on 2022-6-27 16:19:21 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseBatchActiveResultResp extends WxCpBaseResp { + + private static final long serialVersionUID = 8799524570217687659L; + + @SerializedName("active_result") + private List activeResults; + + + /** + * From json wx cp tp license batch active result resp. + * + * @param json the json + * @return the wx cp tp license batch active result resp + */ + public static WxCpTpLicenseBatchActiveResultResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseBatchActiveResultResp.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchCodeInfoResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchCodeInfoResp.java new file mode 100644 index 0000000000..0029700122 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchCodeInfoResp.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.license.account; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveCodeInfo; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 批量查询的激活码详情 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95553 + * + * @author Totoro created on 2022-6-27 14:51:19 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseBatchCodeInfoResp extends WxCpBaseResp { + private static final long serialVersionUID = 1327038464020790843L; + + @SerializedName("active_info_list") + private List activeCodeInfoList; + + @SerializedName("invalid_active_code_list") + private List invalidActiveCodeList; + + + /** + * From json wx cp tp license batch code info resp. + * + * @param json the json + * @return the wx cp tp license batch code info resp + */ + public static WxCpTpLicenseBatchCodeInfoResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseBatchCodeInfoResp.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchTransferResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchTransferResp.java new file mode 100644 index 0000000000..1b24a20a35 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseBatchTransferResp.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.cp.bean.license.account; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 基础结果返回信息 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95673 + * + * @author Totoro created on 2022/6/27 15:49 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseBatchTransferResp extends WxCpBaseResp { + private static final long serialVersionUID = 5443977430756597486L; + + @SerializedName("transfer_result") + private List transferResult; + + /** + * From json wx cp tp license batch transfer resp. + * + * @param json the json + * @return the wx cp tp license batch transfer resp + */ + public static WxCpTpLicenseBatchTransferResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseBatchTransferResp.class); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseCodeInfoResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseCodeInfoResp.java new file mode 100644 index 0000000000..152b38d8b9 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseCodeInfoResp.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean.license.account; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveCodeInfo; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 查询的激活码详情 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95553 + * + * @author Totoro created on 2022/6/27 14:28 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseCodeInfoResp extends WxCpBaseResp { + private static final long serialVersionUID = 8058798194938243361L; + + @SerializedName("active_info") + private WxCpTpLicenseActiveCodeInfo activeCodeInfo; + + + /** + * From json wx cp tp license code info resp. + * + * @param json the json + * @return the wx cp tp license code info resp + */ + public static WxCpTpLicenseCodeInfoResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseCodeInfoResp.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseCorpAccountListResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseCorpAccountListResp.java new file mode 100644 index 0000000000..79e7f81305 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/account/WxCpTpLicenseCorpAccountListResp.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.cp.bean.license.account; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseCorpAccount; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 企业的帐号列表(已激活) + * 文档地址:https://developer.work.weixin.qq.com/document/path/95544 + * + * @author Totoro created on 2022/6/27 15:15 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseCorpAccountListResp extends WxCpBaseResp { + private static final long serialVersionUID = -7976008813041959375L; + + @SerializedName("next_cursor") + private String nextCursor; + + @SerializedName("has_more") + private Integer hasMore; + + @SerializedName("account_list") + private List orderList; + + + /** + * From json wx cp tp license corp account list resp. + * + * @param json the json + * @return the wx cp tp license corp account list resp + */ + public static WxCpTpLicenseCorpAccountListResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseCorpAccountListResp.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseCreateOrderResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseCreateOrderResp.java new file mode 100644 index 0000000000..66648b75d2 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseCreateOrderResp.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean.license.order; + +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; + +/** + * 订单创建结果 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95644 + * + * @author Totoro created on 2022-6-27 11:26:36 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseCreateOrderResp extends WxCpBaseResp { + private static final long serialVersionUID = 6644560301282598903L; + + @SerializedName("order_id") + private String orderId; + + + /** + * From json wx cp tp license create order resp. + * + * @param json the json + * @return the wx cp tp license create order resp + */ + public static WxCpTpLicenseCreateOrderResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseCreateOrderResp.class); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseNewOrderRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseNewOrderRequest.java new file mode 100644 index 0000000000..232fd9d9e6 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseNewOrderRequest.java @@ -0,0 +1,62 @@ +package me.chanjar.weixin.cp.bean.license.order; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccountCount; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccountDuration; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 下单购买帐号 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95644 + * + * @author Totoro created on 2022/6/27 10:52 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseNewOrderRequest implements Serializable { + private static final long serialVersionUID = 6644560301282598903L; + + /** + * 企业ID + */ + @SerializedName("corpid") + private String corpId; + + /** + * 购买者ID + */ + @SerializedName("buyer_userid") + private String buyerUserId; + + /** + * 账号个数 + */ + @SerializedName("account_count") + private WxCpTpLicenseAccountCount accountCount; + + /** + * 购买市场 + */ + @SerializedName("account_duration") + private WxCpTpLicenseAccountDuration accountDuration; + + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderAccountListResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderAccountListResp.java new file mode 100644 index 0000000000..295fdb8436 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderAccountListResp.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.cp.bean.license.order; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccount; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 获取订单中的帐号列表 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95649 + * + * @author Totoro created on 2022-6-27 14:14:40 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpTpLicenseOrderAccountListResp extends WxCpBaseResp { + private static final long serialVersionUID = 470154227651487230L; + + @SerializedName("next_cursor") + private String nextCursor; + + @SerializedName("has_more") + private Integer hasMore; + + @SerializedName("account_list") + private List accountList; + + + /** + * From json wx cp tp license order account list resp. + * + * @param json the json + * @return the wx cp tp license order account list resp + */ + public static WxCpTpLicenseOrderAccountListResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseOrderAccountListResp.class); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderInfoResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderInfoResp.java new file mode 100644 index 0000000000..691aa25a71 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderInfoResp.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.bean.license.order; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseOrder; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 订单详情结果 + * 文档:https://developer.work.weixin.qq.com/document/path/95648 + * + * @author Totoro created on 2022/06/27 11:56:03 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseOrderInfoResp extends WxCpBaseResp { + + private static final long serialVersionUID = 7000171280773370910L; + + private WxCpTpLicenseOrder order; + + + /** + * From json wx cp tp license order info resp. + * + * @param json the json + * @return the wx cp tp license order info resp + */ + public static WxCpTpLicenseOrderInfoResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseOrderInfoResp.class); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderListResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderListResp.java new file mode 100644 index 0000000000..a9e0e5d32f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseOrderListResp.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.cp.bean.license.order; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseSimpleOrder; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 获取订单列表详情 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95647 + * + * @author Totoro created on 2022/6/27 11:39 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpTpLicenseOrderListResp extends WxCpBaseResp { + private static final long serialVersionUID = 1878909432164961275L; + + @SerializedName("next_cursor") + private String nextCursor; + + @SerializedName("has_more") + private Integer hasMore; + + @SerializedName("order_list") + private List orderList; + + + /** + * From json wx cp tp license order list resp. + * + * @param json the json + * @return the wx cp tp license order list resp + */ + public static WxCpTpLicenseOrderListResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseOrderListResp.class); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderJobRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderJobRequest.java new file mode 100644 index 0000000000..aabae94591 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderJobRequest.java @@ -0,0 +1,54 @@ +package me.chanjar.weixin.cp.bean.license.order; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseBaseAccount; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 创建下单续期帐号任务 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95646 + * + * @author Totoro created on 2022/6/27 11:12 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseRenewOrderJobRequest implements Serializable { + + private static final long serialVersionUID = 8074896339359557034L; + /** + * 对应的企业ID + */ + @SerializedName("corpid") + private String corpId; + /** + * 续费的用户UserId + */ + @SerializedName("account_list") + private List accountList; + /** + * 任务id,若不传则默认创建一个新任务。若指定第一次调用后拿到jobid,可以通过该接口将jobid关联多个userid + */ + @SerializedName("jobid") + private String jobId; + + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderJobResp.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderJobResp.java new file mode 100644 index 0000000000..31734b5ad2 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderJobResp.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.cp.bean.license.order; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseInvalidAccount; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +/** + * 创建下单购买帐号任务返回结果 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95646 + * + * @author Totoro created on 2022-6-27 11:15:20 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxCpTpLicenseRenewOrderJobResp extends WxCpBaseResp { + + private static final long serialVersionUID = -4469875729545594102L; + /** + * 任务ID + */ + @SerializedName("jobid") + private String jobId; + /** + * 有效的续费账号列表 + */ + @SerializedName("invalid_account_list") + private List invalidAccountList; + + + /** + * From json wx cp tp license renew order job resp. + * + * @param json the json + * @return the wx cp tp license renew order job resp + */ + public static WxCpTpLicenseRenewOrderJobResp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseRenewOrderJobResp.class); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderRequest.java new file mode 100644 index 0000000000..196e02c1c4 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/license/order/WxCpTpLicenseRenewOrderRequest.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.cp.bean.license.order; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccountDuration; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 续期帐号订单 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95646 + * + * @author Totoro created on 2022-6-27 11:21:51 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxCpTpLicenseRenewOrderRequest implements Serializable { + private static final long serialVersionUID = 8709132346969663049L; + + @SerializedName("buyer_userid") + private String buyerUserId; + @SerializedName("jobid") + private String jobId; + @SerializedName("account_duration") + private WxCpTpLicenseAccountDuration accountDuration; + + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpAgentPerm.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpAgentPerm.java new file mode 100644 index 0000000000..7448b9e0e5 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpAgentPerm.java @@ -0,0 +1,20 @@ +package me.chanjar.weixin.cp.bean.linkedcorp; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 获取应用可见范围请求类 + * + * @author libo + */ +@Data +public class WxCpLinkedCorpAgentPerm implements Serializable { + private static final long serialVersionUID = 6794613362541093845L; + @SerializedName("userids") + private String[] userIdList; + @SerializedName("department_ids") + private String[] departmentIdList; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpDepartment.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpDepartment.java new file mode 100644 index 0000000000..96f94a74e8 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpDepartment.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.cp.bean.linkedcorp; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 获取互联企业部门列表 + * + * @author libo + */ +@Data +public class WxCpLinkedCorpDepartment implements Serializable { + private static final long serialVersionUID = -210249269343292440L; + @SerializedName("department_id") + private String departmentId; + @SerializedName("department_name") + private String departmentName; + @SerializedName("parentid") + private String parentId; + @SerializedName("order") + private Integer order; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpUser.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpUser.java new file mode 100644 index 0000000000..8bb380deac --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/linkedcorp/WxCpLinkedCorpUser.java @@ -0,0 +1,59 @@ +package me.chanjar.weixin.cp.bean.linkedcorp; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 获取互联企业成员详细信息 + * + * @author libo + */ +@Data +public class WxCpLinkedCorpUser implements Serializable { + private static final long serialVersionUID = -5197865724556226531L; + @SerializedName("userid") + private String userId; + @SerializedName("name") + private String name; + @SerializedName("department") + private String[] department; + @SerializedName("mobile") + private String mobile; + @SerializedName("email") + private String email; + @SerializedName("position") + private String position; + @SerializedName("corpid") + private String corpId; + private final List extAttrs = new ArrayList<>(); + + /** + * The type Attr. + */ + @Data + @Accessors(chain = true) + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Attr implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + /** + * 属性类型: 0-文本 1-网页 + */ + private Integer type; + private String name; + private String textValue; + private String webUrl; + private String webTitle; + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingCreateRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingCreateRequest.java new file mode 100644 index 0000000000..00d0320cd1 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingCreateRequest.java @@ -0,0 +1,110 @@ +package me.chanjar.weixin.cp.bean.living; + +import com.google.gson.annotations.SerializedName; +import lombok.*; +import lombok.experimental.Accessors; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 创建预约直播请求. + * + * @author Wang_Wong created on 2021-12-23 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxCpLivingCreateRequest implements Serializable { + private static final long serialVersionUID = -4960239393895754138L; + + @SerializedName("anchor_userid") + private String anchorUserid; + + @SerializedName("theme") + private String theme; + + @SerializedName("living_start") + private Long livingStart; + + @SerializedName("living_duration") + private Long livingDuration; + + @SerializedName("remind_time") + private Long remindTime; + + @SerializedName("description") + private String description; + + @SerializedName("type") + private Integer type; + + @SerializedName("agentid") + private Integer agentId; + + @SerializedName("activity_cover_mediaid") + private String activityCoverMediaid; + + @SerializedName("activity_share_mediaid") + private String activityShareMediaid; + + @SerializedName("activity_detail") + private ActivityDetail activityDetail; + + /** + * The type Activity detail. + */ + @Getter + @Setter + public static class ActivityDetail implements Serializable { + + @SerializedName("image_list") + private List imageList; + + @SerializedName("description") + private String description; + + /** + * From json activity detail. + * + * @param json the json + * @return the activity detail + */ + public static ActivityDetail fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, ActivityDetail.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + /** + * From json wx cp living create request. + * + * @param json the json + * @return the wx cp living create request + */ + public static WxCpLivingCreateRequest fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpLivingCreateRequest.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingInfo.java new file mode 100644 index 0000000000..f8fdeb351a --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingInfo.java @@ -0,0 +1,91 @@ +package me.chanjar.weixin.cp.bean.living; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 直播详情信息. + * + * @author Wang_Wong + */ +@Data +public class WxCpLivingInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("theme") + private String theme; + + @SerializedName("living_start") + private Long livingStart; + + @SerializedName("living_duration") + private Long livingDuration; + + @SerializedName("status") + private Integer status; + + @SerializedName("reserve_living_duration") + private Long reserveLivingDuration; + + @SerializedName("reserve_start") + private Long reserveStart; + + @SerializedName("description") + private String description; + + @SerializedName("anchor_userid") + private String anchorUserid; + + @SerializedName("main_department") + private Long mainDepartment; + + @SerializedName("viewer_num") + private Integer viewerNum; + + @SerializedName("comment_num") + private Integer commentNum; + + @SerializedName("mic_num") + private Integer micNum; + + @SerializedName("open_replay") + private Integer openReplay; + + @SerializedName("replay_status") + private Integer replayStatus; + + @SerializedName("type") + private Integer type; + + @SerializedName("push_stream_url") + private String pushStreamUrl; + + @SerializedName("online_count") + private Integer onlineCount; + + @SerializedName("subscribe_count") + private Integer subscribeCount; + + /** + * From json wx cp living info. + * + * @param json the json + * @return the wx cp living info + */ + public static WxCpLivingInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpLivingInfo.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingModifyRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingModifyRequest.java new file mode 100644 index 0000000000..fe8a446708 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingModifyRequest.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.cp.bean.living; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 创建预约直播请求. + * + * @author Wang_Wong created on 2021-12-23 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxCpLivingModifyRequest implements Serializable { + private static final long serialVersionUID = -4960239393895754138L; + + @SerializedName("livingid") + private String livingId; + + @SerializedName("theme") + private String theme; + + @SerializedName("living_start") + private Long livingStart; + + @SerializedName("living_duration") + private Long livingDuration; + + @SerializedName("remind_time") + private Long remindTime; + + @SerializedName("description") + private String description; + + @SerializedName("type") + private Integer type; + + /** + * From json wx cp living modify request. + * + * @param json the json + * @return the wx cp living modify request + */ + public static WxCpLivingModifyRequest fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpLivingModifyRequest.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingResult.java new file mode 100644 index 0000000000..92f698848f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingResult.java @@ -0,0 +1,80 @@ +package me.chanjar.weixin.cp.bean.living; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 直播返回对象. + * + * @author Wang_Wong + */ +@Data +public class WxCpLivingResult implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("errcode") + private Integer errcode; + + @SerializedName("errmsg") + private String errmsg; + + /** + * The type Living id result. + */ + @Getter + @Setter + public static class LivingIdResult implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("next_cursor") + private String nextCursor; + + @SerializedName("livingid_list") + private String[] livingIdList; + + /** + * From json living id result. + * + * @param json the json + * @return the living id result + */ + public static LivingIdResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, LivingIdResult.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + /** + * From json wx cp living result. + * + * @param json the json + * @return the wx cp living result + */ + public static WxCpLivingResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpLivingResult.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingShareInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingShareInfo.java new file mode 100644 index 0000000000..16f74e253d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingShareInfo.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.cp.bean.living; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 跳转小程序商城的直播观众信息. + * + * @author Wang_Wong + */ +@Data +public class WxCpLivingShareInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + private String livingid; + + @SerializedName("viewer_userid") + private String viewerUserid; + + @SerializedName("viewer_external_userid") + private String viewerExternalUserid; + + @SerializedName("invitor_userid") + private String invitorUserid; + + @SerializedName("invitor_external_userid") + private String invitorExternalUserid; + + /** + * From json wx cp living share info. + * + * @param json the json + * @return the wx cp living share info + */ + public static WxCpLivingShareInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpLivingShareInfo.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpWatchStat.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpWatchStat.java new file mode 100644 index 0000000000..f1c25a1704 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpWatchStat.java @@ -0,0 +1,110 @@ +package me.chanjar.weixin.cp.bean.living; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 直播观看明细. + * + * @author Wang_Wong + */ +@Data +public class WxCpWatchStat implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + private Integer ending; + + @SerializedName("next_key") + private String nextKey; + + @SerializedName("stat_info") + private StatInfo statInfo; + + /** + * The type Stat info. + */ + @Getter + @Setter + public static class StatInfo implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("users") + private List users; + + @SerializedName("external_users") + private List externalUsers; + + } + + /** + * The type User. + */ + @Getter + @Setter + public static class User implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + private String userid; + + @SerializedName("watch_time") + private Long watchTime; + + @SerializedName("is_comment") + private Integer isComment; + + @SerializedName("is_mic") + private Integer isMic; + + } + + /** + * The type External user. + */ + @Getter + @Setter + public static class ExternalUser implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + private String name; + private Integer type; + + @SerializedName("external_userid") + private String externalUserid; + + @SerializedName("watch_time") + private Long watchTime; + + @SerializedName("is_comment") + private Integer isComment; + + @SerializedName("is_mic") + private Integer isMic; + + } + + /** + * From json wx cp watch stat. + * + * @param json the json + * @return the wx cp watch stat + */ + public static WxCpWatchStat fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpWatchStat.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/TemplateCardMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/TemplateCardMessage.java new file mode 100644 index 0000000000..417b5e80e7 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/TemplateCardMessage.java @@ -0,0 +1,276 @@ +package me.chanjar.weixin.cp.bean.message; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TemplateCardMessage implements Serializable { + private static final long serialVersionUID = 8833792280163704239L; + + @JsonProperty("userids") + private List userids; + @JsonProperty("partyids") + private List partyids; + @JsonProperty("tagids") + private List tagids; + @JsonProperty("atall") + private Integer atall; + @JsonProperty("agentid") + private Integer agentid; + @JsonProperty("response_code") + private String responseCode; + @JsonProperty("enable_id_trans") + private Integer enableIdTrans; + @JsonProperty("template_card") + private TemplateCardDTO templateCard; + + @NoArgsConstructor + @Data + public static class TemplateCardDTO { + @JsonProperty("card_type") + private String cardType; + @JsonProperty("source") + private SourceDTO source; + @JsonProperty("main_title") + private MainTitleDTO mainTitle; + @JsonProperty("select_list") + private List selectList; + @JsonProperty("submit_button") + private SubmitButtonDTO submitButton; + @JsonProperty("replace_text") + private String replaceText; + + @JsonProperty("checkbox") + private CheckboxDTO checkbox; + + + @JsonProperty("action_menu") + private ActionMenuDTO actionMenu; + @JsonProperty("quote_area") + private QuoteAreaDTO quoteArea; + @JsonProperty("sub_title_text") + private String subTitleText; + @JsonProperty("horizontal_content_list") + private List horizontalContentList; + @JsonProperty("card_action") + private CardActionDTO cardAction; + @JsonProperty("button_selection") + private ButtonSelectionDTO buttonSelection; + @JsonProperty("button_list") + private List buttonList; + + @JsonProperty("image_text_area") + private ImageTextAreaDTO imageTextArea; + @JsonProperty("card_image") + private CardImageDTO cardImage; + @JsonProperty("vertical_content_list") + private List verticalContentList; + @JsonProperty("jump_list") + private List jumpList; + + + @NoArgsConstructor + @Data + public static class SourceDTO { + @JsonProperty("icon_url") + private String iconUrl; + @JsonProperty("desc") + private String desc; + @JsonProperty("desc_color") + private Integer descColor; + } + + @NoArgsConstructor + @Data + public static class ActionMenuDTO { + @JsonProperty("desc") + private String desc; + @JsonProperty("action_list") + private List actionList; + } + + @NoArgsConstructor + @Data + public static class QuoteAreaDTO { + @JsonProperty("type") + private Integer type; + @JsonProperty("url") + private String url; + @JsonProperty("title") + private String title; + @JsonProperty("quote_text") + private String quoteText; + } + + @NoArgsConstructor + @Data + public static class CardActionDTO { + @JsonProperty("type") + private Integer type; + @JsonProperty("url") + private String url; + @JsonProperty("appid") + private String appid; + @JsonProperty("pagepath") + private String pagepath; + } + + @NoArgsConstructor + @Data + public static class ButtonSelectionDTO { + @JsonProperty("question_key") + private String questionKey; + @JsonProperty("title") + private String title; + @JsonProperty("option_list") + private List optionList; + @JsonProperty("selected_id") + private String selectedId; + } + + @NoArgsConstructor + @Data + public static class HorizontalContentListDTO { + @JsonProperty("keyname") + private String keyname; + @JsonProperty("value") + private String value; + @JsonProperty("type") + private Integer type; + @JsonProperty("url") + private String url; + @JsonProperty("media_id") + private String mediaId; + @JsonProperty("userid") + private String userid; + } + + @NoArgsConstructor + @Data + public static class ButtonListDTO { + @JsonProperty("text") + private String text; + @JsonProperty("style") + private Integer style; + @JsonProperty("key") + private String key; + } + + + @NoArgsConstructor + @Data + public static class CheckboxDTO { + @JsonProperty("question_key") + private String questionKey; + @JsonProperty("option_list") + private List optionList; + @JsonProperty("disable") + private Boolean disable; + @JsonProperty("mode") + private Integer mode; + + @NoArgsConstructor + @Data + public static class OptionListDTO { + @JsonProperty("id") + private String id; + @JsonProperty("text") + private String text; + @JsonProperty("is_checked") + private Boolean isChecked; + } + + } + + @NoArgsConstructor + @Data + public static class MainTitleDTO { + @JsonProperty("title") + private String title; + @JsonProperty("desc") + private String desc; + } + + @NoArgsConstructor + @Data + public static class SubmitButtonDTO { + @JsonProperty("text") + private String text; + @JsonProperty("key") + private String key; + } + + @NoArgsConstructor + @Data + public static class SelectListDTO { + @JsonProperty("question_key") + private String questionKey; + @JsonProperty("title") + private String title; + @JsonProperty("selected_id") + private String selectedId; + @JsonProperty("disable") + private Boolean disable; + @JsonProperty("option_list") + private List optionList; + + @NoArgsConstructor + @Data + public static class OptionListDTO { + @JsonProperty("id") + private String id; + @JsonProperty("text") + private String text; + } + } + + @NoArgsConstructor + @Data + public static class ImageTextAreaDTO { + @JsonProperty("type") + private Integer type; + @JsonProperty("url") + private String url; + @JsonProperty("title") + private String title; + @JsonProperty("desc") + private String desc; + @JsonProperty("image_url") + private String imageUrl; + } + + @NoArgsConstructor + @Data + public static class CardImageDTO { + @JsonProperty("url") + private String url; + @JsonProperty("aspect_ratio") + private Double aspectRatio; + } + + @NoArgsConstructor + @Data + public static class JumpListDTO { + @JsonProperty("type") + private Integer type; + @JsonProperty("title") + private String title; + @JsonProperty("url") + private String url; + @JsonProperty("appid") + private String appid; + @JsonProperty("pagepath") + private String pagepath; + } + + + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpAppChatMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpAppChatMessage.java index 10dd3c1b27..e1cbb5c65d 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpAppChatMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpAppChatMessage.java @@ -75,6 +75,11 @@ public class WxCpAppChatMessage implements Serializable { /** * 构建文本消息. + * + * @param chatId the chat id + * @param content the content + * @param safe the safe + * @return the wx cp app chat message */ public static WxCpAppChatMessage buildTextMsg(String chatId, String content, boolean safe) { final WxCpAppChatMessage message = new WxCpAppChatMessage(); @@ -87,6 +92,8 @@ public static WxCpAppChatMessage buildTextMsg(String chatId, String content, boo /** * 生成json字符串. + * + * @return the string */ public String toJson() { JsonObject messageJson = new JsonObject(); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpGroupRobotMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpGroupRobotMessage.java index de7e88d79b..6c889b6cec 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpGroupRobotMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpGroupRobotMessage.java @@ -7,17 +7,19 @@ import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.cp.bean.article.NewArticle; +import me.chanjar.weixin.cp.bean.templatecard.*; +import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpConsts.GroupRobotMsgType.*; +import static me.chanjar.weixin.cp.constant.WxCpConsts.GroupRobotMsgType.TEMPLATE_CARD; /** * 微信群机器人消息 * - * @author yr - * @date 2020-08-20 + * @author yr created on 2020-08-20 */ @AllArgsConstructor @NoArgsConstructor @@ -25,7 +27,7 @@ @Data public class WxCpGroupRobotMessage implements Serializable { private static final long serialVersionUID = -4301684507150486556L; - + /** * 消息类型 */ @@ -57,9 +59,170 @@ public class WxCpGroupRobotMessage implements Serializable { */ private List articles; + /** + * 文件id + */ + private String mediaId; + + private Integer agentId; + + // 模板型卡片特有属性 + /** + * 模板卡片类型,文本通知型卡片填写 “text_notice”, + * 图文展示型卡片此处填写 “news_notice”, + * 按钮交互型卡片填写”button_interaction”, + * 投票选择型卡片填写”vote_interaction”, + * 多项选择型卡片填写 “multiple_interaction” + */ + private String cardType; + + /** + * 卡片来源样式信息,不需要来源样式可不填写 + * 来源图片的url + */ + private String sourceIconUrl; + /** + * 卡片来源样式信息,不需要来源样式可不填写 + * 来源图片的描述,建议不超过20个字 + */ + private String sourceDesc; + + /** + * 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色 + */ + private Integer sourceDescColor; + + /** + * 更多操作界面的描述 + */ + private String actionMenuDesc; + + /** + * 操作列表,列表长度取值范围为 [1, 3] + */ + private List actionMenuActionList; + + /** + * 一级标题,建议不超过36个字 + */ + private String mainTitleTitle; + /** + * 标题辅助信息,建议不超过44个字 + */ + private String mainTitleDesc; + + /** + * 图文展示型的卡片必须有图片字段。 + * 图片的url. + */ + private String cardImageUrl; + + /** + * 图片的宽高比,宽高比要小于2.25,大于1.3,不填该参数默认1.3 + */ + private Float cardImageAspectRatio; + /** + * 关键数据样式 + * 关键数据样式的数据内容,建议不超过14个字 + */ + private String emphasisContentTitle; + /** + * 关键数据样式的数据描述内容,建议不超过22个字 + */ + private String emphasisContentDesc; + + /** + * 二级普通文本,建议不超过160个字 + */ + private String subTitleText; + + /** + * 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4 + */ + private List verticalContents; + + /** + * 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + */ + private List horizontalContents; + + /** + * 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + */ + private List jumps; + + /** + * 整体卡片的点击跳转事件,text_notice必填本字段 + * 跳转事件类型,1 代表跳转url,2 代表打开小程序。text_notice卡片模版中该字段取值范围为[1,2] + */ + private Integer cardActionType; + /** + * 跳转事件的url,card_action.type是1时必填 + */ + private String cardActionUrl; + + /** + * 跳转事件的小程序的appid,必须是与当前应用关联的小程序,card_action.type是2时必填 + */ + private String cardActionAppid; + + /** + * 跳转事件的小程序的pagepath,card_action.type是2时选填 + */ + private String cardActionPagepath; + + /** + * 按钮交互型卡片需指定。 + * 按钮列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + */ + private List buttons; + + /** + * 投票选择型卡片需要指定 + * 选择题key值,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节 + */ + private String checkboxQuestionKey; + + /** + * 选择题模式,单选:0,多选:1,不填默认0 + */ + private Integer checkboxMode; + + /** + * 选项list,选项个数不超过 20 个,最少1个 + */ + private List options; + + /** + * 提交按钮样式 + * 按钮文案,建议不超过10个字,不填默认为提交 + */ + private String submitButtonText; + /** + * 提交按钮的key,会产生回调事件将本参数作为EventKey返回,最长支持1024字节 + */ + private String submitButtonKey; + /** + * 下拉式的选择器列表,multiple_interaction类型的卡片该字段不可为空,一个消息最多支持 3 个选择器 + */ + private List selects; + + /** + * 引用文献样式 + */ + private QuoteArea quoteArea; + + /** + * To json string. + * + * @return the string + */ public String toJson() { JsonObject messageJson = new JsonObject(); messageJson.addProperty("msgtype", this.getMsgType()); + if (this.getAgentId() != null) { + messageJson.addProperty("agentid", this.getAgentId()); + } switch (this.getMsgType()) { case TEXT: { @@ -112,6 +275,182 @@ public String toJson() { messageJson.add("news", text); break; } + case FILE: { + JsonObject file = new JsonObject(); + file.addProperty("media_id", this.getMediaId()); + messageJson.add("file", file); + break; + } + case TEMPLATE_CARD: { + JsonObject template = new JsonObject(); + template.addProperty("card_type", this.getCardType()); + + if (StringUtils.isNotBlank(this.getSourceIconUrl()) || StringUtils.isNotBlank(this.getSourceDesc())) { + JsonObject source = new JsonObject(); + if (StringUtils.isNotBlank(this.getSourceIconUrl())) { + source.addProperty("icon_url", this.getSourceIconUrl()); + } + if (StringUtils.isNotBlank(this.getSourceDesc())) { + source.addProperty("desc", this.getSourceDesc()); + } + source.addProperty("desc_color", this.getSourceDescColor()); + template.add("source", source); + } + + if (StringUtils.isNotBlank(this.getActionMenuDesc())) { + JsonObject action_menu = new JsonObject(); + action_menu.addProperty("desc", this.getActionMenuDesc()); + JsonArray actionList = new JsonArray(); + List actionMenuItemList = this.getActionMenuActionList(); + for (ActionMenuItem actionItemI : actionMenuItemList) { + actionList.add(actionItemI.toJson()); + } + action_menu.add("action_list", actionList); + template.add("action_menu", action_menu); + } + + if (StringUtils.isNotBlank(this.getMainTitleTitle()) || StringUtils.isNotBlank(this.getMainTitleDesc())) { + JsonObject mainTitle = new JsonObject(); + if (StringUtils.isNotBlank(this.getMainTitleTitle())) { + mainTitle.addProperty("title", this.getMainTitleTitle()); + } + if (StringUtils.isNotBlank(this.getMainTitleDesc())) { + mainTitle.addProperty("desc", this.getMainTitleDesc()); + } + template.add("main_title", mainTitle); + } + + if (StringUtils.isNotBlank(this.getCardImageUrl()) || this.getCardImageAspectRatio() != null) { + JsonObject cardImage = new JsonObject(); + if (StringUtils.isNotBlank(this.getCardImageUrl())) { + cardImage.addProperty("url", this.getCardImageUrl()); + } + if (null != this.getCardImageAspectRatio()) { + cardImage.addProperty("aspect_ratio", this.getCardImageAspectRatio()); + } + template.add("card_image", cardImage); + } + + if (StringUtils.isNotBlank(this.getEmphasisContentTitle()) || StringUtils.isNotBlank(this.getEmphasisContentDesc())) { + JsonObject emphasisContent = new JsonObject(); + if (StringUtils.isNotBlank(this.getEmphasisContentTitle())) { + emphasisContent.addProperty("title", this.getEmphasisContentTitle()); + } + if (StringUtils.isNotBlank(this.getEmphasisContentDesc())) { + emphasisContent.addProperty("desc", this.getEmphasisContentDesc()); + } + template.add("emphasis_content", emphasisContent); + } + + + if (StringUtils.isNotBlank(this.getSubTitleText())) { + template.addProperty("sub_title_text", this.getSubTitleText()); + } + + List verticalContents = this.getVerticalContents(); + if (null != verticalContents && !verticalContents.isEmpty()) { + JsonArray vContentJsonArray = new JsonArray(); + for (VerticalContent vContent : this.getVerticalContents()) { + JsonObject tempObject = vContent.toJson(); + vContentJsonArray.add(tempObject); + } + template.add("vertical_content_list", vContentJsonArray); + } + + List horizontalContents = this.getHorizontalContents(); + if (null != horizontalContents && !horizontalContents.isEmpty()) { + JsonArray hContentJsonArray = new JsonArray(); + for (HorizontalContent hContent : this.getHorizontalContents()) { + JsonObject tempObject = hContent.toJson(); + hContentJsonArray.add(tempObject); + } + template.add("horizontal_content_list", hContentJsonArray); + } + + List jumps = this.getJumps(); + if (null != jumps && !jumps.isEmpty()) { + JsonArray jumpJsonArray = new JsonArray(); + for (TemplateCardJump jump : this.getJumps()) { + JsonObject tempObject = jump.toJson(); + jumpJsonArray.add(tempObject); + } + template.add("jump_list", jumpJsonArray); + } + + if (null != this.getCardActionType()) { + JsonObject cardAction = new JsonObject(); + cardAction.addProperty("type", this.getCardActionType()); + if (StringUtils.isNotBlank(this.getCardActionUrl())) { + cardAction.addProperty("url", this.getCardActionUrl()); + } + if (StringUtils.isNotBlank(this.getCardActionAppid())) { + cardAction.addProperty("appid", this.getCardActionAppid()); + } + if (StringUtils.isNotBlank(this.getCardActionPagepath())) { + cardAction.addProperty("pagepath", this.getCardActionPagepath()); + } + template.add("card_action", cardAction); + } + + List buttons = this.getButtons(); + if (null != buttons && !buttons.isEmpty()) { + JsonArray btnJsonArray = new JsonArray(); + for (TemplateCardButton btn : this.getButtons()) { + JsonObject tempObject = btn.toJson(); + btnJsonArray.add(tempObject); + } + template.add("button_list", btnJsonArray); + } + + // checkbox + if (StringUtils.isNotBlank(this.getCheckboxQuestionKey())) { + JsonObject checkBox = new JsonObject(); + checkBox.addProperty("question_key", this.getCheckboxQuestionKey()); + if (null != this.getCheckboxMode()) { + checkBox.addProperty("mode", this.getCheckboxMode()); + } + JsonArray optionArray = new JsonArray(); + for (CheckboxOption option : this.getOptions()) { + JsonObject tempObject = option.toJson(); + optionArray.add(tempObject); + } + checkBox.add("option_list", optionArray); + + template.add("checkbox", checkBox); + } + + // submit_button + if (StringUtils.isNotBlank(this.getSubmitButtonText()) || StringUtils.isNotBlank(this.getSubmitButtonKey())) { + JsonObject submit_button = new JsonObject(); + if (StringUtils.isNotBlank(this.getSubmitButtonText())) { + submit_button.addProperty("text", this.getSubmitButtonText()); + } + if (StringUtils.isNotBlank(this.getSubmitButtonKey())) { + submit_button.addProperty("key", this.getSubmitButtonKey()); + } + template.add("submit_button", submit_button); + } + + // select_list + List selects = this.getSelects(); + if (null != selects && !selects.isEmpty()) { + JsonArray selectJsonArray = new JsonArray(); + for (MultipleSelect select : this.getSelects()) { + JsonObject tempObject = select.toJson(); + selectJsonArray.add(tempObject); + } + template.add("select_list", selectJsonArray); + } + + QuoteArea quoteArea = this.getQuoteArea(); + if (null != quoteArea) { + JsonObject quoteAreaJson = quoteArea.toJson(); + template.add("quote_area", quoteAreaJson); + } + + messageJson.add("template_card", template); + break; + } default: } 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 0e3f670874..92209fd4e5 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 @@ -21,9 +21,9 @@ /** * 互联企业消息. + * https://developer.work.weixin.qq.com/document/path/90250 * - * @author Binary Wang - * @date 2020-08-30 + * @author Binary Wang created on 2020-08-30 */ @Data @Builder @@ -43,7 +43,8 @@ public class WxCpLinkedCorpMessage implements Serializable { */ private String[] toUsers; /** - * 部门ID列表,最多支持100个。partyid在互联圈子内唯一。每个元素都是字符串类型,格式为:linked_id/party_id,其中linked_id是互联id,party_id是在互联圈子中的部门id。如果是本企业的部门,则直接传party_id即可。 + * 部门ID列表,最多支持100个。partyid在互联圈子内唯一。每个元素都是字符串类型,格式为:linked_id/party_id,其中linked_id是互联id,party_id是在互联圈子中的部门id + * 。如果是本企业的部门,则直接传party_id即可。 */ private String[] toParties; /** @@ -99,6 +100,11 @@ public void setMsgType(String msgType) { this.msgType = msgType; } + /** + * To json string. + * + * @return the string + */ public String toJson() { JsonObject messageJson = new JsonObject(); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageSendResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageSendResult.java index 2955df54c6..9d264664e4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageSendResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageSendResult.java @@ -9,8 +9,7 @@ /** * 互联企业的消息推送接口返回实体 * - * @author pg - * @date 2021年6月22日 + * @author pg created on 2021年6月22日 */ @Setter @Getter @@ -31,6 +30,12 @@ public String toString() { return WxCpGsonBuilder.create().toJson(this); } + /** + * From json wx cp linked corp message send result. + * + * @param json the json + * @return the wx cp linked corp message send result + */ public static WxCpLinkedCorpMessageSendResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpLinkedCorpMessageSendResult.class); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java index 244e7fed07..ca3fbceccb 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java @@ -8,6 +8,7 @@ import me.chanjar.weixin.cp.bean.article.NewArticle; import me.chanjar.weixin.cp.bean.messagebuilder.*; import me.chanjar.weixin.cp.bean.taskcard.TaskCardButton; +import me.chanjar.weixin.cp.bean.templatecard.*; import org.apache.commons.lang3.StringUtils; import java.io.Serializable; @@ -26,26 +27,99 @@ public class WxCpMessage implements Serializable { private static final long serialVersionUID = -2082278303476631708L; + /** + * 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。 + * 特殊情况:指定为"@all",则向该企业应用的全部成员发送 + */ private String toUser; + /** + * 指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。 + * 当touser为"@all"时忽略本参数 + */ private String toParty; + /** + * 指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。 + * 当touser为"@all"时忽略本参数 + */ private String toTag; + /** + * 企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值 + */ private Integer agentId; + /** + * 消息类型 + * 文本消息: text + * 图片消息: image + * 语音消息: voice + * 视频消息: video + * 文件消息: file + * 文本卡片消息: textcard + * 图文消息: news + * 图文消息: mpnews + * markdown消息: markdown + * 模板卡片消息: template_card + */ private String msgType; + /** + * 消息内容,最长不超过2048个字节,超过将截断(支持id转译) + */ private String content; + /** + * 媒体文件id,可以调用上传临时素材接口获取 + */ private String mediaId; + /** + * 图文消息缩略图的media_id, 可以通过素材管理接口获得。此处thumb_media_id即上传接口返回的media_id + */ private String thumbMediaId; + /** + * 标题,不超过128个字节,超过会自动截断(支持id转译) + */ private String title; + /** + * 描述,不超过512个字节,超过会自动截断(支持id转译) + */ private String description; private String musicUrl; private String hqMusicUrl; + /** + * 表示是否是保密消息,默认为0;注意仅 mpnews 类型的消息支持safe值为2,其他消息类型不支持 + * 0表示可对外分享 + * 1表示不能分享且内容显示水印 + * 2表示仅限在企业内分享 + */ private String safe; + /** + * 点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https) + */ private String url; + /** + * 按钮文字。 默认为“详情”, 不超过4个文字,超过自动截断。 + */ private String btnTxt; + /** + * 图文消息,一个图文消息支持1到8条图文 + */ private List articles = new ArrayList<>(); + /** + * 图文消息,一个图文消息支持1到8条图文 + */ private List mpnewsArticles = new ArrayList<>(); + /** + * 小程序appid,必须是与当前应用关联的小程序,appid和pagepath必须同时填写,填写后会忽略url字段 + */ private String appId; + /** + * 点击消息卡片后的小程序页面,最长1024个字节,仅限本小程序内的页面。该字段不填则消息点击后不跳转。 + */ private String page; + /** + * 是否放大第一个content_item + */ private Boolean emphasisFirstItem; + /** + * 消息内容键值对,最多允许10个item + */ private Map contentItems; /** @@ -70,8 +144,168 @@ public class WxCpMessage implements Serializable { private String taskId; private List taskButtons = new ArrayList<>(); + // 模板型卡片特有属性 + /** + * 模板卡片类型,文本通知型卡片填写 “text_notice”, + * 图文展示型卡片此处填写 “news_notice”, + * 按钮交互型卡片填写”button_interaction”, + * 投票选择型卡片填写”vote_interaction”, + * 多项选择型卡片填写 “multiple_interaction” + */ + private String cardType; + + /** + * 卡片来源样式信息,不需要来源样式可不填写 + * 来源图片的url + */ + private String sourceIconUrl; + /** + * 卡片来源样式信息,不需要来源样式可不填写 + * 来源图片的描述,建议不超过20个字 + */ + private String sourceDesc; + + /** + * 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色 + */ + private Integer sourceDescColor; + + /** + * 更多操作界面的描述 + */ + private String actionMenuDesc; + + /** + * 操作列表,列表长度取值范围为 [1, 3] + */ + private List actionMenuActionList; + + /** + * 一级标题,建议不超过36个字 + */ + private String mainTitleTitle; + + /** + * 标题辅助信息,建议不超过44个字 + */ + private String mainTitleDesc; + + /** + * 左图右文样式,news_notice类型的卡片,card_image 和 image_text_area 两者必填一个字段,不可都不填 + */ + private TemplateCardImageTextArea imageTextArea; + + /** + * 图文展示型的卡片必须有图片字段。 + * 图片的url. + */ + private String cardImageUrl; + + /** + * 图片的宽高比,宽高比要小于2.25,大于1.3,不填该参数默认1.3 + */ + private Float cardImageAspectRatio; + /** + * 关键数据样式 + * 关键数据样式的数据内容,建议不超过14个字 + */ + private String emphasisContentTitle; + /** + * 关键数据样式的数据描述内容,建议不超过22个字 + */ + private String emphasisContentDesc; + + /** + * 二级普通文本,建议不超过160个字 + */ + private String subTitleText; + + /** + * 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4 + */ + private List verticalContents; + + /** + * 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + */ + private List horizontalContents; + + /** + * 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + */ + private List jumps; + + /** + * 整体卡片的点击跳转事件,text_notice必填本字段 + * 跳转事件类型,1 代表跳转url,2 代表打开小程序。text_notice卡片模版中该字段取值范围为[1,2] + */ + private Integer cardActionType; + /** + * 跳转事件的url,card_action.type是1时必填 + */ + private String cardActionUrl; + + /** + * 跳转事件的小程序的appid,必须是与当前应用关联的小程序,card_action.type是2时必填 + */ + private String cardActionAppid; + + /** + * 跳转事件的小程序的pagepath,card_action.type是2时选填 + */ + private String cardActionPagepath; + + /** + * 按钮交互型卡片需指定。 + * button_selection + */ + private TemplateCardButtonSelection buttonSelection; + + /** + * 按钮交互型卡片需指定。 + * 按钮列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + */ + private List buttons; + + /** + * 投票选择型卡片需要指定 + * 选择题key值,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节 + */ + private String checkboxQuestionKey; + + /** + * 选择题模式,单选:0,多选:1,不填默认0 + */ + private Integer checkboxMode; + + /** + * 选项list,选项个数不超过 20 个,最少1个 + */ + private List options; + + /** + * 提交按钮样式 + * 按钮文案,建议不超过10个字,不填默认为提交 + */ + private String submitButtonText; + /** + * 提交按钮的key,会产生回调事件将本参数作为EventKey返回,最长支持1024字节 + */ + private String submitButtonKey; + /** + * 下拉式的选择器列表,multiple_interaction类型的卡片该字段不可为空,一个消息最多支持 3 个选择器 + */ + private List selects; + + /** + * 引用文献样式 + */ + private QuoteArea quoteArea; + /** * 获得文本消息builder. + * + * @return the text builder */ public static TextBuilder TEXT() { return new TextBuilder(); @@ -79,6 +313,8 @@ public static TextBuilder TEXT() { /** * 获得文本卡片消息builder. + * + * @return the text card builder */ public static TextCardBuilder TEXTCARD() { return new TextCardBuilder(); @@ -86,6 +322,8 @@ public static TextCardBuilder TEXTCARD() { /** * 获得图片消息builder. + * + * @return the image builder */ public static ImageBuilder IMAGE() { return new ImageBuilder(); @@ -93,6 +331,8 @@ public static ImageBuilder IMAGE() { /** * 获得语音消息builder. + * + * @return the voice builder */ public static VoiceBuilder VOICE() { return new VoiceBuilder(); @@ -100,6 +340,8 @@ public static VoiceBuilder VOICE() { /** * 获得视频消息builder. + * + * @return the video builder */ public static VideoBuilder VIDEO() { return new VideoBuilder(); @@ -107,6 +349,8 @@ public static VideoBuilder VIDEO() { /** * 获得图文消息builder. + * + * @return the news builder */ public static NewsBuilder NEWS() { return new NewsBuilder(); @@ -114,6 +358,8 @@ public static NewsBuilder NEWS() { /** * 获得mpnews图文消息builder. + * + * @return the mpnews builder */ public static MpnewsBuilder MPNEWS() { return new MpnewsBuilder(); @@ -121,6 +367,8 @@ public static MpnewsBuilder MPNEWS() { /** * 获得markdown消息builder. + * + * @return the markdown msg builder */ public static MarkdownMsgBuilder MARKDOWN() { return new MarkdownMsgBuilder(); @@ -128,6 +376,8 @@ public static MarkdownMsgBuilder MARKDOWN() { /** * 获得文件消息builder. + * + * @return the file builder */ public static FileBuilder FILE() { return new FileBuilder(); @@ -135,13 +385,26 @@ public static FileBuilder FILE() { /** * 获得任务卡片消息builder. + * + * @return the task card builder */ public static TaskCardBuilder TASKCARD() { return new TaskCardBuilder(); } + /** + * 获得模板卡片消息builder. + * + * @return the template card builder + */ + public static TemplateCardBuilder TEMPLATECARD() { + return new TemplateCardBuilder(); + } + /** * 获得小程序通知消息builder. + * + * @return the mini program notice msg builder */ public static MiniProgramNoticeMsgBuilder newMiniProgramNoticeBuilder() { return new MiniProgramNoticeMsgBuilder(); @@ -160,6 +423,7 @@ public static MiniProgramNoticeMsgBuilder newMiniProgramNoticeBuilder() { * {@link KefuMsgType#MARKDOWN} * {@link KefuMsgType#TASKCARD} * {@link KefuMsgType#MINIPROGRAM_NOTICE} + * {@link KefuMsgType#TEMPLATE_CARD} *
* * @param msgType 消息类型 @@ -168,6 +432,11 @@ public void setMsgType(String msgType) { this.msgType = msgType; } + /** + * To json string. + * + * @return the string + */ public String toJson() { JsonObject messageJson = new JsonObject(); if (this.getAgentId() != null) { @@ -268,6 +537,8 @@ private void handleMsgType(JsonObject messageJson) { articleJson.addProperty("description", article.getDescription()); articleJson.addProperty("url", article.getUrl()); articleJson.addProperty("picurl", article.getPicUrl()); + articleJson.addProperty("appid", article.getAppid()); + articleJson.addProperty("pagepath", article.getPagepath()); articleJsonArray.add(articleJson); } newsJsonObject.add("articles", articleJsonArray); @@ -328,6 +599,189 @@ private void handleMsgType(JsonObject messageJson) { messageJson.add("miniprogram_notice", notice); break; } + case TEMPLATE_CARD: { + JsonObject template = new JsonObject(); + template.addProperty("card_type", this.getCardType()); + + if (StringUtils.isNotBlank(this.getSourceIconUrl()) || StringUtils.isNotBlank(this.getSourceDesc())) { + JsonObject source = new JsonObject(); + if (StringUtils.isNotBlank(this.getSourceIconUrl())) { + source.addProperty("icon_url", this.getSourceIconUrl()); + } + if (StringUtils.isNotBlank(this.getSourceDesc())) { + source.addProperty("desc", this.getSourceDesc()); + } + source.addProperty("desc_color", this.getSourceDescColor()); + template.add("source", source); + } + + if (StringUtils.isNotBlank(this.getActionMenuDesc())) { + JsonObject action_menu = new JsonObject(); + action_menu.addProperty("desc", this.getActionMenuDesc()); + JsonArray actionList = new JsonArray(); + List actionMenuItemList = this.getActionMenuActionList(); + for (ActionMenuItem actionItemI : actionMenuItemList) { + actionList.add(actionItemI.toJson()); + } + action_menu.add("action_list", actionList); + template.add("action_menu", action_menu); + } + + if (StringUtils.isNotBlank(this.getMainTitleTitle()) || StringUtils.isNotBlank(this.getMainTitleDesc())) { + JsonObject mainTitle = new JsonObject(); + if (StringUtils.isNotBlank(this.getMainTitleTitle())) { + mainTitle.addProperty("title", this.getMainTitleTitle()); + } + if (StringUtils.isNotBlank(this.getMainTitleDesc())) { + mainTitle.addProperty("desc", this.getMainTitleDesc()); + } + template.add("main_title", mainTitle); + } + + if (this.getImageTextArea() != null) { + template.add("image_text_area", this.getImageTextArea().toJson()); + } + + if (StringUtils.isNotBlank(this.getCardImageUrl()) || this.getCardImageAspectRatio() != null) { + JsonObject cardImage = new JsonObject(); + if (StringUtils.isNotBlank(this.getCardImageUrl())) { + cardImage.addProperty("url", this.getCardImageUrl()); + } + if (null != this.getCardImageAspectRatio()) { + cardImage.addProperty("aspect_ratio", this.getCardImageAspectRatio()); + } + template.add("card_image", cardImage); + } + + if (StringUtils.isNotBlank(this.getEmphasisContentTitle()) || StringUtils.isNotBlank(this.getEmphasisContentDesc())) { + JsonObject emphasisContent = new JsonObject(); + if (StringUtils.isNotBlank(this.getEmphasisContentTitle())) { + emphasisContent.addProperty("title", this.getEmphasisContentTitle()); + } + if (StringUtils.isNotBlank(this.getEmphasisContentDesc())) { + emphasisContent.addProperty("desc", this.getEmphasisContentDesc()); + } + template.add("emphasis_content", emphasisContent); + } + + + if (StringUtils.isNotBlank(this.getSubTitleText())) { + template.addProperty("sub_title_text", this.getSubTitleText()); + } + + if (StringUtils.isNotBlank(this.getTaskId())) { + template.addProperty("task_id", this.getTaskId()); + } + + List verticalContents = this.getVerticalContents(); + if (null != verticalContents && !verticalContents.isEmpty()) { + JsonArray vContentJsonArray = new JsonArray(); + for (VerticalContent vContent : this.getVerticalContents()) { + JsonObject tempObject = vContent.toJson(); + vContentJsonArray.add(tempObject); + } + template.add("vertical_content_list", vContentJsonArray); + } + + List horizontalContents = this.getHorizontalContents(); + if (null != horizontalContents && !horizontalContents.isEmpty()) { + JsonArray hContentJsonArray = new JsonArray(); + for (HorizontalContent hContent : this.getHorizontalContents()) { + JsonObject tempObject = hContent.toJson(); + hContentJsonArray.add(tempObject); + } + template.add("horizontal_content_list", hContentJsonArray); + } + + List jumps = this.getJumps(); + if (null != jumps && !jumps.isEmpty()) { + JsonArray jumpJsonArray = new JsonArray(); + for (TemplateCardJump jump : this.getJumps()) { + JsonObject tempObject = jump.toJson(); + jumpJsonArray.add(tempObject); + } + template.add("jump_list", jumpJsonArray); + } + + if (null != this.getCardActionType()) { + JsonObject cardAction = new JsonObject(); + cardAction.addProperty("type", this.getCardActionType()); + if (StringUtils.isNotBlank(this.getCardActionUrl())) { + cardAction.addProperty("url", this.getCardActionUrl()); + } + if (StringUtils.isNotBlank(this.getCardActionAppid())) { + cardAction.addProperty("appid", this.getCardActionAppid()); + } + if (StringUtils.isNotBlank(this.getCardActionPagepath())) { + cardAction.addProperty("pagepath", this.getCardActionPagepath()); + } + template.add("card_action", cardAction); + } + + TemplateCardButtonSelection buttonSelection = this.getButtonSelection(); + if (null != buttonSelection) { + template.add("button_selection", buttonSelection.toJson()); + } + + List buttons = this.getButtons(); + if (null != buttons && !buttons.isEmpty()) { + JsonArray btnJsonArray = new JsonArray(); + for (TemplateCardButton btn : this.getButtons()) { + JsonObject tempObject = btn.toJson(); + btnJsonArray.add(tempObject); + } + template.add("button_list", btnJsonArray); + } + + // checkbox + if (StringUtils.isNotBlank(this.getCheckboxQuestionKey())) { + JsonObject checkBox = new JsonObject(); + checkBox.addProperty("question_key", this.getCheckboxQuestionKey()); + if (null != this.getCheckboxMode()) { + checkBox.addProperty("mode", this.getCheckboxMode()); + } + JsonArray optionArray = new JsonArray(); + for (CheckboxOption option : this.getOptions()) { + JsonObject tempObject = option.toJson(); + optionArray.add(tempObject); + } + checkBox.add("option_list", optionArray); + + template.add("checkbox", checkBox); + } + + // submit_button + if (StringUtils.isNotBlank(this.getSubmitButtonText()) || StringUtils.isNotBlank(this.getSubmitButtonKey())) { + JsonObject submit_button = new JsonObject(); + if (StringUtils.isNotBlank(this.getSubmitButtonText())) { + submit_button.addProperty("text", this.getSubmitButtonText()); + } + if (StringUtils.isNotBlank(this.getSubmitButtonKey())) { + submit_button.addProperty("key", this.getSubmitButtonKey()); + } + template.add("submit_button", submit_button); + } + + // select_list + List selects = this.getSelects(); + if (null != selects && !selects.isEmpty()) { + JsonArray selectJsonArray = new JsonArray(); + for (MultipleSelect select : this.getSelects()) { + JsonObject tempObject = select.toJson(); + selectJsonArray.add(tempObject); + } + template.add("select_list", selectJsonArray); + } + + QuoteArea quoteArea = this.getQuoteArea(); + if (null != quoteArea) { + JsonObject quoteAreaJson = quoteArea.toJson(); + template.add("quote_area", quoteAreaJson); + } + + messageJson.add("template_card", template); + break; + } default: { // do nothing } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendResult.java index 4c41d631b4..2ddf95d8da 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendResult.java @@ -1,15 +1,14 @@ package me.chanjar.weixin.cp.bean.message; -import java.io.Serializable; -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; - import com.google.common.base.Splitter; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; /** * 消息发送结果对象类. @@ -26,6 +25,12 @@ public String toString() { return WxCpGsonBuilder.create().toJson(this); } + /** + * From json wx cp message send result. + * + * @param json the json + * @return the wx cp message send result + */ public static WxCpMessageSendResult fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpMessageSendResult.class); } @@ -44,10 +49,21 @@ public static WxCpMessageSendResult fromJson(String json) { @SerializedName("invalidtag") private String invalidTag; - + @SerializedName("msgid") private String msgId; + /** + * 仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次 + */ + @SerializedName("response_code") + private String responseCode; + + /** + * Gets invalid user list. + * + * @return the invalid user list + */ public List getInvalidUserList() { return this.content2List(this.invalidUser); } @@ -60,10 +76,20 @@ private List content2List(String content) { return Splitter.on("|").splitToList(content); } + /** + * Gets invalid party list. + * + * @return the invalid party list + */ public List getInvalidPartyList() { return this.content2List(this.invalidParty); } + /** + * Gets invalid tag list. + * + * @return the invalid tag list + */ public List getInvalidTagList() { return this.content2List(this.invalidTag); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendStatistics.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendStatistics.java index 7cef0564dc..5b223a2a88 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendStatistics.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessageSendStatistics.java @@ -10,23 +10,31 @@ /** * 应用消息发送统计信息. * - * @author Binary Wang - * @date 2020-09-13 + * @author Binary Wang created on 2020-09-13 */ @Data public class WxCpMessageSendStatistics implements Serializable { private static final long serialVersionUID = 6031833682211475786L; + /** + * From json wx cp message send statistics. + * + * @param json the json + * @return the wx cp message send statistics + */ public static WxCpMessageSendStatistics fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpMessageSendStatistics.class); } private List statistics; + /** + * The type Statistic item. + */ @Data - public static class StatisticItem implements Serializable { + public static class StatisticItem implements Serializable { private static final long serialVersionUID = 6031833682211475786L; - + /** * 应用名 */ diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessage.java new file mode 100644 index 0000000000..a13205cd6b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessage.java @@ -0,0 +1,316 @@ +package me.chanjar.weixin.cp.bean.message; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.api.WxConsts.SchoolContactMsgType; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import me.chanjar.weixin.cp.bean.article.MpnewsArticle; +import me.chanjar.weixin.cp.bean.article.NewArticle; +import org.apache.commons.lang3.ArrayUtils; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import static me.chanjar.weixin.common.api.WxConsts.SchoolContactMsgType.*; + +/** + * 发送「学校通知」 + * https://developer.work.weixin.qq.com/document/path/92321 + * + * @author Wang_Wong created on 2022-06-29 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxCpSchoolContactMessage implements Serializable { + private static final long serialVersionUID = 8833792280163704238L; + + /** + * 指定发送对象,0表示发送给家长,1表示发送给学生,2表示发送给家长和学生,默认为0。 + */ + @SerializedName("recv_scope") + private Integer recvScope = 0; + + /** + * 家校通讯录家长列表,recv_scope为0或2表示发送给对应的家长,recv_scope为1忽略,(最多支持1000个) + */ + @SerializedName("to_parent_userid") + private String[] toParentUserId; + + /** + * 家校通讯录学生列表,recv_scope为0表示发送给学生的所有家长,recv_scope为1表示发送给学生,recv_scope为2表示发送给学生和学生的所有家长(最多支持1000个) + */ + @SerializedName("to_student_userid") + private String[] toStudentUserId; + + /** + * 家校通讯录部门列表,recv_scope为0表示发送给班级的所有家长,recv_scope为1表示发送给班级的所有学生,recv_scope为2表示发送给班级的所有学生和家长(最多支持100个) + */ + @SerializedName("to_party") + private String[] toParty; + + /** + * 1表示字段生效,0表示字段无效。recv_scope为0表示发送给学校的所有家长,recv_scope为1表示发送给学校的所有学生,recv_scope为2表示发送给学校的所有学生和家长,默认为0 + */ + @SerializedName("toall") + private Boolean toAll = false; + + /** + * 消息类型 + */ + @SerializedName("msgtype") + private String msgType; + + /** + * 企业应用的id,整型。可在应用的设置页面查看 + */ + @SerializedName("agentid") + private Integer agentId; + + /** + * 消息内容,最长不超过2048个字节(支持id转译) + */ + @SerializedName("content") + private String content; + + /** + * enable_id_trans + * 表示是否开启id转译,0表示否,1表示是,默认0 + */ + @SerializedName("enable_id_trans") + private Boolean enableIdTrans = false; + + /** + * enable_duplicate_check + * 表示是否开启重复消息检查,0表示否,1表示是,默认0 + */ + @SerializedName("enable_duplicate_check") + private Boolean enableDuplicateCheck = false; + + /** + * duplicate_check_interval + * 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时 + */ + @SerializedName("duplicate_check_interval") + private Integer duplicateCheckInterval; + + /** + * 图片媒体文件id,可以调用上传临时素材接口获取 + */ + @SerializedName("media_id") + private String mediaId; + + /** + * 视频消息的标题,不超过128个字节,超过会自动截断 + */ + @SerializedName("title") + private String title; + + /** + * 视频消息的描述,不超过512个字节,超过会自动截断 + */ + @SerializedName("description") + private String description; + + /** + * 小程序消息封面的mediaid,封面图建议尺寸为520*416 + */ + @SerializedName("thumb_media_id") + private String thumbMediaId; + + /** + * 小程序appid,必须是关联到企业的小程序应用 + */ + @SerializedName("appid") + private String appId; + + /** + * 点击消息卡片后进入的小程序页面路径 + */ + @SerializedName("pagepath") + private String pagePath; + + /** + * 图文消息 + * https://developer.work.weixin.qq.com/document/path/92321#%E5%9B%BE%E6%96%87%E6%B6%88%E6%81%AF + */ + private List articles = new ArrayList<>(); + + /** + * 图文消息(mpnews) + * https://developer.work.weixin.qq.com/document/path/92321#%E5%9B%BE%E6%96%87%E6%B6%88%E6%81%AF%EF%BC%88mpnews%EF + * %BC%89 + *

+ * mpnews类型的图文消息,跟普通的图文消息一致,唯一的差异是图文内容存储在企业微信。 + * 多次发送mpnews,会被认为是不同的图文,阅读、点赞的统计会被分开计算。 + */ + private List mpNewsArticles = new ArrayList<>(); + + /** + *

+   * 请使用.
+   * {@link SchoolContactMsgType#TEXT}
+   * {@link SchoolContactMsgType#IMAGE}
+   * {@link SchoolContactMsgType#VOICE}
+   * {@link SchoolContactMsgType#VIDEO}
+   * {@link SchoolContactMsgType#NEWS}
+   * {@link SchoolContactMsgType#MPNEWS}
+   * {@link SchoolContactMsgType#MINIPROGRAM}
+   * 
+ * + * @param msgType 消息类型 + */ + public void setMsgType(String msgType) { + this.msgType = msgType; + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + JsonObject messageJson = new JsonObject(); + + if (this.getRecvScope() != null) { + messageJson.addProperty("recv_scope", this.getRecvScope()); + } + + if (ArrayUtils.isNotEmpty(this.getToParentUserId())) { + messageJson.add("to_parent_userid", WxGsonBuilder.create().toJsonTree(this.getToParentUserId())); + } + + if (ArrayUtils.isNotEmpty(this.getToStudentUserId())) { + messageJson.add("to_student_userid", WxGsonBuilder.create().toJsonTree(this.getToStudentUserId())); + } + + if (ArrayUtils.isNotEmpty(this.getToParty())) { + messageJson.add("to_party", WxGsonBuilder.create().toJsonTree(this.getToParty())); + } + + if (this.getToAll() != null) { + messageJson.addProperty("toall", this.getToAll() ? 1 : 0); + } + + messageJson.addProperty("msgtype", this.getMsgType()); + + if (this.getAgentId() != null) { + messageJson.addProperty("agentid", this.getAgentId()); + } + + if (this.getEnableIdTrans() != null && this.getEnableIdTrans()) { + messageJson.addProperty("enable_id_trans", 1); + } + + if (this.getEnableDuplicateCheck() != null && this.getEnableDuplicateCheck()) { + messageJson.addProperty("enable_duplicate_check", 1); + } + + if (this.getDuplicateCheckInterval() != null) { + messageJson.addProperty("duplicate_check_interval", this.getDuplicateCheckInterval()); + } + + this.handleMsgType(messageJson); + + return messageJson.toString(); + } + + /** + * 封装消息类型 + * + * @param messageJson + */ + private void handleMsgType(JsonObject messageJson) { + switch (this.getMsgType()) { + case TEXT: { + JsonObject text = new JsonObject(); + text.addProperty("content", this.getContent()); + messageJson.add("text", text); + break; + } + case IMAGE: { + JsonObject image = new JsonObject(); + image.addProperty("media_id", this.getMediaId()); + messageJson.add("image", image); + break; + } + case FILE: { + JsonObject image = new JsonObject(); + image.addProperty("media_id", this.getMediaId()); + messageJson.add("file", image); + break; + } + case VOICE: { + JsonObject voice = new JsonObject(); + voice.addProperty("media_id", this.getMediaId()); + messageJson.add("voice", voice); + break; + } + case VIDEO: { + JsonObject video = new JsonObject(); + video.addProperty("media_id", this.getMediaId()); + video.addProperty("title", this.getTitle()); + video.addProperty("description", this.getDescription()); + messageJson.add("video", video); + break; + } + case NEWS: { + JsonObject newsJsonObject = new JsonObject(); + JsonArray articleJsonArray = new JsonArray(); + for (NewArticle article : this.getArticles()) { + JsonObject articleJson = new JsonObject(); + articleJson.addProperty("title", article.getTitle()); + articleJson.addProperty("description", article.getDescription()); + articleJson.addProperty("url", article.getUrl()); + articleJson.addProperty("picurl", article.getPicUrl()); + articleJsonArray.add(articleJson); + } + newsJsonObject.add("articles", articleJsonArray); + messageJson.add("news", newsJsonObject); + break; + } + case MPNEWS: { + JsonObject newsJsonObject = new JsonObject(); + JsonArray articleJsonArray = new JsonArray(); + for (MpnewsArticle article : this.getMpNewsArticles()) { + JsonObject articleJson = new JsonObject(); + articleJson.addProperty("title", article.getTitle()); + articleJson.addProperty("thumb_media_id", article.getThumbMediaId()); + articleJson.addProperty("author", article.getAuthor()); + articleJson.addProperty("content_source_url", article.getContentSourceUrl()); + articleJson.addProperty("content", article.getContent()); + articleJson.addProperty("digest", article.getDigest()); + articleJsonArray.add(articleJson); + } + newsJsonObject.add("articles", articleJsonArray); + messageJson.add("mpnews", newsJsonObject); + break; + } + case MINIPROGRAM: { + JsonObject miniprogram = new JsonObject(); + miniprogram.addProperty("appid", this.getAppId()); + miniprogram.addProperty("pagepath", this.getPagePath()); + miniprogram.addProperty("title", this.getTitle()); + miniprogram.addProperty("thumb_media_id", this.getThumbMediaId()); + + messageJson.add("miniprogram", miniprogram); + break; + } + default: { + // do nothing + } + + } + + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageSendResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageSendResult.java new file mode 100644 index 0000000000..a66f9baf78 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageSendResult.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.cp.bean.message; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 发送「学校通知」返回实体 + * https://developer.work.weixin.qq.com/document/path/92321 + * + * @author Wang_Wong created on 2022-06-29 + */ +@Data +public class WxCpSchoolContactMessageSendResult extends WxCpBaseResp { + private static final long serialVersionUID = 3990693822996824333L; + + @SerializedName("invalid_parent_userid") + private String[] invalidParentUserId; + + @SerializedName("invalid_student_userid") + private String[] invalidStudentUserId; + + @SerializedName("invalid_party") + private String[] invalidParty; + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * From json wx cp school contact message send result. + * + * @param json the json + * @return the wx cp school contact message send result + */ + public static WxCpSchoolContactMessageSendResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpSchoolContactMessageSendResult.class); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java index e165e7c29d..8b6b0689a7 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java @@ -1,9 +1,5 @@ package me.chanjar.weixin.cp.bean.message; -import java.io.Serializable; -import java.util.List; -import java.util.Map; - import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import com.thoughtworks.xstream.converters.basic.IntConverter; @@ -13,9 +9,16 @@ import me.chanjar.weixin.common.util.xml.IntegerArrayConverter; import me.chanjar.weixin.common.util.xml.StringArrayConverter; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import me.chanjar.weixin.cp.util.crypto.WxCpTpCryptUtil; import me.chanjar.weixin.cp.util.xml.XStreamTransformer; +import java.io.Serializable; +import java.util.List; +import java.util.Map; + /** + * sxh 修改版本,有些参数类型错误,修正版 * 回调推送的message * https://work.weixin.qq.com/api/doc#90001/90143/90612 * @@ -32,185 +35,386 @@ public class WxCpTpXmlMessage implements Serializable { */ private Map allFieldsMap; + /** + * The Suite id. + */ @XStreamAlias("SuiteId") @XStreamConverter(value = XStreamCDataConverter.class) protected String suiteId; + /** + * The Info type. + */ @XStreamAlias("InfoType") @XStreamConverter(value = XStreamCDataConverter.class) protected String infoType; + /** + * The Time stamp. + */ @XStreamAlias("TimeStamp") @XStreamConverter(value = XStreamCDataConverter.class) protected String timeStamp; + /** + * The Suite ticket. + */ @XStreamAlias("SuiteTicket") @XStreamConverter(value = XStreamCDataConverter.class) protected String suiteTicket; + /** + * The Auth code. + */ @XStreamAlias("AuthCode") @XStreamConverter(value = XStreamCDataConverter.class) protected String authCode; + /** + * The Auth corp id. + */ @XStreamAlias("AuthCorpId") @XStreamConverter(value = XStreamCDataConverter.class) protected String authCorpId; + /** + * The Change type. + */ @XStreamAlias("ChangeType") @XStreamConverter(value = XStreamCDataConverter.class) protected String changeType; + /** + * The User id. + */ @XStreamAlias("UserID") @XStreamConverter(value = XStreamCDataConverter.class) protected String userID; + /** + * The Department. + */ @XStreamAlias("Department") @XStreamConverter(value = IntegerArrayConverter.class) protected Integer[] department; + /** + * The Main department. + */ @XStreamAlias("MainDepartment") @XStreamConverter(value = IntConverter.class) protected Integer mainDepartment; + /** + * The Is leader in dept. + */ @XStreamAlias("IsLeaderInDept") @XStreamConverter(value = IntegerArrayConverter.class) protected Integer[] isLeaderInDept; + /** + * The Mobile. + */ @XStreamAlias("Mobile") @XStreamConverter(value = XStreamCDataConverter.class) protected String mobile; + /** + * The Position. + */ @XStreamAlias("Position") @XStreamConverter(value = XStreamCDataConverter.class) protected String position; + /** + * The Gender. + */ @XStreamAlias("Gender") @XStreamConverter(value = IntConverter.class) protected Integer gender; + /** + * The Email. + */ @XStreamAlias("Email") @XStreamConverter(value = XStreamCDataConverter.class) protected String email; + /** + * The Status. + */ @XStreamAlias("Status") @XStreamConverter(value = XStreamCDataConverter.class) protected String status; + /** + * The Avatar. + */ @XStreamAlias("Avatar") @XStreamConverter(value = XStreamCDataConverter.class) protected String avatar; + /** + * The Alias. + */ @XStreamAlias("Alias") @XStreamConverter(value = XStreamCDataConverter.class) protected String alias; + /** + * The Telephone. + */ @XStreamAlias("Telephone") @XStreamConverter(value = XStreamCDataConverter.class) protected String telephone; + /** + * The Id. + */ @XStreamAlias("Id") @XStreamConverter(value = XStreamCDataConverter.class) protected String id; + /** + * The Name. + */ @XStreamAlias("Name") @XStreamConverter(value = XStreamCDataConverter.class) protected String name; + /** + * The Parent id. + */ @XStreamAlias("ParentId") @XStreamConverter(value = XStreamCDataConverter.class) protected String parentId; + /** + * The Order. + */ @XStreamAlias("Order") @XStreamConverter(value = IntConverter.class) protected Integer order; + /** + * The Tag id. + */ @XStreamAlias("TagId") @XStreamConverter(value = IntConverter.class) protected Integer tagId; + /** + * The Add user items. + */ @XStreamAlias("AddUserItems") @XStreamConverter(value = StringArrayConverter.class) protected String[] addUserItems; + /** + * The Del user items. + */ @XStreamAlias("DelUserItems") @XStreamConverter(value = StringArrayConverter.class) protected String[] delUserItems; + /** + * The Add party items. + */ @XStreamAlias("AddPartyItems") @XStreamConverter(value = IntegerArrayConverter.class) protected Integer[] addPartyItems; + /** + * The Del party items. + */ @XStreamAlias("DelPartyItems") @XStreamConverter(value = IntegerArrayConverter.class) protected Integer[] delPartyItems; - //ref: https://work.weixin.qq.com/api/doc/90001/90143/90585 + /** + * The Service corp id. + */ +//ref: https://work.weixin.qq.com/api/doc/90001/90143/90585 @XStreamAlias("ServiceCorpId") @XStreamConverter(value = XStreamCDataConverter.class) protected String serviceCorpId; + /** + * The Register code. + */ @XStreamAlias("RegisterCode") @XStreamConverter(value = XStreamCDataConverter.class) protected String registerCode; + /** + * The Contact sync. + */ @XStreamAlias("ContactSync") protected ContactSync contactSync; + /** + * The Auth user info. + */ @XStreamAlias("AuthUserInfo") protected AuthUserInfo authUserInfo; + /** + * The Template id. + */ @XStreamAlias("TemplateId") @XStreamConverter(value = XStreamCDataConverter.class) protected String templateId; + /** + * The Create time. + */ @XStreamAlias("CreateTime") protected Long createTime; + /** + * The To user name. + */ @XStreamAlias("ToUserName") @XStreamConverter(value = XStreamCDataConverter.class) protected String toUserName; + /** + * The From user name. + */ @XStreamAlias("FromUserName") @XStreamConverter(value = XStreamCDataConverter.class) protected String fromUserName; + /** + * The Msg type. + */ @XStreamAlias("MsgType") @XStreamConverter(value = XStreamCDataConverter.class) protected String msgType; + /** + * The Event. + */ @XStreamAlias("Event") @XStreamConverter(value = XStreamCDataConverter.class) protected String event; + /** + * The Batch job. + */ @XStreamAlias("BatchJob") protected BatchJob batchJob; + /** + * The External user id. + */ @XStreamAlias("ExternalUserID") @XStreamConverter(value = XStreamCDataConverter.class) protected String externalUserID; + /** + * The State. + */ + @XStreamAlias("State") + @XStreamConverter(value = XStreamCDataConverter.class) + protected String state; + + /** + * The Source. + */ + @XStreamAlias("Source") + @XStreamConverter(value = XStreamCDataConverter.class) + protected String source; + + /** + * The Fail reason. + */ + @XStreamAlias("FailReason") + @XStreamConverter(value = XStreamCDataConverter.class) + protected String failReason; + + /** + * The Chat id. + */ + @XStreamAlias("ChatId") + @XStreamConverter(value = XStreamCDataConverter.class) + protected String chatId; + + /** + * The Update detail. + */ + @XStreamAlias("UpdateDetail") + @XStreamConverter(value = XStreamCDataConverter.class) + protected String updateDetail; + + /** + * The Join scene. + */ + @XStreamAlias("JoinScene") + protected Integer joinScene; + + /** + * The Quit scene. + */ + @XStreamAlias("QuitScene") + protected Integer quitScene; + + /** + * The Mem change cnt. + */ + @XStreamAlias("MemChangeCnt") + protected Integer memChangeCnt; + + /** + * The Tag type. + */ + @XStreamAlias("TagType") + @XStreamConverter(value = XStreamCDataConverter.class) + protected String tagType; + + /** + * The Welcome code. + */ @XStreamAlias("WelcomeCode") @XStreamConverter(value = XStreamCDataConverter.class) protected String welcomeCode; + /** + * The From user. + */ @XStreamAlias("FromUser") @XStreamConverter(value = XStreamCDataConverter.class) protected String fromUser; + /** + * The Content. + */ @XStreamAlias("Content") @XStreamConverter(value = XStreamCDataConverter.class) protected String content; + /** + * The Msg id. + */ @XStreamAlias("MsgId") protected String msgId; + /** + * The Agent id. + */ @XStreamAlias("AgentID") protected String agentID; + /** + * The Pic url. + */ @XStreamAlias("PicUrl") @XStreamConverter(value = XStreamCDataConverter.class) protected String picUrl; + /** + * The Media id. + */ @XStreamAlias("MediaId") @XStreamConverter(value = XStreamCDataConverter.class) protected String mediaId; @@ -275,97 +479,190 @@ public class WxCpTpXmlMessage implements Serializable { private WxCpXmlMessage.SendLocationInfo sendLocationInfo = new WxCpXmlMessage.SendLocationInfo(); @XStreamAlias("ApprovalInfo") - private ApprovalInfo approvalInfo = new ApprovalInfo(); + private WxCpXmlApprovalInfo approvalInfo = new WxCpXmlApprovalInfo(); @XStreamAlias("TaskId") @XStreamConverter(value = XStreamCDataConverter.class) private String taskId; + @XStreamAlias("PaidCorpId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String paidCorpId; + + @XStreamAlias("OrderId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String orderId; + + @XStreamAlias("OperatorId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String operatorId; + + @XStreamAlias("OldOrderId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String oldOrderId; + + @XStreamAlias("NewOrderId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String newOrderId; + + /** + * The type Contact sync. + */ @Data @XStreamAlias("ContactSync") public static class ContactSync implements Serializable { private static final long serialVersionUID = 6031833682211475786L; + /** + * The Access token. + */ @XStreamAlias("AccessToken") @XStreamConverter(value = XStreamCDataConverter.class) protected String accessToken; + /** + * The Expires in. + */ @XStreamAlias("ExpiresIn") protected Integer expiresIn; } + /** + * The type Auth user info. + */ @Data @XStreamAlias("AuthUserInfo") public static class AuthUserInfo implements Serializable { + /** + * The User id. + */ @XStreamAlias("UserId") @XStreamConverter(value = XStreamCDataConverter.class) protected String userId; } + /** + * The type Batch job. + */ @Data @XStreamAlias("BatchJob") public static class BatchJob implements Serializable { private static final long serialVersionUID = 6031833682211475786L; + /** + * The Job id. + */ @XStreamAlias("JobId") @XStreamConverter(value = XStreamCDataConverter.class) protected String JobId; + /** + * The Job type. + */ @XStreamAlias("JobType") @XStreamConverter(value = XStreamCDataConverter.class) protected String jobType; + /** + * The Err code. + */ @XStreamAlias("ErrCode") @XStreamConverter(value = IntConverter.class) protected Integer errCode; + /** + * The Err msg. + */ @XStreamAlias("ErrMsg") @XStreamConverter(value = XStreamCDataConverter.class) protected String errMsg; } + /** + * The type Approval info. + * @deprecated 无法同时适配不同回调下的实体字段,使用WxCpXmlApprovalInfo可完美适配 + */ @Data @XStreamAlias("ApprovalInfo") public static class ApprovalInfo implements Serializable { private static final long serialVersionUID = 6031833682211475786L; + /** + * The Third no. + */ @XStreamAlias("ThirdNo") - protected Long thirdNo; + protected String thirdNo; + /** + * The Open sp name. + */ @XStreamAlias("OpenSpName") protected String openSpName; + /** + * The Open template id. + */ @XStreamAlias("OpenTemplateId") - protected Integer openTemplateId; + protected String openTemplateId; + /** + * The Open sp status. + */ @XStreamAlias("OpenSpStatus") protected Integer openSpStatus; + /** + * The Apply time. + */ @XStreamAlias("ApplyTime") protected Long applyTime; + /** + * The Apply user name. + */ @XStreamAlias("ApplyUserName") protected String applyUserName; + /** + * The Apply user id. + */ @XStreamAlias("ApplyUserId") - protected Integer applyUserId; + protected String applyUserId; + /** + * The Apply user party. + */ @XStreamAlias("ApplyUserParty") protected String applyUserParty; + /** + * The Apply user image. + */ @XStreamAlias("ApplyUserImage") protected String applyUserImage; + /** + * The Approval nodes. + */ @XStreamAlias("ApprovalNodes") protected List approvalNodes; + /** + * The Notify nodes. + */ @XStreamAlias("NotifyNodes") protected List notifyNodes; + /** + * The Approverstep. + */ @XStreamAlias("approverstep") protected Integer approverstep; - //自建/第三方应用调用审批流程引擎,状态通知 + /** + * The type Approval node. + */ +//自建/第三方应用调用审批流程引擎,状态通知 //ref: https://work.weixin.qq.com/api/doc/90001/90143/90376#审批状态通知事件 //1.自建/第三方应用调用审批流程引擎发起申请之后,审批状态发生变化时 //2.自建/第三方应用调用审批流程引擎发起申请之后,在“审批中”状态,有任意审批人进行审批操作时 @@ -374,53 +671,104 @@ public static class ApprovalInfo implements Serializable { public static class ApprovalNode implements Serializable { private static final long serialVersionUID = 6031833682211475786L; + /** + * The Node status. + */ @XStreamAlias("NodeStatus") protected Integer nodeStatus; + /** + * The Node attr. + */ @XStreamAlias("NodeAttr") protected Integer nodeAttr; + /** + * The Node type. + */ @XStreamAlias("NodeType") protected Integer nodeType; + /** + * The Items. + */ @XStreamAlias("Items") protected List items; + /** + * The type Item. + */ @Data @XStreamAlias("Item") public static class Item implements Serializable { private static final long serialVersionUID = 6031833682211475786L; + /** + * The Item name. + */ @XStreamAlias("ItemName") protected String itemName; + /** + * The Item user id. + */ @XStreamAlias("ItemUserId") - protected Integer itemUserId; + protected String itemUserId; + /** + * The Item image. + */ @XStreamAlias("ItemImage") protected String itemImage; + /** + * The Item status. + */ @XStreamAlias("ItemStatus") protected Integer itemStatus; + /** + * The Item speech. + */ @XStreamAlias("ItemSpeech") protected String itemSpeech; + /** + * The Item op time. + */ @XStreamAlias("ItemOpTime") protected Long itemOpTime; } } + /** + * The type Notify node. + */ @Data @XStreamAlias("NotifyNode") public static class NotifyNode implements Serializable { private static final long serialVersionUID = 6031833682211475786L; + /** + * The Item name. + */ @XStreamAlias("ItemName") protected String itemName; + /** + * The Item user id. + */ @XStreamAlias("ItemUserId") - protected Integer itemUserId; + protected String itemUserId; + /** + * The Item image. + */ @XStreamAlias("ItemImage") - protected String itemImage; + protected String itemImage; } } + /** + * From xml wx cp tp xml message. + * + * @param xml the xml + * @return the wx cp tp xml message + */ public static WxCpTpXmlMessage fromXml(String xml) { //修改微信变态的消息内容格式,方便解析 //xml = xml.replace("", ""); @@ -429,4 +777,20 @@ public static WxCpTpXmlMessage fromXml(String xml) { return xmlPackage; } + /** + * + * @param encryptedXml the encrypted xml + * @param wxCpTpConfigStorage the wx cp config storage + * @param timestamp the timestamp + * @param nonce the nonce + * @param msgSignature the msg signature + * @return the wx cp tp xml message + */ + public static WxCpTpXmlMessage fromEncryptedXml(String encryptedXml, WxCpTpConfigStorage wxCpTpConfigStorage, + String timestamp, String nonce, String msgSignature) { + WxCpTpCryptUtil cryptUtil = new WxCpTpCryptUtil(wxCpTpConfigStorage); + String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); + log.debug("解密后的原始xml消息内容:{}", plainText); + return fromXml(plainText); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlApprovalInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlApprovalInfo.java new file mode 100644 index 0000000000..c9e8ffa709 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlApprovalInfo.java @@ -0,0 +1,466 @@ +package me.chanjar.weixin.cp.bean.message; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamConverter; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.Data; +import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; + +import java.io.Serializable; +import java.util.List; + +/** + * 审批信息 + *

+ * 审批申请状态变化回调通知 + * https://developer.work.weixin.qq.com/document/path/91815 + *

+ * 自建应用审批状态变化通知回调 + * https://developer.work.weixin.qq.com/document/path/90269 + * + * @author Gyv12345 + */ +@XStreamAlias("ApprovalInfo") +@Data +public class WxCpXmlApprovalInfo implements Serializable { + private static final long serialVersionUID = 8136329462880646091L; + + + // 自建应用审批状态变化通知回调 + /** + * 审批单编号,由开发者在发起申请时自定义 + */ + @XStreamAlias("ThirdNo") + @XStreamConverter(value = XStreamCDataConverter.class) + private String thirdNo; + + /** + * 审批模板名称 + */ + @XStreamAlias("OpenSpName") + @XStreamConverter(value = XStreamCDataConverter.class) + private String openSpName; + + /** + * 审批模板id + */ + @XStreamAlias("OpenTemplateId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String openTemplateId; + + /** + * 申请单当前审批状态:1-审批中;2-已通过;3-已驳回;4-已撤销 + */ + @XStreamAlias("OpenSpStatus") + private Integer openSpStatus; + + /** + * 提交者姓名 + */ + @XStreamAlias("ApplyUserName") + @XStreamConverter(value = XStreamCDataConverter.class) + private String applyUserName; + + /** + * 提交者userid + */ + @XStreamAlias("ApplyUserId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String applyUserId; + + /** + * 提交者所在部门 + */ + @XStreamAlias("ApplyUserParty") + @XStreamConverter(value = XStreamCDataConverter.class) + private String applyUserParty; + + /** + * 提交者头像 + */ + @XStreamAlias("ApplyUserImage") + @XStreamConverter(value = XStreamCDataConverter.class) + private String applyUserImage; + + /** + * 当前审批节点:0-第一个审批节点;1-第二个审批节点…以此类推 + */ + @XStreamAlias("ApproverStep") + private Integer approverStep; + + /** + * 审批流程信息 + */ + @XStreamImplicit(itemFieldName = "ApprovalNodes") + private List approvalNodes; + + /** + * 抄送信息,可能有多个抄送人 + */ + @XStreamImplicit(itemFieldName = "NotifyNodes") + private List notifyNodes; + + /** + * 抄送人信息 + */ + @XStreamAlias("NotifyNodes") + @Data + public static class NotifyNode implements Serializable { + private static final long serialVersionUID = -979255011922209018L; + + /** + * 抄送人姓名 + */ + @XStreamAlias("ItemName") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemName; + + /** + * 抄送人userid + */ + @XStreamAlias("ItemUserid") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemUserId; + + /** + * 抄送人所在部门 + */ + @XStreamAlias("ItemParty") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemParty; + + /** + * 抄送人头像 + */ + @XStreamAlias("ItemImage") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemImage; + + } + + /** + * 审批流程信息,可以有多个审批节点 + */ + @XStreamAlias("ApprovalNodes") + @Data + public static class ApprovalNode implements Serializable { + private static final long serialVersionUID = -979255011922209018L; + + /** + * 节点审批操作状态:1-审批中;2-已同意;3-已驳回;4-已转审 + */ + @XStreamAlias("NodeStatus") + private Integer nodeStatus; + + /** + * 审批节点属性:1-或签;2-会签 + */ + @XStreamAlias("NodeAttr") + private Integer nodeAttr; + + /** + * 审批节点类型:1-固定成员;2-标签;3-上级 + */ + @XStreamAlias("NodeType") + private Integer nodeType; + + /** + * 审批节点信息,当节点为标签或上级时,一个节点可能有多个分支 + */ + @XStreamImplicit(itemFieldName = "Items") + private List items; + + } + + /** + * 审批节点分支,当节点为标签或上级时,一个节点可能有多个分支 + */ + @XStreamAlias("Items") + @Data + public static class Item implements Serializable { + private static final long serialVersionUID = -979255011922209018L; + + /** + * 分支审批人姓名 + */ + @XStreamAlias("ItemName") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemName; + + /** + * 分支审批人userid + */ + @XStreamAlias("ItemUserid") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemUserId; + + /** + * 分支审批人所在部门 + */ + @XStreamAlias("ItemParty") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemParty; + + /** + * 分支审批人头像 + */ + @XStreamAlias("ItemImage") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemImage; + + /** + * 分支审批人审批意见 + */ + @XStreamAlias("ItemSpeech") + @XStreamConverter(value = XStreamCDataConverter.class) + private String itemSpeech; + + /** + * 分支审批审批操作状态:1-审批中;2-已同意;3-已驳回;4-已转审 + */ + @XStreamAlias("ItemStatus") + private Integer itemStatus; + + /** + * 分支审批人操作时间 + */ + @XStreamAlias("ItemOpTime") + private Long itemOpTime; + + } + + + // 审批申请状态变化回调通知 + /** + * 审批编号 + */ + @XStreamAlias("SpNo") + private String spNo; + + /** + * 审批申请类型名称(审批模板名称) + */ + @XStreamAlias("SpName") + @XStreamConverter(value = XStreamCDataConverter.class) + private String spName; + + /** + * 申请单状态:1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付 + */ + @XStreamAlias("SpStatus") + private Integer spStatus; + + /** + * 审批模板id。 + */ + @XStreamAlias("TemplateId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String templateId; + + /** + * 审批申请提交时间,Unix时间戳 + */ + @XStreamAlias("ApplyTime") + private Long applyTime; + + /** + * 申请人信息 + */ + @XStreamAlias("Applyer") + private Applier applier; + + /** + * 审批流程信息,可能有多个审批节点。 + */ + @XStreamImplicit(itemFieldName = "SpRecord") + private List spRecords; + + /** + * 抄送信息,可能有多个抄送节点 + * 这回查字典,notifier通知人,Notifyer这不知道是什么 + */ + @XStreamImplicit(itemFieldName = "Notifyer") + private List notifier; + + /** + * 审批申请备注信息,可能有多个备注节点 + */ + @XStreamImplicit(itemFieldName = "Comments") + private List comments; + + /** + * 审批申请单变化类型 + */ + @XStreamAlias("StatuChangeEvent") + private Integer statusChangeEvent; + + /** + * 申请人信息 + */ + @XStreamAlias("Applyer") + @Data + public static class Applier implements Serializable { + private static final long serialVersionUID = -979255011922209018L; + + /** + * 申请人userid + */ + @XStreamAlias("UserId") + private String userId; + + /** + * 申请人所在部门pid + */ + @XStreamAlias("Party") + private String party; + } + + /** + * 审批流程信息 + */ + @XStreamAlias("SpRecord") + @Data + public static class SpRecord implements Serializable { + private static final long serialVersionUID = 1247535623941881764L; + + /** + * 审批节点状态:1-审批中;2-已同意;3-已驳回;4-已转审 + */ + @XStreamAlias("SpStatus") + private String spStatus; + + /** + * 节点审批方式:1-或签;2-会签 + */ + @XStreamAlias("ApproverAttr") + private String approverAttr; + + /** + * 审批节点详情。当节点为标签或上级时,一个节点可能有多个分支 + */ + @XStreamImplicit(itemFieldName = "Details") + private List details; + + } + + /** + * 审批节点详情 + */ + @XStreamAlias("Details") + @Data + public static class Detail implements Serializable { + private static final long serialVersionUID = -8446107461495047603L; + + /** + * 分支审批人 + */ + @XStreamAlias("Approver") + private Approver approver; + + /** + * 审批意见字段 + */ + @XStreamAlias("Speech") + private String speech; + + /** + * 分支审批人审批状态:1-审批中;2-已同意;3-已驳回;4-已转审 + */ + @XStreamAlias("SpStatus") + private String spStatus; + + /** + * 节点分支审批人审批操作时间,0为尚未操作 + */ + @XStreamAlias("SpTime") + private Long spTime; + + /** + * 节点分支审批人审批意见附件,赋值为media_id具体使用请参考:文档-获取临时素材 + */ + @XStreamImplicit(itemFieldName = "Attach") + private List attach; + } + + /** + * 分支审批人 + */ + @Data + @XStreamAlias("Approver") + public static class Approver implements Serializable { + private static final long serialVersionUID = 7360442444186683191L; + + /** + * 分支审批人userid + */ + @XStreamAlias("UserId") + private String userId; + } + + /** + * 抄送信息 + */ + @Data + @XStreamAlias("Notifyer") + public static class Notifier implements Serializable { + private static final long serialVersionUID = -4524071522890013920L; + + /** + * 节点抄送人userid + */ + @XStreamAlias("UserId") + private String userId; + } + + /** + * 审批申请备注信息 + */ + @Data + @XStreamAlias("Comments") + public static class Comment implements Serializable { + private static final long serialVersionUID = 6912156206252719485L; + + /** + * 备注人信息 + */ + @XStreamAlias("CommentUserInfo") + private CommentUserInfo commentUserInfo; + + /** + * 备注提交时间 + */ + @XStreamAlias("CommentTime") + private String commentTime; + + /** + * 备注文本内容 + */ + @XStreamAlias("CommentContent") + private String commentContent; + + /** + * 备注id + */ + @XStreamAlias("CommentId") + private String commentId; + + /** + * 备注意见附件,值是附件media_id + */ + @XStreamImplicit(itemFieldName = "Attach") + private List attach; + } + + @Data + @XStreamAlias("CommentUserInfo") + public static class CommentUserInfo implements Serializable { + private static final long serialVersionUID = 5031739716823000947L; + + /** + * 备注人userid + */ + @XStreamAlias("UserId") + private String userId; + } + +} 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 b791fffb54..51e395ab13 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 @@ -16,6 +16,7 @@ import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import me.chanjar.weixin.cp.util.xml.XStreamTransformer; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.io.InputStream; @@ -51,7 +52,7 @@ public class WxCpXmlMessage implements Serializable { /////////////////////// @XStreamAlias("AgentID") - private Integer agentId; + private String agentId; @XStreamAlias("ToUserName") @XStreamConverter(value = XStreamCDataConverter.class) @@ -138,6 +139,29 @@ public class WxCpXmlMessage implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String event; + @XStreamAlias("UpdateDetail") + @XStreamConverter(value = XStreamCDataConverter.class) + private String updateDetail; + + @XStreamAlias("JoinScene") + @XStreamConverter(value = XStreamCDataConverter.class) + private String joinScene; + + @XStreamAlias("QuitScene") + @XStreamConverter(value = XStreamCDataConverter.class) + private String quitScene; + + @XStreamAlias("MemChangeCnt") + @XStreamConverter(value = XStreamCDataConverter.class) + private String memChangeCnt; + + @XStreamAlias("Source") + @XStreamConverter(value = XStreamCDataConverter.class) + private String source; + + @XStreamAlias("StrategyId") + private String strategyId; + @XStreamAlias("EventKey") @XStreamConverter(value = XStreamCDataConverter.class) private String eventKey; @@ -220,6 +244,12 @@ public class WxCpXmlMessage implements Serializable { @XStreamConverter(value = LongArrayConverter.class) private Long[] departments; + /** + * 主部门 + */ + @XStreamAlias("MainDepartment") + private Long mainDepartment; + /** * 手机号码. */ @@ -254,6 +284,16 @@ public class WxCpXmlMessage implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String email; + /** + * 企业邮箱;代开发自建应用不返回该字段。 + * ISSUE#2584 + * + * @see Link + */ + @XStreamAlias("BizMail") + @XStreamConverter(value = XStreamCDataConverter.class) + private String bizMail; + /** * 头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可. */ @@ -395,11 +435,20 @@ public class WxCpXmlMessage implements Serializable { * 1. 群发的结果. * 2. 通讯录变更事件 * 激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号). + * 3. 直播回调事件 + * 直播状态 ,0:预约中,1:直播中,2:已结束,4:已取消 (已过期状态目前没有回调) */ @XStreamAlias("Status") @XStreamConverter(value = XStreamCDataConverter.class) private String status; + /** + * 直播ID + */ + @XStreamAlias("LivingId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String livingId; + /** * group_id下粉丝数;或者openid_list中的粉丝数. */ @@ -435,10 +484,25 @@ public class WxCpXmlMessage implements Serializable { private SendLocationInfo sendLocationInfo = new SendLocationInfo(); + /** + * 审批消息 + *

+ * 审批申请状态变化回调通知 + * https://developer.work.weixin.qq.com/document/path/91815 + *

+ * 自建应用审批状态变化通知回调 + * https://developer.work.weixin.qq.com/document/path/90269 + */ @XStreamAlias("ApprovalInfo") - private ApprovalInfo approvalInfo = new ApprovalInfo(); + private WxCpXmlApprovalInfo approvalInfo = new WxCpXmlApprovalInfo(); + /** + * From xml wx cp xml message. + * + * @param xml the xml + * @return the wx cp xml message + */ protected static WxCpXmlMessage fromXml(String xml) { //修改微信变态的消息内容格式,方便解析 xml = xml.replace("", ""); @@ -447,25 +511,70 @@ protected static WxCpXmlMessage fromXml(String xml) { return xmlMessage; } + /** + * From xml wx cp xml message. + * + * @param xml the xml + * @param agentId the agent id + * @return the wx cp xml message + */ + public static WxCpXmlMessage fromXml(String xml, String agentId) { + //修改微信变态的消息内容格式,方便解析 + xml = xml.replace("", ""); + final WxCpXmlMessage xmlMessage = fromXml(xml); + xmlMessage.setAgentId(agentId); + return xmlMessage; + } + + /** + * From xml wx cp xml message. + * + * @param is the is + * @return the wx cp xml message + */ protected static WxCpXmlMessage fromXml(InputStream is) { return XStreamTransformer.fromXml(WxCpXmlMessage.class, is); } /** * 从加密字符串转换. + * + * @param encryptedXml the encrypted xml + * @param wxCpConfigStorage the wx cp config storage + * @param timestamp the timestamp + * @param nonce the nonce + * @param msgSignature the msg signature + * @return the wx cp xml message */ public static WxCpXmlMessage fromEncryptedXml(String encryptedXml, WxCpConfigStorage wxCpConfigStorage, String timestamp, String nonce, String msgSignature) { WxCpCryptUtil cryptUtil = new WxCpCryptUtil(wxCpConfigStorage); + WxCpXmlMessage wxCpXmlMessage = fromXml(encryptedXml); String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); log.debug("解密后的原始xml消息内容:{}", plainText); - return fromXml(plainText); + if (StringUtils.isNotEmpty(wxCpXmlMessage.getAgentId())) { + return fromXml(plainText, wxCpXmlMessage.getAgentId()); + } else { + return fromXml(plainText); + } + } + /** + * From encrypted xml wx cp xml message. + * + * @param is the is + * @param wxCpConfigStorage the wx cp config storage + * @param timestamp the timestamp + * @param nonce the nonce + * @param msgSignature the msg signature + * @return the wx cp xml message + */ public static WxCpXmlMessage fromEncryptedXml(InputStream is, WxCpConfigStorage wxCpConfigStorage, String timestamp, String nonce, String msgSignature) { try { - return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8), wxCpConfigStorage, timestamp, nonce, msgSignature); + return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8), wxCpConfigStorage, timestamp, nonce, + msgSignature); } catch (IOException e) { throw new WxRuntimeException(e); } @@ -476,6 +585,9 @@ public String toString() { return WxCpGsonBuilder.create().toJson(this); } + /** + * The type Scan code info. + */ @Data @XStreamAlias("ScanCodeInfo") public static class ScanCodeInfo implements Serializable { @@ -496,13 +608,22 @@ public static class ScanCodeInfo implements Serializable { private String scanResult; } + /** + * The type Ext attr. + */ @Data public static class ExtAttr implements Serializable { private static final long serialVersionUID = -3418685294606228837L; + /** + * The Items. + */ @XStreamImplicit(itemFieldName = "Item") protected final List items = new ArrayList<>(); + /** + * The type Item. + */ @XStreamAlias("Item") @Data public static class Item implements Serializable { @@ -518,28 +639,40 @@ public static class Item implements Serializable { } } + /** + * The type Send pics info. + */ @Data @XStreamAlias("SendPicsInfo") public static class SendPicsInfo implements Serializable { private static final long serialVersionUID = -6549728838848064881L; + /** + * The Pic list. + */ @XStreamAlias("PicList") protected final List picList = new ArrayList<>(); @XStreamAlias("Count") private Long count; + /** + * The type Item. + */ @XStreamAlias("item") @Data public static class Item implements Serializable { private static final long serialVersionUID = -6549728838848064881L; - + @XStreamAlias("PicMd5Sum") @XStreamConverter(value = XStreamCDataConverter.class) private String picMd5Sum; } } + /** + * The type Send location info. + */ @Data @XStreamAlias("SendLocationInfo") public static class SendLocationInfo implements Serializable { @@ -567,245 +700,4 @@ public static class SendLocationInfo implements Serializable { } - /** - * 审批信息 - */ - @XStreamAlias("ApprovalInfo") - @Data - public static class ApprovalInfo implements Serializable { - private static final long serialVersionUID = 8136329462880646091L; - - /** - * 审批编号 - */ - @XStreamAlias("SpNo") - private String spNo; - - /** - * 审批申请类型名称(审批模板名称) - */ - @XStreamAlias("SpName") - @XStreamConverter(value = XStreamCDataConverter.class) - private String spName; - - /** - * 申请单状态:1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付 - */ - @XStreamAlias("SpStatus") - private Integer spStatus; - - /** - * 审批模板id。 - */ - @XStreamAlias("TemplateId") - @XStreamConverter(value = XStreamCDataConverter.class) - private String templateId; - /** - * 审批申请提交时间,Unix时间戳 - */ - @XStreamAlias("ApplyTime") - private Long applyTime; - - /** - * 申请人信息 - */ - @XStreamAlias("Applyer") - private Applier applier; - - /** - * 审批流程信息,可能有多个审批节点。 - */ - @XStreamImplicit(itemFieldName="SpRecord") - private List spRecords; - - /** - * 抄送信息,可能有多个抄送节点 - * 这回查字典,notifier通知人,Notifyer这不知道是什么 - */ - @XStreamImplicit(itemFieldName="Notifyer") - private List notifier; - - /** - * 审批申请备注信息,可能有多个备注节点 - */ - @XStreamImplicit(itemFieldName="Comments") - private List comments; - - /** - * 审批申请单变化类型 - */ - @XStreamAlias("StatuChangeEvent") - private Integer statusChangeEvent; - - /** - * 申请人信息 - */ - @XStreamAlias("Applyer") - @Data - public static class Applier implements Serializable { - private static final long serialVersionUID = -979255011922209018L; - - /** - * 申请人userid - */ - @XStreamAlias("UserId") - private String userId; - - /** - * 申请人所在部门pid - */ - @XStreamAlias("Party") - private String party; - } - - /** - * 审批流程信息 - */ - @XStreamAlias("SpRecord") - @Data - public static class SpRecord implements Serializable{ - - private static final long serialVersionUID = 1247535623941881764L; - - /** - * 审批节点状态:1-审批中;2-已同意;3-已驳回;4-已转审 - */ - @XStreamAlias("SpStatus") - private String spStatus; - - /** - * 节点审批方式:1-或签;2-会签 - */ - @XStreamAlias("ApproverAttr") - private String approverAttr; - - /** - * 审批节点详情。当节点为标签或上级时,一个节点可能有多个分支 - */ - @XStreamImplicit(itemFieldName="Details") - private List details; - - } - - /** - * 审批节点详情 - */ - @XStreamAlias("Details") - @Data - public static class Detail implements Serializable{ - - private static final long serialVersionUID = -8446107461495047603L; - - /** - * 分支审批人 - */ - @XStreamAlias("Approver") - private Approver approver; - - /** - * 审批意见字段 - */ - @XStreamAlias("Speech") - private String speech; - - /** - * 分支审批人审批状态:1-审批中;2-已同意;3-已驳回;4-已转审 - */ - @XStreamAlias("SpStatus") - private String spStatus; - - /** - * 节点分支审批人审批操作时间,0为尚未操作 - */ - @XStreamAlias("SpTime") - private Long spTime; - - /** - * 节点分支审批人审批意见附件,赋值为media_id具体使用请参考:文档-获取临时素材 - */ - @XStreamAlias("Attach") - private String attach; - } - - /** - * 分支审批人 - */ - @Data - @XStreamAlias("Approver") - public static class Approver implements Serializable{ - - private static final long serialVersionUID = 7360442444186683191L; - - /** - * 分支审批人userid - */ - @XStreamAlias("UserId") - private String userId; - } - - /** - * 抄送信息 - */ - @Data - @XStreamAlias("Notifyer") - public static class Notifier implements Serializable{ - - private static final long serialVersionUID = -4524071522890013920L; - - /** - * 节点抄送人userid - */ - @XStreamAlias("UserId") - private String userId; - } - - /** - * 审批申请备注信息 - */ - @Data - @XStreamAlias("Comments") - public static class Comment implements Serializable{ - - private static final long serialVersionUID = 6912156206252719485L; - - /** - * 备注人信息 - */ - @XStreamAlias("CommentUserInfo") - private CommentUserInfo commentUserInfo; - - /** - * 备注提交时间 - */ - @XStreamAlias("CommentTime") - private String commentTime; - - /** - * 备注文本内容 - */ - @XStreamAlias("CommentContent") - private String commentContent; - - /** - * 备注id - */ - @XStreamAlias("CommentId") - private String commentId; - - } - - @Data - @XStreamAlias("CommentUserInfo") - private static class CommentUserInfo implements Serializable{ - - private static final long serialVersionUID = 5031739716823000947L; - - /** - * 备注人userid - */ - @XStreamAlias("UserId") - private String userId; - } - } - } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutEventMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutEventMessage.java new file mode 100644 index 0000000000..2a252a132d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutEventMessage.java @@ -0,0 +1,88 @@ +package me.chanjar.weixin.cp.bean.message; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; + +/** + * The type Wx cp xml out event message. + * + * @author eYoung + * created at 2021/12/3 16:36 + */ +@XStreamAlias("xml") +@Data +@EqualsAndHashCode(callSuper = false) +public class WxCpXmlOutEventMessage extends WxCpXmlOutMessage { + private static final long serialVersionUID = -692538307520295832L; + + @XStreamAlias("Event") + @XStreamConverter(value = XStreamCDataConverter.class) + private String event; + + @XStreamAlias("ChatId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String chatId; + + @XStreamAlias("ChangeType") + @XStreamConverter(value = XStreamCDataConverter.class) + private String changeType; + + @XStreamAlias("UpdateDetail") + @XStreamConverter(value = XStreamCDataConverter.class) + private String updateDetail; + + @XStreamAlias("JoinScene") + private String joinScene; + + @XStreamAlias("QuitScene") + private String quitScene; + + @XStreamAlias("MemChangeCnt") + private String memChangeCnt; + + @XStreamAlias("TagType") + @XStreamConverter(value = XStreamCDataConverter.class) + private String tagType; + + @XStreamAlias("StrategyId") + private String strategyId; + + @XStreamAlias("UserID") + @XStreamConverter(value = XStreamCDataConverter.class) + private String userID; + + @XStreamAlias("ExternalUserID") + @XStreamConverter(value = XStreamCDataConverter.class) + private String externalUserID; + + @XStreamAlias("State") + @XStreamConverter(value = XStreamCDataConverter.class) + private String state; + + @XStreamAlias("WelcomeCode") + @XStreamConverter(value = XStreamCDataConverter.class) + private String welcomeCode; + + @XStreamAlias("Source") + @XStreamConverter(value = XStreamCDataConverter.class) + private String source; + + @XStreamAlias("FailReason") + @XStreamConverter(value = XStreamCDataConverter.class) + private String failReason; + + @XStreamAlias("Id") + @XStreamConverter(value = XStreamCDataConverter.class) + private String id; + + /** + * Instantiates a new Wx cp xml out event message. + */ + public WxCpXmlOutEventMessage() { + this.msgType = WxConsts.XmlMsgType.EVENT; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessage.java index 99792a2bfe..c3f4532009 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessage.java @@ -7,6 +7,9 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; +/** + * The type Wx cp xml out image message. + */ @XStreamAlias("xml") @Data @EqualsAndHashCode(callSuper = false) @@ -17,6 +20,9 @@ public class WxCpXmlOutImageMessage extends WxCpXmlOutMessage { @XStreamConverter(value = XStreamMediaIdConverter.class) private String mediaId; + /** + * Instantiates a new Wx cp xml out image message. + */ public WxCpXmlOutImageMessage() { this.msgType = WxConsts.XmlMsgType.IMAGE; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutMessage.java index ff036b4c0e..7ef7b1a30e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutMessage.java @@ -1,16 +1,18 @@ package me.chanjar.weixin.cp.bean.message; -import java.io.Serializable; - import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.cp.bean.outxmlbuilder.*; import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil; +import me.chanjar.weixin.cp.util.crypto.WxCpTpCryptUtil; import me.chanjar.weixin.cp.util.xml.XStreamTransformer; +import java.io.Serializable; + /** * 被动回复消息. * https://work.weixin.qq.com/api/doc#12975 @@ -22,23 +24,37 @@ public abstract class WxCpXmlOutMessage implements Serializable { private static final long serialVersionUID = 1418629839964153110L; + /** + * The To user name. + */ @XStreamAlias("ToUserName") @XStreamConverter(value = XStreamCDataConverter.class) protected String toUserName; + /** + * The From user name. + */ @XStreamAlias("FromUserName") @XStreamConverter(value = XStreamCDataConverter.class) protected String fromUserName; + /** + * The Create time. + */ @XStreamAlias("CreateTime") protected Long createTime; + /** + * The Msg type. + */ @XStreamAlias("MsgType") @XStreamConverter(value = XStreamCDataConverter.class) protected String msgType; /** * 获得文本消息builder. + * + * @return the text builder */ public static TextBuilder TEXT() { return new TextBuilder(); @@ -46,6 +62,8 @@ public static TextBuilder TEXT() { /** * 获得图片消息builder. + * + * @return the image builder */ public static ImageBuilder IMAGE() { return new ImageBuilder(); @@ -53,6 +71,8 @@ public static ImageBuilder IMAGE() { /** * 获得语音消息builder. + * + * @return the voice builder */ public static VoiceBuilder VOICE() { return new VoiceBuilder(); @@ -60,6 +80,8 @@ public static VoiceBuilder VOICE() { /** * 获得视频消息builder. + * + * @return the video builder */ public static VideoBuilder VIDEO() { return new VideoBuilder(); @@ -67,6 +89,8 @@ public static VideoBuilder VIDEO() { /** * 获得图文消息builder. + * + * @return the news builder */ public static NewsBuilder NEWS() { return new NewsBuilder(); @@ -74,20 +98,60 @@ public static NewsBuilder NEWS() { /** * 获得任务卡片消息builder. + * + * @return the task card builder */ public static TaskCardBuilder TASK_CARD() { return new TaskCardBuilder(); } + + /** + * 获得任务卡片消息builder. + * + * @return the update button builder + */ + public static UpdateButtonBuilder UPDATE_BUTTON() { + return new UpdateButtonBuilder(); + } + + /** + * 获得事件消息builder. + * + * @return the event builder + */ + public static EventBuilder EVENT() { + return new EventBuilder(); + } + + /** + * To xml string. + * + * @return the string + */ protected String toXml() { return XStreamTransformer.toXml((Class) this.getClass(), this); } /** * 转换成加密的xml格式. + * + * @param wxCpConfigStorage the wx cp config storage + * @return the string */ public String toEncryptedXml(WxCpConfigStorage wxCpConfigStorage) { String plainXml = toXml(); WxCpCryptUtil pc = new WxCpCryptUtil(wxCpConfigStorage); return pc.encrypt(plainXml); } + + /** + * 企业微信服务商 转换加密的xml 格式 + * @param wxCpTpConfigStorage th wx cp tp config storage + * @return the string + */ + public String toEncryptedXml(WxCpTpConfigStorage wxCpTpConfigStorage) { + String plainXml = toXml(); + WxCpTpCryptUtil pc = new WxCpTpCryptUtil(wxCpTpConfigStorage); + return pc.encrypt(plainXml); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessage.java index 7b13ccfca2..f77e5d6d53 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessage.java @@ -11,28 +11,48 @@ import java.util.ArrayList; import java.util.List; +/** + * The type Wx cp xml out news message. + */ @XStreamAlias("xml") @Data @EqualsAndHashCode(callSuper = true) public class WxCpXmlOutNewsMessage extends WxCpXmlOutMessage { private static final long serialVersionUID = -5796178637883178826L; + /** + * The Articles. + */ @XStreamAlias("Articles") protected final List articles = new ArrayList<>(); + /** + * The Article count. + */ @XStreamAlias("ArticleCount") protected int articleCount; + /** + * Instantiates a new Wx cp xml out news message. + */ public WxCpXmlOutNewsMessage() { this.msgType = WxConsts.XmlMsgType.NEWS; } + /** + * Add article. + * + * @param item the item + */ public void addArticle(Item item) { this.articles.add(item); this.articleCount = this.articles.size(); } + /** + * The type Item. + */ @XStreamAlias("item") @Data public static class Item implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessage.java index 63816f7e4c..d5042780fa 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessage.java @@ -7,6 +7,9 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamReplaceNameConverter; +/** + * The type Wx cp xml out task card message. + */ @XStreamAlias("xml") @Data @EqualsAndHashCode(callSuper = false) @@ -17,6 +20,9 @@ public class WxCpXmlOutTaskCardMessage extends WxCpXmlOutMessage { @XStreamConverter(value = XStreamReplaceNameConverter.class) private String replaceName; + /** + * Instantiates a new Wx cp xml out task card message. + */ public WxCpXmlOutTaskCardMessage() { this.msgType = WxConsts.XmlMsgType.UPDATE_TASKCARD; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessage.java index dfae8fef49..0adda399fe 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessage.java @@ -7,6 +7,9 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; +/** + * The type Wx cp xml out text message. + */ @XStreamAlias("xml") @Data @EqualsAndHashCode(callSuper = false) @@ -17,6 +20,9 @@ public class WxCpXmlOutTextMessage extends WxCpXmlOutMessage { @XStreamConverter(value = XStreamCDataConverter.class) private String content; + /** + * Instantiates a new Wx cp xml out text message. + */ public WxCpXmlOutTextMessage() { this.msgType = WxConsts.XmlMsgType.TEXT; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutUpdateBtnMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutUpdateBtnMessage.java new file mode 100644 index 0000000000..6c5ef835d0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutUpdateBtnMessage.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.cp.bean.message; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.util.xml.XStreamReplaceNameConverter; + +/** + * The type Wx cp xml out update btn message. + * + * @author nickname263 created on 2021-09-23 + */ +@XStreamAlias("xml") +@Data +@EqualsAndHashCode(callSuper = false) +public class WxCpXmlOutUpdateBtnMessage extends WxCpXmlOutMessage { + private static final long serialVersionUID = 976182367423048138L; + @XStreamAlias("Button") + @XStreamConverter(value = XStreamReplaceNameConverter.class) + private String replaceName; + + /** + * Instantiates a new Wx cp xml out update btn message. + */ + public WxCpXmlOutUpdateBtnMessage() { + this.msgType = WxConsts.XmlMsgType.UPDATE_BUTTON; + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessage.java index 031dc02cb6..8c78528a67 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessage.java @@ -1,7 +1,5 @@ package me.chanjar.weixin.cp.bean.message; -import java.io.Serializable; - import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; @@ -9,43 +7,87 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; +import java.io.Serializable; + +/** + * The type Wx cp xml out video message. + */ @XStreamAlias("xml") @Data @EqualsAndHashCode(callSuper = false) public class WxCpXmlOutVideoMessage extends WxCpXmlOutMessage { private static final long serialVersionUID = -8672761162722733622L; + /** + * The Video. + */ @XStreamAlias("Video") protected final Video video = new Video(); + /** + * Instantiates a new Wx cp xml out video message. + */ public WxCpXmlOutVideoMessage() { this.msgType = WxConsts.XmlMsgType.VIDEO; } + /** + * Gets media id. + * + * @return the media id + */ public String getMediaId() { return this.video.getMediaId(); } + /** + * Sets media id. + * + * @param mediaId the media id + */ public void setMediaId(String mediaId) { this.video.setMediaId(mediaId); } + /** + * Gets title. + * + * @return the title + */ public String getTitle() { return this.video.getTitle(); } + /** + * Sets title. + * + * @param title the title + */ public void setTitle(String title) { this.video.setTitle(title); } + /** + * Gets description. + * + * @return the description + */ public String getDescription() { return this.video.getDescription(); } + /** + * Sets description. + * + * @param description the description + */ public void setDescription(String description) { this.video.setDescription(description); } + /** + * The type Video. + */ @Data @XStreamAlias("Video") public static class Video implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessage.java index 7a2e0e49cf..ebfd80ab61 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessage.java @@ -7,6 +7,9 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; +/** + * The type Wx cp xml out voice message. + */ @XStreamAlias("xml") @Data @EqualsAndHashCode(callSuper = false) @@ -17,6 +20,9 @@ public class WxCpXmlOutVoiceMessage extends WxCpXmlOutMessage { @XStreamConverter(value = XStreamMediaIdConverter.class) private String mediaId; + /** + * Instantiates a new Wx cp xml out voice message. + */ public WxCpXmlOutVoiceMessage() { this.msgType = WxConsts.XmlMsgType.VOICE; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java index ec312c6fb4..fcbc578a59 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java @@ -4,39 +4,97 @@ import me.chanjar.weixin.cp.bean.message.WxCpMessage; import org.apache.commons.lang3.StringUtils; +/** + * The type Base builder. + * + * @param the type parameter + */ public class BaseBuilder { + /** + * The Msg type. + */ protected String msgType; + /** + * The Agent id. + */ protected Integer agentId; + /** + * The To user. + */ protected String toUser; + /** + * The To party. + */ protected String toParty; + /** + * The To tag. + */ protected String toTag; + /** + * The Safe. + */ protected String safe; + /** + * Agent id t. + * + * @param agentId the agent id + * @return the t + */ public T agentId(Integer agentId) { this.agentId = agentId; return (T) this; } + /** + * To user t. + * + * @param toUser the to user + * @return the t + */ public T toUser(String toUser) { this.toUser = toUser; return (T) this; } + /** + * To party t. + * + * @param toParty the to party + * @return the t + */ public T toParty(String toParty) { this.toParty = toParty; return (T) this; } + /** + * To tag t. + * + * @param toTag the to tag + * @return the t + */ public T toTag(String toTag) { this.toTag = toTag; return (T) this; } + /** + * Safe t. + * + * @param safe the safe + * @return the t + */ public T safe(String safe) { this.safe = safe; return (T) this; } + /** + * Build wx cp message. + * + * @return the wx cp message + */ public WxCpMessage build() { WxCpMessage m = new WxCpMessage(); m.setAgentId(this.agentId); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java index 6b36cf6cf2..a05de0ff92 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java @@ -14,12 +14,21 @@ public final class FileBuilder extends BaseBuilder { private String mediaId; + /** + * Instantiates a new File builder. + */ public FileBuilder() { this.msgType = WxConsts.KefuMsgType.FILE; } - public FileBuilder mediaId(String media_id) { - this.mediaId = media_id; + /** + * Media id file builder. + * + * @param mediaId the media id + * @return the file builder + */ + public FileBuilder mediaId(String mediaId) { + this.mediaId = mediaId; return this; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java index 6735385c90..5f88b59656 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java @@ -14,10 +14,19 @@ public final class ImageBuilder extends BaseBuilder { private String mediaId; + /** + * Instantiates a new Image builder. + */ public ImageBuilder() { this.msgType = WxConsts.KefuMsgType.IMAGE; } + /** + * Media id image builder. + * + * @param media_id the media id + * @return the image builder + */ public ImageBuilder mediaId(String media_id) { this.mediaId = media_id; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MarkdownMsgBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MarkdownMsgBuilder.java index 6b6af40ac5..ce06eafd25 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MarkdownMsgBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MarkdownMsgBuilder.java @@ -14,10 +14,19 @@ public class MarkdownMsgBuilder extends BaseBuilder { private String content; + /** + * Instantiates a new Markdown msg builder. + */ public MarkdownMsgBuilder() { this.msgType = WxConsts.KefuMsgType.MARKDOWN; } + /** + * Content markdown msg builder. + * + * @param content the content + * @return the markdown msg builder + */ public MarkdownMsgBuilder content(String content) { this.content = content; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MiniProgramNoticeMsgBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MiniProgramNoticeMsgBuilder.java index 928ea38634..b211972458 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MiniProgramNoticeMsgBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MiniProgramNoticeMsgBuilder.java @@ -21,35 +21,74 @@ public class MiniProgramNoticeMsgBuilder extends BaseBuilder contentItems; + /** + * Instantiates a new Mini program notice msg builder. + */ public MiniProgramNoticeMsgBuilder() { this.msgType = WxConsts.KefuMsgType.MINIPROGRAM_NOTICE; } + /** + * App id mini program notice msg builder. + * + * @param appId the app id + * @return the mini program notice msg builder + */ public MiniProgramNoticeMsgBuilder appId(String appId) { this.appId = appId; return this; } + /** + * Page mini program notice msg builder. + * + * @param page the page + * @return the mini program notice msg builder + */ public MiniProgramNoticeMsgBuilder page(String page) { this.page = page; return this; } + /** + * Title mini program notice msg builder. + * + * @param title the title + * @return the mini program notice msg builder + */ public MiniProgramNoticeMsgBuilder title(String title) { this.title = title; return this; } + /** + * Description mini program notice msg builder. + * + * @param description the description + * @return the mini program notice msg builder + */ public MiniProgramNoticeMsgBuilder description(String description) { this.description = description; return this; } + /** + * Content items mini program notice msg builder. + * + * @param contentItems the content items + * @return the mini program notice msg builder + */ public MiniProgramNoticeMsgBuilder contentItems(Map contentItems) { this.contentItems = contentItems; return this; } + /** + * Emphasis first item mini program notice msg builder. + * + * @param emphasisFirstItem the emphasis first item + * @return the mini program notice msg builder + */ public MiniProgramNoticeMsgBuilder emphasisFirstItem(Boolean emphasisFirstItem) { this.emphasisFirstItem = emphasisFirstItem; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java index bc1467e14c..f9b31cdfc1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java @@ -1,8 +1,8 @@ package me.chanjar.weixin.cp.bean.messagebuilder; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.cp.bean.message.WxCpMessage; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; +import me.chanjar.weixin.cp.bean.message.WxCpMessage; import java.util.ArrayList; import java.util.Collections; @@ -22,20 +22,41 @@ public final class MpnewsBuilder extends BaseBuilder { private String mediaId; + /** + * Instantiates a new Mpnews builder. + */ public MpnewsBuilder() { this.msgType = WxConsts.KefuMsgType.MPNEWS; } + /** + * Media id mpnews builder. + * + * @param mediaId the media id + * @return the mpnews builder + */ public MpnewsBuilder mediaId(String mediaId) { this.mediaId = mediaId; return this; } + /** + * Add article mpnews builder. + * + * @param articles the articles + * @return the mpnews builder + */ public MpnewsBuilder addArticle(MpnewsArticle... articles) { Collections.addAll(this.articles, articles); return this; } + /** + * Articles mpnews builder. + * + * @param articles the articles + * @return the mpnews builder + */ public MpnewsBuilder articles(List articles) { this.articles = articles; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java index ef661e6ed4..7d75f5f2bc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java @@ -1,8 +1,8 @@ package me.chanjar.weixin.cp.bean.messagebuilder; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.cp.bean.message.WxCpMessage; import me.chanjar.weixin.cp.bean.article.NewArticle; +import me.chanjar.weixin.cp.bean.message.WxCpMessage; import java.util.ArrayList; import java.util.Collections; @@ -21,15 +21,30 @@ public final class NewsBuilder extends BaseBuilder { private List articles = new ArrayList<>(); + /** + * Instantiates a new News builder. + */ public NewsBuilder() { this.msgType = WxConsts.KefuMsgType.NEWS; } + /** + * Add article news builder. + * + * @param articles the articles + * @return the news builder + */ public NewsBuilder addArticle(NewArticle... articles) { Collections.addAll(this.articles, articles); return this; } + /** + * Articles news builder. + * + * @param articles the articles + * @return the news builder + */ public NewsBuilder articles(List articles) { this.articles = articles; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TaskCardBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TaskCardBuilder.java index 57a77503b6..f23ada28d1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TaskCardBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TaskCardBuilder.java @@ -12,8 +12,7 @@ * 用法: WxCustomMessage m = WxCustomMessage.TASKCARD().title(...)....toUser(...).build(); *

* - * @author Jeff - * @date 2019-05-16 + * @author Jeff created on 2019-05-16 */ public class TaskCardBuilder extends BaseBuilder { private String title; @@ -25,30 +24,63 @@ public class TaskCardBuilder extends BaseBuilder { */ private List buttons; + /** + * Instantiates a new Task card builder. + */ public TaskCardBuilder() { this.msgType = WxConsts.KefuMsgType.TASKCARD; } + /** + * Title task card builder. + * + * @param title the title + * @return the task card builder + */ public TaskCardBuilder title(String title) { this.title = title; return this; } + /** + * Description task card builder. + * + * @param description the description + * @return the task card builder + */ public TaskCardBuilder description(String description) { this.description = description; return this; } + /** + * Url task card builder. + * + * @param url the url + * @return the task card builder + */ public TaskCardBuilder url(String url) { this.url = url; return this; } + /** + * Task id task card builder. + * + * @param taskId the task id + * @return the task card builder + */ public TaskCardBuilder taskId(String taskId) { this.taskId = taskId; return this; } + /** + * Buttons task card builder. + * + * @param buttons the buttons + * @return the task card builder + */ public TaskCardBuilder buttons(List buttons) { this.buttons = buttons; return this; 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 new file mode 100644 index 0000000000..b174b7cc75 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TemplateCardBuilder.java @@ -0,0 +1,555 @@ +package me.chanjar.weixin.cp.bean.messagebuilder; + +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.cp.bean.message.WxCpMessage; +import me.chanjar.weixin.cp.bean.templatecard.*; + +import java.util.List; + +/** + *
+ * 模板卡片消息Builder
+ * 用法: WxCustomMessage m = WxCustomMessage.TEMPLATECARD().title(...)....toUser(...).build();
+ * 
+ * + * @author yzts created on 2019-05-16 + */ +public class TemplateCardBuilder extends BaseBuilder { + /** + * 模板卡片类型,文本通知型卡片填写 “text_notice”, + * 图文展示型卡片此处填写 “news_notice”, + * 按钮交互型卡片填写”button_interaction”, + * 投票选择型卡片填写”vote_interaction”, + * 多项选择型卡片填写 “multiple_interaction” + */ + private String cardType; + + /** + * 卡片来源样式信息,不需要来源样式可不填写 + * 来源图片的url + */ + private String sourceIconUrl; + /** + * 卡片来源样式信息,不需要来源样式可不填写 + * 来源图片的描述,建议不超过20个字 + */ + private String sourceDesc; + + /** + * 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色 + */ + private Integer sourceDescColor; + + /** + * 更多操作界面的描述 + */ + private String actionMenuDesc; + + /** + * 操作列表,列表长度取值范围为 [1, 3] + */ + private List actionMenuActionList; + + /** + * 一级标题,建议不超过36个字 + */ + private String mainTitleTitle; + /** + * 标题辅助信息,建议不超过44个字 + */ + private String mainTitleDesc; + + /** + * 图文展示型的卡片必须有图片字段。 + * 图片的url. + */ + private String cardImageUrl; + + /** + * 图片的宽高比,宽高比要小于2.25,大于1.3,不填该参数默认1.3 + */ + private Float cardImageAspectRatio; + /** + * 关键数据样式 + * 关键数据样式的数据内容,建议不超过14个字 + */ + private String emphasisContentTitle; + /** + * 关键数据样式的数据描述内容,建议不超过22个字 + */ + private String emphasisContentDesc; + + /** + * 二级普通文本,建议不超过160个字 + */ + private String subTitleText; + + /** + * 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4 + */ + private List verticalContents; + + /** + * 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + */ + private List horizontalContents; + + /** + * 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + */ + private List jumps; + + /** + * 左图右文样式,news_notice类型的卡片,card_image 和 image_text_area 两者必填一个字段,不可都不填 + */ + private TemplateCardImageTextArea imageTextArea; + + /** + * 整体卡片的点击跳转事件,text_notice必填本字段 + * 跳转事件类型,1 代表跳转url,2 代表打开小程序。text_notice卡片模版中该字段取值范围为[1,2] + */ + private Integer cardActionType; + /** + * 跳转事件的url,card_action.type是1时必填 + */ + private String cardActionUrl; + + /** + * 跳转事件的小程序的appid,必须是与当前应用关联的小程序,card_action.type是2时必填 + */ + private String cardActionAppid; + + /** + * 跳转事件的小程序的pagepath,card_action.type是2时选填 + */ + private String cardActionPagepath; + + /** + * 任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 + */ + private String taskId; + + /** + * 按钮交互型卡片需指定。 + * button_selection + */ + private TemplateCardButtonSelection buttonSelection; + + /** + * 按钮交互型卡片需指定。 + * 按钮列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + */ + private List buttons; + + /** + * 投票选择型卡片需要指定 + * 选择题key值,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节 + */ + private String checkboxQuestionKey; + + /** + * 选择题模式,单选:0,多选:1,不填默认0 + */ + private Integer checkboxMode; + + /** + * 选项list,选项个数不超过 20 个,最少1个 + */ + private List options; + + /** + * 提交按钮样式 + * 按钮文案,建议不超过10个字,不填默认为提交 + */ + private String submitButtonText; + /** + * 提交按钮的key,会产生回调事件将本参数作为EventKey返回,最长支持1024字节 + */ + private String submitButtonKey; + + /** + * 下拉式的选择器列表,multiple_interaction类型的卡片该字段不可为空,一个消息最多支持 3 个选择器 + */ + private List selects; + + /** + * 引用文献样式 + */ + private QuoteArea quoteArea; + + + /** + * Instantiates a new Template card builder. + */ + public TemplateCardBuilder() { + this.msgType = WxConsts.KefuMsgType.TEMPLATE_CARD; + } + + /** + * Card type template card builder. + * + * @param cardType the card type + * @return the template card builder + */ + public TemplateCardBuilder cardType(String cardType) { + this.cardType = cardType; + return this; + } + + /** + * Card image url template card builder. + * + * @param cardImageUrl the card image url + * @return the template card builder + */ + public TemplateCardBuilder cardImageUrl(String cardImageUrl) { + this.cardImageUrl = cardImageUrl; + return this; + } + + /** + * Card image aspect ratio template card builder. + * + * @param cardImageAspectRatio the card image aspect ratio + * @return the template card builder + */ + public TemplateCardBuilder cardImageAspectRatio(Float cardImageAspectRatio) { + this.cardImageAspectRatio = cardImageAspectRatio; + return this; + } + + /** + * Action menu desc template card builder. + * + * @param actionMenuDesc the action menu desc + * @return the template card builder + */ + public TemplateCardBuilder actionMenuDesc(String actionMenuDesc) { + this.actionMenuDesc = actionMenuDesc; + return this; + } + + /** + * Action menu action list template card builder. + * + * @param actionMenuItemList the action menu item list + * @return the template card builder + */ + public TemplateCardBuilder actionMenuActionList(List actionMenuItemList) { + this.actionMenuActionList = actionMenuItemList; + return this; + } + + /** + * Source icon url template card builder. + * + * @param sourceIconUrl the source icon url + * @return the template card builder + */ + public TemplateCardBuilder sourceIconUrl(String sourceIconUrl) { + this.sourceIconUrl = sourceIconUrl; + return this; + } + + /** + * Source desc template card builder. + * + * @param sourceDesc the source desc + * @return the template card builder + */ + public TemplateCardBuilder sourceDesc(String sourceDesc) { + this.sourceDesc = sourceDesc; + return this; + } + + /** + * Source desc color template card builder. + * + * @param sourceDescColor the source desc color + * @return the template card builder + */ + public TemplateCardBuilder sourceDescColor(Integer sourceDescColor) { + this.sourceDescColor = sourceDescColor; + return this; + } + + /** + * Main title title template card builder. + * + * @param mainTitleTitle the main title title + * @return the template card builder + */ + public TemplateCardBuilder mainTitleTitle(String mainTitleTitle) { + this.mainTitleTitle = mainTitleTitle; + return this; + } + + /** + * Main title desc template card builder. + * + * @param mainTitleDesc the main title desc + * @return the template card builder + */ + public TemplateCardBuilder mainTitleDesc(String mainTitleDesc) { + this.mainTitleDesc = mainTitleDesc; + return this; + } + + /** + * Emphasis content title template card builder. + * + * @param emphasisContentTitle the emphasis content title + * @return the template card builder + */ + public TemplateCardBuilder emphasisContentTitle(String emphasisContentTitle) { + this.emphasisContentTitle = emphasisContentTitle; + return this; + } + + /** + * Emphasis content desc template card builder. + * + * @param emphasisContentDesc the emphasis content desc + * @return the template card builder + */ + public TemplateCardBuilder emphasisContentDesc(String emphasisContentDesc) { + this.emphasisContentDesc = emphasisContentDesc; + return this; + } + + /** + * Sub title text template card builder. + * + * @param subTitleText the sub title text + * @return the template card builder + */ + public TemplateCardBuilder subTitleText(String subTitleText) { + this.subTitleText = subTitleText; + return this; + } + + /** + * Vertical contents template card builder. + * + * @param verticalContents the vertical contents + * @return the template card builder + */ + public TemplateCardBuilder verticalContents(List verticalContents) { + this.verticalContents = verticalContents; + return this; + } + + /** + * Horizontal contents template card builder. + * + * @param horizontalContents the horizontal contents + * @return the template card builder + */ + public TemplateCardBuilder horizontalContents(List horizontalContents) { + this.horizontalContents = horizontalContents; + return this; + } + + /** + * Jumps template card builder. + * + * @param jumps the jumps + * @return the template card builder + */ + public TemplateCardBuilder jumps(List jumps) { + this.jumps = jumps; + return this; + } + + /** + * image_text_area template card builder. + * + * @param imageTextArea the card image_text_area + * @return the template card builder + */ + public TemplateCardBuilder imageTextArea(TemplateCardImageTextArea imageTextArea) { + this.imageTextArea = imageTextArea; + return this; + } + + /** + * Card action type template card builder. + * + * @param cardActionType the card action type + * @return the template card builder + */ + public TemplateCardBuilder cardActionType(Integer cardActionType) { + this.cardActionType = cardActionType; + return this; + } + + /** + * Card action url template card builder. + * + * @param cardActionUrl the card action url + * @return the template card builder + */ + public TemplateCardBuilder cardActionUrl(String cardActionUrl) { + this.cardActionUrl = cardActionUrl; + return this; + } + + /** + * Card action appid template card builder. + * + * @param cardActionAppid the card action appid + * @return the template card builder + */ + public TemplateCardBuilder cardActionAppid(String cardActionAppid) { + this.cardActionAppid = cardActionAppid; + return this; + } + + /** + * Card action pagepath template card builder. + * + * @param cardActionPagepath the card action pagepath + * @return the template card builder + */ + public TemplateCardBuilder cardActionPagepath(String cardActionPagepath) { + this.cardActionPagepath = cardActionPagepath; + return this; + } + + /** + * Task id template card builder. + * + * @param taskId the task id + * @return the template card builder + */ + public TemplateCardBuilder taskId(String taskId) { + this.taskId = taskId; + return this; + } + + /** + * Buttons template card builder. + * + * @param buttons the buttons + * @return the template card builder + */ + public TemplateCardBuilder buttons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Checkbox question key template card builder. + * + * @param checkboxQuestionKey the checkbox question key + * @return the template card builder + */ + public TemplateCardBuilder checkboxQuestionKey(String checkboxQuestionKey) { + this.checkboxQuestionKey = checkboxQuestionKey; + return this; + } + + /** + * Checkbox mode template card builder. + * + * @param checkboxMode the checkbox mode + * @return the template card builder + */ + public TemplateCardBuilder checkboxMode(Integer checkboxMode) { + this.checkboxMode = checkboxMode; + return this; + } + + /** + * Options template card builder. + * + * @param options the options + * @return the template card builder + */ + public TemplateCardBuilder options(List options) { + this.options = options; + return this; + } + + /** + * Submit button text template card builder. + * + * @param submitButtonText the submit button text + * @return the template card builder + */ + public TemplateCardBuilder submitButtonText(String submitButtonText) { + this.submitButtonText = submitButtonText; + return this; + } + + /** + * Submit button key template card builder. + * + * @param submitButtonKey the submit button key + * @return the template card builder + */ + public TemplateCardBuilder submitButtonKey(String submitButtonKey) { + this.submitButtonKey = submitButtonKey; + return this; + } + + /** + * Selects template card builder. + * + * @param selects the selects + * @return the template card builder + */ + public TemplateCardBuilder selects(List selects) { + this.selects = selects; + return this; + } + + /** + * Quote area template card builder. + * + * @param quoteArea the quote area + * @return the template card builder + */ + public TemplateCardBuilder quoteArea(QuoteArea quoteArea) { + this.quoteArea = quoteArea; + return this; + } + + @Override + public WxCpMessage build() { + WxCpMessage m = super.build(); + m.setSafe(null); + m.setCardType(this.cardType); + m.setSourceIconUrl(this.sourceIconUrl); + m.setSourceDesc(this.sourceDesc); + m.setSourceDescColor(this.sourceDescColor); + m.setActionMenuDesc(this.actionMenuDesc); + m.setActionMenuActionList(this.actionMenuActionList); + m.setMainTitleTitle(this.mainTitleTitle); + m.setMainTitleDesc(this.mainTitleDesc); + m.setImageTextArea(this.imageTextArea); + m.setCardImageUrl(this.cardImageUrl); + m.setCardImageAspectRatio(this.cardImageAspectRatio); + m.setEmphasisContentTitle(this.emphasisContentTitle); + m.setEmphasisContentDesc(this.emphasisContentDesc); + m.setSubTitleText(this.subTitleText); + m.setVerticalContents(this.verticalContents); + m.setHorizontalContents(this.horizontalContents); + m.setJumps(this.jumps); + m.setCardActionType(this.cardActionType); + m.setCardActionAppid(this.cardActionAppid); + m.setCardActionPagepath(this.cardActionPagepath); + m.setCardActionUrl(this.cardActionUrl); + m.setTaskId(this.taskId); + m.setButtonSelection(this.buttonSelection); + m.setButtons(this.buttons); + m.setCheckboxMode(this.checkboxMode); + m.setCheckboxQuestionKey(this.checkboxQuestionKey); + m.setOptions(this.options); + m.setSubmitButtonText(this.submitButtonText); + m.setSubmitButtonKey(this.submitButtonKey); + m.setSelects(this.selects); + m.setQuoteArea(this.quoteArea); + return m; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java index e072b9a79d..40de567f53 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java @@ -14,10 +14,19 @@ public final class TextBuilder extends BaseBuilder { private String content; + /** + * Instantiates a new Text builder. + */ public TextBuilder() { this.msgType = WxConsts.KefuMsgType.TEXT; } + /** + * Content text builder. + * + * @param content the content + * @return the text builder + */ public TextBuilder content(String content) { this.content = content; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java index 306187ee40..3f58c99546 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java @@ -18,25 +18,52 @@ public class TextCardBuilder extends BaseBuilder { private String url; private String btnTxt; + /** + * Instantiates a new Text card builder. + */ public TextCardBuilder() { this.msgType = WxConsts.KefuMsgType.TEXTCARD; } + /** + * Title text card builder. + * + * @param title the title + * @return the text card builder + */ public TextCardBuilder title(String title) { this.title = title; return this; } + /** + * Description text card builder. + * + * @param description the description + * @return the text card builder + */ public TextCardBuilder description(String description) { this.description = description; return this; } + /** + * Url text card builder. + * + * @param url the url + * @return the text card builder + */ public TextCardBuilder url(String url) { this.url = url; return this; } + /** + * Btn txt text card builder. + * + * @param btnTxt the btn txt + * @return the text card builder + */ public TextCardBuilder btnTxt(String btnTxt) { this.btnTxt = btnTxt; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java index 2c7fab5c8c..226e9dbe7a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java @@ -23,25 +23,52 @@ public final class VideoBuilder extends BaseBuilder { private String description; private String thumbMediaId; + /** + * Instantiates a new Video builder. + */ public VideoBuilder() { this.msgType = WxConsts.KefuMsgType.VIDEO; } + /** + * Media id video builder. + * + * @param mediaId the media id + * @return the video builder + */ public VideoBuilder mediaId(String mediaId) { this.mediaId = mediaId; return this; } + /** + * Title video builder. + * + * @param title the title + * @return the video builder + */ public VideoBuilder title(String title) { this.title = title; return this; } + /** + * Description video builder. + * + * @param description the description + * @return the video builder + */ public VideoBuilder description(String description) { this.description = description; return this; } + /** + * Thumb media id video builder. + * + * @param thumb_media_id the thumb media id + * @return the video builder + */ public VideoBuilder thumbMediaId(String thumb_media_id) { this.thumbMediaId = thumb_media_id; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java index 0e0b9f8286..62308a6d43 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java @@ -14,10 +14,19 @@ public final class VoiceBuilder extends BaseBuilder { private String mediaId; + /** + * Instantiates a new Voice builder. + */ public VoiceBuilder() { this.msgType = WxConsts.KefuMsgType.VOICE; } + /** + * Media id voice builder. + * + * @param media_id the media id + * @return the voice builder + */ public VoiceBuilder mediaId(String media_id) { this.mediaId = media_id; return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpAgreeInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpAgreeInfo.java new file mode 100644 index 0000000000..647bebbad8 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpAgreeInfo.java @@ -0,0 +1,90 @@ +package me.chanjar.weixin.cp.bean.msgaudit; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 获取会话同意情况返回对象. + * + * @author Wang_Wong + */ +@Data +public class WxCpAgreeInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("errcode") + private Integer errcode; + + @SerializedName("errmsg") + private String errmsg; + + @SerializedName("agreeinfo") + private List agreeInfo; + + /** + * The type Agree info. + */ + @Getter + @Setter + public static class AgreeInfo implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("status_change_time") + private Long statusChangeTime; + + @SerializedName("userid") + private String userid; + + @SerializedName("exteranalopenid") + private String exteranalOpenId; + + @SerializedName("agree_status") + private String agreeStatus; + + /** + * From json agree info. + * + * @param json the json + * @return the agree info + */ + public static AgreeInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, AgreeInfo.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + /** + * From json wx cp agree info. + * + * @param json the json + * @return the wx cp agree info + */ + public static WxCpAgreeInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpAgreeInfo.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpChatDatas.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpChatDatas.java new file mode 100644 index 0000000000..89f0219395 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpChatDatas.java @@ -0,0 +1,96 @@ +package me.chanjar.weixin.cp.bean.msgaudit; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 聊天记录数据内容. + * + * @author Wang_Wong created on 2022-01-17 + */ +@Data +public class WxCpChatDatas implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("errcode") + private Integer errCode; + + @SerializedName("errmsg") + private String errMsg; + + @SerializedName("sdk") + private long sdk; + + @SerializedName("chatdata") + private List chatData; + + /** + * The type Wx cp chat data. + */ + @Getter + @Setter + public static class WxCpChatData implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("seq") + private Long seq; + + @SerializedName("msgid") + private String msgId; + + @SerializedName("publickey_ver") + private Integer publickeyVer; + + @SerializedName("encrypt_random_key") + private String encryptRandomKey; + + @SerializedName("encrypt_chat_msg") + private String encryptChatMsg; + + /** + * From json wx cp chat data. + * + * @param json the json + * @return the wx cp chat data + */ + public static WxCpChatData fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpChatData.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + /** + * From json wx cp chat datas. + * + * @param json the json + * @return the wx cp chat datas + */ + public static WxCpChatDatas fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpChatDatas.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpChatModel.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpChatModel.java new file mode 100644 index 0000000000..05098e5e02 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpChatModel.java @@ -0,0 +1,1332 @@ +package me.chanjar.weixin.cp.bean.msgaudit; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 聊天记录数据内容. + * + * @author Wang_Wong + */ +@Data +public class WxCpChatModel implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("msgid") + private String msgId; + + @SerializedName("action") + private String action; + + @SerializedName("send") + private String send; + + @SerializedName("from") + private String from; + + @SerializedName("tolist") + private String[] tolist; + + @SerializedName("roomid") + private String roomId; + + @SerializedName("msgtime") + private Long msgTime; + + @SerializedName("msgtype") + private String msgType; + + /** + * 文本 + */ + @SerializedName("text") + private Text text; + + /** + * 图片 + */ + @SerializedName("image") + private Image image; + + /** + * 撤回消息 + */ + @SerializedName("revoke") + private Revoke revoke; + + /** + * 同意会话聊天内容 + */ + @SerializedName(value = "agree") + private Agree agree; + + @SerializedName(value = "disagree") + private Agree disagree; + + /** + * 语音 + */ + @SerializedName(value = "voice") + private Voice voice; + + /** + * 视频 + */ + @SerializedName(value = "video") + private Video video; + + /** + * 名片 + */ + @SerializedName(value = "card") + private Card card; + + /** + * 位置 + */ + @SerializedName(value = "location") + private Location location; + + /** + * 表情 + */ + @SerializedName(value = "emotion") + private Emotion emotion; + + /** + * 文件 + */ + @SerializedName(value = "file") + private File file; + + /** + * 链接 + */ + @SerializedName(value = "link") + private Link link; + + /** + * 小程序消息 + */ + @SerializedName(value = "weapp") + private Weapp weapp; + + /** + * 会话记录消息 + */ + @SerializedName(value = "chatrecord") + private ChatRecord chatRecord; + + /** + * 待办消息 官网暂无 + */ + + /** + * 投票消息 官网暂无 + */ + + /** + * 填表消息 + */ + @SerializedName(value = "collect") + private Collect collect; + + /** + * 红包消息 + * 互通红包消息 + */ + @SerializedName("redpacket") + private Redpacket redPacket; + + /** + * 会议邀请消息 + */ + @SerializedName("meeting") + private Meeting meeting; + + /** + * 切换企业日志 + */ + @SerializedName("time") + private Long time; + + @SerializedName("user") + private String user; + + /** + * 在线文档消息 + */ + @SerializedName("doc") + private Doc doc; + + @SerializedName("info") + private Info info; + + /** + * 日程消息 + */ + @SerializedName("calendar") + private Calendar calendar; + + /** + * 混合消息 + */ + @SerializedName("mixed") + private Mixed mixed; + + /** + * 音频存档消息 + */ + @SerializedName("voiceid") + private String voiceId; + + @SerializedName("meeting_voice_call") + private MeetingVoiceCall meetingVoiceCall; + + /** + * 音频共享文档消息 + */ + @SerializedName("voipid") + private String voipId; + + @SerializedName("voip_doc_share") + private WxCpFileItem voipDocShare; + + /** + * 视频号消息 + */ + @SerializedName("sphfeed") + private SphFeed sphFeed; + + /** + * From json wx cp chat model. + * + * @param json the json + * @return the wx cp chat model + */ + public static WxCpChatModel fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpChatModel.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + + /** + * The type Text. + */ + @Getter + @Setter + public static class Text implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("content") + private String content; + + /** + * From json text. + * + * @param json the json + * @return the text + */ + public static Text fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Text.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Image. + */ + @Getter + @Setter + public static class Image implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("md5sum") + private String md5Sum; + + @SerializedName("sdkfileid") + private String sdkFileId; + + @SerializedName("filesize") + private Long fileSize; + + /** + * From json image. + * + * @param json the json + * @return the image + */ + public static Image fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Image.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Revoke. + */ + @Getter + @Setter + public static class Revoke implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("pre_msgid") + private String preMsgId; + + /** + * From json revoke. + * + * @param json the json + * @return the revoke + */ + public static Revoke fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Revoke.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Agree. + */ + @Getter + @Setter + public static class Agree implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("userid") + private String userId; + + @SerializedName(value = "agree_time") + private Long agreeTime; + + @SerializedName(value = "disagree_time") + private Long disagreeTime; + + /** + * From json agree. + * + * @param json the json + * @return the agree + */ + public static Agree fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Agree.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Voice. + */ + @Getter + @Setter + public static class Voice implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("md5sum") + private String md5Sum; + + @SerializedName("sdkfileid") + private String sdkFileId; + + @SerializedName("voice_size") + private Long voiceSize; + + @SerializedName("play_length") + private Long playLength; + + /** + * From json voice. + * + * @param json the json + * @return the voice + */ + public static Voice fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Voice.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Video. + */ + @Getter + @Setter + public static class Video implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("md5sum") + private String md5Sum; + + @SerializedName("sdkfileid") + private String sdkFileId; + + @SerializedName("filesize") + private Long fileSize; + + @SerializedName("play_length") + private Long playLength; + + /** + * From json video. + * + * @param json the json + * @return the video + */ + public static Video fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Video.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Card. + */ + @Getter + @Setter + public static class Card implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("corpname") + private String corpName; + + @SerializedName("userid") + private String userId; + + /** + * From json card. + * + * @param json the json + * @return the card + */ + public static Card fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Card.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Location. + */ + @Getter + @Setter + public static class Location implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("longitude") + private Double longitude; + + @SerializedName("latitude") + private Double latitude; + + @SerializedName("address") + private String address; + + @SerializedName("title") + private String title; + + @SerializedName("zoom") + private Integer zoom; + + /** + * From json location. + * + * @param json the json + * @return the location + */ + public static Location fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Location.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Emotion. + */ + @Getter + @Setter + public static class Emotion implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("type") + private Integer type; + + @SerializedName("width") + private Integer width; + + @SerializedName("height") + private Integer height; + + @SerializedName("title") + private String title; + + @SerializedName("imagesize") + private Integer imageSize; + + @SerializedName("md5sum") + private String md5Sum; + + @SerializedName("sdkfileid") + private String sdkFileId; + + /** + * From json emotion. + * + * @param json the json + * @return the emotion + */ + public static Emotion fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Emotion.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type File. + */ + @Getter + @Setter + public static class File implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("md5sum") + private String md5Sum; + + @SerializedName("filename") + private String fileName; + + @SerializedName("fileext") + private String fileExt; + + @SerializedName("sdkfileid") + private String sdkFileId; + + @SerializedName("filesize") + private Integer fileSize; + + /** + * From json file. + * + * @param json the json + * @return the file + */ + public static File fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, File.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Link. + */ + @Getter + @Setter + public static class Link implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("title") + private String title; + + @SerializedName("description") + private String description; + + @SerializedName("link_url") + private String linkUrl; + + @SerializedName("image_url") + private String imageUrl; + + /** + * From json link. + * + * @param json the json + * @return the link + */ + public static Link fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Link.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 小程序消息 + */ + @Getter + @Setter + public static class Weapp implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("title") + private String title; + + @SerializedName("description") + private String description; + + @SerializedName("username") + private String userName; + + @SerializedName("displayname") + private String displayName; + + /** + * From json weapp. + * + * @param json the json + * @return the weapp + */ + public static Weapp fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Weapp.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 会话记录消息 + */ + @Getter + @Setter + public static class ChatRecord implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName(value = "item") + private List item; + + @SerializedName("title") + private String title; + + /** + * From json chat record. + * + * @param json the json + * @return the chat record + */ + public static ChatRecord fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, ChatRecord.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Chat record item. + */ + @Getter + @Setter + public static class ChatRecordItem implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("type") + private String type; + + @SerializedName("msgtime") + private Long msgTime; + + @SerializedName("content") + private String content; + + @SerializedName("from_chatroom") + private Boolean fromChatRoom; + + /** + * From json chat record item. + * + * @param json the json + * @return the chat record item + */ + public static ChatRecordItem fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, ChatRecordItem.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 填表消息 + */ + @Getter + @Setter + public static class Collect implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("room_name") + private String roomName; + + @SerializedName("creator") + private String creator; + + @SerializedName("create_time") + private String createTime; + + @SerializedName("title") + private String title; + + @SerializedName("details") + private List
details; + + /** + * From json collect. + * + * @param json the json + * @return the collect + */ + public static Collect fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Collect.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * The type Details. + */ + @Getter + @Setter + public static class Details implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("id") + private Long id; + + @SerializedName("ques") + private String ques; + + @SerializedName("type") + private String type; + + /** + * From json details. + * + * @param json the json + * @return the details + */ + public static Details fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Details.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 红包消息 + */ + @Getter + @Setter + public static class Redpacket implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("type") + private Integer type; + + @SerializedName("totalcnt") + private Integer totalCnt; + + @SerializedName("totalamount") + private Integer totalAmount; + + @SerializedName("wish") + private String wish; + + /** + * From json redpacket. + * + * @param json the json + * @return the redpacket + */ + public static Redpacket fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Redpacket.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 会议邀请消息 + */ + @Getter + @Setter + public static class Meeting implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("topic") + private String topic; + + @SerializedName("starttime") + private Long startTime; + + @SerializedName("endtime") + private Long endTime; + + @SerializedName("address") + private String address; + + @SerializedName("remarks") + private String remarks; + + @SerializedName("meetingtype") + private Integer meetingType; + + @SerializedName("meetingid") + private Long meetingId; + + @SerializedName("status") + private Integer status; + + /** + * From json meeting. + * + * @param json the json + * @return the meeting + */ + public static Meeting fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Meeting.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 在线文档消息 + */ + @Getter + @Setter + public static class Doc implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("title") + private String title; + + @SerializedName("doc_creator") + private String docCreator; + + @SerializedName("link_url") + private String linkUrl; + + /** + * From json doc. + * + * @param json the json + * @return the doc + */ + public static Doc fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Doc.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * MarkDown格式消息 + */ + @Getter + @Setter + public static class Info implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("content") + private String content; + + @SerializedName("item") + private List newsItem; + + /** + * From json info. + * + * @param json the json + * @return the info + */ + public static Info fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Info.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 图文消息 + */ + @Getter + @Setter + public static class NewsItem implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("title") + private String title; + + @SerializedName("description") + private String description; + + @SerializedName("url") + private String url; + + @SerializedName("picurl") + private String picUrl; + + /** + * From json news item. + * + * @param json the json + * @return the news item + */ + public static NewsItem fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, NewsItem.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 日程消息 + */ + @Getter + @Setter + public static class Calendar implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("title") + private String title; + + @SerializedName("creatorname") + private String creatorName; + + @SerializedName("attendeename") + private String[] attendeeName; + + @SerializedName("starttime") + private Long startTime; + + @SerializedName("endtime") + private Long endTime; + + @SerializedName("place") + private String place; + + @SerializedName("remarks") + private String remarks; + + /** + * From json calendar. + * + * @param json the json + * @return the calendar + */ + public static Calendar fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Calendar.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + + /** + * 混合消息 + */ + @Getter + @Setter + public static class Mixed implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("item") + private List item; + + /** + * The type Item. + */ + @Getter + @Setter + public static class Item implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("type") + private String type; + + @SerializedName("content") + private String content; + + } + + } + + + /** + * 音频存档消息 + */ + @Getter + @Setter + public static class MeetingVoiceCall implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("endtime") + private Long endTime; + + @SerializedName("sdkfileid") + private String sdkFileId; + + @SerializedName("demofiledata") + private List demoFileData; + + @SerializedName("sharescreendata") + private List shareScreenData; + + /** + * From json meeting voice call. + * + * @param json the json + * @return the meeting voice call + */ + public static MeetingVoiceCall fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, MeetingVoiceCall.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * The type Demo file data. + */ + @Getter + @Setter + public static class DemoFileData implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("filename") + private String fileName; + + @SerializedName("demooperator") + private String demoOperator; + + @SerializedName("starttime") + private Long startTime; + + @SerializedName("endtime") + private Long endTime; + + /** + * From json demo file data. + * + * @param json the json + * @return the demo file data + */ + public static DemoFileData fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, DemoFileData.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + /** + * The type Share screen data. + */ + @Getter + @Setter + public static class ShareScreenData implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("share") + private String share; + + @SerializedName("starttime") + private Long startTime; + + @SerializedName("endtime") + private Long endTime; + + /** + * From json share screen data. + * + * @param json the json + * @return the share screen data + */ + public static ShareScreenData fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, ShareScreenData.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + } + + + /** + * 视频号消息 + */ + @Getter + @Setter + public static class SphFeed implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("feed_type") + private Integer feedType; + + @SerializedName("sph_name") + private String sphName; + + @SerializedName("feed_desc") + private String feedDesc; + + /** + * From json sph feed. + * + * @param json the json + * @return the sph feed + */ + public static SphFeed fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, SphFeed.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpCheckAgreeRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpCheckAgreeRequest.java new file mode 100644 index 0000000000..7e53f0d086 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpCheckAgreeRequest.java @@ -0,0 +1,81 @@ +package me.chanjar.weixin.cp.bean.msgaudit; + +import com.google.gson.annotations.SerializedName; +import lombok.*; +import lombok.experimental.Accessors; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 获取会话同意情况请求参数. + * + * @author Wang_Wong created on 2022-01-21 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxCpCheckAgreeRequest implements Serializable { + private static final long serialVersionUID = -4960239393895754138L; + + @SerializedName("info") + private List info; + + /** + * From json wx cp check agree request. + * + * @param json the json + * @return the wx cp check agree request + */ + public static WxCpCheckAgreeRequest fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCheckAgreeRequest.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + /** + * The type Info. + */ + @Getter + @Setter + public static class Info implements Serializable { + private static final long serialVersionUID = -4960239393895754138L; + + @SerializedName("userid") + private String userid; + + @SerializedName("exteranalopenid") + private String exteranalOpenId; + + /** + * From json info. + * + * @param json the json + * @return the info + */ + public static Info fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Info.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpFileItem.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpFileItem.java new file mode 100644 index 0000000000..384f29f756 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpFileItem.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.cp.bean.msgaudit; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 会话存档 文档信息对象 + * + * @author Wang_Wong + */ +@Data +public class WxCpFileItem implements Serializable { + + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("filename") + private String fileName; + + @SerializedName("md5sum") + private String md5Sum; + + @SerializedName("sdkfileid") + private String sdkFileId; + + @SerializedName("filesize") + private Long fileSize; + + /** + * From json wx cp file item. + * + * @param json the json + * @return the wx cp file item + */ + public static WxCpFileItem fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpFileItem.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpGroupChat.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpGroupChat.java new file mode 100644 index 0000000000..039c2c37c3 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/msgaudit/WxCpGroupChat.java @@ -0,0 +1,81 @@ +package me.chanjar.weixin.cp.bean.msgaudit; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 内部群信息 + * + * @author Wang_Wong + */ +@Data +public class WxCpGroupChat implements Serializable { + + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("roomname") + private String roomName; + + @SerializedName("creator") + private String creator; + + @SerializedName("room_create_time") + private Long roomCreateTime; + + @SerializedName("notice") + private String notice; + + private List members; + + /** + * The type Member. + */ + @Getter + @Setter + public static class Member implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + @SerializedName("memberid") + private String memberId; + + @SerializedName("jointime") + private Long joinTime; + + /** + * From json member. + * + * @param json the json + * @return the member + */ + public Member fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, Member.class); + } + + } + + /** + * From json wx cp group chat. + * + * @param json the json + * @return the wx cp group chat + */ + public static WxCpGroupChat fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGroupChat.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/SummaryInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/SummaryInfo.java index 49222cd0a5..fd7e2e77df 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/SummaryInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/SummaryInfo.java @@ -3,7 +3,6 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.experimental.Accessors; -import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest; import java.io.Serializable; import java.util.List; @@ -11,23 +10,27 @@ /** * 摘要行信息,用于定义某一行摘要显示的内容. * - * @author Binary Wang - * @date 2020-07-19 + * @author Binary Wang created on 2020-07-19 */ @Data @Accessors(chain = true) public class SummaryInfo implements Serializable { private static final long serialVersionUID = 8262265774851382414L; + /** * 摘要行信息,用于定义某一行摘要显示的内容 */ @SerializedName("summary_info") private List summaryInfoData; + /** + * The type Summary info data. + */ @Data @Accessors(chain = true) public static class SummaryInfoData implements Serializable { private static final long serialVersionUID = 5314161929610113856L; + /** * 摘要行显示文字,用于记录列表和消息通知的显示,不要超过20个字符 */ diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalApplier.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalApplier.java index b9b1af3c3a..8b16aefa82 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalApplier.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalApplier.java @@ -2,14 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import java.io.Serializable; /** * 申请人信息 + * * @author element */ @Data +@EqualsAndHashCode(callSuper = true) public class WxCpApprovalApplier extends WxCpOperator implements Serializable { private static final long serialVersionUID = -8974662568286821271L; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetail.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetail.java deleted file mode 100644 index cba31fc27c..0000000000 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetail.java +++ /dev/null @@ -1,78 +0,0 @@ -package me.chanjar.weixin.cp.bean.oa; - -import com.google.gson.annotations.SerializedName; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * 审批申请详情 - * - * @author element - */ -@Data -public class WxCpApprovalDetail implements Serializable { - private static final long serialVersionUID = 1353393306564207170L; - - /** - * 审批编号 - */ - @SerializedName("sp_no") - private String spNo; - - /** - * 审批申请类型名称(审批模板名称) - */ - @SerializedName("sp_name") - private String spName; - - /** - * 申请单状态:1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付 - */ - @SerializedName("sp_status") - private WxCpSpStatus spStatus; - - /** - * 审批模板id。可在“获取审批申请详情”、“审批状态变化回调通知”中获得,也可在审批模板的模板编辑页面链接中获得。 - */ - @SerializedName("template_id") - private String templateId; - - /** - * 审批申请提交时间,Unix时间戳 - */ - @SerializedName("apply_time") - private Long applyTime; - - /** - * 申请人信息 - */ - @SerializedName("applyer") - private WxCpApprovalApplier applier; - - /** - * 审批流程信息,可能有多个审批节点 - */ - @SerializedName("sp_record") - private WxCpApprovalRecord[] spRecords; - - /** - * 抄送信息,可能有多个抄送节点 - */ - @SerializedName("notifyer") - private WxCpOperator[] notifiers; - - /** - * 审批申请数据 - */ - @SerializedName("apply_data") - private WxCpApprovalApplyData applyData; - - /** - * 审批申请备注信息,可能有多个备注节点 - */ - @SerializedName("comments") - private List comments; - -} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetailResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetailResult.java index fdbc096a5c..7d55ff878f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetailResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetailResult.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serializable; +import java.util.List; /** * 审批申请详情响应结果 @@ -23,4 +24,73 @@ public class WxCpApprovalDetailResult implements Serializable { @SerializedName("info") private WxCpApprovalDetail info; + /** + * The type Wx cp approval detail. + */ + @Data + public static class WxCpApprovalDetail implements Serializable { + private static final long serialVersionUID = 1353393306564207170L; + + /** + * 审批编号 + */ + @SerializedName("sp_no") + private String spNo; + + /** + * 审批申请类型名称(审批模板名称) + */ + @SerializedName("sp_name") + private String spName; + + /** + * 申请单状态:1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付 + */ + @SerializedName("sp_status") + private WxCpSpStatus spStatus; + + /** + * 审批模板id。可在“获取审批申请详情”、“审批状态变化回调通知”中获得,也可在审批模板的模板编辑页面链接中获得。 + */ + @SerializedName("template_id") + private String templateId; + + /** + * 审批申请提交时间,Unix时间戳 + */ + @SerializedName("apply_time") + private Long applyTime; + + /** + * 申请人信息 + */ + @SerializedName("applyer") + private WxCpApprovalApplier applier; + + /** + * 审批流程信息,可能有多个审批节点 + */ + @SerializedName("sp_record") + private WxCpApprovalRecord[] spRecords; + + /** + * 抄送信息,可能有多个抄送节点 + */ + @SerializedName("notifyer") + private WxCpOperator[] notifiers; + + /** + * 审批申请数据 + */ + @SerializedName("apply_data") + private WxCpApprovalApplyData applyData; + + /** + * 审批申请备注信息,可能有多个备注节点 + */ + @SerializedName("comments") + private List comments; + + } + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java index 4856af4194..70c781df43 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java @@ -1,12 +1,14 @@ package me.chanjar.weixin.cp.bean.oa; -import java.io.Serializable; -import java.util.List; - import com.google.gson.annotations.SerializedName; import lombok.Data; +import java.io.Serializable; +import java.util.List; + /** + * The type Wx cp approval info. + * * @author element */ @Data diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfoQueryFilter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfoQueryFilter.java index 5271312081..306350d569 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfoQueryFilter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfoQueryFilter.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.Getter; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; @@ -21,15 +22,24 @@ public class WxCpApprovalInfoQueryFilter implements Serializable { private static final long serialVersionUID = 3318064927980231802L; - private WxCpApprovalInfoQueryFilter.KEY key; + private KEY key; private Object value; + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxGsonBuilder.create().toJson(this); } - public static enum KEY { + /** + * The enum Key. + */ + @Getter + public enum KEY { /** * template_id - 模板类型/模板id; @@ -50,11 +60,16 @@ public static enum KEY { * sp_status - 审批状态。 */ @SerializedName("sp_status") - SP_STATUS("sp_status"); + SP_STATUS("sp_status"), + /** + * record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批。 + */ + @SerializedName("record_type") + record_type("record_type"); - private String value; + private final String value; - private KEY(String value) { + KEY(String value) { this.value = value; } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecord.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecord.java index 3325eaa4ac..c2ac33176d 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecord.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecord.java @@ -8,6 +8,7 @@ /** * 审批流程信息 + * * @author element */ @Data diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecordDetail.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecordDetail.java index 4c966c9d6f..371546d73c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecordDetail.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalRecordDetail.java @@ -8,11 +8,11 @@ /** * 审批节点详情 + * * @author element */ @Data public class WxCpApprovalRecordDetail implements Serializable { - private static final long serialVersionUID = -9142079764088495301L; /** diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApproverAttr.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApproverAttr.java index 15e55f2f72..ae65a82082 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApproverAttr.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApproverAttr.java @@ -19,9 +19,9 @@ public enum WxCpApproverAttr { @SerializedName("2") ALL_SIGN(2); - private Integer attr; + private final Integer attr; - private WxCpApproverAttr(Integer attr) { + WxCpApproverAttr(Integer attr) { this.attr = attr; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinData.java index 93e975508a..6e88f70cb3 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinData.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinData.java @@ -9,8 +9,7 @@ /** * 企业微信打卡数据. * - * @author Element - * @date 2019-04-06 11:01 + * @author Element created on 2019-04-06 11:01 */ @Data public class WxCpCheckinData implements Serializable { @@ -96,26 +95,26 @@ public class WxCpCheckinData implements Serializable { */ @SerializedName("deviceid") private String deviceId; - + /** * 标准打卡时间,指此次打卡时间对应的标准上班时间或标准下班时间 */ @SerializedName("sch_checkin_time") private Long schCheckinTime; - - /** + + /** * 规则id,表示打卡记录所属规则的id */ @SerializedName("groupid") private Integer groupId; - - /** + + /** * 班次id,表示打卡记录所属规则中,所属班次的id */ @SerializedName("schedule_id") private Integer scheduleId; - - /** + + /** * 时段id,表示打卡记录所属规则中,某一班次中的某一时段的id,如上下班时间为9:00-12:00、13:00-18:00的班次中,9:00-12:00为其中一组时段 */ @SerializedName("timeline_id") diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinDayData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinDayData.java index 0c0bd8a07e..1a8d47c82e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinDayData.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinDayData.java @@ -8,7 +8,6 @@ /** * 企业微信打卡日报数据 - * */ @Data public class WxCpCheckinDayData implements Serializable { @@ -21,8 +20,11 @@ public class WxCpCheckinDayData implements Serializable { @SerializedName("base_info") private BaseInfo baseInfo; + /** + * The type Base info. + */ @Data - public class BaseInfo implements Serializable{ + public class BaseInfo implements Serializable { private static final long serialVersionUID = 3679745559788648438L; @@ -68,6 +70,9 @@ public class BaseInfo implements Serializable{ @SerializedName("rule_info") private RuleInfo ruleInfo; + /** + * The type Rule info. + */ @Data public class RuleInfo implements Serializable { private static final long serialVersionUID = -5512479811648914189L; @@ -101,8 +106,11 @@ public class RuleInfo implements Serializable { @SerializedName("checkintime") private List checkinTime; + /** + * The type Checkin time. + */ @Data - public class CheckinTime implements Serializable{ + public class CheckinTime implements Serializable { private static final long serialVersionUID = 1582835435812966332L; /** * work_sec 上班时间,为距离0点的时间差 @@ -117,6 +125,7 @@ public class CheckinTime implements Serializable{ private Integer offWorkSec; } } + /** * day_type 日报类型:0-工作日日报;1-休息日日报 */ @@ -130,8 +139,11 @@ public class CheckinTime implements Serializable{ @SerializedName("summary_info") private SummaryInfo summaryInfo; + /** + * The type Summary info. + */ @Data - public class SummaryInfo implements Serializable{ + public class SummaryInfo implements Serializable { private static final long serialVersionUID = 3428576099259666595L; /** * checkin_count 当日打卡次数 @@ -170,8 +182,11 @@ public class SummaryInfo implements Serializable{ @SerializedName("holiday_infos") private List holidayInfos; + /** + * The type Holiday infos. + */ @Data - public class HolidayInfos implements Serializable{ + public class HolidayInfos implements Serializable { private static final long serialVersionUID = -6671577072585561527L; /** * sp_number 假勤相关信息 @@ -185,6 +200,9 @@ public class HolidayInfos implements Serializable{ @SerializedName("sp_title") private SpTitle spTitle; + /** + * The type Sp title. + */ @Data public class SpTitle implements Serializable { private static final long serialVersionUID = 2148815417115384998L; @@ -194,8 +212,11 @@ public class SpTitle implements Serializable { @SerializedName("data") private List data; + /** + * The type Data. + */ @lombok.Data - public class Data implements Serializable{ + public class Data implements Serializable { private static final long serialVersionUID = -1672692024530543180L; /** * text 假勤信息摘要-标题文本 @@ -217,8 +238,11 @@ public class Data implements Serializable{ @SerializedName("sp_description") private SpDescription spDescription; + /** + * The type Sp description. + */ @Data - public class SpDescription implements Serializable{ + public class SpDescription implements Serializable { private static final long serialVersionUID = 77680581771933449L; /** @@ -227,8 +251,11 @@ public class SpDescription implements Serializable{ @SerializedName("data") private List data; + /** + * The type Data. + */ @lombok.Data - public class Data implements Serializable{ + public class Data implements Serializable { private static final long serialVersionUID = 3555479101375365805L; /** * text 假勤信息摘要-标题文本 @@ -251,8 +278,11 @@ public class Data implements Serializable{ @SerializedName("exception_infos") private List exceptionInfos; + /** + * The type Exception infos. + */ @Data - public class ExceptionInfos implements Serializable{ + public class ExceptionInfos implements Serializable { private static final long serialVersionUID = -5987438373762518299L; /** * exception 校准状态类型:1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常 @@ -279,8 +309,11 @@ public class ExceptionInfos implements Serializable{ @SerializedName("ot_info") private OtInfo otInfo; + /** + * The type Ot info. + */ @Data - public class OtInfo implements Serializable{ + public class OtInfo implements Serializable { private static final long serialVersionUID = -6557759801572150175L; /** * ot_status 状态:0-无加班;1-正常;2-缺时长 @@ -307,8 +340,11 @@ public class OtInfo implements Serializable{ @SerializedName("sp_items") private List spItems; + /** + * The type Sp item. + */ @Data - public class SpItem implements Serializable{ + public class SpItem implements Serializable { private static final long serialVersionUID = 2423158264958352024L; /** * type 类型:1-请假;2-补卡;3-出差;4-外出;100-外勤 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinGroupBase.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinGroupBase.java new file mode 100644 index 0000000000..f1c1a8580d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinGroupBase.java @@ -0,0 +1,477 @@ +package me.chanjar.weixin.cp.bean.oa; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 打卡规则基础信息 + * + * @author zhongjun96 + * @date 2023/7/7 + **/ +@Data +public class WxCpCheckinGroupBase implements Serializable { + + private static final long serialVersionUID = -2763570465930237249L; + + + /** + * 打卡规则类型,1:固定时间上下班;2:按班次上下班;3:自由上下班 + */ + @SerializedName("grouptype") + private Long groupType; + + /** + * 打卡规则id + */ + @SerializedName("groupid") + private Long groupId; + + /** + * 打卡规则名称 + */ + @SerializedName("groupname") + private String groupName; + + /** + * 打卡时间,当规则类型为排班时没有意义 + */ + @SerializedName("checkindate") + private List checkinDate; + + /** + * 特殊日期-必须打卡日期信息,timestamp表示具体时间 + */ + @SerializedName("spe_workdays") + private List speWorkdays; + + /** + * 特殊日期-不用打卡日期信息, timestamp表示具体时间 + */ + @SerializedName("spe_offdays") + private List speOffDays; + + /** + * 是否同步法定节假日,true为同步,false为不同步,当前排班不支持 + */ + @SerializedName("sync_holidays") + private Boolean syncHolidays; + + /** + * 是否打卡必须拍照,true为必须拍照,false为不必须拍照 + */ + @SerializedName("need_photo") + private Boolean needPhoto; + + /** + * 是否备注时允许上传本地图片,true为允许,false为不允许 + */ + @SerializedName("note_can_use_local_pic") + private Boolean noteCanUseLocalPic; + + /** + * 是否非工作日允许打卡,true为允许,false为不允许 + */ + @SerializedName("allow_checkin_offworkday") + private Boolean allowCheckinOffWorkDay; + + /** + * 是否允许提交补卡申请,true为允许,false为不允许 + */ + @SerializedName("allow_apply_offworkday") + private Boolean allowApplyOffWorkDay; + + /** + * 打卡地点-WiFi打卡信息 + */ + @SerializedName("wifimac_infos") + private List wifiMacInfos; + + /** + * 打卡地点-WiFi打卡信息 + */ + @SerializedName("loc_infos") + private List locInfos; + + + /** + * 排班信息,只有规则为按班次上下班打卡时才有该配置 + */ + @SerializedName("schedulelist") + private List schedulelist; + + + /** + * The type Checkin date. + */ + @Data + public static class CheckinDate implements Serializable { + private static final long serialVersionUID = -8560643656775167406L; + /** + * 工作日。若为固定时间上下班或自由上下班,则1到6分别表示星期一到星期六,0表示星期日 + */ + @SerializedName("workdays") + private List workdays; + + /** + * 工作日上下班打卡时间信息 + */ + @SerializedName("checkintime") + private List checkinTime; + + /** + * 下班不需要打卡,true为下班不需要打卡,false为下班需要打卡 + */ + @SerializedName("noneed_offwork") + private Boolean noneedOffwork; + + /** + * 打卡时间限制(毫秒) + */ + @SerializedName("limit_aheadtime") + private Long limitAheadtime; + + /** + * 弹性时间(毫秒)只有flex_on_duty_time,flex_off_duty_time不生效时(值为-1)才有意义 + */ + @SerializedName("flex_time") + private Integer flexTime; + + /** + * 允许迟到时间,单位ms + */ + @SerializedName("flex_on_duty_time") + private Integer flexOnDutyTime; + + /** + * 允许早退时间,单位ms + */ + @SerializedName("flex_off_duty_time") + private Integer flexOffDutyTime; + } + + /** + * The type Checkin time. + */ + @Data + public static class CheckinTime implements Serializable { + + private static final long serialVersionUID = -5507709858609705279L; + /** + * 上班时间,表示为距离当天0点的秒数。 + */ + @SerializedName("work_sec") + private Integer workSec; + + /** + * 下班时间,表示为距离当天0点的秒数。 + */ + @SerializedName("off_work_sec") + private Integer offWorkSec; + + /** + * 上班提醒时间,表示为距离当天0点的秒数。。 + */ + @SerializedName("remind_work_sec") + private Integer remindWorkSec; + + /** + * 下班提醒时间,表示为距离当天0点的秒数。 + */ + @SerializedName("remind_off_work_sec") + private Integer remindOffWorkSec; + } + + /** + * The type Spe workday. + */ + @Data + public static class SpeWorkday implements Serializable { + + private static final long serialVersionUID = -4620710297258742666L; + /** + * 特殊日期-必须打卡日期时间戳 + */ + @SerializedName("timestamp") + private Long timestamp; + + /** + * 特殊日期备注 + */ + @SerializedName("notes") + private String notes; + + /** + * 特殊日期-必须打卡日期-上下班打卡时间 + */ + @SerializedName("checkintime") + private List checkinTime; + } + + /** + * The type Spe off day. + */ + @Data + public static class SpeOffDay implements Serializable { + private static final long serialVersionUID = 9214798931489490993L; + /** + * 特殊日期-不用打卡日期时间戳 + */ + @SerializedName("timestamp") + private Long timestamp; + + /** + * 特殊日期备注 + */ + @SerializedName("notes") + private String notes; + } + + /** + * The type Wifi mac info. + */ + @Data + public static class WifiMacInfo implements Serializable { + + private static final long serialVersionUID = 6742659716677227089L; + + /** + * WiFi打卡地点名称 + */ + @SerializedName("wifiname") + private String wifiname; + + /** + * WiFi打卡地点MAC地址/bssid + */ + @SerializedName("wifimac") + private String wifimac; + } + + /** + * The type Loc info. + */ + @Data + public static class LocInfo implements Serializable { + + private static final long serialVersionUID = -5591379191341944101L; + /** + * 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准 + */ + @SerializedName("lat") + private Long lat; + + /** + * 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准 + */ + @SerializedName("lng") + private Long lng; + + /** + * 位置打卡地点名称 + */ + @SerializedName("loc_title") + private String locTitle; + + /** + * 位置打卡地点详情 + */ + @SerializedName("loc_detail") + private String locDetail; + + /** + * 允许打卡范围(米) + */ + @SerializedName("distance") + private Integer distance; + } + + + /** + * The type Schedule. + */ + @Data + public static class Schedule implements Serializable { + + private static final long serialVersionUID = -2461113644925307266L; + + /** + * 班次id + */ + @SerializedName("schedule_id") + private Integer scheduleId; + + /** + * 班次名称 + */ + @SerializedName("schedule_name") + private String scheduleName; + + /** + * 班次上下班时段信息 + */ + @SerializedName("time_section") + private List timeSection; + + /** + * 允许提前打卡时间 + */ + @SerializedName("limit_aheadtime") + private Long limitAheadTime; + + /** + * 下班xx秒后不允许打下班卡 + */ + @SerializedName("limit_offtime") + private Integer limitOffTime; + + /** + * 下班不需要打卡 + */ + @SerializedName("noneed_offwork") + private Boolean noNeedOffWork; + + /** + * 是否允许弹性时间 + */ + @SerializedName("allow_flex") + private Boolean allowFlex; + + /** + * 允许迟到时间 + */ + @SerializedName("flex_on_duty_time") + private Integer flexOnDutyTime; + + /** + * 允许早退时间 + */ + @SerializedName("flex_off_duty_time") + private Integer flexOffDutyTime; + + /** + * 非工作日加班,跨天时间,距离当天00:00的秒数 + */ + @SerializedName("late_rule") + private LateRule lateRule; + + /** + * 最早可打卡时间限制 + */ + @SerializedName("max_allow_arrive_early") + private Integer maxAllowArriveEarly; + + /** + * 最晚可打卡时间限制,max_allow_arrive_early、max_allow_arrive_early与flex_on_duty_time、flex_off_duty_time互斥,当设置其中一组时,另一组数值置0 + */ + @SerializedName("max_allow_arrive_late") + private Integer maxAllowArriveLate; + + } + + + /** + * The type Time section. + */ + @Data + public static class TimeSection implements Serializable { + private static final long serialVersionUID = 7497252128339062724L; + + /** + * 时段id,为班次中某一堆上下班时间组合的id + */ + @SerializedName("time_id") + private Integer timeId; + + /** + * 上班时间,表示为距离当天0点的秒数。 + */ + @SerializedName("work_sec") + private Integer workSec; + + /** + * 下班时间,表示为距离当天0点的秒数。 + */ + @SerializedName("off_work_sec") + private Integer offWorkSec; + + /** + * 上班提醒时间,表示为距离当天0点的秒数。 + */ + @SerializedName("remind_work_sec") + private Long remindWorkSec; + + /** + * 下班提醒时间,表示为距离当天0点的秒数。 + */ + @SerializedName("remind_off_work_sec") + private Integer remindOffWorkSec; + + /** + * 休息开始时间,仅单时段支持,距离0点的秒 + */ + @SerializedName("rest_begin_time") + private Integer restBeginTime; + + /** + * 休息结束时间,仅单时段支持,距离0点的秒 + */ + @SerializedName("rest_end_time") + private Integer restEndTime; + + /** + * 是否允许休息 + */ + @SerializedName("allow_rest") + private Boolean allowRest; + } + + + /** + * The type Late rule. + */ + @Data + public static class LateRule implements Serializable { + + private static final long serialVersionUID = 5604969713950037053L; + + + /** + * 是否允许超时下班(下班晚走次日晚到)允许时onwork_flex_time,offwork_after_time才有意义 + */ + @SerializedName("allow_offwork_after_time") + private Boolean allowOffWorkAfterTime; + + /** + * 迟到规则时间 + */ + @SerializedName("timerules") + private List timerules; + } + + + /** + * The type Time rule. + */ + @Data + public static class TimeRule implements Serializable { + + private static final long serialVersionUID = 5680614050081598333L; + + /** + * 晚走的时间 距离最晚一个下班的时间单位:秒 + */ + @SerializedName("offwork_after_time") + private Integer offWorkAfterTime; + + /** + * 第二天第一个班次允许迟到的弹性时间单位:秒 + */ + @SerializedName("onwork_flex_time") + private Integer onWorkFlexTime; + + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinMonthData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinMonthData.java index 003c68d2e2..d0b98bf5db 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinMonthData.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinMonthData.java @@ -8,8 +8,9 @@ /** * 企业微信打卡月报数据 + * + * @author longliveh */ - @Data public class WxCpCheckinMonthData implements Serializable { private static final long serialVersionUID = -3062328201807894236L; @@ -20,9 +21,13 @@ public class WxCpCheckinMonthData implements Serializable { @SerializedName("base_info") private BaseInfo baseInfo; + /** + * The type Base info. + */ @Data - public class BaseInfo implements Serializable { + public static class BaseInfo implements Serializable { private static final long serialVersionUID = -5368331890851903885L; + /** * record_type 记录类型:1-固定上下班;2-外出(此报表中不会出现外出打卡数据);3-按班次上下班;4-自由签到;5-加班;7-无规则 */ @@ -59,9 +64,13 @@ public class BaseInfo implements Serializable { @SerializedName("rule_info") private RuleInfo ruleInfo; + /** + * The type Rule info. + */ @Data - public class RuleInfo implements Serializable { + public static class RuleInfo implements Serializable { private static final long serialVersionUID = 9152263355916880710L; + /** * groupid 所属规则Id */ @@ -76,18 +85,17 @@ public class RuleInfo implements Serializable { } } - - - - /** * summary_info 打卡人员所属规则信息 */ @SerializedName("summary_info") private SummaryInfo summaryInfo; + /** + * The type Summary info. + */ @Data - public class SummaryInfo implements Serializable { + public static class SummaryInfo implements Serializable { private static final long serialVersionUID = -1956770107240513983L; /** * work_days 应打卡天数 @@ -127,8 +135,11 @@ public class SummaryInfo implements Serializable { @SerializedName("exception_infos") private List exceptionInfos; + /** + * The type Exception info. + */ @Data - public class ExceptionInfo implements Serializable { + public static class ExceptionInfo implements Serializable { private static final long serialVersionUID = -4855850255704089359L; /** * exception 异常类型:1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常 @@ -155,10 +166,13 @@ public class ExceptionInfo implements Serializable { @SerializedName("sp_items") private List spItems; + /** + * The type Sp item. + */ @Data - public class SpItem implements Serializable { - + public static class SpItem implements Serializable { private static final long serialVersionUID = 224472626753597080L; + /** * type 假勤类型:1-请假;2-补卡;3-出差;4-外出;100-外勤 */ @@ -202,9 +216,13 @@ public class SpItem implements Serializable { @SerializedName("overwork_info") private OverWorkInfo overworkInfo; + /** + * The type Over work info. + */ @Data - public class OverWorkInfo implements Serializable { + public static class OverWorkInfo implements Serializable { private static final long serialVersionUID = -9149524232645899305L; + /** * workday_over_sec 工作日加班时长 */ diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinOption.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinOption.java index 70cd4b202a..9b3154a867 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinOption.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinOption.java @@ -4,13 +4,11 @@ import lombok.Data; import java.io.Serializable; -import java.util.List; /** * 企业微信打卡规则. * - * @author Element - * @date 2019-04-06 13:22 + * @author Element created on 2019-04-06 13:22 */ @Data public class WxCpCheckinOption implements Serializable { @@ -19,127 +17,6 @@ public class WxCpCheckinOption implements Serializable { @SerializedName("userid") private String userId; - private Group group; - - @Data - public static class CheckinDate implements Serializable { - private static final long serialVersionUID = -5601722383347110974L; - - private List workdays; - - @SerializedName("checkintime") - private CheckinTime[] checkinTime; - - @SerializedName("flex_time") - private Long flexTime; - - @SerializedName("noneed_offwork") - private Boolean noNeedOffwork; - - @SerializedName("limit_aheadtime") - private Long limitAheadTime; - } - - @Data - public static class CheckinTime implements Serializable { - private static final long serialVersionUID = -8579954143265336276L; - - @SerializedName("work_sec") - private Long workSec; - - @SerializedName("off_work_sec") - private Long offWorkSec; - - @SerializedName("remind_work_sec") - private Long remindWorkSec; - - @SerializedName("remind_off_work_sec") - private Long remindOffWorkSec; - } - - @Data - public static class Group implements Serializable { - - private static final long serialVersionUID = -5888406969613403044L; - - @SerializedName("groupid") - private Long id; - - @SerializedName("groupname") - private String name; - - @SerializedName("grouptype") - private Integer type; - - @SerializedName("checkindate") - private List checkinDate; - - @SerializedName("spe_workdays") - private List speWorkdays; - - @SerializedName("spe_offdays") - private List speOffdays; - - @SerializedName("sync_holidays") - private Boolean syncHolidays; - - @SerializedName("need_photo") - private Boolean needPhoto; - - @SerializedName("note_can_use_local_pic") - private Boolean noteCanUseLocalPic; - - @SerializedName("allow_checkin_offworkday") - private Boolean allowCheckinOffWorkday; - - @SerializedName("allow_apply_offworkday") - private Boolean allowApplyOffWorkday; - - @SerializedName("wifimac_infos") - private List wifiMacInfos; - - @SerializedName("loc_infos") - private List locInfos; - - } - - @Data - public static class WifiMacInfo implements Serializable { - private static final long serialVersionUID = -4657809185716627368L; - - @SerializedName("wifiname") - private String name; - - @SerializedName("wifimac") - private String mac; - } - - @Data - public static class LocInfo implements Serializable { - private static final long serialVersionUID = -618965280668099608L; - - private Long lat; - private Long lng; - - @SerializedName("loc_title") - private String title; - - @SerializedName("loc_detail") - private String detail; - - private Long distance; - } - - @Data - public static class SpeDay implements Serializable { - private static final long serialVersionUID = -3538818921359212748L; - - private Long timestamp; - private String notes; - - @SerializedName("checkintime") - private List checkinTime; - - } - + @SerializedName("group") + private WxCpCheckinGroupBase group; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java index 9517a64d4d..af310439fc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java @@ -45,6 +45,9 @@ public class WxCpCheckinSchedule implements Serializable { @SerializedName("schedule") private UserSchedule schedule; + /** + * The type User schedule. + */ @Data public class UserSchedule implements Serializable { private static final long serialVersionUID = 9138985222324576857L; @@ -54,6 +57,9 @@ public class UserSchedule implements Serializable { @SerializedName("scheduleList") private List scheduleList; + /** + * The type Schedule. + */ @Data public class Schedule implements Serializable { @@ -71,6 +77,9 @@ public class Schedule implements Serializable { @SerializedName("schedule_info") private ScheduleInfo scheduleInfo; + /** + * The type Schedule info. + */ @Data public class ScheduleInfo implements Serializable { private static final long serialVersionUID = 1317096341116256963L; @@ -93,6 +102,9 @@ public class ScheduleInfo implements Serializable { private List timeSection; + /** + * The type Time section. + */ @Data public class TimeSection implements Serializable { private static final long serialVersionUID = -3447467962751285748L; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCorpConfInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCorpConfInfo.java new file mode 100644 index 0000000000..5339cc0ba5 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCorpConfInfo.java @@ -0,0 +1,86 @@ +package me.chanjar.weixin.cp.bean.oa; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 企业假期管理配置信息. + * + * @author Wang_Wong + */ +@Data +public class WxCpCorpConfInfo extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 7387181805254287157L; + + @SerializedName("lists") + private List lists; + + /** + * The type Corp conf. + */ + @Getter + @Setter + public static class CorpConf implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("id") + private Integer id; + + @SerializedName("name") + private String name; + + @SerializedName("time_attr") + private Integer timeAttr; + + @SerializedName("duration_type") + private Integer durationType; + + @SerializedName("quota_attr") + private QuotaAttr quotaAttr; + + @SerializedName("perday_duration") + private Integer perdayDuration; + + } + + /** + * The type Quota attr. + */ + @Getter + @Setter + public static class QuotaAttr implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("type") + private Integer type; + + @SerializedName("autoreset_time") + private Integer autoresetTime; + + @SerializedName("autoreset_duration") + private Integer autoresetDuration; + + } + + /** + * From json wx cp corp conf info. + * + * @param json the json + * @return the wx cp corp conf info + */ + public static WxCpCorpConfInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCorpConfInfo.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java index c68741fcaf..bda77447fe 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import java.io.Serializable; import java.util.List; @@ -11,88 +12,11 @@ * * @author Liuwm */ +@EqualsAndHashCode(callSuper = true) @Data -public class WxCpCropCheckinOption implements Serializable { +public class WxCpCropCheckinOption extends WxCpCheckinGroupBase implements Serializable { private static final long serialVersionUID = 1725954575430704232L; - /** - * 打卡规则类型,1:固定时间上下班;2:按班次上下班;3:自由上下班 - */ - @SerializedName("grouptype") - private Long groupType; - - /** - * 打卡规则id - */ - @SerializedName("groupid") - private Long groupId; - - /** - * 打卡规则名称 - */ - @SerializedName("groupname") - private String groupName; - - /** - * 打卡时间,当规则类型为排班时没有意义 - */ - @SerializedName("checkindate") - private List checkinDate; - - /** - * 特殊日期-必须打卡日期信息,timestamp表示具体时间 - */ - @SerializedName("spe_workdays") - private List speWorkdays; - - /** - * 特殊日期-不用打卡日期信息, timestamp表示具体时间 - */ - @SerializedName("spe_offdays") - private List speOffDays; - - /** - * 是否同步法定节假日,true为同步,false为不同步,当前排班不支持 - */ - @SerializedName("sync_holidays") - private Boolean syncHolidays; - - /** - * 是否打卡必须拍照,true为必须拍照,false为不必须拍照 - */ - @SerializedName("need_photo") - private Boolean needPhoto; - - /** - * 是否备注时允许上传本地图片,true为允许,false为不允许 - */ - @SerializedName("note_can_use_local_pic") - private Boolean noteCanUseLocalPic; - - /** - * 是否非工作日允许打卡,true为允许,false为不允许 - */ - @SerializedName("allow_checkin_offworkday") - private Boolean allowCheckinOffWorkDay; - - /** - * 是否允许提交补卡申请,true为允许,false为不允许 - */ - @SerializedName("allow_apply_offworkday") - private Boolean allowApplyOffWorkDay; - - /** - * 打卡地点-WiFi打卡信息 - */ - @SerializedName("wifimac_infos") - private List wifiMacInfos; - - /** - * 打卡地点-WiFi打卡信息 - */ - @SerializedName("loc_infos") - private List locInfos; - /** * 打卡人员信息 */ @@ -106,259 +30,94 @@ public class WxCpCropCheckinOption implements Serializable { private Long createTime; /** - * 打卡人员白名单,即不需要打卡人员,需要有设置白名单才能查看 + * 打卡人员白名单,即不需要打卡人员,需要有设置白名单才能查看 */ @SerializedName("white_users") private List whiteUsers; /** - * 打卡方式,0:手机;2:智慧考勤机;3:手机+智慧考勤机 + * 打卡方式,0:手机;2:智慧考勤机;3:手机+智慧考勤机 */ @SerializedName("type") private Integer type; /** - * 打卡方式,0:手机;2:智慧考勤机;3:手机+智慧考勤机 + * 打卡方式,0:手机;2:智慧考勤机;3:手机+智慧考勤机 */ @SerializedName("reporterinfo") private ReporterInfo reporterInfo; /** - * 加班信息,相关信息需要设置后才能显示 + * 加班信息,相关信息需要设置后才能显示 */ @SerializedName("ot_info") private OtInfo otInfo; /** - * 每月最多补卡次数,默认-1表示不限制 + * 每月最多补卡次数,默认-1表示不限制 */ @SerializedName("allow_apply_bk_cnt") private Integer allowApplyBkCnt; /** - * 范围外打卡处理方式,0-视为范围外异常,默认值;1-视为正常外勤;2:不允许范围外打卡 + * 范围外打卡处理方式,0-视为范围外异常,默认值;1-视为正常外勤;2:不允许范围外打卡 */ @SerializedName("option_out_range") private Integer optionOutRange; /** - * 规则创建人userid + * 规则创建人userid */ @SerializedName("create_userid") private String createUserid; /** - * 人脸识别打卡开关,true为启用,false为不启用 + * 人脸识别打卡开关,true为启用,false为不启用 */ @SerializedName("use_face_detect") private Boolean useFaceDetect; /** - * 允许补卡时限,默认-1表示不限制。单位天 + * 允许补卡时限,默认-1表示不限制。单位天 */ @SerializedName("allow_apply_bk_day_limit") private Integer allowApplyBkDayLimit; /** - * 规则最近编辑人userid + * 规则最近编辑人userid */ @SerializedName("update_userid") private String updateUserid; - /** - * 加班信息,相关信息需要设置后才能显示 - */ - @SerializedName("schedulelist") - private List schedulelist; - /** - * 自由签到,上班打卡后xx秒可打下班卡 + * 自由签到,上班打卡后xx秒可打下班卡 */ @SerializedName("offwork_interval_time") private Integer offWorkIntervalTime; - - @Data - public static class CheckinDate implements Serializable{ - private static final long serialVersionUID = -8560643656775167406L; - /** - * 工作日。若为固定时间上下班或自由上下班,则1到6分别表示星期一到星期六,0表示星期日 - */ - @SerializedName("workdays") - private List workdays; - - /** - * 工作日上下班打卡时间信息 - */ - @SerializedName("checkintime") - private List checkinTime; - - /** - * 下班不需要打卡,true为下班不需要打卡,false为下班需要打卡 - */ - @SerializedName("noneed_offwork") - private Boolean noneedOffwork; - - /** - * 打卡时间限制(毫秒) - */ - @SerializedName("limit_aheadtime") - private Long limitAheadtime; - - /** - * 允许迟到时间,单位ms - */ - @SerializedName("flex_on_duty_time") - private Integer flexOnDutyTime; - - /** - * 允许早退时间,单位ms - */ - @SerializedName("flex_off_duty_time") - private Integer flexOffDutyTime; - } - - @Data - public static class CheckinTime implements Serializable{ - - private static final long serialVersionUID = -5507709858609705279L; - /** - * 上班时间,表示为距离当天0点的秒数。 - */ - @SerializedName("work_sec") - private Integer workSec; - - /** - * 下班时间,表示为距离当天0点的秒数。 - */ - @SerializedName("off_work_sec") - private Integer offWorkSec; - - /** - * 上班提醒时间,表示为距离当天0点的秒数。。 - */ - @SerializedName("remind_work_sec") - private Integer remindWorkSec; - - /** - * 下班提醒时间,表示为距离当天0点的秒数。 - */ - @SerializedName("remind_off_work_sec") - private Integer remindOffWorkSec; - } - - @Data - public static class SpeWorkday implements Serializable{ - - private static final long serialVersionUID = -4620710297258742666L; - /** - * 特殊日期-必须打卡日期时间戳 - */ - @SerializedName("timestamp") - private Long timestamp; - - /** - * 特殊日期备注 - */ - @SerializedName("notes") - private String notes; - - /** - * 特殊日期-必须打卡日期-上下班打卡时间 - */ - @SerializedName("checkintime") - private List checkinTime; - } - - @Data - public static class SpeOffDay implements Serializable{ - private static final long serialVersionUID = 9214798931489490993L; - /** - * 特殊日期-不用打卡日期时间戳 - */ - @SerializedName("timestamp") - private Long timestamp; - - /** - * 特殊日期备注 - */ - @SerializedName("notes") - private String notes; - } - - @Data - public static class WifiMacInfo implements Serializable{ - - private static final long serialVersionUID = 6742659716677227089L; - - /** - * WiFi打卡地点名称 - */ - @SerializedName("wifiname") - private String wifiname; - - /** - * WiFi打卡地点MAC地址/bssid - */ - @SerializedName("wifimac") - private String wifimac; - } - - @Data - public static class LocInfo implements Serializable{ - - private static final long serialVersionUID = -5591379191341944101L; - /** - * 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准 - */ - @SerializedName("lat") - private Long lat; - - /** - * 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准 - */ - @SerializedName("lng") - private Long lng; - - /** - * 位置打卡地点名称 - */ - @SerializedName("loc_title") - private String locTitle; - - /** - * 位置打卡地点详情 - */ - @SerializedName("loc_detail") - private String locDetail; - - /** - * 允许打卡范围(米) - */ - @SerializedName("distance") - private Integer distance; - } - + /** + * The type Range. + */ @Data - public static class Range implements Serializable{ + public static class Range implements Serializable { private static final long serialVersionUID = 8940086218556453088L; /** - * 打卡人员中,单个打卡人员节点的userid + * 打卡人员中,单个打卡人员节点的userid */ @SerializedName("party_id") private List partyid; /** - * 打卡人员中,部门节点的id + * 打卡人员中,部门节点的id */ @SerializedName("userid") private List userid; /** - * 打卡人员中,标签节点的标签id + * 打卡人员中,标签节点的标签id */ @SerializedName("tagid") private List tagid; @@ -366,22 +125,28 @@ public static class Range implements Serializable{ } + /** + * The type Reporter info. + */ @Data - public static class ReporterInfo implements Serializable{ + public static class ReporterInfo implements Serializable { private static final long serialVersionUID = 1132450350458936772L; /** - * 汇报对象,每个汇报人用userid表示 + * 汇报对象,每个汇报人用userid表示 */ @SerializedName("reporters") private List reporters; /** - * 汇报对象更新时间 + * 汇报对象更新时间 */ @SerializedName("updatetime") private long updateTime; } + /** + * The type Reporter. + */ @Data public static class Reporter implements Serializable { @@ -391,8 +156,11 @@ public static class Reporter implements Serializable { private String userid; } + /** + * The type Ot info. + */ @Data - public static class OtInfo implements Serializable{ + public static class OtInfo implements Serializable { private static final long serialVersionUID = 1610150484871066199L; @@ -406,398 +174,248 @@ public static class OtInfo implements Serializable{ private Integer type; /** - * 允许工作日加班,true为允许,false为不允许 + * 允许工作日加班,true为允许,false为不允许 */ @SerializedName("allow_ot_workingday") private Boolean allowOtWorkingDay; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("allow_ot_nonworkingday") private Boolean allowOtNonworkingDay; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("otcheckinfo") private OtCheckInfo otcheckinfo; /** - * 更新时间 + * 更新时间 */ @SerializedName("uptime") private Long uptime; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("otapplyinfo") private OtApplyInfo otapplyinfo; } + /** + * The type Ot check info. + */ @Data public static class OtCheckInfo implements Serializable { private static final long serialVersionUID = -2363047492489556390L; /** - * 允许工作日加班-加班开始时间:下班后xx秒开始计算加班,距离最晚下班时间的秒数,例如,1800(30分钟 乘以 60秒),默认值30分钟 + * 允许工作日加班-加班开始时间:下班后xx秒开始计算加班,距离最晚下班时间的秒数,例如,1800(30分钟 乘以 60秒),默认值30分钟 */ @SerializedName("ot_workingday_time_start") private Integer otWorkingDayTimeStart; /** - * 允许工作日加班-最短加班时长:不足xx秒视为未加班,单位秒,默认值30分钟 + * 允许工作日加班-最短加班时长:不足xx秒视为未加班,单位秒,默认值30分钟 */ @SerializedName("ot_workingday_time_min") private Integer otWorkingDayTimeMin; /** - * 允许工作日加班-最长加班时长:超过则视为加班xx秒,单位秒,默认值240分钟 + * 允许工作日加班-最长加班时长:超过则视为加班xx秒,单位秒,默认值240分钟 */ @SerializedName("ot_workingday_time_max") private Integer otWorkingDayTimeMax; /** - * 允许非工作日加班-最短加班时长:不足xx秒视为未加班,单位秒,默认值30分钟 + * 允许非工作日加班-最短加班时长:不足xx秒视为未加班,单位秒,默认值30分钟 */ @SerializedName("ot_nonworkingday_time_min") private Integer otNonworkingDayTimeMin; /** - * 允许非工作日加班-最长加班时长:超过则视为加班xx秒 单位秒,默认值240分钟 + * 允许非工作日加班-最长加班时长:超过则视为加班xx秒 单位秒,默认值240分钟 */ @SerializedName("ot_nonworkingday_time_max") private Integer otNonworkingDayTimeMax; /** - * 非工作日加班,跨天时间,距离当天00:00的秒数 + * 非工作日加班,跨天时间,距离当天00:00的秒数 */ @SerializedName("ot_nonworkingday_spanday_time") private Integer otNonworkingDaySpanDayTime; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("ot_workingday_restinfo") private OtWorkingDayRestInfo otWorkingdayRestinfo; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("ot_nonworkingday_restinfo") private OtNonworkingDayRestInfo otNonworkingdayRestinfo; } + /** + * The type Ot working day rest info. + */ @Data - public static class OtWorkingDayRestInfo implements Serializable{ + public static class OtWorkingDayRestInfo implements Serializable { private static final long serialVersionUID = -4011047369711928306L; /** - * 工作日加班-休息扣除类型:0-不开启扣除;1-指定休息时间扣除;2-按加班时长扣除休息时间 + * 工作日加班-休息扣除类型:0-不开启扣除;1-指定休息时间扣除;2-按加班时长扣除休息时间 */ @SerializedName("type") private Integer type; /** - * 工作日加班-指定休息时间配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为1时有意义 + * 工作日加班-指定休息时间配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为1时有意义 */ @SerializedName("fix_time_rule") private FixTimeRule fixTimeRule; /** - * 工作日加班-按加班时长扣除配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为2时有意义 + * 工作日加班-按加班时长扣除配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为2时有意义 */ @SerializedName("cal_ottime_rule") private CalOtTimeRule calOttimeRule; } + /** + * The type Fix time rule. + */ @Data - public static class FixTimeRule implements Serializable{ + public static class FixTimeRule implements Serializable { private static final long serialVersionUID = 5709478500196619664L; /** - * 工作日加班-指定休息时间的开始时间, 距离当天00:00的秒数 + * 工作日加班-指定休息时间的开始时间, 距离当天00:00的秒数 */ @SerializedName("fix_time_begin_sec") private Integer fixTimeBeginSec; /** - * 工作日加班-指定休息时间的结束时间, 距离当天00:00的秒数 + * 工作日加班-指定休息时间的结束时间, 距离当天00:00的秒数 */ @SerializedName("fix_time_end_sec") private Integer fixTimeEndSec; } + /** + * The type Cal ot time rule. + */ @Data public static class CalOtTimeRule implements Serializable { private static final long serialVersionUID = -2407839982631243413L; /** - * 工作日加班-按加班时长扣除条件信息 + * 工作日加班-按加班时长扣除条件信息 */ @SerializedName("items") private List items; } + + /** + * The type Item. + */ @Data - public static class Item implements Serializable{ + public static class Item implements Serializable { private static final long serialVersionUID = 5235770378506228461L; /** - * 加班满-时长(秒) + * 加班满-时长(秒) */ @SerializedName("ot_time") private Integer otTime; /** - * 对应扣除-时长(秒) + * 对应扣除-时长(秒) */ @SerializedName("rest_time") private Integer restTime; } + /** + * The type Ot nonworking day rest info. + */ @Data - public static class OtNonworkingDayRestInfo implements Serializable{ + public static class OtNonworkingDayRestInfo implements Serializable { private static final long serialVersionUID = 3773846077049838088L; /** - * 非工作日加班-休息扣除类型:0-不开启扣除;1-指定休息时间扣除;2-按加班时长扣除休息时间 + * 非工作日加班-休息扣除类型:0-不开启扣除;1-指定休息时间扣除;2-按加班时长扣除休息时间 */ @SerializedName("type") private Integer type; /** - * 非工作日加班-指定休息时间配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为1时有意义 + * 非工作日加班-指定休息时间配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为1时有意义 */ @SerializedName("fix_time_rule") private FixTimeRule fixTimeRule; /** - * 非工作日加班-按加班时长扣除配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为2时有意义 + * 非工作日加班-按加班时长扣除配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为2时有意义 */ @SerializedName("cal_ottime_rule") private CalOtTimeRule calOttimeRule; } + /** + * The type Ot apply info. + */ @Data - public static class OtApplyInfo implements Serializable{ + public static class OtApplyInfo implements Serializable { private static final long serialVersionUID = 961217471918884103L; /** - * 允许工作日加班,true为允许,false为不允许 + * 允许工作日加班,true为允许,false为不允许 */ @SerializedName("allow_ot_workingday") private Boolean allowOtWorkingDay; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("allow_ot_nonworkingday") private Boolean allowOtNonworkingDay; /** - * 更新时间 + * 更新时间 */ @SerializedName("uptime") private Long uptime; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("ot_workingday_restinfo") private OtWorkingDayRestInfo otWorkingdayRestinfo; /** - * 允许非工作日加班,true为允许,flase为不允许 + * 允许非工作日加班,true为允许,flase为不允许 */ @SerializedName("ot_nonworkingday_restinfo") private OtNonworkingDayRestInfo otNonworkingdayRestinfo; /** - * 非工作日加班,跨天时间,距离当天00:00的秒数 + * 非工作日加班,跨天时间,距离当天00:00的秒数 */ @SerializedName("ot_nonworkingday_spanday_time") private Integer otNonworkingDaySpanDayTime; } - - @Data - public static class Schedule implements Serializable{ - - private static final long serialVersionUID = -2461113644925307266L; - - /** - * 班次id - */ - @SerializedName("schedule_id") - private Integer scheduleId; - - /** - * 班次名称 - */ - @SerializedName("schedule_name") - private String scheduleName; - - /** - * 班次上下班时段信息 - */ - @SerializedName("time_section") - private List timeSection; - - /** - * 允许提前打卡时间 - */ - @SerializedName("limit_aheadtime") - private Long limitAheadTime; - - /** - * 下班xx秒后不允许打下班卡 - */ - @SerializedName("limit_offtime") - private Integer limitOffTime; - - /** - * 下班不需要打卡 - */ - @SerializedName("noneed_offwork") - private Boolean noNeedOffWork; - - /** - * 是否允许弹性时间 - */ - @SerializedName("allow_flex") - private Boolean allowFlex; - - /** - * 允许迟到时间 - */ - @SerializedName("flex_on_duty_time") - private Integer flexOnDutyTime; - - /** - * 允许早退时间 - */ - @SerializedName("flex_off_duty_time") - private Integer flexOffDutyTime; - - /** - * 非工作日加班,跨天时间,距离当天00:00的秒数 - */ - @SerializedName("late_rule") - private LateRule lateRule; - - /** - * 最早可打卡时间限制 - */ - @SerializedName("max_allow_arrive_early") - private Integer maxAllowArriveEarly; - - /** - * 最晚可打卡时间限制,max_allow_arrive_early、max_allow_arrive_early与flex_on_duty_time、flex_off_duty_time互斥,当设置其中一组时,另一组数值置0 - */ - @SerializedName("max_allow_arrive_late") - private Integer maxAllowArriveLate; - - } - - - @Data - public static class TimeSection implements Serializable { - private static final long serialVersionUID = 7497252128339062724L; - - /** - * 时段id,为班次中某一堆上下班时间组合的id - */ - @SerializedName("time_id") - private Integer timeId; - - /** - * 上班时间,表示为距离当天0点的秒数。 - */ - @SerializedName("work_sec") - private Integer workSec; - - /** - * 下班时间,表示为距离当天0点的秒数。 - */ - @SerializedName("off_work_sec") - private Integer offWorkSec; - - /** - * 上班提醒时间,表示为距离当天0点的秒数。 - */ - @SerializedName("remind_work_sec") - private Long remindWorkSec; - - /** - * 下班提醒时间,表示为距离当天0点的秒数。 - */ - @SerializedName("remind_off_work_sec") - private Integer remindOffWorkSec; - - /** - * 休息开始时间,仅单时段支持,距离0点的秒 - */ - @SerializedName("rest_begin_time") - private Integer restBeginTime; - - /** - * 休息结束时间,仅单时段支持,距离0点的秒 - */ - @SerializedName("rest_end_time") - private Integer restEndTime; - - /** - * 是否允许休息 - */ - @SerializedName("allow_rest") - private Boolean allowRest; - } - - - @Data - public static class LateRule implements Serializable{ - - private static final long serialVersionUID = 5604969713950037053L; - - - /** - * 是否允许超时下班(下班晚走次日晚到)允许时onwork_flex_time,offwork_after_time才有意义 - */ - @SerializedName("allow_offwork_after_time") - private Boolean allowOffWorkAfterTime; - - /** - * 迟到规则时间 - */ - @SerializedName("timerules") - private List timerules; - } - - @Data - public static class TimeRule implements Serializable{ - - private static final long serialVersionUID = 5680614050081598333L; - - /** - * 晚走的时间 距离最晚一个下班的时间单位:秒 - */ - @SerializedName("offwork_after_time") - private Integer offWorkAfterTime; - - /** - * 第二天第一个班次允许迟到的弹性时间单位:秒 - */ - @SerializedName("onwork_flex_time") - private Integer onWorkFlexTime; - - } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpDialRecord.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpDialRecord.java index f3cf7d9881..f8c0956e2c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpDialRecord.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpDialRecord.java @@ -9,8 +9,7 @@ /** * 公费电话拨打记录. * - * @author Element - * @date 2019-04-06 15:38 + * @author Element created on 2019-04-06 15:38 */ @Data public class WxCpDialRecord implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpGetApprovalData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpGetApprovalData.java new file mode 100644 index 0000000000..99d24b75ad --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpGetApprovalData.java @@ -0,0 +1,148 @@ +package me.chanjar.weixin.cp.bean.oa; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 获取审批数据(旧). + * + * @author Wang_Wong + */ +@Data +public class WxCpGetApprovalData extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 7387181805254287159L; + + @SerializedName("count") + private Integer count; + + @SerializedName("total") + private Integer total; + + @SerializedName("next_spnum") + private Long nextSpNum; + + @SerializedName("data") + private List data; + + /** + * The type Approval data. + */ + @Getter + @Setter + public static class ApprovalData implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("spname") + private String spName; + + @SerializedName("apply_name") + private String applyName; + + @SerializedName("apply_org") + private String applyOrg; + + @SerializedName("approval_name") + private List approvalName; + + @SerializedName("notify_name") + private List notifyName; + + @SerializedName("mediaids") + private List mediaIds; + + @SerializedName("sp_status") + private Integer spStatus; + + @SerializedName("sp_num") + private Long spNum; + + @SerializedName("apply_time") + private Long applyTime; + + @SerializedName("apply_user_id") + private String applyUserId; + + @SerializedName("expense") + private Expense expense; + + @SerializedName("comm") + private Comm comm; + + } + + /** + * The type Expense. + */ + @Getter + @Setter + public static class Expense implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("expense_type") + private Integer expenseType; + + @SerializedName("reason") + private String reason; + + @SerializedName("item") + private List item; + + } + + /** + * The type Comm. + */ + @Getter + @Setter + public static class Comm implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("apply_data") + private String applyData; + + } + + /** + * The type Item. + */ + @Getter + @Setter + public static class Item implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("expenseitem_type") + private Integer expenseItemType; + + @SerializedName("time") + private Long time; + + @SerializedName("sums") + private Integer sums; + + @SerializedName("reason") + private String reason; + + } + + /** + * From json wx cp get approval data. + * + * @param json the json + * @return the wx cp get approval data + */ + public static WxCpGetApprovalData fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpGetApprovalData.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequest.java index 81dd6b45b0..8aebb66003 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequest.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequest.java @@ -12,8 +12,7 @@ /** * 提交审批申请 请求对象类. * - * @author Binary Wang - * @date 2020-07-18 + * @author Binary Wang created on 2020-07-18 */ @Data @Accessors(chain = true) @@ -38,6 +37,12 @@ public class WxCpOaApplyEventRequest implements Serializable { @SerializedName("use_template_approver") private Integer useTemplateApprover; + /** + * 提单者提单部门id,不填默认为主部门 + */ + @SerializedName("choose_department") + private Integer chooseDepartment; + /** * 审批流程信息,用于指定审批申请的审批流程,支持单人审批、多人会签、多人或签,可能有多个审批节点,仅use_template_approver为0时生效。 */ @@ -68,10 +73,18 @@ public class WxCpOaApplyEventRequest implements Serializable { @SerializedName("summary_list") private List summaryList; + /** + * To json string. + * + * @return the string + */ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } + /** + * The type Approver. + */ @Data @Accessors(chain = true) public static class Approver implements Serializable { @@ -89,6 +102,9 @@ public static class Approver implements Serializable { private String[] userIds; } + /** + * The type Apply data. + */ @Data @Accessors(chain = true) public static class ApplyData implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApprovalTemplate.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApprovalTemplate.java new file mode 100644 index 0000000000..51c997d08a --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApprovalTemplate.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.cp.bean.oa; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateContent; +import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateTitle; + +import java.io.Serializable; +import java.util.List; + +/** + * 新增/更新审批模板的请求对象 + * + * @author yiyingcanfeng + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxCpOaApprovalTemplate implements Serializable { + private static final long serialVersionUID = 8332120725354015143L; + + /** + * 仅更新审批模版时需要提供 + */ + @SerializedName("template_id") + private String templateId; + + @SerializedName("template_name") + private List templateName; + + @SerializedName("template_content") + private TemplateContent templateContent; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpTemplateResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApprovalTemplateResult.java similarity index 87% rename from weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpTemplateResult.java rename to weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApprovalTemplateResult.java index b8dd2dbe91..afa621e2a9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpTemplateResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApprovalTemplateResult.java @@ -11,10 +11,10 @@ /** * 审批模板详情 * - * @author gyv12345@163.com + * @author gyv12345 @163.com */ @Data -public class WxCpTemplateResult implements Serializable { +public class WxCpOaApprovalTemplateResult implements Serializable { private static final long serialVersionUID = 6690547131189343887L; @SerializedName("errcode") diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaSchedule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaSchedule.java index 2e8315dbde..53229cd81e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaSchedule.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaSchedule.java @@ -12,8 +12,7 @@ /** * 日程信息bean. * - * @author Binary Wang - * @date 2020-12-25 + * @author Binary Wang created on 2020-12-25 */ @Data @Accessors(chain = true) @@ -90,6 +89,9 @@ public String toJson() { return WxCpGsonBuilder.create().toJson(this); } + /** + * The type Attendee. + */ @Data @Accessors(chain = true) public static class Attendee implements Serializable { @@ -112,6 +114,9 @@ public static class Attendee implements Serializable { private Integer responseStatus; } + /** + * The type Reminder. + */ @Data @Accessors(chain = true) public static class Reminder implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpRecordSpStatus.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpRecordSpStatus.java index 206a0aa04e..d6be02d40e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpRecordSpStatus.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpRecordSpStatus.java @@ -1,14 +1,18 @@ package me.chanjar.weixin.cp.bean.oa; import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Getter; /** * 审批记录(节点)分支审批状态 - * - * 1-审批中;2-已同意;3-已驳回;4-已转审 + *

+ * 1-审批中;2-已同意;3-已驳回;4-已转审;11-已退回 * * @author element */ +@AllArgsConstructor +@Getter public enum WxCpRecordSpStatus { /** @@ -30,12 +34,23 @@ public enum WxCpRecordSpStatus { * 已转审 */ @SerializedName("4") - TURNED(4); - - private Integer status; + TURNED(4), + /** + * 已退回 + */ + @SerializedName("11") + WITHDRAWN(11), + /** + * 12-已加签 + */ + @SerializedName("12") + SIGNED(12), + /** + * 13-已同意并加签 + */ + @SerializedName("13") + PASSEDANDSIGNED(13); - private WxCpRecordSpStatus(Integer status) { - this.status = status; - } + private final Integer status; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java index 3d0d1f87f5..13329659ec 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java @@ -32,8 +32,11 @@ public class WxCpSetCheckinSchedule implements Serializable { private Integer yearmonth; + /** + * The type Item. + */ @Data - public static class Item implements Serializable{ + public static class Item implements Serializable { private static final long serialVersionUID = -918057757709951513L; @@ -44,7 +47,7 @@ public static class Item implements Serializable{ private String userid; /** - * 要设置的天日期,取值在1-31之间。联合yearmonth组成唯一日期 比如20201205 + * 要设置的天日期,取值在1-31之间。联合yearmonth组成唯一日期 比如20201205 */ @SerializedName("day") private Integer day; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSpStatus.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSpStatus.java index c3d8005f50..029b7c144e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSpStatus.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSpStatus.java @@ -46,9 +46,9 @@ public enum WxCpSpStatus { @SerializedName("10") ALREADY_PAY(10); - private Integer status; + private final Integer status; - private WxCpSpStatus(Integer status) { + WxCpSpStatus(Integer status) { this.status = status; } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpUserVacationQuota.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpUserVacationQuota.java new file mode 100644 index 0000000000..4195045546 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpUserVacationQuota.java @@ -0,0 +1,64 @@ +package me.chanjar.weixin.cp.bean.oa; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 成员假期余额信息. + * + * @author Wang_Wong + */ +@Data +public class WxCpUserVacationQuota extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 7387181805254287157L; + + @SerializedName("lists") + private List lists; + + /** + * The type Vacation quota. + */ + @Getter + @Setter + public static class VacationQuota implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("id") + private Integer id; + + @SerializedName("assignduration") + private Integer assignDuration; + + @SerializedName("usedduration") + private Integer usedDuration; + + @SerializedName("leftduration") + private Integer leftDuration; + + @SerializedName("vacationname") + private String vacationName; + + } + + /** + * From json wx cp user vacation quota. + * + * @param json the json + * @return the wx cp user vacation quota + */ + public static WxCpUserVacationQuota fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpUserVacationQuota.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ApplyDataContent.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ApplyDataContent.java index f86ab966e3..3ce66ea361 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ApplyDataContent.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ApplyDataContent.java @@ -8,6 +8,8 @@ import java.util.List; /** + * The type Apply data content. + * * @author element */ @Data diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentTitle.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentTitle.java index 24d5fafc2d..cfd0702a27 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentTitle.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentTitle.java @@ -5,6 +5,8 @@ import java.io.Serializable; /** + * The type Content title. + * * @author element */ @Data diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentValue.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentValue.java index 1ad07bf2a8..db1e4cedd0 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentValue.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/applydata/ContentValue.java @@ -8,6 +8,8 @@ import java.util.List; /** + * The type Content value. + * * @author element */ @Data @@ -35,10 +37,22 @@ public class ContentValue implements Serializable { private List children; + @SerializedName("related_approval") + private List relatedApproval; + private Attendance attendance; private Vacation vacation; + @SerializedName("date_range") + private Attendance.DataRange dateRange; + + @SerializedName("punch_correction") + private PunchCorrection punchCorrection; + + /** + * The type Date. + */ @Data public static class Date implements Serializable { private static final long serialVersionUID = -6181554080062231138L; @@ -48,12 +62,18 @@ public static class Date implements Serializable { private String timestamp; } + /** + * The type Selector. + */ @Data public static class Selector implements Serializable { private static final long serialVersionUID = 7305458759126951773L; private String type; private List

  *  任务卡片按钮
  *  Created by Jeff on 2019-05-16.
  * 
* - * @author Jeff - * @date 2019-05-16 + * @author Jeff created on 2019-05-16 */ @Data @Builder @@ -22,7 +21,7 @@ @AllArgsConstructor public class TaskCardButton implements Serializable { private static final long serialVersionUID = -4301684507150486556L; - + private String key; private String name; private String replaceName; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/ActionMenuItem.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/ActionMenuItem.java new file mode 100644 index 0000000000..2b14ae7a61 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/ActionMenuItem.java @@ -0,0 +1,45 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 卡片右上角更多操作按钮点击后出现的操作列表,列表长度取值范围为 [1, 3] + * + * @author xiaohe created on 2022-03-06 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ActionMenuItem implements Serializable { + private static final long serialVersionUID = 400885585614100693L; + + /** + * 操作的描述文案 + */ + private String text; + + /** + * 按钮key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复 + */ + private String key; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject btnObject = new JsonObject(); + btnObject.addProperty("text", this.getText()); + btnObject.addProperty("key", this.getKey()); + return btnObject; + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/CheckboxOption.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/CheckboxOption.java new file mode 100644 index 0000000000..c950ab09ef --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/CheckboxOption.java @@ -0,0 +1,53 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 按钮列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + * + * @author yzts created on 2021/9/22 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CheckboxOption implements Serializable { + private static final long serialVersionUID = 5405702239190050250L; + + /** + * 选项id,用户提交选项后,会产生回调事件,回调事件会带上该id值表示该选项,最长支持128字节,不可重复 + * 必填 + */ + private String id; + /** + * 选项文案描述,建议不超过17个字. + * 必填 + */ + private String text; + /** + * 该选项是否要默认选中 + * 必填 + */ + private Boolean is_checked; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject optionJson = new JsonObject(); + optionJson.addProperty("id", this.getId()); + optionJson.addProperty("text", this.getText()); + if (null != this.getIs_checked()) { + optionJson.addProperty("is_checked", this.getIs_checked()); + } + return optionJson; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/HorizontalContent.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/HorizontalContent.java new file mode 100644 index 0000000000..60a7c475d6 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/HorizontalContent.java @@ -0,0 +1,79 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + * + * @author yzts created on 2021/9/22 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HorizontalContent implements Serializable { + + private static final long serialVersionUID = -2209656515382964372L; + + /** + * 链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件 + */ + private Integer type; + /** + * 二级标题,建议不超过5个字 + */ + private String keyname; + /** + * 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字 + */ + private String value; + /** + * 链接跳转的url,horizontal_content_list.type是1时必填 + */ + private String url; + /** + * 附件的media_id,horizontal_content_list.type是2时必填 + */ + private String media_id; + + /** + * 成员详情的userid,horizontal_content_list.type是3时必填 + */ + private String userid; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject hContentJson = new JsonObject(); + + if (null != this.getType()) { + hContentJson.addProperty("type", this.getType()); + } + hContentJson.addProperty("keyname", this.getKeyname()); + + if (StringUtils.isNotBlank(this.getValue())) { + hContentJson.addProperty("value", this.getValue()); + } + if (StringUtils.isNotBlank(this.getUrl())) { + hContentJson.addProperty("url", this.getUrl()); + } + if (StringUtils.isNotBlank(this.getMedia_id())) { + hContentJson.addProperty("media_id", this.getMedia_id()); + } + if (StringUtils.isNotBlank(this.getUserid())) { + hContentJson.addProperty("userid", this.getUserid()); + } + return hContentJson; + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/MultipleSelect.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/MultipleSelect.java new file mode 100644 index 0000000000..c9f15e6d74 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/MultipleSelect.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.List; + +/** + * 下拉式的选择器列表,multiple_interaction类型的卡片该字段不可为空,一个消息最多支持 3 个选择器 + * + * @author yzts created on 2021/9/22 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MultipleSelect implements Serializable { + private static final long serialVersionUID = 3446092543065698516L; + + /** + * 下拉式的选择器题目的key,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节,不可重复 + */ + private String question_key; + /** + * 下拉式的选择器上面的title + */ + private String title; + /** + * 默认选定的id,不填或错填默认第一个 + */ + private String selected_id; + + /** + * 选项列表,下拉选项不超过 10 个,最少1个 + */ + private List options; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject selectJson = new JsonObject(); + + selectJson.addProperty("question_key", this.getQuestion_key()); + + if (StringUtils.isNotBlank(this.getTitle())) { + selectJson.addProperty("title", this.getTitle()); + } + if (StringUtils.isNotBlank(this.getSelected_id())) { + selectJson.addProperty("selected_id", this.getSelected_id()); + } +// select_list + List options = this.getOptions(); + if (null != options && options.size() > 0) { + JsonArray optionJsonArray = new JsonArray(); + for (CheckboxOption option : this.getOptions()) { + JsonObject tempObject = option.toJson(); + optionJsonArray.add(tempObject); + } + selectJson.add("option_list", optionJsonArray); + } + + return selectJson; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/QuoteArea.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/QuoteArea.java new file mode 100644 index 0000000000..7caba68e33 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/QuoteArea.java @@ -0,0 +1,78 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * 引用文献样式 + * + * @author zp created on 2022/1/2 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QuoteArea implements Serializable { + + private static final long serialVersionUID = -2209656515382964356L; + + /** + * 非必填 引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序 + */ + private Integer type; + /** + * 点击跳转的url,quote_area.type是1时必填 + */ + private String url; + /** + * 点击跳转的小程序的appid,必须是与当前应用关联的小程序,quote_area.type是2时必填 + */ + private String appid; + /** + * 点击跳转的小程序的pagepath,quote_area.type是2时选填 + */ + private String pagepath; + /** + * 引用文献样式的标题 + */ + private String title; + /** + * 引用文献样式的引用文案 + */ + private String quoteText; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject quoteAreaJson = new JsonObject(); + if (null != this.getType()) { + quoteAreaJson.addProperty("type", this.getType()); + } + if (StringUtils.isNotBlank(this.getUrl())) { + quoteAreaJson.addProperty("url", this.getUrl()); + } + if (StringUtils.isNotBlank(this.getAppid())) { + quoteAreaJson.addProperty("appid", this.getAppid()); + } + if (StringUtils.isNotBlank(this.getPagepath())) { + quoteAreaJson.addProperty("pagepath", this.getPagepath()); + } + if (StringUtils.isNotBlank(this.getTitle())) { + quoteAreaJson.addProperty("title", this.getTitle()); + } + if (StringUtils.isNotBlank(this.getQuoteText())) { + quoteAreaJson.addProperty("quote_text", this.getQuoteText()); + } + return quoteAreaJson; + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButton.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButton.java new file mode 100644 index 0000000000..bbb6b73901 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButton.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 按钮列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + * + * @author yzts created on 2021/9/22 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TemplateCardButton implements Serializable { + private static final long serialVersionUID = -4826551822490837002L; + + /** + * 按钮文案,建议不超过10个字 + */ + private String text; + /** + * 按钮样式,目前可填1~4,不填或错填默认1 + */ + private Integer style; + /** + * 按钮key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复 + */ + private String key; + + /** + * 按钮点击事件类型,0 或不填代表回调点击事件,1 代表跳转url + */ + private int type; + + /** + * 跳转事件的url,button_list.type是1时必填 + */ + private String url; + + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject btnObject = new JsonObject(); + + + btnObject.addProperty("text", this.getText()); + + if (null != this.getStyle()) { + btnObject.addProperty("style", this.getStyle()); + } + btnObject.addProperty("key", this.getKey()); + btnObject.addProperty("type", this.getType()); + if (null != this.getUrl()) { + btnObject.addProperty("url", this.getUrl()); + } + return btnObject; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButtonSelection.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButtonSelection.java new file mode 100644 index 0000000000..f279eb2274 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButtonSelection.java @@ -0,0 +1,58 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.List; + +/** + * @author chenjie03 + * @version 1.0 + * @since 2022/11/4 11:54 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TemplateCardButtonSelection implements Serializable { + private String questionKey; + private String title; + private String selectedId; + private List optionList; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject btnObject = new JsonObject(); + + if (StringUtils.isNotBlank(this.questionKey)) { + btnObject.addProperty("question_key", this.questionKey); + } + if (StringUtils.isNotBlank(this.title)) { + btnObject.addProperty("title", this.title); + } + if (StringUtils.isNotBlank(this.selectedId)) { + btnObject.addProperty("selected_id", this.selectedId); + } + + if (this.optionList != null && this.optionList.size() > 0) { + JsonArray optionJsonArray = new JsonArray(); + for (TemplateCardButtonSelectionOption jump : this.getOptionList()) { + JsonObject tempObject = jump.toJson(); + optionJsonArray.add(tempObject); + } + btnObject.add("option_list", optionJsonArray); + } + return btnObject; + } +} + diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButtonSelectionOption.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButtonSelectionOption.java new file mode 100644 index 0000000000..338a739f39 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardButtonSelectionOption.java @@ -0,0 +1,42 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * @author chenjie03 + * @version 1.0 + * @since 2022/11/4 11:57 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TemplateCardButtonSelectionOption implements Serializable { + private String id; + private String text; + + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject btnObject = new JsonObject(); + + if (StringUtils.isNotBlank(this.id)) { + btnObject.addProperty("id", this.id); + } + if (StringUtils.isNotBlank(this.text)) { + btnObject.addProperty("text", this.text); + } + return btnObject; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardImageTextArea.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardImageTextArea.java new file mode 100644 index 0000000000..0f12e5d17d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardImageTextArea.java @@ -0,0 +1,53 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * @author chenjie03 + * @version 1.0 + * @since 2022/11/4 12:12 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TemplateCardImageTextArea implements Serializable { + private Integer type; + private String url; + private String title; + private String desc; + private String imageUrl; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject btnObject = new JsonObject(); + + if (null != this.type) { + btnObject.addProperty("type", this.type); + } + if (StringUtils.isNotBlank(this.url)) { + btnObject.addProperty("url", this.url); + } + if (StringUtils.isNotBlank(this.title)) { + btnObject.addProperty("title", this.title); + } + if (StringUtils.isNotBlank(this.desc)) { + btnObject.addProperty("desc", this.desc); + } + if (StringUtils.isNotBlank(this.imageUrl)) { + btnObject.addProperty("image_url", this.imageUrl); + } + return btnObject; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardJump.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardJump.java new file mode 100644 index 0000000000..6b20fba69f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/TemplateCardJump.java @@ -0,0 +1,70 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + * + * @author yzts created on 2021/9/22 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TemplateCardJump implements Serializable { + private static final long serialVersionUID = 4440089247405968074L; + + /** + * 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序 + */ + private Integer type; + /** + * 跳转链接样式的文案内容,建议不超过18个字 + */ + private String title; + /** + * 跳转链接的url,jump_list.type是1时必填 + */ + private String url; + /** + * 跳转链接的小程序的appid,必须是与当前应用关联的小程序,jump_list.type是2时必填 + */ + private String appid; + /** + * 跳转链接的小程序的pagepath,jump_list.type是2时选填 + */ + private String pagepath; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject hContentJson = new JsonObject(); + + if (null != this.getType()) { + hContentJson.addProperty("type", this.getType()); + } + hContentJson.addProperty("title", this.getTitle()); + + if (StringUtils.isNotBlank(this.getUrl())) { + hContentJson.addProperty("url", this.getUrl()); + } + if (StringUtils.isNotBlank(this.getAppid())) { + hContentJson.addProperty("appid", this.getAppid()); + } + if (StringUtils.isNotBlank(this.getPagepath())) { + hContentJson.addProperty("pagepath", this.getPagepath()); + } + return hContentJson; + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/VerticalContent.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/VerticalContent.java new file mode 100644 index 0000000000..1b192edcba --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/templatecard/VerticalContent.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.cp.bean.templatecard; + +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4 + * + * @author yzts created on 2021/9/22 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VerticalContent implements Serializable { + private static final long serialVersionUID = -1383852553854573558L; + + /** + * 卡片二级标题,建议不超过38个字.必填字段 + */ + private String title; + /** + * 二级普通文本,建议不超过160个字 + */ + private String desc; + + /** + * To json json object. + * + * @return the json object + */ + public JsonObject toJson() { + JsonObject vContentJson = new JsonObject(); + + vContentJson.addProperty("title", this.getTitle()); + + if (StringUtils.isNotBlank(this.getDesc())) { + vContentJson.addProperty("desc", this.getDesc()); + } + return vContentJson; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/user/WxCpDeptUserResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/user/WxCpDeptUserResult.java new file mode 100644 index 0000000000..f5904424b8 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/user/WxCpDeptUserResult.java @@ -0,0 +1,77 @@ +package me.chanjar.weixin.cp.bean.user; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 获取成员ID列表返回参数 + * + * @author Wang_Wong created on 2022/08/09 + */ +@Data +public class WxCpDeptUserResult extends WxCpBaseResp { + private static final long serialVersionUID = 1420065684270213578L; + + @SerializedName("next_cursor") + private String nextCursor; + + @SerializedName("dept_user") + private List deptUser; + + /** + * The type Dept user list. + */ + @Getter + @Setter + public static class DeptUserList implements Serializable { + private static final long serialVersionUID = 1420065684270213578L; + + @SerializedName("userid") + private String userId; + + @SerializedName("department") + private Long department; + + /** + * From json dept user list. + * + * @param json the json + * @return the dept user list + */ + public static DeptUserList fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, DeptUserList.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + + } + + /** + * From json wx cp dept user result. + * + * @param json the json + * @return the wx cp dept user result + */ + public static WxCpDeptUserResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpDeptUserResult.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchKeyData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchKeyData.java index 5bcd9cf133..b11b9fb861 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchKeyData.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchKeyData.java @@ -5,9 +5,10 @@ import java.io.Serializable; /** - * @author songshiyu - * @date : create in 10:21 2020/9/28 - * @description: 关键数据型模板类型 + * The type Work bench key data. + * + * @author songshiyu created on : create in 10:21 2020/9/28 + * 关键数据型模板类型 */ @Data public class WorkBenchKeyData implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchList.java index c03e724732..de4dc72929 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchList.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/workbench/WorkBenchList.java @@ -5,22 +5,25 @@ import java.io.Serializable; /** + * 列表模板类型 * + * * @author songshiyu - * @date : create in 10:21 2020/9/28 - * @description: 列表模板类型 + * created at 10:21 2020/9/28 */ @Data public class WorkBenchList implements Serializable { - /* + private static final long serialVersionUID = -7892708831294949257L; + + /** * 列表显示文字,不超过128个字节 - * */ + */ private String title; - /* + /** * 点击跳转url,若不填且应用设置了主页url,则跳转到主页url,否则跳到应用会话窗口 - * */ + */ private String jumpUrl; - /* + /** * 若应用为小程序类型,该字段填小程序pagepath,若未设置,跳到小程序主页 - * */ + */ private String pagePath; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java index 02a7af880e..36203aab11 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java @@ -174,6 +174,20 @@ public interface WxCpConfigStorage { */ String getAesKey(); + /** + * 企微会话存档私钥 + * + * @return msg audit pri key + */ + String getMsgAuditPriKey(); + + /** + * 获取企微会话存档系统库 绝对路径 + * + * @return msg audit lib path + */ + String getMsgAuditLibPath(); + /** * Gets expires time. * @@ -243,4 +257,10 @@ public interface WxCpConfigStorage { * @return key webhook key */ String getWebhookKey(); + + /** + * 获取会话存档的secret + * @return msg audit secret + */ + String getMsgAuditSecret(); } 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 new file mode 100644 index 0000000000..07acb189a8 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java @@ -0,0 +1,143 @@ +package me.chanjar.weixin.cp.config; + +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; + +import java.util.concurrent.locks.Lock; + +/** + * 微信客户端(企业互联)配置 + * + * @author libo + */ +public interface WxCpCorpGroupConfigStorage { + /** + * 设置企业微信服务器 baseUrl. + * 默认值是 https://qyapi.weixin.qq.com , 如果使用默认值,则不需要调用 setBaseApiUrl + * + * @param baseUrl 企业微信服务器 Url + */ + void setBaseApiUrl(String baseUrl); + + /** + * 读取企业微信 API Url. + * 支持私有化企业微信服务器. + * + * @param path the path + * @return the api url + */ + String getApiUrl(String path); + + /** + * Update corp access token. + * + * @param corpId + * @param agentId + * @param corpAccessToken the corp access token + * @param expiresInSeconds the expires in seconds + */ + void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds); + + /** + * 授权企业的access token相关 + * + * @param corpId the corp id + * @param agentId + * @return the access token + */ + String getCorpAccessToken(String corpId, Integer agentId); + + /** + * Gets access token entity. + * + * @param corpId the corp id + * @param agentId + * @return the access token entity + */ + WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId); + + /** + * Is access token expired boolean. + * + * @param corpId the corp id + * @param agentId + * @return the boolean + */ + boolean isCorpAccessTokenExpired(String corpId, Integer agentId); + + /** + * Expire access token. + * + * @param corpId the corp id + * @param agentId + */ + void expireCorpAccessToken(String corpId, Integer agentId); + + /** + * 网络代理相关 + * + * @return the http proxy host + */ + String getHttpProxyHost(); + + /** + * Gets http proxy port. + * + * @return the http proxy port + */ + int getHttpProxyPort(); + + /** + * Gets http proxy username. + * + * @return the http proxy username + */ + String getHttpProxyUsername(); + + /** + * Gets http proxy password. + * + * @return the http proxy password + */ + String getHttpProxyPassword(); + + /** + * Gets apache http client builder. + * + * @return the apache http client builder + */ + ApacheHttpClientBuilder getApacheHttpClientBuilder(); + + /** + * Auto refresh token boolean. + * + * @return the boolean + */ + boolean autoRefreshToken(); + + /** + * Gets access token lock. + * + * @param corpId the corp id + * @return the access token lock + */ + Lock getCorpAccessTokenLock(String corpId, Integer agentId); + + void setCorpId(String corpId); + + void setAgentId(Integer agentId); + + /** + * Gets corp id. + * + * @return the corp id + */ + String getCorpId(); + + /** + * Gets agent id. + * + * @return the agent id + */ + Integer getAgentId(); +} 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 606c8997e2..72f143fc37 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 @@ -257,8 +257,6 @@ public interface WxCpTpConfigStorage { */ void updateAuthSuiteJsApiTicket(String authCorpId, String jsApiTicket, int expiredInSeconds); - ; - /** * Is provider token expired boolean. * diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImpl.java new file mode 100644 index 0000000000..780e722c30 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImpl.java @@ -0,0 +1,183 @@ +package me.chanjar.weixin.cp.config.impl; + +import lombok.NonNull; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.redis.WxRedisOps; +import org.apache.commons.lang3.StringUtils; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; + +/** + * @author yl + * created on 2023/04/23 + */ +public abstract class AbstractWxCpInRedisConfigImpl extends WxCpDefaultConfigImpl { + private static final long serialVersionUID = 7157341535439380615L; + /** + * The constant LOCK_KEY. + */ + protected static final String LOCK_KEY = "wechat_cp_lock:"; + /** + * The constant CP_ACCESS_TOKEN_KEY. + */ + protected static final String CP_ACCESS_TOKEN_KEY = "wechat_cp_access_token_key:"; + /** + * The constant CP_JSAPI_TICKET_KEY. + */ + protected static final String CP_JSAPI_TICKET_KEY = "wechat_cp_jsapi_ticket_key:"; + /** + * The constant CP_AGENT_JSAPI_TICKET_KEY. + */ + protected static final String CP_AGENT_JSAPI_TICKET_KEY = "wechat_cp_agent_jsapi_ticket_key:"; + + /** + * redis 存储的 key 的前缀,可为空 + */ + protected String keyPrefix; + /** + * The Access token key. + */ + protected String accessTokenKey; + /** + * The Jsapi ticket key. + */ + protected String jsapiTicketKey; + /** + * The Agent jsapi ticket key. + */ + protected String agentJsapiTicketKey; + /** + * The Lock key. + */ + protected String lockKey; + + private final WxRedisOps redisOps; + + /** + * Instantiates a new Wx cp redis config. + * + * @param redisOps the redis ops + * @param keyPrefix the key prefix + */ + public AbstractWxCpInRedisConfigImpl(@NonNull WxRedisOps redisOps, String keyPrefix) { + this.redisOps = redisOps; + this.keyPrefix = keyPrefix; + } + + /** + * 设置企业微信自研应用ID(整数),同时初始化相关的redis key,注意要先调用setCorpId,再调用setAgentId + * + * @param agentId 应用 agentId + */ + @Override + public void setAgentId(Integer agentId) { + super.setAgentId(agentId); + String ukey; + if (agentId != null) { + ukey = getCorpId().concat(":").concat(String.valueOf(agentId)); + } else { + ukey = getCorpId(); + } + String prefix = StringUtils.isBlank(keyPrefix) ? "" : + (StringUtils.endsWith(keyPrefix, ":") ? keyPrefix : (keyPrefix + ":")); + lockKey = prefix + LOCK_KEY.concat(ukey); + accessTokenKey = prefix + CP_ACCESS_TOKEN_KEY.concat(ukey); + jsapiTicketKey = prefix + CP_JSAPI_TICKET_KEY.concat(ukey); + agentJsapiTicketKey = prefix + CP_AGENT_JSAPI_TICKET_KEY.concat(ukey); + } + + /** + * Gets lock by key. + * + * @param key the key + * @return the lock by key + */ + protected Lock getLockByKey(String key) { + return redisOps.getLock(key); + } + + @Override + public Lock getAccessTokenLock() { + return getLockByKey(this.lockKey.concat(":").concat("accessToken")); + } + + @Override + public Lock getAgentJsapiTicketLock() { + return getLockByKey(this.lockKey.concat(":").concat("agentJsapiTicket")); + + } + + @Override + public Lock getJsapiTicketLock() { + return getLockByKey(this.lockKey.concat(":").concat("jsapiTicket")); + } + + @Override + public String getAccessToken() { + return redisOps.getValue(this.accessTokenKey); + } + + @Override + public boolean isAccessTokenExpired() { + Long expire = redisOps.getExpire(this.accessTokenKey); + return expire == null || expire < 2; + } + + @Override + public void updateAccessToken(WxAccessToken accessToken) { + redisOps.setValue(this.accessTokenKey, accessToken.getAccessToken(), accessToken.getExpiresIn(), TimeUnit.SECONDS); + } + + @Override + public void updateAccessToken(String accessToken, int expiresInSeconds) { + redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds, TimeUnit.SECONDS); + } + + @Override + public void expireAccessToken() { + redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); + } + + @Override + public String getJsapiTicket() { + return redisOps.getValue(this.jsapiTicketKey); + } + + @Override + public boolean isJsapiTicketExpired() { + Long expire = redisOps.getExpire(this.jsapiTicketKey); + return expire == null || expire < 2; + } + + @Override + public void expireJsapiTicket() { + redisOps.expire(this.jsapiTicketKey, 0, TimeUnit.SECONDS); + } + + @Override + public void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) { + redisOps.setValue(this.jsapiTicketKey, jsapiTicket, expiresInSeconds, TimeUnit.SECONDS); + } + + @Override + public void expireAgentJsapiTicket() { + redisOps.expire(this.agentJsapiTicketKey, 0, TimeUnit.SECONDS); + } + + @Override + public void updateAgentJsapiTicket(String agentJsapiTicket, int expiresInSeconds) { + redisOps.setValue(this.agentJsapiTicketKey, agentJsapiTicket, expiresInSeconds, TimeUnit.SECONDS); + } + + @Override + public String getAgentJsapiTicket() { + return redisOps.getValue(this.agentJsapiTicketKey); + } + + @Override + public boolean isAgentJsapiTicketExpired() { + Long expire = redisOps.getExpire(this.agentJsapiTicketKey); + return expire == null || expire < 2; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupDefaultConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupDefaultConfigImpl.java new file mode 100644 index 0000000000..bef838c90d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupDefaultConfigImpl.java @@ -0,0 +1,198 @@ +package me.chanjar.weixin.cp.config.impl; + +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; +import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + * 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化. + * + * @author libo + */ +public class WxCpCorpGroupDefaultConfigImpl implements WxCpCorpGroupConfigStorage, Serializable { + private final transient Map corpAccessTokenLocker = new ConcurrentHashMap<>(); + + private final Map corpAccessTokenMap = new HashMap<>(); + private final Map corpAccessTokenExpireTimeMap = new HashMap<>(); + + private volatile String httpProxyHost; + private volatile int httpProxyPort; + private volatile String httpProxyUsername; + private volatile String httpProxyPassword; + private volatile ApacheHttpClientBuilder apacheHttpClientBuilder; + private volatile String baseApiUrl; + + /** + * 微信企业号 corpId + */ + private volatile String corpId; + /** + * 微信企业号应用 ID + */ + private volatile Integer agentId; + + @Override + public void setBaseApiUrl(String baseUrl) { + this.baseApiUrl = baseUrl; + } + + @Override + public String getApiUrl(String path) { + if (baseApiUrl == null) { + baseApiUrl = "https://qyapi.weixin.qq.com"; + } + return baseApiUrl + path; + } + + @Override + public String getCorpId() { + return corpId; + } + + @Override + public void setCorpId(String corpId) { + this.corpId = corpId; + } + + @Override + public Integer getAgentId() { + return agentId; + } + + @Override + public void setAgentId(Integer agentId) { + this.agentId = agentId; + } + + @Override + public void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds) { + String key = generateAccessTokenKey(corpId, agentId); + corpAccessTokenMap.put(key, corpAccessToken); + //预留200秒的时间 + corpAccessTokenExpireTimeMap.put(key, System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L); + } + + @Override + public String getCorpAccessToken(String corpId, Integer agentId) { + return this.corpAccessTokenMap.get(generateAccessTokenKey(corpId, agentId)); + } + + @Override + public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId) { + String key = generateAccessTokenKey(corpId, agentId); + String accessToken = corpAccessTokenMap.getOrDefault(key, StringUtils.EMPTY); + Long expire = corpAccessTokenExpireTimeMap.getOrDefault(key, 0L); + WxAccessToken accessTokenEntity = new WxAccessToken(); + accessTokenEntity.setAccessToken(accessToken); + accessTokenEntity.setExpiresIn((int) ((expire - System.currentTimeMillis()) / 1000 + 200)); + return accessTokenEntity; + } + + @Override + public boolean isCorpAccessTokenExpired(String corpId, Integer agentId) { + //不存在或者过期 + String key = generateAccessTokenKey(corpId, agentId); + return corpAccessTokenExpireTimeMap.get(key) == null + || System.currentTimeMillis() > corpAccessTokenExpireTimeMap.get(key); + } + + @Override + public void expireCorpAccessToken(String corpId, Integer agentId) { + String key = generateAccessTokenKey(corpId, agentId); + corpAccessTokenMap.remove(key); + corpAccessTokenExpireTimeMap.remove(key); + } + + @Override + public String getHttpProxyHost() { + return this.httpProxyHost; + } + + /** + * Sets http proxy host. + * + * @param httpProxyHost the http proxy host + */ + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } + + @Override + public int getHttpProxyPort() { + return this.httpProxyPort; + } + + /** + * Sets http proxy port. + * + * @param httpProxyPort the http proxy port + */ + public void setHttpProxyPort(int httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } + + @Override + public String getHttpProxyUsername() { + return this.httpProxyUsername; + } + + /** + * Sets http proxy username. + * + * @param httpProxyUsername the http proxy username + */ + public void setHttpProxyUsername(String httpProxyUsername) { + this.httpProxyUsername = httpProxyUsername; + } + + @Override + public String getHttpProxyPassword() { + return this.httpProxyPassword; + } + + /** + * Sets http proxy password. + * + * @param httpProxyPassword the http proxy password + */ + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } + + @Override + public ApacheHttpClientBuilder getApacheHttpClientBuilder() { + return this.apacheHttpClientBuilder; + } + + /** + * Sets apache http client builder. + * + * @param apacheHttpClientBuilder the apache http client builder + */ + public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { + this.apacheHttpClientBuilder = apacheHttpClientBuilder; + } + + @Override + public boolean autoRefreshToken() { + return true; + } + + @Override + public Lock getCorpAccessTokenLock(String corpId, Integer agentId) { + return this.corpAccessTokenLocker + .computeIfAbsent(generateAccessTokenKey(corpId, agentId), key -> new ReentrantLock()); + } + + private String generateAccessTokenKey(String corpId, Integer agentId) { + return String.join(":", this.corpId, String.valueOf(this.agentId), corpId, String.valueOf(agentId)); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupRedissonConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupRedissonConfigImpl.java new file mode 100644 index 0000000000..8146b580d0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupRedissonConfigImpl.java @@ -0,0 +1,218 @@ +package me.chanjar.weixin.cp.config.impl; + +import lombok.Builder; +import lombok.NonNull; +import lombok.Setter; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.redis.WxRedisOps; +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; +import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; + +/** + * 企业微信企业互联各种固定、授权配置的Redisson存储实现 + * + * @author libo Email: 422423229@qq.com + * @since 1/3/2023 10:48 AM + */ +@Builder +public class WxCpCorpGroupRedissonConfigImpl implements WxCpCorpGroupConfigStorage, Serializable { + private final transient Map corpAccessTokenLocker = new ConcurrentHashMap<>(); + + /** + * The constant LOCK_KEY. + */ + protected static final String LOCK_KEY = "wechat_cg_lock:"; + /** + * The constant LOCKER_CORP_ACCESS_TOKEN. + */ + protected static final String LOCKER_CORP_ACCESS_TOKEN = "corpAccessTokenLock"; + /** + * The constant CG_ACCESS_TOKEN_KEY. + */ + protected static final String CG_ACCESS_TOKEN_KEY = "wechat_cg_access_token_key:"; + @NonNull + private final WxRedisOps wxRedisOps; + /** + * redis里面key的统一前缀 + */ + @Setter + private String keyPrefix = ""; + + private volatile String httpProxyHost; + private volatile int httpProxyPort; + private volatile String httpProxyUsername; + private volatile String httpProxyPassword; + private volatile ApacheHttpClientBuilder apacheHttpClientBuilder; + private volatile String baseApiUrl; + /** + * 微信企业号 corpId + */ + private volatile String corpId; + /** + * 微信企业号应用 ID + */ + private volatile Integer agentId; + + @Override + public void setBaseApiUrl(String baseUrl) { + this.baseApiUrl = baseUrl; + } + + @Override + public String getApiUrl(String path) { + if (baseApiUrl == null) { + baseApiUrl = "https://qyapi.weixin.qq.com"; + } + return baseApiUrl + path; + } + + @Override + public String getCorpId() { + return corpId; + } + + @Override + public void setCorpId(String corpId) { + this.corpId = corpId; + } + + @Override + public Integer getAgentId() { + return agentId; + } + + @Override + public void setAgentId(Integer agentId) { + this.agentId = agentId; + } + + @Override + public void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds) { + wxRedisOps.setValue(generateAccessTokenKey(corpId, agentId), corpAccessToken, expiresInSeconds, TimeUnit.SECONDS); + } + + @Override + public String getCorpAccessToken(String corpId, Integer agentId) { + return wxRedisOps.getValue(generateAccessTokenKey(corpId, agentId)); + } + + @Override + public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId) { + String key = generateAccessTokenKey(corpId, agentId); + String accessToken = wxRedisOps.getValue(key); + Long expire = wxRedisOps.getExpire(key); + if (StringUtils.isBlank(accessToken) || expire == null || expire == 0 || expire == -2) { + return new WxAccessToken(); + } + WxAccessToken accessTokenEntity = new WxAccessToken(); + accessTokenEntity.setAccessToken(accessToken); + accessTokenEntity.setExpiresIn(Math.max(Math.toIntExact(expire), 0)); + return accessTokenEntity; + } + + @Override + public boolean isCorpAccessTokenExpired(String corpId, Integer agentId) { + String key = generateAccessTokenKey(corpId, agentId); + return wxRedisOps.getExpire(key) == 0L || wxRedisOps.getExpire(key) == -2; + } + + @Override + public void expireCorpAccessToken(String corpId, Integer agentId) { + wxRedisOps.expire(generateAccessTokenKey(corpId, agentId), 0, TimeUnit.SECONDS); + } + + @Override + public String getHttpProxyHost() { + return this.httpProxyHost; + } + + /** + * Sets http proxy host. + * + * @param httpProxyHost the http proxy host + */ + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } + + @Override + public int getHttpProxyPort() { + return this.httpProxyPort; + } + + /** + * Sets http proxy port. + * + * @param httpProxyPort the http proxy port + */ + public void setHttpProxyPort(int httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } + + @Override + public String getHttpProxyUsername() { + return this.httpProxyUsername; + } + + /** + * Sets http proxy username. + * + * @param httpProxyUsername the http proxy username + */ + public void setHttpProxyUsername(String httpProxyUsername) { + this.httpProxyUsername = httpProxyUsername; + } + + @Override + public String getHttpProxyPassword() { + return this.httpProxyPassword; + } + + /** + * Sets http proxy password. + * + * @param httpProxyPassword the http proxy password + */ + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } + + @Override + public ApacheHttpClientBuilder getApacheHttpClientBuilder() { + return this.apacheHttpClientBuilder; + } + + /** + * Sets apache http client builder. + * + * @param apacheHttpClientBuilder the apache http client builder + */ + public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { + this.apacheHttpClientBuilder = apacheHttpClientBuilder; + } + + @Override + public boolean autoRefreshToken() { + return true; + } + + @Override + public Lock getCorpAccessTokenLock(String corpId, Integer agentId) { + return this.getLockByKey(String.join(":", corpId, String.valueOf(agentId), LOCKER_CORP_ACCESS_TOKEN)); + } + + private String generateAccessTokenKey(String corpId, Integer agentId) { + return String.join(":", keyPrefix, CG_ACCESS_TOKEN_KEY, corpId, String.valueOf(agentId)); + } + + private Lock getLockByKey(String key) { + return this.wxRedisOps.getLock(String.join(":", keyPrefix, LOCK_KEY, key)); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java index 0fbf61724d..57647b3712 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java @@ -43,6 +43,12 @@ public class WxCpDefaultConfigImpl implements WxCpConfigStorage, Serializable { private volatile String token; private volatile String aesKey; private volatile long expiresTime; + /** + * 会话存档私钥以及sdk路径 + */ + private volatile String msgAuditSecret; + private volatile String msgAuditPriKey; + private volatile String msgAuditLibPath; private volatile String oauth2redirectUri; private volatile String httpProxyHost; private volatile int httpProxyPort; @@ -256,6 +262,16 @@ public String getAesKey() { return this.aesKey; } + @Override + public String getMsgAuditPriKey() { + return this.msgAuditPriKey; + } + + @Override + public String getMsgAuditLibPath() { + return this.msgAuditLibPath; + } + /** * Sets aes key. * @@ -279,6 +295,24 @@ public void setAgentId(Integer agentId) { this.agentId = agentId; } + /** + * 设置企微会话存档路径. + * + * @param msgAuditLibPath 会话存档具体路径 + */ + public void setMsgAuditLibPath(String msgAuditLibPath) { + this.msgAuditLibPath = msgAuditLibPath; + } + + /** + * 设置会话存档私钥 + * + * @param msgAuditPriKey 会话存档私钥 + */ + public void setMsgAuditPriKey(String msgAuditPriKey) { + this.msgAuditPriKey = msgAuditPriKey; + } + @Override public String getOauth2redirectUri() { return this.oauth2redirectUri; @@ -402,4 +436,18 @@ public WxCpDefaultConfigImpl setWebhookKey(String webhookKey) { this.webhookKey = webhookKey; return this; } + + @Override + public String getMsgAuditSecret() { + return this.msgAuditSecret; + } + + /** + * 设置会话存档secret + * @param msgAuditSecret + */ + public WxCpDefaultConfigImpl setMsgAuditSecret(String msgAuditSecret) { + this.msgAuditSecret = msgAuditSecret; + return this; + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpJedisConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpJedisConfigImpl.java new file mode 100644 index 0000000000..39d3bd896d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpJedisConfigImpl.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.cp.config.impl; + +import lombok.NonNull; +import me.chanjar.weixin.common.redis.JedisWxRedisOps; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.util.Pool; + +/** + * 基于 jdis 的实现 + * + * @author yl + * created on 2023/04/23 + */ +public class WxCpJedisConfigImpl extends AbstractWxCpInRedisConfigImpl { + private static final long serialVersionUID = -1869372247414407433L; + + public WxCpJedisConfigImpl(Pool jedisPool) { + this(jedisPool, null); + } + + public WxCpJedisConfigImpl(@NonNull Pool jedisPool, String keyPrefix) { + super(new JedisWxRedisOps(jedisPool), keyPrefix); + } +} 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 027ab825c7..4225cff0af 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 @@ -40,6 +40,8 @@ public class WxCpRedisConfigImpl implements WxCpConfigStorage { private volatile String token; private volatile String aesKey; private volatile Integer agentId; + private volatile String msgAuditPriKey; + private volatile String msgAuditLibPath; private volatile String oauth2redirectUri; private volatile String httpProxyHost; private volatile int httpProxyPort; @@ -102,7 +104,8 @@ public WxCpRedisConfigImpl(JedisPoolConfig poolConfig, String host, int port, in * @param password the password * @param database the database */ - public WxCpRedisConfigImpl(JedisPoolConfig poolConfig, String host, int port, int timeout, String password, int database) { + public WxCpRedisConfigImpl(JedisPoolConfig poolConfig, String host, int port, int timeout, String password, + int database) { jedisPool = new JedisPool(poolConfig, host, port, timeout, password, database); } @@ -320,6 +323,16 @@ public String getAesKey() { return this.aesKey; } + @Override + public String getMsgAuditPriKey() { + return this.msgAuditPriKey; + } + + @Override + public String getMsgAuditLibPath() { + return this.msgAuditLibPath; + } + /** * Sets aes key. * @@ -453,4 +466,8 @@ public String getWebhookKey() { return this.getWebhookKey(); } + @Override + public String getMsgAuditSecret() { + return null; + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisTemplateConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisTemplateConfigImpl.java new file mode 100644 index 0000000000..15e8a6c8ee --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisTemplateConfigImpl.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.cp.config.impl; + +import lombok.NonNull; +import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; +import org.springframework.data.redis.core.StringRedisTemplate; + +/** + * 基于 RedisTemplate 的实现 + * + * @author yl + * created on 2023/04/23 + */ +public class WxCpRedisTemplateConfigImpl extends AbstractWxCpInRedisConfigImpl { + private static final long serialVersionUID = -1660004125413310620L; + + public WxCpRedisTemplateConfigImpl(@NonNull StringRedisTemplate stringRedisTemplate) { + this(stringRedisTemplate, null); + } + + public WxCpRedisTemplateConfigImpl(@NonNull StringRedisTemplate stringRedisTemplate, String keyPrefix) { + super(new RedisTemplateWxRedisOps(stringRedisTemplate), keyPrefix); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedissonConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedissonConfigImpl.java index 61894b7599..f21491d04a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedissonConfigImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedissonConfigImpl.java @@ -1,199 +1,23 @@ package me.chanjar.weixin.cp.config.impl; import lombok.NonNull; -import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.redis.RedissonWxRedisOps; -import me.chanjar.weixin.common.redis.WxRedisOps; -import org.apache.commons.lang3.StringUtils; import org.redisson.api.RedissonClient; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; - /** * 基于Redisson的实现 * - * @author yuanqixun - * @date 2020 /5/13 + * @author yuanqixun created on 2020 /5/13 + * @author yl */ -public class WxCpRedissonConfigImpl extends WxCpDefaultConfigImpl { - /** - * The constant LOCK_KEY. - */ - protected final static String LOCK_KEY = "wechat_cp_lock:"; - /** - * The constant CP_ACCESS_TOKEN_KEY. - */ - protected final static String CP_ACCESS_TOKEN_KEY = "wechat_cp_access_token_key:"; - /** - * The constant CP_JSAPI_TICKET_KEY. - */ - protected final static String CP_JSAPI_TICKET_KEY = "wechat_cp_jsapi_ticket_key:"; - /** - * The constant CP_AGENT_JSAPI_TICKET_KEY. - */ - protected final static String CP_AGENT_JSAPI_TICKET_KEY = "wechat_cp_agent_jsapi_ticket_key:"; - private final WxRedisOps redisOps; - /** - * redis 存储的 key 的前缀,可为空 - */ - protected String keyPrefix; - /** - * The Access token key. - */ - protected String accessTokenKey; - /** - * The Jsapi ticket key. - */ - protected String jsapiTicketKey; - /** - * The Agent jsapi ticket key. - */ - protected String agentJsapiTicketKey; - /** - * The Lock key. - */ - protected String lockKey; - - /** - * Instantiates a new Wx cp redisson config. - * - * @param redissonClient the redisson client - * @param keyPrefix the key prefix - */ - public WxCpRedissonConfigImpl(@NonNull RedissonClient redissonClient, String keyPrefix) { - this(new RedissonWxRedisOps(redissonClient), keyPrefix); - } +public class WxCpRedissonConfigImpl extends AbstractWxCpInRedisConfigImpl { + private static final long serialVersionUID = -5674792341070783967L; - /** - * Instantiates a new Wx cp redisson config. - * - * @param redissonClient the redisson client - */ public WxCpRedissonConfigImpl(@NonNull RedissonClient redissonClient) { this(redissonClient, null); } - /** - * Instantiates a new Wx cp redisson config. - * - * @param redisOps the redis ops - * @param keyPrefix the key prefix - */ - public WxCpRedissonConfigImpl(@NonNull WxRedisOps redisOps, String keyPrefix) { - this.redisOps = redisOps; - this.keyPrefix = keyPrefix; - } - - /** - * 设置企业微信自研应用ID(整数),同时初始化相关的redis key,注意要先调用setCorpId,再调用setAgentId - * - * @param agentId - */ - @Override - public void setAgentId(Integer agentId) { - super.setAgentId(agentId); - String ukey = getCorpId().concat(":").concat(String.valueOf(agentId)); - String prefix = StringUtils.isBlank(keyPrefix) ? "" : - (StringUtils.endsWith(keyPrefix, ":") ? keyPrefix : (keyPrefix + ":")); - lockKey = prefix + LOCK_KEY.concat(ukey); - accessTokenKey = prefix + CP_ACCESS_TOKEN_KEY.concat(ukey); - jsapiTicketKey = prefix + CP_JSAPI_TICKET_KEY.concat(ukey); - agentJsapiTicketKey = prefix + CP_AGENT_JSAPI_TICKET_KEY.concat(ukey); - } - - /** - * Gets lock by key. - * - * @param key the key - * @return the lock by key - */ - protected Lock getLockByKey(String key) { - return redisOps.getLock(key); - } - - @Override - public Lock getAccessTokenLock() { - return getLockByKey(this.lockKey.concat(":").concat("accessToken")); - } - - @Override - public Lock getAgentJsapiTicketLock() { - return getLockByKey(this.lockKey.concat(":").concat("agentJsapiTicket")); - - } - - @Override - public Lock getJsapiTicketLock() { - return getLockByKey(this.lockKey.concat(":").concat("jsapiTicket")); - } - - @Override - public String getAccessToken() { - return redisOps.getValue(this.accessTokenKey); - } - - @Override - public boolean isAccessTokenExpired() { - Long expire = redisOps.getExpire(this.accessTokenKey); - return expire == null || expire < 2; - } - - @Override - public void updateAccessToken(WxAccessToken accessToken) { - redisOps.setValue(this.accessTokenKey, accessToken.getAccessToken(), accessToken.getExpiresIn(), TimeUnit.SECONDS); - } - - @Override - public void updateAccessToken(String accessToken, int expiresInSeconds) { - redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds, TimeUnit.SECONDS); - } - - @Override - public void expireAccessToken() { - redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); - } - - @Override - public String getJsapiTicket() { - return redisOps.getValue(this.jsapiTicketKey); - } - - @Override - public boolean isJsapiTicketExpired() { - Long expire = redisOps.getExpire(this.jsapiTicketKey); - return expire == null || expire < 2; - } - - @Override - public void expireJsapiTicket() { - redisOps.expire(this.jsapiTicketKey, 0, TimeUnit.SECONDS); - } - - @Override - public void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) { - redisOps.setValue(this.jsapiTicketKey, jsapiTicket, expiresInSeconds, TimeUnit.SECONDS); - } - - @Override - public void expireAgentJsapiTicket() { - redisOps.expire(this.agentJsapiTicketKey, 0, TimeUnit.SECONDS); - } - - @Override - public void updateAgentJsapiTicket(String agentJsapiTicket, int expiresInSeconds) { - redisOps.setValue(this.agentJsapiTicketKey, agentJsapiTicket, expiresInSeconds, TimeUnit.SECONDS); - } - - @Override - public String getAgentJsapiTicket() { - return redisOps.getValue(this.agentJsapiTicketKey); - } - - @Override - public boolean isAgentJsapiTicketExpired() { - Long expire = redisOps.getExpire(this.agentJsapiTicketKey); - return expire == null || expire < 2; + public WxCpRedissonConfigImpl(@NonNull RedissonClient redissonClient, String keyPrefix) { + super(new RedissonWxRedisOps(redissonClient), keyPrefix); } - } 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 c177250bac..a4b8af4677 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 @@ -45,12 +45,12 @@ public class WxCpTpDefaultConfigImpl implements WxCpTpConfigStorage, Serializabl private volatile String suiteTicket; private volatile long suiteTicketExpiresTime; private volatile String oauth2redirectUri; - private volatile Map authCorpAccessTokenMap = new HashMap<>(); - private volatile Map authCorpAccessTokenExpireTimeMap = new HashMap<>(); - private volatile Map authCorpJsApiTicketMap = new HashMap<>(); - private volatile Map authCorpJsApiTicketExpireTimeMap = new HashMap<>(); - private volatile Map authSuiteJsApiTicketMap = new HashMap<>(); - private volatile Map authSuiteJsApiTicketExpireTimeMap = new HashMap<>(); + private final Map authCorpAccessTokenMap = new HashMap<>(); + private final Map authCorpAccessTokenExpireTimeMap = new HashMap<>(); + private final Map authCorpJsApiTicketMap = new HashMap<>(); + private final Map authCorpJsApiTicketExpireTimeMap = new HashMap<>(); + private final Map authSuiteJsApiTicketMap = new HashMap<>(); + private final Map authSuiteJsApiTicketExpireTimeMap = new HashMap<>(); private volatile String httpProxyHost; private volatile int httpProxyPort; private volatile String httpProxyUsername; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpRedissonConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpRedissonConfigImpl.java index 039337fc44..02193cfd33 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpRedissonConfigImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpRedissonConfigImpl.java @@ -429,7 +429,6 @@ public String toString() { /** * 一个provider 会有多个suite,需要唯一标识作为前缀 - * */ private String keyWithPrefix(String key) { return keyPrefix + ":" + suiteId + ":" + key; @@ -438,7 +437,6 @@ private String keyWithPrefix(String key) { /** * provider 应该独享一个key,且不和任何suite关联 * 一个provider 会有多个suite,不同的suite 都应该指向同一个provider 的数据 - * */ private String providerKeyWithPrefix(String key) { return keyPrefix + ":" + corpId + ":" + key; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index 1a184e9a54..0f67a2051e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -1,8 +1,6 @@ package me.chanjar.weixin.cp.constant; -import lombok.experimental.UtilityClass; - /** *
  *  企业微信api地址常量类
@@ -12,16 +10,50 @@
  * @author Binary Wang
  */
 public interface WxCpApiPathConsts {
+  /**
+   * The constant DEFAULT_CP_BASE_URL.
+   */
   String DEFAULT_CP_BASE_URL = "https://qyapi.weixin.qq.com";
 
+  /**
+   * The constant GET_JSAPI_TICKET.
+   */
   String GET_JSAPI_TICKET = "/cgi-bin/get_jsapi_ticket";
+  /**
+   * The constant GET_AGENT_CONFIG_TICKET.
+   */
   String GET_AGENT_CONFIG_TICKET = "/cgi-bin/ticket/get?&type=agent_config";
+  /**
+   * The constant GET_CALLBACK_IP.
+   */
   String GET_CALLBACK_IP = "/cgi-bin/getcallbackip";
+  /**
+   * The constant BATCH_REPLACE_PARTY.
+   */
   String BATCH_REPLACE_PARTY = "/cgi-bin/batch/replaceparty";
+  /**
+   * The constant BATCH_SYNC_USER.
+   */
+  String BATCH_SYNC_USER = "/cgi-bin/batch/syncuser";
+  /**
+   * The constant BATCH_REPLACE_USER.
+   */
   String BATCH_REPLACE_USER = "/cgi-bin/batch/replaceuser";
+  /**
+   * The constant BATCH_GET_RESULT.
+   */
   String BATCH_GET_RESULT = "/cgi-bin/batch/getresult?jobid=";
+  /**
+   * The constant JSCODE_TO_SESSION.
+   */
   String JSCODE_TO_SESSION = "/cgi-bin/miniprogram/jscode2session";
+  /**
+   * The constant GET_TOKEN.
+   */
   String GET_TOKEN = "/cgi-bin/gettoken?corpid=%s&corpsecret=%s";
+  /**
+   * The constant WEBHOOK_SEND.
+   */
   String WEBHOOK_SEND = "/cgi-bin/webhook/send?key=";
 
   /**
@@ -29,6 +61,7 @@ public interface WxCpApiPathConsts {
    * https://work.weixin.qq.com/api/doc/90000/90135/90235
    */
   interface Message {
+
     /**
      * 发送应用消息
      */
@@ -39,171 +72,1453 @@ interface Message {
      */
     String GET_STATISTICS = "/cgi-bin/message/get_statistics";
 
+    /**
+     * 发送「学校通知」
+     * https://developer.work.weixin.qq.com/document/path/92321
+     */
+    String EXTERNAL_CONTACT_MESSAGE_SEND = "/cgi-bin/externalcontact/message/send";
+
+    /**
+     * 撤回应用消息
+     * https://developer.work.weixin.qq.com/document/path/94867
+     */
+    String MESSAGE_RECALL = "/cgi-bin/message/recall";
+
     /**
      * 互联企业发送应用消息
+     * https://developer.work.weixin.qq.com/document/path/90250
      */
     String LINKEDCORP_MESSAGE_SEND = "/cgi-bin/linkedcorp/message/send";
+
   }
 
+  /**
+   * The interface Agent.
+   */
   interface Agent {
+    /**
+     * The constant AGENT_GET.
+     */
     String AGENT_GET = "/cgi-bin/agent/get?agentid=%d";
+    /**
+     * The constant AGENT_SET.
+     */
     String AGENT_SET = "/cgi-bin/agent/set";
+    /**
+     * The constant AGENT_LIST.
+     */
     String AGENT_LIST = "/cgi-bin/agent/list";
   }
 
+  /**
+   * The interface Work bench.
+   */
   interface WorkBench {
+    /**
+     * The constant WORKBENCH_TEMPLATE_SET.
+     */
     String WORKBENCH_TEMPLATE_SET = "/cgi-bin/agent/set_workbench_template";
+    /**
+     * The constant WORKBENCH_TEMPLATE_GET.
+     */
     String WORKBENCH_TEMPLATE_GET = "/cgi-bin/agent/get_workbench_template";
+    /**
+     * The constant WORKBENCH_DATA_SET.
+     */
     String WORKBENCH_DATA_SET = "/cgi-bin/agent/set_workbench_data";
   }
 
+  /**
+   * The interface O auth 2.
+   */
   interface OAuth2 {
+    /**
+     * The constant GET_USER_INFO.
+     */
     String GET_USER_INFO = "/cgi-bin/user/getuserinfo?code=%s&agentid=%d";
+    /**
+     * The constant GET_SCHOOL_USER_INFO.
+     */
+    String GET_SCHOOL_USER_INFO = "/cgi-bin/school/getuserinfo?code=%s";
+    /**
+     * The constant GET_USER_DETAIL.
+     */
     String GET_USER_DETAIL = "/cgi-bin/user/getuserdetail";
+    /**
+     * The constant URL_OAUTH2_AUTHORIZE.
+     */
     String URL_OAUTH2_AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize";
   }
 
+  /**
+   * The interface Chat.
+   */
   interface Chat {
+    /**
+     * The constant APPCHAT_CREATE.
+     */
     String APPCHAT_CREATE = "/cgi-bin/appchat/create";
+    /**
+     * The constant APPCHAT_UPDATE.
+     */
     String APPCHAT_UPDATE = "/cgi-bin/appchat/update";
+    /**
+     * The constant APPCHAT_GET_CHATID.
+     */
     String APPCHAT_GET_CHATID = "/cgi-bin/appchat/get?chatid=";
+    /**
+     * The constant APPCHAT_SEND.
+     */
     String APPCHAT_SEND = "/cgi-bin/appchat/send";
   }
 
+  /**
+   * The interface Department.
+   */
   interface Department {
+    /**
+     * The constant DEPARTMENT_CREATE.
+     */
     String DEPARTMENT_CREATE = "/cgi-bin/department/create";
+    /**
+     * The constant DEPARTMENT_UPDATE.
+     */
     String DEPARTMENT_UPDATE = "/cgi-bin/department/update";
+    /**
+     * The constant DEPARTMENT_GET.
+     */
+    String DEPARTMENT_GET = "/cgi-bin/department/get?id=%d";
+    /**
+     * The constant DEPARTMENT_DELETE.
+     */
     String DEPARTMENT_DELETE = "/cgi-bin/department/delete?id=%d";
+    /**
+     * The constant DEPARTMENT_LIST.
+     */
     String DEPARTMENT_LIST = "/cgi-bin/department/list";
+    /**
+     * The constant DEPARTMENT_SIMPLE_LIST.
+     */
+    String DEPARTMENT_SIMPLE_LIST = "/cgi-bin/department/simplelist";
   }
 
+  /**
+   * The interface Media.
+   */
   interface Media {
+    /**
+     * The constant MEDIA_GET.
+     */
     String MEDIA_GET = "/cgi-bin/media/get";
+    /**
+     * The constant MEDIA_UPLOAD.
+     */
     String MEDIA_UPLOAD = "/cgi-bin/media/upload?type=";
+    /**
+     * The constant IMG_UPLOAD.
+     */
     String IMG_UPLOAD = "/cgi-bin/media/uploadimg";
+    /**
+     * The constant JSSDK_MEDIA_GET.
+     */
     String JSSDK_MEDIA_GET = "/cgi-bin/media/get/jssdk";
   }
 
+  /**
+   * The interface Menu.
+   */
   interface Menu {
+    /**
+     * The constant MENU_CREATE.
+     */
     String MENU_CREATE = "/cgi-bin/menu/create?agentid=%d";
+    /**
+     * The constant MENU_DELETE.
+     */
     String MENU_DELETE = "/cgi-bin/menu/delete?agentid=%d";
+    /**
+     * The constant MENU_GET.
+     */
     String MENU_GET = "/cgi-bin/menu/get?agentid=%d";
   }
 
+  /**
+   * The interface Oa.
+   */
   interface Oa {
+    /**
+     * 打卡
+     * https://developer.work.weixin.qq.com/document/path/94204
+     */
     String GET_CORP_CHECKIN_OPTION = "/cgi-bin/checkin/getcorpcheckinoption";
+    /**
+     * The constant GET_CHECKIN_DATA.
+     */
     String GET_CHECKIN_DATA = "/cgi-bin/checkin/getcheckindata";
+    /**
+     * The constant GET_CHECKIN_OPTION.
+     */
     String GET_CHECKIN_OPTION = "/cgi-bin/checkin/getcheckinoption";
+    /**
+     * The constant GET_CHECKIN_DAY_DATA.
+     */
     String GET_CHECKIN_DAY_DATA = "/cgi-bin/checkin/getcheckin_daydata";
+    /**
+     * The constant GET_CHECKIN_MONTH_DATA.
+     */
     String GET_CHECKIN_MONTH_DATA = "/cgi-bin/checkin/getcheckin_monthdata";
+    /**
+     * The constant GET_CHECKIN_SCHEDULE_DATA.
+     */
     String GET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/getcheckinschedulist";
+    /**
+     * The constant SET_CHECKIN_SCHEDULE_DATA.
+     */
     String SET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/setcheckinschedulist";
+    /**
+     * The constant ADD_CHECK_IN_USER_FACE.
+     */
+    String ADD_CHECK_IN_USER_FACE = "/cgi-bin/checkin/addcheckinuserface";
+
+    /**
+     * 审批
+     * https://developer.work.weixin.qq.com/document/path/91956
+     */
+    String COPY_TEMPLATE = "/cgi-bin/oa/approval/copytemplate";
+    /**
+     * The constant GET_TEMPLATE_DETAIL.
+     */
+    String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail";
+    /**
+     * The constant CREATE_TEMPLATE.
+     */
+    String CREATE_TEMPLATE = "/cgi-bin/oa/approval/create_template";
+    /**
+     * The constant CREATE_TEMPLATE.
+     */
+    String UPDATE_TEMPLATE = "/cgi-bin/oa/approval/update_template";
+    /**
+     * The constant APPLY_EVENT.
+     */
+    String APPLY_EVENT = "/cgi-bin/oa/applyevent";
+    /**
+     * The constant GET_APPROVAL_INFO.
+     */
     String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo";
+    /**
+     * The constant GET_APPROVAL_DETAIL.
+     */
     String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail";
+    /**
+     * The constant GET_APPROVAL_DATA.
+     */
+    String GET_APPROVAL_DATA = "/cgi-bin/corp/getapprovaldata";
+
+    /**
+     * The constant GET_CORP_CONF.
+     */
+    String GET_CORP_CONF = "/cgi-bin/oa/vacation/getcorpconf";
+    /**
+     * The constant GET_USER_VACATION_QUOTA.
+     */
+    String GET_USER_VACATION_QUOTA = "/cgi-bin/oa/vacation/getuservacationquota";
+    /**
+     * The constant SET_ONE_USER_QUOTA.
+     */
+    String SET_ONE_USER_QUOTA = "/cgi-bin/oa/vacation/setoneuserquota";
+
+    /**
+     * 公费电话
+     * https://developer.work.weixin.qq.com/document/path/93662
+     */
     String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record";
-    String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail";
-    String APPLY_EVENT = "/cgi-bin/oa/applyevent";
 
+    /**
+     * 日程
+     * https://developer.work.weixin.qq.com/document/path/93624
+     */
     String CALENDAR_ADD = "/cgi-bin/oa/calendar/add";
+    /**
+     * The constant CALENDAR_UPDATE.
+     */
     String CALENDAR_UPDATE = "/cgi-bin/oa/calendar/update";
+    /**
+     * The constant CALENDAR_GET.
+     */
     String CALENDAR_GET = "/cgi-bin/oa/calendar/get";
+    /**
+     * The constant CALENDAR_DEL.
+     */
     String CALENDAR_DEL = "/cgi-bin/oa/calendar/del";
 
+    /**
+     * The constant SCHEDULE_ADD.
+     */
     String SCHEDULE_ADD = "/cgi-bin/oa/schedule/add";
+    /**
+     * The constant SCHEDULE_UPDATE.
+     */
     String SCHEDULE_UPDATE = "/cgi-bin/oa/schedule/update";
+    /**
+     * The constant SCHEDULE_GET.
+     */
     String SCHEDULE_GET = "/cgi-bin/oa/schedule/get";
+    /**
+     * The constant SCHEDULE_DEL.
+     */
     String SCHEDULE_DEL = "/cgi-bin/oa/schedule/del";
+    /**
+     * The constant SCHEDULE_LIST.
+     */
     String SCHEDULE_LIST = "/cgi-bin/oa/schedule/get_by_calendar";
 
-    String COPY_TEMPLATE = "/cgi-bin/oa/approval/copytemplate";
-  }
-
-  interface Tag {
-    String TAG_CREATE = "/cgi-bin/tag/create";
-    String TAG_UPDATE = "/cgi-bin/tag/update";
-    String TAG_DELETE = "/cgi-bin/tag/delete?tagid=%s";
-    String TAG_LIST = "/cgi-bin/tag/list";
-    String TAG_GET = "/cgi-bin/tag/get?tagid=%s";
-    String TAG_ADD_TAG_USERS = "/cgi-bin/tag/addtagusers";
-    String TAG_DEL_TAG_USERS = "/cgi-bin/tag/deltagusers";
-  }
+    /**
+     * 会议
+     * https://developer.work.weixin.qq.com/document/path/93626
+     */
+    String MEETING_ADD = "/cgi-bin/meeting/create";
+    /**
+     * The constant MEETING_UPDATE.
+     */
+    String MEETING_UPDATE = "/cgi-bin/meeting/update";
+    /**
+     * The constant MEETING_CANCEL.
+     */
+    String MEETING_CANCEL = "/cgi-bin/meeting/cancel";
+    /**
+     * The constant MEETING_DETAIL.
+     */
+    String MEETING_DETAIL = "/cgi-bin/meeting/get_info";
+    /**
+     * The constant GET_USER_MEETING_ID.
+     */
+    String GET_USER_MEETING_ID = "/cgi-bin/meeting/get_user_meetingid";
 
-  interface TaskCard {
-    String UPDATE_TASK_CARD = "/cgi-bin/message/update_taskcard";
-  }
+    /**
+     * 会议室
+     * https://developer.work.weixin.qq.com/document/path/93624
+     */
+    String MEETINGROOM_ADD = "/cgi-bin/oa/meetingroom/add";
+    /**
+     * The constant MEETINGROOM_LIST.
+     */
+    String MEETINGROOM_LIST = "/cgi-bin/oa/meetingroom/list";
+    /**
+     * The constant MEETINGROOM_EDIT.
+     */
+    String MEETINGROOM_EDIT = "/cgi-bin/oa/meetingroom/edit";
+    /**
+     * The constant MEETINGROOM_DEL.
+     */
+    String MEETINGROOM_DEL = "/cgi-bin/oa/meetingroom/del";
 
-  interface Tp {
-    String JSCODE_TO_SESSION = "/cgi-bin/service/miniprogram/jscode2session";
-    String GET_CORP_TOKEN = "/cgi-bin/service/get_corp_token";
-    String GET_PERMANENT_CODE = "/cgi-bin/service/get_permanent_code";
-    String GET_SUITE_TOKEN = "/cgi-bin/service/get_suite_token";
-    String GET_PROVIDER_TOKEN = "/cgi-bin/service/get_provider_token";
-    String GET_PREAUTH_CODE = "/cgi-bin/service/get_pre_auth_code";
-    String GET_AUTH_INFO = "/cgi-bin/service/get_auth_info";
-    String GET_AUTH_CORP_JSAPI_TICKET = "/cgi-bin/get_jsapi_ticket";
-    String GET_SUITE_JSAPI_TICKET = "/cgi-bin/ticket/get";
-    String GET_USERINFO3RD = "/cgi-bin/service/getuserinfo3rd";
-    String GET_USERDETAIL3RD = "/cgi-bin/service/getuserdetail3rd";
-    String GET_LOGIN_INFO = "/cgi-bin/service/get_login_info";
+    /**
+     * 微盘
+     * https://developer.work.weixin.qq.com/document/path/93654
+     */
+    String SPACE_CREATE = "/cgi-bin/wedrive/space_create";
+    /**
+     * The constant SPACE_RENAME.
+     */
+    String SPACE_RENAME = "/cgi-bin/wedrive/space_rename";
+    /**
+     * The constant SPACE_DISMISS.
+     */
+    String SPACE_DISMISS = "/cgi-bin/wedrive/space_dismiss";
+    /**
+     * The constant SPACE_INFO.
+     */
+    String SPACE_INFO = "/cgi-bin/wedrive/space_info";
+    /**
+     * The constant SPACE_ACL_ADD.
+     */
+    String SPACE_ACL_ADD = "/cgi-bin/wedrive/space_acl_add";
+    /**
+     * The constant SPACE_ACL_DEL.
+     */
+    String SPACE_ACL_DEL = "/cgi-bin/wedrive/space_acl_del";
+    /**
+     * The constant SPACE_SETTING.
+     */
+    String SPACE_SETTING = "/cgi-bin/wedrive/space_setting";
+    /**
+     * The constant SPACE_SHARE.
+     */
+    String SPACE_SHARE = "/cgi-bin/wedrive/space_share";
+    /**
+     * The constant FILE_LIST.
+     */
+    String FILE_LIST = "/cgi-bin/wedrive/file_list";
+    /**
+     * The constant FILE_UPLOAD.
+     */
+    String FILE_UPLOAD = "/cgi-bin/wedrive/file_upload";
+    /**
+     * The constant FILE_DOWNLOAD.
+     */
+    String FILE_DOWNLOAD = "/cgi-bin/wedrive/file_download";
+    /**
+     * The constant FILE_RENAME.
+     */
+    String FILE_RENAME = "/cgi-bin/wedrive/file_rename";
+    /**
+     * The constant FILE_CREATE.
+     */
+    String FILE_CREATE = "/cgi-bin/wedrive/file_create";
+    /**
+     * The constant FILE_MOVE.
+     */
+    String FILE_MOVE = "/cgi-bin/wedrive/file_move";
+    /**
+     * The constant FILE_DELETE.
+     */
+    String FILE_DELETE = "/cgi-bin/wedrive/file_delete";
+    /**
+     * The constant FILE_INFO.
+     */
+    String FILE_INFO = "/cgi-bin/wedrive/file_info";
+    /**
+     * The constant FILE_ACL_ADD.
+     */
+    String FILE_ACL_ADD = "/cgi-bin/wedrive/file_acl_add";
+    /**
+     * The constant FILE_ACL_DEL.
+     */
+    String FILE_ACL_DEL = "/cgi-bin/wedrive/file_acl_del";
+    /**
+     * The constant FILE_SETTING.
+     */
+    String FILE_SETTING = "/cgi-bin/wedrive/file_setting";
+    /**
+     * The constant FILE_SHARE.
+     */
+    String FILE_SHARE = "/cgi-bin/wedrive/file_share";
 
+    /**
+     * 审批流程引擎
+     * https://developer.work.weixin.qq.com/document/path/90269
+     */
+    String GET_OPEN_APPROVAL_DATA = "/cgi-bin/corp/getopenapprovaldata";
+  }
 
-    String CONTACT_SEARCH = "/cgi-bin/service/contact/search";
-    String GET_ADMIN_LIST = "/cgi-bin/service/get_admin_list";
+  /**
+   * The interface School.
+   */
+  interface School {
+    /**
+     * The constant GET_HEALTH_REPORT_STAT.
+     */
+    String GET_HEALTH_REPORT_STAT = "/cgi-bin/health/get_health_report_stat";
+    /**
+     * The constant GET_REPORT_JOBIDS.
+     */
+    String GET_REPORT_JOBIDS = "/cgi-bin/health/get_report_jobids";
+    /**
+     * The constant GET_REPORT_JOB_INFO.
+     */
+    String GET_REPORT_JOB_INFO = "/cgi-bin/health/get_report_job_info";
+    /**
+     * The constant GET_REPORT_ANSWER.
+     */
+    String GET_REPORT_ANSWER = "/cgi-bin/health/get_report_answer";
+
+    /**
+     * The constant GET_TEACHER_CUSTOMIZE_HEALTH_INFO.
+     */
+    String GET_TEACHER_CUSTOMIZE_HEALTH_INFO = "/cgi-bin/school/user/get_teacher_customize_health_info";
+    /**
+     * The constant GET_STUDENT_CUSTOMIZE_HEALTH_INFO.
+     */
+    String GET_STUDENT_CUSTOMIZE_HEALTH_INFO = "/cgi-bin/school/user/get_student_customize_health_info";
+    /**
+     * The constant GET_HEALTH_QRCODE.
+     */
+    String GET_HEALTH_QRCODE = "/cgi-bin/school/user/get_health_qrcode";
+
+    /**
+     * The constant BATCH_CREATE_STUDENT.
+     */
+    String BATCH_CREATE_STUDENT = "/cgi-bin/school/user/batch_create_student";
+    /**
+     * The constant BATCH_DELETE_STUDENT.
+     */
+    String BATCH_DELETE_STUDENT = "/cgi-bin/school/user/batch_delete_student";
+    /**
+     * The constant BATCH_UPDATE_STUDENT.
+     */
+    String BATCH_UPDATE_STUDENT = "/cgi-bin/school/user/batch_update_student";
+    /**
+     * The constant BATCH_CREATE_PARENT.
+     */
+    String BATCH_CREATE_PARENT = "/cgi-bin/school/user/batch_create_parent";
+    /**
+     * The constant BATCH_DELETE_PARENT.
+     */
+    String BATCH_DELETE_PARENT = "/cgi-bin/school/user/batch_delete_parent";
+    /**
+     * The constant BATCH_UPDATE_PARENT.
+     */
+    String BATCH_UPDATE_PARENT = "/cgi-bin/school/user/batch_update_parent";
+
+    /**
+     * The constant CREATE_STUDENT.
+     */
+    String CREATE_STUDENT = "/cgi-bin/school/user/create_student";
+    /**
+     * The constant DELETE_STUDENT.
+     */
+    String DELETE_STUDENT = "/cgi-bin/school/user/delete_student?userid=";
+    /**
+     * The constant UPDATE_STUDENT.
+     */
+    String UPDATE_STUDENT = "/cgi-bin/school/user/update_student";
+    /**
+     * The constant CREATE_PARENT.
+     */
+    String CREATE_PARENT = "/cgi-bin/school/user/create_parent";
+    /**
+     * The constant UPDATE_PARENT.
+     */
+    String UPDATE_PARENT = "/cgi-bin/school/user/update_parent";
+    /**
+     * The constant DELETE_PARENT.
+     */
+    String DELETE_PARENT = "/cgi-bin/school/user/delete_parent?userid=";
+    /**
+     * The constant GET_USER.
+     */
+    String GET_USER = "/cgi-bin/school/user/get?userid=";
+    /**
+     * The constant GET_USER_LIST.
+     */
+    String GET_USER_LIST = "/cgi-bin/school/user/list?department_id=%s&fetch_child=%d";
+    /**
+     * The constant GET_USER_LIST_PARENT.
+     */
+    String GET_USER_LIST_PARENT = "/cgi-bin/school/user/list_parent?department_id=";
+    /**
+     * The constant SET_ARCH_SYNC_MODE.
+     */
+    String SET_ARCH_SYNC_MODE = "/cgi-bin/school/set_arch_sync_mode";
+    /**
+     * The constant SET_UPGRADE_INFO.
+     */
+    String SET_UPGRADE_INFO = "/cgi-bin/school/set_upgrade_info";
+
+    /**
+     * The constant DEPARTMENT_CREATE.
+     */
+    String DEPARTMENT_CREATE = "/cgi-bin/school/department/create";
+    /**
+     * The constant DEPARTMENT_UPDATE.
+     */
+    String DEPARTMENT_UPDATE = "/cgi-bin/school/department/update";
+    /**
+     * The constant DEPARTMENT_DELETE.
+     */
+    String DEPARTMENT_DELETE = "/cgi-bin/school/department/delete?id=";
+    /**
+     * The constant DEPARTMENT_LIST.
+     */
+    String DEPARTMENT_LIST = "/cgi-bin/school/department/list?id=";
+
+    /**
+     * The constant GET_PAYMENT_RESULT.
+     */
+    String GET_PAYMENT_RESULT = "/cgi-bin/school/get_payment_result";
+    /**
+     * The constant GET_TRADE.
+     */
+    String GET_TRADE = "/cgi-bin/school/get_trade";
+    /**
+     * The constant GET_ALLOW_SCOPE.
+     */
+    String GET_ALLOW_SCOPE = "/cgi-bin/school/agent/get_allow_scope?agentid=";
+
+    /**
+     * 上课直播
+     */
+    String GET_LIVING_INFO = "/cgi-bin/school/living/get_living_info?livingid=";
+    /**
+     * The constant GET_WATCH_STAT.
+     */
+    String GET_WATCH_STAT = "/cgi-bin/school/living/get_watch_stat";
+    /**
+     * The constant GET_UNWATCH_STAT.
+     */
+    String GET_UNWATCH_STAT = "/cgi-bin/school/living/get_unwatch_stat";
+  }
+
+  /**
+   * The interface Living.
+   */
+  interface Living {
+    /**
+     * The constant GET_LIVING_CODE.
+     */
+    String GET_LIVING_CODE = "/cgi-bin/living/get_living_code";
+    /**
+     * The constant GET_LIVING_INFO.
+     */
+    String GET_LIVING_INFO = "/cgi-bin/living/get_living_info?livingid=";
+    /**
+     * The constant GET_WATCH_STAT.
+     */
+    String GET_WATCH_STAT = "/cgi-bin/living/get_watch_stat";
+    /**
+     * The constant GET_LIVING_SHARE_INFO.
+     */
+    String GET_LIVING_SHARE_INFO = "/cgi-bin/living/get_living_share_info";
+    /**
+     * The constant GET_USER_ALL_LIVINGID.
+     */
+    String GET_USER_ALL_LIVINGID = "/cgi-bin/living/get_user_all_livingid";
+
+    /**
+     * The constant CREATE.
+     */
+    String CREATE = "/cgi-bin/living/create";
+    /**
+     * The constant MODIFY.
+     */
+    String MODIFY = "/cgi-bin/living/modify";
+    /**
+     * The constant CANCEL.
+     */
+    String CANCEL = "/cgi-bin/living/cancel";
+    /**
+     * The constant DELETE_REPLAY_DATA.
+     */
+    String DELETE_REPLAY_DATA = "/cgi-bin/living/delete_replay_data";
+  }
+
+  /**
+   * The interface Msg audit.
+   */
+  interface MsgAudit {
+    /**
+     * The constant GET_PERMIT_USER_LIST.
+     */
+    String GET_PERMIT_USER_LIST = "/cgi-bin/msgaudit/get_permit_user_list";
+    /**
+     * The constant GET_GROUP_CHAT.
+     */
+    String GET_GROUP_CHAT = "/cgi-bin/msgaudit/groupchat/get";
+    /**
+     * The constant CHECK_SINGLE_AGREE.
+     */
+    String CHECK_SINGLE_AGREE = "/cgi-bin/msgaudit/check_single_agree";
+  }
+
+  /**
+   * The interface Tag.
+   */
+  interface Tag {
+    /**
+     * The constant TAG_CREATE.
+     */
+    String TAG_CREATE = "/cgi-bin/tag/create";
+    /**
+     * The constant TAG_UPDATE.
+     */
+    String TAG_UPDATE = "/cgi-bin/tag/update";
+    /**
+     * The constant TAG_DELETE.
+     */
+    String TAG_DELETE = "/cgi-bin/tag/delete?tagid=%s";
+    /**
+     * The constant TAG_LIST.
+     */
+    String TAG_LIST = "/cgi-bin/tag/list";
+    /**
+     * The constant TAG_GET.
+     */
+    String TAG_GET = "/cgi-bin/tag/get?tagid=%s";
+    /**
+     * The constant TAG_ADD_TAG_USERS.
+     */
+    String TAG_ADD_TAG_USERS = "/cgi-bin/tag/addtagusers";
+    /**
+     * The constant TAG_DEL_TAG_USERS.
+     */
+    String TAG_DEL_TAG_USERS = "/cgi-bin/tag/deltagusers";
+  }
+
+  /**
+   * The interface Task card.
+   */
+  interface TaskCard {
+    /**
+     * The constant UPDATE_TASK_CARD.
+     */
+    String UPDATE_TASK_CARD = "/cgi-bin/message/update_taskcard";
+    /**
+     * The constant UPDATE_TEMPLATE_CARD.
+     */
+    String UPDATE_TEMPLATE_CARD = "/cgi-bin/message/update_template_card";
+  }
+
+  /**
+   * The interface Tp.
+   */
+  interface Tp {
+    /**
+     * The constant JSCODE_TO_SESSION.
+     */
+    String JSCODE_TO_SESSION = "/cgi-bin/service/miniprogram/jscode2session";
+    /**
+     * The constant GET_CORP_TOKEN.
+     */
+    String GET_CORP_TOKEN = "/cgi-bin/service/get_corp_token";
+    /**
+     * The constant GET_PERMANENT_CODE.
+     */
+    String GET_PERMANENT_CODE = "/cgi-bin/service/get_permanent_code";
+    /**
+     * The constant GET_SUITE_TOKEN.
+     */
+    String GET_SUITE_TOKEN = "/cgi-bin/service/get_suite_token";
+    /**
+     * The constant GET_PROVIDER_TOKEN.
+     */
+    String GET_PROVIDER_TOKEN = "/cgi-bin/service/get_provider_token";
+    /**
+     * The constant GET_PREAUTH_CODE.
+     */
+    String GET_PREAUTH_CODE = "/cgi-bin/service/get_pre_auth_code";
+    /**
+     * The constant GET_AUTH_INFO.
+     */
+    String GET_AUTH_INFO = "/cgi-bin/service/get_auth_info";
+    /**
+     * The constant GET_AUTH_CORP_JSAPI_TICKET.
+     */
+    String GET_AUTH_CORP_JSAPI_TICKET = "/cgi-bin/get_jsapi_ticket";
+    /**
+     * The constant GET_SUITE_JSAPI_TICKET.
+     */
+    String GET_SUITE_JSAPI_TICKET = "/cgi-bin/ticket/get";
+    /**
+     * The constant GET_USERINFO3RD.
+     */
+    String GET_USERINFO3RD = "/cgi-bin/service/auth/getuserinfo3rd";
+    /**
+     * The constant GET_USERDETAIL3RD.
+     */
+    String GET_USERDETAIL3RD = "/cgi-bin/service/auth/getuserdetail3rd";
+    /**
+     * The constant GET_LOGIN_INFO.
+     */
+    String GET_LOGIN_INFO = "/cgi-bin/service/get_login_info";
+
+    /**
+     * The constant GET_CUSTOMIZED_AUTH_URL.
+     */
+    String GET_CUSTOMIZED_AUTH_URL = "/cgi-bin/service/get_customized_auth_url";
+
+
+    /**
+     * The constant CONTACT_SEARCH.
+     */
+    String CONTACT_SEARCH = "/cgi-bin/service/contact/search";
+    /**
+     * The constant GET_ADMIN_LIST.
+     */
+    String GET_ADMIN_LIST = "/cgi-bin/service/get_admin_list";
+    /**
+     * The constant GET_APP_QRCODE.
+     */
+    String GET_APP_QRCODE = "/cgi-bin/service/get_app_qrcode";
+
+    /**
+     * The constant CORPID_TO_OPENCORPID.
+     */
+    String CORPID_TO_OPENCORPID = "/cgi-bin/service/corpid_to_opencorpid";
+
+    /**
+     * The constant GET_ORDER.
+     */
+// 获取订单详情
+    String GET_ORDER = "/cgi-bin/service/get_order";
+
+    /**
+     * The constant GET_ORDER_LIST.
+     */
+// 获取订单列表
+    String GET_ORDER_LIST = "/cgi-bin/service/get_order_list";
+
+    /**
+     * The constant PROLONG_TRY.
+     */
+// 延长试用期
+    String PROLONG_TRY = "/cgi-bin/service/prolong_try";
 
   }
 
+  /**
+   * The interface License.
+   */
+  interface License {
+    /**
+     * The constant CREATE_NEW_ORDER.
+     */
+    String CREATE_NEW_ORDER = "/cgi-bin/license/create_new_order";
+    /**
+     * The constant CREATE_RENEW_ORDER_JOB.
+     */
+    String CREATE_RENEW_ORDER_JOB = "/cgi-bin/license/create_renew_order_job";
+    /**
+     * The constant SUBMIT_ORDER_JOB.
+     */
+    String SUBMIT_ORDER_JOB = "/cgi-bin/license/submit_order_job";
+    /**
+     * The constant LIST_ORDER.
+     */
+    String LIST_ORDER = "/cgi-bin/license/list_order";
+    /**
+     * The constant GET_ORDER.
+     */
+    String GET_ORDER = "/cgi-bin/license/get_order";
+    /**
+     * The constant LIST_ORDER_ACCOUNT.
+     */
+    String LIST_ORDER_ACCOUNT = "/cgi-bin/license/list_order_account";
+    /**
+     * The constant ACTIVE_ACCOUNT.
+     */
+    String ACTIVE_ACCOUNT = "/cgi-bin/license/active_account";
+    /**
+     * The constant BATCH_ACTIVE_ACCOUNT.
+     */
+    String BATCH_ACTIVE_ACCOUNT = "/cgi-bin/license/batch_active_account";
+    /**
+     * The constant GET_ACTIVE_INFO_BY_CODE.
+     */
+    String GET_ACTIVE_INFO_BY_CODE = "/cgi-bin/license/get_active_info_by_code";
+    /**
+     * The constant BATCH_GET_ACTIVE_INFO_BY_CODE.
+     */
+    String BATCH_GET_ACTIVE_INFO_BY_CODE = "/cgi-bin/license/batch_get_active_info_by_code";
+    /**
+     * The constant LIST_ACTIVED_ACCOUNT.
+     */
+    String LIST_ACTIVED_ACCOUNT = "/cgi-bin/license/list_actived_account";
+    /**
+     * The constant GET_ACTIVE_INFO_BY_USER.
+     */
+    String GET_ACTIVE_INFO_BY_USER = "/cgi-bin/license/get_active_info_by_user";
+    /**
+     * The constant BATCH_TRANSFER_LICENSE.
+     */
+    String BATCH_TRANSFER_LICENSE = "/cgi-bin/license/batch_transfer_license";
+  }
+
+  /**
+   * The interface User.
+   */
   interface User {
+    /**
+     * The constant USER_AUTHENTICATE.
+     */
     String USER_AUTHENTICATE = "/cgi-bin/user/authsucc?userid=";
+    /**
+     * The constant USER_CREATE.
+     */
     String USER_CREATE = "/cgi-bin/user/create";
+    /**
+     * The constant USER_UPDATE.
+     */
     String USER_UPDATE = "/cgi-bin/user/update";
+    /**
+     * The constant USER_DELETE.
+     */
     String USER_DELETE = "/cgi-bin/user/delete?userid=";
+    /**
+     * The constant USER_BATCH_DELETE.
+     */
     String USER_BATCH_DELETE = "/cgi-bin/user/batchdelete";
+    /**
+     * The constant USER_GET.
+     */
     String USER_GET = "/cgi-bin/user/get?userid=";
+    /**
+     * The constant USER_LIST.
+     */
     String USER_LIST = "/cgi-bin/user/list?department_id=";
+    /**
+     * The constant USER_SIMPLE_LIST.
+     */
     String USER_SIMPLE_LIST = "/cgi-bin/user/simplelist?department_id=";
+    /**
+     * The constant BATCH_INVITE.
+     */
     String BATCH_INVITE = "/cgi-bin/batch/invite";
+    /**
+     * The constant USER_CONVERT_TO_OPENID.
+     */
     String USER_CONVERT_TO_OPENID = "/cgi-bin/user/convert_to_openid";
+    /**
+     * The constant USER_CONVERT_TO_USERID.
+     */
     String USER_CONVERT_TO_USERID = "/cgi-bin/user/convert_to_userid";
+    /**
+     * The constant GET_USER_ID.
+     */
     String GET_USER_ID = "/cgi-bin/user/getuserid";
+    /**
+     * The constant GET_USER_ID_BY_EMAIL.
+     */
+    String GET_USER_ID_BY_EMAIL = "/cgi-bin/user/get_userid_by_email";
+    /**
+     * The constant GET_EXTERNAL_CONTACT.
+     */
     String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid=";
+    /**
+     * The constant GET_JOIN_QR_CODE.
+     */
     String GET_JOIN_QR_CODE = "/cgi-bin/corp/get_join_qrcode?size_type=";
+    /**
+     * The constant GET_ACTIVE_STAT.
+     */
+    String GET_ACTIVE_STAT = "/cgi-bin/user/get_active_stat";
+    /**
+     * The constant USERID_TO_OPEN_USERID.
+     */
+    String USERID_TO_OPEN_USERID = "/cgi-bin/batch/userid_to_openuserid";
+    /**
+     * The constant OPEN_USERID_TO_USERID.
+     */
+    String OPEN_USERID_TO_USERID = "/cgi-bin/batch/openuserid_to_userid";
+
+    /**
+     * The constant USER_LIST_ID.
+     */
+    String USER_LIST_ID = "/cgi-bin/user/list_id";
   }
 
+  /**
+   * The interface External contact.
+   */
   interface ExternalContact {
+    /**
+     * The constant GET_EXTERNAL_CONTACT.
+     */
     @Deprecated
     String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid=";
 
+    /**
+     * The constant ADD_CONTACT_WAY.
+     */
     String ADD_CONTACT_WAY = "/cgi-bin/externalcontact/add_contact_way";
+    /**
+     * The constant GET_CONTACT_WAY.
+     */
     String GET_CONTACT_WAY = "/cgi-bin/externalcontact/get_contact_way";
+    /**
+     * The constant UPDATE_CONTACT_WAY.
+     */
     String UPDATE_CONTACT_WAY = "/cgi-bin/externalcontact/update_contact_way";
+    /**
+     * The constant DEL_CONTACT_WAY.
+     */
     String DEL_CONTACT_WAY = "/cgi-bin/externalcontact/del_contact_way";
+    /**
+     * The constant CLOSE_TEMP_CHAT.
+     */
     String CLOSE_TEMP_CHAT = "/cgi-bin/externalcontact/close_temp_chat";
+    /**
+     * The constant GET_FOLLOW_USER_LIST.
+     */
     String GET_FOLLOW_USER_LIST = "/cgi-bin/externalcontact/get_follow_user_list";
+    /**
+     * The constant GET_CONTACT_DETAIL.
+     */
     String GET_CONTACT_DETAIL = "/cgi-bin/externalcontact/get?external_userid=";
+    /**
+     * The constant CONVERT_TO_OPENID.
+     */
     String CONVERT_TO_OPENID = "/cgi-bin/externalcontact/convert_to_openid";
+    /**
+     * The constant UNIONID_TO_EXTERNAL_USERID.
+     */
     String UNIONID_TO_EXTERNAL_USERID = "/cgi-bin/externalcontact/unionid_to_external_userid";
+    /**
+     * The constant UNIONID_TO_EXTERNAL_USERID_3RD.
+     */
+    String UNIONID_TO_EXTERNAL_USERID_3RD = "/cgi-bin/service/externalcontact/unionid_to_external_userid_3rd";
+    /**
+     * The constant GET_NEW_EXTERNAL_USERID.
+     */
+    String GET_NEW_EXTERNAL_USERID = "/cgi-bin/externalcontact/get_new_external_userid";
+    /**
+     * The constant TO_SERVICE_EXTERNAL_USERID.
+     */
+    String TO_SERVICE_EXTERNAL_USERID = "/cgi-bin/externalcontact/to_service_external_userid";
+    /**
+     * The constant FROM_SERVICE_EXTERNAL_USERID.
+     */
+    String FROM_SERVICE_EXTERNAL_USERID = "/cgi-bin/externalcontact/from_service_external_userid";
+    /**
+     * The constant FINISH_EXTERNAL_USERID_MIGRATION.
+     */
+    String FINISH_EXTERNAL_USERID_MIGRATION = "/cgi-bin/externalcontact/finish_external_userid_migration";
+    /**
+     * The constant GET_CONTACT_DETAIL_BATCH.
+     */
     String GET_CONTACT_DETAIL_BATCH = "/cgi-bin/externalcontact/batch/get_by_user?";
+    /**
+     * The constant UPDATE_REMARK.
+     */
     String UPDATE_REMARK = "/cgi-bin/externalcontact/remark";
+    /**
+     * The constant LIST_EXTERNAL_CONTACT.
+     */
     String LIST_EXTERNAL_CONTACT = "/cgi-bin/externalcontact/list?userid=";
+    /**
+     * The constant LIST_UNASSIGNED_CONTACT.
+     */
     String LIST_UNASSIGNED_CONTACT = "/cgi-bin/externalcontact/get_unassigned_list";
+
+    /**
+     * The constant TRANSFER_UNASSIGNED_CONTACT.
+     */
     @Deprecated
     String TRANSFER_UNASSIGNED_CONTACT = "/cgi-bin/externalcontact/transfer";
+    /**
+     * The constant TRANSFER_CUSTOMER.
+     */
     String TRANSFER_CUSTOMER = "/cgi-bin/externalcontact/transfer_customer";
+    /**
+     * The constant TRANSFER_RESULT.
+     */
     String TRANSFER_RESULT = "/cgi-bin/externalcontact/transfer_result";
+    /**
+     * The constant RESIGNED_TRANSFER_CUSTOMER.
+     */
     String RESIGNED_TRANSFER_CUSTOMER = "/cgi-bin/externalcontact/resigned/transfer_customer";
+    /**
+     * The constant RESIGNED_TRANSFER_RESULT.
+     */
     String RESIGNED_TRANSFER_RESULT = "/cgi-bin/externalcontact/resigned/transfer_result";
+    /**
+     * The constant GROUP_CHAT_LIST.
+     */
     String GROUP_CHAT_LIST = "/cgi-bin/externalcontact/groupchat/list";
+    /**
+     * The constant GROUP_CHAT_INFO.
+     */
     String GROUP_CHAT_INFO = "/cgi-bin/externalcontact/groupchat/get";
+    /**
+     * The constant OPENID_TO_CHATID.
+     */
+    String OPENID_TO_CHATID = "/cgi-bin/externalcontact/opengid_to_chatid";
+    /**
+     * The constant GROUP_CHAT_TRANSFER.
+     */
     String GROUP_CHAT_TRANSFER = "/cgi-bin/externalcontact/groupchat/transfer";
+    /**
+     * The constant GROUP_CHAT_ONJOB_TRANSFER.
+     */
+    String GROUP_CHAT_ONJOB_TRANSFER = "/cgi-bin/externalcontact/groupchat/onjob_transfer";
+    /**
+     * The constant LIST_USER_BEHAVIOR_DATA.
+     */
     String LIST_USER_BEHAVIOR_DATA = "/cgi-bin/externalcontact/get_user_behavior_data";
+    /**
+     * The constant LIST_GROUP_CHAT_DATA.
+     */
     String LIST_GROUP_CHAT_DATA = "/cgi-bin/externalcontact/groupchat/statistic";
+    /**
+     * The constant ADD_JOIN_WAY.
+     */
+    String ADD_JOIN_WAY = "/cgi-bin/externalcontact/groupchat/add_join_way";
+    /**
+     * The constant GET_JOIN_WAY.
+     */
+    String GET_JOIN_WAY = "/cgi-bin/externalcontact/groupchat/get_join_way";
+    /**
+     * The constant UPDATE_JOIN_WAY.
+     */
+    String UPDATE_JOIN_WAY = "/cgi-bin/externalcontact/groupchat/update_join_way";
+    /**
+     * The constant DEL_JOIN_WAY.
+     */
+    String DEL_JOIN_WAY = "/cgi-bin/externalcontact/groupchat/del_join_way";
+    /**
+     * The constant ADD_MSG_TEMPLATE.
+     */
     String ADD_MSG_TEMPLATE = "/cgi-bin/externalcontact/add_msg_template";
+    /**
+     * 提醒成员群发
+     */
+    String REMIND_GROUP_MSG_SEND = "/cgi-bin/externalcontact/remind_groupmsg_send";
+    /**
+     * 停止企业群发
+     */
+    String CANCEL_GROUP_MSG_SEND = "/cgi-bin/externalcontact/cancel_groupmsg_send";
+    /**
+     * The constant SEND_WELCOME_MSG.
+     */
     String SEND_WELCOME_MSG = "/cgi-bin/externalcontact/send_welcome_msg";
 
+    /**
+     * The constant GET_CORP_TAG_LIST.
+     */
     String GET_CORP_TAG_LIST = "/cgi-bin/externalcontact/get_corp_tag_list";
+    /**
+     * The constant ADD_CORP_TAG.
+     */
     String ADD_CORP_TAG = "/cgi-bin/externalcontact/add_corp_tag";
+    /**
+     * The constant EDIT_CORP_TAG.
+     */
     String EDIT_CORP_TAG = "/cgi-bin/externalcontact/edit_corp_tag";
+    /**
+     * The constant DEL_CORP_TAG.
+     */
     String DEL_CORP_TAG = "/cgi-bin/externalcontact/del_corp_tag";
+    /**
+     * The constant MARK_TAG.
+     */
     String MARK_TAG = "/cgi-bin/externalcontact/mark_tag";
+
+    /**
+     * The constant ADD_MOMENT_TASK.
+     */
+    String ADD_MOMENT_TASK = "/cgi-bin/externalcontact/add_moment_task";
+    /**
+     * The constant GET_MOMENT_TASK_RESULT.
+     */
+    String GET_MOMENT_TASK_RESULT = "/cgi-bin/externalcontact/get_moment_task_result";
+    /**
+     * The constant GET_MOMENT_LIST.
+     */
+    String GET_MOMENT_LIST = "/cgi-bin/externalcontact/get_moment_list";
+    /**
+     * The constant GET_MOMENT_TASK.
+     */
+    String GET_MOMENT_TASK = "/cgi-bin/externalcontact/get_moment_task";
+    /**
+     * The constant GET_MOMENT_CUSTOMER_LIST.
+     */
+    String GET_MOMENT_CUSTOMER_LIST = "/cgi-bin/externalcontact/get_moment_customer_list";
+    /**
+     * The constant GET_MOMENT_SEND_RESULT.
+     */
+    String GET_MOMENT_SEND_RESULT = "/cgi-bin/externalcontact/get_moment_send_result";
+    /**
+     * The constant GET_MOMENT_COMMENTS.
+     */
+    String GET_MOMENT_COMMENTS = "/cgi-bin/externalcontact/get_moment_comments";
+
+    /**
+     * The constant GET_GROUP_MSG_SEND_RESULT.
+     */
+    String GET_GROUP_MSG_SEND_RESULT = "/cgi-bin/externalcontact/get_groupmsg_send_result";
+    /**
+     * The constant GET_GROUP_MSG_TASK.
+     */
+    String GET_GROUP_MSG_TASK = "/cgi-bin/externalcontact/get_groupmsg_task";
+    /**
+     * The constant GET_GROUP_MSG_LIST_V2.
+     */
+    String GET_GROUP_MSG_LIST_V2 = "/cgi-bin/externalcontact/get_groupmsg_list_v2";
+    /**
+     * The constant GET_GROUP_MSG_RESULT.
+     */
+    String GET_GROUP_MSG_RESULT = "/cgi-bin/externalcontact/get_group_msg_result";
+
+
+    /**
+     * The constant GET_PRODUCT_ALBUM.
+     */
+    String GET_PRODUCT_ALBUM = "/cgi-bin/externalcontact/get_product_album";
+    /**
+     * The constant GET_PRODUCT_ALBUM_LIST.
+     */
+    String GET_PRODUCT_ALBUM_LIST = "/cgi-bin/externalcontact/get_product_album_list";
+    /**
+     * The constant ADD_PRODUCT_ALBUM.
+     */
+    String ADD_PRODUCT_ALBUM = "/cgi-bin/externalcontact/add_product_album";
+    /**
+     * The constant UPDATE_PRODUCT_ALBUM.
+     */
+    String UPDATE_PRODUCT_ALBUM = "/cgi-bin/externalcontact/update_product_album";
+    /**
+     * The constant DELETE_PRODUCT_ALBUM.
+     */
+    String DELETE_PRODUCT_ALBUM = "/cgi-bin/externalcontact/delete_product_album";
+
+    /**
+     * The constant GROUP_WELCOME_TEMPLATE_ADD.
+     */
+    String GROUP_WELCOME_TEMPLATE_ADD = "/cgi-bin/externalcontact/group_welcome_template/add";
+    /**
+     * The constant GROUP_WELCOME_TEMPLATE_EDIT.
+     */
+    String GROUP_WELCOME_TEMPLATE_EDIT = "/cgi-bin/externalcontact/group_welcome_template/edit";
+    /**
+     * The constant GROUP_WELCOME_TEMPLATE_GET.
+     */
+    String GROUP_WELCOME_TEMPLATE_GET = "/cgi-bin/externalcontact/group_welcome_template/get";
+    /**
+     * The constant GROUP_WELCOME_TEMPLATE_DEL.
+     */
+    String GROUP_WELCOME_TEMPLATE_DEL = "/cgi-bin/externalcontact/group_welcome_template/del";
+
+    /**
+     * The constant UPLOAD_ATTACHMENT.
+     */
+    String UPLOAD_ATTACHMENT = "/cgi-bin/media/upload_attachment";
+
+    /**
+     * The constant GET_SUBSCRIBE_QR_CODE.
+     */
+    String GET_SUBSCRIBE_QR_CODE = "/cgi-bin/externalcontact/get_subscribe_qr_code";
+    /**
+     * The constant SET_SUBSCRIBE_MODE.
+     */
+    String SET_SUBSCRIBE_MODE = "/cgi-bin/externalcontact/set_subscribe_mode";
+    /**
+     * The constant GET_SUBSCRIBE_MODE.
+     */
+    String GET_SUBSCRIBE_MODE = "/cgi-bin/externalcontact/get_subscribe_mode";
+    /**
+     * The constant EXTERNAL_CONTACT_GET.
+     */
+    String EXTERNAL_CONTACT_GET = "/cgi-bin/externalcontact/get?external_userid=";
+
+    /**
+     * The constant ADD_INTERCEPT_RULE.
+     */
+    String ADD_INTERCEPT_RULE = "/cgi-bin/externalcontact/add_intercept_rule";
+    /**
+     * The constant UPDATE_INTERCEPT_RULE.
+     */
+    String UPDATE_INTERCEPT_RULE = "/cgi-bin/externalcontact/update_intercept_rule";
+    /**
+     * The constant DEL_INTERCEPT_RULE.
+     */
+    String DEL_INTERCEPT_RULE = "/cgi-bin/externalcontact/del_intercept_rule";
+    /**
+     * 获取当前仍然有效的获客链接
+     */
+    String CUSTOMER_ACQUISITION_LINK_LIST = "/cgi-bin/externalcontact/customer_acquisition/list_link";
+    /**
+     * 获取获客链接详情
+     */
+    String CUSTOMER_ACQUISITION_LINK_GET = "/cgi-bin/externalcontact/customer_acquisition/get";
+    /**
+     * 创建获客链接
+     */
+    String CUSTOMER_ACQUISITION_LINK_CREATE = "/cgi-bin/externalcontact/customer_acquisition/create_link";
+    /**
+     * 编辑获客链接
+     */
+    String CUSTOMER_ACQUISITION_LINK_UPDATE = "/cgi-bin/externalcontact/customer_acquisition/update_link";
+    /**
+     * 删除获客链接
+     */
+    String CUSTOMER_ACQUISITION_LINK_DELETE = "/cgi-bin/externalcontact/customer_acquisition/delete_link";
+    /**
+     * 获取获客客户列表
+     */
+    String CUSTOMER_ACQUISITION_CUSTOMER = "/cgi-bin/externalcontact/customer_acquisition/customer";
+    /**
+     * 查询剩余使用量
+     */
+    String CUSTOMER_ACQUISITION_QUOTA = "/cgi-bin/externalcontact/customer_acquisition_quota";
+
+  }
+
+  /**
+   * The interface Kf.
+   */
+  interface Kf {
+    /**
+     * The constant ACCOUNT_ADD.
+     */
+    String ACCOUNT_ADD = "/cgi-bin/kf/account/add";
+    /**
+     * The constant ACCOUNT_UPD.
+     */
+    String ACCOUNT_UPD = "/cgi-bin/kf/account/update";
+    /**
+     * The constant ACCOUNT_DEL.
+     */
+    String ACCOUNT_DEL = "/cgi-bin/kf/account/del";
+    /**
+     * The constant ACCOUNT_LIST.
+     */
+    String ACCOUNT_LIST = "/cgi-bin/kf/account/list";
+    /**
+     * The constant ADD_CONTACT_WAY.
+     */
+    String ADD_CONTACT_WAY = "/cgi-bin/kf/add_contact_way";
+
+    /**
+     * The constant SERVICER_ADD.
+     */
+    String SERVICER_ADD = "/cgi-bin/kf/servicer/add";
+    /**
+     * The constant SERVICER_DEL.
+     */
+    String SERVICER_DEL = "/cgi-bin/kf/servicer/del";
+    /**
+     * The constant SERVICER_LIST.
+     */
+    String SERVICER_LIST = "/cgi-bin/kf/servicer/list?open_kfid=";
+
+    /**
+     * The constant SERVICE_STATE_GET.
+     */
+    String SERVICE_STATE_GET = "/cgi-bin/kf/service_state/get";
+    /**
+     * The constant SERVICE_STATE_TRANS.
+     */
+    String SERVICE_STATE_TRANS = "/cgi-bin/kf/service_state/trans";
+
+    /**
+     * The constant SYNC_MSG.
+     */
+    String SYNC_MSG = "/cgi-bin/kf/sync_msg";
+    /**
+     * The constant SEND_MSG.
+     */
+    String SEND_MSG = "/cgi-bin/kf/send_msg";
+
+    /**
+     * The constant SEND_MSG_ON_EVENT.
+     */
+    String SEND_MSG_ON_EVENT = "/cgi-bin/kf/send_msg_on_event";
+    /**
+     * The constant CUSTOMER_BATCH_GET.
+     */
+    String CUSTOMER_BATCH_GET = "/cgi-bin/kf/customer/batchget";
+    /**
+     * The constant GET_CORP_STATISTIC.
+     */
+    String GET_CORP_STATISTIC = "/cgi-bin/kf/get_corp_statistic";
+
+    /**
+     * The constant GET_SERVICER_STATISTIC.
+     */
+    String GET_SERVICER_STATISTIC = "/cgi-bin/kf/get_servicer_statistic";
+
+    /**
+     * The constant CUSTOMER_GET_UPGRADE_SERVICE_CONFIG.
+     */
+    String CUSTOMER_GET_UPGRADE_SERVICE_CONFIG = "/cgi-bin/kf/customer/get_upgrade_service_config";
+    /**
+     * The constant CUSTOMER_UPGRADE_SERVICE.
+     */
+    String CUSTOMER_UPGRADE_SERVICE = "/cgi-bin/kf/customer/upgrade_service";
+    /**
+     * The constant CUSTOMER_CANCEL_UPGRADE_SERVICE.
+     */
+    String CUSTOMER_CANCEL_UPGRADE_SERVICE = "/cgi-bin/kf/customer/cancel_upgrade_service";
+
+  }
+
+  /**
+   * The interface Export.
+   */
+  interface Export {
+    /**
+     * The constant SIMPLE_USER.
+     */
+    String SIMPLE_USER = "/cgi-bin/export/simple_user";
+    /**
+     * The constant USER.
+     */
+    String USER = "/cgi-bin/export/user";
+    /**
+     * The constant DEPARTMENT.
+     */
+    String DEPARTMENT = "/cgi-bin/export/department";
+    /**
+     * The constant TAG_USER.
+     */
+    String TAG_USER = "/cgi-bin/export/taguser";
+    /**
+     * The constant GET_RESULT.
+     */
+    String GET_RESULT = "/cgi-bin/export/get_result?jobid=%s";
+  }
+
+  interface CorpGroup {
+    /**
+     * 获取应用共享信息
+     * https://developer.work.weixin.qq.com/document/path/93403
+     */
+    String LIST_SHARE_APP_INFO = "/cgi-bin/corpgroup/corp/list_app_share_info";
+    /**
+     * 获取下级/下游企业的access_token
+     * https://developer.work.weixin.qq.com/document/path/93359
+     */
+    String CORP_GET_TOKEN = "/cgi-bin/corpgroup/corp/gettoken";
+    /**
+     * 获取下级/下游企业小程序session
+     * https://developer.work.weixin.qq.com/document/path/93355
+     */
+    String MA_TRANSFER_SESSION = "/cgi-bin/miniprogram/transfer_session";
+  }
+
+  interface LinkedCorp {
+    /**
+     * 获取应用的可见范围
+     * https://developer.work.weixin.qq.com/document/path/93172
+     */
+    String GET_PERM_LIST = "/cgi-bin/linkedcorp/agent/get_perm_list";
+    /**
+     * 获取互联企业成员详细信息
+     * https://developer.work.weixin.qq.com/document/path/93171
+     */
+    String GET_USER = "/cgi-bin/linkedcorp/user/get";
+    /**
+     * 获取互联企业部门成员
+     * https://developer.work.weixin.qq.com/document/path/93168
+     */
+    String GET_USER_SIMPLELIST = "/cgi-bin/linkedcorp/user/simplelist";
+    /**
+     * 获取互联企业部门成员详情
+     * https://developer.work.weixin.qq.com/document/path/93169
+     */
+    String GET_USER_LIST = "/cgi-bin/linkedcorp/user/list";
+    /**
+     * 获取互联企业部门列表
+     * https://developer.work.weixin.qq.com/document/path/93170
+     */
+    String GET_DEPARTMENT_LIST = "/cgi-bin/linkedcorp/department/list";
+    /**
+     * 发送应用消息
+     * https://developer.work.weixin.qq.com/document/path/90250
+     */
+    String SENG_MESSAGE = "/cgi-bin/linkedcorp/message/send";
+  }
+
+  interface IdConvert {
+
+    /**
+     * 将企业主体下的客户标签ID转换成服务商主体下的客户标签ID。
+     */
+    String EXTERNAL_TAG_ID = "/cgi-bin/idconvert/external_tagid";
+
+    /**
+     * 将微信客户的unionid转为第三方主体的external_userid
+     * 该接口有调用频率限制,当subject_type为0时,按企业作如下的限制:10万次/小时、48万次/天、750万次/月
+     */
+    String UNION_ID_TO_EXTERNAL_USER_ID = "/cgi-bin/idconvert/unionid_to_external_userid";
+
+    /**
+     * 将企业主体下的微信客服ID转换成服务商主体下的微信客服ID
+     */
+    String OPEN_KF_ID = "/cgi-bin/idconvert/open_kfid";
+
+    /**
+     * 将应用获取的外部用户临时idtmp_external_userid,转换为external_userid。
+     */
+    String CONVERT_TMP_EXTERNAL_USER_ID = "/cgi-bin/idconvert/convert_tmp_external_userid";
   }
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java
index 601c7dbb30..7487c6143b 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java
@@ -94,12 +94,23 @@ public static class EventType {
     public static final String TASKCARD_CLICK = "taskcard_click";
 
     /**
-     * 企业成员添加外部联系人事件推送
+     * 企业成员添加外部联系人事件推送 & 会话存档客户同意进行聊天内容存档事件回调事件
      */
     public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact";
 
+    /**
+     * 客户群事件推送
+     */
+    public static final String CHANGE_EXTERNAL_CHAT = "change_external_chat";
+
+    /**
+     * 企业客户标签事件推送
+     */
+    public static final String CHANGE_EXTERNAL_TAG = "change_external_tag";
+
     /**
      * 企业微信审批事件推送(自建应用审批)
+     * https://developer.work.weixin.qq.com/document/path/90269
      */
     public static final String OPEN_APPROVAL_CHANGE = "open_approval_change";
 
@@ -133,6 +144,146 @@ public static class EventType {
      */
     public static final String DELETE_SCHEDULE = "delete_schedule";
 
+    /**
+     * 家校通讯录事件
+     */
+    public static final String CHANGE_SCHOOL_CONTACT = "change_school_contact";
+
+    /**
+     * 产生会话回调事件
+     */
+    public static final String MSGAUDIT_NOTIFY = "msgaudit_notify";
+
+    /**
+     * 直播回调事件
+     */
+    public static final String LIVING_STATUS_CHANGE = "living_status_change";
+
+  }
+
+  /**
+   * 会话存档事件CHANGE_TYPE
+   * https://developer.work.weixin.qq.com/document/path/92005
+   */
+  @UtilityClass
+  public static class MsgAuditChangeType {
+
+    /**
+     * The constant MSG_AUDIT_APPROVED.
+     */
+    public static final String MSG_AUDIT_APPROVED = "msg_audit_approved";
+
+  }
+
+  /**
+   * 会话存档媒体类型
+   * https://developer.work.weixin.qq.com/document/path/91774
+   */
+  @UtilityClass
+  public static class MsgAuditMediaType {
+
+    /**
+     * 图片
+     */
+    public static final String IMAGE = "image";
+
+    /**
+     * 语音
+     */
+    public static final String VOICE = "voice";
+
+    /**
+     * 视频
+     */
+    public static final String VIDEO = "video";
+
+    /**
+     * 表情
+     */
+    public static final String EMOTION = "emotion";
+
+    /**
+     * 文件
+     */
+    public static final String FILE = "file";
+
+    /**
+     * 音频存档消息
+     */
+    public static final String MEETING_VOICE_CALL = "meeting_voice_call";
+
+    /**
+     * 音频共享文档消息
+     */
+    public static final String VOIP_DOC_SHARE = "voip_doc_share";
+
+    @UtilityClass
+    public static class MsgAuditSuffix {
+
+      public static final String JPG = ".jpg";
+      public static final String PNG = ".png";
+      public static final String GIF = ".gif";
+      public static final String MP4 = ".mp4";
+      public static final String AMR = ".amr";
+
+    }
+
+  }
+
+  /**
+   * 家校通讯录变更事件CHANGE_TYPE
+   */
+  @UtilityClass
+  public static class SchoolContactChangeType {
+
+    /**
+     * 部门变更事件
+     * https://developer.work.weixin.qq.com/document/path/92052
+     */
+    public static final String CREATE_DEPARTMENT = "create_department";
+    /**
+     * The constant UPDATE_DEPARTMENT.
+     */
+    public static final String UPDATE_DEPARTMENT = "update_department";
+    /**
+     * The constant DELETE_DEPARTMENT.
+     */
+    public static final String DELETE_DEPARTMENT = "delete_department";
+
+    /**
+     * 成员变更事件
+     * https://developer.work.weixin.qq.com/document/path/92032
+     */
+    public static final String CREATE_STUDENT = "create_student";
+    /**
+     * The constant UPDATE_STUDENT.
+     */
+    public static final String UPDATE_STUDENT = "update_student";
+    /**
+     * The constant DELETE_STUDENT.
+     */
+    public static final String DELETE_STUDENT = "delete_student";
+    /**
+     * The constant CREATE_PARENT.
+     */
+    public static final String CREATE_PARENT = "create_parent";
+    /**
+     * The constant UPDATE_PARENT.
+     */
+    public static final String UPDATE_PARENT = "update_parent";
+    /**
+     * The constant DELETE_PARENT.
+     */
+    public static final String DELETE_PARENT = "delete_parent";
+    /**
+     * The constant SUBSCRIBE.
+     */
+    public static final String SUBSCRIBE = "subscribe";
+    /**
+     * The constant UNSUBSCRIBE.
+     */
+    public static final String UNSUBSCRIBE = "unsubscribe";
+
   }
 
   /**
@@ -144,6 +295,10 @@ public static class ExternalContactChangeType {
      * 新增外部联系人
      */
     public static final String ADD_EXTERNAL_CONTACT = "add_external_contact";
+    /**
+     * 编辑外部联系人
+     */
+    public static final String EDIT_EXTERNAL_CONTACT = "edit_external_contact";
     /**
      * 删除外部联系人
      */
@@ -157,8 +312,113 @@ public static class ExternalContactChangeType {
      * 删除跟进成员事件
      */
     public static final String DEL_FOLLOW_USER = "del_follow_user";
+    /**
+     * 客户接替失败事件
+     */
+    public static final String TRANSFER_FAIL = "transfer_fail";
+
+    /**
+     * The type External contact transfer fail reason.
+     */
+    @UtilityClass
+    public static class ExternalContactTransferFailReason {
+      /**
+       * 客户拒绝
+       */
+      public static final String CUSTOMER_REFUSED = "customer_refused";
+      /**
+       * 接替成员的客户数达到上限
+       */
+      public static final String CUSTOMER_LIMIT_EXCEED = "customer_limit_exceed";
+    }
+  }
+
+  /**
+   * The type External chat change type.
+   */
+  @UtilityClass
+  public static class ExternalChatChangeType {
+    /**
+     * 客户群变更事件
+     */
+    public static final String CREATE = "create";
+    /**
+     * 客户群变更事件
+     */
+    public static final String UPDATE = "update";
+    /**
+     * 客户群解散事件
+     */
+    public static final String DISMISS = "dismiss";
+
+    /**
+     * The type External chat update detail.
+     */
+    @UtilityClass
+    public static class ExternalChatUpdateDetail {
+      /**
+       * 成员入群
+       */
+      public static final String ADD_MEMBER = "add_member";
+      /**
+       * 成员退群
+       */
+      public static final String DEL_MEMBER = "del_member";
+      /**
+       * 群主变更
+       */
+      public static final String CHANGE_OWNER = "change_owner";
+      /**
+       * 群名变更
+       */
+      public static final String CHANGE_NAME = "change_name";
+      /**
+       * 群公告变更
+       */
+      public static final String CHANGE_NOTICE = "change_notice";
+    }
+  }
+
+  /**
+   * The type External tag change type.
+   */
+  @UtilityClass
+  public static class ExternalTagChangeType {
+
+    /**
+     * 创建企业客户标签
+     */
+    public static final String CREATE = "create";
+    /**
+     * 变更企业客户标签
+     */
+    public static final String UPDATE = "update";
+    /**
+     * 删除企业客户标签
+     */
+    public static final String DELETE = "delete";
+    /**
+     * 重排企业客户标签
+     */
+    public static final String SHUFFLE = "shuffle";
   }
 
+  /**
+   * The type Tage type.
+   */
+  @UtilityClass
+  public static class TageType {
+    /**
+     * 标签
+     */
+    public static final String TAG = "tag";
+    /**
+     * 标签组
+     */
+    public static final String TAG_GROUP = "tag_group";
+  }
+
+
   /**
    * 企业微信通讯录变更事件.
    */
@@ -270,6 +530,17 @@ public static class GroupRobotMsgType {
      * 图文消息(点击跳转到外链).
      */
     public static final String NEWS = "news";
+
+    /**
+     * 文件类型消息.
+     */
+    public static final String FILE = "file";
+
+    /**
+     * 模版类型消息.
+     */
+    public static final String TEMPLATE_CARD = "template_card";
+
   }
 
   /**
@@ -315,26 +586,44 @@ public static class AppChatMsgType {
     public static final String MARKDOWN = "markdown";
   }
 
+  /**
+   * The type Work bench type.
+   */
   @UtilityClass
   public static class WorkBenchType {
+    /**
+     * The constant KEYDATA.
+     */
     /*
-    * 关键数据型
-    * */
+     * 关键数据型
+     * */
     public static final String KEYDATA = "keydata";
+    /**
+     * The constant IMAGE.
+     */
     /*
-    * 图片型
-    * */
+     * 图片型
+     * */
     public static final String IMAGE = "image";
+    /**
+     * The constant LIST.
+     */
     /*
-    * 列表型
-    * */
+     * 列表型
+     * */
     public static final String LIST = "list";
+    /**
+     * The constant WEBVIEW.
+     */
     /*
-    * webview型
-    * */
+     * webview型
+     * */
     public static final String WEBVIEW = "webview";
   }
 
+  /**
+   * The type Welcome msg type.
+   */
   @UtilityClass
   public static class WelcomeMsgType {
     /**
@@ -359,4 +648,18 @@ public static class WelcomeMsgType {
      */
     public static final String FILE = "file";
   }
+
+  /**
+   * The type Product attachment type.
+   */
+  @UtilityClass
+  public static class ProductAttachmentType {
+
+    /**
+     * 图片消息.
+     */
+    public static final String IMAGE = "image";
+
+  }
+
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java
index 40270270cf..f256d7068d 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java
@@ -2,9 +2,15 @@
 
 import lombok.experimental.UtilityClass;
 
+/**
+ * The type Wx cp tp consts.
+ */
 public class WxCpTpConsts {
 
 
+  /**
+   * The type Info type.
+   */
   @UtilityClass
   public static class InfoType {
     /**
@@ -27,6 +33,21 @@ public static class InfoType {
      */
     public static final String CANCEL_AUTH = "cancel_auth";
 
+    /**
+     * 企业互联共享应用事件回调
+     */
+    public static final String SHARE_AGENT_CHANGE = "share_agent_change";
+
+    /**
+     * 重置永久授权码通知
+     */
+    public static final String RESET_PERMANENT_CODE = "reset_permanent_code";
+
+    /**
+     * 应用管理员变更通知
+     */
+    public static final String CHANGE_APP_ADMIN = "change_app_admin";
+
     /**
      * 通讯录变更通知
      */
@@ -47,6 +68,48 @@ public static class InfoType {
      */
     public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact";
 
+    /**
+     * 下单成功通知
+     */
+    public static final String OPEN_ORDER = "open_order";
+
+    /**
+     * 改单通知
+     */
+    public static final String CHANGE_ORDER = "change_order";
+
+    /**
+     * 支付成功通知
+     */
+    public static final String PAY_FOR_APP_SUCCESS = "pay_for_app_success";
+
+    /**
+     * 退款通知
+     */
+    public static final String REFUND = "refund";
+
+    /**
+     * 付费版本变更通知
+     */
+    public static final String CHANGE_EDITION = "change_editon";
+
+
+    /**
+     * 接口许可失效通知
+     */
+    public static final String UNLICENSED_NOTIFY = "unlicensed_notify";
+
+    /**
+     * 支付成功通知
+     */
+    public static final String LICENSE_PAY_SUCCESS = "license_pay_success";
+
+    /**
+     * 退款结果通知
+     */
+    public static final String LICENSE_REFUND = "license_refund";
+
+
   }
 
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpCgService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpCgService.java
new file mode 100644
index 0000000000..b9b2c5d774
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpCgService.java
@@ -0,0 +1,173 @@
+package me.chanjar.weixin.cp.corpgroup.service;
+
+import me.chanjar.weixin.common.bean.WxAccessToken;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
+import me.chanjar.weixin.common.util.http.RequestExecutor;
+import me.chanjar.weixin.common.util.http.RequestHttp;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq;
+import me.chanjar.weixin.cp.bean.corpgroup.WxCpMaTransferSession;
+import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage;
+
+/**
+ * 企业微信企业互联API的Service.
+ *
+ * @author libo
+ */
+public interface WxCpCgService {
+  /**
+   * Update corp access token.
+   *
+   * @param corpId .
+   * @param agentId .
+   * @param corpAccessToken  the corp access token
+   * @param expiresInSeconds the expires in seconds
+   */
+  void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds);
+
+  String getCorpAccessToken(String corpId, Integer agentId, Integer businessType) throws WxErrorException;
+
+  String getCorpAccessToken(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException;
+
+  /**
+   * 授权企业的access token相关
+   *
+   * @param corpId       the corp id
+   * @param agentId
+   * @param businessType
+   * @return the access token
+   */
+  WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType) throws WxErrorException;
+
+  /**
+   * Gets access token entity.
+   *
+   * @param corpId       the  corp id
+   * @param agentId
+   * @param businessType
+   * @return the access token entity
+   */
+  WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException;
+
+  /**
+   * Is access token expired boolean.
+   *
+   * @param corpId  the  corp id
+   * @param agentId
+   * @return the boolean
+   */
+  boolean isCorpAccessTokenExpired(String corpId, Integer agentId);
+
+  /**
+   * Expire access token.
+   *
+   * @param corpId  the  corp id
+   * @param agentId
+   */
+  void expireCorpAccessToken(String corpId, Integer agentId);
+
+  /**
+   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求.
+   *
+   * @param url        接口地址
+   * @param queryParam 请求参数
+   * @return the string
+   * @throws WxErrorException the wx error exception
+   */
+  String get(String url, String queryParam, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException;
+
+  /**
+   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求.
+   *
+   * @param url                    接口地址
+   * @param queryParam             请求参数
+   * @param withoutCorpAccessToken 请求是否忽略CorpAccessToken 默认不忽略-false
+   * @return the string
+   * @throws WxErrorException the wx error exception
+   */
+  String get(String url, String queryParam, boolean withoutCorpAccessToken, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException;
+
+  /**
+   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
+   *
+   * @param url      接口地址
+   * @param postData 请求body字符串
+   * @return the string
+   * @throws WxErrorException the wx error exception
+   */
+  String post(String url, String postData, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException;
+
+  /**
+   * 
+   * Service没有实现某个API的时候,可以用这个,
+   * 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。
+   * 可以参考,{@link MediaUploadRequestExecutor}的实现方法
+   * 
+ * + * @param 请求值类型 + * @param 返回值类型 + * @param executor 执行器 + * @param uri 请求地址 + * @param data 参数 + * @return the t + * @throws WxErrorException the wx error exception + */ + T execute(RequestExecutor executor, String uri, E data, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException; + + /** + *
+   * 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试.
+   * 默认:1000ms
+   * 
+ * + * @param retrySleepMillis 重试休息时间 + */ + void setRetrySleepMillis(int retrySleepMillis); + + /** + *
+   * 设置当微信系统响应系统繁忙时,最大重试次数.
+   * 默认:5次
+   * 
+ * + * @param maxRetryTimes 最大重试次数 + */ + void setMaxRetryTimes(int maxRetryTimes); + + /** + * 初始化http请求对象 + */ + void initHttp(); + + void setWxCpCorpGroupConfigStorage(WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage); + + WxCpCorpGroupConfigStorage getWxCpCorpGroupConfigStorage(); + + /** + * http请求对象. + * + * @return the request http + */ + RequestHttp getRequestHttp(); + + void setWxCpService(WxCpService wxCpService); + + /** + * 互联企业的服务类对象 + * + * @return + */ + WxCpLinkedCorpService getLinkedCorpService(); + + /** + * 获取下级/下游企业小程序session + * https://developer.work.weixin.qq.com/document/path/93355 + * + * @param userId + * @param sessionKey + * @return + * @throws WxErrorException + */ + WxCpMaTransferSession getCorpTransferSession(String userId, String sessionKey, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpLinkedCorpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpLinkedCorpService.java new file mode 100644 index 0000000000..065419cdbb --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpLinkedCorpService.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.cp.corpgroup.service; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpAgentPerm; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpDepartment; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpUser; + +import java.util.List; + +/** + * 互联企业相关接口 + * + * @author libo Email: 422423229@qq.com + * @since 27/2/2023 9:57 PM + */ +public interface WxCpLinkedCorpService { + WxCpLinkedCorpAgentPerm getLinkedCorpAgentPerm(WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException; + + WxCpLinkedCorpUser getLinkedCorpUser(String userId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException; + + List getLinkedCorpSimpleUserList(String departmentId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException; + + List getLinkedCorpUserList(String departmentId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException; + + List getLinkedCorpDepartmentList(String departmentId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/BaseWxCpCgServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/BaseWxCpCgServiceImpl.java new file mode 100644 index 0000000000..5fb56cc157 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/BaseWxCpCgServiceImpl.java @@ -0,0 +1,296 @@ +package me.chanjar.weixin.cp.corpgroup.service.impl; + +import com.google.gson.JsonObject; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxCpErrorMsgEnum; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.error.WxRuntimeException; +import me.chanjar.weixin.common.util.DataUtils; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; +import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpMaTransferSession; +import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import me.chanjar.weixin.cp.corpgroup.service.WxCpCgService; +import me.chanjar.weixin.cp.corpgroup.service.WxCpLinkedCorpService; + +import java.io.IOException; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.*; + +/** + * @author libo Email: 422423229@qq.com + * @since 1/3/2023 5:45 PM + */ +@Slf4j +public abstract class BaseWxCpCgServiceImpl implements WxCpCgService, RequestHttp { + + WxCpService wxCpService; + /** + * The Config storage. + */ + protected WxCpCorpGroupConfigStorage configStorage; + + private int retrySleepMillis = 1000; + private int maxRetryTimes = 5; + + private final WxCpLinkedCorpService linkedCorpService = new WxCpLinkedCorpServiceImpl(this); + + @Override + public void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds) { + + } + + @Override + public String getCorpAccessToken(String corpId, Integer agentId, Integer businessType) throws WxErrorException { + return getCorpAccessToken(corpId, agentId, businessType, false); + } + + @Override + public String getCorpAccessToken(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException { + if (!this.configStorage.isCorpAccessTokenExpired(corpId, agentId) && !forceRefresh) { + return this.configStorage.getCorpAccessToken(corpId, agentId); + } + synchronized (this) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("corpid", corpId); + jsonObject.addProperty("agentid", agentId); + jsonObject.addProperty("business_type", businessType); + final String url = this.wxCpService.getWxCpConfigStorage().getApiUrl(CORP_GET_TOKEN); + String responseContent = this.wxCpService.post(url, jsonObject); + WxAccessToken corpToken = WxAccessToken.fromJson(responseContent); + this.configStorage.updateCorpAccessToken(corpId, agentId, corpToken.getAccessToken(), corpToken.getExpiresIn()); + } + return this.configStorage.getCorpAccessToken(corpId, agentId); + } + + @Override + public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType) throws WxErrorException { + return this.getCorpAccessTokenEntity(corpId, agentId, businessType, false); + } + + + @Override + public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException { + return this.configStorage.getCorpAccessTokenEntity(corpId, agentId); + } + + @Override + public boolean isCorpAccessTokenExpired(String corpId, Integer agentId) { + return this.configStorage.isCorpAccessTokenExpired(corpId, agentId); + } + + @Override + public void expireCorpAccessToken(String corpId, Integer agentId) { + this.configStorage.expireCorpAccessToken(corpId, agentId); + } + + @Override + public String get(String url, String queryParam, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + return execute(SimpleGetRequestExecutor.create(this), url, queryParam, req); + } + + @Override + public String get(String url, String queryParam, boolean withoutCorpAccessToken, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + return execute(SimpleGetRequestExecutor.create(this), url, queryParam, withoutCorpAccessToken, req); + } + + @Override + public String post(String url, String postData, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + return execute(SimplePostRequestExecutor.create(this), url, postData, false, req); + } + + /** + * Post string. + * + * @param url the url + * @param postData the post data + * @param withoutCorpAccessToken the without Corp access token + * @return the string + * @throws WxErrorException the wx error exception + */ + public String post(String url, String postData, boolean withoutCorpAccessToken, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + return execute(SimplePostRequestExecutor.create(this), url, postData, withoutCorpAccessToken, req); + } + + /** + * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求. + */ + @Override + public T execute(RequestExecutor executor, String uri, E data, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + return execute(executor, uri, data, false, req); + } + + /** + * Execute t. + * + * @param the type parameter + * @param the type parameter + * @param executor the executor + * @param uri the uri + * @param data the data + * @param withoutCorpAccessToken the without Corp access token + * @return the t + * @throws WxErrorException the wx error exception + */ + public T execute(RequestExecutor executor, String uri, E data, boolean withoutCorpAccessToken, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + int retryTimes = 0; + do { + try { + return this.executeInternal(executor, uri, data, withoutCorpAccessToken, req); + } catch (WxErrorException e) { + if (retryTimes + 1 > this.maxRetryTimes) { + log.warn("重试达到最大次数【{}】", this.maxRetryTimes); + //最后一次重试失败后,直接抛出异常,不再等待 + throw new WxRuntimeException("微信服务端异常,超出重试次数"); + } + + WxError error = e.getError(); + /* + * -1 系统繁忙, 1000ms后重试 + */ + if (error.getErrorCode() == -1) { + int sleepMillis = this.retrySleepMillis * (1 << retryTimes); + try { + log.debug("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); + Thread.sleep(sleepMillis); + } catch (InterruptedException e1) { + Thread.currentThread().interrupt(); + } + } else { + throw e; + } + } + } while (retryTimes++ < this.maxRetryTimes); + + log.warn("重试达到最大次数【{}】", this.maxRetryTimes); + throw new WxRuntimeException("微信服务端异常,超出重试次数"); + } + + /** + * Execute internal t. + * + * @param the type parameter + * @param the type parameter + * @param executor the executor + * @param uri the uri + * @param data the data + * @return the t + * @throws WxErrorException the wx error exception + */ + protected T executeInternal(RequestExecutor executor, String uri, E data, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + return executeInternal(executor, uri, data, false, req); + } + + /** + * Execute internal t. + * + * @param the type parameter + * @param the type parameter + * @param executor the executor + * @param uri the uri + * @param data the data + * @param withoutCorpAccessToken the without Corp access token + * @return the t + * @throws WxErrorException the wx error exception + */ + protected T executeInternal(RequestExecutor executor, String uri, E data, + boolean withoutCorpAccessToken, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + E dataForLog = DataUtils.handleDataWithSecret(data); + + if (uri.contains("access_token=")) { + throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri); + } + String uriWithAccessToken; + if (!withoutCorpAccessToken) { + String corpAccessToken = getCorpAccessToken(req.getCorpId(), req.getAgentId(), req.getBusinessType()); + uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + corpAccessToken; + } else { + uriWithAccessToken = uri; + } + + + try { + T result = executor.execute(uriWithAccessToken, data, WxType.CP); + log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); + return result; + } catch (WxErrorException e) { + WxError error = e.getError(); + /* + * 发生以下情况时尝试刷新Corp_access_token + * 42009 Corp_access_token已过期 + */ + if (error.getErrorCode() == WxCpErrorMsgEnum.CODE_42009.getCode()) { + // 强制设置wxCpCorpGroupConfigStorage它的corp access token过期了,这样在下一次请求里就会刷新corp access token + this.configStorage.expireCorpAccessToken(req.getCorpId(), req.getAgentId()); + if (this.getWxCpCorpGroupConfigStorage().autoRefreshToken()) { + log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg()); + return this.execute(executor, uri, data, req); + } + } + + if (error.getErrorCode() != 0) { + log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); + throw new WxErrorException(error, e); + } + return null; + } catch (IOException e) { + log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); + throw new WxRuntimeException(e); + } + } + + @Override + public void setWxCpCorpGroupConfigStorage(WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage) { + this.configStorage = wxCpCorpGroupConfigStorage; + this.initHttp(); + } + + @Override + public WxCpCorpGroupConfigStorage getWxCpCorpGroupConfigStorage() { + return configStorage; + } + + @Override + public void setRetrySleepMillis(int retrySleepMillis) { + this.retrySleepMillis = retrySleepMillis; + } + + + @Override + public void setMaxRetryTimes(int maxRetryTimes) { + this.maxRetryTimes = maxRetryTimes; + } + + @Override + public RequestHttp getRequestHttp() { + return this; + } + + @Override + public void setWxCpService(WxCpService wxCpService) { + this.wxCpService = wxCpService; + } + + @Override + public WxCpLinkedCorpService getLinkedCorpService() { + return linkedCorpService; + } + + @Override + public WxCpMaTransferSession getCorpTransferSession(String userId, String sessionKey, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + final String url = this.wxCpService.getWxCpConfigStorage().getApiUrl(MA_TRANSFER_SESSION); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + jsonObject.addProperty("session_key", sessionKey); + String result = this.post(url, jsonObject.toString(), req); + return WxCpMaTransferSession.fromJson(result); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImpl.java new file mode 100644 index 0000000000..fde2c76bb2 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImpl.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.cp.corpgroup.service.impl; + +import me.chanjar.weixin.common.util.http.HttpType; +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; +import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; +import org.apache.http.HttpHost; +import org.apache.http.impl.client.CloseableHttpClient; + +/** + * @author libo Email: 422423229@qq.com + * @since 1/3/2023 6:16 PM + */ +public class WxCpCgServiceApacheHttpClientImpl extends BaseWxCpCgServiceImpl { + private CloseableHttpClient httpClient; + private HttpHost httpProxy; + + @Override + public CloseableHttpClient getRequestHttpClient() { + return httpClient; + } + + @Override + public HttpHost getRequestHttpProxy() { + return httpProxy; + } + + @Override + public HttpType getRequestType() { + return HttpType.APACHE_HTTP; + } + + @Override + public void initHttp() { + ApacheHttpClientBuilder apacheHttpClientBuilder = this.configStorage.getApacheHttpClientBuilder(); + if (null == apacheHttpClientBuilder) { + apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get(); + } + + apacheHttpClientBuilder.httpProxyHost(this.configStorage.getHttpProxyHost()) + .httpProxyPort(this.configStorage.getHttpProxyPort()) + .httpProxyUsername(this.configStorage.getHttpProxyUsername()) + .httpProxyPassword(this.configStorage.getHttpProxyPassword()); + + if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) { + this.httpProxy = new HttpHost(this.configStorage.getHttpProxyHost(), this.configStorage.getHttpProxyPort()); + } + + this.httpClient = apacheHttpClientBuilder.build(); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpLinkedCorpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpLinkedCorpServiceImpl.java new file mode 100644 index 0000000000..1f0625eb31 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpLinkedCorpServiceImpl.java @@ -0,0 +1,93 @@ +package me.chanjar.weixin.cp.corpgroup.service.impl; + +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpAgentPerm; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpDepartment; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpUser; +import me.chanjar.weixin.cp.corpgroup.service.WxCpCgService; +import me.chanjar.weixin.cp.corpgroup.service.WxCpLinkedCorpService; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.List; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.LinkedCorp.*; + +/** + * 互联企业相关接口实现类 + * + * @author libo Email: 422423229@qq.com + * @since 27/2/2023 10:02 PM + */ +@RequiredArgsConstructor +public class WxCpLinkedCorpServiceImpl implements WxCpLinkedCorpService { + private final WxCpCgService cpCgService; + + @Override + public WxCpLinkedCorpAgentPerm getLinkedCorpAgentPerm(WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + final String url = this.cpCgService.getWxCpCorpGroupConfigStorage().getApiUrl(GET_PERM_LIST); + JsonObject jsonObject = new JsonObject(); + String responseContent = this.cpCgService.post(url, jsonObject.toString(), req); + return WxCpGsonBuilder.create().fromJson(responseContent, WxCpLinkedCorpAgentPerm.class); + } + + @Override + public WxCpLinkedCorpUser getLinkedCorpUser(String userId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + final String url = this.cpCgService.getWxCpCorpGroupConfigStorage().getApiUrl(GET_USER); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("userid", userId); + String responseContent = this.cpCgService.post(url, jsonObject.toString(), req); + JsonObject tmpJson = GsonParser.parse(responseContent); + + return WxCpGsonBuilder.create().fromJson(tmpJson.get("user_info"), + new TypeToken() { + }.getType() + ); + } + + @Override + public List getLinkedCorpSimpleUserList(String departmentId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + final String url = this.cpCgService.getWxCpCorpGroupConfigStorage().getApiUrl(GET_USER_SIMPLELIST); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("department_id", departmentId); + String responseContent = this.cpCgService.post(url, jsonObject.toString(), req); + JsonObject tmpJson = GsonParser.parse(responseContent); + + return WxCpGsonBuilder.create().fromJson(tmpJson.get("userlist"), + new TypeToken>() { + }.getType() + ); + } + + @Override + public List getLinkedCorpUserList(String departmentId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + final String url = this.cpCgService.getWxCpCorpGroupConfigStorage().getApiUrl(GET_USER_LIST); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("department_id", departmentId); + String responseContent = this.cpCgService.post(url, jsonObject.toString(), req); + JsonObject tmpJson = GsonParser.parse(responseContent); + + return WxCpGsonBuilder.create().fromJson(tmpJson.get("userlist"), + new TypeToken>() { + }.getType() + ); + } + + @Override + public List getLinkedCorpDepartmentList(String departmentId, WxCpCorpGroupCorpGetTokenReq req) throws WxErrorException { + final String url = this.cpCgService.getWxCpCorpGroupConfigStorage().getApiUrl(GET_DEPARTMENT_LIST); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("department_id", departmentId); + String responseContent = this.cpCgService.post(url, jsonObject.toString(), req); + JsonObject tmpJson = GsonParser.parse(responseContent); + + return WxCpGsonBuilder.create().fromJson(tmpJson.get("department_list"), + new TypeToken>() { + }.getType() + ); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java index 92de0c238a..e2daeab546 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; -import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker; +import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateCheckerSingleton; import me.chanjar.weixin.common.session.InternalSession; import me.chanjar.weixin.common.session.InternalSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; @@ -14,10 +14,7 @@ import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; import org.apache.commons.lang3.StringUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.*; /** @@ -65,22 +62,66 @@ public class WxCpMessageRouter { /** * 构造方法. + * + * @param wxCpService the wx cp service */ public WxCpMessageRouter(WxCpService wxCpService) { this.wxCpService = wxCpService; ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxCpMessageRouter-pool-%d").build(); this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); - this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); this.sessionManager = wxCpService.getSessionManager(); this.exceptionHandler = new LogExceptionHandler(); } + /** + * 使用自定义的 {@link ExecutorService}. + * + * @param wxMpService the wx mp service + * @param executorService the executor service + */ + public WxCpMessageRouter(WxCpService wxMpService, ExecutorService executorService) { + this.wxCpService = wxMpService; + this.executorService = executorService; + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); + this.sessionManager = wxCpService.getSessionManager(); + this.exceptionHandler = new LogExceptionHandler(); + } + + /** + * 系统退出前,应该调用该方法 + */ + public void shutDownExecutorService() { + this.executorService.shutdown(); + } + + /** + * 系统退出前,应该调用该方法,增加了超时时间检测 + * + * @param second the second + */ + public void shutDownExecutorService(Integer second) { + this.executorService.shutdown(); + try { + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { + this.executorService.shutdownNow(); + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) + log.error("线程池未关闭!"); + } + } catch (InterruptedException ie) { + this.executorService.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + /** *
    * 设置自定义的 {@link ExecutorService}
    * 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100)
    * 
+ * + * @param executorService the executor service */ public void setExecutorService(ExecutorService executorService) { this.executorService = executorService; @@ -91,6 +132,8 @@ public void setExecutorService(ExecutorService executorService) { * 设置自定义的 {@link me.chanjar.weixin.common.api.WxMessageDuplicateChecker} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker} *
+ * + * @param messageDuplicateChecker the message duplicate checker */ public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicateChecker) { this.messageDuplicateChecker = messageDuplicateChecker; @@ -101,6 +144,8 @@ public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicat * 设置自定义的{@link me.chanjar.weixin.common.session.WxSessionManager} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.session.StandardSessionManager} *
+ * + * @param sessionManager the session manager */ public void setSessionManager(WxSessionManager sessionManager) { this.sessionManager = sessionManager; @@ -111,17 +156,26 @@ public void setSessionManager(WxSessionManager sessionManager) { * 设置自定义的{@link me.chanjar.weixin.common.api.WxErrorExceptionHandler} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.util.LogExceptionHandler} *
+ * + * @param exceptionHandler the exception handler */ public void setExceptionHandler(WxErrorExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } + /** + * Gets rules. + * + * @return the rules + */ List getRules() { return this.rules; } /** * 开始一个新的Route规则. + * + * @return the wx cp message router rule */ public WxCpMessageRouterRule rule() { return new WxCpMessageRouterRule(this); @@ -129,6 +183,10 @@ public WxCpMessageRouterRule rule() { /** * 处理微信消息. + * + * @param wxMessage the wx message + * @param context the context + * @return the wx cp xml out message */ public WxCpXmlOutMessage route(final WxCpXmlMessage wxMessage, final Map context) { if (isMsgDuplicated(wxMessage)) { @@ -158,7 +216,8 @@ public WxCpXmlOutMessage route(final WxCpXmlMessage wxMessage, final Map { - rule.service(wxMessage, context, WxCpMessageRouter.this.wxCpService, WxCpMessageRouter.this.sessionManager, WxCpMessageRouter.this.exceptionHandler); + rule.service(wxMessage, context, WxCpMessageRouter.this.wxCpService, + WxCpMessageRouter.this.sessionManager, WxCpMessageRouter.this.exceptionHandler); }) ); } else { @@ -191,6 +250,9 @@ public WxCpXmlOutMessage route(final WxCpXmlMessage wxMessage, final Map(2)); @@ -209,18 +271,25 @@ private boolean isMsgDuplicated(WxCpXmlMessage wxMessage) { .append("-").append(wxMessage.getCreateTime()) .append("-").append(wxMessage.getFromUserName()); } - - if (StringUtils.isNotEmpty(wxMessage.getUserId())) { - messageId.append("-").append(wxMessage.getUserId()); - } - - if (StringUtils.isNotEmpty(wxMessage.getChangeType())) { - messageId.append("-").append(wxMessage.getChangeType()); + if (Objects.nonNull(wxMessage.getApprovalInfo())) { + append(messageId, wxMessage.getApprovalInfo().getSpNo()); } + append(messageId, wxMessage.getUserId()); + append(messageId, wxMessage.getChangeType()); + append(messageId, wxMessage.getTagId()); + append(messageId, wxMessage.getId()); + append(messageId, wxMessage.getChatId()); + append(messageId, wxMessage.getExternalUserId()); return this.messageDuplicateChecker.isDuplicate(messageId.toString()); } + private void append(StringBuilder sb, String value) { + if (StringUtils.isNotEmpty(value)) { + sb.append("-").append(value); + } + } + /** * 对session的访问结束. */ diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java index 739bb0330f..ba33392e63 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java @@ -183,7 +183,8 @@ public WxCpMessageRouterRule interceptor(WxCpMessageInterceptor interceptor) { * @param otherInterceptors the other interceptors * @return the wx cp message router rule */ - public WxCpMessageRouterRule interceptor(WxCpMessageInterceptor interceptor, WxCpMessageInterceptor... otherInterceptors) { + public WxCpMessageRouterRule interceptor(WxCpMessageInterceptor interceptor, + WxCpMessageInterceptor... otherInterceptors) { this.interceptors.add(interceptor); if (otherInterceptors != null && otherInterceptors.length > 0) { Collections.addAll(this.interceptors, otherInterceptors); @@ -246,7 +247,7 @@ protected boolean test(WxCpXmlMessage wxMessage) { return (this.fromUser == null || this.fromUser.equals(wxMessage.getFromUserName())) && - (this.agentId == null || this.agentId.equals(wxMessage.getAgentId())) + (this.agentId == null || this.agentId.equals(Integer.valueOf(wxMessage.getAgentId()))) && (this.msgType == null || this.msgType.equalsIgnoreCase(wxMessage.getMsgType())) && @@ -254,7 +255,8 @@ protected boolean test(WxCpXmlMessage wxMessage) { && (this.eventKey == null || this.eventKey.equalsIgnoreCase(wxMessage.getEventKey())) && - (this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey()))) + (this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, + StringUtils.trimToEmpty(wxMessage.getEventKey()))) && (this.content == null || this.content.equals(StringUtils.trimToNull(wxMessage.getContent()))) && diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageMatcher.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageMatcher.java index 57e35f1946..882e330b8b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageMatcher.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageMatcher.java @@ -1,7 +1,6 @@ package me.chanjar.weixin.cp.tp.message; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; -import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; /** * 消息匹配器,用在消息路由的时候 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouter.java index 5b045082a8..831de148f9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouter.java @@ -5,6 +5,7 @@ import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker; +import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateCheckerSingleton; import me.chanjar.weixin.common.session.InternalSession; import me.chanjar.weixin.common.session.InternalSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; @@ -67,22 +68,66 @@ public class WxCpTpMessageRouter { /** * 构造方法. + * + * @param wxCpTpService the wx cp tp service */ public WxCpTpMessageRouter(WxCpTpService wxCpTpService) { this.wxCpTpService = wxCpTpService; ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxCpTpMessageRouter-pool-%d").build(); this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); - this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); this.sessionManager = wxCpTpService.getSessionManager(); this.exceptionHandler = new LogExceptionHandler(); } + /** + * 使用自定义的 {@link ExecutorService}. + * + * @param wxCpTpService the wx cp tp service + * @param executorService the executor service + */ + public WxCpTpMessageRouter(WxCpTpService wxCpTpService, ExecutorService executorService) { + this.wxCpTpService = wxCpTpService; + this.executorService = executorService; + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); + this.sessionManager = wxCpTpService.getSessionManager(); + this.exceptionHandler = new LogExceptionHandler(); + } + + /** + * 系统退出前,应该调用该方法 + */ + public void shutDownExecutorService() { + this.executorService.shutdown(); + } + + /** + * 系统退出前,应该调用该方法,增加了超时时间检测 + * + * @param second the second + */ + public void shutDownExecutorService(Integer second) { + this.executorService.shutdown(); + try { + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { + this.executorService.shutdownNow(); + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) + log.error("线程池未关闭!"); + } + } catch (InterruptedException ie) { + this.executorService.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + /** *
    * 设置自定义的 {@link ExecutorService}
    * 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100)
    * 
+ * + * @param executorService the executor service */ public void setExecutorService(ExecutorService executorService) { this.executorService = executorService; @@ -93,6 +138,8 @@ public void setExecutorService(ExecutorService executorService) { * 设置自定义的 {@link WxMessageDuplicateChecker} * 如果不调用该方法,默认使用 {@link WxMessageInMemoryDuplicateChecker} *
+ * + * @param messageDuplicateChecker the message duplicate checker */ public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicateChecker) { this.messageDuplicateChecker = messageDuplicateChecker; @@ -103,6 +150,8 @@ public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicat * 设置自定义的{@link WxSessionManager} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.session.StandardSessionManager} * + * + * @param sessionManager the session manager */ public void setSessionManager(WxSessionManager sessionManager) { this.sessionManager = sessionManager; @@ -113,17 +162,26 @@ public void setSessionManager(WxSessionManager sessionManager) { * 设置自定义的{@link WxErrorExceptionHandler} * 如果不调用该方法,默认使用 {@link LogExceptionHandler} * + * + * @param exceptionHandler the exception handler */ public void setExceptionHandler(WxErrorExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } + /** + * Gets rules. + * + * @return the rules + */ List getRules() { return this.rules; } /** * 开始一个新的Route规则. + * + * @return the wx cp tp message router rule */ public WxCpTpMessageRouterRule rule() { return new WxCpTpMessageRouterRule(this); @@ -131,6 +189,10 @@ public WxCpTpMessageRouterRule rule() { /** * 处理微信消息. + * + * @param wxMessage the wx message + * @param context the context + * @return the wx cp xml out message */ public WxCpXmlOutMessage route(final WxCpTpXmlMessage wxMessage, final Map context) { if (isMsgDuplicated(wxMessage)) { @@ -160,7 +222,8 @@ public WxCpXmlOutMessage route(final WxCpTpXmlMessage wxMessage, final Map { - rule.service(wxMessage, context, WxCpTpMessageRouter.this.wxCpTpService, WxCpTpMessageRouter.this.sessionManager, WxCpTpMessageRouter.this.exceptionHandler); + rule.service(wxMessage, context, WxCpTpMessageRouter.this.wxCpTpService, + WxCpTpMessageRouter.this.sessionManager, WxCpTpMessageRouter.this.exceptionHandler); }) ); } else { @@ -193,6 +256,9 @@ public WxCpXmlOutMessage route(final WxCpTpXmlMessage wxMessage, final Map(2)); @@ -200,30 +266,30 @@ public WxCpXmlOutMessage route(final WxCpTpXmlMessage wxMessage) { private boolean isMsgDuplicated(WxCpTpXmlMessage wxMessage) { StringBuilder messageId = new StringBuilder(); - if (wxMessage.getInfoType() != null) { - messageId.append(wxMessage.getInfoType()) - .append("-").append(StringUtils.trimToEmpty(wxMessage.getSuiteId())) - .append("-").append(wxMessage.getTimeStamp()) - .append("-").append(StringUtils.trimToEmpty(wxMessage.getAuthCorpId())) - .append("-").append(StringUtils.trimToEmpty(wxMessage.getUserID())) - .append("-").append(StringUtils.trimToEmpty(wxMessage.getChangeType())) - .append("-").append(StringUtils.trimToEmpty(wxMessage.getServiceCorpId())); - } + if (wxMessage.getInfoType() != null) { + messageId.append(wxMessage.getInfoType()) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getSuiteId())) + .append("-").append(wxMessage.getTimeStamp()) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getAuthCorpId())) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getUserID())) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getChangeType())) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getServiceCorpId())) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getExternalUserID())); + } - if (wxMessage.getMsgType() != null) { - if (wxMessage.getMsgId() != null) { - messageId.append(wxMessage.getMsgId()) - .append("-").append(wxMessage.getCreateTime()) - .append("-").append(wxMessage.getFromUserName()); - } - else { - messageId.append(wxMessage.getMsgType()) - .append("-").append(wxMessage.getCreateTime()) - .append("-").append(wxMessage.getFromUserName()) - .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent())) - .append("-").append(StringUtils.trimToEmpty(wxMessage.getEventKey())); - } + if (wxMessage.getMsgType() != null) { + if (wxMessage.getMsgId() != null) { + messageId.append(wxMessage.getMsgId()) + .append("-").append(wxMessage.getCreateTime()) + .append("-").append(wxMessage.getFromUserName()); + } else { + messageId.append(wxMessage.getMsgType()) + .append("-").append(wxMessage.getCreateTime()) + .append("-").append(wxMessage.getFromUserName()) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent())) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getEventKey())); } + } return this.messageDuplicateChecker.isDuplicate(messageId.toString()); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouterRule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouterRule.java index 243a17d1b4..434094aa80 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouterRule.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouterRule.java @@ -100,6 +100,7 @@ public WxCpTpMessageRouterRule event(String event) { * 匹配 Message infoType * * @param infoType info + * @return the wx cp tp message router rule */ public WxCpTpMessageRouterRule infoType(String infoType) { this.infoType = infoType; @@ -108,8 +109,9 @@ public WxCpTpMessageRouterRule infoType(String infoType) { /** * 如果changeType等于这个type,符合rule的条件之一 - * @param changeType - * @return + * + * @param changeType the change type + * @return wx cp tp message router rule */ public WxCpTpMessageRouterRule changeType(String changeType) { this.changeType = changeType; @@ -145,7 +147,8 @@ public WxCpTpMessageRouterRule interceptor(WxCpTpMessageInterceptor interceptor) * @param otherInterceptors the other interceptors * @return the wx cp message router rule */ - public WxCpTpMessageRouterRule interceptor(WxCpTpMessageInterceptor interceptor, WxCpTpMessageInterceptor... otherInterceptors) { + public WxCpTpMessageRouterRule interceptor(WxCpTpMessageInterceptor interceptor, + WxCpTpMessageInterceptor... otherInterceptors) { this.interceptors.add(interceptor); if (otherInterceptors != null && otherInterceptors.length > 0) { Collections.addAll(this.interceptors, otherInterceptors); @@ -220,7 +223,8 @@ protected boolean test(WxCpTpXmlMessage wxMessage) { && (this.suiteTicket == null || this.suiteTicket.equalsIgnoreCase(wxMessage.getSuiteTicket())) && - (this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey()))) + (this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, + StringUtils.trimToEmpty(wxMessage.getEventKey()))) && (this.content == null || this.content.equals(StringUtils.trimToNull(wxMessage.getContent()))) && diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpContactService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpContactService.java index d25987c9da..be99a2a514 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpContactService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpContactService.java @@ -5,18 +5,20 @@ import me.chanjar.weixin.cp.bean.WxCpTpContactSearchResp; /** + * The interface Wx cp tp contact service. + * * @author uianz - * @description - * @since 2020/12/23 下午 02:39 + * @since 2020 /12/23 下午 02:39 */ public interface WxCpTpContactService { - /** - * https://work.weixin.qq.com/api/doc/90001/90143/91844 - * 通讯录单个搜索 - * @param wxCpTpContactSearch - * @return - * @throws WxErrorException - */ - WxCpTpContactSearchResp contactSearch(WxCpTpContactSearch wxCpTpContactSearch) throws WxErrorException; + /** + * https://work.weixin.qq.com/api/doc/90001/90143/91844 + * 通讯录单个搜索 + * + * @param wxCpTpContactSearch the wx cp tp contact search + * @return wx cp tp contact search resp + * @throws WxErrorException the wx error exception + */ + WxCpTpContactSearchResp contactSearch(WxCpTpContactSearch wxCpTpContactSearch) throws WxErrorException; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpDepartmentService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpDepartmentService.java index b7ede9ae21..8cbd17d6de 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpDepartmentService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpDepartmentService.java @@ -13,63 +13,65 @@ */ public interface WxCpTpDepartmentService { - /** - *
-     * 部门管理接口 - 创建部门.
-     * 最多支持创建500个部门
-     * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90205
-     * 
- * - * @param depart 部门 - * @return 部门id - * @throws WxErrorException 异常 - */ - Long create(WxCpTpDepart depart) throws WxErrorException; + /** + *
+   * 部门管理接口 - 创建部门.
+   * 最多支持创建500个部门
+   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90205
+   * 
+ * + * @param depart 部门 + * @return 部门id long + * @throws WxErrorException 异常 + */ + Long create(WxCpTpDepart depart) throws WxErrorException; - /** - *
-     * 部门管理接口 - 获取部门列表.
-     * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90208
-     * 
- * - * @param id 部门id。获取指定部门及其下的子部门。非必需,可为null - * @return 获取的部门列表 - * @throws WxErrorException 异常 - */ - List list(Long id, String corpId) throws WxErrorException; + /** + *
+   * 部门管理接口 - 获取部门列表.
+   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90208
+   * 
+ * + * @param id 部门id。获取指定部门及其下的子部门。非必需,可为null + * @param corpId the corp id + * @return 获取的部门列表 list + * @throws WxErrorException 异常 + */ + List list(Long id, String corpId) throws WxErrorException; - /** - *
-     * 部门管理接口 - 更新部门.
-     * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90206
-     * 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
-     * 
- * - * @param group 要更新的group,group的id,name必须设置 - * @throws WxErrorException 异常 - */ - void update(WxCpTpDepart group) throws WxErrorException; + /** + *
+   * 部门管理接口 - 更新部门.
+   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90206
+   * 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
+   * 
+ * + * @param group 要更新的group,group的id,name必须设置 + * @throws WxErrorException 异常 + */ + void update(WxCpTpDepart group) throws WxErrorException; - /** - *
-     * 部门管理接口 - 删除部门.
-     * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90207
-     * 应用须拥有指定部门的管理权限
-     * 
- * - * @param departId 部门id - * @throws WxErrorException 异常 - */ - void delete(Long departId) throws WxErrorException; + /** + *
+   * 部门管理接口 - 删除部门.
+   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90207
+   * 应用须拥有指定部门的管理权限
+   * 
+ * + * @param departId 部门id + * @throws WxErrorException 异常 + */ + void delete(Long departId) throws WxErrorException; - /** - *
-     * 部门管理接口 - 获取部门列表.
-     * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90208
-     * 
- * - * @return 获取所有的部门列表 - * @throws WxErrorException 异常 - */ - List list(String corpId) throws WxErrorException; + /** + *
+   * 部门管理接口 - 获取部门列表.
+   * 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/90208
+   * 
+ * + * @param corpId the corp id + * @return 获取所有的部门列表 list + * @throws WxErrorException 异常 + */ + List list(String corpId) throws WxErrorException; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpEditionService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpEditionService.java new file mode 100644 index 0000000000..2c2f11628b --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpEditionService.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.cp.tp.service; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult; + + +/** + * 应用版本付费版本相关接口 + * + * @author leiguoqing created on 2022年4月24日 + */ +public interface WxCpTpEditionService { + + /** + * 延长试用期 + *

+ * 文档地址 + *

+ * 注意: + *

    + *
  • 一个应用可以多次延长试用,但是试用总天数不能超过60天
  • + *
  • 仅限时试用或试用过期状态下的应用可以延长试用期
  • + *
+ * + * @param buyerCorpId 购买方corpId + * @param prolongDays 延长天数 + * @param appId 仅旧套件需要填此参数 + * @return the order + * @throws WxErrorException the wx error exception + */ + WxCpTpProlongTryResult prolongTry(String buyerCorpId, Integer prolongDays, String appId) throws WxErrorException; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpIdConvertService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpIdConvertService.java new file mode 100644 index 0000000000..78c52d5c36 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpIdConvertService.java @@ -0,0 +1,61 @@ +package me.chanjar.weixin.cp.tp.service; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpTpConvertTmpExternalUserIdResult; +import me.chanjar.weixin.cp.bean.WxCpTpOpenKfIdConvertResult; +import me.chanjar.weixin.cp.bean.WxCpTpTagIdListConvertResult; +import me.chanjar.weixin.cp.bean.WxCpTpUnionidToExternalUseridResult; + +import java.util.List; + +/** + *
+ *  企业微信三方应用ID转换接口
+ *
+ * 
+ * + * @author cocoa + */ +public interface WxCpTpIdConvertService { + + /** + * unionid与external_userid的关联 + * 查看文档 + * + * @param unionid 微信客户的unionid + * @param openid 微信客户的openid + * @param subjectType 程序或公众号的主体类型: 0表示主体名称是企业的,1表示主体名称是服务商的 + * @throws WxErrorException 。 + */ + WxCpTpUnionidToExternalUseridResult unionidToExternalUserid(String cropId, String unionid, String openid, + Integer subjectType) throws WxErrorException; + + + /** + * 将企业主体下的客户标签ID转换成服务商主体下的客户标签ID + * @param corpId 企业微信 ID + * @param externalTagIdList 企业主体下的客户标签ID列表,最多不超过1000个 + * @return 客户标签转换结果 + * @throws WxErrorException . + */ + WxCpTpTagIdListConvertResult externalTagId(String corpId, String... externalTagIdList) throws WxErrorException; + + /** + * 将企业主体下的微信客服ID转换成服务商主体下的微信客服ID + * @param corpId 企业微信 ID + * @param openKfIdList 微信客服ID列表,最多不超过1000个 + * @return 微信客服ID转换结果 + * @throws WxErrorException . + */ + WxCpTpOpenKfIdConvertResult ConvertOpenKfId (String corpId, String... openKfIdList ) throws WxErrorException; + + /** + * 将应用获取的外部用户临时idtmp_external_userid,转换为external_userid + * @param corpId 企业微信Id + * @param businessType 业务类型。1-会议 2-收集表 + * @param userType 转换的目标用户类型。1-客户 2-企业互联 3-上下游 4-互联企业(圈子) + * @param tmpExternalUserIdList 外部用户临时id,最多不超过100个 + * @return 转换成功的结果列表 + */ + WxCpTpConvertTmpExternalUserIdResult convertTmpExternalUserId(String corpId, int businessType, int userType, String... tmpExternalUserIdList) throws WxErrorException; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpLicenseService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpLicenseService.java new file mode 100644 index 0000000000..66c5166d45 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpLicenseService.java @@ -0,0 +1,205 @@ +package me.chanjar.weixin.cp.tp.service; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer; +import me.chanjar.weixin.cp.bean.license.account.*; +import me.chanjar.weixin.cp.bean.license.order.*; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + *
+ * 服务商接口调用许可相关接口
+ * 文档地址:https://developer.work.weixin.qq.com/document/path/95652
+ * 
+ * + * @author Totoro created on 2022/6/27 10:57 + */ +public interface WxCpTpLicenseService { + + + /** + * 下单购买帐号 + * 服务商下单为企业购买新的帐号,可以同时购买基础帐号与互通帐号。 + * 下单之后,需要到服务商管理端发起支付,支付完成之后,订单才能生效。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95644 + * + * @param licenseNewOrderRequest 订单信息 + * @return 订单ID wx cp tp license create order resp + * @throws WxErrorException ; + */ + WxCpTpLicenseCreateOrderResp createNewOrder(WxCpTpLicenseNewOrderRequest licenseNewOrderRequest) throws WxErrorException; + + + /** + * 创建下单续期帐号任务 + *
+   *  可以下单为一批已激活帐号的成员续期,续期下单分为两个步骤:
+   * 传入userid列表创建一个任务,创建之后,可以往同一个任务继续追加待续期的userid列表;
+   * 根据步骤1得到的jobid提交订单。
+   * 
+ * + * @param licenseRenewOrderJobRequest 续费订单信息 + * @return 返回JobId wx cp tp license renew order job resp + * @throws WxErrorException ; + */ + WxCpTpLicenseRenewOrderJobResp createRenewOrderJob(WxCpTpLicenseRenewOrderJobRequest licenseRenewOrderJobRequest) throws WxErrorException; + + + /** + * 提交续期订单 + * 创建续期任务之后,需要调用该接口,以提交订单任务。 + * 注意,提交之后,需要到服务商管理端发起支付,支付完成之后,订单才能生效。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95646 + * + * @param licenseRenewOrderRequest 订单信息 + * @return 订单ID wx cp tp license create order resp + * @throws WxErrorException ; + */ + WxCpTpLicenseCreateOrderResp submitRenewOrder(WxCpTpLicenseRenewOrderRequest licenseRenewOrderRequest) throws WxErrorException; + + + /** + * 获取订单列表 + * 服务商查询自己某段时间内的平台能力服务订单列表 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95647 + * + * @param corpId 企业ID + * @param startTime 开始时间,下单时间。可不填。但是不能单独指定该字段,start_time跟end_time必须同时指定。 + * @param endTime 结束时间,下单时间。起始时间跟结束时间不能超过31天。可不填。但是不能单独指定该字段,start_time跟end_time必须同时指定。 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @param limit 返回的最大记录数,整型,最大值1000,默认值500 + * @return 订单列表 order list + * @throws WxErrorException ; + */ + WxCpTpLicenseOrderListResp getOrderList(String corpId, Date startTime, Date endTime, String cursor, int limit) throws WxErrorException; + + + /** + * 获取订单详情 + * 查询某个订单的详情,包括订单的状态、基础帐号个数、互通帐号个数、帐号购买时长等。 + * 注意,该接口不返回订单中的帐号激活码列表或者续期的帐号成员列表,请调用获取订单中的帐号列表接口以获取帐号列表。 + * + * @param orderId 订单ID + * @return 单条订单信息 order info + * @throws WxErrorException ; + */ + WxCpTpLicenseOrderInfoResp getOrderInfo(String orderId) throws WxErrorException; + + + /** + * 查询指定订单下的平台能力服务帐号列表。 + * 若为购买帐号的订单或者存量企业的版本付费迁移订单,则返回帐号激活码列表; + * 若为续期帐号的订单,则返回续期帐号的成员列表。注意,若是购买帐号的订单, + * 则仅订单支付完成时,系统才会生成帐号,故支付完成之前,该接口不会返回帐号激活码。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95649 + * + * @param orderId 订单ID + * @param limit 大小 + * @param cursor 分页游标 + * @return 订单账号列表 order account list + * @throws WxErrorException ; + */ + WxCpTpLicenseOrderAccountListResp getOrderAccountList(String orderId, int limit, String cursor) throws WxErrorException; + + + /** + * 激活帐号 + * 下单购买帐号并支付完成之后,先调用获取订单中的帐号列表接口获取到帐号激活码, + * 然后可以调用该接口将激活码绑定到某个企业员工,以对其激活相应的平台服务能力。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95553 + * + * @param code 激活码 + * @param corpId 企业ID + * @param userId 用户ID + * @return 激活结果 wx cp base resp + * @throws WxErrorException ; + */ + WxCpBaseResp activeCode(String code, String corpId, String userId) throws WxErrorException; + + + /** + * 批量激活帐号 + * 可在一次请求里为一个企业的多个成员激活许可帐号,便于服务商批量化处理。 + * 一个userid允许激活一个基础帐号以及一个互通帐号。 + * 单次激活的员工数量不超过1000 + * + * @param corpId 企业ID + * @param activeAccountList 激活列表 + * @return 激活结果 wx cp tp license batch active result resp + * @throws WxErrorException ; + */ + WxCpTpLicenseBatchActiveResultResp batchActiveCode(String corpId, + List activeAccountList) throws WxErrorException; + + + /** + * 获取激活码详情 + * 查询某个帐号激活码的状态以及激活绑定情况。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95552 + * + * @param code 激活码 + * @param corpId 企业ID + * @return 激活码信息 active info by code + * @throws WxErrorException ; + */ + WxCpTpLicenseCodeInfoResp getActiveInfoByCode(String code, String corpId) throws WxErrorException; + + + /** + * 获取激活码详情 + * 查询某个帐号激活码的状态以及激活绑定情况。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95552 + * + * @param codes 激活码 + * @param corpId 企业ID + * @return 激活码信息 wx cp tp license batch code info resp + * @throws WxErrorException ; + */ + WxCpTpLicenseBatchCodeInfoResp batchGetActiveInfoByCode(Collection codes, String corpId) throws WxErrorException; + + + /** + * 获取企业的帐号列表 + * 查询指定企业下的平台能力服务帐号列表。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95544 + * + * @param corpId 企业ID + * @param limit 大小 + * @param cursor 游标 + * @return 已激活列表 corp account list + * @throws WxErrorException the wx error exception + */ + WxCpTpLicenseCorpAccountListResp getCorpAccountList(String corpId, int limit, String cursor) throws WxErrorException; + + + /** + * 获取成员的激活详情 + * 查询某个企业成员的激活情况。 + * 文档地址:https://developer.work.weixin.qq.com/document/path/95555 + * + * @param corpId 企业ID + * @param userId 用户ID + * @return 激活情况 active info by user + * @throws WxErrorException ; + */ + WxCpTpLicenseActiveInfoByUserResp getActiveInfoByUser(String corpId, String userId) throws WxErrorException; + + + /** + * 帐号继承 + * 在企业员工离职或者工作范围的有变更时,允许将其许可帐号继承给其他员工。 + * + * @param corpId 企业ID + * @param transferList 转移列表 + * @return 转移结果 wx cp tp license batch transfer resp + * @throws WxErrorException ; + */ + WxCpTpLicenseBatchTransferResp batchTransferLicense(String corpId, List transferList) throws WxErrorException; + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpMediaService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpMediaService.java index f3a611e84f..8aa58d3dc1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpMediaService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpMediaService.java @@ -17,48 +17,54 @@ */ public interface WxCpTpMediaService { - /** - *
-     * 上传多媒体文件.
-     * 上传的多媒体文件有格式和大小限制,如下:
-     *   图片(image): 1M,支持JPG格式
-     *   语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式
-     *   视频(video):10MB,支持MP4格式
-     *   缩略图(thumb):64KB,支持JPG格式
-     * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
-     * 
- * - * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} - * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} - * @param inputStream 输入流,需要调用方控制关闭该输入流 - */ - WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream, String corpId) - throws WxErrorException, IOException; + /** + *
+   * 上传多媒体文件.
+   * 上传的多媒体文件有格式和大小限制,如下:
+   *   图片(image): 1M,支持JPG格式
+   *   语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式
+   *   视频(video):10MB,支持MP4格式
+   *   缩略图(thumb):64KB,支持JPG格式
+   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
+   * 
+ * + * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param inputStream 输入流,需要调用方控制关闭该输入流 + * @param corpId the corp id + * @return the wx media upload result + * @throws WxErrorException the wx error exception + * @throws IOException the io exception + */ + WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream, String corpId) + throws WxErrorException, IOException; - /** - * 上传多媒体文件. - * - * @param mediaType 媒体类型 - * @param file 文件对象 - * @param corpId 授权企业的corpid - * @see #upload(String, String, InputStream, String) - * @throws WxErrorException 异常信息 - */ - WxMediaUploadResult upload(String mediaType, File file, String corpId) throws WxErrorException; + /** + * 上传多媒体文件. + * + * @param mediaType 媒体类型 + * @param file 文件对象 + * @param corpId 授权企业的corpid + * @return the wx media upload result + * @throws WxErrorException 异常信息 + * @see #upload(String, String, InputStream, String) #upload(String, String, InputStream, String) + */ + WxMediaUploadResult upload(String mediaType, File file, String corpId) throws WxErrorException; - /** - *
-     * 上传图片.
-     * 上传图片得到图片URL,该URL永久有效
-     * 返回的图片URL,仅能用于图文消息(mpnews)正文中的图片展示;若用于非企业微信域名下的页面,图片将被屏蔽。
-     * 每个企业每天最多可上传100张图片
-     * 接口url格式:https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
-     * 
- * @param file 上传的文件对象 - * @param corpId 授权企业的corpid - * @return 返回图片url - * @throws WxErrorException 异常信息 - */ - String uploadImg(File file, String corpId) throws WxErrorException; + /** + *
+   * 上传图片.
+   * 上传图片得到图片URL,该URL永久有效
+   * 返回的图片URL,仅能用于图文消息(mpnews)正文中的图片展示;若用于非企业微信域名下的页面,图片将被屏蔽。
+   * 每个企业每天最多可上传100张图片
+   * 接口url格式:https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
+   * 
+ * + * @param file 上传的文件对象 + * @param corpId 授权企业的corpid + * @return 返回图片url string + * @throws WxErrorException 异常信息 + */ + String uploadImg(File file, String corpId) throws WxErrorException; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAService.java index d6e65b6974..85321213ab 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAService.java @@ -4,57 +4,60 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult; import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest; -import me.chanjar.weixin.cp.bean.oa.WxCpTemplateResult; +import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult; /** * 企业微信OA相关接口. * - * @author Element - * @date 2019-04-06 10:52 + * @author Element created on 2019-04-06 10:52 */ public interface WxCpTpOAService { - /** - *
提交审批申请
-     * 调试工具
-     * 企业可通过审批应用或自建应用Secret调用本接口,代应用可见范围内员工在企业微信“审批应用”内提交指定类型的审批申请。
-     *
-     * 请求方式:POST(HTTPS)
-     * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token=ACCESS_TOKEN
-     * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91853
-     * 
- * - * @param request 请求 - * @return 表单提交成功后,返回的表单编号 - * @throws WxErrorException . - */ - String apply(WxCpOaApplyEventRequest request, String corpId) throws WxErrorException; + /** + *
提交审批申请
+   * 调试工具
+   * 企业可通过审批应用或自建应用Secret调用本接口,代应用可见范围内员工在企业微信“审批应用”内提交指定类型的审批申请。
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token=ACCESS_TOKEN
+   * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91853
+   * 
+ * + * @param request 请求 + * @param corpId the corp id + * @return 表单提交成功后 ,返回的表单编号 + * @throws WxErrorException . + */ + String apply(WxCpOaApplyEventRequest request, String corpId) throws WxErrorException; - /** - * 获取审批模板详情 - * - * @param templateId 模板ID - * @return . - * @throws WxErrorException . - */ - WxCpTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException; + /** + * 获取审批模板详情 + * + * @param templateId 模板ID + * @param corpId the corp id + * @return . template detail + * @throws WxErrorException . + */ + WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException; - /** - * 复制/更新模板到企业 - * - * @param openTemplateId 模板ID - * @return . - * @throws WxErrorException . - */ - String copyTemplate(@NonNull String openTemplateId, String corpId) throws WxErrorException; + /** + * 复制/更新模板到企业 + * + * @param openTemplateId 模板ID + * @param corpId the corp id + * @return . string + * @throws WxErrorException . + */ + String copyTemplate(@NonNull String openTemplateId, String corpId) throws WxErrorException; - /** - *
-     *   获取审批申请详情
-     *
-     * @param spNo 审批单编号。
-     * @return WxCpApprovaldetail
-     * @throws WxErrorException .
-     */
-    WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo, String corpId) throws WxErrorException;
+  /**
+   * 
+   *   获取审批申请详情
+   *
+   * @param spNo 审批单编号。
+   * @param corpId the corp id
+   * @return WxCpApprovaldetail approval detail
+   * @throws WxErrorException .
+   */
+  WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo, String corpId) throws WxErrorException;
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAuth2Service.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAuth2Service.java
new file mode 100644
index 0000000000..0746feea2b
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAuth2Service.java
@@ -0,0 +1,34 @@
+package me.chanjar.weixin.cp.tp.service;
+
+/**
+ * 
+ *   构造第三方应用oauth2链接
+ *   Created by feidian108 on 2023/3/24.
+ * 
+ *

+ * 企业微信服务商文档 + */ +public interface WxCpTpOAuth2Service { + + /** + *

+   *   构造第三方应用oauth2链接(静默授权)
+   * 
+ * @param redirectUri 授权后重定向的回调链接地址 + * @param state 重定向后state参数 + * @return url string + */ + String buildAuthorizeUrl(String redirectUri, String state); + + + /** + *
+   *   构造第三方应用oauth2链接
+   * 
+ * @param redirectUri 授权后重定向的回调链接地址 + * @param state 重定向后state参数 + * @param scope 应用授权作用域,snsapi_base:静默授权,snsapi_privateinfo:手动授权 + * @return url string + */ + String buildAuthorizeUrl(String redirectUri, String state, String scope); +} 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 new file mode 100644 index 0000000000..3aff90bb56 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOrderService.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.cp.tp.service; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails; +import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult; + +import java.util.Date; + + +/** + * 应用版本付费订单相关接口 + * + * @author leiguoqing created on 2022年4月24日 + */ +public interface WxCpTpOrderService { + + /** + * 获取订单详情 + *

+ * 文档地址 + *

+ * + * @param orderId 订单号 + * @return the order + * @throws WxErrorException the wx error exception + */ + WxCpTpOrderDetails getOrder(String orderId) throws WxErrorException; + + + /** + * 获取订单列表 + *

+ * 文档地址 + *

+ * + * @param startTime 起始时间 + * @param endTime 终止时间 + * @param testMode 指定拉取正式或测试模式的订单。默认正式模式。0-正式模式,1-测试模式。 + * @return the order + * @throws WxErrorException the wx error exception + */ + WxCpTpOrderListGetResult getOrderList(Date startTime, Date endTime, Integer testMode) throws WxErrorException; +} 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 bd44911feb..356fe64adb 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 @@ -10,6 +10,8 @@ import me.chanjar.weixin.cp.bean.*; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import java.util.List; + /** * 企业微信第三方应用API的Service. * @@ -36,6 +38,7 @@ public interface WxCpTpService { * @return the suite access token * @throws WxErrorException the wx error exception * @see #getSuiteAccessToken(boolean) #getSuiteAccessToken(boolean)#getSuiteAccessToken(boolean) + * #getSuiteAccessToken(boolean) */ String getSuiteAccessToken() throws WxErrorException; @@ -56,15 +59,18 @@ public interface WxCpTpService { /** * 获取suite_access_token和剩余过期时间, 不强制刷新suite_access_token + * * @return suite access token and the remaining expiration time + * @throws WxErrorException the wx error exception */ WxAccessToken getSuiteAccessTokenEntity() throws WxErrorException; /** * 获取suite_access_token和剩余过期时间, 支持强制刷新suite_access_token + * * @param forceRefresh 是否调用微信服务器强制刷新token * @return suite access token and the remaining expiration time - * @throws WxErrorException + * @throws WxErrorException the wx error exception */ WxAccessToken getSuiteAccessTokenEntity(boolean forceRefresh) throws WxErrorException; @@ -73,7 +79,7 @@ public interface WxCpTpService { * * @return the suite ticket * @throws WxErrorException the wx error exception - * @see #getSuiteTicket(boolean) #getSuiteTicket(boolean)#getSuiteTicket(boolean) + * @see #getSuiteTicket(boolean) #getSuiteTicket(boolean)#getSuiteTicket(boolean)#getSuiteTicket(boolean) */ String getSuiteTicket() throws WxErrorException; @@ -101,7 +107,7 @@ public interface WxCpTpService { * @param forceRefresh 强制刷新 * @return the suite ticket * @throws WxErrorException the wx error exception - * @see #setSuiteTicket(String) #setSuiteTicket(String) + * @see #setSuiteTicket(String) #setSuiteTicket(String)#setSuiteTicket(String) * @deprecated 由于无法主动刷新 ,所以这个接口实际已经没有意义,需要在接收企业微信的主动推送后,保存这个ticket */ @Deprecated @@ -132,10 +138,11 @@ public interface WxCpTpService { /** * 获取应用的 jsapi ticket, 支持强制刷新 - * @param authCorpId - * @param forceRefresh - * @return - * @throws WxErrorException + * + * @param authCorpId the auth corp id + * @param forceRefresh the force refresh + * @return suite js api ticket + * @throws WxErrorException the wx error exception */ String getSuiteJsApiTicket(String authCorpId, boolean forceRefresh) throws WxErrorException; @@ -160,11 +167,12 @@ public interface WxCpTpService { /** * 获取企业凭证, 支持强制刷新 - * @param authCorpId - * @param permanentCode - * @param forceRefresh - * @return - * @throws WxErrorException + * + * @param authCorpId the auth corp id + * @param permanentCode the permanent code + * @param forceRefresh the force refresh + * @return corp token + * @throws WxErrorException the wx error exception */ WxAccessToken getCorpToken(String authCorpId, String permanentCode, boolean forceRefresh) throws WxErrorException; @@ -208,9 +216,10 @@ public interface WxCpTpService { *

    *   获取预授权链接,测试环境下使用
    * 
+ * * @param redirectUri 授权完成后的回调网址 - * @param state a-zA-Z0-9的参数值(不超过128个字节),用于第三方自行校验session,防止跨域攻击 - * @param authType 授权类型:0 正式授权, 1 测试授权。 + * @param state a-zA-Z0-9的参数值(不超过128个字节),用于第三方自行校验session,防止跨域攻击 + * @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 @@ -238,10 +247,11 @@ public interface WxCpTpService { /** * 获取授权企业的 jsapi ticket, 支持强制刷新 - * @param authCorpId - * @param forceRefresh - * @return - * @throws WxErrorException + * + * @param authCorpId the auth corp id + * @param forceRefresh the force refresh + * @return auth corp js api ticket + * @throws WxErrorException the wx error exception */ String getAuthCorpJsApiTicket(String authCorpId, boolean forceRefresh) throws WxErrorException; @@ -258,8 +268,8 @@ public interface WxCpTpService { /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求. * - * @param url 接口地址 - * @param queryParam 请求参数 + * @param url 接口地址 + * @param queryParam 请求参数 * @param withoutSuiteAccessToken 请求是否忽略SuiteAccessToken 默认不忽略-false * @return the string * @throws WxErrorException the wx error exception @@ -362,6 +372,7 @@ public interface WxCpTpService { /** *
    * 获取访问用户敏感信息
+   * 文档地址
    * 
* * @param userTicket the user ticket @@ -381,6 +392,18 @@ public interface WxCpTpService { */ WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException; + /** + * 获取带参授权链接 + *

+ * 文档地址:https://developer.work.weixin.qq.com/document/path/95436 + * + * @param state state + * @param templateIdList 代开发自建应用模版ID列表,数量不能超过9个 + * @return customized auth url + * @throws WxErrorException the wx error exception + */ + WxTpCustomizedAuthUrl getCustomizedAuthUrl(String state, List templateIdList) throws WxErrorException; + /** * 获取服务商providerToken * @@ -391,16 +414,18 @@ public interface WxCpTpService { /** * 获取服务商providerToken和剩余过期时间 - * @return - * @throws WxErrorException + * + * @return wx cp provider token entity + * @throws WxErrorException the wx error exception */ WxCpProviderToken getWxCpProviderTokenEntity() throws WxErrorException; /** * 获取服务商providerToken和剩余过期时间,支持强制刷新 - * @param forceRefresh - * @return - * @throws WxErrorException + * + * @param forceRefresh the force refresh + * @return wx cp provider token entity + * @throws WxErrorException the wx error exception */ WxCpProviderToken getWxCpProviderTokenEntity(boolean forceRefresh) throws WxErrorException; @@ -474,6 +499,21 @@ public interface WxCpTpService { */ void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService); + /** + * set license service + * + * @param wxCpTpLicenseService the oa service + */ + void setWxCpTpLicenseService(WxCpTpLicenseService wxCpTpLicenseService); + + + /** + * get license service + * + * @return getCpTPLicenseService wx cp tp license service + */ + WxCpTpLicenseService getWxCpTpLicenseService(); + /** * 获取应用的管理员列表 * @@ -484,21 +524,47 @@ public interface WxCpTpService { */ WxCpTpAdmin getAdminList(String authCorpId, Integer agentId) throws WxErrorException; + /** + * 获取应用二维码 + * @param suiteId 第三方应用id(即ww或wx开头的suiteid) + * @param appId 第三方应用id,单应用不需要该参数,多应用旧套件才需要传该参数。若不传默认为1 + * @param state state值,用于区分不同的安装渠道 + * @param style 二维码样式选项,默认为不带说明外框小尺寸。0:带说明外框的二维码,适合于实体物料,1:带说明外框的二维码,适合于屏幕类,2:不带说明外框(小尺寸),3:不带说明外框(中尺寸),4:不带说明外框(大尺寸)。具体样式与服务商管理端获取到的应用二维码样式一一对应,参见下文二维码样式说明 + * @param resultType 结果返回方式,默认为返回二维码图片buffer。1:二维码图片buffer,2:二维码图片url + * @return 二维码 + * @throws WxErrorException the wx error exception + */ + 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 + */ + WxCpTpCorpId2OpenCorpId corpId2OpenCorpId(String corpId) throws WxErrorException; + /** * 创建机构级jsApiTicket签名 * 详情参见企业微信第三方应用开发文档:https://work.weixin.qq.com/api/doc/90001/90144/90539 - * @param url 调用JS接口页面的完整URL - * @param authCorpId - * @return + * + * @param url 调用JS接口页面的完整URL + * @param authCorpId the auth corp id + * @return wx jsapi signature + * @throws WxErrorException the wx error exception */ WxJsapiSignature createAuthCorpJsApiTicketSignature(String url, String authCorpId) throws WxErrorException; /** * 创建应用级jsapiTicket签名 * 详情参见企业微信第三方应用开发文档:https://work.weixin.qq.com/api/doc/90001/90144/90539 - * @param url 调用JS接口页面的完整URL - * @param authCorpId - * @return + * + * @param url 调用JS接口页面的完整URL + * @param authCorpId the auth corp id + * @return wx jsapi signature + * @throws WxErrorException the wx error exception */ WxJsapiSignature createSuiteJsApiTicketSignature(String url, String authCorpId) throws WxErrorException; @@ -509,18 +575,21 @@ public interface WxCpTpService { /** * 使机构accessToken缓存失效 + * * @param authCorpId 机构id */ void expireAccessToken(String authCorpId); /** * 使机构jsapiticket缓存失效 + * * @param authCorpId 机构id */ void expireAuthCorpJsApiTicket(String authCorpId); /** * 使应用jsapiticket失效 + * * @param authCorpId 机构id */ void expireAuthSuiteJsApiTicket(String authCorpId); @@ -530,4 +599,44 @@ public interface WxCpTpService { */ void expireProviderToken(); + /** + * 获取应用版本付费订单相关接口服务 + * + * @return the wx cp tp order service + */ + WxCpTpOrderService getWxCpTpOrderService(); + + /** + * 设置应用版本付费订单相关接口服务 + * + * @param wxCpTpOrderService the wx cp tp order service + */ + void setWxCpTpOrderService(WxCpTpOrderService wxCpTpOrderService); + + /** + * 获取应用版本付费版本相关接口服务 + * + * @return the wx cp tp edition service + */ + WxCpTpEditionService getWxCpTpEditionService(); + + /** + * 设置应用版本付费版本相关接口服务 + * + * @param wxCpTpEditionService the wx cp tp edition service + */ + void setWxCpTpOrderService(WxCpTpEditionService wxCpTpEditionService); + + + WxCpTpIdConvertService getWxCpTpIdConverService(); + + void setWxCpTpIdConverService(WxCpTpIdConvertService wxCpTpIdConvertService); + + /** + * 构造第三方应用oauth2链接 + */ + WxCpTpOAuth2Service getWxCpTpOAuth2Service(); + + void setWxCpTpOAuth2Service(WxCpTpOAuth2Service wxCpTpOAuth2Service); + } 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 25c5cf88b3..b508df59a1 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 - * @since 2021-02-14 16:02 + * @since 2021 -02-14 16:02 */ public interface WxCpTpTagService { /** @@ -25,8 +25,8 @@ public interface WxCpTpTagService { * * @param name 标签名称,长度限制为32个字以内(汉字或英文字母),标签名不可与其他标签重名。 * @param id 标签id,非负整型,指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。 - * @return 标签id - * @throws WxErrorException + * @return 标签id string + * @throws WxErrorException the wx error exception */ String create(String name, Integer id) throws WxErrorException; @@ -49,9 +49,10 @@ public interface WxCpTpTagService { /** * 获取标签成员 - * @param tagId - * @return - * @throws WxErrorException + * + * @param tagId the tag id + * @return wx cp tp tag get result + * @throws WxErrorException the wx error exception */ WxCpTpTagGetResult get(String tagId) throws WxErrorException; @@ -61,7 +62,7 @@ public interface WxCpTpTagService { * @param tagId 标签id * @param userIds 用户ID 列表 * @param partyIds 企业部门ID列表 - * @return . + * @return . wx cp tp tag add or remove users result * @throws WxErrorException . */ WxCpTpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List userIds, List partyIds) @@ -73,7 +74,7 @@ WxCpTpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List userIds, * @param tagId 标签id * @param userIds 用户id列表 * @param partyIds 企业部门ID列表 - * @return . + * @return . wx cp tp tag add or remove users result * @throws WxErrorException . */ WxCpTpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List userIds, List partyIds) @@ -82,7 +83,7 @@ WxCpTpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List us /** * 获得标签列表. * - * @return 标签列表 + * @return 标签列表 list * @throws WxErrorException . */ List listAll() throws WxErrorException; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java index 55c04e3cf3..0f2fc5dd99 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java @@ -13,7 +13,6 @@ * 用户管理接口 * Created by jamie on 2020/7/22. *
- * */ public interface WxCpTpUserService { @@ -24,6 +23,7 @@ public interface WxCpTpUserService { * * * @param userId 用户id + * @throws WxErrorException the wx error exception */ void authenticate(String userId) throws WxErrorException; @@ -37,8 +37,11 @@ public interface WxCpTpUserService { * @param departId 必填。部门id * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 * @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 + * @param corpId the corp id + * @return the list + * @throws WxErrorException the wx error exception */ - List listByDepartment(Long departId, Boolean fetchChild, Integer status,String corpId) throws WxErrorException; + List listByDepartment(Long departId, Boolean fetchChild, Integer status, String corpId) throws WxErrorException; /** *
@@ -50,6 +53,8 @@ public interface WxCpTpUserService {
    * @param departId   必填。部门id
    * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
    * @param status     非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
+   * @return the list
+   * @throws WxErrorException the wx error exception
    */
   List listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException;
 
@@ -57,6 +62,7 @@ public interface WxCpTpUserService {
    * 新建用户.
    *
    * @param user 用户对象
+   * @throws WxErrorException the wx error exception
    */
   void create(WxCpUser user) throws WxErrorException;
 
@@ -64,6 +70,7 @@ public interface WxCpTpUserService {
    * 更新用户.
    *
    * @param user 用户对象
+   * @throws WxErrorException the wx error exception
    */
   void update(WxCpUser user) throws WxErrorException;
 
@@ -74,6 +81,7 @@ public interface WxCpTpUserService {
    * 
* * @param userIds 员工UserID列表。对应管理端的帐号 + * @throws WxErrorException the wx error exception */ void delete(String... userIds) throws WxErrorException; @@ -81,8 +89,11 @@ public interface WxCpTpUserService { * 获取用户. * * @param userid 用户id + * @param corpId the corp id + * @return the by id + * @throws WxErrorException the wx error exception */ - WxCpUser getById(String userid,String corpId) throws WxErrorException; + WxCpUser getById(String userid, String corpId) throws WxErrorException; /** *
@@ -96,6 +107,8 @@ public interface WxCpTpUserService {
    * @param userIds  成员ID列表, 最多支持1000个。
    * @param partyIds 部门ID列表,最多支持100个。
    * @param tagIds   标签ID列表,最多支持100个。
+   * @return the wx cp invite result
+   * @throws WxErrorException the wx error exception
    */
   WxCpInviteResult invite(List userIds, List partyIds, List tagIds) throws WxErrorException;
 
@@ -113,9 +126,9 @@ public interface WxCpTpUserService {
    *
    * @param userId  企业内的成员id
    * @param agentId 非必填,整型,仅用于发红包。其它场景该参数不要填,如微信支付、企业转账、电子发票
-   * @return map对象,可能包含以下值:
-   * - openid 企业微信成员userid对应的openid,若有传参agentid,则是针对该agentid的openid。否则是针对企业微信corpid的openid
-   * - appid 应用的appid,若请求包中不包含agentid则不返回appid。该appid在使用微信红包时会用到
+   * @return map对象 ,可能包含以下值: - openid 企业微信成员userid对应的openid,若有传参agentid,则是针对该agentid的openid。否则是针对企业微信corpid的openid -
+   * appid 应用的appid,若请求包中不包含agentid则不返回appid。该appid在使用微信红包时会用到
+   * @throws WxErrorException the wx error exception
    */
   Map userId2Openid(String userId, Integer agentId) throws WxErrorException;
 
@@ -133,6 +146,7 @@ public interface WxCpTpUserService {
    *
    * @param openid 在使用微信支付、微信红包和企业转账之后,返回结果的openid
    * @return userid 该openid在企业微信对应的成员userid
+   * @throws WxErrorException the wx error exception
    */
   String openid2UserId(String openid) throws WxErrorException;
 
@@ -148,10 +162,11 @@ public interface WxCpTpUserService {
    * 
* * @param mobile 手机号码。长度为5~32个字节 - * @return userid mobile对应的成员userid + * @param corpId – the corp id + * @return userid mobile对应的成员userid * @throws WxErrorException . */ - String getUserId(String mobile) throws WxErrorException; + String getUserId(String mobile, String corpId) throws WxErrorException; /** * 获取外部联系人详情. @@ -163,7 +178,7 @@ public interface WxCpTpUserService { * * * @param userId 外部联系人的userid - * @return 联系人详情 + * @return 联系人详情 external contact * @throws WxErrorException . */ WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java index 03316b9ae2..407702439a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.enums.WxType; @@ -22,6 +23,7 @@ import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.cp.bean.*; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.tp.service.*; @@ -31,6 +33,7 @@ import java.io.IOException; import java.net.URLEncoder; import java.util.HashMap; +import java.util.List; import java.util.Map; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.*; @@ -38,6 +41,8 @@ /** * . * + * @param the type parameter + * @param

the type parameter * @author zhenjun cai */ @Slf4j @@ -48,7 +53,11 @@ public abstract class BaseWxCpTpServiceImpl implements WxCpTpService, Requ private WxCpTpMediaService wxCpTpMediaService = new WxCpTpMediaServiceImpl(this); private WxCpTpOAService wxCpTpOAService = new WxCpTpOAServiceImpl(this); private WxCpTpUserService wxCpTpUserService = new WxCpTpUserServiceImpl(this); - + private WxCpTpOrderService wxCpTpOrderService = new WxCpTpOrderServiceImpl(this); + private WxCpTpEditionService wxCpTpEditionService = new WxCpTpEditionServiceImpl(this); + private WxCpTpLicenseService wxCpTpLicenseService = new WxCpTpLicenseServiceImpl(this); + private WxCpTpIdConvertService wxCpTpIdConvertService = new WxCpTpIdConvertServiceImpl(this); + private WxCpTpOAuth2Service wxCpTpOAuth2Service = new WxCpTpOAuth2ServiceImpl(this); /** * 全局的是否正在刷新access token的锁. */ @@ -70,11 +79,17 @@ public abstract class BaseWxCpTpServiceImpl implements WxCpTpService, Requ */ protected final Object globalAuthCorpJsApiTicketRefreshLock = new Object(); + /** + * The Global provider token refresh lock. + */ protected final Object globalProviderTokenRefreshLock = new Object(); + /** + * The Config storage. + */ protected WxCpTpConfigStorage configStorage; - private WxSessionManager sessionManager = new StandardSessionManager(); + private final WxSessionManager sessionManager = new StandardSessionManager(); /** * 临时文件目录. @@ -114,7 +129,7 @@ public WxAccessToken getSuiteAccessTokenEntity(boolean forceRefresh) throws WxEr public String getSuiteTicket() throws WxErrorException { if (this.configStorage.isSuiteTicketExpired()) { // 本地suite ticket 不存在或者过期 - WxError wxError = WxError.fromJson("{\"errcode\":40085, \"errmsg\":\"invaild suite ticket\"}", WxType.CP); + WxError wxError = WxError.fromJson("{\"errcode\":40085, \"errmsg\":\"invalid suite ticket\"}", WxType.CP); throw new WxErrorException(wxError); } return this.configStorage.getSuiteTicket(); @@ -149,7 +164,7 @@ public String getSuiteJsApiTicket(String authCorpId) throws WxErrorException { "type=agent_config&access_token=" + this.configStorage.getAccessToken(authCorpId), true); JsonObject jsonObject = GsonParser.parse(resp); - if (jsonObject.get("errcode").getAsInt() == 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) { String jsApiTicket = jsonObject.get("ticket").getAsString(); int expiredInSeconds = jsonObject.get("expires_in").getAsInt(); synchronized (globalJsApiTicketRefreshLock) { @@ -179,7 +194,7 @@ public String getAuthCorpJsApiTicket(String authCorpId) throws WxErrorException "access_token=" + this.configStorage.getAccessToken(authCorpId), true); JsonObject jsonObject = GsonParser.parse(resp); - if (jsonObject.get("errcode").getAsInt() == 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) { String jsApiTicket = jsonObject.get("ticket").getAsString(); int expiredInSeconds = jsonObject.get("expires_in").getAsInt(); @@ -310,11 +325,20 @@ public String get(String url, String queryParam, boolean withoutSuiteAccessToken @Override public String post(String url, String postData) throws WxErrorException { - return execute(SimplePostRequestExecutor.create(this), url, postData,false); + return execute(SimplePostRequestExecutor.create(this), url, postData, false); } - public String post(String url, String postData,boolean withoutSuiteAccessToken) throws WxErrorException { - return execute(SimplePostRequestExecutor.create(this), url, postData,withoutSuiteAccessToken); + /** + * Post string. + * + * @param url the url + * @param postData the post data + * @param withoutSuiteAccessToken the without suite access token + * @return the string + * @throws WxErrorException the wx error exception + */ + public String post(String url, String postData, boolean withoutSuiteAccessToken) throws WxErrorException { + return execute(SimplePostRequestExecutor.create(this), url, postData, withoutSuiteAccessToken); } /** @@ -322,13 +346,26 @@ public String post(String url, String postData,boolean withoutSuiteAccessToken) */ @Override public T execute(RequestExecutor executor, String uri, E data) throws WxErrorException { - return execute(executor, uri, data,false); + return execute(executor, uri, data, false); } - public T execute(RequestExecutor executor, String uri, E data,boolean withoutSuiteAccessToken) throws WxErrorException { + + /** + * Execute t. + * + * @param the type parameter + * @param the type parameter + * @param executor the executor + * @param uri the uri + * @param data the data + * @param withoutSuiteAccessToken the without suite access token + * @return the t + * @throws WxErrorException the wx error exception + */ + public T execute(RequestExecutor executor, String uri, E data, boolean withoutSuiteAccessToken) throws WxErrorException { int retryTimes = 0; do { try { - return this.executeInternal(executor, uri, data,withoutSuiteAccessToken); + return this.executeInternal(executor, uri, data, withoutSuiteAccessToken); } catch (WxErrorException e) { if (retryTimes + 1 > this.maxRetryTimes) { log.warn("重试达到最大次数【{}】", this.maxRetryTimes); @@ -358,20 +395,45 @@ public T execute(RequestExecutor executor, String uri, E data,boole throw new WxRuntimeException("微信服务端异常,超出重试次数"); } + /** + * Execute internal t. + * + * @param the type parameter + * @param the type parameter + * @param executor the executor + * @param uri the uri + * @param data the data + * @return the t + * @throws WxErrorException the wx error exception + */ protected T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException { - return executeInternal( executor, uri,data,false); + return executeInternal(executor, uri, data, false); } - protected T executeInternal(RequestExecutor executor, String uri, E data,boolean withoutSuiteAccessToken) throws WxErrorException { + + /** + * Execute internal t. + * + * @param the type parameter + * @param the type parameter + * @param executor the executor + * @param uri the uri + * @param data the data + * @param withoutSuiteAccessToken the without suite access token + * @return the t + * @throws WxErrorException the wx error exception + */ + protected T executeInternal(RequestExecutor executor, String uri, E data, + boolean withoutSuiteAccessToken) throws WxErrorException { E dataForLog = DataUtils.handleDataWithSecret(data); if (uri.contains("suite_access_token=")) { throw new IllegalArgumentException("uri参数中不允许有suite_access_token: " + uri); } String uriWithAccessToken; - if(!withoutSuiteAccessToken){ + if (!withoutSuiteAccessToken) { String suiteAccessToken = getSuiteAccessToken(false); uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "suite_access_token=" + suiteAccessToken; - }else{ + } else { uriWithAccessToken = uri; } @@ -423,10 +485,20 @@ public void setMaxRetryTimes(int maxRetryTimes) { this.maxRetryTimes = maxRetryTimes; } + /** + * Gets tmp dir file. + * + * @return the tmp dir file + */ public File getTmpDirFile() { return this.tmpDirFile; } + /** + * Sets tmp dir file. + * + * @param tmpDirFile the tmp dir file + */ public void setTmpDirFile(File tmpDirFile) { this.tmpDirFile = tmpDirFile; } @@ -461,10 +533,21 @@ public WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_code", authCode); String access_token = getWxCpProviderToken(); - String responseText = post(configStorage.getApiUrl(GET_LOGIN_INFO) + "?access_token=" + access_token, jsonObject.toString(), true); + String responseText = post(configStorage.getApiUrl(GET_LOGIN_INFO) + "?access_token=" + access_token, + jsonObject.toString(), true); return WxTpLoginInfo.fromJson(responseText); } + @Override + public WxTpCustomizedAuthUrl getCustomizedAuthUrl(String state, List templateIdList) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("state", state); + jsonObject.add("templateid_list", WxGsonBuilder.create().toJsonTree(templateIdList).getAsJsonArray()); + + String responseText = post(configStorage.getApiUrl(GET_CUSTOMIZED_AUTH_URL) + "?provider_access_token=" + getWxCpProviderToken(), jsonObject.toString(), true); + return WxTpCustomizedAuthUrl.fromJson(responseText); + } + @Override public String getWxCpProviderToken() throws WxErrorException { if (this.configStorage.isProviderTokenExpired()) { @@ -475,7 +558,7 @@ public String getWxCpProviderToken() throws WxErrorException { //providerAccessToken 的获取不需要suiteAccessToken ,一不必要,二可以提高效率 WxCpProviderToken wxCpProviderToken = WxCpProviderToken.fromJson(this.post(this.configStorage.getApiUrl(GET_PROVIDER_TOKEN) - , jsonObject.toString(),true)); + , jsonObject.toString(), true)); String providerAccessToken = wxCpProviderToken.getProviderAccessToken(); Integer expiresIn = wxCpProviderToken.getExpiresIn(); @@ -506,22 +589,22 @@ public WxCpTpContactService getWxCpTpContactService() { } @Override - public WxCpTpDepartmentService getWxCpTpDepartmentService(){ + public WxCpTpDepartmentService getWxCpTpDepartmentService() { return wxCpTpDepartmentService; } @Override - public WxCpTpMediaService getWxCpTpMediaService(){ + public WxCpTpMediaService getWxCpTpMediaService() { return wxCpTpMediaService; } @Override - public WxCpTpOAService getWxCpTpOAService(){ + public WxCpTpOAService getWxCpTpOAService() { return wxCpTpOAService; } @Override - public WxCpTpUserService getWxCpTpUserService(){ + public WxCpTpUserService getWxCpTpUserService() { return wxCpTpUserService; } @@ -545,13 +628,25 @@ public void setWxCpTpOAService(WxCpTpOAService wxCpTpOAService) { this.wxCpTpOAService = wxCpTpOAService; } + + @Override + public WxCpTpLicenseService getWxCpTpLicenseService() { + return wxCpTpLicenseService; + } + + + @Override + public void setWxCpTpLicenseService(WxCpTpLicenseService wxCpTpLicenseService) { + this.wxCpTpLicenseService = wxCpTpLicenseService; + } + @Override public void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService) { this.wxCpTpUserService = wxCpTpUserService; } @Override - public WxCpTpAdmin getAdminList(String authCorpId,Integer agentId) throws WxErrorException{ + public WxCpTpAdmin getAdminList(String authCorpId, Integer agentId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_corpid", authCorpId); jsonObject.addProperty("agentid", agentId); @@ -559,6 +654,24 @@ public WxCpTpAdmin getAdminList(String authCorpId,Integer agentId) throws WxErro return WxCpTpAdmin.fromJson(result); } + public WxCpTpAppQrcode getAppQrcode(String suiteId, String appId, String state, Integer style, Integer resultType) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("suite_id", suiteId); + jsonObject.addProperty("appid", appId); + jsonObject.addProperty("state", state); + jsonObject.addProperty("style", style); + jsonObject.addProperty("result_type", resultType); + String result = post(configStorage.getApiUrl(GET_APP_QRCODE), jsonObject.toString()); + return WxCpTpAppQrcode.fromJson(result); + } + + public WxCpTpCorpId2OpenCorpId corpId2OpenCorpId(String corpId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("corpid", corpId); + String result = post(configStorage.getApiUrl(CORPID_TO_OPENCORPID) +"?provider_access_token=" + getWxCpProviderToken(), jsonObject.toString()); + return WxCpTpCorpId2OpenCorpId.fromJson(result); + } + @Override public WxJsapiSignature createAuthCorpJsApiTicketSignature(String url, String authCorpId) throws WxErrorException { return doCreateWxJsapiSignature(url, authCorpId, this.getAuthCorpJsApiTicket(authCorpId)); @@ -594,6 +707,26 @@ public void expireProviderToken() { this.configStorage.expireProviderToken(); } + @Override + public WxCpTpOrderService getWxCpTpOrderService() { + return wxCpTpOrderService; + } + + @Override + public void setWxCpTpOrderService(WxCpTpOrderService wxCpTpOrderService) { + this.wxCpTpOrderService = wxCpTpOrderService; + } + + @Override + public WxCpTpEditionService getWxCpTpEditionService() { + return wxCpTpEditionService; + } + + @Override + public void setWxCpTpOrderService(WxCpTpEditionService wxCpTpEditionService) { + this.wxCpTpEditionService = wxCpTpEditionService; + } + private WxJsapiSignature doCreateWxJsapiSignature(String url, String authCorpId, String jsapiTicket) { long timestamp = System.currentTimeMillis() / 1000; String noncestr = RandomUtils.getRandomStr(); @@ -610,4 +743,24 @@ private WxJsapiSignature doCreateWxJsapiSignature(String url, String authCorpId, return jsapiSignature; } + @Override + public WxCpTpIdConvertService getWxCpTpIdConverService() { + return wxCpTpIdConvertService; + } + + @Override + public void setWxCpTpIdConverService(WxCpTpIdConvertService wxCpTpIdConvertService) { + this.wxCpTpIdConvertService = wxCpTpIdConvertService; + } + + + @Override + public WxCpTpOAuth2Service getWxCpTpOAuth2Service() { + return wxCpTpOAuth2Service; + } + + @Override + public void setWxCpTpOAuth2Service(WxCpTpOAuth2Service wxCpTpOAuth2Service) { + this.wxCpTpOAuth2Service = wxCpTpOAuth2Service; + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpContactServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpContactServiceImpl.java index 9c13f488f4..4ff8b8bc8e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpContactServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpContactServiceImpl.java @@ -10,9 +10,10 @@ import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.CONTACT_SEARCH; /** + * The type Wx cp tp contact service. + * * @author uianz - * @description - * @since 2020/12/23 下午 02:39 + * @since 2020 /12/23 下午 02:39 */ @RequiredArgsConstructor public class WxCpTpContactServiceImpl implements WxCpTpContactService { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpDepartmentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpDepartmentServiceImpl.java index a51eaf2781..7f46c1859d 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpDepartmentServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpDepartmentServiceImpl.java @@ -7,7 +7,6 @@ import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.impl.WxCpDepartmentServiceImpl; -import me.chanjar.weixin.cp.bean.WxCpDepart; import me.chanjar.weixin.cp.bean.WxCpTpDepart; import me.chanjar.weixin.cp.tp.service.WxCpTpDepartmentService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; @@ -18,10 +17,11 @@ import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Department.*; /** + * The type Wx cp tp department service. + * * @author uianz - * @description corp from {@link WxCpDepartmentServiceImpl )} - * 唯一不同在于获取部门列表时需要传对应企业的accessToken - * @since 2020/12/23 下午 02:39 + * copy from {@link WxCpDepartmentServiceImpl )} 唯一不同在于获取部门列表时需要传对应企业的accessToken + * @since 2020 /12/23 下午 02:39 */ @RequiredArgsConstructor public class WxCpTpDepartmentServiceImpl implements WxCpTpDepartmentService { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImpl.java new file mode 100644 index 0000000000..34ca852c3f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImpl.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult; +import me.chanjar.weixin.cp.tp.service.WxCpTpEditionService; +import me.chanjar.weixin.cp.tp.service.WxCpTpService; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.PROLONG_TRY; + +/** + * 应用版本付费版本相关接口实现 + * + * @author leigouqing created on 2022年4月24日 + */ +@RequiredArgsConstructor +public class WxCpTpEditionServiceImpl implements WxCpTpEditionService { + + /** + * The Main service. + */ + private final WxCpTpService mainService; + + /** + * 延长试用期 + *

+ * 文档地址 + *

+ *

    + *
  • 一个应用可以多次延长试用,但是试用总天数不能超过60天
  • + *
  • 仅限时试用或试用过期状态下的应用可以延长试用期
  • + *
+ * + * @param buyerCorpId 购买方corpId + * @param prolongDays 延长天数 + * @param appId 仅旧套件需要填此参数 + * @return the order + * @throws WxErrorException the wx error exception + */ + @Override + public WxCpTpProlongTryResult prolongTry(String buyerCorpId, Integer prolongDays, String appId) throws WxErrorException { + String url = mainService.getWxCpTpConfigStorage().getApiUrl(PROLONG_TRY); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("buyer_corpid", buyerCorpId); + jsonObject.addProperty("prolong_days", prolongDays); + jsonObject.addProperty("appid", appId); + String result = mainService.post(url, jsonObject.toString()); + return WxCpTpProlongTryResult.fromJson(result); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpIdConvertServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpIdConvertServiceImpl.java new file mode 100644 index 0000000000..7d0d80b452 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpIdConvertServiceImpl.java @@ -0,0 +1,90 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpTpConvertTmpExternalUserIdResult; +import me.chanjar.weixin.cp.bean.WxCpTpOpenKfIdConvertResult; +import me.chanjar.weixin.cp.bean.WxCpTpTagIdListConvertResult; +import me.chanjar.weixin.cp.bean.WxCpTpUnionidToExternalUseridResult; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; +import me.chanjar.weixin.cp.tp.service.WxCpTpIdConvertService; +import me.chanjar.weixin.cp.tp.service.WxCpTpService; + +import java.util.List; + + +/** + * @author cocoa + */ +@RequiredArgsConstructor +public class WxCpTpIdConvertServiceImpl implements WxCpTpIdConvertService { + private final WxCpTpService mainService; + + @Override + public WxCpTpUnionidToExternalUseridResult unionidToExternalUserid(String cropId, String unionid, String openid, Integer subjectType) throws WxErrorException { + JsonObject json = new JsonObject(); + json.addProperty("unionid", unionid); + json.addProperty("openid", openid); + if (subjectType != null) { + json.addProperty("subject_type", subjectType); + } + WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); + String accessToken = wxCpTpConfigStorage.getAccessToken(cropId); + String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.UNION_ID_TO_EXTERNAL_USER_ID); + url += "?access_token=" + accessToken; + String responseContent = this.mainService.post(url, json.toString()); + return WxCpTpUnionidToExternalUseridResult.fromJson(responseContent); + } + + @Override + public WxCpTpTagIdListConvertResult externalTagId(String corpId, String... externalTagIdList) throws WxErrorException { + WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); + String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.EXTERNAL_TAG_ID ) + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); + + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + for (String tagId : externalTagIdList) { + jsonArray.add(new JsonPrimitive(tagId)); + } + jsonObject.add("external_tagid_list", jsonArray); + String responseContent = this.mainService.post(url, jsonObject.toString()); + + return WxCpTpTagIdListConvertResult.fromJson(responseContent); + } + + @Override + public WxCpTpOpenKfIdConvertResult ConvertOpenKfId(String corpId, String... openKfIdList) throws WxErrorException { + WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); + String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.OPEN_KF_ID + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId)); + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + for (String kfId : openKfIdList) { + jsonArray.add(new JsonPrimitive(kfId)); + } + jsonObject.add("open_kfid_list", jsonArray); + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpTpOpenKfIdConvertResult.fromJson(responseContent); + } + + @Override + public WxCpTpConvertTmpExternalUserIdResult convertTmpExternalUserId(String corpId, int businessType, int userType, String... tmpExternalUserIdList) throws WxErrorException { + WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); + String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.CONVERT_TMP_EXTERNAL_USER_ID + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId)); + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + jsonObject.addProperty("business_type", businessType); + jsonObject.addProperty("user_type", userType); + for (String userId : tmpExternalUserIdList) { + jsonArray.add(new JsonPrimitive(userId)); + } + jsonObject.add("tmp_external_userid_list", jsonArray); + String responseContent = mainService.post(url, jsonObject.toString()); + return WxCpTpConvertTmpExternalUserIdResult.fromJson(responseContent); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImpl.java new file mode 100644 index 0000000000..5c9fcc2967 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImpl.java @@ -0,0 +1,196 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount; +import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer; +import me.chanjar.weixin.cp.bean.license.account.*; +import me.chanjar.weixin.cp.bean.license.order.*; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import me.chanjar.weixin.cp.tp.service.WxCpTpLicenseService; +import me.chanjar.weixin.cp.tp.service.WxCpTpService; + +import java.util.*; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.License.*; + +/** + * The type Wx cp tp license service. + * + * @author Totoro created on 2022/6/27 11:03 + */ +@RequiredArgsConstructor +public class WxCpTpLicenseServiceImpl implements WxCpTpLicenseService { + + private final WxCpTpService mainService; + + @Override + public WxCpTpLicenseCreateOrderResp createNewOrder(WxCpTpLicenseNewOrderRequest licenseNewOrderRequest) throws WxErrorException { + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(CREATE_NEW_ORDER) + + getProviderAccessToken(), licenseNewOrderRequest.toJson()); + return WxCpTpLicenseCreateOrderResp.fromJson(resultText); + } + + + @Override + public WxCpTpLicenseRenewOrderJobResp createRenewOrderJob(WxCpTpLicenseRenewOrderJobRequest licenseRenewOrderJobRequest) throws WxErrorException { + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(CREATE_RENEW_ORDER_JOB) + + getProviderAccessToken(), licenseRenewOrderJobRequest.toJson()); + return WxCpTpLicenseRenewOrderJobResp.fromJson(resultText); + } + + + @Override + public WxCpTpLicenseCreateOrderResp submitRenewOrder(WxCpTpLicenseRenewOrderRequest licenseRenewOrderRequest) throws WxErrorException { + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(SUBMIT_ORDER_JOB) + + getProviderAccessToken(), licenseRenewOrderRequest.toJson()); + return WxCpTpLicenseCreateOrderResp.fromJson(resultText); + } + + + @Override + public WxCpTpLicenseOrderListResp getOrderList(String corpId, Date startTime, Date endTime, String cursor, + int limit) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("corpid", corpId); + jsonObject.addProperty("cursor", cursor); + jsonObject.addProperty("limit", limit); + if (startTime != null) { + jsonObject.addProperty("start_time", startTime.getTime() / 1000); + } + if (endTime != null) { + jsonObject.addProperty("end_time", endTime.getTime() / 1000); + } + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ORDER) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpTpLicenseOrderListResp.fromJson(resultText); + } + + + @Override + public WxCpTpLicenseOrderInfoResp getOrderInfo(String orderId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("order_id", orderId); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ORDER) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpTpLicenseOrderInfoResp.fromJson(resultText); + } + + @Override + public WxCpTpLicenseOrderAccountListResp getOrderAccountList(String orderId, int limit, String cursor) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("order_id", orderId); + jsonObject.addProperty("cursor", cursor); + jsonObject.addProperty("limit", limit); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ORDER_ACCOUNT) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpTpLicenseOrderAccountListResp.fromJson(resultText); + } + + @Override + public WxCpBaseResp activeCode(String code, String corpId, String userId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("active_code", code); + jsonObject.addProperty("corpid", corpId); + jsonObject.addProperty("userid", userId); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(ACTIVE_ACCOUNT) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpBaseResp.fromJson(resultText); + } + + @Override + public WxCpTpLicenseBatchActiveResultResp batchActiveCode(String corpId, + List activeAccountList) throws WxErrorException { + Map map = new HashMap<>(2); + map.put("corpid", corpId); + map.put("active_list", activeAccountList); + GsonBuilder gsonBuilder = new GsonBuilder(); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_ACTIVE_ACCOUNT) + + getProviderAccessToken(), gsonBuilder.create().toJson(map)); + return WxCpTpLicenseBatchActiveResultResp.fromJson(resultText); + } + + @Override + public WxCpTpLicenseCodeInfoResp getActiveInfoByCode(String code, String corpId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("active_code", code); + jsonObject.addProperty("corpid", corpId); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ACTIVE_INFO_BY_CODE) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpTpLicenseCodeInfoResp.fromJson(resultText); + } + + @Override + public WxCpTpLicenseBatchCodeInfoResp batchGetActiveInfoByCode(Collection codes, String corpId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + JsonArray list = new JsonArray(); + for (String code : codes) { + list.add(new JsonPrimitive(code)); + } + jsonObject.add("active_code_list", list); + jsonObject.addProperty("corpid", corpId); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_GET_ACTIVE_INFO_BY_CODE) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpTpLicenseBatchCodeInfoResp.fromJson(resultText); + } + + @Override + public WxCpTpLicenseCorpAccountListResp getCorpAccountList(String corpId, int limit, String cursor) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("corpid", corpId); + jsonObject.addProperty("cursor", cursor); + jsonObject.addProperty("limit", limit); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ACTIVED_ACCOUNT) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpTpLicenseCorpAccountListResp.fromJson(resultText); + } + + @Override + public WxCpTpLicenseActiveInfoByUserResp getActiveInfoByUser(String corpId, String userId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("corpid", corpId); + jsonObject.addProperty("userid", userId); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ACTIVE_INFO_BY_USER) + + getProviderAccessToken(), jsonObject.toString()); + return WxCpTpLicenseActiveInfoByUserResp.fromJson(resultText); + } + + @Override + public WxCpTpLicenseBatchTransferResp batchTransferLicense(String corpId, List transferList) throws WxErrorException { + Map map = new HashMap<>(2); + map.put("corpid", corpId); + map.put("transfer_list", transferList); + GsonBuilder gsonBuilder = new GsonBuilder(); + String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_TRANSFER_LICENSE) + + getProviderAccessToken(), gsonBuilder.create().toJson(map)); + return WxCpTpLicenseBatchTransferResp.fromJson(resultText); + } + + + /** + * 获取服务商token的拼接参数 + * + * @return url + * @throws WxErrorException / + */ + private String getProviderAccessToken() throws WxErrorException { + return "?provider_access_token=" + mainService.getWxCpProviderToken(); + } + + + /** + * 获取tp参数配置 + * + * @return config + */ + private WxCpTpConfigStorage getWxCpTpConfigStorage() { + return mainService.getWxCpTpConfigStorage(); + } + + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMediaServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMediaServiceImpl.java index 2f8afe092f..326c9dd667 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMediaServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMediaServiceImpl.java @@ -26,25 +26,25 @@ */ @RequiredArgsConstructor public class WxCpTpMediaServiceImpl implements WxCpTpMediaService { - private final WxCpTpService mainService; + private final WxCpTpService mainService; - @Override - public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream, String corpId) - throws WxErrorException, IOException { - return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType), corpId); - } + @Override + public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream, String corpId) + throws WxErrorException, IOException { + return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType), corpId); + } - @Override - public WxMediaUploadResult upload(String mediaType, File file, String corpId) throws WxErrorException { - return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), - mainService.getWxCpTpConfigStorage().getApiUrl(MEDIA_UPLOAD + mediaType) + "&access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId), file); - } + @Override + public WxMediaUploadResult upload(String mediaType, File file, String corpId) throws WxErrorException { + return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), + mainService.getWxCpTpConfigStorage().getApiUrl(MEDIA_UPLOAD + mediaType) + "&access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId), file); + } - @Override - public String uploadImg(File file, String corpId) throws WxErrorException { - String url = mainService.getWxCpTpConfigStorage().getApiUrl(IMG_UPLOAD); - url += "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); - return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), url, file) - .getUrl(); - } + @Override + public String uploadImg(File file, String corpId) throws WxErrorException { + String url = mainService.getWxCpTpConfigStorage().getApiUrl(IMG_UPLOAD); + url += "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); + return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), url, file) + .getUrl(); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAServiceImpl.java index e9db407a76..5d6f1df355 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAServiceImpl.java @@ -7,7 +7,7 @@ import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult; import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest; -import me.chanjar.weixin.cp.bean.oa.WxCpTemplateResult; +import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult; import me.chanjar.weixin.cp.tp.service.WxCpTpOAService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; @@ -17,50 +17,49 @@ /** * 企业微信 OA 接口实现 * - * @author Element - * @date 2019-04-06 11:20 + * @author Element created on 2019-04-06 11:20 */ @RequiredArgsConstructor public class WxCpTpOAServiceImpl implements WxCpTpOAService { - private final WxCpTpService mainService; + private final WxCpTpService mainService; - @Override - public String apply(WxCpOaApplyEventRequest request, String corpId) throws WxErrorException { - String url = mainService.getWxCpTpConfigStorage().getApiUrl(APPLY_EVENT) + - "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); + @Override + public String apply(WxCpOaApplyEventRequest request, String corpId) throws WxErrorException { + String url = mainService.getWxCpTpConfigStorage().getApiUrl(APPLY_EVENT) + + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); - String responseContent = this.mainService.post(url, request.toJson()); - return GsonParser.parse(responseContent).get("sp_no").getAsString(); - } + String responseContent = this.mainService.post(url, request.toJson()); + return GsonParser.parse(responseContent).get("sp_no").getAsString(); + } - @Override - public WxCpTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("template_id", templateId); - String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL) + - "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); - String responseContent = this.mainService.post(url, jsonObject.toString()); - return WxCpGsonBuilder.create().fromJson(responseContent, WxCpTemplateResult.class); - } + @Override + public WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("template_id", templateId); + String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL) + + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpGsonBuilder.create().fromJson(responseContent, WxCpOaApprovalTemplateResult.class); + } - @Override - public String copyTemplate(@NonNull String openTemplateId, String corpId) throws WxErrorException { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("open_template_id", openTemplateId); - String url = mainService.getWxCpTpConfigStorage().getApiUrl(COPY_TEMPLATE) + - "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); - String responseContent = this.mainService.post(url, jsonObject.toString()); - return GsonParser.parse(responseContent).get("template_id").getAsString(); - } + @Override + public String copyTemplate(@NonNull String openTemplateId, String corpId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("open_template_id", openTemplateId); + String url = mainService.getWxCpTpConfigStorage().getApiUrl(COPY_TEMPLATE) + + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); + String responseContent = this.mainService.post(url, jsonObject.toString()); + return GsonParser.parse(responseContent).get("template_id").getAsString(); + } - @Override - public WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo, String corpId) throws WxErrorException { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("sp_no", spNo); - final String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_APPROVAL_DETAIL) + - "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); - String responseContent = this.mainService.post(url, jsonObject.toString()); - return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDetailResult.class); - } + @Override + public WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo, String corpId) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("sp_no", spNo); + final String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_APPROVAL_DETAIL) + + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDetailResult.class); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAuth2ServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAuth2ServiceImpl.java new file mode 100644 index 0000000000..4b2e492463 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAuth2ServiceImpl.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.util.http.URIUtil; +import me.chanjar.weixin.cp.tp.service.WxCpTpOAuth2Service; +import me.chanjar.weixin.cp.tp.service.WxCpTpService; + +import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.SNSAPI_BASE; +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.OAuth2.URL_OAUTH2_AUTHORIZE; + +@RequiredArgsConstructor +public class WxCpTpOAuth2ServiceImpl implements WxCpTpOAuth2Service { + + private final WxCpTpService mainService; + + + @Override + public String buildAuthorizeUrl(String redirectUri, String state) { + return this.buildAuthorizeUrl(redirectUri, state, SNSAPI_BASE); + } + + @Override + public String buildAuthorizeUrl(String redirectUri, String state, String scope) { + StringBuilder url = new StringBuilder(URL_OAUTH2_AUTHORIZE); + url.append("?appid=").append(this.mainService.getWxCpTpConfigStorage().getSuiteId()); + url.append("&redirect_uri=").append(URIUtil.encodeURIComponent(redirectUri)); + url.append("&response_type=code"); + url.append("&scope=").append(scope); + if (state != null) { + url.append("&state=").append(state); + } + url.append("#wechat_redirect"); + return url.toString(); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImpl.java new file mode 100644 index 0000000000..b8aff54d39 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImpl.java @@ -0,0 +1,70 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails; +import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult; +import me.chanjar.weixin.cp.tp.service.WxCpTpOrderService; +import me.chanjar.weixin.cp.tp.service.WxCpTpService; + +import java.util.Date; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER; +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER_LIST; + +/** + * 应用版本付费订单相关接口实现 + * + * @author leigouqing created on 2022年4月24日 + */ +@RequiredArgsConstructor +public class WxCpTpOrderServiceImpl implements WxCpTpOrderService { + + /** + * The Main service. + */ + private final WxCpTpService mainService; + + /** + * 获取订单详情 + *

+ * 文档地址 + *

+ * + * @param orderId 订单号 + * @return the order + * @throws WxErrorException the wx error exception + */ + @Override + public WxCpTpOrderDetails getOrder(String orderId) throws WxErrorException { + String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_ORDER); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("orderid", orderId); + String result = this.mainService.post(url, jsonObject.toString()); + return WxCpTpOrderDetails.fromJson(result); + } + + /** + * 获取订单列表 + *

+ * 文档地址 + *

+ * + * @param startTime 起始时间 + * @param endTime 终止时间 + * @param testMode 指定拉取正式或测试模式的订单。默认正式模式。0-正式模式,1-测试模式。 + * @return the order list + * @throws WxErrorException the wx error exception + */ + @Override + public WxCpTpOrderListGetResult getOrderList(Date startTime, Date endTime, Integer testMode) throws WxErrorException { + String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_ORDER_LIST); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("start_time", startTime.getTime() / 1000); + jsonObject.addProperty("end_time", endTime.getTime() / 1000); + jsonObject.addProperty("test_mode", testMode); + String result = this.mainService.post(url, jsonObject.toString()); + return WxCpTpOrderListGetResult.fromJson(result); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java index 22962d933b..a128afd7e6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java @@ -24,6 +24,8 @@ import java.io.IOException; /** + * The type Wx cp tp service apache http client. + * * @author someone */ public class WxCpTpServiceApacheHttpClientImpl extends BaseWxCpTpServiceImpl { 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 1b03f18c79..b81760e72c 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 - * @since 2021-02-14 16:02 + * @since 2021 -02-14 16:02 */ @RequiredArgsConstructor public class WxCpTpTagServiceImpl implements WxCpTpTagService { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java index 6cbca3bd00..d992627468 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java @@ -186,10 +186,11 @@ public String openid2UserId(String openid) throws WxErrorException { } @Override - public String getUserId(String mobile) throws WxErrorException { + public String getUserId(String mobile, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("mobile", mobile); - String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_USER_ID); + String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_USER_ID) + + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJsonElement = GsonParser.parse(responseContent); return tmpJsonElement.getAsJsonObject().get("userid").getAsString(); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtil.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtil.java index 2914945b89..835aa79797 100755 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtil.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtil.java @@ -1,11 +1,30 @@ package me.chanjar.weixin.cp.util.crypto; -import com.google.common.base.CharMatcher; -import com.google.common.io.BaseEncoding; +import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.crypto.WxCryptUtil; import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import org.apache.commons.lang3.StringUtils; +import sun.security.util.DerInputStream; +import sun.security.util.DerValue; +import javax.crypto.Cipher; +import java.nio.charset.StandardCharsets; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.util.Base64; + +/** + * The type Wx cp crypt util. + * @author qian + */ public class WxCpCryptUtil extends WxCryptUtil { + /** + * Instantiates a new Wx cp crypt util. + * + * @param wxCpConfigStorage the wx cp config storage + */ public WxCpCryptUtil(WxCpConfigStorage wxCpConfigStorage) { /* * @param token 公众平台上,开发者设置的token @@ -18,7 +37,83 @@ public WxCpCryptUtil(WxCpConfigStorage wxCpConfigStorage) { this.token = token; this.appidOrCorpid = corpId; - this.aesKey = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey)); + this.aesKey = Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " ")); + } + + /** + * 判断使用PKCS8或者PKCS1进行解密 + * + * @param encryptRandomKey 使用PUBLICKEY_VER指定版本的公钥进行非对称加密后base64加密的内容 + * @param msgAuditPriKey 会话存档私钥 + * @param pkcs1 使用什么方式进行解密,1代表使用PKCS1进行解密,2代表PKCS8进行解密 ... + * @return string + * @throws Exception the exception + */ + public static String decryptPriKey(String encryptRandomKey, String msgAuditPriKey, Integer pkcs1) throws Exception { + if (pkcs1 == null) { + throw new WxErrorException("请配置会话存档解密方式"); + } + + if (pkcs1 == 1) { + return decryptPriKeyByPKCS1(encryptRandomKey, msgAuditPriKey); + } + + return decryptPriKeyByPKCS8(encryptRandomKey, msgAuditPriKey); + } + + /** + * PKCS8 解密私钥 + * + * @param encryptRandomKey the encrypt random key + * @param msgAuditPriKey the msg audit pri key + * @return string + * @throws Exception the exception + */ + public static String decryptPriKeyByPKCS8(String encryptRandomKey, String msgAuditPriKey) throws Exception { + String privateKey = msgAuditPriKey.replaceAll("(\r\n|\r|\n|\n\r)", "") + .replace("-----BEGIN PRIVATE KEY-----", "") + .replace("-----END PRIVATE KEY-----", "") + .replace(" ", ""); + + byte[] keyBytes = Base64.getDecoder().decode(privateKey); + PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes); + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + PrivateKey priKey = keyFactory.generatePrivate(pkcs8KeySpec); + + Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm()); + cipher.init(Cipher.DECRYPT_MODE, priKey); + byte[] utf8 = cipher.doFinal(Base64.getDecoder().decode(encryptRandomKey)); + return new String(utf8, StandardCharsets.UTF_8); + } + + /** + * 会话存档,PKCS1 解密私钥 + * 企业获取的会话内容将用公钥加密,企业用自行保存的私钥解开会话内容数据 + * + * @param encryptRandomKey 使用PUBLICKEY_VER指定版本的公钥进行非对称加密后base64加密的内容,需要业务方先base64 + * decode处理后,再使用指定版本的私钥进行解密,得出内容。String类型 + * @param msgAuditPriKey 会话存档私钥 + * @return string + * @throws Exception the exception + */ + public static String decryptPriKeyByPKCS1(String encryptRandomKey, String msgAuditPriKey) throws Exception { + String privateKey = msgAuditPriKey.replaceAll("(\r\n|\r|\n|\n\r)", "") + .replace("-----BEGIN RSA PRIVATE KEY-----", "") + .replace("-----END RSA PRIVATE KEY-----", "") + .replace(" ", ""); + + byte[] keyBytes = Base64.getDecoder().decode(privateKey); + DerValue[] seq = new DerInputStream(keyBytes).getSequence(0); + RSAPrivateCrtKeySpec keySpec = new RSAPrivateCrtKeySpec(seq[1].getBigInteger(), seq[2].getBigInteger(), + seq[3].getBigInteger(), seq[4].getBigInteger(), + seq[5].getBigInteger(), seq[6].getBigInteger(), + seq[7].getBigInteger(), seq[8].getBigInteger()); + + PrivateKey priKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec); + Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + cipher.init(Cipher.DECRYPT_MODE, priKey); + byte[] utf8 = cipher.doFinal(Base64.getDecoder().decode(encryptRandomKey)); + return new String(utf8, StandardCharsets.UTF_8); } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpTpCryptUtil.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpTpCryptUtil.java index 900f7ea8aa..ac6097446a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpTpCryptUtil.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpTpCryptUtil.java @@ -1,16 +1,21 @@ package me.chanjar.weixin.cp.util.crypto; -import com.google.common.base.CharMatcher; -import com.google.common.io.BaseEncoding; import me.chanjar.weixin.common.util.crypto.WxCryptUtil; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import org.apache.commons.lang3.StringUtils; + +import java.util.Base64; /** + * The type Wx cp tp crypt util. + * * @author someone */ public class WxCpTpCryptUtil extends WxCryptUtil { /** * 构造函数. + * + * @param wxCpTpConfigStorage the wx cp tp config storage */ public WxCpTpCryptUtil(WxCpTpConfigStorage wxCpTpConfigStorage) { /* @@ -24,7 +29,7 @@ public WxCpTpCryptUtil(WxCpTpConfigStorage wxCpTpConfigStorage) { this.token = token; this.appidOrCorpid = corpId; - this.aesKey = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey)); + this.aesKey = Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " ")); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/StatisticListAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/StatisticListAdapter.java new file mode 100644 index 0000000000..89fd687e72 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/StatisticListAdapter.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.cp.util.json; + +import com.google.gson.*; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.cp.bean.kf.WxCpKfGetCorpStatisticResp; + +import java.lang.reflect.Type; + +/** + * The type Statistic list adapter. + * + * @author zhongjun created on 2022/4/25 + */ +public class StatisticListAdapter implements JsonDeserializer { + + @Override + public WxCpKfGetCorpStatisticResp.StatisticList deserialize(JsonElement jsonElement, Type type, + JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { + WxCpKfGetCorpStatisticResp.StatisticList statisticList = new WxCpKfGetCorpStatisticResp.StatisticList(); + JsonObject asJsonObject = jsonElement.getAsJsonObject(); + statisticList.setStatTime(asJsonObject.get("stat_time").getAsLong()); + JsonElement statistic = asJsonObject.get("statistic"); + if (GsonHelper.isNotNull(statistic)) { + WxCpKfGetCorpStatisticResp.Statistic statisticObj = new WxCpKfGetCorpStatisticResp.Statistic(); + statisticObj.setSessionCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("session_cnt")) ? null : statistic.getAsJsonObject().get("session_cnt").getAsInt()); + statisticObj.setCustomerCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("customer_cnt")) ? null : statistic.getAsJsonObject().get("customer_cnt").getAsInt()); + statisticObj.setCustomerMsgCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("customer_msg_cnt")) ? null : statistic.getAsJsonObject().get("customer_msg_cnt").getAsInt()); + statisticObj.setUpgradeServiceCustomerCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("upgrade_service_customer_cnt")) ? null : statistic.getAsJsonObject().get("upgrade_service_customer_cnt").getAsInt()); + statisticObj.setAiSessionReplyCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("ai_session_reply_cnt")) ? null : statistic.getAsJsonObject().get("ai_session_reply_cnt").getAsInt()); + statisticObj.setAiTransferRate(GsonHelper.isNull(statistic.getAsJsonObject().get("ai_transfer_rate")) ? null : statistic.getAsJsonObject().get("ai_transfer_rate").getAsFloat()); + statisticObj.setAiKnowledgeHitRate(GsonHelper.isNull(statistic.getAsJsonObject().get("ai_knowledge_hit_rate")) ? null : statistic.getAsJsonObject().get("ai_knowledge_hit_rate").getAsFloat()); + statisticObj.setMsgRejectedCustomerCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("msg_rejected_customer_cnt")) ? null : statistic.getAsJsonObject().get("msg_rejected_customer_cnt").getAsInt()); + statisticList.setStatistic(statisticObj); + } + return statisticList; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpChatGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpChatGsonAdapter.java index 0e97181a3a..e3a03ffab3 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpChatGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpChatGsonAdapter.java @@ -8,22 +8,14 @@ */ package me.chanjar.weixin.cp.util.json; +import com.google.gson.*; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.cp.bean.WxCpChat; + import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import me.chanjar.weixin.common.util.json.GsonHelper; -import me.chanjar.weixin.cp.bean.WxCpChat; - /** * 群聊适配器 * @@ -34,12 +26,12 @@ public class WxCpChatGsonAdapter implements JsonSerializer, JsonDeseri @Override public JsonElement serialize(WxCpChat chat, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); - if (chat.getId() != null) { + if (chat.getId() != null) { json.addProperty("chatid", chat.getId()); } if (chat.getName() != null) { json.addProperty("name", chat.getName()); - } + } if (chat.getOwner() != null) { json.addProperty("owner", chat.getOwner()); } @@ -61,7 +53,7 @@ public WxCpChat deserialize(JsonElement json, Type typeOfT, JsonDeserializationC chat.setId(GsonHelper.getAsString(chatJson.get("chatid"))); chat.setName(GsonHelper.getAsString(chatJson.get("name"))); chat.setOwner(GsonHelper.getAsString(chatJson.get("owner"))); - + JsonArray usersJson = chatJson.getAsJsonArray("userlist"); if (usersJson != null) { List users = new ArrayList<>(usersJson.size()); @@ -70,7 +62,7 @@ public WxCpChat deserialize(JsonElement json, Type typeOfT, JsonDeserializationC users.add(userJson.getAsString()); } } - + return chat; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpConclusionAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpConclusionAdapter.java index fd159d1755..0a57884a74 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpConclusionAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpConclusionAdapter.java @@ -11,9 +11,11 @@ * * @author element */ -public class WxCpConclusionAdapter implements JsonSerializer, JsonDeserializer { +public class WxCpConclusionAdapter implements JsonSerializer, + JsonDeserializer { @Override - public WxCpContactWayInfo.ContactWay.Conclusion deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + public WxCpContactWayInfo.ContactWay.Conclusion deserialize(JsonElement json, Type typeOfT, + JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); WxCpContactWayInfo.ContactWay.Conclusion conclusion = new WxCpContactWayInfo.ContactWay.Conclusion(); @@ -77,7 +79,8 @@ public WxCpContactWayInfo.ContactWay.Conclusion deserialize(JsonElement json, Ty } @Override - public JsonElement serialize(WxCpContactWayInfo.ContactWay.Conclusion src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(WxCpContactWayInfo.ContactWay.Conclusion src, Type typeOfSrc, + JsonSerializationContext context) { JsonObject json = new JsonObject(); if (StringUtils.isNotBlank(src.getTextContent())) { JsonObject jsonText = new JsonObject(); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java index 4340855fda..af9344b701 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java @@ -8,18 +8,12 @@ */ package me.chanjar.weixin.cp.util.json; -import java.lang.reflect.Type; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; +import com.google.gson.*; import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.cp.bean.WxCpDepart; +import java.lang.reflect.Type; + /** * WxCpDepart的gson适配器. * @@ -29,6 +23,7 @@ public class WxCpDepartGsonAdapter implements JsonSerializer, JsonDe private static final String ID = "id"; private static final String NAME = "name"; private static final String EN_NAME = "name_en"; + private static final String DEPARTMENT_LEADER = "department_leader"; private static final String PARENT_ID = "parentid"; private static final String ORDER = "order"; @@ -44,6 +39,13 @@ public JsonElement serialize(WxCpDepart group, Type typeOfSrc, JsonSerialization if (group.getEnName() != null) { json.addProperty(EN_NAME, group.getEnName()); } + if (group.getDepartmentLeader() != null) { + JsonArray jsonArray = new JsonArray(); + for (String department : group.getDepartmentLeader()) { + jsonArray.add(new JsonPrimitive(department)); + } + json.add(DEPARTMENT_LEADER, jsonArray); + } if (group.getParentId() != null) { json.addProperty(PARENT_ID, group.getParentId()); } @@ -67,6 +69,15 @@ public WxCpDepart deserialize(JsonElement json, Type typeOfT, JsonDeserializatio if (departJson.get(EN_NAME) != null && !departJson.get(EN_NAME).isJsonNull()) { depart.setEnName(GsonHelper.getAsString(departJson.get(EN_NAME))); } + if (departJson.getAsJsonArray(DEPARTMENT_LEADER) != null && !departJson.get(DEPARTMENT_LEADER).isJsonNull()) { + JsonArray jsonArray = departJson.getAsJsonArray(DEPARTMENT_LEADER); + String[] departments = new String[jsonArray.size()]; + int i = 0; + for (JsonElement jsonElement : jsonArray) { + departments[i++] = jsonElement.getAsString(); + } + depart.setDepartmentLeader(departments); + } if (departJson.get(ORDER) != null && !departJson.get(ORDER).isJsonNull()) { depart.setOrder(GsonHelper.getAsLong(departJson.get(ORDER))); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpGsonBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpGsonBuilder.java index 16f0108e09..7b53aa337a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpGsonBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpGsonBuilder.java @@ -9,13 +9,19 @@ import me.chanjar.weixin.cp.bean.WxCpDepart; import me.chanjar.weixin.cp.bean.WxCpTag; import me.chanjar.weixin.cp.bean.WxCpUser; +import me.chanjar.weixin.cp.bean.kf.WxCpKfGetCorpStatisticResp; + +import java.util.Objects; /** + * The type Wx cp gson builder. + * * @author Daniel Qian */ public class WxCpGsonBuilder { private static final GsonBuilder INSTANCE = new GsonBuilder(); + private static volatile Gson GSON_INSTANCE; static { INSTANCE.disableHtmlEscaping(); @@ -25,10 +31,23 @@ public class WxCpGsonBuilder { INSTANCE.registerTypeAdapter(WxError.class, new WxErrorAdapter()); INSTANCE.registerTypeAdapter(WxMenu.class, new WxCpMenuGsonAdapter()); INSTANCE.registerTypeAdapter(WxCpTag.class, new WxCpTagGsonAdapter()); + INSTANCE.registerTypeAdapter(WxCpKfGetCorpStatisticResp.StatisticList.class, new StatisticListAdapter()); } + /** + * Create gson. + * + * @return the gson + */ public static Gson create() { - return INSTANCE.create(); + if (Objects.isNull(GSON_INSTANCE)) { + synchronized (INSTANCE) { + if (Objects.isNull(GSON_INSTANCE)) { + GSON_INSTANCE = INSTANCE.create(); + } + } + } + return GSON_INSTANCE; } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMenuGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMenuGsonAdapter.java index c7cb05cc62..7b02a2cdb5 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMenuGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMenuGsonAdapter.java @@ -12,8 +12,7 @@ *

  * 企业号菜单json转换适配器
  * Created by Binary Wang on 2017-6-25.
- * @author Binary Wang
- * 
+ * @author Binary Wang */ public class WxCpMenuGsonAdapter extends WxMenuGsonAdapter { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpTagGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpTagGsonAdapter.java index 872190688c..41a5b78400 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpTagGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpTagGsonAdapter.java @@ -15,6 +15,8 @@ import java.lang.reflect.Type; /** + * The type Wx cp tag gson adapter. + * * @author Daniel Qian */ public class WxCpTagGsonAdapter implements JsonSerializer, JsonDeserializer { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java index 6cecde0b4d..0c32ba0060 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java @@ -73,6 +73,7 @@ public WxCpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationC user.setMobile(GsonHelper.getString(o, "mobile")); user.setGender(Gender.fromCode(GsonHelper.getString(o, "gender"))); user.setEmail(GsonHelper.getString(o, "email")); + user.setBizMail(GsonHelper.getString(o, "biz_mail")); user.setAvatar(GsonHelper.getString(o, "avatar")); user.setThumbAvatar(GsonHelper.getString(o, "thumb_avatar")); user.setAddress(GsonHelper.getString(o, "address")); @@ -89,17 +90,19 @@ public WxCpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationC user.setToInvite(GsonHelper.getBoolean(o, "to_invite")); user.setOpenUserId(GsonHelper.getString(o, "open_userid")); user.setMainDepartment(GsonHelper.getString(o, "main_department")); + user.setDirectLeader(GsonHelper.getStringArray(o, "direct_leader")); if (GsonHelper.isNotNull(o.get(EXTRA_ATTR))) { this.buildExtraAttrs(o, user); } if (GsonHelper.isNotNull(o.get(EXTERNAL_PROFILE))) { - user.setExternalCorpName(GsonHelper.getString(o.getAsJsonObject().get(EXTERNAL_PROFILE).getAsJsonObject(), EXTERNAL_CORP_NAME)); + user.setExternalCorpName(GsonHelper.getString(o.getAsJsonObject().get(EXTERNAL_PROFILE).getAsJsonObject(), + EXTERNAL_CORP_NAME)); JsonElement jsonElement = o.get(EXTERNAL_PROFILE).getAsJsonObject().get(WECHAT_CHANNELS); - if(jsonElement !=null){ + if (jsonElement != null) { JsonObject asJsonObject = jsonElement.getAsJsonObject(); - user.setWechatChannels(WechatChannels.builder().nickname(GsonHelper.getString(asJsonObject,"nickname")).status(GsonHelper.getInteger(asJsonObject,"status")).build()); + user.setWechatChannels(WechatChannels.builder().nickname(GsonHelper.getString(asJsonObject, "nickname")).status(GsonHelper.getInteger(asJsonObject, "status")).build()); } this.buildExternalAttrs(o, user); } @@ -124,7 +127,8 @@ private void buildExtraAttrs(JsonObject o, WxCpUser user) { switch (type) { case 0: { - attr.setTextValue(GsonHelper.getString(attrJsonElement.getAsJsonObject().get("text").getAsJsonObject(), "value")); + attr.setTextValue(GsonHelper.getString(attrJsonElement.getAsJsonObject().get("text").getAsJsonObject(), + "value")); break; } case 1: { @@ -139,7 +143,12 @@ private void buildExtraAttrs(JsonObject o, WxCpUser user) { } private void buildExternalAttrs(JsonObject o, WxCpUser user) { - JsonArray attrJsonElements = o.get(EXTERNAL_PROFILE).getAsJsonObject().get(EXTERNAL_ATTR).getAsJsonArray(); + JsonElement jsonElement = o.get(EXTERNAL_PROFILE).getAsJsonObject().get(EXTERNAL_ATTR); + if (jsonElement == null) { + return; + } + + JsonArray attrJsonElements = jsonElement.getAsJsonArray(); for (JsonElement element : attrJsonElements) { final Integer type = GsonHelper.getInteger(element.getAsJsonObject(), "type"); final String name = GsonHelper.getString(element.getAsJsonObject(), "name"); @@ -192,15 +201,9 @@ private void buildExternalAttrs(JsonObject o, WxCpUser user) { @Override public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationContext context) { JsonObject o = new JsonObject(); - if (user.getUserId() != null) { - o.addProperty("userid", user.getUserId()); - } - if (user.getNewUserId() != null) { - o.addProperty("new_userid", user.getNewUserId()); - } - if (user.getName() != null) { - o.addProperty("name", user.getName()); - } + this.addProperty(o, "userid", user.getUserId()); + this.addProperty(o, "new_userid", user.getNewUserId()); + this.addProperty(o, "name", user.getName()); if (user.getDepartIds() != null) { JsonArray jsonArray = new JsonArray(); for (Long departId : user.getDepartIds()) { @@ -217,9 +220,7 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon o.add("order", jsonArray); } - if (user.getPosition() != null) { - o.addProperty("position", user.getPosition()); - } + this.addProperty(o, "position", user.getPosition()); if (user.getPositions() != null) { JsonArray jsonArray = new JsonArray(); @@ -229,39 +230,20 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon o.add("positions", jsonArray); } - if (user.getMobile() != null) { - o.addProperty("mobile", user.getMobile()); - } + this.addProperty(o, "mobile", user.getMobile()); if (user.getGender() != null) { o.addProperty("gender", user.getGender().getCode()); } - if (user.getEmail() != null) { - o.addProperty("email", user.getEmail()); - } - if (user.getAvatar() != null) { - o.addProperty("avatar", user.getAvatar()); - } - if (user.getThumbAvatar() != null) { - o.addProperty("thumb_avatar", user.getThumbAvatar()); - } - if (user.getAddress() != null) { - o.addProperty("address", user.getAddress()); - } - if (user.getAvatarMediaId() != null) { - o.addProperty("avatar_mediaid", user.getAvatarMediaId()); - } - if (user.getStatus() != null) { - o.addProperty("status", user.getStatus()); - } - if (user.getEnable() != null) { - o.addProperty("enable", user.getEnable()); - } - if (user.getAlias() != null) { - o.addProperty("alias", user.getAlias()); - } - if (user.getIsLeader() != null) { - o.addProperty("isleader", user.getIsLeader()); - } + this.addProperty(o, "email", user.getEmail()); + this.addProperty(o, "biz_mail", user.getBizMail()); + this.addProperty(o, "avatar", user.getAvatar()); + this.addProperty(o, "thumb_avatar", user.getThumbAvatar()); + this.addProperty(o, "address", user.getAddress()); + this.addProperty(o, "avatar_mediaid", user.getAvatarMediaId()); + this.addProperty(o, "status", user.getStatus()); + this.addProperty(o, "enable", user.getEnable()); + this.addProperty(o, "alias", user.getAlias()); + this.addProperty(o, "isleader", user.getIsLeader()); if (user.getIsLeaderInDept() != null && user.getIsLeaderInDept().length > 0) { JsonArray ary = new JsonArray(); for (int item : user.getIsLeaderInDept()) { @@ -269,25 +251,22 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon } o.add("is_leader_in_dept", ary); } - if (user.getHideMobile() != null) { - o.addProperty("hide_mobile", user.getHideMobile()); - } - if (user.getEnglishName() != null) { - o.addProperty("english_name", user.getEnglishName()); - } - if (user.getTelephone() != null) { - o.addProperty("telephone", user.getTelephone()); - } - if (user.getQrCode() != null) { - o.addProperty("qr_code", user.getQrCode()); - } + this.addProperty(o, "hide_mobile", user.getHideMobile()); + this.addProperty(o, "english_name", user.getEnglishName()); + this.addProperty(o, "telephone", user.getTelephone()); + this.addProperty(o, "qr_code", user.getQrCode()); if (user.getToInvite() != null) { o.addProperty("to_invite", user.getToInvite()); } - if (user.getMainDepartment() != null) { - o.addProperty("main_department", user.getMainDepartment()); - } + this.addProperty(o, "main_department", user.getMainDepartment()); + if (user.getDirectLeader() != null && user.getDirectLeader().length > 0) { + JsonArray ary = new JsonArray(); + for (String item : user.getDirectLeader()) { + ary.add(item); + } + o.add("direct_leader", ary); + } if (!user.getExtAttrs().isEmpty()) { JsonArray attrsJsonArray = new JsonArray(); for (Attr attr : user.getExtAttrs()) { @@ -316,19 +295,16 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon o.add(EXTRA_ATTR, attrsJson); } - if (user.getExternalPosition() != null) { - o.addProperty(EXTERNAL_POSITION, user.getExternalPosition()); - } + this.addProperty(o, EXTERNAL_POSITION, user.getExternalPosition()); JsonObject attrsJson = new JsonObject(); o.add(EXTERNAL_PROFILE, attrsJson); - if (user.getExternalCorpName() != null) { - attrsJson.addProperty(EXTERNAL_CORP_NAME, user.getExternalCorpName()); - } + this.addProperty(attrsJson, EXTERNAL_CORP_NAME, user.getExternalCorpName()); - if(user.getWechatChannels() != null){ - attrsJson.add(WECHAT_CHANNELS,GsonHelper.buildJsonObject("nickname", user.getWechatChannels().getNickname(), "status", user.getWechatChannels().getStatus())); + if (user.getWechatChannels() != null) { + attrsJson.add(WECHAT_CHANNELS, GsonHelper.buildJsonObject("nickname", user.getWechatChannels().getNickname(), + "status", user.getWechatChannels().getStatus())); } if (!user.getExternalAttrs().isEmpty()) { @@ -364,4 +340,16 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon return o; } + private void addProperty(JsonObject object, String property, Integer value) { + if (value != null) { + object.addProperty(property, value); + } + } + + private void addProperty(JsonObject object, String property, String value) { + if (value != null) { + object.addProperty(property, value); + } + } + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java index aa907b7288..8f540020a1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java @@ -1,20 +1,31 @@ package me.chanjar.weixin.cp.util.xml; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - import com.thoughtworks.xstream.XStream; import me.chanjar.weixin.common.util.xml.XStreamInitializer; -import me.chanjar.weixin.cp.bean.message.*; import me.chanjar.weixin.cp.bean.WxCpTpXmlPackage; +import me.chanjar.weixin.cp.bean.message.*; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +/** + * The type X stream transformer. + */ public class XStreamTransformer { + /** + * The constant CLASS_2_XSTREAM_INSTANCE. + */ protected static final Map CLASS_2_XSTREAM_INSTANCE = configXStreamInstance(); /** * xml -> pojo + * + * @param the type parameter + * @param clazz the clazz + * @param xml the xml + * @return the t */ @SuppressWarnings("unchecked") public static T fromXml(Class clazz, String xml) { @@ -22,6 +33,14 @@ public static T fromXml(Class clazz, String xml) { return object; } + /** + * From xml t. + * + * @param the type parameter + * @param clazz the clazz + * @param is the is + * @return the t + */ @SuppressWarnings("unchecked") public static T fromXml(Class clazz, InputStream is) { T object = (T) CLASS_2_XSTREAM_INSTANCE.get(clazz).fromXML(is); @@ -40,6 +59,11 @@ public static void register(Class clz, XStream xStream) { /** * pojo -> xml. + * + * @param the type parameter + * @param clazz the clazz + * @param object the object + * @return the string */ public static String toXml(Class clazz, T object) { return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object); @@ -54,8 +78,10 @@ private static Map configXStreamInstance() { map.put(WxCpXmlOutVideoMessage.class, configWxCpXmlOutVideoMessage()); map.put(WxCpXmlOutVoiceMessage.class, configWxCpXmlOutVoiceMessage()); map.put(WxCpXmlOutTaskCardMessage.class, configWxCpXmlOutTaskCardMessage()); + map.put(WxCpXmlOutUpdateBtnMessage.class, configWxCpXmlOutUpdateBtnMessage()); map.put(WxCpTpXmlPackage.class, configWxCpTpXmlPackage()); map.put(WxCpTpXmlMessage.class, configWxCpTpXmlMessage()); + map.put(WxCpXmlOutEventMessage.class, configWxCpXmlOutEventMessage()); return map; } @@ -120,6 +146,13 @@ private static XStream configWxCpXmlOutTaskCardMessage() { return xstream; } + private static XStream configWxCpXmlOutUpdateBtnMessage() { + XStream xstream = XStreamInitializer.getInstance(); + xstream.processAnnotations(WxCpXmlOutMessage.class); + xstream.processAnnotations(WxCpXmlOutUpdateBtnMessage.class); + return xstream; + } + private static XStream configWxCpTpXmlPackage() { XStream xstream = XStreamInitializer.getInstance(); xstream.processAnnotations(WxCpTpXmlPackage.class); @@ -134,4 +167,11 @@ private static XStream configWxCpTpXmlMessage() { return xstream; } + private static XStream configWxCpXmlOutEventMessage() { + XStream xstream = XStreamInitializer.getInstance(); + xstream.processAnnotations(WxCpXmlOutMessage.class); + xstream.processAnnotations(WxCpXmlOutEventMessage.class); + return xstream; + } + } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java index 9d89892f4f..69efe530ce 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java @@ -15,9 +15,15 @@ import java.io.IOException; import java.io.InputStream; +/** + * The type Api test module. + */ @Slf4j public class ApiTestModule implements Module { private static final String TEST_CONFIG_XML = "test-config.xml"; + /** + * The Config. + */ protected WxXmlCpInMemoryConfigStorage config; private static T fromXml(Class clazz, InputStream is) { @@ -45,15 +51,30 @@ public void configure(Binder binder) { } } + /** + * The type Wx xml cp in memory config storage. + */ @Data @EqualsAndHashCode(callSuper = true) @XStreamAlias("xml") public static class WxXmlCpInMemoryConfigStorage extends WxCpDefaultConfigImpl { private static final long serialVersionUID = -4521839921547374822L; + /** + * The User id. + */ protected String userId; + /** + * The Department id. + */ protected String departmentId; + /** + * The Tag id. + */ protected String tagId; + /** + * The External user id. + */ protected String externalUserId; } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModuleWithMockServer.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModuleWithMockServer.java index 83f38612d9..867aeecc8c 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModuleWithMockServer.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModuleWithMockServer.java @@ -5,10 +5,12 @@ /** * 带mock server 的test module. * - * @author Binary Wang - * @date 2020-08-30 + * @author Binary Wang created on 2020-08-30 */ public class ApiTestModuleWithMockServer extends ApiTestModule { + /** + * The constant mockServerPort. + */ public static final int mockServerPort = 8080; @Override diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/TestConstants.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/TestConstants.java index 03c84e9256..acd442f9ff 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/TestConstants.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/TestConstants.java @@ -7,11 +7,23 @@ * */ public class TestConstants { - /////////////////////// + /** + * The constant FILE_JPG. + */ +/////////////////////// // 文件类型 /////////////////////// public static final String FILE_JPG = "jpeg"; + /** + * The constant FILE_MP3. + */ public static final String FILE_MP3 = "mp3"; + /** + * The constant FILE_AMR. + */ public static final String FILE_AMR = "amr"; + /** + * The constant FILE_MP4. + */ public static final String FILE_MP4 = "mp4"; } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBaseAPITest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBaseAPITest.java index 58ba1a9791..4a7d4e5473 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBaseAPITest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBaseAPITest.java @@ -18,9 +18,17 @@ @Guice(modules = ApiTestModule.class) public class WxCpBaseAPITest { + /** + * The Wx service. + */ @Inject protected WxCpServiceImpl wxService; + /** + * Test refresh access token. + * + * @throws WxErrorException the wx error exception + */ public void testRefreshAccessToken() throws WxErrorException { WxCpConfigStorage configStorage = this.wxService.getWxCpConfigStorage(); String before = configStorage.getAccessToken(); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java index 34d4065dcf..7acbc9dd2f 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java @@ -13,9 +13,17 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; +/** + * The type Wx cp busy retry test. + */ @Test @Slf4j public class WxCpBusyRetryTest { + /** + * Get service object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider(name = "getService") public Object[][] getService() { WxCpService service = new WxCpServiceImpl() { @@ -36,11 +44,24 @@ public synchronized T executeInternal( }; } + /** + * Test retry. + * + * @param service the service + * @throws WxErrorException the wx error exception + */ @Test(dataProvider = "getService", expectedExceptions = RuntimeException.class) public void testRetry(WxCpService service) throws WxErrorException { service.execute(null, null, null); } + /** + * Test retry in thread pool. + * + * @param service the service + * @throws InterruptedException the interrupted exception + * @throws ExecutionException the execution exception + */ @Test(dataProvider = "getService") public void testRetryInThreadPool(final WxCpService service) throws InterruptedException, ExecutionException { // 当线程池中的线程复用的时候,还是能保证相同的重试次数 diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpExternalContactTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpExternalContactTest.java new file mode 100644 index 0000000000..0359b5f381 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpExternalContactTest.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.cp.api; + +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.external.WxCpUserExternalUnassignList; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * 离职继承测试类 + *

+ * 官方文档: + * https://developer.work.weixin.qq.com/document/path/92124 + */ +@Slf4j +@Guice(modules = ApiTestModule.class) +public class WxCpExternalContactTest { + + @Inject + private WxCpService wxCpService; + /** + * The Config storage. + */ + @Inject + protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; + + /** + * Test get external contact. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetExternalContact() throws WxErrorException { + String externalUserId = this.configStorage.getExternalUserId(); + WxCpUserExternalUnassignList unassignList = this.wxCpService.getExternalContactService().listUnassignedList(null, + null, 100); + log.info(unassignList.toJson()); + + // test str + String result = "{\"errcode\":0,\"errmsg\":\"ok\",\"info\":[{\"handover_userid\":\"zhangsan\"," + + "\"external_userid\":\"woAJ2GCAAAd4uL12hdfsdasassdDmAAAAA\",\"dimission_time\":1550838571}," + + "{\"handover_userid\":\"lisi\",\"external_userid\":\"wmAJ2GCAAAzLTI123ghsdfoGZNqqAAAA\"," + + "\"dimission_time\":1550661468}],\"is_last\":false,\"next_cursor\":\"aSfwejksvhToiMMfFeIGZZ\"}"; + WxCpUserExternalUnassignList json = WxCpUserExternalUnassignList.fromJson(result); + log.info(json.toJson()); + + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpLivingTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpLivingTest.java new file mode 100644 index 0000000000..442a6d7740 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpLivingTest.java @@ -0,0 +1,202 @@ +package me.chanjar.weixin.cp.api; + +import lombok.extern.slf4j.Slf4j; +import lombok.val; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.XmlUtils; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.living.*; +import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.constant.WxCpConsts; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import me.chanjar.weixin.cp.util.xml.XStreamTransformer; +import org.testng.annotations.Test; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; + +/** + * 企业微信直播测试类. + * 官方文档:https://open.work.weixin.qq.com/api/doc/90000/90135/93632 + * + * @author Wang_Wong created on 2021-12-23 + */ +@Slf4j +public class WxCpLivingTest { + + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService wxCpService; + + /** + * Test. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void test() throws WxErrorException { + + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + + wxCpConfigStorage = config; + wxCpService = new WxCpServiceImpl(); + wxCpService.setWxCpConfigStorage(config); + + + /** + * 直播回调事件 + * 一场完整的直播,会经历 预约直播/开始直播/结束直播 等一系列状态变更。 + * 为了让企业实时获取直播的动态,当直播状态变更后,企业微信会将该变更推送到开发者配置的回调URL。 + * 只有通过接口创建的预约/立即直播才会回调。 + * + * 请注意,只有用企业微信api创建的直播才能收到回调,且调用创建直播接口的应用,要配置好回调url。 + */ + String livingXml = "\n" + + " \n" + + " \n" + + " 1348831860\n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " 1\n" + + ""; + + final WxCpXmlMessage livingXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, livingXml); + livingXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(livingXml)); + log.info("livingXmlMsg:{}", WxCpGsonBuilder.create().toJson(livingXmlMsg)); + + /** + * 直播回调事件常量 + * https://developer.work.weixin.qq.com/document/path/94145 + */ + String livingStatusChange = WxCpConsts.EventType.LIVING_STATUS_CHANGE; + + + /** + * 测试创建直播 + */ + WxCpLivingCreateRequest createRequest = new WxCpLivingCreateRequest(); + createRequest.setAnchorUserid("WangKai"); + createRequest.setTheme("直播1"); + + long currentTimeMillis = System.currentTimeMillis() + 3600000L; + createRequest.setLivingStart(currentTimeMillis); + createRequest.setLivingDuration(3600L); + createRequest.setType(4); + createRequest.setDescription("这是通用直播1"); + + val activityDetail = new WxCpLivingCreateRequest.ActivityDetail(); + activityDetail.setDescription("活动描述,非活动类型的直播不用传"); + +// String[] strings = new String[]{"MEDIA_ID_2", "MEDIA_ID_1"}; + ArrayList imageList = new ArrayList(); + imageList.add("MEDIA_ID_1"); + imageList.add("MEDIA_ID_2"); + + activityDetail.setImageList(imageList); + createRequest.setActivityDetail(activityDetail); + + String livingCreate = wxCpService.getLivingService().livingCreate(createRequest); + log.info("返回的直播id为:{}", livingCreate); + + WxCpLivingCreateRequest thisReq = WxCpLivingCreateRequest.fromJson(createRequest.toJson()); + log.info("返回的数据:{}", thisReq.toJson()); + + // 创建预约直播 + String createJson = "{\"anchor_userid\":\"ChenHu\",\"theme\":\"theme\",\"living_start\":164037820420," + + "\"living_duration\":3600,\"description\":\"test description\",\"type\":4,\"remind_time\":60," + + "\"activity_cover_mediaid\":\"MEDIA_ID\",\"activity_share_mediaid\":\"MEDIA_ID\"," + + "\"activity_detail\":{\"description\":\"活动描述,非活动类型的直播不用传\",\"image_list\":[\"xxxx1\",\"xxxx1\"]}}"; + WxCpLivingCreateRequest requestData = WxCpLivingCreateRequest.fromJson(createJson); + String thisLivingId = wxCpService.getLivingService().livingCreate(requestData); + log.info("livingId为:{}", thisLivingId); + + + /** + * other api + */ + String livingCode = wxCpService.getLivingService().getLivingCode("o50by5NezHciWnoexJsrI49ILNqI", + "lvOQpTDwAAD2MYuOq9y_bmLNMJfbbdGw"); + log.info(WxCpGsonBuilder.create().toJson(livingCode)); + + // 直播详情 + WxCpLivingInfo livingInfo = wxCpService.getLivingService().getLivingInfo("lvOQpTDwAAcP9wNOSSxTwpbni-TMPNSg"); + log.info(livingInfo.toJson()); + + // 直播观看明细 + WxCpWatchStat watchStat = wxCpService.getLivingService().getWatchStat("lvOQpTDwAAcP9wNOSSxTwpbni-TMPNSg", "0"); + log.info(watchStat.toJson()); + + final String watchStateJson = "{\"errcode\":0,\"errmsg\":\"ok\",\"ending\":1,\"next_key\":\"NEXT_KEY\"," + + "\"stat_info\":{\"users\":[{\"userid\":\"userid\",\"watch_time\":30,\"is_comment\":1,\"is_mic\":1}]," + + "\"external_users\":[{\"external_userid\":\"external_userid1\",\"type\":1,\"name\":\"user name\"," + + "\"watch_time\":30,\"is_comment\":1,\"is_mic\":1},{\"external_userid\":\"external_userid2\",\"type\":2," + + "\"name\":\"user_name\",\"watch_time\":30,\"is_comment\":1,\"is_mic\":1}]}}"; + + WxCpWatchStat wxCpWatchStat = WxCpWatchStat.fromJson(watchStateJson); + log.info(wxCpWatchStat.toJson()); + + // 直播观众信息 + final String livingShareInfo = "{\"errcode\":0,\"errmsg\":\"ok\",\"livingid\":\"livingid\"," + + "\"viewer_userid\":\"viewer_userid\",\"viewer_external_userid\":\"viewer_external_userid\"," + + "\"invitor_userid\":\"invitor_userid\",\"invitor_external_userid\":\"invitor_external_userid\"}"; + + WxCpLivingShareInfo wxCpLivingShareInfo = WxCpLivingShareInfo.fromJson(livingShareInfo); + log.info(wxCpLivingShareInfo.toJson()); + + // 获取成员直播ID列表 + WxCpLivingResult.LivingIdResult livingResult = wxCpService.getLivingService().getUserAllLivingId("ChenHu", null, + null); + log.info(livingResult.toJson()); + + String livinglist = "{\"errcode\":0,\"errmsg\":\"ok\",\"next_cursor\":\"next_cursor\"," + + "\"livingid_list\":[\"livingid1\",\"livingid2\"]}"; + WxCpLivingResult.LivingIdResult livingIdResult = WxCpLivingResult.LivingIdResult.fromJson(livinglist); + log.info(livingIdResult.toJson()); + + + log.info("{}", new Date().getTime()); + // 创建预约直播 + String create = "{\"anchor_userid\":\"ChenHu\",\"theme\":\"theme\",\"living_start\":164037820420," + + "\"living_duration\":3600,\"description\":\"test description\",\"type\":4,\"remind_time\":60," + + "\"activity_cover_mediaid\":\"MEDIA_ID\",\"activity_share_mediaid\":\"MEDIA_ID\"," + + "\"activity_detail\":{\"description\":\"活动描述,非活动类型的直播不用传\",\"image_list\":[\"xxxx1\",\"xxxx1\"]}}"; + WxCpLivingCreateRequest request = WxCpLivingCreateRequest.fromJson(create); + String livingId = wxCpService.getLivingService().livingCreate(request); + log.info("livingId为:{}", livingId); + + + String modify = "{\"livingid\": \"" + livingId + "\",\"theme\":\"theme\",\"living_start\":164047820420," + + "\"living_duration\":3600,\"description\":\"描述:description\",\"type\":1,\"remind_time\":60}"; + WxCpLivingModifyRequest modifyReq = WxCpLivingModifyRequest.fromJson(modify); + WxCpLivingResult result = wxCpService.getLivingService().livingModify(modifyReq); + log.info("result:{}", result.toJson()); + + + // 取消预约直播 +// WxCpLivingResult result2 = wxCpService.getLivingService().livingCancel("lvOQpTDwAA0KyLmWZhf_LIENzYIBVD2g"); + WxCpLivingResult result2 = wxCpService.getLivingService().livingCancel(livingId); + log.info("取消预约直播为:{}", result2.toJson()); + + + // 删除直播回放 +// WxCpLivingResult response = wxCpService.getLivingService().deleteReplayData("lvOQpTDwAAVdCHyXMgSK63TKPfKDII7w"); +// log.info(response.toJson()); + + + } + + /** + * Main. + * + * @param args the args + */ + public static void main(String[] args) { + log.info("{}", new Date().getTime()); + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java index 5e3f665c35..53a55aeaf5 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java @@ -3,11 +3,11 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.session.StandardSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; +import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; import me.chanjar.weixin.cp.message.WxCpMessageHandler; import me.chanjar.weixin.cp.message.WxCpMessageMatcher; import me.chanjar.weixin.cp.message.WxCpMessageRouter; -import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -22,6 +22,13 @@ @Test public class WxCpMessageRouterTest { + /** + * Prepare. + * + * @param async the async + * @param sb the sb + * @param router the router + */ @Test(enabled = false) public void prepare(boolean async, StringBuffer sb, WxCpMessageRouter router) { router @@ -40,20 +47,28 @@ public void prepare(boolean async, StringBuffer sb, WxCpMessageRouter router) { .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK) .handler(new WxEchoCpMessageHandler(sb, "COMBINE_2")) .end() - .rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XmlMsgType.TEXT)).end() - .rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EventType.CLICK)).end() + .rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoCpMessageHandler(sb, + WxConsts.XmlMsgType.TEXT)).end() + .rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoCpMessageHandler(sb, + WxConsts.EventType.CLICK)).end() .rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end() .rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end() .rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end() .rule().async(async).matcher(new WxCpMessageMatcher() { - @Override - public boolean match(WxCpXmlMessage message) { - return "strangeformat".equals(message.getFormat()); - } - }).handler(new WxEchoCpMessageHandler(sb, "matcher")).end() + @Override + public boolean match(WxCpXmlMessage message) { + return "strangeformat".equals(message.getFormat()); + } + }).handler(new WxEchoCpMessageHandler(sb, "matcher")).end() .rule().async(async).handler(new WxEchoCpMessageHandler(sb, "ALL")).end(); } + /** + * Test sync. + * + * @param message the message + * @param expected the expected + */ @Test(dataProvider = "messages-1") public void testSync(WxCpXmlMessage message, String expected) { StringBuffer sb = new StringBuffer(); @@ -63,6 +78,13 @@ public void testSync(WxCpXmlMessage message, String expected) { Assert.assertEquals(sb.toString(), expected); } + /** + * Test async. + * + * @param message the message + * @param expected the expected + * @throws InterruptedException the interrupted exception + */ @Test(dataProvider = "messages-1") public void testAsync(WxCpXmlMessage message, String expected) throws InterruptedException { StringBuffer sb = new StringBuffer(); @@ -73,6 +95,11 @@ public void testAsync(WxCpXmlMessage message, String expected) throws Interrupte Assert.assertEquals(sb.toString(), expected); } + /** + * Test concurrency. + * + * @throws InterruptedException the interrupted exception + */ public void testConcurrency() throws InterruptedException { final WxCpMessageRouter router = new WxCpMessageRouter(null); router.rule().handler(new WxCpMessageHandler() { @@ -98,6 +125,11 @@ public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map co Thread.sleep(2000); } + /** + * Messages 2 object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider(name = "messages-1") public Object[][] messages2() { WxCpXmlMessage message1 = new WxCpXmlMessage(); @@ -152,6 +184,11 @@ public Object[][] messages2() { } + /** + * Standard session manager object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider public Object[][] standardSessionManager() { @@ -167,6 +204,12 @@ public Object[][] standardSessionManager() { } + /** + * Test session clean 1. + * + * @param ism the ism + * @throws InterruptedException the interrupted exception + */ @Test(dataProvider = "standardSessionManager") public void testSessionClean1(StandardSessionManager ism) throws InterruptedException { @@ -186,6 +229,12 @@ public void testSessionClean1(StandardSessionManager ism) throws InterruptedExce } + /** + * Test session clean 2. + * + * @param ism the ism + * @throws InterruptedException the interrupted exception + */ @Test(dataProvider = "standardSessionManager") public void testSessionClean2(StandardSessionManager ism) throws InterruptedException { @@ -221,6 +270,12 @@ public void testSessionClean2(StandardSessionManager ism) throws InterruptedExce } + /** + * Test session clean 3. + * + * @param ism the ism + * @throws InterruptedException the interrupted exception + */ @Test(dataProvider = "standardSessionManager") public void testSessionClean3(StandardSessionManager ism) throws InterruptedException { @@ -240,6 +295,12 @@ public void testSessionClean3(StandardSessionManager ism) throws InterruptedExce } + /** + * Test session clean 4. + * + * @param ism the ism + * @throws InterruptedException the interrupted exception + */ @Test(dataProvider = "standardSessionManager") public void testSessionClean4(StandardSessionManager ism) throws InterruptedException { @@ -273,11 +334,20 @@ public void testSessionClean4(StandardSessionManager ism) throws InterruptedExce } } + /** + * The type Wx echo cp message handler. + */ public static class WxEchoCpMessageHandler implements WxCpMessageHandler { - private StringBuffer sb; - private String echoStr; + private final StringBuffer sb; + private final String echoStr; + /** + * Instantiates a new Wx echo cp message handler. + * + * @param sb the sb + * @param echoStr the echo str + */ public WxEchoCpMessageHandler(StringBuffer sb, String echoStr) { this.sb = sb; this.echoStr = echoStr; @@ -292,6 +362,9 @@ public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map co } + /** + * The type Wx session message handler. + */ public static class WxSessionMessageHandler implements WxCpMessageHandler { @Override diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMsgAuditTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMsgAuditTest.java new file mode 100644 index 0000000000..740725cb82 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMsgAuditTest.java @@ -0,0 +1,758 @@ +package me.chanjar.weixin.cp.api; + +import com.google.common.collect.Lists; +import com.tencent.wework.Finance; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.util.XmlUtils; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; +import me.chanjar.weixin.cp.bean.msgaudit.*; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.constant.WxCpConsts; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import me.chanjar.weixin.cp.util.xml.XStreamTransformer; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * 企业微信会话内容存档测试类. + * 官方文档 + * + * @author Wang_Wong + * created on 2022-01-17 + */ +@Slf4j +public class WxCpMsgAuditTest { + + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService cpService; + + /** + * Test. + */ +// com.binarywang.spring.starter.wxjava.cp.config.WxCpServiceAutoConfiguration + // WxCpServiceImpl.getAccessToken() + @BeforeTest + private void initCpService() { + if (cpService == null) { + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + wxCpConfigStorage = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + cpService = new WxCpServiceImpl(); + cpService.setWxCpConfigStorage(this.wxCpConfigStorage); + } + } + + @Test + public void test() throws Exception { + /* + * 客户同意进行聊天内容存档事件回调 + * 配置了客户联系功能的成员添加外部联系人同意进行聊天内容存档时,回调该事件。 + * + * https://developer.work.weixin.qq.com/document/path/92005 + */ + String msgAuditApprovedXml = "\n" + + "\t\n" + + "\t \n" + + "\t1403610513\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + ""; + + final WxCpXmlMessage msgAuditApprovedXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditApprovedXml); + msgAuditApprovedXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditApprovedXml)); + log.info("msgAuditApprovedXmlMsg:{}", WxCpGsonBuilder.create().toJson(msgAuditApprovedXmlMsg)); + + /* + * 产生会话回调事件 + * 为了提升企业会话存档的使用性能,降低无效的轮询次数。 + * 当企业收到或发送新消息时,企业微信可以以事件的形式推送到企业指定的url。回调间隔为15秒,在15秒内若有消息则触发回调,若无消息则不会触发回调。 + * + * https://developer.work.weixin.qq.com/document/path/95039 + */ + String msgAuditNotifyXml = "\n" + + " \n" + + " \n" + + " 1629101687\n" + + " \n" + + " 2000004\n" + + " \n" + + ""; + + final WxCpXmlMessage msgAuditNotifyXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditNotifyXml); + msgAuditNotifyXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditNotifyXml)); + log.info("msgAuditNotifyXmlMsg:{}", WxCpGsonBuilder.create().toJson(msgAuditNotifyXmlMsg)); + + /* + * 增加变更事件类型:产生会话回调事件 + */ + String msgauditNotify = WxCpConsts.EventType.MSGAUDIT_NOTIFY; + + + /* + * 仔细配置: + * + * ww45xxx88865xxx + * xIpum7Yt4NMXcyxdzcQ2l_46BG4QIQDR57MhA45ebIw // secret + * 200000 // 会话存档的应用id + * // 回调配置的token + * // 回调配置的EncodingAESKey + * + * // 企业微信会话存档 + * // 1、会话存档私钥,最好去除前缀和换行,如下所示! + * // 2、仔细配置windows以及linux环境sdk路径 + * MIxxx893B2pggd1r95T8k2QxxxxbD6xxxxmXsskn + * +5XunyR1WJlJGqgi0OMVGYvSfkNb9kD50fM21CGLcN1y4miL9fVNBIsvJmIUeJCNS8TioAVGFvh2EgzjqTR1gH + * /www/osfile/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll,WeWorkFinanceSdk.dll, + * libWeWorkFinanceSdk_Java.so + * + * + * 注意:最好先配置lib开头的系统库,再配置sdk类库,配置绝对路径,最好配置为linux路径 + * Windows: + * D:/WorkSpace/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll,WeWorkFinanceSdk.dll, + * libWeWorkFinanceSdk_Java.so + * Linux: + * /www/osfile/work_msg_storage/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll, + * WeWorkFinanceSdk.dll,libWeWorkFinanceSdk_Java.so + * + * + * yml配置(支持多个corpId): + * wx: + * cp: + * appConfigs: + * - agentId: 10001 #客户联系 + * corpId: xxxxxxxxxxx + * secret: T5fTj1n-sBAT4rKNW5c9IYNfPdXZxxxxxxxxxxx + * token: 2bSNqTcLtxxxxxxxxxxx + * aesKey: AXazu2Xyw44SNY1x8go2phn9p9B2xxxxxxxxxxx + * - agentId: 10002 #会话内容存档 + * corpId: xxxxxxxxxxx + * secret: xIpum7Yt4NMXcyxdzcQ2l_46BG4Qxxxxxxxxxxx + * token: + * aesKey: + * msgAuditPriKey: MIxxx893B2pggd1r95T8k2QxxxxbD6xxxxmXsskn + * +5XunyR1WJlJGqgi0OMVGYvSfkNb9kD50fM21CGLcN1y4miL9fVNBIsvJmIUeJCNS8TioAVGFvh2EgzjqTR1gHxxx + * msgAuditLibPath: /www/osfile/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll,WeWorkFinanceSdk + * .dll,libWeWorkFinanceSdk_Java.so + * + * + * 在线生成非对称加密公钥私钥对: + * http://web.chacuo.net/netrsakeypair + * + * + * 或者可以在linux上使用如下命令生成公钥私钥对: + * openssl genrsa -out private_key.pem 2048 + * openssl rsa -in private_key.pem -pubout -out public_key.pem + * / + + /* + * 建议放到redis,本次请求获取消息记录开始的seq值。首次访问填写0,非首次使用上次企业微信返回的最大seq。允许从任意seq重入拉取。 + */ + long seq = 0L; + + /* + * 图片,语音,视频,表情,文件,音频存档消息,音频共享文档消息调用 获取媒体消息 + */ + List mediaType = Arrays.asList(WxCpConsts.MsgAuditMediaType.IMAGE, + WxCpConsts.MsgAuditMediaType.VOICE, WxCpConsts.MsgAuditMediaType.VIDEO, + WxCpConsts.MsgAuditMediaType.EMOTION, WxCpConsts.MsgAuditMediaType.FILE, + WxCpConsts.MsgAuditMediaType.MEETING_VOICE_CALL, WxCpConsts.MsgAuditMediaType.VOIP_DOC_SHARE); + + // 模拟多次拉取数据,根据seq拉取 + for (int i = 0; i < 3; i++) { + // 本次请求获取消息记录开始的seq值。首次访问填写0,非首次使用上次企业微信返回的最大seq。允许从任意seq重入拉取。 + WxCpChatDatas chatDatas = cpService.getMsgAuditService().getChatDatas(seq, 10L, null, null, 1000L); + if (chatDatas != null && chatDatas.getChatData().size() > 0) { + + List chatdata = chatDatas.getChatData(); + Iterator iterator = chatdata.iterator(); + while (iterator.hasNext()) { + WxCpChatDatas.WxCpChatData chatData = iterator.next(); + seq = chatData.getSeq(); + + // 数据 +// String msgId = chatData.getMsgId(); +// String encryptChatMsg = chatData.getEncryptChatMsg(); +// String encryptRandomKey = chatData.getEncryptRandomKey(); +// Integer publickeyVer = chatData.getPublickeyVer(); + + // 获取明文数据 + final String chatPlainText = cpService.getMsgAuditService().getChatPlainText(chatDatas.getSdk(), chatData, 2); + final WxCpChatModel wxCpChatModel = WxCpChatModel.fromJson(chatPlainText); + log.info("明文数据为:{}", wxCpChatModel.toJson()); + + // 获取消息数据 + // https://developer.work.weixin.qq.com/document/path/91774 + final WxCpChatModel decryptData = cpService.getMsgAuditService().getDecryptData(chatDatas.getSdk(), + chatData, 2); + log.info("获取消息数据为:{}", decryptData.toJson()); + + /* + * 注意: + * 根据上面返回的文件类型来获取媒体文件, + * 不同的文件类型,拼接好存放文件的绝对路径,写入文件流,获取媒体文件。(拼接绝对文件路径的原因,以便上传到腾讯云或阿里云对象存储) + * + * 目标文件绝对路径+实际文件名,比如:/usr/local/file/20220114/474f866b39d10718810d55262af82662.gif + */ + String path = "/usr/local/file/"; + String msgType = decryptData.getMsgType(); + if (mediaType.contains(decryptData.getMsgType())) { + // 文件后缀 + String suffix = ""; + // 文件名md5 + String md5Sum = ""; + // sdkFileId + String sdkFileId = ""; + switch (msgType) { + case WxCpConsts.MsgAuditMediaType.IMAGE: + suffix = WxCpConsts.MsgAuditMediaType.MsgAuditSuffix.JPG; + md5Sum = decryptData.getImage().getMd5Sum(); + sdkFileId = decryptData.getImage().getSdkFileId(); + break; + case WxCpConsts.MsgAuditMediaType.VOICE: + suffix = WxCpConsts.MsgAuditMediaType.MsgAuditSuffix.AMR; + md5Sum = decryptData.getVoice().getMd5Sum(); + sdkFileId = decryptData.getVoice().getSdkFileId(); + break; + case WxCpConsts.MsgAuditMediaType.VIDEO: + suffix = WxCpConsts.MsgAuditMediaType.MsgAuditSuffix.MP4; + md5Sum = decryptData.getVideo().getMd5Sum(); + sdkFileId = decryptData.getVideo().getSdkFileId(); + break; + case WxCpConsts.MsgAuditMediaType.EMOTION: + md5Sum = decryptData.getEmotion().getMd5Sum(); + sdkFileId = decryptData.getEmotion().getSdkFileId(); + int type = decryptData.getEmotion().getType(); + switch (type) { + case 1: + suffix = WxCpConsts.MsgAuditMediaType.MsgAuditSuffix.GIF; + break; + case 2: + suffix = WxCpConsts.MsgAuditMediaType.MsgAuditSuffix.PNG; + break; + default: + return; + } + break; + case WxCpConsts.MsgAuditMediaType.FILE: + md5Sum = decryptData.getFile().getMd5Sum(); + suffix = "." + decryptData.getFile().getFileExt(); + sdkFileId = decryptData.getFile().getSdkFileId(); + break; + // 音频存档消息 + case WxCpConsts.MsgAuditMediaType.MEETING_VOICE_CALL: + + md5Sum = decryptData.getVoiceId(); + sdkFileId = decryptData.getMeetingVoiceCall().getSdkFileId(); + for (WxCpChatModel.MeetingVoiceCall.DemoFileData demofiledata : + decryptData.getMeetingVoiceCall().getDemoFileData()) { + String demoFileDataFileName = demofiledata.getFileName(); + suffix = demoFileDataFileName.substring(demoFileDataFileName.lastIndexOf(".") + 1); + } + + break; + // 音频共享文档消息 + case WxCpConsts.MsgAuditMediaType.VOIP_DOC_SHARE: + + md5Sum = decryptData.getVoipId(); + WxCpFileItem docShare = decryptData.getVoipDocShare(); + String fileName = docShare.getFileName(); + suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + + break; + default: + return; + } + + /* + * 拉取媒体文件 + * + * 注意: + * 1、根据上面返回的文件类型,拼接好存放文件的绝对路径即可。此时绝对路径写入文件流,来达到获取媒体文件的目的。 + * 2、拉取完媒体文件之后,此时文件已经存在绝对路径,可以通过mq异步上传到对象存储 + * 3、比如可以上传到阿里云oss或者腾讯云cos + */ + String targetPath = path + md5Sum + suffix; + cpService.getMsgAuditService().getMediaFile(chatDatas.getSdk(), sdkFileId, null, null, 1000L, targetPath); + + } + } + } + // 注意: + // 当此批次数据拉取完毕后,应释放此次sdk + log.info("释放sdk {}", chatDatas.getSdk()); + Finance.DestroySdk(chatDatas.getSdk()); + + } + + + /* + * 文本 + */ +// String text = "{\"msgid\":\"CAQQluDa4QUY0On2rYSAgAMgzPrShAE=\",\"action\":\"send\",\"from\":\"XuJinSheng\", +// \"tolist\":[\"icefog\"],\"roomid\":\"\",\"msgtime\":1547087894783,\"msgtype\":\"text\", +// \"text\":{\"content\":\"test\"}}"; + String text = "{\"msgid\":\"CAQQluDa4QUY0On2rYSAgAMgzPrShAE=\",\"action\":\"send\",\"from\":\"XuJinSheng\"," + + "\"tolist\":[\"icefog\"],\"roomid\":\"\",\"msgtime\":1547087894783,\"msgtype\":\"text\"," + + "\"text\":{\"content\":\"这是一条引用/回复消息:\\\"\\n------\\n@nick777\"}}"; + WxCpChatModel modelText = WxCpChatModel.fromJson(text); + log.info("数据为:" + modelText.toJson()); + + + /* + * 图片 + */ + String image = "{\"msgid\":\"CAQQvPnc4QUY0On2rYSAgAMgooLa0Q8=\",\"action\":\"send\",\"from\":\"XuJinSheng\"," + + "\"tolist\":[\"icefog\"],\"roomid\":\"\",\"msgtime\":0,\"msgtype\":\"image\"," + + "\"image\":{\"md5sum\":\"50de8e5ae8ffe4f1df7a93841f71993a\",\"filesize\":70961," + + "\"sdkfileid" + + "\":\"CtYBMzA2OTAyMDEwMjA0NjIzMDYwMDIwMTAwMDIwNGI3ZmU0MDZlMDIwMzBmNTliMTAyMDQ1YzliNTQ3NzAyMDQ1YzM3M2NiYzA0MjQ2NjM0MzgzNTM0NjEzNTY1MmQzNDYxMzQzODJkMzQzMTYxNjEyZDM5NjEzOTM2MmQ2MTM2NjQ2NDY0NjUzMDY2NjE2NjM1MzcwMjAxMDAwMjAzMDExNTQwMDQxMDUwZGU4ZTVhZThmZmU0ZjFkZjdhOTM4NDFmNzE5OTNhMDIwMTAyMDIwMTAwMDQwMBI4TkRkZk1UWTRPRGcxTVRBek1ETXlORFF6TWw4eE9UUTVOamN6TkRZMlh6RTFORGN4TWpNNU1ERT0aIGEwNGQwYWUyM2JlYzQ3NzQ5MjZhNWZjMjk0ZTEyNTkz\"}}"; + WxCpChatModel modelImage = WxCpChatModel.fromJson(image); + log.info("数据为:" + modelImage.toJson()); + + + /* + * 撤回消息 + */ + String revoke = "{\"msgid\":\"15775510700152506326_1603875615\",\"action\":\"recall\",\"from\":\"kenshin\"," + + "\"tolist\":[\"wmUu0zBgAALV7ZymkcMyxvbTe8YdWxxA\"],\"roomid\":\"\",\"msgtime\":1603875615723," + + "\"msgtype\":\"revoke\",\"revoke\":{\"pre_msgid\":\"14822339130656386894_1603875600\"}}"; + WxCpChatModel modelRevoke = WxCpChatModel.fromJson(revoke); + log.info("数据为:" + modelRevoke.toJson()); + + + /* + * 同意会话聊天内容 + */ + String agree = "{\"msgid\":\"8891446340739254950_1603875826\",\"action\":\"send\"," + + "\"from\":\"wmGAgeDQAAvQeaTqWwkMTxGMkvI7OOuQ\",\"tolist\":[\"kenshin\"],\"roomid\":\"\"," + + "\"msgtime\":1603875826656,\"msgtype\":\"agree\",\"agree\":{\"userid\":\"wmGAgeDQAAvQeaTqWwkMTxGMkvI7OOuQ\"," + + "\"agree_time\":1603875826656}}"; + String disagree = "{\"msgid\":\"17972321270926900092_1603875944\",\"action\":\"send\"," + + "\"from\":\"wmErxtDgAA9AW32YyyuYRimKr7D1KWlw\",\"tolist\":[\"kenshin\"],\"roomid\":\"\"," + + "\"msgtime\":1603875944122,\"msgtype\":\"disagree\"," + + "\"disagree\":{\"userid\":\"wmErxtDgAA9AW32YyyuYRimKr7D1KWlw\",\"disagree_time\":1603875944122}}"; + WxCpChatModel modelAgree = WxCpChatModel.fromJson(agree); + WxCpChatModel modelDisagree = WxCpChatModel.fromJson(disagree); + log.info("数据为:" + modelAgree.toJson()); + log.info("数据为:" + modelDisagree.toJson()); + + + /* + * 语音 + */ + String voice = "{\"msgid\":\"10958372969718811103_1603875609\",\"action\":\"send\"," + + "\"from\":\"wmGAgeDQAAdBjb8CK4ieMPRm7Cqm-9VA\",\"tolist\":[\"kenshin\"],\"roomid\":\"\"," + + "\"msgtime\":1603875609704,\"msgtype\":\"voice\",\"voice\":{\"md5sum\":\"9db09c7fa627c9e53f17736c786a74d5\"," + + "\"voice_size\":6810,\"play_length\":10," + + "\"sdkfileid" + + "\":\"kcyZjZqOXhETGYxajB2Zkp5Rk8zYzh4RVF3ZzZGdXlXNWRjMUoxVGZxbzFTTDJnQ2YxL0NraVcxUUJNK3VUamhEVGxtNklCbjZmMEEwSGRwN0h2cU1GQTU1MDRSMWdTSmN3b25ZMkFOeG5hMS90Y3hTQ0VXRlVxYkR0Ymt5c3JmV2VVcGt6UlNXR1ZuTFRWVGtudXVldDRjQ3hscDBrMmNhMFFXVnAwT3Y5NGVqVGpOcWNQV2wrbUJwV01TRm9xWmNDRVVrcFY5Nk9OUS9GbXIvSmZvOVVZZjYxUXBkWnMvUENkVFQxTHc2N0drb2pJT0FLZnhVekRKZ1FSNDU3ZnZtdmYvTzZDOG9DRXl2SUNIOHc9PRI0TkRkZk56ZzRNVE13TVRjMk5qQTRNak0yTmw4ek5qRTVOalExTjE4eE5qQXpPRGMxTmpBNRogNzM3MDY2NmM2YTc5Njg3NDdhNzU3NDY0NzY3NTY4NjY=\"}}"; + WxCpChatModel modelVoice = WxCpChatModel.fromJson(voice); + log.info("数据为:" + modelVoice.toJson()); + + + /* + * 视频 + */ + String video = "{\"msgid\":\"17955920891003447432_1603875627\",\"action\":\"send\",\"from\":\"kenshin\"," + + "\"tolist\":[\"wmGAgeDQAAHuRJbt4ZQI_1cqoQcf41WQ\"],\"roomid\":\"\",\"msgtime\":1603875626823," + + "\"msgtype\":\"video\",\"video\":{\"md5sum\":\"d06fc80c01d6fbffcca3b229ba41eac6\",\"filesize\":15169724," + + "\"play_length\":108," + + "\"sdkfileid" + + "\":\"MzAzMjYxMzAzNTYzMzgzMjMyMzQwMjAxMDAwMjA0MDBlNzc4YzAwNDEwZDA2ZmM4MGMwMWQ2ZmJmZmNjYTNiMjI5YmE0MWVhYzYwMjAxMDQwMjAxMDAwNDAwEjhORGRmTVRZNE9EZzFNREEyTlRjM056QXpORjgxTWpZeE9USTBOek5mTVRZd016ZzNOVFl5Tnc9PRogNTIzNGQ1NTQ5N2RhNDM1ZDhlZTU5ODk4NDQ4NzRhNDk=\"}}"; + WxCpChatModel modelVideo = WxCpChatModel.fromJson(video); + log.info("数据为:" + modelVideo.toJson()); + + + /* + * 名片 + */ + String card = "{\"msgid\":\"13714216591700685558_1603875680\",\"action\":\"send\",\"from\":\"kenshin\"," + + "\"tolist\":[\"wmGAgeDQAAy2Dtr0F8aK4dTuatfm-5Rg\"],\"roomid\":\"\",\"msgtime\":1603875680377," + + "\"msgtype\":\"card\",\"card\":{\"corpname\":\"微信联系人\",\"userid\":\"wmGAgeDQAAGjFmfnP7A3j2JxQDdLNhSw\"}}"; + WxCpChatModel modelCard = WxCpChatModel.fromJson(card); + log.info("数据为:" + modelCard.toJson()); + + + /* + * 位置 + */ + String location = "{\"msgid\":\"2641513858500683770_1603876152\",\"action\":\"send\",\"from\":\"icefog\"," + + "\"tolist\":[\"wmN6etBgAA0sbJ3invMvRxPQDFoq9uWA\"],\"roomid\":\"\",\"msgtime\":1603876152141," + + "\"msgtype\":\"location\",\"location\":{\"longitude\":116.586285899,\"latitude\":39.911125799," + + "\"address\":\"北京市xxx区xxx路xxx大厦x座\",\"title\":\"xxx管理中心\",\"zoom\":15}}"; + WxCpChatModel modelLocation = WxCpChatModel.fromJson(location); + log.info("数据为:" + modelLocation.toJson()); + + + /* + * 表情 + */ + String emotion = "{\"msgid\":\"6623217619416669654_1603875612\",\"action\":\"send\",\"from\":\"icef\"," + + "\"tolist\":[\"wmErxtDgAAhteCglUZH2kUt3rq431qmg\"],\"roomid\":\"\",\"msgtime\":1603875611148," + + "\"msgtype\":\"emotion\",\"emotion\":{\"type\":1,\"width\":290,\"height\":290,\"imagesize\":962604," + + "\"md5sum\":\"94c2b0bba52cc456cb8221b248096612\"," + + "\"sdkfileid\":\"4eE1ESTVNalE1TnprMFh6RTJNRE00TnpVMk1UST0aIDc0NzI2NjY1NzE3NTc0Nzg2ZDZlNzg2YTY5NjY2MTYx\"}}"; + WxCpChatModel modelEmotion = WxCpChatModel.fromJson(emotion); + log.info("数据为:" + modelEmotion.toJson()); + + + /* + * 文件 + */ + String file = "{\"msgid\":\"18039699423706571225_1603875608\",\"action\":\"send\",\"from\":\"kens\"," + + "\"tolist\":[\"wmErxtDgAArDlFIhf76O6w4GxU81al8w\"],\"roomid\":\"\",\"msgtime\":1603875608214," + + "\"msgtype\":\"file\",\"file\":{\"md5sum\":\"18e93fc2ea884df23b3d2d3b8667b9f0\",\"filename\":\"资料.docx\"," + + "\"fileext\":\"docx\",\"filesize\":18181," + + "\"sdkfileid" + + "\":\"E4ODRkZjIzYjNkMmQzYjg2NjdiOWYwMDIwMTA1MDIwMTAwMDQwMBI4TkRkZk1UWTRPRGcxTURrek9UZzBPVEF6TTE4eE1EUXpOVGcxTlRVNVh6RTJNRE00TnpVMk1EZz0aIDMwMzkzMzY0NjEzNjM3NjY2NDY1NjMzNjYxMzIzNzYx\"}}"; + WxCpChatModel modelFile = WxCpChatModel.fromJson(file); + log.info("数据为:" + modelFile.toJson()); + + + /* + * 链接 + */ + String link = "{\"msgid\":\"11788441727514772650_1603875624\",\"action\":\"send\",\"from\":\"kenshin\"," + + "\"tolist\":[\"0000726\"],\"roomid\":\"\",\"msgtime\":1603875624476,\"msgtype\":\"link\"," + + "\"link\":{\"title\":\"邀请你加入群聊\",\"description\":\"技术支持群,进入可查看详情\",\"link_url\":\"https://work.weixin.qq" + + ".com/wework_admin/external_room/join/exceed?vcode=xxx\",\"image_url\":\"https://wework.qpic.cn/wwpic/xxx/0\"}}"; + WxCpChatModel modelLink = WxCpChatModel.fromJson(link); + log.info("数据为:" + modelLink.toJson()); + + + /* + * 小程序消息 + */ + String weapp = "{\"msgid\":\"11930598857592605935_1603875608\",\"action\":\"send\",\"from\":\"kens\"," + + "\"tolist\":[\"wmGAgeDQAAsgQetTQGqRbMxrkodpM3fA\"],\"roomid\":\"\",\"msgtime\":1603875608691," + + "\"msgtype\":\"weapp\",\"weapp\":{\"title\":\"开始聊天前请仔细阅读服务须知事项\",\"description\":\"客户需同意存档聊天记录\"," + + "\"username\":\"xxx@app\",\"displayname\":\"服务须知\"}}"; + WxCpChatModel modelWeapp = WxCpChatModel.fromJson(weapp); + log.info("数据为:" + modelWeapp.toJson()); + + + /* + * 会话记录消息 + */ + String chatrecord = "{\"msgid\":\"11354299838102555191_1603875658\",\"action\":\"send\",\"from\":\"ken\"," + + "\"tolist\":[\"icef\"],\"roomid\":\"\",\"msgtime\":1603875657905,\"msgtype\":\"chatrecord\"," + + "\"chatrecord\":{\"title\":\"群聊\",\"item\":[{\"type\":\"ChatRecordText\",\"msgtime\":1603875610," + + "\"content\":\"{\\\"content\\\":\\\"test\\\"}\",\"from_chatroom\":false},{\"type\":\"ChatRecordText\"," + + "\"msgtime\":1603875620,\"content\":\"{\\\"content\\\":\\\"test2\\\"}\",\"from_chatroom\":false}]}}"; + WxCpChatModel modelChatRecord = WxCpChatModel.fromJson(chatrecord); + log.info("数据为:" + modelChatRecord.toJson()); + + + /* + * 填表消息 + */ + String collect = "{\"msgid\":\"2500536226619379797_1576034482\",\"action\":\"send\",\"from\":\"nick\"," + + "\"tolist\":[\"XuJinSheng\",\"15108264797\"],\"roomid\":\"wrjc7bDwYAOAhf9quEwRRxyyoMm0QAAA\"," + + "\"msgtime\":1576034482344,\"msgtype\":\"collect\",\"collect\":{\"room_name\":\"这是一个群\",\"creator\":\"nick\"," + + "\"create_time\":\"2019-12-11 11:21:22\",\"title\":\"这是填表title\",\"details\":[{\"id\":1,\"ques\":\"表项1,文本\"," + + "\"type\":\"Text\"},{\"id\":2,\"ques\":\"表项2,数字\",\"type\":\"Number\"},{\"id\":3,\"ques\":\"表项3,日期\"," + + "\"type\":\"Date\"},{\"id\":4,\"ques\":\"表项4,时间\",\"type\":\"Time\"}]}}"; + WxCpChatModel modelCollect = WxCpChatModel.fromJson(collect); + log.info("数据为:" + modelCollect.toJson()); + + + /* + * 红包消息 + */ + String redpacket = "{\"msgid\":\"333590477316965370_1603877439\",\"action\":\"send\",\"from\":\"kens\"," + + "\"tolist\":[\"1000000444696\"],\"roomid\":\"\",\"msgtime\":1603877439038,\"msgtype\":\"redpacket\"," + + "\"redpacket\":{\"type\":1,\"wish\":\"恭喜发财,大吉大利\",\"totalcnt\":1,\"totalamount\":3000}}"; + WxCpChatModel modelRedpacket = WxCpChatModel.fromJson(redpacket); + log.info("数据为:" + modelRedpacket.toJson()); + + + /* + * 会议邀请信息 + */ + String meeting = "{\"msgid\":\"5935786683775673543_1603877328\",\"action\":\"send\",\"from\":\"ken\"," + + "\"tolist\":[\"icef\",\"test\"],\"roomid\":\"wr2vOpDgAAN4zVWKbS\",\"msgtime\":1603877328914," + + "\"msgtype\":\"meeting\",\"meeting\":{\"topic\":\"夕会\",\"starttime\":1603877400,\"endtime\":1603881000," + + "\"address\":\"\",\"remarks\":\"\",\"meetingtype\":102,\"meetingid\":1210342560,\"status\":1}}"; + WxCpChatModel modelMeeting = WxCpChatModel.fromJson(meeting); + log.info("数据为:" + modelMeeting.toJson()); + + + /* + * 切换企业日志 + */ + String switchlog = "{\"msgid\":\"125289002219525886280\",\"action\":\"switch\",\"time\":1554119421840," + + "\"user\":\"XuJinSheng\"}"; + WxCpChatModel modelSwitchLog = WxCpChatModel.fromJson(switchlog); + log.info("数据为:" + modelSwitchLog.toJson()); + + + /* + * 在线文档消息 + */ + String docMsg = "{\"msgid\":\"9732089160923053207_1603877765\",\"action\":\"send\",\"from\":\"ken\"," + + "\"tolist\":[\"icef\",\"test\"],\"roomid\":\"wrJawBCQAAStr3jxVxEH\",\"msgtime\":1603877765291," + + "\"msgtype\":\"docmsg\",\"doc\":{\"title\":\"测试&演示客户\",\"doc_creator\":\"test\",\"link_url\":\"https://doc" + + ".weixin.qq.com/txdoc/excel?docid=xxx\"}}"; + WxCpChatModel modelDocMsg = WxCpChatModel.fromJson(docMsg); + log.info("数据为:" + modelDocMsg.toJson()); + + + /* + * MarkDown格式消息 + */ + String markDown = "{\"msgid\":\"7546287934688259248_1603875715\",\"action\":\"send\",\"from\":\"ken\"," + + "\"tolist\":[\"icef\",\"test\"],\"roomid\":\"wr0SfLCgAAgCaCPeM33UNe\",\"msgtime\":1603875715782," + + "\"msgtype\":\"markdown\",\"info\":{\"content\":\"请前往系统查看,谢谢。\"}}"; + WxCpChatModel modelMarkDown = WxCpChatModel.fromJson(markDown); + log.info("数据为:" + modelMarkDown.toJson()); + + + /* + * 图文消息 + */ + String news = "{\"msgid\":\"118732825779547782215\",\"action\":\"send\",\"from\":\"kens\",\"tolist\":[\"icef\"," + + "\"test\"],\"roomid\":\"wrErxtDgAA0jgXE5\",\"msgtime\":1603876045165,\"msgtype\":\"news\"," + + "\"info\":{\"item\":[{\"title\":\"service \",\"description\":\"test\",\"url\":\"http://xxx\"," + + "\"picurl\":\"https://www.qq.com/xxx.jpg\"}]}}"; + WxCpChatModel modelNews = WxCpChatModel.fromJson(news); + log.info("数据为:" + modelNews.toJson()); + + + /* + * 日程消息 + */ + String calendar = "{\"msgid\":\"2345881211604379705_1603877680\",\"action\":\"send\",\"from\":\"ken\"," + + "\"tolist\":[\"icef\",\"test\"],\"roomid\":\"wr2LO0CAAAFrTZCGWWAxBA\",\"msgtime\":1603877680795," + + "\"msgtype\":\"calendar\",\"calendar\":{\"title\":\"xxx业绩复盘会\",\"creatorname\":\"test\"," + + "\"attendeename\":[\"aaa\",\"bbb\"],\"starttime\":1603882800,\"endtime\":1603886400,\"place\":\"\"," + + "\"remarks\":\"\"}}"; + WxCpChatModel modelCalendar = WxCpChatModel.fromJson(calendar); + log.info("数据为:" + modelCalendar.toJson()); + + + /* + * 混合消息 + */ + String mixed = "{\"msgid\":\"DAQQluDa4QUY0On4kYSABAMgzPrShAE=\",\"action\":\"send\",\"from\":\"HeMiao\"," + + "\"tolist\":[\"HeChangTian\",\"LiuZeYu\"],\"roomid\":\"wr_tZ2BwAAUwHpYMwy9cIWqnlU3Hzqfg\"," + + "\"msgtime\":1577414359072,\"msgtype\":\"mixed\",\"mixed\":{\"item\":[{\"type\":\"text\"," + + "\"content\":\"{\\\"content\\\":\\\"你好[微笑]\\\\n\\\"}\"},{\"type\":\"image\"," + + "\"content\":\"{\\\"md5sum\\\":\\\"368b6c18c82e6441bfd89b343e9d2429\\\",\\\"filesize\\\":13177," + + "\\\"sdkfileid" + + "\\\":\\\"CtYBMzA2OTAyMDEwMjA0NjIzMDYwMDIwMTAwMDWwNDVmYWY4Y2Q3MDIwMzBmNTliMTAyMDQwYzljNTQ3NzAyMDQ1ZTA1NmFlMjA0MjQ2NjM0NjIzNjY2MzYzNTMyMmQzNzYxMzQ2NDJkMzQ2MjYxNjQyZDM4MzMzMzM4MmQ3MTYyMzczMTM4NjM2NDYxMzczMjY2MzkwMjAxMDAwMjAzMDIwMDEwMDQxMDM2OGI2YzE4YzgyZTY0NDFiZmQ4OWIyNDNlOWQyNDI4MDIwMTAyMDIwMTAwMDQwMBI4TkRkZk2UWTRPRGcxTVRneE5URTFNRGc1TVY4eE1UTTFOak0yTURVeFh6RTFOemMwTVRNek5EYz0aIDQzMTY5NDFlM2MxZDRmZjhhMjEwY2M0NDQzZGUXOTEy\\\"}\"}]}}"; + WxCpChatModel modelMixed = WxCpChatModel.fromJson(mixed); + log.info("获取混合消息,文件对象为:{}", modelMixed.getMixed().getItem().get(0).getContent()); + + // 返回文件对象 + WxCpFileItem wxCpFileItem = WxCpFileItem.fromJson(modelMixed.getMixed().getItem().get(1).getContent()); + log.info("获取混合消息,文件对象为:{}", wxCpFileItem.toJson()); + log.info("数据为:" + modelMixed.toJson()); + + + /* + * 音频存档消息 + */ + String meetingVoiceCall = "{\"msgid\":\"17952229780246929345_1594197637\",\"action\":\"send\"," + + "\"from\":\"wo137MCgAAYW6pIiKKrDe5SlzEhSgwbA\",\"tolist\":[\"wo137MCgAAYW6pIiKKrDe5SlzEhSgwbA\"]," + + "\"msgtime\":1594197581203,\"msgtype\":\"meeting_voice_call\"," + + "\"voiceid\":\"grb8a4c48a3c094a70982c518d55e40557\",\"meeting_voice_call\":{\"endtime\":1594197635," + + "\"sdkfileid" + + "\":\"CpsBKjAqd0xhb2JWRUJldGtwcE5DVTB6UjRUalN6c09vTjVyRnF4YVJ5M24rZC9YcHF3cHRPVzRwUUlaMy9iTytFcnc0SlBkZDU1YjRNb0MzbTZtRnViOXV5WjUwZUIwKzhjbU9uRUlxZ3pyK2VXSVhUWVN2ejAyWFJaTldGSkRJVFl0aUhkcVdjbDJ1L2RPbjJsRlBOamJaVDNnPT0SOE5EZGZNVFk0T0RnMU16YzVNVGt5T1RJMk9GOHhNalk0TXpBeE9EZzJYekUxT1RReE9UYzJNemM9GiA3YTYyNzA3NTY4Nzc2MTY3NzQ2MTY0NzA2ZTc4NjQ2OQ==\",\"demofiledata\":[{\"filename\":\"65eb1cdd3e7a3c1740ecd74220b6c627.docx\",\"demooperator\":\"wo137MCgAAYW6pIiKKrDe5SlzEhSgwbA\",\"starttime\":1594197599,\"endtime\":1594197609}],\"sharescreendata\":[{\"share\":\"wo137MCgAAYW6pIiKKrDe5SlzEhSgwbA\",\"starttime\":1594197624,\"endtime\":1594197624}]}}"; + WxCpChatModel modelMeetingVoiceCall = WxCpChatModel.fromJson(meetingVoiceCall); + log.info("数据为:" + modelMeetingVoiceCall.toJson()); + + + /* + * 音频共享文档消息 + */ + String voipDocShare = "{\"msgid\":\"16527954622422422847_1594199256\",\"action\":\"send\"," + + "\"from\":\"18002520162\",\"tolist\":[\"wo137MCgAAYW6pIiKKrDe5SlzEhSgwbA\"],\"msgtime\":1594199235014," + + "\"msgtype\":\"voip_doc_share\",\"voipid\":\"gr2751c98b19300571f8afb3b74514bd32\"," + + "\"voip_doc_share\":{\"filename\":\"欢迎使用微盘.pdf.pdf\",\"md5sum\":\"ff893900f24e55e216e617a40e5c4648\"," + + "\"filesize\":4400654," + + "\"sdkfileid" + + "\":\"CpsBKjAqZUlLdWJMd2gvQ1JxMzd0ZjlpdW5mZzJOOE9JZm5kbndvRmRqdnBETjY0QlcvdGtHSFFTYm95dHM2VlllQXhkUUN5KzRmSy9KT3pudnA2aHhYZFlPemc2aVZ6YktzaVh3YkFPZHlqNnl2L2MvcGlqcVRjRTlhZEZsOGlGdHJpQ2RWSVNVUngrVFpuUmo3TGlPQ1BJemlRPT0SOE5EZGZNVFk0T0RnMU16YzVNVGt5T1RJMk9GODFNelUyTlRBd01qQmZNVFU1TkRFNU9USTFOZz09GiA3YTcwNmQ2Zjc5NjY3MDZjNjY2Zjc4NzI3NTZmN2E2YQ==\"}}"; + WxCpChatModel modelVoipDocShare = WxCpChatModel.fromJson(voipDocShare); + log.info("数据为:" + modelVoipDocShare.toJson()); + + + /* + * 互通红包消息 + */ + String externalRedpacket = "{\"msgid\":\"8632214264349267353_1603786184\",\"action\":\"send\"," + + "\"from\":\"woJ7ijBwAAmqwojT8r_DaNMbr_NAvaag\",\"tolist\":[\"woJ7ijBwAA6SjS_sIyPLZtyEPJlT7Cfw\"," + + "\"tiny-six768\"],\"roomid\":\"wrJ7ijBwAAG1vly_DzVI72Ghc-PtA5Dw\",\"msgtime\":1603786183955," + + "\"msgtype\":\"external_redpacket\",\"redpacket\":{\"type\":1,\"wish\":\"恭喜发财,大吉大利\",\"totalcnt\":2," + + "\"totalamount\":20}}"; + WxCpChatModel modelExternalRedpacket = WxCpChatModel.fromJson(externalRedpacket); + log.info("数据为:" + modelExternalRedpacket.toJson()); + + + /* + * 视频号消息 + */ + String sphfeed = "{\"msgid\":\"5702551662099334532_1619511584_external\",\"action\":\"send\"," + + "\"from\":\"yangzhu1\",\"tolist\":[\"wmJSb5CgAA4aWXWndJspQGpJMDbsMwMA\"],\"roomid\":\"\"," + + "\"msgtime\":1619511584444,\"msgtype\":\"sphfeed\",\"sphfeed\":{\"feed_type\":4,\"sph_name\":\"云游天地旅行家\"," + + "\"feed_desc\":\"瑞士丨盖尔默缆车,名副其实的过山车~\\n\\n#旅行#风景#热门\"}}"; + WxCpChatModel modelSphFeed = WxCpChatModel.fromJson(sphfeed); + log.info("数据为:" + modelSphFeed.toJson()); + + + /* + * 获取会话内容存档开启成员列表 + */ + List permitUserList = cpService.getMsgAuditService().getPermitUserList(null); + log.info(permitUserList.toString()); + + + ArrayList userList = Lists.newArrayList(); + WxCpCheckAgreeRequest checkAgreeRequest = new WxCpCheckAgreeRequest(); + /* + * 获取会话同意情况 + */ + WxCpCheckAgreeRequest.Info info = new WxCpCheckAgreeRequest.Info(); + info.setUserid("wangkai"); + info.setExteranalOpenId("wmOQpTDwAAkOscTrtUlSli0YLU2jcpUg"); + if (info != null) { + userList.add(info); + checkAgreeRequest.setInfo(userList); + } + + WxCpAgreeInfo wxCpAgreeInfo = cpService.getMsgAuditService().checkSingleAgree(checkAgreeRequest); + log.info(wxCpAgreeInfo.toJson()); + + + /* + * 获取会话内容存档内部群信息 + */ + WxCpGroupChat room = cpService.getMsgAuditService().getGroupChat("wrOQpTDwAAyPl84GBJ40W5eWxWtixSCA"); + log.info(room.toJson()); + + + /* + * 获取access_token + * https://developer.work.weixin.qq.com/document/path/91039 + * https://www.jianshu.com/p/dde171887d63 + */ + String getUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s"; + String data = cpService.get(String.format(getUrl, wxCpConfigStorage.getCorpId(), + wxCpConfigStorage.getCorpSecret()), null); + + + } + + @Test + public void testGetMediaFile() throws Exception { + WxCpMsgAuditService msgAuditService = cpService.getMsgAuditService(); + WxCpChatDatas chatDatas = msgAuditService.getChatDatas(0L, 100L, null, null, 10); + for (WxCpChatDatas.WxCpChatData chatDatum : chatDatas.getChatData()) { + WxCpChatModel decryptData = msgAuditService.getDecryptData(chatDatas.getSdk(), chatDatum, 2); + // 文件后缀 + String suffix = ""; + // 文件名md5 + String md5Sum = ""; + // sdkFileId + String sdkFileId = ""; + String msgType = decryptData.getMsgType(); + if (msgType == null) msgType = ""; + switch (msgType) { + case "image": + suffix = ".jpg"; + md5Sum = decryptData.getImage().getMd5Sum(); + sdkFileId = decryptData.getImage().getSdkFileId(); + break; + case "voice": + suffix = ".amr"; + md5Sum = decryptData.getVoice().getMd5Sum(); + sdkFileId = decryptData.getVoice().getSdkFileId(); + break; + case "video": + suffix = ".mp4"; + md5Sum = decryptData.getVideo().getMd5Sum(); + sdkFileId = decryptData.getVideo().getSdkFileId(); + break; + case "emotion": + md5Sum = decryptData.getEmotion().getMd5Sum(); + sdkFileId = decryptData.getEmotion().getSdkFileId(); + int type = decryptData.getEmotion().getType(); + switch (type) { + case 1: + suffix = ".gif"; + break; + case 2: + suffix = ".png"; + break; + default: + return; + } + break; + case "file": + md5Sum = decryptData.getFile().getMd5Sum(); + suffix = "." + decryptData.getFile().getFileExt(); + sdkFileId = decryptData.getFile().getSdkFileId(); + break; + // 音频存档消息 + case "meeting_voice_call": + + md5Sum = decryptData.getVoiceId(); + sdkFileId = decryptData.getMeetingVoiceCall().getSdkFileId(); + for (WxCpChatModel.MeetingVoiceCall.DemoFileData demofiledata : + decryptData.getMeetingVoiceCall().getDemoFileData()) { + String demoFileDataFileName = demofiledata.getFileName(); + suffix = demoFileDataFileName.substring(demoFileDataFileName.lastIndexOf(".") + 1); + } + + break; + // 音频共享文档消息 + case "voip_doc_share": + + md5Sum = decryptData.getVoipId(); + WxCpFileItem docShare = decryptData.getVoipDocShare(); + String fileName = docShare.getFileName(); + suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + break; + default: + continue; + } + + /* + * 拉取媒体文件 + * + * 传入一个each函数,用于遍历每个分片的数据 + */ + String path = Thread.currentThread().getContextClassLoader().getResource("").getPath(); + String targetPath = path + "testfile/" + md5Sum + suffix; + File file = new File(targetPath); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } else { + file.delete(); + } + cpService.getMsgAuditService().getMediaFile(chatDatas.getSdk(), sdkFileId, null, null, 1000L, data -> { + try { + // 大于512k的文件会分片拉取,此处需要使用追加写,避免后面的分片覆盖之前的数据。 + FileOutputStream outputStream = new FileOutputStream(targetPath, true); + outputStream.write(data); + outputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + }); + } + Finance.DestroySdk(chatDatas.getSdk()); + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java new file mode 100644 index 0000000000..855d25b571 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java @@ -0,0 +1,218 @@ +package me.chanjar.weixin.cp.api; + +import com.google.gson.reflect.TypeToken; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.XmlUtils; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; +import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.constant.WxCpConsts; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import me.chanjar.weixin.cp.util.xml.XStreamTransformer; +import org.testng.annotations.Test; + +import java.io.InputStream; + +/** + * 企业微信自建应用接口测试类. + * https://developer.work.weixin.qq.com/document/path/90269 + * https://developer.work.weixin.qq.com/document/path/90240#%E5%AE%A1%E6%89%B9%E7%8A%B6%E6%80%81%E9%80%9A%E7%9F%A5%E4 + * %BA%8B%E4%BB%B6 + * + * @author Wang_Wong created on 2022-04-06 + */ +@Slf4j +public class WxCpOaAgentTest { + + // extends WxCpBaseResp + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService cpService; + + /** + * Test. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void test() throws WxErrorException { + + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + + wxCpConfigStorage = config; + cpService = new WxCpServiceImpl(); + cpService.setWxCpConfigStorage(config); + + + /** + * 测试 审批状态通知事件 + */ + String testXml2 = "\n" + + " \n" + + " \n" + + " 1527838022\n" + + " \n" + + " \n" + + " 1\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " 1527837645\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " 1\n" + + " 1\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " \n" + + " 0\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 0\n" + + " \n" + + "\n"; + final WxCpXmlMessage mess2 = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml2); + mess2.setAllFieldsMap(XmlUtils.xml2Map(testXml2)); + log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(mess2)); + + + /** + * 测试 弹出微信相册发图器的事件推送 + * + * https://developer.work.weixin.qq.com/document/path/90240 + */ + String testXml = "\n" + + "\t\n" + + "\t\n" + + "\t1408090816\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t1\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t1\n" + + "\n"; + + final WxCpXmlMessage mess = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml); + mess.setAllFieldsMap(XmlUtils.xml2Map(testXml)); + log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(mess)); + + + /** + * 审批流程引擎 + * 自建应用审批状态变化通知回调 + * + * https://developer.work.weixin.qq.com/document/path/90269 + */ + String approvalInfoXml = "\n" + + " wwd08c8e7c775abaaa \n" + + " sys \n" + + " 1527838022 \n" + + " event \n" + + " open_approval_change\n" + + " 1\n" + + " \n" + + " thirdNoxxx \n" + + " 付款 \n" + + " 1234567111 \n" + + " 1 \n" + + " 1527837645 \n" + + " jackiejjwu \n" + + " WuJunJie \n" + + " 产品部 \n" + + " http://www.qq.com/xxx.png \n" + + " \n" + + " \n" + + " 1 \n" + + " 1 \n" + + " 1 \n" + + " \n" + + " \n" + + " chauvetxiao \n" + + " XiaoWen \n" + + " 产品部 \n" + + " http://www.qq.com/xxx.png \n" + + " 1 \n" + + " \n" + + " 0 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " jinhuiguo \n" + + " GuoJinHui \n" + + " 行政部 \n" + + " http://www.qq.com/xxx.png \n" + + " \n" + + " \n" + + " 0 \n" + + " \n" + + "\n"; + + final WxCpXmlMessage msg = XStreamTransformer.fromXml(WxCpXmlMessage.class, approvalInfoXml); + msg.setAllFieldsMap(XmlUtils.xml2Map(approvalInfoXml)); + log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(msg)); + + /** + * 增加 + * 自建应用审批状态变化通知回调类型 + */ + String openApprovalChange = WxCpConsts.EventType.OPEN_APPROVAL_CHANGE; + + + /** + * Test + */ + String test = "{\"errcode\":0,\"errmsg\":\"ok\",\"data\":{\"ThirdNo\":\"thirdNoxxx\"," + + "\"OpenTemplateId\":\"1234567111\",\"OpenSpName\":\"付款\",\"OpenSpstatus\":1,\"ApplyTime\":1527837645," + + "\"ApplyUsername\":\"jackiejjwu\",\"ApplyUserParty\":\"产品部\",\"ApplyUserImage\":\"http://www.qq.com/xxx.png\"," + + "\"ApplyUserId\":\"WuJunJie\",\"ApprovalNodes\":{\"ApprovalNode\":[{\"NodeStatus\":1,\"NodeAttr\":1," + + "\"NodeType\":1,\"Items\":{\"Item\":[{\"ItemName\":\"chauvetxiao\",\"ItemParty\":\"产品部\"," + + "\"ItemImage\":\"http://www.qq.com/xxx.png\",\"ItemUserId\":\"XiaoWen\",\"ItemStatus\":1,\"ItemSpeech\":\"\"," + + "\"ItemOpTime\":0}]}}]},\"NotifyNodes\":{\"NotifyNode\":[{\"ItemName\":\"jinhuiguo\",\"ItemParty\":\"行政部\"," + + "\"ItemImage\":\"http://www.qq.com/xxx.png\",\"ItemUserId\":\"GuoJinHui\"}]},\"ApproverStep\":0}}"; + + final WxCpOpenApprovalData data = WxCpGsonBuilder.create() + .fromJson(GsonParser.parse(test).get("data"), + new TypeToken() { + }.getType() + ); + + log.info(data.toJson()); + + + WxCpOpenApprovalData openApprovalData = cpService.getOaAgentService().getOpenApprovalData("943225459735269376"); + log.info(openApprovalData.toJson()); + + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java new file mode 100644 index 0000000000..dc1c458734 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java @@ -0,0 +1,290 @@ +package me.chanjar.weixin.cp.api; + +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import lombok.var; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.oa.wedrive.*; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Base64; +import java.util.List; + +/** + * 微盘测试类. + * 官方文档:https://developer.work.weixin.qq.com/document/path/93654 + * + * @author Wang_Wong + */ +@Slf4j +public class WxCpOaWeDriveServiceTest { + + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService cpService; + + /** + * Test. + * + * @throws Exception the exception + */ + @Test + public void test() throws Exception { + + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + + wxCpConfigStorage = config; + cpService = new WxCpServiceImpl(); + cpService.setWxCpConfigStorage(config); + + String createSpace = "{\"userid\":\"USERID\",\"space_name\":\"SPACE_NAME\",\"auth_info\":[{\"type\":1," + + "\"userid\":\"USERID\",\"auth\":2},{\"type\":2,\"departmentid\":2,\"auth\":1}]}"; + WxCpSpaceCreateRequest wxCpSpaceCreateRequest = WxCpSpaceCreateRequest.fromJson(createSpace); + log.info(wxCpSpaceCreateRequest.toJson()); + + String uId = "WangKai"; + String spId = "s.ww45d3e188865aca30.652091685u4h"; + // 空间的文件id + String fileId = "s.ww45d3e188865aca30.652091685u4h_f.652344507ysDL"; + String fileId2 = "s.ww45d3e188865aca30.652091685u4h_f.652696024TU4P"; + + + /** + * 获取分享链接 + */ + WxCpFileShare fileShare = cpService.getOaWeDriveService().fileShare(uId, fileId2); + log.info("获取分享链接返回结果为:{}", fileShare.toJson()); + + /** + * 分享设置 + */ + WxCpBaseResp fileSetting = cpService.getOaWeDriveService().fileSetting(uId, fileId2, 2, 1); + log.info("分享设置返回结果为:{}", fileSetting.toJson()); + + /** + * 删除指定人 + */ + WxCpFileAclDelRequest aclDelRequest = new WxCpFileAclDelRequest(); + aclDelRequest.setUserId(uId); + aclDelRequest.setFileId(fileId2); + + ArrayList aclDelList = Lists.newArrayList(); + + WxCpFileAclDelRequest.AuthInfo aclDelAuthInfo = new WxCpFileAclDelRequest.AuthInfo(); + aclDelAuthInfo.setType(1); + aclDelAuthInfo.setUserId(uId); + + aclDelList.add(aclDelAuthInfo); + aclDelRequest.setAuthInfo(aclDelList); + + WxCpBaseResp aclDel = cpService.getOaWeDriveService().fileAclDel(aclDelRequest); + log.info("删除指定人返回结果为:{}", aclDel.toJson()); + + /** + * 新增指定人 + */ + WxCpFileAclAddRequest fileAclAdd = new WxCpFileAclAddRequest(); + fileAclAdd.setUserId(uId); + fileAclAdd.setFileId(fileId2); + var authInfoData = new WxCpFileAclAddRequest.AuthInfo(); + authInfoData.setType(1); + authInfoData.setAuth(1); + authInfoData.setUserId(uId); + + ArrayList authList = Lists.newArrayList(); + authList.add(authInfoData); + fileAclAdd.setAuthInfo(authList); + + WxCpBaseResp result = cpService.getOaWeDriveService().fileAclAdd(fileAclAdd); + log.info("返回结果为:{}", result.toJson()); + + /** + * 删除文件 + */ + ArrayList fileIds = Lists.newArrayList(); + fileIds.add(fileId); + WxCpBaseResp fileDelete = cpService.getOaWeDriveService().fileDelete(uId, fileIds); + log.info("删除文件数据为:{}", fileDelete.toJson()); + + /** + * 文件信息 + */ + WxCpFileInfo fileInfo = cpService.getOaWeDriveService().fileInfo(uId, fileId); + log.info("fileInfo数据为:{}", fileInfo.toJson()); + + /** + * 移动文件 + */ + WxCpFileMoveRequest fileMoveRequest = new WxCpFileMoveRequest(); + fileMoveRequest.setUserId(uId); + fileMoveRequest.setFatherId(spId); + fileMoveRequest.setReplace(true); + fileMoveRequest.setFileId(new String[]{fileId}); + + WxCpFileMove fileMove = cpService.getOaWeDriveService().fileMove(fileMoveRequest); + log.info("fileMove数据为:{}", fileMove.toJson()); + + /** + * 新建文件/微文档 + */ + WxCpFileCreate fileCreate = cpService.getOaWeDriveService().fileCreate(uId, spId, spId, 3, "新建微文档1"); + log.info("新建文件/微文档:{}", fileCreate.toJson()); + + /** + * 下载文件 + */ + WxCpFileDownload fileDownload = cpService.getOaWeDriveService().fileDownload(uId, fileId); + log.info("下载文件为:{}", fileDownload.toJson()); + + /** + * 上传文件 + */ + WxCpFileUploadRequest fileUploadRequest = new WxCpFileUploadRequest(); + fileUploadRequest.setUserId(uId); + fileUploadRequest.setSpaceId(spId); + fileUploadRequest.setFatherId(spId); + fileUploadRequest.setFileName("第一个文件"); + + // 将文件转成base64字符串 + File file = new File("D:/info.log.2022-05-07.0.log"); +// File file = new File("D:/16.png"); + FileInputStream inputFile = new FileInputStream(file); + byte[] buffer = new byte[(int) file.length()]; + inputFile.read(buffer); + inputFile.close(); + String encodeBase64Content = Base64.getEncoder().encodeToString(buffer); + fileUploadRequest.setFileBase64Content(encodeBase64Content); + + WxCpFileUpload fileUpload = cpService.getOaWeDriveService().fileUpload(fileUploadRequest); + log.info("上传文件为:{}", fileUpload.toJson()); + + /** + * 重命名文件 + */ + WxCpFileRename fileRename = cpService.getOaWeDriveService().fileRename(uId, fileUpload.getFileId(), "新的名字呢"); + log.info("重命名文件:{}", fileRename.toJson()); + + /** + * 获取文件列表 + */ + WxCpFileListRequest fileListRequest = new WxCpFileListRequest(); + fileListRequest.setUserId(uId); + fileListRequest.setSpaceId(spId); + fileListRequest.setFatherId(spId); + fileListRequest.setSortType(1); + fileListRequest.setStart(0); + fileListRequest.setLimit(100); + + WxCpFileList fileList = cpService.getOaWeDriveService().fileList(fileListRequest); + log.info("获取文件列表为:{}", fileList.toJson()); + + /** + * 权限管理 + */ + WxCpSpaceSettingRequest spaceSettingRequest = new WxCpSpaceSettingRequest(); + spaceSettingRequest.setUserId(uId); + spaceSettingRequest.setSpaceId(spId); +// spaceSettingRequest.setEnableWatermark(false); + spaceSettingRequest.setAddMemberOnlyAdmin(true); + spaceSettingRequest.setEnableShareUrl(false); + spaceSettingRequest.setShareUrlNoApprove(true); + spaceSettingRequest.setShareUrlNoApproveDefaultAuth(2); + + WxCpBaseResp spaceSetting = cpService.getOaWeDriveService().spaceSetting(spaceSettingRequest); + log.info("权限管理信息为:{}", spaceSetting.toJson()); + + /** + * 获取邀请链接 + */ + WxCpSpaceShare spaceShare = cpService.getOaWeDriveService().spaceShare(uId, spId); + log.info("获取邀请链接信息为:{}", spaceShare.toJson()); + + /** + * 获取空间信息 + */ + WxCpSpaceInfo data = cpService.getOaWeDriveService().spaceInfo(uId, spId); + log.info("获取空间信息为:{}", data.toJson()); + + /** + * 移除成员/部门 + */ + WxCpSpaceAclDelRequest spaceAclDelRequest = new WxCpSpaceAclDelRequest(); + spaceAclDelRequest.setUserId(uId); + spaceAclDelRequest.setSpaceId(spId); + + // 被移除的空间成员信息 + WxCpSpaceAclDelRequest.AuthInfo delAuthInfo = new WxCpSpaceAclDelRequest.AuthInfo(); + delAuthInfo.setType(1); + delAuthInfo.setUserId("MiaoMiu99"); + + List delAuthInfoList = new ArrayList<>(); + delAuthInfoList.add(delAuthInfo); + + spaceAclDelRequest.setAuthInfo(delAuthInfoList); + WxCpBaseResp spaceAclDel = cpService.getOaWeDriveService().spaceAclDel(spaceAclDelRequest); + log.info("移除成员/部门,返回数据为:{}", spaceAclDel.toJson()); + + /** + * 添加成员/部门 + * https://developer.work.weixin.qq.com/document/path/93656 + */ + WxCpSpaceAclAddRequest spaceAclAddRequest = new WxCpSpaceAclAddRequest(); + spaceAclAddRequest.setUserId(uId); + spaceAclAddRequest.setSpaceId(spId); + + List authInfoList = new ArrayList<>(); + // 被添加的空间成员信息 + WxCpSpaceAclAddRequest.AuthInfo authInfo = new WxCpSpaceAclAddRequest.AuthInfo(); + authInfo.setAuth(2); + authInfo.setType(1); + authInfo.setUserId("MiaoMiu99"); + + authInfoList.add(authInfo); + spaceAclAddRequest.setAuthInfo(authInfoList); + + WxCpBaseResp wxCpBaseResp = cpService.getOaWeDriveService().spaceAclAdd(spaceAclAddRequest); + log.info("添加成员/部门,返回数据为:{}", wxCpBaseResp.toJson()); + + /** + * 获取空间信息 + */ + WxCpSpaceInfo spaceInfo = cpService.getOaWeDriveService().spaceInfo("WangKai", "s.ww45d3e188865aca30.652091685u4h"); + log.info("获取空间信息,spaceInfo信息为:{}", spaceInfo.toJson()); + + /** + * 新建空间 + */ + WxCpSpaceCreateRequest request = new WxCpSpaceCreateRequest(); + request.setUserId("WangKai"); + request.setSpaceName("测试云盘Three"); + + WxCpSpaceCreateData spaceCreateData = cpService.getOaWeDriveService().spaceCreate(request); + log.info("空间id为:{}", spaceCreateData.getSpaceId()); // + log.info(spaceCreateData.toJson()); + + /** + * 重命名空间 + */ + WxCpSpaceRenameRequest wxCpSpaceRenameRequest = new WxCpSpaceRenameRequest(); + wxCpSpaceRenameRequest.setUserId("WangKai"); + wxCpSpaceRenameRequest.setSpaceId(spaceCreateData.getSpaceId()); + wxCpSpaceRenameRequest.setSpaceName("测试云盘Four"); + WxCpBaseResp baseResp = cpService.getOaWeDriveService().spaceRename(wxCpSpaceRenameRequest); + log.info("重命名成功:{}", baseResp.toJson()); + + /** + * 解散空间 + */ + WxCpBaseResp thisResp = cpService.getOaWeDriveService().spaceDismiss("WangKai", spaceCreateData.getSpaceId()); + log.info("解散成功:{}", thisResp.toJson()); + + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthTest.java new file mode 100644 index 0000000000..d922c14dcc --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthTest.java @@ -0,0 +1,143 @@ +package me.chanjar.weixin.cp.api; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetHealthReportStat; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportAnswer; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobIds; +import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobInfo; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import org.testng.annotations.Test; + +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 企业微信家校应用 健康上报接口. + * https://developer.work.weixin.qq.com/document/path/93676 + * + * @author Wang_Wong created on : 2022/5/31 9:10 + */ +@Slf4j +public class WxCpSchoolHealthTest { + + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService cpService; + + /** + * Test. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void test() throws WxErrorException { + + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + + wxCpConfigStorage = config; + cpService = new WxCpServiceImpl(); + cpService.setWxCpConfigStorage(config); + String currDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + + + // Test Json + String reportAnswerStr = "{\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"answers\":[\n" + + "\t\t{\n" + + "\t\t\t\"id_type\": 1,\n" + + "\t\t\t\"userid\": \"userid2\",\n" + + "\t\t\t\"report_time\": 123456789,\n" + + "\t\t\t\"report_values\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 1,\n" + + "\t\t\t\t\t\"single_choice\": 2\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 2,\n" + + "\t\t\t\t\t\"text\": \"广东省广州市\"\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 3,\n" + + "\t\t\t\t\t\"multi_choice\": [\n" + + "\t\t\t\t\t\t1, 3\n" + + "\t\t\t\t\t]\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 4,\n" + + "\t\t\t\t\t\"fileid\": [\n" + + " \"XXXXXXX\"\n" + + " ]\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t},\n" + + "\t\t{\n" + + "\t\t\t\"id_type\": 2,\n" + + "\t\t\t\"student_userid\": \"student_userid1\",\n" + + "\t\t\t\"parent_userid\": \"parent_userid1\",\n" + + "\t\t\t\"report_time\": 123456789,\n" + + "\t\t\t\"report_values\":[\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 1,\n" + + "\t\t\t\t\t\"single_choice\": 1\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 2,\n" + + "\t\t\t\t\t\"text\": \"广东省深圳市\"\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 3,\n" + + "\t\t\t\t\t\"multi_choice\":[\n" + + "\t\t\t\t\t\t1,2,3\n" + + "\t\t\t\t\t]\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"question_id\": 4,\n" + + "\t\t\t\t\t\"fileid\": [\n" + + " \"XXXXXXX\"\n" + + " ]\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + WxCpGetReportAnswer getReportAnswer = WxCpGetReportAnswer.fromJson(reportAnswerStr); + log.info("获取对应的getReportAnswer:{}", getReportAnswer.toJson()); + + /** + * 获取用户填写答案 + * https://developer.work.weixin.qq.com/document/path/93679 + */ + WxCpGetReportAnswer reportAnswer = cpService.getSchoolHealthService().getReportAnswer("xxxx", currDate, null, null); + log.info("返回的reportAnswer为:{}", reportAnswer.toJson()); + + /** + * 获取健康上报任务ID列表 + * https://developer.work.weixin.qq.com/document/path/93677 + */ + WxCpGetReportJobIds reportJobids = cpService.getSchoolHealthService().getReportJobIds(null, null); + log.info("返回的reportJobids为:{}", reportJobids.toJson()); + + /** + * 获取健康上报任务详情 + * https://developer.work.weixin.qq.com/document/path/93678 + */ + WxCpGetReportJobInfo reportJobInfo = cpService.getSchoolHealthService().getReportJobInfo(null, currDate); + log.info("返回的reportJobInfo为:{}", reportJobInfo.toJson()); + + /** + * 获取健康上报使用统计 + * https://developer.work.weixin.qq.com/document/path/93676 + */ + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + WxCpGetHealthReportStat healthReportStat = cpService.getSchoolHealthService().getHealthReportStat(date); + log.info("返回的healthReportStat为:{}", healthReportStat.toJson()); + + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolTest.java new file mode 100644 index 0000000000..08843bc405 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolTest.java @@ -0,0 +1,174 @@ +package me.chanjar.weixin.cp.api; + +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.living.WxCpLivingResult; +import me.chanjar.weixin.cp.bean.school.*; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import org.testng.annotations.Test; + +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; + +/** + * 企业微信家校应用 复学码相关接口. + * https://developer.work.weixin.qq.com/document/path/93744 + * + * @author Wang_Wong created on : 2022/5/31 9:10 + */ +@Slf4j +public class WxCpSchoolTest { + + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService cpService; + + /** + * Test. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void test() throws WxErrorException { + + /** + * 注意: + * 权限说明:仅复学码应用可以调用 + */ + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + + wxCpConfigStorage = config; + cpService = new WxCpServiceImpl(); + cpService.setWxCpConfigStorage(config); + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + + + /** + * 上课直播 + */ + String livingId = "lvOQpTDwAAh0hxHsSeSwTQcmH0nWUC_Q"; + + + /** + * 获取老师直播ID列表 + * https://developer.work.weixin.qq.com/document/path/93739 + */ + WxCpLivingResult.LivingIdResult result = cpService.getSchoolService().getUserAllLivingId("WangKai", null, 20); + log.info("result:{}", result.toJson()); + + /** + * 删除直播回放 + * https://developer.work.weixin.qq.com/document/path/93743 + */ + WxCpLivingResult livingResult = cpService.getSchoolService().deleteReplayData(livingId); + log.info("livingResult:{}", livingResult.toJson()); + + /** + * 获取未观看直播统计 + * https://developer.work.weixin.qq.com/document/path/93742 + */ + String str3 = "{\"errcode\":0,\"errmsg\":\"ok\",\"ending\":1,\"next_key\":\"NEXT_KEY\"," + + "\"stat_info\":{\"students\":[{\"student_userid\":\"zhansan_child\",\"parent_userid\":\"zhangsan\"," + + "\"partyids\":[10,11]},{\"student_userid\":\"lisi_child\",\"parent_userid\":\"lisi\",\"partyids\":[5]}]}}"; + WxCpSchoolUnwatchStat schoolUnwatchStat = WxCpSchoolUnwatchStat.fromJson(str3); + log.info("unwatchStat:{}", schoolUnwatchStat.toJson()); + + WxCpSchoolUnwatchStat unwatchStat = cpService.getSchoolService().getUnwatchStat(livingId, "0"); + log.info("unwatchStat:{}", unwatchStat.toJson()); + + /** + * 获取观看直播统计 + * https://developer.work.weixin.qq.com/document/path/93741 + */ + String str2 = "{\"errcode\":0,\"errmsg\":\"ok\",\"ending\":1,\"next_key\":\"NEXT_KEY\"," + + "\"stat_infoes\":{\"students\":[{\"student_userid\":\"zhansan_child\",\"parent_userid\":\"zhangsan\"," + + "\"partyids\":[10,11],\"watch_time\":30,\"enter_time\":1586433904,\"leave_time\":1586434000,\"is_comment\":1}," + + "{\"student_userid\":\"lisi_child\",\"parent_userid\":\"lisi\",\"partyids\":[10,11],\"watch_time\":30," + + "\"enter_time\":1586433904,\"leave_time\":1586434000,\"is_comment\":0}]," + + "\"visitors\":[{\"nickname\":\"wx_nickname1\",\"watch_time\":30,\"enter_time\":1586433904," + + "\"leave_time\":1586434000,\"is_comment\":1},{\"nickname\":\"wx_nickname2\",\"watch_time\":30," + + "\"enter_time\":1586433904,\"leave_time\":1586434000,\"is_comment\":0}]}}"; + WxCpSchoolWatchStat wxCpSchoolWatchStat = WxCpSchoolWatchStat.fromJson(str2); + log.info("wxCpSchoolWatchStat:{}", wxCpSchoolWatchStat.toJson()); + + WxCpSchoolWatchStat watchStat = cpService.getSchoolService().getWatchStat(livingId, "0"); + log.info("watchStat:{}", watchStat.toJson()); + + String str1 = "{\"errcode\":0,\"errmsg\":\"ok\",\"living_info\":{\"theme\":\"直角三角形讲解\"," + + "\"living_start\":1586405229,\"living_duration\":1800,\"anchor_userid\":\"zhangsan\"," + + "\"living_range\":{\"partyids\":[1,4,9],\"group_names\":[\"group_name1\",\"group_name2\"]},\"viewer_num\":100," + + "\"comment_num\":110,\"open_replay\":1,\"push_stream_url\":\"https://www.qq.test.com\"}}"; + WxCpSchoolLivingInfo wxCpSchoolLivingInfo = WxCpSchoolLivingInfo.fromJson(str1); + log.info("str1:{}", wxCpSchoolLivingInfo.toJson()); + + /** + * 获取直播详情 + * https://developer.work.weixin.qq.com/document/path/93740 + */ + WxCpSchoolLivingInfo schoolLivingInfo = cpService.getSchoolService().getLivingInfo(livingId); + log.info("schoolLivingInfo:{}", schoolLivingInfo.toJson()); + + + /** + * 获取学生付款结果 + * https://developer.work.weixin.qq.com/document/path/94553 + */ + String paymentResultStr = "{\"errcode\":0,\"errmsg\":\"ok\",\"project_name\":\"学费\",\"amount\":998," + + "\"payment_result\":[{\"student_userid\":\"xxxx\",\"trade_state\":1,\"trade_no\":\"xxxxx\"," + + "\"payer_parent_userid\":\"zhangshan\"}]}"; + WxCpPaymentResult cpPaymentResult = WxCpPaymentResult.fromJson(paymentResultStr); + log.info("cpPaymentResult:{}", cpPaymentResult.toJson()); + + WxCpPaymentResult paymentResult = cpService.getSchoolService().getPaymentResult(""); + log.info("paymentResult:{}", paymentResult.toJson()); + + /** + * 获取订单详情 + * https://developer.work.weixin.qq.com/document/path/94554 + */ + String tradeStr = "{\n" + + "\t\"errcode\":0,\n" + + "\t\"errmsg\":\"ok\",\n" + + "\t\"transaction_id\":\"xxxxx\", \t \n" + + "\t\"pay_time\":12345\n" + + "}"; + WxCpTrade wxCpTrade = WxCpTrade.fromJson(tradeStr); + log.info("wxCpTrade:{}", wxCpTrade.toJson()); + + WxCpTrade trade = cpService.getSchoolService().getTrade("", ""); + log.info("trade:{}", trade.toJson()); + + + /** + * 获取老师健康信息 + * https://developer.work.weixin.qq.com/document/path/93744 + */ + WxCpCustomizeHealthInfo teacherCustomizeHealthInfo = + cpService.getSchoolService().getTeacherCustomizeHealthInfo(date, null, null); + log.info("teacherCustomizeHealthInfo为:{}", teacherCustomizeHealthInfo.toJson()); + + /** + * 获取学生健康信息 + * https://developer.work.weixin.qq.com/document/path/93745 + */ + WxCpCustomizeHealthInfo studentCustomizeHealthInfo = + cpService.getSchoolService().getStudentCustomizeHealthInfo(date, null, null); + log.info("studentCustomizeHealthInfo为:{}", studentCustomizeHealthInfo.toJson()); + + /** + * 获取师生健康码 + * https://developer.work.weixin.qq.com/document/path/93746 + */ + ArrayList userIds = Lists.newArrayList(); + userIds.add("Wangkai"); + WxCpResultList healthQrCode = cpService.getSchoolService().getHealthQrCode(userIds, 1); + log.info("healthQrCode为:{}", healthQrCode.toJson()); + + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolUserTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolUserTest.java new file mode 100644 index 0000000000..77be02e96f --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolUserTest.java @@ -0,0 +1,793 @@ +package me.chanjar.weixin.cp.api; + +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import lombok.var; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.XmlUtils; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo; +import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; +import me.chanjar.weixin.cp.bean.school.user.*; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import me.chanjar.weixin.cp.util.xml.XStreamTransformer; +import org.testng.annotations.Test; + +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * 企业微信家校沟通相关接口. + * https://developer.work.weixin.qq.com/document/path/91638 + * + * @author Wang_Wong created on : 2022/6/18 9:10 + */ +@Slf4j +public class WxCpSchoolUserTest { + + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService cpService; + + /** + * Test. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void test() throws WxErrorException { + + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + + wxCpConfigStorage = config; + cpService = new WxCpServiceImpl(); + cpService.setWxCpConfigStorage(config); + + List list = Lists.newArrayList(); + list.add(1); + list.add(2); + list.add(3); + log.info("list:{}", list); + + final String userId = "WangKai"; + final String exUserId = "wmOQpTDwAAJFHrryZ8I8ALLEZuLHIUKA"; + + + /** + * 获取部门家长详情 + * + * https://developer.work.weixin.qq.com/document/path/92446 + */ + WxCpListParentResult userListParent = cpService.getSchoolUserService().getUserListParent(1); + + String jsonUserListParentResult = "{\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"parents\": [\n" + + " {\n" + + " \"parent_userid\": \"zhangsan_parent\",\n" + + " \"mobile\": \"18900000000\",\n" + + " \"is_subscribe\": 1,\n" + + "\t\t\t\"external_userid\":\"xxx\",\n" + + " \"children\": [\n" + + " {\n" + + " \"student_userid\": \"zhangsan\",\n" + + " \"relation\": \"爸爸\",\n" + + " \"name\": \"张三\"\n" + + " }\n" + + " ]\n" + + " },\n" + + "\t\t{\n" + + " \"parent_userid\": \"lisi_parent\",\n" + + " \"mobile\": \"18900000001\",\n" + + " \"is_subscribe\": 0,\n" + + " \"children\": [\n" + + " {\n" + + " \"student_userid\": \"lisi\",\n" + + " \"relation\": \"妈妈\",\n" + + " \"name\": \"李四\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}"; + + WxCpListParentResult wxCpListParentResult = WxCpListParentResult.fromJson(jsonUserListParentResult); + assertThat(wxCpListParentResult.toJson()).isEqualTo(GsonParser.parse(jsonUserListParentResult).toString()); + + + /** + * 获取部门成员详情 + * + * https://developer.work.weixin.qq.com/document/path/92043 + */ + WxCpUserListResult userList = cpService.getSchoolUserService().getUserList(1, 0); + + String jsonUserListResult = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"students\":[\n" + + "\t\t{\n" + + "\t\t\t\"student_userid\": \"zhangsan\",\n" + + "\t\t\t\"name\": \"张三\",\n" + + "\t\t\t\"department\": [1, 2],\n" + + "\t\t\t\"parents\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"parent_userid\": \"zhangsan_parent1\",\n" + + "\t\t\t\t\t\"relation\": \"爸爸\",\n" + + "\t\t\t\t\t\"mobile\": \"18000000001\",\n" + + "\t\t\t\t\t\"is_subscribe\": 1,\n" + + "\t\t\t\t\t\"external_userid\":\"xxx\"\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"parent_userid\": \"zhangsan_parent2\",\n" + + "\t\t\t\t\t\"relation\": \"妈妈\",\n" + + "\t\t\t\t\t\"mobile\": \"18000000002\",\n" + + "\t\t\t\t\t\"is_subscribe\": 0\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t},\n" + + "\t\t{\n" + + "\t\t\t\"student_userid\": \"lisi\",\n" + + "\t\t\t\"name\": \"李四\",\n" + + "\t\t\t\"department\": [4, 5],\n" + + "\t\t\t\"parents\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"parent_userid\": \"lisi_parent1\",\n" + + "\t\t\t\t\t\"relation\": \"爷爷\",\n" + + "\t\t\t\t\t\"mobile\": \"18000000003\",\n" + + "\t\t\t\t\t\"is_subscribe\": 1,\n" + + "\t\t\t\t\t\"external_userid\":\"xxx\"\n" + + "\t\t\t\t},\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"parent_userid\": \"lisi_parent2\",\n" + + "\t\t\t\t\t\"relation\": \"妈妈\",\n" + + "\t\t\t\t\t\"mobile\": \"18000000004\",\n" + + "\t\t\t\t\t\"is_subscribe\": 1,\n" + + "\t\t\t\t\t\"external_userid\":\"xxx\"\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + + WxCpUserListResult wxCpUserListResult = WxCpUserListResult.fromJson(jsonUserListResult); + assertThat(wxCpUserListResult.toJson()).isEqualTo(GsonParser.parse(jsonUserListResult).toString()); + + /** + * 读取学生或家长 + * + * https://developer.work.weixin.qq.com/document/path/92337 + */ + WxCpUserResult userResult = cpService.getSchoolUserService().getUser(userId); + + String jsonUserResult = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"user_type\": 1,\n" + + "\t\"student\":{\n" + + "\t\t\"student_userid\": \"zhangsan\",\n" + + "\t\t\"name\": \"张三\",\n" + + "\t\t\"department\": [1, 2],\n" + + "\t\t\"parents\":[\n" + + "\t\t\t{\n" + + "\t\t\t\t\"parent_userid\": \"zhangsan_parent1\",\n" + + "\t\t\t\t\"relation\": \"爸爸\",\n" + + "\t\t\t\t\"mobile\":\"18000000000\",\n" + + "\t\t\t\t\"is_subscribe\": 1,\n" + + "\t\t\t\t\"external_userid\":\"xxxxx\"\n" + + "\t\t\t},\n" + + "\t\t\t{\n" + + "\t\t\t\t\"parent_userid\": \"zhangsan_parent2\",\n" + + "\t\t\t\t\"relation\": \"妈妈\",\n" + + "\t\t\t\t\"mobile\": \"18000000001\",\n" + + "\t\t\t\t\"is_subscribe\": 0\n" + + "\t\t\t}\n" + + "\t\t]\n" + + " },\n" + + "\t\"parent\":{\n" + + "\t\t\"parent_userid\": \"zhangsan_parent2\",\n" + + "\t\t\"mobile\": \"18000000003\",\n" + + "\t\t\"is_subscribe\": 1,\n" + + "\t\t\"external_userid\":\"xxxxx\",\n" + + "\t\t\"children\":[\n" + + "\t\t\t{\n" + + "\t\t\t\t\"student_userid\": \"zhangsan\",\n" + + "\t\t\t\t\"relation\": \"妈妈\"\n" + + "\t\t\t},\n" + + "\t\t\t{\n" + + "\t\t\t\t\"student_userid\": \"lisi\",\n" + + "\t\t\t\t\"relation\": \"伯母\"\n" + + "\t\t\t}\n" + + "\t\t]\n" + + "\t}\n" + + "}"; + + WxCpUserResult wxCpUserResult = WxCpUserResult.fromJson(jsonUserResult); + assertThat(wxCpUserResult.toJson()).isEqualTo(GsonParser.parse(jsonUserResult).toString()); + + + /** + * 批量更新家长 + * + * https://developer.work.weixin.qq.com/document/path/92336 + */ + String batchUpdateParentRequestParam = "{\n" + + " \"parents\":[\n" + + " { \n" + + " \"parent_userid\": \"zhangsan_baba\",\n" + + "\t\t\t\"new_parent_userid\":\"zhangsan_baba_new\",\n" + + " \"mobile\": \"10000000000\",\n" + + " \"children\":[\n" + + " { \n" + + " \"student_userid\": \"zhangsan\",\n" + + " \"relation\": \"爸爸\"\n" + + " } \n" + + " ] \n" + + " }, \n" + + " { \n" + + " \"parent_userid\": \"lisi_mama\",\n" + + " \"mobile\": \"10000000001\",\n" + + " \"children\":[\n" + + " {\n" + + " \"student_userid\": \"lisi\",\n" + + " \"relation\": \"妈妈\"\n" + + " } \n" + + " ] \n" + + " } \n" + + " ] \n" + + "}"; + WxCpBatchUpdateParentRequest batchUpdateParentRequest = + WxCpBatchUpdateParentRequest.fromJson(batchUpdateParentRequestParam); + WxCpBatchResultList batchUpdateParentResult = + cpService.getSchoolUserService().batchUpdateParent(batchUpdateParentRequest); + + + /** + * 批量删除家长 + * + * https://developer.work.weixin.qq.com/document/path/92335 + */ + WxCpBatchResultList batchDeleteParentResult = cpService.getSchoolUserService().batchDeleteParent("abc", userId); + + + /** + * 批量创建家长 封装请求参数 + * + * https://developer.work.weixin.qq.com/document/path/92334 + */ + var child1 = WxCpBatchCreateParentRequest.Children.builder() + .relation("爸爸") + .studentUserId("zhangsan") + .build(); + var child2 = WxCpBatchCreateParentRequest.Children.builder() + .relation("伯父") + .studentUserId("lisi") + .build(); + var child3 = WxCpBatchCreateParentRequest.Children.builder() + .relation("爸爸") + .studentUserId("lisi") + .build(); + var child4 = WxCpBatchCreateParentRequest.Children.builder() + .relation("伯父") + .studentUserId("zhangsan") + .build(); + + List childrenList1 = Lists.newArrayList(); + childrenList1.add(child1); + childrenList1.add(child2); + + List childrenList2 = Lists.newArrayList(); + childrenList2.add(child3); + childrenList2.add(child4); + + var zhangsanParent = WxCpBatchCreateParentRequest.Parent.builder() + .parentUserId("zhangsan_parent_userid") + .mobile("18000000000") + .toInvite(false) + .children(childrenList1) + .build(); + var lisiParent = WxCpBatchCreateParentRequest.Parent.builder() + .parentUserId("lisi_parent_userid") + .mobile("18000000001") + .children(childrenList2) + .build(); + + List batchCreateParent = Lists.newArrayList(); + batchCreateParent.add(zhangsanParent); + batchCreateParent.add(lisiParent); + WxCpBatchCreateParentRequest wxCpBatchCreateParentRequest = WxCpBatchCreateParentRequest.builder() + .parents(batchCreateParent) + .build(); + + // 请求参数json + String batchCreateParentRequestParam = "{\n" + + "\t\"parents\":[\n" + + "\t\t{\n" + + "\t\t\t\"parent_userid\": \"zhangsan_parent_userid\",\n" + + " \t\t\"mobile\": \"18000000000\",\n" + + "\t\t\t\"to_invite\": false,\n" + + "\t\t\t\"children\":[\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"student_userid\": \"zhangsan\",\n" + + " \t\t \"relation\": \"爸爸\"\n" + + " \t\t },\n" + + " \t\t {\n" + + "\t\t\t\t\t\"student_userid\": \"lisi\",\n" + + " \t\t \"relation\": \"伯父\"\n" + + " \t\t }\n" + + " \t\t]\n" + + "\t\t},\n" + + "\t\t{\n" + + "\t\t\t\"parent_userid\": \"lisi_parent_userid\",\n" + + " \t\t\"mobile\": \"18000000001\",\n" + + "\t\t\t\"children\":[\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"student_userid\": \"lisi\",\n" + + " \t\t \"relation\": \"爸爸\"\n" + + " \t\t },\n" + + " \t\t {\n" + + "\t\t\t\t\t\"student_userid\": \"zhangsan\",\n" + + " \t\t \"relation\": \"伯父\"\n" + + " \t\t }\n" + + " \t\t]\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + assertThat(wxCpBatchCreateParentRequest.toJson()).isEqualTo(GsonParser.parse(batchCreateParentRequestParam).toString()); + + WxCpBatchResultList batchCreateParentResult = + cpService.getSchoolUserService().batchCreateParent(wxCpBatchCreateParentRequest); + + // 返回结果 + String batchResultStr = "{\n" + + "\t\"errcode\": 1,\n" + + "\t\"errmsg\": \"invalid parent_userid: lisi_parent_userid\",\n" + + "\t\"result_list\": [\n" + + "\t\t{\n" + + "\t\t\t\"parent_userid\": \"lisi_parent_userid\",\n" + + "\t\t\t\"errcode\": 1,\n" + + "\t\t\t\"errmsg\": \"invalid parent_userid: lisi_parent_userid\",\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + assertThat(batchCreateParentResult.toJson()).isEqualTo(GsonParser.parse(batchResultStr).toString()); + + + /** + * 获取家校访问用户身份 + * + * https://developer.work.weixin.qq.com/document/path/95791 + */ + WxCpOauth2UserInfo schoolUserInfo = cpService.getSchoolUserService().getSchoolUserInfo("abc"); + assertThat(schoolUserInfo).isNotNull(); + + WxCpOauth2UserInfo oauth2UserInfo = cpService.getSchoolUserService().getUserInfo("abc"); + assertThat(oauth2UserInfo).isNotNull(); + + WxCpOauth2UserInfo userInfo = cpService.getOauth2Service().getUserInfo("abc"); + assertThat(userInfo).isNotNull(); + + + // 返回值 + String batchResult = "{\n" + + "\t\"errcode\": 1,\n" + + "\t\"errmsg\": \"invalid student_userid: zhangsan\",\n" + + "\t\"result_list\": [\n" + + "\t\t{\n" + + "\t\t\t\"student_userid\": \"zhangsan\",\n" + + "\t\t\t\"errcode\": 1,\n" + + "\t\t\t\"errmsg\": \"invalid student_userid: zhangsan\"\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + + WxCpBatchResultList batchResultList = WxCpBatchResultList.fromJson(batchResult); + log.info("batchResultList: {}", batchResultList.toJson()); + + + /** + * 批量更新学生 + * https://developer.work.weixin.qq.com/document/path/92330 + * + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_update_student?access_token=ACCESS_TOKEN + */ + String batchUpdateStudent = "{\n" + + "\t\"students\":[\n" + + " {\n" + + "\t\t\t\"student_userid\": \"zhangsan\",\n" + + "\t\t\t\"new_student_userid\":\"zhangsan_new\",\n" + + "\t\t\t\"name\": \"张三\",\n" + + "\t\t\t\"department\": [1, 2]\n" + + "\t\t},\n" + + " {\n" + + "\t\t\t\"student_userid\": \"lisi\",\n" + + "\t\t\t\"name\": \"李四\",\n" + + "\t\t\t\"department\": [3, 4]\n" + + "\t\t}\n" + + " ]\n" + + "}"; + WxCpBatchUpdateStudentRequest batchUpdateStudentRequest = + WxCpBatchUpdateStudentRequest.fromJson(batchUpdateStudent); + WxCpBatchResultList list3 = cpService.getSchoolUserService().batchUpdateStudent(batchUpdateStudentRequest); + log.info("list3: {}", list3.toJson()); + + /** + * 批量删除学生 + * https://developer.work.weixin.qq.com/document/path/92329 + * + * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_delete_student?access_token=ACCESS_TOKEN + */ + String batchDeleteStudent = "{\n" + + "\t\"useridlist\": [\"zhangsan\", \"lisi\"]\n" + + "}\n"; + WxCpBatchDeleteStudentRequest batchDeleteStudentRequest = + WxCpBatchDeleteStudentRequest.fromJson(batchDeleteStudent); + WxCpBatchResultList list2 = cpService.getSchoolUserService().batchDeleteStudent(batchDeleteStudentRequest); + log.info("list2: {}", list2.toJson()); + + /** + * 批量创建学生 + * https://developer.work.weixin.qq.com/document/path/92328 + */ + String batchCreateStudent = "{\n" + + "\t\"students\":[\n" + + " {\n" + + "\t\t\t\"student_userid\": \"zhangsan\",\n" + + "\t\t\t\"name\": \"张三\",\n" + + "\t\t\t\"department\": [1, 2]\n" + + "\t\t},\n" + + " {\n" + + "\t\t\t\"student_userid\": \"lisi\",\n" + + "\t\t\t\"name\": \"李四\",\n" + + "\t\t\t\"department\": [3, 4]\n" + + "\t\t}\n" + + " ]\n" + + "}"; + WxCpBatchCreateStudentRequest batchCreateStudentRequest = + WxCpBatchCreateStudentRequest.fromJson(batchCreateStudent); + WxCpBatchResultList list1 = cpService.getSchoolUserService().batchCreateStudent(batchCreateStudentRequest); + log.info("list1: {}", list1.toJson()); + + +// String changeContact = WxCpConsts.EventType.CHANGE_CONTACT; + /** + * 增加变更事件类型: + */ +// WxCpConsts.EventType.CHANGE_SCHOOL_CONTACT; +// WxCpConsts.SchoolContactChangeType.DELETE_STUDENT; +// WxCpConsts.SchoolContactChangeType.CREATE_DEPARTMENT; + + /** + * 测试家校通讯录变更回调 + * https://developer.work.weixin.qq.com/document/path/92052 + * + * 新增学生事件 + * 当学校在家校通讯录中新增学生时,回调此事件。 + */ + String createStudentXml = "\n" + + "\t\n" + + "\t \n" + + "\t1403610513\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + ""; + + /** + * 家长取消关注事件 + * 当家长取消关注家校通知时,回调此事件。 + */ + String unSubscribeXml = "\n" + + "\t\n" + + "\t \n" + + "\t1403610513\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + ""; + + /** + * 创建部门事件 + * 当学校在家校通讯录中创建部门时,回调此事件。 + */ + String createDepartmentXml = "\n" + + "\t\n" + + "\t \n" + + "\t1403610513\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + ""; + + /** + * 删除部门事件 + * 当学校删除家校通讯录部门时,回调此事件。 + */ + String deleteDepartmentXml = "\n" + + "\t\n" + + "\t \n" + + "\t1403610513\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + ""; + +// WxCpXmlMessage.fromXml(createStudentXml); + final WxCpXmlMessage createStudentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createStudentXml); + Map map1 = XmlUtils.xml2Map(createStudentXml); + createStudentMsg.setAllFieldsMap(map1); + log.info("createStudentMsg:{}", WxCpGsonBuilder.create().toJson(createStudentMsg)); + + final WxCpXmlMessage unSubscribeMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, unSubscribeXml); + Map map2 = XmlUtils.xml2Map(unSubscribeXml); + unSubscribeMsg.setAllFieldsMap(map2); + log.info("unSubscribeMsg:{}", WxCpGsonBuilder.create().toJson(unSubscribeMsg)); + + final WxCpXmlMessage createDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createDepartmentXml); + createDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(createDepartmentXml)); + log.info("createDepartmentMsg:{}", WxCpGsonBuilder.create().toJson(createDepartmentMsg)); + + final WxCpXmlMessage deleteDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, deleteDepartmentXml); + deleteDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(deleteDepartmentXml)); + log.info("deleteDepartmentMsg:{}", WxCpGsonBuilder.create().toJson(deleteDepartmentMsg)); + + + /** + * 获取可使用的家长范围 + * https://developer.work.weixin.qq.com/document/path/94895 + */ + String str8 = "{\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"allow_scope\": {\n" + + " \"students\": [\n" + + " {\"userid\": \"student1\"},\n" + + " {\"userid\": \"student2\"}\n" + + " ],\n" + + "\t \"departments\": [1, 2]\n" + + " }\n" + + "}"; + WxCpAllowScope cpAllowScope = WxCpAllowScope.fromJson(str8); + log.info("cpAllowScope:{}", cpAllowScope.toJson()); + + WxCpAllowScope allowScope = cpService.getSchoolUserService().getAllowScope(100000); + log.info("allowScope:{}", allowScope); + + /** + * 外部联系人openid转换 + * https://developer.work.weixin.qq.com/document/path/92323 + */ + String openId = cpService.getSchoolUserService().convertToOpenId("wmOQpTDwAAh_sKvmJBJ4FQ0iYAcbppFA"); + log.info("openId:{}", openId); + + /** + * 家校沟通 获取外部联系人详情 + * https://developer.work.weixin.qq.com/document/path/92322 + */ + String str7 = "{\"errcode\":0,\"errmsg\":\"ok\",\"external_contact\":{\"external_userid\":\"woAAAA\"," + + "\"name\":\"李四\",\"position\":\"Mangaer\",\"avatar\":\"http://p.qlogo.cn/bizmail/IcsdgagqefergqerhewSdage/0\"," + + "\"corp_name\":\"腾讯\",\"corp_full_name\":\"腾讯科技有限公司\",\"type\":2,\"gender\":1,\"unionid\":\"unAAAAA\"," + + "\"is_subscribe\":1,\"subscriber_info\":{\"tag_id\":[\"TAG_ID1\",\"TAG_ID2\"]," + + "\"remark_mobiles\":[\"10000000000\",\"10000000001\"],\"remark\":\"李小明-爸爸\"}," + + "\"external_profile\":{\"external_attr\":[{\"type\":0,\"name\":\"文本名称\",\"text\":{\"value\":\"文本\"}}," + + "{\"type\":1,\"name\":\"网页名称\",\"web\":{\"url\":\"http://www.test.com\",\"title\":\"标题\"}},{\"type\":2," + + "\"name\":\"测试app\",\"miniprogram\":{\"appid\":\"wxAAAAA\",\"pagepath\":\"/index\",\"title\":\"my " + + "miniprogram\"}}]}},\"follow_user\":[{\"userid\":\"rocky\",\"remark\":\"李部长\",\"description\":\"对接采购事物\"," + + "\"createtime\":1525779812,\"tags\":[{\"group_name\":\"标签分组名称\",\"tag_name\":\"标签名称\",\"type\":1}]," + + "\"remark_corp_name\":\"腾讯科技\",\"remark_mobiles\":[10000000003,10000000004]},{\"userid\":\"tommy\"," + + "\"remark\":\"李总\",\"description\":\"采购问题咨询\",\"createtime\":1525881637,\"state\":\"外联二维码1\"}]}"; + WxCpExternalContact wxCpExternalContact = WxCpExternalContact.fromJson(str7); + log.info("wxCpExternalContact:{}", wxCpExternalContact.toJson()); + +// cpService.getExternalContactService().getExternalContact(); + WxCpExternalContact externalContact = cpService.getSchoolUserService().getExternalContact(exUserId); + log.info("externalContact:{}", externalContact.toJson()); + + /** + * 获取关注「学校通知」的模式 + * 可通过此接口获取家长关注「学校通知」的模式:“可扫码填写资料加入”或“禁止扫码填写资料加入” + * https://developer.work.weixin.qq.com/document/path/92290 + */ + Integer subscribeMode = cpService.getSchoolUserService().getSubscribeMode(); + log.info("subscribeMode:{}", subscribeMode); + + /** + * 管理「学校通知」的关注模式 + * 设置关注「学校通知」的模式 + * https://developer.work.weixin.qq.com/document/path/92290 + */ + WxCpBaseResp setSubscribeMode = cpService.getSchoolUserService().setSubscribeMode(1); + log.info("setSubscribeMode:{}", setSubscribeMode.toJson()); + + /** + * 获取「学校通知」二维码 + * https://developer.work.weixin.qq.com/document/path/92320 + */ + String str6 = "{\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"qrcode_big\":\"http://p.qpic.cn/wwhead/XXXX\",\n" + + " \"qrcode_middle\":\"http://p.qpic.cn/wwhead/XXXX\",\n" + + " \"qrcode_thumb\":\"http://p.qpic.cn/wwhead/XXXX\"\n" + + "}"; + + WxCpSubscribeQrCode cpSubscribeQrCode = WxCpSubscribeQrCode.fromJson(str6); + log.info("cpSubscribeQrCode:{}", cpSubscribeQrCode.toJson()); + + WxCpSubscribeQrCode subscribeQrCode = cpService.getSchoolUserService().getSubscribeQrCode(); + log.info("subscribeQrCode:{}", subscribeQrCode.toJson()); + + /** + * 修改自动升年级的配置 + * https://developer.work.weixin.qq.com/document/path/92949 + */ + WxCpSetUpgradeInfo wxCpSetUpgradeInfo = cpService.getSchoolUserService().setUpgradeInfo(1594090969L, 2); + log.info("wxCpSetUpgradeInfo:{}", wxCpSetUpgradeInfo.toJson()); + + /** + * 获取部门列表 + * https://developer.work.weixin.qq.com/document/path/92343 + */ + String str5 = "{\"errcode\":0,\"errmsg\":\"ok\",\"departments\":[{\"name\":\"一年级\",\"parentid\":1,\"id\":2," + + "\"type\":2,\"register_year\":2018,\"standard_grade\":1,\"order\":1," + + "\"department_admins\":[{\"userid\":\"zhangsan\",\"type\":1},{\"userid\":\"lisi\",\"type\":2}]," + + "\"is_graduated\":0},{\"name\":\"一年级一班\",\"parentid\":1,\"id\":3,\"type\":1," + + "\"department_admins\":[{\"userid\":\"zhangsan\",\"type\":3,\"subject\":\"语文\"},{\"userid\":\"lisi\"," + + "\"type\":4,\"subject\":\"数学\"}],\"open_group_chat\":1,\"group_chat_id\":\"group_chat_id\"}]}"; + WxCpDepartmentList wxCpDepartmentList = WxCpDepartmentList.fromJson(str5); + log.info("wxCpDepartmentList:{}", wxCpDepartmentList.toJson()); + + WxCpDepartmentList departmentList = cpService.getSchoolUserService().listDepartment(7); + log.info("departmentList:{}", departmentList.toJson()); + + /** + * 删除部门 + * https://developer.work.weixin.qq.com/document/path/92342 + */ + WxCpBaseResp deleteDepartment = cpService.getSchoolUserService().deleteDepartment(7); + log.info("deleteDepartment:{}", deleteDepartment.toJson()); + + /** + * 更新部门 + * https://developer.work.weixin.qq.com/document/path/92341 + */ + String str4 = "{\"name\":\"一年级\",\"parentid\":5,\"id\":2,\"register_year\":2018,\"standard_grade\":1,\"order\":1," + + "\"new_id\":100,\"department_admins\":[{\"op\":0,\"userid\":\"zhangsan\",\"type\":3,\"subject\":\"语文\"}," + + "{\"op\":1,\"userid\":\"lisi\",\"type\":4,\"subject\":\"数学\"}]}"; + WxCpUpdateDepartmentRequest wxCpUpdateDepartmentRequest = WxCpUpdateDepartmentRequest.fromJson(str4); + log.info("wxCpUpdateParentRequest:{}", wxCpUpdateDepartmentRequest.toJson()); + + WxCpBaseResp updateDepartment = cpService.getSchoolUserService().updateDepartment(wxCpUpdateDepartmentRequest); + log.info("updateDepartment:{}", updateDepartment.toJson()); + + /** + * 创建部门 + * https://developer.work.weixin.qq.com/document/path/92340 + */ + String str3 = "{\"name\":\"一年级\",\"parentid\":5,\"id\":2,\"type\":1,\"register_year\":2018,\"standard_grade\":1," + + "\"order\":1,\"department_admins\":[{\"userid\":\"zhangsan\",\"type\":4,\"subject\":\"语文\"}," + + "{\"userid\":\"lisi\",\"type\":3,\"subject\":\"数学\"}]}"; + WxCpCreateDepartmentRequest wxCpCreateDepartmentRequest = WxCpCreateDepartmentRequest.fromJson(str3); + log.info("wxCpCreateDepartmentRequest:{}", wxCpCreateDepartmentRequest.toJson()); + + WxCpCreateDepartmentRequest createDepartmentRequest = new WxCpCreateDepartmentRequest(); + createDepartmentRequest.setParentId(5); + createDepartmentRequest.setName("一年级"); + createDepartmentRequest.setId(2); + createDepartmentRequest.setType(1); + createDepartmentRequest.setRegisterYear(2018); + createDepartmentRequest.setStandardGrade(1); + createDepartmentRequest.setOrder(1); + + var departmentAdmin = new WxCpCreateDepartmentRequest.DepartmentAdmin(); + departmentAdmin.setUserId(userId); + departmentAdmin.setType(4); + departmentAdmin.setSubject("英语"); + List createDepartList = Lists.newArrayList(); + createDepartList.add(departmentAdmin); + + createDepartmentRequest.setDepartmentAdmins(createDepartList); + WxCpCreateDepartment createDepartment = cpService.getSchoolUserService().createDepartment(createDepartmentRequest); + log.info("createDepartment:{}", createDepartment.toJson()); + + /** + * 更新家长 + * https://developer.work.weixin.qq.com/document/path/92333 + */ + String str2 = "{\"parent_userid\":\"zhangsan_parent_userid\",\"new_parent_userid\":\"NEW_ID\"," + + "\"mobile\":\"18000000000\",\"children\":[{\"student_userid\":\"zhangsan\",\"relation\":\"爸爸\"}," + + "{\"student_userid\":\"lisi\",\"relation\":\"伯父\"}]}"; + WxCpUpdateParentRequest updateParentRequest1 = WxCpUpdateParentRequest.fromJson(str2); + log.info("updateParentRequest1:{}", updateParentRequest1.toJson()); + + WxCpUpdateParentRequest updateParentRequest = new WxCpUpdateParentRequest(); + updateParentRequest.setParentUserId("zhangsan"); + updateParentRequest.setMobile("17324399999"); + updateParentRequest.setNewParentUserId("wangkai"); + + var child = new WxCpUpdateParentRequest.Children(); + child.setStudentUserId("zhangguiyuan"); + child.setRelation("伯父"); + + List childList = Lists.newArrayList(); + childList.add(child); + updateParentRequest.setChildren(childList); + + WxCpBaseResp updateParent = cpService.getSchoolUserService().updateParent(updateParentRequest); + log.info("updateParent:{}", updateParent.toJson()); + + /** + * 删除家长 + * https://developer.work.weixin.qq.com/document/path/92332 + */ + WxCpBaseResp deleteParent = cpService.getSchoolUserService().deleteParent("zhangsan"); + log.info("deleteParent:{}", deleteParent.toJson()); + + /** + * 创建家长 + * https://developer.work.weixin.qq.com/document/path/92331 + */ + String str1 = "{\"parent_userid\":\"zhangsan_parent_userid\",\"mobile\":\"10000000000\",\"to_invite\":false," + + "\"children\":[{\"student_userid\":\"zhangsan\",\"relation\":\"爸爸\"},{\"student_userid\":\"lisi\"," + + "\"relation\":\"伯父\"}]}"; + WxCpCreateParentRequest createParentRequest1 = WxCpCreateParentRequest.fromJson(str1); + log.info("createParentRequest1:{}", createParentRequest1.toJson()); + + WxCpCreateParentRequest createParentRequest = new WxCpCreateParentRequest(); + createParentRequest.setParentUserId("wangkai"); + createParentRequest.setMobile("17324398888"); + createParentRequest.setToInvite(false); + + var children1 = new WxCpCreateParentRequest.Children(); + children1.setStudentUserId("zhangguiyuan"); + children1.setRelation("伯父"); + + List children = Lists.newArrayList(); + children.add(children1); + createParentRequest.setChildren(children); + + WxCpBaseResp createParent = cpService.getSchoolUserService().createParent(createParentRequest); + log.info("createParent:{}", createParent.toJson()); + + /** + * 设置家校通讯录自动同步模式 + * 企业和第三方可通过此接口修改家校通讯录与班级标签之间的自动同步模式,注意,一旦设置禁止自动同步,将无法再次开启。 + */ + WxCpBaseResp setArchSyncMode = cpService.getSchoolUserService().setArchSyncMode(2); + log.info("setArchSyncMode:{}", setArchSyncMode.toJson()); + + /** + * 更新学生 + */ + WxCpBaseResp updateStudent = cpService.getSchoolUserService().updateStudent("WangKai", "wangkai", "王", list); + log.info("updateStudent:{}", updateStudent.toJson()); + + /** + * 删除学生 + */ + WxCpBaseResp deleteStudent = cpService.getSchoolUserService().deleteStudent("WangKai"); + log.info("deleteStudent:{}", deleteStudent.toJson()); + + /** + * 创建学生 + */ + WxCpBaseResp student = cpService.getSchoolUserService().createStudent("WangKai", "王", list); + log.info("student:{}", student.toJson()); + + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpTpMessageRouterTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpTpMessageRouterTest.java index 41c0b37968..91f91058cf 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpTpMessageRouterTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpTpMessageRouterTest.java @@ -15,9 +15,15 @@ import static org.testng.Assert.assertNotNull; import static org.testng.AssertJUnit.assertNull; +/** + * The type Wx cp tp message router test. + */ public class WxCpTpMessageRouterTest { + /** + * Test message router. + */ @Test public void testMessageRouter() { WxCpTpService service = new WxCpTpServiceApacheHttpClientImpl(); @@ -40,7 +46,8 @@ public void testMessageRouter() { router.rule().infoType("change_contact").changeType("update_tag").handler(new WxCpTpMessageHandler() { @Override - public WxCpXmlOutMessage handle(WxCpTpXmlMessage wxMessage, Map context, WxCpTpService wxCpService, WxSessionManager sessionManager) throws WxErrorException { + public WxCpXmlOutMessage handle(WxCpTpXmlMessage wxMessage, Map context, + WxCpTpService wxCpService, WxSessionManager sessionManager) throws WxErrorException { System.out.println("handler enter"); assertNotNull(wxCpService); return null; diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java index 739470a2d7..c2b1dad933 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java @@ -32,26 +32,50 @@ @Test @Guice(modules = ApiTestModule.class) public class BaseWxCpServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; + /** + * Test get agent jsapi ticket. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetAgentJsapiTicket() throws WxErrorException { assertThat(this.wxService.getAgentJsapiTicket()).isNotEmpty(); assertThat(this.wxService.getAgentJsapiTicket(true)).isNotEmpty(); } + /** + * Test js code 2 session. + * + * @throws WxErrorException the wx error exception + */ @Test public void testJsCode2Session() throws WxErrorException { assertThat(this.wxService.jsCode2Session("111")).isNotNull(); } + /** + * Test get provider token. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetProviderToken() throws WxErrorException { assertThat(this.wxService.getProviderToken("111", "123")).isNotNull(); } + /** + * Test execute auto refresh token. + * + * @throws WxErrorException the wx error exception + * @throws IOException the io exception + */ @Test public void testExecuteAutoRefreshToken() throws WxErrorException, IOException { //测试access token获取时的重试机制 @@ -94,12 +118,13 @@ public WxCpConfigStorage getWxCpConfigStorage() { AtomicInteger counter = new AtomicInteger(); Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer(invocation -> { counter.incrementAndGet(); - WxError error = WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build(); + WxError error = + WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build(); throw new WxErrorException(error); }); try { Object execute = service.execute(re, "http://baidu.com", new HashMap<>()); - Assert.assertTrue(false, "代码应该不会执行到这里"); + Assert.fail("代码应该不会执行到这里"); } catch (WxErrorException e) { Assert.assertEquals(WxMpErrorMsgEnum.CODE_40001.getCode(), e.getError().getErrorCode()); Assert.assertEquals(2, counter.get()); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java index 97c7d40fe5..07438056c3 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java @@ -33,6 +33,11 @@ public class WxCpAgentServiceImplTest { @Inject private WxCpService wxCpService; + /** + * Test get. + * + * @throws Exception the exception + */ @Test public void testGet() throws Exception { final Integer agentId = this.wxCpService.getWxCpConfigStorage().getAgentId(); @@ -45,6 +50,11 @@ public void testGet() throws Exception { assertThat(wxCpAgent.getAllowTags().getTagIds().toArray()).isNotEmpty(); } + /** + * Test set. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSet() throws WxErrorException { final Integer agentId = this.wxCpService.getWxCpConfigStorage().getAgentId(); @@ -56,6 +66,11 @@ public void testSet() throws WxErrorException { .build()); } + /** + * Test list. + * + * @throws WxErrorException the wx error exception + */ @Test public void testList() throws WxErrorException { List list = this.wxCpService.getAgentService().list(); @@ -67,12 +82,25 @@ public void testList() throws WxErrorException { assertThat(list.get(0).getSquareLogoUrl()).isNotEmpty(); } + /** + * The type Mock test. + */ public static class MockTest { - private WxCpService wxService = mock(WxCpService.class); + private final WxCpService wxService = mock(WxCpService.class); + /** + * Test get. + * + * @throws Exception the exception + */ @Test public void testGet() throws Exception { - String returnJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\",\"square_logo_url\": \"http://wx.qlogo.cn/mmhead/alksjf;lasdjf;lasjfuodiuj3rj2o34j/0\",\"description\": \"这是一个企业号应用\",\"allow_userinfos\": {\"user\": [{\"userid\": \"0009854\"}, {\"userid\": \"1723\"}, {\"userid\": \"5625\"}]},\"allow_partys\": {\"partyid\": [42762742]},\"allow_tags\": {\"tagid\": [23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7]},\"close\": 0,\"redirect_domain\": \"weixin.com.cn\",\"report_location_flag\": 0,\"isreportenter\": 0,\"home_url\": \"\"}"; + String returnJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\",\"square_logo_url\": " + + "\"http://wx.qlogo.cn/mmhead/alksjf;lasdjf;lasjfuodiuj3rj2o34j/0\",\"description\": \"这是一个企业号应用\"," + + "\"allow_userinfos\": {\"user\": [{\"userid\": \"0009854\"}, {\"userid\": \"1723\"}, {\"userid\": " + + "\"5625\"}]},\"allow_partys\": {\"partyid\": [42762742]},\"allow_tags\": {\"tagid\": [23, 22, 35, 19, 32, " + + "125, 133, 46, 150, 38, 183, 9, 7]},\"close\": 0,\"redirect_domain\": \"weixin.com.cn\"," + + "\"report_location_flag\": 0,\"isreportenter\": 0,\"home_url\": \"\"}"; final WxCpConfigStorage configStorage = new WxCpDefaultConfigImpl(); when(wxService.getWxCpConfigStorage()).thenReturn(configStorage); when(wxService.get(String.format(configStorage.getApiUrl(WxCpApiPathConsts.Agent.AGENT_GET), 9), null)).thenReturn(returnJson); @@ -85,7 +113,8 @@ public void testGet() throws Exception { assertEquals(new Integer[]{42762742}, wxCpAgent.getAllowParties().getPartyIds().toArray()); - assertEquals(new Integer[]{23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7}, wxCpAgent.getAllowTags().getTagIds().toArray()); + assertEquals(new Integer[]{23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7}, + wxCpAgent.getAllowTags().getTagIds().toArray()); } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchImplTest.java index eca3a1df9f..540eaec399 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchImplTest.java @@ -16,9 +16,10 @@ import java.util.List; /** + * 测试工作台服务 + * * @author songshiyu - * @date : create in 10:31 2020/9/29 - * @description: 测试工作台服务 + * created at 10:31 2020/9/29 */ @Guice(modules = ApiTestModule.class) public class WxCpAgentWorkBenchImplTest { @@ -26,22 +27,44 @@ public class WxCpAgentWorkBenchImplTest { @Inject private WxCpService wxCpService; + /** + * Test template set. + * + * @param template the template + * @throws WxErrorException the wx error exception + */ @Test(dataProvider = "template") public void testTemplateSet(WxCpAgentWorkBench template) throws WxErrorException { this.wxCpService.getWorkBenchService().setWorkBenchTemplate(template); } + /** + * Test template get. + * + * @throws WxErrorException the wx error exception + */ @Test public void testTemplateGet() throws WxErrorException { String result = this.wxCpService.getWorkBenchService().getWorkBenchTemplate(1000011L); - System.out.println("获取工作台模板设置:"+result); + System.out.println("获取工作台模板设置:" + result); } + /** + * Test user data set. + * + * @param userDatas the user datas + * @throws WxErrorException the wx error exception + */ @Test(dataProvider = "userDatas") public void testUserDataSet(WxCpAgentWorkBench userDatas) throws WxErrorException { this.wxCpService.getWorkBenchService().setWorkBenchData(userDatas); } + /** + * Template object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider public Object[][] template() { return new Object[][]{ @@ -57,6 +80,11 @@ public Object[][] template() { }; } + /** + * User datas object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider public Object[][] userDatas() { return new Object[][]{ @@ -72,15 +100,20 @@ public Object[][] userDatas() { }; } + /** + * Test key data template set. + * + * @throws WxErrorException the wx error exception + */ @Test public void testKeyDataTemplateSet() throws WxErrorException { WxCpAgentWorkBench template = new WxCpAgentWorkBench(); template.setAgentId(1000011L); template.setType(WxCpConsts.WorkBenchType.KEYDATA); List workBenchKeyDataList = new ArrayList<>(); - for(int i = 1;i < 4;i++){ + for (int i = 1; i < 4; i++) { WorkBenchKeyData workBenchKeyData = new WorkBenchKeyData(); - workBenchKeyData.setKey("审批"+i); + workBenchKeyData.setKey("审批" + i); workBenchKeyData.setData(String.valueOf(i)); workBenchKeyData.setJumpUrl("http://www.qq.com"); workBenchKeyData.setPagePath("pages/index"); @@ -91,6 +124,11 @@ public void testKeyDataTemplateSet() throws WxErrorException { this.wxCpService.getWorkBenchService().setWorkBenchTemplate(template); } + /** + * Test key data user data set. + * + * @throws WxErrorException the wx error exception + */ @Test public void testKeyDataUserDataSet() throws WxErrorException { WxCpAgentWorkBench template = new WxCpAgentWorkBench(); @@ -108,15 +146,20 @@ public void testKeyDataUserDataSet() throws WxErrorException { this.wxCpService.getWorkBenchService().setWorkBenchTemplate(template); } + /** + * Test list template set. + * + * @throws WxErrorException the wx error exception + */ @Test public void testListTemplateSet() throws WxErrorException { WxCpAgentWorkBench template = new WxCpAgentWorkBench(); template.setAgentId(1000011L); template.setType(WxCpConsts.WorkBenchType.LIST); List workBenchListArray = new ArrayList<>(); - for(int i = 0;i < 2;i++){ + for (int i = 0; i < 2; i++) { WorkBenchList workBenchlist = new WorkBenchList(); - workBenchlist.setTitle("测试"+i); + workBenchlist.setTitle("测试" + i); workBenchlist.setJumpUrl("http://www.qq.com"); workBenchlist.setPagePath("pages/index"); workBenchListArray.add(workBenchlist); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImplTest.java index 56df47e36a..09c50574c5 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImplTest.java @@ -1,20 +1,23 @@ package me.chanjar.weixin.cp.api.impl; -import java.util.Arrays; - -import org.testng.*; -import org.testng.annotations.*; - import com.google.common.collect.Lists; import com.google.inject.Inject; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.cp.constant.WxCpConsts.AppChatMsgType; import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.WxCpService; -import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; import me.chanjar.weixin.cp.bean.WxCpChat; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import me.chanjar.weixin.cp.bean.article.NewArticle; +import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; +import me.chanjar.weixin.cp.constant.WxCpConsts.AppChatMsgType; +import org.testng.Assert; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; @@ -31,12 +34,20 @@ public class WxCpChatServiceImplTest { @Inject private WxCpService cpService; + /** + * Init. + */ @BeforeTest public void init() { this.chatId = "mychatid"; this.userId = ((ApiTestModule.WxXmlCpInMemoryConfigStorage) this.cpService.getWxCpConfigStorage()).getUserId(); } + /** + * Test create. + * + * @throws Exception the exception + */ @Test public void testCreate() throws Exception { final String result = cpService.getChatService().create("测试群聊", userId, @@ -45,6 +56,11 @@ public void testCreate() throws Exception { assertThat(result).isEqualTo(chatId); } + /** + * Test get. + * + * @throws Exception the exception + */ @Test public void testGet() throws Exception { WxCpChat chat = this.cpService.getChatService().get(chatId); @@ -52,14 +68,24 @@ public void testGet() throws Exception { Assert.assertEquals(chat.getName(), "测试群聊"); } + /** + * Test update. + * + * @throws Exception the exception + */ @Test public void testUpdate() throws Exception { - this.cpService.getChatService().update(chatId, "", "", Arrays.asList("ZhengWuYao"), null); + this.cpService.getChatService().update(chatId, "", "", Collections.singletonList("ZhengWuYao"), null); WxCpChat chat = this.cpService.getChatService().get(chatId); System.out.println(chat); Assert.assertEquals(chat.getUsers().size(), 3); } + /** + * Messages object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider public Object[][] messages() { return new Object[][]{ @@ -101,7 +127,8 @@ public Object[][] messages() { .btnTxt("更多") .title("领奖通知") .url("https://zhidao.baidu.com/question/2073647112026042748.html") - .description("

2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:520258
请于2016年10月10日前联系行 政同事领取
") + .description("
2016年9月26日
恭喜你抽中iPhone " + + "7一台,领奖码:520258
请于2016年10月10日前联系行 政同事领取
") .build() }, {WxCpAppChatMessage.builder() @@ -151,6 +178,12 @@ public Object[][] messages() { }; } + /** + * Test send msg. + * + * @param message the message + * @throws WxErrorException the wx error exception + */ @Test(dataProvider = "messages") public void testSendMsg(WxCpAppChatMessage message) throws WxErrorException { this.cpService.getChatService().sendMsg(message); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImplTest.java new file mode 100644 index 0000000000..e78ce5c008 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImplTest.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.ApiTestModule; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorp; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.testng.Assert.assertNotNull; + +/** + * @author libo + */ +@Guice(modules = ApiTestModule.class) +public class WxCpCorpGroupServiceImplTest { + @Inject + private WxCpService wxService; + + @Test + public void testListAppShareInfo() throws WxErrorException { + Integer agentId = wxService.getWxCpConfigStorage().getAgentId(); + Integer businessType = 1; + String corpId = null; + Integer limit = null; + String cursor = null; + List resp = wxService.getCorpGroupService().listAppShareInfo(agentId, businessType, corpId, limit, cursor); + assertNotNull(resp); + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java index 57957d3fb6..f8e0d5e198 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java @@ -1,13 +1,15 @@ package me.chanjar.weixin.cp.api.impl; -import java.util.List; - -import org.testng.annotations.*; - import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpDepart; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -25,6 +27,11 @@ public class WxCpDepartmentServiceImplTest { private WxCpDepart depart; + /** + * Test create. + * + * @throws Exception the exception + */ @Test public void testCreate() throws Exception { WxCpDepart cpDepart = new WxCpDepart(); @@ -35,15 +42,26 @@ public void testCreate() throws Exception { System.out.println(departId); } + /** + * Depart ids object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider - public Object[][] departIds(){ + public Object[][] departIds() { return new Object[][]{ {null}, - {1}, - {5} + {12L}, + {5L} }; } + /** + * Test list. + * + * @param id the id + * @throws Exception the exception + */ @Test(dataProvider = "departIds") public void testList(Long id) throws Exception { System.out.println("=================获取部门"); @@ -56,6 +74,11 @@ public void testList(Long id) throws Exception { } } + /** + * Test update. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = {"testList", "testCreate"}) public void testUpdate() throws Exception { System.out.println("=================更新部门"); @@ -63,6 +86,11 @@ public void testUpdate() throws Exception { this.wxCpService.getDepartmentService().update(this.depart); } + /** + * Test delete. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = "testUpdate") public void testDelete() throws Exception { System.out.println("=================删除部门"); @@ -70,4 +98,35 @@ public void testDelete() throws Exception { this.wxCpService.getDepartmentService().delete(this.depart.getId()); } + /** + * 获取子部门ID列表 + * https://developer.work.weixin.qq.com/document/path/95350 + * + * @param id the id + * @throws WxErrorException the wx error exception + */ + @Test(dataProvider = "departIds") + public void testSimpleList(Long id) throws WxErrorException { + System.out.println("=================获取子部门ID列表"); + List departList = this.wxCpService.getDepartmentService().simpleList(id); + assertThat(departList).isNotEmpty(); + departList.forEach(System.out::println); + } + + /** + * Test get. + * + * @param id the id + * @throws WxErrorException the wx error exception + */ + @Test(dataProvider = "departIds") + public void testGet(Long id) throws WxErrorException { + if (id == null) { + return; + } + + WxCpDepart depart = this.wxCpService.getDepartmentService().get(id); + assertThat(depart).isNotNull(); + System.out.println(depart); + } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java index cfbdcca930..d7ed2a6221 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java @@ -10,11 +10,13 @@ import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo; import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; import me.chanjar.weixin.cp.bean.external.msg.Attachment; +import me.chanjar.weixin.cp.bean.external.msg.AttachmentBuilder; import me.chanjar.weixin.cp.bean.external.msg.Image; import me.chanjar.weixin.cp.bean.external.msg.Video; import org.apache.commons.lang3.time.DateFormatUtils; import org.testng.annotations.Guice; import org.testng.annotations.Test; +import org.testng.collections.CollectionUtils; import java.util.ArrayList; import java.util.Collections; @@ -23,14 +25,25 @@ import static org.testng.Assert.assertNotNull; +/** + * The type Wx cp external contact service impl test. + */ @Guice(modules = ApiTestModule.class) public class WxCpExternalContactServiceImplTest { @Inject private WxCpService wxCpService; + /** + * The Config storage. + */ @Inject protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; private final String userId = "someone" + System.currentTimeMillis(); + /** + * Test get external contact. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetExternalContact() throws WxErrorException { String externalUserId = this.configStorage.getExternalUserId(); @@ -39,6 +52,11 @@ public void testGetExternalContact() throws WxErrorException { assertNotNull(result); } + /** + * Test add contact way. + * + * @throws WxErrorException the wx error exception + */ @Test public void testAddContactWay() throws WxErrorException { @@ -55,6 +73,11 @@ public void testAddContactWay() throws WxErrorException { this.wxCpService.getExternalContactService().addContactWay(info); } + /** + * Test get contact way. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetContactWay() throws WxErrorException { final String configId = "39fea3d93e30faaa8c7a9edd4cfe4d08"; @@ -63,6 +86,11 @@ public void testGetContactWay() throws WxErrorException { assertNotNull(contactWayInfo); } + /** + * Test update contact way. + * + * @throws WxErrorException the wx error exception + */ @Test public void testUpdateContactWay() throws WxErrorException { final String configId = "2d7a68c657663afbd1d90db19a4b5ee9"; @@ -78,6 +106,11 @@ public void testUpdateContactWay() throws WxErrorException { assertNotNull(resp); } + /** + * Test del contact way. + * + * @throws WxErrorException the wx error exception + */ @Test public void testDelContactWay() throws WxErrorException { final String configId = "2d7a68c657663afbd1d90db19a4b5ee9"; @@ -86,6 +119,11 @@ public void testDelContactWay() throws WxErrorException { assertNotNull(resp); } + /** + * Test close temp chat. + * + * @throws WxErrorException the wx error exception + */ @Test public void testCloseTempChat() throws WxErrorException { final String externalUserId = "externalUserId"; @@ -93,6 +131,11 @@ public void testCloseTempChat() throws WxErrorException { System.out.println(resp); } + /** + * Test list external contacts. + * + * @throws WxErrorException the wx error exception + */ @Test public void testListExternalContacts() throws WxErrorException { String userId = this.configStorage.getUserId(); @@ -101,6 +144,11 @@ public void testListExternalContacts() throws WxErrorException { assertNotNull(ret); } + /** + * Test list external with permission. + * + * @throws WxErrorException the wx error exception + */ @Test public void testListExternalWithPermission() throws WxErrorException { List ret = this.wxCpService.getExternalContactService().listFollowers(); @@ -108,22 +156,39 @@ public void testListExternalWithPermission() throws WxErrorException { assertNotNull(ret); } + /** + * Test get contact detail. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetContactDetail() throws WxErrorException { String externalUserId = this.configStorage.getExternalUserId(); - WxCpExternalContactInfo result = this.wxCpService.getExternalContactService().getContactDetail(externalUserId); + WxCpExternalContactInfo result = this.wxCpService.getExternalContactService().getContactDetail(externalUserId, + null); System.out.println(result); assertNotNull(result); } + /** + * Test get contact detail batch. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetContactDetailBatch() throws WxErrorException { String userId = this.configStorage.getUserId(); - WxCpExternalContactBatchInfo result = this.wxCpService.getExternalContactService().getContactDetailBatch(new String[]{userId}, "", 100); + WxCpExternalContactBatchInfo result = + this.wxCpService.getExternalContactService().getContactDetailBatch(new String[]{userId}, "", 100); System.out.println(result); assertNotNull(result); } + /** + * Test get corp tag list. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetCorpTagList() throws WxErrorException { String[] tag = {}; @@ -132,19 +197,24 @@ public void testGetCorpTagList() throws WxErrorException { assertNotNull(result); } + /** + * Test add corp tag. + * + * @throws WxErrorException the wx error exception + */ @Test public void testAddCorpTag() throws WxErrorException { List list = new ArrayList<>(); WxCpUserExternalTagGroupInfo.Tag tag = new WxCpUserExternalTagGroupInfo.Tag(); tag.setName("测试标签20"); - tag.setOrder(1); + tag.setOrder(1L); list.add(tag); WxCpUserExternalTagGroupInfo tagGroupInfo = new WxCpUserExternalTagGroupInfo(); WxCpUserExternalTagGroupInfo.TagGroup tagGroup = new WxCpUserExternalTagGroupInfo.TagGroup(); tagGroup.setGroupName("其他"); - tagGroup.setOrder(1); + tagGroup.setOrder(1L); tagGroup.setTag(list); tagGroupInfo.setTagGroup(tagGroup); @@ -154,15 +224,26 @@ public void testAddCorpTag() throws WxErrorException { assertNotNull(result); } + /** + * Test edit corp tag. + * + * @throws WxErrorException the wx error exception + */ @Test public void testEditCorpTag() throws WxErrorException { - WxCpBaseResp result = this.wxCpService.getExternalContactService().editCorpTag("et2omCCwAA6PtGsfeEOQMENl3Ub1FA6A", "未知6", 2); + WxCpBaseResp result = this.wxCpService.getExternalContactService().editCorpTag("et2omCCwAA6PtGsfeEOQMENl3Ub1FA6A" + , "未知6", 2); System.out.println(result); assertNotNull(result); } + /** + * Test del corp tag. + * + * @throws WxErrorException the wx error exception + */ @Test public void testDelCorpTag() throws WxErrorException { @@ -175,6 +256,11 @@ public void testDelCorpTag() throws WxErrorException { assertNotNull(result); } + /** + * Test mark tag. + * + * @throws WxErrorException the wx error exception + */ @Test public void testMarkTag() throws WxErrorException { @@ -183,28 +269,46 @@ public void testMarkTag() throws WxErrorException { String[] addTag = {"et2omCCwAAzdcSK-RV80YS9sbpCXlNlQ"}; String[] removeTag = {}; - WxCpBaseResp result = this.wxCpService.getExternalContactService().markTag(userid, externalUserid, addTag, removeTag); + WxCpBaseResp result = this.wxCpService.getExternalContactService().markTag(userid, externalUserid, addTag, + removeTag); System.out.println(result); assertNotNull(result); } + /** + * Test delete contact way. + */ @Test public void testDeleteContactWay() { } + /** + * Test list followers. + */ @Test public void testListFollowers() { } + /** + * Test list unassigned list. + */ @Test public void testListUnassignedList() { } + /** + * Test transfer external contact. + */ @Test public void testTransferExternalContact() { } + /** + * Test transfer customer. + * + * @throws WxErrorException the wx error exception + */ @Test public void testTransferCustomer() throws WxErrorException { WxCpUserTransferCustomerReq req = new WxCpUserTransferCustomerReq(); @@ -217,6 +321,11 @@ public void testTransferCustomer() throws WxErrorException { assertNotNull(result); } + /** + * Test trnsfer result. + * + * @throws WxErrorException the wx error exception + */ @Test public void testTrnsferResult() throws WxErrorException { WxCpUserTransferResultResp result = this.wxCpService.getExternalContactService().transferResult("123", "234", ""); @@ -224,6 +333,11 @@ public void testTrnsferResult() throws WxErrorException { assertNotNull(result); } + /** + * Testresigned transfer customer. + * + * @throws WxErrorException the wx error exception + */ @Test public void testresignedTransferCustomer() throws WxErrorException { WxCpUserTransferCustomerReq req = new WxCpUserTransferCustomerReq(); @@ -236,51 +350,106 @@ public void testresignedTransferCustomer() throws WxErrorException { assertNotNull(result); } + /** + * Testresigned trnsfer result. + * + * @throws WxErrorException the wx error exception + */ @Test public void testresignedTrnsferResult() throws WxErrorException { - WxCpUserTransferResultResp result = this.wxCpService.getExternalContactService().resignedTransferResult("123", "234", ""); + WxCpUserTransferResultResp result = this.wxCpService.getExternalContactService().resignedTransferResult("123", + "234", ""); System.out.println(result); assertNotNull(result); } + /** + * Test list group chat. + * + * @throws WxErrorException the wx error exception + */ @Test public void testListGroupChat() throws WxErrorException { - WxCpUserExternalGroupChatList result = this.wxCpService.getExternalContactService().listGroupChat(0, 100, 0, new String[1], new String[1]); + WxCpUserExternalGroupChatList result = this.wxCpService.getExternalContactService().listGroupChat(0, 100, 0, + new String[1], new String[1]); System.out.println(result); assertNotNull(result); } + /** + * Test list group chat v 3. + * + * @throws WxErrorException the wx error exception + */ @Test public void testListGroupChatV3() throws WxErrorException { - WxCpUserExternalGroupChatList result = this.wxCpService.getExternalContactService().listGroupChat(100, "", 0, new String[1]); + WxCpUserExternalGroupChatList result = this.wxCpService.getExternalContactService().listGroupChat(100, "", 0, + new String[1]); System.out.println(result); assertNotNull(result); } + /** + * Test get group chat. + */ @Test public void testGetGroupChat() { } + /** + * Test transfer group chat. + * + * @throws WxErrorException the wx error exception + */ @Test public void testTransferGroupChat() throws WxErrorException { String[] str = {"wri1_QEAAATfnZl_VJ4hlQda0e4Mgf1A"}; - WxCpUserExternalGroupChatTransferResp result = this.wxCpService.getExternalContactService().transferGroupChat(str, "123"); + WxCpUserExternalGroupChatTransferResp result = this.wxCpService.getExternalContactService().transferGroupChat(str + , "123"); System.out.println(result); assertNotNull(result); } + /** + * Test onjob transfer group chat. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testOnjobTransferGroupChat() throws WxErrorException { + String[] str = {"wrHlLKQAAAFbfB99-BO97YZlcywznGZg", "error_group_id"}; + WxCpUserExternalGroupChatTransferResp result = this.wxCpService.getExternalContactService().onjobTransferGroupChat(str + , "x"); + System.out.println(result); + assertNotNull(result); + } + + /** + * Test get user behavior statistic. + */ @Test public void testGetUserBehaviorStatistic() { } + /** + * Test get group chat statistic. + */ @Test public void testGetGroupChatStatistic() { } + /** + * Test add msg template. + */ @Test public void testAddMsgTemplate() { } + /** + * Test send welcome msg. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendWelcomeMsg() throws WxErrorException { Image image = new Image(); @@ -302,6 +471,38 @@ public void testSendWelcomeMsg() throws WxErrorException { .build()); } + /** + * Test send welcome msg. use AttachmentBuilder + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testSendWelcomeMsg2() throws WxErrorException { + + Attachment imageAttachment = AttachmentBuilder.imageBuilder().mediaId("123123").build(); + Attachment videoAttachment = AttachmentBuilder.videoBuilder().mediaId("video_media_id").build(); + Attachment miniProgramAttachment = AttachmentBuilder.miniProgramBuilder() + .title("title") + .picMediaId("123123123") + .appId("wxcxxxxxxxxxxx") + .page("https://") + .build(); + + List attachments = new ArrayList<>(); + attachments.add(imageAttachment); + attachments.add(videoAttachment); + attachments.add(miniProgramAttachment); + this.wxCpService.getExternalContactService().sendWelcomeMsg(WxCpWelcomeMsg.builder() + .welcomeCode("abc") + .attachments(attachments) + .build()); + } + + /** + * Test update remark. + * + * @throws WxErrorException the wx error exception + */ @Test public void testUpdateRemark() throws WxErrorException { this.wxCpService.getExternalContactService().updateRemark(WxCpUpdateRemarkRequest.builder() @@ -314,4 +515,126 @@ public void testUpdateRemark() throws WxErrorException { .remarkPicMediaId("aaa") .build()); } + + /** + * Test get product list album. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetProductListAlbum() throws WxErrorException { + WxCpProductAlbumListResult result = this.wxCpService.getExternalContactService() + .getProductAlbumList(100, null); + System.out.println(result); + assertNotNull(result); + if (CollectionUtils.hasElements(result.getProductList())) { + WxCpProductAlbumResult result1 = + this.wxCpService.getExternalContactService().getProductAlbum(result.getProductList().get(0).getProductId()); + System.out.println(result1); + assertNotNull(result1); + } + } + + /** + * Test get moment list. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetMomentList() throws WxErrorException { + WxCpGetMomentList result = this.wxCpService.getExternalContactService() + .getMomentList(1636732800L, 1636991999L, null, null, null, null); + System.out.println(result); + assertNotNull(result); + } + + /** + * Test add join way. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testAddJoinWay() throws WxErrorException { + + + WxCpGroupJoinWayInfo.JoinWay joinWay = new WxCpGroupJoinWayInfo.JoinWay(); + joinWay.setChatIdList(Collections.singletonList("wrfpBaCwAAxR-iIqIUa5vvbpZQcAexJA")); + joinWay.setScene(2); + joinWay.setAutoCreateRoom(1); + joinWay.setRemark("CreateDate:" + DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(new Date())); + + WxCpGroupJoinWayInfo info = new WxCpGroupJoinWayInfo(); + info.setJoinWay(joinWay); + this.wxCpService.getExternalContactService().addJoinWay(info); + } + + /** + * Test update join way. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testUpdateJoinWay() throws WxErrorException { + + final String configId = ""; + + WxCpGroupJoinWayInfo.JoinWay joinWay = new WxCpGroupJoinWayInfo.JoinWay(); + joinWay.setConfigId(configId); + joinWay.setChatIdList(Collections.singletonList("wrfpBaCwAAxR-iIqIUa5vvbpZQcAexJA")); + joinWay.setScene(2); + joinWay.setAutoCreateRoom(1); + joinWay.setRemark("CreateDate:" + DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(new Date())); + + WxCpGroupJoinWayInfo info = new WxCpGroupJoinWayInfo(); + info.setJoinWay(joinWay); + this.wxCpService.getExternalContactService().updateJoinWay(info); + } + + /** + * Test del join way. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testDelJoinWay() throws WxErrorException { + + final String configId = ""; + + this.wxCpService.getExternalContactService().delJoinWay(configId); + } + + /** + * Test get join way. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetJoinWay() throws WxErrorException { + + final String configId = ""; + + this.wxCpService.getExternalContactService().getJoinWay(configId); + } + + /** + * 提醒成员群发 + * + * @throws WxErrorException + */ + @Test + public void testRemindGroupMsgSend() throws WxErrorException { + this.wxCpService.getExternalContactService() + .remindGroupMsgSend("msgGCAAAXtWyujaWJHDDGi0mACAAAA"); + } + + /** + * 测试取消提醒成员群发 + * + * @throws WxErrorException + */ + @Test + public void testCancelGroupMsgSend() throws WxErrorException { + this.wxCpService.getExternalContactService() + .cancelGroupMsgSend("msgGCAAAXtWyujaWJHDDGi0mACAAAA"); + } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java index 57bd9b750d..8e0d87d82c 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java @@ -19,27 +19,42 @@ /** * 微信群机器人消息发送api 单元测试 * - * @author yr - * @date 2020-08-20 + * @author yr created on 2020-08-20 */ @Slf4j @Guice(modules = ApiTestModule.class) public class WxCpGroupRobotServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; private WxCpGroupRobotService robotService; + /** + * Sets . + */ @BeforeTest public void setup() { robotService = wxService.getGroupRobotService(); } + /** + * Test send text. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendText() throws WxErrorException { robotService.sendText("Hello World", null, null); } + /** + * Test send mark down. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendMarkDown() throws WxErrorException { String content = "实时新增用户反馈132例,请相关同事注意。\n" + @@ -49,6 +64,11 @@ public void testSendMarkDown() throws WxErrorException { robotService.sendMarkdown(content); } + /** + * Test send image. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendImage() throws WxErrorException { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("mm.jpeg"); @@ -58,10 +78,15 @@ public void testSendImage() throws WxErrorException { robotService.sendImage(base64, md5); } + /** + * Test send news. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendNews() throws WxErrorException { NewArticle article = new NewArticle("图文消息测试", "hello world", "http://www.baidu.com", - "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png", null); + "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png", null, null, null); robotService.sendNews(Stream.of(article).collect(Collectors.toList())); } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java new file mode 100644 index 0000000000..c918c297bb --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java @@ -0,0 +1,100 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.inject.Inject; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import me.chanjar.weixin.cp.api.ApiTestModule; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.kf.*; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.io.InputStream; + +/** + * WxCpKfServiceImpl-测试类 + * 需要用到专门的 secret https://kf.weixin.qq.com/api/doc/path/93304#secret + * + * @author Fu created on 2022/1/19 20:12 + */ +@Guice(modules = ApiTestModule.class) +public class WxCpKfServiceImplTest { + + @Inject + private WxCpService wxService; + + private static String kfid = "wkPzhXVAAAJD9oR75LrO1DmURSOUFBIg"; + + /** + * Test account add. + * + * @throws Exception the exception + */ + @Test(priority = 1) + public void testAccountAdd() throws Exception { + try (InputStream in = ClassLoader.getSystemResourceAsStream("mm.jpeg")) { + WxMediaUploadResult result = this.wxService.getMediaService().upload(WxConsts.MediaFileType.IMAGE, "jpeg", in); + String mediaId = result.getMediaId(); + WxCpKfAccountAdd add = new WxCpKfAccountAdd(); + add.setMediaId(mediaId); + add.setName("kefu01"); + WxCpKfAccountAddResp resp = this.wxService.getKfService().addAccount(add); + System.out.println(resp); + kfid = resp.getOpenKfid(); + } + } + + /** + * Test account upd. + * + * @throws Exception the exception + */ + @Test(priority = 2) + public void testAccountUpd() throws Exception { + WxCpKfAccountUpd upd = new WxCpKfAccountUpd(); + upd.setOpenKfid(kfid); + upd.setName("kefu01-upd"); + WxCpBaseResp resp = this.wxService.getKfService().updAccount(upd); + System.out.println(resp); + } + + /** + * Test account list. + * + * @throws Exception the exception + */ + @Test(priority = 3) + public void testAccountList() throws Exception { + WxCpKfAccountListResp resp = this.wxService.getKfService().listAccount(0, 10); + System.out.println(resp); + } + + /** + * Test account link. + * + * @throws Exception the exception + */ + @Test(priority = 4) + public void testAccountLink() throws Exception { + WxCpKfAccountLink link = new WxCpKfAccountLink(); + link.setOpenKfid(kfid); + link.setScene("scene"); + WxCpKfAccountLinkResp resp = this.wxService.getKfService().getAccountLink(link); + System.out.println(resp); + } + + /** + * Test account del. + * + * @throws Exception the exception + */ + @Test(priority = 5) + public void testAccountDel() throws Exception { + WxCpKfAccountDel del = new WxCpKfAccountDel(); + del.setOpenKfid(kfid); + WxCpBaseResp resp = this.wxService.getKfService().delAccount(del); + System.out.println(resp); + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java index 70873c49cf..b964aad513 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java @@ -1,14 +1,5 @@ package me.chanjar.weixin.cp.api.impl; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.testng.annotations.*; - import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; @@ -16,9 +7,19 @@ import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.TestConstants; import me.chanjar.weixin.cp.api.WxCpService; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.*; +import static org.testng.Assert.assertTrue; /** * Created by Binary Wang on 2017-6-25. @@ -30,8 +31,13 @@ public class WxCpMediaServiceImplTest { @Inject private WxCpService wxService; - private List mediaIds = new ArrayList<>(); + private final List mediaIds = new ArrayList<>(); + /** + * Media data object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider public Object[][] mediaData() { return new Object[][]{ @@ -44,6 +50,15 @@ public Object[][] mediaData() { }; } + /** + * Test upload media. + * + * @param mediaType the media type + * @param fileType the file type + * @param fileName the file name + * @throws WxErrorException the wx error exception + * @throws IOException the io exception + */ @Test(dataProvider = "mediaData") public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException { try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName)) { @@ -62,6 +77,11 @@ public void testUploadMedia(String mediaType, String fileType, String fileName) } } + /** + * Download media object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider public Object[][] downloadMedia() { Object[][] params = new Object[this.mediaIds.size()][]; @@ -71,6 +91,12 @@ public Object[][] downloadMedia() { return params; } + /** + * Test download. + * + * @param mediaId the media id + * @throws WxErrorException the wx error exception + */ @Test(dependsOnMethods = {"testUploadMedia"}, dataProvider = "downloadMedia") public void testDownload(String mediaId) throws WxErrorException { File file = this.wxService.getMediaService().download(mediaId); @@ -78,6 +104,11 @@ public void testDownload(String mediaId) throws WxErrorException { System.out.println(file); } + /** + * Test upload img. + * + * @throws WxErrorException the wx error exception + */ @Test public void testUploadImg() throws WxErrorException { URL url = ClassLoader.getSystemResource("mm.jpeg"); @@ -85,6 +116,11 @@ public void testUploadImg() throws WxErrorException { assertThat(res).isNotEmpty(); } + /** + * Test get jssdk file. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetJssdkFile() throws WxErrorException { File file = this.wxService.getMediaService().getJssdkFile("...."); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImplTest.java new file mode 100644 index 0000000000..2c00674286 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImplTest.java @@ -0,0 +1,89 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.ApiTestModule; +import me.chanjar.weixin.cp.api.WxCpMeetingService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult; +import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; +import org.testng.collections.Lists; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.testng.Assert.assertEquals; + + +/** + * 单元测试类. + * + * @author wangmeng3486 created on 2023-02-03 + */ +@Test +@Slf4j +@Guice(modules = ApiTestModule.class) +public class WxCpMeetingServiceImplTest { + /** + * The Wx service. + */ + @Inject + private WxCpService wxCpService; + /** + * The Config storage. + */ + @Inject + protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; + + /** + * Test + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testAdd() throws WxErrorException { + WxCpMeetingService wxCpMeetingService = this.wxCpService.getMeetingService(); + /* + 测试 创建会议 + */ + long startTime = System.currentTimeMillis() / 1000 + 30 * 60L; + List userIds = Lists.newArrayList(this.configStorage.getUserId(), "lisi"); + WxCpMeeting wxCpMeeting = new WxCpMeeting().setAdminUserId(this.configStorage.getUserId()).setTitle("新建会议") + .setMeetingStart(startTime).setMeetingDuration(3600).setDescription("新建会议描述").setLocation("广州媒体港") + .setAttendees(new WxCpMeeting.Attendees().setUserId(userIds)) + .setSettings(new WxCpMeeting.Setting().setRemindScope(1).setPassword("1234").setEnableWaitingRoom(false) + .setAllowEnterBeforeHost(true).setEnableEnterMute(1).setAllowExternalUser(false).setEnableScreenWatermark(false) + .setHosts(new WxCpMeeting.Attendees().setUserId(userIds)).setRingUsers(new WxCpMeeting.Attendees().setUserId(userIds))) + .setReminders(new WxCpMeeting.Reminder().setIsRepeat(1).setRepeatType(0).setRepeatUntil(startTime + 24 * 60 * 60L) + .setRepeatInterval(1).setRemindBefore(Lists.newArrayList(0, 900))); + String meetingId = "hyXG0RCQAAogMgFb9Tx_b-1-lhJRWvvg";// wxCpMeetingService.create(wxCpMeeting); + assertThat(meetingId).isNotNull(); + /* + 测试 获取用户会议列表 + */ + wxCpMeeting.setMeetingId(meetingId); + WxCpUserMeetingIdResult wxCpUserMeetingIdResult = wxCpMeetingService.getUserMeetingIds(this.configStorage.getUserId(), null, null, startTime, null); + assertThat(wxCpUserMeetingIdResult.getMeetingIdList()).isNotNull(); + log.info("获取用户会议列表: {}", wxCpUserMeetingIdResult.toJson()); + /* + 测试 修改会议 + */ + wxCpMeeting.setTitle("修改会议"); + wxCpMeeting.setDescription("修改会议描述"); + WxCpMeetingUpdateResult wxCpMeetingUpdateResult = wxCpMeetingService.update(wxCpMeeting); + assertEquals(wxCpMeetingUpdateResult.getErrcode().longValue(), 0L); + /* + 测试 获取会议详情 + */ + WxCpMeeting wxCpMeetingResult = wxCpMeetingService.getDetail(meetingId); + log.info("获取会议详情: {}", wxCpMeetingResult.toJson()); + /* + 测试 取消会议 + */ + wxCpMeetingService.cancel(meetingId); + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java index b9dbbd3aa1..928cf4be46 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java @@ -6,22 +6,31 @@ import me.chanjar.weixin.common.bean.menu.WxMenuButton; import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.WxCpService; -import org.testng.annotations.*; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; -import static org.testng.Assert.*; +import static org.testng.Assert.assertNotNull; /** *
  *
  * Created by Binary Wang on 2017-6-25.
- * @author Binary Wang
- * 
+ * @author Binary Wang */ @Guice(modules = ApiTestModule.class) public class WxCpMenuServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; + /** + * Menu data object [ ] [ ]. + * + * @return the object [ ] [ ] + */ @DataProvider public Object[][] menuData() { WxMenu menu = new WxMenu(); @@ -69,11 +78,22 @@ public Object[][] menuData() { } + /** + * Test create. + * + * @param wxMenu the wx menu + * @throws Exception the exception + */ @Test(dataProvider = "menuData") public void testCreate(WxMenu wxMenu) throws Exception { this.wxService.getMenuService().create(wxMenu); } + /** + * Test get. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = "testCreate") public void testGet() throws Exception { WxMenu menu = this.wxService.getMenuService().get(); @@ -81,6 +101,11 @@ public void testGet() throws Exception { System.out.println(menu.toJson()); } + /** + * Test delete. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = {"testGet", "testCreate"}) public void testDelete() throws Exception { this.wxService.getMenuService().delete(); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImplTest.java index 3a1e5460fa..708542f41d 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImplTest.java @@ -7,7 +7,6 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.ApiTestModule; -import me.chanjar.weixin.cp.api.ApiTestModuleWithMockServer; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage; import me.chanjar.weixin.cp.bean.message.WxCpMessage; @@ -27,19 +26,26 @@ /** * 测试类. * - * @author Binary Wang - * @date 2020-08-30 + * @author Binary Wang created on 2020-08-30 */ @Test //@Guice(modules = ApiTestModuleWithMockServer.class) @Guice(modules = ApiTestModule.class) public class WxCpMessageServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; private Runner mockRunner; private ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; + private WxCpMessageSendResult wxCpMessageSendResult; + + /** + * Sets . + */ @BeforeTest public void setup() { HttpServer mockServer = jsonHttpServer(mockServerPort, file("src/test/resources/moco/message.json")); @@ -48,11 +54,19 @@ public void setup() { this.configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) this.wxService.getWxCpConfigStorage(); } + /** + * Stop mock server. + */ @AfterTest public void stopMockServer() { this.mockRunner.stop(); } + /** + * Test send message. + * + * @throws WxErrorException the wx error exception + */ public void testSendMessage() throws WxErrorException { WxCpMessage message = new WxCpMessage(); // message.setAgentId(configStorage.getAgentId()); @@ -68,6 +82,11 @@ public void testSendMessage() throws WxErrorException { System.out.println(messageSendResult.getInvalidTagList()); } + /** + * Test send message 1. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendMessage1() throws WxErrorException { WxCpMessage message = WxCpMessage @@ -79,12 +98,18 @@ public void testSendMessage1() throws WxErrorException { WxCpMessageSendResult messageSendResult = this.wxService.getMessageService().send(message); assertNotNull(messageSendResult); + wxCpMessageSendResult = messageSendResult; System.out.println(messageSendResult); System.out.println(messageSendResult.getInvalidPartyList()); System.out.println(messageSendResult.getInvalidUserList()); System.out.println(messageSendResult.getInvalidTagList()); } + /** + * Test send message markdown. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendMessage_markdown() throws WxErrorException { WxCpMessage message = WxCpMessage @@ -113,13 +138,19 @@ public void testSendMessage_markdown() throws WxErrorException { System.out.println(messageSendResult.getInvalidTagList()); } + /** + * Test send message text card. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendMessage_textCard() throws WxErrorException { WxCpMessage message = WxCpMessage .TEXTCARD() .toUser(configStorage.getUserId()) .btnTxt("更多") - .description("
2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
") + .description("
2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
") .url("URL") .title("领奖通知") .build(); @@ -132,6 +163,11 @@ public void testSendMessage_textCard() throws WxErrorException { System.out.println(messageSendResult.getInvalidTagList()); } + /** + * Test send message mini program notice. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendMessage_miniProgram_notice() throws WxErrorException { WxCpMessage message = WxCpMessage @@ -155,6 +191,11 @@ public void testSendMessage_miniProgram_notice() throws WxErrorException { System.out.println(messageSendResult.getInvalidTagList()); } + /** + * Test send linked corp message. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendLinkedCorpMessage() throws WxErrorException { this.wxService.getMessageService().sendLinkedCorpMessage(WxCpLinkedCorpMessage.builder() @@ -164,11 +205,19 @@ public void testSendLinkedCorpMessage() throws WxErrorException { .build()); } + /** + * Test send. + */ @Test public void testSend() { // see other test methods } + /** + * Test get statistics. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetStatistics() throws WxErrorException { final WxCpMessageSendStatistics statistics = this.wxService.getMessageService().getStatistics(1); @@ -176,4 +225,13 @@ public void testGetStatistics() throws WxErrorException { assertThat(statistics.getStatistics()).isNotNull(); } + /** + * Test message recall + * @throws WxErrorException + */ + @Test(dependsOnMethods = "testSendMessage1") + public void testRecall() throws WxErrorException { + this.wxService.getMessageService().recall(wxCpMessageSendResult.getMsgId()); + } + } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImplTest.java index 4df8756334..ca45be64ce 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImplTest.java @@ -23,12 +23,22 @@ public class WxCpOAuth2ServiceImplTest { @Inject private WxCpService wxService; + /** + * Test get user detail. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetUserDetail() throws WxErrorException { WxCpUserDetail userDetail = this.wxService.getOauth2Service().getUserDetail("b"); System.out.println(userDetail); } + /** + * Test get user info. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetUserInfo() throws WxErrorException { final WxCpOauth2UserInfo result = this.wxService.getOauth2Service().getUserInfo("abc"); @@ -36,6 +46,9 @@ public void testGetUserInfo() throws WxErrorException { System.out.println(result); } + /** + * Test build authorization url. + */ @Test public void testBuildAuthorizationUrl() { } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImplTest.java index f8f43cb816..befa115116 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImplTest.java @@ -9,6 +9,7 @@ import org.testng.annotations.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -16,17 +17,23 @@ /** * 单元测试. * - * @author Binary Wang - * @date 2020-09-20 + * @author Binary Wang created on 2020-09-20 */ - @Test @Guice(modules = ApiTestModule.class) public class WxCpOaCalendarServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; private final String calId = "wcbBJNCQAARipW967iE8DKPAp5Kb96qQ"; + /** + * Test add. + * + * @throws WxErrorException the wx error exception + */ @Test public void testAdd() throws WxErrorException { this.wxService.getOaCalendarService().add(WxCpOaCalendar.builder() @@ -41,6 +48,11 @@ public void testAdd() throws WxErrorException { .build()); } + /** + * Test update. + * + * @throws WxErrorException the wx error exception + */ @Test public void testUpdate() throws WxErrorException { this.wxService.getOaCalendarService().update(WxCpOaCalendar.builder() @@ -56,12 +68,22 @@ public void testUpdate() throws WxErrorException { .build()); } + /** + * Test get. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGet() throws WxErrorException { - final List calendars = this.wxService.getOaCalendarService().get(Arrays.asList(calId)); + final List calendars = this.wxService.getOaCalendarService().get(Collections.singletonList(calId)); assertThat(calendars).isNotEmpty(); } + /** + * Test delete. + * + * @throws WxErrorException the wx error exception + */ @Test public void testDelete() throws WxErrorException { this.wxService.getOaCalendarService().delete(calId); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImplTest.java new file mode 100644 index 0000000000..c6ed846e8c --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImplTest.java @@ -0,0 +1,93 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.ApiTestModule; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * 单元测试. + * + * @author Binary Wang created on 2020-09-20 + */ +@Test +@Guice(modules = ApiTestModule.class) +public class WxCpOaMeetingRoomServiceImplTest { + /** + * The Wx service. + */ + @Inject + protected WxCpService wxService; + + /** + * Test add. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testAdd() throws WxErrorException { + this.wxService.getOaMeetingRoomService().addMeetingRoom(WxCpOaMeetingRoom.builder() + .building("腾讯大厦") + .capacity(10) + .city("深圳") + .name("18F-会议室") + .floor("18F") + .equipment(Arrays.asList(1, 2)) +// .coordinate() + .build()); + + } + + /** + * Test update. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testUpdate() throws WxErrorException { + this.wxService.getOaMeetingRoomService().editMeetingRoom(WxCpOaMeetingRoom.builder() + .building("腾讯大厦") + .capacity(10) + .city("深圳") + .name("16F-会议室") + .floor("16F") + .equipment(Arrays.asList(1, 2, 3)) + .meetingroomId(1) + .build()); + } + + /** + * Test get. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGet() throws WxErrorException { + final List meetingRooms = + this.wxService.getOaMeetingRoomService().listMeetingRoom(WxCpOaMeetingRoom.builder() + .building("腾讯大厦") + .city("深圳") + .equipment(Arrays.asList(1, 2)) + .build()); + assertThat(meetingRooms).isNotEmpty(); + } + + /** + * Test delete. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testDelete() throws WxErrorException { + Integer calId = 1; + this.wxService.getOaMeetingRoomService().deleteMeetingRoom(calId); + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaScheduleServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaScheduleServiceImplTest.java index 09cbf874d4..5c5465381f 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaScheduleServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaScheduleServiceImplTest.java @@ -9,20 +9,28 @@ import org.testng.annotations.Test; import java.util.Arrays; +import java.util.Collections; /** * 单元测试类. * - * @author Binary Wang - * @date 2020-12-25 + * @author Binary Wang created on 2020-12-25 */ @Test @Guice(modules = ApiTestModule.class) public class WxCpOaScheduleServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; + /** + * Test add. + * + * @throws WxErrorException the wx error exception + */ @Test public void testAdd() throws WxErrorException { this.wxService.getOaScheduleService().add(new WxCpOaSchedule().setOrganizer("userid1") @@ -30,6 +38,11 @@ public void testAdd() throws WxErrorException { .setSummary("summary"), null); } + /** + * Test update. + * + * @throws WxErrorException the wx error exception + */ @Test public void testUpdate() throws WxErrorException { this.wxService.getOaScheduleService().update(new WxCpOaSchedule().setScheduleId("2222").setOrganizer("userid1") @@ -37,16 +50,31 @@ public void testUpdate() throws WxErrorException { .setSummary("summary")); } + /** + * Test get details. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetDetails() throws WxErrorException { - this.wxService.getOaScheduleService().getDetails(Arrays.asList("11111")); + this.wxService.getOaScheduleService().getDetails(Collections.singletonList("11111")); } + /** + * Test delete. + * + * @throws WxErrorException the wx error exception + */ @Test public void testDelete() throws WxErrorException { this.wxService.getOaScheduleService().delete("111"); } + /** + * Test list by calendar. + * + * @throws WxErrorException the wx error exception + */ @Test public void testListByCalendar() throws WxErrorException { this.wxService.getOaScheduleService().listByCalendar("111", null, null); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java index 4370bb3d83..857dc09752 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java @@ -1,22 +1,20 @@ package me.chanjar.weixin.cp.api.impl; import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.*; -import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import org.apache.commons.lang3.time.DateFormatUtils; import org.testng.annotations.Guice; import org.testng.annotations.Test; import org.testng.collections.Lists; import java.text.ParseException; -import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -25,18 +23,30 @@ /** * 企业微信 OA数据接口 测试用例 * - * @author Element + * @author Element & Wang_Wong */ - +@Slf4j @Guice(modules = ApiTestModule.class) public class WxCpOaServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; + /** + * The Gson. + */ @Inject protected Gson gson; + /** + * Test get checkin data. + * + * @throws ParseException the parse exception + * @throws WxErrorException the wx error exception + */ @Test public void testGetCheckinData() throws ParseException, WxErrorException { Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-04-11"); @@ -52,6 +62,12 @@ public void testGetCheckinData() throws ParseException, WxErrorException { } + /** + * Test get checkin day data. + * + * @throws ParseException the parse exception + * @throws WxErrorException the wx error exception + */ @Test public void testGetCheckinDayData() throws ParseException, WxErrorException { Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-06-30"); @@ -68,6 +84,12 @@ public void testGetCheckinDayData() throws ParseException, WxErrorException { } + /** + * Test get checkin month data. + * + * @throws ParseException the parse exception + * @throws WxErrorException the wx error exception + */ @Test public void testGetCheckinMonthData() throws ParseException, WxErrorException { Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-01"); @@ -81,6 +103,12 @@ public void testGetCheckinMonthData() throws ParseException, WxErrorException { System.out.println(gson.toJson(results)); } + /** + * Test get checkin schedule data. + * + * @throws ParseException the parse exception + * @throws WxErrorException the wx error exception + */ @Test public void testGetCheckinScheduleData() throws ParseException, WxErrorException { Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-01"); @@ -94,6 +122,11 @@ public void testGetCheckinScheduleData() throws ParseException, WxErrorException System.out.println(gson.toJson(results)); } + /** + * Test set checkin schedule list. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSetCheckinScheduleList() throws WxErrorException { WxCpSetCheckinSchedule wxCpSetCheckinSchedule = new WxCpSetCheckinSchedule(); @@ -103,10 +136,15 @@ public void testSetCheckinScheduleList() throws WxErrorException { item.setScheduleId(0); item.setDay(20); item.setUserid("12003648"); - wxCpSetCheckinSchedule.setItems(Arrays.asList(item)); + wxCpSetCheckinSchedule.setItems(Collections.singletonList(item)); wxService.getOaService().setCheckinScheduleList(wxCpSetCheckinSchedule); } + /** + * Test get checkin option. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetCheckinOption() throws WxErrorException { @@ -117,6 +155,11 @@ public void testGetCheckinOption() throws WxErrorException { System.out.println(gson.toJson(results)); } + /** + * Test get crop checkin option. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetCropCheckinOption() throws WxErrorException { @@ -127,6 +170,12 @@ public void testGetCropCheckinOption() throws WxErrorException { System.out.println(gson.toJson(results)); } + /** + * Test get approval info. + * + * @throws WxErrorException the wx error exception + * @throws ParseException the parse exception + */ @Test public void testGetApprovalInfo() throws WxErrorException, ParseException { Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-12-01"); @@ -139,6 +188,11 @@ public void testGetApprovalInfo() throws WxErrorException, ParseException { System.out.println(gson.toJson(result)); } + /** + * Test get approval detail. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetApprovalDetail() throws WxErrorException { String spNo = "201912020001"; @@ -150,25 +204,121 @@ public void testGetApprovalDetail() throws WxErrorException { System.out.println(gson.toJson(result)); } + /** + * Test get template detail. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetTemplateDetail() throws WxErrorException { String templateId = "3TkZjxugodbqpEMk9j7X6h6zKqYkc7MxQrrFmT7H"; - WxCpTemplateResult result = wxService.getOaService().getTemplateDetail(templateId); + WxCpOaApprovalTemplateResult result = wxService.getOaService().getTemplateDetail(templateId); assertThat(result).isNotNull(); System.out.println("result "); System.out.println(gson.toJson(result)); } + /** + * Test apply. + * + * @throws WxErrorException the wx error exception + */ @Test public void testApply() throws WxErrorException { this.wxService.getOaService().apply(new WxCpOaApplyEventRequest().setCreatorUserId("123")); } + /** + * 获取审批数据(旧) + * https://developer.work.weixin.qq.com/document/path/91530 + * + * @throws WxErrorException the wx error exception + */ @Test - public void testGetApprovalData() { + public void testGetApprovalData() throws WxErrorException { + + // 提示:推荐使用新接口“批量获取审批单号”及“获取审批申请详情”,此接口后续将不再维护、逐步下线。 +// WxCpGetApprovalData approvalData = this.wxService.getOaService().getApprovalData(System.currentTimeMillis(), +// System.currentTimeMillis() + 3600L, null); +// log.info("返回数据:{}", approvalData.toJson()); + + String text = "{\"errcode\":0,\"errmsg\":\"ok\",\"count\":3,\"total\":5,\"next_spnum\":201704240001," + + "\"data\":[{\"spname\":\"报销\",\"apply_name\":\"报销测试\",\"apply_org\":\"报销测试企业\",\"approval_name\":[\"审批人测试\"]," + + "\"notify_name\":[\"抄送人测试\"],\"sp_status\":1,\"sp_num\":201704200001," + + "\"mediaids\":[\"WWCISP_G8PYgRaOVHjXWUWFqchpBqqqUpGj0OyR9z6WTwhnMZGCPHxyviVstiv_2fTG8YOJq8L8zJT2T2OvTebANV-2MQ" + + "\"],\"apply_time\":1499153693,\"apply_user_id\":\"testuser\",\"expense\":{\"expense_type\":1,\"reason\":\"\"," + + "\"item\":[{\"expenseitem_type\":6,\"time\":1492617600,\"sums\":9900,\"reason\":\"\"}]}," + + "\"comm\":{\"apply_data\":\"{\\\"item-1492610773696\\\":{\\\"title\\\":\\\"abc\\\",\\\"type\\\":\\\"text\\\"," + + "\\\"value\\\":\\\"\\\"}}\"}},{\"spname\":\"请假\",\"apply_name\":\"请假测试\",\"apply_org\":\"请假测试企业\"," + + "\"approval_name\":[\"审批人测试\"],\"notify_name\":[\"抄送人测试\"],\"sp_status\":1,\"sp_num\":201704200004," + + "\"apply_time\":1499153693,\"apply_user_id\":\"testuser\",\"leave\":{\"timeunit\":0,\"leave_type\":4," + + "\"start_time\":1492099200,\"end_time\":1492790400,\"duration\":144,\"reason\":\"\"}," + + "\"comm\":{\"apply_data\":\"{\\\"item-1492610773696\\\":{\\\"title\\\":\\\"abc\\\",\\\"type\\\":\\\"text\\\"," + + "\\\"value\\\":\\\"\\\"}}\"}},{\"spname\":\"自定义审批\",\"apply_name\":\"自定义\",\"apply_org\":\"自定义测试企业\"," + + "\"approval_name\":[\"自定义审批人\"],\"notify_name\":[\"自定义抄送人\"],\"sp_status\":1,\"sp_num\":201704240001," + + "\"apply_time\":1499153693,\"apply_user_id\":\"testuser\"," + + "\"comm\":{\"apply_data\":\"{\\\"item-1492610773696\\\":{\\\"title\\\":\\\"abc\\\",\\\"type\\\":\\\"text\\\"," + + "\\\"value\\\":\\\"\\\"}}\"}}]}"; + WxCpGetApprovalData wxCpGetApprovalData = WxCpGetApprovalData.fromJson(text); + log.info("返回数据2:{}", wxCpGetApprovalData.toJson()); + } + /** + * Test get dial record. + */ @Test public void testGetDialRecord() { } + + /** + * 获取企业假期管理配置 + * https://developer.work.weixin.qq.com/document/path/93375 + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetCorpConf() throws WxErrorException { + WxCpCorpConfInfo corpConf = this.wxService.getOaService().getCorpConf(); + log.info(corpConf.toJson()); + } + + /** + * 获取成员假期余额 + * https://developer.work.weixin.qq.com/document/path/93376 + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetUserVacationQuota() throws WxErrorException { + WxCpUserVacationQuota vacationQuota = this.wxService.getOaService().getUserVacationQuota("WangKai"); + log.info(vacationQuota.toJson()); + + String text = + "{\"errcode\":0,\"errmsg\":\"ok\",\"lists\":[{\"id\":1,\"assignduration\":0,\"usedduration\":0," + + "\"leftduration\":604800,\"vacationname\":\"年假\"},{\"id\":2,\"assignduration\":0,\"usedduration\":0," + + "\"leftduration\":1296000,\"vacationname\":\"事假\"},{\"id\":3,\"assignduration\":0,\"usedduration\":0," + + "\"leftduration\":0,\"vacationname\":\"病假\"}]}"; + WxCpUserVacationQuota json = WxCpUserVacationQuota.fromJson(text); + log.info("数据为:{}", json.toJson()); + + } + + /** + * 修改成员假期余额 + * https://developer.work.weixin.qq.com/document/path/93377 + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testSetOneUserQuota() throws WxErrorException { + + String text = "{\"errcode\":0,\"errmsg\":\"ok\"}"; + WxCpBaseResp resp = WxCpBaseResp.fromJson(text); + log.info("返回结果为:{}", resp.toJson()); + +// WxCpBaseResp wxCpBaseResp = this.wxService.getOaService().setOneUserQuota(, , , , ); + + } + } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImplTest.java index 7db4564f62..bd2cd5bcca 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImplTest.java @@ -30,31 +30,57 @@ */ @Guice(modules = ApiTestModule.class) public class WxCpTagServiceImplTest { + /** + * The Wx service. + */ @Inject protected WxCpService wxService; + /** + * The Config storage. + */ @Inject protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; private String tagId; + /** + * Test create. + * + * @throws Exception the exception + */ @Test public void testCreate() throws Exception { this.tagId = this.wxService.getTagService().create("测试标签" + System.currentTimeMillis(), null); System.out.println(this.tagId); } + /** + * Test update. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = "testCreate") public void testUpdate() throws Exception { this.wxService.getTagService().update(this.tagId, "测试标签-改名" + System.currentTimeMillis()); } + /** + * Test list all. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = {"testUpdate", "testCreate"}) public void testListAll() throws Exception { List tags = this.wxService.getTagService().listAll(); assertNotEquals(tags.size(), 0); } + /** + * Test add users 2 tag. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = {"testListAll", "testUpdate", "testCreate"}) public void testAddUsers2Tag() throws Exception { List userIds = Splitter.on("|").splitToList(this.configStorage.getUserId()); @@ -62,12 +88,22 @@ public void testAddUsers2Tag() throws Exception { assertEquals(result.getErrCode(), Integer.valueOf(0)); } + /** + * Test list users by tag id. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = {"testAddUsers2Tag", "testListAll", "testUpdate", "testCreate"}) public void testListUsersByTagId() throws Exception { List users = this.wxService.getTagService().listUsersByTagId(this.tagId); assertNotEquals(users.size(), 0); } + /** + * Test remove users from tag. + * + * @throws Exception the exception + */ @Test(dependsOnMethods = {"testListUsersByTagId", "testAddUsers2Tag", "testListAll", "testUpdate", "testCreate"}) public void testRemoveUsersFromTag() throws Exception { List userIds = Splitter.on("|").splitToList(this.configStorage.getUserId()); @@ -75,16 +111,29 @@ public void testRemoveUsersFromTag() throws Exception { assertEquals(result.getErrCode(), Integer.valueOf(0)); } - @Test(dependsOnMethods = {"testRemoveUsersFromTag", "testListUsersByTagId", "testAddUsers2Tag", "testListAll", "testUpdate", "testCreate"}) + /** + * Test delete. + * + * @throws Exception the exception + */ + @Test(dependsOnMethods = {"testRemoveUsersFromTag", "testListUsersByTagId", "testAddUsers2Tag", "testListAll", + "testUpdate", "testCreate"}) public void testDelete() throws Exception { this.wxService.getTagService().delete(this.tagId); } + /** + * Test get. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGet() throws WxErrorException { - String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": \"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}"; + String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": " + + "\"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}"; WxCpService wxService = mock(WxCpService.class); - when(wxService.get(String.format(wxService.getWxCpConfigStorage().getApiUrl(WxCpApiPathConsts.Tag.TAG_GET), 150), null)).thenReturn(apiResultJson); + when(wxService.get(String.format(wxService.getWxCpConfigStorage().getApiUrl(WxCpApiPathConsts.Tag.TAG_GET), 150), + null)).thenReturn(apiResultJson); when(wxService.getTagService()).thenReturn(new WxCpTagServiceImpl(wxService)); WxCpTagService wxCpTagService = wxService.getTagService(); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImplTest.java index 1bdcb9e244..0d92038933 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImplTest.java @@ -17,8 +17,7 @@ /** * 测试任务卡片服务 * - * @author Jeff - * @date 2019-05-16 + * @author Jeff created on 2019-05-16 */ @Guice(modules = ApiTestModule.class) public class WxCpTaskCardServiceImplTest { @@ -26,6 +25,11 @@ public class WxCpTaskCardServiceImplTest { @Inject private WxCpService wxCpService; + /** + * Test send task card. + * + * @throws WxErrorException the wx error exception + */ @Test public void testSendTaskCard() throws WxErrorException { TaskCardButton btn1 = TaskCardButton.builder() @@ -57,6 +61,11 @@ public void testSendTaskCard() throws WxErrorException { System.out.println(messageSendResult.getInvalidTagList()); } + /** + * Test update. + * + * @throws Exception the exception + */ @Test public void testUpdate() throws Exception { wxCpService.getTaskCardService().update(Arrays.asList("jeff", "mr.t"), "task_1", "key1"); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImplTest.java index 9c4448830e..73282c16f7 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImplTest.java @@ -1,22 +1,26 @@ package me.chanjar.weixin.cp.api.impl; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.testng.annotations.*; - import com.google.common.collect.Lists; import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.Gender; import me.chanjar.weixin.cp.bean.WxCpInviteResult; import me.chanjar.weixin.cp.bean.WxCpUser; +import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.Date; +import java.util.List; +import java.util.Map; -import static org.testng.Assert.*; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertNotNull; /** *
@@ -25,17 +29,28 @@
  *
  * @author Binary Wang
  */
+@Slf4j
 @Guice(modules = ApiTestModule.class)
 public class WxCpUserServiceImplTest {
   @Inject
   private WxCpService wxCpService;
-  private String userId = "someone" + System.currentTimeMillis();
+  private final String userId = "someone" + System.currentTimeMillis();
 
+  /**
+   * Test authenticate.
+   *
+   * @throws Exception the exception
+   */
   @Test
   public void testAuthenticate() throws Exception {
     this.wxCpService.getUserService().authenticate("abc");
   }
 
+  /**
+   * Test create.
+   *
+   * @throws Exception the exception
+   */
   @Test
   public void testCreate() throws Exception {
     WxCpUser user = new WxCpUser();
@@ -51,6 +66,11 @@ public void testCreate() throws Exception {
     this.wxCpService.getUserService().create(user);
   }
 
+  /**
+   * Test update.
+   *
+   * @throws Exception the exception
+   */
   @Test(dependsOnMethods = "testCreate")
   public void testUpdate() throws Exception {
     WxCpUser user = new WxCpUser();
@@ -60,17 +80,32 @@ public void testUpdate() throws Exception {
     this.wxCpService.getUserService().update(user);
   }
 
+  /**
+   * Test delete.
+   *
+   * @throws Exception the exception
+   */
   @Test(dependsOnMethods = {"testCreate", "testUpdate"})
   public void testDelete() throws Exception {
     this.wxCpService.getUserService().delete(userId);
   }
 
+  /**
+   * Test get by id.
+   *
+   * @throws Exception the exception
+   */
   @Test(dependsOnMethods = "testUpdate")
   public void testGetById() throws Exception {
     WxCpUser user = this.wxCpService.getUserService().getById(userId);
     assertNotNull(user);
   }
 
+  /**
+   * Test list by department.
+   *
+   * @throws Exception the exception
+   */
   @Test
   public void testListByDepartment() throws Exception {
     List users = this.wxCpService.getUserService().listByDepartment(2L, true, 0);
@@ -80,6 +115,11 @@ public void testListByDepartment() throws Exception {
     }
   }
 
+  /**
+   * Test list simple by department.
+   *
+   * @throws Exception the exception
+   */
   @Test
   public void testListSimpleByDepartment() throws Exception {
     List users = this.wxCpService.getUserService().listSimpleByDepartment(1L, true, 0);
@@ -89,6 +129,11 @@ public void testListSimpleByDepartment() throws Exception {
     }
   }
 
+  /**
+   * Test invite.
+   *
+   * @throws Exception the exception
+   */
   @Test
   public void testInvite() throws Exception {
     WxCpInviteResult result = this.wxCpService.getUserService().invite(
@@ -96,6 +141,11 @@ public void testInvite() throws Exception {
     System.out.println(result);
   }
 
+  /**
+   * Test user id 2 openid.
+   *
+   * @throws Exception the exception
+   */
   @Test
   public void testUserId2Openid() throws Exception {
     Map result = this.wxCpService.getUserService().userId2Openid(userId, null);
@@ -103,6 +153,11 @@ public void testUserId2Openid() throws Exception {
     assertNotNull(result);
   }
 
+  /**
+   * Test openid 2 user id.
+   *
+   * @throws Exception the exception
+   */
   @Test
   public void testOpenid2UserId() throws Exception {
     String result = this.wxCpService.getUserService().openid2UserId(userId);
@@ -111,6 +166,11 @@ public void testOpenid2UserId() throws Exception {
   }
 
 
+  /**
+   * Test get user id.
+   *
+   * @throws WxErrorException the wx error exception
+   */
   @Test
   public void testGetUserId() throws WxErrorException {
     String result = this.wxCpService.getUserService().getUserId("xxx");
@@ -118,7 +178,50 @@ public void testGetUserId() throws WxErrorException {
     assertNotNull(result);
   }
 
+  /**
+   * Test get user id by email.
+   *
+   * @throws WxErrorException the wx error exception
+   */
+  @Test
+  public void testGetUserIdByEmail() throws WxErrorException {
+    String result = this.wxCpService.getUserService().getUserIdByEmail("xxx",1);
+    System.out.println(result);
+    assertNotNull(result);
+  }
+
+  /**
+   * Test get external contact.
+   */
   @Test
   public void testGetExternalContact() {
   }
+
+  /**
+   * Test get active stat.
+   *
+   * @throws WxErrorException the wx error exception
+   */
+  @Test
+  public void testGetActiveStat() throws WxErrorException {
+    Integer activeStat = this.wxCpService.getUserService().getActiveStat(new Date());
+    System.out.printf("active stat: %d", activeStat);
+    assertNotNull(activeStat);
+  }
+
+  /**
+   * 获取成员ID列表
+   * 获取企业成员的userid与对应的部门ID列表,预计于2022年8月8号发布。若需要获取其他字段,参见「适配建议」。
+   * 

+ * https://developer.work.weixin.qq.com/document/40856 + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetUserListId() throws WxErrorException { + WxCpDeptUserResult result = this.wxCpService.getUserService().getUserListId(null, 10); + log.info("返回结果为:{}", result.toJson()); + assertNotNull(result); + } + } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpAgentTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpAgentTest.java index 9f187e43aa..a3410b16b0 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpAgentTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpAgentTest.java @@ -1,7 +1,7 @@ package me.chanjar.weixin.cp.bean; -import org.testng.*; -import org.testng.annotations.*; +import org.testng.Assert; +import org.testng.annotations.Test; /** * Created by huansinho on 2018/4/13. @@ -9,6 +9,9 @@ @Test public class WxCpAgentTest { + /** + * Test deserialize. + */ public void testDeserialize() { String json = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\"," + "\"square_logo_url\": \"http://wx.qlogo.cn/mmhead/alksjf;lasdjf;lasjfuodiuj3rj2o34j/0\"," + diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackageTest.java index 5a54bfd8af..60e8a850f0 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpTpXmlPackageTest.java @@ -7,11 +7,13 @@ /** * . * - * @author Binary Wang - * @date 2019-08-18 + * @author Binary Wang created on 2019-08-18 */ public class WxCpTpXmlPackageTest { + /** + * Test from xml. + */ @Test public void testFromXml() { WxCpTpXmlPackage result = WxCpTpXmlPackage.fromXml(" \n" + diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequestTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequestTest.java index 9564cdf9bc..1e533a7436 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequestTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequestTest.java @@ -8,11 +8,13 @@ /** * 单元测试. * - * @author Binary Wang - * @date 2020-09-20 + * @author Binary Wang created on 2020-09-20 */ public class WxCpUpdateRemarkRequestTest { + /** + * Test to json. + */ @Test public void testToJson() { String json = "{\n" + @@ -34,7 +36,7 @@ public void testToJson() { .externalUserId("woAJ2GCAAAd1asdasdjO4wKmE8Aabj9AAA") .remark("备注信息") .remarkCompany("腾讯科技") - .remarkMobiles(new String[]{"13800000001","13800000002"}) + .remarkMobiles(new String[]{"13800000001", "13800000002"}) .remarkPicMediaId("MEDIAID") .build(); assertThat(request.toJson()).isEqualTo(GsonParser.parse(json).toString()); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactInfoTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactInfoTest.java index c666c1b94d..5ade6bd098 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactInfoTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalContactInfoTest.java @@ -1,9 +1,14 @@ package me.chanjar.weixin.cp.bean.external; +import com.google.gson.reflect.TypeToken; +import lombok.val; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.bean.WxCpDepart; import me.chanjar.weixin.cp.bean.external.contact.ExternalContact; import me.chanjar.weixin.cp.bean.external.contact.FollowedUser; import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; -import org.testng.annotations.*; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.testng.annotations.Test; import java.util.List; @@ -19,6 +24,9 @@ */ public class WxCpUserExternalContactInfoTest { + /** + * Test from json. + */ @Test public void testFromJson() { final String json = "{\n" + @@ -68,7 +76,11 @@ public void testFromJson() { " \"userid\": \"rocky\",\n" + " \"remark\": \"李部长\",\n" + " \"description\": \"对接采购事物\",\n" + - " \"createtime\": 1525779812\n" + + " \"createtime\": 1525779812,\n" + + " \"wechat_channels\": {\n" + + " \"nickname\": \"视频号名称\",\n" + + " \"source\": 1\n" + + " }" + " },\n" + " {\n" + " \"userid\": \"tommy\",\n" + @@ -79,13 +91,53 @@ public void testFromJson() { " ]\n" + "}"; + final String testJson = "{\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"department\": [\n" + + " {\n" + + " \"id\": 2,\n" + + " \"name\": \"广州研发中心\",\n" + + " \"name_en\": \"RDGZ\",\n" + + " \"department_leader\":[\"zhangsan\",\"lisi\"],\n" + + " \"parentid\": 1,\n" + + " \"order\": 10\n" + + " },\n" + + " {\n" + + " \"id\": 3,\n" + + " \"name\": \"邮箱产品部\",\n" + + " \"name_en\": \"mail\",\n" + + " \"department_leader\":[\"lisi\",\"wangwu\"],\n" + + " \"parentid\": 2,\n" + + " \"order\": 40\n" + + " }\n" + + " ]\n" + + "}\n"; + + // 测试序列化 + val depart = new WxCpDepart(); + depart.setId(8L); + depart.setName("name"); + depart.setEnName("enName"); + depart.setDepartmentLeader(new String[]{"zhangsan", "lisi"}); + depart.setParentId(88L); + depart.setOrder(99L); + + String toJson = depart.toJson(); + + // 测试企业微信字段返回 + List department = WxCpGsonBuilder.create().fromJson(GsonParser.parse(testJson).get("department"), + new TypeToken>() { + }.getType()); + final WxCpExternalContactInfo contactInfo = WxCpExternalContactInfo.fromJson(json); assertThat(contactInfo).isNotNull(); assertThat(contactInfo.getExternalContact()).isNotNull(); assertThat(contactInfo.getExternalContact().getExternalUserId()).isEqualTo("woAJ2GCAAAXtWyujaWJHDDGi0mACH71w"); assertThat(contactInfo.getExternalContact().getPosition()).isEqualTo("Mangaer"); - assertThat(contactInfo.getExternalContact().getAvatar()).isEqualTo("http://p.qlogo.cn/bizmail/IcsdgagqefergqerhewSdage/0"); + assertThat(contactInfo.getExternalContact().getAvatar()).isEqualTo("http://p.qlogo" + + ".cn/bizmail/IcsdgagqefergqerhewSdage/0"); assertThat(contactInfo.getExternalContact().getCorpName()).isEqualTo("腾讯"); assertThat(contactInfo.getExternalContact().getCorpFullName()).isEqualTo("腾讯科技有限公司"); assertThat(contactInfo.getExternalContact().getType()).isEqualTo(2); @@ -95,7 +147,8 @@ public void testFromJson() { assertThat(contactInfo.getExternalContact().getExternalProfile()).isNotNull(); - final List externalAttrs = contactInfo.getExternalContact().getExternalProfile().getExternalAttrs(); + final List externalAttrs = + contactInfo.getExternalContact().getExternalProfile().getExternalAttrs(); assertThat(externalAttrs).isNotEmpty(); final ExternalContact.ExternalAttribute externalAttr1 = externalAttrs.get(0); @@ -123,6 +176,8 @@ public void testFromJson() { assertThat(followedUsers.get(0).getRemark()).isEqualTo("李部长"); assertThat(followedUsers.get(0).getDescription()).isEqualTo("对接采购事物"); assertThat(followedUsers.get(0).getCreateTime()).isEqualTo(1525779812); + assertThat(followedUsers.get(0).getWechatChannels().getNickname()).isEqualTo("视频号名称"); + assertThat(followedUsers.get(0).getWechatChannels().getSource()).isEqualTo(1); assertThat(followedUsers.get(1).getUserId()).isEqualTo("tommy"); assertThat(followedUsers.get(1).getRemark()).isEqualTo("李总"); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResultTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResultTest.java new file mode 100644 index 0000000000..0c4bf97b33 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResultTest.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.cp.bean.external.contact; + +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The type Wx cp group msg result test. + */ +public class WxCpGroupMsgResultTest { + + /** + * Test to json. + */ + @Test + public void testToJson() { + /* + @see https://work.weixin.qq.com/api/doc/16251 + */ + String json = "{ " + + "\"errcode\": 0, " + + "\"errmsg\": \"ok\", " + + "\"detail_list\": [ " + + " { " + + " \"external_userid\": \"wmqfasd1e19278asdasAAAA\", " + + " \"chat_id\":\"wrOgQhDgAAMYQiS5ol9G7gK9JVAAAA\", " + + " \"userid\": \"zhangsan\", " + + " \"status\": 1, " + + " \"send_time\": 1552536375 " + + " } " + + " ] " + + "}"; + + WxCpGroupMsgResult result = WxCpGroupMsgResult.fromJson(json); + assertThat(result.getDetailList().size()).isEqualTo(1); + WxCpGroupMsgResult.ExternalContactGroupMsgDetailInfo detail = result.getDetailList().get(0); + assertThat(detail.getChatId()).isEqualTo("wrOgQhDgAAMYQiS5ol9G7gK9JVAAAA"); + assertThat(detail.getExternalUserId()).isEqualTo("wmqfasd1e19278asdasAAAA"); + assertThat(detail.getUserId()).isEqualTo("zhangsan"); + assertThat(detail.getStatus()).isEqualTo(1); + assertThat(detail.getSendTime()).isEqualTo(1552536375L); + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java index d692d0fc99..cab57e1510 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java @@ -2,23 +2,24 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import me.chanjar.weixin.cp.bean.article.NewArticle; import org.testng.annotations.Test; -import static me.chanjar.weixin.common.api.WxConsts.*; +import static me.chanjar.weixin.common.api.WxConsts.KefuMsgType; import static org.assertj.core.api.Assertions.assertThat; /** * 测试用例中的json参考 https://work.weixin.qq.com/api/doc/90000/90135/90250 * - * @author Binary Wang - * @date 2020-08-30 + * @author Binary Wang created on 2020-08-30 */ public class WxCpLinkedCorpMessageTest { + /** + * Test to json text. + */ @Test public void testToJson_text() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -41,7 +42,8 @@ public void testToJson_text() { " \"msgtype\" : \"text\",\n" + " \"agentid\" : 1,\n" + " \"text\" : {\n" + - " \"content\" : \"你的快递已到,请携带工卡前往邮件中心领取。\\n出发前可查看邮件中心视频实况,聪明避开排队。\"\n" + + " \"content\" : \"你的快递已到,请携带工卡前往邮件中心领取。\\n出发前可查看邮件中心视频实况,聪明避开排队。\"\n" + " },\n" + " \"safe\":0\n" + "}"; @@ -49,6 +51,9 @@ public void testToJson_text() { assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); } + /** + * Test to json image. + */ @Test public void testToJson_image() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -79,6 +84,9 @@ public void testToJson_image() { assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); } + /** + * Test to json video. + */ @Test public void testToJson_video() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -113,6 +121,9 @@ public void testToJson_video() { assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); } + /** + * Test to json file. + */ @Test public void testToJson_file() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -143,6 +154,9 @@ public void testToJson_file() { assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); } + /** + * Test to json text card. + */ @Test public void testToJson_textCard() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -153,7 +167,8 @@ public void testToJson_textCard() { .agentId(1) .isToAll(false) .title("领奖通知") - .description("

2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
") + .description("
2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
") .url("URL") .btnTxt("更多") .build(); @@ -168,7 +183,8 @@ public void testToJson_textCard() { " \"agentid\" : 1,\n" + " \"textcard\" : {\n" + " \"title\" : \"领奖通知\",\n" + - " \"description\" : \"
2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
\",\n" + + " \"description\" : \"
2016年9月26日
恭喜你抽中iPhone" + + " 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
\",\n" + " \"url\" : \"URL\",\n" + " \"btntxt\":\"更多\"\n" + " }\n" + @@ -177,6 +193,9 @@ public void testToJson_textCard() { assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); } + /** + * Test to json news. + */ @Test public void testToJson_news() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -209,7 +228,8 @@ public void testToJson_news() { " \"title\" : \"中秋节礼品领取\",\n" + " \"description\" : \"今年中秋节公司有豪礼相送\",\n" + " \"url\" : \"URL\",\n" + - " \"picurl\" : \"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png\",\n" + + " \"picurl\" : \"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1" + + ".png\",\n" + " \"btntxt\":\"更多\"\n" + " }\n" + " ]\n" + @@ -220,6 +240,9 @@ public void testToJson_news() { } + /** + * Test to json mpnews. + */ @Test public void testToJson_mpnews() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -266,6 +289,9 @@ public void testToJson_mpnews() { assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); } + /** + * Test to json markdown. + */ @Test public void testToJson_markdown() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -318,6 +344,9 @@ public void testToJson_markdown() { assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); } + /** + * Test to json mini program notice. + */ @Test public void testToJson_miniProgramNotice() { WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder() @@ -330,10 +359,10 @@ public void testToJson_miniProgramNotice() { .title("会议室预订成功通知") .appId("wx123123123123123") .page("pages/index?userid=zhangsan&orderid=123123123") - .contentItems(ImmutableMap.of("会议室","402", - "会议地点","广州TIT-402会议室", - "会议时间","2018年8月1日 09:00-09:30", - "参与人员","周剑轩")) + .contentItems(ImmutableMap.of("会议室", "402", + "会议地点", "广州TIT-402会议室", + "会议时间", "2018年8月1日 09:00-09:30", + "参与人员", "周剑轩")) .build(); final String json = message.toJson(); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java index 3f7859116e..9d6210b460 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java @@ -1,24 +1,34 @@ package me.chanjar.weixin.cp.bean.message; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import me.chanjar.weixin.cp.bean.article.NewArticle; -import me.chanjar.weixin.cp.bean.message.WxCpMessage; import me.chanjar.weixin.cp.bean.taskcard.TaskCardButton; +import me.chanjar.weixin.cp.bean.templatecard.*; import org.testng.annotations.Test; import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; +/** + * The type Wx cp message test. + */ @Test public class WxCpMessageTest { + /** + * Test text build. + */ public void testTextBuild() { WxCpMessage reply = WxCpMessage.TEXT().toUser("OPENID").content("sfsfdsdf").build(); assertThat(reply.toJson()) .isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"},\"safe\":\"0\"}"); } + /** + * Test text card build. + */ public void testTextCardBuild() { WxCpMessage reply = WxCpMessage.TEXTCARD().toUser("OPENID") .title("领奖通知") @@ -34,18 +44,27 @@ public void testTextCardBuild() { "\"url\":\"http://www.qq.com\",\"btntxt\":\"更多\"},\"safe\":\"0\"}"); } + /** + * Test image build. + */ public void testImageBuild() { WxCpMessage reply = WxCpMessage.IMAGE().toUser("OPENID").mediaId("MEDIA_ID").build(); assertThat(reply.toJson()) .isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"},\"safe\":\"0\"}"); } + /** + * Test voice build. + */ public void testVoiceBuild() { WxCpMessage reply = WxCpMessage.VOICE().toUser("OPENID").mediaId("MEDIA_ID").build(); assertThat(reply.toJson()) .isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"},\"safe\":\"0\"}"); } + /** + * Test video build. + */ public void testVideoBuild() { WxCpMessage reply = WxCpMessage.VIDEO().toUser("OPENID").title("TITLE").mediaId("MEDIA_ID").thumbMediaId("MEDIA_ID") .description("DESCRIPTION").build(); @@ -54,6 +73,9 @@ public void testVideoBuild() { "\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"},\"safe\":\"0\"}"); } + /** + * Test news build. + */ public void testNewsBuild() { NewArticle article1 = new NewArticle(); article1.setUrl("URL"); @@ -72,10 +94,14 @@ public void testNewsBuild() { assertThat(reply.toJson()) .isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":" + "[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}," + - "{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}," + + "{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\"," + + "\"picurl\":\"PIC_URL\"}]}," + "\"safe\":\"0\"}"); } + /** + * Test mpnews build with articles. + */ public void testMpnewsBuild_with_articles() { MpnewsArticle article1 = MpnewsArticle.newBuilder() .title("Happy Day") @@ -102,12 +128,17 @@ public void testMpnewsBuild_with_articles() { assertThat(reply.toJson()) .isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"mpnews\",\"mpnews\":{\"articles\":" + "[{\"title\":\"Happy Day\",\"thumb_media_id\":\"thumb\",\"author\":\"aaaaaa\"," + - "\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\",\"show_cover_pic\":\"heihei\"}" + + "\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\"," + + "\"show_cover_pic\":\"heihei\"}" + ",{\"title\":\"Happy Day\",\"thumb_media_id\":\"thumb\",\"author\":\"aaaaaa\"," + - "\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\",\"show_cover_pic\":\"heihei\"}]}," + + "\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\"," + + "\"show_cover_pic\":\"heihei\"}]}," + "\"safe\":\"0\"}"); } + /** + * Test mpnews build with media id. + */ public void testMpnewsBuild_with_media_id() { WxCpMessage reply = WxCpMessage.MPNEWS().toUser("OPENID").mediaId("mmm").build(); @@ -115,6 +146,9 @@ public void testMpnewsBuild_with_media_id() { .isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"mpnews\",\"mpnews\":{\"media_id\":\"mmm\"},\"safe\":\"0\"}"); } + /** + * Test task card builder. + */ public void testTaskCardBuilder() { TaskCardButton button1 = TaskCardButton.builder() .key("yes") @@ -138,7 +172,369 @@ public void testTaskCardBuilder() { .buttons(Arrays.asList(button1, button2)) .build(); assertThat(reply.toJson()) - .isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"taskcard\",\"taskcard\":{\"title\":\"任务卡片\",\"description\":\"有一条待处理任务\",\"url\":\"http://www.qq.com\",\"task_id\":\"task_123\",\"btn\":[{\"key\":\"yes\",\"name\":\"批准\",\"replace_name\":\"已批准\",\"color\":\"blue\",\"is_bold\":true},{\"key\":\"yes\",\"name\":\"拒绝\",\"replace_name\":\"已拒绝\",\"color\":\"red\",\"is_bold\":false}]}}"); + .isEqualTo( + "{\"touser\":\"OPENID\",\"msgtype\":\"taskcard\",\"taskcard\":{\"title\":\"任务卡片\"," + + "\"description\":\"有一条待处理任务\",\"url\":\"http://www.qq.com\",\"task_id\":\"task_123\"," + + "\"btn\":[{\"key\":\"yes\",\"name\":\"批准\",\"replace_name\":\"已批准\",\"color\":\"blue\",\"is_bold\":true}," + + "{\"key\":\"yes\",\"name\":\"拒绝\",\"replace_name\":\"已拒绝\",\"color\":\"red\",\"is_bold\":false}]}}"); + } + + /** + * 测试模板卡片消息 + * 文本通知型 + */ + public void TestTemplateCardBuilder_text_notice() { + + HorizontalContent hContent1 = HorizontalContent.builder() + .keyname("邀请人") + .value("张三") + .build(); + HorizontalContent hContent2 = HorizontalContent.builder() + .type(1) + .keyname("企业微信官网") + .value("点击访问") + .url("https://work.weixin.qq.com") + .build(); + HorizontalContent hContent3 = HorizontalContent.builder() + .type(2) + .keyname("企业微信下载") + .value("企业微信.apk") + .media_id("文件的media_id") + .build(); + HorizontalContent hContent4 = HorizontalContent.builder() + .type(3) + .keyname("员工信息") + .value("点击查看") + .userid("zhangsan") + .build(); + + TemplateCardJump jump1 = TemplateCardJump.builder() + .type(1) + .title("企业微信官网") + .url("https://work.weixin.qq.com") + .build(); + TemplateCardJump jump2 = TemplateCardJump.builder() + .type(2) + .title("跳转小程序") + .appid("小程序的appid") + .pagepath("/index.html") + .build(); + QuoteArea quoteArea = QuoteArea.builder() + .type(1) + .title("引用文献标题") + .appid("小程序的appid") + .pagepath("/index.html") + .url("https://work.weixin.qq.com") + .quoteText("引用文献样式的引用文案") + .build(); + ActionMenuItem action1 = ActionMenuItem.builder() + .text("接受推送") + .key("A") + .build(); + ActionMenuItem action2 = ActionMenuItem.builder() + .text("不再推送") + .key("B") + .build(); + WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") + .toParty("PartyID1 | PartyID2") + .toTag("TagID1 | TagID2") + .agentId(1000002) + .cardType(WxConsts.TemplateCardType.TEXT_NOTICE) + .taskId("task_id") + .sourceIconUrl("图片的url") + .sourceDesc("企业微信") + .sourceDescColor(1) + .actionMenuDesc("卡片副交互辅助文本说明") + .actionMenuActionList(Arrays.asList(action1, action2)) + .mainTitleTitle("欢迎使用企业微信") + .mainTitleDesc("您的好友正在邀请您加入企业微信") + .emphasisContentTitle("100") + .emphasisContentDesc("核心数据") + .subTitleText("下载企业微信还能抢红包!") + .horizontalContents(Arrays.asList(hContent1, hContent2, hContent3, hContent4)) + .jumps(Arrays.asList(jump1, jump2)) + .cardActionType(2) + .cardActionAppid("小程序的appid") + .cardActionUrl("https://work.weixin.qq.com") + .cardActionPagepath("/index.html") + .quoteArea(quoteArea) + .build(); + reply.setEnableIdTrans(false); + reply.setEnableDuplicateCheck(false); + reply.setDuplicateCheckInterval(1800); +// System.out.println(reply.toJson()); + assertThat(reply.toJson()) + .isEqualTo( + "{\"agentid\":1000002,\"touser\":\"OPENID\",\"msgtype\":\"template_card\",\"toparty\":\"PartyID1 | " + + "PartyID2\",\"totag\":\"TagID1 | TagID2\",\"duplicate_check_interval\":1800," + + "\"template_card\":{\"card_type\":\"text_notice\",\"source\":{\"icon_url\":\"图片的url\",\"desc\":\"企业微信\"," + + "\"desc_color\":1},\"action_menu\":{\"desc\":\"卡片副交互辅助文本说明\",\"action_list\":[{\"text\":\"接受推送\"," + + "\"key\":\"A\"},{\"text\":\"不再推送\",\"key\":\"B\"}]},\"main_title\":{\"title\":\"欢迎使用企业微信\"," + + "\"desc\":\"您的好友正在邀请您加入企业微信\"},\"emphasis_content\":{\"title\":\"100\",\"desc\":\"核心数据\"}," + + "\"sub_title_text\":\"下载企业微信还能抢红包!\",\"task_id\":\"task_id\"," + + "\"horizontal_content_list\":[{\"keyname\":\"邀请人\",\"value\":\"张三\"},{\"type\":1,\"keyname\":\"企业微信官网\"," + + "\"value\":\"点击访问\",\"url\":\"https://work.weixin.qq.com\"},{\"type\":2,\"keyname\":\"企业微信下载\"," + + "\"value\":\"企业微信.apk\",\"media_id\":\"文件的media_id\"},{\"type\":3,\"keyname\":\"员工信息\",\"value\":\"点击查看\"," + + "\"userid\":\"zhangsan\"}],\"jump_list\":[{\"type\":1,\"title\":\"企业微信官网\",\"url\":\"https://work.weixin.qq" + + ".com\"},{\"type\":2,\"title\":\"跳转小程序\",\"appid\":\"小程序的appid\",\"pagepath\":\"/index.html\"}]," + + "\"card_action\":{\"type\":2,\"url\":\"https://work.weixin.qq.com\",\"appid\":\"小程序的appid\"," + + "\"pagepath\":\"/index.html\"},\"quote_area\":{\"type\":1,\"url\":\"https://work.weixin.qq.com\"," + + "\"appid\":\"小程序的appid\",\"pagepath\":\"/index.html\",\"title\":\"引用文献标题\"," + + "\"quote_text\":\"引用文献样式的引用文案\"}}}"); + } + + /** + * 测试模板卡片消息 + * 图文展示型 + */ + public void TestTemplateCardBuilder_news_notice() { + + VerticalContent vContent1 = VerticalContent.builder() + .title("惊喜红包等你来拿") + .desc("下载企业微信还能抢红包!") + .build(); + VerticalContent vContent2 = VerticalContent.builder() + .title("二级垂直内容") + .desc("二级垂直内容!") + .build(); + + HorizontalContent hContent1 = HorizontalContent.builder() + .keyname("邀请人") + .value("张三") + .build(); + HorizontalContent hContent2 = HorizontalContent.builder() + .type(1) + .keyname("企业微信官网") + .value("点击访问") + .url("https://work.weixin.qq.com") + .build(); + HorizontalContent hContent3 = HorizontalContent.builder() + .type(2) + .keyname("企业微信下载") + .value("企业微信.apk") + .media_id("文件的media_id") + .build(); + + TemplateCardJump jump1 = TemplateCardJump.builder() + .type(1) + .title("企业微信官网") + .url("https://work.weixin.qq.com") + .build(); + TemplateCardJump jump2 = TemplateCardJump.builder() + .type(2) + .title("跳转小程序") + .appid("小程序的appid") + .pagepath("/index.html") + .build(); + + WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") + .agentId(1000002) + .cardType(WxConsts.TemplateCardType.NEWS_NOTICE) + .sourceIconUrl("图片的url") + .sourceDesc("企业微信") + .mainTitleTitle("欢迎使用企业微信") + .mainTitleDesc("您的好友正在邀请您加入企业微信") + .verticalContents(Arrays.asList(vContent1, vContent2)) + .horizontalContents(Arrays.asList(hContent1, hContent2, hContent3)) + .jumps(Arrays.asList(jump1, jump2)) + .cardActionType(2) + .cardActionAppid("小程序的appid") + .cardActionUrl("https://work.weixin.qq.com") + .cardActionPagepath("/index.html") + .build(); + reply.setEnableIdTrans(false); + reply.setEnableDuplicateCheck(false); + reply.setDuplicateCheckInterval(1800); + System.out.println(reply.toJson()); + assertThat(reply.toJson()) + .isEqualTo( + "{\"agentid\":1000002,\"touser\":\"OPENID\",\"msgtype\":\"template_card\",\"duplicate_check_interval\":1800," + + "\"template_card\":{\"card_type\":\"news_notice\",\"source\":{\"icon_url\":\"图片的url\",\"desc\":\"企业微信\"}," + + "\"main_title\":{\"title\":\"欢迎使用企业微信\",\"desc\":\"您的好友正在邀请您加入企业微信\"}," + + "\"vertical_content_list\":[{\"title\":\"惊喜红包等你来拿\",\"desc\":\"下载企业微信还能抢红包!\"},{\"title\":\"二级垂直内容\"," + + "\"desc\":\"二级垂直内容!\"}],\"horizontal_content_list\":[{\"keyname\":\"邀请人\",\"value\":\"张三\"},{\"type\":1," + + "\"keyname\":\"企业微信官网\",\"value\":\"点击访问\",\"url\":\"https://work.weixin.qq.com\"},{\"type\":2," + + "\"keyname\":\"企业微信下载\",\"value\":\"企业微信.apk\",\"media_id\":\"文件的media_id\"}],\"jump_list\":[{\"type\":1," + + "\"title\":\"企业微信官网\",\"url\":\"https://work.weixin.qq.com\"},{\"type\":2,\"title\":\"跳转小程序\"," + + "\"appid\":\"小程序的appid\",\"pagepath\":\"/index.html\"}],\"card_action\":{\"type\":2,\"url\":\"https://work" + + ".weixin.qq.com\",\"appid\":\"小程序的appid\",\"pagepath\":\"/index.html\"}}}"); + } + + /** + * 测试模板卡片消息 + * 按钮交互型 + */ + public void TestTemplateCardBuilder_button_interaction() { + + TemplateCardButton tButton1 = TemplateCardButton.builder() + .text("按钮1") + .style(1) + .key("button_key_1") + .build(); + TemplateCardButton tButton2 = TemplateCardButton.builder() + .text("按钮2") + .style(2) + .key("button_key_2") + .build(); + + HorizontalContent hContent1 = HorizontalContent.builder() + .keyname("邀请人") + .value("张三") + .build(); + HorizontalContent hContent2 = HorizontalContent.builder() + .type(1) + .keyname("企业微信官网") + .value("点击访问") + .url("https://work.weixin.qq.com") + .build(); + HorizontalContent hContent3 = HorizontalContent.builder() + .type(2) + .keyname("企业微信下载") + .value("企业微信.apk") + .media_id("文件的media_id") + .build(); + + WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") + .agentId(1000002) + .cardType(WxConsts.TemplateCardType.BUTTON_INTERACTION) + .sourceIconUrl("图片的url") + .sourceDesc("企业微信") + .mainTitleTitle("欢迎使用企业微信") + .mainTitleDesc("您的好友正在邀请您加入企业微信") + .subTitleText("下载企业微信还能抢红包!") + .horizontalContents(Arrays.asList(hContent1, hContent2, hContent3)) + .cardActionType(2) + .cardActionAppid("小程序的appid") + .cardActionUrl("https://work.weixin.qq.com") + .cardActionPagepath("/index.html") + .taskId("task_id") + .buttons(Arrays.asList(tButton1, tButton2)) + .build(); + reply.setEnableIdTrans(false); + reply.setEnableDuplicateCheck(false); + reply.setDuplicateCheckInterval(1800); + System.out.println(reply.toJson()); + assertThat(reply.toJson()) + .isEqualTo( + "{\"agentid\":1000002,\"touser\":\"OPENID\",\"msgtype\":\"template_card\",\"duplicate_check_interval\":1800," + + "\"template_card\":{\"card_type\":\"button_interaction\",\"source\":{\"icon_url\":\"图片的url\"," + + "\"desc\":\"企业微信\"},\"main_title\":{\"title\":\"欢迎使用企业微信\",\"desc\":\"您的好友正在邀请您加入企业微信\"}," + + "\"sub_title_text\":\"下载企业微信还能抢红包!\",\"task_id\":\"task_id\"," + + "\"horizontal_content_list\":[{\"keyname\":\"邀请人\",\"value\":\"张三\"},{\"type\":1,\"keyname\":\"企业微信官网\"," + + "\"value\":\"点击访问\",\"url\":\"https://work.weixin.qq.com\"},{\"type\":2,\"keyname\":\"企业微信下载\"," + + "\"value\":\"企业微信.apk\",\"media_id\":\"文件的media_id\"}],\"card_action\":{\"type\":2,\"url\":\"https://work" + + ".weixin.qq.com\",\"appid\":\"小程序的appid\",\"pagepath\":\"/index.html\"},\"button_list\":[{\"text\":\"按钮1\"," + + "\"style\":1,\"key\":\"button_key_1\"},{\"text\":\"按钮2\",\"style\":2,\"key\":\"button_key_2\"}]}}"); + } + + /** + * 测试模板卡片消息 + * 投票选择型 + */ + public void TestTemplateCardBuilder_vote_interaction() { + CheckboxOption option1 = CheckboxOption.builder() + .id("option_id1") + .text("选择题选项1") + .is_checked(true) + .build(); + CheckboxOption option2 = CheckboxOption.builder() + .id("option_id2") + .text("选择题选项2") + .is_checked(false) + .build(); + + WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") + .agentId(1000002) + .cardType(WxConsts.TemplateCardType.VOTE_INTERACTION) + .sourceIconUrl("图片的url") + .sourceDesc("企业微信") + .mainTitleTitle("欢迎使用企业微信") + .mainTitleDesc("您的好友正在邀请您加入企业微信") + .taskId("task_id") + .checkboxQuestionKey("question_key1") + .checkboxMode(1) + .options(Arrays.asList(option1, option2)) + .submitButtonKey("key") + .submitButtonText("提交") + .build(); + + reply.setEnableIdTrans(false); + reply.setEnableDuplicateCheck(false); + reply.setDuplicateCheckInterval(1800); + System.out.println(reply.toJson()); + + assertThat(reply.toJson()) + .isEqualTo( + "{\"agentid\":1000002,\"touser\":\"OPENID\",\"msgtype\":\"template_card\",\"duplicate_check_interval\":1800," + + "\"template_card\":{\"card_type\":\"vote_interaction\",\"source\":{\"icon_url\":\"图片的url\"," + + "\"desc\":\"企业微信\"},\"main_title\":{\"title\":\"欢迎使用企业微信\",\"desc\":\"您的好友正在邀请您加入企业微信\"}," + + "\"task_id\":\"task_id\",\"checkbox\":{\"question_key\":\"question_key1\",\"mode\":1," + + "\"option_list\":[{\"id\":\"option_id1\",\"text\":\"选择题选项1\",\"is_checked\":true},{\"id\":\"option_id2\"," + + "\"text\":\"选择题选项2\",\"is_checked\":false}]},\"submit_button\":{\"text\":\"提交\",\"key\":\"key\"}}}"); + } + + /** + * 测试模板卡片消息 + * 投票选择型 + */ + public void TestTemplateCardBuilder_multiple_interaction() { + CheckboxOption option1 = CheckboxOption.builder() + .id("selection_id1") + .text("选择器选项1") + .build(); + CheckboxOption option2 = CheckboxOption.builder() + .id("selection_id2") + .text("选择题选项2") + .build(); + CheckboxOption option3 = CheckboxOption.builder() + .id("selection_id3") + .text("选择器选项3") + .build(); + CheckboxOption option4 = CheckboxOption.builder() + .id("selection_id4") + .text("选择题选项4") + .build(); + + MultipleSelect mSelect1 = MultipleSelect.builder() + .question_key("question_key1") + .title("选择器标签1") + .selected_id("selection_id1") + .options(Arrays.asList(option1, option2)) + .build(); + MultipleSelect mSelect2 = MultipleSelect.builder() + .question_key("question_key2") + .title("选择器标签2") + .selected_id("selection_id3") + .options(Arrays.asList(option3, option4)) + .build(); + + + WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") + .agentId(1000002) + .cardType(WxConsts.TemplateCardType.MULTIPLE_INTERACTION) + .sourceIconUrl("图片的url") + .sourceDesc("企业微信") + .mainTitleTitle("欢迎使用企业微信") + .mainTitleDesc("您的好友正在邀请您加入企业微信") + .taskId("task_id") + .selects(Arrays.asList(mSelect1, mSelect2)) + .submitButtonKey("key") + .submitButtonText("提交") + .build(); + reply.setEnableIdTrans(false); + reply.setEnableDuplicateCheck(false); + reply.setDuplicateCheckInterval(1800); + System.out.println(reply.toJson()); + assertThat(reply.toJson()) + .isEqualTo("{\"agentid\":1000002,\"touser\":\"OPENID\",\"msgtype\":\"template_card\"," + + "\"duplicate_check_interval\":1800,\"template_card\":{\"card_type\":\"multiple_interaction\"," + + "\"source\":{\"icon_url\":\"图片的url\",\"desc\":\"企业微信\"},\"main_title\":{\"title\":\"欢迎使用企业微信\"," + + "\"desc\":\"您的好友正在邀请您加入企业微信\"},\"task_id\":\"task_id\",\"submit_button\":{\"text\":\"提交\",\"key\":\"key\"}," + + "\"select_list\":[{\"question_key\":\"question_key1\",\"title\":\"选择器标签1\",\"selected_id\":\"selection_id1\"," + + "\"option_list\":[{\"id\":\"selection_id1\",\"text\":\"选择器选项1\"},{\"id\":\"selection_id2\"," + + "\"text\":\"选择题选项2\"}]},{\"question_key\":\"question_key2\",\"title\":\"选择器标签2\"," + + "\"selected_id\":\"selection_id3\",\"option_list\":[{\"id\":\"selection_id3\",\"text\":\"选择器选项3\"}," + + "{\"id\":\"selection_id4\",\"text\":\"选择题选项4\"}]}]}}"); } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageTest.java new file mode 100644 index 0000000000..f261827059 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageTest.java @@ -0,0 +1,442 @@ +package me.chanjar.weixin.cp.bean.message; + +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.article.MpnewsArticle; +import me.chanjar.weixin.cp.bean.article.NewArticle; +import me.chanjar.weixin.cp.bean.school.user.WxCpAllowScope; +import me.chanjar.weixin.cp.bean.school.user.WxCpListParentResult; +import me.chanjar.weixin.cp.bean.school.user.WxCpUserListResult; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; +import org.testng.annotations.Test; + +import java.io.InputStream; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * 发送「学校通知」消息测试类 + * https://developer.work.weixin.qq.com/document/path/92321 + * + * @author Wang_Wong created on 2022-06-29 + */ +@Slf4j +public class WxCpSchoolContactMessageTest { + + private static WxCpConfigStorage wxCpConfigStorage; + private static WxCpService cpService; + + + /** + * 发送「学校通知」 + * 学校可以通过此接口来给家长发送不同类型的学校通知,来满足多种场景下的学校通知需求。目前支持的消息类型为文本、图片、语音、视频、文件、图文。 + *

+ * https://developer.work.weixin.qq.com/document/path/92321 + *

+ * 消息体类型请参考测试类 + * WxCpSchoolContactMessageTest + * {@link WxCpSchoolContactMessageTest} + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testSendSchoolContactMessage() throws WxErrorException { + + InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml"); + WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream); + + wxCpConfigStorage = config; + cpService = new WxCpServiceImpl(); + cpService.setWxCpConfigStorage(config); + + // 获取可使用的家长范围 返回的数据 + WxCpAllowScope allowScope = cpService.getSchoolUserService().getAllowScope(1000002); + + WxCpUserListResult userList = cpService.getSchoolUserService().getUserList(1, 1); + + // 测试发送给家长 [学校通知] + WxCpListParentResult userListParent = cpService.getSchoolUserService().getUserListParent(1); + List collect = userListParent.getParents() + .stream() + .filter(parent -> parent.getMobile().equals("13079226621")) + .collect(Collectors.toList()); + + String[] parentsId = {"ab0b1691d0204d4900f6b7a7e5a6aa8f", collect.get(0).getParentUserId()}; + + WxCpSchoolContactMessageSendResult sendResult = cpService.getMessageService().sendSchoolContactMessage( + + WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.NEWS) + .toParentUserId(parentsId) +// .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) +// .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(cpService.getWxCpConfigStorage().getAgentId()) + .articles(Lists.newArrayList(NewArticle.builder() + .title("这是接口测试标题") + .description("今年中秋节公司有豪礼相送哦") + .url("https://www.baidu.com/") + .picUrl("http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png") + .build())) + .build() + + ); + + log.info("sendResult: {}", sendResult.toJson()); + + } + + /** + * Test to json text. + */ +// WxCpConsts.SchoolContactChangeType + @Test + public void testToJson_text() { + + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.TEXT) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .content("你的快递已到,请携带工卡前往邮件中心领取。\n出发前可查看邮件中心视频实况,聪明避开排队。") + .enableIdTrans(false) + .enableDuplicateCheck(false) + .duplicateCheckInterval(1800) + .build(); + + WxCpSchoolContactMessage schoolContactMessage1 = new WxCpSchoolContactMessage(); + schoolContactMessage1.setMsgType(WxConsts.SchoolContactMsgType.TEXT); + schoolContactMessage1.setRecvScope(0); + schoolContactMessage1.setToParentUserId(new String[]{"parent_userid1", "parent_userid2"}); + schoolContactMessage1.setToStudentUserId(new String[]{"student_userid1", "student_userid2"}); + schoolContactMessage1.setToParty(new String[]{"partyid1", "partyid2"}); + schoolContactMessage1.setToAll(false); + schoolContactMessage1.setAgentId(1); + schoolContactMessage1.setContent("你的快递已到,请携带工卡前往邮件中心领取"); + schoolContactMessage1.setEnableIdTrans(false); + schoolContactMessage1.setEnableDuplicateCheck(false); + schoolContactMessage1.setDuplicateCheckInterval(1800); + final String jsonMsg = schoolContactMessage1.toJson(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + "\t\"recv_scope\" : 0,\n" + + "\t\"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + "\t\"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + "\t\"to_party\": [\"partyid1\", \"partyid2\"],\n" + + "\t\"toall\" : 0,\n" + + "\t\"msgtype\" : \"text\",\n" + + "\t\"agentid\" : 1,\n" + + "\t\"text\" : {\n" + + "\t\t\"content\" : \"你的快递已到,请携带工卡前往邮件中心领取。\\n出发前可查看邮件中心视频实况,聪明避开排队。\"\n" + + "\t},\n" + + "\t\"enable_id_trans\": 0,\n" + + "\t\"enable_duplicate_check\": 0,\n" + + "\t\"duplicate_check_interval\": 1800\n" + + "}"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + + /** + * Test to json image. + */ + @Test + public void testToJson_image() { + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.IMAGE) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .mediaId("MEDIA_ID") + .build(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + "\t\"recv_scope\" : 0,\n" + + "\t\"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + "\t\"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + "\t\"to_party\": [\"partyid1\", \"partyid2\"],\n" + + "\t\"toall\" : 0,\n" + + "\t\"msgtype\" : \"image\",\n" + + "\t\"agentid\" : 1,\n" + + "\t\"image\" : {\n" + + "\t\t\"media_id\" : \"MEDIA_ID\"\n" + + "\t},\n" + + "\t\"enable_duplicate_check\": 0,\n" + + "\t\"duplicate_check_interval\": 1800\n" + + "}"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + + /** + * Test to json voice. + */ + @Test + public void testToJson_voice() { + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.VOICE) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .mediaId("MEDIA_ID") + .build(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + "\t\"recv_scope\" : 0,\n" + + "\t\"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + "\t\"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + "\t\"to_party\": [\"partyid1\", \"partyid2\"],\n" + + "\t\"toall\" : 0,\n" + + "\t\"msgtype\" : \"voice\",\n" + + "\t\"agentid\" : 1,\n" + + "\t\"voice\" : {\n" + + "\t\t\"media_id\" : \"MEDIA_ID\"\n" + + "\t},\n" + + "\t\"enable_duplicate_check\": 0,\n" + + "\t\"duplicate_check_interval\": 1800\n" + + "}"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + + /** + * Test to json video. + */ + @Test + public void testToJson_video() { + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.VIDEO) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .mediaId("MEDIA_ID") + .title("Title") + .description("Description") + .build(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + "\t\"recv_scope\" : 0,\n" + + "\t\"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + "\t\"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + "\t\"to_party\": [\"partyid1\", \"partyid2\"],\n" + + "\t\"toall\" : 0,\n" + + "\t\"msgtype\" : \"video\",\n" + + "\t\"agentid\" : 1,\n" + + "\t\"video\" : {\n" + + " \"media_id\" : \"MEDIA_ID\",\n" + + " \"title\" : \"Title\",\n" + + " \"description\" : \"Description\"\n" + + "\t},\n" + + "\t\"enable_duplicate_check\": 0,\n" + + "\t\"duplicate_check_interval\": 1800\n" + + "}"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + + /** + * Test to json file. + */ + @Test + public void testToJson_file() { + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.FILE) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .mediaId("1Yv-zXfHjSjU-7LH-GwtYqDGS-zz6w22KmWAT5COgP7o") + .build(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + "\t\"recv_scope\" : 0,\n" + + "\t\"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + "\t\"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + "\t\"to_party\": [\"partyid1\", \"partyid2\"],\n" + + "\t\"toall\" : 0,\n" + + "\t\"msgtype\" : \"file\",\n" + + "\t\"agentid\" : 1,\n" + + "\t\"file\" : {\n" + + " \"media_id\" : \"1Yv-zXfHjSjU-7LH-GwtYqDGS-zz6w22KmWAT5COgP7o\"\n" + + "\t},\n" + + "\t\"enable_duplicate_check\": 0,\n" + + "\t\"duplicate_check_interval\": 1800\n" + + "}"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + + /** + * Test to json news. + */ + @Test + public void testToJson_news() { + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.NEWS) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .articles(Lists.newArrayList(NewArticle.builder() + .title("中秋节礼品领取") + .description("今年中秋节公司有豪礼相送") + .url("URL") + .picUrl("http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png") + .build())) + .build(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + " \"recv_scope\" : 0,\n" + + " \"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + " \"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + " \"to_party\": [\"partyid1\", \"partyid2\"],\n" + + " \"toall\" : 0,\n" + + " \"msgtype\" : \"news\",\n" + + " \"agentid\" : 1,\n" + + " \"news\" : {\n" + + " \"articles\" : [\n" + + " {\n" + + " \"title\" : \"中秋节礼品领取\",\n" + + " \"description\" : \"今年中秋节公司有豪礼相送\",\n" + + " \"url\" : \"URL\",\n" + + " \"picurl\" : \"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1" + + ".png\"\n" + + " }\n" + + "\t\t]\n" + + " },\n" + + " \"enable_id_trans\": 0,\n" + + " \"enable_duplicate_check\": 0,\n" + + " \"duplicate_check_interval\": 1800\n" + + "}"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + + + /** + * Test to json mpnews. + */ + @Test + public void testToJson_mpnews() { + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.MPNEWS) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .mpNewsArticles(Lists.newArrayList(MpnewsArticle.newBuilder() + .title("Title") + .thumbMediaId("MEDIA_ID") + .author("Author") + .contentSourceUrl("URL") + .content("Content") + .digest("Digest description") + .build())) + .build(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + " \"recv_scope\" : 0,\n" + + " \"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + " \"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + " \"to_party\": [\"partyid1\", \"partyid2\"],\n" + + " \"toall\" : 0,\n" + + " \"msgtype\" : \"mpnews\",\n" + + " \"agentid\" : 1,\n" + + " \"mpnews\" : {\n" + + " \"articles\":[\n" + + " {\n" + + " \"title\": \"Title\", \n" + + " \"thumb_media_id\": \"MEDIA_ID\",\n" + + " \"author\": \"Author\",\n" + + " \"content_source_url\": \"URL\",\n" + + " \"content\": \"Content\",\n" + + " \"digest\": \"Digest description\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"enable_id_trans\": 0,\n" + + " \"enable_duplicate_check\": 0,\n" + + " \"duplicate_check_interval\": 1800\n" + + "}\n"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + + /** + * Test to json mini program. + */ + @Test + public void testToJson_miniProgram() { + WxCpSchoolContactMessage message = WxCpSchoolContactMessage.builder() + .recvScope(0) + .msgType(WxConsts.SchoolContactMsgType.MINIPROGRAM) + .toParentUserId(new String[]{"parent_userid1", "parent_userid2"}) + .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) + .toParty(new String[]{"partyid1", "partyid2"}) + .toAll(false) + .agentId(1) + .appId("APPID") + .title("欢迎报名夏令营") + .thumbMediaId("MEDIA_ID") + .pagePath("PAGE_PATH") + .build(); + + final String json = message.toJson(); + String expectedJson = "{\n" + + " \"recv_scope\" : 0,\n" + + " \"to_parent_userid\": [\"parent_userid1\", \"parent_userid2\"],\n" + + " \"to_student_userid\": [\"student_userid1\", \"student_userid2\"],\n" + + " \"to_party\": [\"partyid1\", \"partyid2\"],\n" + + " \"toall\" : 0,\n" + + " \"agentid\" : 1,\n" + + " \"msgtype\" : \"miniprogram\",\n" + + " \"miniprogram\" : {\n" + + " \"appid\": \"APPID\",\n" + + " \"title\": \"欢迎报名夏令营\",\n" + + " \"thumb_media_id\": \"MEDIA_ID\",\n" + + " \"pagepath\": \"PAGE_PATH\"\n" + + " },\n" + + " \"enable_id_trans\": 0,\n" + + " \"enable_duplicate_check\": 0,\n" + + " \"duplicate_check_interval\": 1800\n" + + "}\n"; + + assertThat(json).isEqualTo(GsonParser.parse(expectedJson).toString()); + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessageTest.java index 04d9455cf6..d6cd827630 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessageTest.java @@ -5,8 +5,14 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +/** + * The type Wx cp tp xml message test. + */ public class WxCpTpXmlMessageTest { + /** + * Test user notify xml. + */ @Test public void testUserNotifyXML() { String xml = "\n" + @@ -24,7 +30,9 @@ public void testUserNotifyXML() { " \n" + " 1\n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -54,6 +62,9 @@ public void testUserNotifyXML() { } + /** + * Test register corp. + */ @Test public void testRegisterCorp() { String xml = "\n" + @@ -85,6 +96,9 @@ public void testRegisterCorp() { assertEquals(wxXmlMessage.getTemplateId(), "tpl1test"); } + /** + * Tag notify test. + */ @Test public void tagNotifyTest() { String xml = "\n" + @@ -118,6 +132,9 @@ public void tagNotifyTest() { } + /** + * Enter app test. + */ @Test public void enterAppTest() { String xml = "\n" + @@ -138,6 +155,9 @@ public void enterAppTest() { assertEquals(wxXmlMessage.getAgentID(), Integer.valueOf(1)); } + /** + * Text message test. + */ @Test public void textMessageTest() { String xml = "\n" + @@ -160,6 +180,9 @@ public void textMessageTest() { assertEquals(wxXmlMessage.getId(), "etEsNADQAAaiB0cWCSDFiJ2qCap-ww9A"); } + /** + * Approval info test. + */ @Test public void ApprovalInfoTest() { String xml = "\n" + @@ -227,13 +250,17 @@ public void ApprovalInfoTest() { assertNotNull(wxXmlMessage.getApprovalInfo().getApprovalNodes().get(0).getItems()); assertEquals(wxXmlMessage.getApprovalInfo().getApprovalNodes().get(0).getItems().get(0).getItemName(), "xiaohong"); - assertEquals(wxXmlMessage.getApprovalInfo().getApprovalNodes().get(0).getItems().get(0).getItemOpTime(), Long.valueOf(0)); + assertEquals(wxXmlMessage.getApprovalInfo().getApprovalNodes().get(0).getItems().get(0).getItemOpTime(), + Long.valueOf(0)); assertNotNull(wxXmlMessage.getApprovalInfo().getNotifyNodes().get(0)); assertEquals(wxXmlMessage.getApprovalInfo().getNotifyNodes().get(0).getItemImage(), "http://www.qq.com/xxx.png"); assertEquals(wxXmlMessage.getApprovalInfo().getNotifyNodes().get(0).getItemUserId(), Integer.valueOf(3)); } + /** + * Test from xml. + */ @Test public void testFromXml() { String xml = "\n" + diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java index 044e364b6d..cb5a9b02e8 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java @@ -1,7 +1,6 @@ package me.chanjar.weixin.cp.bean.message; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; import me.chanjar.weixin.cp.constant.WxCpConsts; import me.chanjar.weixin.cp.util.xml.XStreamTransformer; import org.testng.annotations.Test; @@ -11,9 +10,15 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +/** + * The type Wx cp xml message test. + */ @Test public class WxCpXmlMessageTest { + /** + * Test from xml. + */ public void testFromXml() { String xml = "" @@ -63,10 +68,10 @@ public void testFromXml() { WxCpXmlMessage wxMessage = WxCpXmlMessage.fromXml(xml); assertEquals(wxMessage.getToUserName(), "toUser"); assertEquals(wxMessage.getFromUserName(), "fromUser"); - assertEquals(wxMessage.getCreateTime(), new Long(1348831860)); + assertEquals(wxMessage.getCreateTime(), Long.valueOf(1348831860)); assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); assertEquals(wxMessage.getContent(), "this is a test"); - assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); + assertEquals(wxMessage.getMsgId(), Long.valueOf(1234567890123456L)); assertEquals(wxMessage.getPicUrl(), "this is a url"); assertEquals(wxMessage.getMediaId(), "media_id"); assertEquals(wxMessage.getFormat(), "Format"); @@ -86,7 +91,7 @@ public void testFromXml() { assertEquals(wxMessage.getPrecision().doubleValue(), 119.385040); assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); - assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1)); + assertEquals(wxMessage.getSendPicsInfo().getCount(), Long.valueOf(1)); assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); @@ -95,6 +100,9 @@ public void testFromXml() { assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi"); } + /** + * Test send pics info. + */ public void testSendPicsInfo() { String xml = "" + "" + @@ -113,17 +121,20 @@ public void testSendPicsInfo() { WxCpXmlMessage wxMessage = WxCpXmlMessage.fromXml(xml.replace("", "")); assertEquals(wxMessage.getToUserName(), "wx45a0972125658be9"); assertEquals(wxMessage.getFromUserName(), "xiaohe"); - assertEquals(wxMessage.getCreateTime(), new Long(1502012364L)); + assertEquals(wxMessage.getCreateTime(), Long.valueOf(1502012364L)); assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); assertEquals(wxMessage.getAgentId(), Integer.valueOf(1000004)); assertEquals(wxMessage.getEvent(), "pic_weixin"); assertEquals(wxMessage.getEventKey(), "faceSimilarity"); assertNotNull(wxMessage.getSendPicsInfo()); - assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(2L)); + assertEquals(wxMessage.getSendPicsInfo().getCount(), Long.valueOf(2L)); assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "aef52ae501537e552725c5d7f99c1741"); assertEquals(wxMessage.getSendPicsInfo().getPicList().get(1).getPicMd5Sum(), "c4564632a4fab91378c39bea6aad6f9e"); } + /** + * Test ext attr. + */ public void testExtAttr() { String xml = "" + @@ -135,16 +146,19 @@ public void testExtAttr() { " " + " " + " " + - " " + - " " + - " " + + " " + + " " + + " " + " " + "

" + ""; WxCpXmlMessage wxMessage = WxCpXmlMessage.fromXml(xml); assertEquals(wxMessage.getToUserName(), "w56c9fe3d50ad1ea2"); assertEquals(wxMessage.getFromUserName(), "sys"); - assertEquals(wxMessage.getCreateTime(), new Long(1557241961)); + assertEquals(wxMessage.getCreateTime(), Long.valueOf(1557241961)); assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); assertEquals(wxMessage.getEvent(), "change_contact"); assertEquals(wxMessage.getChangeType(), "update_user"); @@ -156,6 +170,9 @@ public void testExtAttr() { } + /** + * Test task card event. + */ public void testTaskCardEvent() { String xml = "" + "" + @@ -178,6 +195,9 @@ public void testTaskCardEvent() { assertEquals(wxMessage.getTaskId(), "taskid111"); } + /** + * Test add external user event. + */ public void testAddExternalUserEvent() { String xml = "" + "" + @@ -204,6 +224,9 @@ public void testAddExternalUserEvent() { } + /** + * Test del external user event. + */ public void testDelExternalUserEvent() { String xml = "" + "" + @@ -226,6 +249,9 @@ public void testDelExternalUserEvent() { assertEquals(wxMessage.getExternalUserId(), "woAJ2GCAAAXtWyujaWJHDDGi0mACH71w"); } + /** + * Test change contact. + */ public void testChangeContact() { String xml = "\n" + " \n" + @@ -244,7 +270,9 @@ public void testChangeContact() { " 1\n" + " \n" + " 1\n" + - " \n" + + " \n" + " \n" + " \n" + "
\n" + diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessageTest.java index 0ecbec67dc..f680f7a250 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutImageMessageTest.java @@ -1,13 +1,17 @@ package me.chanjar.weixin.cp.bean.message; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutImageMessage; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; import org.testng.Assert; import org.testng.annotations.Test; +/** + * The type Wx cp xml out image message test. + */ @Test public class WxCpXmlOutImageMessageTest { + /** + * Test. + */ public void test() { WxCpXmlOutImageMessage m = new WxCpXmlOutImageMessage(); m.setMediaId("ddfefesfsdfef"); @@ -26,6 +30,9 @@ public void test() { Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); } + /** + * Test build. + */ public void testBuild() { WxCpXmlOutImageMessage m = WxCpXmlOutMessage.IMAGE().mediaId("ddfefesfsdfef").fromUser("from").toUser("to").build(); String expected = "" diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessageTest.java index b0d3efabd4..d8adabcd03 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutNewsMessageTest.java @@ -1,13 +1,17 @@ package me.chanjar.weixin.cp.bean.message; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutNewsMessage; import org.testng.Assert; import org.testng.annotations.Test; +/** + * The type Wx cp xml out news message test. + */ @Test public class WxCpXmlOutNewsMessageTest { + /** + * Test. + */ public void test() { WxCpXmlOutNewsMessage m = new WxCpXmlOutNewsMessage(); m.setCreateTime(1122L); @@ -47,6 +51,9 @@ public void test() { Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); } + /** + * Test build. + */ public void testBuild() { WxCpXmlOutNewsMessage.Item item = new WxCpXmlOutNewsMessage.Item(); item.setDescription("description"); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessageTest.java index bc867b72d1..533286f5df 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTaskCardMessageTest.java @@ -1,12 +1,17 @@ package me.chanjar.weixin.cp.bean.message; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutTaskCardMessage; import org.testng.Assert; import org.testng.annotations.Test; +/** + * The type Wx cp xml out task card message test. + */ @Test public class WxCpXmlOutTaskCardMessageTest { + /** + * Test. + */ public void test() { WxCpXmlOutTaskCardMessage m = new WxCpXmlOutTaskCardMessage(); m.setReplaceName("已驳回"); @@ -25,8 +30,12 @@ public void test() { Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); } + /** + * Test build. + */ public void testBuild() { - WxCpXmlOutTaskCardMessage m = WxCpXmlOutMessage.TASK_CARD().replaceName("已驳回").fromUser("from").toUser("to").build(); + WxCpXmlOutTaskCardMessage m = + WxCpXmlOutMessage.TASK_CARD().replaceName("已驳回").fromUser("from").toUser("to").build(); String expected = "" + "" + "" diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessageTest.java index 68945f826a..aa00c9ec63 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutTextMessageTest.java @@ -1,13 +1,17 @@ package me.chanjar.weixin.cp.bean.message; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutTextMessage; import org.testng.Assert; import org.testng.annotations.Test; +/** + * The type Wx cp xml out text message test. + */ @Test public class WxCpXmlOutTextMessageTest { + /** + * Test. + */ public void test() { WxCpXmlOutTextMessage m = new WxCpXmlOutTextMessage(); m.setContent("content"); @@ -26,6 +30,9 @@ public void test() { Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); } + /** + * Test build. + */ public void testBuild() { WxCpXmlOutTextMessage m = WxCpXmlOutMessage.TEXT().content("content").fromUser("from").toUser("to").build(); String expected = "" diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessageTest.java index 7077ceeede..ea7a52ffea 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVideoMessageTest.java @@ -1,13 +1,17 @@ package me.chanjar.weixin.cp.bean.message; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutVideoMessage; import org.testng.Assert; import org.testng.annotations.Test; +/** + * The type Wx cp xml out video message test. + */ @Test public class WxCpXmlOutVideoMessageTest { + /** + * Test. + */ public void test() { WxCpXmlOutVideoMessage m = new WxCpXmlOutVideoMessage(); m.setMediaId("media_id"); @@ -32,6 +36,9 @@ public void test() { Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); } + /** + * Test build. + */ public void testBuild() { WxCpXmlOutVideoMessage m = WxCpXmlOutMessage.VIDEO() .mediaId("media_id") diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessageTest.java index 9c03486001..94ec90b15e 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlOutVoiceMessageTest.java @@ -1,13 +1,17 @@ package me.chanjar.weixin.cp.bean.message; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; -import me.chanjar.weixin.cp.bean.message.WxCpXmlOutVoiceMessage; import org.testng.Assert; import org.testng.annotations.Test; +/** + * The type Wx cp xml out voice message test. + */ @Test public class WxCpXmlOutVoiceMessageTest { + /** + * Test. + */ public void test() { WxCpXmlOutVoiceMessage m = new WxCpXmlOutVoiceMessage(); m.setMediaId("ddfefesfsdfef"); @@ -26,6 +30,9 @@ public void test() { Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); } + /** + * Test build. + */ public void testBuild() { WxCpXmlOutVoiceMessage m = WxCpXmlOutMessage.VOICE().mediaId("ddfefesfsdfef").fromUser("from").toUser("to").build(); String expected = "" diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequestTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequestTest.java index b5022115b8..f2dedb4ddf 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequestTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequestTest.java @@ -13,10 +13,12 @@ /** * 测试. * - * @author Binary Wang - * @date 2020-07-18 + * @author Binary Wang created on 2020-07-18 */ public class WxCpOaApplyEventRequestTest { + /** + * Test to json. + */ @Test public void testToJson() { String json = "{\n" + @@ -72,7 +74,8 @@ public void testToJson() { request.setCreatorUserId("WangXiaoMing") .setTemplateId("3Tka1eD6v6JfzhDMqPd3aMkFdxqtJMc2ZRioeFXkaaa") .setUseTemplateApprover(0) - .setApprovers(Arrays.asList(new WxCpOaApplyEventRequest.Approver().setAttr(2).setUserIds(new String[]{"WuJunJie", "WangXiaoMing"}), + .setApprovers(Arrays.asList(new WxCpOaApplyEventRequest.Approver().setAttr(2).setUserIds(new String[]{"WuJunJie" + , "WangXiaoMing"}), new WxCpOaApplyEventRequest.Approver().setAttr(1).setUserIds(new String[]{"LiuXiaoGang"}))) .setNotifiers(new String[]{"WuJunJie", "WangXiaoMing"}) .setNotifyType(1) @@ -80,11 +83,14 @@ public void testToJson() { .setContents(Collections.singletonList(new ApplyDataContent() .setControl("Text").setId("Text-15111111111").setValue(new ContentValue().setText("文本填写的内容"))))) .setSummaryList(Arrays.asList(new SummaryInfo() - .setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText("摘要第1行"))), + .setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText( + "摘要第1行"))), new SummaryInfo() - .setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText("摘要第2行"))), + .setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText( + "摘要第2行"))), new SummaryInfo() - .setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText("摘要第3行"))))) + .setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText( + "摘要第3行"))))) ; assertThat(request.toJson()).isEqualTo(GsonParser.parse(json).toString()); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/calendar/WxCpOaCalendarTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/calendar/WxCpOaCalendarTest.java index 761b0f8f9a..5d61410f30 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/calendar/WxCpOaCalendarTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/calendar/WxCpOaCalendarTest.java @@ -10,11 +10,13 @@ /** * 单元测试. * - * @author Binary Wang - * @date 2020-09-20 + * @author Binary Wang created on 2020-09-20 */ public class WxCpOaCalendarTest { + /** + * Test to json. + */ @Test public void testToJson() { String json = "{\n" + diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImplTest.java index 86e7b0f922..120da27b1b 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImplTest.java @@ -6,11 +6,20 @@ import java.util.concurrent.TimeUnit; +/** + * The type Wx cp tp default config impl test. + */ public class WxCpTpDefaultConfigImplTest { + /** + * Test get suite access token entity. + * + * @throws InterruptedException the interrupted exception + */ @Test public void testGetSuiteAccessTokenEntity() throws InterruptedException { - final String testAccessToken = "5O_32IEDOib99RliaF301vzGiZaAJw3CsaNb4QXyQ-07KJ0UDQ8nxq9vs66jNLIZ4TvYs3QFlYZag1WfG8i4gNu_dYQj2Ff89xznZPquv7EFMAZha_faYZrE0uCFRqkV"; + final String testAccessToken = "5O_32IEDOib99RliaF301vzGiZaAJw3CsaNb4QXyQ" + + "-07KJ0UDQ8nxq9vs66jNLIZ4TvYs3QFlYZag1WfG8i4gNu_dYQj2Ff89xznZPquv7EFMAZha_faYZrE0uCFRqkV"; final long testExpireTime = 7200L; final long restTime = 10L; WxCpTpDefaultConfigImpl storage = new WxCpTpDefaultConfigImpl(); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImplTest.java new file mode 100644 index 0000000000..4c99dbf5ed --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImplTest.java @@ -0,0 +1,109 @@ +package me.chanjar.weixin.cp.corpgroup.service.impl; + +import com.google.gson.JsonObject; +import com.google.inject.Inject; +import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.cp.api.ApiTestModule; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.api.impl.WxCpServiceApacheHttpClientImpl; +import me.chanjar.weixin.cp.bean.WxCpAgent; +import me.chanjar.weixin.cp.bean.WxCpUser; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpMaTransferSession; +import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpCorpGroupDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpCorpGroupRedissonConfigImpl; +import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; +import me.chanjar.weixin.cp.corpgroup.service.WxCpCgService; + +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.mockito.Mockito; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.MA_TRANSFER_SESSION; +import static org.testng.Assert.assertNotNull; + +/** + * @author libo + */ +@Guice(modules = ApiTestModule.class) +public class WxCpCgServiceApacheHttpClientImplTest { + private final WxCpCgService cgService = Mockito.spy(new WxCpCgServiceApacheHttpClientImpl()); + WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage; + @Inject + WxCpService wxCpService; + + //下游企业的corpId + String corpId = ""; + //下游企业的agentId + int agentId = 0; + int businessType = 0; + String userId = ""; + WxCpCorpGroupCorpGetTokenReq wxCpCorpGroupCorpGetTokenReq; + + @BeforeMethod + public void setUp() { + cgService.setWxCpCorpGroupConfigStorage(wxCpCorpGroupConfigStorage()); + cgService.setWxCpService(wxCpService); + + wxCpCorpGroupCorpGetTokenReq = new WxCpCorpGroupCorpGetTokenReq(); + wxCpCorpGroupCorpGetTokenReq.setCorpId(corpId); + wxCpCorpGroupCorpGetTokenReq.setAgentId(agentId); + wxCpCorpGroupCorpGetTokenReq.setBusinessType(businessType); + } + + public WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage() { + wxCpCorpGroupConfigStorage = new WxCpCorpGroupDefaultConfigImpl(); + wxCpCorpGroupConfigStorage.setCorpId(wxCpService.getWxCpConfigStorage().getCorpId()); + wxCpCorpGroupConfigStorage.setAgentId(wxCpService.getWxCpConfigStorage().getAgentId()); + return wxCpCorpGroupConfigStorage; + } + + @Test + public void testGetCorpAccessToken() throws Exception { + String corpAccessToken = cgService.getCorpAccessToken(corpId, agentId, businessType); + assertNotNull(corpAccessToken); + } + + /** + * 通讯录-读取成员 + * + * @throws Exception + */ + @Test + public void testGetCorpUser() throws Exception { + String result = cgService.get(wxCpService.getWxCpConfigStorage().getApiUrl(WxCpApiPathConsts.User.USER_GET + userId), null, wxCpCorpGroupCorpGetTokenReq); + assertNotNull(result); + WxCpUser wxCpUser = WxCpUser.fromJson(result); + assertNotNull(wxCpUser.getUserId()); + } + + /** + * 应用管理-获取指定的应用详情 + * + * @throws Exception + */ + @Test + public void testGetAgent() throws Exception { + + String result = cgService.get(wxCpService.getWxCpConfigStorage().getApiUrl(String.format(WxCpApiPathConsts.Agent.AGENT_GET, agentId)), null, wxCpCorpGroupCorpGetTokenReq); + assertNotNull(result); + WxCpAgent wxCpAgent = WxCpAgent.fromJson(result); + assertNotNull(wxCpAgent.getAgentId()); + } + + /** + * 获取下级/下游企业小程序session + * + * @throws Exception + */ + @Test + public void testGetTransferSession() throws Exception { + String sessionKey = ""; + + WxCpMaTransferSession wxCpMaTransferSession = cgService.getCorpTransferSession(userId, sessionKey, wxCpCorpGroupCorpGetTokenReq); + assertNotNull(wxCpMaTransferSession); + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpLinkedCorpServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpLinkedCorpServiceImplTest.java new file mode 100644 index 0000000000..c5a8e658e1 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpLinkedCorpServiceImplTest.java @@ -0,0 +1,93 @@ +package me.chanjar.weixin.cp.corpgroup.service.impl; + +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.ApiTestModule; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpAgentPerm; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpDepartment; +import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpUser; +import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpCorpGroupDefaultConfigImpl; +import me.chanjar.weixin.cp.corpgroup.service.WxCpCgService; +import org.mockito.Mockito; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.testng.Assert.assertNotNull; + +/** + * @author libo + */ +@Guice(modules = ApiTestModule.class) +public class WxCpLinkedCorpServiceImplTest { + WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage; + @Inject + WxCpService wxCpService; + + WxCpCgService cgService; + + //下游企业的corpId + String corpId = ""; + //下游企业的agentId + int agentId = 0; + int businessType = 0; + //CorpID/UserID + String corpUserId = ""; + String departmentId = ""; + WxCpCorpGroupCorpGetTokenReq wxCpCorpGroupCorpGetTokenReq; + + @BeforeMethod + public void setUp() { + cgService = new WxCpCgServiceApacheHttpClientImpl(); + cgService.setWxCpCorpGroupConfigStorage(wxCpCorpGroupConfigStorage()); + cgService.setWxCpService(wxCpService); + + wxCpCorpGroupCorpGetTokenReq = new WxCpCorpGroupCorpGetTokenReq(); + wxCpCorpGroupCorpGetTokenReq.setCorpId(corpId); + wxCpCorpGroupCorpGetTokenReq.setAgentId(agentId); + wxCpCorpGroupCorpGetTokenReq.setBusinessType(businessType); + } + + public WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage() { + wxCpCorpGroupConfigStorage = new WxCpCorpGroupDefaultConfigImpl(); + wxCpCorpGroupConfigStorage.setCorpId(wxCpService.getWxCpConfigStorage().getCorpId()); + wxCpCorpGroupConfigStorage.setAgentId(wxCpService.getWxCpConfigStorage().getAgentId()); + return wxCpCorpGroupConfigStorage; + } + + @Test + public void testGetLinkedCorpAgentPerm() throws WxErrorException { + WxCpLinkedCorpAgentPerm resp = cgService.getLinkedCorpService().getLinkedCorpAgentPerm(wxCpCorpGroupCorpGetTokenReq); + assertNotNull(resp); + } + + @Test + public void testGetLinkedCorpUser() throws WxErrorException { + WxCpLinkedCorpUser resp = cgService.getLinkedCorpService().getLinkedCorpUser(corpUserId, wxCpCorpGroupCorpGetTokenReq); + assertNotNull(resp); + } + + @Test + public void testGetLinkedCorpSimpleUserList() throws WxErrorException { + List resp = cgService.getLinkedCorpService().getLinkedCorpSimpleUserList(departmentId, wxCpCorpGroupCorpGetTokenReq); + assertNotNull(resp); + } + + @Test + public void testGetLinkedCorpUserList() throws WxErrorException { + List resp = cgService.getLinkedCorpService().getLinkedCorpUserList(departmentId, wxCpCorpGroupCorpGetTokenReq); + assertNotNull(resp); + } + + @Test + public void testGetLinkedCorpDepartmentList() throws WxErrorException { + List resp = cgService.getLinkedCorpService().getLinkedCorpDepartmentList(departmentId, wxCpCorpGroupCorpGetTokenReq); + assertNotNull(resp); + } + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoInMemoryConfigStorage.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoInMemoryConfigStorage.java index 35a2fc0e43..7d5e3f7936 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoInMemoryConfigStorage.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoInMemoryConfigStorage.java @@ -1,19 +1,27 @@ package me.chanjar.weixin.cp.demo; -import java.io.InputStream; - import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; import lombok.ToString; import me.chanjar.weixin.common.util.xml.XStreamInitializer; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import java.io.InputStream; + /** + * The type Wx cp demo in memory config storage. + * * @author Daniel Qian */ @XStreamAlias("xml") @ToString public class WxCpDemoInMemoryConfigStorage extends WxCpDefaultConfigImpl { + /** + * From xml wx cp demo in memory config storage. + * + * @param is the is + * @return the wx cp demo in memory config storage + */ public static WxCpDemoInMemoryConfigStorage fromXml(InputStream is) { XStream xstream = XStreamInitializer.getInstance(); xstream.processAnnotations(WxCpDemoInMemoryConfigStorage.class); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java index 52bc8e2ab7..154e2b2c47 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java @@ -15,12 +15,21 @@ import java.io.IOException; import java.io.InputStream; +/** + * The type Wx cp demo server. + */ public class WxCpDemoServer { private static WxCpConfigStorage wxCpConfigStorage; private static WxCpService wxCpService; private static WxCpMessageRouter wxCpMessageRouter; + /** + * The entry point of application. + * + * @param args the input arguments + * @throws Exception the exception + */ public static void main(String[] args) throws Exception { initWeixin(); @@ -29,7 +38,8 @@ public static void main(String[] args) throws Exception { ServletHandler servletHandler = new ServletHandler(); server.setHandler(servletHandler); - ServletHolder endpointServletHolder = new ServletHolder(new WxCpEndpointServlet(wxCpConfigStorage, wxCpService, wxCpMessageRouter)); + ServletHolder endpointServletHolder = new ServletHolder(new WxCpEndpointServlet(wxCpConfigStorage, wxCpService, + wxCpMessageRouter)); servletHandler.addServletWithMapping(endpointServletHolder, "/*"); ServletHolder oauthServletHolder = new ServletHolder(new WxCpOAuth2Servlet(wxCpService)); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java index a5e785ffdf..8af5f3dafa 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java @@ -1,10 +1,10 @@ package me.chanjar.weixin.cp.demo; -import me.chanjar.weixin.cp.config.WxCpConfigStorage; -import me.chanjar.weixin.cp.message.WxCpMessageRouter; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; +import me.chanjar.weixin.cp.config.WxCpConfigStorage; +import me.chanjar.weixin.cp.message.WxCpMessageRouter; import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil; import org.apache.commons.lang3.StringUtils; @@ -14,14 +14,32 @@ import java.io.IOException; /** + * The type Wx cp endpoint servlet. + * * @author Daniel Qian */ public class WxCpEndpointServlet extends HttpServlet { private static final long serialVersionUID = 1L; + /** + * The Wx cp config storage. + */ protected WxCpConfigStorage wxCpConfigStorage; + /** + * The Wx cp service. + */ protected WxCpService wxCpService; + /** + * The Wx cp message router. + */ protected WxCpMessageRouter wxCpMessageRouter; + /** + * Instantiates a new Wx cp endpoint servlet. + * + * @param wxCpConfigStorage the wx cp config storage + * @param wxCpService the wx cp service + * @param wxCpMessageRouter the wx cp message router + */ public WxCpEndpointServlet(WxCpConfigStorage wxCpConfigStorage, WxCpService wxCpService, WxCpMessageRouter wxCpMessageRouter) { this.wxCpConfigStorage = wxCpConfigStorage; diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpOAuth2Servlet.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpOAuth2Servlet.java index b6dda81301..a0947ac3d5 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpOAuth2Servlet.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpOAuth2Servlet.java @@ -9,11 +9,22 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; +/** + * The type Wx cp o auth 2 servlet. + */ public class WxCpOAuth2Servlet extends HttpServlet { private static final long serialVersionUID = 1L; + /** + * The Wx cp service. + */ protected WxCpService wxCpService; + /** + * Instantiates a new Wx cp o auth 2 servlet. + * + * @param wxCpService the wx cp service + */ public WxCpOAuth2Servlet(WxCpService wxCpService) { this.wxCpService = wxCpService; } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java index 26ca567c12..6f2639c890 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java @@ -2,16 +2,27 @@ import com.google.gson.JsonObject; import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.redis.RedissonWxRedisOps; import me.chanjar.weixin.cp.bean.WxCpTpAuthInfo; import me.chanjar.weixin.cp.bean.WxCpTpCorp; import me.chanjar.weixin.cp.bean.WxCpTpPermanentCodeInfo; +import me.chanjar.weixin.cp.bean.WxTpCustomizedAuthUrl; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl; +import me.chanjar.weixin.cp.config.impl.WxCpTpRedissonConfigImpl; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import org.mockito.Mockito; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; import org.testng.Assert; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_AUTH_INFO; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_PERMANENT_CODE; import static org.assertj.core.api.Assertions.assertThat; @@ -19,36 +30,107 @@ /** * 测试代码. * - * @author Binary Wang - * @date 2019-08-18 + * @author Binary Wang created on 2019-08-18 */ public class BaseWxCpTpServiceImplTest { private final WxCpTpService tpService = Mockito.spy(new WxCpTpServiceApacheHttpClientImpl()); + /** + * The constant PROVIDER_CORP_ID. + */ + public static final String PROVIDER_CORP_ID = "xxxxxx"; + /** + * The constant PROVIDER_SECRET. + */ + public static final String PROVIDER_SECRET = "xxxxxx"; + /** + * The constant REDIS_ADDR. + */ + public static final String REDIS_ADDR = "redis://xxx.xxx.xxx.xxx:6379"; + /** + * The constant REDIS_PASSWD. + */ + public static final String REDIS_PASSWD = "xxxxxx"; + + private WxCpTpService wxCpTpService; + + /** + * Sets up. + */ + @BeforeMethod + public void setUp() { + wxCpTpService = new WxCpTpServiceApacheHttpClientImpl(); + wxCpTpService.setWxCpTpConfigStorage(wxCpTpConfigStorage()); + } + + /** + * Wx cp tp config storage wx cp tp config storage. + * + * @return the wx cp tp config storage + */ + public WxCpTpConfigStorage wxCpTpConfigStorage() { + return WxCpTpRedissonConfigImpl.builder().corpId(PROVIDER_CORP_ID).providerSecret(PROVIDER_SECRET).wxRedisOps(new RedissonWxRedisOps(redissonClient())).build(); + } + + /** + * Redisson client redisson client. + * + * @return the redisson client + */ + public RedissonClient redissonClient() { + Config config = new Config(); + config.useSingleServer().setAddress(REDIS_ADDR).setConnectTimeout(10 * 1000).setDatabase(6) + .setPassword(REDIS_PASSWD).setConnectionMinimumIdleSize(2).setConnectionPoolSize(2); + return Redisson.create(config); + } + + /** + * Test check signature. + */ @Test public void testCheckSignature() { } + /** + * Test get suite access token. + */ @Test public void testGetSuiteAccessToken() { } + /** + * Test get suite ticket. + */ @Test public void testGetSuiteTicket() { } + /** + * Test test get suite ticket. + */ @Test public void testTestGetSuiteTicket() { } + /** + * Test js code 2 session. + */ @Test public void testJsCode2Session() { } + /** + * Test get corp token. + */ @Test public void testGetCorpToken() { } + /** + * Test get permanent code. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetPermanentCode() throws WxErrorException { String returnJson = "{\n" + @@ -123,7 +205,8 @@ public void testGetPermanentCode() throws WxErrorException { JsonObject jsonObject = new JsonObject(); String authCode = ""; jsonObject.addProperty("auth_code", authCode); - Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString()); + Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), + jsonObject.toString()); final WxCpTpCorp tpCorp = tpService.getPermanentCode(authCode); assertThat(tpCorp.getPermanentCode()).isEqualTo("xxxx"); @@ -133,21 +216,30 @@ public void testGetPermanentCode() throws WxErrorException { } + /** + * Test get permanent code info. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetPermanentCodeInfo() throws WxErrorException { String returnJson = "{\n" + - " \"access_token\": \"u6SoEWyrEmworJ1uNzddbiXh42mCLNU_mdd6b01Afo2LKmyi-WdaaYqhEGFZjB1RGZ-rhjLcAJ86ger7b7Q0gowSw9iIDR8dm49aVH_MztzmQttP3XFG7np1Dxs_VQkVwhhRmfRpEonAmK1_JWIFqayJXXiPUS3LsFd3tWpE7rxmsRa7Ev2ml2htbRp_qGUjtFTErKoDsnNGSka6_RqFPA\", \n" + + " \"access_token\": \"u6SoEWyrEmworJ1uNzddbiXh42mCLNU_mdd6b01Afo2LKmyi-WdaaYqhEGFZjB1RGZ" + + "-rhjLcAJ86ger7b7Q0gowSw9iIDR8dm49aVH_MztzmQttP3XFG7np1Dxs_VQkVwhhRmfRpEonAmK1_JWIFqayJXXiPUS3LsFd3tWpE7rxmsRa7Ev2ml2htbRp_qGUjtFTErKoDsnNGSka6_RqFPA\", \n" + " \"expires_in\": 7200, \n" + " \"permanent_code\": \"lMLlxss77ntxzuEl1i1_AQ3-6-cvqMLYs209YNWVruk\", \n" + " \"auth_corp_info\": {\n" + " \"corpid\": \"xxxcorpid\", \n" + " \"corp_name\": \"xxxx有限公司\", \n" + " \"corp_type\": \"unverified\", \n" + - " \"corp_round_logo_url\": \"http://p.qpic.cn/pic_wework/3777001839/4046834be7a5f2711feaaa3cc4e691e1bcb1e526cb4544b5/0\", \n" + - " \"corp_square_logo_url\": \"https://p.qlogo.cn/bizmail/EsvsszIt9hJrjrx8QKXuIs0iczdnV4icaPibLIViaukn1iazCay8L1UXtibA/0\", \n" + + " \"corp_round_logo_url\": \"http://p.qpic" + + ".cn/pic_wework/3777001839/4046834be7a5f2711feaaa3cc4e691e1bcb1e526cb4544b5/0\", \n" + + " \"corp_square_logo_url\": \"https://p.qlogo" + + ".cn/bizmail/EsvsszIt9hJrjrx8QKXuIs0iczdnV4icaPibLIViaukn1iazCay8L1UXtibA/0\", \n" + " \"corp_user_max\": 200, \n" + " \"corp_agent_max\": 300, \n" + - " \"corp_wxqrcode\": \"http://p.qpic.cn/pic_wework/211781738/a9af41a60af7519775dd7ac846a4942979dc4a14b8bb2c72/0\", \n" + + " \"corp_wxqrcode\": \"http://p.qpic" + + ".cn/pic_wework/211781738/a9af41a60af7519775dd7ac846a4942979dc4a14b8bb2c72/0\", \n" + " \"corp_full_name\": \"xxxx有限公司\", \n" + " \"subject_type\": 1, \n" + " \"corp_scale\": \"1-50人\", \n" + @@ -160,7 +252,8 @@ public void testGetPermanentCodeInfo() throws WxErrorException { " {\n" + " \"agentid\": 1000012, \n" + " \"name\": \"xxxxx\", \n" + - " \"square_logo_url\": \"http://wx.qlogo.cn/mmhead/Q3auHgzwzM4ZCtdxicN8ghMOtTv7M7rLPKmeZ3amic00btdwbNmicaW3Q/0\", \n" + + " \"square_logo_url\": \"http://wx.qlogo" + + ".cn/mmhead/Q3auHgzwzM4ZCtdxicN8ghMOtTv7M7rLPKmeZ3amic00btdwbNmicaW3Q/0\", \n" + " \"privilege\": {\n" + " \"level\": 1, \n" + " \"allow_party\": [ ], \n" + @@ -178,7 +271,32 @@ public void testGetPermanentCodeInfo() throws WxErrorException { " \"auth_user_info\": {\n" + " \"userid\": \"yuanqixun\", \n" + " \"name\": \"袁启勋\", \n" + - " \"avatar\": \"http://wework.qpic.cn/bizmail/ZYqy8EswiaFyPnk7gy7eiafoicz3TL35f4bAvCf2eSe6RVYSK7aPDFxcw/0\"\n" + + " \"avatar\": \"http://wework.qpic.cn/bizmail/ZYqy8EswiaFyPnk7gy7eiafoicz3TL35f4bAvCf2eSe6RVYSK7aPDFxcw/0" + + "\"\n" + + " },\n" + + " \"edition_info\":\n" + + " {\n" + + " \"agent\" :\n" + + " [\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791\n" + + " },\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791,\n" + + " \"is_virtual_version\":false,\n" + + " \"is_shared_from_other_corp\":true\n" + + " }\n" + + " ]\n" + " }\n" + "}"; @@ -187,13 +305,28 @@ public void testGetPermanentCodeInfo() throws WxErrorException { JsonObject jsonObject = new JsonObject(); String authCode = ""; jsonObject.addProperty("auth_code", authCode); - Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString()); + Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), + jsonObject.toString()); final WxCpTpPermanentCodeInfo tpPermanentCodeInfo = tpService.getPermanentCodeInfo(authCode); assertThat(tpPermanentCodeInfo.getAuthInfo().getAgents().get(0).getAgentId()).isEqualTo(1000012); Assert.assertNotNull(tpPermanentCodeInfo.getAuthInfo().getAgents().get(0).getSquareLogoUrl()); Assert.assertNotNull(tpPermanentCodeInfo.getAuthCorpInfo().getCorpSquareLogoUrl()); + + final WxCpTpPermanentCodeInfo.EditionInfo editionInfo = tpPermanentCodeInfo.getEditionInfo(); + Assert.assertNotNull(editionInfo); + + final List editionInfoAgents = editionInfo.getAgents(); + Assert.assertTrue(Objects.nonNull(editionInfoAgents) && !editionInfoAgents.isEmpty()); + + Assert.assertNotNull(editionInfoAgents.get(0).getExpiredTime()); + } + /** + * Test get auth info. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetAuthInfo() throws WxErrorException { String returnJson = "{\n" + @@ -250,6 +383,32 @@ public void testGetAuthInfo() throws WxErrorException { " \"appid\":5\n" + " }\n" + " ]\n" + + " },\n" + + " \"edition_info\":\n" + + " {\n" + + " \"agent\" :\n" + + " [\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791,\n" + + " \"is_virtual_version\":false,\n" + + " \"is_shared_from_other_corp\":true\n" + + " },\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791,\n" + + " \"is_virtual_version\":false,\n" + + " \"is_shared_from_other_corp\":true\n" + + " }\n" + + " ]\n" + " }\n" + "}\n"; @@ -263,45 +422,93 @@ public void testGetAuthInfo() throws WxErrorException { Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_AUTH_INFO), jsonObject.toString()); WxCpTpAuthInfo authInfo = tpService.getAuthInfo(authCorpId, permanentCode); Assert.assertNotNull(authInfo.getAuthCorpInfo().getCorpId()); + + final WxCpTpAuthInfo.EditionInfo editionInfo = authInfo.getEditionInfo(); + Assert.assertNotNull(editionInfo); + + final List editionInfoAgents = editionInfo.getAgents(); + Assert.assertTrue(Objects.nonNull(editionInfoAgents) && !editionInfoAgents.isEmpty()); + + Assert.assertNotNull(editionInfoAgents.get(0).getExpiredTime()); } + /** + * Test get. + */ @Test public void testGet() { } + /** + * Test post. + */ @Test public void testPost() { } + /** + * Test execute. + */ @Test public void testExecute() { } + /** + * Test execute internal. + */ @Test public void testExecuteInternal() { } + /** + * Test set wx cp tp config storage. + */ @Test public void testSetWxCpTpConfigStorage() { } + /** + * Test set retry sleep millis. + */ @Test public void testSetRetrySleepMillis() { } + /** + * Test set max retry times. + */ @Test public void testSetMaxRetryTimes() { } + /** + * Test get tmp dir file. + */ @Test public void testGetTmpDirFile() { } + /** + * Test set tmp dir file. + */ @Test public void testSetTmpDirFile() { } + /** + * Test get request http. + */ @Test public void testGetRequestHttp() { } + + @Test + public void testGetCustomizedAuthUrl() throws WxErrorException { + String state = "test"; + List templateIdList = Arrays.asList(""); + + final WxTpCustomizedAuthUrl customizedAuthUrl = wxCpTpService.getCustomizedAuthUrl(state, templateIdList); + Assert.assertNotNull(customizedAuthUrl); + Assert.assertEquals((long) customizedAuthUrl.getErrcode(), 0); + } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImplTest.java new file mode 100644 index 0000000000..7eebf1f306 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImplTest.java @@ -0,0 +1,75 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl; +import me.chanjar.weixin.cp.tp.service.WxCpTpEditionService; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.PROLONG_TRY; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.when; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +/** + * 应用版本付费版本相关接口测试 + */ +public class WxCpTpEditionServiceImplTest { + + @Mock + private WxCpTpServiceApacheHttpClientImpl wxCpTpService; + + private WxCpTpConfigStorage configStorage; + + private WxCpTpEditionService wxCpTpEditionService; + + /** + * Sets up. + */ + @BeforeClass + public void setUp() { + MockitoAnnotations.initMocks(this); + configStorage = new WxCpTpDefaultConfigImpl(); + when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage); + wxCpTpEditionService = new WxCpTpEditionServiceImpl(wxCpTpService); + } + + + /** + * 延长试用期 + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testProlongTry() throws WxErrorException { + + String buyerCorpId = "wx7da9abf8ac62baaa"; + Integer prolongDays = 7; + String appId = "1"; + + Long tryEndTime = 1565152189L; + + String result = "" + + " {\n" + + " \"errcode\" : 0,\n" + + " \"errmsg\" : \"ok\",\n" + + " \"try_end_time\" : 1565152189\n" + + " }"; + + String url = configStorage.getApiUrl(PROLONG_TRY); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + + final WxCpTpProlongTryResult prolongTryResult = wxCpTpEditionService.prolongTry(buyerCorpId, prolongDays, appId); + + assertNotNull(prolongTryResult); + + assertEquals(prolongTryResult.getTryEndTime(), tryEndTime); + + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImplTest.java new file mode 100644 index 0000000000..7ad22c6543 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImplTest.java @@ -0,0 +1,537 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.bean.license.*; +import me.chanjar.weixin.cp.bean.license.account.*; +import me.chanjar.weixin.cp.bean.license.order.*; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl; +import me.chanjar.weixin.cp.tp.service.WxCpTpLicenseService; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.*; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.License.*; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.when; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +/** + * 许可证账号服务测试 + * + * @author Totoro created on 2022/6/27 16:34 + */ +public class WxCpTpLicenseServiceImplTest { + + @Mock + private WxCpTpServiceApacheHttpClientImpl wxCpTpService; + + private WxCpTpConfigStorage configStorage; + + private WxCpTpLicenseService wxCpTpLicenseService; + + /** + * Sets up. + */ + @BeforeClass + public void setUp() { + MockitoAnnotations.initMocks(this); + configStorage = new WxCpTpDefaultConfigImpl(); + when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage); + wxCpTpLicenseService = new WxCpTpLicenseServiceImpl(wxCpTpService); + } + + + /** + * Test crate new order. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testCrateNewOrder() throws WxErrorException { + String orderId = "OASFNAISFASFA252462"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"order_id\": \"OASFNAISFASFA252462\"\n" + + "}"; + String url = + configStorage.getApiUrl(CREATE_NEW_ORDER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseNewOrderRequest orderRequest = WxCpTpLicenseNewOrderRequest.builder() + .accountCount(WxCpTpLicenseAccountCount.builder().baseCount(5).externalContactCount(6).build()) + .buyerUserId("test") + .corpId("test") + .accountDuration(WxCpTpLicenseAccountDuration.builder().months(5).build()) + .build(); + final WxCpTpLicenseCreateOrderResp newOrder = wxCpTpLicenseService.createNewOrder(orderRequest); + assertNotNull(newOrder); + assertEquals(newOrder.getOrderId(), orderId); + } + + + /** + * Test create renew order job. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testCreateRenewOrderJob() throws WxErrorException { + String jobId = "test123456"; + String result = "{\n" + + " \"errcode\":0,\n" + + " \"errmsg\":\"ok\",\n" + + " \"jobid\":\"test123456\",\n" + + " \"invalid_account_list\":[\n" + + " {\n" + + " \"errcode\":1,\n" + + " \"errmsg\":\"error\",\n" + + " \"userid\":\"userid1\",\n" + + " \"type\":1\n" + + " },\n" + + " {\n" + + " \"errcode\":0,\n" + + " \"errmsg\":\"ok\",\n" + + " \"userid\":\"userid2\",\n" + + " \"type\":1\n" + + " }\n" + + " ]\n" + + "}"; + String url = + configStorage.getApiUrl(CREATE_RENEW_ORDER_JOB) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + List accountList = new ArrayList<>(); + accountList.add(WxCpTpLicenseBaseAccount.builder().type(1).userid("userid1").build()); + accountList.add(WxCpTpLicenseBaseAccount.builder().type(1).userid("userid2").build()); + WxCpTpLicenseRenewOrderJobRequest orderJobRequest = WxCpTpLicenseRenewOrderJobRequest.builder() + .jobId("test123456") + .accountList(accountList).build(); + final WxCpTpLicenseRenewOrderJobResp renewOrderJob = wxCpTpLicenseService.createRenewOrderJob(orderJobRequest); + assertNotNull(renewOrderJob); + + assertEquals(renewOrderJob.getJobId(), jobId); + + assertEquals(renewOrderJob.getInvalidAccountList().size(), accountList.size()); + } + + /** + * Test submit renew order job. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testSubmitRenewOrderJob() throws WxErrorException { + String orderId = "test5915231"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"order_id\": \"test5915231\"\n" + + "}"; + String url = + configStorage.getApiUrl(SUBMIT_ORDER_JOB) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseRenewOrderRequest renewOrderRequest = WxCpTpLicenseRenewOrderRequest.builder() + .jobId("test123456") + .accountDuration(WxCpTpLicenseAccountDuration.builder().months(5).build()) + .buyerUserId("test") + .build(); + WxCpTpLicenseCreateOrderResp createOrderResp = wxCpTpLicenseService.submitRenewOrder(renewOrderRequest); + assertNotNull(createOrderResp); + + assertEquals(createOrderResp.getOrderId(), orderId); + } + + /** + * Test get order list. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetOrderList() throws WxErrorException { + String nextCursor = "DSGAKAFA4524"; + String orderId = "test123"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"next_cursor\":\"DSGAKAFA4524\",\n" + + "\t\"has_more\":1,\n" + + "\t\"order_list\":[\n" + + "\t\t{\n" + + "\t\t\t\"order_id\":\"test123\",\n" + + "\t\t\t\"order_type\":1\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + + String url = configStorage.getApiUrl(LIST_ORDER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseOrderListResp orderList = wxCpTpLicenseService.getOrderList("test", new Date(), new Date(), null, 10); + assertNotNull(orderList); + + assertEquals(orderList.getNextCursor(), nextCursor); + + assertEquals(orderList.getOrderList().get(0).getOrderId(), orderId); + + } + + /** + * Test get order. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetOrder() throws WxErrorException { + String corpId = "ASFASF4254"; + String orderId = "FASASIFJ9W125234"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"order\":{\n" + + "\t\t\"order_id\":\"FASASIFJ9W125234\",\n" + + "\t\t\"order_type\":1,\n" + + "\t\t\"order_status\":1,\n" + + "\t\t\"corpid\":\"ASFASF4254\",\n" + + "\t\t\"price\":10000,\n" + + "\t\t\"account_count\":{\n" + + "\t \t \"base_count\":100,\n" + + " \t \"external_contact_count\":100\n" + + "\t },\n" + + "\t\t \"account_duration\":\n" + + " \t\t {\n" + + "\t \t \t\"months\":2\n" + + " \t \t \t},\n" + + "\t\t\"create_time\":150000000,\n" + + "\t \"pay_time\":1550000000\n" + + "\t}\n" + + "}"; + String url = configStorage.getApiUrl(GET_ORDER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseOrderInfoResp orderInfo = wxCpTpLicenseService.getOrderInfo(orderId); + assertNotNull(orderInfo); + + assertNotNull(orderInfo.getOrder()); + + assertEquals(orderInfo.getOrder().getOrderId(), orderId); + + assertEquals(orderInfo.getOrder().getCorpId(), corpId); + + + } + + + /** + * Test get order account. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetOrderAccount() throws WxErrorException { + String orderId = "ASFASF4254"; + String activeCode = "FASASIFJ9W125234"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"next_cursor\": \"ASFASF4254\",\n" + + "\t\"has_more\":1,\n" + + "\t\"account_list\":[\n" + + "\t\t{\n" + + "\t\t\t\"active_code\": \"FASASIFJ9W125234\",\n" + + "\t\t\t\"userid\":\"XXX\",\n" + + "\t\t\t\"type\": 1\n" + + "\t\t},\n" + + "\t\t{\n" + + "\t\t\t\"active_code\": \"code2\",\n" + + "\t\t\t\"userid\":\"XXX\",\n" + + "\t\t\t\"type\": 2\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + + String url = + configStorage.getApiUrl(LIST_ORDER_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseOrderAccountListResp orderAccountList = wxCpTpLicenseService.getOrderAccountList(orderId, 10, null); + assertNotNull(orderAccountList); + + assertNotNull(orderAccountList.getAccountList()); + + assertEquals(orderAccountList.getAccountList().get(0).getActiveCode(), activeCode); + + + } + + + /** + * Test active account. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testActiveAccount() throws WxErrorException { + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\"\n" + + "}"; + + String url = + configStorage.getApiUrl(ACTIVE_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpBaseResp wxCpBaseResp = wxCpTpLicenseService.activeCode("123456", "123456", "123456"); + assertNotNull(wxCpBaseResp); + } + + /** + * Test batch active account. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testBatchActiveAccount() throws WxErrorException { + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"active_result\":[\n" + + "\t{\n" + + "\t\t\"active_code\" : \"aASFINAJOFASF\",\n" + + "\t\t\"userid\": \"SAGASGSD\",\n" + + "\t\t\"errcode\":0\n" + + "\t},\n" + + "\t{\n" + + "\t\t\"active_code\" : \"ASDEGAFAd\",\n" + + "\t\t\"userid\": \"dsfafD\",\n" + + "\t\t\"errcode\":0\n" + + "\t}]\n" + + "}"; + String url = + configStorage.getApiUrl(BATCH_ACTIVE_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + List accountList = new ArrayList<>(); + accountList.add(WxCpTpLicenseActiveAccount.builder().userid("SAGASGSD").activeCode("aASFINAJOFASF").build()); + accountList.add(WxCpTpLicenseActiveAccount.builder().userid("dsfafD").activeCode("ASDEGAFAd").build()); + WxCpTpLicenseBatchActiveResultResp wxCpTpLicenseBatchActiveResultResp = wxCpTpLicenseService.batchActiveCode( + "123456", accountList); + assertNotNull(wxCpTpLicenseBatchActiveResultResp); + + assertEquals(wxCpTpLicenseBatchActiveResultResp.getActiveResults().size(), accountList.size()); + + assertEquals(wxCpTpLicenseBatchActiveResultResp.getActiveResults().get(0).getActiveCode(), "aASFINAJOFASF"); + } + + + /** + * Test get active info by code. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetActiveInfoByCode() throws WxErrorException { + String activeCode = "asgasfasfa"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"active_info\": {\n" + + "\t\t\"active_code\": \"asgasfasfa\",\n" + + "\t\t\"type\": 1,\n" + + "\t\t\"status\": 1,\n" + + "\t\t\"userid\": \"asfasgasg\",\n" + + "\t\t\"create_time\":1640966400,\n" + + "\t\t\"active_time\": 1640966400,\n" + + "\t\t\"expire_time\":1640966400\n" + + "\t}\n" + + "}"; + + String url = + configStorage.getApiUrl(GET_ACTIVE_INFO_BY_CODE) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseCodeInfoResp activeInfoByCode = wxCpTpLicenseService.getActiveInfoByCode("123456", "safasg"); + assertNotNull(activeInfoByCode); + + assertEquals(activeInfoByCode.getActiveCodeInfo().getActiveCode(), activeCode); + + + } + + + /** + * Test get active info by user. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetActiveInfoByUser() throws WxErrorException { + String activeCode = "asfaisfhiuaw"; + String userid = "asfasgasga"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"active_status\": 1,\n" + + "\t\"active_info_list\": \n" + + "\t[\n" + + "\t\t {\n" + + "\t\t\t\"active_code\": \"asfaisfhiuaw\",\n" + + "\t\t\t\"type\": 1,\n" + + "\t\t\t\"userid\": \"asfasgasga\",\n" + + "\t\t\t\"active_time\": 1640966400,\n" + + "\t\t\t\"expire_time\":1640966400\n" + + " \t \t },\n" + + " {\n" + + "\t\t\t\"active_code\": \"gasdawsd\",\n" + + "\t\t\t\"type\": 2,\n" + + "\t\t\t\"userid\": \"asdfasfasf\",\n" + + "\t\t\t\"active_time\":1640966400,\n" + + "\t\t\t\"expire_time\":1640966400\n" + + "\t\t }\n" + + " ]\n" + + "}"; + + String url = + configStorage.getApiUrl(GET_ACTIVE_INFO_BY_USER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseActiveInfoByUserResp activeInfoByUser = wxCpTpLicenseService.getActiveInfoByUser("123456", userid); + assertNotNull(activeInfoByUser); + + assertEquals(activeInfoByUser.getActiveStatus().intValue(), 1); + + assertEquals(activeInfoByUser.getActiveInfoList().get(0).getActiveCode(), activeCode); + } + + /** + * Test batch get active info by user. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testBatchGetActiveInfoByUser() throws WxErrorException { + String activeCode = "asgasgasgas"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"active_info_list\": [\n" + + "\t\t{\n" + + "\t\t\t\"active_code\": \"asgasgasgas\",\n" + + "\t\t\t\"type\": 1,\n" + + "\t\t\t\"status\": 1,\n" + + "\t\t\t\"userid\": \"gadfFDF\",\n" + + "\t\t\t\"create_time\":1640966400,\n" + + "\t\t\t\"active_time\": 1640966400,\n" + + "\t\t\t\"expire_time\":1640966400\n" + + "\t\t},\n" + + "\t\t{\n" + + "\t\t\t\"active_code\": \"awsgdgasdasd\",\n" + + "\t\t\t\"type\": 2,\n" + + "\t\t\t\"status\": 1,\n" + + "\t\t\t\"userid\": \"SGASRDASGAQ\",\n" + + "\t\t\t\"create_time\":1640966400,\n" + + "\t\t\t\"active_time\": 1640966400,\n" + + "\t\t\t\"expire_time\":1640966400\n" + + "\t\t}\n" + + "\t],\n" + + "\t\"invalid_active_code_list\":[\"fasgasga\"]\n" + + "}"; + + + String url = + configStorage.getApiUrl(BATCH_GET_ACTIVE_INFO_BY_CODE) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + Set codes = new HashSet<>(); + codes.add("asgasgasgas"); + codes.add("awsgdgasdasd"); + codes.add("fasgasga"); + WxCpTpLicenseBatchCodeInfoResp codeInfoResp = wxCpTpLicenseService.batchGetActiveInfoByCode(codes, "asfasfas"); + assertNotNull(codeInfoResp); + + assertEquals(codeInfoResp.getActiveCodeInfoList().size(), codes.size() - 1); + + assertNotNull(codeInfoResp.getInvalidActiveCodeList()); + + + } + + + /** + * Test get corp account list. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetCorpAccountList() throws WxErrorException { + String nextCursor = "asfasdfas"; + String userid = "asdasdasd"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"next_cursor\":\"asfasdfas\",\n" + + "\t\"has_more\":1,\n" + + "\t\"account_list\":[\n" + + "\t\t{\n" + + "\t\t\t\"userid\": \"asdasdasd\",\n" + + "\t\t\t\"type\": 1,\n" + + "\t\t\t\"expire_time\":1500000000,\n" + + "\t\t\t\"active_time\":1500000000\n" + + "\t\t},\n" + + "\t\t{\n" + + "\t\t\t\"userid\": \"asgasgasdasd\",\n" + + "\t\t\t\"type\": 1,\n" + + "\t\t\t\"expire_time\":1500000000,\n" + + "\t\t\t\"active_time\":1500000000\n" + + "\t\t}\n" + + "\t]\n" + + "}"; + + String url = + configStorage.getApiUrl(LIST_ACTIVED_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + WxCpTpLicenseCorpAccountListResp accountList = wxCpTpLicenseService.getCorpAccountList("123456", 10, null); + assertNotNull(accountList); + + assertNotNull(accountList.getOrderList()); + + assertEquals(accountList.getNextCursor(), nextCursor); + + assertEquals(accountList.getOrderList().get(0).getUserid(), userid); + } + + + /** + * Test batch transfer license. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testBatchTransferLicense() throws WxErrorException { + String handoverUserid = "dazdasfasf"; + String takeoverUserid = "asfasfasf"; + String result = "{\n" + + "\t\"errcode\": 0,\n" + + "\t\"errmsg\": \"ok\",\n" + + "\t\"transfer_result\":[\n" + + "\t{\n" + + "\t\t\"handover_userid\":\"dazdasfasf\",\n" + + "\t\t\"takeover_userid\":\"asfasfasf\",\n" + + "\t\t\"errcode\":0\n" + + "\t}]\n" + + "}"; + + String url = + configStorage.getApiUrl(BATCH_TRANSFER_LICENSE) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken(); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + List transferList = new ArrayList<>(); + transferList.add(WxCpTpLicenseTransfer.builder().handoverUserId(handoverUserid).takeoverUserId(takeoverUserid).build()); + WxCpTpLicenseBatchTransferResp licenseBatchTransferResp = wxCpTpLicenseService.batchTransferLicense("123456", + transferList); + assertNotNull(licenseBatchTransferResp); + + assertNotNull(licenseBatchTransferResp.getTransferResult()); + + assertEquals(licenseBatchTransferResp.getTransferResult().size(), transferList.size()); + + } + + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImplTest.java new file mode 100644 index 0000000000..91df78051d --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImplTest.java @@ -0,0 +1,163 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails; +import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult; +import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; +import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl; +import me.chanjar.weixin.cp.tp.service.WxCpTpOrderService; +import org.apache.commons.lang3.time.DateUtils; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Date; +import java.util.List; +import java.util.Objects; + +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER; +import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER_LIST; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.when; +import static org.testng.Assert.*; + +/** + * 应用版本付费订单相关接口测试 + */ +public class WxCpTpOrderServiceImplTest { + + @Mock + private WxCpTpServiceApacheHttpClientImpl wxCpTpService; + + private WxCpTpConfigStorage configStorage; + + private WxCpTpOrderService wxCpTpOrderService; + + /** + * Sets up. + */ + @BeforeClass + public void setUp() { + MockitoAnnotations.initMocks(this); + configStorage = new WxCpTpDefaultConfigImpl(); + when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage); + wxCpTpOrderService = new WxCpTpOrderServiceImpl(wxCpTpService); + } + + + /** + * 获取订单详情 + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetOrder() throws WxErrorException { + String orderId = "2018091822ks1sd3s"; + + String result = "" + + "{\n" + + " \"errcode\" : 0,\n" + + " \"errmsg\" : \"ok\",\n" + + " \"orderid\" : \"2018091822ks1sd3s\",\n" + + " \"order_status\" : 1,\n" + + " \"order_type\" : 1,\n" + + " \"paid_corpid\" : \"wwfedd7e5291d63aaa\",\n" + + " \"operator_id\" : \"zhangsan\",\n" + + " \"suiteid\" : \"wx67cce113441ccaaa\",\n" + + " \"appid\" : 1,\n" + + " \"edition_id\" : \"RLS65535\",\n" + + " \"edition_name\" : \"协同版\",\n" + + " \"price\" : 100,\n" + + " \"user_count\" : 1000,\n" + + " \"order_period\": 365,\n" + + " \"order_time\" : 1533702999,\n" + + " \"paid_time\" : 1533702910,\n" + + " \"begin_time\" : 1533702910,\n" + + " \"end_time\" : 1553515904,\n" + + " \"order_from\" : 1,\n" + + " \"operator_corpid\" : \"wwfedd7e5292d63aaa\",\n" + + " \"service_share_amount\" : 60,\n" + + " \"platform_share_amount\" : 10,\n" + + " \"dealer_share_amount\" : 30,\n" + + " \"dealer_corp_info\":\n" + + " {\n" + + " \"corpid\": \"xxxx\",\n" + + " \"corp_name\": \"name\"\n" + + " }\n" + + " }"; + String url = configStorage.getApiUrl(GET_ORDER); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + + final WxCpTpOrderDetails orderDetails = wxCpTpOrderService.getOrder(orderId); + + assertNotNull(orderDetails); + + assertEquals(orderDetails.getOrderId(), orderId); + + } + + /** + * 获取订单列表 + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testGetOrderList() throws WxErrorException { + String orderId = "2018091822ks1sd3s"; + Date startTime = new Date(); + Date endTime = DateUtils.addDays(startTime, 5); + Integer testMode = 0; + + String result = "" + + " {\n" + + " \"errcode\" : 0,\n" + + " \"errmsg\" : \"ok\",\n" + + " \"order_list\": [\n" + + " {\n" + + " \"orderid\" : \"2018091822ks1sd3s\",\n" + + " \"order_status\" : 1,\n" + + " \"order_type\" : 1,\n" + + " \"paid_corpid\" : \"wwfedd7e5292d63aaa\",\n" + + " \"operator_id\" : \"zhangsan\",\n" + + " \"suiteid\" : \"wx67cce113441cc7a6\",\n" + + " \"appid\" : 1,\n" + + " \"edition_id\" : \"RLS65535\",\n" + + " \"edition_name\" : \"协同版\",\n" + + " \"price\" : 100,\n" + + " \"user_count\" : 1000,\n" + + " \"order_period\": 365,\n" + + " \"order_time\" : 1533702999,\n" + + " \"paid_time\" : 1533702910,\n" + + " \"begin_time\" : 1533702910,\n" + + " \"end_time\" : 1553515904,\n" + + " \"order_from\" : 1,\n" + + " \"operator_corpid\" : \"wwfedd7e5292d63aaa\",\n" + + " \"service_share_amount\" : 60,\n" + + " \"platform_share_amount\" : 10,\n" + + " \"dealer_share_amount\" : 30,\n" + + " \"dealer_corp_info\":\n" + + " {\n" + + " \"corpid\": \"xxxx\",\n" + + " \"corp_name\": \"name\"\n" + + " }\n" + + " }]\n" + + " }"; + + String url = configStorage.getApiUrl(GET_ORDER_LIST); + when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result); + + final WxCpTpOrderListGetResult orderList = wxCpTpOrderService.getOrderList(startTime, endTime, testMode); + + assertNotNull(orderList); + + final List detailsList = orderList.getOrderList(); + + assertTrue(Objects.nonNull(detailsList) && !detailsList.isEmpty()); + + assertEquals(detailsList.get(0).getOrderId(), orderId); + } + + +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImplTest.java index e0ded23d26..75927af4d9 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImplTest.java @@ -4,6 +4,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.redis.RedissonWxRedisOps; import me.chanjar.weixin.cp.bean.WxCpProviderToken; +import me.chanjar.weixin.cp.bean.WxCpTpCorpId2OpenCorpId; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.config.impl.WxCpTpRedissonConfigImpl; import me.chanjar.weixin.cp.tp.service.WxCpTpService; @@ -23,15 +24,45 @@ */ public class WxCpTpServiceApacheHttpClientImplTest { + /** + * The constant API_URL. + */ public static final String API_URL = "https://qyapi.weixin.qq.com"; + /** + * The constant SUITE_ID. + */ public static final String SUITE_ID = "xxxxxx"; + /** + * The constant SUITE_SECRET. + */ public static final String SUITE_SECRET = "xxxxxx"; + /** + * The constant TOKEN. + */ public static final String TOKEN = "xxxxxx"; + /** + * The constant AES_KEY. + */ public static final String AES_KEY = "xxxxxx"; + /** + * The constant PROVIDER_CORP_ID. + */ public static final String PROVIDER_CORP_ID = "xxxxxx"; + /** + * The constant CORP_SECRET. + */ public static final String CORP_SECRET = "xxxxxx"; + /** + * The constant PROVIDER_SECRET. + */ public static final String PROVIDER_SECRET = CORP_SECRET; + /** + * The constant REDIS_ADDR. + */ public static final String REDIS_ADDR = "redis://xxx.xxx.xxx.xxx:6379"; + /** + * The constant REDIS_PASSWD. + */ public static final String REDIS_PASSWD = "xxxxxx"; private static final String AUTH_CORP_ID = "xxxxxx"; @@ -39,18 +70,31 @@ public class WxCpTpServiceApacheHttpClientImplTest { private WxCpTpService wxCpTpService; + /** + * Sets up. + */ @BeforeMethod public void setUp() { wxCpTpService = new WxCpTpServiceApacheHttpClientImpl(); wxCpTpService.setWxCpTpConfigStorage(wxCpTpConfigStorage()); } + /** + * Wx cp tp config storage wx cp tp config storage. + * + * @return the wx cp tp config storage + */ public WxCpTpConfigStorage wxCpTpConfigStorage() { return WxCpTpRedissonConfigImpl.builder().baseApiUrl(API_URL).suiteId(SUITE_ID).suiteSecret(SUITE_SECRET) .token(TOKEN).aesKey(AES_KEY).corpId(PROVIDER_CORP_ID).corpSecret(CORP_SECRET).providerSecret(PROVIDER_SECRET) .wxRedisOps(new RedissonWxRedisOps(redissonClient())).build(); } + /** + * Redisson client redisson client. + * + * @return the redisson client + */ public RedissonClient redissonClient() { Config config = new Config(); config.useSingleServer().setAddress(REDIS_ADDR).setConnectTimeout(10 * 1000).setDatabase(6) @@ -58,6 +102,11 @@ public RedissonClient redissonClient() { return Redisson.create(config); } + /** + * Test get suite access token entity. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetSuiteAccessTokenEntity() throws WxErrorException { wxCpTpService.getWxCpTpConfigStorage().expireSuiteAccessToken(); @@ -71,6 +120,11 @@ public void testGetSuiteAccessTokenEntity() throws WxErrorException { StringUtils.isNotBlank(suiteAccessTokenEntity.getAccessToken()) && suiteAccessTokenEntity.getExpiresIn() > 0); } + /** + * Test get wx cp provider token entity. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetWxCpProviderTokenEntity() throws WxErrorException { wxCpTpService.getWxCpTpConfigStorage().expireProviderToken(); @@ -84,6 +138,11 @@ public void testGetWxCpProviderTokenEntity() throws WxErrorException { .assertTrue(StringUtils.isNotBlank(providerToken.getProviderAccessToken()) && providerToken.getExpiresIn() > 0); } + /** + * Test get corp token. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetCorpToken() throws WxErrorException { wxCpTpService.getWxCpTpConfigStorage().expireAccessToken(AUTH_CORP_ID); @@ -93,6 +152,11 @@ public void testGetCorpToken() throws WxErrorException { System.out.println("accessToken:" + accessToken); } + /** + * Test get auth corp js api ticket. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetAuthCorpJsApiTicket() throws WxErrorException { wxCpTpService.getWxCpTpConfigStorage().expireAuthCorpJsApiTicket(AUTH_CORP_ID); @@ -102,6 +166,11 @@ public void testGetAuthCorpJsApiTicket() throws WxErrorException { System.out.println("authCorpJsApiTicket:" + authCorpJsApiTicket); } + /** + * Test get suite js api ticket. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGetSuiteJsApiTicket() throws WxErrorException { wxCpTpService.getWxCpTpConfigStorage().expireAuthSuiteJsApiTicket(AUTH_CORP_ID); @@ -110,4 +179,10 @@ public void testGetSuiteJsApiTicket() throws WxErrorException { suiteJsApiTicket = wxCpTpService.getSuiteJsApiTicket(AUTH_CORP_ID); System.out.println("suiteJsApiTicket:" + suiteJsApiTicket); } + + @Test + public void testCorpId2OpenCorpId() throws WxErrorException { + WxCpTpCorpId2OpenCorpId openCorpId = wxCpTpService.corpId2OpenCorpId("wpVIkfEAAAu2wGiOEeNMQ69afwLM6BbA"); + System.out.println("openCorpId:" + openCorpId); + } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImplTest.java index 1dc1148582..7ff33045fd 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImplTest.java @@ -25,7 +25,7 @@ * 企业微信-第三方开发-标签管理相关测试 * * @author zhangq - * @since 2021/2/15 9:14 + * @since 2021 /2/15 9:14 */ public class WxCpTpTagServiceImplTest { @@ -36,6 +36,9 @@ public class WxCpTpTagServiceImplTest { private WxCpTpTagService wxCpTpTagService; + /** + * Sets up. + */ @BeforeClass public void setUp() { MockitoAnnotations.initMocks(this); @@ -44,6 +47,11 @@ public void setUp() { wxCpTpTagService = new WxCpTpTagServiceImpl(wxCpTpService); } + /** + * Test create. + * + * @throws WxErrorException the wx error exception + */ @Test public void testCreate() throws WxErrorException { String url = configStorage.getApiUrl(TAG_CREATE); @@ -55,10 +63,16 @@ public void testCreate() throws WxErrorException { assertEquals(wxCpTpTagService.create(tagName, tagId), String.valueOf(tagId)); } + /** + * Test list all. + * + * @throws WxErrorException the wx error exception + */ @Test public void testListAll() throws WxErrorException { String url = configStorage.getApiUrl(TAG_LIST); - String result = "{\"errcode\":0,\"errmsg\":\"ok\",\"taglist\":[{\"tagid\":1,\"tagname\":\"a\"},{\"tagid\":2,\"tagname\":\"b\"}]}"; + String result = "{\"errcode\":0,\"errmsg\":\"ok\",\"taglist\":[{\"tagid\":1,\"tagname\":\"a\"},{\"tagid\":2," + + "\"tagname\":\"b\"}]}"; when(wxCpTpService.get(eq(url), anyString())).thenReturn(result); List wxCpTpTags = wxCpTpTagService.listAll(); @@ -68,11 +82,17 @@ public void testListAll() throws WxErrorException { assertEquals(wxCpTpTags.get(1).getTagName(), "b"); } + /** + * Test get. + * + * @throws WxErrorException the wx error exception + */ @Test public void testGet() throws WxErrorException { String tagId = "anyTagId"; String url = String.format(configStorage.getApiUrl(TAG_GET), tagId); - String result = "{\"errcode\":0,\"errmsg\":\"ok\",\"tagname\":\"乒乓球协会\",\"userlist\":[{\"userid\":\"zhangsan\",\"name\":\"李四\"}],\"partylist\":[2]}"; + String result = "{\"errcode\":0,\"errmsg\":\"ok\",\"tagname\":\"乒乓球协会\",\"userlist\":[{\"userid\":\"zhangsan\"," + + "\"name\":\"李四\"}],\"partylist\":[2]}"; when(wxCpTpService.get(eq(url), anyString())).thenReturn(result); WxCpTpTagGetResult getResult = wxCpTpTagService.get(tagId); @@ -81,6 +101,11 @@ public void testGet() throws WxErrorException { assertEquals(getResult.getUserlist().get(0).getUserId(), "zhangsan"); } + /** + * Test add users 2 tag. + * + * @throws WxErrorException the wx error exception + */ @Test public void testAddUsers2Tag() throws WxErrorException { String tagId = "anyTagId"; @@ -113,6 +138,11 @@ public void testAddUsers2Tag() throws WxErrorException { assertNull(postResult.getInvalidUsers()); } + /** + * Test remove users from tag. + * + * @throws WxErrorException the wx error exception + */ @Test public void testRemoveUsersFromTag() throws WxErrorException { String tagId = "anyTagId"; @@ -129,7 +159,8 @@ public void testRemoveUsersFromTag() throws WxErrorException { // 部分失败时返回对象 String partFailure = "{\"errcode\":0,\"errmsg\":\"ok\",\"invalidlist\":\"usr1|usr2\",\"invalidparty\":[2,3,4]}"; when(wxCpTpService.post(eq(url), anyString())).thenReturn(partFailure); - postResult = wxCpTpTagService.removeUsersFromTag(tagId, Arrays.asList("usr1", "usr2"), Arrays.asList("dept1", "dept2")); + postResult = wxCpTpTagService.removeUsersFromTag(tagId, Arrays.asList("usr1", "usr2"), Arrays.asList("dept1", + "dept2")); assertEquals((int) postResult.getErrCode(), 0); assertEquals(postResult.getInvalidUserList().size(), 2); assertEquals(postResult.getInvalidUserList().get(1), "usr2"); @@ -139,7 +170,8 @@ public void testRemoveUsersFromTag() throws WxErrorException { // 全部失败时返回对象 String allFailure = "{\"errcode\":40070,\"errmsg\":\"all list invalid \"}"; when(wxCpTpService.post(eq(url), anyString())).thenReturn(allFailure); - postResult = wxCpTpTagService.removeUsersFromTag(tagId, Arrays.asList("usr1", "usr2"), Arrays.asList("dept1", "dept2")); + postResult = wxCpTpTagService.removeUsersFromTag(tagId, Arrays.asList("usr1", "usr2"), Arrays.asList("dept1", + "dept2")); assertEquals((int) postResult.getErrCode(), 40070); assertNull(postResult.getInvalidParty()); assertNull(postResult.getInvalidUsers()); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtilTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtilTest.java index 62fbce13b8..fabe375750 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtilTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtilTest.java @@ -1,23 +1,26 @@ package me.chanjar.weixin.cp.util.crypto; -import com.google.common.base.CharMatcher; -import com.google.common.io.BaseEncoding; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; /** - * @author Binary Wang - * @date 2020-06-11 + * The type Wx cp crypt util test. + * + * @author Binary Wang created on 2020-06-11 */ public class WxCpCryptUtilTest { + /** + * Test. + */ @Test public void test() { String encodingAesKey = "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C"; final byte[] commonsCodec = Base64.decodeBase64(encodingAesKey + "="); - final byte[] guava = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey)); - final byte[] guava1 = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey + "=")); + final byte[] guava = java.util.Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " ")); + final byte[] guava1 = java.util.Base64.getDecoder().decode(StringUtils.remove(encodingAesKey + "=", " ")); assertEquals(commonsCodec, guava); assertEquals(guava1, guava); } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterForPrivatizedVersionTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterForPrivatizedVersionTest.java index 167de73c46..c73d68af88 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterForPrivatizedVersionTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterForPrivatizedVersionTest.java @@ -11,10 +11,13 @@ *
* * @author 庄壮壮 - * @since 2020-06-16 09:36 + * @since 2020 -06-16 09:36 */ public class WxCpUserGsonAdapterForPrivatizedVersionTest { + /** + * Test deserialize. + */ @Test public void testDeserialize() { final String userJson = "{\n" + @@ -31,13 +34,15 @@ public void testDeserialize() { " \"gender\": \"1\",\n" + " \"email\": \"zhangsan@gzdev.com\",\n" + " \"is_leader_in_dept\": [1, 0],\n" + - " \"avatar\": \"http://wx.qlogo.cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0\",\n" + + " \"avatar\": \"http://wx.qlogo" + + ".cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0\",\n" + " \"telephone\": \"020-123456\",\n" + " \"english_name\": \"jackzhang\",\n" + " \"extattr\": {\"attrs\":[{\"name\":\"爱好\",\"value\":\"旅游\"},{\"name\":\"卡号\",\"value\":\"1234567234\"}]},\n" + " \"status\": 1,\n" + " \"enable\": 0,\n" + - " \"qr_code\": \"https://wwlocal.qq.com/wework_admin/userQRCode?vcode=vc2140a8b3c6207c74&lvc=vcf6f1acfdc4b45088\"\n" + + " \"qr_code\": \"https://wwlocal.qq.com/wework_admin/userQRCode?vcode=vc2140a8b3c6207c74&lvc" + + "=vcf6f1acfdc4b45088\"\n" + "}"; final WxCpUser user = WxCpUser.fromJson(userJson); @@ -70,6 +75,9 @@ public void testDeserialize() { assertThat(user.getPositions()[1]).isEqualTo("后台工程师2"); } + /** + * Test serialize. + */ @Test public void testSerialize() { WxCpUser user = new WxCpUser(); @@ -84,6 +92,8 @@ public void testSerialize() { user.addExtAttr(attr1); user.addExtAttr(attr2); - assertThat(user.toJson()).isEqualTo("{\"order\":[1,2],\"positions\":[\"后台工程师1\",\"后台工程师2\"],\"english_name\":\"jackson\",\"extattr\":{\"attrs\":[{\"name\":\"爱好\",\"value\":\"旅游\"},{\"name\":\"卡号\",\"value\":\"1234567234\"}]},\"external_profile\":{}}"); + assertThat(user.toJson()).isEqualTo("{\"order\":[1,2],\"positions\":[\"后台工程师1\",\"后台工程师2\"]," + + "\"english_name\":\"jackson\",\"extattr\":{\"attrs\":[{\"name\":\"爱好\",\"value\":\"旅游\"},{\"name\":\"卡号\"," + + "\"value\":\"1234567234\"}]},\"external_profile\":{}}"); } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterTest.java index a83e8837d9..9b62a8d580 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapterTest.java @@ -15,6 +15,9 @@ */ public class WxCpUserGsonAdapterTest { + /** + * Test deserialize. + */ @Test public void testDeserialize() { final String userJson = "{\n" + @@ -29,7 +32,8 @@ public void testDeserialize() { " \"gender\": \"1\",\n" + " \"email\": \"zhangsan@gzdev.com\",\n" + " \"isleader\": 1,\n" + - " \"avatar\": \"http://wx.qlogo.cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0\",\n" + + " \"avatar\": \"http://wx.qlogo" + + ".cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0\",\n" + " \"telephone\": \"020-123456\",\n" + " \"address\": \"广州市海珠区新港中路\"," + " \"enable\": 1,\n" + @@ -136,6 +140,9 @@ public void testDeserialize() { } + /** + * Test serialize. + */ @Test public void testSerialize() { WxCpUser user = new WxCpUser(); diff --git a/weixin-java-cp/src/test/resources/test-config.sample.xml b/weixin-java-cp/src/test/resources/test-config.sample.xml index 76a74a25a3..5aa02af949 100644 --- a/weixin-java-cp/src/test/resources/test-config.sample.xml +++ b/weixin-java-cp/src/test/resources/test-config.sample.xml @@ -11,4 +11,23 @@ 企业号通讯录里的某个tagid 网页授权获取用户信息回调地址 webhook链接地址的key值 + + 会话存档的secret + 会话存档的lib path + -----BEGIN RSA PRIVATE KEY----- + MIICXAIBAAKBgQCTfm5cxqfglfOV7b/Z7OtTZZoZpk2EPTvVhn/ngsfKR899xRdR + 25s4h8HkK0XhxqYdOGoAdG3Gms+DvCSY/vu3UtImf0eZSNXpKZJBUnvUVjX4ivnr + Ohu2Rjw6O4gPjPnZKw8voCu0Nae1YLeNvFYw48PK7QrqmpHQv1sCd/8zHwIDAQAB + AoGAResz7xgfQghjsgnEHk9BGUY7YHhlG9CZWjYJ0Ro+ksYq9vClBuGHeitk/0CC + Pq7YVVbGbVPELFd8EvNwF/UcJsMlvFis16FzNS60Hn7M/o82gI6AVhSQmocoGhNs + MIKxTnXRqqlKFbCdcSfG+hQP7syHah6Z8UhLYuEA8s/ppd0CQQD99HTSvB4P5FfL + rlKTz6w6uh4qBYl53u5cLQxCRFGgXD6HvPnEwdzQf+2LCVM1zIhyxw2Kak1U467Q + 6JizEuHDTC2YljEbg/j+/AlpA/Ua5HQYnH5yD3DCK7rQyTvqE5gU+CfRbwTbLGre + fk/WJK4iqizgZobNRyUCQGB7jR5b8K7NsX7SoV7v/PFOsoj4G2W5q7LSz4GaoXGl + 3F+dSlXPYHdTow3dzfgVDldEzgoThs5UWMTQvBUZch0= + -----END RSA PRIVATE KEY----- + + + /www/osfile/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll,WeWorkFinanceSdk.dll,libWeWorkFinanceSdk_Java.so + diff --git a/weixin-java-cp/src/test/resources/testng.xml b/weixin-java-cp/src/test/resources/testng.xml index 96da66bd21..81f5a42fcb 100644 --- a/weixin-java-cp/src/test/resources/testng.xml +++ b/weixin-java-cp/src/test/resources/testng.xml @@ -8,7 +8,7 @@ - + diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 1dba48165a..fe1715dc1d 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B weixin-java-miniapp diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCloudService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCloudService.java index 02c363a3a0..4e18fec5c4 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCloudService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCloudService.java @@ -1,6 +1,7 @@ package cn.binarywang.wx.miniapp.api; import cn.binarywang.wx.miniapp.bean.cloud.*; +import cn.binarywang.wx.miniapp.bean.cloud.request.WxCloudSendSmsV2Request; import com.google.gson.JsonArray; import me.chanjar.weixin.common.error.WxErrorException; @@ -11,7 +12,7 @@ * 云开发相关接口. * * @author Binary Wang - * @date 2020 -01-22 + * created on 2020 -01-22 */ public interface WxMaCloudService { /** @@ -539,4 +540,15 @@ Long databaseMigrateImport(String env, String collectionName, String filePath, i * @throws WxErrorException . */ WxCloudDatabaseCollectionGetResult databaseCollectionGet(String env, Long limit, Long offset) throws WxErrorException; + + /** + * 发送携带 URL Link 的短信 + * + * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/cloudbase/cloudbase.sendSmsV2.html + * @param request + * @return WxCloudSendSmsV2Result + * @throws WxErrorException + */ + WxCloudSendSmsV2Result sendSmsV2(WxCloudSendSmsV2Request request) throws WxErrorException; + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCodeService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCodeService.java index 7c13818b81..88f7f9e99c 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCodeService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCodeService.java @@ -39,7 +39,7 @@ public interface WxMaCodeService { * @return List * @throws WxErrorException 获取失败时返回,具体错误码请看此接口的注释文档 */ - List getCategory() throws WxErrorException; + List getCategory() throws WxErrorException; /** * 获取小程序的第三方提交代码的页面配置(仅供第三方开发者代小程序调用). @@ -69,7 +69,7 @@ public interface WxMaCodeService { /** * 查询最新一次提交的审核状态(仅供第三方代小程序调用). - * + * 文档:文档地址 * @return 审核状态 * @throws WxErrorException 查询失败时返回,具体错误码请看此接口的注释文档 */ @@ -105,6 +105,14 @@ public interface WxMaCodeService { */ WxMaCodeVersionDistribution getSupportVersion() throws WxErrorException; + /** + * 查询小程序版本信息 + * + * @return 小程序的体验版和线上版本信息 + * @throws WxErrorException 失败时抛出,具体错误码请看此接口的注释文档 + */ + WxMaCodeVersionInfo getVersionInfo() throws WxErrorException; + /** * 设置最低基础库版本(仅供第三方代小程序调用). * diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaDeviceSubscribeService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaDeviceSubscribeService.java new file mode 100644 index 0000000000..f44f64e48d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaDeviceSubscribeService.java @@ -0,0 +1,40 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.device.WxMaDeviceSubscribeMessageRequest; +import cn.binarywang.wx.miniapp.bean.device.WxMaDeviceTicketRequest; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 小程序设备订阅消息相关 API + * 文档: + * + * @author JCLee + * @since 2021-12-16 17:13:35 + */ +public interface WxMaDeviceSubscribeService { + + /** + *
+   * 获取设备票据
+   * 应用场景:
+   * 小程序前端界面拉起设备消息授权订阅弹框界面
+   * 注意:
+   * 设备ticket有效时间为5分钟
+   * 
+ * @param deviceTicketRequest + * @return + * @throws WxErrorException + */ + String getSnTicket(WxMaDeviceTicketRequest deviceTicketRequest) throws WxErrorException; + + /** + *
+   * 发送设备订阅消息
+   * 
+ * + * @param deviceSubscribeMessageRequest 订阅消息 + * @throws WxErrorException . + */ + void sendDeviceSubscribeMsg(WxMaDeviceSubscribeMessageRequest deviceSubscribeMessageRequest) throws WxErrorException; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaExpressDeliveryReturnService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaExpressDeliveryReturnService.java new file mode 100644 index 0000000000..4254d18dfe --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaExpressDeliveryReturnService.java @@ -0,0 +1,22 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.express.request.WxMaExpressDeliveryReturnAddRequest; +import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressReturnInfoResult; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 退货组件 + */ +public interface WxMaExpressDeliveryReturnService { + + /** + * 获取支持的快递公司列表 + */ + String ADD_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/add"; + String GET_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/get"; + String UNBIND_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/unbind"; + + WxMaExpressReturnInfoResult addDeliveryReturn(WxMaExpressDeliveryReturnAddRequest wxMaExpressDeliveryReturnAddRequest) throws WxErrorException; + WxMaExpressReturnInfoResult getDeliveryReturn(String returnId) throws WxErrorException; + WxMaExpressReturnInfoResult unbindDeliveryReturn(String returnId) throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaExpressService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaExpressService.java index b8229ceeb3..72575db1d0 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaExpressService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaExpressService.java @@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPath; import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPrinter; import cn.binarywang.wx.miniapp.bean.express.request.*; +import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressInfoResult; import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressOrderInfoResult; import me.chanjar.weixin.common.error.WxErrorException; @@ -44,7 +45,7 @@ public interface WxMaExpressService { * @param wxMaExpressBindAccountRequest 物流账号对象 * @throws WxErrorException 请求失败时返回 */ - void bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException; + WxMaExpressInfoResult bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException; /** * 获取电子面单余额。仅在使用加盟类快递公司时,才可以调用。 @@ -136,4 +137,7 @@ public interface WxMaExpressService { * @throws WxErrorException 模拟更新订单状态失败时返回 */ void testUpdateOrder(WxMaExpressTestUpdateOrderRequest wxMaExpressTestUpdateOrderRequest) throws WxErrorException; + + + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java new file mode 100644 index 0000000000..29df4afcd6 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java @@ -0,0 +1,166 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmRequest; +import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmResponse; +import cn.binarywang.wx.miniapp.bean.delivery.AddOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.AddOrderResponse; +import cn.binarywang.wx.miniapp.bean.delivery.BindAccountResponse; +import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderResponse; +import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillRequest; +import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillResponse; +import cn.binarywang.wx.miniapp.bean.delivery.GetOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.GetOrderResponse; +import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderResponse; +import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceRequest; +import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceResponse; +import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceRequest; +import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceResponse; +import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillRequest; +import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 微信小程序即时配送服务. + *
+ *     文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/immediate-delivery/overview.html
+ * 
+ * + * @author Luo + * @version 1.0 + * created on 2021-10-13 16:40 + */ +public interface WxMaImmediateDeliveryService { + + /** + * 拉取已绑定账号. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getBindAccount.html
+   * 
+ * + * @return 响应 + * @throws WxErrorException 异常 + */ + BindAccountResponse getBindAccount() throws WxErrorException; + + /** + * 下配送单接口. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.addOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + AddOrderResponse addOrder(AddOrderRequest request) throws WxErrorException; + + /** + * 拉取配送单信息. + *
+   * 商家可使用本接口查询某一配送单的配送状态,便于商家掌握配送情况。
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + GetOrderResponse getOrder(GetOrderRequest request) throws WxErrorException; + + /** + * 取消配送单接口. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.cancelOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + CancelOrderResponse cancelOrder(CancelOrderRequest request) throws WxErrorException; + + /** + * 异常件退回商家商家确认收货接口. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.abnormalConfirm.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + AbnormalConfirmResponse abnormalConfirm(AbnormalConfirmRequest request) throws WxErrorException; + + /** + * 模拟配送公司更新配送单状态, 该接口只用于沙盒环境,即订单并没有真实流转到运力方. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.mockUpdateOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + MockUpdateOrderResponse mockUpdateOrder(MockUpdateOrderRequest request) throws WxErrorException; + + + /** + * 商户使用此接口向微信提供某交易单号对应的运单号。微信后台会跟踪运单的状态变化 + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/express_search.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + TraceWaybillResponse traceWaybill(TraceWaybillRequest request) throws WxErrorException; + + + /** + * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息 + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/express_search.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + QueryWaybillTraceResponse queryWaybillTrace(QueryWaybillTraceRequest request) + throws WxErrorException; + + + /** + * 传运单接口 follow_waybill 订阅微信后台会跟踪运单的状态变化 + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/express_open_msg.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + FollowWaybillResponse followWaybill(FollowWaybillRequest request) + throws WxErrorException; + + + /** + * 查运单接口 query_follow_trace + * + *
+   * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/express_open_msg.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + QueryFollowTraceResponse queryFollowTrace(QueryFollowTraceRequest request) + throws WxErrorException ; + + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaInternetService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaInternetService.java index 8e6a3e2d80..4d055ba2de 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaInternetService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaInternetService.java @@ -8,20 +8,36 @@ * 【小程序-服务端-网络】网络相关接口. * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/internet/internet.getUserEncryptKey.html * + * * @author chutian0124 */ public interface WxMaInternetService { /** + *
+   * 获取用户encryptKey。 会获取用户最近3次的key,每个key的存活时间为3600s。
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/internet/internet.getUserEncryptKey.html
+   * 接口地址:POST https://api.weixin.qq.com/wxa/business/getuserencryptkey?access_token=ACCESS_TOKEN&openid=OPENID&signature=SIGNATURE&sig_method=hmac_sha256
+   * @param openid 用户的openid
+   * @param signature 用sessionkey对空字符串签名得到的结果
+   * @param sigMethod 签名方法,只支持 hmac_sha256
+   * 
* - * + * @return {@link WxMaInternetResponse} + * @throws WxErrorException + */ + WxMaInternetResponse getUserEncryptKey(String openid, String signature, String sigMethod) throws WxErrorException; + + /** *
    * 获取用户encryptKey。 会获取用户最近3次的key,每个key的存活时间为3600s。
    * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/internet/internet.getUserEncryptKey.html
    * 接口地址:POST https://api.weixin.qq.com/wxa/business/getuserencryptkey?access_token=ACCESS_TOKEN&openid=OPENID&signature=SIGNATURE&sig_method=hmac_sha256
+   * @param openid 用户的openid
+   * @param sessionKey 用户的sessionKey
    * 
* * @return {@link WxMaInternetResponse} * @throws WxErrorException */ - WxMaInternetResponse getUserEncryptKey() throws WxErrorException; + WxMaInternetResponse getUserEncryptKey(String openid, String sessionKey) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLinkService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLinkService.java index 090ac95e35..f72645d290 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLinkService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLinkService.java @@ -3,6 +3,8 @@ import cn.binarywang.wx.miniapp.bean.shortlink.GenerateShortLinkRequest; import cn.binarywang.wx.miniapp.bean.urllink.GenerateUrlLinkRequest; +import cn.binarywang.wx.miniapp.bean.urllink.request.QueryUrlLinkRequest; +import cn.binarywang.wx.miniapp.bean.urllink.response.QueryUrlLinkResponse; import me.chanjar.weixin.common.error.WxErrorException; /** @@ -29,4 +31,14 @@ public interface WxMaLinkService { * @throws WxErrorException . */ String generateShortLink(GenerateShortLinkRequest request) throws WxErrorException; + + /** + * 查询 URL Link + * 接口文档: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-link/queryUrlLink.html + * + * @param request 请求 + * @return link地址 + * @throws WxErrorException . + */ + QueryUrlLinkResponse queryUrlLink(QueryUrlLinkRequest request) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveGoodsService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveGoodsService.java index d0e06d480f..7b41e0f78f 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveGoodsService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveGoodsService.java @@ -114,4 +114,32 @@ public interface WxMaLiveGoodsService { * @throws WxErrorException . */ WxMaLiveResult getApprovedGoods(Integer offset, Integer limit, Integer status) throws WxErrorException; + + /** + * 直播挂件设置全局key + *
+   * 若已设置此全局key,且添加商品时未指定goodsKey字段,则我们会使用此全局key作为该商品的goodsKey。 须注意的是,若全局key已设定,并添加了未指定goodsKey字段的商品之后,再重新设定不一样的全局key则会导致先前的映射失效。 为了避免映射失效,建议全局key只设定一次。
+   * 注意:key必须为字符串数组
+   * 调用额度:500次/一天
+   * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/setkey?access_token=
+   * 
+ * + * @param goodsKey 全局key + * @return 设置是否成功 + * @throws WxErrorException . + */ + boolean setKey(List goodsKey) throws WxErrorException; + + /** + * 查看当前设定的全局key + *
+   * 查看当前设定的全局key。
+   * 调用额度:500次/一天
+   * http请求方式:GET https://api.weixin.qq.com/wxaapi/broadcast/goods/getkey?access_token=
+   * 
+ * + * @return 全局key + * @throws WxErrorException . + */ + List getKey() throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveMemberService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveMemberService.java index 02e20923b4..a92330a93e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveMemberService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveMemberService.java @@ -9,7 +9,7 @@ * https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/role-manage.html * * @author Binary Wang - * @date 2021 -02-15 + * created on 2021 -02-15 */ public interface WxMaLiveMemberService { /** diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java index a90f4756b9..1473b54a17 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java @@ -4,6 +4,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import java.util.List; +import java.util.Map; /** *
@@ -83,7 +84,7 @@ public interface WxMaLiveService {
    * @return .
    * @throws WxErrorException .
    */
-  String getSharedCode(Integer roomId, String params) throws WxErrorException;
+  WxMaLiveSharedCode getSharedCode(Integer roomId, String params) throws WxErrorException;
 
   /**
    * 获取直播房间列表.(分页)
@@ -207,4 +208,190 @@ public interface WxMaLiveService {
    * @throws WxErrorException .
    */
   List getAssistantList(Integer roomId) throws WxErrorException;
+
+  /**
+   * 添加主播副号
+   * 

+ * 调用接口添加主播副号 + *

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/addsubanchor?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param username 用户微信号
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean addSubanchor(Integer roomId, String username) throws WxErrorException;
+
+  /**
+   * 修改主播副号
+   * 

+ * 调用接口修改主播副号 + *

+ * 调用频率: 10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/modifyassistant?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param username 小助手微信号
+   * @param username 用户微信号
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean modifySubanchor(Integer roomId, String username) throws WxErrorException;
+
+  /**
+   * 删除主播副号
+   * 

+ * 调用频率: 10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/deletesubanchor?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean deleteSubanchor(Integer roomId) throws WxErrorException;
+
+  /**
+   * 获取主播副号
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:GET https://api.weixin.qq.com/wxaapi/broadcast/room/getsubanchor?access_token=ACCESS_TOKEN + *

+ * @param roomId 直播间id + * @return . + * @throws WxErrorException . + */ + String getSubanchor(Integer roomId) throws WxErrorException; + + /** + * 开启/关闭直播间官方收录 + *

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatefeedpublic?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param isFeedsPublic 是否开启官方收录 【1: 开启,0:关闭】
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean updatefeedpublic(Integer roomId, Integer isFeedsPublic) throws WxErrorException;
+
+  /**
+   * 开启/关闭回放功能
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatereplay?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param closeReplay 是否关闭回放 【0:开启,1:关闭】
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean updatereplay(Integer roomId, Integer closeReplay) throws WxErrorException;
+
+  /**
+   * 开启/关闭客服功能
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatekf?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param closeKf 是否关闭客服 【0:开启,1:关闭】
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean updatekf(Integer roomId, Integer closeKf) throws WxErrorException;
+
+  /**
+   * 开启/关闭直播间全局禁言
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatecomment?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param banComment 1-禁言,0-取消禁言
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean updatecomment(Integer roomId, Integer banComment) throws WxErrorException;
+
+  /**
+   * 上下架商品
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/onsale?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param goodsId 商品ID
+   * @param onSale 上下架 【0:下架,1:上架】
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean onsale(Integer roomId, Integer goodsId, Integer onSale) throws WxErrorException;
+
+  /**
+   * 删除直播间商品
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param goodsId 商品ID
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean deleteInRoom(Integer roomId, Integer goodsId) throws WxErrorException;
+
+  /**
+   * 推送商品
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/push?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param goodsId 商品ID
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean push(Integer roomId, Integer goodsId) throws WxErrorException;
+
+  /**
+   * 直播间商品排序
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/sort?access_token=ACCESS_TOKEN + *

+   * @param roomId 房间ID
+   * @param goods 商品ID列表, 例如: [{"goodsId":"123"}, {"goodsId":"234"}]
+   * @return 是否成功
+   * @throws WxErrorException .
+   */
+  boolean sort(Integer roomId, List> goods) throws WxErrorException;
+
+  /**
+   * 下载商品讲解视频
+   * 

+ * 调用额度:10000次/一天 + *

+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/getVideo?access_token=ACCESS_TOKEN + *

+ * @param roomId 直播间id + * @param goodsId 商品ID + * @return . + * @throws WxErrorException . + */ + String getVideo(Integer roomId, Integer goodsId) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMarketingService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMarketingService.java new file mode 100644 index 0000000000..e8e59ca0a7 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMarketingService.java @@ -0,0 +1,35 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.marketing.WxMaUserAction; +import me.chanjar.weixin.common.error.WxErrorException; +import java.util.List; + +/** + * + * 微信营销接口 + * @author 184759547 + * @since : 2021/12/28 + */ +public interface WxMaMarketingService { + /** + *
+   * 创建数据源.
+   * 接口调用请求说明
+   * https://ad.weixin.qq.com/guide/457
+   * 
+ * + * @param type 用户行为源类型 + * @param name 用户行为源名称 必填 + * @param description 用户行为源描述,字段长度最小 1 字节,长度最大 128 字节 + */ + long addUserActionSets(String type, String name, String description) throws WxErrorException; + + /** + * 回传数据. + * 接口调用请求说明 + * https://ad.weixin.qq.com/guide/457 + * + * @param actions 用户行为源类型 + */ + String addUserAction(List actions, Long userActionSetId) throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMediaService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMediaService.java index 9cf42599af..519c5ef879 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMediaService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMediaService.java @@ -46,7 +46,7 @@ public interface WxMaMediaService { * @param inputStream 输入流 * @return the wx media upload result * @throws WxErrorException the wx error exception - * @see #uploadMedia(java.lang.String, java.io.File) #uploadMedia(java.lang.String, java.io.File) + * @see #uploadMedia(String, File) #uploadMedia(java.lang.String, java.io.File) */ WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputStream inputStream) throws WxErrorException; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaOpenApiService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaOpenApiService.java new file mode 100644 index 0000000000..438c43c6b8 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaOpenApiService.java @@ -0,0 +1,65 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.openapi.WxMiniGetApiQuotaResult; +import cn.binarywang.wx.miniapp.bean.openapi.WxMiniGetRidInfoResult; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * openApi管理 + * + * @author shuiyihan12 + * @see openApi管理 微信文档 + * @since 2023/7/7 17:07 + */ +public interface WxMaOpenApiService { + + /** + * 本接口用于清空公众号/小程序/第三方平台等接口的每日调用接口次数 + * HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN + * + * @return 是否成功 + * @throws WxErrorException the wx error exception + * @apiNote !!! 单小程序直接调用该方法 , 如多个appid调用此方法前请调用 {@link WxMaService#switchoverTo} 切换appid !!! + * @code wxMaService.getWxMaOpenApiService().clearQuota() //单个 + * @code wxMaService.switchoverTo(" appid ").getWxMaOpenApiService().clearQuota() //多个 + * @see 注意事项参考微信文档 + */ + boolean clearQuota() throws WxErrorException; + + /** + * 查询API调用额度 + * HTTP调用:https://api.weixin.qq.com/cgi-bin/openapi/quota/get?access_token=ACCESS_TOKEN + * + * @param cgiPath api的请求地址,例如"/cgi-bin/message/custom/send";不要前缀“https://api.weixin.qq.com” ,也不要漏了"/",否则都会76003的报错 + * @return 额度详情 + * @throws WxErrorException 微信异常 + * @see 注意事项参考微信文档 + */ + WxMiniGetApiQuotaResult getApiQuota(String cgiPath) throws WxErrorException; + + /** + * 查询rid信息 + * HTTP调用:https://api.weixin.qq.com/cgi-bin/openapi/rid/get?access_token=ACCESS_TOKEN + * + * @param rid 调用接口报错返回的rid + * @return 该rid对应的请求详情 + * @throws WxErrorException 微信异常 + * @see 注意事项参考微信文档 + */ + WxMiniGetRidInfoResult getRidInfo(String rid) throws WxErrorException; + + + /** + * 使用AppSecret重置 API 调用次数 + * HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota/v2 + * + * @return 是否成功 + * @throws WxErrorException 微信异常 + * @apiNote !!! 单小程序直接调用该方法 , 如多个appid调用此方法前请调用 {@link WxMaService#switchoverTo} 切换appid!!! + * 参考示例 + * @code wxMaService.getWxMaOpenApiService().clearQuotaByAppSecret() //单个 + * @code wxMaService.switchoverTo(" appid ").getWxMaOpenApiService().clearQuotaByAppSecret() //多个 + * @see 注意事项参考微信文档 + */ + boolean clearQuotaByAppSecret() throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaOrderShippingService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaOrderShippingService.java new file mode 100644 index 0000000000..322d740d5b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaOrderShippingService.java @@ -0,0 +1,89 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetListResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingIsTradeManagedResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * @author xzh + * created on 2023/5/17 16:49 + */ +public interface WxMaOrderShippingService { + /** + * 查询小程序是否已开通发货信息管理服务 + * + * @param appId 待查询小程序的 appid,非服务商调用时仅能查询本账号 + * @return WxMaOrderShippingInfoBaseResponse + * @throws WxErrorException e + */ + WxMaOrderShippingIsTradeManagedResponse isTradeManaged(String appId) + throws WxErrorException; + + /** + * 发货信息录入接口 + * + * @param request 请求 + * @return WxMaOrderShippingInfoBaseResponse + * @throws WxErrorException e + */ + WxMaOrderShippingInfoBaseResponse upload(WxMaOrderShippingInfoUploadRequest request) + throws WxErrorException; + + + /** + * 发货信息合单录入接口 + * + * @param request 请求 + * @return WxMaOrderShippingInfoBaseResponse + * @throws WxErrorException e + */ + WxMaOrderShippingInfoBaseResponse upload(WxMaOrderCombinedShippingInfoUploadRequest request) + throws WxErrorException; + + /** + * 查询订单发货状态 + * 你可以通过交易单号或商户号+商户单号来查询该支付单的发货状态。 + * + * @param request 请求 + * @return WxMaOrderShippingInfoGetResponse + * @throws WxErrorException e + */ + WxMaOrderShippingInfoGetResponse get(WxMaOrderShippingInfoGetRequest request) + throws WxErrorException; + + /** + * 查询订单列表 + * 你可以通过支付时间、支付者openid或订单状态来查询订单列表。 + * + * @param request 请求 + * @return WxMaOrderShippingInfoGetListResponse + * @throws WxErrorException e + */ + WxMaOrderShippingInfoGetListResponse getList(WxMaOrderShippingInfoGetListRequest request) + throws WxErrorException; + + /** + * 确认收货提醒接口 + * 如你已经从你的快递物流服务方获知到用户已经签收相关商品,可以通过该接口提醒用户及时确认收货,以提高资金结算效率,每个订单仅可调用一次。 + * + * @param request 请求 + * @return WxMaOrderShippingInfoBaseResponse + * @throws WxErrorException e + */ + WxMaOrderShippingInfoBaseResponse notifyConfirmReceive(WxMaOrderShippingInfoNotifyConfirmRequest request) + throws WxErrorException; + + /** + * 消息跳转路径设置接口 + * 如你已经在小程序内接入平台提供的确认收货组件,可以通过该接口设置发货消息及确认收货消息的跳转动作,用户点击发货消息时会直接进入你的小程序订单列表页面或详情页面进行确认收货,进一步优化用户体验。 + * + * @param path 商户自定义跳转路径 + * @return WxMaOrderShippingInfoBaseResponse + * @throws WxErrorException e + */ + WxMaOrderShippingInfoBaseResponse setMsgJumpPath(String path) + throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaProductOrderService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaProductOrderService.java new file mode 100644 index 0000000000..793df60a27 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaProductOrderService.java @@ -0,0 +1,76 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.product.WxMiniBatchGetAfterSaleOrderResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMiniGetAfterSaleOrderResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMiniOrderDeliveryRequest; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderDetailResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import java.util.List; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 小程序交易组件-标准版-商品服务 + * + * @author boris + */ +public interface WxMaProductOrderService { + + + /** + * 获取订单列表 + * + * @param startCreateTime 否(未填更新时间范围时必填) + * @param endCreateTime 否(未填更新时间范围时必填) + * @param startUpdateTime 否(未填创建时间范围时必填) + * @param endUpdateTime 否(未填创建时间范围时必填) + * @param status 订单状态,枚举值见RequestOrderStatus + * @param page 第几页(最小填1) + * @param pageSize 每页数量(不超过10,000) + * @param source 1:小商店,2:CPS带货 + * @return + * @throws WxErrorException + */ + WxMinishopOrderListResponse getOrderList( + String startCreateTime, + String endCreateTime, + String startUpdateTime, + String endUpdateTime, + Integer status, + Integer page, + Integer pageSize, + Integer source + ) throws WxErrorException; + + + /** + * 获取订单详情 + * + * @param orderId 订单ID,可从获取订单列表中获得 + * @return + */ + WxMinishopOrderDetailResponse getOrderDetail(Long orderId) throws WxErrorException; + + + /** + * 修改订单备注 + * @param orderId 订单id + * @param merchantNotes 备注内容 + */ + void changeMerchantNotes(Long orderId,String merchantNotes) throws WxErrorException; + + WxMaShopBaseResponse deliverySend(WxMiniOrderDeliveryRequest request) + throws WxErrorException; + + WxMiniGetAfterSaleOrderResponse getAfterSaleOrder(Long afterSaleOrderId) + throws WxErrorException; + + WxMiniBatchGetAfterSaleOrderResponse batchGetAfterSaleOrder(List afterSaleOrderIdList) + throws WxErrorException; + + WxMaShopBaseResponse afterSaleAccept(Long orderId, Long addressId) + throws WxErrorException; + + WxMaShopBaseResponse afterSaleReject(Long afterSaleOrderId, String rejectReason) + throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaProductService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaProductService.java new file mode 100644 index 0000000000..b629772a27 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaProductService.java @@ -0,0 +1,137 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSkuData; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSpuData; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetBrandResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetCategoryResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetFrightTemplateResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopResult; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopSku; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopSkuListResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpu; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGet; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGetResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuListResponse; +import cn.binarywang.wx.miniapp.bean.product.WxMinishopUpdateGoodsSkuData; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopSpuPageRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetSpuListResponse; +import java.io.File; +import java.util.List; +import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 小程序交易组件-商品服务 + * + * @author boris + */ +public interface WxMaProductService { + + WxMinishopImageUploadResult uploadImg(File file, Integer respType, Integer width, Integer height) throws WxErrorException; + + WxMinishopImageUploadResult uploadImg(String imgUrl, Integer respType) throws WxErrorException; + + WxMinishopGetCategoryResponse getCategory(Integer fCatId) throws WxErrorException; + + WxMinishopGetBrandResponse getBrand() throws WxErrorException; + + WxMinishopGetFrightTemplateResponse getFreightTemplate() throws WxErrorException; + + WxMinishopResult addSpu(WxMinishopSpu spuInfo) throws WxErrorException; + + WxMaShopBaseResponse deleteSpu(Integer productId, String outProductId) throws WxErrorException; + + WxMinishopSpuGetResponse getSpu(Integer productId, String outProductId, Integer needEditSpu) + throws WxErrorException; + + WxMinishopSpuListResponse getSpuList(WxMaShopSpuPageRequest request) + throws WxErrorException; + + WxMinishopResult updateSpu(WxMinishopSpu spuInfo) throws WxErrorException; + + WxMaShopBaseResponse listingSpu(Integer productId, String outProductId) + throws WxErrorException; + + WxMaShopBaseResponse delistingSpu(Integer productId, String outProductId) + throws WxErrorException; + + WxMinishopSkuListResponse getSkuList(Long productId, Integer needRealStock, Integer needEditSku) + throws WxErrorException; + + /** + * 小商店新增sku信息 + * + * @param sku + * @return + * @throws WxErrorException + */ + WxMinishopResult minishiopGoodsAddSku(WxMinishopSku sku) throws WxErrorException; + + + /** + * 小商店批量新增sku信息 + * + * @param skuList + * @return + * @throws WxErrorException + */ + WxMinishopResult> minishopGoodsBatchAddSku(List skuList) throws WxErrorException; + + + /** + * 小商店删除sku消息 + * + * @param productId + * @param outProductId + * @param outSkuId + * @param skuId + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse minishopGoodsDelSku(Long productId, Long outProductId, String outSkuId, Long skuId) throws WxErrorException; + + + /** + * 小商店更新sku + * + * @param sku + * @return + * @throws WxErrorException + */ + WxMinishopResult minishopGoodsUpdateSku(WxMinishopSku sku) throws WxErrorException; + + + /** + * 小商店更新sku价格 + * + * @param productId + * @param outProductId + * @param outSkuId + * @param skuId + * @param salePrice + * @param marketPrice + * @return + * @throws WxErrorException + */ + WxMinishopResult minishopGoodsUpdateSkuPrice(Long productId, + String outProductId, String outSkuId, Long skuId, Long salePrice, Long marketPrice) throws WxErrorException; + + + /** + * 小商店更新sku库存 + * + * @param productId + * @param outProductId + * @param outSkuId + * @param skuId + * @param type + * @param stockNum + * @return + * @throws WxErrorException + */ + WxMinishopResult minishopGoodsUpdateSkuStock(Long productId, + String outProductId, String outSkuId, Long skuId, Integer type, Integer stockNum) throws WxErrorException; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java index 5ef3ba7982..9e92908904 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java @@ -11,7 +11,8 @@ * * 接口A(createWxaCode)加上接口C(createQrcode),总共生成的码数量限制为100,000,请谨慎调用。 * - * 文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html + * 文档地址1:https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html + * 文档地址2:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html *
* * @author Binary Wang @@ -101,45 +102,48 @@ public interface WxMaQrcodeService { /** * 接口A: 获取小程序码. * - * @param path 不能为空,最大长度 128 字节 - * @param width 默认430 二维码的宽度 - * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 - * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} - * @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码 + * @param path 不能为空,最大长度 128 字节 + * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" + * @param width 默认430 二维码的宽度 + * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} + * @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码 * @return 文件内容字节数组 * @throws WxErrorException 异常 */ - byte[] createWxaCodeBytes(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) - throws WxErrorException; + byte[] createWxaCodeBytes(String path, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor, + boolean isHyaline) throws WxErrorException; /** * 接口A: 获取小程序码. * - * @param path 不能为空,最大长度 128 字节 - * @param width 默认430 二维码的宽度 - * @param filePath 二维码生成的文件路径,例如: /var/temp - * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 - * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} - * @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码 + * @param path 不能为空,最大长度 128 字节 + * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" + * @param width 默认430 二维码的宽度 + * @param filePath 二维码生成的文件路径,例如: /var/temp + * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} + * @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码 * @return 文件对象 * @throws WxErrorException 异常 */ - File createWxaCode(String path, int width, String filePath, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) - throws WxErrorException; + File createWxaCode(String path, String envVersion, int width, String filePath, boolean autoColor, + WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException; /** * 接口A: 获取小程序码. * - * @param path 不能为空,最大长度 128 字节 - * @param width 默认430 二维码的宽度 - * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 - * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} - * @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码 + * @param path 不能为空,最大长度 128 字节 + * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" + * @param width 默认430 二维码的宽度 + * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} + * @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码 * @return 文件对象 * @throws WxErrorException 异常 */ - File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) - throws WxErrorException; + File createWxaCode(String path, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor, + boolean isHyaline) throws WxErrorException; /** * 接口A: 获取小程序码. @@ -190,17 +194,20 @@ File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor * 调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode *
* - * @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, - * 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) - * @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面 - * @param width 默认430 二维码的宽度 - * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 - * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} - * @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 + * @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, + * 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) + * @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面 + * @param checkPath 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错); + * 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用 + * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" + * @param width 默认430 二维码的宽度 + * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} + * @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 * @return 文件内容字节数组 * @throws WxErrorException 异常 */ - byte[] createWxaCodeUnlimitBytes(String scene, String page, int width, boolean autoColor, + byte[] createWxaCodeUnlimitBytes(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException; /** @@ -212,19 +219,22 @@ byte[] createWxaCodeUnlimitBytes(String scene, String page, int width, boolean a * 调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode *
* - * @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, - * 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) - * @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面 - * @param filePath 二维码生成的文件路径,例如: /var/temp - * @param width 默认430 二维码的宽度 - * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 - * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} - * @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 + * @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, + * 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) + * @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面 + * @param filePath 二维码生成的文件路径,例如: /var/temp + * @param checkPath 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错); + * 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用 + * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" + * @param width 默认430 二维码的宽度 + * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} + * @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 * @return 文件对象 * @throws WxErrorException 异常 */ - File createWxaCodeUnlimit(String scene, String page, String filePath, int width, boolean autoColor, - WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException; + File createWxaCodeUnlimit(String scene, String page, String filePath, boolean checkPath, String envVersion, int width, + boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException; /** * 接口B: 获取小程序码(永久有效、数量暂无限制). @@ -235,17 +245,20 @@ File createWxaCodeUnlimit(String scene, String page, String filePath, int width, * 调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode *
* - * @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, - * 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) - * @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面 - * @param width 默认430 二维码的宽度 - * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 - * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} - * @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 + * @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, + * 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) + * @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面 + * @param checkPath 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错); + * 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用 + * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" + * @param width 默认430 二维码的宽度 + * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} + * @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 * @return 文件对象 * @throws WxErrorException 异常 */ - File createWxaCodeUnlimit(String scene, String page, int width, boolean autoColor, + File createWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException; /** diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSafetyRiskControlService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSafetyRiskControlService.java new file mode 100644 index 0000000000..c84a93d13d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSafetyRiskControlService.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest; +import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + *
+ * 小程序安全风控相关接口
+ * 
+ * + * @author azouever + */ +public interface WxMaSafetyRiskControlService { + + /** + *
+   * 根据提交的用户信息数据获取用户的安全等级,无需用户授权
+   * 文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/safety-control-capability/riskControl.getUserRiskRank.html
+   * 
+ * + * @param wxMaUserSafetyRiskRankRequest 获取用户安全等级请求 + * @throws WxErrorException 通用异常 + */ + WxMaUserSafetyRiskRankResponse getUserRiskRank(WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest) throws WxErrorException; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSchemeService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSchemeService.java index e480912e7c..2526ee0d9e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSchemeService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSchemeService.java @@ -1,5 +1,6 @@ package cn.binarywang.wx.miniapp.api; +import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateNfcSchemeRequest; import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest; import me.chanjar.weixin.common.error.WxErrorException; @@ -7,18 +8,25 @@ *
  * 小程序Scheme码相关操作接口.
  *
- * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html
+ *
  * 
* * @author : cofedream - * @date : 2021-01-26 + * created on : 2021-01-26 */ public interface WxMaSchemeService { /** * 获取小程序scheme码 - * + *文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html * @param request 请求参数 * @throws WxErrorException 生成失败时抛出,具体错误码请看文档 */ String generate(WxMaGenerateSchemeRequest request) throws WxErrorException; + /** + * 获取NFC 的小程序 scheme + *文档地址:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-scheme/generateNFCScheme.html + * @param request 请求参数 + * @throws WxErrorException 生成失败时抛出,具体错误码请看文档 + */ + String generateNFC(WxMaGenerateNfcSchemeRequest request) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSecCheckService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSecCheckService.java index 8b135adcdf..b7721b4e73 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSecCheckService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSecCheckService.java @@ -1,6 +1,7 @@ package cn.binarywang.wx.miniapp.api; import cn.binarywang.wx.miniapp.bean.WxMaMediaAsyncCheckResult; +import cn.binarywang.wx.miniapp.bean.security.WxMaMediaSecCheckCheckRequest; import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest; import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse; import me.chanjar.weixin.common.error.WxErrorException; @@ -22,7 +23,7 @@ public interface WxMaSecCheckService { * 应用场景举例: * 1)图片智能鉴黄:涉及拍照的工具类应用(如美拍,识图类应用)用户拍照上传检测;电商类商品上架图片检测;媒体类用户文章里的图片检测等; * 2)敏感人脸识别:用户头像;媒体类用户文章里的图片检测;社交类用户上传的图片检测等。频率限制:单个 appId 调用上限为 1000 次/分钟,100,000 次/天 - * 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/imgSecCheck.html + * 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/imgSecCheck.html *
* * @param file the file @@ -47,7 +48,7 @@ public interface WxMaSecCheckService { * 用户个人资料违规文字检测; * 媒体新闻类用户发表文章,评论内容检测; * 游戏类用户编辑上传的素材(如答题类小游戏用户上传的问题及答案)检测等。 频率限制:单个 appId 调用上限为 4000 次/分钟,2,000,000 次/天* - * 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/msgSecCheck.html + * 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/msgSecCheck.html *
* * @param msgString the msg string @@ -60,11 +61,11 @@ public interface WxMaSecCheckService { /** *
    * 检查一段文本是否含有违法违规内容(新版本接口,主要是request和response做了参数优化)
-   * 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html
+   * 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html
    * 
- * @param msgRequest + * @param msgRequest request * @return WxMaMsgSecCheckCheckResponse - * @throws WxErrorException + * @throws WxErrorException the wx error exception */ WxMaMsgSecCheckCheckResponse checkMessage(WxMaMsgSecCheckCheckRequest msgRequest) throws WxErrorException; @@ -78,7 +79,7 @@ public interface WxMaSecCheckService { * 频率限制: * 单个 appId 调用上限为 2000 次/分钟,200,000 次/天;文件大小限制:单个文件大小不超过10M * 详情请见: - * https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.mediaCheckAsync.html + * https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.mediaCheckAsync.html *
* * @param mediaUrl 要检测的多媒体url @@ -88,4 +89,24 @@ public interface WxMaSecCheckService { */ WxMaMediaAsyncCheckResult mediaCheckAsync(String mediaUrl, int mediaType) throws WxErrorException; + /** + *
+   * 异步校验图片/音频是否含有违法违规内容。(新版本接口,主要对request和respone做了参数优化)
+   * 应用场景举例:
+   * 语音风险识别:社交类用户发表的语音内容检测;
+   * 图片智能鉴黄:涉及拍照的工具类应用(如美拍,识图类应用)用户拍照上传检测;电商类商品上架图片检测;媒体类用户文章里的图片检测等;
+   * 敏感人脸识别:用户头像;媒体类用户文章里的图片检测;社交类用户上传的图片检测等。
+   * 频率限制:
+   * 单个 appId 调用上限为 2000 次/分钟,200,000 次/天;文件大小限制:单个文件大小不超过10M
+   * 详情请见:
+   * https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.mediaCheckAsync.html
+   * 
+ * + * @param request 请求 + * @return wx ma media async check result + * @throws WxErrorException the wx error exception + */ + + WxMaMediaAsyncCheckResult mediaCheckAsync(WxMaMediaSecCheckCheckRequest 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 d0b2dcf12b..4dc51f7485 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 @@ -22,6 +22,8 @@ public interface WxMaService extends WxService { * 获取access_token. */ String GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"; + String GET_STABLE_ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/stable_token"; + /** * The constant JSCODE_TO_SESSION_URL. @@ -462,4 +464,95 @@ public interface WxMaService extends WxService { * @return */ WxMaReimburseInvoiceService getReimburseInvoiceService(); + + /** + * 返回设备订阅消息相关接口服务对象 + * + * @return WxMaDeviceSubscribeService plugin service + */ + WxMaDeviceSubscribeService getDeviceSubscribeService(); + + /** + * 返回小程序广告接入相关接口服务对象 + * + * @return WxMaDeviceSubscribeService plugin service + */ + WxMaMarketingService getMarketingService(); + + /** + * 返回微信小程序即时配送服务接口. + * + * @return WxMaImmediateDeliveryService + */ + WxMaImmediateDeliveryService getWxMaImmediateDeliveryService(); + + + /** + * 小程序安全风控相关接口服务 + * + * @return safetyRiskControl service + */ + WxMaSafetyRiskControlService getSafetyRiskControlService(); + + /** + * 分享人接口 + * + * @return WxMaShopSharerService + */ + WxMaShopSharerService getShopSharerService(); + + /** + * 标准交易组件接口 + * + * @return WxMaProductService + */ + WxMaProductService getProductService(); + + /** + * 小商店-标准交易组件-订单服务 + * + * @return getProductOrderService + */ + WxMaProductOrderService getProductOrderService(); + + /** + * 小商店-标准交易组件-优惠券 + * + * @return getWxMaShopCouponService + */ + WxMaShopCouponService getWxMaShopCouponService(); + + /** + * 小程序支付管理-订单支付 + * + * @return getWxMaShopPayService + */ + WxMaShopPayService getWxMaShopPayService(); + + /** + * 小程序发货信息管理服务 + * + * @return getWxMaOrderShippingService + */ + WxMaOrderShippingService getWxMaOrderShippingService(); + + /** + * 小程序openApi管理 + * + * @return getWxMaOpenApiService + */ + WxMaOpenApiService getWxMaOpenApiService(); + /** + * 小程序短剧管理 + * + * @return getWxMaVodService + */ + WxMaVodService getWxMaVodService(); + /** + * 小程序虚拟支付 + * + * @return getWxMaXPayService + */ + WxMaXPayService getWxMaXPayService(); + WxMaExpressDeliveryReturnService getWxMaExpressDeliveryReturnService(); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java index 97b8aa56d7..458d5171c5 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java @@ -1,10 +1,7 @@ package cn.binarywang.wx.miniapp.api; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.request.*; +import cn.binarywang.wx.miniapp.bean.shop.response.*; import me.chanjar.weixin.common.error.WxErrorException; /** @@ -21,7 +18,7 @@ public interface WxMaShopAfterSaleService { * @return WxMaShopBaseResponse * @throws WxErrorException */ - WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException; + WxMaShopAfterSaleAddResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException; /** * 获取订单下售后单 @@ -32,6 +29,15 @@ public interface WxMaShopAfterSaleService { */ WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException; + /** + * 获取售后单详情(EC版) + * + * @param request + * @return WxMaShopEcAfterSaleGetResponse + * @throws WxErrorException + */ + WxMaShopEcAfterSaleGetResponse get(WxMaShopEcAfterSaleGetRequest request) throws WxErrorException; + /** * 更新售后 * @@ -41,4 +47,91 @@ public interface WxMaShopAfterSaleService { */ WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException; + /** + * 更新售后(EC版) + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + WxMaShopBaseResponse update(WxMaShopEcAfterSaleUpdateRequest request) throws WxErrorException; + + + /** + * 用户取消售后申请 + * @param outAfterSaleId 商家自定义订单ID + * @param afterSaleId 与out_aftersale_id二选一 + * @param openId 用户openid + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse cancel(String outAfterSaleId, Long afterSaleId, String openId) + throws WxErrorException; + + /** + * 用户上传退货物流 + * @param request + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse uploadReturnInfo(WxMaShopAfterSaleUploadReturnInfoRequest request) + throws WxErrorException; + + /** + * 商家同意退款 + * @param outAfterSaleId + * @param afterSaleId + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse acceptRefund(String outAfterSaleId, Long afterSaleId) + throws WxErrorException; + + /** + * 商家同意退货 + * @param request + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse acceptReturn(WxMaShopAcceptReturnRequest request) + throws WxErrorException; + + /** + * 商家拒绝售后 + * @param outAfterSaleId + * @param afterSaleId + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse reject(String outAfterSaleId, Long afterSaleId) + throws WxErrorException; + + /** + * 商家上传退款凭证 + * @param request + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse uploadCertificates(WxMaShopUploadCerficatesRequest request) + throws WxErrorException; + + /** + * 商家更新订单售后期 + * @param outOrderId + * @param orderId + * @param openid + * @param afterSaleDeadline + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse updateDeadline(String outOrderId, Long orderId, String openid, + Long afterSaleDeadline) throws WxErrorException; + + /** + * 获取售后单详情 + * @param request + * @return + * @throws WxErrorException + */ + WxMaShopAfterSaleListResponse list(WxMaShopAfterSaleListRequest request) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAuditService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAuditService.java index 157052b4c0..7db67e886d 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAuditService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAuditService.java @@ -12,7 +12,7 @@ * 小程序交易组件-接入商品前必需接口(审核相关接口) * * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ public interface WxMaShopAuditService { /** diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopCouponService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopCouponService.java new file mode 100644 index 0000000000..942aa0e230 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopCouponService.java @@ -0,0 +1,40 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponListResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopUserCouponListResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * @author leiin + * created on 2022/7/1 2:49 下午 + */ +public interface WxMaShopCouponService { + + WxMaShopBaseResponse addCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException; + + WxMaShopCouponResponse getCoupon(String outCouponId) throws WxErrorException; + + WxMaShopCouponListResponse getCouponList(Integer pageSize, + Integer offset) throws WxErrorException; + + WxMaShopBaseResponse updateCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException; + + WxMaShopBaseResponse updateCouponStatus(String outCouponId, + Integer status) throws WxErrorException; + + WxMaShopBaseResponse updateCouponStock(String outCouponId, Integer isUsedNum, Integer receiveNum) throws WxErrorException; + + WxMaShopBaseResponse addUserCoupon(String openid, String outUserCouponId, + String outCouponId, Integer status, Long recvTime) throws WxErrorException; + + WxMaShopUserCouponListResponse getUserCouponList(Integer pageSize, Integer offset, String openid) throws WxErrorException; + + WxMaShopBaseResponse updateUserCoupon(String openid, String outUserCouponId, + String outCouponId, Long useTime, Long recvTime) throws WxErrorException; + + WxMaShopBaseResponse updateUserCouponStatus(String openid, String outUserCouponId, + String outCouponId, Integer status) throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopImgService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopImgService.java index 2cb9334fc2..0bb4d31987 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopImgService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopImgService.java @@ -29,4 +29,14 @@ public interface WxMaShopImgService { * @throws WxErrorException */ WxMinishopImageUploadCustomizeResult uploadImg(File file, String respType) throws WxErrorException; + + /** + * 上传图片链接,带respType参数 + * + * @param imgUrl + * @param respType + * @return WxMinishopImageUploadCustomizeResult + * @throws WxErrorException + */ + WxMinishopImageUploadCustomizeResult uploadImg(String imgUrl, String respType) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopOrderService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopOrderService.java index 50b39fb6ed..abcbe25ea7 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopOrderService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopOrderService.java @@ -2,11 +2,11 @@ import cn.binarywang.wx.miniapp.bean.shop.WxMaShopOrderInfo; import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopOrderPayRequest; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAddOrderResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetOrderResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.*; import me.chanjar.weixin.common.error.WxErrorException; +import java.util.Date; + /** * 小程序交易组件-订单服务 * @@ -19,6 +19,48 @@ public interface WxMaShopOrderService { WxMaShopBaseResponse orderPay(WxMaShopOrderPayRequest request) throws WxErrorException; - WxMaShopGetOrderResponse getOrder(Integer orderId, String outOrderId, String openid) + WxMaShopGetOrderResponse getOrder(Long orderId, String outOrderId, String openid) throws WxErrorException; + + + /** + *
+   *
+   * 获取订单列表
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:请求地址
+   *
+   * 文档地址:文档地址
+   * 
+ * + * @param page 第x页,大于等于1 + * @param pageSize 每页订单数,上限100 + * @param desc 是否时间倒叙 + * @param startCreateTime 起始创建时间 + * @param endCreateTime 最终创建时间 + * @return 订单列表信息 + * @throws WxErrorException . + */ + WxMaShopGetOrderListResponse getOrderList(Integer page, Integer pageSize, Boolean desc, Date startCreateTime, Date endCreateTime) + throws WxErrorException; + + /** + *
+   *
+   * 生成支付参数
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:请求地址
+   *
+   * 文档地址:文档地址
+   * 
+ * + * @param orderId 微信侧订单id + * @param outOrderId 商家自定义订单ID + * @param openid 用户openid + * @return 支付参数 + * @throws WxErrorException . + */ + WxMaShopGetPaymentParamsResponse getPaymentParams(String orderId, String outOrderId, String openid) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopPayService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopPayService.java new file mode 100644 index 0000000000..b14ea11ab9 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopPayService.java @@ -0,0 +1,46 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 小程序支付管理订单相关接口 + * + * @author liming1019 + */ +public interface WxMaShopPayService { + + /** + * 创建订单 + * 文档地址:文档地址 + * + * @param request 创建订单参数 + * @return 创建订单结果 + * @throws WxErrorException . + */ + WxMaShopPayCreateOrderResponse createOrder(WxMaShopPayCreateOrderRequest request) throws WxErrorException; + + /** + * 查询订单详情 + * 文档地址:文档地址 + * + * @param trade_no + * @return + * @throws WxErrorException + */ + WxMaShopPayGetOrderResponse getOrder(String trade_no) throws WxErrorException; + + /** + * 订单退款 + * 文档地址:文档地址 + * + * @param request + * @return + * @throws WxErrorException + */ + WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopSharerService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopSharerService.java new file mode 100644 index 0000000000..c63016ab88 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopSharerService.java @@ -0,0 +1,83 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSearchSharerResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerBindResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerDataSummaryResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerListResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveOrderListResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveSummaryListResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerUnbindResponse; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 分享员 + * @author leiin + * created on 2022/6/18 2:48 下午 + */ +public interface WxMaShopSharerService { + + /** + * 绑定分享员 + * 用来批量邀请分享员 + * @param openids + * @return + * @throws WxErrorException + */ + WxMaShopSharerBindResponse bindSharer(String[] openids) throws WxErrorException; + + /** + * 获取分享员的总带货数据 + * @param openid + * @return + * @throws WxErrorException + */ + WxMaShopSharerDataSummaryResponse getSharerDataSummary(String openid) throws WxErrorException; + + /** + * 获取已经绑定的分享员列表 + * @param page + * @param pageSize + * @return + * @throws WxErrorException + */ + WxMaShopSharerListResponse getSharerList(Integer page, Integer pageSize) throws WxErrorException; + + /** + * 获取分享员的直播间订单汇总 + * @param openid + * @param liveExportId + * @param page + * @param pageSize + * @return + * @throws WxErrorException + */ + WxMaShopSharerLiveOrderListResponse getSharerLiveOrderList(String openid, String liveExportId, + Integer page, Integer pageSize) throws WxErrorException; + + /** + * 获取分享员的直播间带货数据汇总 + * @param openid + * @param page + * @param pageSize + * @return + * @throws WxErrorException + */ + WxMaShopSharerLiveSummaryListResponse getSharerLiveSummaryList(String openid, + Integer page, Integer pageSize) throws WxErrorException; + + /** + * 查看分享员 + * @param openid + * @return + * @throws WxErrorException + */ + WxMaShopSearchSharerResponse searchSharer(String openid) throws WxErrorException; + + /** + * 解绑分享员 + * @param openids + * @return + * @throws WxErrorException + */ + WxMaShopSharerUnbindResponse unbindSharer(String[] openids) throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSubscribeService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSubscribeService.java index 1f1248e3ab..694404d980 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSubscribeService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSubscribeService.java @@ -13,7 +13,7 @@ * 订阅消息类 * * @author Binary Wang - * @date 2019-12-15 + * created on 2019-12-15 */ public interface WxMaSubscribeService { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java index 0c513789cd..5032008ef8 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java @@ -51,9 +51,31 @@ public interface WxMaUserService { * @param encryptedData 消息密文 * @param ivStr 加密算法的初始向量 * @return . + * @deprecated 请使用替代方法 {@link #getPhoneNoInfo(String)} */ + @Deprecated WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedData, String ivStr); + /** + * 获取手机号信息,基础库:2.21.2及以上 + * + * @param code 动态令牌 + * @return . + * @throws WxErrorException . + */ + WxMaPhoneNumberInfo getPhoneNoInfo(String code) throws WxErrorException; + + /** + * 获取手机号信息,基础库:2.21.2及以上 + * + * @param code 动态令牌 + * @return . + * @throws WxErrorException . + * @deprecated 命名有些复杂,请使用替代方法 {@link #getPhoneNoInfo(String)} + */ + @Deprecated + WxMaPhoneNumberInfo getNewPhoneNoInfo(String code) throws WxErrorException; + /** * 验证用户信息完整性. * diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaVodService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaVodService.java new file mode 100644 index 0000000000..547d280962 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaVodService.java @@ -0,0 +1,44 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.vod.*; +import me.chanjar.weixin.common.error.WxErrorException; + +import java.io.File; +import java.util.List; + +public interface WxMaVodService { + List listMedia(WxMaVodListMediaRequest request) throws WxErrorException; + + List listDrama(WxMaVodListDramaRequest request) throws WxErrorException; + + WxMaVodMediaPlaybackInfo getMediaLink(WxMaVodGetMediaLinkRequest request) throws WxErrorException; + + WxMaVodMediaInfo getMedia(WxMaVodGetMediaRequest request) throws WxErrorException; + + boolean deleteMedia(WxMaVodDeleteMediaRequest request) throws WxErrorException; + + WxMaVodDramaInfo getDrama(WxMaVodGetDramaRequest request) throws WxErrorException; + + Integer auditDrama(WxMaVodAuditDramaRequest request) throws WxErrorException; + + WxMaVodGetCdnUsageResponse getCdnUsageData(WxMaVodGetCdnUsageRequest request) throws WxErrorException; + + WxMaVodGetCdnLogResponse getCdnLogs(WxMaVodGetCdnLogRequest request) throws WxErrorException; + + + WxMaVodPullUploadResponse pullUpload(WxMaVodPullUploadRequest request) throws WxErrorException; + + WxMaVodGetTaskResponse getTask(WxMaVodGetTaskRequest request) throws WxErrorException; + + + WxMaVodSingleFileUploadResult uploadSingleFile(File file, String mediaName, String mediaType) throws WxErrorException; + + WxMaVodSingleFileUploadResult uploadSingleFile(File file, String mediaName, String mediaType, String coverType, File coverData, String sourceContext) throws WxErrorException; + + WxMaVodApplyUploadResponse applyUpload(WxMaVodApplyUploadRequest request) throws WxErrorException; + + WxMaVodCommitUploadResponse commitUpload(WxMaVodCommitUploadRequest request) throws WxErrorException; + + WxMaVodUploadPartResult uploadPart(File file, String uploadId, Integer partNumber, Integer resourceType) throws WxErrorException; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaXPayService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaXPayService.java new file mode 100644 index 0000000000..a099cd6dd7 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaXPayService.java @@ -0,0 +1,37 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.xpay.*; +import me.chanjar.weixin.common.error.WxErrorException; + +public interface WxMaXPayService { + + WxMaXPayQueryUserBalanceResponse queryUserBalance(WxMaXPayQueryUserBalanceRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayCurrencyPayResponse currencyPay(WxMaXPayCurrencyPayRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayQueryOrderResponse queryOrder(WxMaXPayQueryOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayCancelCurrencyPayResponse cancelCurrencyPay(WxMaXPayCancelCurrencyPayRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + boolean notifyProvideGoods(WxMaXPayNotifyProvideGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayPresentCurrencyResponse presentCurrency(WxMaXPayPresentCurrencyRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + + WxMaXPayDownloadBillResponse downloadBill(WxMaXPayDownloadBillRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayRefundOrderResponse refundOrder(WxMaXPayRefundOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayCreateWithdrawOrderResponse createWithdrawOrder(WxMaXPayCreateWithdrawOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayQueryWithdrawOrderResponse queryWithdrawOrder(WxMaXPayQueryWithdrawOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + boolean startUploadGoods(WxMaXPayStartUploadGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayQueryUploadGoodsResponse queryUploadGoods(WxMaXPayQueryUploadGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + boolean startPublishGoods(WxMaXPayStartPublishGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + + WxMaXPayQueryPublishGoodsResponse queryPublishGoods(WxMaXPayQueryPublishGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java index ecbce2ee05..37a25db14a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java @@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.util.WxMaConfigHolder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; @@ -75,7 +76,24 @@ public abstract class BaseWxMaServiceImpl implements WxMaService, RequestH private final WxMaShopDeliveryService shopDeliveryService = new WxMaShopDeliveryServiceImpl(this); private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this); private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this); - private Map configMap; + private final WxMaDeviceSubscribeService deviceSubscribeService = new WxMaDeviceSubscribeServiceImpl(this); + private final WxMaMarketingService marketingService = new WxMaMarketingServiceImpl(this); + private final WxMaImmediateDeliveryService immediateDeliveryService = new WxMaImmediateDeliveryServiceImpl(this); + private final WxMaSafetyRiskControlService safetyRiskControlService = new WxMaSafetyRiskControlServiceImpl(this); + private final WxMaShopSharerService shopSharerService = new WxMaShopSharerServiceImpl(this); + private final WxMaProductService productService = new WxMaProductServiceImpl(this); + private final WxMaProductOrderService productOrderService = new WxMaProductOrderServiceImpl(this); + private final WxMaShopCouponService wxMaShopCouponService = new WxMaShopCouponServiceImpl(this); + private final WxMaShopPayService wxMaShopPayService = new WxMaShopPayServiceImpl(this); + + private final WxMaOrderShippingService wxMaOrderShippingService = new WxMaOrderShippingServiceImpl(this); + + private final WxMaOpenApiService wxMaOpenApiService = new WxMaOpenApiServiceImpl(this); + private final WxMaVodService wxMaVodService = new WxMaVodServiceImpl(this); + private final WxMaXPayService wxMaXPayService = new WxMaXPayServiceImpl(this); + private final WxMaExpressDeliveryReturnService wxMaExpressDeliveryReturnService = new WxMaExpressDeliveryReturnServiceImpl(this); + + private Map configMap = new HashMap<>(); private int retrySleepMillis = 1000; private int maxRetryTimes = 5; @@ -165,7 +183,13 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { return this.getWxMaConfig().getAccessToken(); } } while (!locked); - String response = doGetAccessTokenRequest(); + + String response; + if (getWxMaConfig().isStableAccessToken()) { + response = doGetStableAccessTokenRequest(forceRefresh); + } else { + response = doGetAccessTokenRequest(); + } return extractAccessToken(response); } catch (IOException | InterruptedException e) { throw new WxRuntimeException(e); @@ -184,6 +208,15 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { */ protected abstract String doGetAccessTokenRequest() throws IOException; + + /** + * 通过网络请求获取稳定版接口调用凭据 + * + * @return . + * @throws IOException . + */ + protected abstract String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException; + @Override public String get(String url, String queryParam) throws WxErrorException { return execute(SimpleGetRequestExecutor.create(this), url, queryParam); @@ -290,12 +323,12 @@ private T executeInternal(RequestExecutor executor, String uri, E d } if (error.getErrorCode() != 0) { - log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); throw new WxErrorException(error, e); } return null; } catch (IOException e) { - log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); throw new WxRuntimeException(e); } } @@ -308,14 +341,15 @@ private T executeInternal(RequestExecutor executor, String uri, E d * @throws WxErrorException 异常 */ protected String extractAccessToken(String resultContent) throws WxErrorException { - log.info("resultContent: " + resultContent); + log.debug("access-token response: {}", resultContent); WxMaConfig config = this.getWxMaConfig(); WxError error = WxError.fromJson(resultContent, WxType.MiniApp); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } + WxAccessToken accessToken = WxAccessToken.fromJson(resultContent); - config.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); + config.updateAccessTokenProcessor(accessToken.getAccessToken(), accessToken.getExpiresIn()); return accessToken.getAccessToken(); } @@ -341,8 +375,14 @@ public void setMultiConfigs(Map configs) { } @Override + @JsonDeserialize public void setMultiConfigs(Map configs, String defaultMiniappId) { - this.configMap = Maps.newHashMap(configs); + // 防止覆盖配置 + if(this.configMap != null) { + this.configMap.putAll(configs); + } else { + this.configMap = Maps.newHashMap(configs); + } WxMaConfigHolder.set(defaultMiniappId); this.initHttp(); } @@ -350,7 +390,11 @@ public void setMultiConfigs(Map configs, String defaultMinia @Override public void addConfig(String miniappId, WxMaConfig configStorages) { synchronized (this) { - if (this.configMap == null) { + /* + * 因为commit f74b00cf 默认初始化了configMap,导致使用此方法无法进入if从而触发initHttp(), + * 就会出现HttpClient报NullPointException + */ + if (this.configMap == null || this.configMap.isEmpty()) { this.setWxMaConfig(configStorages); } else { WxMaConfigHolder.set(miniappId); @@ -573,4 +617,79 @@ public WxMaLinkService getLinkService() { public WxMaReimburseInvoiceService getReimburseInvoiceService() { return this.reimburseInvoiceService; } + + @Override + public WxMaDeviceSubscribeService getDeviceSubscribeService() { + return this.deviceSubscribeService; + } + + @Override + public WxMaMarketingService getMarketingService() { + return this.marketingService; + } + + @Override + public WxMaImmediateDeliveryService getWxMaImmediateDeliveryService() { + return this.immediateDeliveryService; + } + + @Override + public WxMaSafetyRiskControlService getSafetyRiskControlService() { + return this.safetyRiskControlService; + } + + @Override + public WxMaShopSharerService getShopSharerService() { + return this.shopSharerService; + } + + @Override + public WxMaProductService getProductService() { + return this.productService; + } + + @Override + public WxMaProductOrderService getProductOrderService() { + return this.productOrderService; + } + + @Override + public WxMaShopCouponService getWxMaShopCouponService() { + return this.wxMaShopCouponService; + } + + @Override + public WxMaShopPayService getWxMaShopPayService() { + return this.wxMaShopPayService; + } + + /** + * 小程序发货信息管理服务 + * + * @return getWxMaOrderShippingService + */ + @Override + public WxMaOrderShippingService getWxMaOrderShippingService() { + return this.wxMaOrderShippingService; + } + + @Override + public WxMaOpenApiService getWxMaOpenApiService() { + return this.wxMaOpenApiService; + } + + @Override + public WxMaVodService getWxMaVodService() { + return this.wxMaVodService; + } + + @Override + public WxMaXPayService getWxMaXPayService() { + return this.wxMaXPayService; + } + + @Override + public WxMaExpressDeliveryReturnService getWxMaExpressDeliveryReturnService(){ + return this.wxMaExpressDeliveryReturnService; + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImpl.java index d2ed6e2de2..3e16814479 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImpl.java @@ -3,9 +3,9 @@ import cn.binarywang.wx.miniapp.api.WxMaCloudService; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.cloud.*; -import cn.binarywang.wx.miniapp.constant.WxMaConstants; +import cn.binarywang.wx.miniapp.bean.cloud.request.WxCloudSendSmsV2Request; import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; -import cn.binarywang.wx.miniapp.util.JoinerUtils; +import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.gson.JsonArray; @@ -13,6 +13,7 @@ import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; @@ -31,11 +32,13 @@ * 云开发相关接口实现类. * * @author Binary Wang - * @date 2020-01-22 + * created on 2020-01-22 */ @Slf4j @RequiredArgsConstructor public class WxMaCloudServiceImpl implements WxMaCloudService { + private static final Joiner blankJoiner = Joiner.on("").skipNulls(); + private final WxMaService wxMaService; @Override @@ -54,7 +57,7 @@ public String invokeCloudFunction(String env, String name, String body) throws W @Override public List add(String collection, List list) throws WxErrorException { String jsonData = WxMaGsonBuilder.create().toJson(list); - String query = JoinerUtils.blankJoiner.join( + String query = blankJoiner.join( "db.collection('", collection, "')", ".add({data: ", jsonData, "})"); @@ -64,7 +67,7 @@ public List add(String collection, List list) throws WxErrorException { String responseContent = wxMaService.post(DATABASE_ADD_URL, params.toString()); JsonObject jsonObject = GsonParser.parse(responseContent); - if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } JsonArray idArray = jsonObject.getAsJsonArray("id_list"); @@ -78,7 +81,7 @@ public List add(String collection, List list) throws WxErrorException { @Override public String add(String collection, Object obj) throws WxErrorException { String jsonData = WxMaGsonBuilder.create().toJson(obj); - String query = JoinerUtils.blankJoiner.join( + String query = blankJoiner.join( "db.collection('", collection, "')", ".add({data: ", jsonData, "})"); @@ -88,7 +91,7 @@ public String add(String collection, Object obj) throws WxErrorException { String responseContent = wxMaService.post(DATABASE_ADD_URL, params.toString()); JsonObject jsonObject = GsonParser.parse(responseContent); - if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } JsonArray idArray = jsonObject.getAsJsonArray("id_list"); @@ -109,7 +112,7 @@ public JsonArray databaseAdd(String env, String query) throws WxErrorException { @Override public Integer delete(String collection, String whereJson) throws WxErrorException { - String query = JoinerUtils.blankJoiner.join( + String query = blankJoiner.join( "db.collection('", collection, "')", ".where(", whereJson, ").remove()"); @@ -119,7 +122,7 @@ public Integer delete(String collection, String whereJson) throws WxErrorExcepti String responseContent = wxMaService.post(DATABASE_DELETE_URL, params.toString()); JsonObject jsonObject = GsonParser.parse(responseContent); - if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } return jsonObject.get("deleted").getAsInt(); @@ -139,7 +142,7 @@ public int databaseDelete(String env, String query) throws WxErrorException { @Override public WxCloudDatabaseUpdateResult update(String collection, String whereJson, String updateJson) throws WxErrorException { - String query = JoinerUtils.blankJoiner.join( + String query = blankJoiner.join( "db.collection('", collection, "')", ".where(", whereJson, ").update({data:", updateJson, " })"); @@ -182,7 +185,7 @@ public WxCloudDatabaseQueryResult query(String collection, String whereJson, Map if (null == skip) { skip = 0; } - String query = JoinerUtils.blankJoiner.join( + String query = blankJoiner.join( "db.collection('", collection, "')", ".where(", whereJson, ")", orderBySb.toString(), ".skip(", skip, ").limit(", limit, ").get()"); @@ -220,7 +223,7 @@ public JsonArray databaseAggregate(String env, String query) throws WxErrorExcep @Override public Long count(String collection, String whereJson) throws WxErrorException { - String query = JoinerUtils.blankJoiner.join( + String query = blankJoiner.join( "db.collection('", collection, "')", ".where(", whereJson, ").count()"); @@ -410,4 +413,15 @@ public WxCloudDatabaseCollectionGetResult databaseCollectionGet(String env, Long String response = this.wxMaService.post(DATABASE_COLLECTION_GET_URL, params); return WxGsonBuilder.create().fromJson(response, WxCloudDatabaseCollectionGetResult.class); } + + @Override + public WxCloudSendSmsV2Result sendSmsV2(WxCloudSendSmsV2Request request) throws WxErrorException { + // 如果没有指定云环境ID,取默认云环境ID + if (request.getEnv() == null) { + String cloudEnv = this.wxMaService.getWxMaConfig().getCloudEnv(); + request.setEnv(cloudEnv); + } + String response = this.wxMaService.post(SEND_SMS_V2_URL, request); + return WxGsonBuilder.create().fromJson(response, WxCloudSendSmsV2Result.class); + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImpl.java index 37265cfe5a..921174f110 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImpl.java @@ -67,13 +67,13 @@ public byte[] getQrCode(String path) throws WxErrorException { } @Override - public List getCategory() throws WxErrorException { + public List getCategory() throws WxErrorException { String responseContent = this.service.get(GET_CATEGORY_URL, null); JsonObject jsonObject = GsonParser.parse(responseContent); boolean hasCategoryList = jsonObject.has("category_list"); if (hasCategoryList) { return WxMaGsonBuilder.create().fromJson(jsonObject.getAsJsonArray("category_list"), - new TypeToken>() { + new TypeToken>() { }.getType()); } else { return null; @@ -138,6 +138,12 @@ public WxMaCodeVersionDistribution getSupportVersion() throws WxErrorException { return WxMaCodeVersionDistribution.fromJson(responseContent); } + @Override + public WxMaCodeVersionInfo getVersionInfo() throws WxErrorException { + String responseContent = this.service.post(GET_VERSION_INFO_URL, "{}"); + return WxMaCodeVersionInfo.fromJson(responseContent); + } + @Override public void setSupportVersion(String version) throws WxErrorException { JsonObject param = new JsonObject(); diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImpl.java new file mode 100644 index 0000000000..0943a1feeb --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImpl.java @@ -0,0 +1,51 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaDeviceSubscribeService; +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.device.WxMaDeviceSubscribeMessageRequest; +import cn.binarywang.wx.miniapp.bean.device.WxMaDeviceTicketRequest; +import cn.binarywang.wx.miniapp.constant.WxMaConstants; +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; + +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.DeviceSubscribe.GET_SN_TICKET_URL; +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.DeviceSubscribe.SEND_DEVICE_SUBSCRIBE_MSG_URL; + +/** + * 小程序设备订阅消息相关 API + * 文档: + * + * @author JCLee + * @since 2021-12-16 17:13:35 + */ + +@RequiredArgsConstructor +public class WxMaDeviceSubscribeServiceImpl implements WxMaDeviceSubscribeService { + + private final WxMaService service; + + @Override + public String getSnTicket(WxMaDeviceTicketRequest deviceTicketRequest) throws WxErrorException { + String responseContent = this.service.post(GET_SN_TICKET_URL, deviceTicketRequest.toJson()); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + String snTicket = jsonObject.get("sn_ticket").getAsString(); + return snTicket; + } + + @Override + public void sendDeviceSubscribeMsg(WxMaDeviceSubscribeMessageRequest deviceSubscribeMessageRequest) throws WxErrorException { + String responseContent = this.service.post(SEND_DEVICE_SUBSCRIBE_MSG_URL, deviceSubscribeMessageRequest.toJson()); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaExpressDeliveryReturnServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaExpressDeliveryReturnServiceImpl.java new file mode 100644 index 0000000000..aef8a2cad2 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaExpressDeliveryReturnServiceImpl.java @@ -0,0 +1,36 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaExpressDeliveryReturnService; +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.express.request.WxMaExpressDeliveryReturnAddRequest; +import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressReturnInfoResult; +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxErrorException; + +@RequiredArgsConstructor +public class WxMaExpressDeliveryReturnServiceImpl implements WxMaExpressDeliveryReturnService { + private final WxMaService service; + + @Override + public WxMaExpressReturnInfoResult addDeliveryReturn(WxMaExpressDeliveryReturnAddRequest wxMaExpressDeliveryReturnAddRequest) throws WxErrorException { + String result= this.service.get(ADD_DELIVERY_RETURN_URL,wxMaExpressDeliveryReturnAddRequest.toJson()); + return WxMaExpressReturnInfoResult.fromJson(result); + } + + @Override + public WxMaExpressReturnInfoResult getDeliveryReturn(String returnId) throws WxErrorException { + JsonObject param = new JsonObject(); + param.addProperty("return_id",returnId); + String result= this.service.get(GET_DELIVERY_RETURN_URL,param.toString()); + return WxMaExpressReturnInfoResult.fromJson(result); + } + + @Override + public WxMaExpressReturnInfoResult unbindDeliveryReturn(String returnId) throws WxErrorException { + JsonObject param = new JsonObject(); + param.addProperty("return_id",returnId); + String result= this.service.get(UNBIND_DELIVERY_RETURN_URL,param.toString()); + return WxMaExpressReturnInfoResult.fromJson(result); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaExpressServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaExpressServiceImpl.java index 17568c9e8a..ba773d6f78 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaExpressServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaExpressServiceImpl.java @@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPath; import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPrinter; import cn.binarywang.wx.miniapp.bean.express.request.*; +import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressInfoResult; import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressOrderInfoResult; import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import lombok.RequiredArgsConstructor; @@ -39,8 +40,8 @@ public List getAllAccount() throws WxErrorException { } @Override - public void bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException { - this.service.post(BIND_ACCOUNT_URL, wxMaExpressBindAccountRequest.toJson()); + public WxMaExpressInfoResult bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException { + return WxMaExpressInfoResult.fromJson(this.service.post(BIND_ACCOUNT_URL, wxMaExpressBindAccountRequest.toJson())); } @Override diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java index 1ed94fe4df..03f46fb31e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java @@ -35,7 +35,7 @@ public WxImgProcQrCodeResult qrCode(String imgUrl) throws WxErrorException { //ignore } - final String result = this.service.get(String.format(QRCODE, imgUrl), null); + final String result = this.service.post(String.format(QRCODE, imgUrl), ""); return WxImgProcQrCodeResult.fromJson(result); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java new file mode 100644 index 0000000000..b6c3814f62 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java @@ -0,0 +1,226 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaImmediateDeliveryService; +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.delivery.*; +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; +import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants; +import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.InstantDelivery; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE; + +/** + * 微信小程序即时配送服务. + *
+ *     文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/immediate-delivery/overview.html
+ * 
+ * + * @author Luo + * @version 1.0 + * created on 2021-10-13 16:40 + */ +@RequiredArgsConstructor +public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliveryService { + + /** + * 顺丰同城响应码. + */ + public static final String SF_ERR_CODE = "resultcode"; + + /** + * 顺丰同城响应说明. + */ + public static final String SF_ERR_MSG = "resultmsg"; + + /** + * 成功响应状态码. + */ + public static final int SUCCESS_CODE = 0; + + private final WxMaService wxMaService; + + /** + * 拉取已绑定账号. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getBindAccount.html
+   * 
+ * + * @return 响应 + * @throws WxErrorException 异常 + */ + @Override + public BindAccountResponse getBindAccount() throws WxErrorException { + return this.parse(this.wxMaService.post(InstantDelivery.GET_BIND_ACCOUNT, "{}"), + BindAccountResponse.class); + } + + /** + * 下配送单接口. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.addOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + @Override + public AddOrderResponse addOrder(final AddOrderRequest request) throws WxErrorException { + request.getDeliverySign(); + return this.parse(this.wxMaService.post(InstantDelivery.PlaceAnOrder.ADD_ORDER, request), + AddOrderResponse.class); + } + + /** + * 拉取配送单信息. + *
+   * 商家可使用本接口查询某一配送单的配送状态,便于商家掌握配送情况。
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + @Override + public GetOrderResponse getOrder(final GetOrderRequest request) throws WxErrorException { + request.getDeliverySign(); + return this.parse(this.wxMaService.post(InstantDelivery.GET_ORDER, request), + GetOrderResponse.class); + } + + /** + * 取消配送单接口. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.cancelOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + @Override + public CancelOrderResponse cancelOrder(final CancelOrderRequest request) throws WxErrorException { + request.getDeliverySign(); + return this.parse(this.wxMaService.post(InstantDelivery.Cancel.CANCEL_ORDER, request), + CancelOrderResponse.class); + } + + /** + * 异常件退回商家商家确认收货接口. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.abnormalConfirm.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + @Override + public AbnormalConfirmResponse abnormalConfirm(final AbnormalConfirmRequest request) throws WxErrorException { + request.getDeliverySign(); + return this.parse(this.wxMaService.post(InstantDelivery.Cancel.ABNORMAL_CONFIRM, request), + AbnormalConfirmResponse.class); + } + + /** + * 模拟配送公司更新配送单状态, 该接口只用于沙盒环境,即订单并没有真实流转到运力方. + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.mockUpdateOrder.html
+   * 
+ * + * @param request request + * @return 响应 + * @throws WxErrorException 异常 + */ + @Override + public MockUpdateOrderResponse mockUpdateOrder(final MockUpdateOrderRequest request) throws WxErrorException { + return this.parse(this.wxMaService.post(InstantDelivery.MOCK_UPDATE_ORDER, request), + MockUpdateOrderResponse.class); + } + + @Override + public TraceWaybillResponse traceWaybill( + TraceWaybillRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(InstantDelivery.TRACE_WAYBILL_URL, request); + TraceWaybillResponse response = TraceWaybillResponse.fromJson(responseContent); + if (response.getErrcode() == -1) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return response; + + } + + @Override + public QueryWaybillTraceResponse queryWaybillTrace( + QueryWaybillTraceRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(InstantDelivery.QUERY_WAYBILL_TRACE_URL, request); + QueryWaybillTraceResponse response = QueryWaybillTraceResponse.fromJson(responseContent); + if (response.getErrcode() == -1) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return response; + } + + @Override + public FollowWaybillResponse followWaybill( + FollowWaybillRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(InstantDelivery.FOLLOW_WAYBILL_URL, request); + FollowWaybillResponse response = FollowWaybillResponse.fromJson(responseContent); + if (response.getErrcode() == -1) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return response; + } + + @Override + public QueryFollowTraceResponse queryFollowTrace( + QueryFollowTraceRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(InstantDelivery.QUERY_FOLLOW_TRACE_URL, request); + QueryFollowTraceResponse response = QueryFollowTraceResponse.fromJson(responseContent); + if (response.getErrcode() == -1) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return response; + } + + /** + * 解析响应. + * + * @param responseContent 响应内容 + * @param valueType 类型 + * @param 类型 + * @return 结果 + * @throws WxErrorException 异常 + */ + private T parse(final String responseContent, final Class valueType) throws WxErrorException { + if (StringUtils.isBlank(responseContent)) { + throw new RuntimeException("the responseContent cannot be empty"); + } + // 解析成Json对象 + JsonObject jsonObject = GsonParser.parse(responseContent); + // 是否为微信错误响应 当 errcode==0 或者 不存在 还需要看 运力方 resultcode 状态码 + JsonElement element = jsonObject.get(ERR_CODE); + // 正常响应下不会有该字段返回 + if (!ObjectUtils.isEmpty(element) && SUCCESS_CODE != element.getAsInt()) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + // 是否为运力方错误响应 + JsonElement delivery = jsonObject.get(SF_ERR_CODE); + if (!ObjectUtils.isEmpty(delivery) && SUCCESS_CODE != delivery.getAsInt()) { + throw new WxErrorException(jsonObject.get(SF_ERR_MSG).getAsString()); + } + // 解析成对应响应对象 + return WxMaDeliveryBaseResponse.fromJson(responseContent, valueType); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImpl.java index 8ee023baf5..f42564279a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImpl.java @@ -10,20 +10,51 @@ import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + /** - * * 服务端网络相关接口 * * @author chutian0124 - * @Date 2021-09-06 + * created on 2021-09-06 */ @RequiredArgsConstructor public class WxMaInternetServiceImpl implements WxMaInternetService { private final WxMaService wxMaService; + private String sha256(String data, String sessionKey) throws Exception { + Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); + SecretKeySpec secret_key = new SecretKeySpec(sessionKey.getBytes("UTF-8"), "HmacSHA256"); + sha256_HMAC.init(secret_key); + byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (byte item : array) { + sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); + } + return sb.toString().toUpperCase(); + } + @Override - public WxMaInternetResponse getUserEncryptKey() throws WxErrorException { - String responseContent = this.wxMaService.post(WxMaApiUrlConstants.Internet.GET_USER_ENCRYPT_KEY, ""); + public WxMaInternetResponse getUserEncryptKey(String openid, String signature, String sigMethod) throws WxErrorException { + String url = WxMaApiUrlConstants.Internet.GET_USER_ENCRYPT_KEY + "?openid=" + openid + "&signature=" + signature + "&sig_method=" + sigMethod; + return getWxMaInternetResponse(url); + } + + @Override + public WxMaInternetResponse getUserEncryptKey(String openid, String sessionKey) throws WxErrorException { + String signature = null; + try { + signature = sha256("", sessionKey); + } catch (Exception e) { + throw new WxErrorException("签名错误"); + } + String url = WxMaApiUrlConstants.Internet.GET_USER_ENCRYPT_KEY + "?sig_method=hmac_sha256&openid=" + openid + "&signature=" + signature; + return getWxMaInternetResponse(url); + } + + private WxMaInternetResponse getWxMaInternetResponse(String url) throws WxErrorException { + String responseContent = this.wxMaService.post(url, ""); WxMaInternetResponse response = WxMaGsonBuilder.create().fromJson(responseContent, WxMaInternetResponse.class); if (response.getErrcode() == -1) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImpl.java index e0dd4a915c..c316148621 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImpl.java @@ -4,12 +4,16 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.shortlink.GenerateShortLinkRequest; import cn.binarywang.wx.miniapp.bean.urllink.GenerateUrlLinkRequest; +import cn.binarywang.wx.miniapp.bean.urllink.request.QueryUrlLinkRequest; +import cn.binarywang.wx.miniapp.bean.urllink.response.QueryUrlLinkResponse; import com.google.gson.JsonObject; import lombok.AllArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Link.GENERATE_URLLINK_URL; +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Link.QUERY_URLLINK_URL; import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.ShortLink.GENERATE_SHORT_LINK_URL; /** @@ -29,7 +33,7 @@ public String generateUrlLink(GenerateUrlLinkRequest request) throws WxErrorExce String linkField = "url_link"; JsonObject jsonObject = GsonParser.parse(result); if (jsonObject.has(linkField)) { - return jsonObject.get(linkField).toString(); + return jsonObject.get(linkField).getAsString(); } throw new WxErrorException("无url_link"); } @@ -40,8 +44,14 @@ public String generateShortLink(GenerateShortLinkRequest request) throws WxError String linkField = "link"; JsonObject jsonObject = GsonParser.parse(result); if (jsonObject.has(linkField)) { - return jsonObject.get(linkField).toString(); + return jsonObject.get(linkField).getAsString(); } throw new WxErrorException("无link"); } + + @Override + public QueryUrlLinkResponse queryUrlLink(QueryUrlLinkRequest request) throws WxErrorException { + String result = this.wxMaService.post(QUERY_URLLINK_URL, request); + return WxGsonBuilder.create().fromJson(result, QueryUrlLinkResponse.class); + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveGoodsServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveGoodsServiceImpl.java index 99d82fdbf8..cfd8428673 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveGoodsServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveGoodsServiceImpl.java @@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonHelper; @@ -20,6 +21,7 @@ import java.util.Map; import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Goods.*; +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Code.GET_PAGE_URL; /** *
@@ -94,4 +96,26 @@ public WxMaLiveResult getApprovedGoods(Integer offset, Integer limit, Integer st
     return WxMaLiveResult.fromJson(jsonObject.toString());
   }
 
+  @Override
+  public boolean setKey(List goodsKey) throws WxErrorException {
+    Map map = new HashMap<>(1);
+    map.put("goodsKey", goodsKey);
+    this.wxMaService.post(SET_KEY, WxMaGsonBuilder.create().toJson(map));
+    return true;
+  }
+
+  @Override
+  public List getKey() throws WxErrorException {
+    String responseContent = this.wxMaService.get(GET_KEY, null);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    boolean vendorGoodsKey = jsonObject.has("vendorGoodsKey");
+    if (vendorGoodsKey) {
+      return WxMaGsonBuilder.create().fromJson(jsonObject.getAsJsonArray("vendorGoodsKey"),
+              new TypeToken>() {
+              }.getType());
+    } else {
+      return null;
+    }
+  }
+
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImpl.java
index 065b401fe0..fad6fba17b 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImpl.java
@@ -19,7 +19,7 @@
  * .
  *
  * @author Binary Wang
- * @date 2021-02-15
+ * created on  2021-02-15
  */
 @RequiredArgsConstructor
 public class WxMaLiveMemberServiceImpl implements WxMaLiveMemberService {
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java
index b71e58653e..8dbc81b576 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java
@@ -18,8 +18,8 @@
 import java.util.List;
 import java.util.Map;
 
-import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.GET_LIVE_INFO;
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Room;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * 
@@ -31,7 +31,6 @@
 @Slf4j
 @RequiredArgsConstructor
 public class WxMaLiveServiceImpl implements WxMaLiveService {
-  private static final String ERR_CODE = "errcode";
   private static final String ROOM_ID = "roomId";
   private final WxMaService wxMaService;
 
@@ -88,7 +87,7 @@ public String getPushUrl(Integer roomId) throws WxErrorException {
   }
 
   @Override
-  public String getSharedCode(Integer roomId, String params) throws WxErrorException {
+  public WxMaLiveSharedCode getSharedCode(Integer roomId, String params) throws WxErrorException {
     Map map = new HashMap<>(2);
     map.put(ROOM_ID, roomId);
     if (null != params) {
@@ -99,7 +98,7 @@ public String getSharedCode(Integer roomId, String params) throws WxErrorExcepti
     if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
-    return jsonObject.get("cdnUrl").getAsString();
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaLiveSharedCode.class);
   }
 
   @Override
@@ -152,7 +151,7 @@ private JsonObject getLiveInfo(Integer start, Integer limit, Map
     }
     map.put("start", start);
     map.put("limit", limit);
-    String responseContent = wxMaService.post(GET_LIVE_INFO, WxMaGsonBuilder.create().toJson(map));
+    String responseContent = wxMaService.post(Room.GET_LIVE_INFO, WxMaGsonBuilder.create().toJson(map));
     JsonObject jsonObject = GsonParser.parse(responseContent);
     if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
@@ -231,4 +230,172 @@ public List getAssistantList(Integer roomId) thro
     return WxMaAssistantResult.fromJson(responseContent).getList();
   }
 
+  @Override
+  public boolean addSubanchor(Integer roomId, String username) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("username", username);
+    String responseContent = this.wxMaService.post(Room.ADD_SUBANCHOR, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean modifySubanchor(Integer roomId, String username) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("username", username);
+    String responseContent = this.wxMaService.post(Room.MODIFY_SUBANCHOR, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean deleteSubanchor(Integer roomId) throws WxErrorException {
+    Map map = new HashMap<>(1);
+    map.put(ROOM_ID, roomId);
+    String responseContent = this.wxMaService.post(Room.DELETE_SUBANCHOR, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public String getSubanchor(Integer roomId) throws WxErrorException {
+    Map map = new HashMap<>(1);
+    map.put(ROOM_ID, roomId);
+    String responseContent = this.wxMaService.get(Room.GET_SUBANCHOR, Joiner.on("&").withKeyValueSeparator("=").join(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return jsonObject.get("username").getAsString();
+  }
+
+  @Override
+  public boolean updatefeedpublic(Integer roomId, Integer isFeedsPublic) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("isFeedsPublic", isFeedsPublic);
+    String responseContent = this.wxMaService.post(Room.UPDATE_FEED_PUBLIC, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean updatereplay(Integer roomId, Integer closeReplay) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("closeReplay", closeReplay);
+    String responseContent = this.wxMaService.post(Room.UPDATE_REPLAY, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean updatekf(Integer roomId, Integer closeKf) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("closeKf", closeKf);
+    String responseContent = this.wxMaService.post(Room.UPDATE_KF, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean updatecomment(Integer roomId, Integer banComment) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("banComment", banComment);
+    String responseContent = this.wxMaService.post(Room.UPDATE_COMMENT, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean onsale(Integer roomId, Integer goodsId, Integer onSale) throws WxErrorException {
+    Map map = new HashMap<>(3);
+    map.put(ROOM_ID, roomId);
+    map.put("goodsId", goodsId);
+    map.put("onSale", onSale);
+    String responseContent = this.wxMaService.post(Room.ONSALE, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean deleteInRoom(Integer roomId, Integer goodsId) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("goodsId", goodsId);
+    String responseContent = this.wxMaService.post(Room.DELETE_IN_ROOM, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean push(Integer roomId, Integer goodsId) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("goodsId", goodsId);
+    String responseContent = this.wxMaService.post(Room.PUSH, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public boolean sort(Integer roomId, List> goods) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("goods", goods);
+    String responseContent = this.wxMaService.post(Room.SORT, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return true;
+  }
+
+  @Override
+  public String getVideo(Integer roomId, Integer goodsId) throws WxErrorException {
+    Map map = new HashMap<>(2);
+    map.put(ROOM_ID, roomId);
+    map.put("goodsId", goodsId);
+    String responseContent = this.wxMaService.post(Room.GET_VIDEO, WxMaGsonBuilder.create().toJson(map));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return jsonObject.get("url").getAsString();
+  }
+
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMarketingServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMarketingServiceImpl.java
new file mode 100644
index 0000000000..e67edc1432
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMarketingServiceImpl.java
@@ -0,0 +1,41 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaMarketingService;
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.marketing.WxMaUserAction;
+import com.google.gson.JsonObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+import java.util.List;
+
+/**
+ * @author 184759547
+ * 微信营销接口
+ * @since : 2021/12/28
+ */
+@Slf4j
+@RequiredArgsConstructor
+public class WxMaMarketingServiceImpl implements WxMaMarketingService {
+  private final WxMaService wxMaService;
+  private final String USER_ACTION_SETS_ADD = "https://api.weixin.qq.com/marketing/user_action_sets/add?version=v1.0";
+  private final String USER_ACTIONS_ADD = "https://api.weixin.qq.com/marketing/user_actions/add?version=v1.0";
+
+  @Override
+  public long addUserActionSets(String type, String name, String description) throws WxErrorException {
+    JsonObject json = new JsonObject();
+    json.addProperty("type", type);
+    json.addProperty("name", name);
+    json.addProperty("description", description);
+    String responseContent = wxMaService.post(USER_ACTION_SETS_ADD, json.toString());
+    JsonObject tmpJson = GsonParser.parse(responseContent);
+    return tmpJson.get("data").getAsJsonObject().get("user_action_set_id").getAsLong();
+  }
+
+  @Override
+  public String addUserAction(List actions, Long userActionSetId) throws WxErrorException {
+    return wxMaService.post(USER_ACTIONS_ADD, WxMaUserAction.listToJson(actions, userActionSetId));
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java
index b000afeeaa..eaf23f11e9 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java
@@ -10,6 +10,7 @@
 import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
 import com.google.gson.JsonObject;
 import lombok.RequiredArgsConstructor;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.enums.WxType;
 import me.chanjar.weixin.common.error.WxError;
 import me.chanjar.weixin.common.error.WxErrorException;
@@ -34,7 +35,7 @@ public boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException {
   public void sendSubscribeMsg(WxMaSubscribeMessage subscribeMessage) throws WxErrorException {
     String responseContent = this.service.post(SUBSCRIBE_MSG_SEND_URL, subscribeMessage.toJson());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
   }
@@ -43,7 +44,7 @@ public void sendSubscribeMsg(WxMaSubscribeMessage subscribeMessage) throws WxErr
   public void sendUniformMsg(WxMaUniformMessage uniformMessage) throws WxErrorException {
     String responseContent = this.service.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
   }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java
index 66668e0043..8faef8e30e 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java
@@ -18,7 +18,7 @@
  * ocr 接口实现.
  *
  * @author Binary Wang
- * @date 2019-06-22
+ * created on  2019-06-22
  */
 @RequiredArgsConstructor
 public class WxMaOcrServiceImpl implements WxOcrService {
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOpenApiServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOpenApiServiceImpl.java
new file mode 100644
index 0000000000..b74b9bfb27
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOpenApiServiceImpl.java
@@ -0,0 +1,81 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaOpenApiService;
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.openapi.WxMiniGetApiQuotaResult;
+import cn.binarywang.wx.miniapp.bean.openapi.WxMiniGetRidInfoResult;
+import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.JsonObject;
+import lombok.RequiredArgsConstructor;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
+
+/**
+ * @author shuiyihan12
+ * @since 2023/7/7 17:08
+ */
+@RequiredArgsConstructor
+public class WxMaOpenApiServiceImpl implements WxMaOpenApiService {
+  private final WxMaService wxMaService;
+
+  private static final String QUOTA = "quota";
+  private static final String REQUEST = "request";
+
+
+  @Override
+  public boolean clearQuota() throws WxErrorException {
+    JsonObject params = new JsonObject();
+    params.addProperty("appid", this.wxMaService.getWxMaConfig().getAppid());
+    String responseContent = this.wxMaService.post(WxMaApiUrlConstants.OpenApi.CLEAR_QUOTA, params.toString());
+    parseErrorResponse(responseContent);
+    return true;
+  }
+
+  @Override
+  public WxMiniGetApiQuotaResult getApiQuota(String cgiPath) throws WxErrorException {
+    JsonObject params = new JsonObject();
+    params.addProperty("cgi_path", cgiPath);
+    String responseContent = this.wxMaService.post(WxMaApiUrlConstants.OpenApi.GET_API_QUOTA, params.toString());
+    parseErrorResponse(responseContent);
+    JsonObject response = GsonParser.parse(responseContent);
+    if (response.has(QUOTA)) {
+      return WxMaGsonBuilder.create().fromJson(response.getAsJsonObject(QUOTA), WxMiniGetApiQuotaResult.class);
+    }
+    return null;
+  }
+
+
+  @Override
+  public WxMiniGetRidInfoResult getRidInfo(String rid) throws WxErrorException {
+    JsonObject params = new JsonObject();
+    params.addProperty("rid", rid);
+    String responseContent = this.wxMaService.post(WxMaApiUrlConstants.OpenApi.GET_RID_INFO, params.toString());
+    parseErrorResponse(responseContent);
+    JsonObject response = GsonParser.parse(responseContent);
+    if (response.has(REQUEST)) {
+      return WxMaGsonBuilder.create().fromJson(response.getAsJsonObject(QUOTA), WxMiniGetRidInfoResult.class);
+    }
+    return null;
+  }
+
+  @Override
+  public boolean clearQuotaByAppSecret() throws WxErrorException {
+    String url = String.format(WxMaApiUrlConstants.OpenApi.CLEAR_QUOTA_BY_APP_SECRET, this.wxMaService.getWxMaConfig().getAppid(), this.wxMaService.getWxMaConfig().getSecret());
+    String responseContent = this.wxMaService.post(url, "");
+    parseErrorResponse(responseContent);
+    return true;
+  }
+
+
+  private void parseErrorResponse(String response) throws WxErrorException {
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOrderShippingServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOrderShippingServiceImpl.java
new file mode 100644
index 0000000000..4aee53e15d
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOrderShippingServiceImpl.java
@@ -0,0 +1,134 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaOrderShippingService;
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.shop.request.WxMaOrderShippingIsTradeManagedRequest;
+import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetListResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingIsTradeManagedResponse;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.JsonObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.api.WxConsts;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonHelper;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.OrderShipping.*;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_CATEGORY;
+
+
+/**
+ * @author xzh
+ * created on  2023/5/17 17:44
+ */
+@Slf4j
+@RequiredArgsConstructor
+public class WxMaOrderShippingServiceImpl implements WxMaOrderShippingService {
+
+  private final WxMaService wxMaService;
+
+  /**
+   * 查询小程序是否已开通发货信息管理服务
+   *
+   * @param appId 待查询小程序的 appid,非服务商调用时仅能查询本账号
+   * @return WxMaOrderShippingInfoBaseResponse
+   * @throws WxErrorException e
+   */
+  @Override
+  public WxMaOrderShippingIsTradeManagedResponse isTradeManaged(String appId) throws WxErrorException {
+    WxMaOrderShippingIsTradeManagedRequest request = WxMaOrderShippingIsTradeManagedRequest.builder().appId(appId).build();
+    return request(IS_TRADE_MANAGED, request, WxMaOrderShippingIsTradeManagedResponse.class);
+  }
+
+  /**
+   * 发货信息录入接口
+   *
+   * @param request 请求
+   * @return WxMaOrderShippingInfoBaseResponse
+   * @throws WxErrorException e
+   */
+  @Override
+  public WxMaOrderShippingInfoBaseResponse upload(WxMaOrderShippingInfoUploadRequest request) throws WxErrorException {
+    return request(UPLOAD_SHIPPING_INFO, request, WxMaOrderShippingInfoBaseResponse.class);
+  }
+
+  /**
+   * 发货信息合单录入接口
+   *
+   * @param request 请求
+   * @return WxMaOrderShippingInfoBaseResponse
+   * @throws WxErrorException e
+   */
+  @Override
+  public WxMaOrderShippingInfoBaseResponse upload(WxMaOrderCombinedShippingInfoUploadRequest request) throws WxErrorException {
+    return request(UPLOAD_COMBINED_SHIPPING_INFO, request, WxMaOrderShippingInfoBaseResponse.class);
+  }
+
+  /**
+   * 查询订单发货状态
+   * 你可以通过交易单号或商户号+商户单号来查询该支付单的发货状态。
+   *
+   * @param request 请求
+   * @return WxMaOrderShippingInfoGetResponse
+   * @throws WxErrorException e
+   */
+  @Override
+  public WxMaOrderShippingInfoGetResponse get(WxMaOrderShippingInfoGetRequest request) throws WxErrorException {
+    return request(GET_SHIPPING_INFO, request, WxMaOrderShippingInfoGetResponse.class);
+  }
+
+  /**
+   * 查询订单列表
+   * 你可以通过支付时间、支付者openid或订单状态来查询订单列表。
+   *
+   * @param request 请求
+   * @return WxMaOrderShippingInfoGetListResponse
+   * @throws WxErrorException e
+   */
+  @Override
+  public WxMaOrderShippingInfoGetListResponse getList(WxMaOrderShippingInfoGetListRequest request) throws WxErrorException {
+    return request(GET_SHIPPING_INFO_LIST, request, WxMaOrderShippingInfoGetListResponse.class);
+  }
+
+  /**
+   * 确认收货提醒接口
+   * 如你已经从你的快递物流服务方获知到用户已经签收相关商品,可以通过该接口提醒用户及时确认收货,以提高资金结算效率,每个订单仅可调用一次。
+   *
+   * @param request 请求
+   * @return WxMaOrderShippingInfoBaseResponse
+   * @throws WxErrorException e
+   */
+  @Override
+  public WxMaOrderShippingInfoBaseResponse notifyConfirmReceive(WxMaOrderShippingInfoNotifyConfirmRequest request) throws WxErrorException {
+    return request(NOTIFY_CONFIRM_RECEIVE, request, WxMaOrderShippingInfoBaseResponse.class);
+  }
+
+  /**
+   * 消息跳转路径设置接口
+   * 如你已经在小程序内接入平台提供的确认收货组件,可以通过该接口设置发货消息及确认收货消息的跳转动作,用户点击发货消息时会直接进入你的小程序订单列表页面或详情页面进行确认收货,进一步优化用户体验。
+   *
+   * @param path 商户自定义跳转路径
+   * @return WxMaOrderShippingInfoBaseResponse
+   * @throws WxErrorException e
+   */
+  @Override
+  public WxMaOrderShippingInfoBaseResponse setMsgJumpPath(String path) throws WxErrorException {
+    JsonObject jsonObject = GsonHelper.buildJsonObject("path", path);
+    return request(SET_MSG_JUMP_PATH, jsonObject, WxMaOrderShippingInfoBaseResponse.class);
+  }
+
+  private  T request(String url, Object request, Class resultT) throws WxErrorException {
+    String responseContent = this.wxMaService.post(url, request);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, resultT);
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaProductOrderServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaProductOrderServiceImpl.java
new file mode 100644
index 0000000000..15ed07a945
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaProductOrderServiceImpl.java
@@ -0,0 +1,167 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.AFTER_SALE_ACCEPT_APPLY;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.AFTER_SALE_REJECT_APPLY;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.BATCH_GET_AFTER_SALE_ORDER;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.GET_AFTER_SALE_ORDER;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_DELIVERY_SEND;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_CHANGE_MERCHANT_NOTES_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_DETAIL_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_GET_LIST;
+
+import cn.binarywang.wx.miniapp.api.WxMaProductOrderService;
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.product.WxMiniBatchGetAfterSaleOrderResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMiniGetAfterSaleOrderResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMiniOrderDeliveryRequest;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderDetailResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonHelper;
+import me.chanjar.weixin.common.util.json.WxGsonBuilder;
+
+/**
+ * 小程序交易组件-标准版-订单服务
+ *
+ * @author boris 详情请见 : https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/order/get_order_list.html
+ */
+@RequiredArgsConstructor
+@Slf4j
+public class WxMaProductOrderServiceImpl implements WxMaProductOrderService {
+
+  private final WxMaService wxMaService;
+
+
+  @Override
+  public WxMinishopOrderListResponse getOrderList(
+    String startCreateTime, String endCreateTime, String startUpdateTime,
+    String endUpdateTime, Integer status, Integer page, Integer pageSize, Integer source)
+    throws WxErrorException {
+    String responseContent = this.wxMaService
+      .post(PRODUCT_ORDER_GET_LIST, GsonHelper.buildJsonObject(
+        "start_create_time", startCreateTime, "end_create_time", endCreateTime,
+        "start_update_time", startUpdateTime, "end_update_time", endUpdateTime,
+        "status", status, "page", page, "page_size", pageSize, "source", source));
+
+    WxMinishopOrderListResponse response = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMinishopOrderListResponse.class);
+
+    if (response.getErrCode() != 0) {
+      throw new WxErrorException(new WxError(response.getErrCode(), response.getErrMsg()));
+    }
+
+    return response;
+
+  }
+
+  @Override
+  public WxMinishopOrderDetailResponse getOrderDetail(
+    Long orderId) throws WxErrorException {
+    String responseContent = this.wxMaService
+      .post(PRODUCT_ORDER_DETAIL_URL, GsonHelper.buildJsonObject(
+        "order_id", orderId));
+
+    WxMinishopOrderDetailResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMinishopOrderDetailResponse.class);
+
+    if (getDetailResponse.getErrCode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrCode(), getDetailResponse.getErrMsg()));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public void changeMerchantNotes(Long orderId, String merchantNotes) throws WxErrorException {
+    String responseContent = this.wxMaService
+      .post(PRODUCT_ORDER_CHANGE_MERCHANT_NOTES_URL, GsonHelper.buildJsonObject(
+        "order_id", orderId,"merchant_notes",merchantNotes));
+
+    WxMaShopBaseResponse changeResult = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaShopBaseResponse.class);
+
+    if (changeResult.getErrCode() != 0) {
+      throw new WxErrorException(
+        new WxError(changeResult.getErrCode(), changeResult.getErrMsg()));
+    }
+  }
+
+  @Override
+  public WxMaShopBaseResponse deliverySend(WxMiniOrderDeliveryRequest request)
+    throws WxErrorException {
+    String response = this.wxMaService.post(PRODUCT_DELIVERY_SEND, request);
+    WxMaShopBaseResponse baseResponse = WxMaGsonBuilder.create()
+      .fromJson(response, WxMaShopBaseResponse.class);
+    if (baseResponse.getErrCode() != 0) {
+      throw new WxErrorException(
+        new WxError(baseResponse.getErrCode(), baseResponse.getErrMsg()));
+    }
+    return baseResponse;
+  }
+
+  @Override
+  public WxMiniGetAfterSaleOrderResponse getAfterSaleOrder(Long afterSaleOrderId)
+    throws WxErrorException {
+    String response = this.wxMaService.post(GET_AFTER_SALE_ORDER,
+      GsonHelper.buildJsonObject("after_sale_order_id", afterSaleOrderId));
+
+    WxMiniGetAfterSaleOrderResponse orderResponse = WxMaGsonBuilder.create()
+      .fromJson(response, WxMiniGetAfterSaleOrderResponse.class);
+    if (orderResponse.getErrCode() != 0) {
+      throw new WxErrorException(
+        new WxError(orderResponse.getErrCode(), orderResponse.getErrMsg()));
+    }
+    return orderResponse;
+  }
+
+  @Override
+  public WxMiniBatchGetAfterSaleOrderResponse batchGetAfterSaleOrder(
+    List afterSaleOrderIdList)
+    throws WxErrorException {
+    String response = this.wxMaService.post(BATCH_GET_AFTER_SALE_ORDER,
+      GsonHelper.buildJsonObject("after_sale_order_id_list", afterSaleOrderIdList));
+
+    WxMiniBatchGetAfterSaleOrderResponse orderResponse = WxMaGsonBuilder.create()
+      .fromJson(response, WxMiniBatchGetAfterSaleOrderResponse.class);
+    if (orderResponse.getAfterSaleOrderList() == null) {
+      throw new WxErrorException(
+        new WxError(orderResponse.getErrCode(), "售后查询不存在"));
+    }
+    return orderResponse;
+  }
+
+  @Override
+  public WxMaShopBaseResponse afterSaleAccept(Long orderId, Long addressId)
+    throws WxErrorException {
+    String response = this.wxMaService.post(AFTER_SALE_ACCEPT_APPLY,
+      GsonHelper.buildJsonObject("order_id", orderId, "address_id", addressId));
+    WxMaShopBaseResponse baseResponse = WxGsonBuilder.create()
+      .fromJson(response, WxMaShopBaseResponse.class);
+    if (baseResponse.getErrCode() != 0) {
+      throw new WxErrorException(
+        new WxError(baseResponse.getErrCode(), baseResponse.getErrMsg()));
+    }
+    return baseResponse;
+  }
+
+  @Override
+  public WxMaShopBaseResponse afterSaleReject(Long afterSaleOrderId, String rejectReason)
+    throws WxErrorException {
+    String response = this.wxMaService.post(AFTER_SALE_REJECT_APPLY,
+      GsonHelper.buildJsonObject("order_id", afterSaleOrderId, "reject_reason", rejectReason));
+    WxMaShopBaseResponse baseResponse = WxGsonBuilder.create()
+      .fromJson(response, WxMaShopBaseResponse.class);
+    if (baseResponse.getErrCode() != 0) {
+      throw new WxErrorException(
+        new WxError(baseResponse.getErrCode(), baseResponse.getErrMsg()));
+    }
+    return baseResponse;
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaProductServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaProductServiceImpl.java
new file mode 100644
index 0000000000..6e6ee05e38
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaProductServiceImpl.java
@@ -0,0 +1,375 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_BRAND;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_CATEGORY;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_FREIGHT_TEMPLATE;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.IMG_UPLOAD;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_ADD_SKU_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_BATCH_ADD_SKU_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_DEL_SKU_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_SKU_LIST;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_GET_LIST;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_ADD_SKU_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_BATCH_ADD_SKU_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_DEL_SKU_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_UPDATE_SKU_PRICE_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_UPDATE_SKU_STOCK_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_UPDATE_SKU_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_ADD_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_DELISTING_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_DEL_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_GET_LIST_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_GET_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_LISTING_URL;
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_UPDATE_URL;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
+
+import cn.binarywang.wx.miniapp.api.WxMaProductService;
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSkuData;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSpuData;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopResult;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopSku;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetBrandResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetCategoryResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetFrightTemplateResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopResult;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopSku;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopSkuListResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpu;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGetResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuListResponse;
+import cn.binarywang.wx.miniapp.bean.product.WxMinishopUpdateGoodsSkuData;
+import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopSpuPageRequest;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.api.WxConsts;
+import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.http.MinishopUploadRequestExecutor;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonHelper;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+/**
+ * @author boris
+ */
+@RequiredArgsConstructor
+@Slf4j
+public class WxMaProductServiceImpl implements WxMaProductService {
+  private final WxMaService wxMaService;
+
+  @Override
+  public WxMinishopImageUploadResult uploadImg(File file, Integer respType, Integer width,
+    Integer height) throws WxErrorException {
+    String url = IMG_UPLOAD + "?upload_type=0" + "&height=" + height + "&width=" + width + "&resp_type=" + respType;
+    WxMinishopImageUploadResult result = this.wxMaService.execute(
+      MinishopUploadRequestExecutor.create(this.wxMaService.getRequestHttp()), url, file);
+    return result;
+  }
+
+  @Override
+  public WxMinishopImageUploadResult uploadImg(String imgUrl, Integer respType) throws WxErrorException {
+    JsonObject jsonObject = GsonHelper.buildJsonObject("img_url", imgUrl);
+    String url = IMG_UPLOAD + "?upload_type=1" + "&resp_type=" + respType;
+    String response = this.wxMaService.post(url, jsonObject);
+    JsonObject respObj = GsonParser.parse(response);
+
+    if (respObj.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    return WxMinishopImageUploadResult.fromJson(response);
+  }
+
+  @Override
+  public WxMinishopGetCategoryResponse getCategory(Integer fCatId) throws WxErrorException {
+    JsonObject jsonObject = GsonHelper.buildJsonObject("f_cat_id", fCatId);
+    String response = this.wxMaService.post(GET_CATEGORY, jsonObject);
+    JsonObject respObj = GsonParser.parse(response);
+
+    if (respObj.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    return WxMaGsonBuilder.create().fromJson(response, WxMinishopGetCategoryResponse.class);
+  }
+
+  @Override
+  public WxMinishopGetBrandResponse getBrand() throws WxErrorException {
+    String response = this.wxMaService.post(GET_BRAND, new Object());
+    JsonObject respObj = GsonParser.parse(response);
+
+    if (respObj.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    return WxMaGsonBuilder.create().fromJson(response, WxMinishopGetBrandResponse.class);
+  }
+
+  @Override
+  public WxMinishopGetFrightTemplateResponse getFreightTemplate() throws WxErrorException {
+    String response = this.wxMaService.post(GET_FREIGHT_TEMPLATE, new Object());
+    JsonObject respObj = GsonParser.parse(response);
+
+    if (respObj.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    return WxMaGsonBuilder.create().fromJson(response, WxMinishopGetFrightTemplateResponse.class);
+  }
+
+  @Override
+  public WxMinishopResult addSpu(WxMinishopSpu spu) throws WxErrorException {
+
+    String response = this.wxMaService.post(PRODUCT_SPU_ADD_URL, spu);
+
+    JsonObject respObj = GsonParser.parse(response);
+
+    if (respObj.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+    WxMinishopResult result = new WxMinishopResult();
+    result.setErrcode(respObj.get(ERR_CODE).getAsInt());
+    JsonObject dataObj = respObj.get("data").getAsJsonObject();
+    WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
+    resultData.setProductId(dataObj.get("product_id").getAsLong());
+    resultData.setOutProductId(dataObj.get("out_product_id").getAsString());
+    resultData.setCreateTime(dataObj.get("create_time").getAsString());
+    result.setData(resultData);
+    return result;
+  }
+
+  @Override
+  public WxMaShopBaseResponse deleteSpu(Integer productId, String outProductId)
+    throws WxErrorException {
+    String responseContent = this.wxMaService
+      .post(PRODUCT_SPU_DEL_URL, GsonHelper.buildJsonObject("product_id", productId,
+        "out_product_id", outProductId));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMinishopSpuGetResponse getSpu(Integer productId, String outProductId, Integer needEditSpu)
+    throws WxErrorException {
+    String response = this.wxMaService
+      .post(PRODUCT_SPU_GET_URL, GsonHelper.buildJsonObject("product_id", productId,
+        "out_product_id", outProductId, "need_edit_spu", needEditSpu));
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    return WxMaGsonBuilder.create().fromJson(response, WxMinishopSpuGetResponse.class);
+  }
+
+  @Override
+  public WxMinishopSpuListResponse getSpuList(WxMaShopSpuPageRequest request)
+    throws WxErrorException {
+    String responseContent = this.wxMaService.post(PRODUCT_SPU_GET_LIST_URL, request);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMinishopSpuListResponse.class);
+  }
+
+  @Override
+  public WxMinishopResult updateSpu(WxMinishopSpu spu) throws WxErrorException {
+    String response = this.wxMaService.post(PRODUCT_SPU_UPDATE_URL, spu);
+
+    JsonObject respObj = GsonParser.parse(response);
+
+    if (respObj.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+    WxMinishopResult result = new WxMinishopResult();
+    result.setErrcode(respObj.get(ERR_CODE).getAsInt());
+    JsonObject dataObj = respObj.get("data").getAsJsonObject();
+    WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
+    resultData.setProductId(dataObj.get("product_id").getAsLong());
+    resultData.setOutProductId(dataObj.get("out_product_id").getAsString());
+    resultData.setUpdateTime(dataObj.get("update_time").getAsString());
+    result.setData(resultData);
+    return result;
+  }
+
+  @Override
+  public WxMaShopBaseResponse listingSpu(Integer productId, String outProductId)
+    throws WxErrorException {
+    String responseContent = this.wxMaService
+      .post(PRODUCT_SPU_LISTING_URL, GsonHelper.buildJsonObject("product_id", productId,
+        "out_product_id", outProductId));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse delistingSpu(Integer productId, String outProductId)
+    throws WxErrorException {
+    String responseContent = this.wxMaService
+      .post(PRODUCT_SPU_DELISTING_URL, GsonHelper.buildJsonObject("product_id", productId,
+        "out_product_id", outProductId));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMinishopSkuListResponse getSkuList(Long productId, Integer needRealStock, Integer needEditSku)
+    throws WxErrorException {
+    String responseContent = this.wxMaService
+      .post(PRODUCT_SKU_LIST, GsonHelper.buildJsonObject("product_id", productId,
+        "need_edit_sku", needEditSku, "need_real_stock", needRealStock));
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMinishopSkuListResponse.class);
+  }
+
+  @Override
+  public WxMinishopResult minishiopGoodsAddSku(
+    WxMinishopSku sku) throws WxErrorException {
+    String response = this.wxMaService
+      .post(PRODUCT_ADD_SKU_URL, sku);
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+    WxMinishopResult result = new WxMinishopResult();
+    result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
+    JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
+    WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
+    resultData.setSkuId(dataObj.get("sku_id").getAsLong());
+    resultData.setCreateTime(dataObj.get("create_time").getAsString());
+    result.setData(resultData);
+    return result;
+  }
+
+  @Override
+  public WxMinishopResult> minishopGoodsBatchAddSku(
+    List skuList) throws WxErrorException {
+    String response = this.wxMaService
+      .post(PRODUCT_BATCH_ADD_SKU_URL, GsonHelper.buildJsonObject("skus", skuList));
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    WxMinishopResult result = new WxMinishopResult();
+    result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
+    JsonArray jsonArray = jsonObject.get("data").getAsJsonArray();
+    List skuData = new ArrayList<>();
+    for (JsonElement jsonElement : jsonArray) {
+      JsonObject element = jsonElement.getAsJsonObject();
+      WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
+      resultData.setSkuId(element.get("sku_id").getAsLong());
+      resultData.setOutSkuId(element.get("out_sku_id").getAsString());
+      resultData.setCreateTime(element.get("create_time").getAsString());
+      skuData.add(resultData);
+    }
+    result.setData(skuData);
+    return result;
+  }
+
+  @Override
+  public WxMaShopBaseResponse minishopGoodsDelSku(Long productId, Long outProductId,
+    String outSkuId, Long skuId) throws WxErrorException {
+    String response = this.wxMaService
+      .post(PRODUCT_DEL_SKU_URL, GsonHelper.buildJsonObject("product_id", productId,
+        "out_product_id", outProductId, "out_sku_id", outSkuId, "sku_id", skuId));
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(response, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMinishopResult minishopGoodsUpdateSku(
+    WxMinishopSku sku) throws WxErrorException {
+    String response = this.wxMaService
+      .post(PRODUCT_UPDATE_SKU_URL, sku);
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+    WxMinishopResult result = new WxMinishopResult();
+    result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
+    JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
+    WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
+    resultData.setUpdateTime(dataObj.get("update_time").getAsString());
+    result.setData(resultData);
+    return result;
+  }
+
+  @Override
+  public WxMinishopResult minishopGoodsUpdateSkuPrice(
+    Long productId, String outProductId, String outSkuId, Long skuId, Long salePrice,
+    Long marketPrice) throws WxErrorException {
+    String response = this.wxMaService
+      .post(PRODUCT_UPDATE_SKU_PRICE_URL, GsonHelper.buildJsonObject(
+        "product_id", productId, "out_product_id", outProductId,
+        "sku_id", skuId, "out_sku_id", outSkuId, "sale_price", salePrice, "market_price", marketPrice));
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    WxMinishopResult result = new WxMinishopResult();
+    result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
+    JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
+    WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
+    resultData.setUpdateTime(dataObj.get("update_time").getAsString());
+    result.setData(resultData);
+    return result;
+  }
+
+  @Override
+  public WxMinishopResult minishopGoodsUpdateSkuStock(
+    Long productId, String outProductId, String outSkuId, Long skuId, Integer type,
+    Integer stockNum) throws WxErrorException {
+    String response = this.wxMaService
+      .post(PRODUCT_UPDATE_SKU_STOCK_URL, GsonHelper.buildJsonObject(
+        "product_id", productId, "out_product_id", outProductId,
+        "sku_id", skuId, "out_sku_id", outSkuId, "type", type, "stock_num", stockNum));
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+
+    WxMinishopResult result = new WxMinishopResult();
+    result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
+    JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
+    WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
+    resultData.setUpdateTime(dataObj.get("update_time").getAsString());
+    result.setData(resultData);
+    return result;
+  }
+
+
+
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java
index 31bba36a3a..cc7fc51feb 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java
@@ -10,10 +10,12 @@
 import cn.binarywang.wx.miniapp.executor.QrcodeRequestExecutor;
 import lombok.RequiredArgsConstructor;
 import me.chanjar.weixin.common.error.WxErrorException;
+import org.apache.commons.lang3.StringUtils;
 
 import java.io.File;
 
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Qrcode.*;
+import static cn.binarywang.wx.miniapp.constant.WxMaConstants.DEFAULT_ENV_VERSION;
 
 /**
  * @author Binary Wang
@@ -40,11 +42,12 @@ public File createQrcode(String path) throws WxErrorException {
   }
 
   @Override
-  public byte[] createWxaCodeBytes(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
-    throws WxErrorException {
+  public byte[] createWxaCodeBytes(String path, String envVersion, int width, boolean autoColor,
+                                   WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
     return this.service.execute(QrcodeBytesRequestExecutor.create(this.service.getRequestHttp()), GET_WXACODE_URL,
       WxaCode.builder()
         .path(path)
+        .envVersion(StringUtils.defaultIfEmpty(envVersion, DEFAULT_ENV_VERSION))
         .width(width)
         .autoColor(autoColor)
         .lineColor(lineColor)
@@ -53,11 +56,12 @@ public byte[] createWxaCodeBytes(String path, int width, boolean autoColor, WxMa
   }
 
   @Override
-  public File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
-    throws WxErrorException {
+  public File createWxaCode(String path, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor,
+                            boolean isHyaline) throws WxErrorException {
     return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp()), GET_WXACODE_URL,
       WxaCode.builder()
         .path(path)
+        .envVersion(StringUtils.defaultIfEmpty(envVersion, DEFAULT_ENV_VERSION))
         .width(width)
         .autoColor(autoColor)
         .lineColor(lineColor)
@@ -67,7 +71,7 @@ public File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLin
 
   @Override
   public File createWxaCode(String path, int width) throws WxErrorException {
-    return this.createWxaCode(path, width, true, null, false);
+    return this.createWxaCode(path, null, width, true, null, false);
   }
 
   @Override
@@ -76,24 +80,27 @@ public File createWxaCode(String path) throws WxErrorException {
   }
 
   @Override
-  public byte[] createWxaCodeUnlimitBytes(String scene, String page, int width, boolean autoColor,
-                                          WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
+  public byte[] createWxaCodeUnlimitBytes(String scene, String page, boolean checkPath, String envVersion, int width,
+                                          boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
+    throws WxErrorException {
     return this.service.execute(QrcodeBytesRequestExecutor.create(this.service.getRequestHttp()),
-      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, width, autoColor, lineColor, isHyaline));
+      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
   }
 
   @Override
-  public File createWxaCodeUnlimit(String scene, String page, int width, boolean autoColor,
-                                   WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
+  public File createWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width,
+                                   boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
     return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp()),
-      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, width, autoColor, lineColor, isHyaline));
+      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
   }
 
-  private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, int width, boolean autoColor,
-                                             WxMaCodeLineColor lineColor, boolean isHyaline) {
+  private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width,
+                                             boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) {
     WxaCodeUnlimit wxaCodeUnlimit = new WxaCodeUnlimit();
     wxaCodeUnlimit.setScene(scene);
     wxaCodeUnlimit.setPage(page);
+    wxaCodeUnlimit.setCheckPath(checkPath);
+    wxaCodeUnlimit.setEnvVersion(envVersion);
     wxaCodeUnlimit.setWidth(width);
     wxaCodeUnlimit.setAutoColor(autoColor);
     wxaCodeUnlimit.setLineColor(lineColor);
@@ -104,7 +111,7 @@ private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, int width,
 
   @Override
   public File createWxaCodeUnlimit(String scene, String page) throws WxErrorException {
-    return this.createWxaCodeUnlimit(scene, page, 430, true, null, false);
+    return this.createWxaCodeUnlimit(scene, page, true, DEFAULT_ENV_VERSION, 430, true, null, false);
   }
 
   @Override
@@ -119,12 +126,12 @@ public File createQrcode(String path, String filePath) throws WxErrorException {
   }
 
   @Override
-  public File createWxaCode(String path, int width, String filePath, boolean autoColor, WxMaCodeLineColor lineColor,
-                            boolean isHyaline)
-    throws WxErrorException {
+  public File createWxaCode(String path, String envVersion, int width, String filePath, boolean autoColor,
+                            WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
     return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp(), filePath), GET_WXACODE_URL,
       WxaCode.builder()
         .path(path)
+        .envVersion(StringUtils.defaultIfEmpty(envVersion, DEFAULT_ENV_VERSION))
         .width(width)
         .autoColor(autoColor)
         .lineColor(lineColor)
@@ -134,7 +141,7 @@ public File createWxaCode(String path, int width, String filePath, boolean autoC
 
   @Override
   public File createWxaCode(String path, int width, String filePath) throws WxErrorException {
-    return this.createWxaCode(path, width, filePath, true, null, false);
+    return this.createWxaCode(path, null, width, filePath, true, null, false);
   }
 
   @Override
@@ -143,15 +150,16 @@ public File createWxaCode(String path, String filePath) throws WxErrorException
   }
 
   @Override
-  public File createWxaCodeUnlimit(String scene, String page, String filePath, int width, boolean autoColor,
-                                   WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
+  public File createWxaCodeUnlimit(String scene, String page, String filePath, boolean checkPath, String envVersion,
+                                   int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
+    throws WxErrorException {
     return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp(), filePath),
-      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, width, autoColor, lineColor, isHyaline));
+      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
   }
 
   @Override
   public File createWxaCodeUnlimit(String scene, String page, String filePath) throws WxErrorException {
-    return this.createWxaCodeUnlimit(scene, page, filePath, 430, true, null, false);
+    return this.createWxaCodeUnlimit(scene, page, filePath, true, DEFAULT_ENV_VERSION, 430, true, null, false);
   }
 
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSafetyRiskControlServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSafetyRiskControlServiceImpl.java
new file mode 100644
index 0000000000..f9f2bbd6d7
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSafetyRiskControlServiceImpl.java
@@ -0,0 +1,36 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaSafetyRiskControlService;
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest;
+import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse;
+import cn.binarywang.wx.miniapp.constant.WxMaConstants;
+import com.google.gson.JsonObject;
+import lombok.RequiredArgsConstructor;
+import me.chanjar.weixin.common.api.WxConsts;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.InstantDelivery.SafetyRiskControl.GET_USER_RISK_RANK;
+
+/**
+ * @author azouever
+ */
+
+@RequiredArgsConstructor
+public class WxMaSafetyRiskControlServiceImpl implements WxMaSafetyRiskControlService {
+
+  private final WxMaService service;
+
+  @Override
+  public WxMaUserSafetyRiskRankResponse getUserRiskRank(WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest) throws WxErrorException {
+    String responseContent = this.service.post(GET_USER_RISK_RANK, wxMaUserSafetyRiskRankRequest.toJson());
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaUserSafetyRiskRankResponse.fromJson(responseContent);
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImpl.java
index 149552dde0..bf0976f0a4 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImpl.java
@@ -2,30 +2,56 @@
 
 import cn.binarywang.wx.miniapp.api.WxMaSchemeService;
 import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateNfcSchemeRequest;
 import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest;
 import com.google.gson.JsonObject;
 import lombok.AllArgsConstructor;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.enums.WxType;
 import me.chanjar.weixin.common.error.WxError;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.util.json.GsonParser;
 
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Scheme.GENERATE_NFC_SCHEME_URL;
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Scheme.GENERATE_SCHEME_URL;
 
 /**
  * @author : cofedream
- * @date : 2021-01-28
+ * created on  : 2021-01-28
  */
 @AllArgsConstructor
 public class WxMaSchemeServiceImpl implements WxMaSchemeService {
-  private static final String ERR_CODE = "errcode";
   private final WxMaService wxMaService;
 
+  /**
+   * 获取小程序scheme码
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html
+   *
+   * @param request 请求参数
+   * @throws WxErrorException 生成失败时抛出,具体错误码请看文档
+   */
   @Override
   public String generate(WxMaGenerateSchemeRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(GENERATE_SCHEME_URL, request.toJson());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return jsonObject.get("openlink").getAsString();
+  }
+
+  /**
+   * 获取NFC 的小程序 scheme
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-scheme/generateNFCScheme.html
+   *
+   * @param request 请求参数
+   * @throws WxErrorException 生成失败时抛出,具体错误码请看文档
+   */
+  @Override
+  public String generateNFC(WxMaGenerateNfcSchemeRequest request) throws WxErrorException {
+    String responseContent = this.wxMaService.post(GENERATE_NFC_SCHEME_URL, request.toJson());
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return jsonObject.get("openlink").getAsString();
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSecCheckServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSecCheckServiceImpl.java
index 332a47ad7a..09046524be 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSecCheckServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSecCheckServiceImpl.java
@@ -3,6 +3,7 @@
 import cn.binarywang.wx.miniapp.api.WxMaSecCheckService;
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.bean.WxMaMediaAsyncCheckResult;
+import cn.binarywang.wx.miniapp.bean.security.WxMaMediaSecCheckCheckRequest;
 import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest;
 import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse;
 import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
@@ -21,7 +22,7 @@
 import java.net.URL;
 
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.SecCheck.*;
-import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * 
@@ -68,10 +69,7 @@ public boolean checkMessage(String msgString) throws WxErrorException {
   @Override
   public WxMaMsgSecCheckCheckResponse checkMessage(WxMaMsgSecCheckCheckRequest msgRequest) throws WxErrorException {
     String response = this.service.post(MSG_SEC_CHECK_URL, msgRequest);
-    JsonObject jsonObject = GsonParser.parse(response);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
-      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
-    }
+    parseErrorResponse(response);
     return WxMaGsonBuilder.create().fromJson(response, WxMaMsgSecCheckCheckResponse.class);
   }
 
@@ -86,4 +84,17 @@ public WxMaMediaAsyncCheckResult mediaCheckAsync(String mediaUrl, int mediaType)
       .fromJson(this.service.post(MEDIA_CHECK_ASYNC_URL, jsonObject.toString()));
   }
 
+  @Override
+  public WxMaMediaAsyncCheckResult mediaCheckAsync(WxMaMediaSecCheckCheckRequest request) throws WxErrorException {
+    String response = this.service.post(MEDIA_CHECK_ASYNC_URL, request);
+    parseErrorResponse(response);
+    return WxMaGsonBuilder.create().fromJson(response,WxMaMediaAsyncCheckResult.class);
+  }
+
+  private void parseErrorResponse(String response) throws WxErrorException {
+    JsonObject jsonObject = GsonParser.parse(response);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
+    }
+  }
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceHttpClientImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceHttpClientImpl.java
index 6914977861..7b1ea3e96b 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceHttpClientImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceHttpClientImpl.java
@@ -1,6 +1,7 @@
 package cn.binarywang.wx.miniapp.api.impl;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaStableAccessTokenRequest;
 import cn.binarywang.wx.miniapp.config.WxMaConfig;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.util.http.HttpType;
@@ -11,6 +12,9 @@
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.BasicResponseHandler;
 import org.apache.http.impl.client.CloseableHttpClient;
 
@@ -62,10 +66,12 @@ public HttpType getRequestType() {
   @Override
   protected String doGetAccessTokenRequest() throws IOException {
 
-    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
+    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
+      this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
       WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
       WxMaService.GET_ACCESS_TOKEN_URL;
-    
+
+
     url = String.format(url, this.getWxMaConfig().getAppid(), this.getWxMaConfig().getSecret());
 
     HttpGet httpGet = null;
@@ -91,4 +97,40 @@ protected String doGetAccessTokenRequest() throws IOException {
     }
   }
 
+  @Override
+  protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException {
+    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
+      this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
+      GET_STABLE_ACCESS_TOKEN.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
+      GET_STABLE_ACCESS_TOKEN;
+
+    HttpPost httpPost = null;
+    CloseableHttpResponse response = null;
+    try {
+      httpPost = new HttpPost(url);
+      if (this.getRequestHttpProxy() != null) {
+        RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();
+        httpPost.setConfig(config);
+      }
+      WxMaStableAccessTokenRequest wxMaAccessTokenRequest = new WxMaStableAccessTokenRequest();
+      wxMaAccessTokenRequest.setAppid(this.getWxMaConfig().getAppid());
+      wxMaAccessTokenRequest.setSecret(this.getWxMaConfig().getSecret());
+      wxMaAccessTokenRequest.setGrantType("client_credential");
+      wxMaAccessTokenRequest.setForceRefresh(forceRefresh);
+      httpPost.setEntity(new StringEntity(wxMaAccessTokenRequest.toJson(), ContentType.APPLICATION_JSON));
+      response = getRequestHttpClient().execute(httpPost);
+      return new BasicResponseHandler().handleResponse(response);
+    } finally {
+      if (httpPost != null) {
+        httpPost.releaseConnection();
+      }
+      if (response != null) {
+        try {
+          response.close();
+        } catch (IOException e) {
+        }
+      }
+    }
+  }
+
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceJoddHttpImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceJoddHttpImpl.java
index 90ee6516ae..d2037a0732 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceJoddHttpImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceJoddHttpImpl.java
@@ -1,15 +1,18 @@
 package cn.binarywang.wx.miniapp.api.impl;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaStableAccessTokenRequest;
 import cn.binarywang.wx.miniapp.config.WxMaConfig;
 import jodd.http.HttpConnectionProvider;
 import jodd.http.HttpRequest;
 import jodd.http.ProxyInfo;
 import jodd.http.net.SocketHttpConnectionProvider;
+import jodd.net.MimeTypes;
 import me.chanjar.weixin.common.util.http.HttpType;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 
 /**
  * jodd-http方式实现.
@@ -46,7 +49,8 @@ public HttpType getRequestType() {
 
   @Override
   protected String doGetAccessTokenRequest() throws IOException {
-    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
+    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
+      this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
       WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
       WxMaService.GET_ACCESS_TOKEN_URL;
 
@@ -61,4 +65,30 @@ protected String doGetAccessTokenRequest() throws IOException {
     return request.send().bodyText();
   }
 
+  @Override
+  protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException {
+
+    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
+      this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
+      GET_STABLE_ACCESS_TOKEN.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
+      GET_STABLE_ACCESS_TOKEN;
+
+    WxMaStableAccessTokenRequest wxMaAccessTokenRequest = new WxMaStableAccessTokenRequest();
+    wxMaAccessTokenRequest.setAppid(this.getWxMaConfig().getAppid());
+    wxMaAccessTokenRequest.setSecret(this.getWxMaConfig().getSecret());
+    wxMaAccessTokenRequest.setGrantType("client_credential");
+    wxMaAccessTokenRequest.setForceRefresh(forceRefresh);
+
+    HttpRequest request = HttpRequest.post(url)
+      .contentType(MimeTypes.MIME_APPLICATION_JSON, StandardCharsets.UTF_8.name())
+      .body(wxMaAccessTokenRequest.toJson());
+    if (this.getRequestHttpProxy() != null) {
+      SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider();
+      provider.useProxy(getRequestHttpProxy());
+
+      request.withConnectionProvider(provider);
+    }
+    return request.send().bodyText();
+  }
+
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceOkHttpImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceOkHttpImpl.java
index 0fa49d9d07..ff78a6984a 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceOkHttpImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceOkHttpImpl.java
@@ -1,8 +1,10 @@
 package cn.binarywang.wx.miniapp.api.impl;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaStableAccessTokenRequest;
 import cn.binarywang.wx.miniapp.config.WxMaConfig;
 import me.chanjar.weixin.common.util.http.HttpType;
+import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder;
 import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
 import okhttp3.*;
 import org.apache.commons.lang3.StringUtils;
@@ -27,12 +29,8 @@ public void initHttp() {
         wxMpConfigStorage.getHttpProxyPort(),
         wxMpConfigStorage.getHttpProxyUsername(),
         wxMpConfigStorage.getHttpProxyPassword());
-    }
-
-    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
-    if (httpProxy != null) {
+      OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
       clientBuilder.proxy(getRequestHttpProxy().getProxy());
-
       //设置授权
       clientBuilder.authenticator(new Authenticator() {
         @Override
@@ -43,8 +41,10 @@ public Request authenticate(Route route, Response response) throws IOException {
             .build();
         }
       });
+      httpClient = clientBuilder.build();
+    } else {
+      httpClient = DefaultOkHttpClientBuilder.get().build();
     }
-    httpClient = clientBuilder.build();
   }
 
   @Override
@@ -64,7 +64,8 @@ public HttpType getRequestType() {
 
   @Override
   protected String doGetAccessTokenRequest() throws IOException {
-    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
+    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
+      this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
       WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
       WxMaService.GET_ACCESS_TOKEN_URL;
 
@@ -74,4 +75,22 @@ protected String doGetAccessTokenRequest() throws IOException {
       return Objects.requireNonNull(response.body()).string();
     }
   }
+
+  @Override
+  protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException {
+    String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
+      this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
+      GET_STABLE_ACCESS_TOKEN.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
+      GET_STABLE_ACCESS_TOKEN;
+    WxMaStableAccessTokenRequest wxMaAccessTokenRequest = new WxMaStableAccessTokenRequest();
+    wxMaAccessTokenRequest.setAppid(this.getWxMaConfig().getAppid());
+    wxMaAccessTokenRequest.setSecret(this.getWxMaConfig().getSecret());
+    wxMaAccessTokenRequest.setGrantType("client_credential");
+    wxMaAccessTokenRequest.setForceRefresh(forceRefresh);
+    RequestBody body = RequestBody.Companion.create(wxMaAccessTokenRequest.toJson(), MediaType.parse("application/json; charset=utf-8"));
+    Request request = new Request.Builder().url(url).post(body).build();
+    try (Response response = getRequestHttpClient().newCall(request).execute()) {
+      return Objects.requireNonNull(response.body()).string();
+    }
+  }
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAccountServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAccountServiceImpl.java
index 00ea99850c..2ff9ef8da4 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAccountServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAccountServiceImpl.java
@@ -11,6 +11,7 @@
 import com.google.gson.JsonObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.enums.WxType;
 import me.chanjar.weixin.common.error.WxError;
 import me.chanjar.weixin.common.error.WxErrorException;
@@ -24,14 +25,13 @@
 @RequiredArgsConstructor
 @Slf4j
 public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
-  private static final String ERR_CODE = "errcode";
   private final WxMaService wxMaService;
 
   @Override
   public WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException {
     String responseContent = this.wxMaService.post(GET_CATEGORY_LIST, new JsonObject());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetCategoryListResponse.class);
@@ -41,7 +41,7 @@ public WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorEx
   public WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException {
     String responseContent = this.wxMaService.post(GET_BRAND_LIST, new JsonObject());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetBrandListResponse.class);
@@ -51,7 +51,7 @@ public WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorExceptio
   public WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(UPDATE_INFO, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
@@ -61,7 +61,7 @@ public WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request)
   public WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException {
     String responseContent = this.wxMaService.post(GET_INFO, new JsonObject());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetInfoResponse.class);
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java
index 9fd24350a5..b2898ab256 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java
@@ -2,11 +2,8 @@
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.api.WxMaShopAfterSaleService;
-import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest;
-import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest;
-import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest;
-import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse;
-import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
+import cn.binarywang.wx.miniapp.bean.shop.request.*;
+import cn.binarywang.wx.miniapp.bean.shop.response.*;
 import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
 import com.google.gson.JsonObject;
 import lombok.RequiredArgsConstructor;
@@ -14,10 +11,11 @@
 import me.chanjar.weixin.common.enums.WxType;
 import me.chanjar.weixin.common.error.WxError;
 import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonHelper;
 import me.chanjar.weixin.common.util.json.GsonParser;
 
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Aftersale.*;
-import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * @author boris
@@ -37,13 +35,13 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
    * @throws WxErrorException
    */
   @Override
-  public WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException {
+  public WxMaShopAfterSaleAddResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(AFTERSALE_ADD, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
-    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleAddResponse.class);
   }
 
   /**
@@ -57,12 +55,29 @@ public WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxEr
   public WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(AFTERSALE_GET, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleGetResponse.class);
   }
 
+  /**
+   * 获取售后单详情(EC版)
+   *
+   * @param request
+   * @return WxMaShopEcAfterSaleGetResponse
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopEcAfterSaleGetResponse get(WxMaShopEcAfterSaleGetRequest request) throws WxErrorException {
+    String responseContent = this.wxMaService.post(ECAFTERSALE_GET, request);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopEcAfterSaleGetResponse.class);
+  }
+
   /**
    * 更新售后
    *
@@ -74,9 +89,169 @@ public WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) thr
   public WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(AFTERSALE_UPDATE, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
   }
+
+  @Override
+  public WxMaShopBaseResponse update(WxMaShopEcAfterSaleUpdateRequest request) throws WxErrorException {
+    String responseContent = this.wxMaService.post(EC_AFTERSALE_UPDATE, request);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 用户取消售后申请
+   * @param outAfterSaleId 商家自定义订单ID
+   * @param afterSaleId 与out_aftersale_id二选一
+   * @param openId 用户openid
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopBaseResponse cancel(String outAfterSaleId, Long afterSaleId, String openId)
+    throws WxErrorException {
+    JsonObject request = GsonHelper.buildJsonObject("out_aftersale_id", outAfterSaleId,
+      "aftersale_id", afterSaleId, "openid", openId);
+    String resp = this.wxMaService.post(AFTERSALE_CANCEL, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 用户上传退货物流
+   * @param request
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopBaseResponse uploadReturnInfo(WxMaShopAfterSaleUploadReturnInfoRequest request)
+    throws WxErrorException {
+    String resp = this.wxMaService.post(AFTERSALE_UPLOAD_RETURN_INFO, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 商家同意退款
+   * @param outAfterSaleId
+   * @param afterSaleId
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopBaseResponse acceptRefund(String outAfterSaleId, Long afterSaleId)
+    throws WxErrorException {
+    JsonObject request = GsonHelper.buildJsonObject("out_aftersale_id", outAfterSaleId,
+      "aftersale_id", afterSaleId);
+    String resp = this.wxMaService.post(AFTERSALE_ACCEPT_REFUND, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 商家同意退货
+   * @param request
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopBaseResponse acceptReturn(WxMaShopAcceptReturnRequest request)
+    throws WxErrorException {
+    String resp = this.wxMaService.post(AFTERSALE_ACCEPT_RETURN, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 商家拒绝售后
+   * @param outAfterSaleId
+   * @param afterSaleId
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopBaseResponse reject(String outAfterSaleId, Long afterSaleId)
+    throws WxErrorException {
+    JsonObject request = GsonHelper.buildJsonObject("out_aftersale_id", outAfterSaleId,
+      "aftersale_id", afterSaleId);
+    String resp = this.wxMaService.post(AFTERSALE_REJECT, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 商家上传退款凭证
+   * @param request
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopBaseResponse uploadCertificates(WxMaShopUploadCerficatesRequest request)
+    throws WxErrorException {
+    String resp = this.wxMaService.post(AFTERSALE_UPLOAD_CERTIFICATES, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 商家更新订单售后期
+   * @param outOrderId
+   * @param orderId
+   * @param openid
+   * @param afterSaleDeadline
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopBaseResponse updateDeadline(String outOrderId, Long orderId, String openid,
+    Long afterSaleDeadline) throws WxErrorException {
+    JsonObject request = GsonHelper.buildJsonObject("out_order_id", outOrderId,
+      "order_id", orderId, "openid", openid, "after_sale_deadline", afterSaleDeadline);
+    String resp = this.wxMaService.post(AFTERSALE_UPLOAD_DEADLINE, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
+  }
+
+  /**
+   * 获取售后单详情
+   * @param request
+   * @return
+   * @throws WxErrorException
+   */
+  @Override
+  public WxMaShopAfterSaleListResponse list(WxMaShopAfterSaleListRequest request) throws WxErrorException {
+    String resp = this.wxMaService.post(AFTERSALE_GET_LIST, request);
+    JsonObject jsonObject = GsonParser.parse(resp);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(resp, WxMaShopAfterSaleListResponse.class);
+  }
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImpl.java
index b456410124..30fadd6922 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImpl.java
@@ -18,13 +18,13 @@
 import me.chanjar.weixin.common.util.json.GsonParser;
 
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Audit.*;
-import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * 小程序交易组件-接入商品前必需接口(审核相关接口)
  *
  * @author liming1019
- * @date 2021/8/12
+ * created on  2021/8/12
  */
 @RequiredArgsConstructor
 @Slf4j
@@ -42,7 +42,7 @@ public class WxMaShopAuditServiceImpl implements WxMaShopAuditService {
   public WxMaShopAuditBrandResponse auditBrand(WxMaShopAuditBrandRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(AUDIT_BRAND, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditBrandResponse.class);
@@ -59,7 +59,7 @@ public WxMaShopAuditBrandResponse auditBrand(WxMaShopAuditBrandRequest request)
   public WxMaShopAuditCategoryResponse auditCategory(WxMaShopAuditCategoryRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(AUDIT_CATEGORY, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditCategoryResponse.class);
@@ -76,7 +76,7 @@ public WxMaShopAuditCategoryResponse auditCategory(WxMaShopAuditCategoryRequest
   public WxMaShopAuditResultResponse getAuditResult(String auditId) throws WxErrorException {
     String responseContent = this.wxMaService.post(AUDIT_RESULT, GsonHelper.buildJsonObject("audit_id", auditId));
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditResultResponse.class);
@@ -93,7 +93,7 @@ public WxMaShopAuditResultResponse getAuditResult(String auditId) throws WxError
   public JsonObject getMiniappCertificate(int reqType) throws WxErrorException {
     String responseContent = this.wxMaService.post(GET_MINIAPP_CERTIFICATE, GsonHelper.buildJsonObject("req_type", reqType));
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, JsonObject.class);
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCatServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCatServiceImpl.java
index 8bf9411f4a..0a5298476e 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCatServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCatServiceImpl.java
@@ -13,7 +13,7 @@
 import me.chanjar.weixin.common.util.json.GsonParser;
 
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Cat.GET_CAT;
-import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * @author liming1019
@@ -27,7 +27,7 @@ public class WxMaShopCatServiceImpl implements WxMaShopCatService {
   public WxMaShopCatGetResponse getCat() throws WxErrorException {
     String responseContent = this.wxMaService.post(GET_CAT, new JsonObject());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCatGetResponse.class);
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCouponServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCouponServiceImpl.java
new file mode 100644
index 0000000000..83398d6a7d
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCouponServiceImpl.java
@@ -0,0 +1,166 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.api.WxMaShopCouponService;
+import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponListResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopUserCouponListResponse;
+import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Coupon;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.JsonObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonHelper;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
+
+/**
+ * @author leiin
+ * created on  2022/7/1 2:49 下午
+ */
+@RequiredArgsConstructor
+@Slf4j
+public class WxMaShopCouponServiceImpl implements WxMaShopCouponService {
+  private final WxMaService wxMaService;
+
+  @Override
+  public WxMaShopBaseResponse addCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("coupon", couponInfo);
+    String responseContent = this.wxMaService.post(Coupon.ADD_COUPON, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopCouponResponse getCoupon(String outCouponId) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("out_coupon_id", outCouponId);
+    String responseContent = this.wxMaService.post(Coupon.GET_COUPON, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCouponResponse.class);
+  }
+
+  @Override
+  public WxMaShopCouponListResponse getCouponList(Integer pageSize, Integer offset) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("page_size", pageSize, "offset", offset);
+    String responseContent = this.wxMaService.post(Coupon.GET_COUPON_LIST, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCouponListResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse updateCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("coupon", couponInfo);
+    String responseContent = this.wxMaService.post(Coupon.UPDATE_COUPON, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse updateCouponStatus(String outCouponId, Integer status) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("out_coupon_id", outCouponId, "status", status);
+    String responseContent = this.wxMaService.post(Coupon.UPDATE_COUPON_STATUS, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse updateCouponStock(String outCouponId, Integer isUsedNum, Integer receiveNum) throws WxErrorException {
+    JsonObject stockInfo = GsonHelper.buildJsonObject("issued_num", isUsedNum, "receive_num", receiveNum);
+    JsonObject stock = GsonHelper.buildJsonObject("out_coupon_id", outCouponId, "stock_info", stockInfo);
+    JsonObject json = GsonHelper.buildJsonObject("coupon_stock", stock);
+
+    String responseContent = this.wxMaService.post(Coupon.UPDATE_COUPON_STOCK, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse addUserCoupon(String openid, String outUserCouponId,
+                                            String outCouponId, Integer status, Long recvTime) throws WxErrorException {
+    JsonObject userCoupon = GsonHelper.buildJsonObject("out_user_coupon_id", outUserCouponId,
+      "out_coupon_id", outCouponId,
+      "status", status);
+    JsonObject json = GsonHelper.buildJsonObject("openid", openid, "user_coupon", userCoupon,
+      "recv_time", recvTime);
+
+    String responseContent = this.wxMaService.post(Coupon.ADD_USER_COUPON, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopUserCouponListResponse getUserCouponList(Integer pageSize, Integer offset, String openid) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("page_size", pageSize, "offset", offset,
+      "openid", openid);
+    String responseContent = this.wxMaService.post(Coupon.GET_USER_COUPON_LIST, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopUserCouponListResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse updateUserCoupon(String openid, String outUserCouponId,
+                                               String outCouponId, Long useTime, Long recvTime) throws WxErrorException {
+    JsonObject extInfo = GsonHelper.buildJsonObject("use_time", useTime);
+
+    JsonObject userCoupon = GsonHelper.buildJsonObject("out_user_coupon_id", outUserCouponId,
+      "out_coupon_id", outCouponId, "ext_info", extInfo);
+
+    JsonObject json = GsonHelper.buildJsonObject("openid", openid, "user_coupon", userCoupon,
+      "recv_time", recvTime);
+
+    String responseContent = this.wxMaService.post(Coupon.UPDATE_USER_COUPON, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse updateUserCouponStatus(String openid, String outUserCouponId,
+                                                     String outCouponId, Integer status) throws WxErrorException {
+
+    JsonObject json = GsonHelper.buildJsonObject("openid", openid,
+      "out_user_coupon_id", outUserCouponId,
+      "out_coupon_id", outCouponId,
+      "status", status);
+
+    String responseContent = this.wxMaService.post(Coupon.UPDATE_USER_COUPON_STATUS, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java
index 8fd9d63f95..bc7d509c4c 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java
@@ -16,7 +16,7 @@
 import me.chanjar.weixin.common.util.json.GsonParser;
 
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Delivery.*;
-import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * @author boris
@@ -37,7 +37,7 @@ public class WxMaShopDeliveryServiceImpl implements WxMaShopDeliveryService {
   public WxMaShopDeliveryGetCompanyListResponse getCompanyList() throws WxErrorException {
     String responseContent = this.wxMaService.post(GET_COMPANY_LIST, new JsonObject());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopDeliveryGetCompanyListResponse.class);
@@ -54,7 +54,7 @@ public WxMaShopDeliveryGetCompanyListResponse getCompanyList() throws WxErrorExc
   public WxMaShopBaseResponse send(WxMaShopDeliverySendRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(DELIVERY_SEND, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
@@ -71,7 +71,7 @@ public WxMaShopBaseResponse send(WxMaShopDeliverySendRequest request) throws WxE
   public WxMaShopBaseResponse receive(WxMaShopDeliveryRecieveRequest request) throws WxErrorException {
     String responseContent = this.wxMaService.post(DELIVERY_RECEIVE, request);
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
     return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImpl.java
index 1c69f8dc80..33e2a5de57 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImpl.java
@@ -23,14 +23,21 @@ public class WxMaShopImgServiceImpl implements WxMaShopImgService {
   @Override
   public WxMinishopImageUploadCustomizeResult uploadImg(File file) throws WxErrorException {
     WxMinishopImageUploadCustomizeResult result = this.service.execute(
-      MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), "0"), IMG_UPLOAD, file);
+      MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), "0", null), IMG_UPLOAD, file);
     return result;
   }
 
   @Override
   public WxMinishopImageUploadCustomizeResult uploadImg(File file, String respType) throws WxErrorException {
     WxMinishopImageUploadCustomizeResult result = this.service.execute(
-      MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), respType), IMG_UPLOAD, file);
+      MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), respType, null), IMG_UPLOAD, file);
+    return result;
+  }
+
+  @Override
+  public WxMinishopImageUploadCustomizeResult uploadImg(String imgUrl, String respType) throws WxErrorException {
+    WxMinishopImageUploadCustomizeResult result = this.service.execute(
+            MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), respType, imgUrl), IMG_UPLOAD, null);
     return result;
   }
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopOrderServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopOrderServiceImpl.java
index ff466ded63..2d65793444 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopOrderServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopOrderServiceImpl.java
@@ -1,17 +1,10 @@
 package cn.binarywang.wx.miniapp.api.impl;
 
-import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Order.ORDER_ADD;
-import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Order.ORDER_CHECK_SCENE;
-import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Order.ORDER_GET;
-import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Order.ORDER_PAY;
-
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.api.WxMaShopOrderService;
 import cn.binarywang.wx.miniapp.bean.shop.WxMaShopOrderInfo;
 import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopOrderPayRequest;
-import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAddOrderResponse;
-import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
-import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetOrderResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.*;
 import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
 import com.google.gson.JsonObject;
 import lombok.RequiredArgsConstructor;
@@ -21,6 +14,13 @@
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.util.json.GsonHelper;
 import me.chanjar.weixin.common.util.json.GsonParser;
+import org.apache.commons.lang3.time.FastDateFormat;
+
+import java.text.Format;
+import java.util.Date;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Order.*;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * @author boris
@@ -28,7 +28,9 @@
 @RequiredArgsConstructor
 @Slf4j
 public class WxMaShopOrderServiceImpl implements WxMaShopOrderService {
-  private static final String ERR_CODE = "errcode";
+
+  private final Format dateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
+
   private static final String MATCH_KEY = "is_matched";
   private final WxMaService wxMaService;
 
@@ -45,34 +47,49 @@ public Boolean checkScene(Integer scene) throws WxErrorException {
 
   @Override
   public WxMaShopAddOrderResponse addOrder(WxMaShopOrderInfo orderInfo) throws WxErrorException {
-    String responseContent = this.wxMaService.post(ORDER_ADD, orderInfo);
-    JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
-      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
-    }
-    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAddOrderResponse.class);
+    return this.post(ORDER_ADD,orderInfo, WxMaShopAddOrderResponse.class);
   }
 
   @Override
   public WxMaShopBaseResponse orderPay(WxMaShopOrderPayRequest request) throws WxErrorException {
-    String responseContent = this.wxMaService.post(ORDER_PAY, request);
-    JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
-      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    return this.post(ORDER_PAY,request, WxMaShopBaseResponse.class);
+  }
+
+  @Override
+  public WxMaShopGetOrderResponse getOrder(Long orderId, String outOrderId, String openid) throws WxErrorException {
+    return this.post(ORDER_GET, GsonHelper.buildJsonObject("order_id", orderId, "out_order_id", outOrderId,
+      "openid", openid), WxMaShopGetOrderResponse.class);
+  }
+
+  @Override
+  public WxMaShopGetOrderListResponse getOrderList(Integer page, Integer pageSize, Boolean desc, Date startCreateTime, Date endCreateTime) throws WxErrorException {
+    JsonObject object = new JsonObject();
+    object.addProperty("page", page == null ? 1 : page);
+    object.addProperty("page_size", pageSize == null ? 10 : pageSize);
+    object.addProperty("desc", desc ? 1 : 2);
+    if (startCreateTime != null) {
+      object.addProperty("start_create_time", this.dateFormat.format(startCreateTime));
+    }
+    if (endCreateTime != null) {
+      object.addProperty("end_create_time", this.dateFormat.format(endCreateTime));
     }
-    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
+    return this.post(ORDER_GET_LIST, object, WxMaShopGetOrderListResponse.class);
   }
 
   @Override
-  public WxMaShopGetOrderResponse getOrder(Integer orderId, String outOrderId, String openid)
-    throws WxErrorException {
-    String responseContent = this.wxMaService.post(ORDER_GET,
+  public WxMaShopGetPaymentParamsResponse getPaymentParams(String orderId, String outOrderId, String openid) throws WxErrorException {
+    return this.post(ORDER_GET_PAYMENT_PARAMS,
       GsonHelper.buildJsonObject("order_id", orderId, "out_order_id", outOrderId,
-        "openid", openid));
+        "openid", openid), WxMaShopGetPaymentParamsResponse.class);
+  }
+
+
+  private  T post(String url, Object params, Class classOfT) throws WxErrorException {
+    String responseContent = this.wxMaService.post(url, params);
     JsonObject jsonObject = GsonParser.parse(responseContent);
     if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
-    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopGetOrderResponse.class);
+    return WxMaGsonBuilder.create().fromJson(responseContent, classOfT);
   }
 }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopPayServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopPayServiceImpl.java
new file mode 100644
index 0000000000..b9e253f119
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopPayServiceImpl.java
@@ -0,0 +1,47 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.api.WxMaShopPayService;
+import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest;
+import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse;
+import com.google.gson.JsonObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonHelper;
+import me.chanjar.weixin.common.util.json.WxGsonBuilder;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.*;
+
+/**
+ * 小程序支付管理订单相关接口
+ *
+ * @author liming1019
+ */
+@RequiredArgsConstructor
+@Slf4j
+public class WxMaShopPayServiceImpl implements WxMaShopPayService {
+  private final WxMaService wxMaService;
+
+  @Override
+  public WxMaShopPayCreateOrderResponse createOrder(WxMaShopPayCreateOrderRequest request) throws WxErrorException {
+    String response = this.wxMaService.post(CREATE_ORDER, request);
+    return WxGsonBuilder.create().fromJson(response, WxMaShopPayCreateOrderResponse.class);
+  }
+
+  @Override
+  public WxMaShopPayGetOrderResponse getOrder(String tradeNo) throws WxErrorException {
+    JsonObject request = GsonHelper.buildJsonObject("trade_no", tradeNo);
+    String response = this.wxMaService.post(GET_ORDER, request);
+    return WxGsonBuilder.create().fromJson(response, WxMaShopPayGetOrderResponse.class);
+  }
+
+  @Override
+  public WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException {
+    String response = this.wxMaService.post(REFUND_ORDER, request);
+    return WxGsonBuilder.create().fromJson(response, WxMaShopBaseResponse.class);
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopSharerServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopSharerServiceImpl.java
new file mode 100644
index 0000000000..9f92d284d5
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopSharerServiceImpl.java
@@ -0,0 +1,113 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Sharer;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.api.WxMaShopSharerService;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSearchSharerResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerBindResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerDataSummaryResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerListResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveOrderListResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveSummaryListResponse;
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerUnbindResponse;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.JsonObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonHelper;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+/**
+ * @author leiin
+ * created on  2022/6/18 3:38 下午
+ */
+@RequiredArgsConstructor
+@Slf4j
+public class WxMaShopSharerServiceImpl implements WxMaShopSharerService {
+  private final WxMaService wxMaService;
+
+  @Override
+  public WxMaShopSharerBindResponse bindSharer(String[] openids) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("openids", openids);
+    String responseContent = this.wxMaService.post(Sharer.BIND, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopSharerBindResponse.class);
+  }
+
+  @Override
+  public WxMaShopSharerDataSummaryResponse getSharerDataSummary(String openid) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("openid", openid);
+    String responseContent = this.wxMaService.post(Sharer.GET_SHARER_DATA_SUMMARY, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopSharerDataSummaryResponse.class);
+  }
+
+  @Override
+  public WxMaShopSharerListResponse getSharerList(Integer page, Integer pageSize) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("page", page, "page_size", pageSize);
+    String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIST, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopSharerListResponse.class);
+  }
+
+  @Override
+  public WxMaShopSharerLiveOrderListResponse getSharerLiveOrderList(String openid, String liveExportId,
+    Integer page, Integer pageSize) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("openid", openid, "live_export_id", liveExportId,
+      "page", page, "page_size", pageSize);
+    String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIVE_ORDER_LIST, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopSharerLiveOrderListResponse.class);
+  }
+
+  @Override
+  public WxMaShopSharerLiveSummaryListResponse getSharerLiveSummaryList(String openid,
+    Integer page, Integer pageSize) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("openid", openid, "page", page, "page_size", pageSize);
+    String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIVE_SUMMARY_LIST, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopSharerLiveSummaryListResponse.class);
+  }
+
+  @Override
+  public WxMaShopSearchSharerResponse searchSharer(String openid) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("openid", openid);
+    String responseContent = this.wxMaService.post(Sharer.SEARCH_SHARER, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopSearchSharerResponse.class);
+  }
+
+  @Override
+  public WxMaShopSharerUnbindResponse unbindSharer(String[] openids) throws WxErrorException {
+    JsonObject json = GsonHelper.buildJsonObject("openids", openids);
+    String responseContent = this.wxMaService.post(Sharer.UNBIND, json);
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopSharerUnbindResponse.class);
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopSpuServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopSpuServiceImpl.java
index 94b779c6c9..064673686e 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopSpuServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopSpuServiceImpl.java
@@ -20,6 +20,7 @@
 import me.chanjar.weixin.common.util.json.GsonParser;
 
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.*;
+import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
 
 /**
  * @author boris
@@ -27,8 +28,6 @@
 @RequiredArgsConstructor
 @Slf4j
 public class WxMaShopSpuServiceImpl implements WxMaShopSpuService {
-
-  private static final String ERR_CODE = "errcode";
   private final WxMaService wxMaService;
 
   @Override
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImpl.java
index bf37efe1c8..2167ba062b 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImpl.java
@@ -3,6 +3,7 @@
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
 import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.bean.subscribemsg.CategoryData;
 import me.chanjar.weixin.common.bean.subscribemsg.PubTemplateKeyword;
 import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;
@@ -27,7 +28,7 @@
 
 /**
  * @author Binary Wang
- * @date 2019-12-15
+ * created on  2019-12-15
  */
 @RequiredArgsConstructor
 public class WxMaSubscribeServiceImpl implements WxMaSubscribeService {
@@ -85,7 +86,7 @@ public List getCategory() throws WxErrorException {
   public void sendSubscribeMsg(WxMaSubscribeMessage subscribeMessage) throws WxErrorException {
     String responseContent = this.service.post(SUBSCRIBE_MSG_SEND_URL, subscribeMessage.toJson());
     JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
+    if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
     }
   }
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java
index 97c2d196a1..b6dde6f907 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java
@@ -6,16 +6,19 @@
 import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
 import cn.binarywang.wx.miniapp.config.WxMaConfig;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
 import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import lombok.RequiredArgsConstructor;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.util.SignUtils;
+import me.chanjar.weixin.common.util.json.GsonParser;
 import org.apache.commons.codec.digest.DigestUtils;
 
 import java.util.Map;
 
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.GET_PHONE_NUMBER_URL;
 import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.SET_USER_STORAGE;
 
 /**
@@ -23,6 +26,7 @@
  */
 @RequiredArgsConstructor
 public class WxMaUserServiceImpl implements WxMaUserService {
+  private static final String PHONE_INFO = "phone_info";
   private final WxMaService service;
 
   @Override
@@ -58,6 +62,25 @@ public WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedDat
     return WxMaPhoneNumberInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr));
   }
 
+  @Override
+  public WxMaPhoneNumberInfo getPhoneNoInfo(String code) throws WxErrorException {
+    JsonObject param = new JsonObject();
+    param.addProperty("code", code);
+    String responseContent = this.service.post(GET_PHONE_NUMBER_URL, param.toString());
+    JsonObject response = GsonParser.parse(responseContent);
+    if (response.has(PHONE_INFO)) {
+      return WxMaGsonBuilder.create().fromJson(response.getAsJsonObject(PHONE_INFO),
+        WxMaPhoneNumberInfo.class);
+    }
+
+    return null;
+  }
+
+  @Override
+  public WxMaPhoneNumberInfo getNewPhoneNoInfo(String code) throws WxErrorException {
+    return this.getPhoneNoInfo(code);
+  }
+
   @Override
   public boolean checkUserInfo(String sessionKey, String rawData, String signature) {
     final String generatedSignature = DigestUtils.sha1Hex(rawData + sessionKey);
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImpl.java
new file mode 100644
index 0000000000..0a3eb74016
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImpl.java
@@ -0,0 +1,229 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.api.WxMaVodService;
+import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse;
+import cn.binarywang.wx.miniapp.bean.vod.*;
+import cn.binarywang.wx.miniapp.executor.VodSingleUploadRequestExecutor;
+import cn.binarywang.wx.miniapp.executor.VodUploadPartRequestExecutor;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.util.json.GsonParser;
+
+import java.io.File;
+import java.util.List;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Vod.*;
+
+
+@RequiredArgsConstructor
+@Slf4j
+public class WxMaVodServiceImpl implements WxMaVodService {
+
+  private final WxMaService service;
+
+  @Override
+  public List listMedia(WxMaVodListMediaRequest mediaRequest) throws WxErrorException {
+    String responseContent = this.service.post(LIST_MEDIA_URL, mediaRequest.toJson());
+
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    boolean hasMediaInfoList = jsonObject.has("media_info_list");
+    if (hasMediaInfoList) {
+      return WxMaGsonBuilder.create().fromJson(jsonObject.getAsJsonArray("media_info_list"),
+        new TypeToken>() {
+        }.getType());
+    } else {
+      return null;
+    }
+  }
+
+
+  @Override
+  public List listDrama(WxMaVodListDramaRequest mediaRequest) throws WxErrorException {
+    String responseContent = this.service.post(LIST_DRAMAS_URL, mediaRequest.toJson());
+    JsonObject jsonObject = GsonParser.parse(responseContent);
+    boolean hasMediaInfoList = jsonObject.has("drama_info_list");
+    if (hasMediaInfoList) {
+      return WxMaGsonBuilder.create().fromJson(jsonObject.getAsJsonArray("drama_info_list"),
+        new TypeToken>() {
+        }.getType());
+    } else {
+      return null;
+    }
+  }
+
+
+  @Override
+  public WxMaVodMediaPlaybackInfo getMediaLink(WxMaVodGetMediaLinkRequest request) throws WxErrorException {
+    String responseContent = this.service.post(GET_MEDIA_LINK_URL, request.toJson());
+    WxMaVodGetMediaLinkResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodGetMediaLinkResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return getDetailResponse.getMediaInfo();
+  }
+
+
+  @Override
+  public WxMaVodMediaInfo getMedia(WxMaVodGetMediaRequest request) throws WxErrorException {
+    String responseContent = this.service.post(GET_MEDIA_URL, request.toJson());
+    WxMaVodGetMediaResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodGetMediaResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return getDetailResponse.getMediaInfo();
+  }
+
+  @Override
+  public boolean deleteMedia(WxMaVodDeleteMediaRequest request) throws WxErrorException {
+    String responseContent = this.service.post(DELETE_MEDIA_URL, request.toJson());
+    WxMaBaseResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaBaseResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return true;
+  }
+
+  @Override
+  public WxMaVodDramaInfo getDrama(WxMaVodGetDramaRequest request) throws WxErrorException {
+    String responseContent = this.service.post(GET_DRAMA_URL, request.toJson());
+    WxMaVodGetDramaResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodGetDramaResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse.getDramaInfo();
+
+  }
+
+  @Override
+  public Integer auditDrama(WxMaVodAuditDramaRequest request) throws WxErrorException {
+    String responseContent = this.service.post(AUDIT_DRAMA_URL, request.toJson());
+    WxMaVodAuditDramaResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodAuditDramaResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse.getDramaId();
+
+  }
+
+  @Override
+  public WxMaVodGetCdnUsageResponse getCdnUsageData(WxMaVodGetCdnUsageRequest request) throws WxErrorException {
+    String responseContent = this.service.post(GET_CDN_USAGE_DATA_URL, request.toJson());
+    WxMaVodGetCdnUsageResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodGetCdnUsageResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaVodGetCdnLogResponse getCdnLogs(WxMaVodGetCdnLogRequest request) throws WxErrorException {
+    String responseContent = this.service.post(GET_CDN_LOGS_URL, request.toJson());
+    WxMaVodGetCdnLogResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodGetCdnLogResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaVodGetTaskResponse getTask(WxMaVodGetTaskRequest request) throws WxErrorException {
+    String responseContent = this.service.post(GET_TASK_URL, request.toJson());
+    WxMaVodGetTaskResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodGetTaskResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaVodPullUploadResponse pullUpload(WxMaVodPullUploadRequest request) throws WxErrorException {
+    String responseContent = this.service.post(PULL_UPLOAD_URL, request.toJson());
+    WxMaVodPullUploadResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodPullUploadResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaVodSingleFileUploadResult uploadSingleFile(File file, String mediaName, String mediaType) throws WxErrorException {
+    WxMaVodSingleFileUploadResult result = this.service.execute(
+      VodSingleUploadRequestExecutor.create(this.service.getRequestHttp(), mediaName, mediaType, null, null, null), SINGLE_FILE_UPLOAD_URL, file);
+    return result;
+  }
+
+  @Override
+  public WxMaVodSingleFileUploadResult uploadSingleFile(File file, String mediaName, String mediaType, String coverType, File coverData, String sourceContext) throws WxErrorException {
+    WxMaVodSingleFileUploadResult result = this.service.execute(
+      VodSingleUploadRequestExecutor.create(this.service.getRequestHttp(), mediaName, mediaType, coverType, coverData, sourceContext), SINGLE_FILE_UPLOAD_URL, file);
+    return result;
+  }
+
+  @Override
+  public WxMaVodApplyUploadResponse applyUpload(WxMaVodApplyUploadRequest request) throws WxErrorException {
+    String responseContent = this.service.post(APPLY_UPLOAD_URL, request.toJson());
+    WxMaVodApplyUploadResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodApplyUploadResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaVodCommitUploadResponse commitUpload(WxMaVodCommitUploadRequest request) throws WxErrorException {
+    String responseContent = this.service.post(COMMIT_UPLOAD_URL, request.toJson());
+    WxMaVodCommitUploadResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaVodCommitUploadResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaVodUploadPartResult uploadPart(File file, String uploadId, Integer partNumber, Integer resourceType) throws WxErrorException {
+    WxMaVodUploadPartResult result = this.service.execute(
+      VodUploadPartRequestExecutor.create(this.service.getRequestHttp(), uploadId, partNumber, resourceType), UPLOAD_PART_URL, file);
+    return result;
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaXPayServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaXPayServiceImpl.java
new file mode 100644
index 0000000000..5e33d1059f
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaXPayServiceImpl.java
@@ -0,0 +1,238 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse;
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import cn.binarywang.wx.miniapp.api.WxMaXPayService;
+import cn.binarywang.wx.miniapp.bean.xpay.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.enums.WxType;
+import me.chanjar.weixin.common.error.WxError;
+import me.chanjar.weixin.common.error.WxErrorException;
+
+import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.XPay.*;
+
+
+@RequiredArgsConstructor
+@Slf4j
+public class WxMaXPayServiceImpl implements WxMaXPayService {
+
+  private final WxMaService service;
+
+  @Override
+  public WxMaXPayQueryUserBalanceResponse queryUserBalance(WxMaXPayQueryUserBalanceRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithBoth(QUERY_USER_BALANCE_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayQueryUserBalanceResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayQueryUserBalanceResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaXPayCurrencyPayResponse currencyPay(WxMaXPayCurrencyPayRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithBoth(CURRENCY_PAY_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayCurrencyPayResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayCurrencyPayResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaXPayQueryOrderResponse queryOrder(WxMaXPayQueryOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(QUERY_ORDER_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayQueryOrderResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayQueryOrderResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaXPayCancelCurrencyPayResponse cancelCurrencyPay(WxMaXPayCancelCurrencyPayRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithBoth(CANCEL_CURRENCY_PAY_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayCancelCurrencyPayResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayCancelCurrencyPayResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    }
+    return getDetailResponse;
+  }
+
+  @Override
+  public boolean notifyProvideGoods(WxMaXPayNotifyProvideGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(NOTIFY_PROVIDE_GOODS_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaBaseResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaBaseResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return true;
+  }
+
+  @Override
+  public WxMaXPayPresentCurrencyResponse presentCurrency(WxMaXPayPresentCurrencyRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(PRESENT_CURRENCY_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayPresentCurrencyResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayPresentCurrencyResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaXPayDownloadBillResponse downloadBill(WxMaXPayDownloadBillRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(DOWNLOAD_BILL_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayDownloadBillResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayDownloadBillResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaXPayRefundOrderResponse refundOrder(WxMaXPayRefundOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(REFUND_ORDER_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayRefundOrderResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayRefundOrderResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaXPayCreateWithdrawOrderResponse createWithdrawOrder(WxMaXPayCreateWithdrawOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(CREATE_WITHDRAW_ORDER_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayCreateWithdrawOrderResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayCreateWithdrawOrderResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public WxMaXPayQueryWithdrawOrderResponse queryWithdrawOrder(WxMaXPayQueryWithdrawOrderRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(QUERY_WITHDRAW_ORDER_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayQueryWithdrawOrderResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayQueryWithdrawOrderResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public boolean startUploadGoods(WxMaXPayStartUploadGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(START_UPLOAD_GOODS_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaBaseResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaBaseResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return true;
+  }
+
+  @Override
+  public WxMaXPayQueryUploadGoodsResponse queryUploadGoods(WxMaXPayQueryUploadGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(QUERY_UPLOAD_GOODS_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayQueryUploadGoodsResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayQueryUploadGoodsResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse;
+  }
+
+  @Override
+  public boolean startPublishGoods(WxMaXPayStartPublishGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(START_PUBLISH_GOODS_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaBaseResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaBaseResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return true;
+  }
+
+  @Override
+  public WxMaXPayQueryPublishGoodsResponse queryPublishGoods(WxMaXPayQueryPublishGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
+    final String postBody = request.toJson();
+    final String uri = sigParams.signUriWithPay(QUERY_PUBLISH_GOODS_URL, postBody);
+    String responseContent = this.service.post(uri, postBody);
+    WxMaXPayQueryPublishGoodsResponse getDetailResponse = WxMaGsonBuilder.create()
+      .fromJson(responseContent, WxMaXPayQueryPublishGoodsResponse.class);
+
+    if (getDetailResponse.getErrcode() != 0) {
+      throw new WxErrorException(
+        new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
+    }
+
+    return getDetailResponse;
+  }
+}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/Watermark.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/Watermark.java
index 4747c77f84..0ce4260093 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/Watermark.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/Watermark.java
@@ -11,7 +11,7 @@
  * 数据水印.
  *
  * @author Binary Wang
- * @date 2020-05-25
+ * created on  2020-05-25
  */
 @Data
 @AllArgsConstructor
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaBaseResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaBaseResponse.java
index a0f524d324..9abf9c6750 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaBaseResponse.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaBaseResponse.java
@@ -7,7 +7,7 @@
 
 /**
  * @author liming1019
- * @date 2021/8/17
+ * created on  2021/8/17
  */
 @Data
 public class WxMaBaseResponse implements Serializable {
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
index 2afb4c073e..388556a7bf 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
@@ -2,6 +2,7 @@
 
 import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 /**
  * 
@@ -12,6 +13,7 @@
  * @author Element
  */
 @Data
+@NoArgsConstructor
 @AllArgsConstructor
 public class WxMaCodeLineColor {
   private String r = "0", g = "0", b = "0";
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java
index af113e4ec5..1b0f6f28a1 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java
@@ -10,7 +10,8 @@
 /**
  * 
  * code换取session_key接口的响应
- * 文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-login.html#wxloginobject
+ * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html
+ *
  * 微信返回报文:{"session_key":"nzoqhc3OnwHzeTxJs+inbQ==","openid":"oVBkZ0aYgDMDIywRdgPW8-joxXc4"}
  * 
* @author Binary Wang diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java index 5d16b60b75..0cd77c7937 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java @@ -9,6 +9,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.io.Serializable; @@ -41,6 +42,7 @@ public class WxMaKefuMessage implements Serializable { @Data @AllArgsConstructor + @NoArgsConstructor public static class KfText implements Serializable { private static final long serialVersionUID = 151122958720941270L; @@ -49,6 +51,7 @@ public static class KfText implements Serializable { @Data @AllArgsConstructor + @NoArgsConstructor public static class KfImage implements Serializable { private static final long serialVersionUID = -5409342945117300782L; @@ -58,6 +61,8 @@ public static class KfImage implements Serializable { @Data @Builder + @NoArgsConstructor + @AllArgsConstructor public static class KfLink implements Serializable { private static final long serialVersionUID = -6728776817556127413L; @@ -71,6 +76,8 @@ public static class KfLink implements Serializable { @Data @Builder + @NoArgsConstructor + @AllArgsConstructor public static class KfMaPage implements Serializable { private static final long serialVersionUID = -5633492281871634466L; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMediaAsyncCheckResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMediaAsyncCheckResult.java index f4428b959b..64351ece6d 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMediaAsyncCheckResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMediaAsyncCheckResult.java @@ -2,7 +2,11 @@ import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import com.google.gson.annotations.SerializedName; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Builder; import lombok.Data; +import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import java.io.Serializable; @@ -19,6 +23,60 @@ public class WxMaMediaAsyncCheckResult implements Serializable { @SerializedName("trace_id") private String traceId; + /** + * 综合结果 + */ + @Data + @Builder + @XStreamAlias("result") + public static class ResultBean implements Serializable { + /** + * suggest : risky + * label : 20001 + */ + @SerializedName("suggest") + @XStreamAlias("suggest") + @XStreamConverter(value = XStreamCDataConverter.class) + private String suggest; + @SerializedName("label") + @XStreamAlias("label") + @XStreamConverter(value = XStreamCDataConverter.class) + private String label; + } + + /** + * 详细检测结果 + */ + @Data + @Builder + @XStreamAlias("detail") + public static class DetailBean implements Serializable { + /** + * strategy : content_model + * errcode : 0 + * suggest : risky + * label : 20006 + * prob : 90 + */ + @SerializedName("strategy") + @XStreamAlias("strategy") + @XStreamConverter(value = XStreamCDataConverter.class) + private String strategy; + @SerializedName("errcode") + @XStreamAlias("errcode") + private Integer errcode; + @SerializedName("suggest") + @XStreamAlias("suggest") + @XStreamConverter(value = XStreamCDataConverter.class) + private String suggest; + @SerializedName("label") + @XStreamAlias("label") + @XStreamConverter(value = XStreamCDataConverter.class) + private String label; + @SerializedName("prob") + @XStreamAlias("prob") + private Integer prob; + } public static WxMaMediaAsyncCheckResult fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaMediaAsyncCheckResult.class); diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java index 57d6a5b9be..e34d63cd69 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java @@ -7,15 +7,20 @@ import com.google.gson.annotations.SerializedName; import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import com.thoughtworks.xstream.annotations.XStreamImplicit; import lombok.Data; import me.chanjar.weixin.common.error.WxRuntimeException; +import me.chanjar.weixin.common.util.XmlUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; /** * @author Binary Wang @@ -25,6 +30,11 @@ public class WxMaMessage implements Serializable { private static final long serialVersionUID = -3586245291677274914L; + /** + * 使用dom4j解析的存放所有xml属性和值的map. + */ + private Map allFieldsMap; + @SerializedName("Encrypt") @XStreamAlias("Encrypt") @XStreamConverter(value = XStreamCDataConverter.class) @@ -136,6 +146,29 @@ public class WxMaMessage implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String statusCode; + /** + * 异步校验图片/音频内容安全 接口版本 + * @since 2.0 + */ + @SerializedName("version") + @XStreamAlias("version") + private Integer version; + /** + * 异步校验图片/音频内容安全 综合结果 + * @since 2.0 + */ + @SerializedName("result") + @XStreamAlias("result") + private WxMaMediaAsyncCheckResult.ResultBean result; + /** + * 异步校验图片/音频内容安全 详细检测结果 + * @since 2.0 + */ + @SerializedName("detail") + @XStreamAlias("detail") + @XStreamImplicit + private List detail; + @SerializedName("Scene") @XStreamAlias("Scene") private Integer scene; @@ -145,10 +178,72 @@ public class WxMaMessage implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String query; + @SerializedName("AppID") + @XStreamAlias("AppID") + @XStreamConverter(value = XStreamCDataConverter.class) + private String appID; + + @SerializedName("RevokeInfo") + @XStreamAlias("RevokeInfo") + @XStreamConverter(value = XStreamCDataConverter.class) + private String revokeInfo; + + @SerializedName("OpenID") + @XStreamAlias("OpenID") + @XStreamConverter(value = XStreamCDataConverter.class) + private String openId; + + @SerializedName("PluginID") + @XStreamAlias("PluginID") + @XStreamConverter(value = XStreamCDataConverter.class) + private String pluginId; + + @SerializedName("OpenPID") + @XStreamAlias("OpenPID") + @XStreamConverter(value = XStreamCDataConverter.class) + private String openPid; + + @XStreamAlias("SubscribeMsgPopupEvent") + private WxMaSubscribeMsgEvent.SubscribeMsgPopupEvent subscribeMsgPopupEvent; + + @XStreamAlias("SubscribeMsgChangeEvent") + private WxMaSubscribeMsgEvent.SubscribeMsgChangeEvent subscribeMsgChangeEvent; + + @XStreamAlias("SubscribeMsgSentEvent") + private WxMaSubscribeMsgEvent.SubscribeMsgSentEvent subscribeMsgSentEvent; + + /** + * 不要直接使用这个字段, + * 这个字段只是为了适配 SubscribeMsgPopupEvent SubscribeMsgChangeEvent SubscribeMsgSentEvent + * 在json里面名称都是List并且有时候是对象有时候是数组的问题 + * 当List只有一个对象的时候,微信服务器推送过来的的List是对象而非数组,当有多个对象的时候推送过来的才是数组 + * 当只有一个对象的时候 + * "List": { + * "TemplateId": "hD-ixGOhYmUfjOnI8MCzQMPshzGVeux_2vzyvQu7O68", + * "SubscribeStatusString": "accept", + * "PopupScene": "0" + * } + * 当有多条数据的时候 + * "List": [ { + * "TemplateId": "hD-ixGOhYmUfjOnI8MCzQMPshzGVeux_2vzyvQu7O68", + * "SubscribeStatusString": "accept", + * "PopupScene": "0" + * }, { + * "TemplateId": "hD-ixGOhYmUfjOnI8MCzQMPshzGVeux_2vzyvQu7O68", + * "SubscribeStatusString": "accept", + * "PopupScene": "0" + * }] + */ + @SerializedName("List") + private WxMaSubscribeMsgEvent.WxMaSubscribeMsgEventJson uselessMsg; + public static WxMaMessage fromXml(String xml) { - return XStreamTransformer.fromXml(WxMaMessage.class, xml); + WxMaMessage message = XStreamTransformer.fromXml(WxMaMessage.class, xml); + message.setAllFieldsMap(XmlUtils.xml2Map(xml)); + return message; } + @Deprecated public static WxMaMessage fromXml(InputStream is) { return XStreamTransformer.fromXml(WxMaMessage.class, is); } @@ -165,7 +260,7 @@ public static WxMaMessage fromXml(InputStream is) { public static WxMaMessage fromEncryptedXml(String encryptedXml, WxMaConfig wxMaConfig, String timestamp, String nonce, String msgSignature) { - String plainText = new WxMaCryptUtils(wxMaConfig).decrypt(msgSignature, timestamp, nonce, encryptedXml); + String plainText = new WxMaCryptUtils(wxMaConfig).decryptXml(msgSignature, timestamp, nonce, encryptedXml); return fromXml(plainText); } @@ -180,7 +275,19 @@ public static WxMaMessage fromEncryptedXml(InputStream is, WxMaConfig wxMaConfig } public static WxMaMessage fromJson(String json) { - return WxMaGsonBuilder.create().fromJson(json, WxMaMessage.class); + WxMaMessage message = WxMaGsonBuilder.create().fromJson(json, WxMaMessage.class); + // 在这里处理 event的json格式时候的 list 问题,让json和xml的程序接口可以保持一致, 详见 uselessMsg 字段的注释 + if (message.getUselessMsg() != null) { + if (StringUtils.equals(message.getEvent(), "subscribe_msg_popup_event")) { + message.setSubscribeMsgPopupEvent(message.getUselessMsg().getPopupEvents()); + } else if (StringUtils.equals(message.getEvent(), "subscribe_msg_change_event")) { + message.setSubscribeMsgChangeEvent(message.getUselessMsg().getChangeEvents()); + } else if (StringUtils.equals(message.getEvent(), "subscribe_msg_sent_event")) { + message.setSubscribeMsgSentEvent(message.getUselessMsg().getSentEvent()); + } + message.setUselessMsg(null); + } + return message; } public static WxMaMessage fromEncryptedJson(String encryptedJson, WxMaConfig config) { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaStableAccessTokenRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaStableAccessTokenRequest.java new file mode 100644 index 0000000000..06a708542a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaStableAccessTokenRequest.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.bean; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 小程序码. + * + * @author Element + * created on 2017/7/27 + */ +@Data +public class WxMaStableAccessTokenRequest implements Serializable { + + private static final long serialVersionUID = 1L; + + @SerializedName("grant_type") + private String grantType = "client_credential"; + + @SerializedName("appid") + private String appid; + @SerializedName("secret") + private String secret; + + @SerializedName("force_refresh") + private boolean forceRefresh; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaSubscribeMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaSubscribeMessage.java index 836b64b084..984e9573db 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaSubscribeMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaSubscribeMessage.java @@ -3,14 +3,15 @@ import cn.binarywang.wx.miniapp.constant.WxMaConstants; import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import lombok.*; +import lombok.experimental.Accessors; import java.io.Serializable; import java.util.ArrayList; import java.util.List; /** - * 订阅消息. - * https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html + * 订阅消息 + * 点击查阅文档 * * @author S */ @@ -19,6 +20,7 @@ @NoArgsConstructor @AllArgsConstructor @Builder +@Accessors(chain = true) public class WxMaSubscribeMessage implements Serializable { private static final long serialVersionUID = 6846729898251286686L; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaSubscribeMsgEvent.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaSubscribeMsgEvent.java new file mode 100644 index 0000000000..29d29b0317 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaSubscribeMsgEvent.java @@ -0,0 +1,118 @@ +package cn.binarywang.wx.miniapp.bean; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamConverter; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.Data; +import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +/** + * WxMaSubscribeMsgEvent class + * 客户端订阅,服务端收到的通知 + * @author dany + * created on 2021/12/31 + */ +public class WxMaSubscribeMsgEvent { + /** + * https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html + */ + @Data + @XStreamAlias("SubscribeMsgPopupEvent") + public static class SubscribeMsgPopupEvent implements Serializable { + private static final long serialVersionUID = 6319723189257161326L; + @XStreamImplicit(itemFieldName = "List") + private List list = new LinkedList<>(); + } + + @Data + @XStreamAlias("SubscribeMsgChangeEvent") + public static class SubscribeMsgChangeEvent implements Serializable { + private static final long serialVersionUID = 7705686111539437751L; + @XStreamImplicit(itemFieldName = "List") + private List list = new LinkedList<>(); + } + + @Data + @XStreamAlias("SubscribeMsgSentEvent") + public static class SubscribeMsgSentEvent implements Serializable { + private static final long serialVersionUID = 7705686111539437751L; + @XStreamAlias("List") + private SentEvent list; + } + + + @Data + public static class PopupEvent implements Serializable { + private static final long serialVersionUID = 4934029303241387226L; + /** + * 模板id + */ + @XStreamAlias("TemplateId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String templateId; + /** + * 订阅结果(accept接收;reject拒收) + */ + @XStreamAlias("SubscribeStatusString") + @XStreamConverter(value = XStreamCDataConverter.class) + private String subscribeStatusString; + /** + * 弹框场景,0代表在小程序页面内 + */ + @XStreamAlias("PopupScene") + private String popupScene; + } + + @Data + public static class ChangeEvent implements Serializable { + private static final long serialVersionUID = 1523634146232757624L; + /** + * 模板id + */ + @XStreamAlias("TemplateId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String templateId; + /** + * 订阅结果(accept接收;reject拒收) + */ + @XStreamAlias("SubscribeStatusString") + @XStreamConverter(value = XStreamCDataConverter.class) + private String subscribeStatusString; + } + + @Data + public static class SentEvent implements Serializable { + private static final long serialVersionUID = -8734478345463177940L; + /** + * 模板id + */ + @XStreamAlias("TemplateId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String templateId; + + @XStreamAlias("MsgID") + private String msgId; + + @XStreamAlias("ErrorCode") + private String errorCode; + + @XStreamAlias("ErrorStatus") + @XStreamConverter(value = XStreamCDataConverter.class) + private String errorStatus; + } + + @Data + public static class WxMaSubscribeMsgEventJson implements Serializable { + private static final long serialVersionUID = -4820758280837190275L; + + private SubscribeMsgPopupEvent popupEvents; + + private SubscribeMsgChangeEvent changeEvents; + + private SubscribeMsgSentEvent sentEvent; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUpdatableMsg.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUpdatableMsg.java index 98429b850c..22d1401adf 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUpdatableMsg.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUpdatableMsg.java @@ -11,7 +11,7 @@ * 动态消息. * * @author Binary Wang - * @date 2020-02-17 + * created on 2020-02-17 */ @Data @Accessors(chain = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java index e2f67a7718..da1126fd04 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java @@ -12,7 +12,6 @@ public class WxMaUserInfo implements Serializable { private static final long serialVersionUID = 6719822331555402137L; - private String openId; private String nickName; private String gender; private String language; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCode.java index 2361355adf..fcd2214035 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCode.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCode.java @@ -10,11 +10,13 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import static cn.binarywang.wx.miniapp.constant.WxMaConstants.DEFAULT_ENV_VERSION; + /** * 小程序码. * * @author Element - * @date 2017/7/27 + * created on 2017/7/27 */ @Data @EqualsAndHashCode(callSuper = false) @@ -26,6 +28,9 @@ public class WxaCode extends AbstractWxMaQrcodeWrapper implements Serializable { private String path; + @SerializedName("env_version") + private String envVersion = DEFAULT_ENV_VERSION; + @Builder.Default private int width = 430; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCodeUnlimit.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCodeUnlimit.java index ab0dad4e2b..75c9bf754b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCodeUnlimit.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxaCodeUnlimit.java @@ -7,11 +7,13 @@ import java.io.Serializable; +import static cn.binarywang.wx.miniapp.constant.WxMaConstants.DEFAULT_ENV_VERSION; + /** * 小程序码接口B. * * @author Element - * @date 2017/7/27 + * created on 2017/7/27 */ @Data @EqualsAndHashCode(callSuper = false) @@ -20,6 +22,12 @@ public class WxaCodeUnlimit extends AbstractWxMaQrcodeWrapper implements Seriali private String scene; private String page; + @SerializedName("check_path") + private boolean checkPath = true; + + @SerializedName("env_version") + private String envVersion = DEFAULT_ENV_VERSION; + private int width = 430; @SerializedName("auto_color") diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDeleteFileResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDeleteFileResult.java index 52a70037f7..4fc55c74f4 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDeleteFileResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDeleteFileResult.java @@ -10,7 +10,7 @@ * 文件删除结果. * * @author Binary Wang - * @date 2020-01-27 + * created on 2020-01-27 */ @Data public class WxCloudBatchDeleteFileResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDownloadFileResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDownloadFileResult.java index 1519e72318..1da70ff96a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDownloadFileResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudBatchDownloadFileResult.java @@ -10,7 +10,7 @@ * 获取文件下载链接结果. * * @author Binary Wang - * @date 2020-01-27 + * created on 2020-01-27 */ @Data public class WxCloudBatchDownloadFileResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudCloudDatabaseMigrateQueryInfoResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudCloudDatabaseMigrateQueryInfoResult.java index b2639c5545..4bad66951f 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudCloudDatabaseMigrateQueryInfoResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudCloudDatabaseMigrateQueryInfoResult.java @@ -9,7 +9,7 @@ * 云开发数据库迁移状态查询结果. * * @author Binary Wang - * @date 2020-01-26 + * created on 2020-01-26 */ @Data public class WxCloudCloudDatabaseMigrateQueryInfoResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCollectionGetResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCollectionGetResult.java index 347762b4c1..e47175db3d 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCollectionGetResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCollectionGetResult.java @@ -9,7 +9,7 @@ * 云开发获取集合接口的结果. * * @author Binary Wang - * @date 2020-01-28 + * created on 2020-01-28 */ @Data public class WxCloudDatabaseCollectionGetResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCreateIndexRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCreateIndexRequest.java index 9b551db255..f5d5f9aad1 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCreateIndexRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseCreateIndexRequest.java @@ -10,7 +10,7 @@ * 云开发新增索引的请求对象. * * @author Binary Wang - * @date 2020-01-26 + * created on 2020-01-26 */ @Accessors(chain = true) @Data diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseQueryResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseQueryResult.java index 19ca4dce1f..37d6b64847 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseQueryResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseQueryResult.java @@ -9,7 +9,7 @@ * 云开发数据库查询记录接口请求结果. * * @author Binary Wang - * @date 2020-01-26 + * created on 2020-01-26 */ @Data public class WxCloudDatabaseQueryResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseUpdateResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseUpdateResult.java index 000774132f..a06a415df7 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseUpdateResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudDatabaseUpdateResult.java @@ -8,7 +8,7 @@ * 云开发数据库更新记录接口请求结果. * * @author Binary Wang - * @date 2020-01-26 + * created on 2020-01-26 */ @Data public class WxCloudDatabaseUpdateResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudGetQcloudTokenResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudGetQcloudTokenResult.java index f2b8bf0a1d..7443871e31 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudGetQcloudTokenResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudGetQcloudTokenResult.java @@ -9,7 +9,7 @@ * 获取腾讯云API调用凭证结果. * * @author Binary Wang - * @date 2020-01-27 + * created on 2020-01-27 */ @Data public class WxCloudGetQcloudTokenResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudSendSmsV2Result.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudSendSmsV2Result.java new file mode 100644 index 0000000000..2ee1cac2be --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudSendSmsV2Result.java @@ -0,0 +1,44 @@ +package cn.binarywang.wx.miniapp.bean.cloud; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 发送携带 URL Link 的短信结果 + * + * @author liming1019 + * created on 2022-07-26 + */ +@Data +public class WxCloudSendSmsV2Result extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 4273038291300329985L; + + @SerializedName("send_status_list") + private List sendStatusList; + + @NoArgsConstructor + @Data + public static class SendStatus implements Serializable { + private static final long serialVersionUID = 5765836923681051366L; + + @SerializedName("serial_no") + private String serialNo; + + @SerializedName("phone_number") + private String phoneNumber; + + @SerializedName("code") + private String code; + + @SerializedName("message") + private String message; + + @SerializedName("iso_code") + private String isoCode; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudUploadFileResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudUploadFileResult.java index 300ae86200..a1abe85d3a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudUploadFileResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/WxCloudUploadFileResult.java @@ -9,7 +9,7 @@ * 云开发文件上传接口响应结果. * * @author Binary Wang - * @date 2020-01-27 + * created on 2020-01-27 */ @Data public class WxCloudUploadFileResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/request/WxCloudSendSmsV2Request.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/request/WxCloudSendSmsV2Request.java new file mode 100644 index 0000000000..3d51c7d06f --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/cloud/request/WxCloudSendSmsV2Request.java @@ -0,0 +1,41 @@ +package cn.binarywang.wx.miniapp.bean.cloud.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 发送携带 URL Link 的短信请求 + * + * @author liming1019 + * created on 2022-07-26 + */ +@Data +@Builder +public class WxCloudSendSmsV2Request implements Serializable { + private static final long serialVersionUID = 8917033507660980594L; + + @SerializedName("env") + private String env; + + @SerializedName("url_link") + private String urlLink; + + @SerializedName("template_id") + private String templateId; + + @SerializedName("template_param_list") + private List templateParamList; + + @SerializedName("phone_number_list") + private List phoneNumberList; + + @SerializedName("use_short_name") + private Boolean useShortName; + + @SerializedName("resource_appid") + private String resourceAppid; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeAuditStatus.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeAuditStatus.java index d8733756c1..59de0573b1 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeAuditStatus.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeAuditStatus.java @@ -41,6 +41,24 @@ public class WxMaCodeAuditStatus implements Serializable { @SerializedName(value = "screenshot") private String screenShot; + /** + * 审核版本 + */ + @SerializedName(value = "user_version") + private String userVersion; + + /** + * 版本描述 + */ + @SerializedName(value = "user_desc") + private String userDesc; + + /** + * 时间戳,提交审核的时间 + */ + @SerializedName(value = "submit_audit_time") + private String submitAuditTime; + public static WxMaCodeAuditStatus fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaCodeAuditStatus.class); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeExtConfig.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeExtConfig.java index c7d4de5491..304392132b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeExtConfig.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeExtConfig.java @@ -1,17 +1,17 @@ package cn.binarywang.wx.miniapp.bean.code; -import java.io.Serializable; -import java.util.List; -import java.util.Map; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; +import java.util.List; +import java.util.Map; + /** * 上传代码需要用到的第三方自定义的配置 - * 详细文档,参考:https://developers.weixin.qq.com/miniprogram/dev/framework/config.html + * 详细文档,参考:文档 * * @author Charming * @since 2018-04-26 19:44 @@ -75,13 +75,35 @@ public class WxMaCodeExtConfig implements Serializable { */ private TabBar tabBar; + /** + * 关于新增 requiredPrivateInfos 说明 + * 关于地理位置接口新增与相关流程调整可以查看社区公告: + * ... + * 7.14后,在代码中使用的地理位置相关接口(共计 8 个,见表1),第三方开发者均需要在 ext_json 参数中 requiredPrivateInfos 配置项中声明 + * 在ext_json参数中配置requiredPrivateInfos,其规则为「整体替换」。即如果在 app.json 里也配置了,那么最终会是ext_json的配置会覆盖 app.json + * 配置的requiredPrivateInfos。其余规则可查看下方的「ext_json补充说明」 + * 在ext_json参数中配置 requiredPrivateInfos 示例如下 + * { + * "template_id": "95", + * "ext_json": "{\"requiredPrivateInfos\":[\"onLocationChange\",\"startLocationUpdate\"]}", + * "user_version": "V1.0", + * "user_desc": "test" + * } + * requiredPrivateInfos主要会检查格式是否正确,填入的 api 名称是否正确,填入的 api 名称是否有权限,填入的 api 名称是否互斥。对应的错误码可查看文档末尾的错误码文档。 + * requiredPrivateInfos在2022.7.14后才会生效,文档提前更新是为了方便开发者可以提前了解接口的参数变更规则,提前进行调整。 + */ + private String[] requiredPrivateInfos; + /** * page.json 配置,页面配置 - * 文档:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html + * 文档 */ @Data @Builder - public static class PageConfig { + @NoArgsConstructor + @AllArgsConstructor + public static class PageConfig implements Serializable { + private static final long serialVersionUID = -8615574764987479723L; /** * 导航栏背景颜色,如"#000000" HexColor. * 默认:#000000 @@ -128,7 +150,11 @@ public static class PageConfig { */ @Data @Builder - public static class TabBar { + @NoArgsConstructor + @AllArgsConstructor + public static class TabBar implements Serializable { + private static final long serialVersionUID = -3037016532526129399L; + /** * HexColor, tab 上的文字默认颜色. */ @@ -159,7 +185,10 @@ public static class TabBar { */ @Data @Builder - public static class Item { + @NoArgsConstructor + @AllArgsConstructor + public static class Item implements Serializable { + private static final long serialVersionUID = -5824322265161612460L; /** * 页面路径,必须在 pages 中先定义. */ @@ -184,7 +213,11 @@ public static class Item { */ @Data @Builder - public static class NetworkTimeout { + @NoArgsConstructor + @AllArgsConstructor + public static class NetworkTimeout implements Serializable { + private static final long serialVersionUID = -9180176522015880991L; + /** * wx.request的超时时间,单位毫秒,默认为:60000. * 必填:否 diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCategory.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditItem.java similarity index 83% rename from weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCategory.java rename to weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditItem.java index 5e176cfa61..38a43ee810 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCategory.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditItem.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; import java.io.Serializable; @@ -18,10 +19,22 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class WxMaCategory implements Serializable { +@Accessors(chain = true) +public class WxMaCodeSubmitAuditItem implements Serializable { private static final long serialVersionUID = -7663757440028175135L; + + /** + * 小程序的页面,可通过“获取小程序的第三方提交代码的页面配置”接口获得 + */ + private String address; + /** + * 小程序的标签,多个标签用空格分隔,标签不能多于10个,标签长度不超过20 + */ + private String tag; + /** * 一级类目名称 + * 类目名称,可通过“获取授权小程序帐号的可选类目”接口获得 */ @SerializedName("first_class") private String firstClass; @@ -37,6 +50,7 @@ public class WxMaCategory implements Serializable { private String thirdClass; /** * 一级类目的ID编号 + * 类目的ID,可通过“获取授权小程序帐号的可选类目”接口获得 */ @SerializedName("first_id") private Long firstId; @@ -51,14 +65,6 @@ public class WxMaCategory implements Serializable { @SerializedName("third_id") private Long thirdId; - /** - * 小程序的页面,可通过“获取小程序的第三方提交代码的页面配置”接口获得 - */ - private String address; - /** - * 小程序的标签,多个标签用空格分隔,标签不能多于10个,标签长度不超过20 - */ - private String tag; /** * 小程序页面的标题,标题长度不超过32 */ diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditPreviewInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditPreviewInfo.java new file mode 100644 index 0000000000..cdb8e7a510 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditPreviewInfo.java @@ -0,0 +1,35 @@ +package cn.binarywang.wx.miniapp.bean.code; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * @author binarywang + */ +@Data +@Accessors(chain = true) +public class WxMaCodeSubmitAuditPreviewInfo implements Serializable { + private static final long serialVersionUID = -3391652096859063951L; + + /** + * video_id_list + * String Array + * 否 + * 录屏mediaid列表,可以通过提审素材上传接口获得 + */ + @SerializedName("video_id_list") + private List videoIdList; + + /** + * pic_id_list + * String Array + * 否 + * 截屏mediaid列表,可以通过提审素材上传接口获得 + */ + @SerializedName("pic_id_list") + private List picIdList; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequest.java index ff245c8e6a..18bb79fb8a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequest.java @@ -6,6 +6,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; import java.io.Serializable; import java.util.List; @@ -20,15 +21,66 @@ @Builder @NoArgsConstructor @AllArgsConstructor +@Accessors(chain = true) public class WxMaCodeSubmitAuditRequest implements Serializable { private static final long serialVersionUID = 8854979405505241314L; + /** * 提交审核项的一个列表(至少填写1项,至多填写5项) */ @SerializedName("item_list") - private List itemList; + private List itemList; + + /** + * feedback_info String 否 反馈内容,至多 200 字 + */ + @SerializedName("feedback_info") + private String feedbackInfo; + + /** + * feedback_stuff String 否 用 | 分割的 media_id 列表,至多 5 张图片, 可以通过新增临时素材接口上传而得到 + */ + @SerializedName("feedback_stuff") + private String feedbackStuff; + + /** + * preview_info Object 否 预览信息(小程序页面截图和操作录屏) + */ + @SerializedName("preview_info") + private WxMaCodeSubmitAuditPreviewInfo previewInfo; + + /** + * version_desc + * String + * 否 + * 小程序版本说明和功能解释 + */ + @SerializedName("version_desc") + private String versionDesc; + + /** + * ugc_declare + * Object + * 否 + * 用户生成内容场景(UGC)信息安全声明 + */ + @SerializedName("ugc_declare") + private WxMaCodeSubmitAuditUgcDeclare ugcDeclare; + + /** + * 用于声明是否不使用“代码中检测出但是未配置的隐私相关接口” + */ + @SerializedName("privacy_api_not_use") + private Boolean privacyApiNotUse; + + /** + * 订单中心path + */ + @SerializedName("order_path") + private String orderPath; public String toJson() { return WxMaGsonBuilder.create().toJson(this); } + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditUgcDeclare.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditUgcDeclare.java new file mode 100644 index 0000000000..286f88acb5 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditUgcDeclare.java @@ -0,0 +1,61 @@ +package cn.binarywang.wx.miniapp.bean.code; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author binarywang + */ +@Data +@Accessors(chain = true) +public class WxMaCodeSubmitAuditUgcDeclare implements Serializable { + private static final long serialVersionUID = 201470564426848261L; + + /** + * scene + * Number Array + * 否 + * UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段 + */ + @SerializedName("scene") + private Integer[] scene; + + /** + * other_scene_desc + * String + * 否 + * 当scene选其他时的说明,不超时256字 + */ + @SerializedName("other_scene_desc") + private String otherSceneDesc; + + /** + * method + * Number Array + * 否 + * 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关 + */ + @SerializedName("method") + private Integer[] method; + + /** + * has_audit_team + * Number + * 否 + * 是否有审核团队, 0.无,1.有,默认0 + */ + @SerializedName("has_audit_team") + private Integer hasAuditTeam; + + /** + * audit_desc + * String + * 否 + * 说明当前对UGC内容的审核机制,不超过256字 + */ + @SerializedName("audit_desc") + private String auditDesc; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeVersionInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeVersionInfo.java new file mode 100644 index 0000000000..32999382fb --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeVersionInfo.java @@ -0,0 +1,91 @@ +package cn.binarywang.wx.miniapp.bean.code; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 查询小程序版本信息 + * + * @author LeonXi + * @since 2022-04-13 16:45 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WxMaCodeVersionInfo implements Serializable { + + private static final long serialVersionUID = 6929700728659511688L; + + /** + * 体验版信息 + */ + @SerializedName("exp_info") + private ExpInfo expInfo; + + /** + * 线上版信息 + */ + @SerializedName("release_info") + private ReleaseInfo releaseInfo; + + public static WxMaCodeVersionInfo fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WxMaCodeVersionInfo.class); + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class ExpInfo implements Serializable { + + private static final long serialVersionUID = 6315578419554592943L; + + /** + * 提交体验版的时间 + */ + @SerializedName("exp_time") + private Long expTime; + + /** + * 体验版版本信息 + */ + @SerializedName("exp_version") + private String expVersion; + + /** + * 体验版版本描述 + */ + @SerializedName("exp_desc") + private String expDesc; + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class ReleaseInfo implements Serializable { + + private static final long serialVersionUID = 2098307354673939939L; + + /** + * 发布线上版的时间 + */ + @SerializedName("release_time") + private Long releaseTime; + + /** + * 线上版版本信息 + */ + @SerializedName("release_version") + private String releaseVersion; + + /** + * 线上版本描述 + */ + @SerializedName("release_desc") + private String releaseDesc; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AbnormalConfirmRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AbnormalConfirmRequest.java new file mode 100644 index 0000000000..9855827082 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AbnormalConfirmRequest.java @@ -0,0 +1,43 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseRequest; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 微信小程序即时配送 异常件退回商家商家确认收货接口 请求参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class AbnormalConfirmRequest extends WxMaDeliveryBaseRequest implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 配送单id. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("waybill_id") + private String waybillId; + + /** + * 备注. + *
+     * 是否必填:否
+     * 
+ */ + @SerializedName("remark") + private String remark; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AbnormalConfirmResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AbnormalConfirmResponse.java new file mode 100644 index 0000000000..0f9fcc22ee --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AbnormalConfirmResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 微信小程序即时配送 异常件退回商家商家确认收货接口 响应参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class AbnormalConfirmResponse extends WxMaDeliveryBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AddOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AddOrderRequest.java new file mode 100644 index 0000000000..d9b5f5b576 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AddOrderRequest.java @@ -0,0 +1,639 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseRequest; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 微信小程序即时配送 下配送单接口 请求参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class AddOrderRequest extends WxMaDeliveryBaseRequest implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 子商户id,区分小程序内部多个子商户. + *
+     * 是否必填:否
+     * 
+ */ + @SerializedName("sub_biz_id") + private String subBizId; + + /** + * 发件人信息,顺丰同城急送必须填写,美团配送、达达、闪送,若传了shop_no的值可不填该字段. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("sender") + private Sender sender; + + /** + * 收件人信息. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("receiver") + private Receiver receiver; + + /** + * 货物信息. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("cargo") + private Cargo cargo; + + /** + * 订单信息. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("order_info") + private OrderInfo orderInfo; + + /** + * 商品信息,会展示到物流通知消息中. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("shop") + private Shop shop; + + /** + * 发件人信息. + */ + @Data + @Accessors(chain = true) + public static class Sender implements Serializable { + + private static final long serialVersionUID = -8101805250220380047L; + + /** + * 姓名,最长不超过256个字符. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("name") + private String name; + + /** + * 城市名称,如广州市. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("city") + private String city; + + /** + * 地址(街道、小区、大厦等,用于定位). + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("address") + private String address; + + /** + * 地址(街道、小区、大厦等,用于定位). + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("address_detail") + private String addressDetail; + + /** + * 坐标类型,默认 0:火星坐标(高德,腾讯地图均采用火星坐标) 1:百度坐标. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("coordinate_type") + private int coordinateType; + + /** + * 经度(火星坐标或百度坐标,和 coordinate_type 字段配合使用,确到小数点后6位. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("lng") + private BigDecimal lng; + + /** + * 纬度(火星坐标或百度坐标,和 coordinate_type 字段配合使用,精确到小数点后6位). + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("lat") + private BigDecimal lat; + + /** + * 电话/手机号,最长不超过64个字符. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("phone") + private String phone; + + } + + /** + * 收件人信息. + */ + @Data + @Accessors(chain = true) + public static class Receiver implements Serializable { + + private static final long serialVersionUID = -8101805250220380047L; + + /** + * 姓名,最长不超过256个字符. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("name") + private String name; + + /** + * 城市名称,如广州市. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("city") + private String city; + + /** + * 地址(街道、小区、大厦等,用于定位). + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("address") + private String address; + + /** + * 地址(街道、小区、大厦等,用于定位). + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("address_detail") + private String addressDetail; + + /** + * 坐标类型,默认 0:火星坐标(高德,腾讯地图均采用火星坐标) 1:百度坐标. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("coordinate_type") + private int coordinateType; + + /** + * 经度(火星坐标或百度坐标,和 coordinate_type 字段配合使用,确到小数点后6位. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("lng") + private BigDecimal lng; + + /** + * 纬度(火星坐标或百度坐标,和 coordinate_type 字段配合使用,精确到小数点后6位). + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("lat") + private BigDecimal lat; + + /** + * 电话/手机号,最长不超过64个字符. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("phone") + private String phone; + + } + + /** + * 商品信息. + */ + @Data + @Accessors(chain = true) + public static class Shop implements Serializable { + + private static final long serialVersionUID = -8958461649711388689L; + + /** + * 商品数量. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("goods_count") + private Integer goodsCount; + + /** + * 商品名称. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("goods_name") + private String goodsName; + + /** + * 商品缩略图 url. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("img_url") + private String imgUrl; + + /** + * 商家小程序的路径,建议为订单页面. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("wxa_path") + private String wxaPath; + + /** + * 若结算方式为:第三方向配送公司统一结算,商户后续和第三方结算,则该参数必填. + * 在该结算模式下,第三方用自己的开发小程序替授权商户发起下单,并将授权小程序的appid给平台,后续配送通知中可回流授权商户小程序. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("wxa_appid") + private String wxaAppid; + + } + + /** + * 订单信息. + */ + @Data + @Accessors(chain = true) + public static class OrderInfo implements Serializable { + + private static final long serialVersionUID = 5277759430030747900L; + + /** + * 配送服务代码 不同配送公司自定义, 顺丰和达达不填. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("delivery_service_code") + private String deliveryServiceCode; + + /** + * 订单类型, 0: 即时单 1 预约单,如预约单,需要设置expected_delivery_time或expected_finish_time或expected_pick_time. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("order_type") + private Integer orderType; + + /** + * 期望派单时间(达达支持,表示达达系统调度时间, 到那个时间才会有状态更新的回调通知),unix-timestamp, 比如1586342180. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("expected_delivery_time") + private Long expectedDeliveryTime; + + /** + * 期望送达时间(美团、顺丰同城急送支持),unix-timestamp, 比如1586342180. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("expected_finish_time") + private Long expectedFinishTime; + + /** + * 期望取件时间(闪送、顺丰同城急送支持,闪送需要设置两个小时后的时间,顺丰同城急送只需传expected_finish_time或expected_pick_time其中之一即可,同时都传则以expected_finish_time为准),unix-timestamp, 比如1586342180. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("expected_pick_time") + private Long expectedPickTime; + + /** + * 备注,最长不超过200个字符. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("note") + private String note; + + /** + * 门店订单流水号,建议提供,方便骑手门店取货,最长不超过32个字符. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("poi_seq") + private String poiSeq; + + /** + * 用户下单付款时间, 顺丰必填, 比如1555220757. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("order_time") + private Long orderTime; + + /** + * 是否保价,0:非保价,1:保价. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("is_insured") + private Integer isInsured; + + /** + * 保价金额,单位为元,精确到分. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("declared_value") + private BigDecimal declaredValue; + + /** + * 小费,单位为元, 下单一般不加小费. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("tips") + private Integer tips; + + /** + * 是否选择直拿直送(0:不需要;1:需要。选择直拿直送后,同一时间骑手只能配送此订单至完成,配送费用也相应高一些,闪送必须选1,达达可选0或1,其余配送公司不支持直拿直送). + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("is_direct_delivery") + private Integer isDirectDelivery; + + /** + * 骑手应付金额,单位为元,精确到分. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("cash_on_delivery") + private BigDecimal cashOnDelivery; + + /** + * 骑手应收金额,单位为元,精确到分. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("cash_on_pickup") + private BigDecimal cashOnPickup; + + /** + * 物流流向,1:从门店取件送至用户;2:从用户取件送至门店. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("rider_pick_method") + private Integer riderPickMethod; + + /** + * 收货码(0:不需要;1:需要。收货码的作用是:骑手必须输入收货码才能完成订单妥投). + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("is_finish_code_needed") + private Integer isFinishCodeNeeded; + + /** + * 取货码(0:不需要;1:需要。取货码的作用是:骑手必须输入取货码才能从商家取货). + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("is_pickup_code_needed") + private Integer isPickupCodeNeeded; + + } + + /** + * 货物信息. + */ + @NoArgsConstructor + @Data + @Accessors(chain = true) + public static class Cargo implements Serializable { + + private static final long serialVersionUID = -8339389045820636620L; + + /** + * 货物价格,单位为元,精确到小数点后两位(如果小数点后位数多于两位,则四舍五入保留两位小数),范围为(0-5000]. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("goods_value") + private BigDecimal goodsValue; + + /** + * 货物高度,单位为cm,精确到小数点后两位(如果小数点后位数多于两位,则四舍五入保留两位小数),范围为(0-45]. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("goods_height") + private BigDecimal goodsHeight; + + /** + * 货物长度,单位为cm,精确到小数点后两位(如果小数点后位数多于两位,则四舍五入保留两位小数),范围为(0-65]. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("goods_length") + private BigDecimal goodsLength; + + /** + * 货物宽度,单位为cm,精确到小数点后两位(如果小数点后位数多于两位,则四舍五入保留两位小数),范围为(0-50]. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("goods_width") + private BigDecimal goodsWidth; + + /** + * 货物重量,单位为kg,精确到小数点后两位(如果小数点后位数多于两位,则四舍五入保留两位小数),范围为(0-50]. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("goods_weight") + private BigDecimal goodsWeight; + + /** + * 货物详情,最长不超过10240个字符. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("goods_detail") + private GoodsDetail goodsDetail; + + /** + * 货物取货信息,用于骑手到店取货,最长不超过100个字符. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("goods_pickup_info") + private String goodsPickupInfo; + + /** + * 货物交付信息,最长不超过100个字符. + *
+         * 是否必填:否
+         * 
+ */ + @SerializedName("goods_delivery_info") + private String goodsDeliveryInfo; + + /** + * 品类一级类目, 详见品类表 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("cargo_first_class") + private String cargoFirstClass; + + /** + * 品类二级类目. + *
+         * 是否必填:是
+         * 
+ */ + @SerializedName("cargo_second_class") + private String cargoSecondClass; + + /** + * 货物详情. + */ + @Data + @Accessors(chain = true) + public static class GoodsDetail implements Serializable { + + private static final long serialVersionUID = -8339389045820636620L; + + /** + * 货物列表. + *
+             * 是否必填:是
+             * 
+ */ + @SerializedName("goods") + private List goods; + + /** + * 货物详情. + */ + @NoArgsConstructor + @Data + @Accessors(chain = true) + public static class Goods implements Serializable { + + private static final long serialVersionUID = -8339389045820636620L; + + /** + * 货物数量. + *
+                 * 是否必填:是
+                 * 
+ */ + @SerializedName("good_count") + private Integer goodCount; + + /** + * 货品名称. + *
+                 * 是否必填:是
+                 * 
+ */ + @SerializedName("good_name") + private String goodName; + + /** + * 货品单价,精确到小数点后两位(如果小数点后位数多于两位,则四舍五入保留两位小数). + *
+                 * 是否必填:否
+                 * 
+ */ + @SerializedName("good_price") + private BigDecimal goodPrice; + + /** + * 货品单位,最长不超过20个字符. + *
+                 * 是否必填:否
+                 * 
+ */ + @SerializedName("good_unit") + private String goodUnit; + + } + + } + + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AddOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AddOrderResponse.java new file mode 100644 index 0000000000..c954bdd80d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/AddOrderResponse.java @@ -0,0 +1,92 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 微信小程序即时配送 下配送单接口 响应参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class AddOrderResponse extends WxMaDeliveryBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 实际运费(单位:元),运费减去优惠券费用. + */ + @SerializedName("fee") + private BigDecimal fee; + + /** + * 运费(单位:元). + */ + @SerializedName("deliverfee") + private BigDecimal deliverFee; + + /** + * 优惠券费用(单位:元). + */ + @SerializedName("couponfee") + private BigDecimal couponFee; + + /** + * 小费(单位:元). + */ + @SerializedName("tips") + private BigDecimal tips; + + /** + * 保价费(单位:元). + */ + @SerializedName("insurancfee") + private BigDecimal insurancFee; + + /** + * 配送距离(整数单位:米). + */ + @SerializedName("distance") + private BigDecimal distance; + + /** + * 配送单号. + */ + @SerializedName("waybill_id") + private String waybillId; + + /** + * 配送状态. + */ + @SerializedName("order_status") + private Integer orderStatus; + + /** + * 收货码. + */ + @SerializedName("finish_code") + private Integer finishCode; + + /** + * 取货码. + */ + @SerializedName("pickup_code") + private Integer pickupCode; + + /** + * 预计骑手接单时间,单位秒,比如5分钟,就填300, 无法预计填0. + */ + @SerializedName("dispatch_duration") + private BigDecimal dispatchDuration; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/BindAccountResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/BindAccountResponse.java new file mode 100644 index 0000000000..8cad5e9234 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/BindAccountResponse.java @@ -0,0 +1,66 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信小程序即时配送 拉取已绑定账号 响应参数. + *
+ * 使用场景:
+ *      1.商家可通过本接口查询自己已经在小程序后台绑定的和配送公司签约的账号;
+ *      2.服务商可通过本接口查询代开发的小程序在小程序后台绑定的和配送公司签约的账号,为其完成后续的接口代开发业务;
+ * 
+ * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class BindAccountResponse extends WxMaDeliveryBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 店铺账号信息集合. + */ + @SerializedName("shop_list") + private List shopList; + + /** + * 店铺账号信息. + */ + @Data + @Accessors(chain = true) + public static class Shop implements Serializable { + + private static final long serialVersionUID = -3759074878713856529L; + + /** + * 配送公司Id. + */ + @SerializedName("delivery_id") + private String deliveryId; + + /** + * 商家id. + */ + @SerializedName("shopid") + private String shopId; + + /** + * 审核状态 0:审核通过、1:审核中、2:审核不通过. + */ + @SerializedName("audit_result") + private String auditResult; + + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/CancelOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/CancelOrderRequest.java new file mode 100644 index 0000000000..71183e9714 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/CancelOrderRequest.java @@ -0,0 +1,52 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseRequest; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 微信小程序即时配送 取消配送单接口 请求参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class CancelOrderRequest extends WxMaDeliveryBaseRequest implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 配送单id. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("waybill_id") + private String waybillId; + + /** + * 取消原因Id. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("cancel_reason_id") + private Integer cancelReasonId; + + /** + * 取消原因. + *
+     * 是否必填:否
+     * 
+ */ + @SerializedName("cancel_reason") + private String cancelReason; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/CancelOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/CancelOrderResponse.java new file mode 100644 index 0000000000..080c12c415 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/CancelOrderResponse.java @@ -0,0 +1,38 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 微信小程序即时配送 取消配送单接口 响应参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class CancelOrderResponse extends WxMaDeliveryBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 扣除的违约金(单位:元),精确到分. + */ + @SerializedName("deduct_fee") + private BigDecimal deductFee; + + /** + * 说明. + */ + @SerializedName("desc") + private String desc; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/FollowWaybillRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/FollowWaybillRequest.java new file mode 100644 index 0000000000..92add53aa2 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/FollowWaybillRequest.java @@ -0,0 +1,103 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + *
+ * 传运单接口 follow_waybil
+ *
+ * 商户使用此接口向微信提供某交易单号对应的运单号。微信后台会跟踪运单的状态变化,在关键物流节点给下单用户推送消息通知。
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class FollowWaybillRequest implements Serializable { + + private static final long serialVersionUID = -7538739003766268386L; + + + /** + * 用户openid + *
+   * 是否必填: 是
+   * 描述: 用户openid
+   * 
+ */ + @SerializedName("openid") + private String openid; + + /** + * 寄件人手机号 + *
+   * 是否必填: 否
+   * 描述:
+   * 
+ */ + @SerializedName("sender_phone") + private String senderPhone; + + /** + * 收件人手机号 + *
+   * 是否必填: 否
+   * 描述:部分运力需要用户手机号作为查单依据
+   * 
+ */ + @SerializedName("receiver_phone") + private String receiverPhone; + + /** + * 运单ID + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("waybill_id") + private String waybillId; + + /** + * 交易单号(微信支付生成的交易单号,一般以420开头) + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("trans_id") + private String transId; + + + /** + * 点击落地页商品卡片跳转路径(建议为订单详情页path),不传默认跳转小程序首页。 + *
+   * 是否必填: 否
+   * 
+ */ + @SerializedName("order_detail_path") + private String orderDetailPath; + + /** + * 商品信息 + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("goods_info") + private WaybillGoodsInfo goodsInfo; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/FollowWaybillResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/FollowWaybillResponse.java new file mode 100644 index 0000000000..748f9465aa --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/FollowWaybillResponse.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + *
+ * 查运单接口 query_follow_trace 响应参数
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Accessors(chain = true) +public class FollowWaybillResponse extends WxMaBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 查询id. + */ + @SerializedName("waybill_token") + private String waybillToken; + + + public static FollowWaybillResponse fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, FollowWaybillResponse.class); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetOrderRequest.java new file mode 100644 index 0000000000..e69a868607 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetOrderRequest.java @@ -0,0 +1,24 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 微信小程序即时配送 拉取配送单信息 请求参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class GetOrderRequest extends WxMaDeliveryBaseRequest implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetOrderResponse.java new file mode 100644 index 0000000000..4527630352 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetOrderResponse.java @@ -0,0 +1,68 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 微信小程序即时配送 拉取配送单信息 响应参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class GetOrderResponse extends WxMaDeliveryBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 配送状态. + */ + @SerializedName("order_status") + private Integer orderStatus; + + /** + * 配送单号. + */ + @SerializedName("waybill_id") + private String waybillId; + + /** + * 骑手姓名. + */ + @SerializedName("rider_name") + private String riderName; + + /** + * 骑手电话. + */ + @SerializedName("rider_phone") + private String riderPhone; + + /** + * 骑手位置经度, 配送中时返回. + */ + @SerializedName("rider_lng") + private BigDecimal riderLng; + + /** + * 骑手位置纬度, 配送中时返回. + */ + @SerializedName("rider_lat") + private BigDecimal riderLat; + + /** + * 预计还剩多久送达时间, 配送中时返回,单位秒, 已取货配送中需返回,比如5分钟后送达,填300. + */ + @SerializedName("reach_time") + private BigDecimal reachTime; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/MockUpdateOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/MockUpdateOrderRequest.java new file mode 100644 index 0000000000..9eeef27725 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/MockUpdateOrderRequest.java @@ -0,0 +1,58 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 微信小程序即时配送 模拟配送公司更新配送单状态 请求参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +public class MockUpdateOrderRequest implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 商家id, 必须是 "test_shop_id". + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("shopid") + private String shopId = "test_shop_id"; + + /** + * 唯一标识订单的 ID,由商户生成. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("shop_order_id") + private String shopOrderId; + + /** + * 状态变更时间点,Unix秒级时间戳. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("action_time") + private Long actionTime; + + /** + * 配送状态,枚举值. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("order_status") + private Integer orderStatus; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/MockUpdateOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/MockUpdateOrderResponse.java new file mode 100644 index 0000000000..388f9083f4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/MockUpdateOrderResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 微信小程序即时配送 模拟配送公司更新配送单状态 响应参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:49 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class MockUpdateOrderResponse extends WxMaDeliveryBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryFollowTraceRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryFollowTraceRequest.java new file mode 100644 index 0000000000..600ea0f14c --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryFollowTraceRequest.java @@ -0,0 +1,46 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + *
+ * 消息组件-查运单接口 query_follow_trace
+ *
+ * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class QueryFollowTraceRequest implements Serializable { + + private static final long serialVersionUID = -7538739003766268386L; + + + /** + * 查询id + *
+   * 是否必填: 是
+   * 描述: 可以从 传运单接口 follow_waybill 取数据
+   * 
+ */ + @SerializedName("waybill_token") + private String waybillToken; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryFollowTraceResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryFollowTraceResponse.java new file mode 100644 index 0000000000..a6e698d0df --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryFollowTraceResponse.java @@ -0,0 +1,123 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + *
+ * 消息组件-查运单接口 query_follow_trace 响应参数
+ *
+ * 商户在调用完follow_waybill/trace_waybill接口后,可以使用本接口查询到对应运单的详情信息
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Accessors(chain = true) +public class QueryFollowTraceResponse extends WxMaBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 运单信息. + */ + @SerializedName("waybill_info") + private WaybillInfo waybillInfo; + + /** + * 商品信息 + */ + @SerializedName("shop_info") + private ShopInfo shopInfo; + + /** + * 运力信息. + */ + @SerializedName("delivery_info") + private DeliveryInfo deliveryInfo; + + + public static QueryFollowTraceResponse fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, QueryFollowTraceResponse.class); + } + + /** + * 运单信息. + */ + @Data + @Accessors(chain = true) + public static class WaybillInfo implements Serializable { + + private static final long serialVersionUID = -3759074878713856529L; + + /** + * 运单状态 释义 + *
+     *
+     * 0	运单不存在或者未揽收
+     * 1	已揽件
+     * 2	运输中
+     * 3	派件中
+     * 4	已签收
+     * 5	异常
+     * 6	代签收
+     *
+     * 
+ */ + @SerializedName("status") + private Integer status; + + /** + * 查询id. + */ + @SerializedName("waybill_token") + private String waybillToken; + } + + /** + * 商品信息. + */ + @Data + @Accessors(chain = true) + public static class ShopInfo implements Serializable { + + private static final long serialVersionUID = -3759074878713856529L; + + /** + * 配送公司Id. + */ + @SerializedName("goods_info") + private WaybillGoodsInfo goodsInfo; + + + } + + + /** + * 运力信息. + */ + @Data + @Accessors(chain = true) + public static class DeliveryInfo implements Serializable { + + private static final long serialVersionUID = -3759074878713856529L; + + /** + * 配送公司Id. + */ + @SerializedName("delivery_id") + private String deliveryId; + + /** + * 运力公司名称. + */ + @SerializedName("delivery_name") + private String deliveryName; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryWaybillTraceRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryWaybillTraceRequest.java new file mode 100644 index 0000000000..b7069a8737 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryWaybillTraceRequest.java @@ -0,0 +1,46 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + *
+ * 查询运单接口 query_trace
+ *
+ * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class QueryWaybillTraceRequest implements Serializable { + + private static final long serialVersionUID = -7538739003766268386L; + + + /** + * 查询id + *
+   * 是否必填: 是
+   * 描述: 可以从 传运单接口 trace_waybill 取数据
+   * 
+ */ + @SerializedName("waybill_token") + private String waybillToken; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryWaybillTraceResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryWaybillTraceResponse.java new file mode 100644 index 0000000000..726705cf8d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/QueryWaybillTraceResponse.java @@ -0,0 +1,123 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + *
+ * 查询运单接口 query_trace 响应参数
+ *
+ * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Accessors(chain = true) +public class QueryWaybillTraceResponse extends WxMaBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 运单信息. + */ + @SerializedName("waybill_info") + private WaybillInfo waybillInfo; + + /** + * 商品信息 + */ + @SerializedName("shop_info") + private ShopInfo shopInfo; + + /** + * 运力信息. + */ + @SerializedName("delivery_info") + private DeliveryInfo deliveryInfo; + + + public static QueryWaybillTraceResponse fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, QueryWaybillTraceResponse.class); + } + + /** + * 运单信息. + */ + @Data + @Accessors(chain = true) + public static class WaybillInfo implements Serializable { + + private static final long serialVersionUID = -3759074878713856529L; + + /** + * 运单状态 释义 + *
+     *
+     * 0	运单不存在或者未揽收
+     * 1	已揽件
+     * 2	运输中
+     * 3	派件中
+     * 4	已签收
+     * 5	异常
+     * 6	代签收
+     *
+     * 
+ */ + @SerializedName("status") + private Integer status; + + /** + * 查询id. + */ + @SerializedName("waybill_token") + private String waybillToken; + } + + /** + * 商品信息. + */ + @Data + @Accessors(chain = true) + public static class ShopInfo implements Serializable { + + private static final long serialVersionUID = -3759074878713856529L; + + /** + * 配送公司Id. + */ + @SerializedName("goods_info") + private WaybillGoodsInfo goodsInfo; + + + } + + + /** + * 运力信息. + */ + @Data + @Accessors(chain = true) + public static class DeliveryInfo implements Serializable { + + private static final long serialVersionUID = -3759074878713856529L; + + /** + * 配送公司Id. + */ + @SerializedName("delivery_id") + private String deliveryId; + + /** + * 运力公司名称. + */ + @SerializedName("delivery_name") + private String deliveryName; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java new file mode 100644 index 0000000000..0f929956a2 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java @@ -0,0 +1,101 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + *
+ * 传运单接口 trace_waybill
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class TraceWaybillRequest implements Serializable { + + private static final long serialVersionUID = -7538739003766268386L; + + + /** + * 用户openid + *
+   * 是否必填: 是
+   * 描述: 用户openid
+   * 
+ */ + @SerializedName("openid") + private String openid; + + /** + * 寄件人手机号 + *
+   * 是否必填: 否
+   * 描述:
+   * 
+ */ + @SerializedName("sender_phone") + private String senderPhone; + + /** + * 收件人手机号 + *
+   * 是否必填: 否
+   * 描述:部分运力需要用户手机号作为查单依据
+   * 
+ */ + @SerializedName("receiver_phone") + private String receiverPhone; + + /** + * 运单ID + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("waybill_id") + private String waybillId; + + /** + * 交易单号(微信支付生成的交易单号,一般以420开头) + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("trans_id") + private String transId; + + + /** + * 点击落地页商品卡片跳转路径(建议为订单详情页path),不传默认跳转小程序首页。 + *
+   * 是否必填: 否
+   * 
+ */ + @SerializedName("order_detail_path") + private String orderDetailPath; + + /** + * 商品信息 + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("goods_info") + private WaybillGoodsInfo goodsInfo; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillResponse.java new file mode 100644 index 0000000000..836e51ba07 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillResponse.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + *
+ * 传运单接口 trace_waybill 响应参数
+ * 
+ * + * @author boris + * @since 2022-04-01 + */ +@Data +@Accessors(chain = true) +public class TraceWaybillResponse extends WxMaBaseResponse implements Serializable { + + private static final long serialVersionUID = 3773007367000633663L; + + /** + * 查询id. + */ + @SerializedName("waybill_token") + private String waybillToken; + + + public static TraceWaybillResponse fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, TraceWaybillResponse.class); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java new file mode 100644 index 0000000000..8695efec1a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java @@ -0,0 +1,59 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 运单商品信息 + * + * @author boris + * @since 2022-04-01 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WaybillGoodsInfo implements Serializable { + + private static final long serialVersionUID = 5643624677715536605L; + + + + /** + * 商品信息 + */ + @SerializedName("detail_list") + private List goodsItemList; + + public static WaybillGoodsInfo fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WaybillGoodsInfo.class); + } + + @Data + public static class GoodsItem { + + /** + * 商品名称 + *
+     * 是否必填: 是
+     * 
+ */ + @SerializedName("goods_name") + private String goodsName; + + /** + * 商品图片URL + *
+     * 是否必填: 是
+     * 
+ */ + @SerializedName("goods_img_url") + private String goodsImgUrl; + + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/base/WxMaDeliveryBaseRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/base/WxMaDeliveryBaseRequest.java new file mode 100644 index 0000000000..6d964dcd03 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/base/WxMaDeliveryBaseRequest.java @@ -0,0 +1,120 @@ +package cn.binarywang.wx.miniapp.bean.delivery.base; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import lombok.AccessLevel; +import lombok.Data; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * 微信小程序 即时配送 基础请求参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:36 + */ +@Data +@Accessors(chain = true) +public abstract class WxMaDeliveryBaseRequest implements Serializable { + + private static final long serialVersionUID = -6811550517417623460L; + + /** + * 配送公司ID. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("delivery_id") + private String deliveryId; + + /** + * 唯一标识订单的 ID,由商户生成, 不超过 128 字节. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("shop_order_id") + private String shopOrderId; + + /** + * 下单用户的openid. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("openid") + private String openid; + + /** + * 商家门店编号,在配送公司登记,如果只有一个门店,美团闪送必填, 值为店铺id. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("shop_no") + private String shopNo; + + /** + * 商家id,由配送公司分配的appKey. + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("shopid") + private String shopId; + + /** + * 用配送公司提供的appSecret加密的校验串. + *
+     * 除了平台本身的加解密和签名,和订单相关的请求还需要带上运力侧签名delivery_sign,签名规则为
+     * 如果接口请求里有字段shop_order_id ,则delivery_sign=SHA1(shopid + shop_order_id + AppSecret),其中shopid对应运力侧的appkey,shop_order_id对应订单id,AppSecret即配送公司帐号对应的秘钥
+     * 如果请求里没有字段shop_order_id ,则delivery_sign=SHA1(shopid + AppSecret),其中shopid对应运力侧的appkey,AppSecret即配送公司帐号对应的秘钥
+     * 示例:shopid=“test_shop_id”,shop_order_id =“test_shop_order_id”, AppSecret=“test_app_secrect”,则delivery_sign=“a93d8d6bae9a9483c1b1d4e8670e7f6226ec94cb”
+     * 是否必填:是
+     * 
+ */ + @Setter(AccessLevel.NONE) + @SerializedName("delivery_sign") + private String deliverySign; + + /** + * 配送公司分配的appSecret. + *
+     * 是否必填:是
+     * 
+ */ + @Expose + private String appSecret; + + /** + * 获取签名. + *
+     * 除了平台本身的加解密和签名,和订单相关的请求还需要带上运力侧签名delivery_sign,签名规则为
+     * 如果接口请求里有字段shop_order_id ,则delivery_sign=SHA1(shopid + shop_order_id + AppSecret),其中shopid对应运力侧的appkey,shop_order_id对应订单id,AppSecret即配送公司帐号对应的秘钥
+     * 如果请求里没有字段shop_order_id ,则delivery_sign=SHA1(shopid + AppSecret),其中shopid对应运力侧的appkey,AppSecret即配送公司帐号对应的秘钥
+     * 示例:shopid=“test_shop_id”,shop_order_id =“test_shop_order_id”, AppSecret=“test_app_secrect”,则delivery_sign=“a93d8d6bae9a9483c1b1d4e8670e7f6226ec94cb”
+     * 是否必填:是
+     * 
+ * + * @return 结果 + */ + public String getDeliverySign() { + if (StringUtils.isBlank(getShopId()) || StringUtils.isBlank(getAppSecret())) { + throw new RuntimeException("shopId or appSecret can not be empty"); + } + String str = getShopId(); + if (StringUtils.isNotBlank(getShopOrderId())) { + str = str.concat(getShopOrderId()); + } + str = str.concat(getAppSecret()); + this.deliverySign = DigestUtils.sha1Hex(str); + return this.deliverySign; + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/base/WxMaDeliveryBaseResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/base/WxMaDeliveryBaseResponse.java new file mode 100644 index 0000000000..7278c83f69 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/base/WxMaDeliveryBaseResponse.java @@ -0,0 +1,66 @@ +package cn.binarywang.wx.miniapp.bean.delivery.base; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +/** + * 微信小程序 即时配送 基础响应参数. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 10:36 + */ +@Data +@Accessors(chain = true) +public abstract class WxMaDeliveryBaseResponse implements Serializable { + + private static final long serialVersionUID = -6811550517417623460L; + + /** + * 成功状态码. + */ + private static final int SUCCESS_CODE = 0; + + /** + * 运力返回的错误码. + */ + @SerializedName("resultcode") + private Integer resultCode; + + /** + * 运力返回的错误描述. + */ + @SerializedName("resultmsg") + private String resultMsg; + + /** + * 是否响应成功. + * + * @return true:成功、false:失败 + */ + public boolean success() { + return SUCCESS_CODE == getResultCode(); + } + + /** + * 解析响应. + * + * @param json 响应内容 + * @param valueType 类型 + * @param 类型 + * @return 结果 + */ + public static T fromJson(final String json, final Class valueType) { + if (StringUtils.isBlank(json)) { + throw new RuntimeException("the json cannot be empty"); + } + // 解析成对应响应对象 + return WxMaGsonBuilder.create().fromJson(json, valueType); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/device/WxMaDeviceSubscribeMessageRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/device/WxMaDeviceSubscribeMessageRequest.java new file mode 100644 index 0000000000..7ff7ec2537 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/device/WxMaDeviceSubscribeMessageRequest.java @@ -0,0 +1,78 @@ +package cn.binarywang.wx.miniapp.bean.device; + +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; +import java.util.List; + +/** + * 小程序设备订阅消息请求参数 + * + * @author JCLee + * @since 2021-12-16 17:13:22 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaDeviceSubscribeMessageRequest implements Serializable { + + private static final long serialVersionUID = -7973228178407991299L; + + /** + * 接收者(用户)的 openid列表. + */ + @SerializedName("to_openid_list") + private List toOpenidList; + + /** + * 下发通知的设备唯⼀序列号。由⼚商⽣成 + */ + @SerializedName("sn") + private String sn; + + /** + * 所需下发的消息模板ID + */ + @SerializedName("template_id") + private String templateId; + + /** + * 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转. + */ + @SerializedName("page") + private String page; + + /** + * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版. + */ + @SerializedName("miniprogram_state") + private String miniprogramState; + + /** + * 设备型号 id ,通过注册设备获得。 + */ + @SerializedName("modelId") + private String modelId; + + /** + * 进入小程序查看”的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN. + */ + @SerializedName("lang") + private String lang; + + /** + * 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }. + */ + @SerializedName("data") + private Object data; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/device/WxMaDeviceTicketRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/device/WxMaDeviceTicketRequest.java new file mode 100644 index 0000000000..c3319eecde --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/device/WxMaDeviceTicketRequest.java @@ -0,0 +1,41 @@ +package cn.binarywang.wx.miniapp.bean.device; + +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; + +/** + * 小程序设备ticket请求参数 + * + * @author JCLee + * @since 2021-12-16 17:13:28 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaDeviceTicketRequest implements Serializable { + private static final long serialVersionUID = -2152114813101871295L; + + /** + * 设备型号id。通过注册设备获得(必填) + * + */ + @SerializedName("model_id") + private String modelId; + + /** + * 设备唯⼀序列号。由⼚商分配。⻓度不能超过128字节。字符只接受数字与⼤⼩写字⺟(必填) + */ + @SerializedName("sn") + private String sn; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressDeliveryReturnAddRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressDeliveryReturnAddRequest.java new file mode 100644 index 0000000000..9b5caa0be9 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressDeliveryReturnAddRequest.java @@ -0,0 +1,93 @@ +package cn.binarywang.wx.miniapp.bean.express.request; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 创建退货ID + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WxMaExpressDeliveryReturnAddRequest implements Serializable { + private static final long serialVersionUID = -9111430627246688840L; + + /** + * 商家内部使用的退货编号 + *
+   * 是否必填: 是
+   * 描述:
+   * 
+ */ + @SerializedName("shop_order_id") + private String shopOrderId; + + /** + * 商家退货地址 + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("biz_addr") + private WxMaExpressOrderPerson bizAddr; + + /** + * 用户购物时的收货地址 + *
+   * 是否必填: 否
+   * 
+ */ + @SerializedName("user_addr") + private WxMaExpressOrderPerson userAddr; + + /** + * 退货用户的openid + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("openid") + private String openid; + + + /** + * 退货订单在小程序中的path + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("order_path") + private String orderPath; + + /** + * 退货订单的金额(单位:分) + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("goods_list") + private List goodsList; + + + /** + * 退货订单的金额(单位:分) + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("order_price") + private Integer orderPrice; + + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderShop.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderShop.java index 41c08f9e8e..029f0d44b7 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderShop.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderShop.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import java.io.Serializable; +import java.util.List; /** * 商品信息对象 @@ -55,4 +56,14 @@ public class WxMaExpressOrderShop implements Serializable { @SerializedName("goods_count") private Integer goodsCount; + /** + * 商品详情列表 + *
+   * 是否必填: 否
+   * 描述: 适配多商品场景,用以消息落地页展示。(新规范,新接入商家建议用此字段)
+   * 
+ */ + @SerializedName("detail_list") + private List detailList; + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderShopDetail.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderShopDetail.java new file mode 100644 index 0000000000..638bca6ddc --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderShopDetail.java @@ -0,0 +1,51 @@ +package cn.binarywang.wx.miniapp.bean.express.request; + + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + + +/** + * 商品详情 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WxMaExpressOrderShopDetail implements Serializable { + + private static final long serialVersionUID = 5988620921216969796L; + + /** + * 商品名称 + *
+   * 是否必填: 否
+   * 描述: 最多40汉字
+   * 
+ */ + @SerializedName("goods_name") + private String goodsName; + + /** + * 商品图片url + *
+   * 是否必填: 否
+   * 
+ */ + @SerializedName("goods_img_url") + private String goodsImgUrl; + + /** + * 商品详情描述 + *
+   * 是否必填: 否
+   * 描述: 最多40汉字
+   * 
+ */ + @SerializedName("goods_desc") + private String goodsDesc; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressReturnOrder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressReturnOrder.java new file mode 100644 index 0000000000..a6558beaeb --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressReturnOrder.java @@ -0,0 +1,40 @@ +package cn.binarywang.wx.miniapp.bean.express.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 退货商品对象 + * @author xiaoyu + * @since 2019-11-26 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WxMaExpressReturnOrder implements Serializable { + private static final long serialVersionUID = -7798434835843377474L; + + /** + * 商品名称 + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("name") + private String name; + + /** + * 商品缩略图url + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("url") + private String url; + + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressInfoResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressInfoResult.java new file mode 100644 index 0000000000..9819c10d01 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressInfoResult.java @@ -0,0 +1,19 @@ +package cn.binarywang.wx.miniapp.bean.express.result; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; + +public class WxMaExpressInfoResult { + /** + * 错误码 + */ + private Integer errcode; + + /** + * 错误信息 + */ + private String errmsg; + + public static WxMaExpressInfoResult fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WxMaExpressInfoResult.class); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressOrderInfoResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressOrderInfoResult.java index 9502eee826..275c2d093b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressOrderInfoResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressOrderInfoResult.java @@ -23,19 +23,10 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class WxMaExpressOrderInfoResult implements Serializable { +public class WxMaExpressOrderInfoResult extends WxMaExpressInfoResult implements Serializable { private static final long serialVersionUID = -9166603059965942285L; - /** - * 错误码 - */ - private Integer errcode; - - /** - * 错误信息 - */ - private String errmsg; /** * 订单ID */ diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressReturnInfoResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressReturnInfoResult.java new file mode 100644 index 0000000000..e97c03b6de --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/result/WxMaExpressReturnInfoResult.java @@ -0,0 +1,68 @@ +package cn.binarywang.wx.miniapp.bean.express.result; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 运单信息返回结果对象
+ * 
+ * @author xiaoyu + * @since 2019-11-26 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WxMaExpressReturnInfoResult extends WxMaExpressInfoResult implements Serializable { + + private static final long serialVersionUID = -9166603059965942285L; + + /** + * 退货ID + */ + @SerializedName("return_id") + private String returnId; + + + /** + * 0 用户未填写退货信息, 1. 在线预约, 2. 自主填写 + */ + private String status; + + + /** + * 运单ID + */ + @SerializedName("waybill_id") + private String waybillId; + + /** + * //0› 已下单待揽件 1› 已揽件 2› 运输中 3› 派件中 4› 已签收 5› 异常 6› 代签收 7› 揽收失败 8› 签收失败(拒收,超区) 11› 已取消 13› 退件中 14› 已退件 99 未知 + */ + @SerializedName("order_status") + private String orderStatus; + + /** + * //运力公司名称 + */ + @SerializedName("delivery_name") + private String deliveryName; + + /** + * //运力公司名称 + */ + @SerializedName("delivery_id") + private String deliveryId; + + + + public static WxMaExpressReturnInfoResult fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WxMaExpressReturnInfoResult.class); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaAssistantResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaAssistantResult.java index b508b2e09d..d905bcc89a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaAssistantResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaAssistantResult.java @@ -8,6 +8,8 @@ /** * 直播间小助手用户信息 + * + * @author GaoMinZhu */ @Data public class WxMaAssistantResult implements Serializable { @@ -22,6 +24,7 @@ public class WxMaAssistantResult implements Serializable { public static WxMaAssistantResult fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaAssistantResult.class); } + @Data public static class Assistant implements Serializable { private static final long serialVersionUID = 6362128855371134033L; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaCreateRoomResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaCreateRoomResult.java index 56b4eb7251..4f1e315a65 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaCreateRoomResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaCreateRoomResult.java @@ -9,7 +9,7 @@ * 创建直播间接口返回. * * @author Binary Wang - * @date 2020-11-29 + * created on 2020-11-29 */ @Data public class WxMaCreateRoomResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveAssistantInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveAssistantInfo.java index bfd727ca82..0b800e249a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveAssistantInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveAssistantInfo.java @@ -6,6 +6,8 @@ /** * 直播间小助手用户信息 + * + * @author GaoMinZhu */ @Data public class WxMaLiveAssistantInfo implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java index 4a63ff7a48..e416650863 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java @@ -4,9 +4,12 @@ import java.io.Serializable; import java.math.BigDecimal; +import java.util.List; /** * 直播商品信息 + * + * @author unkown */ @Data public class WxMaLiveGoodInfo implements Serializable { @@ -22,4 +25,14 @@ public class WxMaLiveGoodInfo implements Serializable { * 1, 2:表示是为api添加商品,否则是在MP添加商品 */ private String thirdPartyTag; + /** + * see here + */ + private List goodsKey; + + + /** + * 当商品为第三方小程序的商品则填写为对应第三方小程序的appid,自身小程序商品则为'' + */ + private String thirdPartyAppid; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java index 7d880ecc89..40e649dc32 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java @@ -20,7 +20,7 @@ public class WxMaLiveResult implements Serializable { private static final long serialVersionUID = 1L; private Integer total; - private Integer auditId; + private Long auditId; private Integer goodsId; private List goods; @@ -74,6 +74,11 @@ public static class Goods implements Serializable { */ @SerializedName("third_party_tag") private String thirdPartyTag; + + /** + * 当商品为第三方小程序的商品则填写为对应第三方小程序的appid,自身小程序商品则为'' + */ + private String thirdPartyAppid; } /** diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveRoomInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveRoomInfo.java index 75f445fe2f..8f560bfa54 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveRoomInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveRoomInfo.java @@ -6,6 +6,8 @@ /** * 直播间信息 + * + * @author unkown */ @Data public class WxMaLiveRoomInfo implements Serializable { @@ -20,7 +22,9 @@ public class WxMaLiveRoomInfo implements Serializable { **/ private String name; /** - * 背景图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;直播间背景图,图片规则:建议像素1080*1920,大小不超过2M + * 背景图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取, + * 请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html; + * 直播间背景图,图片规则:建议像素1080*1920,大小不超过2M **/ private String coverImg; /** @@ -36,11 +40,13 @@ public class WxMaLiveRoomInfo implements Serializable { **/ private String anchorName; /** - * 主播微信号,如果未实名认证,需要先前往“小程序直播”小程序进行实名验证, 小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr + * 主播微信号,如果未实名认证,需要先前往“小程序直播”小程序进行实名验证, + * 小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr **/ private String anchorWechat; /** - * 主播副号微信号,如果未实名认证,需要先前往“小程序直播”小程序进行实名验证, 小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr + * 主播副号微信号,如果未实名认证,需要先前往“小程序直播”小程序进行实名验证, + * 小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr **/ private String subAnchorWechat; /** @@ -48,20 +54,30 @@ public class WxMaLiveRoomInfo implements Serializable { **/ private String createrWechat; /** - * 分享图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;直播间分享图,图片规则:建议像素800*640,大小不超过1M; + * 分享图,填入mediaID(mediaID获取后,三天内有效); + * 图片mediaID的获取,请参考以下文档: + * https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html; + * 直播间分享图,图片规则:建议像素800*640,大小不超过1M; **/ private String shareImg; /** - * 购物直播频道封面图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html; 购物直播频道封面图,图片规则:建议像素800*800,大小不超过100KB; + * 购物直播频道封面图,填入mediaID(mediaID获取后,三天内有效); + * 图片mediaID的获取,请参考以下文档: + * https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html; + * 购物直播频道封面图,图片规则:建议像素800*800,大小不超过100KB; *

- * 该字段仅用于编辑直播间,不用于创建直播间 + * 该字段仅用于 + * 编辑直播间,不用于创建直播间 *

**/ private String feedsImg; /** - * 直播间分享图,填入mediaID(mediaID获取后,三天内有效);图片规则:建议像素1080*1920,大小不超过2M;图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html; + * 直播间分享图,填入mediaID(mediaID获取后,三天内有效);图片规则:建议像素1080*1920,大小不超过2M; + * 图片mediaID的获取,请参考以下文档: + * https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html; *

- * 该字段仅用于创建直播间,不用于编辑直播间 + * 该字段仅用于 + * 创建直播间,不用于编辑直播间 *

**/ private String anchorImg; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveSharedCode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveSharedCode.java new file mode 100644 index 0000000000..0a7c4e36eb --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveSharedCode.java @@ -0,0 +1,29 @@ +package cn.binarywang.wx.miniapp.bean.live; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author linlinjava + */ +@Data +public class WxMaLiveSharedCode implements Serializable { + private static final long serialVersionUID = 8525117884393611947L; + /** + * 分享二维码 + */ + @SerializedName("cdnUrl") + private String cdnUrl; + /** + * 分享路径 + */ + @SerializedName("pagePath") + private String pagePath; + /** + * 分享海报 + */ + @SerializedName("posterUrl") + private String posterUrl; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/marketing/WxMaUserAction.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/marketing/WxMaUserAction.java new file mode 100644 index 0000000000..b731e1e729 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/marketing/WxMaUserAction.java @@ -0,0 +1,74 @@ +package cn.binarywang.wx.miniapp.bean.marketing; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信营销接口 + * + * @author 184759547 + * @since : 2021/12/28 + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class WxMaUserAction implements Serializable { + private static final long serialVersionUID = 7482378011709983616L; + private String url; + private Integer actionTime; + private String actionType; + private String leadsType; + private String clickId; + private Integer actionParam; + + private JsonObject toJsonObject() { + JsonObject json = new JsonObject(); + json.addProperty("url", this.url); + json.addProperty("action_time", this.actionTime); + json.addProperty("action_type", this.actionType); + + if (this.clickId != null) { + JsonObject traceJson = new JsonObject(); + traceJson.addProperty("click_id", this.clickId); + json.add("trace", traceJson); + } + + if (this.actionParam != null) { + JsonObject actionParamJson = new JsonObject(); + actionParamJson.addProperty("value", actionParam); + if (this.leadsType != null) { + actionParamJson.addProperty("leads_type", leadsType); + } + json.add("action_param", actionParamJson); + } + + return json; + } + + /** + * list对象转换为json字符串 + * + * @param actions . + * @return . + */ + public static String listToJson(List actions, Long userActionSetId) { + JsonArray array = new JsonArray(); + for (WxMaUserAction action : actions) { + array.add(action.toJsonObject()); + } + + JsonObject result = new JsonObject(); + result.addProperty("user_action_set_id", userActionSetId); + result.add("actions", array); + return result.toString(); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/openapi/WxMiniGetApiQuotaResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/openapi/WxMiniGetApiQuotaResult.java new file mode 100644 index 0000000000..be02f68395 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/openapi/WxMiniGetApiQuotaResult.java @@ -0,0 +1,28 @@ +package cn.binarywang.wx.miniapp.bean.openapi; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * 查询API调用额度 返回数据 + * + * @author shuiyihan12 + * @since 2023/7/10 16:52 + */ +@Data +public class WxMiniGetApiQuotaResult { + + /** + * 当天该账号可调用该接口的次数 + */ + @SerializedName("daily_limit") + private Integer dailyLimit; + /** + * 当天已经调用的次数 + */ + private Integer used; + /** + * 当天剩余调用次数 + */ + private Integer remain; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/openapi/WxMiniGetRidInfoResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/openapi/WxMiniGetRidInfoResult.java new file mode 100644 index 0000000000..d0dabe1c60 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/openapi/WxMiniGetRidInfoResult.java @@ -0,0 +1,44 @@ +package cn.binarywang.wx.miniapp.bean.openapi; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * 查询rid信息 返回数据 + * @author shuiyihan12 + * @since 2023/7/10 16:53 + */ +@Data +public class WxMiniGetRidInfoResult { + + /** + * 发起请求的时间戳 + */ + @SerializedName("invoke_time") + private Integer invokeTime; + /** + * 请求毫秒级耗时 + */ + @SerializedName("cost_in_ms") + private Integer costInMs; + /** + * 请求的URL参数 + */ + @SerializedName("request_url") + private String requestUrl; + /** + * post请求的请求参数 + */ + @SerializedName("request_body") + private String requestBody; + /** + * 接口请求返回参数 + */ + @SerializedName("response_body") + private String responseBody; + /** + * 接口请求的客户端ip + */ + @SerializedName("client_ip") + private String clientIp; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/MinishopShopCat.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/MinishopShopCat.java new file mode 100644 index 0000000000..54015f2ed1 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/MinishopShopCat.java @@ -0,0 +1,23 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * 店铺的商品分类 + */ +@Data +public class MinishopShopCat implements Serializable { + private static final long serialVersionUID = 4179473856929659641L; + + @SerializedName("cat_id") + private Integer shopCatId; + + private String shopCatName; + + private Integer fShopCatId; + + @SerializedName("level") + private Integer catLevel; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniAfterSaleDetail.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniAfterSaleDetail.java new file mode 100644 index 0000000000..9ae66a8b5a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniAfterSaleDetail.java @@ -0,0 +1,24 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 7:16 下午 + */ +@Data +public class WxMiniAfterSaleDetail { + @SerializedName("aftersale_order_list") + private List aftersaleOrderList; + @SerializedName("on_aftersale_order_cnt") + private Integer onAftersaleOrderCnt; + + @Data + public static class AfterSaleOrder { + @SerializedName("aftersale_order_id") + private Long aftersaleOrderId; + private Integer status; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniAfterSaleOrder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniAfterSaleOrder.java new file mode 100644 index 0000000000..d4c87416af --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniAfterSaleOrder.java @@ -0,0 +1,95 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/11 20:33 + */ +@Data +public class WxMiniAfterSaleOrder { + @SerializedName("order_id") + private Long orderId; + @SerializedName("status") + private String status; + @SerializedName("openid") + private String openid; + @SerializedName("original_order_id") + private Long originalOrderId; + @SerializedName("product_info") + private AfterSaleProductInfo productInfo; + + private AfterSaleDetails details; + @SerializedName("refund_info") + private RefundInfo refundInfo; + @SerializedName("return_info") + private ReturnInfo returnInfo; + @SerializedName("merchant_upload_info") + private MerchantUploadInfo merchantUploadInfo; + @SerializedName("create_time") + private Long createTime; + @SerializedName("update_time") + private Long updateTime; + @SerializedName("reason") + private String reason; + @SerializedName("refund_resp") + private RefundResp refundResp; + private String type; + + @Data + public static class AfterSaleProductInfo { + @SerializedName("product_id") + private Long productId; + @SerializedName("sku_id") + private Long skuId; + @SerializedName("count") + private Integer count; + } + + @Data + public static class AfterSaleDetails { + + @SerializedName("num") + private Integer num; + @SerializedName("desc") + private String desc; + @SerializedName("cancel_time") + private Long cancelTime; + @SerializedName("prove_imgs") + private List proveImgs; + @SerializedName("tel_number") + private String telNumber; + } + + @Data + public static class RefundInfo { + private Long amount; + } + + @Data + public static class ReturnInfo { + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("waybill_id") + private String waybillId; + @SerializedName("delivery_name") + private String deliveryName; + } + + @Data + public static class MerchantUploadInfo { + @SerializedName("reject_reason") + private String rejectReason; + @SerializedName("refund_certificates") + private List refundCertificates; + } + + @Data + public static class RefundResp { + private String code; + private Integer ret; + private String message; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniBatchGetAfterSaleOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniBatchGetAfterSaleOrderResponse.java new file mode 100644 index 0000000000..a56c1ab331 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniBatchGetAfterSaleOrderResponse.java @@ -0,0 +1,16 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/11 20:59 + */ +@Data +public class WxMiniBatchGetAfterSaleOrderResponse extends WxMaShopBaseResponse { + @SerializedName("after_sale_order_list") + private List afterSaleOrderList; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniGetAfterSaleOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniGetAfterSaleOrderResponse.java new file mode 100644 index 0000000000..3a32d7b35e --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniGetAfterSaleOrderResponse.java @@ -0,0 +1,15 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/11 20:58 + */ +@Data +public class WxMiniGetAfterSaleOrderResponse extends WxMaShopBaseResponse { + @SerializedName("after_sale_order") + private WxMiniAfterSaleOrder afterSaleOrder; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniOrderAfterSaleDetail.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniOrderAfterSaleDetail.java new file mode 100644 index 0000000000..2368645f1d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniOrderAfterSaleDetail.java @@ -0,0 +1,24 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 7:16 下午 + */ +@Data +public class WxMiniOrderAfterSaleDetail { + @SerializedName("aftersale_order_list") + private List aftersaleOrderList; + @SerializedName("on_aftersale_order_cnt") + private Integer onAftersaleOrderCnt; + + @Data + public static class AfterSaleOrder { + @SerializedName("aftersale_order_id") + private Long aftersaleOrderId; + private Integer status; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniOrderDeliveryRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniOrderDeliveryRequest.java new file mode 100644 index 0000000000..f6e8924be7 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMiniOrderDeliveryRequest.java @@ -0,0 +1,41 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/14 19:05 + */ +@Data +public class WxMiniOrderDeliveryRequest { + @SerializedName("order_id") + private Long orderId; + @SerializedName("delivery_list") + private List deliveryList; + + @Data + public static class DeliveryListBean implements Serializable { + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("is_all_product") + private Boolean isAllProduct; + @SerializedName("waybill_id") + private String waybillId; + @SerializedName("product_infos") + private List productInfoList; + } + + @Data + public static class ProductInfosBean implements Serializable { + + @SerializedName("product_id") + private String productId; + @SerializedName("sku_id") + private String skuId; + @SerializedName("product_cnt") + private Integer productCnt; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddGoodsSkuData.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddGoodsSkuData.java new file mode 100644 index 0000000000..6645140787 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddGoodsSkuData.java @@ -0,0 +1,16 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +@Data +public class WxMinishopAddGoodsSkuData implements Serializable { + private static final long serialVersionUID = -2596988603027040989L; + @SerializedName("sku_id") + private Long skuId; + @SerializedName("out_sku_id") + private String outSkuId; + @SerializedName("create_time") + private String createTime; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddGoodsSpuData.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddGoodsSpuData.java new file mode 100644 index 0000000000..bf9bb5c757 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddGoodsSpuData.java @@ -0,0 +1,16 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class WxMinishopAddGoodsSpuData implements Serializable { + private static final long serialVersionUID = 2023708625713948192L; + private Long productId; + + private String outProductId; + + private String createTime; + + private String updateTime; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddressInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddressInfo.java new file mode 100644 index 0000000000..df22488f9b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopAddressInfo.java @@ -0,0 +1,28 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 7:32 下午 + */ +@Data +public class WxMinishopAddressInfo { + @SerializedName("user_name") + private String userName; + @SerializedName("postal_code") + private String postalCode; + @SerializedName("province_name") + private String provinceName; + @SerializedName("city_name") + private String cityName; + @SerializedName("county_name") + private String countyName; + @SerializedName("detail_info") + private String detailInfo; + @SerializedName("national_code") + private String nationalCode; + @SerializedName("tel_number") + private String telNumber; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopDeliveryCompany.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopDeliveryCompany.java new file mode 100644 index 0000000000..7534a94553 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopDeliveryCompany.java @@ -0,0 +1,12 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class WxMinishopDeliveryCompany implements Serializable { + private static final long serialVersionUID = 3736970376549639779L; + private String deliveryId; + + private String deliveryName; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopDeliveryInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopDeliveryInfo.java new file mode 100644 index 0000000000..95c1385c7c --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopDeliveryInfo.java @@ -0,0 +1,62 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 7:28 下午 + */ +@Data +public class WxMinishopDeliveryInfo { + @SerializedName("address_info") + private WxMinishopAddressInfo addressInfo; + @SerializedName("delivery_method") + private String deliveryMethod; + @SerializedName("delivery_product_info") + private List deliveryProductInfo; + @SerializedName("ship_done_time") + private Long shipDoneTime; + @SerializedName("insurance_info") + private InsuranceInfo insuranceInfo; + @SerializedName("deliver_type") + private String deliverType; + @SerializedName("offline_delivery_time") + private Long offlineDeliveryTime; + @SerializedName("offline_pickup_time") + private Long offlinePickupTime; + + @Data + public static class DeliveryProductInfo { + @SerializedName("waybill_id") + private String waybillId; + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("delivery_time") + private String deliveryTime; + @SerializedName("deliver_type") + private String deliverType; + @SerializedName("delivery_address") + private WxMinishopAddressInfo deliveryAddress; + @SerializedName("product_infos") + private List productInfos; + } + + @Data + public static class InsuranceInfo { + private String type; + @SerializedName("insurance_price") + private Long insurancePrice; + } + + @Data + public static class ProductInfo { + @SerializedName("product_id") + private Long productId; + @SerializedName("sku_id") + private Long skuId; + @SerializedName("product_cnt") + private Long productCnt; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetBrandResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetBrandResponse.java new file mode 100644 index 0000000000..0614e610c9 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetBrandResponse.java @@ -0,0 +1,35 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/8 3:46 下午 + */ +@Data +public class WxMinishopGetBrandResponse extends WxMaShopBaseResponse { + private List brands; + + @Data + public static class MinishopBrandItem { + @SerializedName("first_cat_id") + private Integer firstCatId; + @SerializedName("second_cat_id") + private Integer secondCatId; + @SerializedName("third_cat_id") + private Integer thirdCatId; + @SerializedName("brand_info") + private MinishopBrandInfo brandInfo; + } + + @Data + public static class MinishopBrandInfo { + @SerializedName("brand_id") + private Long brandId; + @SerializedName("brand_name") + private String brandName; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetCategoryResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetCategoryResponse.java new file mode 100644 index 0000000000..7faae66039 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetCategoryResponse.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author leiin + * created on 2022/7/8 3:39 下午 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMinishopGetCategoryResponse extends WxMaShopBaseResponse { + @SerializedName("cat_list") + private List catList; + + @Data + public static class MinishopCatItem { + + @SerializedName("cat_id") + private Integer catId; + + @SerializedName("f_cat_id") + private Integer fCatId; + + private String name; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetFrightTemplateResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetFrightTemplateResponse.java new file mode 100644 index 0000000000..f96c063dbd --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGetFrightTemplateResponse.java @@ -0,0 +1,26 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/8 3:46 下午 + */ +@Data +public class WxMinishopGetFrightTemplateResponse extends WxMaShopBaseResponse { + @SerializedName("template_list") + private List templateList; + + @Data + public static class MinishopFeightTemplateItem { + @SerializedName("template_id") + private Long templateId; + private String name; + @SerializedName("valuation_type") + private Integer valuationType; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGoodsSkuAttr.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGoodsSkuAttr.java new file mode 100644 index 0000000000..5b0b2735e4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopGoodsSkuAttr.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.JsonObject; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +@Data +public class WxMinishopGoodsSkuAttr implements Serializable { + private static final long serialVersionUID = -7274443170526394680L; + + @SerializedName("attr_key") + private String attrKey; + + @SerializedName("attr_value") + private String attrValue; + + public JsonObject toJsonObject() { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("attr_key", attrKey); + jsonObject.addProperty("attr_value", attrValue); + + return jsonObject; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderDetail.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderDetail.java new file mode 100644 index 0000000000..ad33029b15 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderDetail.java @@ -0,0 +1,48 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2021/3/23 + */ +@Data +public class WxMinishopOrderDetail implements Serializable { + private static final long serialVersionUID = 3325843289672341160L; + + /** + * 下单商品信息 + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("product_infos") + private List productInfos; + + /** + * 支付信息 (当作为返回结果,payorder时action_type!=6时存在) + *
+   * 是否必填:
+   * 
+ */ + @SerializedName("pay_info") + private WxMinishopPayInfo payInfo; + + /** + * 价格信息 + *
+   * 是否必填:
+   * 
+ */ + @SerializedName("price_info") + private WxMinishopPriceInfo priceInfo; + + /** + * 必须调过发货接口才会存在这个字段 + */ + @SerializedName("delivery_info") + private WxMinishopDeliveryInfo deliveryInfo; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderDetailResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderDetailResponse.java new file mode 100644 index 0000000000..4472b14f51 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderDetailResponse.java @@ -0,0 +1,19 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import lombok.Data; + +/** + * 获取订单详情 回包结构 + * + * @author leiin + * created on 2022/6/20 7:09 下午 + */ +@Data +public class WxMinishopOrderDetailResponse extends WxMaShopBaseResponse { + + /** + * 订单结构 + */ + private WxMinishopOrderResult order; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderListResponse.java new file mode 100644 index 0000000000..b4c6776cb2 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderListResponse.java @@ -0,0 +1,17 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 7:09 下午 + */ +@Data +public class WxMinishopOrderListResponse extends WxMaShopBaseResponse { + private List orders; + @SerializedName("total_num") + private Long totalNum; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderResult.java new file mode 100644 index 0000000000..5d73e1d53f --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopOrderResult.java @@ -0,0 +1,60 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2021/3/23 + */ +@Data +public class WxMinishopOrderResult implements Serializable { + private static final long serialVersionUID = -2665426592693969921L; + + /** + * 交易组件平台订单ID + */ + @SerializedName("order_id") + private Long orderId; + + /** + * 订单状态 + */ + @SerializedName("status") + private Integer status; + + @SerializedName("create_time") + private String createTime; + + @SerializedName("update_time") + private String updateTime; + /** + * 订单详情 + */ + @SerializedName("order_detail") + private WxMinishopOrderDetail orderDetail; + + @SerializedName("aftersale_detail") + private WxMiniOrderAfterSaleDetail afterSaleDetail; + + /** + * 商家小程序该订单的用户id + */ + @SerializedName("openid") + private String openid; + + @SerializedName("ext_info") + private ExtInfo extInfo; + + @SerializedName("order_type") + private Integer orderType; + + @Data + public static class ExtInfo { + @SerializedName("customer_notes") + private String customerNotes; + @SerializedName("merchant_notes") + private String merchantNotes; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopPayInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopPayInfo.java new file mode 100644 index 0000000000..01b3dc4e7e --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopPayInfo.java @@ -0,0 +1,54 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2021/3/23 + */ +@Data +public class WxMinishopPayInfo implements Serializable { + private static final long serialVersionUID = 687488209024968647L; + + @SerializedName("pay_method") + private String payMethod; + + /** + * 预支付ID + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("prepay_id") + private String prepayId; + + /** + * 预付款时间(拿到prepay_id的时间) + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("prepay_time") + private String prepayTime; + + // 以下字段仅作为返回数据 + /** + * 支付ID,调过同步订单支付结果且action_type=1时才存在 + *
+   * 是否必填:
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + * 付款时间(拿到transaction_id的时间) + *
+   * 是否必填:
+   * 
+ */ + @SerializedName("pay_time") + private String payTime; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopPriceInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopPriceInfo.java new file mode 100644 index 0000000000..87b26b114e --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopPriceInfo.java @@ -0,0 +1,44 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2021/3/23 + */ +@Data +public class WxMinishopPriceInfo implements Serializable { + private static final long serialVersionUID = 1588840927992523263L; + + @SerializedName("product_price") + private Integer productPrice; + /** + * 该订单最终的金额(单位:分) + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("order_price") + private Integer orderPrice; + /** + * 运费(单位:分) + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("freight") + private Integer freight; + /** + * 优惠金额(单位:分) + *
+   * 是否必填:否
+   * 
+ */ + @SerializedName("discounted_price") + private Integer discountedPrice; + + @SerializedName("is_discounted") + private Boolean isDiscounted; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopProductInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopProductInfo.java new file mode 100644 index 0000000000..e80533704c --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopProductInfo.java @@ -0,0 +1,71 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2021/3/23 + */ +@Data +public class WxMinishopProductInfo implements Serializable { + private static final long serialVersionUID = 8979181840150112093L; + /** + * 交易组件平台内部商品ID + */ + @SerializedName("product_id") + private Integer productId; + + @SerializedName("out_product_id") + private String outProductId; + + /** + * 交易组件平台内部skuID,可填0(如果这个product_id下没有sku) + */ + @SerializedName("sku_id") + private Integer skuId; + + @SerializedName("out_sku_id") + private String outSkuId; + /** + * 购买的数量 + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("sku_cnt") + private Integer skuCnt; + + @SerializedName("on_aftersale_sku_cnt") + private Integer onAftersaleSkuCnt; + + @SerializedName("finish_aftersale_sku_cnt") + private Integer finishAftersaleSkuCnt; + /** + * 生成订单时商品的标题 + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("title") + private String title; + @SerializedName("thumb_img") + private String thumbImg; + + @SerializedName("sku_attrs") + private List skuAttrs; + /** + * 生成订单时商品的售卖价(单位:分) + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("sale_price") + private Integer salePrice; + + @SerializedName("market_price") + private Integer marketPrice; +} + diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopResult.java new file mode 100644 index 0000000000..c47fcddd99 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopResult.java @@ -0,0 +1,14 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class WxMinishopResult implements Serializable { + private static final long serialVersionUID = 4323118714581265968L; + private Integer errcode; + + private String errmsg; + + private T data; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSku.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSku.java new file mode 100644 index 0000000000..9ac5636156 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSku.java @@ -0,0 +1,44 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +@Data +public class WxMinishopSku implements Serializable { + private static final long serialVersionUID = 12373392723136246L; + + @SerializedName("product_id") + private Long productId; + + @SerializedName("out_product_id") + private String outProductId; + + @SerializedName("out_sku_id") + private String outSkuId; + + @SerializedName("sku_id") + private Long skuId; + + @SerializedName("thumb_img") + private String thumbImg; + + @SerializedName("sale_price") + private Integer salePrice; + + @SerializedName("market_price") + private Integer marketPrice; + + @SerializedName("stock_num") + private Integer stockNum; + + @SerializedName("sku_code") + private String skuCode; + + @SerializedName("barcode") + private String barCode; + + @SerializedName("sku_attrs") + private List skuAttrs; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSkuListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSkuListResponse.java new file mode 100644 index 0000000000..76f6c18db2 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSkuListResponse.java @@ -0,0 +1,14 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/13 20:00 + */ +@Data +public class WxMinishopSkuListResponse extends WxMaShopBaseResponse { + private List skus; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpu.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpu.java new file mode 100644 index 0000000000..8b18dc45a7 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpu.java @@ -0,0 +1,54 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +@Data +public class WxMinishopSpu implements Serializable { + private static final long serialVersionUID = 6689040014027161007L; + + @SerializedName("product_id") + private String productId; + + @SerializedName("out_product_id") + private String outProductId; + + private String title; + + @SerializedName("sub_title") + private String subTitle; + + @SerializedName("head_img") + private List headImgs; + + @SerializedName("desc_info") + private DescInfo descInfo; + + @SerializedName("brand_id") + private Long brandId; + + @SerializedName("cats") + private List shopCats; + + private List attrs; + + private String model; + + @SerializedName("express_info") + private ExpressInfo expressInfo; + + private List skus; + + @Data + public static class DescInfo { + private List imgs; + } + + @Data + public static class ExpressInfo { + @SerializedName("template_id") + private Long templateId; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuGet.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuGet.java new file mode 100644 index 0000000000..1249e048b1 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuGet.java @@ -0,0 +1,16 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 4:36 下午 + */ +@Data +public class WxMinishopSpuGet implements Serializable { + + private static final long serialVersionUID = -957810527714924409L; + + private WxMinishopSpu spu; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuGetResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuGetResponse.java new file mode 100644 index 0000000000..84793b1a7f --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuGetResponse.java @@ -0,0 +1,12 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 4:46 下午 + */ +@Data +public class WxMinishopSpuGetResponse extends WxMinishopResult { + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuListResponse.java new file mode 100644 index 0000000000..42a5dd5ee8 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopSpuListResponse.java @@ -0,0 +1,17 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/20 4:46 下午 + */ +@Data +public class WxMinishopSpuListResponse extends WxMinishopResult { + @SerializedName("total_num") + private Long totalNum; + + private List spus; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopUpdateGoodsSkuData.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopUpdateGoodsSkuData.java new file mode 100644 index 0000000000..446404e4a4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/product/WxMinishopUpdateGoodsSkuData.java @@ -0,0 +1,16 @@ +package cn.binarywang.wx.miniapp.bean.product; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +@Data +public class WxMinishopUpdateGoodsSkuData implements Serializable { + private static final long serialVersionUID = -2596988603027040989L; + @SerializedName("sku_id") + private Long skuId; + @SerializedName("out_sku_id") + private String outSkuId; + @SerializedName("update_time") + private String updateTime; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/safety/request/WxMaUserSafetyRiskRankRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/safety/request/WxMaUserSafetyRiskRankRequest.java new file mode 100644 index 0000000000..da9384b1af --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/safety/request/WxMaUserSafetyRiskRankRequest.java @@ -0,0 +1,81 @@ +package cn.binarywang.wx.miniapp.bean.safety.request; + +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 azouever + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaUserSafetyRiskRankRequest implements Serializable { + private static final long serialVersionUID = 1052539797739665816L; + + + /** + * 小程序appid + * 必填 + */ + private String appid; + + /** + * 用户的openid + * 必填 + */ + private String openid; + + /** + * 场景值,0:注册,1:营销作弊 + * 必填 + */ + private Integer scene; + + /** + * 用户手机号 + * 非必填 + */ + @SerializedName("mobile_no") + private String mobileNo; + + /** + * 用户访问源ip + * 必填 + */ + @SerializedName("client_ip") + private String clientIp; + + /** + * 用户邮箱地址 + * 非必填 + */ + @SerializedName("email_address") + private String emailAddress; + + /** + * 额外补充信息 + * 非必填 + */ + @SerializedName("extended_info") + private String extendedInfo; + + /** + * false:正式调用,true:测试调用 + * 非必填 + */ + @SerializedName("is_test") + private boolean isTest; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/safety/response/WxMaUserSafetyRiskRankResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/safety/response/WxMaUserSafetyRiskRankResponse.java new file mode 100644 index 0000000000..afec04a3a8 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/safety/response/WxMaUserSafetyRiskRankResponse.java @@ -0,0 +1,42 @@ +package cn.binarywang.wx.miniapp.bean.safety.response; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 获取用户的安全等级响应参数 + * + * @author azouever + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaUserSafetyRiskRankResponse implements Serializable { + + private static final long serialVersionUID = -2434941857751339150L; + + /** + * 唯一请求标识,标记单次请求 + */ + @SerializedName("unoin_id") + private Long unoinId; + + /** + * 用户风险等级 + * 合法值 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/safety-control-capability/riskControl.getUserRiskRank.html + */ + @SerializedName("risk_rank") + private Integer riskRank; + + public static WxMaUserSafetyRiskRankResponse fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMaUserSafetyRiskRankResponse.class); + } +} + diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/scheme/WxMaGenerateNfcSchemeRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/scheme/WxMaGenerateNfcSchemeRequest.java new file mode 100644 index 0000000000..73d4e4a6da --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/scheme/WxMaGenerateNfcSchemeRequest.java @@ -0,0 +1,75 @@ +package cn.binarywang.wx.miniapp.bean.scheme; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +/** + * @author : lyt + * created on : 2023-07-31 + */ +@Data +@Builder(builderMethodName = "newBuilder") +public class WxMaGenerateNfcSchemeRequest { + /** + * 跳转到的目标小程序信息。 + *
+   * 是否必填:否
+   * 
+ */ + @SerializedName("jump_wxa") + private JumpWxa jumpWxa; + + /** + * scheme对应的设备model_id + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("model_id") + private String modelId; + + /** + * scheme对应的设备sn,仅一机一码时填写 + *
+   * 是否必填:否
+   * 
+ */ + @SerializedName("sn") + private String sn; + + @Data + @Builder(builderMethodName = "newBuilder") + public static class JumpWxa { + /** + * 通过scheme码进入的小程序页面路径,必须是已经发布的小程序存在的页面,不可携带query。path为空时会跳转小程序主页。 + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("path") + private String path; + + /** + * 通过scheme码进入小程序时的query,最大128个字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~ + * 返回值 + *
+     * 是否必填:是
+     * 
+ */ + @SerializedName("query") + private String query; + + /** + * 要打开的小程序版本。正式版为"release",体验版为"trial",开发版为"develop"默认值:release + */ + @SerializedName("env_version") + private String envVersion = "release"; + } + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/scheme/WxMaGenerateSchemeRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/scheme/WxMaGenerateSchemeRequest.java index 799a7390a6..c40491d097 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/scheme/WxMaGenerateSchemeRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/scheme/WxMaGenerateSchemeRequest.java @@ -7,7 +7,7 @@ /** * @author : cofedream - * @date : 2021-01-26 + * created on : 2021-01-26 */ @Data @Builder(builderMethodName = "newBuilder") @@ -39,6 +39,25 @@ public class WxMaGenerateSchemeRequest { @SerializedName("expire_time") private Long expireTime; + /** + * 到期失效的 scheme 码失效类型,失效时间:0,失效间隔天数:1 + *
+   * 是否必填:否
+   * 
+ */ + @SerializedName("expire_type") + private Integer expireType; + + /** + * 到期失效的 scheme 码的失效间隔天数。 + *
+   * 生成的到期失效 scheme 码在该间隔时间到达前有效。最长间隔天数为365天。is_expire 为 true 且 expire_type 为 1 时必填   * 
+   * 是否必填:否
+   * 
+ */ + @SerializedName("expire_interval") + private Integer expireInterval; + @Data @Builder(builderMethodName = "newBuilder") public static class JumpWxa { @@ -60,6 +79,12 @@ public static class JumpWxa { */ @SerializedName("query") private String query; + + /** + * 要打开的小程序版本。正式版为"release",体验版为"trial",开发版为"develop"默认值:release + */ + @SerializedName("env_version") + private String envVersion = "release"; } public String toJson() { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/security/WxMaMediaSecCheckCheckRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/security/WxMaMediaSecCheckCheckRequest.java new file mode 100644 index 0000000000..0c7375f3a2 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/security/WxMaMediaSecCheckCheckRequest.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.bean.security; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author dingxw + * created on 2021/11/18 20:27 + */ +@Data +@Builder +public class WxMaMediaSecCheckCheckRequest implements Serializable { + + private static final long serialVersionUID = -3947838615379224577L; + + @SerializedName("media_url") + private String mediaUrl; + + @SerializedName("media_type") + private Integer mediaType; + + @SerializedName("version") + private Integer version; + + @SerializedName("openid") + private String openid; + + @SerializedName("scene") + private Integer scene; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaPromotionInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaPromotionInfo.java new file mode 100644 index 0000000000..d88c3311c3 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaPromotionInfo.java @@ -0,0 +1,24 @@ +package cn.binarywang.wx.miniapp.bean.shop; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/18 3:14 下午 + */ +@Data +public class WxMaPromotionInfo implements Serializable { + + private static final long serialVersionUID = 2090629980847386450L; + + @SerializedName("finder_username") + private String finderUsername; + @SerializedName("finder_nickname") + private String finderNickname; + @SerializedName("sharer_openid") + private String sharerOpenid; + @SerializedName("live_start_time") + private String liveStartTime; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetBrandListItem.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetBrandListItem.java index 48019b2420..610b8b5ea2 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetBrandListItem.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetBrandListItem.java @@ -7,7 +7,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data public class WxMaShopAccountGetBrandListItem implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetCategoryListItem.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetCategoryListItem.java index 987ff074d5..bafdfe14fd 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetCategoryListItem.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetCategoryListItem.java @@ -7,7 +7,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data public class WxMaShopAccountGetCategoryListItem implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetInfo.java index 7c0fd95cbd..373026fc4f 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetInfo.java @@ -7,7 +7,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data public class WxMaShopAccountGetInfo implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddOrderResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddOrderResult.java index 7733529983..70d1f2f744 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddOrderResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddOrderResult.java @@ -6,7 +6,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopAddOrderResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddSpuResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddSpuResult.java index 5fdae9fd26..19abbf7984 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddSpuResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddSpuResult.java @@ -8,7 +8,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 * 添加商品参数返回 */ @Data diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddressInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddressInfo.java index bab59469bb..524f4188d4 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddressInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAddressInfo.java @@ -6,7 +6,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopAddressInfo implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopCatGetDetail.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopCatGetDetail.java index 3c8f752dd8..9dee8a1878 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopCatGetDetail.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopCatGetDetail.java @@ -7,7 +7,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data public class WxMaShopCatGetDetail implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopCouponInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopCouponInfo.java new file mode 100644 index 0000000000..4c468b8d3a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopCouponInfo.java @@ -0,0 +1,319 @@ +package cn.binarywang.wx.miniapp.bean.shop; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author leiin + * created on 2022/7/1 2:57 下午 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopCouponInfo implements Serializable { + + private static final long serialVersionUID = 5807154725645642700L; + + /** + * 是否必填:是 + * 说明:商家侧优惠券ID + */ + @SerializedName("out_coupon_id") + private String outCouponId; + /** + * 是否必填:是 + * 说明:优惠券类型 + */ + @SerializedName("type") + private Integer type; + /** + * 是否必填:是 + * 说明:优惠券推广类型 + */ + @SerializedName("promote_type") + private Integer promoteType; + + @SerializedName("coupon_info") + private CouponInfo couponInfo; + + // 返回参数 + /** + * 优惠券状态 + */ + @SerializedName("status") + private Integer status; + /** + * 创建时间 + */ + @SerializedName("create_time") + private Long createTime; + /** + * 更新时间 + */ + @SerializedName("update_time") + private Long updateTime; + + @SerializedName("coupon_stock") + private CouponStock couponStock; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class CouponInfo implements Serializable { + + private static final long serialVersionUID = -7913225774910831745L; + + /** + * 是否必填:是 + * 说明:优惠券名 + */ + private String name; + + @SerializedName("promote_info") + private PromoteInfo promoteInfo; + + @SerializedName("discount_info") + private DiscountInfo discountInfo; + + @SerializedName("receive_info") + private ReceiveInfo receiveInfo; + + @SerializedName("valid_info") + private ValidInfo validInfo; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class PromoteInfo { + @SerializedName("promote_type") + private Integer promoteType; + private PromoteFinder finder; + + @Data + public static class PromoteFinder { + private String nickname; + } + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class DiscountInfo { + + /** + * 是否必填: 否 + * 说明:折扣数,比如5.1折,则填5100,折扣券必需 + */ + @SerializedName("discount_num") + private Integer discountNum; + /** + * 是否必填: 否 + * 说明:减金额,单位为分,直减券、满减券必需 + */ + @SerializedName("discount_fee") + private Long discountFee; + + @SerializedName("discount_condition") + private DiscountCondition discountCondition; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class DiscountCondition { + + /** + * 是否必填: 否 + * 说明:优惠条件所需的商品数 + */ + @SerializedName("product_cnt") + private Integer productCnt; + /** + * 是否必填: 否 + * 说明:优惠条件所需满足的金额 + */ + @SerializedName("product_price") + private Long productPrice; + /** + * 是否必填: 否 + * 说明:指定商品商家侧ID,商品券必需,最多128个 + */ + @SerializedName("out_product_ids") + private List outProductIds; + + @SerializedName("tradein_info") + private TradeinInfo tradeinInfo; + + @SerializedName("buyget_info") + private BuygetInfo buyget_info; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class TradeinInfo { + + /** + * 是否必填:否 + * 说明:换购商品商家侧ID,换购券必需 + */ + @SerializedName("out_product_id") + private String outProductId; + /** + * 是否必填:否 + * 说明:需要支付的金额,单位分,换购券必需 + */ + @SerializedName("price") + private Long price; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class BuygetInfo { + /** + * 是否必填:否 + * 说明:购买商品商家侧ID,买赠券必需 + */ + @SerializedName("buy_out_product_id") + private String buyOutProductId; + /** + * 是否必填:否 + * 说明:购买商品数,买赠券必需 + */ + @SerializedName("buy_product_cnt") + private Integer buyProductCnt; + /** + * 是否必填:否 + * 说明:赠送商品商家侧ID,买赠券必需 + */ + @SerializedName("get_out_product_id") + private String getOutProductId; + /** + * 是否必填:否 + * 说明:赠送商品数,买赠券必需 + */ + @SerializedName("get_product_cnt") + private Integer getProductCnt; + } + } + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ReceiveInfo { + + /** + * 是否必填:是 + * 说明:领取开始时间 (秒级时间戳) + */ + @SerializedName("start_time") + private Long startTime; + /** + * 是否必填:是 + * 说明:领取结束时间 (秒级时间戳) + */ + @SerializedName("end_time") + private Long endTime; + /** + * 是否必填:是 + * 说明:个人限领张数,只做展示,领券回调时接入方判断有无超领。 + */ + @SerializedName("limit_num_one_person") + private Integer limitNumOnePerson; + /** + * 是否必填:是 + * 说明:总发放量,即初始库存数,只做展示,领券回调时接入方判断有无超领。 + */ + @SerializedName("total_num") + private Integer totalNum; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ValidInfo { + + /** + * 是否必填:是 + * 说明:有效期类型,1:商品指定时间区间,2:生效天数,3:生效秒数 + */ + @SerializedName("valid_type") + private Integer validType; + /** + * 是否必填:否 + * 说明:生效天数,有效期类型为2时必需 + */ + @SerializedName("valid_day_num") + private Integer validDayNum; + /** + * 是否必填:否 + * 说明:生效秒数,有效期类型为3时必需 + */ + @SerializedName("valid_second") + private Long validSecond; + /** + * 是否必填:否 + * 说明:生效开始时间,有效期类型为1时必需 + */ + @SerializedName("start_time") + private Long startTime; + /** + * 是否必填:否 + * 说明:生效结束时间,有效期类型为1时必需 + */ + @SerializedName("end_time") + private Long endTime; + } + + @Data + public static class CouponStock { + + /** + * 商家侧优惠券ID + */ + @SerializedName("out_coupon_id") + private String outCouponId; + /** + * 创建时间 + */ + @SerializedName("create_time") + private Long createTime; + /** + * 更新时间 + */ + @SerializedName("update_time") + private Long updateTime; + + @SerializedName("stock_info") + private StockInfo stockInfo; + + @Data + public static class StockInfo { + /** + * 优惠券库存剩余量 + */ + @SerializedName("issued_num") + private Integer issuedNum; + /** + * 优惠卷发放量 + */ + @SerializedName("receive_num") + private Integer receiveNum; + } + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryDetail.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryDetail.java index 0a2ba9b2ef..cb9cb2bebc 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryDetail.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryDetail.java @@ -7,7 +7,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopDeliveryDetail implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryItem.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryItem.java index 006b5a00d6..d698d775c1 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryItem.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopDeliveryItem.java @@ -6,7 +6,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopDeliveryItem implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopGetSpuResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopGetSpuResult.java index e25868fb39..94d9faa3f6 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopGetSpuResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopGetSpuResult.java @@ -8,7 +8,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderDetail.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderDetail.java index 661fa3208a..e5eef6b77e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderDetail.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderDetail.java @@ -8,12 +8,19 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopOrderDetail implements Serializable { private static final long serialVersionUID = 3325843289672341160L; + + /** + * 推广员、分享员信息 + */ + @SerializedName("promotion_info") + private WxMaShopPromotionInfo promotionInfo; + /** * 下单商品信息 *
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderInfo.java
index b942bb6b55..1baff0215a 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderInfo.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderInfo.java
@@ -6,7 +6,7 @@
 
 /**
  * @author Boris
- * @date 2021/3/23
+ * created on  2021/3/23
  */
 @Data
 public class WxMaShopOrderInfo implements Serializable {
@@ -84,4 +84,53 @@ public class WxMaShopOrderInfo implements Serializable {
   @SerializedName("address_info")
   private WxMaShopAddressInfo addressInfo;
 
+  /**
+   * 订单类型:0,普通单,1,二级商户单
+   * 
+   * 是否必填:是
+   * 
+ */ + @SerializedName("fund_type") + private Integer fundType; // 订单类型:0,普通单,1,二级商户单 + /** + * unix秒级时间戳,订单超时时间,取值:[15min, 1d] + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("expire_time") + private Long expireTime; // unix秒级时间戳,订单超时时间,取值:[15min, 1d] + /** + * 取值范围,[7,3 * 365],单位:天 + *
+   * 是否必填:选填
+   * 
+ */ + @SerializedName("aftersale_duration") + private Integer aftersaleDuration; // 取值范围,[7,3 * 365],单位:天 + /** + * 会影响主播归因、分享员归因等,从下单前置检查获取 + *
+   * 是否必填:是
+   * 
+ */ + @SerializedName("trace_id") + private String traceId; // 会影响主播归因、分享员归因等,从下单前置检查获取 + /** + * 默认退货地址,退货售后超时时,会让用户将货物寄往此地址 + *
+   * 是否必填:选填
+   * 
œ + */ + @SerializedName("default_receiving_address") + private WxMaShopAddressInfo defaultReceivingAddress; // 默认退货地址,退货售后超时时,会让用户将货物寄往此地址 + /** + * 生成的order_id以字符串形式返回 + *
+   * 是否必填:选填
+   * 
+ */ + @SerializedName("stringify_64bits_number") + private Boolean stringify64bitsNumber; // 生成的order_id以字符串形式返回 + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderResult.java index b2d23995d5..7d877014ed 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopOrderResult.java @@ -6,7 +6,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopOrderResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPayInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPayInfo.java index c9a56a3aed..5d45cc35d5 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPayInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPayInfo.java @@ -6,18 +6,21 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopPayInfo implements Serializable { private static final long serialVersionUID = 687488209024968647L; /** - * 支付方式(目前只有"微信支付") + * 支付方式(支付方式,0:微信支付,1: 货到付款,2:商家会员储蓄卡, 默认0) *
    * 是否必填:是
    * 
*/ + @SerializedName("pay_method_type") + private Integer payMethodType; + @SerializedName("pay_method") private String payMethod; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPriceInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPriceInfo.java index f050d3a127..62c98fa4c7 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPriceInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPriceInfo.java @@ -7,7 +7,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopPriceInfo implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopProductInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopProductInfo.java index b381b18f66..1a4b9f1f59 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopProductInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopProductInfo.java @@ -7,7 +7,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopProductInfo implements Serializable { @@ -88,5 +88,8 @@ public class WxMaShopProductInfo implements Serializable { */ @SerializedName("real_price") private Integer realPrice; + + @SerializedName("sku_real_price") + private Integer skuRealPrice; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPromotionInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPromotionInfo.java new file mode 100644 index 0000000000..d09243998b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopPromotionInfo.java @@ -0,0 +1,39 @@ +package cn.binarywang.wx.miniapp.bean.shop; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 推广员、分享员信息 + * + * @author zhongjun + * created on 2022/5/17 + **/ +@Data +public class WxMaShopPromotionInfo implements Serializable { + private static final long serialVersionUID = -812058443344709898L; + /** + * 推广员唯一ID + */ + @SerializedName("promoter_id") + private String promoterId; + + /** + * 推广员视频号昵称 + */ + @SerializedName("finder_nickname") + private String finderNickname; + /** + * 推广员openid + */ + @SerializedName("promoter_openid") + private String promoterOpenid; + + /** + * 分享员openid + */ + @SerializedName("sharer_openid") + private String sharerOpenid; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuResult.java index c4dc1e820f..f0bee2c980 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuResult.java @@ -7,7 +7,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopSkuResult implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuWithoutAuditInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuWithoutAuditInfo.java index 334555b2bd..266a498bfe 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuWithoutAuditInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSkuWithoutAuditInfo.java @@ -6,7 +6,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopSkuWithoutAuditInfo implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuAudit.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuAudit.java index a9d30139c3..f39eb89162 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuAudit.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuAudit.java @@ -7,7 +7,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopSpuAudit implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuInfo.java index bd0c552f0b..9fdd8ce512 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuInfo.java @@ -7,7 +7,7 @@ /** * @author Boris - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopSpuInfo implements Serializable { @@ -102,4 +102,22 @@ public class WxMaShopSpuInfo implements Serializable { */ @SerializedName("skus") private List skus; + + /** + * 商品使用场景 + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("scene_group_list") + private Integer[] sceneGroupList; + + /** + * 商品类型 + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("item_type") + private Integer itemType; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuWithoutAuditInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuWithoutAuditInfo.java index 306120ed9d..edc79f5255 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuWithoutAuditInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopSpuWithoutAuditInfo.java @@ -8,7 +8,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopSpuWithoutAuditInfo implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaOrderShippingIsTradeManagedRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaOrderShippingIsTradeManagedRequest.java new file mode 100644 index 0000000000..d70e04327a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaOrderShippingIsTradeManagedRequest.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaOrderShippingIsTradeManagedRequest implements Serializable { + + private static final long serialVersionUID = -5735132900385013330L; + /** + * 必填 + * 待查询小程序的 appid,非服务商调用时仅能查询本账号 + */ + @SerializedName("appid") + private String appId; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAcceptReturnRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAcceptReturnRequest.java new file mode 100644 index 0000000000..380259ae3a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAcceptReturnRequest.java @@ -0,0 +1,43 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author leiin + * created on 2022/6/28 11:39 上午 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopAcceptReturnRequest implements Serializable { + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("aftersale_id") + private Long aftersaleId; + @SerializedName("address_info") + private RefundAddressInfo addressInfo; + + @Data + public static class RefundAddressInfo { + @SerializedName("receiver_name") + private String receiverName; + @SerializedName("detailed_address") + private String detailedAddress; + @SerializedName("tel_number") + private String telNumber; + @SerializedName("country") + private String country; + @SerializedName("province") + private String province; + @SerializedName("city") + private String city; + @SerializedName("town") + private String town; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAccountUpdateInfoRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAccountUpdateInfoRequest.java index 8e74f6b4a9..7b259143c8 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAccountUpdateInfoRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAccountUpdateInfoRequest.java @@ -7,7 +7,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data public class WxMaShopAccountUpdateInfoRequest implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java index 47c33f1ae7..ca3c451601 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java @@ -11,7 +11,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @Builder @@ -33,6 +33,8 @@ public class WxMaShopAfterSaleAddRequest implements Serializable { * product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}] */ + @SerializedName("order_id") + private Long orderId; @SerializedName("out_order_id") private String outOrderId; @SerializedName("out_aftersale_id") @@ -41,8 +43,14 @@ public class WxMaShopAfterSaleAddRequest implements Serializable { private String openid; @SerializedName("type") private Integer type; - @SerializedName("create_time") - private String createTime; + @SerializedName("product_info") + private ProductInfosBean productInfo; + @SerializedName("orderamt") + private Long orderamt; + @SerializedName("refund_reason") + private String refundReason; + @SerializedName("refund_reason_type") + private Integer refundReasonType; @SerializedName("status") private Integer status; @SerializedName("finish_all_aftersale") @@ -51,8 +59,8 @@ public class WxMaShopAfterSaleAddRequest implements Serializable { private String path; @SerializedName("refund") private Long refund; - @SerializedName("product_infos") - private List productInfos; + @SerializedName("media_list") + private UploadMediaList mediaList; @Data @Builder @@ -72,4 +80,12 @@ public static class ProductInfosBean implements Serializable { @SerializedName("product_cnt") private Integer productCnt; } + + @Data + public static class UploadMediaList { + private Integer type; + private String url; + @SerializedName("thumb_url") + private String thumbUrl; + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java index fdad13ebb0..2c303cbed1 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java @@ -10,7 +10,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @Builder diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleListRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleListRequest.java new file mode 100644 index 0000000000..19db2d2a1b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleListRequest.java @@ -0,0 +1,36 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author leiin + * created on 2022/6/28 11:39 上午 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopAfterSaleListRequest implements Serializable { + @SerializedName("status") + private Integer status; //售后单状态,见 AfterSalesState + @SerializedName("out_order_id") + private String outOrderId; //售后单关联的外部订单号 + @SerializedName("order_id") + private Long orderId; //售后单关联的微信侧订单号 + @SerializedName("openid") + private String openid; //买家openid + @SerializedName("begin_create_time") + private Long beginCreateTime; //申请时间(单位毫秒)起始 + @SerializedName("end_create_time") + private Long endCreateTime; //申请时间(单位毫秒)结束 + @SerializedName("offset") + private Long offset; //本次拉取的起始位置(从0开始) + @SerializedName("limit") + private Integer limit; //本次拉取的大小(最大50) +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java index d208b239e2..ac586fa7b7 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java @@ -1,5 +1,6 @@ package cn.binarywang.wx.miniapp.bean.shop.request; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest.UploadMediaList; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,7 +11,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @Builder diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUploadReturnInfoRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUploadReturnInfoRequest.java new file mode 100644 index 0000000000..60558f9012 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUploadReturnInfoRequest.java @@ -0,0 +1,31 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author leiin + * created on 2022/6/28 11:39 上午 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopAfterSaleUploadReturnInfoRequest implements Serializable { + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("aftersale_id") + private Long aftersaleId; + @SerializedName("openid") + private String openid; + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("waybill_id") + private String waybillId; + @SerializedName("delivery_name") + private String deliveryName; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditBrandRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditBrandRequest.java index f589f503f5..63fe5e30f2 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditBrandRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditBrandRequest.java @@ -11,7 +11,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @Builder diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditCategoryRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditCategoryRequest.java index 300c77db78..3e48ca13f7 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditCategoryRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditCategoryRequest.java @@ -11,7 +11,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @Builder diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java index bbf896626d..9b1f233e33 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java @@ -10,7 +10,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @Builder diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java index bf8acced5e..fe261f5a5e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java @@ -1,5 +1,6 @@ package cn.binarywang.wx.miniapp.bean.shop.request; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest.ProductInfosBean; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,7 +12,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @Builder @@ -38,6 +39,8 @@ public class WxMaShopDeliverySendRequest implements Serializable { private Integer finishAllDelivery; @SerializedName("delivery_list") private List deliveryList; + @SerializedName("ship_done_time") + private String shipDoneTme; @Data @Builder @@ -53,5 +56,7 @@ public static class DeliveryListBean implements Serializable { private String deliveryId; @SerializedName("waybill_id") private String waybillId; + @SerializedName("product_info_list") + private List productInfoList; } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java new file mode 100644 index 0000000000..1485d72880 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author liming1019 + * created on 2022/8/25 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopEcAfterSaleGetRequest implements Serializable { + + private static final long serialVersionUID = -1967384908983649001L; + + @SerializedName("aftersale_id") + private Long aftersaleId; + @SerializedName("out_aftersale_id") + private String outAftersaleId; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleUpdateRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleUpdateRequest.java new file mode 100644 index 0000000000..607ed16553 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleUpdateRequest.java @@ -0,0 +1,50 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author liming1019 + * created on 2022/8/26 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopEcAfterSaleUpdateRequest implements Serializable { + private static final long serialVersionUID = 349486861004919697L; + + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("aftersale_id") + private String aftersaleId; + @SerializedName("openid") + private String openid; + @SerializedName("type") + private int type; + @SerializedName("orderamt") + private int orderamt; + @SerializedName("refund_reason") + private String refundReason; + @SerializedName("refund_reason_type") + private int refundReasonType; + @SerializedName("media_list") + private List mediaList; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class MediaListBean implements Serializable { + @SerializedName("type") + private int type; + @SerializedName("url") + private String url; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopOrderPayRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopOrderPayRequest.java index 96e56d891a..9a00de2d2b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopOrderPayRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopOrderPayRequest.java @@ -6,7 +6,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopOrderPayRequest implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayCreateOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayCreateOrderRequest.java new file mode 100644 index 0000000000..f8897ad419 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayCreateOrderRequest.java @@ -0,0 +1,47 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author liming1019 + * created on 2022/8/10 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopPayCreateOrderRequest implements Serializable { + private static final long serialVersionUID = -5597409427574429095L; + + @SerializedName("openid") + private String openid; + @SerializedName("combine_trade_no") + private String combineTradeNo; + @SerializedName("expire_time") + private Long expireTime; + @SerializedName("sub_orders") + private List subOrders; + + @NoArgsConstructor + @AllArgsConstructor + @Data + @Builder + public static class SubOrdersDTO { + @SerializedName("mchid") + private String mchid; + @SerializedName("amount") + private Integer amount; + @SerializedName("trade_no") + private String tradeNo; + @SerializedName("description") + private String description; + } +} + diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayOrderRefundRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayOrderRefundRequest.java new file mode 100644 index 0000000000..012cb310d8 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayOrderRefundRequest.java @@ -0,0 +1,37 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author liming1019 + * created on 2022/8/31 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopPayOrderRefundRequest implements Serializable { + private static final long serialVersionUID = -5850024411710741165L; + + @SerializedName("openid") + private String openid; + @SerializedName("mchid") + private String mchid; + @SerializedName("trade_no") + private String tradeNo; + @SerializedName("transaction_id") + private String transactionId; + @SerializedName("refund_no") + private String refundNo; + @SerializedName("total_amount") + private int totalAmount; + @SerializedName("refund_amount") + private int refundAmount; +} + diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterApplySceneRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterApplySceneRequest.java index bec18e27f1..57d1138878 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterApplySceneRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterApplySceneRequest.java @@ -7,7 +7,7 @@ /** * @author liming1019 - * @date 2021/8/6 + * created on 2021/8/6 */ @Data public class WxMaShopRegisterApplySceneRequest implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterFinishAccessInfoRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterFinishAccessInfoRequest.java index 6b2999e2f2..20eabab177 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterFinishAccessInfoRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterFinishAccessInfoRequest.java @@ -7,7 +7,7 @@ /** * @author liming1019 - * @date 2021/8/6 + * created on 2021/8/6 */ @Data public class WxMaShopRegisterFinishAccessInfoRequest implements Serializable { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopSpuPageRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopSpuPageRequest.java index 8aee162f3f..95e1e30c12 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopSpuPageRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopSpuPageRequest.java @@ -7,7 +7,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 * spu分页参数 */ @Data diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopUploadCerficatesRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopUploadCerficatesRequest.java new file mode 100644 index 0000000000..37678f97d7 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopUploadCerficatesRequest.java @@ -0,0 +1,28 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author leiin + * created on 2022/6/28 11:39 上午 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopUploadCerficatesRequest implements Serializable { + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("aftersale_id") + private Long aftersaleId; + @SerializedName("refund_desc") + private String refundDesc; + @SerializedName("certificates") + private List certificates; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ContactBean.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ContactBean.java new file mode 100644 index 0000000000..685061aee3 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ContactBean.java @@ -0,0 +1,33 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xzh + * @Description + * @createTime 2023/07/10 10:38 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ContactBean implements Serializable { + private static final long serialVersionUID = 3388264169113920140L; + + /** + * 寄件人联系方式,寄件人联系方式,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024 + */ + @SerializedName("consignor_contact") + private String consignorContact; + /** + * 收件人联系方式,收件人联系方式为,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024 + */ + @SerializedName("receiver_contact") + private String receiverContact; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/OrderKeyBean.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/OrderKeyBean.java new file mode 100644 index 0000000000..87372479a4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/OrderKeyBean.java @@ -0,0 +1,44 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xzh + * @Description + * @createTime 2023/07/10 10:37 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderKeyBean implements Serializable { + private static final long serialVersionUID = -6322907878214196106L; + + /** + * 必填 + * 订单单号类型,用于确认需要上传详情的订单。枚举值1,使用下单商户号和商户侧单号;枚举值2,使用微信支付单号。 + */ + @SerializedName("order_number_type") + private int orderNumberType; + /** + * 原支付交易对应的微信订单号 + */ + @SerializedName("transaction_id") + private String transactionId; + /** + * 支付下单商户的商户号,由微信支付生成并下发。 + */ + @SerializedName("mchid") + private String mchId; + /** + * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一 + */ + @SerializedName("out_trade_no") + private String outTradeNo; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/PayerBean.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/PayerBean.java new file mode 100644 index 0000000000..f6dd55ce84 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/PayerBean.java @@ -0,0 +1,29 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xzh + * @Description + * @createTime 2023/07/10 10:38 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PayerBean implements Serializable { + + private static final long serialVersionUID = 6628077253606871512L; + /** + * 必填 + * 用户标识,用户在小程序appid下的唯一标识。 下单前需获取到用户的Openid 示例值: oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 字符字节限制: [1, 128] + */ + @SerializedName("openid") + private String openid; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ShippingListBean.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ShippingListBean.java new file mode 100644 index 0000000000..136f8b504f --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ShippingListBean.java @@ -0,0 +1,44 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xzh + * @Description + * @createTime 2023/07/10 10:39 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ShippingListBean implements Serializable { + private static final long serialVersionUID = -6554762808990702774L; + + /** + * 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128] + */ + @SerializedName("tracking_no") + private String trackingNo; + /** + * 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128] + */ + @SerializedName("express_company") + private String expressCompany; + /** + * 必填 + * 商品信息,例如:微信红包抱枕*1个,限120个字以内 + */ + @SerializedName("item_desc") + private String itemDesc; + /** + * 联系方式,当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一 + */ + @SerializedName("contact") + private ContactBean contact; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderCombinedShippingInfoUploadRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderCombinedShippingInfoUploadRequest.java new file mode 100644 index 0000000000..74c4a76780 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderCombinedShippingInfoUploadRequest.java @@ -0,0 +1,96 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import cn.binarywang.wx.miniapp.bean.shop.request.shipping.ContactBean; +import cn.binarywang.wx.miniapp.bean.shop.request.shipping.OrderKeyBean; +import cn.binarywang.wx.miniapp.bean.shop.request.shipping.PayerBean; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaOrderCombinedShippingInfoUploadRequest implements Serializable { + private static final long serialVersionUID = -334322216049787167L; + + /** + * 必填 + * 订单,需要上传物流信息的订单 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + @SerializedName("sub_orders") + private List subOrders; + + /** + * 必填 + * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 + */ + @SerializedName("upload_time") + private String uploadTime; + + /** + * 必填 + * 支付者,支付者信息 + */ + @SerializedName("payer") + private PayerBean payer; + + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SubOrderBean implements Serializable { + + private static final long serialVersionUID = -8999547192454376968L; + + /** + * 必填 + * 需要上传物流详情的子单订单,订单类型与合单订单保持一致 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + /** + * 必填 + * 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 + */ + @SerializedName("logistics_type") + private int logisticsType; + + /** + * 必填 + * 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) + * 示例值: UNIFIED_DELIVERY + */ + @SerializedName("delivery_mode") + private int deliveryMode; + + /** + * 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。 + * 示例值: true/false + */ + @SerializedName("is_all_delivered") + private Boolean isAllDelivered; + + /** + * 子单物流信息列表 多重性: [1, 10] + */ + @SerializedName("shipping_list") + private List shippingList; + } + + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetListRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetListRequest.java new file mode 100644 index 0000000000..fd9be83ae1 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetListRequest.java @@ -0,0 +1,67 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaOrderShippingInfoGetListRequest implements Serializable { + + private static final long serialVersionUID = -3682480001426075609L; + + /** + * 支付时间所属范围 + */ + @SerializedName("pay_time_range") + private PayTimeRange payTimeRange; + + /** + * 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款。 + */ + @SerializedName("order_state") + private Integer orderState; + /** + * 支付者openid + */ + @SerializedName("openid") + private String openId; + /** + * 翻页时使用,获取第一页时不用传入,如果查询结果中 has_more 字段为 true,则传入该次查询结果中返回的 last_index 字段可获取下一页。 + */ + @SerializedName("last_index") + private String lastIndex; + /** + * 翻页时使用,返回列表的长度,默认为100。 + */ + @SerializedName("page_size") + private Long pageSize; + + @Data + public static class PayTimeRange implements Serializable { + + private static final long serialVersionUID = -1477231289550635468L; + + /** + * 起始时间,时间戳形式,不填则视为从0开始 + */ + @SerializedName("begin_time") + private Long beginTime; + /** + * 结束时间(含),时间戳形式,不填则视为32位无符号整型的最大值 + */ + @SerializedName("end_time") + private Long endTime; + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetRequest.java new file mode 100644 index 0000000000..3d4f33e3c1 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetRequest.java @@ -0,0 +1,43 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaOrderShippingInfoGetRequest implements Serializable { + + private static final long serialVersionUID = -6868378515860675152L; + + /** + * 原支付交易对应的微信订单号 + */ + @SerializedName("transaction_id") + private String transactionId; + /** + * 支付下单商户的商户号,由微信支付生成并下发 + */ + @SerializedName("merchant_id") + private String merchantId; + /** + * 二级商户号 + */ + @SerializedName("sub_merchant_id") + private String subMerchantId; + /** + * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一。 + */ + @SerializedName("merchant_trade_no") + private String merchantTradeNo; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoNotifyConfirmRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoNotifyConfirmRequest.java new file mode 100644 index 0000000000..5ddcb53a0e --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoNotifyConfirmRequest.java @@ -0,0 +1,49 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaOrderShippingInfoNotifyConfirmRequest implements Serializable { + + private static final long serialVersionUID = -6868378515860675152L; + + /** + * 原支付交易对应的微信订单号 + */ + @SerializedName("transaction_id") + private String transactionId; + /** + * 支付下单商户的商户号,由微信支付生成并下发 + */ + @SerializedName("merchant_id") + private String merchantId; + /** + * 二级商户号 + */ + @SerializedName("sub_merchant_id") + private String subMerchantId; + /** + * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一。 + */ + @SerializedName("merchant_trade_no") + private String merchantTradeNo; + + /** + * 快递签收时间,时间戳形式。 + */ + @SerializedName("received_time") + private Long receivedTime; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoUploadRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoUploadRequest.java new file mode 100644 index 0000000000..27cb57e5de --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoUploadRequest.java @@ -0,0 +1,74 @@ +package cn.binarywang.wx.miniapp.bean.shop.request.shipping; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaOrderShippingInfoUploadRequest implements Serializable { + private static final long serialVersionUID = -334322216049787167L; + + + /** + * 必填 + * 订单,需要上传物流信息的订单 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + /** + * 必填 + * 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 + */ + @SerializedName("logistics_type") + private int logisticsType; + + /** + * 必填 + * 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) + * 示例值: UNIFIED_DELIVERY + */ + @SerializedName("delivery_mode") + private int deliveryMode; + + /** + * 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。 + * 示例值: true/false + */ + @SerializedName("is_all_delivered") + private Boolean isAllDelivered; + + /** + * 必填 + * 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式,多重性: [1, 10] + */ + @SerializedName("shipping_list") + private List shippingList; + + /** + * 必填 + * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 + */ + @SerializedName("upload_time") + private String uploadTime; + + /** + * 必填 + * 支付者,支付者信息 + */ + @SerializedName("payer") + private PayerBean payer; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoBaseResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoBaseResponse.java new file mode 100644 index 0000000000..4ac48aacfa --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoBaseResponse.java @@ -0,0 +1,187 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +public class WxMaOrderShippingInfoBaseResponse implements Serializable { + private static final long serialVersionUID = -5414031943436195493L; + /** + * 错误码 + */ + @SerializedName("errcode") + private Integer errCode; + + /** + * 错误原因 + */ + @SerializedName("errmsg") + private String errMsg; + + //region 类型定义 + @Data + public static class Order implements Serializable { + private static final long serialVersionUID = -1390355751615987663L; + /** + * 原支付交易对应的微信订单号 + */ + @SerializedName("transaction_id") + private String transactionId; + /** + * 支付下单商户的商户号,由微信支付生成并下发 + */ + @SerializedName("merchant_id") + private String merchantId; + /** + * 二级商户号 + */ + @SerializedName("sub_merchant_id") + private String subMerchantId; + /** + * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一。 + */ + @SerializedName("merchant_trade_no") + private String merchantTradeNo; + + /** + * 以分号连接的该支付单的所有商品描述,当超过120字时自动截断并以 “...” 结尾。 + */ + @SerializedName("description") + private String description; + + /** + * 支付单实际支付金额,整型,单位:分钱。 + */ + @SerializedName("paid_amount") + private Long paidAmount; + /** + * 支付者openid + */ + @SerializedName("openid") + private String openId; + + /** + * 交易创建时间,时间戳形式 + */ + @SerializedName("trade_create_time") + private Long tradeCreateTime; + /** + * 支付时间,时间戳形式。 + */ + @SerializedName("pay_time") + private Long payTime; + + /** + * 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款。 + */ + @SerializedName("order_state") + private Integer orderState; + /** + * 是否处在交易纠纷中 + */ + @SerializedName("in_complaint") + private Boolean inComplaint; + + /** + * 发货信息 + */ + @SerializedName("shipping") + private Shipping shipping; + } + + @Data + public static class Shipping implements Serializable { + + private static final long serialVersionUID = -3527308640256070121L; + + /** + * 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) 示例值: UNIFIED_DELIVERY + */ + @SerializedName("delivery_mode") + private Integer deliveryMode; + /** + * 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 + */ + @SerializedName("logistics_type") + private Integer logisticsType; + /** + * 是否已完成全部发货 + */ + @SerializedName("finish_shipping") + private Boolean finishShipping; + /** + * 在小程序后台发货信息录入页录入的商品描述 + */ + @SerializedName("goods_desc") + private String goodsDesc; + /** + * 已完成全部发货的次数,未完成时为 0,完成时为 1,重新发货并完成后为 2。 + */ + @SerializedName("finish_shipping_count") + private Integer finishShippingCount; + /** + * 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式。 + */ + @SerializedName("shipping_list") + private List shippingList; + + } + + @Data + public static class ShippingItem implements Serializable { + + private static final long serialVersionUID = 7064368114873624112L; + + /** + * 物流单号,示例值: "323244567777"。 + */ + @SerializedName("tracking_no") + private String trackingNo; + /** + * 同城配送公司名或物流公司编码,快递公司ID,参见「查询物流公司编码列表」 示例值: "DHL"。 + */ + @SerializedName("express_company") + private String expressCompany; + /** + * 使用上传物流信息 API 录入的该物流信息的商品描述。 + */ + @SerializedName("goods_desc") + private String goodsDesc; + /** + * 该物流信息的上传时间,时间戳形式。 + */ + @SerializedName("upload_time") + private Long uploadTime; + + /** + * 联系方式 + */ + @SerializedName("contact") + private Contact contact; + } + + @Data + public static class Contact implements Serializable { + private static final long serialVersionUID = -320914533207502380L; + + /** + * 寄件人联系方式 + */ + @SerializedName("consignor_contact") + private String consignorContact; + + /** + * 收件人联系方式 + */ + @SerializedName("receiver_contact") + private String receiverContact; + } + //endregion +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoGetListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoGetListResponse.java new file mode 100644 index 0000000000..2c40ad41ba --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoGetListResponse.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +public class WxMaOrderShippingInfoGetListResponse extends WxMaOrderShippingInfoBaseResponse implements Serializable { + private static final long serialVersionUID = -5414031943436195493L; + + /** + * 翻页时使用 + */ + @SerializedName("last_index") + private String lastIndex; + /** + * 是否还有更多支付单 + */ + @SerializedName("has_more") + private Boolean hasMore; + + /** + * 支付单信息列表。 + */ + @SerializedName("order_list") + private List orderList; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoGetResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoGetResponse.java new file mode 100644 index 0000000000..28e702fcbf --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingInfoGetResponse.java @@ -0,0 +1,22 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +public class WxMaOrderShippingInfoGetResponse extends WxMaOrderShippingInfoBaseResponse implements Serializable { + private static final long serialVersionUID = -5414031943436195493L; + + /** + * 支付单信息 + */ + @SerializedName("order") + private Order order; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingIsTradeManagedResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingIsTradeManagedResponse.java new file mode 100644 index 0000000000..4606298340 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaOrderShippingIsTradeManagedResponse.java @@ -0,0 +1,33 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author xzh + * created on 2023/5/17 17:01 + */ +@Data +public class WxMaOrderShippingIsTradeManagedResponse implements Serializable { + + private static final long serialVersionUID = -5397007157487018762L; + /** + * 错误码 + */ + @SerializedName("errcode") + private Integer errCode; + + /** + * 错误原因 + */ + @SerializedName("errmsg") + private String errMsg; + + /** + * 是否已开通小程序发货信息管理服务 + */ + @SerializedName("is_trade_managed") + private Boolean tradeManaged; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetBrandListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetBrandListResponse.java index a734126bc4..d38587ff40 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetBrandListResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetBrandListResponse.java @@ -10,7 +10,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetCategoryListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetCategoryListResponse.java index ba9ccee563..e1fd5c4fd6 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetCategoryListResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetCategoryListResponse.java @@ -10,7 +10,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetInfoResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetInfoResponse.java index f14a59ae5a..21c8bc0015 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetInfoResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAccountGetInfoResponse.java @@ -9,7 +9,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddOrderResponse.java index 4e724423bb..fa707b8aea 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddOrderResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddOrderResponse.java @@ -8,7 +8,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data @EqualsAndHashCode(callSuper = true) @@ -16,5 +16,5 @@ public class WxMaShopAddOrderResponse extends WxMaShopBaseResponse implements Se private static final long serialVersionUID = -8923439859095040010L; @SerializedName("data") - private WxMaShopAddOrderResult date; + private WxMaShopAddOrderResult data; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddSpuResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddSpuResponse.java index 4f5890c0de..34c87095f0 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddSpuResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAddSpuResponse.java @@ -8,7 +8,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleAddResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleAddResponse.java new file mode 100644 index 0000000000..1882923f78 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleAddResponse.java @@ -0,0 +1,15 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/28 11:29 上午 + */ +@Data +public class WxMaShopAfterSaleAddResponse extends WxMaShopBaseResponse implements Serializable { + @SerializedName("aftersale_id") + private String aftersaleId; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java index ac8f68db66..2261ad3dda 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java @@ -1,5 +1,6 @@ package cn.binarywang.wx.miniapp.bean.shop.response; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest.UploadMediaList; import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.EqualsAndHashCode; @@ -29,24 +30,43 @@ public static class AftersaleInfosBean implements Serializable { * product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}] */ - @SerializedName("out_order_id") - private String outOrderId; + @SerializedName("aftersale_id") + private Long aftersaleId; @SerializedName("out_aftersale_id") private String outAftersaleId; - @SerializedName("openid") - private String openid; + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("order_id") + private Long orderId; + @SerializedName("product_info") + private List productInfo; @SerializedName("type") private Integer type; - @SerializedName("create_time") - private String createTime; - @SerializedName("path") - private String path; + @SerializedName("return_info") + private ReturnInfo returnInfo; + @SerializedName("orderamt") + private Long orderamt; + @SerializedName("refund_reason") + private String refundReason; + @SerializedName("refund_reason_type") + private Integer refundReasonType; + @SerializedName("media_list") + private UploadMediaList mediaList; @SerializedName("status") private Integer status; - @SerializedName("refund") - private Long refund; - @SerializedName("product_infos") - private List productInfos; + @SerializedName("create_time") + private String createTime; + @SerializedName("update_time") + private String updateTime; + @SerializedName("openid") + private String openid; + @SerializedName("refund_pay_detail") + private RefundPayDetail refund_pay_detail; + @SerializedName("return_id") + private String returnId; + @SerializedName("complaint_order_id_list") + private List complaintOrderIdList; + @Data public static class ProductInfosBean implements Serializable { @@ -58,10 +78,32 @@ public static class ProductInfosBean implements Serializable { @SerializedName("out_product_id") private String outProductId; + @SerializedName("product_id") + private Long productId; @SerializedName("out_sku_id") private String outSkuId; + @SerializedName("sku_id") + private Long skuId; @SerializedName("product_cnt") private Integer productCnt; } + + @Data + public static class ReturnInfo { + @SerializedName("order_return_time") + private Long orderReturnTime; + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("waybill_id") + private String waybillId; + @SerializedName("delivery_name") + private String deliveryName; + } + + @Data + public static class RefundPayDetail { + @SerializedName("refund_id") + private String refundId; + } } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleListResponse.java new file mode 100644 index 0000000000..a5dd22cd96 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleListResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse.AftersaleInfosBean; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author leiin + * created on 2022/6/28 11:39 上午 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopAfterSaleListResponse extends WxMaShopBaseResponse implements Serializable { + @SerializedName("has_more") + private Boolean hasMore; + @SerializedName("after_sales_orders") + private List afterSalesOrders; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditBrandResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditBrandResponse.java index 59f7a6ff9c..f5c52ca85e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditBrandResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditBrandResponse.java @@ -8,7 +8,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditCategoryResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditCategoryResponse.java index db157fdddd..4aaa5803d9 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditCategoryResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditCategoryResponse.java @@ -8,7 +8,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditResultResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditResultResponse.java index 5f3fca5cc7..213885beec 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditResultResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAuditResultResponse.java @@ -8,7 +8,7 @@ /** * @author liming1019 - * @date 2021/8/12 + * created on 2021/8/12 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopBaseResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopBaseResponse.java index 4332c130c4..e4a015e9ab 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopBaseResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopBaseResponse.java @@ -8,7 +8,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data public class WxMaShopBaseResponse implements Serializable { @@ -21,7 +21,7 @@ public class WxMaShopBaseResponse implements Serializable { *
*/ @SerializedName("errcode") - private Integer errcode; + private Integer errCode; /** * 错误信息 @@ -30,5 +30,5 @@ public class WxMaShopBaseResponse implements Serializable { *
*/ @SerializedName("errmsg") - private String errmsg; + private String errMsg; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCatGetResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCatGetResponse.java index 2077027f29..bc16f77bb5 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCatGetResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCatGetResponse.java @@ -10,7 +10,7 @@ /** * @author liming1019 - * @date 2021/8/9 + * created on 2021/8/9 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCouponListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCouponListResponse.java new file mode 100644 index 0000000000..55544fd3d0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCouponListResponse.java @@ -0,0 +1,23 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/1 3:34 下午 + */ +@Data +public class WxMaShopCouponListResponse extends WxMaShopBaseResponse { + @SerializedName("total_num") + private Long totalNum; + @SerializedName("result_list") + private List resultList; + + @Data + public static class ResponseCouponResult { + private WxMaShopCouponInfo coupon; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCouponResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCouponResponse.java new file mode 100644 index 0000000000..db9da87a7f --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopCouponResponse.java @@ -0,0 +1,18 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/1 3:34 下午 + */ +@Data +public class WxMaShopCouponResponse extends WxMaShopBaseResponse { + private ResponseCouponResult result; + + @Data + public static class ResponseCouponResult { + private WxMaShopCouponInfo coupon; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopEcAfterSaleGetResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopEcAfterSaleGetResponse.java new file mode 100644 index 0000000000..fa03fabd0e --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopEcAfterSaleGetResponse.java @@ -0,0 +1,73 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author liming1019 + * created on 2022/8/25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMaShopEcAfterSaleGetResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = -338753264205536337L; + + @SerializedName("after_sales_order") + private AfterSalesOrderDTO afterSalesOrder; + + @Data + public static class AfterSalesOrderDTO implements Serializable { + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("aftersale_id") + private Long aftersaleId; + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("order_id") + private Long orderId; + @SerializedName("product_info") + private ProductInfoDTO productInfo; + @SerializedName("type") + private Integer type; + @SerializedName("return_info") + private ReturnInfoDTO returnInfo; + @SerializedName("orderamt") + private Integer orderamt; + @SerializedName("refund_reason_type") + private Integer refundReasonType; + @SerializedName("refund_reason") + private String refundReason; + @SerializedName("status") + private Integer status; + @SerializedName("create_time") + private String createTime; + @SerializedName("update_time") + private String updateTime; + + @Data + public static class ProductInfoDTO implements Serializable { + @SerializedName("out_product_id") + private String outProductId; + @SerializedName("out_sku_id") + private String outSkuId; + @SerializedName("product_cnt") + private Integer productCnt; + } + + @Data + public static class ReturnInfoDTO implements Serializable { + @SerializedName("order_return_time") + private String orderReturnTime; + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("waybill_id") + private String waybillId; + @SerializedName("delivery_name") + private String deliveryName; + } + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetOrderListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetOrderListResponse.java new file mode 100644 index 0000000000..ffe70cbc07 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetOrderListResponse.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import cn.binarywang.wx.miniapp.bean.shop.WxMaShopOrderResult; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author leiin + * created on 2021/3/23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMaShopGetOrderListResponse extends WxMaShopBaseResponse implements Serializable { + private static final long serialVersionUID = -81207907908726897L; + + /** + * 订单满足条件的总数 + */ + @SerializedName("total_num") + private Integer totalNum; + + /** + * 订单列表 + */ + @SerializedName("order") + private WxMaShopOrderResult order; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetOrderResponse.java index b55d163604..18c278096d 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetOrderResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetOrderResponse.java @@ -9,7 +9,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetPaymentParamsResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetPaymentParamsResponse.java new file mode 100644 index 0000000000..c7ae91947b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetPaymentParamsResponse.java @@ -0,0 +1,41 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 生成支付参数响应 + * + * @author zhongjun + * created on 2022/5/17 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMaShopGetPaymentParamsResponse extends WxMaShopBaseResponse implements Serializable { + private static final long serialVersionUID = -8796836131438585559L; + + @SerializedName("payment_params") + private PaymentParams paymentParams; + + @Getter + @Setter + public static class PaymentParams { + + private String timeStamp; + + private String nonceStr; + + @SerializedName("package") + private String packageValue; + + private String signType; + + private String paySign; + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuListResponse.java index b1b01978f2..d1e172f9e0 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuListResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuListResponse.java @@ -10,7 +10,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuResponse.java index be68f8ee84..05b9fdaca3 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopGetSpuResponse.java @@ -9,7 +9,7 @@ /** * @author leiin - * @date 2021/3/23 + * created on 2021/3/23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopPayCreateOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopPayCreateOrderResponse.java new file mode 100644 index 0000000000..f6c40ee0f0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopPayCreateOrderResponse.java @@ -0,0 +1,40 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author liming1019 + * created on 2022/8/10 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopPayCreateOrderResponse extends WxMaShopBaseResponse implements Serializable { + private static final long serialVersionUID = -375471325664721192L; + + @SerializedName("payment_params") + private PaymentParamsDTO paymentParams; + + @NoArgsConstructor + @Data + public static class PaymentParamsDTO { + @SerializedName("timeStamp") + private Integer timeStamp; + @SerializedName("nonceStr") + private String nonceStr; + @SerializedName("package") + private String packageX; + @SerializedName("paySign") + private String paySign; + @SerializedName("signType") + private String signType; + } +} + diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopPayGetOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopPayGetOrderResponse.java new file mode 100644 index 0000000000..745a85d5f4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopPayGetOrderResponse.java @@ -0,0 +1,102 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author liming1019 + * created on 2022/8/31 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopPayGetOrderResponse extends WxMaShopBaseResponse implements Serializable { + private static final long serialVersionUID = -3329915987130142268L; + + @SerializedName("order") + private OrderBean order; + + @Data + public static class OrderBean implements Serializable { + @SerializedName("trade_no") + private String tradeNo; + @SerializedName("transaction_id") + private String transactionId; + @SerializedName("combine_trade_no") + private String combineTradeNo; + @SerializedName("mchid") + private String mchid; + @SerializedName("create_time") + private int createTime; + @SerializedName("update_time") + private int updateTime; + @SerializedName("pay_time") + private int payTime; + @SerializedName("expire_time") + private int expireTime; + @SerializedName("amount") + private int amount; + @SerializedName("description") + private String description; + @SerializedName("profit_sharing_delay") + private int profitSharingDelay; + @SerializedName("profit_sharing_frozen") + private int profitSharingFrozen; + @SerializedName("refund_list") + private List refundList; + @SerializedName("profit_sharing_list") + private List profitSharingList; + + @Data + public static class RefundListBean implements Serializable { + @SerializedName("amount") + private int amount; + @SerializedName("create_time") + private int createTime; + @SerializedName("finish_time") + private int finishTime; + @SerializedName("result") + private String result; + @SerializedName("refund_id") + private String refundId; + @SerializedName("refund_no") + private String refundNo; + } + + @Data + public static class ProfitSharingListBean implements Serializable { + /** + * mchid : 1623426221 + * amount : 1 + * create_time : 1648880985 + * finish_time : 1648881016 + * result : SUCCESS + * profit_sharing_id : 30002107912022040228952584675 + * profit_sharing_no : 512341 + */ + + @SerializedName("mchid") + private String mchid; + @SerializedName("amount") + private int amount; + @SerializedName("create_time") + private int createTime; + @SerializedName("finish_time") + private int finishTime; + @SerializedName("result") + private String result; + @SerializedName("profit_sharing_id") + private String profitSharingId; + @SerializedName("profit_sharing_no") + private String profitSharingNo; + } + } +} + diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopRegisterCheckResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopRegisterCheckResponse.java index 494a70ff42..d94bcfc494 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopRegisterCheckResponse.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopRegisterCheckResponse.java @@ -9,7 +9,7 @@ /** * @author liming1019 - * @date 2021/8/5 + * created on 2021/8/5 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSearchSharerResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSearchSharerResponse.java new file mode 100644 index 0000000000..ac0ff4b7d0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSearchSharerResponse.java @@ -0,0 +1,24 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/18 2:58 下午 + */ +@Data +public class WxMaShopSearchSharerResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = 2049214239752832818L; + + @SerializedName("invited_time") + private Long invitedTime; + @SerializedName("bind_time") + private Long bindTime; + @SerializedName("nickname") + private String nickname; + @SerializedName("bind_status") + private Integer bindStatus; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerBindResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerBindResponse.java new file mode 100644 index 0000000000..b540ae70d4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerBindResponse.java @@ -0,0 +1,40 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * @author leiin + * created on 2022/6/18 2:51 下午 + */ +@Data +public class WxMaShopSharerBindResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = 5648529892711033276L; + + @SerializedName("success_list") + private List successList; + + @SerializedName("fail_list") + private List failList; + + @SerializedName("refuse_list") + private List refuseList; + + @SerializedName("result_list") + private List resultList; + + @Getter + @Setter + public static class ResultListItem { + private String openid; + @SerializedName("result_code") + private Integer resultCode; + @SerializedName("reason_code") + private Integer reasonCode; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerDataSummaryResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerDataSummaryResponse.java new file mode 100644 index 0000000000..3b712fe120 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerDataSummaryResponse.java @@ -0,0 +1,21 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/18 2:53 下午 + */ +@Data +public class WxMaShopSharerDataSummaryResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = 3985829585979186778L; + + private Long gmv; + @SerializedName("order_cnt") + private Long orderCnt; + @SerializedName("user_cnt") + private Long userCnt; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerListResponse.java new file mode 100644 index 0000000000..33d936e153 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerListResponse.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/18 2:55 下午 + */ +@Data +public class WxMaShopSharerListResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = -8533731677643022825L; + + private List sharers; + @SerializedName("total_num") + private Integer totalNum; + + @Data + public static class SharerInfo { + private String openid; + @SerializedName("invited_time") + private Long invitedTime; + @SerializedName("bind_time") + private Long bindTime; + private String nickname; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerLiveOrderListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerLiveOrderListResponse.java new file mode 100644 index 0000000000..a6c02fcdc5 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerLiveOrderListResponse.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import cn.binarywang.wx.miniapp.bean.shop.WxMaShopOrderDetail; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/18 2:56 下午 + */ +@Data +public class WxMaShopSharerLiveOrderListResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = -4190199778148290127L; + + private List orders; + + @SerializedName("total_num") + private Integer totalNum; + + @Data + public static class WxMaShopOrderItem { + @SerializedName("order_id") + private Long orderId; + @SerializedName("out_order_id") + private String outOrderId; + private Integer status; + private String path; + @SerializedName("order_detail") + private WxMaShopOrderDetail orderDetail; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerLiveSummaryListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerLiveSummaryListResponse.java new file mode 100644 index 0000000000..f0b2cc3956 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerLiveSummaryListResponse.java @@ -0,0 +1,41 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/18 2:57 下午 + */ +@Data +public class WxMaShopSharerLiveSummaryListResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = -2085366863029618067L; + + private List lives; + + @SerializedName("total_num") + private Integer totalNum; + + @Data + public static class LiveSummaryItem { + @SerializedName("live_export_id") + private String liveExportId; + @SerializedName("live_nickname") + private String liveNickname; + @SerializedName("live_start_time") + private Long liveStartTime; + @SerializedName("live_end_time") + private Long liveEndTime; + @SerializedName("live_status") + private Long liveStatus; + @SerializedName("gmv") + private Long gmv; + @SerializedName("order_cnt") + private Long orderCnt; + @SerializedName("user_cnt") + private Long userCnt; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerUnbindResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerUnbindResponse.java new file mode 100644 index 0000000000..d995ee40b6 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopSharerUnbindResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/6/18 3:00 下午 + */ +@Data +public class WxMaShopSharerUnbindResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = -9015680115600175408L; + + @SerializedName("success_list") + private List successList; + + @SerializedName("fail_list") + private List failList; + + @SerializedName("refuse_list") + private List refuseList; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopUserCouponListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopUserCouponListResponse.java new file mode 100644 index 0000000000..932e46ccca --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopUserCouponListResponse.java @@ -0,0 +1,76 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * @author leiin + * created on 2022/7/1 3:59 下午 + */ +@Data +public class WxMaShopUserCouponListResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = 3264119403757388410L; + + @SerializedName("total_num") + private Long totalNum; + @SerializedName("result_list") + private List resultList; + + @Data + public static class UserCouponResultItem { + + /** + * 商家侧用户优惠券ID + */ + @SerializedName("out_user_coupon_id") + private String outUserCouponId; + /** + * openid + */ + @SerializedName("openid") + private String openid; + /** + * 商家侧优惠券ID + */ + @SerializedName("out_coupon_id") + private String outCouponId; + /** + * 用户优惠券状态 + */ + @SerializedName("status") + private Integer status; + /** + * 用户优惠券创建时间 + */ + @SerializedName("create_time") + private Long createTime; + /** + * 用户优惠券更新时间 + */ + @SerializedName("update_time") + private Long updateTime; + /** + * 用户优惠券有效开始时间 + */ + @SerializedName("start_time") + private Long startTime; + /** + * 用户优惠券有效结束时间 + */ + @SerializedName("end_time") + private Long endTime; + + @SerializedName("ext_info") + private UserCouponExtInfo extInfo; + + @Data + public static class UserCouponExtInfo { + @SerializedName("use_time") + private Long useTime; + } + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/GenerateUrlLinkRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/GenerateUrlLinkRequest.java index 207aa3deee..5bf52967c2 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/GenerateUrlLinkRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/GenerateUrlLinkRequest.java @@ -1,9 +1,11 @@ package cn.binarywang.wx.miniapp.bean.urllink; -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 lombok.experimental.Accessors; import java.io.Serializable; @@ -16,6 +18,9 @@ */ @Data @Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor public class GenerateUrlLinkRequest implements Serializable { private static final long serialVersionUID = -2183685760797791910L; @@ -36,6 +41,15 @@ public class GenerateUrlLinkRequest implements Serializable { */ private String query; + /** + * 要打开的小程序版本。正式版为"release",体验版为"trial",开发版为"develop",仅在微信外打开时生效。 + *
+   * 是否必填: 否
+   * 
+ */ + @SerializedName("env_version") + private String envVersion = "release"; + /** * 生成的 URL Link 类型,到期失效:true,永久有效:false *
@@ -62,7 +76,7 @@ public class GenerateUrlLinkRequest implements Serializable {
    * 
*/ @SerializedName("expire_time") - private Integer expireTime; + private Long expireTime; /** * 到期失效的URL Link的失效间隔天数。生成的到期失效URL Link在该间隔时间到达前有效。最长间隔天数为365天。expire_type 为 1 必填 diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/request/QueryUrlLinkRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/request/QueryUrlLinkRequest.java new file mode 100644 index 0000000000..cea89f9fdc --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/request/QueryUrlLinkRequest.java @@ -0,0 +1,35 @@ +package cn.binarywang.wx.miniapp.bean.urllink.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + *
+ * 查询小程序 URL Link参数对象
+ * 
+ * @author imyzt + * @since 2023-11-13 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class QueryUrlLinkRequest implements Serializable { + + /** + * 小程序 url_link + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("url_link") + private String urlLink; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/response/QueryUrlLinkResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/response/QueryUrlLinkResponse.java new file mode 100644 index 0000000000..340192eb57 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/response/QueryUrlLinkResponse.java @@ -0,0 +1,79 @@ +package cn.binarywang.wx.miniapp.bean.urllink.response; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + *
+ * 查询小程序 URL Link响应对象
+ * 
+ * @author imyzt + * @since 2023-11-13 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class QueryUrlLinkResponse extends WxMaBaseResponse implements Serializable { + + /** + * 访问Link的用户openid,为空表示未被访问过 + */ + @SerializedName("visit_openid") + private String visitOpenid; + + /** + * url_link 配置 + */ + @SerializedName("url_link_info") + private UrlLinkInfo urlLinkInfo; + + @Data + @Builder + public static class UrlLinkInfo { + + /** + * 小程序 appid + */ + private String appid; + + /** + * 小程序页面路径 + */ + private String path; + + /** + * 小程序页面query + */ + private String query; + + /** + * 创建时间,为 Unix 时间戳 + */ + @SerializedName("create_time") + private Long createTime; + + /** + * 到期失效时间,为 Unix 时间戳,0 表示永久生效 + */ + @SerializedName("expire_time") + private Long expireTime; + + /** + * 要打开的小程序版本。正式版为"release",体验版为"trial",开发版为"develop" + */ + @SerializedName("env_version") + private String envVersion; + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodApplyUploadRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodApplyUploadRequest.java new file mode 100644 index 0000000000..3e832666ca --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodApplyUploadRequest.java @@ -0,0 +1,33 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodApplyUploadRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_name") + private String mediaName; + @SerializedName("media_type") + private String mediaType; + @SerializedName("cover_type") + private String coverType; + + @SerializedName("source_context") + private String sourceContext; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodApplyUploadResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodApplyUploadResponse.java new file mode 100644 index 0000000000..fd7d625cd1 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodApplyUploadResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodApplyUploadResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("upload_id") + private String uploadId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaRequest.java new file mode 100644 index 0000000000..87d53fcc6c --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaRequest.java @@ -0,0 +1,46 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodAuditDramaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("name") + private String name; + @SerializedName("media_count") + private Long mediaCount; + @SerializedName("media_id_list") + private List mediaIdList; + @SerializedName("producer") + private String producer; + @SerializedName("cover_material_id") + private String coverMaterialId; + @SerializedName("authorized_material_id") + private String authorizedMaterialId; + @SerializedName("registration_number") + private String registrationNumber; + @SerializedName("publish_license") + private String publishLicense; + @SerializedName("publish_license_material_id") + private String publishLicenseMaterialId; + @SerializedName("expedited") + private Long expedited; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaResponse.java new file mode 100644 index 0000000000..b456443415 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodAuditDramaResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("drama_id") + private Integer dramaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnLogRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnLogRequest.java new file mode 100644 index 0000000000..bb9bffa614 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnLogRequest.java @@ -0,0 +1,32 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodCdnLogRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("offset") + private Integer offset; + @SerializedName("limit") + private Integer limit; + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnLogResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnLogResponse.java new file mode 100644 index 0000000000..b6d758b8e4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnLogResponse.java @@ -0,0 +1,40 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodCdnLogResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + @SerializedName("total_count") + private Integer totalCount; + @SerializedName("domestic_cdn_logs") + private List domesticCdnLogs; + + @Data + public static class CdnLogInfo { + @SerializedName("date") + private Long date; + @SerializedName("name") + private String name; + @SerializedName("url") + private String url; + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnUsageRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnUsageRequest.java new file mode 100644 index 0000000000..a462b78113 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnUsageRequest.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodCdnUsageRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("data_interval") + private Integer dataInterval; + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnUsageResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnUsageResponse.java new file mode 100644 index 0000000000..9b89af59a4 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCdnUsageResponse.java @@ -0,0 +1,36 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodCdnUsageResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + @SerializedName("data_interval") + private Integer dataInterval; + @SerializedName("item_list") + private List itemList; + + @Data + public static class DataItem { + + @SerializedName("value") + private Long value; + @SerializedName("time") + private Long time; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCommitUploadRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCommitUploadRequest.java new file mode 100644 index 0000000000..a2be6fe095 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCommitUploadRequest.java @@ -0,0 +1,39 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodCommitUploadRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("upload_id") + private String uploadId; + @SerializedName("media_part_infos") + private List mediaPartInfos; + @SerializedName("cover_part_infos") + private List coverPartInfos; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class PartInfo { + + @SerializedName("part_number") + private Integer partNumber; + @SerializedName("etag") + private String etag; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCommitUploadResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCommitUploadResponse.java new file mode 100644 index 0000000000..fd967844c6 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodCommitUploadResponse.java @@ -0,0 +1,26 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodCommitUploadResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("media_id") + private Integer mediaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDeleteMediaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDeleteMediaRequest.java new file mode 100644 index 0000000000..a553e21092 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDeleteMediaRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodDeleteMediaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_id") + private Integer mediaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDramaInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDramaInfo.java new file mode 100644 index 0000000000..405f8e37c8 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDramaInfo.java @@ -0,0 +1,64 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodDramaInfo implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + + private String name; + private String producer; + private String playwright; + + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("create_time") + private Long createTime; + @SerializedName("cover_url") + private String coverUrl; + @SerializedName("media_count") + private Long mediaCount; + @SerializedName("expedited") + private Long expedited; + @SerializedName("production_license") + private String productionLicense; + @SerializedName("description") + private String description; + + @SerializedName("audit_detail") + private DramaAuditDetail auditDetail; + @SerializedName("media_list") + private List mediaList; + + @Data + public static class DramaAuditDetail { + + @SerializedName("status") + private Integer status; + @SerializedName("create_time") + private Long createTime; + @SerializedName("audit_time") + private Long auditTime; + } + + @Data + public static class DramaMediaInfo { + + @SerializedName("media_id") + private Integer mediaId; + + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnLogRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnLogRequest.java new file mode 100644 index 0000000000..33acf43149 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnLogRequest.java @@ -0,0 +1,32 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetCdnLogRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("offset") + private Integer offset; + @SerializedName("limit") + private Integer limit; + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnLogResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnLogResponse.java new file mode 100644 index 0000000000..90dd22298d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnLogResponse.java @@ -0,0 +1,40 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodGetCdnLogResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + @SerializedName("total_count") + private Integer totalCount; + @SerializedName("domestic_cdn_logs") + private List domesticCdnLogs; + + @Data + public static class CdnLogInfo { + @SerializedName("date") + private Long date; + @SerializedName("name") + private String name; + @SerializedName("url") + private String url; + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnUsageRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnUsageRequest.java new file mode 100644 index 0000000000..377f7c9b8b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnUsageRequest.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetCdnUsageRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("data_interval") + private Integer dataInterval; + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnUsageResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnUsageResponse.java new file mode 100644 index 0000000000..0789a8484d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetCdnUsageResponse.java @@ -0,0 +1,36 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodGetCdnUsageResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + @SerializedName("data_interval") + private Integer dataInterval; + @SerializedName("item_list") + private List itemList; + + @Data + public static class DataItem { + + @SerializedName("value") + private Long value; + @SerializedName("time") + private Long time; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaRequest.java new file mode 100644 index 0000000000..58c902f18f --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetDramaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("drama_id") + private Integer dramaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaResponse.java new file mode 100644 index 0000000000..eaffa6782d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaResponse.java @@ -0,0 +1,26 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetDramaResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("drama_info") + private WxMaVodDramaInfo dramaInfo; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkRequest.java new file mode 100644 index 0000000000..81200c8ff0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkRequest.java @@ -0,0 +1,39 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaLinkRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_id") + private Integer mediaId; + @SerializedName("t") + private Long t; + + @SerializedName("expr") + private Long expr; + @SerializedName("rlimit") + private Long rlimit; + + @SerializedName("us") + private String us; + @SerializedName("whref") + private String whRef; + @SerializedName("bkref") + private String bkRef; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkResponse.java new file mode 100644 index 0000000000..044e6268ad --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkResponse.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaLinkResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_info") + private WxMaVodMediaPlaybackInfo mediaInfo; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaRequest.java new file mode 100644 index 0000000000..1756171340 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_id") + private Integer mediaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaResponse.java new file mode 100644 index 0000000000..f33b822fe5 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaResponse.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_info") + private WxMaVodMediaInfo mediaInfo; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskRequest.java new file mode 100644 index 0000000000..5609442bbd --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetTaskRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("task_id") + private Integer taskId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskResponse.java new file mode 100644 index 0000000000..bc75c8c107 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskResponse.java @@ -0,0 +1,45 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetTaskResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("task_info") + private TaskInfo taskInfo; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class TaskInfo { + + @SerializedName("task_type") + private Integer taskType; + @SerializedName("status") + private Integer status; + @SerializedName("errcode") + private Integer errCode; + @SerializedName("errmsg") + private String errMsg; + @SerializedName("create_time") + private Long createTime; + @SerializedName("finish_time") + private Long finishTime; + @SerializedName("media_id") + private Integer mediaId; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListDramaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListDramaRequest.java new file mode 100644 index 0000000000..55dc79d4be --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListDramaRequest.java @@ -0,0 +1,28 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodListDramaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + + @SerializedName("offset") + private Integer offset; + @SerializedName("limit") + private Integer limit; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListMediaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListMediaRequest.java new file mode 100644 index 0000000000..ace2c3b749 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListMediaRequest.java @@ -0,0 +1,37 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodListMediaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("media_name") + private String mediaName; + + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + @SerializedName("offset") + private Integer offset; + @SerializedName("limit") + private Integer limit; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaInfo.java new file mode 100644 index 0000000000..53b4f1c0bf --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaInfo.java @@ -0,0 +1,76 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 小程序帐号的可选类目,其中 address / tag / title 是提交审核会用到的 + *

+ * media_id number 媒资文件id。 + * create_time number 上传时间,时间戳。 + * expire_time number 过期时间,时间戳。 + * drama_id number 所属剧目id。 + * file_size string 媒资文件大小,单位:字节。 + * duration number 播放时长,单位:秒。 + * name string 媒资文件名。 + * description string 描述。 + * cover_url string 封面图临时链接。 + * original_url string 原始视频临时链接。 + * mp4_url string mp4格式临时链接 。 + * hls_url string hls格式临时链接。 + * audit_detail MediaAuditDetail 审核信息。 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodMediaInfo implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + private String name; + private String description; + @SerializedName("media_id") + private Integer mediaId; + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("create_time") + private Long createTime; + @SerializedName("file_size") + private String fileSize; + @SerializedName("duration") + private Long duration; + @SerializedName("expire_time") + private Long expireTime; + @SerializedName("cover_url") + private String coverUrl; + @SerializedName("original_url") + private String originalUrl; + @SerializedName("mp4_url") + private String mp4Url; + @SerializedName("hls_url") + private String hlsUrl; + @SerializedName("audit_detail") + private MediaAuditDetail auditDetail; + + @Data + public static class MediaAuditDetail { + + @SerializedName("status") + private Integer status; + @SerializedName("create_time") + private Long createTime; + @SerializedName("audit_time") + private Long auditTime; + @SerializedName("reason") + private String reason; + @SerializedName("evidence_material_id_list") + private List evidenceMaterialIdList; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaPlaybackInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaPlaybackInfo.java new file mode 100644 index 0000000000..a4746d5e5b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaPlaybackInfo.java @@ -0,0 +1,35 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodMediaPlaybackInfo implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + + private String name; + private String description; + @SerializedName("media_id") + private Integer mediaId; + @SerializedName("duration") + private Long duration; + + @SerializedName("cover_url") + private String coverUrl; + @SerializedName("mp4_url") + private String mp4Url; + @SerializedName("hls_url") + private String hlsUrl; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodPullUploadRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodPullUploadRequest.java new file mode 100644 index 0000000000..7dcda5baa5 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodPullUploadRequest.java @@ -0,0 +1,32 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodPullUploadRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("cover_url") + private String coverUrl; + @SerializedName("media_url") + private String mediaUrl; + @SerializedName("media_name") + private String mediaName; + + @SerializedName("source_context") + private String sourceContext; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodPullUploadResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodPullUploadResponse.java new file mode 100644 index 0000000000..7816354f14 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodPullUploadResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodPullUploadResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("task_id") + private Integer taskId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodSingleFileUploadResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodSingleFileUploadResult.java new file mode 100644 index 0000000000..ffbbd27691 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodSingleFileUploadResult.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + + +@Data +public class WxMaVodSingleFileUploadResult extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_id") + private Integer mediaId; + + public static WxMaVodSingleFileUploadResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMaVodSingleFileUploadResult.class); + } + + @Override + public String toString() { + return WxGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodUploadPartResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodUploadPartResult.java new file mode 100644 index 0000000000..38c5da8104 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodUploadPartResult.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + + +@Data +public class WxMaVodUploadPartResult extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("etag") + private String etag; + + public static WxMaVodUploadPartResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMaVodUploadPartResult.class); + } + + @Override + public String toString() { + return WxGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCancelCurrencyPayRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCancelCurrencyPayRequest.java new file mode 100644 index 0000000000..eb0a8e3d52 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCancelCurrencyPayRequest.java @@ -0,0 +1,47 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayCancelCurrencyPayRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("openid") + private String openid; + @SerializedName("env") + private Integer env; + @SerializedName("user_ip") + private String userIp; + + /* + * 退款单的单号 + */ + @SerializedName("order_id") + private String orderId; + /* + * 代币支付时传的order_id + */ + @SerializedName("pay_order_id") + private String payOrderId; + /* + * 退款金额 + */ + @SerializedName("amount") + private Long amount; + @SerializedName("device_type") + private Integer deviceType; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCancelCurrencyPayResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCancelCurrencyPayResponse.java new file mode 100644 index 0000000000..0c19f6bfb1 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCancelCurrencyPayResponse.java @@ -0,0 +1,26 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayCancelCurrencyPayResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @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/bean/xpay/WxMaXPayCreateWithdrawOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCreateWithdrawOrderRequest.java new file mode 100644 index 0000000000..7acab79417 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCreateWithdrawOrderRequest.java @@ -0,0 +1,29 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayCreateWithdrawOrderRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("env") + private Integer env; + + @SerializedName("withdraw_no") + private String withdrawNo; + @SerializedName("withdraw_amount") + private String withdrawAmount; //提现的金额,单位元,不传的情况下表示全额提现 + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCreateWithdrawOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCreateWithdrawOrderResponse.java new file mode 100644 index 0000000000..b174a7b2c0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCreateWithdrawOrderResponse.java @@ -0,0 +1,28 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayCreateWithdrawOrderResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("withdraw_no") + private String withdrawNo; + @SerializedName("wx_withdraw_no") + private String wxWithdrawNo; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCurrencyPayRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCurrencyPayRequest.java new file mode 100644 index 0000000000..32f8a018db --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCurrencyPayRequest.java @@ -0,0 +1,43 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayCurrencyPayRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("openid") + private String openid; + @SerializedName("env") + private Integer env; + @SerializedName("user_ip") + private String userIp; + + @SerializedName("amount") + private Long amount; + + @SerializedName("order_id") + private String orderId; + + @SerializedName("device_type") + private Integer deviceType; + + @SerializedName("payitem") + private String payitem;//物品信息。记录到账户流水中。如:[{"productid":"物品id", "unit_price": 单价, "quantity": 数量}] + + @SerializedName("remark") + private String remark; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCurrencyPayResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCurrencyPayResponse.java new file mode 100644 index 0000000000..4170f04125 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayCurrencyPayResponse.java @@ -0,0 +1,31 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayCurrencyPayResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("balance") + private Long balance; + + @SerializedName("used_present_amount") + private Long usedPresentAmount; + @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/bean/xpay/WxMaXPayDownloadBillRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayDownloadBillRequest.java new file mode 100644 index 0000000000..995638fe22 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayDownloadBillRequest.java @@ -0,0 +1,27 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayDownloadBillRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("begin_ds") + private Integer beginDs; + @SerializedName("end_ds") + private Integer endDs; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayDownloadBillResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayDownloadBillResponse.java new file mode 100644 index 0000000000..23f93b1bb3 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayDownloadBillResponse.java @@ -0,0 +1,25 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayDownloadBillResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("url") + private String url; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayNotifyProvideGoodsRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayNotifyProvideGoodsRequest.java new file mode 100644 index 0000000000..6afa4ad6fa --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayNotifyProvideGoodsRequest.java @@ -0,0 +1,30 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayNotifyProvideGoodsRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("env") + private Integer env; + + @SerializedName("order_id") + private String orderId; + @SerializedName("wx_order_id") + private String wxOrderId; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentCurrencyRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentCurrencyRequest.java new file mode 100644 index 0000000000..6081c12416 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentCurrencyRequest.java @@ -0,0 +1,35 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayPresentCurrencyRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("openid") + private String openid; + @SerializedName("env") + private Integer env; + + @SerializedName("order_id") + private String orderId; + + @SerializedName("device_type") + private Integer deviceType; + + @SerializedName("amount") + private Long amount; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentCurrencyResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentCurrencyResponse.java new file mode 100644 index 0000000000..6c5838bbc6 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentCurrencyResponse.java @@ -0,0 +1,31 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayPresentCurrencyResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("balance") + private Long balance; + + @SerializedName("present_balance") + private Long presentBalance; + @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/bean/xpay/WxMaXPayQueryOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryOrderRequest.java new file mode 100644 index 0000000000..a042a2b2ee --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryOrderRequest.java @@ -0,0 +1,38 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryOrderRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("openid") + private String openid; + + @SerializedName("env") + private Integer env; + + /* + * 创建的订单号 + */ + @SerializedName("order_id") + private String orderId; + /* + * 微信内部单号(与order_id二选一) + */ + @SerializedName("wx_order_id") + private String wxOrderId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryOrderResponse.java new file mode 100644 index 0000000000..a0edf409bd --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryOrderResponse.java @@ -0,0 +1,65 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryOrderResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("order") + private OrderInfo order; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class OrderInfo { + @SerializedName("order_id") + private String orderId; + @SerializedName("create_time") + private Long createTime; + @SerializedName("update_time") + private Long updateTime; + @SerializedName("status") + private Integer status; + @SerializedName("biz_type") + private Integer bizType; + @SerializedName("order_fee") + private Long orderFee; + @SerializedName("coupon_fee") + private Long couponFee; + @SerializedName("paid_fee") + private Long paidFee; + @SerializedName("order_type") + private Integer orderType; + @SerializedName("refund_fee") + private Long refundFee; + @SerializedName("paid_time") + private Long paidTime;//unix秒级时间戳 + @SerializedName("provide_time") + private Long provideTime; + @SerializedName("env_type") + private Long envType; + @SerializedName("biz_meta") + private String bizMeta; + @SerializedName("token") + private String token; + + @SerializedName("leftFee") + private Long leftFee; //支付单类型时表示此单经过退款还剩余的金额,单位分 + @SerializedName("wxOrderId") + private String wxOrderId; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryPublishGoodsRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryPublishGoodsRequest.java new file mode 100644 index 0000000000..d6ee653f1b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryPublishGoodsRequest.java @@ -0,0 +1,24 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryPublishGoodsRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("env") + private Integer env; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryPublishGoodsResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryPublishGoodsResponse.java new file mode 100644 index 0000000000..8daabe0685 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryPublishGoodsResponse.java @@ -0,0 +1,39 @@ +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; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryPublishGoodsResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("status") + private Integer status; + @SerializedName("publish_item") + private List publishItem; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class PublishItem { + @SerializedName("id") + private String id; + @SerializedName("publish_status") + private Integer publishStatus; + @SerializedName("errmsg") + private String errmsg; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUploadGoodsRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUploadGoodsRequest.java new file mode 100644 index 0000000000..56fd43993d --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUploadGoodsRequest.java @@ -0,0 +1,24 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryUploadGoodsRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("env") + private Integer env; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUploadGoodsResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUploadGoodsResponse.java new file mode 100644 index 0000000000..2f3199ab41 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUploadGoodsResponse.java @@ -0,0 +1,47 @@ +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; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryUploadGoodsResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("status") + private Integer status; + @SerializedName("upload_item") + private List uploadItem; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class UploadItem { + @SerializedName("id") + private String id; + @SerializedName("name") + private String name; + @SerializedName("price") + private Integer price; + @SerializedName("remark") + private String remark; + @SerializedName("item_url") + private String itemUrl; + @SerializedName("upload_status") + private Integer uploadStatus; + @SerializedName("errmsg") + private String errmsg; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUserBalanceRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUserBalanceRequest.java new file mode 100644 index 0000000000..df48c276f9 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUserBalanceRequest.java @@ -0,0 +1,29 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryUserBalanceRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("user_ip") + private String userIp; + @SerializedName("openid") + private String openid; + @SerializedName("env") + private Integer env; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUserBalanceResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUserBalanceResponse.java new file mode 100644 index 0000000000..5bb1f40536 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryUserBalanceResponse.java @@ -0,0 +1,39 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryUserBalanceResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("balance") + private Long balance; + + @SerializedName("present_balance") + private Long presentBalance; + @SerializedName("sum_save") + private Long sumSave; + @SerializedName("sum_present") + private Long sumPresent; + @SerializedName("sum_balance") + private Long sumBalance; + @SerializedName("sum_cost") + private Long sumCost; + @SerializedName("first_save_flag") + private Boolean firstSaveFlag; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryWithdrawOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryWithdrawOrderRequest.java new file mode 100644 index 0000000000..df25518709 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryWithdrawOrderRequest.java @@ -0,0 +1,27 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryWithdrawOrderRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("env") + private Integer env; + + @SerializedName("withdraw_no") + private String withdrawNo; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryWithdrawOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryWithdrawOrderResponse.java new file mode 100644 index 0000000000..eaccd3d004 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryWithdrawOrderResponse.java @@ -0,0 +1,39 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayQueryWithdrawOrderResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("withdraw_no") + private String withdrawNo; + @SerializedName("withdraw_amount") + private String withdrawAmount; //提现的金额,单位元,不传的情况下表示全额提现 + + @SerializedName("wx_withdraw_no") + private String wxWithdrawNo; + + @SerializedName("status") + private Integer status; + @SerializedName("withdraw_success_timestamp") + private String withdrawSuccessTimestamp; + @SerializedName("create_time") + private String createTime; + @SerializedName("fail_reason") + private String failReason; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayRefundOrderRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayRefundOrderRequest.java new file mode 100644 index 0000000000..bf9d68c299 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayRefundOrderRequest.java @@ -0,0 +1,46 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayRefundOrderRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("openid") + private String openid; + @SerializedName("env") + private Integer env; + @SerializedName("order_id") + private String orderId; + @SerializedName("wx_order_id") + private String wxOrderId; + @SerializedName("refund_order_id") + private String refundOrderId; + + + @SerializedName("left_fee") + private Long leftFee; + @SerializedName("refund_fee") + private Long refundFee; + @SerializedName("biz_meta") + private String bizMeta; + + @SerializedName("refund_reason") + private String refundReason; + + @SerializedName("req_from") + private String reqFrom; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayRefundOrderResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayRefundOrderResponse.java new file mode 100644 index 0000000000..20ddf2a8ac --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayRefundOrderResponse.java @@ -0,0 +1,33 @@ +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; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayRefundOrderResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("refund_order_id") + private String refundOrderId; + @SerializedName("refund_wx_order_id") + private String refundWxOrderId; + @SerializedName("pay_order_id") + private String payOrderId; + + @SerializedName("pay_wx_order_id") + private String payWxOrderId; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPaySigParams.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPaySigParams.java new file mode 100644 index 0000000000..089f2d5390 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPaySigParams.java @@ -0,0 +1,91 @@ +package cn.binarywang.wx.miniapp.bean.xpay; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.SignUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPaySigParams implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + private String sessionKey; + private String appKey; + + public String signUriWithBoth(String url, String postData) { + final String sig = this.calcSig(postData); + final String paySig = this.calcPaySig(url, postData); + final String uri = String.format(url, paySig, sig); + return uri; + } + + public String signUriWithPay(String url, String postData) { + final String paySig = this.calcPaySig(url, postData); + final String uri = String.format(url, paySig); + return uri; + } + + public String signUriWithUser(String url, String postData) { + final String sig = this.calcSig(postData); + final String uri = String.format(url, sig); + return uri; + } + + protected String convUrlToSigUri(String url) { + if (url == null) return ""; + + String t = url.replace("https://api.weixin.qq.com", ""); + if (t.contains("?")) { + t = t.substring(0, t.indexOf("?")); + } + return t; + } + + public String calcPaySig(String url, String postBody) { + String ak = StringUtils.trimToEmpty(this.appKey); + final String sigUri = convUrlToSigUri(url); + final String paySig = calcPaySignature(sigUri, postBody, ak); + return paySig; + } + + public String calcSig(String postBody) { + String sk = StringUtils.trimToEmpty(this.sessionKey); + final String sig = calcSignature(postBody, sk); + return sig; + } + + protected String calcSignature(String postBody, String sessionKey) { +// """ 用户登录态signature签名算法 +// Args: +// postBody - http POST的数据包体 +// sessionKey - 当前用户有效的session_key,参考auth.code2Session接口 +// Returns: +// 用户登录态签名signature +// """ + String needSignData = postBody; + String signature = SignUtils.createHmacSha256Sign(needSignData, sessionKey); + return signature; + } + + + protected String calcPaySignature(String uri, String postBody, String appKey) { +// """ pay_sig签名算法 +// Args: +// uri - 当前请求的API的uri部分,不带query_string 例如:/xpay/query_user_balance +// postBody - http POST的数据包体 +// appKey - 对应环境的AppKey +// Returns: +// 支付请求签名pay_sig +// """ + String needSignData = uri + '&' + postBody; + String paySig = SignUtils.createHmacSha256Sign(needSignData, appKey); + return paySig; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayStartPublishGoodsRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayStartPublishGoodsRequest.java new file mode 100644 index 0000000000..9163c69ad1 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayStartPublishGoodsRequest.java @@ -0,0 +1,35 @@ +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; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayStartPublishGoodsRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("env") + private Integer env; + + @SerializedName("publish_item") + private List publishItem; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class PublishItem { + @SerializedName("id") + private String id; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayStartUploadGoodsRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayStartUploadGoodsRequest.java new file mode 100644 index 0000000000..ebd7c51342 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayStartUploadGoodsRequest.java @@ -0,0 +1,43 @@ +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; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayStartUploadGoodsRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("env") + private Integer env; + + @SerializedName("upload_item") + private List uploadItem; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class UploadItem { + @SerializedName("id") + private String id; + @SerializedName("name") + private String name; + @SerializedName("price") + private Integer price; + @SerializedName("remark") + private String remark; + @SerializedName("item_url") + private String itemUrl; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaConfig.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaConfig.java index b8ba1e188b..12e1da07b9 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaConfig.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaConfig.java @@ -1,9 +1,11 @@ package cn.binarywang.wx.miniapp.config; import me.chanjar.weixin.common.bean.WxAccessToken; +import me.chanjar.weixin.common.bean.WxAccessTokenEntity; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import java.util.concurrent.locks.Lock; +import java.util.function.Consumer; /** * 小程序配置 @@ -12,6 +14,10 @@ */ public interface WxMaConfig { + default void setUpdateAccessTokenBefore(Consumer updateAccessTokenBefore) { + + } + /** * Gets access token. * @@ -19,6 +25,13 @@ public interface WxMaConfig { */ String getAccessToken(); + //region 稳定版access token + boolean isStableAccessToken(); + + void useStableAccessToken(boolean useStableAccessToken); + //endregion + + /** * Gets access token lock. * @@ -43,7 +56,9 @@ public interface WxMaConfig { * * @param accessToken 要更新的WxAccessToken对象 */ - void updateAccessToken(WxAccessToken accessToken); + default void updateAccessToken(WxAccessToken accessToken) { + updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); + } /** * 应该是线程安全的 @@ -53,6 +68,20 @@ public interface WxMaConfig { */ void updateAccessToken(String accessToken, int expiresInSeconds); + default void updateAccessTokenProcessor(String accessToken, int expiresInSeconds) { + WxAccessTokenEntity wxAccessTokenEntity = new WxAccessTokenEntity(); + wxAccessTokenEntity.setAppid(getAppid()); + wxAccessTokenEntity.setAccessToken(accessToken); + wxAccessTokenEntity.setExpiresIn(expiresInSeconds); + updateAccessTokenBefore(wxAccessTokenEntity); + updateAccessToken(accessToken, expiresInSeconds); + } + + default void updateAccessTokenBefore(WxAccessTokenEntity wxAccessTokenEntity) { + + } + + /** * Gets jsapi ticket. * @@ -250,4 +279,19 @@ public interface WxMaConfig { * @return 自定义的api域名地址 */ String getApiHostUrl(); + + /** + * 获取自定义的获取accessToken地址,用于向自定义统一服务获取accessToken + * + * @return 自定义的获取accessToken地址 + */ + String getAccessTokenUrl(); + + /** + * 设置自定义的获取accessToken地址 + * 可用于设置获取accessToken的自定义服务 + * + * @param accessTokenUrl 自定义的获取accessToken地址 + */ + void setAccessTokenUrl(String accessTokenUrl); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java index 9b94a04bbb..aabdd48932 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java @@ -1,10 +1,11 @@ package cn.binarywang.wx.miniapp.config.impl; -import com.github.jedis.lock.JedisLock; import me.chanjar.weixin.common.error.WxRuntimeException; import redis.clients.jedis.Jedis; +import redis.clients.jedis.params.SetParams; import java.io.File; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -79,7 +80,7 @@ private String getValueFromRedis(String key) { private void setValueToRedis(String key, long expiresTime, String value) { try (Jedis jedis = getConfiguredJedis()) { - Map hash = new HashMap(); + Map hash = new HashMap<>(); hash.put(HASH_VALUE_FIELD, value); hash.put(HASH_EXPIRE_FIELD, String.valueOf(expiresTime)); jedis.hmset(getRedisKey(key), hash); @@ -223,16 +224,21 @@ public void setExpiresTime(long expiresTime) { */ private class DistributedLock implements Lock { - private JedisLock lock; + private final String LOCK_SUCCESS = "OK"; + + private final Long RELEASE_SUCCESS = 1L; + + private String lockKey; private DistributedLock(String key) { - this.lock = new JedisLock(getRedisKey(key)); + this.lockKey = key; } @Override public void lock() { try (Jedis jedis = getConfiguredJedis()) { - if (!lock.acquire(jedis)) { + + if (!acquire(jedis)) { throw new WxRuntimeException("acquire timeouted"); } } catch (InterruptedException e) { @@ -240,10 +246,11 @@ public void lock() { } } + @Override public void lockInterruptibly() throws InterruptedException { try (Jedis jedis = getConfiguredJedis()) { - if (!lock.acquire(jedis)) { + if (!acquire(jedis)) { throw new WxRuntimeException("acquire timeouted"); } } @@ -252,7 +259,7 @@ public void lockInterruptibly() throws InterruptedException { @Override public boolean tryLock() { try (Jedis jedis = getConfiguredJedis()) { - return lock.acquire(jedis); + return acquire(jedis); } catch (InterruptedException e) { throw new WxRuntimeException("lock failed", e); } @@ -261,14 +268,14 @@ public boolean tryLock() { @Override public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { try (Jedis jedis = getConfiguredJedis()) { - return lock.acquire(jedis); + return acquire(jedis); } } @Override public void unlock() { try (Jedis jedis = getConfiguredJedis()) { - lock.release(jedis); + releaseDistributedLock(jedis); } } @@ -277,5 +284,54 @@ public Condition newCondition() { throw new WxRuntimeException("unsupported method"); } + + /** + * 尝试获取锁 有限次数的重试 + * + * @param jedis + * @return + * @throws InterruptedException + */ + private Boolean acquire(Jedis jedis) throws InterruptedException { + Integer i = 0; + do { + i++; + boolean locked = tryGetDistributedLock(jedis); + if (locked) { + return true; + } else { + Thread.sleep(100L); + } + } while (i < 20); + return false; + } + + /** + * 尝试获取锁 + * + * @param jedis + * @return + */ + private Boolean tryGetDistributedLock(Jedis jedis) { + Long millisecondsToExpire = 2L; + Long threadId = Thread.currentThread().getId(); + String result = jedis.set(this.lockKey, threadId.toString(), SetParams.setParams().nx().px(millisecondsToExpire)); + return LOCK_SUCCESS.equals(result); + } + + + /** + * 释放分布式锁 + * + * @param jedis + * @return 是否释放成功 + */ + private Boolean releaseDistributedLock(Jedis jedis) { + Long threadId = Thread.currentThread().getId(); + String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"; + Object result = jedis.eval(script, Collections.singletonList(lockKey), Collections.singletonList(threadId.toString())); + return RELEASE_SUCCESS.equals(result); + } + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaDefaultConfigImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaDefaultConfigImpl.java index c05d6f1aa2..bd9a4e20b0 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaDefaultConfigImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaDefaultConfigImpl.java @@ -2,13 +2,16 @@ import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import lombok.AccessLevel; import lombok.Getter; -import me.chanjar.weixin.common.bean.WxAccessToken; +import lombok.Setter; +import me.chanjar.weixin.common.bean.WxAccessTokenEntity; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import java.io.File; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import java.util.function.Consumer; /** * 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化 @@ -19,6 +22,13 @@ public class WxMaDefaultConfigImpl implements WxMaConfig { protected volatile String appid; protected volatile String token; + + /** + * 是否使用稳定版获取accessToken接口 + */ + @Getter(value = AccessLevel.NONE) + private boolean useStableAccessToken; + /** * 小程序原始ID */ @@ -56,6 +66,26 @@ public class WxMaDefaultConfigImpl implements WxMaConfig { protected volatile Lock cardApiTicketLock = new ReentrantLock(); private volatile ApacheHttpClientBuilder apacheHttpClientBuilder; private String apiHostUrl; + private String accessTokenUrl; + + /** + * 自定义配置token的消费者 + */ + @Setter + private Consumer updateAccessTokenBefore; + + /** + * 开启回调 + */ + @Getter(AccessLevel.NONE) + private boolean enableUpdateAccessTokenBefore = true; + + /** + * 可临时关闭更新token回调,主要用于其他介质初始化数据时,可不进行回调 + */ + public void enableUpdateAccessTokenBefore(boolean enableUpdateAccessTokenBefore) { + this.enableUpdateAccessTokenBefore = enableUpdateAccessTokenBefore; + } /** * 会过期的数据提前过期时间,默认预留200秒的时间 @@ -80,6 +110,19 @@ public void setAccessToken(String accessToken) { this.accessToken = accessToken; } + //region 使用稳定版接口获取accessToken + @Override + public boolean isStableAccessToken() { + return this.useStableAccessToken; + } + + @Override + public void useStableAccessToken(boolean useStableAccessToken) { + this.useStableAccessToken = useStableAccessToken; + } + //endregion + + @Override public Lock getAccessTokenLock() { return this.accessTokenLock; @@ -94,10 +137,10 @@ public boolean isAccessTokenExpired() { return isExpired(this.expiresTime); } - @Override - public synchronized void updateAccessToken(WxAccessToken accessToken) { - updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); - } +// @Override +// public synchronized void updateAccessToken(WxAccessToken accessToken) { +// updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); +// } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { @@ -105,6 +148,13 @@ public synchronized void updateAccessToken(String accessToken, int expiresInSeco setExpiresTime(expiresAheadInMillis(expiresInSeconds)); } + @Override + public void updateAccessTokenBefore(WxAccessTokenEntity wxAccessTokenEntity) { + if (updateAccessTokenBefore != null && enableUpdateAccessTokenBefore) { + updateAccessTokenBefore.accept(wxAccessTokenEntity); + } + } + @Override public String getJsapiTicket() { return this.jsapiTicket; @@ -303,6 +353,11 @@ public void setApiHostUrl(String apiHostUrl) { this.apiHostUrl = apiHostUrl; } + @Override + public void setAccessTokenUrl(String accessTokenUrl) { + this.accessTokenUrl = accessTokenUrl; + } + @Override public String getAppid() { return appid; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisBetterConfigImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisBetterConfigImpl.java index 48c5e8e31f..4b38f1d642 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisBetterConfigImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisBetterConfigImpl.java @@ -7,6 +7,8 @@ /** * 基于redis存储的微信小程序配置类 + * + * @author Mario Luo, 2020-04-18 23:08 */ public class WxMaRedisBetterConfigImpl extends WxMaDefaultConfigImpl { private static final String ACCESS_TOKEN_KEY_TPL = "%s:access_token:%s"; @@ -121,4 +123,20 @@ private void doExpireTicket(TicketType type) { redisOps.expire(this.getTicketRedisKey(type), 0, TimeUnit.SECONDS); } + @Override + public String toString() { + return "WxMaRedisBetterConfigImpl{" + + "appid='" + appid + '\'' + + ", token='" + token + '\'' + + ", originalId='" + originalId + '\'' + + ", accessTokenLock=" + accessTokenLock + + ", tmpDirFile=" + tmpDirFile + + ", jsapiTicketLock=" + jsapiTicketLock + + ", cardApiTicketLock=" + cardApiTicketLock + + ", redisOps=" + redisOps + + ", keyPrefix='" + keyPrefix + '\'' + + ", accessTokenKey='" + accessTokenKey + '\'' + + ", lockKey='" + lockKey + '\'' + + '}'; + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImpl.java index c45ad50946..36d782506f 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImpl.java @@ -14,14 +14,14 @@ * 基于Redisson的实现 * * @author yuanqixun - * @date 2020/5/3 + * created on 2020/5/3 */ public class WxMaRedissonConfigImpl extends WxMaDefaultConfigImpl { - protected final static String LOCK_KEY = "wechat_ma_lock:"; - protected final static String MA_ACCESS_TOKEN_KEY = "wechat_ma_access_token_key:"; - protected final static String MA_JSAPI_TICKET_KEY = "wechat_ma_jsapi_ticket_key:"; - protected final static String MA_CARD_API_TICKET_KEY = "wechat_ma_card_api_ticket_key:"; + protected static final String LOCK_KEY = "wechat_ma_lock:"; + protected static final String MA_ACCESS_TOKEN_KEY = "wechat_ma_access_token_key:"; + protected static final String MA_JSAPI_TICKET_KEY = "wechat_ma_jsapi_ticket_key:"; + protected static final String MA_CARD_API_TICKET_KEY = "wechat_ma_card_api_ticket_key:"; /** * redis 存储的 key 的前缀,可为空 @@ -91,7 +91,7 @@ public boolean isAccessTokenExpired() { @Override public void updateAccessToken(WxAccessToken accessToken) { - redisOps.setValue(this.accessTokenKey, accessToken.getAccessToken(), accessToken.getExpiresIn(), TimeUnit.SECONDS); + updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } @Override diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java index 17b72c8db5..858ace8bd6 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java @@ -6,10 +6,34 @@ * 小程序接口地址常量. * * @author Binary Wang - * @date 2021-01-28 + * created on 2021-01-28 */ @UtilityClass public class WxMaApiUrlConstants { + + /** + * openApi管理 + */ + public interface OpenApi { + /** + * 重置API调用次数 + */ + String CLEAR_QUOTA = "https://api.weixin.qq.com/cgi-bin/clear_quota"; + /** + * 查询API调用额度 + */ + String GET_API_QUOTA = "https://api.weixin.qq.com/cgi-bin/openapi/quota/get"; + /** + * 查询rid信息 + */ + String GET_RID_INFO = "https://api.weixin.qq.com/cgi-bin/openapi/rid/get"; + /** + * 使用AppSecret重置 API 调用次数 + */ + String CLEAR_QUOTA_BY_APP_SECRET = "https://api.weixin.qq.com/cgi-bin/clear_quota/v2?appid=%s&appsecret=%s"; + + } + public interface Analysis { String GET_DAILY_SUMMARY_TREND_URL = "https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend"; String GET_DAILY_VISIT_TREND_URL = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend"; @@ -42,6 +66,7 @@ public interface Cloud { String DATABASE_UPDATE_URL = "https://api.weixin.qq.com/tcb/databaseupdate"; String DATABASE_DELETE_URL = "https://api.weixin.qq.com/tcb/databasedelete"; String DATABASE_ADD_URL = "https://api.weixin.qq.com/tcb/databaseadd"; + String SEND_SMS_V2_URL = "https://api.weixin.qq.com/tcb/sendsmsv2"; } public interface Msg { @@ -70,6 +95,7 @@ public interface Code { String GET_SUPPORT_VERSION_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/getweappsupportversion"; String SET_SUPPORT_VERSION_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/setweappsupportversion"; String UNDO_CODE_AUDIT_URL = "https://api.weixin.qq.com/wxa/undocodeaudit"; + String GET_VERSION_INFO_URL = "https://api.weixin.qq.com/wxa/getversioninfo"; } public interface Express { @@ -158,22 +184,107 @@ public interface Jsapi { } public interface Broadcast { - String GET_LIVE_INFO = "https://api.weixin.qq.com/wxa/business/getliveinfo"; - /** * 直播间管理相关接口 */ interface Room { + /** + * 创建直播间 + */ String CREATE_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/room/create"; + /** + * 获取直播间列表 + * 获取直播间回放 + */ + String GET_LIVE_INFO = "https://api.weixin.qq.com/wxa/business/getliveinfo"; + /** + * 直播间导入商品 + */ String ADD_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods"; + /** + * 删除直播间 + */ String DELETE_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/room/deleteroom"; + /** + * 编辑直播间 + */ String EDIT_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/room/editroom"; + /** + * 获取直播间推流地址 + */ String GET_PUSH_URL = "https://api.weixin.qq.com/wxaapi/broadcast/room/getpushurl"; + /** + * 获取直播间分享二维码 + */ String GET_SHARED_CODE = "https://api.weixin.qq.com/wxaapi/broadcast/room/getsharedcode"; + /** + * 添加管理直播间小助手 + */ String ADD_ASSISTANT = "https://api.weixin.qq.com/wxaapi/broadcast/room/addassistant"; + /** + * 修改管理直播间小助手 + */ String MODIFY_ASSISTANT = "https://api.weixin.qq.com/wxaapi/broadcast/room/modifyassistant"; + /** + * 删除管理直播间小助手 + */ String REMOVE_ASSISTANT = "https://api.weixin.qq.com/wxaapi/broadcast/room/removeassistant"; + /** + * 查询管理直播间小助手 + */ String GET_ASSISTANT_LIST = "https://api.weixin.qq.com/wxaapi/broadcast/room/getassistantlist"; + /** + * 添加主播副号 + */ + String ADD_SUBANCHOR = "https://api.weixin.qq.com/wxaapi/broadcast/room/addsubanchor"; + /** + * 修改主播副号 + */ + String MODIFY_SUBANCHOR = "https://api.weixin.qq.com/wxaapi/broadcast/room/modifysubanchor"; + /** + * 删除主播副号 + */ + String DELETE_SUBANCHOR = "https://api.weixin.qq.com/wxaapi/broadcast/room/deletesubanchor"; + /** + * 获取主播副号 + */ + String GET_SUBANCHOR = "https://api.weixin.qq.com/wxaapi/broadcast/room/getsubanchor"; + /** + * 开启/关闭直播间官方收录 + */ + String UPDATE_FEED_PUBLIC = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatefeedpublic"; + /** + * 开启/关闭回放功能 + */ + String UPDATE_REPLAY = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatereplay"; + /** + * 开启/关闭客服功能 + */ + String UPDATE_KF = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatekf"; + /** + * 开启/关闭直播间全局禁言 + */ + String UPDATE_COMMENT = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatecomment"; + /** + * 上下架商品 + */ + String ONSALE = "https://api.weixin.qq.com/wxaapi/broadcast/goods/onsale"; + /** + * 删除商品 + */ + String DELETE_IN_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom"; + /** + * 推送商品 + */ + String PUSH = "https://api.weixin.qq.com/wxaapi/broadcast/goods/push"; + /** + * 商品排序 + */ + String SORT = "https://api.weixin.qq.com/wxaapi/broadcast/goods/sort"; + /** + * 下载商品讲解视频 + */ + String GET_VIDEO = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getVideo"; } /** @@ -187,6 +298,14 @@ interface Goods { String UPDATE_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/update"; String GET_GOODS_WARE_HOUSE = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse"; String GET_APPROVED_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved"; + /** + * 直播挂件设置全局 Key + */ + String SET_KEY = "https://api.weixin.qq.com/wxaapi/broadcast/goods/setkey"; + /** + * 直播挂件获取全局 Key + */ + String GET_KEY = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getkey"; } /** @@ -220,10 +339,12 @@ public interface Run { public interface Scheme { String GENERATE_SCHEME_URL = "https://api.weixin.qq.com/wxa/generatescheme"; + String GENERATE_NFC_SCHEME_URL = "https://api.weixin.qq.com/wxa/generatenfcscheme"; } public interface Link { String GENERATE_URLLINK_URL = "https://api.weixin.qq.com/wxa/generate_urllink"; + String QUERY_URLLINK_URL = "https://api.weixin.qq.com/wxa/query_urllink"; } public interface ShortLink { @@ -288,6 +409,7 @@ public interface Subscribe { public interface User { String SET_USER_STORAGE = "https://api.weixin.qq.com/wxa/set_user_storage?appid=%s&signature=%s&openid=%s&sig_method=%s"; + String GET_PHONE_NUMBER_URL = "https://api.weixin.qq.com/wxa/business/getuserphonenumber"; } public interface Ocr { @@ -305,6 +427,48 @@ public interface Ocr { String FILE_COMM = "https://api.weixin.qq.com/cv/ocr/comm"; } + public interface Product { + interface Spu { + String PRODUCT_SPU_ADD_URL = "https://api.weixin.qq.com/product/spu/add"; + String PRODUCT_SPU_DEL_URL = "https://api.weixin.qq.com/product/spu/del"; + String PRODUCT_SPU_GET_URL = "https://api.weixin.qq.com/product/spu/get"; + String PRODUCT_SPU_GET_LIST_URL = "https://api.weixin.qq.com/product/spu/get_list"; + String PRODUCT_SPU_UPDATE_URL = "https://api.weixin.qq.com/product/spu/update"; + String PRODUCT_SPU_LISTING_URL = "https://api.weixin.qq.com/product/spu/listing"; + String PRODUCT_SPU_DELISTING_URL = "https://api.weixin.qq.com/product/spu/delisting"; + } + + interface Sku { + String PRODUCT_ADD_SKU_URL = "https://api.weixin.qq.com/product/sku/add"; + String PRODUCT_BATCH_ADD_SKU_URL = "https://api.weixin.qq.com/product/sku/batch_add"; + String PRODUCT_DEL_SKU_URL = "https://api.weixin.qq.com/product/sku/del"; + String PRODUCT_UPDATE_SKU_URL = "https://api.weixin.qq.com/product/sku/update"; + String PRODUCT_UPDATE_SKU_PRICE_URL = "https://api.weixin.qq.com/product/sku/update_price"; + String PRODUCT_UPDATE_SKU_STOCK_URL = "https://api.weixin.qq.com/product/stock/update"; + String PRODUCT_SKU_LIST = "https://api.weixin.qq.com/product/sku/get_list"; + } + + interface Order { + String PRODUCT_ORDER_GET_LIST = "https://api.weixin.qq.com/product/order/get_list"; + String PRODUCT_ORDER_DETAIL_URL = "https://api.weixin.qq.com/product/order/get"; + String PRODUCT_ORDER_CHANGE_MERCHANT_NOTES_URL = "https://api.weixin.qq.com/product/order/change_merchant_notes"; + + String PRODUCT_DELIVERY_SEND = "https://api.weixin.qq.com/product/delivery/send"; + + String GET_AFTER_SALE_ORDER = "https://api.weixin.qq.com/product/order/getaftersaleorder"; + String BATCH_GET_AFTER_SALE_ORDER = "https://api.weixin.qq.com/product/order/batchgetaftersaleorder"; + String AFTER_SALE_ACCEPT_APPLY = "https://api.weixin.qq.com/product/order/acceptapply"; + String AFTER_SALE_REJECT_APPLY = "https://api.weixin.qq.com/product/order/rejectrefund"; + } + + interface OTHER { + String GET_CATEGORY = "https://api.weixin.qq.com/product/category/get"; + String GET_BRAND = "https://api.weixin.qq.com/product/brand/get"; + String GET_FREIGHT_TEMPLATE = "https://api.weixin.qq.com/product/delivery/get_freight_template"; + String IMG_UPLOAD = "https://api.weixin.qq.com/product/img/upload"; + } + } + public interface Shop { interface Spu { String SPU_ADD_URL = "https://api.weixin.qq.com/shop/spu/add"; @@ -323,6 +487,8 @@ interface Order { String ORDER_ADD = "https://api.weixin.qq.com/shop/order/add"; String ORDER_PAY = "https://api.weixin.qq.com/shop/order/pay"; String ORDER_GET = "https://api.weixin.qq.com/shop/order/get"; + String ORDER_GET_LIST = "https://api.weixin.qq.com/shop/order/get_list"; + String ORDER_GET_PAYMENT_PARAMS = "https://api.weixin.qq.com/shop/order/getpaymentparams"; } interface Register { @@ -357,20 +523,59 @@ interface Audit { interface Delivery { String GET_COMPANY_LIST = "https://api.weixin.qq.com/shop/delivery/get_company_list"; String DELIVERY_SEND = "https://api.weixin.qq.com/shop/delivery/send"; - String DELIVERY_RECEIVE = "https://api.weixin.qq.com/shop/delivery/recieve"; + String DELIVERY_RECEIVE = "https://api.weixin.qq.com/shop/delivery/recieve"; } interface Aftersale { - String AFTERSALE_ADD = "https://api.weixin.qq.com/shop/aftersale/add"; + String AFTERSALE_ADD = "https://api.weixin.qq.com/shop/ecaftersale/add"; + String AFTERSALE_CANCEL = "https://api.weixin.qq.com/shop/ecaftersale/cancel"; + String AFTERSALE_UPDATE = "https://api.weixin.qq.com/shop/aftersale/update"; + String EC_AFTERSALE_UPDATE = "https://api.weixin.qq.com/shop/ecaftersale/update"; + String AFTERSALE_UPLOAD_RETURN_INFO = "https://api.weixin.qq.com/shop/ecaftersale/uploadreturninfo"; + String AFTERSALE_ACCEPT_REFUND = "https://api.weixin.qq.com/shop/ecaftersale/acceptrefund"; + String AFTERSALE_ACCEPT_RETURN = "https://api.weixin.qq.com/shop/ecaftersale/acceptreturn"; + String AFTERSALE_REJECT = "https://api.weixin.qq.com/shop/ecaftersale/reject"; + String AFTERSALE_UPLOAD_CERTIFICATES = "https://api.weixin.qq.com/shop/ecaftersale/upload_certificates"; + String AFTERSALE_UPLOAD_DEADLINE = "https://api.weixin.qq.com/shop/aftersale/update_deadline"; + String AFTERSALE_GET_LIST = "https://api.weixin.qq.com/shop/ecaftersale/get_list"; String AFTERSALE_GET = "https://api.weixin.qq.com/shop/aftersale/get"; - String AFTERSALE_UPDATE = "https://api.weixin.qq.com/shop/aftersale/update"; + String ECAFTERSALE_GET = "https://api.weixin.qq.com/shop/ecaftersale/get"; + } + + interface Sharer { + String BIND = "https://api.weixin.qq.com/shop/sharer/bind"; + String GET_SHARER_DATA_SUMMARY = "https://api.weixin.qq.com/shop/sharer/get_sharer_data_summary"; + String GET_SHARER_LIST = "https://api.weixin.qq.com/shop/sharer/get_sharer_list"; + String GET_SHARER_LIVE_ORDER_LIST = "https://api.weixin.qq.com/shop/sharer/get_sharer_live_order_list"; + String GET_SHARER_LIVE_SUMMARY_LIST = "https://api.weixin.qq.com/shop/sharer/get_sharer_live_summary_list"; + String SEARCH_SHARER = "https://api.weixin.qq.com/shop/sharer/search_sharer"; + String UNBIND = "https://api.weixin.qq.com/shop/sharer/unbind"; + } + + interface Coupon { + String ADD_COUPON = "https://api.weixin.qq.com/shop/coupon/add"; + String GET_COUPON = "https://api.weixin.qq.com/shop/coupon/get"; + String GET_COUPON_LIST = "https://api.weixin.qq.com/shop/coupon/get_list"; + String UPDATE_COUPON = "https://api.weixin.qq.com/shop/coupon/update"; + String UPDATE_COUPON_STATUS = "https://api.weixin.qq.com/shop/coupon/update_status"; + String UPDATE_COUPON_STOCK = "https://api.weixin.qq.com/shop/coupon/update_coupon_stock"; + String ADD_USER_COUPON = "https://api.weixin.qq.com/shop/coupon/add_user_coupon"; + String GET_USER_COUPON_LIST = "https://api.weixin.qq.com/shop/coupon/get_usercoupon_list"; + String UPDATE_USER_COUPON = "https://api.weixin.qq.com/shop/coupon/update_user_coupon"; + String UPDATE_USER_COUPON_STATUS = "https://api.weixin.qq.com/shop/coupon/update_usercoupon_status"; + } + + interface Pay { + String CREATE_ORDER = "https://api.weixin.qq.com/shop/pay/createorder"; + String GET_ORDER = "https://api.weixin.qq.com/shop/pay/getorder"; + String REFUND_ORDER = "https://api.weixin.qq.com/shop/pay/refundorder"; } } /** * 电子发票报销方 */ - public interface Invoice{ + public interface Invoice { /** * 报销方查询报销发票信息 @@ -393,7 +598,293 @@ public interface Invoice{ String UPDATE_STATUS_BATCH = "https://api.weixin.qq.com/card/invoice/reimburse/updatestatusbatch"; } - public interface Internet{ + public interface Internet { String GET_USER_ENCRYPT_KEY = "https://api.weixin.qq.com/wxa/business/getuserencryptkey"; } + + /** + * 设备订阅消息 + */ + public interface DeviceSubscribe { + /** + * 获取设备票据 + */ + String GET_SN_TICKET_URL = "https://api.weixin.qq.com/wxa/getsnticket"; + /** + * 发送设备订阅消息 + */ + String SEND_DEVICE_SUBSCRIBE_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/device/subscribe/send"; + } + + /** + * 即时配送相关接口. + *

+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/immediate-delivery/overview.html
+   * 
+ */ + public interface InstantDelivery { + + /** + * 拉取已绑定账号. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getBindAccount.html
+     * 
+ */ + String GET_BIND_ACCOUNT = "https://api.weixin.qq.com/cgi-bin/express/local/business/shop/get"; + + /** + * 拉取配送单信息. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getOrder.html
+     * 
+ */ + String GET_ORDER = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/get"; + + /** + * 模拟配送公司更新配送单状态. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.mockUpdateOrder.html
+     * 
+ */ + String MOCK_UPDATE_ORDER = "https://api.weixin.qq.com/cgi-bin/express/local/business/test_update_order"; + + /** + * 物流服务-查询组件-跟踪物流面单 + * 商户使用此接口向微信提供某交易单号对应的运单号。微信后台会跟踪运单的状态变化 + */ + String TRACE_WAYBILL_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/trace_waybill"; + + + /** + * 物流服务-查询组件-查询运单接口 query_trace + * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息 + */ + String QUERY_WAYBILL_TRACE_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/query_trace"; + + /** + * 物流服务-消息组件-传运单接口(订阅消息) follow_waybill + * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息 + */ + String FOLLOW_WAYBILL_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/follow_waybill"; + + /** + * 物流服务-消息组件-查运单接口(订阅消息) query_follow_trace + * 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息 + */ + String QUERY_FOLLOW_TRACE_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/query_follow_trace"; + + + /** + * 下单接口. + */ + interface PlaceAnOrder { + + /** + * 获取已支持的配送公司列表接口. + *
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getAllImmeDelivery.html
+       * 
+ */ + String GET_ALL_IMME_DELIVERY = "https://api.weixin.qq.com/cgi-bin/express/local/business/delivery/getall"; + + /** + * 预下配送单接口. + *
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.preAddOrder.html
+       * 
+ */ + String PRE_ADD_ORDER = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add"; + + /** + * 下配送单接口. + *
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.addOrder.html
+       * 
+ */ + String ADD_ORDER = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/add"; + + /** + * 重新下单. + *
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.reOrder.html
+       * 
+ */ + String RE_ORDER = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/readd"; + + /** + * 增加小费. + *
+       * 可以对待接单状态的订单增加小费。需要注意:订单的小费,以最新一次加小费动作的金额为准,故下一次增加小费额必须大于上一次小费额.
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.addTip.html
+       * 
+ */ + String ADD_TIP = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/addtips"; + + } + + /** + * 取消接口. + */ + interface Cancel { + + /** + * 预取消配送单接口. + *
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.preCancelOrder.html
+       * 
+ */ + String PRE_CANCEL_ORDER = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/precancel"; + + /** + * 取消配送单接口. + *
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.cancelOrder.html
+       * 
+ */ + String CANCEL_ORDER = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/cancel"; + + /** + * 异常件退回商家商家确认收货接口. + *
+       * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.abnormalConfirm.html
+       * 
+ */ + String ABNORMAL_CONFIRM = "https://api.weixin.qq.com/cgi-bin/express/local/business/order/confirm_return"; + + } + + + /** + * 安全风控 + */ + interface SafetyRiskControl { + /** + * 获取用户的安全等级,无需用户授权 + */ + String GET_USER_RISK_RANK = "https://api.weixin.qq.com/wxa/getuserriskrank"; + } + + } + + /** + * 发货信息管理服务相关接口 + *
+   * 文档地址: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
+   * 
+ */ + public interface OrderShipping { + + /** + * 查询小程序是否已开通发货信息管理服务. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%83%E3%80%81%E6%9F%A5%E8%AF%A2%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%90%A6%E5%B7%B2%E5%BC%80%E9%80%9A%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E7%AE%A1%E7%90%86%E6%9C%8D%E5%8A%A1
+     * 
+ */ + String IS_TRADE_MANAGED = "https://api.weixin.qq.com/wxa/sec/order/is_trade_managed"; + + /** + * 发货信息录入接口. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
+     * 
+ */ + String UPLOAD_SHIPPING_INFO = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info"; + + /** + * 发货信息合单录入接口. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%BA%8C%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%90%88%E5%8D%95%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
+     * 
+ */ + String UPLOAD_COMBINED_SHIPPING_INFO = "https://api.weixin.qq.com/wxa/sec/order/upload_combined_shipping_info"; + + /** + * 查询订单发货状态. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%BA%8C%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%90%88%E5%8D%95%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
+     * 
+ */ + String GET_SHIPPING_INFO = "https://api.weixin.qq.com/wxa/sec/order/get_order"; + + /** + * 查询订单发货状态列表. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%9B%9B%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8
+     * 
+ */ + String GET_SHIPPING_INFO_LIST = "https://api.weixin.qq.com/wxa/sec/order/get_order_list"; + + /** + * 确认收货提醒接口. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%BA%94%E3%80%81%E7%A1%AE%E8%AE%A4%E6%94%B6%E8%B4%A7%E6%8F%90%E9%86%92%E6%8E%A5%E5%8F%A3
+     * 
+ */ + String NOTIFY_CONFIRM_RECEIVE = "https://api.weixin.qq.com/wxa/sec/order/notify_confirm_receive"; + + /** + * 消息跳转路径设置接口. + *
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%85%AD%E3%80%81%E6%B6%88%E6%81%AF%E8%B7%B3%E8%BD%AC%E8%B7%AF%E5%BE%84%E8%AE%BE%E7%BD%AE%E6%8E%A5%E5%8F%A3
+     * 
+ */ + String SET_MSG_JUMP_PATH = "https://api.weixin.qq.com/wxa/sec/order/set_msg_jump_path"; + + } + + public interface Vod { + String LIST_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/listmedia"; + String GET_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/getmedia"; + String GET_MEDIA_LINK_URL = "https://api.weixin.qq.com/wxa/sec/vod/getmedialink"; + String DELETE_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/deletemedia"; + String AUDIT_DRAMA_URL = "https://api.weixin.qq.com/wxa/sec/vod/auditdrama"; + String LIST_DRAMAS_URL = "https://api.weixin.qq.com/wxa/sec/vod/listdramas"; + String GET_DRAMA_URL = "https://api.weixin.qq.com/wxa/sec/vod/getdrama"; + String SINGLE_FILE_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/singlefileupload"; + String PULL_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/pullupload"; + String GET_TASK_URL = "https://api.weixin.qq.com/wxa/sec/vod/gettask"; + String APPLY_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/applyupload"; + String UPLOAD_PART_URL = "https://api.weixin.qq.com/wxa/sec/vod/uploadpart"; + String COMMIT_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/commitupload"; + String GET_CDN_USAGE_DATA_URL = "https://api.weixin.qq.com/wxa/sec/vod/getcdnusagedata"; + String GET_CDN_LOGS_URL = "https://api.weixin.qq.com/wxa/sec/vod/getcdnlogs"; + + } + /** + * 小程序虚拟支付服务相关接口 + *
+   * 文档地址: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html#_2-3-%E6%9C%8D%E5%8A%A1%E5%99%A8API
+   * 
+ */ + public interface XPay { + String QUERY_USER_BALANCE_URL = "https://api.weixin.qq.com/xpay/query_user_balance?pay_sig=%s&signature=%s"; + String CURRENCY_PAY_URL = "https://api.weixin.qq.com/xpay/currency_pay?pay_sig=%s&signature=%s"; + String QUERY_ORDER_URL = "https://api.weixin.qq.com/xpay/query_order?pay_sig=%s"; + String CANCEL_CURRENCY_PAY_URL = "https://api.weixin.qq.com/xpay/cancel_currency_pay?pay_sig=%s&signature=%s"; + String NOTIFY_PROVIDE_GOODS_URL = "https://api.weixin.qq.com/xpay/notify_provide_goods?pay_sig=%s"; + String PRESENT_CURRENCY_URL = "https://api.weixin.qq.com/xpay/present_currency?pay_sig=%s"; + String DOWNLOAD_BILL_URL = "https://api.weixin.qq.com/xpay/download_bill?pay_sig=%s"; + String REFUND_ORDER_URL = "https://api.weixin.qq.com/xpay/refund_order?pay_sig=%s"; + String CREATE_WITHDRAW_ORDER_URL = "https://api.weixin.qq.com/xpay/create_withdraw_order?pay_sig=%s"; + String QUERY_WITHDRAW_ORDER_URL = "https://api.weixin.qq.com/xpay/query_withdraw_order?pay_sig=%s"; + String START_UPLOAD_GOODS_URL = "https://api.weixin.qq.com/xpay/start_upload_goods?pay_sig=%s"; + String QUERY_UPLOAD_GOODS_URL = "https://api.weixin.qq.com/xpay/query_upload_goods?pay_sig=%s"; + String START_PUBLISH_GOODS_URL = "https://api.weixin.qq.com/xpay/start_publish_goods?pay_sig=%s"; + String QUERY_PUBLISH_GOODS_URL = "https://api.weixin.qq.com/xpay/query_publish_goods?pay_sig=%s"; + + } + + /** + * 退货组件 + *
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_sale_return.html
+   * 
+ * + */ + public interface ExpressDeliveryReturn{ + String ADD_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/add"; + String GET_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/get"; + String UNBIND_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/unbind"; + } + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java index 8ac322aa5f..488481c011 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java @@ -1,5 +1,7 @@ package cn.binarywang.wx.miniapp.constant; +import lombok.experimental.UtilityClass; + /** *
  *  小程序常量.
@@ -7,19 +9,19 @@
  *
  * @author Binary Wang
  */
-public abstract class WxMaConstants {
-  private WxMaConstants() {
-  }
+@UtilityClass
+public class WxMaConstants {
 
   /**
-   * 微信接口返回的参数errcode.
+   * 默认的env_version值
    */
-  public static final String ERRCODE = "errcode";
+  public static final String DEFAULT_ENV_VERSION = "release";
 
   /**
    * 素材类型.
    */
-  public abstract static class MediaType {
+  @UtilityClass
+  public static class MediaType {
     /**
      * 图片.
      */
@@ -29,7 +31,8 @@ public abstract static class MediaType {
   /**
    * 消息格式.
    */
-  public abstract static class MsgDataFormat {
+  @UtilityClass
+  public static class MsgDataFormat {
     public static final String XML = "XML";
     public static final String JSON = "JSON";
   }
@@ -37,6 +40,7 @@ public abstract static class MsgDataFormat {
   /**
    * 客服消息的消息类型.
    */
+  @UtilityClass
   public static class KefuMsgType {
     /**
      * 文本消息.
@@ -59,8 +63,8 @@ public static class KefuMsgType {
   /**
    * 内容安全检测的媒体类型
    */
+  @UtilityClass
   public static final class SecCheckMediaType {
-
     /**
      * 音频
      */
@@ -75,6 +79,7 @@ public static final class SecCheckMediaType {
   /**
    * 快递账号绑定类型
    */
+  @UtilityClass
   public static final class BindAccountType {
 
     /**
@@ -91,6 +96,7 @@ public static final class BindAccountType {
   /**
    * 快递下单订单来源
    */
+  @UtilityClass
   public static final class OrderAddSource {
 
     /**
@@ -107,11 +113,8 @@ public static final class OrderAddSource {
   /**
    * 快递下单保价
    */
+  @UtilityClass
   public static final class OrderAddInsured {
-    private OrderAddInsured() {
-
-    }
-
     /**
      * 不保价
      */
@@ -133,10 +136,8 @@ private OrderAddInsured() {
    * 

* developer为开发版;trial为体验版;formal为正式版;默认为正式版 */ + @UtilityClass public static final class MiniProgramState { - private MiniProgramState() { - } - /** * 开发版 */ @@ -158,10 +159,8 @@ private MiniProgramState() { * 进入小程序查看的语言类型 * 支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN */ + @UtilityClass public static final class MiniProgramLang { - private MiniProgramLang() { - } - /** * 简体中文 */ @@ -182,4 +181,126 @@ private MiniProgramLang() { */ public static final String ZH_TW = "zh_TW"; } + + @UtilityClass + public static final class AuditStatus { + public static final int INVALID = 0; + public static final int ONGOING = 1; + public static final int REJECTED = 2; + public static final int APPROVED = 3; + public static final int RECOMMIT = 4; + } + + + @UtilityClass + public static final class ExpeditedType { + + /** + * 非加急 + */ + public static final int NORMAL = 0; + + /** + * 加急 + */ + public static final int HIGH_PRIORITY = 1; + } + + @UtilityClass + public static final class UploadTaskType { + public static final int PULL_UPLOAD = 1; + } + + @UtilityClass + public static final class UploadTaskStatus { + public static final int WAITING = 1; + public static final int WORKING = 2; + public static final int DONE = 3; + public static final int FAILED = 4; + } + + @UtilityClass + public static final class UploadResourceType { + public static final int MEDIA = 1; + public static final int COVER = 2; + } + @UtilityClass + public static final class XPayEnv { + public static final int PRODUCT = 0; + public static final int SANDBOX = 1; + } + @UtilityClass + public static final class XPayFirstCharge { + public static final int NO = 0; + public static final int YES = 1; + } + @UtilityClass + public static final class XPayDeviceType { + public static final int ANDROID = 1; + public static final int IOS = 2; + } + @UtilityClass + public static final class XPayBizType { + public static final int SHORT_DRAMA = 1; + } + @UtilityClass + public static final class XPayOrderType { + public static final int PAY_ORDER = 0;//0-支付单 + public static final int REFUND_ORDER = 1;//1-退款单 + } + @UtilityClass + public static final class XPayOrderStatus { + public static final int INIT = 0;//0-订单初始化(未创建成功,不可用于支付) + public static final int CREATED = 1;// 1-订单创建成功 + public static final int PAID = 2;//2-订单已经支付,待发货 + public static final int PROVIDING = 3;// 3-订单发货中 + public static final int PROVIDED = 4;// 4-订单已发货 + public static final int REFUNDED = 5;// 5-订单已经退款 + public static final int CLOSED = 6;// 6-订单已经关闭(不可再使用) + public static final int REFUND_FAILED = 7;// 7-订单退款失败 + } + @UtilityClass + public static final class XPayNotifyEvent { + public static String COIN_PAY = "xpay_coin_pay_notify"; + public static String GOODS_DELIVER = "xpay_goods_deliver_notify"; + + } + @UtilityClass + public static final class XPayPaymentMode { + public static String COIN = "short_series_coin"; + public static String GOODS = "short_series_goods"; + + } + + @UtilityClass + public static final class XPayPlatform { + public static String ANDROID = "android"; + } + + @UtilityClass + public static final class XPayCurrencyType { + public static String CNY = "CNY"; + + } + + @UtilityClass + public static final class XPayWxApiSigUri { + public static String WXAPI = "requestVirtualPayment"; + + } + + @UtilityClass + public static final class XPayRefundReqFrom { + public static final String FROM_CS = "1";//人工客服退款 + public static final String FROM_USER = "2";//用户自己发起 + public static final String FROM_MISC = "3";//1-其它 + } + + @UtilityClass + public static final class XPayPublishStatus { + public static final int PUBLISH_UPLOADING = 0;//0-上传中 + public static final int PUBLISH_EXISTED = 1;//1-id已经存在 + public static final int PUBLISH_SUCCESSFUL = 2;// 2-发布成功 + public static final int PUBLISH_FAILED = 3;//3-发布失败 + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/ApacheVodSingleUploadRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/ApacheVodSingleUploadRequestExecutor.java new file mode 100644 index 0000000000..a9ffd1af39 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/ApacheVodSingleUploadRequestExecutor.java @@ -0,0 +1,68 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodSingleFileUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; + +import java.io.File; +import java.io.IOException; + +/** + * + */ +public class ApacheVodSingleUploadRequestExecutor extends VodSingleUploadRequestExecutor { + + public ApacheVodSingleUploadRequestExecutor(RequestHttp requestHttp, String mediaName, String mediaType, String coverType, File coverData, String sourceContext) { + super(requestHttp, mediaName, mediaType, coverType, coverData, sourceContext); + + } + + @Override + public WxMaVodSingleFileUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { + HttpPost httpPost = new HttpPost(uri); + if (requestHttp.getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); + httpPost.setConfig(config); + } + if (file != null) { + MultipartEntityBuilder entityBuilder = MultipartEntityBuilder + .create() + .setMode(HttpMultipartMode.RFC6532) + .addTextBody("media_name", mediaName) + .addTextBody("media_type", mediaType) + .addBinaryBody("media_data", file); + + if (coverType != null) { + entityBuilder.addTextBody("cover_type", coverType); + } + if (coverData != null) { + entityBuilder.addBinaryBody("cover_data", coverData); + } + if (sourceContext != null) { + entityBuilder.addTextBody("source_context", sourceContext); + } + + httpPost.setEntity(entityBuilder.build()); + } + try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { + String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMaVodSingleFileUploadResult.fromJson(responseContent); + } finally { + httpPost.releaseConnection(); + } + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/ApacheVodUploadPartRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/ApacheVodUploadPartRequestExecutor.java new file mode 100644 index 0000000000..e27840cd59 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/ApacheVodUploadPartRequestExecutor.java @@ -0,0 +1,59 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodUploadPartResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; + +import java.io.File; +import java.io.IOException; + +/** + * + */ +public class ApacheVodUploadPartRequestExecutor extends VodUploadPartRequestExecutor { + + public ApacheVodUploadPartRequestExecutor(RequestHttp requestHttp, String uploadId, Integer partNumber, Integer resourceType) { + super(requestHttp, uploadId, partNumber, resourceType); + + } + + @Override + public WxMaVodUploadPartResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { + HttpPost httpPost = new HttpPost(uri); + if (requestHttp.getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); + httpPost.setConfig(config); + } + if (file != null) { + MultipartEntityBuilder entityBuilder = MultipartEntityBuilder + .create() + .setMode(HttpMultipartMode.RFC6532) + .addTextBody("upload_id", uploadId) + .addTextBody("part_number", String.valueOf(partNumber)) + .addTextBody("resource_type", String.valueOf(resourceType)) + .addBinaryBody("data", file); + + httpPost.setEntity(entityBuilder.build()); + } + try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { + String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMaVodUploadPartResult.fromJson(responseContent); + } finally { + httpPost.releaseConnection(); + } + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/JoddHttpVodSingleUploadRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/JoddHttpVodSingleUploadRequestExecutor.java new file mode 100644 index 0000000000..ed47a9fc67 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/JoddHttpVodSingleUploadRequestExecutor.java @@ -0,0 +1,57 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodSingleFileUploadResult; +import jodd.http.HttpConnectionProvider; +import jodd.http.HttpRequest; +import jodd.http.HttpResponse; +import jodd.http.ProxyInfo; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestHttp; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +/** + * + */ +public class JoddHttpVodSingleUploadRequestExecutor extends VodSingleUploadRequestExecutor { + + public JoddHttpVodSingleUploadRequestExecutor(RequestHttp requestHttp, String mediaName, String mediaType, String coverType, File coverData, String sourceContext) { + super(requestHttp, mediaName, mediaType, coverType, coverData, sourceContext); + } + + @Override + public WxMaVodSingleFileUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { + HttpRequest request = HttpRequest.post(uri); + if (requestHttp.getRequestHttpProxy() != null) { + requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); + } + request.withConnectionProvider(requestHttp.getRequestHttpClient()); + request.form("media_data", file); + request.form("media_name", mediaName); + request.form("media_type", mediaType); + if (coverType != null) { + request.form("cover_type", coverType); + } + if (coverData != null) { + request.form("cover_data", coverData); + } + if (sourceContext != null) { + request.form("source_context", sourceContext); + } + + + HttpResponse response = request.send(); + response.charset(StandardCharsets.UTF_8.name()); + + String responseContent = response.bodyText(); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMaVodSingleFileUploadResult.fromJson(responseContent); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/JoddHttpVodUploadPartRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/JoddHttpVodUploadPartRequestExecutor.java new file mode 100644 index 0000000000..36e53b66bf --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/JoddHttpVodUploadPartRequestExecutor.java @@ -0,0 +1,49 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodUploadPartResult; +import jodd.http.HttpConnectionProvider; +import jodd.http.HttpRequest; +import jodd.http.HttpResponse; +import jodd.http.ProxyInfo; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestHttp; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +/** + * + */ +public class JoddHttpVodUploadPartRequestExecutor extends VodUploadPartRequestExecutor { + + public JoddHttpVodUploadPartRequestExecutor(RequestHttp requestHttp, String uploadId, Integer partNumber, Integer resourceType) { + super(requestHttp, uploadId, partNumber, resourceType); + + } + + @Override + public WxMaVodUploadPartResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { + HttpRequest request = HttpRequest.post(uri); + if (requestHttp.getRequestHttpProxy() != null) { + requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); + } + request.withConnectionProvider(requestHttp.getRequestHttpClient()); + request.form("data", file); + request.form("upload_id", uploadId); + request.form("part_number", partNumber); + request.form("resource_type", resourceType); + + HttpResponse response = request.send(); + response.charset(StandardCharsets.UTF_8.name()); + + String responseContent = response.bodyText(); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMaVodUploadPartResult.fromJson(responseContent); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/OkHttpVodSingleUploadRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/OkHttpVodSingleUploadRequestExecutor.java new file mode 100644 index 0000000000..78fbdd3d25 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/OkHttpVodSingleUploadRequestExecutor.java @@ -0,0 +1,56 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodSingleFileUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; +import okhttp3.*; + +import java.io.File; +import java.io.IOException; + +/** + * + */ +public class OkHttpVodSingleUploadRequestExecutor extends VodSingleUploadRequestExecutor { + + public OkHttpVodSingleUploadRequestExecutor(RequestHttp requestHttp, String mediaName, String mediaType, String coverType, File coverData, String sourceContext) { + super(requestHttp, mediaName, mediaType, coverType, coverData, sourceContext); + } + + @Override + public WxMaVodSingleFileUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { + + MultipartBody.Builder bodyBuilder = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("media_data", + file.getName(), + RequestBody.create(MediaType.parse("application/octet-stream"), file)); + bodyBuilder.addFormDataPart("media_type", this.mediaType) + .addFormDataPart("media_name", this.mediaName); + + if (coverType != null) { + bodyBuilder.addFormDataPart("cover_type", this.coverType); + } + if (coverData != null) { + bodyBuilder.addFormDataPart("cover_data", + coverData.getName(), + RequestBody.create(MediaType.parse("application/octet-stream"), coverData)); + } + if (sourceContext != null) { + bodyBuilder.addFormDataPart("source_context", this.sourceContext); + } + Request request = new Request.Builder().url(uri).post(bodyBuilder.build()).build(); + + Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); + String responseContent = response.body().string(); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMaVodSingleFileUploadResult.fromJson(responseContent); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/OkHttpVodUploadPartRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/OkHttpVodUploadPartRequestExecutor.java new file mode 100644 index 0000000000..c9e991d082 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/OkHttpVodUploadPartRequestExecutor.java @@ -0,0 +1,47 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodUploadPartResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; +import okhttp3.*; + +import java.io.File; +import java.io.IOException; + +/** + * + */ +public class OkHttpVodUploadPartRequestExecutor extends VodUploadPartRequestExecutor { + + public OkHttpVodUploadPartRequestExecutor(RequestHttp requestHttp, String uploadId, Integer partNumber, Integer resourceType) { + super(requestHttp, uploadId, partNumber, resourceType); + + } + + @Override + public WxMaVodUploadPartResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { + + MultipartBody.Builder bodyBuilder = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("data", + file.getName(), + RequestBody.create(MediaType.parse("application/octet-stream"), file)); + bodyBuilder.addFormDataPart("upload_id", uploadId) + .addFormDataPart("part_number", String.valueOf(this.partNumber)) + .addFormDataPart("resource_type", String.valueOf(this.resourceType)); + + Request request = new Request.Builder().url(uri).post(bodyBuilder.build()).build(); + + Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); + String responseContent = response.body().string(); + WxError error = WxError.fromJson(responseContent, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return WxMaVodUploadPartResult.fromJson(responseContent); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/VodSingleUploadRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/VodSingleUploadRequestExecutor.java new file mode 100644 index 0000000000..40c73b0064 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/VodSingleUploadRequestExecutor.java @@ -0,0 +1,59 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodSingleFileUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.ResponseHandler; + +import java.io.File; +import java.io.IOException; + +/** + * 小程序 提审素材上传接口 + * 上传媒体文件请求执行器. + * 请求的参数是File, 返回的结果是String + * + * @author yangyh22 + * @since 2020/11/14 + */ +public abstract class VodSingleUploadRequestExecutor implements RequestExecutor { + + protected RequestHttp requestHttp; + protected String mediaName; + protected String mediaType; + protected String coverType; + protected String sourceContext; + protected File coverData; + + public VodSingleUploadRequestExecutor(RequestHttp requestHttp, String mediaName, String mediaType, String coverType, File coverData, String sourceContext) { + this.requestHttp = requestHttp; + this.mediaName = mediaName; + this.mediaType = mediaType; + this.coverType = coverType; + this.coverData = coverData; + this.sourceContext = sourceContext; + + } + + public static RequestExecutor create(RequestHttp requestHttp, String mediaName, String mediaType, String coverType, File coverData, String sourceContext) { + switch (requestHttp.getRequestType()) { + case APACHE_HTTP: + return new ApacheVodSingleUploadRequestExecutor(requestHttp, mediaName, mediaType, coverType, coverData, sourceContext); + case JODD_HTTP: + return new JoddHttpVodSingleUploadRequestExecutor(requestHttp, mediaName, mediaType, coverType, coverData, sourceContext); + case OK_HTTP: + return new OkHttpVodSingleUploadRequestExecutor(requestHttp, mediaName, mediaType, coverType, coverData, sourceContext); + default: + return null; + } + } + + @Override + public void execute(String uri, File data, ResponseHandler handler, WxType wxType) throws WxErrorException, IOException { + handler.handle(this.execute(uri, data, wxType)); + } + + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/VodUploadPartRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/VodUploadPartRequestExecutor.java new file mode 100644 index 0000000000..96c6914acf --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/executor/VodUploadPartRequestExecutor.java @@ -0,0 +1,49 @@ +package cn.binarywang.wx.miniapp.executor; + +import cn.binarywang.wx.miniapp.bean.vod.WxMaVodUploadPartResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.ResponseHandler; + +import java.io.File; +import java.io.IOException; + +/** + */ +public abstract class VodUploadPartRequestExecutor implements RequestExecutor { + + protected RequestHttp requestHttp; + protected String uploadId; + protected Integer partNumber; + protected Integer resourceType; + + public VodUploadPartRequestExecutor(RequestHttp requestHttp, String uploadId, Integer partNumber, Integer resourceType) { + this.requestHttp = requestHttp; + this.uploadId = uploadId; + this.partNumber = partNumber; + this.resourceType = resourceType; + + } + + public static RequestExecutor create(RequestHttp requestHttp, String uploadId, Integer partNumber, Integer resourceType) { + switch (requestHttp.getRequestType()) { + case APACHE_HTTP: + return new ApacheVodUploadPartRequestExecutor(requestHttp, uploadId, partNumber, resourceType); + case JODD_HTTP: + return new JoddHttpVodUploadPartRequestExecutor(requestHttp, uploadId, partNumber, resourceType); + case OK_HTTP: + return new OkHttpVodUploadPartRequestExecutor(requestHttp, uploadId, partNumber, resourceType); + default: + return null; + } + } + + @Override + public void execute(String uri, File data, ResponseHandler handler, WxType wxType) throws WxErrorException, IOException { + handler.handle(this.execute(uri, data, wxType)); + } + + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/json/WxMaGsonBuilder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/json/WxMaGsonBuilder.java index e6f6842fa2..5379826656 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/json/WxMaGsonBuilder.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/json/WxMaGsonBuilder.java @@ -1,6 +1,7 @@ package cn.binarywang.wx.miniapp.json; import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMsgEvent; import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage; import cn.binarywang.wx.miniapp.bean.analysis.WxMaRetainInfo; import cn.binarywang.wx.miniapp.bean.analysis.WxMaUserPortrait; @@ -10,12 +11,14 @@ import cn.binarywang.wx.miniapp.json.adaptor.*; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import java.util.Objects; /** * @author Binary Wang */ public class WxMaGsonBuilder { private static final GsonBuilder INSTANCE = new GsonBuilder(); + private static volatile Gson GSON_INSTANCE; static { INSTANCE.disableHtmlEscaping(); @@ -26,10 +29,18 @@ public class WxMaGsonBuilder { INSTANCE.registerTypeAdapter(WxMaVisitDistribution.class, new WxMaVisitDistributionGsonAdapter()); INSTANCE.registerTypeAdapter(WxMaRetainInfo.class, new WxMaRetainInfoGsonAdapter()); INSTANCE.registerTypeAdapter(WxMaUserPortrait.class, new WxMaUserPortraitGsonAdapter()); + INSTANCE.registerTypeAdapter(WxMaSubscribeMsgEvent.WxMaSubscribeMsgEventJson.class, new WxMaSubscribeMsgEventJsonAdapter()); } public static Gson create() { - return INSTANCE.create(); + if (Objects.isNull(GSON_INSTANCE)) { + synchronized (INSTANCE) { + if (Objects.isNull(GSON_INSTANCE)) { + GSON_INSTANCE = INSTANCE.create(); + } + } + } + return GSON_INSTANCE; } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/json/adaptor/WxMaSubscribeMsgEventJsonAdapter.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/json/adaptor/WxMaSubscribeMsgEventJsonAdapter.java new file mode 100644 index 0000000000..377f8e35ef --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/json/adaptor/WxMaSubscribeMsgEventJsonAdapter.java @@ -0,0 +1,104 @@ +package cn.binarywang.wx.miniapp.json.adaptor; + +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMsgEvent; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import lombok.extern.slf4j.Slf4j; + +import java.lang.reflect.Type; + +/** + * WxMaSubscribeMsgEventJsonAdapter class + * + * @author dany + * created on 2021/12/31 + */ +@Slf4j +public class WxMaSubscribeMsgEventJsonAdapter implements JsonDeserializer { + @Override + public WxMaSubscribeMsgEvent.WxMaSubscribeMsgEventJson deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + WxMaSubscribeMsgEvent.WxMaSubscribeMsgEventJson result = new WxMaSubscribeMsgEvent.WxMaSubscribeMsgEventJson(); + if (json.isJsonArray()) { + JsonArray array = json.getAsJsonArray(); + if (array.size() > 0) { + JsonObject obj = array.get(0).getAsJsonObject(); + MsgEventTypeEnum eventType = detectMsgEventType(obj); + for (int i = 0; i < array.size(); ++i) { + obj = array.get(i).getAsJsonObject(); + setField(result, eventType, obj); + } + } + } else { + JsonObject obj = json.getAsJsonObject(); + MsgEventTypeEnum eventType = detectMsgEventType(obj); + setField(result, eventType, obj); + } + return result; + } + + public enum MsgEventTypeEnum { + EVENT_POPUP,EVENT_CHANGE,EVENT_SENT; + } + private MsgEventTypeEnum detectMsgEventType(JsonObject obj) { + JsonElement popupScene = obj.get("PopupScene"); + if (popupScene != null) { + return MsgEventTypeEnum.EVENT_POPUP; + } + + JsonElement msgId = obj.get("MsgID"); + if (msgId != null) { + return MsgEventTypeEnum.EVENT_SENT; + } + JsonElement errorCode = obj.get("ErrorCode"); + if (errorCode != null) { + return MsgEventTypeEnum.EVENT_SENT; + } + JsonElement errorStatus = obj.get("ErrorStatus"); + if (errorStatus != null) { + return MsgEventTypeEnum.EVENT_SENT; + } + + return MsgEventTypeEnum.EVENT_CHANGE; + } + + private WxMaSubscribeMsgEvent.WxMaSubscribeMsgEventJson setField(WxMaSubscribeMsgEvent.WxMaSubscribeMsgEventJson target, + MsgEventTypeEnum eventType, JsonObject json) { + switch (eventType) { + case EVENT_POPUP: + if (target.getPopupEvents() == null) { + target.setPopupEvents(new WxMaSubscribeMsgEvent.SubscribeMsgPopupEvent()); + } + WxMaSubscribeMsgEvent.PopupEvent popupEvent = new WxMaSubscribeMsgEvent.PopupEvent(); + popupEvent.setTemplateId(json.get("TemplateId").getAsString()); + popupEvent.setSubscribeStatusString(json.get("SubscribeStatusString").getAsString()); + popupEvent.setPopupScene(json.get("PopupScene").getAsString()); + target.getPopupEvents().getList().add(popupEvent); + break; + case EVENT_CHANGE: + if (target.getChangeEvents() == null) { + target.setChangeEvents(new WxMaSubscribeMsgEvent.SubscribeMsgChangeEvent()); + } + WxMaSubscribeMsgEvent.ChangeEvent changeEvent = new WxMaSubscribeMsgEvent.ChangeEvent(); + changeEvent.setTemplateId(json.get("TemplateId").getAsString()); + changeEvent.setSubscribeStatusString(json.get("SubscribeStatusString").getAsString()); + target.getChangeEvents().getList().add(changeEvent); + break; + case EVENT_SENT: + if (target.getSentEvent() == null) { + target.setSentEvent(new WxMaSubscribeMsgEvent.SubscribeMsgSentEvent()); + } + WxMaSubscribeMsgEvent.SentEvent sentEvent = new WxMaSubscribeMsgEvent.SentEvent(); + sentEvent.setTemplateId(json.get("TemplateId").getAsString()); + sentEvent.setMsgId(json.get("MsgID").getAsString()); + sentEvent.setErrorCode(json.get("ErrorCode").getAsString()); + sentEvent.setErrorStatus(json.get("ErrorStatus").getAsString()); + target.getSentEvent().setList(sentEvent); + break; + } + return target; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java index 031c688c52..6cd603929d 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java @@ -2,11 +2,13 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaMessage; +import cn.binarywang.wx.miniapp.util.WxMaConfigHolder; import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.Data; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker; +import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateCheckerSingleton; import me.chanjar.weixin.common.session.InternalSession; import me.chanjar.weixin.common.session.InternalSessionManager; import me.chanjar.weixin.common.session.StandardSessionManager; @@ -48,7 +50,52 @@ public WxMaMessageRouter(WxMaService wxMaService) { 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); this.sessionManager = new StandardSessionManager(); this.exceptionHandler = new LogExceptionHandler(); - this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); + } + + /** + * 使用自定义的 {@link ExecutorService}. + */ + public WxMaMessageRouter(WxMaService wxMaService, ExecutorService executorService) { + this.wxMaService = wxMaService; + this.executorService = executorService; + this.sessionManager = new StandardSessionManager(); + this.exceptionHandler = new LogExceptionHandler(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); + } + + /** + * 系统退出前,应该调用该方法 + */ + public void shutDownExecutorService() { + this.executorService.shutdown(); + } + + /** + * 系统退出前,应该调用该方法,增加了超时时间检测 + */ + public void shutDownExecutorService(Integer second) { + this.executorService.shutdown(); + try { + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { + this.executorService.shutdownNow(); + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) + log.error("线程池未关闭!"); + } + } catch (InterruptedException ie) { + this.executorService.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + + /** + *

+   * 设置自定义的 {@link ExecutorService}
+   * 如果不调用该方法,默认使用内置的
+   * 
+ */ + public void setExecutorService(ExecutorService executorService) { + this.executorService = executorService; } /** @@ -61,7 +108,7 @@ public WxMaMessageRouterRule rule() { /** * 处理微信消息. */ - private WxMaXmlOutMessage route(final WxMaMessage wxMessage, final Map context) { + public WxMaXmlOutMessage route(final WxMaMessage wxMessage, final Map context) { if (isMsgDuplicated(wxMessage)) { // 如果是重复消息,那么就不做处理 return null; @@ -87,9 +134,14 @@ private WxMaXmlOutMessage route(final WxMaMessage wxMessage, final Map { + //子线程中设置实际的appId + this.wxMaService.switchoverTo(miniAppId); rule.service(wxMessage, context, WxMaMessageRouter.this.wxMaService, WxMaMessageRouter.this.sessionManager, WxMaMessageRouter.this.exceptionHandler); + WxMaConfigHolder.remove(); }) ); } else { @@ -137,6 +189,10 @@ private boolean isMsgDuplicated(WxMaMessage wxMessage) { messageId.append("-").append(wxMessage.getToUser()); } + if (StringUtils.isNotEmpty(wxMessage.getTraceId())) { + messageId.append("-").append(wxMessage.getTraceId()); + } + return this.messageDuplicateChecker.isDuplicate(messageId.toString()); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaXmlOutMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaXmlOutMessage.java index 7211e0531a..a6c2b828ae 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaXmlOutMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaXmlOutMessage.java @@ -18,7 +18,7 @@ * 微信小程序输出给微信服务器的消息. * * @author Binary Wang - * @date 2019-06-22 + * created on 2019-06-22 */ @Data @XStreamAlias("xml") diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/JoinerUtils.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/JoinerUtils.java deleted file mode 100644 index 3ef3eb915d..0000000000 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/JoinerUtils.java +++ /dev/null @@ -1,253 +0,0 @@ -/** - * Copyright (c) 2019,sunnybs. - * All Rights Reserved. - *

- * Project Name:yigou - */ -package cn.binarywang.wx.miniapp.util; - -import com.google.common.base.Joiner; - -/** - * ClassName: JoinerUtils
- * Description: 字符串连接器
- * Date: 2019年10月18日 下午1:42:59
- * - * @author wsp - */ - -public class JoinerUtils { - private static final String NULL = "null"; - - /** - *

- * 空白连接器,忽略null - *

- * - *
-     * JoinerUtils.blankJoiner.join("a", "b", "c");
-     * result : abc
-     * 
-     * JoinerUtils.blankJoiner.join("a", null, "c");
-     * result : ac
-     * 
- */ - public static final Joiner blankJoiner = Joiner.on("").skipNulls(); - /** - *

- * 空白连接器 - *

- * - *
-     * JoinerUtils.blankJoinerWithNull.join("a", "b", "c");
-     * result : abc
-     * 
-     * JoinerUtils.blankJoinerWithNull.join("a", null, "c");
-     * result : anullc
-     * 
- */ - public static final Joiner blankJoinerWithNull = Joiner.on("").useForNull(NULL); - - /** - *

- * 空格连接器,忽略null - *

- * - *
-     * JoinerUtils.spaceJoiner.join("a", "b", "c");
-     * result : a b c
-     * 
-     * JoinerUtils.spaceJoiner.join("a", null, "c");
-     * result : a c
-     * 
- */ - public static final Joiner spaceJoiner = Joiner.on(" ").skipNulls(); - /** - *

- * 空格连接器 - *

- * - *
-     * JoinerUtils.spaceJoinerWithNull.join("a", "b", "c");
-     * result : a b c
-     * 
-     * JoinerUtils.spaceJoinerWithNull.join("a", null, "c");
-     * result : a null c
-     * 
- */ - public static final Joiner spaceJoinerWithNull = Joiner.on(" ").useForNull(NULL); - - /** - *

- * 逗号分隔符连接器,忽略null - *

- * - *
-   * JoinerUtils.commaJoiner.join("a", "b", "c");
-   * result : a,b,c
-   *
-   * JoinerUtils.commaJoiner.join("a", null, "c");
-   * result : a,c
-   * 
- */ - public static final Joiner commaJoiner = Joiner.on(",").skipNulls(); - /** - *

- * 逗号分隔符连接器 - *

- * - *
-   * JoinerUtils.commaJoinerWithNull.join("a", "b", "c");
-   * result : a,b,c
-   *
-   * JoinerUtils.commaJoinerWithNull.join("a", null, "c");
-   * result : a,null,c
-   * 
- */ - public static final Joiner commaJoinerWithNull = Joiner.on(",").useForNull(NULL); - - /** - *

- * 等号分隔符连接器,忽略null - *

- * - *
-   * JoinerUtils.equalJoiner.join("a", "b", "c");
-   * result : a=b=c
-   *
-   * JoinerUtils.equalJoiner.join("a", null, "c");
-   * result : a=c
-   * 
- */ - public static final Joiner equalJoiner = Joiner.on("=").skipNulls(); - /** - *

- * 等号分隔符连接器 - *

- * - *
-   * JoinerUtils.equalJoinerWithNull.join("a", "b", "c");
-   * result : a=b=c
-   *
-   * JoinerUtils.equalJoinerWithNull.join("a", null, "c");
-   * result : a=null=c
-   * 
- */ - public static final Joiner equalJoinerWithNull = Joiner.on("=").useForNull(NULL); - - /** - *

- * 竖线分隔符连接器,忽略null - *

- * - *
-     * JoinerUtils.vLineJoiner.join("a", "b", "c");
-     * result : a|b|c
-     * 
-     * JoinerUtils.vLineJoiner.join("a", null, "c");
-     * result : a|c
-     * 
- */ - public static final Joiner vLineJoiner = Joiner.on("|").skipNulls(); - /** - *

- * 竖线分隔符连接器 - *

- * - *
-     * JoinerUtils.vLineJoinerWithNull.join("a", "b", "c");
-     * result : a|b|c
-     * 
-     * JoinerUtils.vLineJoinerWithNull.join("a", null, "c");
-     * result : a|null|c
-     * 
- */ - public static final Joiner vLineJoinerWithNull = Joiner.on("|").useForNull(NULL); - - /** - *

- * 中横线分隔符连接器,忽略null - *

- * - *
-     * JoinerUtils.hLineJoiner.join("a", "b", "c");
-     * result : a-b-c
-     * 
-     * JoinerUtils.hLineJoiner.join("a", null, "c");
-     * result : a-c
-     * 
- */ - public static final Joiner hLineJoiner = Joiner.on("-").skipNulls(); - /** - *

- * 中横线分隔符连接器 - *

- * - *
-     * JoinerUtils.hLineJoinerWithNull.join("a", "b", "c");
-     * result : a-b-c
-     * 
-     * JoinerUtils.hLineJoinerWithNull.join("a", null, "c");
-     * result : a-null-c
-     * 
- */ - public static final Joiner hLineJoinerWithNull = Joiner.on("-").useForNull(NULL); - - /** - *

- * 下划线分隔符连接器,忽略null - *

- * - *
-     * JoinerUtils.underlineJoiner.join("a", "b", "c");
-     * result : a_b_c
-     * 
-     * JoinerUtils.underlineJoiner.join("a", null, "c");
-     * result : a_c
-     * 
- */ - public static final Joiner underlineJoiner = Joiner.on("_").skipNulls(); - /** - *

- * 下划线分隔符连接器 - *

- * - *
-     * JoinerUtils.underlineJoinerWithNull.join("a", "b", "c");
-     * result : a_b_c
-     * 
-     * JoinerUtils.underlineJoinerWithNull.join("a", null, "c");
-     * result : a_null_c
-     * 
- */ - public static final Joiner underlineJoinerWithNull = Joiner.on("_").useForNull(NULL); - - /** - *

- * 斜线分隔符连接器,忽略null - *

- * - *
-     * JoinerUtils.pathJoiner.join("a", "b", "c");
-     * result : a/b/c
-     * 
-     * JoinerUtils.pathJoiner.join("a", null, "c");
-     * result : a/c
-     * 
- */ - public static final Joiner pathJoiner = Joiner.on("/").skipNulls(); - /** - *

- * 斜线分隔符连接器 - *

- * - *
-     * JoinerUtils.pathJoinerWithNull.join("a", "b", "c");
-     * result : a/b/c
-     * 
-     * JoinerUtils.pathJoinerWithNull.join("a", null, "c");
-     * result : a/null/c
-     * 
- */ - public static final Joiner pathJoinerWithNull = Joiner.on("/").useForNull(NULL); -} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/WxMaConfigHolder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/WxMaConfigHolder.java index e73cb2282d..15dd8654c0 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/WxMaConfigHolder.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/WxMaConfigHolder.java @@ -4,10 +4,10 @@ * 小程序存储值存放类. * * @author Binary Wang - * @date 2020-08-16 + * created on 2020-08-16 */ public class WxMaConfigHolder { - private final static ThreadLocal THREAD_LOCAL = new ThreadLocal() { + private static final ThreadLocal THREAD_LOCAL = new ThreadLocal() { @Override protected String initialValue() { return "default"; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java index f1a05d001a..0222265e44 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java @@ -14,6 +14,7 @@ import com.google.common.io.BaseEncoding; import me.chanjar.weixin.common.error.WxRuntimeException; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; import org.bouncycastle.jce.provider.BouncyCastleProvider; import cn.binarywang.wx.miniapp.config.WxMaConfig; @@ -28,7 +29,7 @@ public class WxMaCryptUtils extends me.chanjar.weixin.common.util.crypto.WxCrypt public WxMaCryptUtils(WxMaConfig config) { this.appidOrCorpid = config.getAppid(); this.token = config.getToken(); - this.aesKey = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(config.getAesKey())); + this.aesKey = java.util.Base64.getDecoder().decode(StringUtils.remove(config.getAesKey(), " ")); } /** diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java index f0961d5edf..f36d8c8fbd 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java @@ -54,7 +54,22 @@ public static String toXml(Class clazz, T object) { public static void register(Class clz, XStream xStream) { CLASS_2_XSTREAM_INSTANCE.put(clz, xStream); } + /** + * 注册第三方的该类及其子类. + * 便利第三方类使用 XStreamTransformer进行序列化, 以及支持XStream 1.4.18 以上增加安全许可 + * @param clz 要注册的类 + */ + public static void registerExtendClass(Class clz){ + XStream xstream = XStreamInitializer.getInstance(); + Class[] innerClz = getInnerClasses(clz); + xstream.processAnnotations(clz); + xstream.processAnnotations(innerClz); + xstream.allowTypes(new Class[]{clz}); + xstream.allowTypes(innerClz); + + register(clz, xstream); + } /** * 会自动注册该类及其子类. * diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImplTest.java index 69d6cc990e..abc8f68fc1 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCloudServiceImplTest.java @@ -2,6 +2,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.cloud.*; +import cn.binarywang.wx.miniapp.bean.cloud.request.WxCloudSendSmsV2Request; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Lists; @@ -22,7 +23,7 @@ * 测试类. * * @author Binary Wang - * @date 2020-01-22 + * created on 2020-01-22 */ @Guice(modules = ApiTestModule.class) public class WxMaCloudServiceImplTest { @@ -394,4 +395,17 @@ public void testDatabaseCollectionGet() throws WxErrorException { assertThat(result.getCollections()[0].getIndexCount()).isGreaterThan(0); assertThat(result.getCollections()[0].getIndexSize()).isGreaterThan(0); } + + @Test + public void testSendSmsV2() throws WxErrorException { + WxCloudSendSmsV2Request request = WxCloudSendSmsV2Request.builder() + .urlLink("https://wxaurl.cn/xxxxxx") + .templateId("844110") + .templateParamList(Arrays.asList(new String[]{"能力上新"})) + .phoneNumberList(Arrays.asList("+8612345678910")) + .build(); + + final WxCloudSendSmsV2Result result = this.wxMaService.getCloudService().sendSmsV2(request); + assertThat(result).isNotNull(); + } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImplTest.java index 0a4aca45e3..52f8a02983 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaCodeServiceImplTest.java @@ -1,25 +1,21 @@ package cn.binarywang.wx.miniapp.api.impl; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.testng.annotations.*; - import cn.binarywang.wx.miniapp.api.WxMaCodeService; import cn.binarywang.wx.miniapp.api.WxMaService; -import cn.binarywang.wx.miniapp.bean.code.WxMaCategory; -import cn.binarywang.wx.miniapp.bean.code.WxMaCodeAuditStatus; -import cn.binarywang.wx.miniapp.bean.code.WxMaCodeCommitRequest; -import cn.binarywang.wx.miniapp.bean.code.WxMaCodeExtConfig; -import cn.binarywang.wx.miniapp.bean.code.WxMaCodeSubmitAuditRequest; -import cn.binarywang.wx.miniapp.bean.code.WxMaCodeVersionDistribution; +import cn.binarywang.wx.miniapp.bean.code.*; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import static org.testng.Assert.*; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; /** * @author Charming @@ -35,7 +31,7 @@ public class WxMaCodeServiceImplTest { @Test public void testGetCategory() throws Exception { - List categories = wxService.getCodeService().getCategory(); + List categories = wxService.getCodeService().getCategory(); System.out.println(String.valueOf(categories)); } @@ -91,7 +87,7 @@ public void testSubmitAudit() throws Exception { WxMaCodeSubmitAuditRequest auditRequest = WxMaCodeSubmitAuditRequest .builder() .itemList(Arrays.asList( - WxMaCategory + WxMaCodeSubmitAuditItem .builder() .address("pages/logs/logs") .tag("工具 效率") @@ -143,6 +139,12 @@ public void testGetSupportVersion() throws Exception { System.out.println(distribution); } + @Test + public void testGetVersionInfo() throws Exception { + WxMaCodeVersionInfo versionInfo = wxService.getCodeService().getVersionInfo(); + System.out.println(versionInfo); + } + @Test public void testSetSupportVersion() throws Exception { wxService.getCodeService().setSupportVersion("1.2.0"); diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImplTest.java new file mode 100644 index 0000000000..e1c4390549 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImplTest.java @@ -0,0 +1,59 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.device.WxMaDeviceSubscribeMessageRequest; +import cn.binarywang.wx.miniapp.bean.device.WxMaDeviceTicketRequest; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.common.collect.Lists; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * 小程序设备订阅消息相关 测试类 + * + * @author JCLee + * @since 2021-12-16 17:13:35 + */ +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaDeviceSubscribeServiceImplTest { + + @Inject + protected WxMaService wxService; + + @Test + public void testGetSnTicket() throws WxErrorException{ + WxMaDeviceTicketRequest wxMaDeviceTicketRequest = new WxMaDeviceTicketRequest(); + wxMaDeviceTicketRequest.setModelId("11111"); + wxMaDeviceTicketRequest.setSn("11111"); + String snTicket = this.wxService.getDeviceSubscribeService().getSnTicket(wxMaDeviceTicketRequest); + System.out.println(snTicket); + } + + @Test + public void sendDeviceSubscribeMsg() throws WxErrorException{ + WxMaDeviceSubscribeMessageRequest wxMaDeviceSubscribeMessageRequest = new WxMaDeviceSubscribeMessageRequest(); + wxMaDeviceSubscribeMessageRequest.setToOpenidList(Lists.newArrayList("1", "2")); + wxMaDeviceSubscribeMessageRequest.setPage("pages/index/index"); + wxMaDeviceSubscribeMessageRequest.setTemplateId("11111111"); + wxMaDeviceSubscribeMessageRequest.setSn("111111"); + JsonObject data = GsonParser.parse("{\n" + + "\t\t\"thing2\": {\n" + + "\t\t\t\"value\": \"阳台\"\n" + + "\t\t},\n" + + "\t\t\"time1\": {\n" + + "\t\t\t\"value\": \"2021-09-30 13:32:44\"\n" + + "\t\t},\n" + + "\t\t\"thing3\": {\n" + + "\t\t\t\"value\": \"洗衣已完成\"\n" + + "\t\t}\n" + + "\t}"); + wxMaDeviceSubscribeMessageRequest.setData(data); + this.wxService.getDeviceSubscribeService().sendDeviceSubscribeMsg(wxMaDeviceSubscribeMessageRequest); + } +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImplTest.java new file mode 100644 index 0000000000..49e3e3e0c9 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImplTest.java @@ -0,0 +1,203 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmRequest; +import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmResponse; +import cn.binarywang.wx.miniapp.bean.delivery.AddOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.AddOrderResponse; +import cn.binarywang.wx.miniapp.bean.delivery.BindAccountResponse; +import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderResponse; +import cn.binarywang.wx.miniapp.bean.delivery.GetOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.GetOrderResponse; +import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderRequest; +import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderResponse; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.common.collect.Lists; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.math.BigDecimal; + +/** + * 微信小程序即时配送服务测试. + * + * @author Luo + * @version 1.0 + * created on 2021-10-14 11:48 + */ +@Guice(modules = ApiTestModule.class) +public class WxMaImmediateDeliveryServiceImplTest { + + /** + * 对应配送公司的appKey. + */ + private static final String SHOP_ID = "***"; + + /** + * 对应配送公司appSecret. + */ + private static final String APP_SECRET = "****"; + + /** + * 商家门店编号. + */ + private static final String SHOP_NO = "***"; + + /** + * 快递公司Id. + */ + private static final String DELIVERY_ID = "SFTC"; + + @Inject + private WxMaService wxMaService; + + /** + * 测试拉取已绑定账号接口. + * + * @throws WxErrorException 异常 + */ + @Test + public void testGetBindAccount() throws WxErrorException { + BindAccountResponse response = wxMaService.getWxMaImmediateDeliveryService().getBindAccount(); + System.out.println("response = " + response); + } + + /** + * 测试下配送单接口. + * + * @throws WxErrorException 异常 + */ + @Test + public void testAddOrder() throws WxErrorException { + AddOrderRequest request = new AddOrderRequest(); + // 下单用户的openid + request.setOpenid("*****"); + // 微信平台字段,对应配送公司的appkey + request.setShopId(SHOP_ID); + // 对应配送公司appSecret + request.setAppSecret(APP_SECRET); + // 商家门店编号,在配送公司登记,如果只有一个门店,美团闪送必填, 值为店铺id + // 商家对不同门店进行的编号,需要在配送公司系统有过登记,比如商家自己门店系统中有100个门店,编号是1-100,在顺丰同城的系统中有登记过这100个门店,且在顺丰同城登记的编号也是1-100,那么下单的时候传shop_no + // =1,就是编号为1 的门店下的配送单 + request.setShopNo(SHOP_NO); + // 配送公司Id + request.setDeliveryId(DELIVERY_ID); + // 唯一标识订单的 ID,由商户生成, 不超过 128 字节 + String shopOrderId = String.valueOf(System.currentTimeMillis()); + request.setShopOrderId(shopOrderId); + + // 订单信息 + AddOrderRequest.OrderInfo orderInfo = new AddOrderRequest.OrderInfo(); + orderInfo.setOrderTime(System.currentTimeMillis() / 1000L); + request.setOrderInfo(orderInfo); + + // 发件人信息 + AddOrderRequest.Sender sender = new AddOrderRequest.Sender(); + sender.setCity("上海市").setAddress("***").setAddressDetail("****"); + sender.setName("***").setPhone("166****8829"); + sender.setLng(new BigDecimal("121.281379")).setLat(new BigDecimal("31.049363")); + request.setSender(sender); + + // 收件人信息 + AddOrderRequest.Receiver receiver = new AddOrderRequest.Receiver().setCoordinateType(1); + receiver.setCity("北京市").setAddress("海淀区").setAddressDetail("北京市海淀区学清嘉创大厦A座15层"); + receiver.setName("顺丰同城").setPhone("166****8829"); + receiver.setLng(new BigDecimal("116.359442")).setLat(new BigDecimal("40.020407")); + request.setReceiver(receiver); + + // 商品信息 + AddOrderRequest.Cargo cargo = new AddOrderRequest.Cargo(); + cargo.setCargoFirstClass("电商").setCargoSecondClass("线上商城"); + cargo.setGoodsHeight(BigDecimal.valueOf(1)).setGoodsLength(BigDecimal.valueOf(3)); + cargo.setGoodsValue(BigDecimal.valueOf(5)).setGoodsWeight(BigDecimal.valueOf(1)).setGoodsWidth(BigDecimal.valueOf(2)); + // 商品列表 + AddOrderRequest.Cargo.GoodsDetail goodsDetail = new AddOrderRequest.Cargo.GoodsDetail(); + AddOrderRequest.Cargo.GoodsDetail.Goods goods1 = new AddOrderRequest.Cargo.GoodsDetail.Goods(); + goods1.setGoodCount(1).setGoodName("水果").setGoodPrice(new BigDecimal(10)); + AddOrderRequest.Cargo.GoodsDetail.Goods goods2 = new AddOrderRequest.Cargo.GoodsDetail.Goods(); + goods2.setGoodCount(2).setGoodName("蔬菜").setGoodPrice(new BigDecimal(20)); + goodsDetail.setGoods(Lists.newArrayList(goods1, goods2)); + cargo.setGoodsDetail(goodsDetail); + request.setCargo(cargo); + + // 店铺信息 + AddOrderRequest.Shop shop = new AddOrderRequest.Shop(); + int sum = + request.getCargo().getGoodsDetail().getGoods().stream().mapToInt(AddOrderRequest.Cargo.GoodsDetail.Goods::getGoodCount).sum(); + shop.setGoodsCount(sum).setGoodsName("商品"); + shop.setImgUrl("https://").setWxaPath("pages/index/index"); + request.setShop(shop); + + AddOrderResponse response = wxMaService.getWxMaImmediateDeliveryService().addOrder(request); + System.out.println("response = " + response); + + } + + /** + * 测试拉取配送单信息接口. + * + * @throws WxErrorException 异常 + */ + @Test + public void testGetOrder() throws WxErrorException { + GetOrderRequest request = new GetOrderRequest(); + request.setShopId(SHOP_ID).setShopNo(SHOP_NO).setAppSecret(APP_SECRET); + request.setShopOrderId("1561399675737608193"); + GetOrderResponse response = wxMaService.getWxMaImmediateDeliveryService().getOrder(request); + System.out.println("response = " + response); + } + + /** + * 测试取消配送单信息接口. + * + * @throws WxErrorException 异常 + */ + @Test + public void testCancelOrder() throws WxErrorException { + CancelOrderRequest request = new CancelOrderRequest(); + request.setShopId(SHOP_ID).setShopNo(SHOP_NO).setAppSecret(APP_SECRET); + request.setDeliveryId(DELIVERY_ID); + request.setCancelReasonId(1); + request.setShopOrderId("1560365275348471809"); + request.setWaybillId("3427365636312065025"); + CancelOrderResponse response = wxMaService.getWxMaImmediateDeliveryService().cancelOrder(request); + System.out.println("response = " + response); + } + + /** + * 测试异常件退回商家商家确认收货接口. + * + * @throws WxErrorException 异常 + */ + @Test + public void testAbnormalConfirm() throws WxErrorException { + AbnormalConfirmRequest request = new AbnormalConfirmRequest(); + request.setShopId(SHOP_ID).setShopNo(SHOP_NO).setAppSecret(APP_SECRET); + request.setDeliveryId(DELIVERY_ID); + request.setShopOrderId("1561399675737608193"); + request.setWaybillId("3427882855372591617"); + request.setRemark("测试签收异常订单"); + AbnormalConfirmResponse response = wxMaService.getWxMaImmediateDeliveryService().abnormalConfirm(request); + System.out.println("response = " + response); + } + + /** + * 测试模拟配送公司更新配送单状态接口. + * + * @throws WxErrorException 异常 + */ + @Test + public void testMockUpdateOrder() throws WxErrorException { + // 请求参数 + MockUpdateOrderRequest request = new MockUpdateOrderRequest(); + request.setActionTime(System.currentTimeMillis() / 1000L); + request.setOrderStatus(102); + request.setShopOrderId(""); + MockUpdateOrderResponse response = wxMaService.getWxMaImmediateDeliveryService().mockUpdateOrder(request); + System.out.println("response = " + response); + } + +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImplTest.java index ccc2f9c93a..9a0203a7a5 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaInternetServiceImplTest.java @@ -4,16 +4,19 @@ import cn.binarywang.wx.miniapp.bean.internet.WxMaInternetResponse; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; -import me.chanjar.weixin.common.error.WxErrorException; import org.testng.annotations.Guice; import org.testng.annotations.Test; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +import static org.assertj.core.api.Assertions.assertThat; + /** - * * 服务端网络相关接口测试 * * @author chutian0124 - * @date 2021-09-06 + * created on 2021-09-06 */ @Test @Guice(modules = ApiTestModule.class) @@ -21,9 +24,32 @@ public class WxMaInternetServiceImplTest { @Inject private WxMaService wxService; + private static String HMACSHA256(String data, String key) throws Exception { + Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); + SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256"); + sha256_HMAC.init(secret_key); + byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (byte item : array) { + sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); + } + return sb.toString().toUpperCase(); + } + + @Test + public void testGetUserEncryptKey() throws Exception { + String openid = "ogu-84hVFTbTt-myGisQESoDJ6BM"; + String signature = HMACSHA256("", "9ny8n3t0KULoi0deF7T9pw=="); + String sigMethod = "hmac_sha256"; + WxMaInternetResponse response = this.wxService.getInternetService().getUserEncryptKey(openid, signature, sigMethod); + assertThat(response).isNotNull(); + } + @Test - public void testGetUserEncryptKey() throws WxErrorException { - WxMaInternetResponse response = this.wxService.getInternetService().getUserEncryptKey(); - System.out.println(response); + public void testGetUserEncryptKey2() throws Exception { + String openid = "ogu-84hVFTbTt-myGisQESoDJ6BM"; + String sessionKey = "9ny8n3t0KULoi0deF7T9pw=="; + WxMaInternetResponse response = this.wxService.getInternetService().getUserEncryptKey(openid, sessionKey); + assertThat(response).isNotNull(); } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImplTest.java index c97e11077d..45ea9e2279 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImplTest.java @@ -3,14 +3,22 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.shortlink.GenerateShortLinkRequest; import cn.binarywang.wx.miniapp.bean.urllink.GenerateUrlLinkRequest; +import cn.binarywang.wx.miniapp.bean.urllink.request.QueryUrlLinkRequest; +import cn.binarywang.wx.miniapp.bean.urllink.response.QueryUrlLinkResponse; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; +import java.time.LocalDateTime; +import java.time.ZoneId; + @Test @Guice(modules = ApiTestModule.class) +@Slf4j public class WxMaLinkServiceImplTest { @Inject private WxMaService wxMaService; @@ -19,6 +27,7 @@ public class WxMaLinkServiceImplTest { public void testGenerateUrlLink() throws WxErrorException { String url = this.wxMaService.getLinkService().generateUrlLink(GenerateUrlLinkRequest.builder() .path("pages/tabBar/home/home") + .expireTime(LocalDateTime.now().plusDays(5).atZone(ZoneId.systemDefault()).toEpochSecond()) //增加有效期,此行可注释 .build()); System.out.println(url); @@ -34,4 +43,34 @@ public void testGenerateShortLink() throws WxErrorException { System.out.println("generate:"); System.out.println(generate); } + + /** + * 多版本链接生成测试 + * 开发时,仅支持IOS设备打开体验版及开发版 + */ + @Test + public void testGenerateMultiEnvUrlLink() throws WxErrorException { + String url = this.wxMaService.getLinkService().generateUrlLink(GenerateUrlLinkRequest.builder() + .path("") + .envVersion("trial") + .build()); + log.info("generate url link = {}", url); + } + + @Test + public void testQueryUrlLink() throws WxErrorException { + + String path = "pages/index"; + String urlLink = this.wxMaService.getLinkService().generateUrlLink(GenerateUrlLinkRequest.builder() + .path(path) + .expireTime(LocalDateTime.now().plusDays(5).atZone(ZoneId.systemDefault()).toEpochSecond()) //增加有效期,此行可注释 + .build()); + System.out.println("urlLink: " + urlLink); + + QueryUrlLinkResponse queryUrlLinkResponse = this.wxMaService.getLinkService() + .queryUrlLink(QueryUrlLinkRequest.builder().urlLink(urlLink).build()); + System.out.println("linkInfo: " + queryUrlLinkResponse.toString()); + + Assert.assertEquals(path, queryUrlLinkResponse.getUrlLinkInfo().getPath()); + } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImplTest.java index f5ffb59d7e..eab4826014 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveMemberServiceImplTest.java @@ -12,7 +12,7 @@ * 测试. * * @author Binary Wang - * @date 2021-02-15 + * created on 2021-02-15 */ @Test @Guice(modules = ApiTestModule.class) diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java index b9a5b94121..9129b8e7fc 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java @@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.bean.live.WxMaCreateRoomResult; import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult; import cn.binarywang.wx.miniapp.bean.live.WxMaLiveRoomInfo; +import cn.binarywang.wx.miniapp.bean.live.WxMaLiveSharedCode; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; @@ -39,14 +40,14 @@ public void createRoom() throws Exception { roomInfo.setName("订阅通知直播间"); roomInfo.setCoverImg(mediaUpload.getMediaId()); Calendar c = Calendar.getInstance(); - c.set(2020, Calendar.DECEMBER, 10, 8, 0); + c.set(2023, Calendar.FEBRUARY, 10, 8, 0); roomInfo.setStartTime(c.getTimeInMillis() / 1000); - c.set(2020, Calendar.DECEMBER, 10, 12, 0); + c.set(2023, Calendar.FEBRUARY, 10, 12, 0); roomInfo.setEndTime(c.getTimeInMillis() / 1000); roomInfo.setAnchorName("鹏军_专业小程序开发"); roomInfo.setAnchorWechat("pengjun939961241"); - roomInfo.setCreaterWechat("pengjun939961241"); roomInfo.setShareImg(mediaUpload.getMediaId()); + roomInfo.setFeedsImg(mediaUpload.getMediaId()); roomInfo.setType(1); roomInfo.setScreenType(1); roomInfo.setCloseLike(0); @@ -95,7 +96,7 @@ public void getPushUrl() throws Exception { @Test public void getSharedCode() throws Exception { - String result = this.wxService.getLiveService().getSharedCode(39, null); + WxMaLiveSharedCode result = this.wxService.getLiveService().getSharedCode(39, null); System.out.println(result); } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImplTest.java index b52476fb92..e520388c5c 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImplTest.java @@ -24,7 +24,7 @@ /** * @author Binary Wang - * @date 2020-07-05 + * created on 2020-07-05 */ @Test @Guice(modules = ApiTestModule.class) diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaOpenApiServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaOpenApiServiceImplTest.java new file mode 100644 index 0000000000..409e63e717 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaOpenApiServiceImplTest.java @@ -0,0 +1,48 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.openapi.WxMiniGetApiQuotaResult; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.gson.Gson; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertTrue; + +/** + * openApi管理测试 + * + * @author shuiyihan12 + * @since 2023/7/7 17:08 + */ +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaOpenApiServiceImplTest { + + @Inject + private WxMaService wxMaService; + + + @Test + public void clearQuota() throws WxErrorException { + final boolean result = wxMaService.getWxMaOpenApiService().clearQuota(); + assertTrue(result); + } + + @Test + public void getApiQuota() throws WxErrorException { + String cgiPath = "/cgi-bin/openapi/quota/get"; + final WxMiniGetApiQuotaResult apiQuota = wxMaService.getWxMaOpenApiService().getApiQuota(cgiPath); + assertNotNull(apiQuota); + System.out.println(new Gson().toJson(apiQuota)); + } + @Test + public void clearQuotaByAppSecret() throws WxErrorException { + final boolean result = wxMaService.getWxMaOpenApiService().clearQuotaByAppSecret(); + assertTrue(result); + } + +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java index e6c5969441..d45651ba2a 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java @@ -1,13 +1,13 @@ package cn.binarywang.wx.miniapp.api.impl; -import java.io.File; - -import org.testng.annotations.*; - import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.io.File; import static org.assertj.core.api.Assertions.assertThat; @@ -46,13 +46,13 @@ public void testCreateQrcodeBytes() throws WxErrorException { @Test public void testCreateWxaCodeBytes() throws WxErrorException { - final byte[] wxCode = this.wxService.getQrcodeService().createWxaCodeBytes("111", 122, true, null, false); + final byte[] wxCode = this.wxService.getQrcodeService().createWxaCodeBytes("111", null, 122, true, null, false); assertThat(wxCode).isNotNull(); } @Test public void testCreateWxaCodeUnlimitBytes() throws WxErrorException { - final byte[] wxCode = this.wxService.getQrcodeService().createWxaCodeUnlimitBytes("111", null, 122, true, null, false); + final byte[] wxCode = this.wxService.getQrcodeService().createWxaCodeUnlimitBytes("111", "pages/unknown", false, "trial", 122, true, null, false); assertThat(wxCode).isNotNull(); } @@ -70,7 +70,7 @@ public void testCreateWxaCodeByFile() throws WxErrorException { @Test public void testCreateQrcodeUnlimitByFile() throws WxErrorException { - final File wxCode = this.wxService.getQrcodeService().createWxaCodeUnlimit("111",null,"/opt/logs"); + final File wxCode = this.wxService.getQrcodeService().createWxaCodeUnlimit("111", null, "/opt/logs"); assertThat(wxCode).isNotNull(); } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSafetyRiskControlServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSafetyRiskControlServiceImplTest.java new file mode 100644 index 0000000000..9a2491fee7 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSafetyRiskControlServiceImplTest.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.api.impl; + + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest; +import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import static org.testng.AssertJUnit.assertNotNull; + +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaSafetyRiskControlServiceImplTest { + + @Inject + protected WxMaService wxService; + + @Test + public void testGetUserRiskRank() throws WxErrorException { + WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest = WxMaUserSafetyRiskRankRequest.builder() + .appid("") + .openid("") + .scene(1) + .isTest(true) + .build(); + WxMaUserSafetyRiskRankResponse wxMaUserSafetyRiskRankResponse = this.wxService.getSafetyRiskControlService().getUserRiskRank(wxMaUserSafetyRiskRankRequest); + assertNotNull(wxMaUserSafetyRiskRankResponse); + } + +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImplTest.java index e24997bc01..07c0c83956 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSchemeServiceImplTest.java @@ -1,6 +1,7 @@ package cn.binarywang.wx.miniapp.api.impl; import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateNfcSchemeRequest; import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; @@ -13,7 +14,7 @@ /** * @author : cofedream - * @date : 2021-01-28 + * created on : 2021-01-28 */ @Test @Guice(modules = ApiTestModule.class) @@ -37,4 +38,21 @@ public void testGenerate() throws WxErrorException { System.out.println("generate:"); System.out.println(generate); } + + @Test + public void testGenerateNfc() throws WxErrorException { + final Date date = DateUtils.addMinutes(new Date(), 20); // 20分钟后失效 + final long expireTime = date.getTime() / 1000; + final String generate = this.wxService.getWxMaSchemeService().generateNFC(WxMaGenerateNfcSchemeRequest.newBuilder() + .jumpWxa(WxMaGenerateNfcSchemeRequest.JumpWxa.newBuilder() +// .path("/pages/productView/editPhone/editPhone") // 都可以 + .path("pages/productView/editPhone/editPhone") // + .query("") + .build()) + .modelId("") // 到期失效 + .sn("") // 失效时间 + .build()); + System.out.println("generate:"); + System.out.println(generate); + } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImplTest.java index 73343d8e4e..b31dea2dd3 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImplTest.java @@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; +import me.chanjar.weixin.common.bean.WxAccessTokenEntity; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxMpErrorMsgEnum; @@ -33,6 +34,8 @@ public class WxMaServiceImplTest { @Inject private WxMaService wxService; + @Inject + private WxMaServiceOkHttpImpl wxMaServiceOkHttp; public void testRefreshAccessToken() throws WxErrorException { WxMaConfig configStorage = this.wxService.getWxMaConfig(); @@ -44,6 +47,46 @@ public void testRefreshAccessToken() throws WxErrorException { assertTrue(StringUtils.isNotBlank(after)); } + + private void updateAccessTokenBefore(WxAccessTokenEntity wxAccessTokenEntity) { + System.out.println("token:" + wxAccessTokenEntity.toString()); + } + + public void testTokenCallBack() throws WxErrorException { + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + WxMaConfig configStorage = this.wxService.getWxMaConfig(); + config.setAppid(configStorage.getAppid()); + config.setSecret(configStorage.getSecret()); +// //第一种方式 +// config.setUpdateAccessTokenBefore(e -> { +// System.out.println("token:" + e.toString()); +// }); + //第二种方式 + config.setUpdateAccessTokenBefore(this::updateAccessTokenBefore); + this.wxService.setWxMaConfig(config); + + String before = config.getAccessToken(); + this.wxService.getAccessToken(true); + String after = config.getAccessToken(); + assertNotEquals(before, after); + assertTrue(StringUtils.isNotBlank(after)); + config.enableUpdateAccessTokenBefore(false); + this.wxService.getAccessToken(true); + after = config.getAccessToken(); + System.out.println(after); + } + + public void testStableRefreshAccessToken() throws WxErrorException { + WxMaConfig configStorage = this.wxMaServiceOkHttp.getWxMaConfig(); + configStorage.useStableAccessToken(true); + String before = configStorage.getAccessToken(); + this.wxMaServiceOkHttp.getAccessToken(false); + String after = configStorage.getAccessToken(); + assertNotEquals(before, after); + assertTrue(StringUtils.isNotBlank(after)); + } + + @Test(expectedExceptions = {WxErrorException.class}) public void testGetPaidUnionId() throws WxErrorException { final String unionId = this.wxService.getPaidUnionId("1", null, "3", "4"); @@ -127,14 +170,14 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { RequestExecutor re = mock(RequestExecutor.class); AtomicInteger counter = new AtomicInteger(); - Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer(invocation -> { + Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer((invocation) -> { counter.incrementAndGet(); WxError error = WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build(); throw new WxErrorException(error); }); try { Object execute = service.execute(re, "http://baidu.com", new HashMap<>()); - Assert.assertTrue(false, "代码应该不会执行到这里"); + Assert.fail("代码应该不会执行到这里"); } catch (WxErrorException e) { Assert.assertEquals(WxMpErrorMsgEnum.CODE_40001.getCode(), e.getError().getErrorCode()); Assert.assertEquals(2, counter.get()); diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java index 75538a1510..2446b2e3ef 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java @@ -4,8 +4,10 @@ import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest; import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest; import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopEcAfterSaleGetRequest; import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopEcAfterSaleGetResponse; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; import me.chanjar.weixin.common.error.WxErrorException; @@ -38,12 +40,11 @@ public void testAdd() throws WxErrorException { .outAftersaleId("318092069606883328X") .openid("odIi15CuQ0IQviqsnUMy6CKNetrMX") .type(1) - .createTime("2021-08-20 00:00:00") .status(1) .finishAllAftersale(0) .path("/pages/aftersale.html?out_aftersale_id=318092069606883328X") .refund(100L) - .productInfos(new ArrayList<>(Arrays.asList(productInfosBean))) + .productInfo(productInfosBean) .build(); WxMaShopBaseResponse response = wxService.getShopAfterSaleService().add(request); assertThat(response).isNotNull(); @@ -72,4 +73,15 @@ public void testUpdate() throws WxErrorException { WxMaShopBaseResponse response = wxService.getShopAfterSaleService().update(request); assertThat(response).isNotNull(); } + + @Test + public void testEcGet() throws WxErrorException { + WxMaShopEcAfterSaleGetRequest request = WxMaShopEcAfterSaleGetRequest.builder() + .aftersaleId(123L) + .outAftersaleId("aso_123124341") + .build(); + WxMaShopEcAfterSaleGetResponse response = wxService.getShopAfterSaleService().get(request); + assertThat(response).isNotNull(); + } + } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImplTest.java index c8ec9f081c..117f052ac3 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImplTest.java @@ -33,23 +33,23 @@ public void testAuditBrand() throws WxErrorException { WxMaShopAuditBrandRequest request = WxMaShopAuditBrandRequest.builder().build(); WxMaShopAuditBrandRequest.AuditReqBean auditReqBean = WxMaShopAuditBrandRequest.AuditReqBean.builder().build(); - auditReqBean.setLicense(new ArrayList(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))); + auditReqBean.setLicense(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))); auditReqBean.setBrandInfo(WxMaShopAuditBrandRequest.AuditReqBean.BrandInfoBean.builder() .brandAuditType(1) .trademarkType("29") .brandManagementType(2) .commodityOriginType(2) .brandWording("346225226351203275") - .saleAuthorization(new ArrayList(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) - .trademarkRegistrationCertificate(new ArrayList(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) - .trademarkChangeCertificate(new ArrayList(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) + .saleAuthorization(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) + .trademarkRegistrationCertificate(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) + .trademarkChangeCertificate(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) .trademarkRegistrant("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg") .trademarkRegistrantNu("1249305") .trademarkAuthorizationPeriod("2020-03-25 12:05:25") - .trademarkRegistrationApplication(new ArrayList(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) + .trademarkRegistrationApplication(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) .trademarkApplicant("张三") .trademarkApplicationTime("2020-03-25 12:05:25") - .importedGoodsForm(new ArrayList(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) + .importedGoodsForm(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"))) .build()); request.setAuditReq(auditReqBean); @@ -61,12 +61,12 @@ public void testAuditBrand() throws WxErrorException { public void testAuditCategory() throws WxErrorException { WxMaShopAuditCategoryRequest request = WxMaShopAuditCategoryRequest.builder().build(); WxMaShopAuditCategoryRequest.AuditReqBean auditReqBean = WxMaShopAuditCategoryRequest.AuditReqBean.builder().build(); - auditReqBean.setLicense(new ArrayList(Arrays.asList("www.xxxxx.com"))); + auditReqBean.setLicense(new ArrayList<>(Arrays.asList("www.xxxxx.com"))); auditReqBean.setCategoryInfo(WxMaShopAuditCategoryRequest.AuditReqBean.CategoryInfoBean.builder() .level1(7419) .level2(7439) .level3(7448) - .certificate(new ArrayList(Arrays.asList("www.xxxxx.com"))) + .certificate(new ArrayList<>(Arrays.asList("www.xxxxx.com"))) .build()); request.setAuditReq(auditReqBean); WxMaShopAuditCategoryResponse response = wxService.getShopAuditService().auditCategory(request); diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImplTest.java index 060896ab09..9999c14ab6 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopImgServiceImplTest.java @@ -35,4 +35,11 @@ public void testUploadImg2() throws WxErrorException { WxMinishopImageUploadCustomizeResult result = wxService.getShopImgService().uploadImg(file, "1"); assertThat(result).isNotNull(); } + + @Test + public void testUploadImg3() throws WxErrorException { + String imgUrl = "https://www.example.com/demo.jpg"; + WxMinishopImageUploadCustomizeResult result = wxService.getShopImgService().uploadImg(imgUrl, "1"); + assertThat(result).isNotNull(); + } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopPayServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopPayServiceImplTest.java new file mode 100644 index 0000000000..2b51c0c6b5 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopPayServiceImplTest.java @@ -0,0 +1,47 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.inject.Inject; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaShopPayServiceImplTest { + + @Inject + private WxMaService wxService; + + @Test + public void testCreateOrder() throws Exception { + WxMaShopPayCreateOrderRequest request = + WxMaShopPayCreateOrderRequest.builder() + .openid("") + .combineTradeNo("") + .expireTime(1234L) + .subOrders(Arrays.asList(WxMaShopPayCreateOrderRequest.SubOrdersDTO.builder() + .mchid("") + .amount(0) + .tradeNo("") + .description("") + .build() + )) + .build(); + WxMaShopPayCreateOrderResponse response = wxService.getWxMaShopPayService().createOrder(request); + assertThat(response).isNotNull(); + } + + @Test + public void testGetOrder() throws Exception { + WxMaShopPayGetOrderResponse response = wxService.getWxMaShopPayService().getOrder("457243057210572800"); + assertThat(response).isNotNull(); + } +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java index 7013b2f888..10993e5651 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java @@ -21,7 +21,7 @@ * 测试类. * * @author Binary Wang - * @date 2019-12-15 + * created on 2019-12-15 */ @Test @Guice(modules = ApiTestModule.class) diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplTest.java index fe3fa1675c..5b04d05f81 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplTest.java @@ -71,4 +71,14 @@ public void testSetUserStorage() throws WxErrorException { this.wxService.getUserService().setUserStorage(ImmutableMap.of("1","2"), "r7BXXKkLb8qrSNn05n0qiA",((TestConfig)this.wxService.getWxMaConfig()).getOpenid()); } + + @Test + public void testGetNewPhoneNoInfo() throws Exception{ + assertNotNull(wxService.getUserService().getNewPhoneNoInfo("test")); + } + + @Test + public void testGetAccessToken() throws Exception{ + assertNotNull(wxService.getAccessToken(true)); + } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImplTest.java new file mode 100644 index 0000000000..037ebe0889 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImplTest.java @@ -0,0 +1,129 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.vod.*; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.inject.Inject; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.testng.Assert.assertNotNull; + +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaVodServiceImplTest { + @Inject + private WxMaService wxService; + + @Test + public void testListMedia() throws Exception { + WxMaVodListMediaRequest request = WxMaVodListMediaRequest.builder() + .dramaId(100000) + .offset(0) + .limit(100) + .build(); + List response = this.wxService.getWxMaVodService().listMedia(request); + assertNotNull(response); + } + + @Test + public void testListDrama() throws Exception { + WxMaVodListDramaRequest request = WxMaVodListDramaRequest.builder() + .offset(0) + .limit(100) + .build(); + List response = this.wxService.getWxMaVodService().listDrama(request); + assertNotNull(response); + + } + + @Test + public void testGetMediaLink() throws Exception { + WxMaVodGetMediaLinkRequest request = WxMaVodGetMediaLinkRequest.builder() + .mediaId(10000) + .build(); + WxMaVodMediaPlaybackInfo response = this.wxService.getWxMaVodService().getMediaLink(request); + assertNotNull(response); + } + + @Test + public void testGetMedia() throws Exception { + WxMaVodGetMediaRequest request = WxMaVodGetMediaRequest.builder() + .mediaId(0) + .build(); + WxMaVodMediaInfo response = this.wxService.getWxMaVodService().getMedia(request); + assertNotNull(response); + } + + @Test + public void testDeleteMedia() throws Exception { + WxMaVodDeleteMediaRequest request = WxMaVodDeleteMediaRequest.builder() + .mediaId(0) + .build(); + boolean response = this.wxService.getWxMaVodService().deleteMedia(request); + assertNotNull(response); + } + + @Test + public void testGetDrama() throws Exception { + WxMaVodGetDramaRequest request = WxMaVodGetDramaRequest.builder() + .dramaId(0) + .build(); + WxMaVodDramaInfo response = this.wxService.getWxMaVodService().getDrama(request); + assertNotNull(response); + } + + @Test + public void testAuditDrama() throws Exception { + WxMaVodAuditDramaRequest request = WxMaVodAuditDramaRequest.builder() + .dramaId(0) + .name("name") + .build(); + Integer response = this.wxService.getWxMaVodService().auditDrama(request); + assertNotNull(response); + } + + @Test + public void testGetTask() throws Exception { + WxMaVodGetTaskRequest request = WxMaVodGetTaskRequest.builder() + .taskId(0) + .build(); + WxMaVodGetTaskResponse response = this.wxService.getWxMaVodService().getTask(request); + assertNotNull(response); + } + + @Test + public void testPullUpload() throws Exception { + WxMaVodPullUploadRequest request = WxMaVodPullUploadRequest.builder() + .coverUrl("") + .mediaUrl("") + .mediaName("我的中国梦 - 第1集") + .sourceContext("") + .build(); + WxMaVodPullUploadResponse response = this.wxService.getWxMaVodService().pullUpload(request); + assertNotNull(response); + } + @Test + public void testGetCdnUsageData() throws Exception { + WxMaVodGetCdnUsageRequest request = WxMaVodGetCdnUsageRequest.builder() + .startTime(0L) + .endTime(0L) + .dataInterval(1440) + .build(); + WxMaVodGetCdnUsageResponse response = this.wxService.getWxMaVodService().getCdnUsageData(request); + assertNotNull(response); + } + + @Test + public void testGetCdnLogs() throws Exception { + WxMaVodGetCdnLogRequest request = WxMaVodGetCdnLogRequest.builder() + .startTime(0L).endTime(0L) + .offset(0).limit(100) + .build(); + WxMaVodGetCdnLogResponse response = this.wxService.getWxMaVodService().getCdnLogs(request); + assertNotNull(response); + } + +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaXPayServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaXPayServiceImplTest.java new file mode 100644 index 0000000000..0c980fda55 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaXPayServiceImplTest.java @@ -0,0 +1,220 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.xpay.*; +import cn.binarywang.wx.miniapp.constant.WxMaConstants; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.inject.Inject; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.ArrayList; + +import static org.testng.Assert.assertNotNull; + +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaXPayServiceImplTest { + @Inject + private WxMaService wxService; + + @Test + public void testQueryUserBalance() throws Exception { + WxMaXPayQueryUserBalanceRequest request = WxMaXPayQueryUserBalanceRequest.builder() + .openid("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .userIp("127.0.0.1") + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayQueryUserBalanceResponse response = this.wxService.getWxMaXPayService().queryUserBalance(request, sigParams); + assertNotNull(response); + } + + @Test + public void testCurrencyPay() throws Exception { + WxMaXPayCurrencyPayRequest request = WxMaXPayCurrencyPayRequest.builder() + .openid("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .userIp("127.0.0.1") + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayCurrencyPayResponse response = this.wxService.getWxMaXPayService().currencyPay(request, sigParams); + assertNotNull(response); + } + + @Test + public void testQueryOrder() throws Exception { + WxMaXPayQueryOrderRequest request = WxMaXPayQueryOrderRequest.builder() + .openid("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .orderId("") + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayQueryOrderResponse response = this.wxService.getWxMaXPayService().queryOrder(request, sigParams); + assertNotNull(response); + } + + @Test + public void testCancelCurrencyPay() throws Exception { + WxMaXPayCancelCurrencyPayRequest request = WxMaXPayCancelCurrencyPayRequest.builder() + .openid("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .userIp("127.0.0.1") + .orderId("") + .payOrderId("") + .amount(1000L) + .deviceType(WxMaConstants.XPayDeviceType.ANDROID) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayCancelCurrencyPayResponse response = this.wxService.getWxMaXPayService().cancelCurrencyPay(request, sigParams); + assertNotNull(response); + } + + @Test + public void testNotifyProvideGoods() throws Exception { + WxMaXPayNotifyProvideGoodsRequest request = WxMaXPayNotifyProvideGoodsRequest.builder() + .env(WxMaConstants.XPayEnv.PRODUCT) + .orderId("") + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + boolean response = this.wxService.getWxMaXPayService().notifyProvideGoods(request, sigParams); + assertNotNull(response); + } + + @Test + public void testPresentCurrency() throws Exception { + WxMaXPayPresentCurrencyRequest request = WxMaXPayPresentCurrencyRequest.builder() + .openid("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .orderId("").deviceType(WxMaConstants.XPayDeviceType.ANDROID) + .amount(100L) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayPresentCurrencyResponse response = this.wxService.getWxMaXPayService().presentCurrency(request, sigParams); + assertNotNull(response); + } + + + @Test + public void testDownloadBill() throws Exception { + WxMaXPayDownloadBillRequest request = WxMaXPayDownloadBillRequest.builder() + .beginDs(20230801) + .endDs(20230810) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayDownloadBillResponse response = this.wxService.getWxMaXPayService().downloadBill(request, sigParams); + assertNotNull(response); + } + @Test + public void testRefundOrder() throws Exception { + WxMaXPayRefundOrderRequest request = WxMaXPayRefundOrderRequest.builder() + .openid("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .orderId("") + .refundOrderId("") + .leftFee(100L) + .refundFee(10L) + .bizMeta("").refundReason("").reqFrom("") + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayRefundOrderResponse response = this.wxService.getWxMaXPayService().refundOrder(request, sigParams); + assertNotNull(response); + } + + @Test + public void testCreateWithdrawOrder() throws Exception { + WxMaXPayCreateWithdrawOrderRequest request = WxMaXPayCreateWithdrawOrderRequest.builder() + .withdrawNo("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .withdrawAmount("0.01") + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayCreateWithdrawOrderResponse response = this.wxService.getWxMaXPayService().createWithdrawOrder(request, sigParams); + assertNotNull(response); + } + + + @Test + public void testQueryWithdrawOrder() throws Exception { + WxMaXPayQueryWithdrawOrderRequest request = WxMaXPayQueryWithdrawOrderRequest.builder() + .withdrawNo("") + .env(WxMaConstants.XPayEnv.PRODUCT) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayQueryWithdrawOrderResponse response = this.wxService.getWxMaXPayService().queryWithdrawOrder(request, sigParams); + assertNotNull(response); + } + + + @Test + public void testStartUploadGoods() throws Exception { + WxMaXPayStartUploadGoodsRequest request = WxMaXPayStartUploadGoodsRequest.builder() + .env(WxMaConstants.XPayEnv.PRODUCT) + .uploadItem(new ArrayList<>()) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + boolean response = this.wxService.getWxMaXPayService().startUploadGoods(request, sigParams); + assertNotNull(response); + } + + @Test + public void testQueryUploadGoods() throws Exception { + WxMaXPayQueryUploadGoodsRequest request = WxMaXPayQueryUploadGoodsRequest.builder() + .env(WxMaConstants.XPayEnv.PRODUCT) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayQueryUploadGoodsResponse response = this.wxService.getWxMaXPayService().queryUploadGoods(request, sigParams); + assertNotNull(response); + } + + + @Test + public void testStartPublishGoods() throws Exception { + WxMaXPayStartPublishGoodsRequest request = WxMaXPayStartPublishGoodsRequest.builder() + .env(WxMaConstants.XPayEnv.PRODUCT) + .publishItem(new ArrayList<>()) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + boolean response = this.wxService.getWxMaXPayService().startPublishGoods(request, sigParams); + assertNotNull(response); + } + + @Test + public void testQueryPublishGoods() throws Exception { + WxMaXPayQueryPublishGoodsRequest request = WxMaXPayQueryPublishGoodsRequest.builder() + .env(WxMaConstants.XPayEnv.PRODUCT) + .build(); + WxMaXPaySigParams sigParams = new WxMaXPaySigParams(); + sigParams.setSessionKey(""); + sigParams.setAppKey(""); + WxMaXPayQueryPublishGoodsResponse response = this.wxService.getWxMaXPayService().queryPublishGoods(request, sigParams); + assertNotNull(response); + } + +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java index 26855b36ef..bfdb912f6d 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java @@ -3,7 +3,13 @@ import me.chanjar.weixin.common.api.WxConsts; import org.testng.annotations.Test; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.as; +import static org.assertj.core.api.Assertions.assertThat; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; /** * @author Binary Wang @@ -32,7 +38,7 @@ public void testFromXml() { WxMaMessage wxMessage = WxMaMessage.fromXml(xml); assertEquals(wxMessage.getToUser(), "toUser"); assertEquals(wxMessage.getFromUser(), "fromUser"); - assertEquals(wxMessage.getCreateTime(),new Integer(1482048670)); + assertEquals(wxMessage.getCreateTime(), new Integer(1482048670)); assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); assertEquals(wxMessage.getContent(), "this is a test"); assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); @@ -47,4 +53,279 @@ public void testFromXml() { assertEquals(wxMessage.getSessionFrom(), "sessionFrom"); } + public void testSubscribeMsgPopupEvent() { + // xml 格式 + String xml = "" + + "\n" + + "\n" + + "1610969440\n" + + "\n" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " 0\n" + + " \n" + + "" + + ""; + + WxMaMessage wxMessage = WxMaMessage.fromXml(xml); + checkSubscribeMsgPopupEvent(wxMessage); + + // 订阅单个模板 json格式 (对象) + String json = "{\n" + + " \"ToUserName\": \"gh_123456789abc\",\n" + + " \"FromUserName\": \"otFpruAK8D-E6EfStSYonYSBZ8_4\",\n" + + " \"CreateTime\": \"1610969440\",\n" + + " \"MsgType\": \"event\",\n" + + " \"Event\": \"subscribe_msg_popup_event\",\n" + + " \"List\": {\n" + + " \"TemplateId\": \"VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc\",\n" + + " \"SubscribeStatusString\": \"accept\",\n" + + " \"PopupScene\": \"0\"\n" + + " }\n" + + " }"; + wxMessage = WxMaMessage.fromJson(json); + checkSubscribeMsgPopupEvent(wxMessage); + // 订阅多条模板的 json格式(数组) + json = "{\n" + + " \"ToUserName\": \"gh_123456789abc\",\n" + + " \"FromUserName\": \"otFpruAK8D-E6EfStSYonYSBZ8_4\",\n" + + " \"CreateTime\": \"1610969440\",\n" + + " \"MsgType\": \"event\",\n" + + " \"Event\": \"subscribe_msg_popup_event\",\n" + + " \"List\": [{\n" + + " \"TemplateId\": \"VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc\",\n" + + " \"SubscribeStatusString\": \"accept\",\n" + + " \"PopupScene\": \"0\"\n" + + " }]\n" + + " }"; + wxMessage = WxMaMessage.fromJson(json); + checkSubscribeMsgPopupEvent(wxMessage); + } + + private void checkSubscribeMsgPopupEvent(WxMaMessage wxMessage) { + assertEquals(wxMessage.getToUser(), "gh_123456789abc"); + assertEquals(wxMessage.getFromUser(), "otFpruAK8D-E6EfStSYonYSBZ8_4"); + assertEquals(wxMessage.getCreateTime(), new Integer(1610969440)); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); + assertEquals(wxMessage.getEvent(), "subscribe_msg_popup_event"); + assertEquals(wxMessage.getSubscribeMsgPopupEvent().getList().size(), 1); + WxMaSubscribeMsgEvent.PopupEvent event = wxMessage.getSubscribeMsgPopupEvent().getList().get(0); + assertEquals(event.getTemplateId(), "VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc"); + assertEquals(event.getSubscribeStatusString(), "accept"); + assertEquals(event.getPopupScene(), "0"); + } + + public void testSubscribeMsgChangeEvent() { + // xml 格式 + String xml = "\n" + + " \n" + + " \n" + + " 1610968440\n" + + " \n" + + " \n" + + " \n" + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + WxMaMessage wxMessage = WxMaMessage.fromXml(xml); + checkSubscribeMsgChangeEvent(wxMessage); + + // json格式 (对象) + String json = "{\n" + + " \"ToUserName\": \"gh_123456789abc\",\n" + + " \"FromUserName\": \"o7esq5OI1Uej6Xixw1lA2H7XDVbc\",\n" + + " \"CreateTime\": \"1610968440\",\n" + + " \"MsgType\": \"event\",\n" + + " \"Event\": \"subscribe_msg_change_event\",\n" + + " \"List\": {\n" + + " \"TemplateId\":\"BEwX0BOT3MqK3Uc5oTU3CGBqzjpndk2jzUf7VfExd8\",\n" + + " \"SubscribeStatusString\": \"reject\"\n" + + " }\n" + + "}\n"; + wxMessage = WxMaMessage.fromJson(json); + checkSubscribeMsgChangeEvent(wxMessage); + // json格式(数组) + json = "{\n" + + " \"ToUserName\": \"gh_123456789abc\",\n" + + " \"FromUserName\": \"o7esq5OI1Uej6Xixw1lA2H7XDVbc\",\n" + + " \"CreateTime\": \"1610968440\",\n" + + " \"MsgType\": \"event\",\n" + + " \"Event\": \"subscribe_msg_change_event\",\n" + + " \"List\": [ {\n" + + " \"TemplateId\":\"BEwX0BOT3MqK3Uc5oTU3CGBqzjpndk2jzUf7VfExd8\",\n" + + " \"SubscribeStatusString\": \"reject\"\n" + + " }]" + + "}"; + wxMessage = WxMaMessage.fromJson(json); + checkSubscribeMsgChangeEvent(wxMessage); + } + + private void checkSubscribeMsgChangeEvent(WxMaMessage wxMessage) { + assertEquals(wxMessage.getToUser(), "gh_123456789abc"); + assertEquals(wxMessage.getFromUser(), "o7esq5OI1Uej6Xixw1lA2H7XDVbc"); + assertEquals(wxMessage.getCreateTime(), new Integer(1610968440)); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); + assertEquals(wxMessage.getEvent(), "subscribe_msg_change_event"); + assertEquals(wxMessage.getSubscribeMsgChangeEvent().getList().size(), 1); + WxMaSubscribeMsgEvent.ChangeEvent event = wxMessage.getSubscribeMsgChangeEvent().getList().get(0); + assertEquals(event.getTemplateId(), "BEwX0BOT3MqK3Uc5oTU3CGBqzjpndk2jzUf7VfExd8"); + assertEquals(event.getSubscribeStatusString(), "reject"); + } + + public void testSubscribeMsgSentEvent() { + // xml 格式 + String xml = "\n" + + " \n" + + " \n" + + " 1620963428\n" + + " \n" + + " \n" + + " \n" + + " " + + " \n" + + " 1864323726461255680\n" + + " 0\n" + + " \n" + + " \n" + + " \n" + + ""; + + WxMaMessage wxMessage = WxMaMessage.fromXml(xml); + checkSubscribeMsgSentEvent(wxMessage); + + // json格式 (对象) + String json = "{\n" + + " \"ToUserName\": \"gh_123456789abc\",\n" + + " \"FromUserName\": \"o7esq5PHRGBQYmeNyfG064wEFVpQ\",\n" + + " \"CreateTime\": \"1620963428\",\n" + + " \"MsgType\": \"event\",\n" + + " \"Event\": \"subscribe_msg_sent_event\",\n" + + " \"List\": {\n" + + " \"TemplateId\": \"BEwX0BO-T3MqK3Uc5oTU3CGBqzjpndk2jzUf7VfExd8\",\n" + + " \"MsgID\": \"1864323726461255680\",\n" + + " \"ErrorCode\": \"0\",\n" + + " \"ErrorStatus\": \"success\"\n" + + " }\n" + + "}"; + wxMessage = WxMaMessage.fromJson(json); + checkSubscribeMsgSentEvent(wxMessage); + } + + private void checkSubscribeMsgSentEvent(WxMaMessage wxMessage) { + assertEquals(wxMessage.getToUser(), "gh_123456789abc"); + assertEquals(wxMessage.getFromUser(), "o7esq5PHRGBQYmeNyfG064wEFVpQ"); + assertEquals(wxMessage.getCreateTime(), new Integer(1620963428)); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); + assertEquals(wxMessage.getEvent(), "subscribe_msg_sent_event"); + assertNotNull(wxMessage.getSubscribeMsgSentEvent()); + WxMaSubscribeMsgEvent.SentEvent event = wxMessage.getSubscribeMsgSentEvent().getList(); + assertEquals(event.getTemplateId(), "BEwX0BO-T3MqK3Uc5oTU3CGBqzjpndk2jzUf7VfExd8"); + assertEquals(event.getMsgId(), "1864323726461255680"); + assertEquals(event.getErrorCode(), "0"); + assertEquals(event.getErrorStatus(), "success"); + } + + @Test + public void testFromXmlForAllFieldsMap() { + String xml = "\n" + + " \n" + + " \n" + + " 1642658087\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 16\n" + + " 2\n" + + " \n" + + " 1642605533\n" + + " 300001\n" + + " \n" + + " 0\n" + + " 0\n" + + " \n" + + " \n" + + " 1642605533\n" + + " 100001\n" + + " \n" + + " 0\n" + + " 0\n" + + " \n" + + " \n" + + ""; + + WxMaMessage wxMessage = WxMaMessage.fromXml(xml); + Map allFieldsMap = wxMessage.getAllFieldsMap(); + assertThat(allFieldsMap).isNotEmpty() + .containsEntry("ToUserName", "gh_3953b390c11d") + .containsEntry("FromUserName", "ofYMP5JFT4SD7EX1LQv3IWrciBSo") + .containsEntry("CreateTime", "1642658087") + .containsEntry("MsgType", "event") + .containsEntry("Event", "add_express_path") + .containsEntry("DeliveryID", "TEST") + .containsEntry("WayBillId", "01234567894_waybill_id") + .containsEntry("Version", "16") + .containsEntry("Count", "2") + .containsEntry("OrderId", "01234567894"); + + List> actions = (List>) allFieldsMap.get("Actions"); + assertThat(actions).isNotEmpty().hasSize(2); + + assertThat(actions.get(0)) + .containsEntry("ActionTime", "1642605533") + .containsEntry("ActionType", "300001") + .containsEntry("ActionMsg", "揽件阶段-揽件成功") + .containsEntry("Lat", "0") + .containsEntry("Lng", "0"); + + assertThat(actions.get(1)) + .containsEntry("ActionTime", "1642605533") + .containsEntry("ActionType", "100001") + .containsEntry("ActionMsg", "揽件阶段-揽件成功") + .containsEntry("Lat", "0") + .containsEntry("Lng", "0"); + } + + /** + * 自定义交易组件付款通知事件测试用例 + * msgType等于event且event等于WxConsts.EventType.OPEN_PRODUCT_ORDER_PAY + */ + @Test + public void testFromXmlForOpenProductOrderPayEvent(){ + String xml = " \n" + + " gh_abcdefg \n" + + " oABCD \n" + + " 1642658087 \n" + + " event \n" + + " open_product_order_pay\n" + + " \n" + + " 123456\n" + + " 1234567\n" + + " 42000000123123\n" + + " 2021-12-30 22:31:00\n" + + " 10\n" + + " oNMZ-5C0SPGHUiKsTwnOXpSHzFvw\n" + + " \n" + + ""; + WxMaMessage wxMessage = WxMaMessage.fromXml(xml); + assertThat(wxMessage.getMsgType()).isEqualTo("event"); + assertThat(wxMessage.getEvent()).isEqualTo(WxConsts.EventType.OPEN_PRODUCT_ORDER_PAY); + Map allFieldsMap = wxMessage.getAllFieldsMap(); + Map orderInfo = (Map) allFieldsMap.get("order_info"); + assertThat(orderInfo).isNotEmpty(); + assertThat(orderInfo) + .containsEntry("out_order_id","123456") + .containsEntry("order_id","1234567") + .containsEntry("transaction_id","42000000123123") + .containsEntry("pay_time","2021-12-30 22:31:00") + .containsEntry("amount","10") + .containsEntry("sp_openid","oNMZ-5C0SPGHUiKsTwnOXpSHzFvw"); + } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeCommitRequestTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeCommitRequestTest.java index 36cf1c4840..f311193782 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeCommitRequestTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeCommitRequestTest.java @@ -1,5 +1,6 @@ package cn.binarywang.wx.miniapp.bean.code; +import com.google.gson.JsonParser; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; @@ -20,6 +21,28 @@ public void testToJson() { .extEnable(true) .build()) .build(); - assertEquals(commitRequest.toJson(), "{\"template_id\":1,\"user_version\":\"v0.1.0\",\"user_desc\":\"init\",\"ext_json\":\"{\\\"extEnable\\\":true,\\\"extAppid\\\":\\\"app123\\\"}\"}"); + assertEquals(commitRequest.toJson(), "{\"template_id\":1,\"user_version\":\"v0.1.0\",\"user_desc\":\"init\"," + + "\"ext_json\":\"{\\\"extEnable\\\":true,\\\"extAppid\\\":\\\"app123\\\"}\"}"); + } + + @Test + public void testToJsonWithRequiredPrivateInfos() { + WxMaCodeCommitRequest commitRequest = WxMaCodeCommitRequest.builder() + .templateId(95L) + .userVersion("V1.0") + .userDesc("test") + .extConfig(WxMaCodeExtConfig.builder() + .requiredPrivateInfos(new String[]{ + "onLocationChange", "startLocationUpdate" + }) + .build()) + .build(); + + assertEquals(commitRequest.toJson(), JsonParser.parseString("{\n" + + " \"template_id\": \"95\",\n" + + " \"ext_json\": \"{\\\"requiredPrivateInfos\\\":[\\\"onLocationChange\\\",\\\"startLocationUpdate\\\"]}\",\n" + + " \"user_version\": \"V1.0\",\n" + + " \"user_desc\": \"test\"\n" + + "}").toString()); } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequestTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequestTest.java index 1f962087dc..10732952c2 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequestTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/code/WxMaCodeSubmitAuditRequestTest.java @@ -1,9 +1,12 @@ package cn.binarywang.wx.miniapp.bean.code; +import me.chanjar.weixin.common.util.json.GsonParser; import org.testng.annotations.Test; import java.util.Arrays; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Charming * @since 2018-04-26 19:55 @@ -11,20 +14,84 @@ public class WxMaCodeSubmitAuditRequestTest { @Test public void testToJson() { - WxMaCodeSubmitAuditRequest request = WxMaCodeSubmitAuditRequest - .builder() + WxMaCodeSubmitAuditRequest request = WxMaCodeSubmitAuditRequest.builder() .itemList(Arrays.asList( - WxMaCategory - .builder() - .address("pages/logs/logs") - .tag("工具 效率") - .firstClass("工具") - .firstId(287L) - .secondClass("效率") - .secondId(616L) + WxMaCodeSubmitAuditItem.builder() + .address("index") + .tag("学习 生活") + .firstClass("文娱") + .firstId(1L) + .secondClass("资讯") + .secondId(2L) + .title("首页") + .build(), + WxMaCodeSubmitAuditItem.builder() + .address("page/logs/logs") + .tag("学习 工作") + .firstClass("教育") + .firstId(3L) + .secondClass("学历教育") + .secondId(4L) + .thirdClass("高等") + .thirdId(5L) .title("日志") .build() - )).build(); - System.out.println(request.toJson()); + )) + .feedbackInfo("blablabla") + .feedbackStuff("xx|yy|zz") + .previewInfo(new WxMaCodeSubmitAuditPreviewInfo().setVideoIdList(Arrays.asList("xxxx")) + .setPicIdList(Arrays.asList("xxxx", "yyyy", "zzzz"))) + .versionDesc("blablabla") + .ugcDeclare(new WxMaCodeSubmitAuditUgcDeclare() + .setAuditDesc("blablabla") + .setHasAuditTeam(1) + .setMethod(new Integer[]{1}) + .setScene(new Integer[]{1, 2}) + ).build(); + + String expectedJson = "{\n" + + "\t\"item_list\": [\n" + + "\t{\n" + + "\t\t\"address\":\"index\",\n" + + "\t\t\"tag\":\"学习 生活\",\n" + + "\t\t\"first_class\": \"文娱\",\n" + + "\t\t\"second_class\": \"资讯\",\n" + + "\t\t\"first_id\":1,\n" + + "\t\t\"second_id\":2,\n" + + "\t\t\"title\": \"首页\"\n" + + "\t},\n" + + "\t{\n" + + "\t\t\"address\":\"page/logs/logs\",\n" + + "\t\t\"tag\":\"学习 工作\",\n" + + "\t\t\"first_class\": \"教育\",\n" + + "\t\t\"second_class\": \"学历教育\",\n" + + "\t\t\"third_class\": \"高等\",\n" + + "\t\t\"first_id\":3,\n" + + "\t\t\"second_id\":4,\n" + + "\t\t\"third_id\":5,\n" + + "\t\t\"title\": \"日志\"\n" + + "\t}\n" + + "\t],\n" + + "\t\"feedback_info\": \"blablabla\",\n" + + " \"feedback_stuff\": \"xx|yy|zz\",\n" + + " \"preview_info\" : {\n" + + " \"video_id_list\": [\"xxxx\"],\n" + + " \"pic_id_list\": [\"xxxx\", \"yyyy\", \"zzzz\" ]\n" + + " },\n" + + " \"version_desc\":\"blablabla\",\n" + + " \"ugc_declare\": {\n" + + " \"scene\": [\n" + + " 1,\n" + + " 2\n" + + " ],\n" + + " \"method\": [\n" + + " 1\n" + + " ],\n" + + " \"has_audit_team\": 1,\n" + + " \"audit_desc\": \"blablabla\"\n" + + " }\n" + + "}\n" + + ""; + assertThat(request.toJson().replace("\n", "")).isEqualTo(GsonParser.parse(expectedJson).toString()); } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImplTest.java index 6fdcee10f4..75e0fb4aad 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImplTest.java @@ -11,7 +11,7 @@ /** * @author yqx - * @date 2020/5/3 + * created on 2020/5/3 */ public class WxMaRedissonConfigImplTest { diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/AddOrderJsonTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/AddOrderJsonTest.java new file mode 100644 index 0000000000..b072eff189 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/AddOrderJsonTest.java @@ -0,0 +1,20 @@ +package cn.binarywang.wx.miniapp.test; + +import cn.binarywang.wx.miniapp.bean.delivery.AddOrderRequest; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import org.testng.annotations.Test; + +public class AddOrderJsonTest { + + /** + * 验证转化Json时是否有deliverySign + */ + @Test + public void test(){ + AddOrderRequest request = new AddOrderRequest(); + request.setShopId("1"); + request.setAppSecret("2"); + request.getDeliverySign(); + System.out.printf(WxGsonBuilder.create().toJson(request)); + } +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java index a9f5def789..26eec1fa66 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java @@ -1,17 +1,17 @@ package cn.binarywang.wx.miniapp.test; -import java.io.IOException; -import java.io.InputStream; -import java.util.concurrent.locks.ReentrantLock; - -import me.chanjar.weixin.common.error.WxRuntimeException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.impl.WxMaServiceOkHttpImpl; import cn.binarywang.wx.miniapp.config.WxMaConfig; import com.google.inject.Binder; import com.google.inject.Module; +import me.chanjar.weixin.common.error.WxRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.locks.ReentrantLock; /** * @author Binary Wang @@ -34,6 +34,11 @@ public void configure(Binder binder) { binder.bind(WxMaService.class).toInstance(wxService); binder.bind(WxMaConfig.class).toInstance(config); + + WxMaServiceOkHttpImpl wxMaServiceOkHttp = new WxMaServiceOkHttpImpl(); + wxMaServiceOkHttp.setWxMaConfig(config); + binder.bind(WxMaServiceOkHttpImpl.class).toInstance(wxMaServiceOkHttp); + } catch (IOException e) { this.log.error(e.getMessage(), e); } diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 62ebb65b13..7efadd173d 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B weixin-java-mp @@ -84,6 +84,11 @@ org.redisson redisson + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + true + diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpAiOpenService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpAiOpenService.java index 230910e888..07bc1e52e1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpAiOpenService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpAiOpenService.java @@ -23,9 +23,10 @@ public interface WxMpAiOpenService { * http://api.weixin.qq.com/cgi-bin/media/voice/addvoicetorecofortext?access_token=ACCESS_TOKEN&format=&voice_id=xxxxxx&lang=zh_CN *
* + * @param voiceId 语音唯一标识 * @param lang 语言,zh_CN 或 en_US,默认中文 * @param voiceFile 语音文件 - * @param voiceId 语音唯一标识 + * @throws WxErrorException the wx error exception */ void uploadVoice(String voiceId, AiLangType lang, File voiceFile) throws WxErrorException; @@ -39,8 +40,10 @@ public interface WxMpAiOpenService { * *
* - * @param lang 语言,zh_CN 或 en_US,默认中文 * @param voiceId 语音唯一标识 + * @param lang 语言,zh_CN 或 en_US,默认中文 + * @return the string + * @throws WxErrorException the wx error exception */ String queryRecognitionResult(String voiceId, AiLangType lang) throws WxErrorException; @@ -48,9 +51,11 @@ public interface WxMpAiOpenService { * 识别指定语音文件内容. * 此方法揉合了前两两个方法:uploadVoice 和 queryRecognitionResult * + * @param voiceId 语音唯一标识 * @param lang 语言,zh_CN 或 en_US,默认中文 * @param voiceFile 语音文件 - * @param voiceId 语音唯一标识 + * @return the string + * @throws WxErrorException the wx error exception */ String recogniseVoice(String voiceId, AiLangType lang, File voiceFile) throws WxErrorException; @@ -67,6 +72,8 @@ public interface WxMpAiOpenService { * @param langFrom 源语言,zh_CN 或 en_US * @param langTo 目标语言,zh_CN 或 en_US * @param content 要翻译的文本内容 + * @return the string + * @throws WxErrorException the wx error exception */ String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java index a9eac896d7..08c040e144 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java @@ -13,292 +13,292 @@ * @author yuanqixun 2018-08-29 */ public interface WxMpCardService { - /** - * 得到WxMpService. - * - * @return WxMpService wx mp service - */ - WxMpService getWxMpService(); - - /** - * 获得卡券api_ticket,不强制刷新卡券api_ticket. - * - * @return 卡券api_ticket card api ticket - * @throws WxErrorException 异常 - * @see #getCardApiTicket(boolean) #getCardApiTicket(boolean) - */ - String getCardApiTicket() throws WxErrorException; - - /** - *
-   * 获得卡券api_ticket.
-   * 获得时会检查卡券apiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干
-   *
-   * 详情请见:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E9.99.84.E5.BD.954-.E5.8D.A1.E5.88.B8.E6.89.A9.E5.B1.95.E5.AD.97.E6.AE.B5.E5.8F.8A.E7.AD.BE.E5.90.8D.E7.94.9F.E6.88.90.E7.AE.97.E6.B3.95
-   * 
- * - * @param forceRefresh 强制刷新 - * @return 卡券api_ticket card api ticket - * @throws WxErrorException 异常 - */ - String getCardApiTicket(boolean forceRefresh) throws WxErrorException; - - /** - *
-   * 创建调用卡券api时所需要的签名.
-   *
-   * 详情请见:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E9.99.84.E5.BD
-   * .954-.E5.8D.A1.E5.88.B8.E6.89.A9.E5.B1.95.E5.AD.97.E6.AE.B5.E5.8F.8A.E7.AD.BE.E5.90.8D.E7.94
-   * .9F.E6.88.90.E7.AE.97.E6.B3.95
-   * 
- * - * @param optionalSignParam 参与签名的参数数组。可以为下列字段:app_id, card_id, card_type, code, openid, location_id
注意:当做wx.chooseCard调用时,必须传入app_id参与签名,否则会造成签名失败导致拉取卡券列表为空 - * @return 卡券Api签名对象 wx card api signature - * @throws WxErrorException 异常 - */ - WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException; - - /** - * 卡券Code解码. - * - * @param encryptCode 加密Code,通过JSSDK的chooseCard接口获得 - * @return 解密后的Code string - * @throws WxErrorException 异常 - */ - String decryptCardCode(String encryptCode) throws WxErrorException; - - /** - * 卡券Code查询. - * 文档地址: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025272&anchor=1 - * - * @param cardId 卡券ID代表一类卡券 - * @param code 单张卡券的唯一标准 - * @param checkConsume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同 - * @return WxMpCardResult对象 wx mp card result - * @throws WxErrorException 异常 - */ - WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume) throws WxErrorException; - - /** - * 卡券Code核销。核销失败会抛出异常 - * - * @param code 单张卡券的唯一标准 - * @return 调用返回的JSON字符串 。可用 com.google.gson.JsonParser#parse 等方法直接取JSON串中的errcode等信息。 - * @throws WxErrorException 异常 - */ - String consumeCardCode(String code) throws WxErrorException; - - /** - * 卡券Code核销。核销失败会抛出异常. - * - * @param code 单张卡券的唯一标准 - * @param cardId 当自定义Code卡券时需要传入card_id - * @return 调用返回的JSON字符串 。可用 com.google.gson.JsonParser#parse 等方法直接取JSON串中的errcode等信息。 - * @throws WxErrorException 异常 - */ - String consumeCardCode(String code, String cardId) throws WxErrorException; - - /** - * 卡券Mark接口. - * 开发者在帮助消费者核销卡券之前,必须帮助先将此code(卡券串码)与一个openid绑定(即mark住), - * 才能进一步调用核销接口,否则报错。 - * - * @param code 卡券的code码 - * @param cardId 卡券的ID - * @param openId 用券用户的openid - * @param isMark 是否要mark(占用)这个code,填写true或者false,表示占用或解除占用 - * @throws WxErrorException 异常 - */ - void markCardCode(String code, String cardId, String openId, boolean isMark) throws WxErrorException; - - /** - * 查看卡券详情接口. - * 详见 https://mp.weixin.qq.com/wiki/14/8dd77aeaee85f922db5f8aa6386d385e.html#.E6.9F.A5.E7.9C.8B.E5.8D.A1.E5.88.B8.E8.AF.A6.E6.83.85 - * - * @param cardId 卡券的ID - * @return 返回的卡券详情JSON字符串
[注] 由于返回的JSON格式过于复杂,难以定义其对应格式的Bean并且难以维护,因此只返回String格式的JSON串。
可由 com.google.gson.JsonParser#parse 等方法直接取JSON串中的某个字段。 - * @throws WxErrorException 异常 - */ - String getCardDetail(String cardId) throws WxErrorException; - - /** - * 添加测试白名单. - * - * @param openid 用户的openid - * @return string string - * @throws WxErrorException 异常 - */ - String addTestWhiteList(String openid) throws WxErrorException; - - /** - * 创建卡券. - * - * @param cardCreateMessage 请求 - * @return result wx mp card create result - * @throws WxErrorException 异常 - */ - WxMpCardCreateResult createCard(WxMpCardCreateRequest cardCreateMessage) throws WxErrorException; - - /** - * 创建卡券二维码. - * - * @param cardId 卡券编号 - * @param outerStr 二维码标识 - * @return WxMpCardQrcodeCreateResult wx mp card qrcode create result - * @throws WxErrorException 异常 - */ - WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr) throws WxErrorException; - - /** - * 创建卡券二维码. - * - * @param cardId 卡券编号 - * @param outerStr 二维码标识 - * @param expiresIn 指定二维码的有效时间,范围是60 ~ 1800秒。不填默认为365天有效 - * @return WxMpCardQrcodeCreateResult wx mp card qrcode create result - * @throws WxErrorException 异常 - */ - WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn) throws WxErrorException; - - /** - * 创建卡券二维码. - * - * @param cardId 卡券编号 - * @param outerStr 用户首次领卡时,会通过 领取事件推送 给商户; 对于会员卡的二维码,用户每次扫码打开会员卡后点击任何url,会将该值拼入url中,方便开发者定位扫码来源 - * @param expiresIn 指定二维码的有效时间,范围是60 ~ 1800秒。不填默认为365天有效 - * @param openid 指定领取者的openid,只有该用户能领取。bind_openid字段为true的卡券必须填写,非指定openid不必填写。 - * @param code 卡券Code码,use_custom_code字段为true的卡券必须填写,非自定义code和导入code模式的卡券不必填写。 - * @param isUniqueCode 指定下发二维码,生成的二维码随机分配一个code,领取后不可再次扫描。填写true或false。默认false,注意填写该字段时,卡券须通过审核且库存不为0。 - * @return WxMpCardQrcodeCreateResult wx mp card qrcode create result - * @throws WxErrorException 异常 - */ - WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn, String openid, + /** + * 得到WxMpService. + * + * @return WxMpService wx mp service + */ + WxMpService getWxMpService(); + + /** + * 获得卡券api_ticket,不强制刷新卡券api_ticket. + * + * @return 卡券api_ticket card api ticket + * @throws WxErrorException 异常 + * @see #getCardApiTicket(boolean) #getCardApiTicket(boolean)#getCardApiTicket(boolean) + */ + String getCardApiTicket() throws WxErrorException; + + /** + *
+     * 获得卡券api_ticket.
+     * 获得时会检查卡券apiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干
+     *
+     * 详情请见:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E9.99.84.E5.BD.954-.E5.8D.A1.E5.88.B8.E6.89.A9.E5.B1.95.E5.AD.97.E6.AE.B5.E5.8F.8A.E7.AD.BE.E5.90.8D.E7.94.9F.E6.88.90.E7.AE.97.E6.B3.95
+     * 
+ * + * @param forceRefresh 强制刷新 + * @return 卡券api_ticket card api ticket + * @throws WxErrorException 异常 + */ + String getCardApiTicket(boolean forceRefresh) throws WxErrorException; + + /** + *
+     * 创建调用卡券api时所需要的签名.
+     *
+     * 详情请见:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E9.99.84.E5.BD
+     * .954-.E5.8D.A1.E5.88.B8.E6.89.A9.E5.B1.95.E5.AD.97.E6.AE.B5.E5.8F.8A.E7.AD.BE.E5.90.8D.E7.94
+     * .9F.E6.88.90.E7.AE.97.E6.B3.95
+     * 
+ * + * @param optionalSignParam 参与签名的参数数组。可以为下列字段:app_id, card_id, card_type, code, openid, location_id
注意:当做wx.chooseCard调用时,必须传入app_id参与签名,否则会造成签名失败导致拉取卡券列表为空 + * @return 卡券Api签名对象 wx card api signature + * @throws WxErrorException 异常 + */ + WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException; + + /** + * 卡券Code解码. + * + * @param encryptCode 加密Code,通过JSSDK的chooseCard接口获得 + * @return 解密后的Code string + * @throws WxErrorException 异常 + */ + String decryptCardCode(String encryptCode) throws WxErrorException; + + /** + * 卡券Code查询. + * 文档地址: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025272&anchor=1 + * + * @param cardId 卡券ID代表一类卡券 + * @param code 单张卡券的唯一标准 + * @param checkConsume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同 + * @return WxMpCardResult对象 wx mp card result + * @throws WxErrorException 异常 + */ + WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume) throws WxErrorException; + + /** + * 卡券Code核销。核销失败会抛出异常 + * + * @param code 单张卡券的唯一标准 + * @return 调用返回的JSON字符串 。可用 com.google.gson.JsonParser#parse 等方法直接取JSON串中的errcode等信息。 + * @throws WxErrorException 异常 + */ + String consumeCardCode(String code) throws WxErrorException; + + /** + * 卡券Code核销。核销失败会抛出异常. + * + * @param code 单张卡券的唯一标准 + * @param cardId 当自定义Code卡券时需要传入card_id + * @return 调用返回的JSON字符串 。可用 com.google.gson.JsonParser#parse 等方法直接取JSON串中的errcode等信息。 + * @throws WxErrorException 异常 + */ + String consumeCardCode(String code, String cardId) throws WxErrorException; + + /** + * 卡券Mark接口. + * 开发者在帮助消费者核销卡券之前,必须帮助先将此code(卡券串码)与一个openid绑定(即mark住), + * 才能进一步调用核销接口,否则报错。 + * + * @param code 卡券的code码 + * @param cardId 卡券的ID + * @param openId 用券用户的openid + * @param isMark 是否要mark(占用)这个code,填写true或者false,表示占用或解除占用 + * @throws WxErrorException 异常 + */ + void markCardCode(String code, String cardId, String openId, boolean isMark) throws WxErrorException; + + /** + * 查看卡券详情接口. + * 详见 https://mp.weixin.qq.com/wiki/14/8dd77aeaee85f922db5f8aa6386d385e.html#.E6.9F.A5.E7.9C.8B.E5.8D.A1.E5.88.B8.E8.AF.A6.E6.83.85 + * + * @param cardId 卡券的ID + * @return 返回的卡券详情JSON字符串
[注] 由于返回的JSON格式过于复杂,难以定义其对应格式的Bean并且难以维护,因此只返回String格式的JSON串。
可由 com.google.gson.JsonParser#parse 等方法直接取JSON串中的某个字段。 + * @throws WxErrorException 异常 + */ + String getCardDetail(String cardId) throws WxErrorException; + + /** + * 添加测试白名单. + * + * @param openid 用户的openid + * @return string string + * @throws WxErrorException 异常 + */ + String addTestWhiteList(String openid) throws WxErrorException; + + /** + * 创建卡券. + * + * @param cardCreateMessage 请求 + * @return result wx mp card create result + * @throws WxErrorException 异常 + */ + WxMpCardCreateResult createCard(WxMpCardCreateRequest cardCreateMessage) throws WxErrorException; + + /** + * 创建卡券二维码. + * + * @param cardId 卡券编号 + * @param outerStr 二维码标识 + * @return WxMpCardQrcodeCreateResult wx mp card qrcode create result + * @throws WxErrorException 异常 + */ + WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr) throws WxErrorException; + + /** + * 创建卡券二维码. + * + * @param cardId 卡券编号 + * @param outerStr 二维码标识 + * @param expiresIn 指定二维码的有效时间,范围是60 ~ 1800秒。不填默认为365天有效 + * @return WxMpCardQrcodeCreateResult wx mp card qrcode create result + * @throws WxErrorException 异常 + */ + WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn) throws WxErrorException; + + /** + * 创建卡券二维码. + * + * @param cardId 卡券编号 + * @param outerStr 用户首次领卡时,会通过 领取事件推送 给商户; 对于会员卡的二维码,用户每次扫码打开会员卡后点击任何url,会将该值拼入url中,方便开发者定位扫码来源 + * @param expiresIn 指定二维码的有效时间,范围是60 ~ 1800秒。不填默认为365天有效 + * @param openid 指定领取者的openid,只有该用户能领取。bind_openid字段为true的卡券必须填写,非指定openid不必填写。 + * @param code 卡券Code码,use_custom_code字段为true的卡券必须填写,非自定义code和导入code模式的卡券不必填写。 + * @param isUniqueCode 指定下发二维码,生成的二维码随机分配一个code,领取后不可再次扫描。填写true或false。默认false,注意填写该字段时,卡券须通过审核且库存不为0。 + * @return WxMpCardQrcodeCreateResult wx mp card qrcode create result + * @throws WxErrorException 异常 + */ + WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn, String openid, String code, boolean isUniqueCode) throws WxErrorException; - /** - * 创建卡券货架. - * - * @param createRequest 货架创建参数 - * @return WxMpCardLandingPageCreateResult wx mp card landing page create result - * @throws WxErrorException 异常 - */ - WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest createRequest) + /** + * 创建卡券货架. + * + * @param createRequest 货架创建参数 + * @return WxMpCardLandingPageCreateResult wx mp card landing page create result + * @throws WxErrorException 异常 + */ + WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest createRequest) throws WxErrorException; - /** - * 将用户的卡券设置为失效状态. - * 详见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025272&anchor=9 - * - * @param cardId 卡券编号 - * @param code 用户会员卡号 - * @param reason 设置为失效的原因 - * @return result string - * @throws WxErrorException 异常 - */ - String unavailableCardCode(String cardId, String code, String reason) throws WxErrorException; - - /** - * 删除卡券接口. - * - * @param cardId 卡券id - * @return 删除结果 wx mp card delete result - * @throws WxErrorException 异常 - */ - WxMpCardDeleteResult deleteCard(String cardId) throws WxErrorException; - - /** - * 导入自定义code(仅对自定义code商户) - * - * @param cardId 卡券id - * @param codeList 需导入微信卡券后台的自定义code,上限为100个。 - * @return the wx mp card code deposit result - * @throws WxErrorException the wx error exception - */ - WxMpCardCodeDepositResult cardCodeDeposit(String cardId, List codeList) throws WxErrorException; - - /** - * 查询导入code数目接口 - * - * @param cardId 卡券id - * @return the wx mp card code deposit count result - * @throws WxErrorException the wx error exception - */ - WxMpCardCodeDepositCountResult cardCodeDepositCount(String cardId) throws WxErrorException; - - /** - * 核查code接口 - * - * @param cardId 卡券id - * @param codeList 已经微信卡券后台的自定义code,上限为100个 - * @return the wx mp card code checkcode result - * @throws WxErrorException the wx error exception - */ - WxMpCardCodeCheckcodeResult cardCodeCheckcode(String cardId, List codeList) throws WxErrorException; - - /** - * 图文消息群发卡券获取内嵌html - * - * @param cardId 卡券id - * @return the wx mp card mpnews gethtml result - * @throws WxErrorException the wx error exception - */ - WxMpCardMpnewsGethtmlResult cardMpnewsGethtml(String cardId) throws WxErrorException; - - - /** - * 修改库存接口 - * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Managing_Coupons_Vouchers_and_Cards.html#5 - * - * @param cardId 卡券ID - * @param changeValue 库存变更值,负值为减少库存 - * @throws WxErrorException the wx error exception - */ - void cardModifyStock(String cardId, Integer changeValue) throws WxErrorException; - - - /** - * 更改Code接口 - * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Managing_Coupons_Vouchers_and_Cards.html#6 - * - * @param cardId 卡券ID - * @param oldCode 需变更的Code码 - * @param newCode 变更后的有效Code码 - * @throws WxErrorException the wx error exception - */ - void cardCodeUpdate(String cardId, String oldCode, String newCode) throws WxErrorException; - - /** - * 设置买单接口 - * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Create_a_Coupon_Voucher_or_Card.html#12 - * - * @param cardId 卡券ID - * @param isOpen 是否开启买单功能,填true/false - * @throws WxErrorException the wx error exception - */ - void cardPaycellSet(String cardId, Boolean isOpen) throws WxErrorException; - - /** - * 设置自助核销 - * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Create_a_Coupon_Voucher_or_Card.html#14 - * - * @param cardId 卡券ID - * @param isOpen 是否开启自助核销功能 - * @param needVerifyCod 用户核销时是否需要输入验证码, 填true/false, 默认为false - * @param needRemarkAmount 用户核销时是否需要备注核销金额, 填true/false, 默认为false - * @throws WxErrorException the wx error exception - */ - void cardSelfConsumeCellSet(String cardId, Boolean isOpen, + /** + * 将用户的卡券设置为失效状态. + * 详见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025272&anchor=9 + * + * @param cardId 卡券编号 + * @param code 用户会员卡号 + * @param reason 设置为失效的原因 + * @return result string + * @throws WxErrorException 异常 + */ + String unavailableCardCode(String cardId, String code, String reason) throws WxErrorException; + + /** + * 删除卡券接口. + * + * @param cardId 卡券id + * @return 删除结果 wx mp card delete result + * @throws WxErrorException 异常 + */ + WxMpCardDeleteResult deleteCard(String cardId) throws WxErrorException; + + /** + * 导入自定义code(仅对自定义code商户) + * + * @param cardId 卡券id + * @param codeList 需导入微信卡券后台的自定义code,上限为100个。 + * @return the wx mp card code deposit result + * @throws WxErrorException the wx error exception + */ + WxMpCardCodeDepositResult cardCodeDeposit(String cardId, List codeList) throws WxErrorException; + + /** + * 查询导入code数目接口 + * + * @param cardId 卡券id + * @return the wx mp card code deposit count result + * @throws WxErrorException the wx error exception + */ + WxMpCardCodeDepositCountResult cardCodeDepositCount(String cardId) throws WxErrorException; + + /** + * 核查code接口 + * + * @param cardId 卡券id + * @param codeList 已经微信卡券后台的自定义code,上限为100个 + * @return the wx mp card code checkcode result + * @throws WxErrorException the wx error exception + */ + WxMpCardCodeCheckcodeResult cardCodeCheckcode(String cardId, List codeList) throws WxErrorException; + + /** + * 图文消息群发卡券获取内嵌html + * + * @param cardId 卡券id + * @return the wx mp card mpnews gethtml result + * @throws WxErrorException the wx error exception + */ + WxMpCardMpnewsGethtmlResult cardMpnewsGethtml(String cardId) throws WxErrorException; + + + /** + * 修改库存接口 + * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Managing_Coupons_Vouchers_and_Cards.html#5 + * + * @param cardId 卡券ID + * @param changeValue 库存变更值,负值为减少库存 + * @throws WxErrorException the wx error exception + */ + void cardModifyStock(String cardId, Integer changeValue) throws WxErrorException; + + + /** + * 更改Code接口 + * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Managing_Coupons_Vouchers_and_Cards.html#6 + * + * @param cardId 卡券ID + * @param oldCode 需变更的Code码 + * @param newCode 变更后的有效Code码 + * @throws WxErrorException the wx error exception + */ + void cardCodeUpdate(String cardId, String oldCode, String newCode) throws WxErrorException; + + /** + * 设置买单接口 + * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Create_a_Coupon_Voucher_or_Card.html#12 + * + * @param cardId 卡券ID + * @param isOpen 是否开启买单功能,填true/false + * @throws WxErrorException the wx error exception + */ + void cardPaycellSet(String cardId, Boolean isOpen) throws WxErrorException; + + /** + * 设置自助核销 + * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Create_a_Coupon_Voucher_or_Card.html#14 + * + * @param cardId 卡券ID + * @param isOpen 是否开启自助核销功能 + * @param needVerifyCod 用户核销时是否需要输入验证码, 填true/false, 默认为false + * @param needRemarkAmount 用户核销时是否需要备注核销金额, 填true/false, 默认为false + * @throws WxErrorException the wx error exception + */ + void cardSelfConsumeCellSet(String cardId, Boolean isOpen, Boolean needVerifyCod, Boolean needRemarkAmount) throws WxErrorException; - /** - * 获取用户已领取卡券接口 - * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Managing_Coupons_Vouchers_and_Cards.html#1 - * - * @param openId 需要查询的用户openid - * @param cardId 卡券ID。不填写时默认查询当前appid下的卡券 - * @return user card list - * @throws WxErrorException the wx error exception - */ - WxUserCardListResult getUserCardList(String openId, String cardId) throws WxErrorException; + /** + * 获取用户已领取卡券接口 + * https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Managing_Coupons_Vouchers_and_Cards.html#1 + * + * @param openId 需要查询的用户openid + * @param cardId 卡券ID。不填写时默认查询当前appid下的卡券 + * @return user card list + * @throws WxErrorException the wx error exception + */ + WxUserCardListResult getUserCardList(String openId, String cardId) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCommentService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCommentService.java index c4ba7ca326..25463061fe 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCommentService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCommentService.java @@ -7,97 +7,96 @@ * 图文消息留言管理接口. * https://developers.weixin.qq.com/doc/offiaccount/Comments_management/Image_Comments_Management_Interface.html * - * @author Binary Wang - * @date 2019-06-16 + * @author Binary Wang created on 2019-06-16 */ public interface WxMpCommentService { - /** - * 打开已群发文章评论. - * https://api.weixin.qq.com/cgi-bin/comment/open?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @throws WxErrorException 异常 - */ - void open(String msgDataId, Integer index) throws WxErrorException; + /** + * 打开已群发文章评论. + * https://api.weixin.qq.com/cgi-bin/comment/open?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @throws WxErrorException 异常 + */ + void open(String msgDataId, Integer index) throws WxErrorException; - /** - * 关闭已群发文章评论. - * https://api.weixin.qq.com/cgi-bin/comment/close?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @throws WxErrorException 异常 - */ - void close(String msgDataId, Integer index) throws WxErrorException; + /** + * 关闭已群发文章评论. + * https://api.weixin.qq.com/cgi-bin/comment/close?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @throws WxErrorException 异常 + */ + void close(String msgDataId, Integer index) throws WxErrorException; - /** - * 查看指定文章的评论数据. - * https://api.weixin.qq.com/cgi-bin/comment/list?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @param begin 起始位置 - * @param count 获取数目(>=50会被拒绝) - * @param type type=0 普通评论&精选评论 type=1 普通评论 type=2 精选评论 - * @return 评论列表数据 - * @throws WxErrorException 异常 - */ - WxMpCommentListVo list(String msgDataId, Integer index, int begin, int count, int type) throws WxErrorException; + /** + * 查看指定文章的评论数据. + * https://api.weixin.qq.com/cgi-bin/comment/list?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @param begin 起始位置 + * @param count 获取数目(>=50会被拒绝) + * @param type type=0 普通评论&精选评论 type=1 普通评论 type=2 精选评论 + * @return 评论列表数据 wx mp comment list vo + * @throws WxErrorException 异常 + */ + WxMpCommentListVo list(String msgDataId, Integer index, int begin, int count, int type) throws WxErrorException; - /** - * 2.4 将评论标记精选. - * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/markelect?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @param userCommentId 用户评论id - * @throws WxErrorException 异常 - */ - void markElect(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; + /** + * 2.4 将评论标记精选. + * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/markelect?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @param userCommentId 用户评论id + * @throws WxErrorException 异常 + */ + void markElect(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; - /** - * 2.5 将评论取消精选. - * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/unmarkelect?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @param userCommentId 用户评论id - * @throws WxErrorException 异常 - */ - void unmarkElect(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; + /** + * 2.5 将评论取消精选. + * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/unmarkelect?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @param userCommentId 用户评论id + * @throws WxErrorException 异常 + */ + void unmarkElect(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; - /** - * 2.6 删除评论. - * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/delete?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @param userCommentId 用户评论id - * @throws WxErrorException 异常 - */ - void delete(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; + /** + * 2.6 删除评论. + * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/delete?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @param userCommentId 用户评论id + * @throws WxErrorException 异常 + */ + void delete(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; - /** - * 2.7 回复评论. - * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/reply/add?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @param userCommentId 用户评论id - * @param content 回复内容 - * @throws WxErrorException 异常 - */ - void replyAdd(String msgDataId, Integer index, Long userCommentId, String content) throws WxErrorException; + /** + * 2.7 回复评论. + * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/reply/add?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @param userCommentId 用户评论id + * @param content 回复内容 + * @throws WxErrorException 异常 + */ + void replyAdd(String msgDataId, Integer index, Long userCommentId, String content) throws WxErrorException; - /** - * 2.8 删除回复. - * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/reply/delete?access_token=ACCESS_TOKEN - * - * @param msgDataId 群发返回的msg_data_id - * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 - * @param userCommentId 用户评论id - * @throws WxErrorException 异常 - */ - void replyDelete(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; + /** + * 2.8 删除回复. + * 接口调用请求: POST https://api.weixin.qq.com/cgi-bin/comment/reply/delete?access_token=ACCESS_TOKEN + * + * @param msgDataId 群发返回的msg_data_id + * @param index 多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文 + * @param userCommentId 用户评论id + * @throws WxErrorException 异常 + */ + void replyDelete(String msgDataId, Integer index, Long userCommentId) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDataCubeService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDataCubeService.java index cd2fda8350..d107444e21 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDataCubeService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDataCubeService.java @@ -15,234 +15,234 @@ public interface WxMpDataCubeService { //*******************用户分析数据接口***********************// - /** - *
-   * 获取用户增减数据
-   * 详情请见文档:用户分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getusersummary?access_token=ACCESS_TOKEN
-   * 
- * - * @param beginDate 开始时间 - * @param endDate 最大时间跨度7天,endDate不能早于begingDate - * @return the user summary - * @throws WxErrorException the wx error exception - */ - List getUserSummary(Date beginDate, Date endDate) throws WxErrorException; - - /** - *
-   * 获取累计用户数据
-   * 详情请见文档:用户分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getusercumulate?access_token=ACCESS_TOKEN
-   * 
- * - * @param beginDate 开始时间 - * @param endDate 最大时间跨度7天,endDate不能早于begingDate - * @return the user cumulate - * @throws WxErrorException the wx error exception - */ - List getUserCumulate(Date beginDate, Date endDate) throws WxErrorException; + /** + *
+     * 获取用户增减数据
+     * 详情请见文档:用户分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getusersummary?access_token=ACCESS_TOKEN
+     * 
+ * + * @param beginDate 开始时间 + * @param endDate 最大时间跨度7天,endDate不能早于begingDate + * @return the user summary + * @throws WxErrorException the wx error exception + */ + List getUserSummary(Date beginDate, Date endDate) throws WxErrorException; + + /** + *
+     * 获取累计用户数据
+     * 详情请见文档:用户分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getusercumulate?access_token=ACCESS_TOKEN
+     * 
+ * + * @param beginDate 开始时间 + * @param endDate 最大时间跨度7天,endDate不能早于begingDate + * @return the user cumulate + * @throws WxErrorException the wx error exception + */ + List getUserCumulate(Date beginDate, Date endDate) throws WxErrorException; //*******************图文分析数据接口***********************// - /** - *
-   * 获取图文群发每日数据(getarticlesummary)
-   * 详情请见文档:图文分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getarticlesummary?access_token=ACCESS_TOKEN
-   * 
- * - * @param beginDate 开始时间 - * @param endDate 最大时间跨度1天,endDate不能早于begingDate - * @return the article summary - * @throws WxErrorException the wx error exception - */ - List getArticleSummary(Date beginDate, Date endDate) throws WxErrorException; - - /** - *
-   * 获取图文群发总数据(getarticletotal)
-   * 详情请见文档:图文分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getarticletotal?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度1天,endDate不能早于begingDate
-   * @return the article total
-   * @throws WxErrorException the wx error exception
-   */
-  List getArticleTotal(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取图文统计数据(getuserread)
-   * 详情请见文档:图文分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getuserread?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度3天,endDate不能早于begingDate
-   * @return the user read
-   * @throws WxErrorException the wx error exception
-   */
-  List getUserRead(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取图文统计分时数据(getuserreadhour)
-   * 详情请见文档:图文分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getuserreadhour?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度1天,endDate不能早于begingDate
-   * @return the user read hour
-   * @throws WxErrorException the wx error exception
-   */
-  List getUserReadHour(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取图文分享转发数据(getusershare)
-   * 详情请见文档:图文分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getusershare?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度7天,endDate不能早于begingDate
-   * @return the user share
-   * @throws WxErrorException the wx error exception
-   */
-  List getUserShare(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取图文分享转发分时数据(getusersharehour)
-   * 详情请见文档:图文分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getusersharehour?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度1天,endDate不能早于begingDate
-   * @return the user share hour
-   * @throws WxErrorException the wx error exception
-   */
-  List getUserShareHour(Date beginDate, Date endDate) throws WxErrorException;
+    /**
+     * 
+     * 获取图文群发每日数据(getarticlesummary)
+     * 详情请见文档:图文分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getarticlesummary?access_token=ACCESS_TOKEN
+     * 
+ * + * @param beginDate 开始时间 + * @param endDate 最大时间跨度1天,endDate不能早于begingDate + * @return the article summary + * @throws WxErrorException the wx error exception + */ + List getArticleSummary(Date beginDate, Date endDate) throws WxErrorException; + + /** + *
+     * 获取图文群发总数据(getarticletotal)
+     * 详情请见文档:图文分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getarticletotal?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度1天,endDate不能早于begingDate
+     * @return the article total
+     * @throws WxErrorException the wx error exception
+     */
+    List getArticleTotal(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取图文统计数据(getuserread)
+     * 详情请见文档:图文分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getuserread?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度3天,endDate不能早于begingDate
+     * @return the user read
+     * @throws WxErrorException the wx error exception
+     */
+    List getUserRead(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取图文统计分时数据(getuserreadhour)
+     * 详情请见文档:图文分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getuserreadhour?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度1天,endDate不能早于begingDate
+     * @return the user read hour
+     * @throws WxErrorException the wx error exception
+     */
+    List getUserReadHour(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取图文分享转发数据(getusershare)
+     * 详情请见文档:图文分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getusershare?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度7天,endDate不能早于begingDate
+     * @return the user share
+     * @throws WxErrorException the wx error exception
+     */
+    List getUserShare(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取图文分享转发分时数据(getusersharehour)
+     * 详情请见文档:图文分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getusersharehour?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度1天,endDate不能早于begingDate
+     * @return the user share hour
+     * @throws WxErrorException the wx error exception
+     */
+    List getUserShareHour(Date beginDate, Date endDate) throws WxErrorException;
 
   //*******************消息分析数据接口***********************//
 
-  /**
-   * 
-   * 获取消息发送概况数据(getupstreammsg)
-   * 详情请见文档:消息分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsg?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度7天,endDate不能早于begingDate
-   * @return the upstream msg
-   * @throws WxErrorException the wx error exception
-   */
-  List getUpstreamMsg(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取消息分送分时数据(getupstreammsghour)
-   * 详情请见文档:消息分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsghour?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度1天,endDate不能早于begingDate
-   * @return the upstream msg hour
-   * @throws WxErrorException the wx error exception
-   */
-  List getUpstreamMsgHour(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取消息发送周数据(getupstreammsgweek)
-   * 详情请见文档:消息分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgweek?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度30天,endDate不能早于begingDate
-   * @return the upstream msg week
-   * @throws WxErrorException the wx error exception
-   */
-  List getUpstreamMsgWeek(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取消息发送月数据(getupstreammsgmonth)
-   * 详情请见文档:消息分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgmonth?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度30天,endDate不能早于begingDate
-   * @return the upstream msg month
-   * @throws WxErrorException the wx error exception
-   */
-  List getUpstreamMsgMonth(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取消息发送分布数据(getupstreammsgdist)
-   * 详情请见文档:消息分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdist?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度15天,endDate不能早于begingDate
-   * @return the upstream msg dist
-   * @throws WxErrorException the wx error exception
-   */
-  List getUpstreamMsgDist(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取消息发送分布周数据(getupstreammsgdistweek)
-   * 详情请见文档:消息分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdistweek?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度30天,endDate不能早于begingDate
-   * @return the upstream msg dist week
-   * @throws WxErrorException the wx error exception
-   */
-  List getUpstreamMsgDistWeek(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取消息发送分布月数据(getupstreammsgdistmonth)
-   * 详情请见文档:消息分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdistmonth?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度30天,endDate不能早于begingDate
-   * @return the upstream msg dist month
-   * @throws WxErrorException the wx error exception
-   */
-  List getUpstreamMsgDistMonth(Date beginDate, Date endDate) throws WxErrorException;
+    /**
+     * 
+     * 获取消息发送概况数据(getupstreammsg)
+     * 详情请见文档:消息分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsg?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度7天,endDate不能早于begingDate
+     * @return the upstream msg
+     * @throws WxErrorException the wx error exception
+     */
+    List getUpstreamMsg(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取消息分送分时数据(getupstreammsghour)
+     * 详情请见文档:消息分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsghour?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度1天,endDate不能早于begingDate
+     * @return the upstream msg hour
+     * @throws WxErrorException the wx error exception
+     */
+    List getUpstreamMsgHour(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取消息发送周数据(getupstreammsgweek)
+     * 详情请见文档:消息分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgweek?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度30天,endDate不能早于begingDate
+     * @return the upstream msg week
+     * @throws WxErrorException the wx error exception
+     */
+    List getUpstreamMsgWeek(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取消息发送月数据(getupstreammsgmonth)
+     * 详情请见文档:消息分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgmonth?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度30天,endDate不能早于begingDate
+     * @return the upstream msg month
+     * @throws WxErrorException the wx error exception
+     */
+    List getUpstreamMsgMonth(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取消息发送分布数据(getupstreammsgdist)
+     * 详情请见文档:消息分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdist?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度15天,endDate不能早于begingDate
+     * @return the upstream msg dist
+     * @throws WxErrorException the wx error exception
+     */
+    List getUpstreamMsgDist(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取消息发送分布周数据(getupstreammsgdistweek)
+     * 详情请见文档:消息分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdistweek?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度30天,endDate不能早于begingDate
+     * @return the upstream msg dist week
+     * @throws WxErrorException the wx error exception
+     */
+    List getUpstreamMsgDistWeek(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取消息发送分布月数据(getupstreammsgdistmonth)
+     * 详情请见文档:消息分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdistmonth?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度30天,endDate不能早于begingDate
+     * @return the upstream msg dist month
+     * @throws WxErrorException the wx error exception
+     */
+    List getUpstreamMsgDistMonth(Date beginDate, Date endDate) throws WxErrorException;
 
   //*******************接口分析数据接口***********************//
 
-  /**
-   * 
-   * 获取接口分析数据(getinterfacesummary)
-   * 详情请见文档:接口分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getinterfacesummary?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度30天,endDate不能早于begingDate
-   * @return the interface summary
-   * @throws WxErrorException the wx error exception
-   */
-  List getInterfaceSummary(Date beginDate, Date endDate) throws WxErrorException;
-
-  /**
-   * 
-   * 获取接口分析分时数据(getinterfacesummaryhour)
-   * 详情请见文档:接口分析数据接口
-   * 接口url格式:https://api.weixin.qq.com/datacube/getinterfacesummaryhour?access_token=ACCESS_TOKEN
-   *
-   * @param beginDate 开始时间
-   * @param endDate 最大时间跨度1天,endDate不能早于begingDate
-   * @return the interface summary hour
-   * @throws WxErrorException the wx error exception
-   */
-  List getInterfaceSummaryHour(Date beginDate, Date endDate) throws WxErrorException;
+    /**
+     * 
+     * 获取接口分析数据(getinterfacesummary)
+     * 详情请见文档:接口分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getinterfacesummary?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度30天,endDate不能早于begingDate
+     * @return the interface summary
+     * @throws WxErrorException the wx error exception
+     */
+    List getInterfaceSummary(Date beginDate, Date endDate) throws WxErrorException;
+
+    /**
+     * 
+     * 获取接口分析分时数据(getinterfacesummaryhour)
+     * 详情请见文档:接口分析数据接口
+     * 接口url格式:https://api.weixin.qq.com/datacube/getinterfacesummaryhour?access_token=ACCESS_TOKEN
+     *
+     * @param beginDate 开始时间
+     * @param endDate 最大时间跨度1天,endDate不能早于begingDate
+     * @return the interface summary hour
+     * @throws WxErrorException the wx error exception
+     */
+    List getInterfaceSummaryHour(Date beginDate, Date endDate) throws WxErrorException;
 
 }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java
index c2ccef5a64..466bf0b229 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java
@@ -9,101 +9,113 @@
  * @author keungtung
  */
 public interface WxMpDeviceService {
-  /**
-   * 
-   * 主动发送消息给设备
-   * 详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-3
-   * 
- */ - TransMsgResp transMsg(WxDeviceMsg msg) throws WxErrorException; + /** + *
+     * 主动发送消息给设备
+     * 详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-3
+     * 
+ * + * @param msg the msg + * @return the trans msg resp + * @throws WxErrorException the wx error exception + */ + TransMsgResp transMsg(WxDeviceMsg msg) throws WxErrorException; - /** - *
-   *   获取一组新的deviceid和设备二维码
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-6
-   * 
- * - * @param productId 产品id - * @return 返回WxDeviceQrCodeResult - */ - WxDeviceQrCodeResult getQrCode(String productId) throws WxErrorException; + /** + *
+     *   获取一组新的deviceid和设备二维码
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-6
+     * 
+ * + * @param productId 产品id + * @return 返回WxDeviceQrCodeResult qr code + * @throws WxErrorException the wx error exception + */ + WxDeviceQrCodeResult getQrCode(String productId) throws WxErrorException; - /** - *
-   *   将device id及其属性信息提交公众平台进行授权
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-6
-   * 
- * - * @param wxDeviceAuthorize 授权请求对象 - * @return WxDeviceAuthorizeResult - */ - WxDeviceAuthorizeResult authorize(WxDeviceAuthorize wxDeviceAuthorize) throws WxErrorException; + /** + *
+     *   将device id及其属性信息提交公众平台进行授权
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-6
+     * 
+ * + * @param wxDeviceAuthorize 授权请求对象 + * @return WxDeviceAuthorizeResult wx device authorize result + * @throws WxErrorException the wx error exception + */ + WxDeviceAuthorizeResult authorize(WxDeviceAuthorize wxDeviceAuthorize) throws WxErrorException; - /** - *
-   *   第三方后台绑定成功后,通知公众平台
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html/page=3-4-7
-   * 
- * - * @param wxDeviceBind 绑定请求对象 - * @return WxDeviceBindResult - */ - WxDeviceBindResult bind(WxDeviceBind wxDeviceBind) throws WxErrorException; + /** + *
+     *   第三方后台绑定成功后,通知公众平台
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html/page=3-4-7
+     * 
+ * + * @param wxDeviceBind 绑定请求对象 + * @return WxDeviceBindResult wx device bind result + * @throws WxErrorException the wx error exception + */ + WxDeviceBindResult bind(WxDeviceBind wxDeviceBind) throws WxErrorException; - /** - *
-   *   强制绑定用户和设备
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7
-   * 
- * - * @param wxDeviceBind 强制绑定请求对象 - * @return WxDeviceBindResult - */ - WxDeviceBindResult compelBind(WxDeviceBind wxDeviceBind) throws WxErrorException; + /** + *
+     *   强制绑定用户和设备
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7
+     * 
+ * + * @param wxDeviceBind 强制绑定请求对象 + * @return WxDeviceBindResult wx device bind result + * @throws WxErrorException the wx error exception + */ + WxDeviceBindResult compelBind(WxDeviceBind wxDeviceBind) throws WxErrorException; - /** - *
-   *   第三方确认用户和设备的解绑操作
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html/page=3-4-7
-   * 
- * - * @param wxDeviceBind 绑定请求对象 - * @return WxDeviceBidResult - */ - WxDeviceBindResult unbind(WxDeviceBind wxDeviceBind) throws WxErrorException; + /** + *
+     *   第三方确认用户和设备的解绑操作
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html/page=3-4-7
+     * 
+ * + * @param wxDeviceBind 绑定请求对象 + * @return WxDeviceBidResult wx device bind result + * @throws WxErrorException the wx error exception + */ + WxDeviceBindResult unbind(WxDeviceBind wxDeviceBind) throws WxErrorException; - /** - *
-   *   强制解绑用户和设备
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7
-   * 
- * - * @param wxDeviceBind 强制解绑请求对象 - * @return WxDeviceBindResult - */ - WxDeviceBindResult compelUnbind(WxDeviceBind wxDeviceBind) throws WxErrorException; + /** + *
+     *   强制解绑用户和设备
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7
+     * 
+ * + * @param wxDeviceBind 强制解绑请求对象 + * @return WxDeviceBindResult wx device bind result + * @throws WxErrorException the wx error exception + */ + WxDeviceBindResult compelUnbind(WxDeviceBind wxDeviceBind) throws WxErrorException; - /** - *
-   *   通过device type和device id 获取设备主人的openid
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-11
-   * 
- * - * @param deviceType 设备类型,目前为"公众账号原始ID" - * @param deviceId 设备ID - * @return WxDeviceOpenIdResult - */ - WxDeviceOpenIdResult getOpenId(String deviceType, String deviceId) throws WxErrorException; + /** + *
+     *   通过device type和device id 获取设备主人的openid
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-11
+     * 
+ * + * @param deviceType 设备类型,目前为"公众账号原始ID" + * @param deviceId 设备ID + * @return WxDeviceOpenIdResult open id + * @throws WxErrorException the wx error exception + */ + WxDeviceOpenIdResult getOpenId(String deviceType, String deviceId) throws WxErrorException; - /** - *
-   *   通过openid获取用户在当前devicetype下绑定的deviceid列表`
-   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-12
-   * 
- * - * @param openId 要查询的用户的openid - * @return WxDeviceBindDeviceResult - */ - WxDeviceBindDeviceResult getBindDevice(String openId) throws WxErrorException; + /** + *
+     *   通过openid获取用户在当前devicetype下绑定的deviceid列表`
+     *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-12
+     * 
+ * + * @param openId 要查询的用户的openid + * @return WxDeviceBindDeviceResult bind device + * @throws WxErrorException the wx error exception + */ + WxDeviceBindDeviceResult getBindDevice(String openId) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDraftService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDraftService.java new file mode 100644 index 0000000000..8ecf0073de --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDraftService.java @@ -0,0 +1,130 @@ +package me.chanjar.weixin.mp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.bean.draft.WxMpAddDraft; +import me.chanjar.weixin.mp.bean.draft.WxMpDraftInfo; +import me.chanjar.weixin.mp.bean.draft.WxMpDraftList; +import me.chanjar.weixin.mp.bean.draft.WxMpUpdateDraft; + +/** + * 微信 草稿箱 接口. + * + * @author dragon created on 2021-10-22 + */ +public interface WxMpDraftService { + + /** + * 新建草稿 - 只有默认必填参数 + *
+     * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Add_draft.html
+     * 
+ * + * @param title 标题 + * @param content 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS,涉及图片url必须来源 "上传图文消息内的图片获取URL"接口获取。外部图片url将被过滤。 + * @param thumbMediaId 图文消息的封面图片素材id(必须是永久MediaID) + * @return the string + * @throws WxErrorException . + */ + String addDraft(String title, String content, String thumbMediaId) throws WxErrorException; + + /** + * 新建草稿 - 完整参数 + *
+     * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Add_draft.html
+     * 
+ * + * @param addDraft 新建草稿信息 + * @return the string + * @throws WxErrorException . + */ + String addDraft(WxMpAddDraft addDraft) throws WxErrorException; + + /** + * 修改草稿 - 完整参数 + * 正常情况下调用成功时,errcode将为0。错误时微信会返回错误码等信息,请根据错误码查询错误信息 + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/draft/update?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Update_draft.html
+     * 
+ * + * @param updateDraftInfo 修改草稿信息 + * @return the boolean + * @throws WxErrorException . + */ + Boolean updateDraft(WxMpUpdateDraft updateDraftInfo) throws WxErrorException; + + /** + * 获取草稿信息 + * + *
+     * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/get?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Get_draft.html
+     * 
+ * + * @param mediaId 要获取的草稿的media_id + * @return 草稿信息 draft + * @throws WxErrorException . + */ + WxMpDraftInfo getDraft(String mediaId) throws WxErrorException; + + /** + * 删除草稿 + * 正常情况下调用成功时,errcode将为0。错误时微信会返回错误码等信息,请根据错误码查询错误信息。 + * 多次删除同一篇草稿,也返回 0. + *
+     * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/delete?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Delete_draft.html
+     * 
+ * + * @param mediaId 要删除的草稿的media_id + * @return the boolean + * @throws WxErrorException . + */ + Boolean delDraft(String mediaId) throws WxErrorException; + + /** + * 获取草稿列表 + * + *
+     * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Get_draft_list.html
+     * 
+ * + * @param offset 分页页数,从0开始 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 + * @param count 每页数量 返回素材的数量,取值在1到20之间 + * @param noContent 1 表示不返回 content 字段,0 表示正常返回,默认为 0 + * @return 草稿信息列表 wx mp draft list + * @throws WxErrorException . + */ + WxMpDraftList listDraft(int offset, int count, int noContent) throws WxErrorException; + + /** + * 获取草稿列表 + *
+     * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Get_draft_list.html
+     * 
+ * + * @param offset 分页页数,从0开始 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 + * @param count 每页数量 返回素材的数量,取值在1到20之间 + * @return wx mp draft list + * @throws WxErrorException the wx error exception + */ + WxMpDraftList listDraft(int offset, int count) throws WxErrorException; + + /** + * 获取草稿数量 + * 开发者可以根据本接口来获取草稿的总数。此接口只统计数量,不返回草稿的具体内容。 + *
+     * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/count?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Count_drafts.html
+     * 
+ * + * @return 草稿的总数 long + * @throws WxErrorException . + */ + Long countDraft() throws WxErrorException; + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpFreePublishService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpFreePublishService.java new file mode 100644 index 0000000000..670490ecec --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpFreePublishService.java @@ -0,0 +1,116 @@ +package me.chanjar.weixin.mp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishInfo; +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList; +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishStatus; + +/** + * 微信 发布能力 接口. + * + * @author dragon created on 2021-10-23 + */ +public interface WxMpFreePublishService { + + /** + * 发布接口 - 只有默认必填参数 + * 开发者需要先将图文素材以草稿的形式保存(见“草稿箱/新建草稿”,如需从已保存的草稿中选择,见“草稿箱/获取草稿列表”),选择要发布的草稿 media_id 进行发布 + *
+   * 请求地址:POST https://api.weixin.qq.com/cgi-bin/freepublish/submit?access_token=ACCESS_TOKEN
+   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Publish/Publish.html
+   * 
+ * + * @param mediaId 要发布的草稿的media_id + * @return the string + * @throws WxErrorException . + */ + String submit(String mediaId) throws WxErrorException; + + /** + * 发布状态轮询接口 + * 开发者可以尝试通过下面的发布状态轮询接口获知发布情况。 + *
+   * 请求地址:POST https://api.weixin.qq.com/cgi-bin/freepublish/get?access_token=ACCESS_TOKEN
+   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Publish/Get_status.html
+   * 
+ * + * @param publishId 发布任务id + * @return the push status + * @throws WxErrorException . + */ + WxMpFreePublishStatus getPushStatus(String publishId) throws WxErrorException; + + /** + * 删除发布 + * 发布成功之后,随时可以通过该接口删除。此操作不可逆,请谨慎操作。 + *
+   * 请求地址:POST https://api.weixin.qq.com/cgi-bin/freepublish/delete?access_token=ACCESS_TOKEN
+   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Publish/Delete_posts.html
+   * 
+ * + * @param articleId 成功发布时返回的 article_id + * @param index 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章 + * @return the boolean + * @throws WxErrorException . + */ + Boolean deletePush(String articleId, Integer index) throws WxErrorException; + + /** + * 删除发布 - 此条发布的所有内容,不指定文章编号 + * 发布成功之后,随时可以通过该接口删除。此操作不可逆,请谨慎操作。 + *
+   * 请求地址:POST https://api.weixin.qq.com/cgi-bin/freepublish/delete?access_token=ACCESS_TOKEN
+   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Publish/Delete_posts.html
+   * 
+ * + * @param articleId 成功发布时返回的 article_id + * @return the boolean + * @throws WxErrorException . + */ + Boolean deletePushAllArticle(String articleId) throws WxErrorException; + + /** + * 通过 article_id 获取已发布文章 + * 开发者可以通过 article_id 获取已发布的图文信息。 + *
+   * 请求地址:POST https://api.weixin.qq.com/cgi-bin/freepublish/getarticle?access_token=ACCESS_TOKEN
+   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Publish/Get_article_from_id.html
+   * 
+ * + * @param articleId 要获取的草稿的article_id + * @return 已发布文章信息 article from id + * @throws WxErrorException . + */ + WxMpFreePublishInfo getArticleFromId(String articleId) throws WxErrorException; + + /** + * 获取成功发布列表 - 支持选择是否返回:图文消息的具体内容 + * + *
+   * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=ACCESS_TOKEN
+   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Publish/Get_publication_records.html
+   * 
+ * + * @param offset 分页页数,从0开始 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 + * @param count 每页数量 返回素材的数量,取值在1到20之间 + * @param noContent 1 表示不返回 content 字段,0 表示正常返回,默认为 0 + * @return 草稿信息列表 publication records + * @throws WxErrorException . + */ + WxMpFreePublishList getPublicationRecords(int offset, int count, int noContent) throws WxErrorException; + + /** + * 获取成功发布列表 - 默认返回 图文消息的具体内容 + *
+   * 请求地址:POST https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=ACCESS_TOKEN
+   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Publish/Get_publication_records.html
+   * 
+ * + * @param offset 分页页数,从0开始 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 + * @param count 每页数量 返回素材的数量,取值在1到20之间 + * @return . publication records + * @throws WxErrorException the wx error exception + */ + WxMpFreePublishList getPublicationRecords(int offset, int count) throws WxErrorException; + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideBuyerService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideBuyerService.java index 5d3c21407f..9f641635bf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideBuyerService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideBuyerService.java @@ -6,152 +6,154 @@ import java.util.List; /** - * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * The interface Wx mp guide buyer service. + * + * @author 广州跨界-宋心成 created on 2021/5/13/013 */ public interface WxMpGuideBuyerService { - /** - * 为顾问分配客户(批量) - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerrelation?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.addGuideBuyerRelation.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param infos 客户列表 - * @return 客户列表添加结果 - * @throws WxErrorException . - */ - List addGuideBuyerRelation(String account, String openid, List infos) throws WxErrorException; + /** + * 为顾问分配客户(批量) + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerrelation?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.addGuideBuyerRelation.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param infos 客户列表 + * @return 客户列表添加结果 list + * @throws WxErrorException . + */ + List addGuideBuyerRelation(String account, String openid, List infos) throws WxErrorException; - /** - * 为顾问分配客户(单个) - * - * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param userOpenid 用户openid - * @param nickname 用户昵称 - * @throws WxErrorException . - */ - void addGuideBuyerRelation(String account, String openid, String userOpenid, String nickname) throws WxErrorException; + /** + * 为顾问分配客户(单个) + * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param userOpenid 用户openid + * @param nickname 用户昵称 + * @throws WxErrorException . + */ + void addGuideBuyerRelation(String account, String openid, String userOpenid, String nickname) throws WxErrorException; - /** - * 为顾问移除客户(批量) - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidebuyerrelation?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.delGuideBuyerRelation.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param buyerOpenIds 客户openid列表,不超过200 - * @return 客户列表移除结果 - */ - List delGuideBuyerRelation(String account, String openid, List buyerOpenIds) throws WxErrorException; + /** + * 为顾问移除客户(批量) + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidebuyerrelation?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.delGuideBuyerRelation.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param buyerOpenIds 客户openid列表,不超过200 + * @return 客户列表移除结果 list + * @throws WxErrorException the wx error exception + */ + List delGuideBuyerRelation(String account, String openid, List buyerOpenIds) throws WxErrorException; - /** - * 为顾问移除客户(单个) - * - * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param userOpenid 用户openid - * @throws WxErrorException . - */ - void delGuideBuyerRelation(String account, String openid, String userOpenid) throws WxErrorException; + /** + * 为顾问移除客户(单个) + * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param userOpenid 用户openid + * @throws WxErrorException . + */ + void delGuideBuyerRelation(String account, String openid, String userOpenid) throws WxErrorException; - /** - * 获取顾问的客户列表 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelationlist?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.getGuideBuyerRelationList.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param page 分页页数,从0开始,用于组内顾问分页获取 - * @param num 每页数量 - * @return 顾问的客户列表 - * @throws WxErrorException . - */ - WxMpGuideBuyerInfoList getGuideBuyerRelationList(String account, String openid, int page, int num) throws WxErrorException; + /** + * 获取顾问的客户列表 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelationlist?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.getGuideBuyerRelationList.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param page 分页页数,从0开始,用于组内顾问分页获取 + * @param num 每页数量 + * @return 顾问的客户列表 guide buyer relation list + * @throws WxErrorException . + */ + WxMpGuideBuyerInfoList getGuideBuyerRelationList(String account, String openid, int page, int num) throws WxErrorException; - /** - * 为客户更换顾问(批量) - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/rebindguideacctforbuyer?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.rebindGuideAcctForBuyer.html
-   * 
- * - * @param oldAccount 原顾问微信号(old_guide_account和new_guide_account配套使用) - * @param oldOpenid 原顾问openid或者unionid(old_guide_openid和new_guide_openid配套使用) - * @param account 新顾问微信号(new_guide_account和new_guide_openid二选一) - * @param openid 新顾问openid或者unionid(new_guide_account和new_guide_openid二选一) - * @param buyerOpenIds 客户列表,不超过200 - * @return 客户列表换绑结果 - * @throws WxErrorException . - */ - List rebindGuideAcctForBuyer(String oldAccount, String oldOpenid, String account, String openid, List buyerOpenIds) throws WxErrorException; + /** + * 为客户更换顾问(批量) + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/rebindguideacctforbuyer?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.rebindGuideAcctForBuyer.html
+     * 
+ * + * @param oldAccount 原顾问微信号(old_guide_account和new_guide_account配套使用) + * @param oldOpenid 原顾问openid或者unionid(old_guide_openid和new_guide_openid配套使用) + * @param account 新顾问微信号(new_guide_account和new_guide_openid二选一) + * @param openid 新顾问openid或者unionid(new_guide_account和new_guide_openid二选一) + * @param buyerOpenIds 客户列表,不超过200 + * @return 客户列表换绑结果 list + * @throws WxErrorException . + */ + List rebindGuideAcctForBuyer(String oldAccount, String oldOpenid, String account, String openid, List buyerOpenIds) throws WxErrorException; - /** - * 为客户更换顾问(单个) - * - * @param oldAccount 原顾问微信号(old_guide_account和new_guide_account配套使用) - * @param oldOpenid 原顾问openid或者unionid(old_guide_openid和new_guide_openid配套使用) - * @param account 新顾问微信号(new_guide_account和new_guide_openid二选一) - * @param openid 新顾问openid或者unionid(new_guide_account和new_guide_openid二选一) - * @param userOpenid 用户openid - * @throws WxErrorException 。 - */ - void rebindGuideAcctForBuyer(String oldAccount, String oldOpenid, String account, String openid, String userOpenid) throws WxErrorException; + /** + * 为客户更换顾问(单个) + * + * @param oldAccount 原顾问微信号(old_guide_account和new_guide_account配套使用) + * @param oldOpenid 原顾问openid或者unionid(old_guide_openid和new_guide_openid配套使用) + * @param account 新顾问微信号(new_guide_account和new_guide_openid二选一) + * @param openid 新顾问openid或者unionid(new_guide_account和new_guide_openid二选一) + * @param userOpenid 用户openid + * @throws WxErrorException 。 + */ + void rebindGuideAcctForBuyer(String oldAccount, String oldOpenid, String account, String openid, String userOpenid) throws WxErrorException; - /** - * 修改客户昵称 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/updateguidebuyerrelation?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.updateGuideBuyerRelation.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param userOpenid 客户openid - * @param nickname 客户昵称 - * @throws WxErrorException . - */ - void updateGuideBuyerRelation(String account, String openid, String userOpenid, String nickname) throws WxErrorException; + /** + * 修改客户昵称 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/updateguidebuyerrelation?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.updateGuideBuyerRelation.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param userOpenid 客户openid + * @param nickname 客户昵称 + * @throws WxErrorException . + */ + void updateGuideBuyerRelation(String account, String openid, String userOpenid, String nickname) throws WxErrorException; - /** - * 查询客户所属顾问 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelationbybuyer?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.getGuideBuyerRelationByBuyer.html
-   * 
- * - * @param openid 客户openid - * @return 客户顾问关系信息 - * @throws WxErrorException . - */ - WxMpGuideBuyerRelation getGuideBuyerRelationByBuyer(String openid) throws WxErrorException; + /** + * 查询客户所属顾问 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelationbybuyer?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.getGuideBuyerRelationByBuyer.html
+     * 
+ * + * @param openid 客户openid + * @return 客户顾问关系信息 guide buyer relation by buyer + * @throws WxErrorException . + */ + WxMpGuideBuyerRelation getGuideBuyerRelationByBuyer(String openid) throws WxErrorException; - /** - * 查询指定顾问和客户的关系 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelation?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.getGuideBuyerRelation.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param userOpenid 客户openid - * @return 客户信息 - * @throws WxErrorException . - */ - WxMpGuideBuyerInfo getGuideBuyerRelation(String account, String openid, String userOpenid) throws WxErrorException; + /** + * 查询指定顾问和客户的关系 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelation?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/buyer-account/shopping-guide.getGuideBuyerRelation.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param userOpenid 客户openid + * @return 客户信息 guide buyer relation + * @throws WxErrorException . + */ + WxMpGuideBuyerInfo getGuideBuyerRelation(String account, String openid, String userOpenid) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMassedJobService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMassedJobService.java index 2414615807..68cd46e994 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMassedJobService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMassedJobService.java @@ -8,8 +8,9 @@ import java.util.List; /** - * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * The interface Wx mp guide massed job service. + * + * @author 广州跨界-宋心成 created on 2021/5/13/013 */ public interface WxMpGuideMassedJobService { @@ -28,7 +29,7 @@ public interface WxMpGuideMassedJobService { * @param pushTime 任务下发给顾问的时间, 秒级时间戳, 范围为当前时间开始到最近一个月内 * @param userOpenIds 客户openid列表 * @param materialInfos 不超过3个素材 - * @return 群发任务id与客户openid列表 + * @return 群发任务id与客户openid列表 wx mp guide massed * @throws WxErrorException 。 */ WxMpGuideMassed addGuideMassedJob(String account, String openid, String taskName, String taskRemark, Long pushTime, List userOpenIds, List materialInfos) throws WxErrorException; @@ -46,7 +47,7 @@ public interface WxMpGuideMassedJobService { * @param taskStatus 获取指定状态的任务(为空则表示拉取所有状态的任务) * @param offset 偏移位置(从什么位置开始拉取) * @param limit 条数(默认50) - * @return 群发任务列表 + * @return 群发任务列表 guide massed job list * @throws WxErrorException 。 */ List getGuideMassedJobList(String account, String openid, List taskStatus, Integer offset, Integer limit) throws WxErrorException; @@ -60,7 +61,7 @@ public interface WxMpGuideMassedJobService { *
* * @param taskId 任务ID - * @return 群发任务信息 + * @return 群发任务信息 guide massed job * @throws WxErrorException 。 */ WxMpGuideMassedInfo getGuideMassedJob(String taskId) throws WxErrorException; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMaterialService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMaterialService.java index 70fd5f8007..f0b9af12e1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMaterialService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideMaterialService.java @@ -8,146 +8,147 @@ import java.util.List; /** - * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * The interface Wx mp guide material service. + * + * @author 广州跨界-宋心成 created on 2021/5/13/013 */ public interface WxMpGuideMaterialService { - /** - * 添加小程序卡片素材 - *

- * 踩坑记录(2021/5/12):该方法只支持临时素材mediaid - * - *

-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/setguidecardmaterial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.setGuideCardMaterial.html
-   * 
- * - * @param mediaId 图片素材,只能用《素材管理获取media_id》(注意:只支持临时素材的media_id) - * @param type 操作类型,填0,表示服务号素材 - * @param title 小程序卡片名字 - * @param path 小程序路径 - * @param appId 小程序的appid - * @throws WxErrorException . - */ - void setGuideCardMaterial(String mediaId, int type, String title, String path, String appId) throws WxErrorException; + /** + * 添加小程序卡片素材 + *

+ * 踩坑记录(2021/5/12):该方法只支持临时素材mediaid + * + *

+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/setguidecardmaterial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.setGuideCardMaterial.html
+     * 
+ * + * @param mediaId 图片素材,只能用《素材管理获取media_id》(注意:只支持临时素材的media_id) + * @param type 操作类型,填0,表示服务号素材 + * @param title 小程序卡片名字 + * @param path 小程序路径 + * @param appId 小程序的appid + * @throws WxErrorException . + */ + void setGuideCardMaterial(String mediaId, int type, String title, String path, String appId) throws WxErrorException; - /** - * 查询小程序卡片素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidecardmaterial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.getGuideCardMaterial.html
-   * 
- * - * @param type 操作类型,填0,表示服务号素材 - * @return 小程序卡片素材信息列表 - * @throws WxErrorException . - */ - List getGuideCardMaterial(int type) throws WxErrorException; + /** + * 查询小程序卡片素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidecardmaterial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.getGuideCardMaterial.html
+     * 
+ * + * @param type 操作类型,填0,表示服务号素材 + * @return 小程序卡片素材信息列表 guide card material + * @throws WxErrorException . + */ + List getGuideCardMaterial(int type) throws WxErrorException; - /** - * 删除小程序卡片素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidecardmaterial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.delGuideCardMaterial.html
-   * 
- * - * @param type 操作类型,填0,表示服务号素材 - * @param title 小程序卡片名字 - * @param path 小程序路径 - * @param appId 小程序的appid - * @throws WxErrorException . - */ - void delGuideCardMaterial(int type, String title, String path, String appId) throws WxErrorException; + /** + * 删除小程序卡片素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidecardmaterial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.delGuideCardMaterial.html
+     * 
+ * + * @param type 操作类型,填0,表示服务号素材 + * @param title 小程序卡片名字 + * @param path 小程序路径 + * @param appId 小程序的appid + * @throws WxErrorException . + */ + void delGuideCardMaterial(int type, String title, String path, String appId) throws WxErrorException; - /** - * 添加图片素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/setguideimagematerial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.setGuideImageMaterial.html
-   * 
- * - * @param mediaId 图片素材,只能用《素材管理获取media_id》(注意:只支持临时素材的media_id) - * @param type 操作类型,填0,表示服务号素材 - * @throws WxErrorException . - */ - void setGuideImageMaterial(String mediaId, int type) throws WxErrorException; + /** + * 添加图片素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/setguideimagematerial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.setGuideImageMaterial.html
+     * 
+ * + * @param mediaId 图片素材,只能用《素材管理获取media_id》(注意:只支持临时素材的media_id) + * @param type 操作类型,填0,表示服务号素材 + * @throws WxErrorException . + */ + void setGuideImageMaterial(String mediaId, int type) throws WxErrorException; - /** - * 查询图片素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguideimagematerial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.getGuideImageMaterial.html
-   * 
- * - * @param type 操作类型,填0,表示服务号素材 - * @param start 分页查询,起始位置 - * @param num 分页查询,查询个数 - * @return 图片素材列表 - * @throws WxErrorException . - */ - WxMpGuideImgMaterialInfoList getGuideImageMaterial(int type, int start, int num) throws WxErrorException; + /** + * 查询图片素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguideimagematerial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.getGuideImageMaterial.html
+     * 
+ * + * @param type 操作类型,填0,表示服务号素材 + * @param start 分页查询,起始位置 + * @param num 分页查询,查询个数 + * @return 图片素材列表 guide image material + * @throws WxErrorException . + */ + WxMpGuideImgMaterialInfoList getGuideImageMaterial(int type, int start, int num) throws WxErrorException; - /** - * 删除图片素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguideimagematerial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.delGuideImageMaterial.html
-   * 
- * - * @param type 操作类型,填0,表示服务号素材 - * @param picUrl 图片素材内容 - * @throws WxErrorException . - */ - void delGuideImageMaterial(int type, String picUrl) throws WxErrorException; + /** + * 删除图片素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguideimagematerial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.delGuideImageMaterial.html
+     * 
+ * + * @param type 操作类型,填0,表示服务号素材 + * @param picUrl 图片素材内容 + * @throws WxErrorException . + */ + void delGuideImageMaterial(int type, String picUrl) throws WxErrorException; - /** - * 添加文字素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/setguidewordmaterial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.setGuideWordMaterial.html
-   * 
- * - * @param type 操作类型,填0,表示服务号素材 - * @param word 文字素材内容 - * @throws WxErrorException . - */ - void setGuideWordMaterial(int type, String word) throws WxErrorException; + /** + * 添加文字素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/setguidewordmaterial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.setGuideWordMaterial.html
+     * 
+ * + * @param type 操作类型,填0,表示服务号素材 + * @param word 文字素材内容 + * @throws WxErrorException . + */ + void setGuideWordMaterial(int type, String word) throws WxErrorException; - /** - * 查询文字素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidewordmaterial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.getGuideWordMaterial.html
-   * 
- * - * @param type 操作类型,填0,表示服务号素材 - * @param start 分页查询,起始位置 - * @param num 分页查询,查询个数 - * @return 文字素材列表 - * @throws WxErrorException 。 - */ - WxMpGuideWordMaterialInfoList getGuideWordMaterial(int type, int start, int num) throws WxErrorException; + /** + * 查询文字素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidewordmaterial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.getGuideWordMaterial.html
+     * 
+ * + * @param type 操作类型,填0,表示服务号素材 + * @param start 分页查询,起始位置 + * @param num 分页查询,查询个数 + * @return 文字素材列表 guide word material + * @throws WxErrorException 。 + */ + WxMpGuideWordMaterialInfoList getGuideWordMaterial(int type, int start, int num) throws WxErrorException; - /** - * 删除文字素材 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidewordmaterial?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.delGuideWordMaterial.html
-   * 
- * - * @param type 操作类型,填0,表示服务号素材 - * @param word 文字素材内容 - * @throws WxErrorException . - */ - void delGuideWordMaterial(int type, String word) throws WxErrorException; + /** + * 删除文字素材 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidewordmaterial?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/model-account/shopping-guide.delGuideWordMaterial.html
+     * 
+ * + * @param type 操作类型,填0,表示服务号素材 + * @param word 文字素材内容 + * @throws WxErrorException . + */ + void delGuideWordMaterial(int type, String word) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java index e91cfc1dc4..92823c795a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java @@ -8,8 +8,7 @@ /** * 微信导购助手(现在叫对话能力)接口. * - * @author Binary Wang - * @date 2020 -10-06 + * @author Binary Wang created on 2020 -10-06 */ public interface WxMpGuideService { @@ -62,7 +61,7 @@ public interface WxMpGuideService { * * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @return 顾问信息 + * @return 顾问信息 guide * @throws WxErrorException . */ WxMpGuideInfo getGuide(String account, String openid) throws WxErrorException; @@ -91,7 +90,7 @@ public interface WxMpGuideService { * * @param page 分页页数,从0开始 * @param num 每页数量 - * @return 顾问信息列表 + * @return 顾问信息列表 wx mp guide list * @throws WxErrorException . */ WxMpGuideList listGuide(int page, int num) throws WxErrorException; @@ -111,7 +110,7 @@ public interface WxMpGuideService { * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) * @param qrcodeInfo 额外参数,用于事件推送 - * @return 二维码下载链接 + * @return 二维码下载链接 string * @throws WxErrorException . */ String createGuideQrCode(String account, String openid, String qrcodeInfo) throws WxErrorException; @@ -133,7 +132,8 @@ public interface WxMpGuideService { * @param endTime 消息的截止UNIX时间戳,如果不填,默认当前时间。 * @param page 分页页数,从0开始 * @param num 每页数量 - * @return 顾问聊天记录列表 + * @return 顾问聊天记录列表 guide chat record + * @throws WxErrorException the wx error exception */ WxMpGuideMsgList getGuideChatRecord(String account, String openid, String clientOpenid, Long beginTime, Long endTime, int page, int num) throws WxErrorException; @@ -184,6 +184,7 @@ public interface WxMpGuideService { * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) * @return 顾问的 快捷回复,关注顾问自动回复 + * @throws WxErrorException the wx error exception */ WxMpGuideConfig getGuideConfig(String account, String openid) throws WxErrorException; @@ -214,7 +215,7 @@ public interface WxMpGuideService { * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.getGuideAcctConfig.html *
* - * @return 离线自动回复与敏感词 + * @return 离线自动回复与敏感词 guide acct config * @throws WxErrorException . */ WxMpGuideAcctConfig getGuideAcctConfig() throws WxErrorException; @@ -243,7 +244,7 @@ public interface WxMpGuideService { *
* * @param groupName 顾问分组名称 - * @return 顾问分组唯一id + * @return 顾问分组唯一id long * @throws WxErrorException . */ Long newGuideGroup(String groupName) throws WxErrorException; @@ -256,7 +257,7 @@ public interface WxMpGuideService { * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.getGuideGroupList.html *
* - * @return 顾问分组列表 + * @return 顾问分组列表 guide group list * @throws WxErrorException . */ List getGuideGroupList() throws WxErrorException; @@ -272,7 +273,7 @@ public interface WxMpGuideService { * @param groupId 顾问群组id * @param page 分页页数,从0开始,用于组内顾问分页获取 * @param num 每页数量 - * @return 顾问分组内顾问信息 + * @return 顾问分组内顾问信息 group info * @throws WxErrorException . */ WxMpGuideGroupInfoList getGroupInfo(long groupId, int page, int num) throws WxErrorException; @@ -314,7 +315,7 @@ public interface WxMpGuideService { *
* * @param account 顾问微信号 - * @return 顾问分组id列表 + * @return 顾问分组id列表 group by guide * @throws WxErrorException . */ List getGroupByGuide(String account) throws WxErrorException; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideTagService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideTagService.java index b2bb76d787..dadba40452 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideTagService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideTagService.java @@ -9,198 +9,198 @@ /** * 微信导购助手(现在叫对话能力)标签相关接口. * - * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * @author 广州跨界-宋心成 created on 2021/5/13/013 */ public interface WxMpGuideTagService { - /** - * 新建标签类型 - * 最多 4 类标签类型,50 个可选值,所有的标签可选值不能有相等重复的值。 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/newguidetagoption?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.newGuideTagOption.html
-   * 
- * - * @param tagName 标签类型的名字 - * @param values 标签可选值列表,可选值不能为空值,所有的标签可选值不能有相等重复的值 - * @throws WxErrorException 。 - */ - void newGuideTagOption(String tagName, List values) throws WxErrorException; - - /** - * 删除指定标签类型 - * 此操作会更新所有相关客户的标签信息,存在延迟。 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidetagoption?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.delguidetagoption.html
-   * 
- * - * @param tagName 标签类型的名字 - * @throws WxErrorException 。 - */ - void delGuideTagOption(String tagName) throws WxErrorException; - - /** - * 为标签添加可选值 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidetagoption?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.addGuideTagOption.html
-   * 
- * - * @param tagName 标签类型的名字 - * @param values 标签可选值列表,可选值不能为空值,所有的标签可选值不能有相等重复的值 - * @throws WxErrorException 。 - */ - void addGuideTagOption(String tagName, List values) throws WxErrorException; - - /** - * 获取标签和可选值 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidetagoption?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.getGuideTagOption.html
-   * 
- * - * @return 标签信息列表 - */ - List getGuideTagOption() throws WxErrorException; - - /** - * 为客户设置标签(批量) - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidebuyertag?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.addGuideBuyerTag.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param value 标签的可选值,该值必须在标签的可选值集合中 - * @param userOpenIds 客户列表,不超过200 - * @return 客户列表添加结果 - * @throws WxErrorException . - */ - List addGuideBuyerTag(String account, String openid, String value, List userOpenIds) throws WxErrorException; - - /** - * 为客户设置标签(单个) - * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param value 标签的可选值,该值必须在标签的可选值集合中 - * @param userOpenid 用户openid - * @throws WxErrorException . - */ - void addGuideBuyerTag(String account, String openid, String value, String userOpenid) throws WxErrorException; - - /** - * 查询客户标签 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyertag?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.getGuideBuyerTag.html
-   * 
- *

- * 踩坑记录(2021/5/12):这里不只是返回标签值 - * 如果该客户设置了自定义信息也会同样返回在标签数组的末尾 - * 未设置则只返回客户标签列表 - * 为此坑我添加一个参数是否排除客户自定义信息 - * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param userOpenid 用户openid - * @param isExclude 是否排除客户自定义信息 - * @return 标签值列表 - * @throws WxErrorException 。 - */ - List getGuideBuyerTag(String account, String openid, String userOpenid, Boolean isExclude) throws WxErrorException; - - /** - * 根据标签值筛选客户 - * - *

-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/queryguidebuyerbytag?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.queryGuideBuyerByTag.html
-   * 
- *

- * 踩坑记录(2021/5/12): 不传递pushCount参数会返回-1 - * 传递0查询所有 (推荐传递0) - * 当pushCount > 0 该条件查询逻辑有问题 - * 目前发现:传递1可以查询出可发次数为4次的用户,而传递4是查询不出来的。 - *

- * 注意:该查询是查询所有条件均符合的 例如:查询A标签的客户 假如客户标签为A,B两个 将无法查询到该客户 - * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param pushCount 本月还可主动发消息次数 (建议传递0查询) - * @param value 标签值集合,该值必须在标签可选值集合中 - * @return 客户openid集合 - * @throws WxErrorException 。 - */ - List queryGuideBuyerByTag(String account, String openid, Integer pushCount, List value) throws WxErrorException; - - /** - * 删除客户标签(批量) - * - *

-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidebuyertag?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.delGuideBuyerTag.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param value 标签的可选值,该值必须在标签的可选值集合中 - * @param userOpenIds 客户列表,不超过200 - * @return 客户列表处理结果 - * @throws WxErrorException。 - */ - List delGuideBuyerTag(String account, String openid, String value, List userOpenIds) throws WxErrorException; - - /** - * 删除客户标签(单个) - * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param value 标签的可选值,该值必须在标签的可选值集合中 - * @param userOpenid 用户openid - * @throws WxErrorException . - */ - void delGuideBuyerTag(String account, String openid, String value, String userOpenid) throws WxErrorException; - - /** - * 设置自定义客户信息 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerdisplaytag?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.addGuideBuyerDisplayTag.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param userOpenid 用户openid - * @param msgList 自定义客户信息,全量更新,调用时传所有信息 - * @throws WxErrorException . - */ - void addGuideBuyerDisplayTag(String account, String openid, String userOpenid, List msgList) throws WxErrorException; - - /** - * 获取自定义客户信息 - * - *
-   * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerdisplaytag?access_token=ACCESS_TOKEN
-   * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.getGuideBuyerDisplayTag.html
-   * 
- * - * @param account 顾问微信号(guide_account和guide_openid二选一) - * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) - * @param userOpenid 用户openid - * @return 自定义客户信息列表 - * @throws WxErrorException 。 - */ - List getGuideBuyerDisplayTag(String account, String openid, String userOpenid) throws WxErrorException; + /** + * 新建标签类型 + * 最多 4 类标签类型,50 个可选值,所有的标签可选值不能有相等重复的值。 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/newguidetagoption?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.newGuideTagOption.html
+     * 
+ * + * @param tagName 标签类型的名字 + * @param values 标签可选值列表,可选值不能为空值,所有的标签可选值不能有相等重复的值 + * @throws WxErrorException 。 + */ + void newGuideTagOption(String tagName, List values) throws WxErrorException; + + /** + * 删除指定标签类型 + * 此操作会更新所有相关客户的标签信息,存在延迟。 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidetagoption?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.delguidetagoption.html
+     * 
+ * + * @param tagName 标签类型的名字 + * @throws WxErrorException 。 + */ + void delGuideTagOption(String tagName) throws WxErrorException; + + /** + * 为标签添加可选值 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidetagoption?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.addGuideTagOption.html
+     * 
+ * + * @param tagName 标签类型的名字 + * @param values 标签可选值列表,可选值不能为空值,所有的标签可选值不能有相等重复的值 + * @throws WxErrorException 。 + */ + void addGuideTagOption(String tagName, List values) throws WxErrorException; + + /** + * 获取标签和可选值 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidetagoption?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.getGuideTagOption.html
+     * 
+ * + * @return 标签信息列表 guide tag option + * @throws WxErrorException the wx error exception + */ + List getGuideTagOption() throws WxErrorException; + + /** + * 为客户设置标签(批量) + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidebuyertag?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.addGuideBuyerTag.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param value 标签的可选值,该值必须在标签的可选值集合中 + * @param userOpenIds 客户列表,不超过200 + * @return 客户列表添加结果 list + * @throws WxErrorException . + */ + List addGuideBuyerTag(String account, String openid, String value, List userOpenIds) throws WxErrorException; + + /** + * 为客户设置标签(单个) + * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param value 标签的可选值,该值必须在标签的可选值集合中 + * @param userOpenid 用户openid + * @throws WxErrorException . + */ + void addGuideBuyerTag(String account, String openid, String value, String userOpenid) throws WxErrorException; + + /** + * 查询客户标签 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyertag?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.getGuideBuyerTag.html
+     * 
+ *

+ * 踩坑记录(2021/5/12):这里不只是返回标签值 + * 如果该客户设置了自定义信息也会同样返回在标签数组的末尾 + * 未设置则只返回客户标签列表 + * 为此坑我添加一个参数是否排除客户自定义信息 + * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param userOpenid 用户openid + * @param isExclude 是否排除客户自定义信息 + * @return 标签值列表 guide buyer tag + * @throws WxErrorException 。 + */ + List getGuideBuyerTag(String account, String openid, String userOpenid, Boolean isExclude) throws WxErrorException; + + /** + * 根据标签值筛选客户 + * + *

+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/queryguidebuyerbytag?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.queryGuideBuyerByTag.html
+     * 
+ *

+ * 踩坑记录(2021/5/12): 不传递pushCount参数会返回-1 + * 传递0查询所有 (推荐传递0) + * 当pushCount > 0 该条件查询逻辑有问题 + * 目前发现:传递1可以查询出可发次数为4次的用户,而传递4是查询不出来的。 + *

+ * 注意:该查询是查询所有条件均符合的 例如:查询A标签的客户 假如客户标签为A,B两个 将无法查询到该客户 + * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param pushCount 本月还可主动发消息次数 (建议传递0查询) + * @param value 标签值集合,该值必须在标签可选值集合中 + * @return 客户openid集合 list + * @throws WxErrorException 。 + */ + List queryGuideBuyerByTag(String account, String openid, Integer pushCount, List value) throws WxErrorException; + + /** + * 删除客户标签(批量) + * + *

+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguidebuyertag?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.delGuideBuyerTag.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param value 标签的可选值,该值必须在标签的可选值集合中 + * @param userOpenIds 客户列表,不超过200 + * @return 客户列表处理结果 list + * @throws WxErrorException 。 + */ + List delGuideBuyerTag(String account, String openid, String value, List userOpenIds) throws WxErrorException; + + /** + * 删除客户标签(单个) + * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param value 标签的可选值,该值必须在标签的可选值集合中 + * @param userOpenid 用户openid + * @throws WxErrorException . + */ + void delGuideBuyerTag(String account, String openid, String value, String userOpenid) throws WxErrorException; + + /** + * 设置自定义客户信息 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerdisplaytag?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.addGuideBuyerDisplayTag.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param userOpenid 用户openid + * @param msgList 自定义客户信息,全量更新,调用时传所有信息 + * @throws WxErrorException . + */ + void addGuideBuyerDisplayTag(String account, String openid, String userOpenid, List msgList) throws WxErrorException; + + /** + * 获取自定义客户信息 + * + *
+     * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerdisplaytag?access_token=ACCESS_TOKEN
+     * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/tag-account/shopping-guide.getGuideBuyerDisplayTag.html
+     * 
+ * + * @param account 顾问微信号(guide_account和guide_openid二选一) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @param userOpenid 用户openid + * @return 自定义客户信息列表 guide buyer display tag + * @throws WxErrorException 。 + */ + List getGuideBuyerDisplayTag(String account, String openid, String userOpenid) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java index fdce7833f7..e36238c334 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java @@ -22,249 +22,249 @@ * @author Binary Wang */ public interface WxMpKefuService { - /** - *
-   * 发送客服消息
-   * 详情请见: 发送客服消息
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
-   * 
- * - * @param message the message - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean sendKefuMessage(WxMpKefuMessage message) throws WxErrorException; + /** + *
+     * 发送客服消息
+     * 详情请见: 发送客服消息
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
+     * 
+ * + * @param message the message + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean sendKefuMessage(WxMpKefuMessage message) throws WxErrorException; - /** - *
-   * 发送客服消息
-   * 详情请见: 发送客服消息
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
-   * 
- * - * @param message the message - * @return the response - * @throws WxErrorException 异常 - */ - String sendKefuMessageWithResponse(WxMpKefuMessage message) throws WxErrorException; + /** + *
+     * 发送客服消息
+     * 详情请见: 发送客服消息
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
+     * 
+ * + * @param message the message + * @return the response + * @throws WxErrorException 异常 + */ + String sendKefuMessageWithResponse(WxMpKefuMessage message) throws WxErrorException; //*******************客服管理接口***********************// - /** - *
-   * 获取客服基本信息
-   * 详情请见:客服管理
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN
-   * 
- * - * @return the wx mp kf list - * @throws WxErrorException 异常 - */ - WxMpKfList kfList() throws WxErrorException; + /** + *
+     * 获取客服基本信息
+     * 详情请见:客服管理
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN
+     * 
+ * + * @return the wx mp kf list + * @throws WxErrorException 异常 + */ + WxMpKfList kfList() throws WxErrorException; - /** - *
-   * 获取在线客服接待信息
-   * 详情请见:客服管理
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=ACCESS_TOKEN
-   * 
- * - * @return the wx mp kf online list - * @throws WxErrorException 异常 - */ - WxMpKfOnlineList kfOnlineList() throws WxErrorException; + /** + *
+     * 获取在线客服接待信息
+     * 详情请见:客服管理
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=ACCESS_TOKEN
+     * 
+ * + * @return the wx mp kf online list + * @throws WxErrorException 异常 + */ + WxMpKfOnlineList kfOnlineList() throws WxErrorException; - /** - *
-   * 添加客服账号
-   * 详情请见:客服管理
-   * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN
-   * 
- * - * @param request the request - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean kfAccountAdd(WxMpKfAccountRequest request) throws WxErrorException; + /** + *
+     * 添加客服账号
+     * 详情请见:客服管理
+     * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN
+     * 
+ * + * @param request the request + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean kfAccountAdd(WxMpKfAccountRequest request) throws WxErrorException; - /** - *
-   * 设置客服信息(即更新客服信息)
-   * 详情请见:客服管理
-   * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN
-   * 
- * - * @param request the request - * @return the boolean - * @throws WxErrorException the wx error exception - */ - boolean kfAccountUpdate(WxMpKfAccountRequest request) throws WxErrorException; + /** + *
+     * 设置客服信息(即更新客服信息)
+     * 详情请见:客服管理
+     * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN
+     * 
+ * + * @param request the request + * @return the boolean + * @throws WxErrorException the wx error exception + */ + boolean kfAccountUpdate(WxMpKfAccountRequest request) throws WxErrorException; - /** - *
-   * 设置客服信息(即更新客服信息)
-   * 详情请见:客服管理
-   * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/inviteworker?access_token=ACCESS_TOKEN
-   * 
- * - * @param request the request - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException; + /** + *
+     * 设置客服信息(即更新客服信息)
+     * 详情请见:客服管理
+     * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/inviteworker?access_token=ACCESS_TOKEN
+     * 
+ * + * @param request the request + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException; - /** - *
-   * 上传客服头像
-   * 详情请见:客服管理
-   * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
-   * 
- * - * @param kfAccount the kf account - * @param imgFile the img file - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) throws WxErrorException; + /** + *
+     * 上传客服头像
+     * 详情请见:客服管理
+     * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
+     * 
+ * + * @param kfAccount the kf account + * @param imgFile the img file + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) throws WxErrorException; - /** - *
-   * 删除客服账号
-   * 详情请见:客服管理
-   * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
-   * 
- * - * @param kfAccount the kf account - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean kfAccountDel(String kfAccount) throws WxErrorException; + /** + *
+     * 删除客服账号
+     * 详情请见:客服管理
+     * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
+     * 
+ * + * @param kfAccount the kf account + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean kfAccountDel(String kfAccount) throws WxErrorException; //*******************客服会话控制接口***********************// - /** - *
-   * 创建会话
-   * 此接口在客服和用户之间创建一个会话,如果该客服和用户会话已存在,则直接返回0。指定的客服帐号必须已经绑定微信号且在线。
-   * 详情请见:客服会话控制接口
-   * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/create?access_token=ACCESS_TOKEN
-   * 
- * - * @param openid the openid - * @param kfAccount the kf account - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean kfSessionCreate(String openid, String kfAccount) throws WxErrorException; + /** + *
+     * 创建会话
+     * 此接口在客服和用户之间创建一个会话,如果该客服和用户会话已存在,则直接返回0。指定的客服帐号必须已经绑定微信号且在线。
+     * 详情请见:客服会话控制接口
+     * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/create?access_token=ACCESS_TOKEN
+     * 
+ * + * @param openid the openid + * @param kfAccount the kf account + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean kfSessionCreate(String openid, String kfAccount) throws WxErrorException; - /** - *
-   * 关闭会话
-   * 开发者可以使用本接口,关闭一个会话。
-   * 详情请见:客服会话控制接口
-   * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/close?access_token=ACCESS_TOKEN
-   * 
- * - * @param openid the openid - * @param kfAccount the kf account - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean kfSessionClose(String openid, String kfAccount) throws WxErrorException; + /** + *
+     * 关闭会话
+     * 开发者可以使用本接口,关闭一个会话。
+     * 详情请见:客服会话控制接口
+     * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/close?access_token=ACCESS_TOKEN
+     * 
+ * + * @param openid the openid + * @param kfAccount the kf account + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean kfSessionClose(String openid, String kfAccount) throws WxErrorException; - /** - *
-   * 获取客户的会话状态
-   * 此接口获取一个客户的会话,如果不存在,则kf_account为空。
-   * 详情请见:客服会话控制接口
-   * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getsession?access_token=ACCESS_TOKEN&openid=OPENID
-   * 
- * - * @param openid the openid - * @return the wx mp kf session get result - * @throws WxErrorException 异常 - */ - WxMpKfSessionGetResult kfSessionGet(String openid) throws WxErrorException; + /** + *
+     * 获取客户的会话状态
+     * 此接口获取一个客户的会话,如果不存在,则kf_account为空。
+     * 详情请见:客服会话控制接口
+     * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getsession?access_token=ACCESS_TOKEN&openid=OPENID
+     * 
+ * + * @param openid the openid + * @return the wx mp kf session get result + * @throws WxErrorException 异常 + */ + WxMpKfSessionGetResult kfSessionGet(String openid) throws WxErrorException; - /** - *
-   * 获取客服的会话列表
-   * 开发者可以通过本接口获取某个客服正在接待的会话列表。
-   * 详情请见:客服会话控制
-   * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getsessionlist?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
-   * 
- * - * @param kfAccount the kf account - * @return the wx mp kf session list - * @throws WxErrorException 异常 - */ - WxMpKfSessionList kfSessionList(String kfAccount) throws WxErrorException; + /** + *
+     * 获取客服的会话列表
+     * 开发者可以通过本接口获取某个客服正在接待的会话列表。
+     * 详情请见:客服会话控制
+     * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getsessionlist?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
+     * 
+ * + * @param kfAccount the kf account + * @return the wx mp kf session list + * @throws WxErrorException 异常 + */ + WxMpKfSessionList kfSessionList(String kfAccount) throws WxErrorException; - /** - *
-   * 获取未接入会话列表
-   * 开发者可以通过本接口获取当前正在等待队列中的会话列表,此接口最多返回最早进入队列的100个未接入会话。
-   * 详情请见:客服会话控制
-   * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getwaitcase?access_token=ACCESS_TOKEN
-   * 
- * - * @return the wx mp kf session wait case list - * @throws WxErrorException 异常 - */ - WxMpKfSessionWaitCaseList kfSessionGetWaitCase() throws WxErrorException; + /** + *
+     * 获取未接入会话列表
+     * 开发者可以通过本接口获取当前正在等待队列中的会话列表,此接口最多返回最早进入队列的100个未接入会话。
+     * 详情请见:客服会话控制
+     * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getwaitcase?access_token=ACCESS_TOKEN
+     * 
+ * + * @return the wx mp kf session wait case list + * @throws WxErrorException 异常 + */ + WxMpKfSessionWaitCaseList kfSessionGetWaitCase() throws WxErrorException; //*******************获取聊天记录的接口***********************// - /** - *
-   * 获取聊天记录(原始接口)
-   * 此接口返回的聊天记录中,对于图片、语音、视频,分别展示成文本格式的[image]、[voice]、[video]
-   * 详情请见:获取聊天记录
-   * 接口url格式: https://api.weixin.qq.com/customservice/msgrecord/getmsglist?access_token=ACCESS_TOKEN
-   * 
- * - * @param startTime 起始时间 - * @param endTime 结束时间 - * @param msgId 消息id顺序从小到大,从1开始 - * @param number 每次获取条数,最多10000条 - * @return 聊天记录对象 wx mp kf msg list - * @throws WxErrorException 异常 - */ - WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer number) throws WxErrorException; + /** + *
+     * 获取聊天记录(原始接口)
+     * 此接口返回的聊天记录中,对于图片、语音、视频,分别展示成文本格式的[image]、[voice]、[video]
+     * 详情请见:获取聊天记录
+     * 接口url格式: https://api.weixin.qq.com/customservice/msgrecord/getmsglist?access_token=ACCESS_TOKEN
+     * 
+ * + * @param startTime 起始时间 + * @param endTime 结束时间 + * @param msgId 消息id顺序从小到大,从1开始 + * @param number 每次获取条数,最多10000条 + * @return 聊天记录对象 wx mp kf msg list + * @throws WxErrorException 异常 + */ + WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer number) throws WxErrorException; - /** - *
-   * 获取聊天记录(优化接口,返回指定时间段内所有的聊天记录)
-   * 此接口返回的聊天记录中,对于图片、语音、视频,分别展示成文本格式的[image]、[voice]、[video]
-   * 详情请见:获取聊天记录
-   * 接口url格式: https://api.weixin.qq.com/customservice/msgrecord/getmsglist?access_token=ACCESS_TOKEN
-   * 
- * - * @param startTime 起始时间 - * @param endTime 结束时间 - * @return 聊天记录对象 wx mp kf msg list - * @throws WxErrorException 异常 - */ - WxMpKfMsgList kfMsgList(Date startTime, Date endTime) throws WxErrorException; + /** + *
+     * 获取聊天记录(优化接口,返回指定时间段内所有的聊天记录)
+     * 此接口返回的聊天记录中,对于图片、语音、视频,分别展示成文本格式的[image]、[voice]、[video]
+     * 详情请见:获取聊天记录
+     * 接口url格式: https://api.weixin.qq.com/customservice/msgrecord/getmsglist?access_token=ACCESS_TOKEN
+     * 
+ * + * @param startTime 起始时间 + * @param endTime 结束时间 + * @return 聊天记录对象 wx mp kf msg list + * @throws WxErrorException 异常 + */ + WxMpKfMsgList kfMsgList(Date startTime, Date endTime) throws WxErrorException; - /** - *
-   * 客服输入状态
-   * 开发者可通过调用“客服输入状态”接口,返回客服当前输入状态给用户。
-   * 此接口需要客服消息接口权限。
-   * 如果不满足发送客服消息的触发条件,则无法下发输入状态。
-   * 下发输入状态,需要客服之前30秒内跟用户有过消息交互。
-   * 在输入状态中(持续15s),不可重复下发输入态。
-   * 在输入状态中,如果向用户下发消息,会同时取消输入状态。
-   *
-   * 详情请见:客服输入状态
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
-   * 
- * - * @param openid 用户id - * @param command "Typing":对用户下发“正在输入"状态 "CancelTyping":取消对用户的”正在输入"状态 - * @return the boolean - * @throws WxErrorException 异常 - */ - boolean sendKfTypingState(String openid, String command) throws WxErrorException; + /** + *
+     * 客服输入状态
+     * 开发者可通过调用“客服输入状态”接口,返回客服当前输入状态给用户。
+     * 此接口需要客服消息接口权限。
+     * 如果不满足发送客服消息的触发条件,则无法下发输入状态。
+     * 下发输入状态,需要客服之前30秒内跟用户有过消息交互。
+     * 在输入状态中(持续15s),不可重复下发输入态。
+     * 在输入状态中,如果向用户下发消息,会同时取消输入状态。
+     *
+     * 详情请见:客服输入状态
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
+     * 
+ * + * @param openid 用户id + * @param command "Typing":对用户下发“正在输入"状态 "CancelTyping":取消对用户的”正在输入"状态 + * @return the boolean + * @throws WxErrorException 异常 + */ + boolean sendKfTypingState(String openid, String command) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMarketingService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMarketingService.java index c7daa1f991..6d7d4248a3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMarketingService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMarketingService.java @@ -16,56 +16,61 @@ * @author 007 */ public interface WxMpMarketingService { - /** - *
-   * 创建数据源.
-   * 接口调用请求说明
-   * https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39
-   * 
- * - * @param type 用户行为源类型 - * @param name 用户行为源名称 必填 - * @param description 用户行为源描述,字段长度最小 1 字节,长度最大 128 字节 - */ - long addUserActionSets(String type, String name, String description) throws WxErrorException; + /** + *
+     * 创建数据源.
+     * 接口调用请求说明
+     * https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39
+     * 
+ * + * @param type 用户行为源类型 + * @param name 用户行为源名称 必填 + * @param description 用户行为源描述,字段长度最小 1 字节,长度最大 128 字节 + * @return the long + * @throws WxErrorException the wx error exception + */ + long addUserActionSets(String type, String name, String description) throws WxErrorException; - /** - *
-   * 获取数据源信息.
-   * 
- * - * @param userActionSetId 数据源唯一ID - */ - List getUserActionSets(Long userActionSetId) throws WxErrorException; + /** + *
+     * 获取数据源信息.
+     * 
+ * + * @param userActionSetId 数据源唯一ID + * @return the user action sets + * @throws WxErrorException the wx error exception + */ + List getUserActionSets(Long userActionSetId) throws WxErrorException; - /** - * 回传数据. - * 接口调用请求说明 - * https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39 - * - * @param actions 用户行为源类型 - */ - void addUserAction(List actions) throws WxErrorException; + /** + * 回传数据. + * 接口调用请求说明 + * https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39 + * + * @param actions 用户行为源类型 + * @throws WxErrorException the wx error exception + */ + void addUserAction(List actions) throws WxErrorException; - /** - *
-   * 获取朋友圈销售线索数据接口.
-   * 接口调用请求说明
-   *
-   * http请求方式: POST
-   * http://api.weixin.qq.com/cgi-bin/media/voice/translatecontent?access_token=ACCESS_TOKEN&lfrom=xxx<o=xxx
-   *
-   * 
- * - * @param beginDate 开始日期 - * @param endDate 结束日期 - * @param filtering 过滤条件 - * @param page 页码,获取指定页数据 - * @param pageSize 一页获取的数据条数(1-100) - * @return . - * @throws WxErrorException . - * @throws IOException . - */ - WxMpAdLeadResult getAdLeads(Date beginDate, Date endDate, List filtering, Integer page, Integer pageSize) + /** + *
+     * 获取朋友圈销售线索数据接口.
+     * 接口调用请求说明
+     *
+     * http请求方式: POST
+     * http://api.weixin.qq.com/cgi-bin/media/voice/translatecontent?access_token=ACCESS_TOKEN&lfrom=xxx<o=xxx
+     *
+     * 
+ * + * @param beginDate 开始日期 + * @param endDate 结束日期 + * @param filtering 过滤条件 + * @param page 页码,获取指定页数据 + * @param pageSize 一页获取的数据条数(1-100) + * @return . ad leads + * @throws WxErrorException . + * @throws IOException . + */ + WxMpAdLeadResult getAdLeads(Date beginDate, Date endDate, List filtering, Integer page, Integer pageSize) throws WxErrorException, IOException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java index df5d03e0c9..823c2c6343 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java @@ -16,114 +16,130 @@ * @author Binary Wang */ public interface WxMpMassMessageService { - /** - *
-   * 上传群发用的图文消息,上传后才能群发图文消息.
-   *
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
-   * 
- * - * @see #massGroupMessageSend(WxMpMassTagMessage) - * @see #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) - */ - WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException; + /** + *
+     * 上传群发用的图文消息,上传后才能群发图文消息.
+     *
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
+     * 
+ * + * @param news the news + * @return the wx mp mass upload result + * @throws WxErrorException the wx error exception + * @see #massGroupMessageSend(WxMpMassTagMessage) #massGroupMessageSend(WxMpMassTagMessage) + * @see #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) + */ + WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException; - /** - *
-   * 上传群发用的视频,上传后才能群发视频消息.
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
-   * 
- * - * @see #massGroupMessageSend(WxMpMassTagMessage) - * @see #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) - */ - WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException; + /** + *
+     * 上传群发用的视频,上传后才能群发视频消息.
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
+     * 
+ * + * @param video the video + * @return the wx mp mass upload result + * @throws WxErrorException the wx error exception + * @see #massGroupMessageSend(WxMpMassTagMessage) #massGroupMessageSend(WxMpMassTagMessage) + * @see #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) + */ + WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException; - /** - *
-   * 分组群发消息.
-   * 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMpMassNews)} 获得media_id,然后再发送
-   * 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMpMassVideo)} 获得media_id,然后再发送
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
-   * 
- */ - WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException; + /** + *
+     * 分组群发消息.
+     * 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMpMassNews)} 获得media_id,然后再发送
+     * 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMpMassVideo)} 获得media_id,然后再发送
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
+     * 
+ * + * @param message the message + * @return the wx mp mass send result + * @throws WxErrorException the wx error exception + */ + WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException; - /** - *
-   * 按openId列表群发消息.
-   * 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMpMassNews)} 获得media_id,然后再发送
-   * 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMpMassVideo)} 获得media_id,然后再发送
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
-   * 
- */ - WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException; + /** + *
+     * 按openId列表群发消息.
+     * 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMpMassNews)} 获得media_id,然后再发送
+     * 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMpMassVideo)} 获得media_id,然后再发送
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
+     * 
+ * + * @param message the message + * @return the wx mp mass send result + * @throws WxErrorException the wx error exception + */ + WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException; - /** - *
-   * 群发消息预览接口.
-   * 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版。为了满足第三方平台开发者的需求,
-   * 在保留对openID预览能力的同时,增加了对指定微信号发送预览的能力,但该能力每日调用次数有限制(100次),请勿滥用。
-   * 接口调用请求说明
-   *  http请求方式: POST
-   *  https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=ACCESS_TOKEN
-   * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
-   * 
- * - * @return wxMpMassSendResult - */ - WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws WxErrorException; + /** + *
+     * 群发消息预览接口.
+     * 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版。为了满足第三方平台开发者的需求,
+     * 在保留对openID预览能力的同时,增加了对指定微信号发送预览的能力,但该能力每日调用次数有限制(100次),请勿滥用。
+     * 接口调用请求说明
+     *  http请求方式: POST
+     *  https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=ACCESS_TOKEN
+     * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
+     * 
+ * + * @param wxMpMassPreviewMessage the wx mp mass preview message + * @return wxMpMassSendResult wx mp mass send result + * @throws WxErrorException the wx error exception + */ + WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws WxErrorException; - /** - *
-   * 删除群发.
-   * 群发之后,随时可以通过该接口删除群发。
-   * 请注意:
-   * 1、只有已经发送成功的消息才能删除
-   * 2、删除消息是将消息的图文详情页失效,已经收到的用户,还是能在其本地看到消息卡片。
-   * 3、删除群发消息只能删除图文消息和视频消息,其他类型的消息一经发送,无法删除。
-   * 4、如果多次群发发送的是一个图文消息,那么删除其中一次群发,就会删除掉这个图文消息也,导致所有群发都失效
-   * 接口调用请求说明:
-   *  http请求方式: POST
-   *  https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=ACCESS_TOKEN
-   * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1481187827_i0l21
-   * 
- * - * @param msgId 发送出去的消息ID - * @param articleIndex 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章 - */ - void delete(Long msgId, Integer articleIndex) throws WxErrorException; + /** + *
+     * 删除群发.
+     * 群发之后,随时可以通过该接口删除群发。
+     * 请注意:
+     * 1、只有已经发送成功的消息才能删除
+     * 2、删除消息是将消息的图文详情页失效,已经收到的用户,还是能在其本地看到消息卡片。
+     * 3、删除群发消息只能删除图文消息和视频消息,其他类型的消息一经发送,无法删除。
+     * 4、如果多次群发发送的是一个图文消息,那么删除其中一次群发,就会删除掉这个图文消息也,导致所有群发都失效
+     * 接口调用请求说明:
+     *  http请求方式: POST
+     *  https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=ACCESS_TOKEN
+     * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1481187827_i0l21
+     * 
+ * + * @param msgId 发送出去的消息ID + * @param articleIndex 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章 + * @throws WxErrorException the wx error exception + */ + void delete(Long msgId, Integer articleIndex) throws WxErrorException; - /** - * 获取群发速度 - * https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html#9 - */ - WxMpMassSpeedGetResult messageMassSpeedGet() throws WxErrorException; + /** + * 获取群发速度 + * https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html#9 + * + * @return the wx mp mass speed get result + * @throws WxErrorException the wx error exception + */ + WxMpMassSpeedGetResult messageMassSpeedGet() throws WxErrorException; - /** - * 设置群发速度 - * https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html#9 - * - * @param speed 群发速度的级别,是一个0到4的整数,数字越大表示群发速度越慢。 - * speed realspeed - * 0 80w/分钟 - * 1 60w/分钟 - * 2 45w/分钟 - * 3 30w/分钟 - * 4 10w/分钟 - */ - void messageMassSpeedSet(Integer speed) throws WxErrorException; + /** + * 设置群发速度 + * https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html#9 + * + * @param speed 群发速度的级别,是一个0到4的整数,数字越大表示群发速度越慢。 speed realspeed 0 80w/分钟 1 60w/分钟 2 45w/分钟 3 30w/分钟 4 10w/分钟 + * @throws WxErrorException the wx error exception + */ + void messageMassSpeedSet(Integer speed) throws WxErrorException; - /** - * 查询群发消息发送状态【订阅号与服务号认证后均可用】 - * 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 - * - * @param msgId 群发消息后返回的消息id - * @return 消息发送后的状态,SEND_SUCCESS表示发送成功,SENDING表示发送中,SEND_FAIL表示发送失败,DELETE表示已删除 - */ - WxMpMassGetResult messageMassGet(Long msgId) throws WxErrorException; + /** + * 查询群发消息发送状态【订阅号与服务号认证后均可用】 + * 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 + * + * @param msgId 群发消息后返回的消息id + * @return 消息发送后的状态 ,SEND_SUCCESS表示发送成功,SENDING表示发送中,SEND_FAIL表示发送失败,DELETE表示已删除 + * @throws WxErrorException the wx error exception + */ + WxMpMassGetResult messageMassGet(Long msgId) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java index afccd004e0..b3a6fb6a6c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java @@ -26,269 +26,273 @@ * @author Binary Wang */ public interface WxMpMaterialService { - /** - *
-   * 新增临时素材
-   * 公众号经常有需要用到一些临时性的多媒体素材的场景,例如在使用接口特别是发送消息时,对多媒体文件、多媒体消息的获取和调用等操作,是通过media_id来进行的。
-   * 素材管理接口对所有认证的订阅号和服务号开放。通过本接口,公众号可以新增临时素材(即上传临时多媒体文件)。
-   * 请注意:
-   *  1、对于临时素材,每个素材(media_id)会在开发者上传或粉丝发送到微信服务器3天后自动删除(所以用户发送给开发者的素材,若开发者需要,应尽快下载到本地),以节省服务器资源。
-   *  2、media_id是可复用的。
-   *  3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/amr格式
-   *  4、需使用https调用本接口。
-   *  本接口即为原“上传多媒体文件”接口。
-   *  注意事项:
-   *    上传的临时多媒体文件有格式和大小限制,如下:
-   *    图片(image): 2M,支持PNG\JPEG\JPG\GIF格式
-   *    语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式
-   *    视频(video):10MB,支持MP4格式
-   *    缩略图(thumb):64KB,支持JPG格式
-   * 媒体文件在后台保存时间为3天,即3天后media_id失效。
-   * 详情请见: 新增临时素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
-   * 
- * - * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} - * @param file 文件对象 - * @return the wx media upload result - * @throws WxErrorException the wx error exception - * @see #mediaUpload(String, String, InputStream) #mediaUpload(String, String, InputStream) - */ - WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException; + /** + *
+     * 新增临时素材
+     * 公众号经常有需要用到一些临时性的多媒体素材的场景,例如在使用接口特别是发送消息时,对多媒体文件、多媒体消息的获取和调用等操作,是通过media_id来进行的。
+     * 素材管理接口对所有认证的订阅号和服务号开放。通过本接口,公众号可以新增临时素材(即上传临时多媒体文件)。
+     * 请注意:
+     *  1、对于临时素材,每个素材(media_id)会在开发者上传或粉丝发送到微信服务器3天后自动删除(所以用户发送给开发者的素材,若开发者需要,应尽快下载到本地),以节省服务器资源。
+     *  2、media_id是可复用的。
+     *  3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/amr格式
+     *  4、需使用https调用本接口。
+     *  本接口即为原“上传多媒体文件”接口。
+     *  注意事项:
+     *    上传的临时多媒体文件有格式和大小限制,如下:
+     *    图片(image): 2M,支持PNG\JPEG\JPG\GIF格式
+     *    语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式
+     *    视频(video):10MB,支持MP4格式
+     *    缩略图(thumb):64KB,支持JPG格式
+     * 媒体文件在后台保存时间为3天,即3天后media_id失效。
+     * 详情请见: 新增临时素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
+     * 
+ * + * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param file 文件对象 + * @return the wx media upload result + * @throws WxErrorException the wx error exception + * @see #mediaUpload(String, String, InputStream) #mediaUpload(String, String, InputStream)#mediaUpload(String, String, InputStream) + */ + WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException; - /** - *
-   * 新增临时素材
-   * 本接口即为原“上传多媒体文件”接口。
-   *
-   * 详情请见: 新增临时素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
-   * 
- * - * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} - * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} - * @param inputStream 输入流 - * @return the wx media upload result - * @throws WxErrorException the wx error exception - * @see #mediaUpload(java.lang.String, java.io.File) #mediaUpload(java.lang.String, java.io.File) - */ - WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException; + /** + *
+     * 新增临时素材
+     * 本接口即为原“上传多媒体文件”接口。
+     *
+     * 详情请见: 新增临时素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
+     * 
+ * + * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param inputStream 输入流 + * @return the wx media upload result + * @throws WxErrorException the wx error exception + * @see #mediaUpload(java.lang.String, java.io.File) #mediaUpload(java.lang.String, java.io.File)#mediaUpload(java.lang.String, java.io.File) + */ + WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException; - /** - *
-   * 获取临时素材
-   * 公众号可以使用本接口获取临时素材(即下载临时的多媒体文件)。请注意,视频文件不支持https下载,调用该接口需http协议。
-   * 本接口即为原“下载多媒体文件”接口。
-   * 根据微信文档,视频文件下载不了,会返回null
-   * 详情请见: 获取临时素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
-   * 
- * - * @param mediaId 媒体文件Id - * @return 保存到本地的临时文件 file - * @throws WxErrorException the wx error exception - */ - File mediaDownload(String mediaId) throws WxErrorException; + /** + *
+     * 获取临时素材
+     * 公众号可以使用本接口获取临时素材(即下载临时的多媒体文件)。请注意,视频文件不支持https下载,调用该接口需http协议。
+     * 本接口即为原“下载多媒体文件”接口。
+     * 根据微信文档,视频文件下载不了,会返回null
+     * 详情请见: 获取临时素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
+     * 
+ * + * @param mediaId 媒体文件Id + * @return 保存到本地的临时文件 file + * @throws WxErrorException the wx error exception + */ + File mediaDownload(String mediaId) throws WxErrorException; - /** - *
-   * 获取高清语音素材
-   * 公众号可以使用本接口获取从JSSDK的uploadVoice接口上传的临时语音素材,格式为speex,16K采样率。
-   * 该音频比上文的临时素材获取接口(格式为amr,8K采样率)更加清晰,适合用作语音识别等对音质要求较高的业务。
-   * 详情请见: 
-   * 获取高清语音素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
-   * 
- * - * @param mediaId 媒体文件Id - * @return 保存到本地的临时文件 file - * @throws WxErrorException the wx error exception - */ - File jssdkMediaDownload(String mediaId) throws WxErrorException; + /** + *
+     * 获取高清语音素材
+     * 公众号可以使用本接口获取从JSSDK的uploadVoice接口上传的临时语音素材,格式为speex,16K采样率。
+     * 该音频比上文的临时素材获取接口(格式为amr,8K采样率)更加清晰,适合用作语音识别等对音质要求较高的业务。
+     * 详情请见: 
+     * 获取高清语音素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
+     * 
+ * + * @param mediaId 媒体文件Id + * @return 保存到本地的临时文件 file + * @throws WxErrorException the wx error exception + */ + File jssdkMediaDownload(String mediaId) throws WxErrorException; - /** - *
-   * 上传图文消息内的图片获取URL
-   * 请注意,本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式,大小必须在1MB以下。
-   * 详情请见: 新增永久素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
-   * 
- * - * @param file 上传的文件对象 - * @return WxMediaImgUploadResult 返回图片url - * @throws WxErrorException the wx error exception - */ - WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException; + /** + *
+     * 上传图文消息内的图片获取URL
+     * 请注意,本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式,大小必须在1MB以下。
+     * 详情请见: 新增永久素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
+     * 
+ * + * @param file 上传的文件对象 + * @return WxMediaImgUploadResult 返回图片url + * @throws WxErrorException the wx error exception + */ + WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException; - /** - *
-   * 新增非图文永久素材
-   * 通过POST表单来调用接口,表单id为media,包含需要上传的素材内容,有filename、filelength、content-type等信息。请注意:图片素材将进入公众平台官网素材管理模块中的默认分组。
-   * 新增永久视频素材需特别注意:
-   * 在上传视频素材时需要POST另一个表单,id为description,包含素材的描述信息,内容格式为JSON,格式如下:
-   * {   "title":VIDEO_TITLE,   "introduction":INTRODUCTION   }
-   * 详情请见: 新增永久素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE
-   *
-   * 除了3天就会失效的临时素材外,开发者有时需要永久保存一些素材,届时就可以通过本接口新增永久素材。
-   * 永久图片素材新增后,将带有URL返回给开发者,开发者可以在腾讯系域名内使用(腾讯系域名外使用,图片将被屏蔽)。
-   * 请注意:
-   * 1、新增的永久素材也可以在公众平台官网素材管理模块中看到
-   * 2、永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,其他类型为1000
-   * 3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式
-   * 4、调用该接口需https协议
-   * 
- * - * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} - * @param material 上传的素材, 请看{@link WxMpMaterial} - * @return the wx mp material upload result - * @throws WxErrorException the wx error exception - */ - WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException; + /** + *
+     * 新增非图文永久素材
+     * 通过POST表单来调用接口,表单id为media,包含需要上传的素材内容,有filename、filelength、content-type等信息。请注意:图片素材将进入公众平台官网素材管理模块中的默认分组。
+     * 新增永久视频素材需特别注意:
+     * 在上传视频素材时需要POST另一个表单,id为description,包含素材的描述信息,内容格式为JSON,格式如下:
+     * {   "title":VIDEO_TITLE,   "introduction":INTRODUCTION   }
+     * 详情请见: 新增永久素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE
+     *
+     * 除了3天就会失效的临时素材外,开发者有时需要永久保存一些素材,届时就可以通过本接口新增永久素材。
+     * 永久图片素材新增后,将带有URL返回给开发者,开发者可以在腾讯系域名内使用(腾讯系域名外使用,图片将被屏蔽)。
+     * 请注意:
+     * 1、新增的永久素材也可以在公众平台官网素材管理模块中看到
+     * 2、永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,其他类型为1000
+     * 3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式
+     * 4、调用该接口需https协议
+     * 
+ * + * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param material 上传的素材, 请看{@link WxMpMaterial} + * @return the wx mp material upload result + * @throws WxErrorException the wx error exception + */ + WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException; - /** - *
-   * 新增永久图文素材
-   *
-   * 详情请见: 新增永久素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN
-   *
-   * 除了3天就会失效的临时素材外,开发者有时需要永久保存一些素材,届时就可以通过本接口新增永久素材。
-   * 永久图片素材新增后,将带有URL返回给开发者,开发者可以在腾讯系域名内使用(腾讯系域名外使用,图片将被屏蔽)。
-   * 请注意:
-   * 1、新增的永久素材也可以在公众平台官网素材管理模块中看到
-   * 2、永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,其他类型为1000
-   * 3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式
-   * 4、调用该接口需https协议
-   * 
- * - * @param news 上传的图文消息, 请看{@link WxMpMaterialNews} - * @return the wx mp material upload result - * @throws WxErrorException the wx error exception - */ + /** + *
+     * 新增永久图文素材
+     *
+     * 详情请见: 新增永久素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN
+     *
+     * 除了3天就会失效的临时素材外,开发者有时需要永久保存一些素材,届时就可以通过本接口新增永久素材。
+     * 永久图片素材新增后,将带有URL返回给开发者,开发者可以在腾讯系域名内使用(腾讯系域名外使用,图片将被屏蔽)。
+     * 请注意:
+     * 1、新增的永久素材也可以在公众平台官网素材管理模块中看到
+     * 2、永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,其他类型为1000
+     * 3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式
+     * 4、调用该接口需https协议
+     * 
+ * + * @param news 上传的图文消息, 请看{@link WxMpMaterialNews} + * @return the wx mp material upload result + * @throws WxErrorException the wx error exception + * @deprecated 关于永久图文素材相关接口下线的公告 : https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11644831863qFQSh&version=&token=2085564289&lang=zh_CN + */ + @Deprecated WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException; - /** - *
-   * 获取声音或者图片永久素材
-   *
-   * 详情请见: 获取永久素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN
-   * 
- * - * @param mediaId 永久素材的id - * @return the input stream - * @throws WxErrorException the wx error exception - */ - InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException; + /** + *
+     * 获取声音或者图片永久素材
+     *
+     * 详情请见: 获取永久素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN
+     * 
+ * + * @param mediaId 永久素材的id + * @return the input stream + * @throws WxErrorException the wx error exception + */ + InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException; - /** - *
-   * 获取视频永久素材的信息和下载地址
-   *
-   * 详情请见: 获取永久素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN
-   * 
- * - * @param mediaId 永久素材的id - * @return the wx mp material video info result - * @throws WxErrorException the wx error exception - */ - WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId) throws WxErrorException; + /** + *
+     * 获取视频永久素材的信息和下载地址
+     *
+     * 详情请见: 获取永久素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN
+     * 
+ * + * @param mediaId 永久素材的id + * @return the wx mp material video info result + * @throws WxErrorException the wx error exception + */ + WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId) throws WxErrorException; - /** - *
-   * 获取图文永久素材的信息
-   *
-   * 详情请见: 获取永久素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN
-   * 
- * - * @param mediaId 永久素材的id - * @return the wx mp material news - * @throws WxErrorException the wx error exception - */ - WxMpMaterialNews materialNewsInfo(String mediaId) throws WxErrorException; + /** + *
+     * 获取图文永久素材的信息
+     *
+     * 详情请见: 获取永久素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN
+     * 
+ * + * @param mediaId 永久素材的id + * @return the wx mp material news + * @throws WxErrorException the wx error exception + */ + WxMpMaterialNews materialNewsInfo(String mediaId) throws WxErrorException; - /** - *
-   * 修改永久图文素材
-   *
-   * 详情请见: 修改永久图文素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/update_news?access_token=ACCESS_TOKEN
-   * 
- * - * @param wxMpMaterialArticleUpdate 用来更新图文素材的bean, 请看{@link WxMpMaterialArticleUpdate} - * @return the boolean - * @throws WxErrorException the wx error exception - */ + /** + *
+     * 修改永久图文素材
+     *
+     * 详情请见: 修改永久图文素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/update_news?access_token=ACCESS_TOKEN
+     * 
+ * + * @param wxMpMaterialArticleUpdate 用来更新图文素材的bean, 请看{@link WxMpMaterialArticleUpdate} + * @return the boolean + * @throws WxErrorException the wx error exception + * @deprecated 关于永久图文素材相关接口下线的公告 : https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11644831863qFQSh&version=&token=2085564289&lang=zh_CN + */ + @Deprecated boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException; - /** - *
-   * 删除永久素材
-   * 在新增了永久素材后,开发者可以根据本接口来删除不再需要的永久素材,节省空间。
-   * 请注意:
-   *  1、请谨慎操作本接口,因为它可以删除公众号在公众平台官网素材管理模块中新建的图文消息、语音、视频等素材(但需要先通过获取素材列表来获知素材的media_id)
-   *  2、临时素材无法通过本接口删除
-   *  3、调用该接口需https协议
-   * 详情请见: 删除永久素材
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=ACCESS_TOKEN
-   * 
- * - * @param mediaId 永久素材的id - * @return the boolean - * @throws WxErrorException the wx error exception - */ - boolean materialDelete(String mediaId) throws WxErrorException; + /** + *
+     * 删除永久素材
+     * 在新增了永久素材后,开发者可以根据本接口来删除不再需要的永久素材,节省空间。
+     * 请注意:
+     *  1、请谨慎操作本接口,因为它可以删除公众号在公众平台官网素材管理模块中新建的图文消息、语音、视频等素材(但需要先通过获取素材列表来获知素材的media_id)
+     *  2、临时素材无法通过本接口删除
+     *  3、调用该接口需https协议
+     * 详情请见: 删除永久素材
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=ACCESS_TOKEN
+     * 
+ * + * @param mediaId 永久素材的id + * @return the boolean + * @throws WxErrorException the wx error exception + */ + boolean materialDelete(String mediaId) throws WxErrorException; - /** - *
-   * 获取各类素材总数
-   * 开发者可以根据本接口来获取永久素材的列表,需要时也可保存到本地。
-   * 请注意:
-   *  1.永久素材的总数,也会计算公众平台官网素材管理中的素材
-   *  2.图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000
-   *  3.调用该接口需https协议
-   *
-   * 详情请见: 获取素材总数
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token=ACCESS_TOKEN
-   * 
- * - * @return the wx mp material count result - * @throws WxErrorException the wx error exception - */ - WxMpMaterialCountResult materialCount() throws WxErrorException; + /** + *
+     * 获取各类素材总数
+     * 开发者可以根据本接口来获取永久素材的列表,需要时也可保存到本地。
+     * 请注意:
+     *  1.永久素材的总数,也会计算公众平台官网素材管理中的素材
+     *  2.图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000
+     *  3.调用该接口需https协议
+     *
+     * 详情请见: 获取素材总数
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token=ACCESS_TOKEN
+     * 
+ * + * @return the wx mp material count result + * @throws WxErrorException the wx error exception + */ + WxMpMaterialCountResult materialCount() throws WxErrorException; - /** - *
-   * 分页获取图文素材列表
-   *
-   * 详情请见: 获取素材列表
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN
-   * 
- * - * @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回 - * @param count 返回素材的数量,取值在1到20之间 - * @return the wx mp material news batch get result - * @throws WxErrorException the wx error exception - */ - WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException; + /** + *
+     * 分页获取图文素材列表
+     *
+     * 详情请见: 获取素材列表
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN
+     * 
+ * + * @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回 + * @param count 返回素材的数量,取值在1到20之间 + * @return the wx mp material news batch get result + * @throws WxErrorException the wx error exception + */ + WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException; - /** - *
-   * 分页获取其他媒体素材列表
-   *
-   * 详情请见: 获取素材列表
-   * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN
-   * 
- * - * @param type 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} - * @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回 - * @param count 返回素材的数量,取值在1到20之间 - * @return the wx mp material file batch get result - * @throws WxErrorException the wx error exception - */ - WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException; + /** + *
+     * 分页获取其他媒体素材列表
+     *
+     * 详情请见: 获取素材列表
+     * 接口url格式:https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN
+     * 
+ * + * @param type 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} + * @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回 + * @param count 返回素材的数量,取值在1到20之间 + * @return the wx mp material file batch get result + * @throws WxErrorException the wx error exception + */ + WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java index 07572bb500..ea8cab7e50 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java @@ -13,113 +13,112 @@ * * @author YuJian(mgcnrx11 @ gmail.com) * @author yuanqixun - * @version 2017/7/8 - * @date 2018-08-30 + * @version 2017 /7/8 created on 2018-08-30 */ public interface WxMpMemberCardService { - /** - * 得到WxMpService. - * - * @return WxMpService - */ - WxMpService getWxMpService(); + /** + * 得到WxMpService. + * + * @return WxMpService wx mp service + */ + WxMpService getWxMpService(); - /** - * 会员卡创建接口. - * - * @param createJson 会员卡json字符串 - * @return 返回json字符串 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - WxMpCardCreateResult createMemberCard(String createJson) throws WxErrorException; + /** + * 会员卡创建接口. + * + * @param createJson 会员卡json字符串 + * @return 返回json字符串 wx mp card create result + * @throws WxErrorException 接口调用失败抛出的异常 + */ + WxMpCardCreateResult createMemberCard(String createJson) throws WxErrorException; - /** - * 会员卡创建接口 - * - * @param createMessageMessage 会员卡创建对象 - * @return 会员卡信息的结果对象 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - WxMpCardCreateResult createMemberCard(WxMpMemberCardCreateMessage createMessageMessage) throws WxErrorException; + /** + * 会员卡创建接口 + * + * @param createMessageMessage 会员卡创建对象 + * @return 会员卡信息的结果对象 wx mp card create result + * @throws WxErrorException 接口调用失败抛出的异常 + */ + WxMpCardCreateResult createMemberCard(WxMpMemberCardCreateMessage createMessageMessage) throws WxErrorException; - /** - * 会员卡激活接口. - * - * @param activatedMessage 激活所需参数 - * @return 会员卡激活后的json字符串 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage) throws WxErrorException; + /** + * 会员卡激活接口. + * + * @param activatedMessage 激活所需参数 + * @return 会员卡激活后的json字符串 string + * @throws WxErrorException 接口调用失败抛出的异常 + */ + String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage) throws WxErrorException; - /** - * 拉取会员信息接口. - * - * @param cardId 会员卡的CardId,微信分配 - * @param code 领取会员的会员卡Code - * @return 会员信息的结果对象 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException; + /** + * 拉取会员信息接口. + * + * @param cardId 会员卡的CardId,微信分配 + * @param code 领取会员的会员卡Code + * @return 会员信息的结果对象 user info + * @throws WxErrorException 接口调用失败抛出的异常 + */ + WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException; - /** - * 当会员持卡消费后,支持开发者调用该接口更新会员信息. - * 会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。 - * 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。 - * 同时传入add_bonus和bonus时 add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。 - * 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。 - * - * @param updateUserMessage 更新会员信息所需字段消息 - * @return 调用返回的JSON字符串。 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage) throws WxErrorException; + /** + * 当会员持卡消费后,支持开发者调用该接口更新会员信息. + * 会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。 + * 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。 + * 同时传入add_bonus和bonus时 add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。 + * 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。 + * + * @param updateUserMessage 更新会员信息所需字段消息 + * @return 调用返回的JSON字符串 。 + * @throws WxErrorException 接口调用失败抛出的异常 + */ + WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage) throws WxErrorException; - /** - * 设置会员卡激活的字段(会员卡设置:wx_activate=true 时需要). - * - * @param userFormRequest 会员卡激活字段对象 - * @return 会员卡激活后结果对象 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - MemberCardActivateUserFormResult setActivateUserForm(MemberCardActivateUserFormRequest userFormRequest) throws WxErrorException; + /** + * 设置会员卡激活的字段(会员卡设置:wx_activate=true 时需要). + * + * @param userFormRequest 会员卡激活字段对象 + * @return 会员卡激活后结果对象 activate user form + * @throws WxErrorException 接口调用失败抛出的异常 + */ + MemberCardActivateUserFormResult setActivateUserForm(MemberCardActivateUserFormRequest userFormRequest) throws WxErrorException; - /** - * 获取会员卡开卡插件参数(跳转型开卡组件需要参数). - * - * @param cardId 会员卡的CardId,微信分配 - * @param outStr 会员卡设置商户的渠道 - * @return 会员卡开卡插件参数结果对象 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException; + /** + * 获取会员卡开卡插件参数(跳转型开卡组件需要参数). + * + * @param cardId 会员卡的CardId,微信分配 + * @param outStr 会员卡设置商户的渠道 + * @return 会员卡开卡插件参数结果对象 activate plugin param + * @throws WxErrorException 接口调用失败抛出的异常 + */ + ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException; - /** - * 获取开卡组件链接接口 - * - * @param cardId 会员卡的CardId,微信分配 - * @param outStr 会员卡设置商户的渠道 - * @return 会员卡开卡插件参数结果对象 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - String getActivatePluginUrl(String cardId, String outStr) throws WxErrorException; + /** + * 获取开卡组件链接接口 + * + * @param cardId 会员卡的CardId,微信分配 + * @param outStr 会员卡设置商户的渠道 + * @return 会员卡开卡插件参数结果对象 activate plugin url + * @throws WxErrorException 接口调用失败抛出的异常 + */ + String getActivatePluginUrl(String cardId, String outStr) throws WxErrorException; - /** - * 更新会员卡信息. - * - * @param memberCardUpdateRequest 会员卡更新对象 - * @return 会员卡更新后结果对象 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - CardUpdateResult updateCardInfo(MemberCardUpdateRequest memberCardUpdateRequest) throws WxErrorException; + /** + * 更新会员卡信息. + * + * @param memberCardUpdateRequest 会员卡更新对象 + * @return 会员卡更新后结果对象 card update result + * @throws WxErrorException 接口调用失败抛出的异常 + */ + CardUpdateResult updateCardInfo(MemberCardUpdateRequest memberCardUpdateRequest) throws WxErrorException; - /** - * 解析跳转型开卡字段用户提交的资料. - * 开发者在URL上截取ticket后须先进行urldecode - * - * @param activateTicket 用户提交的资料 - * @return 开卡字段的会员信息对象 - * @throws WxErrorException 接口调用失败抛出的异常 - */ - WxMpMemberCardActivateTempInfoResult getActivateTempInfo(String activateTicket) throws WxErrorException; + /** + * 解析跳转型开卡字段用户提交的资料. + * 开发者在URL上截取ticket后须先进行urldecode + * + * @param activateTicket 用户提交的资料 + * @return 开卡字段的会员信息对象 activate temp info + * @throws WxErrorException 接口调用失败抛出的异常 + */ + WxMpMemberCardActivateTempInfoResult getActivateTempInfo(String activateTicket) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMenuService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMenuService.java index e7cef4ebb3..3e78893005 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMenuService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMenuService.java @@ -11,80 +11,95 @@ * @author Binary Wang */ public interface WxMpMenuService { - /** - *
-   * 自定义菜单创建接口
-   * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013&token=&lang=zh_CN
-   * 如果要创建个性化菜单,请设置matchrule属性
-   * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN
-   * 
- * - * @return 如果是个性化菜单,则返回menuid,否则返回null - */ - String menuCreate(WxMenu menu) throws WxErrorException; + /** + *
+     * 自定义菜单创建接口
+     * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013&token=&lang=zh_CN
+     * 如果要创建个性化菜单,请设置matchrule属性
+     * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN
+     * 
+ * + * @param menu the menu + * @return 如果是个性化菜单 ,则返回menuid,否则返回null + * @throws WxErrorException the wx error exception + */ + String menuCreate(WxMenu menu) throws WxErrorException; - /** - *
-   * 自定义菜单创建接口
-   * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013&token=&lang=zh_CN
-   * 如果要创建个性化菜单,请设置matchrule属性
-   * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN
-   * 
- * - * @return 如果是个性化菜单,则返回menuid,否则返回null - */ - String menuCreate(String json) throws WxErrorException; + /** + *
+     * 自定义菜单创建接口
+     * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013&token=&lang=zh_CN
+     * 如果要创建个性化菜单,请设置matchrule属性
+     * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN
+     * 
+ * + * @param json the json + * @return 如果是个性化菜单 ,则返回menuid,否则返回null + * @throws WxErrorException the wx error exception + */ + String menuCreate(String json) throws WxErrorException; - /** - *
-   * 自定义菜单删除接口
-   * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141015&token=&lang=zh_CN
-   * 
- */ - void menuDelete() throws WxErrorException; + /** + *
+     * 自定义菜单删除接口
+     * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141015&token=&lang=zh_CN
+     * 
+ * + * @throws WxErrorException the wx error exception + */ + void menuDelete() throws WxErrorException; - /** - *
-   * 删除个性化菜单接口
-   * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN
-   * 
- * - * @param menuId 个性化菜单的menuid - */ - void menuDelete(String menuId) throws WxErrorException; + /** + *
+     * 删除个性化菜单接口
+     * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN
+     * 
+ * + * @param menuId 个性化菜单的menuid + * @throws WxErrorException the wx error exception + */ + void menuDelete(String menuId) throws WxErrorException; - /** - *
-   * 自定义菜单查询接口
-   * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141014&token=&lang=zh_CN
-   * 
- */ - WxMpMenu menuGet() throws WxErrorException; + /** + *
+     * 自定义菜单查询接口
+     * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141014&token=&lang=zh_CN
+     * 
+ * + * @return the wx mp menu + * @throws WxErrorException the wx error exception + */ + WxMpMenu menuGet() throws WxErrorException; - /** - *
-   * 测试个性化菜单匹配结果
-   * 详情请见: http://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html
-   * 
- * - * @param userid 可以是粉丝的OpenID,也可以是粉丝的微信号。 - */ - WxMenu menuTryMatch(String userid) throws WxErrorException; + /** + *
+     * 测试个性化菜单匹配结果
+     * 详情请见: http://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html
+     * 
+ * + * @param userid 可以是粉丝的OpenID,也可以是粉丝的微信号。 + * @return the wx menu + * @throws WxErrorException the wx error exception + */ + WxMenu menuTryMatch(String userid) throws WxErrorException; - /** - *
-   * 获取自定义菜单配置接口
-   * 本接口将会提供公众号当前使用的自定义菜单的配置,如果公众号是通过API调用设置的菜单,则返回菜单的开发配置,而如果公众号是在公众平台官网通过网站功能发布菜单,则本接口返回运营者设置的菜单配置。
-   * 请注意:
-   * 1、第三方平台开发者可以通过本接口,在旗下公众号将业务授权给你后,立即通过本接口检测公众号的自定义菜单配置,并通过接口再次给公众号设置好自动回复规则,以提升公众号运营者的业务体验。
-   * 2、本接口与自定义菜单查询接口的不同之处在于,本接口无论公众号的接口是如何设置的,都能查询到接口,而自定义菜单查询接口则仅能查询到使用API设置的菜单配置。
-   * 3、认证/未认证的服务号/订阅号,以及接口测试号,均拥有该接口权限。
-   * 4、从第三方平台的公众号登录授权机制上来说,该接口从属于消息与菜单权限集。
-   * 5、本接口中返回的图片/语音/视频为临时素材(临时素材每次获取都不同,3天内有效,通过素材管理-获取临时素材接口来获取这些素材),本接口返回的图文消息为永久素材素材(通过素材管理-获取永久素材接口来获取这些素材)。
-   *  接口调用请求说明:
-   * http请求方式: GET(请使用https协议)
-   * https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=ACCESS_TOKEN
-   * 
- */ - WxMpGetSelfMenuInfoResult getSelfMenuInfo() throws WxErrorException; + /** + *
+     * 获取自定义菜单配置接口
+     * 本接口将会提供公众号当前使用的自定义菜单的配置,如果公众号是通过API调用设置的菜单,则返回菜单的开发配置,而如果公众号是在公众平台官网通过网站功能发布菜单,则本接口返回运营者设置的菜单配置。
+     * 请注意:
+     * 1、第三方平台开发者可以通过本接口,在旗下公众号将业务授权给你后,立即通过本接口检测公众号的自定义菜单配置,并通过接口再次给公众号设置好自动回复规则,以提升公众号运营者的业务体验。
+     * 2、本接口与自定义菜单查询接口的不同之处在于,本接口无论公众号的接口是如何设置的,都能查询到接口,而自定义菜单查询接口则仅能查询到使用API设置的菜单配置。
+     * 3、认证/未认证的服务号/订阅号,以及接口测试号,均拥有该接口权限。
+     * 4、从第三方平台的公众号登录授权机制上来说,该接口从属于消息与菜单权限集。
+     * 5、本接口中返回的图片/语音/视频为临时素材(临时素材每次获取都不同,3天内有效,通过素材管理-获取临时素材接口来获取这些素材),本接口返回的图文消息为永久素材素材(通过素材管理-获取永久素材接口来获取这些素材)。
+     *  接口调用请求说明:
+     * http请求方式: GET(请使用https协议)
+     * https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=ACCESS_TOKEN
+     * 
+ * + * @return the self menu info + * @throws WxErrorException the wx error exception + */ + WxMpGetSelfMenuInfoResult getSelfMenuInfo() throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java index 795c848b3a..088ef0d6e5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java @@ -13,113 +13,113 @@ * 73100: 开票平台错误 *

* 流程文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Vendor_and_Invoicing_Platform_Mode_Instruction.html - * 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Vendor_API_List.html + * 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Vendor_API_List.html * * @author Mario Luo */ public interface WxMpMerchantInvoiceService { - /** - * 获取开票授权页链接 - * - * @param params the params - * @return the auth page url - * @throws WxErrorException the wx error exception - */ - InvoiceAuthPageResult getAuthPageUrl(InvoiceAuthPageRequest params) throws WxErrorException; + /** + * 获取开票授权页链接 + * + * @param params the params + * @return the auth page url + * @throws WxErrorException the wx error exception + */ + InvoiceAuthPageResult getAuthPageUrl(InvoiceAuthPageRequest params) throws WxErrorException; - /** - * 获得用户授权数据 - * - * @param params the params - * @return the auth data - * @throws WxErrorException the wx error exception - */ - InvoiceAuthDataResult getAuthData(InvoiceAuthDataRequest params) throws WxErrorException; + /** + * 获得用户授权数据 + * + * @param params the params + * @return the auth data + * @throws WxErrorException the wx error exception + */ + InvoiceAuthDataResult getAuthData(InvoiceAuthDataRequest params) throws WxErrorException; - /** - * 拒绝开票 - *

- * 场景: 用户授权填写数据无效 - * 结果: 用户会收到一条开票失败提示 - * - * @param params the params - * @throws WxErrorException the wx error exception - */ - void rejectInvoice(InvoiceRejectRequest params) throws WxErrorException; + /** + * 拒绝开票 + *

+ * 场景: 用户授权填写数据无效 + * 结果: 用户会收到一条开票失败提示 + * + * @param params the params + * @throws WxErrorException the wx error exception + */ + void rejectInvoice(InvoiceRejectRequest params) throws WxErrorException; - /** - * 开具电子发票 - * - * @param params the params - * @throws WxErrorException the wx error exception - */ - void makeOutInvoice(MakeOutInvoiceRequest params) throws WxErrorException; + /** + * 开具电子发票 + * + * @param params the params + * @throws WxErrorException the wx error exception + */ + void makeOutInvoice(MakeOutInvoiceRequest params) throws WxErrorException; - /** - * 发票冲红 - * - * @param params the params - * @throws WxErrorException the wx error exception - */ - void clearOutInvoice(ClearOutInvoiceRequest params) throws WxErrorException; + /** + * 发票冲红 + * + * @param params the params + * @throws WxErrorException the wx error exception + */ + void clearOutInvoice(ClearOutInvoiceRequest params) throws WxErrorException; - /** - * 查询发票信息 - * - * @param fpqqlsh 发票请求流水号 - * @param nsrsbh 纳税人识别号 - * @return the invoice result - * @throws WxErrorException the wx error exception - */ - InvoiceResult queryInvoiceInfo(String fpqqlsh, String nsrsbh) throws WxErrorException; + /** + * 查询发票信息 + * + * @param fpqqlsh 发票请求流水号 + * @param nsrsbh 纳税人识别号 + * @return the invoice result + * @throws WxErrorException the wx error exception + */ + InvoiceResult queryInvoiceInfo(String fpqqlsh, String nsrsbh) throws WxErrorException; - /** - * 设置商户联系方式, 获取授权链接前需要设置商户联系信息 - * - * @param contact the contact - * @throws WxErrorException the wx error exception - */ - void setMerchantContactInfo(MerchantContactInfo contact) throws WxErrorException; + /** + * 设置商户联系方式, 获取授权链接前需要设置商户联系信息 + * + * @param contact the contact + * @throws WxErrorException the wx error exception + */ + void setMerchantContactInfo(MerchantContactInfo contact) throws WxErrorException; - /** - * 获取商户联系方式 - * - * @return the merchant contact info - * @throws WxErrorException the wx error exception - */ - MerchantContactInfo getMerchantContactInfo() throws WxErrorException; + /** + * 获取商户联系方式 + * + * @return the merchant contact info + * @throws WxErrorException the wx error exception + */ + MerchantContactInfo getMerchantContactInfo() throws WxErrorException; - /** - * 配置授权页面字段 - * - * @param authPageSetting the auth page setting - * @throws WxErrorException the wx error exception - */ - void setAuthPageSetting(InvoiceAuthPageSetting authPageSetting) throws WxErrorException; + /** + * 配置授权页面字段 + * + * @param authPageSetting the auth page setting + * @throws WxErrorException the wx error exception + */ + void setAuthPageSetting(InvoiceAuthPageSetting authPageSetting) throws WxErrorException; - /** - * 获取授权页面配置 - * - * @return the auth page setting - * @throws WxErrorException the wx error exception - */ - InvoiceAuthPageSetting getAuthPageSetting() throws WxErrorException; + /** + * 获取授权页面配置 + * + * @return the auth page setting + * @throws WxErrorException the wx error exception + */ + InvoiceAuthPageSetting getAuthPageSetting() throws WxErrorException; - /** - * 设置商户开票平台信息 - * - * @param merchantInvoicePlatformInfo the merchant invoice platform info - * @throws WxErrorException the wx error exception - */ - void setMerchantInvoicePlatform(MerchantInvoicePlatformInfo merchantInvoicePlatformInfo) throws WxErrorException; + /** + * 设置商户开票平台信息 + * + * @param merchantInvoicePlatformInfo the merchant invoice platform info + * @throws WxErrorException the wx error exception + */ + void setMerchantInvoicePlatform(MerchantInvoicePlatformInfo merchantInvoicePlatformInfo) throws WxErrorException; - /** - * 获取商户开票平台信息 - * - * @param merchantInvoicePlatformInfo the merchant invoice platform info - * @return the merchant invoice platform - * @throws WxErrorException the wx error exception - */ - MerchantInvoicePlatformInfo getMerchantInvoicePlatform(MerchantInvoicePlatformInfo merchantInvoicePlatformInfo) throws WxErrorException; + /** + * 获取商户开票平台信息 + * + * @param merchantInvoicePlatformInfo the merchant invoice platform info + * @return the merchant invoice platform + * @throws WxErrorException the wx error exception + */ + MerchantInvoicePlatformInfo getMerchantInvoicePlatform(MerchantInvoicePlatformInfo merchantInvoicePlatformInfo) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageHandler.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageHandler.java index 0c6912c38d..6fc95bc0b7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageHandler.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageHandler.java @@ -14,17 +14,17 @@ */ public interface WxMpMessageHandler { - /** - * 处理微信推送消息. - * - * @param wxMessage 微信推送消息 - * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 - * @param wxMpService 服务类 - * @param sessionManager session管理器 - * @return xml格式的消息,如果在异步规则里处理的话,可以返回null - * @throws WxErrorException 异常 - */ - WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + /** + * 处理微信推送消息. + * + * @param wxMessage 微信推送消息 + * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 + * @param wxMpService 服务类 + * @param sessionManager session管理器 + * @return xml格式的消息 ,如果在异步规则里处理的话,可以返回null + * @throws WxErrorException 异常 + */ + WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageInterceptor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageInterceptor.java index f377b036d1..bc3654039c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageInterceptor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageInterceptor.java @@ -13,16 +13,17 @@ */ public interface WxMpMessageInterceptor { - /** - * 拦截微信消息 - * - * @param wxMessage - * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 - * @param wxMpService - * @param sessionManager - * @return true代表OK,false代表不OK - */ - boolean intercept(WxMpXmlMessage wxMessage, + /** + * 拦截微信消息 + * + * @param wxMessage the wx message + * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 + * @param wxMpService the wx mp service + * @param sessionManager the session manager + * @return true代表OK ,false代表不OK + * @throws WxErrorException the wx error exception + */ + boolean intercept(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageMatcher.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageMatcher.java index fd522c7730..0503675bbc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageMatcher.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageMatcher.java @@ -7,11 +7,12 @@ */ public interface WxMpMessageMatcher { - /** - * 消息是否匹配某种模式 - * - * @param message - */ - boolean match(WxMpXmlMessage message); + /** + * 消息是否匹配某种模式 + * + * @param message the message + * @return the boolean + */ + boolean match(WxMpXmlMessage message); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java index 263305c0d0..070e952c0f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java @@ -5,7 +5,7 @@ import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; -import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker; +import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateCheckerSingleton; import me.chanjar.weixin.common.session.InternalSession; import me.chanjar.weixin.common.session.InternalSessionManager; import me.chanjar.weixin.common.session.StandardSessionManager; @@ -13,9 +13,8 @@ import me.chanjar.weixin.common.util.LogExceptionHandler; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder; import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.HashMap; @@ -67,40 +66,69 @@ public class WxMpMessageRouter { private WxErrorExceptionHandler exceptionHandler; + /** + * Instantiates a new Wx mp message router. + * + * @param wxMpService the wx mp service + */ public WxMpMessageRouter(WxMpService wxMpService) { this.wxMpService = wxMpService; ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxMpMessageRouter-pool-%d").build(); this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); - this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); this.sessionManager = new StandardSessionManager(); this.exceptionHandler = new LogExceptionHandler(); } /** * 使用自定义的 {@link ExecutorService}. + * + * @param wxMpService the wx mp service + * @param executorService the executor service */ public WxMpMessageRouter(WxMpService wxMpService, ExecutorService executorService) { this.wxMpService = wxMpService; this.executorService = executorService; - this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker(); + this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); this.sessionManager = new StandardSessionManager(); this.exceptionHandler = new LogExceptionHandler(); } /** - * 如果使用默认的 {@link ExecutorService},则系统退出前,应该调用该方法. + * 系统退出前,应该调用该方法 */ public void shutDownExecutorService() { this.executorService.shutdown(); } + /** + * 系统退出前,应该调用该方法,增加了超时时间检测 + * + * @param second the second + */ + public void shutDownExecutorService(Integer second) { + this.executorService.shutdown(); + try { + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { + this.executorService.shutdownNow(); + if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { + log.error("线程池未关闭!"); + } + } + } catch (InterruptedException ie) { + this.executorService.shutdownNow(); + Thread.currentThread().interrupt(); + } + } /** *

    * 设置自定义的 {@link ExecutorService}
    * 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100)
    * 
+ * + * @param executorService the executor service */ public void setExecutorService(ExecutorService executorService) { this.executorService = executorService; @@ -111,6 +139,8 @@ public void setExecutorService(ExecutorService executorService) { * 设置自定义的 {@link me.chanjar.weixin.common.api.WxMessageDuplicateChecker} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker} *
+ * + * @param messageDuplicateChecker the message duplicate checker */ public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicateChecker) { this.messageDuplicateChecker = messageDuplicateChecker; @@ -121,6 +151,8 @@ public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicat * 设置自定义的{@link me.chanjar.weixin.common.session.WxSessionManager} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.session.StandardSessionManager} *
+ * + * @param sessionManager the session manager */ public void setSessionManager(WxSessionManager sessionManager) { this.sessionManager = sessionManager; @@ -131,17 +163,26 @@ public void setSessionManager(WxSessionManager sessionManager) { * 设置自定义的{@link me.chanjar.weixin.common.api.WxErrorExceptionHandler} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.util.LogExceptionHandler} *
+ * + * @param exceptionHandler the exception handler */ public void setExceptionHandler(WxErrorExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } + /** + * Gets rules. + * + * @return the rules + */ List getRules() { return this.rules; } /** * 开始一个新的Route规则. + * + * @return the wx mp message router rule */ public WxMpMessageRouterRule rule() { return new WxMpMessageRouterRule(this); @@ -149,6 +190,10 @@ public WxMpMessageRouterRule rule() { /** * 处理微信消息. + * + * @param wxMessage the wx message + * @param context the context + * @return the wx mp xml out message */ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map context) { return route(wxMessage, context, null); @@ -156,18 +201,31 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map context) { + public WxMpXmlOutMessage route(final String appid, final WxMpXmlMessage wxMessage, + final Map context) { return route(wxMessage, context, this.wxMpService.switchoverTo(appid)); } /** * 处理微信消息. + * + * @param wxMessage the wx message + * @param context the context + * @param wxMpService the wx mp service + * @return the wx mp xml out message */ - public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map context, WxMpService wxMpService) { + public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map context, + WxMpService wxMpService) { if (wxMpService == null) { wxMpService = this.wxMpService; } + final WxMpService mpService = wxMpService; if (isMsgDuplicated(wxMessage)) { // 如果是重复消息,那么就不做处理 @@ -191,12 +249,19 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map> futures = new ArrayList<>(); + for (final WxMpMessageRouterRule rule : matchRules) { // 返回最后一个非异步的rule的执行结果 if (rule.isAsync()) { + //获取当前线程使用的实际appId。兼容只有一个appId,且未显式设置当前使用的appId的情况 + String appId = mpService.getWxMpConfigStorage().getAppId(); futures.add( this.executorService.submit(() -> { - rule.service(wxMessage, context, mpService, WxMpMessageRouter.this.sessionManager, WxMpMessageRouter.this.exceptionHandler); + //传入父线程的appId + mpService.switchoverTo(appId); + rule.service(wxMessage, context, mpService, WxMpMessageRouter.this.sessionManager, + WxMpMessageRouter.this.exceptionHandler); + WxMpConfigStorageHolder.remove(); }) ); } else { @@ -229,10 +294,23 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map(2)); } + /** + * Route wx mp xml out message. + * + * @param appid the appid + * @param wxMessage the wx message + * @return the wx mp xml out message + */ public WxMpXmlOutMessage route(String appid, final WxMpXmlMessage wxMessage) { return this.route(appid, wxMessage, new HashMap<>(2)); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java index a742c196c9..79a4ff1a5e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java @@ -10,6 +10,9 @@ import java.util.*; import java.util.regex.Pattern; +/** + * The type Wx mp message router rule. + */ public class WxMpMessageRouterRule { private final WxMpMessageRouter routerBuilder; @@ -38,93 +41,132 @@ public class WxMpMessageRouterRule { private List interceptors = new ArrayList<>(); - public WxMpMessageRouterRule(WxMpMessageRouter routerBuilder) { + /** + * Instantiates a new Wx mp message router rule. + * + * @param routerBuilder the router builder + */ + public WxMpMessageRouterRule(WxMpMessageRouter routerBuilder) { this.routerBuilder = routerBuilder; } - /** - * 设置是否异步执行,默认是true - */ - public WxMpMessageRouterRule async(boolean async) { + /** + * 设置是否异步执行,默认是true + * + * @param async the async + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule async(boolean async) { this.async = async; return this; } - /** - * 如果msgType等于某值 - */ - public WxMpMessageRouterRule msgType(String msgType) { + /** + * 如果msgType等于某值 + * + * @param msgType the msg type + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule msgType(String msgType) { this.msgType = msgType; return this; } - /** - * 如果event等于某值 - */ - public WxMpMessageRouterRule event(String event) { + /** + * 如果event等于某值 + * + * @param event the event + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule event(String event) { this.event = event; return this; } - /** - * 如果eventKey等于某值 - */ - public WxMpMessageRouterRule eventKey(String eventKey) { + /** + * 如果eventKey等于某值 + * + * @param eventKey the event key + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule eventKey(String eventKey) { this.eventKey = eventKey; return this; } - /** - * 如果eventKey匹配该正则表达式 - */ - public WxMpMessageRouterRule eventKeyRegex(String regex) { + /** + * 如果eventKey匹配该正则表达式 + * + * @param regex the regex + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule eventKeyRegex(String regex) { this.eventKeyRegex = regex; return this; } - /** - * 如果content等于某值 - */ - public WxMpMessageRouterRule content(String content) { + /** + * 如果content等于某值 + * + * @param content the content + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule content(String content) { this.content = content; return this; } - /** - * 如果content匹配该正则表达式 - */ - public WxMpMessageRouterRule rContent(String regex) { + /** + * 如果content匹配该正则表达式 + * + * @param regex the regex + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule rContent(String regex) { this.rContent = regex; return this; } - /** - * 如果fromUser等于某值 - */ - public WxMpMessageRouterRule fromUser(String fromUser) { + /** + * 如果fromUser等于某值 + * + * @param fromUser the from user + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule fromUser(String fromUser) { this.fromUser = fromUser; return this; } - /** - * 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候 - */ - public WxMpMessageRouterRule matcher(WxMpMessageMatcher matcher) { + /** + * 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候 + * + * @param matcher the matcher + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule matcher(WxMpMessageMatcher matcher) { this.matcher = matcher; return this; } - /** - * 设置微信消息拦截器 - */ - public WxMpMessageRouterRule interceptor(WxMpMessageInterceptor interceptor) { + /** + * 设置微信消息拦截器 + * + * @param interceptor the interceptor + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule interceptor(WxMpMessageInterceptor interceptor) { return interceptor(interceptor, (WxMpMessageInterceptor[]) null); } - /** - * 设置微信消息拦截器 - */ - public WxMpMessageRouterRule interceptor(WxMpMessageInterceptor interceptor, WxMpMessageInterceptor... otherInterceptors) { + /** + * 设置微信消息拦截器 + * + * @param interceptor the interceptor + * @param otherInterceptors the other interceptors + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule interceptor(WxMpMessageInterceptor interceptor, WxMpMessageInterceptor... otherInterceptors) { this.interceptors.add(interceptor); if (otherInterceptors != null && otherInterceptors.length > 0) { Collections.addAll(this.interceptors, otherInterceptors); @@ -132,17 +174,24 @@ public WxMpMessageRouterRule interceptor(WxMpMessageInterceptor interceptor, WxM return this; } - /** - * 设置微信消息处理器 - */ - public WxMpMessageRouterRule handler(WxMpMessageHandler handler) { + /** + * 设置微信消息处理器 + * + * @param handler the handler + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule handler(WxMpMessageHandler handler) { return handler(handler, (WxMpMessageHandler[]) null); } - /** - * 设置微信消息处理器 - */ - public WxMpMessageRouterRule handler(WxMpMessageHandler handler, WxMpMessageHandler... otherHandlers) { + /** + * 设置微信消息处理器 + * + * @param handler the handler + * @param otherHandlers the other handlers + * @return the wx mp message router rule + */ + public WxMpMessageRouterRule handler(WxMpMessageHandler handler, WxMpMessageHandler... otherHandlers) { this.handlers.add(handler); if (otherHandlers != null && otherHandlers.length > 0) { for (WxMpMessageHandler i : otherHandlers) { @@ -152,27 +201,34 @@ public WxMpMessageRouterRule handler(WxMpMessageHandler handler, WxMpMessageHand return this; } - /** - * 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则 - */ - public WxMpMessageRouter end() { + /** + * 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则 + * + * @return the wx mp message router + */ + public WxMpMessageRouter end() { this.routerBuilder.getRules().add(this); return this.routerBuilder; } - /** - * 规则结束,但是消息还会进入其他规则 - */ - public WxMpMessageRouter next() { + /** + * 规则结束,但是消息还会进入其他规则 + * + * @return the wx mp message router + */ + public WxMpMessageRouter next() { this.reEnter = true; return end(); } - /** - * 将微信自定义的事件修正为不区分大小写, - * 比如框架定义的事件常量为click,但微信传递过来的却是CLICK - */ - protected boolean test(WxMpXmlMessage wxMessage) { + /** + * 将微信自定义的事件修正为不区分大小写, + * 比如框架定义的事件常量为click,但微信传递过来的却是CLICK + * + * @param wxMessage the wx message + * @return the boolean + */ + protected boolean test(WxMpXmlMessage wxMessage) { return (this.fromUser == null || this.fromUser.equals(wxMessage.getFromUser())) && @@ -192,13 +248,17 @@ protected boolean test(WxMpXmlMessage wxMessage) { ; } - /** - * 处理微信推送过来的消息 - * - * @param wxMessage - * @return true 代表继续执行别的router,false 代表停止执行别的router - */ - protected WxMpXmlOutMessage service(WxMpXmlMessage wxMessage, + /** + * 处理微信推送过来的消息 + * + * @param wxMessage the wx message + * @param context the context + * @param wxMpService the wx mp service + * @param sessionManager the session manager + * @param exceptionHandler the exception handler + * @return true 代表继续执行别的router,false 代表停止执行别的router + */ + protected WxMpXmlOutMessage service(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager, @@ -233,95 +293,210 @@ protected WxMpXmlOutMessage service(WxMpXmlMessage wxMessage, } - public WxMpMessageRouter getRouterBuilder() { + /** + * Gets router builder. + * + * @return the router builder + */ + public WxMpMessageRouter getRouterBuilder() { return this.routerBuilder; } - public boolean isAsync() { + /** + * Is async boolean. + * + * @return the boolean + */ + public boolean isAsync() { return this.async; } - public void setAsync(boolean async) { + /** + * Sets async. + * + * @param async the async + */ + public void setAsync(boolean async) { this.async = async; } - public String getFromUser() { + /** + * Gets from user. + * + * @return the from user + */ + public String getFromUser() { return this.fromUser; } - public void setFromUser(String fromUser) { + /** + * Sets from user. + * + * @param fromUser the from user + */ + public void setFromUser(String fromUser) { this.fromUser = fromUser; } - public String getMsgType() { + /** + * Gets msg type. + * + * @return the msg type + */ + public String getMsgType() { return this.msgType; } - public void setMsgType(String msgType) { + /** + * Sets msg type. + * + * @param msgType the msg type + */ + public void setMsgType(String msgType) { this.msgType = msgType; } - public String getEvent() { + /** + * Gets event. + * + * @return the event + */ + public String getEvent() { return this.event; } - public void setEvent(String event) { + /** + * Sets event. + * + * @param event the event + */ + public void setEvent(String event) { this.event = event; } - public String getEventKey() { + /** + * Gets event key. + * + * @return the event key + */ + public String getEventKey() { return this.eventKey; } - public void setEventKey(String eventKey) { + /** + * Sets event key. + * + * @param eventKey the event key + */ + public void setEventKey(String eventKey) { this.eventKey = eventKey; } - public String getContent() { + /** + * Gets content. + * + * @return the content + */ + public String getContent() { return this.content; } - public void setContent(String content) { + /** + * Sets content. + * + * @param content the content + */ + public void setContent(String content) { this.content = content; } - public String getrContent() { + /** + * Gets content. + * + * @return the content + */ + public String getrContent() { return this.rContent; } - public void setrContent(String rContent) { + /** + * Sets content. + * + * @param rContent the r content + */ + public void setrContent(String rContent) { this.rContent = rContent; } - public WxMpMessageMatcher getMatcher() { + /** + * Gets matcher. + * + * @return the matcher + */ + public WxMpMessageMatcher getMatcher() { return this.matcher; } - public void setMatcher(WxMpMessageMatcher matcher) { + /** + * Sets matcher. + * + * @param matcher the matcher + */ + public void setMatcher(WxMpMessageMatcher matcher) { this.matcher = matcher; } - public boolean isReEnter() { + /** + * Is re enter boolean. + * + * @return the boolean + */ + public boolean isReEnter() { return this.reEnter; } - public void setReEnter(boolean reEnter) { + /** + * Sets re enter. + * + * @param reEnter the re enter + */ + public void setReEnter(boolean reEnter) { this.reEnter = reEnter; } - public List getHandlers() { + /** + * Gets handlers. + * + * @return the handlers + */ + public List getHandlers() { return this.handlers; } - public void setHandlers(List handlers) { + /** + * Sets handlers. + * + * @param handlers the handlers + */ + public void setHandlers(List handlers) { this.handlers = handlers; } - public List getInterceptors() { + /** + * Gets interceptors. + * + * @return the interceptors + */ + public List getInterceptors() { return this.interceptors; } - public void setInterceptors(List interceptors) { + /** + * Sets interceptors. + * + * @param interceptors the interceptors + */ + public void setInterceptors(List interceptors) { this.interceptors = interceptors; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java index 0bb0d1dcd3..847f6e7ecf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java @@ -14,93 +14,93 @@ * @author Binary Wang */ public interface WxMpQrcodeService { - /** - *
-   * 换取临时二维码ticket
-   * 详情请见: 生成带参数的二维码
-   * 
- * - * @param sceneId 场景值ID,临时二维码时为32位非0整型 - * @param expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 - * @return the wx mp qr code ticket - * @throws WxErrorException the wx error exception - */ - WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException; + /** + *
+     * 换取临时二维码ticket
+     * 详情请见: 生成带参数的二维码
+     * 
+ * + * @param sceneId 场景值ID,临时二维码时为32位非0整型 + * @param expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 + * @return the wx mp qr code ticket + * @throws WxErrorException the wx error exception + */ + WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException; - /** - *
-   * 换取临时二维码ticket
-   * 详情请见: 生成带参数的二维码
-   * 
- * - * @param sceneStr 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64 - * @param expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 - * @return the wx mp qr code ticket - * @throws WxErrorException the wx error exception - */ - WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException; + /** + *
+     * 换取临时二维码ticket
+     * 详情请见: 生成带参数的二维码
+     * 
+ * + * @param sceneStr 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64 + * @param expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 + * @return the wx mp qr code ticket + * @throws WxErrorException the wx error exception + */ + WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException; - /** - *
-   * 换取永久二维码ticket
-   * 详情请见: 生成带参数的二维码
-   * 
- * - * @param sceneId 场景值ID,最大值为100000(目前参数只支持1--100000) - * @return the wx mp qr code ticket - * @throws WxErrorException the wx error exception - */ - WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException; + /** + *
+     * 换取永久二维码ticket
+     * 详情请见: 生成带参数的二维码
+     * 
+ * + * @param sceneId 场景值ID,最大值为100000(目前参数只支持1--100000) + * @return the wx mp qr code ticket + * @throws WxErrorException the wx error exception + */ + WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException; - /** - *
-   * 换取永久字符串二维码ticket
-   * 详情请见: 生成带参数的二维码
-   * 
- * - * @param sceneStr 参数。字符串类型长度现在为1到64 - * @return the wx mp qr code ticket - * @throws WxErrorException the wx error exception - */ - WxMpQrCodeTicket qrCodeCreateLastTicket(String sceneStr) throws WxErrorException; + /** + *
+     * 换取永久字符串二维码ticket
+     * 详情请见: 生成带参数的二维码
+     * 
+ * + * @param sceneStr 参数。字符串类型长度现在为1到64 + * @return the wx mp qr code ticket + * @throws WxErrorException the wx error exception + */ + WxMpQrCodeTicket qrCodeCreateLastTicket(String sceneStr) throws WxErrorException; - /** - *
-   * 换取二维码图片文件,jpg格式
-   * 详情请见: 生成带参数的二维码
-   * 
- * - * @param ticket 二维码ticket - * @return the file - * @throws WxErrorException the wx error exception - */ - File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException; + /** + *
+     * 换取二维码图片文件,jpg格式
+     * 详情请见: 生成带参数的二维码
+     * 
+ * + * @param ticket 二维码ticket + * @return the file + * @throws WxErrorException the wx error exception + */ + File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException; - /** - *
-   * 换取二维码图片url地址(可以选择是否生成压缩的网址)
-   * 详情请见: 生成带参数的二维码
-   * 
- * - * @param ticket 二维码ticket - * @param needShortUrl 是否需要压缩的二维码地址 - * @return the string - * @throws WxErrorException the wx error exception - */ - @Deprecated + /** + *
+     * 换取二维码图片url地址(可以选择是否生成压缩的网址)
+     * 详情请见: 生成带参数的二维码
+     * 
+ * + * @param ticket 二维码ticket + * @param needShortUrl 是否需要压缩的二维码地址 + * @return the string + * @throws WxErrorException the wx error exception + */ + @Deprecated String qrCodePictureUrl(String ticket, boolean needShortUrl) throws WxErrorException; - /** - *
-   * 换取二维码图片url地址
-   * 详情请见: 生成带参数的二维码
-   * 
- * - * @param ticket 二维码ticket - * @return the string - * @throws WxErrorException the wx error exception - */ - String qrCodePictureUrl(String ticket) throws WxErrorException; + /** + *
+     * 换取二维码图片url地址
+     * 详情请见: 生成带参数的二维码
+     * 
+ * + * @param ticket 二维码ticket + * @return the string + * @throws WxErrorException the wx error exception + */ + String qrCodePictureUrl(String ticket) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpReimburseInvoiceService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpReimburseInvoiceService.java index 51745558c9..3de4312d43 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpReimburseInvoiceService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpReimburseInvoiceService.java @@ -8,41 +8,46 @@ /** * 电子发票报销方相关接口 * 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Reimburser_API_List.html + * * @author xiaoyu - * @since 2021-03-23 + * @since 2021 -03-23 */ public interface WxMpReimburseInvoiceService { - /** - * 查询报销发票信息 - * @param request {@link InvoiceInfoRequest} 查询报销发票信息参数 - * @return {@link InvoiceInfoResponse} 查询结果 - * @throws WxErrorException 查询失败时 - */ - InvoiceInfoResponse getInvoiceInfo(InvoiceInfoRequest request) throws WxErrorException; - - - /** - * 批量查询报销发票信息 - * @param request {@link InvoiceBatchRequest} 批量查询报销发票信息参数对象 - * @return {@link InvoiceInfoResponse} 查询结果列表 - * @throws WxErrorException 查询失败时 - */ - List getInvoiceBatch(InvoiceBatchRequest request) throws WxErrorException; - - - /** - * 更新发票状态 - * @param request {@link UpdateInvoiceStatusRequest} 更新发票状态参数 - * @throws WxErrorException 更新失败时 - */ - void updateInvoiceStatus(UpdateInvoiceStatusRequest request) throws WxErrorException; - - - /** - * 批量更新发票状态 - * @param request {@link UpdateStatusBatchRequest} 批量更新发票状态参数 - * @throws WxErrorException 更新失败时 - */ - void updateStatusBatch(UpdateStatusBatchRequest request) throws WxErrorException; + /** + * 查询报销发票信息 + * + * @param request {@link InvoiceInfoRequest} 查询报销发票信息参数 + * @return {@link InvoiceInfoResponse} 查询结果 + * @throws WxErrorException 查询失败时 + */ + InvoiceInfoResponse getInvoiceInfo(InvoiceInfoRequest request) throws WxErrorException; + + + /** + * 批量查询报销发票信息 + * + * @param request {@link InvoiceBatchRequest} 批量查询报销发票信息参数对象 + * @return {@link InvoiceInfoResponse} 查询结果列表 + * @throws WxErrorException 查询失败时 + */ + List getInvoiceBatch(InvoiceBatchRequest request) throws WxErrorException; + + + /** + * 更新发票状态 + * + * @param request {@link UpdateInvoiceStatusRequest} 更新发票状态参数 + * @throws WxErrorException 更新失败时 + */ + void updateInvoiceStatus(UpdateInvoiceStatusRequest request) throws WxErrorException; + + + /** + * 批量更新发票状态 + * + * @param request {@link UpdateStatusBatchRequest} 批量更新发票状态参数 + * @throws WxErrorException 更新失败时 + */ + void updateStatusBatch(UpdateStatusBatchRequest request) throws WxErrorException; } 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 6b6e30b7f3..6df78c12d2 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 @@ -20,6 +20,7 @@ import me.chanjar.weixin.mp.enums.WxMpApiUrl; import java.util.Map; +import java.util.function.Function; /** * 微信公众号API的Service. @@ -70,7 +71,7 @@ public interface WxMpService extends WxService { * * @return token access token * @throws WxErrorException . - * @see #getAccessToken(boolean) #getAccessToken(boolean)#getAccessToken(boolean) + * @see #getAccessToken(boolean) #getAccessToken(boolean)#getAccessToken(boolean)#getAccessToken(boolean) */ String getAccessToken() throws WxErrorException; @@ -98,7 +99,7 @@ public interface WxMpService extends WxService { * @param type ticket 类型 * @return ticket ticket * @throws WxErrorException . - * @see #getTicket(TicketType, boolean) #getTicket(TicketType, boolean)#getTicket(TicketType, boolean) + * @see #getTicket(TicketType, boolean) #getTicket(TicketType, boolean)#getTicket(TicketType, boolean)#getTicket(TicketType, boolean) */ String getTicket(TicketType type) throws WxErrorException; @@ -120,7 +121,7 @@ public interface WxMpService extends WxService { * * @return jsapi ticket * @throws WxErrorException . - * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean) + * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean)#getJsapiTicket(boolean) */ String getJsapiTicket() throws WxErrorException; @@ -393,6 +394,8 @@ public interface WxMpService extends WxService { */ boolean switchover(String mpId); + boolean switchover(String mpId, Function func); + /** * 进行相应的公众号切换. * @@ -401,6 +404,8 @@ public interface WxMpService extends WxService { */ WxMpService switchoverTo(String mpId); + WxMpService switchoverTo(String mpId, Function func); + /** * 返回客服接口方法实现类,以方便调用其各个接口. * @@ -567,6 +572,20 @@ public interface WxMpService extends WxService { */ WxMpReimburseInvoiceService getReimburseInvoiceService(); + /** + * 返回草稿箱相关接口 + * + * @return WxMpDraftService draft service + */ + WxMpDraftService getDraftService(); + + /** + * 返回发布能力接口 + * + * @return WxMpFreePublishService free publish service + */ + WxMpFreePublishService getFreePublishService(); + /** * . * @@ -818,4 +837,18 @@ public interface WxMpService extends WxService { * @param merchantInvoiceService the merchant invoice service */ void setMerchantInvoiceService(WxMpMerchantInvoiceService merchantInvoiceService); + + /** + * Sets draft service. + * + * @param draftService the draft service + */ + void setDraftService(WxMpDraftService draftService); + + /** + * Sets free publish service. + * + * @param freePublishService the free publish service + */ + void setFreePublishService(WxMpFreePublishService freePublishService); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java index 8c45dadea0..53507e20ac 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java @@ -22,6 +22,8 @@ public interface WxMpShakeService { *
* * @param wxMpShakeQuery 查询参数 + * @return the shake info + * @throws WxErrorException the wx error exception */ WxMpShakeInfoResult getShakeInfo(WxMpShakeQuery wxMpShakeQuery) throws WxErrorException; @@ -30,9 +32,10 @@ public interface WxMpShakeService { * 页面管理
* 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1459246752 *
- * @param shakeAroundPageAddQuery - * @return - * @throws WxErrorException + * + * @param shakeAroundPageAddQuery the shake around page add query + * @return . wx mp shake around page add result + * @throws WxErrorException the wx error exception */ WxMpShakeAroundPageAddResult pageAdd(WxMpShakeAroundPageAddQuery shakeAroundPageAddQuery) throws WxErrorException; @@ -41,9 +44,10 @@ public interface WxMpShakeService { * 配置设备与页面的关联关系
* 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1459301931 *
- * @param shakeAroundDeviceBindPageQuery - * @return - * @throws WxErrorException + * + * @param shakeAroundDeviceBindPageQuery the shake around device bind page query + * @return . wx error + * @throws WxErrorException the wx error exception */ WxError deviceBindPageQuery(WxMpShakeAroundDeviceBindPageQuery shakeAroundDeviceBindPageQuery) throws WxErrorException; @@ -52,9 +56,10 @@ public interface WxMpShakeService { * 查询设备与页面的关联关系
* 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1443447914 *
- * @param shakeAroundRelationSearchQuery - * @return - * @throws WxErrorException + * + * @param shakeAroundRelationSearchQuery the shake around relation search query + * @return . wx mp shake around relation search result + * @throws WxErrorException the wx error exception */ WxMpShakeAroundRelationSearchResult relationSearch(WxMpShakeAroundRelationSearchQuery shakeAroundRelationSearchQuery) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java index 82eaa5eeb5..44ca69f3f3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java @@ -11,90 +11,109 @@ * 门店管理的相关接口代码. * Created by Binary Wang on 2016-09-23. * + * @param the type parameter + * @param

the type parameter * @author Binary Wang */ public interface WxMpStoreService { - /** - *

-   * 创建门店
-   * 接口说明
-   * 创建门店接口是为商户提供创建自己门店数据的接口,门店数据字段越完整,商户页面展示越丰富,越能够吸引更多用户,并提高曝光度。
-   * 创建门店接口调用成功后会返回errcode 0、errmsg ok,但不会实时返回poi_id。
-   * 成功创建后,会生成poi_id,但该id不一定为最终id。门店信息会经过审核,审核通过后方可获取最终poi_id,该id为门店的唯一id,强烈建议自行存储审核通过后的最终poi_id,并为后续调用使用。
-   * 详情请见: 微信门店接口
-   * 接口格式: https://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token=TOKEN
-   * 
- */ - void add(WxMpStoreBaseInfo request) throws WxErrorException; + /** + *
+     * 创建门店
+     * 接口说明
+     * 创建门店接口是为商户提供创建自己门店数据的接口,门店数据字段越完整,商户页面展示越丰富,越能够吸引更多用户,并提高曝光度。
+     * 创建门店接口调用成功后会返回errcode 0、errmsg ok,但不会实时返回poi_id。
+     * 成功创建后,会生成poi_id,但该id不一定为最终id。门店信息会经过审核,审核通过后方可获取最终poi_id,该id为门店的唯一id,强烈建议自行存储审核通过后的最终poi_id,并为后续调用使用。
+     * 详情请见: 微信门店接口
+     * 接口格式: https://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token=TOKEN
+     * 
+ * + * @param request the request + * @throws WxErrorException the wx error exception + */ + void add(WxMpStoreBaseInfo request) throws WxErrorException; - /** - *
-   * 查询门店信息
-   * 创建门店后获取poi_id 后,商户可以利用poi_id,查询具体某条门店的信息。
-   * 若在查询时,update_status 字段为1,表明在5 个工作日内曾用update 接口修改过门店扩展字段,该扩展字段为最新的修改字段,尚未经过审核采纳,因此不是最终结果。
-   * 最终结果会在5 个工作日内,最终确认是否采纳,并前端生效(但该扩展字段的采纳过程不影响门店的可用性,即available_state仍为审核通过状态)
-   * 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。
-   * 详情请见: 微信门店接口
-   * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token=TOKEN
-   * 
- * - * @param poiId 门店Id - */ - WxMpStoreBaseInfo get(String poiId) throws WxErrorException; + /** + *
+     * 查询门店信息
+     * 创建门店后获取poi_id 后,商户可以利用poi_id,查询具体某条门店的信息。
+     * 若在查询时,update_status 字段为1,表明在5 个工作日内曾用update 接口修改过门店扩展字段,该扩展字段为最新的修改字段,尚未经过审核采纳,因此不是最终结果。
+     * 最终结果会在5 个工作日内,最终确认是否采纳,并前端生效(但该扩展字段的采纳过程不影响门店的可用性,即available_state仍为审核通过状态)
+     * 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。
+     * 详情请见: 微信门店接口
+     * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token=TOKEN
+     * 
+ * + * @param poiId 门店Id + * @return the wx mp store base info + * @throws WxErrorException the wx error exception + */ + WxMpStoreBaseInfo get(String poiId) throws WxErrorException; - /** - *
-   * 删除门店
-   * 商户可以通过该接口,删除已经成功创建的门店。请商户慎重调用该接口。
-   * 详情请见: 微信门店接口
-   * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token=TOKEN
-   * 
- * - * @param poiId 门店Id - */ - void delete(String poiId) throws WxErrorException; + /** + *
+     * 删除门店
+     * 商户可以通过该接口,删除已经成功创建的门店。请商户慎重调用该接口。
+     * 详情请见: 微信门店接口
+     * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token=TOKEN
+     * 
+ * + * @param poiId 门店Id + * @throws WxErrorException the wx error exception + */ + void delete(String poiId) throws WxErrorException; - /** - *
-   * 查询门店列表(指定查询起始位置和个数)
-   * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。
-   * 详情请见: 微信门店接口
-   * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
-   * 
- * - * @param begin 开始位置,0 即为从第一条开始查询 - * @param limit 返回数据条数,最大允许50,默认为20 - */ - WxMpStoreListResult list(int begin, int limit) throws WxErrorException; + /** + *
+     * 查询门店列表(指定查询起始位置和个数)
+     * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。
+     * 详情请见: 微信门店接口
+     * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
+     * 
+ * + * @param begin 开始位置,0 即为从第一条开始查询 + * @param limit 返回数据条数,最大允许50,默认为20 + * @return the wx mp store list result + * @throws WxErrorException the wx error exception + */ + WxMpStoreListResult list(int begin, int limit) throws WxErrorException; - /** - *
-   * 查询门店列表(所有)
-   * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。
-   * 详情请见: 微信门店接口
-   * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
-   * 
- */ - List listAll() throws WxErrorException; + /** + *
+     * 查询门店列表(所有)
+     * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。
+     * 详情请见: 微信门店接口
+     * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
+     * 
+ * + * @return the list + * @throws WxErrorException the wx error exception + */ + List listAll() throws WxErrorException; - /** - *
-   * 修改门店服务信息
-   * 商户可以通过该接口,修改门店的服务信息,包括:sid、图片列表、营业时间、推荐、特色服务、简介、人均价格、电话8个字段(名称、坐标、地址等不可修改)修改后需要人工审核。
-   * 详情请见: 微信门店接口
-   * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/updatepoi?access_token=TOKEN
-   * 
- */ - void update(WxMpStoreBaseInfo info) throws WxErrorException; + /** + *
+     * 修改门店服务信息
+     * 商户可以通过该接口,修改门店的服务信息,包括:sid、图片列表、营业时间、推荐、特色服务、简介、人均价格、电话8个字段(名称、坐标、地址等不可修改)修改后需要人工审核。
+     * 详情请见: 微信门店接口
+     * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/updatepoi?access_token=TOKEN
+     * 
+ * + * @param info the info + * @throws WxErrorException the wx error exception + */ + void update(WxMpStoreBaseInfo info) throws WxErrorException; - /** - *
-   * 门店类目表
-   * 类目名称接口是为商户提供自己门店类型信息的接口。门店类目定位的越规范,能够精准的吸引更多用户,提高曝光率。
-   * 详情请见: 微信门店接口
-   * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getwxcategory?access_token=TOKEN
-   * 
- */ - List listCategories() throws WxErrorException; + /** + *
+     * 门店类目表
+     * 类目名称接口是为商户提供自己门店类型信息的接口。门店类目定位的越规范,能够精准的吸引更多用户,提高曝光率。
+     * 详情请见: 微信门店接口
+     * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getwxcategory?access_token=TOKEN
+     * 
+ * + * @return the list + * @throws WxErrorException the wx error exception + */ + List listCategories() throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpSubscribeMsgService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpSubscribeMsgService.java index 897c00e783..fa5a5dbbfb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpSubscribeMsgService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpSubscribeMsgService.java @@ -14,129 +14,129 @@ * 订阅消息服务接口 *
* - * @author Mklaus - * @date 2018 -01-22 上午11:07 + * @author Mklaus created on 2018 -01-22 上午11:07 */ public interface WxMpSubscribeMsgService { - /** - *
-   * 构造用户订阅一条模板消息授权的url连接
-   * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1500374289_66bvB
-   * 
- * - * @param redirectURI 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode - * @param scene 重定向后会带上scene参数,开发者可以填0-10000的整形值,用来标识订阅场景值 - * @param reserved 用于保持请求和回调的状态,授权请后原样带回给第三方 (最多128字节,要求做urlencode) - * @return url string - */ - String subscribeMsgAuthorizationUrl(String redirectURI, int scene, String reserved); + /** + *
+     * 构造用户订阅一条模板消息授权的url连接
+     * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1500374289_66bvB
+     * 
+ * + * @param redirectURI 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode + * @param scene 重定向后会带上scene参数,开发者可以填0-10000的整形值,用来标识订阅场景值 + * @param reserved 用于保持请求和回调的状态,授权请后原样带回给第三方 (最多128字节,要求做urlencode) + * @return url string + */ + String subscribeMsgAuthorizationUrl(String redirectURI, int scene, String reserved); - /** - *
-   * 发送一次性订阅消息
-   * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1500374289_66bvB
-   * 
- * - * @param message the message - * @return 消息Id boolean - * @throws WxErrorException the wx error exception - */ - boolean sendOnce(WxMpSubscribeMessage message) throws WxErrorException; + /** + *
+     * 发送一次性订阅消息
+     * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1500374289_66bvB
+     * 
+ * + * @param message the message + * @return 消息Id boolean + * @throws WxErrorException the wx error exception + */ + boolean sendOnce(WxMpSubscribeMessage message) throws WxErrorException; - /** - *
-   * 获取帐号所属类目下的公共模板标题
-   *
-   * 详情请见: 获取帐号所属类目下的公共模板标题
-   * 接口url格式: https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token=ACCESS_TOKEN
-   * 
- * - * @param ids 类目 id,多个用逗号隔开 - * @param start 用于分页,表示从 start 开始。从 0 开始计数。 - * @param limit 用于分页,表示拉取 limit 条记录。最大为 30。 - * @return . pub template title list - * @throws WxErrorException . - */ - PubTemplateTitleListResult getPubTemplateTitleList(String[] ids, int start, int limit) throws WxErrorException; + /** + *
+     * 获取帐号所属类目下的公共模板标题
+     *
+     * 详情请见: 获取帐号所属类目下的公共模板标题
+     * 接口url格式: https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token=ACCESS_TOKEN
+     * 
+ * + * @param ids 类目 id,多个用逗号隔开 + * @param start 用于分页,表示从 start 开始。从 0 开始计数。 + * @param limit 用于分页,表示拉取 limit 条记录。最大为 30。 + * @return . pub template title list + * @throws WxErrorException . + */ + PubTemplateTitleListResult getPubTemplateTitleList(String[] ids, int start, int limit) throws WxErrorException; - /** - *
-   * 获取模板库某个模板标题下关键词库
-   *
-   * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
-   * 接口url格式: GET https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token=ACCESS_TOKEN
-   * 
- * - * @param id 模板标题 id,可通过接口获取 - * @return . pub template key words by id - * @throws WxErrorException . - */ - List getPubTemplateKeyWordsById(String id) throws WxErrorException; + /** + *
+     * 获取模板库某个模板标题下关键词库
+     *
+     * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
+     * 接口url格式: GET https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token=ACCESS_TOKEN
+     * 
+ * + * @param id 模板标题 id,可通过接口获取 + * @return . pub template key words by id + * @throws WxErrorException . + */ + List getPubTemplateKeyWordsById(String id) throws WxErrorException; - /** - *
-   * 组合模板并添加至帐号下的个人模板库
-   *
-   * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
-   * 接口url格式: POST https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token=ACCESS_TOKEN
-   * 
- * - * @param id 模板标题 id,可通过接口获取,也可登录小程序后台查看获取 - * @param keywordIdList 模板关键词列表 - * @param sceneDesc 服务场景描述,15个字以内 - * @return 添加至帐号下的模板id ,发送小程序订阅消息时所需 - * @throws WxErrorException . - */ - String addTemplate(String id, List keywordIdList, String sceneDesc) throws WxErrorException; + /** + *
+     * 组合模板并添加至帐号下的个人模板库
+     *
+     * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
+     * 接口url格式: POST https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token=ACCESS_TOKEN
+     * 
+ * + * @param id 模板标题 id,可通过接口获取,也可登录小程序后台查看获取 + * @param keywordIdList 模板关键词列表 + * @param sceneDesc 服务场景描述,15个字以内 + * @return 添加至帐号下的模板id ,发送小程序订阅消息时所需 + * @throws WxErrorException . + */ + String addTemplate(String id, List keywordIdList, String sceneDesc) throws WxErrorException; - /** - *
-   * 获取当前帐号下的个人模板列表
-   *
-   * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
-   * 接口url格式: GET https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token=ACCESS_TOKEN
-   * 
- * - * @return . template list - * @throws WxErrorException . - */ - List getTemplateList() throws WxErrorException; + /** + *
+     * 获取当前帐号下的个人模板列表
+     *
+     * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
+     * 接口url格式: GET https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token=ACCESS_TOKEN
+     * 
+ * + * @return . template list + * @throws WxErrorException . + */ + List getTemplateList() throws WxErrorException; - /** - *
-   * 删除帐号下的某个模板
-   *
-   * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
-   * 接口url格式: POST https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate?access_token=ACCESS_TOKEN
-   * 
- * - * @param templateId 要删除的模板id - * @return 删除是否成功 boolean - * @throws WxErrorException . - */ - boolean delTemplate(String templateId) throws WxErrorException; + /** + *
+     * 删除帐号下的某个模板
+     *
+     * 详情请见: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
+     * 接口url格式: POST https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate?access_token=ACCESS_TOKEN
+     * 
+ * + * @param templateId 要删除的模板id + * @return 删除是否成功 boolean + * @throws WxErrorException . + */ + boolean delTemplate(String templateId) throws WxErrorException; - /** - *
-   * 获取公众号类目
-   * https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
-   * GET https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token=ACCESS_TOKEN
-   * 
- * - * @return . category - * @throws WxErrorException . - */ - List getCategory() throws WxErrorException; + /** + *
+     * 获取公众号类目
+     * https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
+     * GET https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token=ACCESS_TOKEN
+     * 
+ * + * @return . category + * @throws WxErrorException . + */ + List getCategory() throws WxErrorException; - /** - *
-   * 发送订阅消息
-   * https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
-   * 
- * - * @param subscribeMessage 订阅消息 - * @throws WxErrorException . - */ - void send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException; + /** + *
+     * 发送订阅消息
+     * https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
+     * 
+ * + * @param subscribeMessage 订阅消息 + * @return 下发消息id,与下发结果回调的msgId对应 + * @throws WxErrorException . + */ + String send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java index 24c6eded72..08522992d6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java @@ -13,8 +13,7 @@ * http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN * Created by Binary Wang on 2016-10-14. * @author miller.lin - * @author Binary Wang - *
+ * @author Binary Wang
*/ public interface WxMpTemplateMsgService { /** @@ -25,7 +24,7 @@ public interface WxMpTemplateMsgService { *
* * @param wxMpIndustry 行业信息 - * @return 是否成功 + * @return 是否成功 industry * @throws WxErrorException . */ boolean setIndustry(WxMpTemplateIndustry wxMpIndustry) throws WxErrorException; @@ -36,7 +35,7 @@ public interface WxMpTemplateMsgService { * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN *
* - * @return wxMpIndustry + * @return wxMpIndustry industry * @throws WxErrorException . */ WxMpTemplateIndustry getIndustry() throws WxErrorException; @@ -48,7 +47,7 @@ public interface WxMpTemplateMsgService { *
* * @param templateMessage 模板消息 - * @return 消息Id + * @return 消息Id string * @throws WxErrorException . */ String sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException; @@ -64,9 +63,26 @@ public interface WxMpTemplateMsgService { * @param shortTemplateId 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式 * @return templateId 模板Id * @throws WxErrorException . + * @deprecated 请使用 addTemplate(java.lang.String, java.util.List) */ + @Deprecated String addTemplate(String shortTemplateId) throws WxErrorException; + /** + *
+   * 获得模板ID
+   * 从类目模板库选择模板到帐号后台,获得模板ID的过程可在MP中完成
+   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
+   * 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=ACCESS_TOKEN
+   * 
+ * + * @param shortTemplateId 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式,对于类目模板,为纯数字ID + * @param keywordNameList 选用的类目模板的关键词,按顺序传入,如果为空,或者关键词不在模板库中,会返回40246错误码 + * @return templateId 模板Id + * @throws WxErrorException . + */ + String addTemplate(String shortTemplateId, List keywordNameList) throws WxErrorException; + /** *
    * 获取模板列表
@@ -89,7 +105,7 @@ public interface WxMpTemplateMsgService {
    * 
* * @param templateId 模板Id - * @return . + * @return . boolean * @throws WxErrorException . */ boolean delPrivateTemplate(String templateId) throws WxErrorException; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserBlacklistService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserBlacklistService.java index e7e2fd84fc..2fb77280dd 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserBlacklistService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserBlacklistService.java @@ -6,30 +6,42 @@ import java.util.List; /** + * The interface Wx mp user blacklist service. + * * @author miller */ public interface WxMpUserBlacklistService { - /** - *
-   * 获取公众号的黑名单列表
-   * 详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN
-   * 
- */ - WxMpUserBlacklistGetResult getBlacklist(String nextOpenid) throws WxErrorException; + /** + *
+     * 获取公众号的黑名单列表
+     * 详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN
+     * 
+ * + * @param nextOpenid the next openid + * @return the blacklist + * @throws WxErrorException the wx error exception + */ + WxMpUserBlacklistGetResult getBlacklist(String nextOpenid) throws WxErrorException; - /** - *
-   *   拉黑用户
-   *   详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN
-   * 
- */ - void pushToBlacklist(List openidList) throws WxErrorException; + /** + *
+     *   拉黑用户
+     *   详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN
+     * 
+ * + * @param openidList the openid list + * @throws WxErrorException the wx error exception + */ + void pushToBlacklist(List openidList) throws WxErrorException; - /** - *
-   *   取消拉黑用户
-   *   详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN
-   * 
- */ - void pullFromBlacklist(List openidList) throws WxErrorException; + /** + *
+     *   取消拉黑用户
+     *   详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN
+     * 
+ * + * @param openidList the openid list + * @throws WxErrorException the wx error exception + */ + void pullFromBlacklist(List openidList) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java index 00eea89e74..08e599509d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java @@ -14,96 +14,120 @@ * @author Binary Wang */ public interface WxMpUserService { - /** - *
-   * 设置用户备注名
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140838&token=&lang=zh_CN
-   * http请求方式: POST(请使用https协议)
-   * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN
-   * 
- * - * @param openid 用户openid - * @param remark 备注名 - */ - void userUpdateRemark(String openid, String remark) throws WxErrorException; + /** + *
+     * 设置用户备注名
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140838&token=&lang=zh_CN
+     * http请求方式: POST(请使用https协议)
+     * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN
+     * 
+ * + * @param openid 用户openid + * @param remark 备注名 + * @throws WxErrorException the wx error exception + */ + void userUpdateRemark(String openid, String remark) throws WxErrorException; - /** - *
-   * 获取用户基本信息(语言为默认的zh_CN 简体)
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
-   * http请求方式: GET
-   * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
-   * 
- * - * @param openid 用户openid - */ - WxMpUser userInfo(String openid) throws WxErrorException; + /** + *
+     * 获取用户基本信息(语言为默认的zh_CN 简体)
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
+     * http请求方式: GET
+     * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
+     * 
+ * + * @param openid 用户openid + * @return the wx mp user + * @throws WxErrorException the wx error exception + */ + WxMpUser userInfo(String openid) throws WxErrorException; - /** - *
-   * 获取用户基本信息
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
-   * http请求方式: GET
-   * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
-   * 
- * - * @param openid 用户openid - * @param lang 语言,zh_CN 简体(默认),zh_TW 繁体,en 英语 - */ - WxMpUser userInfo(String openid, String lang) throws WxErrorException; + /** + *
+     * 获取用户基本信息
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
+     * http请求方式: GET
+     * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
+     * 
+ * + * @param openid 用户openid + * @param lang 语言,zh_CN 简体(默认),zh_TW 繁体,en 英语 + * @return the wx mp user + * @throws WxErrorException the wx error exception + */ + WxMpUser userInfo(String openid, String lang) throws WxErrorException; - /** - *
-   * 获取用户基本信息列表
-   * 开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
-   * http请求方式: POST
-   * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN
-   * 
- * - * @param openidList 用户openid列表 - */ - List userInfoList(List openidList) throws WxErrorException; + /** + *
+     * 获取用户基本信息列表
+     * 开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
+     * http请求方式: POST
+     * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN
+     * 
+ * + * @param openidList 用户openid列表 + * @return the list + * @throws WxErrorException the wx error exception + */ + List userInfoList(List openidList) throws WxErrorException; - /** - *
-   * 获取用户基本信息列表
-   * 开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
-   * http请求方式: POST
-   * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN
-   * 
- * - * @param userQuery 详细查询参数 - */ - List userInfoList(WxMpUserQuery userQuery) throws WxErrorException; + /** + *
+     * 获取用户基本信息列表
+     * 开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
+     * http请求方式: POST
+     * 接口地址:https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN
+     * 
+ * + * @param userQuery 详细查询参数 + * @return the list + * @throws WxErrorException the wx error exception + */ + List userInfoList(WxMpUserQuery userQuery) throws WxErrorException; - /** - *
-   * 获取用户列表
-   * 公众号可通过本接口来获取帐号的关注者列表,
-   * 关注者列表由一串OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。
-   * 一次拉取调用最多拉取10000个关注者的OpenID,可以通过多次拉取的方式来满足需求。
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN
-   * http请求方式: GET(请使用https协议)
-   * 接口地址:https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
-   * 
- * - * @param nextOpenid 可选,第一个拉取的OPENID,null为从头开始拉取 - */ - WxMpUserList userList(String nextOpenid) throws WxErrorException; + /** + *
+     * 获取用户列表
+     * 公众号可通过本接口来获取帐号的关注者列表,
+     * 关注者列表由一串OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。
+     * 一次拉取调用最多拉取10000个关注者的OpenID,可以通过多次拉取的方式来满足需求。
+     * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN
+     * http请求方式: GET(请使用https协议)
+     * 接口地址:https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
+     * 
+ * + * @param nextOpenid 可选,第一个拉取的OPENID,null为从头开始拉取 + * @return the wx mp user list + * @throws WxErrorException the wx error exception + */ + WxMpUserList userList(String nextOpenid) throws WxErrorException; - /** - *
-   * 微信公众号主体变更迁移用户 openid
-   * 详情请见: http://kf.qq.com/faq/170221aUnmmU170221eUZJNf.html
-   * http://kf.qq.com/faq/1901177NrqMr190117nqYJze.html
-   * http请求方式: POST
-   * 接口地址:https://api.weixin.qq.com/cgi-bin/changeopenid?access_token=ACCESS_TOKEN
-   * 
- * - * @param fromAppid 原公众号的 appid - * @param openidList 需要转换的openid,这些必须是旧账号目前关注的才行,否则会出错;一次最多100个 - */ - List changeOpenid(String fromAppid, List openidList) throws WxErrorException; + /** + *
+     * 获取用户列表(全部)
+     * 公众号可通过本接口来获取帐号的关注者列表,
+     * 关注者列表由一串OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。
+     * @return the wx mp user list
+     * @throws WxErrorException the wx error exception
+     * @see #userList(java.lang.String) #userList(java.lang.String)的增强,内部进行了多次数据拉取的汇总 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN http请求方式: GET(请使用https协议) 接口地址:https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID 
+ */ + WxMpUserList userList() throws WxErrorException; + + /** + *
+     * 微信公众号主体变更迁移用户 openid
+     * 详情请见: http://kf.qq.com/faq/170221aUnmmU170221eUZJNf.html
+     * http://kf.qq.com/faq/1901177NrqMr190117nqYJze.html
+     * http请求方式: POST
+     * 接口地址:https://api.weixin.qq.com/cgi-bin/changeopenid?access_token=ACCESS_TOKEN
+     * 
+ * + * @param fromAppid 原公众号的 appid + * @param openidList 需要转换的openid,这些必须是旧账号目前关注的才行,否则会出错;一次最多100个 + * @return the list + * @throws WxErrorException the wx error exception + */ + List changeOpenid(String fromAppid, List openidList) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java index c1549aff41..3f1b7223c7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java @@ -13,83 +13,114 @@ * @author Binary Wang */ public interface WxMpUserTagService { - /** - *
-   * 创建标签
-   * 一个公众号,最多可以创建100个标签。
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN
-   * 
- * - * @param name 标签名字(30个字符以内) - */ - WxUserTag tagCreate(String name) throws WxErrorException; + /** + *
+     * 创建标签
+     * 一个公众号,最多可以创建100个标签。
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN
+     * 
+ * + * @param name 标签名字(30个字符以内) + * @return the wx user tag + * @throws WxErrorException the wx error exception + */ + WxUserTag tagCreate(String name) throws WxErrorException; - /** - *
-   * 获取公众号已创建的标签
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN
-   * 
- */ - List tagGet() throws WxErrorException; + /** + *
+     * 获取公众号已创建的标签
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN
+     * 
+ * + * @return the list + * @throws WxErrorException the wx error exception + */ + List tagGet() throws WxErrorException; - /** - *
-   * 编辑标签
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN
-   * 
- */ - Boolean tagUpdate(Long tagId, String name) throws WxErrorException; + /** + *
+     * 编辑标签
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN
+     * 
+ * + * @param tagId the tag id + * @param name the name + * @return the boolean + * @throws WxErrorException the wx error exception + */ + Boolean tagUpdate(Long tagId, String name) throws WxErrorException; - /** - *
-   * 删除标签
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN
-   * 
- */ - Boolean tagDelete(Long tagId) throws WxErrorException; + /** + *
+     * 删除标签
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN
+     * 
+ * + * @param tagId the tag id + * @return the boolean + * @throws WxErrorException the wx error exception + */ + Boolean tagDelete(Long tagId) throws WxErrorException; - /** - *
-   * 获取标签下粉丝列表
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN
-   * 
- */ - WxTagListUser tagListUser(Long tagId, String nextOpenid) + /** + *
+     * 获取标签下粉丝列表
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN
+     * 
+ * + * @param tagId the tag id + * @param nextOpenid the next openid + * @return the wx tag list user + * @throws WxErrorException the wx error exception + */ + WxTagListUser tagListUser(Long tagId, String nextOpenid) throws WxErrorException; - /** - *
-   * 批量为用户打标签
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN
-   * 
- */ - boolean batchTagging(Long tagId, String[] openids) throws WxErrorException; + /** + *
+     * 批量为用户打标签
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN
+     * 
+ * + * @param tagId the tag id + * @param openids the openids + * @return the boolean + * @throws WxErrorException the wx error exception + */ + boolean batchTagging(Long tagId, String[] openids) throws WxErrorException; - /** - *
-   * 批量为用户取消标签
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN
-   * 
- */ - boolean batchUntagging(Long tagId, String[] openids) throws WxErrorException; + /** + *
+     * 批量为用户取消标签
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN
+     * 
+ * + * @param tagId the tag id + * @param openids the openids + * @return the boolean + * @throws WxErrorException the wx error exception + */ + boolean batchUntagging(Long tagId, String[] openids) throws WxErrorException; - /** - *
-   * 获取用户身上的标签列表
-   * 详情请见:用户标签管理
-   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN
-   * 
- * - * @return 标签Id的列表 - */ - List userTagList(String openid) throws WxErrorException; + /** + *
+     * 获取用户身上的标签列表
+     * 详情请见:用户标签管理
+     * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN
+     * 
+ * + * @param openid the openid + * @return 标签Id的列表 list + * @throws WxErrorException the wx error exception + */ + List userTagList(String openid) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpWifiService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpWifiService.java index b0876c7686..0c9a85183b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpWifiService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpWifiService.java @@ -13,54 +13,54 @@ * @author Binary Wang */ public interface WxMpWifiService { - /** - *
-   * 获取Wi-Fi门店列表.
-   * 通过此接口获取WiFi的门店列表,该列表包括公众平台的门店信息、以及添加设备后的WiFi相关信息。创建门店方法请参考“微信门店接口”。
-   * 注:微信连Wi-Fi下的所有接口中的shop_id,必需先通过此接口获取。
-   *
-   * http请求方式: POST
-   * 请求URL:https://api.weixin.qq.com/bizwifi/shop/list?access_token=ACCESS_TOKEN
-   * 
- * - * @param pageIndex 分页下标,默认从1开始 - * @param pageSize 每页的个数,默认10个,最大20个 - * @return 结果 - * @throws WxErrorException 异常 - */ - WxMpWifiShopListResult listShop(int pageIndex, int pageSize) throws WxErrorException; + /** + *
+     * 获取Wi-Fi门店列表.
+     * 通过此接口获取WiFi的门店列表,该列表包括公众平台的门店信息、以及添加设备后的WiFi相关信息。创建门店方法请参考“微信门店接口”。
+     * 注:微信连Wi-Fi下的所有接口中的shop_id,必需先通过此接口获取。
+     *
+     * http请求方式: POST
+     * 请求URL:https://api.weixin.qq.com/bizwifi/shop/list?access_token=ACCESS_TOKEN
+     * 
+ * + * @param pageIndex 分页下标,默认从1开始 + * @param pageSize 每页的个数,默认10个,最大20个 + * @return 结果 wx mp wifi shop list result + * @throws WxErrorException 异常 + */ + WxMpWifiShopListResult listShop(int pageIndex, int pageSize) throws WxErrorException; - /** - *
-   * 查询门店Wi-Fi信息
-   * 通过此接口查询某一门店的详细Wi-Fi信息,包括门店内的设备类型、ssid、密码、设备数量、商家主页URL、顶部常驻入口文案。
-   *
-   * http请求方式: POST
-   * 请求URL:https://api.weixin.qq.com/bizwifi/shop/get?access_token=ACCESS_TOKEN
-   * POST数据格式:JSON
-   * 
- * - * @param shopId 门店ID - * @return 结果 - * @throws WxErrorException 异常 - */ - WxMpWifiShopDataResult getShopWifiInfo(int shopId) throws WxErrorException; + /** + *
+     * 查询门店Wi-Fi信息
+     * 通过此接口查询某一门店的详细Wi-Fi信息,包括门店内的设备类型、ssid、密码、设备数量、商家主页URL、顶部常驻入口文案。
+     *
+     * http请求方式: POST
+     * 请求URL:https://api.weixin.qq.com/bizwifi/shop/get?access_token=ACCESS_TOKEN
+     * POST数据格式:JSON
+     * 
+ * + * @param shopId 门店ID + * @return 结果 shop wifi info + * @throws WxErrorException 异常 + */ + WxMpWifiShopDataResult getShopWifiInfo(int shopId) throws WxErrorException; - /** - *
-   * 修改门店网络信息.
-   * 通过此接口修改门店的网络信息,包括网络名称(ssid)或密码。需注意:
-   * 只有门店下已添加Wi-Fi网络信息,才能调用此接口修改网络信息;添加方式请参考“添加密码型设备”和"添加portal型设备”接口文档。
-   * 网络信息修改后,密码型设备需同步修改所有设备的ssid或密码;portal型设备需修改所有设备的ssid,并按照《硬件鉴权协议接口》修改“第二步:改造移动端portal页面”中的ssid参数,否则将无法正常连网。
-   * 文档地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1457435413
-   * 
- * - * @param shopId 门店ID - * @param oldSsid 旧的ssid - * @param ssid 无线网络设备的ssid。32个字符以内;ssid支持中文,但可能因设备兼容性问题导致显示乱码,或无法连接等问题,相关风险自行承担! 当门店下是portal型设备时,ssid必填;当门店下是密码型设备时,ssid选填,且ssid和密码必须有一个以大写字母“WX”开头 - * @param password 无线网络设备的密码。8-24个字符;不能包含中文字符; 当门店下是密码型设备时,才可填写password,且ssid和密码必须有一个以大写字母“WX”开头 - * @return 是否更新成功 - * @throws WxErrorException . - */ - boolean updateShopWifiInfo(int shopId, String oldSsid, String ssid, String password) throws WxErrorException; + /** + *
+     * 修改门店网络信息.
+     * 通过此接口修改门店的网络信息,包括网络名称(ssid)或密码。需注意:
+     * 只有门店下已添加Wi-Fi网络信息,才能调用此接口修改网络信息;添加方式请参考“添加密码型设备”和"添加portal型设备”接口文档。
+     * 网络信息修改后,密码型设备需同步修改所有设备的ssid或密码;portal型设备需修改所有设备的ssid,并按照《硬件鉴权协议接口》修改“第二步:改造移动端portal页面”中的ssid参数,否则将无法正常连网。
+     * 文档地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1457435413
+     * 
+ * + * @param shopId 门店ID + * @param oldSsid 旧的ssid + * @param ssid 无线网络设备的ssid。32个字符以内;ssid支持中文,但可能因设备兼容性问题导致显示乱码,或无法连接等问题,相关风险自行承担! 当门店下是portal型设备时,ssid必填;当门店下是密码型设备时,ssid选填,且ssid和密码必须有一个以大写字母“WX”开头 + * @param password 无线网络设备的密码。8-24个字符;不能包含中文字符; 当门店下是密码型设备时,才可填写password,且ssid和密码必须有一个以大写字母“WX”开头 + * @return 是否更新成功 boolean + * @throws WxErrorException . + */ + boolean updateShopWifiInfo(int shopId, String oldSsid, String ssid, String password) throws WxErrorException; } 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 2b8d9bfd39..d7c0f53abe 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 @@ -39,8 +39,11 @@ import org.apache.commons.lang3.StringUtils; import java.io.IOException; +import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; +import java.util.function.Function; import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.*; @@ -87,7 +90,7 @@ public abstract class BaseWxMpServiceImpl implements WxMpService, RequestH private WxMpTemplateMsgService templateMsgService = new WxMpTemplateMsgServiceImpl(this); @Getter @Setter - private final WxMpSubscribeMsgService subscribeMsgService = new WxMpSubscribeMsgServiceImpl(this); + private WxMpSubscribeMsgService subscribeMsgService = new WxMpSubscribeMsgServiceImpl(this); @Getter @Setter private WxMpDeviceService deviceService = new WxMpDeviceServiceImpl(this); @@ -105,7 +108,7 @@ public abstract class BaseWxMpServiceImpl implements WxMpService, RequestH private WxMpAiOpenService aiOpenService = new WxMpAiOpenServiceImpl(this); @Getter @Setter - private final WxMpWifiService wifiService = new WxMpWifiServiceImpl(this); + private WxMpWifiService wifiService = new WxMpWifiServiceImpl(this); @Getter @Setter private WxMpMarketingService marketingService = new WxMpMarketingServiceImpl(this); @@ -146,7 +149,19 @@ public abstract class BaseWxMpServiceImpl implements WxMpService, RequestH @Setter private WxMpReimburseInvoiceService reimburseInvoiceService = new WxMpReimburseInvoiceServiceImpl(this); - private Map configStorageMap; + @Getter + @Setter + private WxMpDraftService draftService = new WxMpDraftServiceImpl(this); + + @Getter + @Setter + private WxMpFreePublishService freePublishService = new WxMpFreePublishServiceImpl(this); + + @Getter + @Setter + private Function configStorageFunction; + + private Map configStorageMap = new HashMap<>(); private int retrySleepMillis = 1000; private int maxRetryTimes = 5; @@ -243,6 +258,55 @@ public String getAccessToken() throws WxErrorException { return getAccessToken(false); } + @Override + public String getAccessToken(boolean forceRefresh) throws WxErrorException { + if (!forceRefresh && !this.getWxMpConfigStorage().isAccessTokenExpired()) { + return this.getWxMpConfigStorage().getAccessToken(); + } + + Lock lock = this.getWxMpConfigStorage().getAccessTokenLock(); + boolean locked = false; + try { + do { + locked = lock.tryLock(100, TimeUnit.MILLISECONDS); + if (!forceRefresh && !this.getWxMpConfigStorage().isAccessTokenExpired()) { + return this.getWxMpConfigStorage().getAccessToken(); + } + } while (!locked); + + String response; + if (getWxMpConfigStorage().isStableAccessToken()) { + response = doGetStableAccessTokenRequest(forceRefresh); + } else { + response = doGetAccessTokenRequest(); + } + return extractAccessToken(response); + } catch (IOException | InterruptedException e) { + throw new WxRuntimeException(e); + } finally { + if (locked) { + lock.unlock(); + } + } + } + + /** + * 通过网络请求获取AccessToken + * + * @return . + * @throws IOException . + */ + protected abstract String doGetAccessTokenRequest() throws IOException; + + + /** + * 通过网络请求获取稳定版接口调用凭据 + * + * @return . + * @throws IOException . + */ + protected abstract String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException; + @Override public String shortUrl(String longUrl) throws WxErrorException { if (longUrl.contains("&access_token=")) { @@ -427,12 +491,12 @@ protected T executeInternal(RequestExecutor executor, String uri, E } if (error.getErrorCode() != 0) { - log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); throw new WxErrorException(error, e); } return null; } catch (IOException e) { - log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); throw new WxErrorException(e); } } @@ -461,17 +525,29 @@ protected String extractAccessToken(String resultContent) throws WxErrorExceptio @Override public void setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider) { final String defaultMpId = wxConfigProvider.getAppId(); + if (defaultMpId == null) { + throw new WxRuntimeException("appid不能设置为null"); + } + this.setMultiConfigStorages(ImmutableMap.of(defaultMpId, wxConfigProvider), defaultMpId); } @Override public void setMultiConfigStorages(Map configStorages) { + if (configStorages.isEmpty()) { + return; + } this.setMultiConfigStorages(configStorages, configStorages.keySet().iterator().next()); } @Override public void setMultiConfigStorages(Map configStorages, String defaultMpId) { - this.configStorageMap = Maps.newHashMap(configStorages); + // 防止覆盖配置 + if(this.configStorageMap != null) { + this.configStorageMap.putAll(configStorages); + } else { + this.configStorageMap = Maps.newHashMap(configStorages); + } WxMpConfigStorageHolder.set(defaultMpId); this.initHttp(); } @@ -479,7 +555,11 @@ public void setMultiConfigStorages(Map configStorages @Override public void addConfigStorage(String mpId, WxMpConfigStorage configStorages) { synchronized (this) { - if (this.configStorageMap == null) { + /* + * 因为commit 2aa27cf12d 默认初始化了configStorageMap,导致使用此方法无法进入if从而触发initHttp(), + * 就会出现HttpClient报NullPointException + */ + if (this.configStorageMap == null || this.configStorageMap.isEmpty()) { this.setWxMpConfigStorage(configStorages); } else { WxMpConfigStorageHolder.set(mpId); @@ -509,21 +589,43 @@ public void removeConfigStorage(String mpId) { @Override public WxMpService switchoverTo(String mpId) { + return switchoverTo(mpId, configStorageFunction); + } + + @Override + public WxMpService switchoverTo(String mpId, Function func) { if (this.configStorageMap.containsKey(mpId)) { WxMpConfigStorageHolder.set(mpId); return this; } - + if (func != null) { + WxMpConfigStorage storage = func.apply(mpId); + if (storage != null) { + this.addConfigStorage(mpId, storage); + return this; + } + } throw new WxRuntimeException(String.format("无法找到对应【%s】的公众号配置信息,请核实!", mpId)); } @Override public boolean switchover(String mpId) { + return switchover(mpId, configStorageFunction); + } + + @Override + public boolean switchover(String mpId, Function func) { if (this.configStorageMap.containsKey(mpId)) { WxMpConfigStorageHolder.set(mpId); return true; } - + if (func != null) { + WxMpConfigStorage storage = func.apply(mpId); + if (storage != null) { + this.addConfigStorage(mpId, storage); + return true; + } + } log.error("无法找到对应【{}】的公众号配置信息,请核实!", mpId); return false; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java index cbfd5d8d07..2ac835bbc4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java @@ -4,6 +4,7 @@ import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.WxCardApiSignature; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; @@ -161,7 +162,7 @@ public String getCardDetail(String cardId) throws WxErrorException { // 判断返回值 JsonObject json = GsonParser.parse(responseContent); - String errcode = json.get("errcode").getAsString(); + String errcode = json.get(WxConsts.ERR_CODE).getAsString(); if (!"0".equals(errcode)) { String errmsg = json.get("errmsg").getAsString(); throw new WxErrorException(WxError.builder() diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImpl.java index 8f287a80f1..3e3172d9ab 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImpl.java @@ -11,7 +11,7 @@ /** * @author Binary Wang - * @date 2019-06-16 + * created on 2019-06-16 */ @RequiredArgsConstructor public class WxMpCommentServiceImpl implements WxMpCommentService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDraftServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDraftServiceImpl.java new file mode 100644 index 0000000000..2957c3c852 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDraftServiceImpl.java @@ -0,0 +1,84 @@ +package me.chanjar.weixin.mp.api.impl; + +import lombok.AllArgsConstructor; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.mp.api.WxMpDraftService; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.draft.WxMpAddDraft; +import me.chanjar.weixin.mp.bean.draft.WxMpDraftArticles; +import me.chanjar.weixin.mp.bean.draft.WxMpDraftInfo; +import me.chanjar.weixin.mp.bean.draft.WxMpDraftList; +import me.chanjar.weixin.mp.bean.draft.WxMpUpdateDraft; +import me.chanjar.weixin.mp.enums.WxMpApiUrl; + +import java.util.ArrayList; +import java.util.List; + +/** + * 草稿箱能力-service实现类. + * + * @author dragon + * created on 2021-10-22 + */ +@AllArgsConstructor +public class WxMpDraftServiceImpl implements WxMpDraftService { + + private static final String MEDIA_ID = "media_id"; + private static final String ERRCODE_SUCCESS = "0"; + private final WxMpService mpService; + + @Override + public String addDraft(String title, String content, String thumbMediaId) throws WxErrorException { + List draftArticleList = new ArrayList<>(); + WxMpDraftArticles draftArticle = WxMpDraftArticles.builder() + .title(title).content(content).thumbMediaId(thumbMediaId).build(); + WxMpAddDraft addDraft = WxMpAddDraft.builder().articles(draftArticleList).build(); + draftArticleList.add(draftArticle); + return addDraft(addDraft); + } + + @Override + public String addDraft(WxMpAddDraft addDraft) throws WxErrorException { + String json = this.mpService.post(WxMpApiUrl.Draft.ADD_DRAFT, addDraft); + return GsonParser.parse(json).get(MEDIA_ID).getAsString(); + } + + @Override + public Boolean updateDraft(WxMpUpdateDraft updateDraftInfo) throws WxErrorException { + String json = this.mpService.post(WxMpApiUrl.Draft.UPDATE_DRAFT, updateDraftInfo); + return GsonParser.parse(json).get(WxConsts.ERR_CODE).getAsString().equals(ERRCODE_SUCCESS); + } + + @Override + public WxMpDraftInfo getDraft(String mediaId) throws WxErrorException { + return WxMpDraftInfo.fromJson(this.mpService.post(WxMpApiUrl.Draft.GET_DRAFT, + GsonHelper.buildJsonObject(MEDIA_ID, mediaId))); + } + + @Override + public Boolean delDraft(String mediaId) throws WxErrorException { + String json = this.mpService.post(WxMpApiUrl.Draft.DEL_DRAFT, + GsonHelper.buildJsonObject(MEDIA_ID, mediaId)); + return GsonParser.parse(json).get(WxConsts.ERR_CODE).getAsString().equals(ERRCODE_SUCCESS); + } + + @Override + public WxMpDraftList listDraft(int offset, int count, int noContent) throws WxErrorException { + return WxMpDraftList.fromJson(this.mpService.post(WxMpApiUrl.Draft.LIST_DRAFT, + GsonHelper.buildJsonObject("offset", offset, "count", count, "no_content", noContent))); + } + + @Override + public WxMpDraftList listDraft(int offset, int count) throws WxErrorException { + return listDraft(offset, count, 0); + } + + @Override + public Long countDraft() throws WxErrorException { + String json = this.mpService.get(WxMpApiUrl.Draft.COUNT_DRAFT, null); + return Long.valueOf(GsonParser.parse(json).get("total_count").toString()); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpFreePublishServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpFreePublishServiceImpl.java new file mode 100644 index 0000000000..8f3b2fcf3f --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpFreePublishServiceImpl.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.mp.api.impl; + +import lombok.AllArgsConstructor; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.common.util.json.GsonParser; +import me.chanjar.weixin.mp.api.WxMpFreePublishService; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishInfo; +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList; +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishStatus; +import me.chanjar.weixin.mp.enums.WxMpApiUrl; + +/** + * 发布能力-service实现类. + * + * @author dragon + * created on 2021-10-23 + */ +@AllArgsConstructor +public class WxMpFreePublishServiceImpl implements WxMpFreePublishService { + + private static final String MEDIA_ID = "media_id"; + private static final String PUBLISH_ID = "publish_id"; + private static final String ARTICLE_ID = "article_id"; + private static final String ERRCODE_SUCCESS = "0"; + private final WxMpService mpService; + + @Override + public String submit(String mediaId) throws WxErrorException { + String json = this.mpService.post(WxMpApiUrl.FreePublish.SUBMIT, + GsonHelper.buildJsonObject(MEDIA_ID, mediaId)); + return GsonParser.parse(json).get(PUBLISH_ID).toString(); + } + + @Override + public WxMpFreePublishStatus getPushStatus(String publishId) throws WxErrorException { + return WxMpFreePublishStatus.fromJson(this.mpService.post(WxMpApiUrl.FreePublish.GET_PUSH_STATUS, + GsonHelper.buildJsonObject(PUBLISH_ID, publishId))); + } + + @Override + public Boolean deletePush(String articleId, Integer index) throws WxErrorException { + String json = this.mpService.post(WxMpApiUrl.FreePublish.DEL_PUSH, + GsonHelper.buildJsonObject(ARTICLE_ID, articleId, "index", index)); + return GsonParser.parse(json).get(WxConsts.ERR_CODE).toString().equals(ERRCODE_SUCCESS); + } + + @Override + public Boolean deletePushAllArticle(String articleId) throws WxErrorException { + // index字段不填或填0会删除全部文章 + return deletePush(articleId, 0); + } + + @Override + public WxMpFreePublishInfo getArticleFromId(String articleId) throws WxErrorException { + return WxMpFreePublishInfo.fromJson(this.mpService.post(WxMpApiUrl.FreePublish.GET_ARTICLE, + GsonHelper.buildJsonObject(ARTICLE_ID, articleId))); + } + + @Override + public WxMpFreePublishList getPublicationRecords(int offset, int count, int noContent) throws WxErrorException { + return WxMpFreePublishList.fromJson(this.mpService.post(WxMpApiUrl.FreePublish.BATCH_GET, + GsonHelper.buildJsonObject("offset", offset, "count", count, "no_content", noContent))); + } + + @Override + public WxMpFreePublishList getPublicationRecords(int offset, int count) throws WxErrorException { + return getPublicationRecords(offset, count, 0); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImpl.java index 94c07ad4db..723b2572a0 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImpl.java @@ -17,7 +17,7 @@ /** * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @AllArgsConstructor public class WxMpGuideBuyerServiceImpl implements WxMpGuideBuyerService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImpl.java index 9bc7881b6d..b91c580621 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImpl.java @@ -19,7 +19,7 @@ /** * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @AllArgsConstructor public class WxMpGuideMassedJobServiceImpl implements WxMpGuideMassedJobService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImpl.java index 0584d82460..b41d4ae2ed 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImpl.java @@ -19,7 +19,7 @@ /** * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @AllArgsConstructor public class WxMpGuideMaterialServiceImpl implements WxMpGuideMaterialService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java index 3fb47d0971..dd6256c3e8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java @@ -21,7 +21,7 @@ * . * * @author Binary Wang - * @date 2020-10-06 + * created on 2020-10-06 */ @AllArgsConstructor public class WxMpGuideServiceImpl implements WxMpGuideService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImpl.java index 2747cbdae7..11b0e4d2de 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImpl.java @@ -20,7 +20,7 @@ /** * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @AllArgsConstructor diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImpl.java index 5631a44f7e..7a3f4ac377 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImpl.java @@ -22,6 +22,9 @@ @Slf4j @RequiredArgsConstructor public class WxMpMenuServiceImpl implements WxMpMenuService { + private static final String MENU_ID = "menuid"; + private static final String MATCH_RULE = "matchrule"; + private final WxMpService wxMpService; @Override @@ -38,7 +41,7 @@ public String menuCreate(WxMenu menu) throws WxErrorException { log.debug("创建菜单:{},结果:{}", menuJson, result); if (menu.getMatchRule() != null) { - return GsonParser.parse(result).get("menuid").getAsString(); + return GsonParser.parse(result).get(MENU_ID).getAsString(); } return null; @@ -48,13 +51,13 @@ public String menuCreate(WxMenu menu) throws WxErrorException { public String menuCreate(String json) throws WxErrorException { JsonObject jsonObject = GsonParser.parse(json); WxMpApiUrl.Menu url = MENU_CREATE; - if (jsonObject.get("matchrule") != null) { + if (jsonObject.get(MATCH_RULE) != null) { url = MENU_ADDCONDITIONAL; } String result = this.wxMpService.post(url, json); - if (jsonObject.get("matchrule") != null) { - return GsonParser.parse(result).get("menuid").getAsString(); + if (jsonObject.get(MATCH_RULE) != null) { + return GsonParser.parse(result).get(MENU_ID).getAsString(); } return null; @@ -69,9 +72,9 @@ public void menuDelete() throws WxErrorException { @Override public void menuDelete(String menuId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("menuid", menuId); + jsonObject.addProperty(MENU_ID, menuId); String result = this.wxMpService.post(MENU_DELCONDITIONAL, jsonObject.toString()); - log.debug("根据MeunId({})删除个性化菜单结果:{}", menuId, result); + log.debug("根据MenuId({})删除个性化菜单结果:{}", menuId, result); } @Override diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java index 11883cded3..4631a2e2cc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java @@ -1,7 +1,9 @@ package me.chanjar.weixin.mp.api.impl; import com.google.common.collect.ImmutableMap; +import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import lombok.AllArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; @@ -97,7 +99,7 @@ public MerchantInvoicePlatformInfo getMerchantInvoicePlatform(MerchantInvoicePla */ private T doCommonInvoiceHttpPost(WxMpApiUrl url, Object data, Class resultClass) throws WxErrorException { String json = ""; - final Gson gson = WxMpGsonBuilder.create(); + final Gson gson = this.createGson(); if (data != null) { json = gson.toJson(data); } @@ -108,4 +110,10 @@ private T doCommonInvoiceHttpPost(WxMpApiUrl url, Object data, Class resu return gson.fromJson(responseText, resultClass); } + + private Gson createGson() { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES); + return gsonBuilder.create(); + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java index f77da7c855..726311ffa5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java @@ -23,7 +23,7 @@ * oauth2 相关接口实现类. * * @author Binary Wang - * @date 2020-08-08 + * created on 2020-08-08 */ @RequiredArgsConstructor public class WxMpOAuth2ServiceImpl implements WxOAuth2Service { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java index 7f6a2e3cff..1c8221338f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java @@ -18,7 +18,7 @@ * ocr 接口实现. * * @author Binary Wang - * @date 2019-06-22 + * created on 2019-06-22 */ @RequiredArgsConstructor public class WxMpOcrServiceImpl implements WxOcrService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java index 8b5e029104..750f787137 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java @@ -1,23 +1,24 @@ package me.chanjar.weixin.mp.api.impl; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpType; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; +import me.chanjar.weixin.mp.bean.WxMpStableAccessTokenRequest; import me.chanjar.weixin.mp.config.WxMpConfigStorage; import org.apache.http.HttpHost; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.CloseableHttpClient; import java.io.IOException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.GET_ACCESS_TOKEN_URL; +import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.GET_STABLE_ACCESS_TOKEN_URL; /** * apache http client方式实现. @@ -64,42 +65,62 @@ public void initHttp() { } @Override - public String getAccessToken(boolean forceRefresh) throws WxErrorException { - final WxMpConfigStorage config = this.getWxMpConfigStorage(); - if (!config.isAccessTokenExpired() && !forceRefresh) { - return config.getAccessToken(); - } + protected String doGetAccessTokenRequest() throws IOException { + String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(getWxMpConfigStorage()), getWxMpConfigStorage().getAppId(), getWxMpConfigStorage().getSecret()); - Lock lock = config.getAccessTokenLock(); - boolean locked = false; + HttpGet httpGet = null; + CloseableHttpResponse response = null; try { - do { - locked = lock.tryLock(100, TimeUnit.MILLISECONDS); - if (!forceRefresh && !config.isAccessTokenExpired()) { - return config.getAccessToken(); - } - } while (!locked); - - String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret()); - try { - HttpGet httpGet = new HttpGet(url); - if (this.getRequestHttpProxy() != null) { - RequestConfig requestConfig = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); - httpGet.setConfig(requestConfig); - } - try (CloseableHttpResponse response = getRequestHttpClient().execute(httpGet)) { - return this.extractAccessToken(new BasicResponseHandler().handleResponse(response)); - } finally { - httpGet.releaseConnection(); + httpGet = new HttpGet(url); + if (this.getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); + httpGet.setConfig(config); + } + response = getRequestHttpClient().execute(httpGet); + return new BasicResponseHandler().handleResponse(response); + } finally { + if (httpGet != null) { + httpGet.releaseConnection(); + } + if (response != null) { + try { + response.close(); + } catch (IOException e) { } - } catch (IOException e) { - throw new WxRuntimeException(e); } - } catch (InterruptedException e) { - throw new WxRuntimeException(e); + } + } + + @Override + protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException { + String url = GET_STABLE_ACCESS_TOKEN_URL.getUrl(getWxMpConfigStorage()); + + HttpPost httpPost = null; + CloseableHttpResponse response = null; + try { + httpPost = new HttpPost(url); + if (this.getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); + httpPost.setConfig(config); + } + WxMpStableAccessTokenRequest wxMaAccessTokenRequest = new WxMpStableAccessTokenRequest(); + wxMaAccessTokenRequest.setAppid(this.getWxMpConfigStorage().getAppId()); + wxMaAccessTokenRequest.setSecret(this.getWxMpConfigStorage().getSecret()); + wxMaAccessTokenRequest.setGrantType("client_credential"); + wxMaAccessTokenRequest.setForceRefresh(forceRefresh); + + httpPost.setEntity(new StringEntity(wxMaAccessTokenRequest.toJson(), ContentType.APPLICATION_JSON)); + response = getRequestHttpClient().execute(httpPost); + return new BasicResponseHandler().handleResponse(response); } finally { - if (locked) { - lock.unlock(); + if (httpPost != null) { + httpPost.releaseConnection(); + } + if (response != null) { + try { + response.close(); + } catch (IOException e) { + } } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java index eb75f1ff62..b174c4bdf9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java @@ -4,15 +4,16 @@ import jodd.http.HttpRequest; import jodd.http.ProxyInfo; import jodd.http.net.SocketHttpConnectionProvider; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.error.WxRuntimeException; +import jodd.net.MimeTypes; import me.chanjar.weixin.common.util.http.HttpType; +import me.chanjar.weixin.mp.bean.WxMpStableAccessTokenRequest; import me.chanjar.weixin.mp.config.WxMpConfigStorage; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.GET_ACCESS_TOKEN_URL; +import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.GET_STABLE_ACCESS_TOKEN_URL; /** * jodd-http方式实现. @@ -51,39 +52,39 @@ public void initHttp() { } @Override - public String getAccessToken(boolean forceRefresh) throws WxErrorException { - final WxMpConfigStorage config = this.getWxMpConfigStorage(); - if (!config.isAccessTokenExpired() && !forceRefresh) { - return config.getAccessToken(); + protected String doGetAccessTokenRequest() throws IOException { + String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(getWxMpConfigStorage()), getWxMpConfigStorage().getAppId(), getWxMpConfigStorage().getSecret()); + + HttpRequest request = HttpRequest.get(url); + if (this.getRequestHttpProxy() != null) { + SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider(); + provider.useProxy(getRequestHttpProxy()); + + request.withConnectionProvider(provider); } + return request.send().bodyText(); + } - Lock lock = config.getAccessTokenLock(); - boolean locked = false; - try { - do { - locked = lock.tryLock(100, TimeUnit.MILLISECONDS); - if (!forceRefresh && !config.isAccessTokenExpired()) { - return config.getAccessToken(); - } - } while (!locked); - String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret()); - - HttpRequest request = HttpRequest.get(url); - if (this.getRequestHttpProxy() != null) { - SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider(); - provider.useProxy(getRequestHttpProxy()); - - request.withConnectionProvider(provider); - } - - return this.extractAccessToken(request.send().bodyText()); - } catch (InterruptedException e) { - throw new WxRuntimeException(e); - } finally { - if (locked) { - lock.unlock(); - } + @Override + protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException { + String url = GET_STABLE_ACCESS_TOKEN_URL.getUrl(getWxMpConfigStorage()); + + WxMpStableAccessTokenRequest wxMaAccessTokenRequest = new WxMpStableAccessTokenRequest(); + wxMaAccessTokenRequest.setAppid(this.getWxMpConfigStorage().getAppId()); + wxMaAccessTokenRequest.setSecret(this.getWxMpConfigStorage().getSecret()); + wxMaAccessTokenRequest.setGrantType("client_credential"); + wxMaAccessTokenRequest.setForceRefresh(forceRefresh); + + HttpRequest request = HttpRequest.post(url) + .contentType(MimeTypes.MIME_APPLICATION_JSON, StandardCharsets.UTF_8.name()) + .body(wxMaAccessTokenRequest.toJson()); + if (this.getRequestHttpProxy() != null) { + SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider(); + provider.useProxy(getRequestHttpProxy()); + + request.withConnectionProvider(provider); } + return request.send().bodyText(); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java index 3639d1bc06..6d4869b6a1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java @@ -1,18 +1,17 @@ package me.chanjar.weixin.mp.api.impl; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpType; +import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; +import me.chanjar.weixin.mp.bean.WxMpStableAccessTokenRequest; import me.chanjar.weixin.mp.config.WxMpConfigStorage; import okhttp3.*; import java.io.IOException; import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.GET_ACCESS_TOKEN_URL; +import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.GET_STABLE_ACCESS_TOKEN_URL; /** * okhttp实现. @@ -38,38 +37,6 @@ public HttpType getRequestType() { return HttpType.OK_HTTP; } - @Override - public String getAccessToken(boolean forceRefresh) throws WxErrorException { - final WxMpConfigStorage config = this.getWxMpConfigStorage(); - if (!config.isAccessTokenExpired() && !forceRefresh) { - return config.getAccessToken(); - } - - Lock lock = config.getAccessTokenLock(); - boolean locked = false; - try { - do { - locked = lock.tryLock(100, TimeUnit.MILLISECONDS); - if (!forceRefresh && !config.isAccessTokenExpired()) { - return config.getAccessToken(); - } - } while (!locked); - String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret()); - - Request request = new Request.Builder().url(url).get().build(); - Response response = getRequestHttpClient().newCall(request).execute(); - return this.extractAccessToken(Objects.requireNonNull(response.body()).string()); - } catch (IOException e) { - throw new WxRuntimeException(e); - } catch (InterruptedException e) { - throw new WxRuntimeException(e); - } finally { - if (locked) { - lock.unlock(); - } - } - } - @Override public void initHttp() { WxMpConfigStorage wxMpConfigStorage = getWxMpConfigStorage(); @@ -79,10 +46,7 @@ public void initHttp() { wxMpConfigStorage.getHttpProxyPort(), wxMpConfigStorage.getHttpProxyUsername(), wxMpConfigStorage.getHttpProxyPassword()); - } - - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); - if (httpProxy != null) { + OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); clientBuilder.proxy(getRequestHttpProxy().getProxy()); //设置授权 @@ -95,8 +59,36 @@ public Request authenticate(Route route, Response response) throws IOException { .build(); } }); + httpClient = clientBuilder.build(); + } else { + httpClient = DefaultOkHttpClientBuilder.get().build(); } - httpClient = clientBuilder.build(); } + @Override + protected String doGetAccessTokenRequest() throws IOException { + String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(getWxMpConfigStorage()), getWxMpConfigStorage().getAppId(), getWxMpConfigStorage().getSecret()); + + Request request = new Request.Builder().url(url).get().build(); + try (Response response = getRequestHttpClient().newCall(request).execute()) { + return Objects.requireNonNull(response.body()).string(); + } + } + + @Override + protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException { + String url = GET_STABLE_ACCESS_TOKEN_URL.getUrl(getWxMpConfigStorage()); + + WxMpStableAccessTokenRequest wxMaAccessTokenRequest = new WxMpStableAccessTokenRequest(); + wxMaAccessTokenRequest.setAppid(this.getWxMpConfigStorage().getAppId()); + wxMaAccessTokenRequest.setSecret(this.getWxMpConfigStorage().getSecret()); + wxMaAccessTokenRequest.setGrantType("client_credential"); + wxMaAccessTokenRequest.setForceRefresh(forceRefresh); + + RequestBody body = RequestBody.Companion.create(wxMaAccessTokenRequest.toJson(), MediaType.parse("application/json; charset=utf-8")); + Request request = new Request.Builder().url(url).post(body).build(); + try (Response response = getRequestHttpClient().newCall(request).execute()) { + return Objects.requireNonNull(response.body()).string(); + } + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImpl.java index 48cd042e91..2d83259e8b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImpl.java @@ -24,17 +24,17 @@ import java.io.Serializable; import java.util.List; +import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE; import static me.chanjar.weixin.mp.enums.WxMpApiUrl.SubscribeMsg.*; /** * 订阅消息接口. * * @author Mklaus - * @date 2018-01-22 上午11:19 + * created on 2018-01-22 上午11:19 */ @RequiredArgsConstructor public class WxMpSubscribeMsgServiceImpl implements WxMpSubscribeMsgService { - private static final String ERR_CODE = "errcode"; private final WxMpService service; @Override @@ -103,11 +103,12 @@ public List getCategory() throws WxErrorException { } @Override - public void send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException { + public String send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException { String responseContent = this.service.post(SEND_SUBSCRIBE_MESSAGE_URL, subscribeMessage.toJson()); JsonObject jsonObject = GsonParser.parse(responseContent); if (jsonObject.get(ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP)); } + return jsonObject.get("msgid").getAsString(); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java index c4120022e1..af4c5cfb13 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java @@ -1,7 +1,9 @@ package me.chanjar.weixin.mp.api.impl; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; @@ -12,6 +14,7 @@ import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; +import java.util.Collections; import java.util.List; import static me.chanjar.weixin.mp.enums.WxMpApiUrl.TemplateMsg.*; @@ -25,15 +28,13 @@ */ @RequiredArgsConstructor public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { - - private final WxMpService wxMpService; @Override public String sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException { String responseContent = this.wxMpService.post(MESSAGE_TEMPLATE_SEND, templateMessage.toJson()); final JsonObject jsonObject = GsonParser.parse(responseContent); - if (jsonObject.get("errcode").getAsInt() == 0) { + if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) { return jsonObject.get("msgid").getAsString(); } throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP)); @@ -58,11 +59,22 @@ public WxMpTemplateIndustry getIndustry() throws WxErrorException { @Override public String addTemplate(String shortTemplateId) throws WxErrorException { + return this.addTemplate(shortTemplateId, Collections.emptyList()); + } + + @Override + public String addTemplate(String shortTemplateId, List keywordNameList) throws WxErrorException { JsonObject jsonObject = new JsonObject(); + + JsonArray jsonArray = new JsonArray(); + keywordNameList.forEach(jsonArray::add); + jsonObject.addProperty("template_id_short", shortTemplateId); + jsonObject.add("keyword_name_list", jsonArray); + String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString()); final JsonObject result = GsonParser.parse(responseContent); - if (result.get("errcode").getAsInt() == 0) { + if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) { return result.get("template_id").getAsString(); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java index 03c83e3b45..8308f6df8d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java @@ -10,6 +10,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUserList; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import org.apache.commons.lang3.StringUtils; import java.util.HashMap; import java.util.List; @@ -52,6 +53,25 @@ public WxMpUserList userList(String nextOpenid) throws WxErrorException { return WxMpUserList.fromJson(responseContent); } + @Override + public WxMpUserList userList() throws WxErrorException { + String responseContent = this.wxMpService.get(USER_GET_URL, null); + WxMpUserList mergeList = new WxMpUserList(); + + WxMpUserList wxMpUserList = WxMpUserList.fromJson(responseContent); + mergeList.getOpenids().addAll(wxMpUserList.getOpenids()); + mergeList.setCount(wxMpUserList.getCount()); + mergeList.setTotal(wxMpUserList.getTotal()); + + while (StringUtils.isNotEmpty(wxMpUserList.getNextOpenid())) { + WxMpUserList nextReqUserList = userList(wxMpUserList.getNextOpenid()); + mergeList.getOpenids().addAll(nextReqUserList.getOpenids()); + mergeList.setCount(mergeList.getCount() + nextReqUserList.getCount()); + wxMpUserList = nextReqUserList; + } + return mergeList; + } + @Override public List changeOpenid(String fromAppid, List openidList) throws WxErrorException { Map map = new HashMap<>(2); 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 ce1d77b62e..80e1658c16 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 @@ -36,6 +36,10 @@ public class WxMpMassOpenIdsMessage implements Serializable { private String msgType; private String content; private String mediaId; + /** + * 图片列表 + */ + private List mediaIds; /** * 文章被判定为转载时,是否继续进行群发操作。 */ 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 5e0b638e9f..598e5754f1 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 @@ -5,6 +5,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; +import java.util.List; /** * 按标签群发的消息. @@ -34,6 +35,10 @@ public class WxMpMassTagMessage implements Serializable { private String msgType; private String content; private String mediaId; + /** + * 图片列表 + */ + private List mediaIds; /** * 是否群发给所有用户. */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpStableAccessTokenRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpStableAccessTokenRequest.java new file mode 100644 index 0000000000..50662e2636 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpStableAccessTokenRequest.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.mp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +import java.io.Serializable; + +/** + * @author SKYhuangjing + * 微信公众号 获取稳定版接口调用凭据 请求参数 + */ +@Data +public class WxMpStableAccessTokenRequest implements Serializable { + + private static final long serialVersionUID = 1L; + + @SerializedName("grant_type") + private String grantType = "client_credential"; + + @SerializedName("appid") + private String appid; + @SerializedName("secret") + private String secret; + + @SerializedName("force_refresh") + private boolean forceRefresh; + + public String toJson() { + return WxMpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/AbstractCardCreateRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/AbstractCardCreateRequest.java index 7655b240db..0e2cacc67f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/AbstractCardCreateRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/AbstractCardCreateRequest.java @@ -8,7 +8,7 @@ * . * * @author leeis - * @date 2018/12/29 + * created on 2018/12/29 */ @Data public abstract class AbstractCardCreateRequest implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/BaseWxMpCardResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/BaseWxMpCardResult.java index 72c7420f01..dd889ff4a7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/BaseWxMpCardResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/BaseWxMpCardResult.java @@ -6,7 +6,7 @@ * 卡券返回结果基础类. * * @author fanxl - * @date 2019/1/22 0022 10:08 + * created on 2019/1/22 0022 10:08 */ public class BaseWxMpCardResult implements Serializable { private static final long serialVersionUID = -3502867243738689870L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/Card.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/Card.java index 6e0f32edc4..cdea61217f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/Card.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/Card.java @@ -8,7 +8,7 @@ /** * . * @author leeis - * @date 2018/12/29 + * created on 2018/12/29 */ @Data public class Card implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CardUpdateResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CardUpdateResult.java index e5d04358d4..3a82067597 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CardUpdateResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CardUpdateResult.java @@ -7,7 +7,7 @@ /** * @author yqx - * @date 2018/11/07 + * created on 2018/11/07 */ @Data public class CardUpdateResult implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCard.java index df5290b218..3ab25b1c63 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCard.java @@ -10,7 +10,7 @@ /** * . * @author leeis - * @Date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCardCreateRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCardCreateRequest.java index ab4d54e477..59999a10d9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCardCreateRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/CashCardCreateRequest.java @@ -11,7 +11,7 @@ * . * * @author leeis - * @date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCard.java index 60c7c911bd..edc0657017 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCard.java @@ -9,7 +9,7 @@ /** * . * @author leeis - * @Date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCardCreateRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCardCreateRequest.java index e125c19057..530365dea1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCardCreateRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/DiscountCardCreateRequest.java @@ -10,7 +10,7 @@ /** * . * @author leeis - * @Date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCoupon.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCoupon.java index df8194a6ac..0e051b0e36 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCoupon.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCoupon.java @@ -10,7 +10,7 @@ /** * . * @author leeis - * @date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCouponCreateRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCouponCreateRequest.java index b44dc74cf8..30ea5c6dab 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCouponCreateRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GeneralCouponCreateRequest.java @@ -10,7 +10,7 @@ /** * . * @author leeis - * @date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCard.java index 1712b19eb7..b3377ce7d4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCard.java @@ -8,7 +8,7 @@ /** * . * @author leeis - * @Date 2018/12/29 + * created on 2018/12/29 */ @Data public final class GiftCard extends Card implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCardCreateRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCardCreateRequest.java index a757b00f48..48ad1bed27 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCardCreateRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GiftCardCreateRequest.java @@ -10,7 +10,7 @@ /** * . * @author leeis - * @Date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCard.java index ba343a435b..d5c6f5dcce 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCard.java @@ -10,7 +10,7 @@ /** * . * @author leeis - * @Date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCardCreateRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCardCreateRequest.java index 1f001549e7..db283b0650 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCardCreateRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/GrouponCardCreateRequest.java @@ -10,7 +10,7 @@ /** * . * @author leeis - * @Date 2018/12/29 + * created on 2018/12/29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/UserCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/UserCard.java index 5985988e01..83611370be 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/UserCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/UserCard.java @@ -7,7 +7,7 @@ /** * 用户已领卡圈对象 * @author yang229 - * @date 2019/12/22 + * created on 2019/12/22 */ @Data public class UserCard implements java.io.Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardDeleteResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardDeleteResult.java index 8eedbebf60..e2848f652d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardDeleteResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardDeleteResult.java @@ -6,7 +6,7 @@ * 删除卡券结果. * * @author fanxl - * @date 2019/1/22 0022 10:24 + * created on 2019/1/22 0022 10:24 */ public class WxMpCardDeleteResult extends BaseWxMpCardResult { private static final long serialVersionUID = -4367717540650523290L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxUserCardListResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxUserCardListResult.java index e38c11564e..4cdd5a0d05 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxUserCardListResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxUserCardListResult.java @@ -11,7 +11,7 @@ * 用户已领卡券返回 * * @author yang229 - * @date 2019/12/22 + * created on 2019/12/22 */ @Data public class WxUserCardListResult implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardColor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardColor.java index 0977cc9239..a694d4d372 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardColor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardColor.java @@ -4,7 +4,7 @@ * 会员卡颜色 * * @author yuanqixun - * @date 2018-08-29 + * created on 2018-08-29 */ public enum CardColor { Color010("#63b359"), diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardFieldType.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardFieldType.java index 4134f3e543..42804b635b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardFieldType.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardFieldType.java @@ -4,7 +4,7 @@ * 微信卡券激活字段类型 * * @author yuanqixun - * @date 2018-08-30 + * created on 2018-08-30 */ public enum CardFieldType { COMMON_FIELD("微信选项"), diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardRichFieldType.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardRichFieldType.java index 40d4b79fac..7659864939 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardRichFieldType.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardRichFieldType.java @@ -4,7 +4,7 @@ * 会员卡富文本字段类型 * * @author yuanqixun - * @date 2018-08-30 + * created on 2018-08-30 */ public enum CardRichFieldType { FORM_FIELD_RADIO("自定义单选"), diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardWechatFieldType.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardWechatFieldType.java index 1d57bbda97..c34bd58ace 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardWechatFieldType.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/enums/CardWechatFieldType.java @@ -4,7 +4,7 @@ * 微信卡券激活字段类型 * * @author yuanqixun - * @date 2018-08-30 + * created on 2018-08-30 */ public enum CardWechatFieldType { USER_FORM_INFO_FLAG_MOBILE("手机号"), diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParam.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParam.java index 1ce8ef128c..f4384a0c12 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParam.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParam.java @@ -5,7 +5,7 @@ /** * @author yqx - * @date 2018/9/19 + * created on 2018/9/19 */ @Data public class ActivatePluginParam { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParamResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParamResult.java index 8e7be799a4..b67c0147a4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParamResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/ActivatePluginParamResult.java @@ -4,7 +4,7 @@ /** * @author yqx - * @date 2018/9/19 + * created on 2018/9/19 */ @Data public class ActivatePluginParamResult { 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 8dd758c372..d8634cfa3c 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 @@ -11,7 +11,7 @@ * 会员卡激活,用户字段提交请求 * * @author yuanqixun - * @date 2018-08-30 + * created on 2018-08-30 */ @Data public class MemberCardActivateUserFormRequest implements Serializable { 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 9edc0f89b4..0c0fae3e2b 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 @@ -15,7 +15,7 @@ * 用户表单对象. * * @author yuanqixun - * @date 2018-08-30 + * created on 2018-08-30 */ @Data public class MemberCardUserForm implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserFormRichField.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserFormRichField.java index a9837029df..9fedd7a535 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserFormRichField.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserFormRichField.java @@ -12,7 +12,7 @@ * 富文本字段. * * @author yuanqixun - * @date 2018-08-30 + * created on 2018-08-30 */ @Data public class MemberCardUserFormRichField { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserInfo.java index e411e19e96..ae75874f76 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserInfo.java @@ -6,7 +6,7 @@ /** * @author YuJian - * @date 2017/7/11 + * created on 2017/7/11 */ @Data public class MemberCardUserInfo implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NameValues.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NameValues.java index 32275e8ce6..759a2580ae 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NameValues.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NameValues.java @@ -7,7 +7,7 @@ /** * * @author YuJian - * @date 2017/7/11 + * created on 2017/7/11 */ @Data public class NameValues implements Serializable{ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardActivateTempInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardActivateTempInfoResult.java index 07b2d25719..85ef0f9f04 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardActivateTempInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardActivateTempInfoResult.java @@ -6,7 +6,7 @@ /** * @author thomas - * @date 2019/4/26 + * created on 2019/4/26 */ @Data public class WxMpMemberCardActivateTempInfoResult { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/comment/WxMpCommentListVo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/comment/WxMpCommentListVo.java index 10d1dafcad..492df23057 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/comment/WxMpCommentListVo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/comment/WxMpCommentListVo.java @@ -11,7 +11,7 @@ * 群发图文评论数据. * * @author Binary Wang - * @date 2019-08-30 + * created on 2019-08-30 */ @Data public class WxMpCommentListVo implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java index d49999c504..260edd61fd 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java @@ -8,7 +8,7 @@ * 设备抽象类. * * @author keungtung - * @date 14/12/2016 + * created on 14/12/2016 */ public abstract class AbstractDeviceBean implements Serializable { private static final long serialVersionUID = 4359729626772515385L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java index 5c66b0cd60..a0b65c8842 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java @@ -6,7 +6,7 @@ /** * @author keungtung. - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java index 601f848223..8d2d59a29d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java @@ -7,7 +7,7 @@ /** * * @author keungtung. - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java index f2b35da5ea..f8fd517674 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java @@ -8,7 +8,7 @@ /** * * @author keungtung. - * @date 14/12/2016 + * created on 14/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java index 84c5b2d66d..d2d0c9c476 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java @@ -7,7 +7,7 @@ /** * @author keungtung - * @date 10/12/2016 + * created on 10/12/2016 */ @Data public class WxDevice implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java index 5e00c4faea..46f7f79c17 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -10,7 +10,7 @@ /** * @author keungtung - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java index 9608452ce1..1927a2e301 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java @@ -8,7 +8,7 @@ /** * @author keungtung. - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java index aeb7f819ce..009a567778 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java @@ -6,7 +6,7 @@ /** * @author keungtung. - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java index 6227a6ef44..0cdb83b04b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java @@ -9,7 +9,7 @@ /** * @author keungtung. - * @date 16/12/2016 + * created on 16/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java index f6c702aa29..1c3303ac5d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java @@ -7,7 +7,7 @@ /** * @author keungtung. - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java index 2b554abc27..9b603eb4df 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java @@ -7,7 +7,7 @@ /** * @author keungtung. - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java index 95cf2a94ff..0158567e50 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java @@ -9,7 +9,7 @@ /** * @author keungtung. - * @date 16/12/2016 + * created on 16/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java index 816354818c..aca51bfc82 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java @@ -7,7 +7,7 @@ /** * @author keungtung. - * @date 10/12/2016 + * created on 10/12/2016 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpAddDraft.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpAddDraft.java new file mode 100644 index 0000000000..762657ff35 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpAddDraft.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.mp.bean.draft; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 草稿箱能力-新建草稿. + * + * @author dragon + * created on 2021-10-22 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class WxMpAddDraft implements ToJson, Serializable { + private static final long serialVersionUID = 2481699972367293721L; + + /** + * 图文素材列表 + */ + @SerializedName("articles") + private List articles; + + public static WxMpAddDraft fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpAddDraft.class); + } + + @Override + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftArticles.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftArticles.java new file mode 100644 index 0000000000..f9dcb23240 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftArticles.java @@ -0,0 +1,91 @@ +package me.chanjar.weixin.mp.bean.draft; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 草稿箱能力-图文素材文章实体. + * + * @author dragon + * created on 2021-10-22 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class WxMpDraftArticles implements ToJson, Serializable { + /** + * 标题 + */ + @SerializedName("title") + private String title; + /** + * 作者 + */ + @SerializedName("author") + private String author; + /** + * 图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空。如果本字段为没有填写,则默认抓取正文前54个字。 + */ + @SerializedName("digest") + private String digest; + /** + * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS,涉及图片url必须来源 "上传图文消息内的图片获取URL"接口获取。外部图片url将被过滤。 + */ + @SerializedName("content") + private String content; + /** + * 图文消息的原文地址,即点击“阅读原文”后的URL + */ + @SerializedName("content_source_url") + private String contentSourceUrl; + /** + * 图文消息的封面图片素材id(必须是永久MediaID) + */ + @SerializedName("thumb_media_id") + private String thumbMediaId; + /** + * 是否显示封面,0为false,即不显示,1为true,即显示(默认) + */ + @SerializedName("show_cover_pic") + private Integer showCoverPic; + /** + * 是否打开评论,0不打开(默认),1打开 + */ + @SerializedName("need_open_comment") + private Integer needOpenComment; + /** + * 是否粉丝才可评论,0所有人可评论(默认),1粉丝才可评论 + */ + @SerializedName("only_fans_can_comment") + private Integer onlyFansCanComment; + /** + * 草稿的临时链接,点击图文消息跳转链接 + */ + @SerializedName("url") + private String url; + /** + * 图文消息的封面url + */ + @SerializedName("thumb_url") + private String thumbUrl; + + public static WxMpDraftArticles fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpDraftArticles.class); + } + + @Override + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftInfo.java new file mode 100644 index 0000000000..8520220e6f --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftInfo.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.mp.bean.draft; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 草稿箱能力-获取草稿详情. + * + * @author dragon + * created on 2021-10-22 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class WxMpDraftInfo implements ToJson, Serializable { + private static final long serialVersionUID = 6111694033486314392L; + + /** + * 文章列表 + */ + @SerializedName("news_item") + private List newsItem; + + public static WxMpDraftInfo fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpDraftInfo.class); + } + + @Override + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftItem.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftItem.java new file mode 100644 index 0000000000..40f129322c --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftItem.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.mp.bean.draft; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 一条草稿 + * + * @author dragon + * created on 2021-10-22 + */ +@Data +public class WxMpDraftItem implements Serializable { + private static final long serialVersionUID = 214696458030935146L; + + /** + * 图文消息的id + */ + @SerializedName("media_id") + private String mediaId; + /** + * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS。 + */ + @SerializedName("content") + private WxMpDraftInfo content; + + /** + * 本草稿的图文消息素材的最后更新时间 + */ + @SerializedName("update_time") + private Long updateTime; + + public static WxMpDraftItem fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpDraftItem.class); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftList.java new file mode 100644 index 0000000000..b77f0f9325 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpDraftList.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.mp.bean.draft; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 草稿箱能力-获取草稿列表. + * + * @author dragon + * created on 2021-10-22 + */ +@Data +public class WxMpDraftList implements Serializable { + private static final long serialVersionUID = 7216822694952035295L; + + /** + * 草稿素材的总数 + */ + @SerializedName("total_count") + private Integer totalCount; + + /** + * 本次调用获取的素材的数量 + */ + @SerializedName("item_count") + private Integer itemCount; + + /** + * 所有草稿列表 + */ + @SerializedName("item") + private List items; + + public static WxMpDraftList fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpDraftList.class); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpUpdateDraft.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpUpdateDraft.java new file mode 100644 index 0000000000..9b5473936e --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/draft/WxMpUpdateDraft.java @@ -0,0 +1,55 @@ +package me.chanjar.weixin.mp.bean.draft; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 草稿箱能力-修改草稿. + * + * @author dragon + * created on 2021-10-22 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class WxMpUpdateDraft implements ToJson, Serializable { + + private static final long serialVersionUID = -8564521168423899915L; + /** + * 要修改的图文消息的id + */ + @SerializedName("media_id") + private String mediaId; + + /** + * 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为0 + */ + @SerializedName("index") + private Integer index; + + /** + * 图文素材列表 + */ + @SerializedName("articles") + private WxMpDraftArticles articles; + + public static WxMpUpdateDraft fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpUpdateDraft.class); + } + + @Override + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishArticles.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishArticles.java new file mode 100644 index 0000000000..13410642b2 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishArticles.java @@ -0,0 +1,91 @@ +package me.chanjar.weixin.mp.bean.freepublish; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 一条发布的图文记录 + * + * @author dragon + * created on 2021-10-23 + */ +@NoArgsConstructor +@Data +public class WxMpFreePublishArticles implements Serializable { + private static final long serialVersionUID = -6435229818150835883L; + + /** + * 标题 + */ + @SerializedName("title") + private String title; + /** + * 作者 + */ + @SerializedName("author") + private String author; + /** + * 图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空。 + */ + @SerializedName("digest") + private String digest; + /** + * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS + */ + @SerializedName("content") + private String content; + /** + * 图文消息的原文地址,即点击“阅读原文”后的URL + */ + @SerializedName("content_source_url") + private String contentSourceUrl; + /** + * 图文消息的封面图片素材id(一定是永久MediaID) + */ + @SerializedName("thumb_media_id") + private String thumbMediaId; + /** + * 是否显示封面,0为false,即不显示,1为true,即显示(默认) + */ + @SerializedName("show_cover_pic") + private Integer showCoverPic; + /** + * 是否打开评论,0不打开(默认),1打开 + */ + @SerializedName("need_open_comment") + private Integer needOpenComment; + /** + * 是否粉丝才可评论,0所有人可评论(默认),1粉丝才可评论 + */ + @SerializedName("only_fans_can_comment") + private Integer onlyFansCanComment; + + /** + * 图文消息的封面url + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /* + * ===== 上面的参数,就是草稿箱的内容的字段,为了后续扩展,单独写一份==== + */ + + /** + * 草稿的临时链接 + */ + @SerializedName("url") + private String url; + /** + * 该图文是否被删除 + */ + @SerializedName("is_deleted") + private Boolean isDeleted; + + public static WxMpFreePublishArticles fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpFreePublishArticles.class); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishInfo.java new file mode 100644 index 0000000000..4abbb3456f --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishInfo.java @@ -0,0 +1,44 @@ +package me.chanjar.weixin.mp.bean.freepublish; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 发布能力-通过 article_id 获取已发布文章. + * + * @author dragon + * created on 2021-10-23 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class WxMpFreePublishInfo implements ToJson, Serializable { + private static final long serialVersionUID = 3331288672996730705L; + + /** + * 文章列表 + */ + @SerializedName("news_item") + private List newsItem; + + public static WxMpFreePublishInfo fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpFreePublishInfo.class); + } + + @Override + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishItem.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishItem.java new file mode 100644 index 0000000000..c27ee24336 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishItem.java @@ -0,0 +1,42 @@ +package me.chanjar.weixin.mp.bean.freepublish; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 发布列表的一条记录 + * + * @author dragon + * created on 2021-10-23 + */ +@NoArgsConstructor +@Data +public class WxMpFreePublishItem implements Serializable { + private static final long serialVersionUID = -6435229818150835883L; + + /** + * 成功发布的图文消息id + */ + @SerializedName("article_id") + private String articleId; + + /** + * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS。 + */ + @SerializedName("content") + private WxMpFreePublishInfo content; + + /** + * 这篇图文消息素材的最后更新时间 + */ + @SerializedName("update_time") + private String updateTime; + + public static WxMpFreePublishItem fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpFreePublishItem.class); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishList.java new file mode 100644 index 0000000000..e52ff6f2fc --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishList.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.mp.bean.freepublish; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 发布能力-获取成功发布列表. + * + * @author dragon + * created on 2021-10-22 + */ +@Data +public class WxMpFreePublishList implements Serializable { + private static final long serialVersionUID = 764054773431665250L; + + /** + * 成功发布素材的总数 + */ + @SerializedName("total_count") + private Integer totalCount; + + /** + * 本次调用获取的素材的数量 + */ + @SerializedName("item_count") + private Integer itemCount; + + /** + * 所有成功发布列表 + */ + @SerializedName("item") + private List items; + + public static WxMpFreePublishList fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpFreePublishList.class); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishStatus.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishStatus.java new file mode 100644 index 0000000000..844ad4b241 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishStatus.java @@ -0,0 +1,58 @@ +package me.chanjar.weixin.mp.bean.freepublish; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.bean.ToJson; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 发布能力-发布状态轮询接口,通过publishId返回 article_id(删除发布时需要用到). + * + * @author dragon + * created on 2021-10-23 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class WxMpFreePublishStatus implements ToJson, Serializable { + + private static final long serialVersionUID = -7526369389476785732L; + private String publish_id; + private Integer publish_status; + private String article_id; + private ArticleDetail article_detail; + private List fail_idx; + + public static WxMpFreePublishStatus fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxMpFreePublishStatus.class); + } + + @Override + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + + @NoArgsConstructor + @Data + public static class ArticleDetail implements Serializable{ + private static final long serialVersionUID = 2802949203075628412L; + private Integer count; + private List item; + + @NoArgsConstructor + @Data + public static class Item implements Serializable{ + private static final long serialVersionUID = -6496102084844816489L; + private Integer idx; + private String article_url; + } + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideAutoReply.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideAutoReply.java index 87ad3cb3fc..4874dab7bf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideAutoReply.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideAutoReply.java @@ -12,7 +12,7 @@ * 关注顾问自动回复(欢迎语)添加实体 * * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data @Builder diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideBuyerInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideBuyerInfo.java index caac651070..23efa0a20a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideBuyerInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideBuyerInfo.java @@ -11,7 +11,7 @@ /** * 客户信息dto * @author 广州跨界-宋心成 - * @date 2021/5/11/011 + * created on 2021/5/11/011 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAcctConfig.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAcctConfig.java index fcd817a981..a0be253d1d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAcctConfig.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAcctConfig.java @@ -9,7 +9,7 @@ /** * 离线自动回复与敏感词 * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data public class WxMpGuideAcctConfig implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAutoReply.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAutoReply.java index b0ea06a46d..1cee5ebe90 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAutoReply.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAutoReply.java @@ -11,7 +11,7 @@ * 关注顾问自动回复(欢迎语) * * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data public class WxMpGuideAutoReply implements ToJson, Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfo.java index a692c7d15e..6e577a7313 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfo.java @@ -15,7 +15,7 @@ * 客户信息 * * @author 广州跨界-宋心成 - * @date 2021/5/10/010 + * created on 2021/5/10/010 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfoList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfoList.java index 530a7810c5..9476c2eded 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfoList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfoList.java @@ -10,7 +10,7 @@ /** * 顾问的客户列表 * @author 广州跨界-宋心成 - * @date 2021/5/11/011 + * created on 2021/5/11/011 */ @Data public class WxMpGuideBuyerInfoList implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerRelation.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerRelation.java index f4609937a8..964e4ab339 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerRelation.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerRelation.java @@ -11,7 +11,7 @@ * 客户顾问关系 * * @author 广州跨界-宋心成 - * @date 2021/5/11/011 + * created on 2021/5/11/011 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerResp.java index f0707ebd7a..6ace2e6057 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerResp.java @@ -10,7 +10,7 @@ /** * 批量操作客户是否成功返回信息 * @author 广州跨界-宋心成 - * @date 2021/5/10/010 + * created on 2021/5/10/010 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideCardMaterialInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideCardMaterialInfo.java index 7c83432de4..c85bb4ef30 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideCardMaterialInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideCardMaterialInfo.java @@ -11,7 +11,7 @@ * 小程序素材信息 * * @author 广州跨界-宋心成 - * @date 2021/5/12/012 + * created on 2021/5/12/012 */ @Data public class WxMpGuideCardMaterialInfo implements ToJson, Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideConfig.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideConfig.java index 9ddaf7318f..da23fdbb0c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideConfig.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideConfig.java @@ -10,7 +10,7 @@ /** * 获取快捷回复,关注顾问自动回复返回类 * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data public class WxMpGuideConfig implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideFastReply.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideFastReply.java index 116ed91c70..e131380af9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideFastReply.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideFastReply.java @@ -11,7 +11,7 @@ * 顾问快捷回复 * * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data public class WxMpGuideFastReply implements ToJson, Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroup.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroup.java index f37677ea79..c3e0416fc0 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroup.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroup.java @@ -11,7 +11,7 @@ * 顾问分组信息 * * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data public class WxMpGuideGroup implements ToJson, Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfo.java index 4173ad35d2..e579af9aa8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfo.java @@ -15,7 +15,7 @@ * 分组顾问信息. * * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data @Builder diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfoList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfoList.java index 63e18b80d7..e4b1c1e867 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfoList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfoList.java @@ -10,7 +10,7 @@ /** * 顾问分组内顾问信息 * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data public class WxMpGuideGroupInfoList implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfo.java index 854d6ab8ac..da63bcea4b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfo.java @@ -10,7 +10,7 @@ /** * 图片素材信息 * @author 广州跨界-宋心成 - * @date 2021/5/12/012 + * created on 2021/5/12/012 */ @Data public class WxMpGuideImgMaterialInfo implements ToJson, Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfoList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfoList.java index f87900191d..2dc2bfc420 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfoList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfoList.java @@ -11,7 +11,7 @@ * 图片素材列表 * * @author 广州跨界-宋心成 - * @date 2021/5/12/012 + * created on 2021/5/12/012 */ @Data public class WxMpGuideImgMaterialInfoList implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideInfo.java index b20b743ab4..3a6db16675 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideInfo.java @@ -15,7 +15,7 @@ * 对话能力-顾问信息. * * @author Binary Wang - * @date 2020-10-06 + * created on 2020-10-06 */ @Data @Builder diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java index e550c34608..2802b9b7a5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java @@ -11,7 +11,7 @@ * 顾问列表. * * @author Binary Wang - * @date 2020-10-07 + * created on 2020-10-07 */ @Data public class WxMpGuideList implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassed.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassed.java index 258793ccad..584eae3e27 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassed.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassed.java @@ -13,7 +13,7 @@ * 添加群发任务返回值 * * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @Data public class WxMpGuideMassed implements ToJson, Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedBuyerInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedBuyerInfo.java index 58f6345f33..cf69140d87 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedBuyerInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedBuyerInfo.java @@ -11,7 +11,7 @@ * 下方客户状态信息 * * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedInfo.java index ddce7d6b73..c624d79538 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedInfo.java @@ -13,7 +13,7 @@ * 群发任务信息 * * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMaterialInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMaterialInfo.java index e7426fcc9c..21443aaa78 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMaterialInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMaterialInfo.java @@ -11,7 +11,7 @@ /** * 素材信息 * @author 广州跨界-宋心成 - * @date 2021/5/13/013 + * created on 2021/5/13/013 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsg.java index 37e1246579..052e4ef27f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsg.java @@ -14,7 +14,7 @@ /** * 顾问聊天记录 * @author 广州跨界-宋心成 - * @date 2021/5/7/007 + * created on 2021/5/7/007 */ @Data @Builder diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsgList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsgList.java index 04e58b0c3d..14077cb3ed 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsgList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsgList.java @@ -10,7 +10,7 @@ /** * 顾问聊天记录列表 * @author 广州跨界-宋心成 - * @date 2021/5/7/007 + * created on 2021/5/7/007 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideOffLineReply.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideOffLineReply.java index 37ea15937f..8f7a79b67b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideOffLineReply.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideOffLineReply.java @@ -15,7 +15,7 @@ * 离线自动回复 * * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data @Builder diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideSensitiveWords.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideSensitiveWords.java index 3346def2b0..b1b6d78a02 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideSensitiveWords.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideSensitiveWords.java @@ -11,7 +11,7 @@ * 顾问敏感词 * * @author 广州跨界-宋心成 - * @date 2021/5/8/008 + * created on 2021/5/8/008 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideTagInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideTagInfo.java index 2d39ebcba3..dba026783b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideTagInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideTagInfo.java @@ -12,7 +12,7 @@ * 标签信息 * * @author 广州跨界-宋心成 - * @date 2021/5/11/011 + * created on 2021/5/11/011 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfo.java index 213615d547..1193caeacc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfo.java @@ -9,7 +9,7 @@ /** 文字素材信息 * @author 广州跨界-宋心成 - * @date 2021/5/12/012 + * created on 2021/5/12/012 */ @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfoList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfoList.java index 52ee16adad..861555c2ad 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfoList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfoList.java @@ -10,7 +10,7 @@ /** * 文字素材信息列表 * @author 广州跨界-宋心成 - * @date 2021/5/12/012 + * created on 2021/5/12/012 */ @Data public class WxMpGuideWordMaterialInfoList implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/ClearOutInvoiceRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/ClearOutInvoiceRequest.java index 108e76ca23..7b90a0797f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/ClearOutInvoiceRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/ClearOutInvoiceRequest.java @@ -6,15 +6,18 @@ /** * 发票充红请求参数 + * + * @author Mario Luo */ @Data public class ClearOutInvoiceRequest implements Serializable { - + private static final long serialVersionUID = 36469746428007271L; private ClearOutInvoiceInfo invoiceinfo; @Data public static class ClearOutInvoiceInfo implements Serializable { + private static final long serialVersionUID = -9119257155033644495L; /** * 用户的openid 用户知道是谁在开票 diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataRequest.java index 092e16410a..cef4690999 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataRequest.java @@ -1,23 +1,29 @@ package me.chanjar.weixin.mp.bean.invoice.merchant; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.io.Serializable; /** * 获取电子开票用户授权数据 + * + * @author Mario Luo */ @Data public class InvoiceAuthDataRequest implements Serializable { + private static final long serialVersionUID = -7423619297443219650L; /** * 开票平台在微信的标识号,商户需要找开票平台提供 */ + @SerializedName("s_pappid") private String sPappid; /** * 订单id,在商户内单笔开票请求的唯一识别号 */ + @SerializedName("order_id") private String orderId; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataResult.java index 99d8f57cc6..433c700c99 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthDataResult.java @@ -7,9 +7,12 @@ /** * 用户开票认证信息返回结果DTO + * + * @author Mario Luo */ @Data public class InvoiceAuthDataResult implements Serializable { + private static final long serialVersionUID = 7199243456761896912L; /** * 订单授权状态,当errcode为0时会出现 @@ -28,6 +31,8 @@ public class InvoiceAuthDataResult implements Serializable { @Data public static class UserAuthInfo implements Serializable { + private static final long serialVersionUID = 3132380567762544927L; + /** * 个人抬头 */ @@ -41,6 +46,8 @@ public static class UserAuthInfo implements Serializable { @Data public static class UserField implements Serializable { + private static final long serialVersionUID = 2114368427010646381L; + private String title; private String phone; private String email; @@ -49,6 +56,8 @@ public static class UserField implements Serializable { @Data public static class BizField implements Serializable { + private static final long serialVersionUID = 1799355181972008881L; + private String title; private String taxNo; private String addr; @@ -60,6 +69,8 @@ public static class BizField implements Serializable { @Data public static class KeyValuePair implements Serializable { + private static final long serialVersionUID = -1068075389526145791L; + private String key; private String value; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageRequest.java index 07a8a24e55..0b50111df2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageRequest.java @@ -1,23 +1,29 @@ package me.chanjar.weixin.mp.bean.invoice.merchant; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.io.Serializable; /** * 获取授权地址的输入参数 + * + * @author Mario Luo */ @Data public class InvoiceAuthPageRequest implements Serializable { + private static final long serialVersionUID = -804002889404266929L; /** * 开票平台在微信的标识号,商户需要找开票平台提供 */ + @SerializedName("s_pappid") private String sPappid; /** * 订单id,在商户内单笔开票请求的唯一识别号 */ + @SerializedName("order_id") private String orderId; /** @@ -33,6 +39,7 @@ public class InvoiceAuthPageRequest implements Serializable { /** * 授权成功后跳转页面。本字段只有在source为H5的时候需要填写,引导用户在微信中进行下一步流程。app开票因为从外部app拉起微信授权页,授权完成后自动回到原来的app,故无需填写。 */ + @SerializedName("redirect_url") private String redirectUrl; /** diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageResult.java index d137adb49a..1ab3513bfe 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageResult.java @@ -6,9 +6,12 @@ /** * 获取授权链接返回结果DTO + * + * @author Mario Luo */ @Data public class InvoiceAuthPageResult implements Serializable { + private static final long serialVersionUID = 2922797121045894425L; /** * 授权页地址 diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageSetting.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageSetting.java index dbc04816ec..83a72c852d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageSetting.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceAuthPageSetting.java @@ -5,19 +5,27 @@ import java.io.Serializable; import java.util.List; +/** + * @author Mario Luo + */ @Data public class InvoiceAuthPageSetting implements Serializable { + private static final long serialVersionUID = 4585269585619597753L; private AuthField authField; @Data public static class AuthField implements Serializable { + private static final long serialVersionUID = 7341329271546930795L; + private UserField userField; private BizField bizField; } @Data public static class UserField implements Serializable { + private static final long serialVersionUID = -128178697394854697L; + private Integer showTitle; private Integer showPhone; private Integer showEmail; @@ -28,6 +36,8 @@ public static class UserField implements Serializable { @Data public static class BizField implements Serializable { + private static final long serialVersionUID = -8277885344416192644L; + private Integer showTitle; private Integer showTaxNo; private Integer showAddr; @@ -45,6 +55,8 @@ public static class BizField implements Serializable { @Data public static class CustomField implements Serializable { + private static final long serialVersionUID = -3838241240210071209L; + /** * 字段名 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceRejectRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceRejectRequest.java index 9048ceb059..992faa4d2c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceRejectRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceRejectRequest.java @@ -1,20 +1,29 @@ package me.chanjar.weixin.mp.bean.invoice.merchant; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + import java.io.Serializable; /** * 拒绝开票请求参数 + * + * @author Mario Luo */ +@Data public class InvoiceRejectRequest implements Serializable { + private static final long serialVersionUID = -5303749544133451879L; /** * 开票平台标示 */ + @SerializedName("s_pappid") private String sPappid; /** * 订单id */ + @SerializedName("order_id") private String orderId; /** diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceResult.java index 6f4da63a20..184b57970c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/InvoiceResult.java @@ -6,9 +6,12 @@ /** * 电子发票信息查询结果 + * + * @author Mario Luo */ @Data public class InvoiceResult implements Serializable { + private static final long serialVersionUID = 7896888653261133444L; /** * 发票相关信息 @@ -17,6 +20,8 @@ public class InvoiceResult implements Serializable { @Data public static class InvoiceDetail implements Serializable { + private static final long serialVersionUID = -3465795497702734126L; + /** * 发票流水号 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MakeOutInvoiceRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MakeOutInvoiceRequest.java index d9336eac12..666bdb97e5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MakeOutInvoiceRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MakeOutInvoiceRequest.java @@ -7,9 +7,12 @@ /** * 开票信息请求参数 + * + * @author Mario Luo */ @Data public class MakeOutInvoiceRequest implements Serializable { + private static final long serialVersionUID = 2089481479917841771L; private InvoiceInfo invoiceinfo; @@ -18,6 +21,8 @@ public class MakeOutInvoiceRequest implements Serializable { */ @Data public static class InvoiceInfo implements Serializable { + private static final long serialVersionUID = 8492738482767944634L; + /** * 维修openid */ @@ -145,6 +150,8 @@ public static class InvoiceInfo implements Serializable { */ @Data public static class InvoiceDetailItem implements Serializable { + private static final long serialVersionUID = 2981363715996297681L; + /** * 发票性质 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfo.java index f7a64edfc3..32adbc29a6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfo.java @@ -1,11 +1,18 @@ package me.chanjar.weixin.mp.bean.invoice.merchant; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + import java.io.Serializable; /** * 商户的开票平台信息 + * + * @author Mario Luo */ +@Data public class MerchantInvoicePlatformInfo implements Serializable { + private static final long serialVersionUID = -2388214622725430530L; /** * 微信支付商户号 @@ -15,5 +22,6 @@ public class MerchantInvoicePlatformInfo implements Serializable { /** * 为该商户提供开票服务的开票平台 id ,由开票平台提供给商户 */ + @SerializedName("s_pappid") private String sPappid; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfoWrapper.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfoWrapper.java index 0351466164..fb79122fce 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfoWrapper.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/merchant/MerchantInvoicePlatformInfoWrapper.java @@ -6,9 +6,12 @@ /** * 设置商户联系信息和发票过时时间参数 + * + * @author Mario Luo */ @Data public class MerchantInvoicePlatformInfoWrapper implements Serializable { + private static final long serialVersionUID = 7994013978048258576L; private MerchantInvoicePlatformInfo paymchInfo; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceBatchRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceBatchRequest.java index 48c878ba61..ce7b1860f5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceBatchRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceBatchRequest.java @@ -22,7 +22,6 @@ @NoArgsConstructor @AllArgsConstructor public class InvoiceBatchRequest implements Serializable { - private static final long serialVersionUID = -9121443117105107231L; /** diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceCommodityInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceCommodityInfo.java index a75874efab..2d4786341c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceCommodityInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceCommodityInfo.java @@ -2,6 +2,8 @@ import lombok.Data; +import java.io.Serializable; + /** *
  * 发票商品信息
@@ -10,7 +12,8 @@
  * @since 2021-03-23
  */
 @Data
-public class InvoiceCommodityInfo {
+public class InvoiceCommodityInfo implements Serializable {
+  private static final long serialVersionUID = 5139576099614652523L;
 
   /**
    * 项目(商品)名称
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoRequest.java
index 8a9b09f42b..0dd960681b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoRequest.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoRequest.java
@@ -22,10 +22,8 @@
 @NoArgsConstructor
 @AllArgsConstructor
 public class InvoiceInfoRequest implements Serializable {
-
   private static final long serialVersionUID = 7854633127026139444L;
 
-
   /**
   * 发票卡券的card_id
   * 
@@ -45,8 +43,6 @@ public class InvoiceInfoRequest implements Serializable {
   @SerializedName("encrypt_code")
   private String encryptCode;
 
-
-
   public String toJson() {
     return WxMpGsonBuilder.create().toJson(this);
   }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoResponse.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoResponse.java
index 0dded411c2..5572f3c45b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoResponse.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceInfoResponse.java
@@ -7,17 +7,20 @@
 import me.chanjar.weixin.common.util.json.GsonParser;
 import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
  * 
  * 查询报销发票信息响应对象
  * 
+ * * @author xiaoyu * @since 2021-03-23 */ @Data -public class InvoiceInfoResponse { +public class InvoiceInfoResponse implements Serializable { + private static final long serialVersionUID = -4835089274990526299L; /** * 发票ID diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceUserInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceUserInfo.java index 1d8d709248..3fc60b0b9e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceUserInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/InvoiceUserInfo.java @@ -3,17 +3,20 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import java.io.Serializable; import java.util.List; /** *
  * 用户可在发票票面看到的主要信息
  * 
+ * * @author xiaoyu * @since 2021-03-23 */ @Data -public class InvoiceUserInfo { +public class InvoiceUserInfo implements Serializable { + private static final long serialVersionUID = 4970283608560240497L; /** * 发票加税合计金额,以分为单位 diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateInvoiceStatusRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateInvoiceStatusRequest.java index 7e3b6e363e..16a7901ca8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateInvoiceStatusRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateInvoiceStatusRequest.java @@ -21,7 +21,6 @@ @NoArgsConstructor @AllArgsConstructor public class UpdateInvoiceStatusRequest implements Serializable { - private static final long serialVersionUID = -4122242332481909977L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateStatusBatchRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateStatusBatchRequest.java index e117d94d1a..17f6a68cde 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateStatusBatchRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/invoice/reimburse/UpdateStatusBatchRequest.java @@ -22,7 +22,6 @@ @NoArgsConstructor @AllArgsConstructor public class UpdateStatusBatchRequest implements Serializable { - private static final long serialVersionUID = 7016357689566912199L; /** * 用户openid 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 37beb77e78..f066c1d934 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 @@ -3,7 +3,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.mp.builder.kefu.*; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -37,6 +36,7 @@ public class WxMpKefuMessage implements Serializable { private String headContent; private String tailContent; private List articles = new ArrayList<>(); + private String mpNewsArticleId; /** * 菜单消息里的菜单内容. @@ -113,20 +113,28 @@ public static MiniProgramPageBuilder MINIPROGRAMPAGE() { return new MiniProgramPageBuilder(); } + /** + * 发送图文消息(点击跳转到图文消息页面)使用通过 “发布” 系列接口得到的 article_id(草稿箱功能上线后不再支持客服接口中带 media_id 的 mpnews 类型的图文消息) + */ + public static MpNewsArticleBuilder MPNEWSARTICLE() { + return new MpNewsArticleBuilder(); + } + /** *
    * 请使用
-   * {@link WxConsts.KefuMsgType#TEXT}
-   * {@link WxConsts.KefuMsgType#IMAGE}
-   * {@link WxConsts.KefuMsgType#VOICE}
-   * {@link WxConsts.KefuMsgType#MUSIC}
-   * {@link WxConsts.KefuMsgType#VIDEO}
-   * {@link WxConsts.KefuMsgType#NEWS}
-   * {@link WxConsts.KefuMsgType#MPNEWS}
-   * {@link WxConsts.KefuMsgType#WXCARD}
-   * {@link WxConsts.KefuMsgType#MINIPROGRAMPAGE}
-   * {@link WxConsts.KefuMsgType#TASKCARD}
-   * {@link WxConsts.KefuMsgType#MSGMENU}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#TEXT}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#IMAGE}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#VOICE}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#MUSIC}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#VIDEO}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#NEWS}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#MPNEWS}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#WXCARD}
+   * {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#MINIPROGRAMPAGE}
+   * {@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}
    * 
*/ public void setMsgType(String msgType) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java index af5559ea42..737140d87a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java @@ -10,7 +10,7 @@ /** * * @author Binary Wang - * @date 2016/7/15 + * created on 2016/7/15 */ @Data public class WxMpKfMsgList implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java index 325c66aa95..4ab34bd428 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java @@ -9,7 +9,7 @@ /** * * @author Binary Wang - * @date 2016/7/18 + * created on 2016/7/18 */ @Data public class WxMpKfMsgRecord implements Serializable { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java index f0e0a1049a..0e3866f46e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java @@ -80,6 +80,22 @@ public static class WxMpSelfMenuButton implements Serializable { @SerializedName("value") private String value; + /** + * 调用新增永久素材接口返回的合法media_id + *

+ * media_id类型和view_limited类型必须 + */ + @SerializedName("media_id") + private String mediaId; + + /** + * 发布后获得的合法article_id + *

+ * article_id类型和article_view_limited类型必须 + */ + @SerializedName("article_id") + private String articleId; + /** *

      * 小程序的appid.
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ArticleUrlResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ArticleUrlResult.java
index e635e7e506..601c187430 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ArticleUrlResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ArticleUrlResult.java
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -13,14 +16,17 @@
  * @author plw on 2021/9/7 10:39 AM.
  * @version 1.0
  */
-@XStreamAlias("ArticleUrlResult")
 @Data
+@XStreamAlias("ArticleUrlResult")
+@JacksonXmlRootElement(localName = "ArticleUrlResult")
 public class ArticleUrlResult implements Serializable {
 
   @XStreamAlias("ResultList")
+  @JacksonXmlProperty(localName = "ResultList")
   private List resultList;
 
   @XStreamAlias("Count")
+  @JacksonXmlProperty(localName = "Count")
   private Long count;
 
   @Override
@@ -28,15 +34,19 @@ public String toString() {
     return WxMpGsonBuilder.create().toJson(this);
   }
 
-  @XStreamAlias("item")
   @Data
+  @XStreamAlias("item")
+  @JacksonXmlRootElement(localName = "item")
   public static class Item implements Serializable {
 
     @XStreamAlias("ArticleIdx")
+    @JacksonXmlProperty(localName = "ArticleIdx")
     private String articleIdx;
 
     @XStreamAlias("ArticleUrl")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "ArticleUrl")
+    @JacksonXmlCData
     private String articleUrl;
 
     @Override
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java
index a75c98e02c..2dbd701404 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java
@@ -2,6 +2,9 @@
 
 import java.io.Serializable;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -15,8 +18,9 @@
  *
  * @author Binary Wang
  */
-@XStreamAlias("HardWare")
 @Data
+@XStreamAlias("HardWare")
+@JacksonXmlRootElement(localName = "HardWare")
 public class HardWare implements Serializable {
   private static final long serialVersionUID = -1295785297354896461L;
 
@@ -25,12 +29,17 @@ public class HardWare implements Serializable {
    */
   @XStreamAlias("MessageView")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "MessageView")
+  @JacksonXmlCData
   private String messageView;
+
   /**
    * 消息点击动作,目前支持ranklist(点击跳转排行榜)
    */
   @XStreamAlias("MessageAction")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "MessageAction")
+  @JacksonXmlCData
   private String messageAction;
 
   @Override
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java
index f53b44c41d..685290bf31 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java
@@ -2,6 +2,9 @@
 
 import java.io.Serializable;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -15,8 +18,9 @@
  *
  * @author Binary Wang
  */
-@XStreamAlias("ScanCodeInfo")
 @Data
+@XStreamAlias("ScanCodeInfo")
+@JacksonXmlRootElement(localName = "ScanCodeInfo")
 public class ScanCodeInfo implements Serializable {
   private static final long serialVersionUID = 4745181270645050122L;
 
@@ -25,6 +29,8 @@ public class ScanCodeInfo implements Serializable {
    */
   @XStreamAlias("ScanType")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "ScanType")
+  @JacksonXmlCData
   private String scanType;
 
   /**
@@ -32,6 +38,8 @@ public class ScanCodeInfo implements Serializable {
    */
   @XStreamAlias("ScanResult")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "ScanResult")
+  @JacksonXmlCData
   private String scanResult;
 
   @Override
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java
index 09f1776bb5..6fb4695546 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java
@@ -2,6 +2,9 @@
 
 import java.io.Serializable;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -15,29 +18,40 @@
  *
  * @author Binary Wang
  */
-@XStreamAlias("SendLocationInfo")
 @Data
+@XStreamAlias("SendLocationInfo")
+@JacksonXmlRootElement(localName = "SendLocationInfo")
 public class SendLocationInfo implements Serializable {
   private static final long serialVersionUID = 6633214140499161130L;
 
   @XStreamAlias("Location_X")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Location_X")
+  @JacksonXmlCData
   private String locationX;
 
   @XStreamAlias("Location_Y")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Location_Y")
+  @JacksonXmlCData
   private String locationY;
 
   @XStreamAlias("Scale")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Scale")
+  @JacksonXmlCData
   private String scale;
 
   @XStreamAlias("Label")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Label")
+  @JacksonXmlCData
   private String label;
 
   @XStreamAlias("Poiname")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Poiname")
+  @JacksonXmlCData
   private String poiName;
 
   @Override
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java
index a01e66596c..c5533328c6 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java
@@ -4,6 +4,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -17,15 +20,18 @@
  *
  * @author Binary Wang
  */
-@XStreamAlias("SendPicsInfo")
 @Data
+@XStreamAlias("SendPicsInfo")
+@JacksonXmlRootElement(localName = "SendPicsInfo")
 public class SendPicsInfo implements Serializable {
   private static final long serialVersionUID = -4572837013294199227L;
 
   @XStreamAlias("PicList")
+  @JacksonXmlProperty(localName = "PicList")
   protected final List picList = new ArrayList<>();
 
   @XStreamAlias("Count")
+  @JacksonXmlProperty(localName = "Count")
   private Long count;
 
   @Override
@@ -33,13 +39,16 @@ public String toString() {
     return WxMpGsonBuilder.create().toJson(this);
   }
 
-  @XStreamAlias("item")
   @Data
+  @XStreamAlias("item")
+  @JacksonXmlRootElement(localName = "item")
   public static class Item implements Serializable {
     private static final long serialVersionUID = 7706235740094081194L;
 
     @XStreamAlias("PicMd5Sum")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "PicMd5Sum")
+    @JacksonXmlCData
     private String picMd5Sum;
 
     @Override
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpSubscribeMsgEvent.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpSubscribeMsgEvent.java
new file mode 100644
index 0000000000..d3def164be
--- /dev/null
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpSubscribeMsgEvent.java
@@ -0,0 +1,144 @@
+package me.chanjar.weixin.mp.bean.message;
+
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+import com.thoughtworks.xstream.annotations.XStreamConverter;
+import com.thoughtworks.xstream.annotations.XStreamImplicit;
+import lombok.Data;
+import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * WxMpSubscribeMsgEvent class
+ *  订阅通知事件推送,与小程序一致
+ * @author liuxy
+ * created on  2022/12/30
+ */
+public class WxMpSubscribeMsgEvent {
+  /**
+   * https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
+   * */
+  @Data
+  @XStreamAlias("SubscribeMsgPopupEvent")
+  @JacksonXmlRootElement(localName = "SubscribeMsgPopupEvent")
+  public static class SubscribeMsgPopupEvent implements Serializable {
+    private static final long serialVersionUID = 6329723189257161326L;
+    @XStreamImplicit(itemFieldName = "List")
+    @JacksonXmlElementWrapper(useWrapping = false)
+    @JacksonXmlProperty(localName = "List")
+    private List list = new LinkedList<>();
+  }
+
+  @Data
+  @XStreamAlias("SubscribeMsgChangeEvent")
+  @JacksonXmlRootElement(localName = "SubscribeMsgChangeEvent")
+  public static class SubscribeMsgChangeEvent implements Serializable {
+    private static final long serialVersionUID = 7205686111539437751L;
+    @XStreamImplicit(itemFieldName = "List")
+    @JacksonXmlElementWrapper(useWrapping = false)
+    @JacksonXmlProperty(localName = "List")
+    private List list = new LinkedList<>();
+  }
+
+  @Data
+  @XStreamAlias("SubscribeMsgSentEvent")
+  @JacksonXmlRootElement(localName = "SubscribeMsgSentEvent")
+  public static class SubscribeMsgSentEvent implements Serializable {
+    private static final long serialVersionUID = 7305686111539437752L;
+    @XStreamImplicit(itemFieldName = "List")
+    @JacksonXmlElementWrapper(useWrapping = false)
+    @JacksonXmlProperty(localName = "List")
+    private List list = new LinkedList<>();
+  }
+
+
+  @Data
+  public static class PopupEvent implements Serializable {
+    private static final long serialVersionUID = 4934029303242387226L;
+    /**
+     * 模板id
+     */
+    @XStreamAlias("TemplateId")
+    @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "TemplateId")
+    @JacksonXmlCData
+    private String templateId;
+    /**
+     * 订阅结果(accept接收;reject拒收)
+     */
+    @XStreamAlias("SubscribeStatusString")
+    @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "SubscribeStatusString")
+    @JacksonXmlCData
+    private String subscribeStatusString;
+    /**
+     * 弹框场景,1代表弹窗来自 H5 页面, 2代表弹窗来自图文消息
+     */
+    @XStreamAlias("PopupScene")
+    @JacksonXmlProperty(localName = "PopupScene")
+    private String popupScene;
+  }
+
+  @Data
+  public static class ChangeEvent implements Serializable {
+    private static final long serialVersionUID = 3523634146232757624L;
+    /**
+     * 模板id
+     */
+    @XStreamAlias("TemplateId")
+    @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "TemplateId")
+    @JacksonXmlCData
+    private String templateId;
+    /**
+     * 订阅结果(accept接收;reject拒收)
+     */
+    @XStreamAlias("SubscribeStatusString")
+    @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "SubscribeStatusString")
+    @JacksonXmlCData
+    private String subscribeStatusString;
+  }
+
+  @Data
+  public static class SentEvent implements Serializable {
+    private static final long serialVersionUID = 1734478345463177940L;
+    /**
+     * 模板id
+     */
+    @XStreamAlias("TemplateId")
+    @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "TemplateId")
+    @JacksonXmlCData
+    private String templateId;
+
+    /**
+     * 消息id
+     */
+    @XStreamAlias("MsgID")
+    @JacksonXmlProperty(localName = "MsgID")
+    private String msgId;
+
+    /**
+     * 推送结果状态码(0表示成功)
+     */
+    @XStreamAlias("ErrorCode")
+    @JacksonXmlProperty(localName = "ErrorCode")
+    private String errorCode;
+
+    /**
+     * 推送结果状态码文字含义
+     */
+    @XStreamAlias("ErrorStatus")
+    @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "ErrorStatus")
+    @JacksonXmlCData
+    private String errorStatus;
+  }
+}
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 56af43a642..2c801f93e2 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
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -33,6 +36,7 @@
 @Data
 @Slf4j
 @XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 public class WxMpXmlMessage implements Serializable {
   private static final long serialVersionUID = -3586245291677274914L;
 
@@ -47,128 +51,182 @@ public class WxMpXmlMessage implements Serializable {
 
   @XStreamAlias("ToUserName")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "ToUserName")
+  @JacksonXmlCData
   private String toUser;
 
   @XStreamAlias("FromUserName")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "FromUserName")
+  @JacksonXmlCData
   private String fromUser;
 
   @XStreamAlias("CreateTime")
+  @JacksonXmlProperty(localName = "CreateTime")
   private Long createTime;
 
   @XStreamAlias("MsgType")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "MsgType")
+  @JacksonXmlCData
   private String msgType;
 
   @XStreamAlias("Content")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Content")
+  @JacksonXmlCData
   private String content;
 
   @XStreamAlias("MenuId")
+  @JacksonXmlProperty(localName = "MenuId")
   private Long menuId;
 
   @XStreamAlias("MsgId")
+  @JacksonXmlProperty(localName = "MsgId")
   private Long msgId;
 
   @XStreamAlias("PicUrl")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "PicUrl")
+  @JacksonXmlCData
   private String picUrl;
 
   @XStreamAlias("MediaId")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "MediaId")
+  @JacksonXmlCData
   private String mediaId;
 
   @XStreamAlias("Format")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Format")
+  @JacksonXmlCData
   private String format;
 
   @XStreamAlias("ThumbMediaId")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "ThumbMediaId")
+  @JacksonXmlCData
   private String thumbMediaId;
 
   @XStreamAlias("Location_X")
+  @JacksonXmlProperty(localName = "Location_X")
   private Double locationX;
 
   @XStreamAlias("Location_Y")
+  @JacksonXmlProperty(localName = "Location_Y")
   private Double locationY;
 
   @XStreamAlias("Scale")
+  @JacksonXmlProperty(localName = "Scale")
   private Double scale;
 
   @XStreamAlias("Label")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Label")
+  @JacksonXmlCData
   private String label;
 
   @XStreamAlias("Title")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Title")
+  @JacksonXmlCData
   private String title;
 
   @XStreamAlias("Description")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Description")
+  @JacksonXmlCData
   private String description;
 
   @XStreamAlias("Url")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Url")
+  @JacksonXmlCData
   private String url;
 
   @XStreamAlias("Event")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Event")
+  @JacksonXmlCData
   private String event;
 
   @XStreamAlias("EventKey")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "EventKey")
+  @JacksonXmlCData
   private String eventKey;
 
   @XStreamAlias("Ticket")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Ticket")
+  @JacksonXmlCData
   private String ticket;
 
   @XStreamAlias("Latitude")
+  @JacksonXmlProperty(localName = "Latitude")
   private Double latitude;
 
   @XStreamAlias("Longitude")
+  @JacksonXmlProperty(localName = "Longitude")
   private Double longitude;
 
   @XStreamAlias("Precision")
+  @JacksonXmlProperty(localName = "Precision")
   private Double precision;
 
   @XStreamAlias("Recognition")
+  @JacksonXmlProperty(localName = "Recognition")
   @XStreamConverter(value = XStreamCDataConverter.class)
   private String recognition;
 
   @XStreamAlias("UnionId")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "UnionId")
+  @JacksonXmlCData
   private String unionId;
 
   ///////////////////////////////////////
   // 群发消息返回的结果
   ///////////////////////////////////////
+  /**
+   * 群发的消息ID
+   */
+  @XStreamAlias("MsgID")
+  @JacksonXmlProperty(localName = "MsgID")
+  private Long massMsgId;
   /**
    * 群发的结果.
    */
   @XStreamAlias("Status")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Status")
+  @JacksonXmlCData
   private String status;
   /**
    * group_id下粉丝数;或者openid_list中的粉丝数.
    */
   @XStreamAlias("TotalCount")
+  @JacksonXmlProperty(localName = "TotalCount")
   private Integer totalCount;
   /**
    * 过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数.
    * 原则上,filterCount = sentCount + errorCount
    */
   @XStreamAlias("FilterCount")
+  @JacksonXmlProperty(localName = "FilterCount")
   private Integer filterCount;
   /**
    * 发送成功的粉丝数.
    */
   @XStreamAlias("SentCount")
+  @JacksonXmlProperty(localName = "SentCount")
   private Integer sentCount;
   /**
    * 发送失败的粉丝数.
    */
   @XStreamAlias("ErrorCount")
+  @JacksonXmlProperty(localName = "ErrorCount")
   private Integer errorCount;
 
   ///////////////////////////////////////
@@ -178,16 +236,19 @@ public class WxMpXmlMessage implements Serializable {
    * 创建或关闭客服会话时的客服帐号.
    */
   @XStreamAlias("KfAccount")
+  @JacksonXmlProperty(localName = "KfAccount")
   private String kfAccount;
   /**
    * 转接客服会话时的转入客服帐号.
    */
   @XStreamAlias("ToKfAccount")
+  @JacksonXmlProperty(localName = "ToKfAccount")
   private String toKfAccount;
   /**
    * 转接客服会话时的转出客服帐号.
    */
   @XStreamAlias("FromKfAccount")
+  @JacksonXmlProperty(localName = "FromKfAccount")
   private String fromKfAccount;
 
   ///////////////////////////////////////
@@ -196,33 +257,44 @@ public class WxMpXmlMessage implements Serializable {
 
   @XStreamAlias("CardId")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "CardId")
+  @JacksonXmlCData
   private String cardId;
 
   @XStreamAlias("FriendUserName")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "FriendUserName")
+  @JacksonXmlCData
   private String friendUserName;
 
   /**
    * 是否为转赠,1代表是,0代表否.
    */
   @XStreamAlias("IsGiveByFriend")
+  @JacksonXmlProperty(localName = "IsGiveByFriend")
   private Integer isGiveByFriend;
 
   @XStreamAlias("UserCardCode")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "UserCardCode")
+  @JacksonXmlCData
   private String userCardCode;
 
   @XStreamAlias("OldUserCardCode")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "OldUserCardCode")
+  @JacksonXmlCData
   private String oldUserCardCode;
 
   @XStreamAlias("OuterId")
+  @JacksonXmlProperty(localName = "OuterId")
   private Integer outerId;
 
   /**
    * 用户删除会员卡后可重新找回,当用户本次操作为找回时,该值为1,否则为0.
    */
   @XStreamAlias("IsRestoreMemberCard")
+  @JacksonXmlProperty(localName = "IsRestoreMemberCard")
   private String isRestoreMemberCard;
 
   /**
@@ -235,18 +307,21 @@ public class WxMpXmlMessage implements Serializable {
    * 
*/ @XStreamAlias("OuterStr") + @JacksonXmlProperty(localName = "OuterStr") private String outerStr; /** * 是否转赠退回,0代表不是,1代表是. */ @XStreamAlias("IsReturnBack") + @JacksonXmlProperty(localName = "IsReturnBack") private String isReturnBack; /** * 是否是群转赠,0代表不是,1代表是. */ @XStreamAlias("IsChatRoom") + @JacksonXmlProperty(localName = "IsChatRoom") private String isChatRoom; /** @@ -254,6 +329,7 @@ public class WxMpXmlMessage implements Serializable { * 支持开发者统计API核销(FROM_API)、公众平台核销(FROM_MP)、卡券商户助手核销(FROM_MOBILE_HELPER)(核销员微信号) */ @XStreamAlias("ConsumeSource") + @JacksonXmlProperty(localName = "ConsumeSource") private String consumeSource; /** @@ -261,24 +337,28 @@ public class WxMpXmlMessage implements Serializable { * 当前卡券核销的门店名称(只有通过自助核销和买单核销时才会出现该字段) */ @XStreamAlias("LocationName") + @JacksonXmlProperty(localName = "LocationName") private String locationName; /** * 核销该卡券核销员的openid(只有通过卡券商户助手核销时才会出现). */ @XStreamAlias("StaffOpenId") + @JacksonXmlProperty(localName = "StaffOpenId") private String staffOpenId; /** * 自助核销时,用户输入的验证码. */ @XStreamAlias("VerifyCode") + @JacksonXmlProperty(localName = "VerifyCode") private String verifyCode; /** * 自助核销时,用户输入的备注金额. */ @XStreamAlias("RemarkAmount") + @JacksonXmlProperty(localName = "RemarkAmount") private String remarkAmount; /** @@ -288,6 +368,7 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("Detail") + @JacksonXmlProperty(localName = "Detail") private String detail; /** @@ -297,6 +378,7 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("ModifyBonus") + @JacksonXmlProperty(localName = "ModifyBonus") private String modifyBonus; /** @@ -306,6 +388,7 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("ModifyBalance") + @JacksonXmlProperty(localName = "ModifyBalance") private String modifyBalance; /** @@ -315,6 +398,7 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("TransId") + @JacksonXmlProperty(localName = "TransId") private String transId; /** @@ -324,6 +408,7 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("LocationId") + @JacksonXmlProperty(localName = "LocationId") private String locationId; /** @@ -333,6 +418,7 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("Fee") + @JacksonXmlProperty(localName = "Fee") private String fee; /** @@ -342,72 +428,86 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("OriginalFee") + @JacksonXmlProperty(localName = "OriginalFee") private String originalFee; @XStreamAlias("ScanCodeInfo") + @JacksonXmlProperty(localName = "ScanCodeInfo") private ScanCodeInfo scanCodeInfo = new ScanCodeInfo(); @XStreamAlias("SendPicsInfo") + @JacksonXmlProperty(localName = "SendPicsInfo") private SendPicsInfo sendPicsInfo = new SendPicsInfo(); @XStreamAlias("SendLocationInfo") + @JacksonXmlProperty(localName = "SendLocationInfo") private SendLocationInfo sendLocationInfo = new SendLocationInfo(); @XStreamAlias("ArticleUrlResult") + @JacksonXmlProperty(localName = "ArticleUrlResult") private ArticleUrlResult articleUrlResult = new ArticleUrlResult(); /** * 审核不通过原因 */ @XStreamAlias("RefuseReason") + @JacksonXmlProperty(localName = "RefuseReason") private String refuseReason; /** * 是否为朋友推荐,0代表否,1代表是 */ @XStreamAlias("IsRecommendByFriend") + @JacksonXmlProperty(localName = "IsRecommendByFriend") private String isRecommendByFriend; /** * 购买券点时,实际支付成功的时间 */ @XStreamAlias("PayFinishTime") + @JacksonXmlProperty(localName = "PayFinishTime") private String payFinishTime; /** * 购买券点时,支付二维码的生成时间 */ @XStreamAlias("CreateOrderTime") + @JacksonXmlProperty(localName = "CreateOrderTime") private String createOrderTime; /** * 购买券点时,支付二维码的生成时间 */ @XStreamAlias("Desc") + @JacksonXmlProperty(localName = "Desc") private String desc; /** * 剩余免费券点数量 */ @XStreamAlias("FreeCoinCount") + @JacksonXmlProperty(localName = "FreeCoinCount") private String freeCoinCount; /** * 剩余付费券点数量 */ @XStreamAlias("PayCoinCount") + @JacksonXmlProperty(localName = "PayCoinCount") private String payCoinCount; /** * 本次变动的免费券点数量 */ @XStreamAlias("RefundFreeCoinCount") + @JacksonXmlProperty(localName = "RefundFreeCoinCount") private String refundFreeCoinCount; /** * 本次变动的付费券点数量 */ @XStreamAlias("RefundPayCoinCount") + @JacksonXmlProperty(localName = "RefundPayCoinCount") private String refundPayCoinCount; /** @@ -417,21 +517,23 @@ public class WxMpXmlMessage implements Serializable { *
*/ @XStreamAlias("OrderType") + @JacksonXmlProperty(localName = "OrderType") private String orderType; /** * 系统备注,说明此次变动的缘由,如开通账户奖励、门店奖励、核销奖励以及充值、扣减。 */ @XStreamAlias("Memo") + @JacksonXmlProperty(localName = "Memo") private String memo; /** * 所开发票的详情 */ @XStreamAlias("ReceiptInfo") + @JacksonXmlProperty(localName = "ReceiptInfo") private String receiptInfo; - /////////////////////////////////////// // 门店审核事件推送 /////////////////////////////////////// @@ -439,12 +541,14 @@ public class WxMpXmlMessage implements Serializable { * 商户自己内部ID,即字段中的sid. */ @XStreamAlias("UniqId") + @JacksonXmlProperty(localName = "UniqId") private String storeUniqId; /** * 微信的门店ID,微信内门店唯一标示ID. */ @XStreamAlias("PoiId") + @JacksonXmlProperty(localName = "PoiId") private String poiId; /** @@ -453,12 +557,14 @@ public class WxMpXmlMessage implements Serializable { * 在商品审核结果推送时,verify_ok表示审核通过,verify_not_pass表示审核未通过。 */ @XStreamAlias("Result") + @JacksonXmlProperty(localName = "Result") private String result; /** * 成功的通知信息,或审核失败的驳回理由. */ @XStreamAlias("msg") + @JacksonXmlProperty(localName = "msg") private String msg; /////////////////////////////////////// @@ -470,16 +576,19 @@ public class WxMpXmlMessage implements Serializable { * 认证过期失效通知: 有效期 (整形),指的是时间戳,表示已于该时间戳认证过期,需要重新发起微信认证 */ @XStreamAlias("ExpiredTime") + @JacksonXmlProperty(localName = "ExpiredTime") private Long expiredTime; /** * 失败发生时间 (整形),时间戳. */ @XStreamAlias("FailTime") + @JacksonXmlProperty(localName = "FailTime") private Long failTime; /** * 认证失败的原因. */ @XStreamAlias("FailReason") + @JacksonXmlProperty(localName = "FailReason") private String failReason; /////////////////////////////////////// @@ -490,12 +599,15 @@ public class WxMpXmlMessage implements Serializable { */ @XStreamAlias("OrderId") @XStreamConverter(value = XStreamCDataConverter.class) + @JacksonXmlProperty(localName = "OrderId") + @JacksonXmlCData private String orderId; /** * 订单状态. */ @XStreamAlias("OrderStatus") + @JacksonXmlProperty(localName = "OrderStatus") private String orderStatus; /** @@ -503,6 +615,8 @@ public class WxMpXmlMessage implements Serializable { */ @XStreamAlias("ProductId") @XStreamConverter(value = XStreamCDataConverter.class) + @JacksonXmlProperty(localName = "ProductId") + @JacksonXmlCData private String productId; /** @@ -510,6 +624,8 @@ public class WxMpXmlMessage implements Serializable { */ @XStreamAlias("SkuInfo") @XStreamConverter(value = XStreamCDataConverter.class) + @JacksonXmlProperty(localName = "SkuInfo") + @JacksonXmlCData private String skuInfo; /////////////////////////////////////// @@ -521,6 +637,8 @@ public class WxMpXmlMessage implements Serializable { */ @XStreamAlias("DeviceType") @XStreamConverter(value = XStreamCDataConverter.class) + @JacksonXmlProperty(localName = "DeviceType") + @JacksonXmlCData private String deviceType; /** @@ -529,6 +647,8 @@ public class WxMpXmlMessage implements Serializable { */ @XStreamAlias("DeviceID") @XStreamConverter(value = XStreamCDataConverter.class) + @JacksonXmlProperty(localName = "DeviceID") + @JacksonXmlCData private String deviceId; /** @@ -537,6 +657,8 @@ public class WxMpXmlMessage implements Serializable { */ @XStreamAlias("SessionID") @XStreamConverter(value = XStreamCDataConverter.class) + @JacksonXmlProperty(localName = "SessionID") + @JacksonXmlCData private String sessionId; /** @@ -544,9 +666,12 @@ public class WxMpXmlMessage implements Serializable { */ @XStreamAlias("OpenID") @XStreamConverter(value = XStreamCDataConverter.class) + @JacksonXmlProperty(localName = "OpenID") + @JacksonXmlCData private String openId; @XStreamAlias("HardWare") + @JacksonXmlProperty(localName = "HardWare") private HardWare hardWare = new HardWare(); /** @@ -556,6 +681,7 @@ public class WxMpXmlMessage implements Serializable { * 2:订阅设备状态 */ @XStreamAlias("OpType") + @JacksonXmlProperty(localName = "OpType") private Integer opType; /** @@ -563,6 +689,7 @@ public class WxMpXmlMessage implements Serializable { * 0:未连接;1:已连接 */ @XStreamAlias("DeviceStatus") + @JacksonXmlProperty(localName = "DeviceStatus") private Integer deviceStatus; /////////////////////////////////////// @@ -572,12 +699,14 @@ public class WxMpXmlMessage implements Serializable { * 审核成功时的时间(整形),时间戳 */ @XStreamAlias("SuccTime") + @JacksonXmlProperty(localName = "SuccTime") private Long successTime; /** * 审核失败的原因 */ @XStreamAlias("Reason") + @JacksonXmlProperty(localName = "Reason") private String reason; /////////////////////////////////////// @@ -587,65 +716,76 @@ public class WxMpXmlMessage implements Serializable { * 商品编码标准 */ @XStreamAlias("KeyStandard") + @JacksonXmlProperty(localName = "KeyStandard") private String keyStandard; /** * 商品编码内容 */ @XStreamAlias("KeyStr") + @JacksonXmlProperty(localName = "KeyStr") private String keyStr; /** * 用户在微信内设置的国家 */ @XStreamAlias("Country") + @JacksonXmlProperty(localName = "Country") private String country; /** * 用户在微信内设置的省份 */ @XStreamAlias("Province") + @JacksonXmlProperty(localName = "Province") private String province; /** * 用户在微信内设置的城市 */ @XStreamAlias("City") + @JacksonXmlProperty(localName = "City") private String city; /** * 用户的性别,1为男性,2为女性,0代表未知 */ @XStreamAlias("Sex") + @JacksonXmlProperty(localName = "Sex") private String sex; /** * 打开商品主页的场景,1为扫码,2为其他打开场景(如会话、收藏或朋友圈) */ @XStreamAlias("Scene") + @JacksonXmlProperty(localName = "Scene") private String scene; /** * 调用“获取商品二维码接口”时传入的extinfo,为标识参数 */ @XStreamAlias("ExtInfo") + @JacksonXmlProperty(localName = "ExtInfo") private String extInfo; /** * 用户的实时地理位置信息(目前只精确到省一级),可在国家统计局网站查到对应明细: http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201504/t20150415_712722.html */ @XStreamAlias("RegionCode") + @JacksonXmlProperty(localName = "RegionCode") private String regionCode; /** * 审核未通过的原因. */ @XStreamAlias("ReasonMsg") + @JacksonXmlProperty(localName = "ReasonMsg") private String reasonMsg; /** * 给用户发菜单消息类型的客服消息后,用户所点击的菜单ID. */ @XStreamAlias("bizmsgmenuid") + @JacksonXmlProperty(localName = "bizmsgmenuid") private String bizMsgMenuId; /*------------------ 电子发票 ------------------*/ @@ -653,39 +793,72 @@ public class WxMpXmlMessage implements Serializable { * 授权成功的订单号,与失败订单号两者必显示其一 */ @XStreamAlias("SuccOrderId") + @JacksonXmlProperty(localName = "SuccOrderId") private String succOrderId; /** * 授权失败的订单号,与成功订单号两者必显示其一 */ @XStreamAlias("FailOrderId") + @JacksonXmlProperty(localName = "FailOrderId") private String failOrderId; /** * 获取授权页链接的AppId */ @XStreamAlias("AuthorizeAppId") + @JacksonXmlProperty(localName = "AuthorizeAppId") private String authorizeAppId; /** * 授权来源,web:公众号开票,app:app开票,wxa:小程序开票,wap:h5开票 */ @XStreamAlias("source") + @JacksonXmlProperty(localName = "source") private String source; /** * 发票请求流水号,唯一识别发票请求的流水号 */ @XStreamAlias("fpqqlsh") + @JacksonXmlProperty(localName = "fpqqlsh") private String fpqqlsh; /** * 纳税人识别码 */ @XStreamAlias("nsrsbh") + @JacksonXmlProperty(localName = "nsrsbh") private String nsrsbh; + /** + * 授权用户资料变更 + */ + @XStreamAlias("RevokeInfo") + @JacksonXmlProperty(localName = "RevokeInfo") + private String revokeInfo; + + /** + * 加密消息 + */ + @XStreamAlias("Encrypt") + @JacksonXmlProperty(localName = "Encrypt") + private String encrypt; + + @XStreamAlias("SubscribeMsgPopupEvent") + @JacksonXmlProperty(localName = "SubscribeMsgPopupEvent") + private WxMpSubscribeMsgEvent.SubscribeMsgPopupEvent subscribeMsgPopupEvent; + + @XStreamAlias("SubscribeMsgChangeEvent") + @JacksonXmlProperty(localName = "SubscribeMsgChangeEvent") + private WxMpSubscribeMsgEvent.SubscribeMsgChangeEvent subscribeMsgChangeEvent; + + @XStreamAlias("SubscribeMsgSentEvent") + @JacksonXmlProperty(localName = "SubscribeMsgSentEvent") + private WxMpSubscribeMsgEvent.SubscribeMsgSentEvent subscribeMsgSentEvent; + + public static WxMpXmlMessage fromXml(String xml) { //修改微信变态的消息内容格式,方便解析 xml = xml.replace("", ""); @@ -710,7 +883,7 @@ public static WxMpXmlMessage fromXml(InputStream is) { public static WxMpXmlMessage fromEncryptedXml(String encryptedXml, WxMpConfigStorage wxMpConfigStorage, String timestamp, String nonce, String msgSignature) { WxMpCryptUtil cryptUtil = new WxMpCryptUtil(wxMpConfigStorage); - String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); + String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml); log.debug("解密后的原始xml消息内容:{}", plainText); return fromXml(plainText); } @@ -724,6 +897,14 @@ public static WxMpXmlMessage fromEncryptedXml(InputStream is, WxMpConfigStorage } } + public WxMpXmlMessage decryptField(WxMpConfigStorage wxMpConfigStorage, + String timestamp, String nonce, String msgSignature) { + WxMpCryptUtil cryptUtil = new WxMpCryptUtil(wxMpConfigStorage); + String plainText = cryptUtil.decryptContent(msgSignature, timestamp, nonce, this.encrypt); + log.debug("解密后的原始xml消息内容:{}", plainText); + return fromXml(plainText); + } + /** *
    * 当接受用户消息时,可能会获得以下值:
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutDeviceMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutDeviceMessage.java
index b32935a106..d8b41bb249 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutDeviceMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutDeviceMessage.java
@@ -1,36 +1,48 @@
-package me.chanjar.weixin.mp.bean.message;
-
-import com.thoughtworks.xstream.annotations.XStreamAlias;
-import com.thoughtworks.xstream.annotations.XStreamConverter;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import me.chanjar.weixin.common.api.WxConsts;
-import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
-
-@XStreamAlias("xml")
-@Data
-@EqualsAndHashCode(callSuper = true)
-public class WxMpXmlOutDeviceMessage extends WxMpXmlOutMessage {
-  private static final long serialVersionUID = -3093843149649157587L;
-
-  @XStreamAlias("DeviceType")
-  @XStreamConverter(value = XStreamCDataConverter.class)
-  private String deviceType;
-
-  @XStreamAlias("DeviceID")
-  @XStreamConverter(value = XStreamCDataConverter.class)
-  private String deviceId;
-
-  @XStreamAlias("Content")
-  @XStreamConverter(value = XStreamCDataConverter.class)
-  private String content;
-
-  @XStreamAlias("SessionID")
-  @XStreamConverter(value = XStreamCDataConverter.class)
-  private String sessionId;
-
-  public WxMpXmlOutDeviceMessage() {
-    this.msgType = WxConsts.XmlMsgType.DEVICE_TEXT;
-  }
-}
+package me.chanjar.weixin.mp.bean.message;
+
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+import com.thoughtworks.xstream.annotations.XStreamConverter;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import me.chanjar.weixin.common.api.WxConsts;
+import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
+
+@Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
+@EqualsAndHashCode(callSuper = true)
+public class WxMpXmlOutDeviceMessage extends WxMpXmlOutMessage {
+  private static final long serialVersionUID = -3093843149649157587L;
+
+  @XStreamAlias("DeviceType")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "DeviceType")
+  @JacksonXmlCData
+  private String deviceType;
+
+  @XStreamAlias("DeviceID")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "DeviceID")
+  @JacksonXmlCData
+  private String deviceId;
+
+  @XStreamAlias("Content")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Content")
+  @JacksonXmlCData
+  private String content;
+
+  @XStreamAlias("SessionID")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "SessionID")
+  @JacksonXmlCData
+  private String sessionId;
+
+  public WxMpXmlOutDeviceMessage() {
+    this.msgType = WxConsts.XmlMsgType.DEVICE_TEXT;
+  }
+}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
index dbb0ab90f9..d2328890e5 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -7,14 +10,17 @@
 import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter;
 
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 @EqualsAndHashCode(callSuper = true)
 public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage {
   private static final long serialVersionUID = -2684778597067990723L;
 
   @XStreamAlias("Image")
   @XStreamConverter(value = XStreamMediaIdConverter.class)
+  @JacksonXmlProperty(localName = "Image")
+  @JacksonXmlCData
   private String mediaId;
 
   public WxMpXmlOutImageMessage() {
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 40e0b41a2b..a44aea740c 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
@@ -1,8 +1,12 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
+import me.chanjar.weixin.common.util.crypto.WxCryptUtil;
 import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
 import me.chanjar.weixin.mp.config.WxMpConfigStorage;
 import me.chanjar.weixin.mp.builder.outxml.*;
@@ -11,26 +15,59 @@
 
 import java.io.Serializable;
 
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 public abstract class WxMpXmlOutMessage implements Serializable {
   private static final long serialVersionUID = -381382011286216263L;
 
   @XStreamAlias("ToUserName")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "ToUserName")
+  @JacksonXmlCData
   protected String toUserName;
 
   @XStreamAlias("FromUserName")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "FromUserName")
+  @JacksonXmlCData
   protected String fromUserName;
 
   @XStreamAlias("CreateTime")
+  @JacksonXmlProperty(localName = "CreateTime")
   protected Long createTime;
 
   @XStreamAlias("MsgType")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "MsgType")
+  @JacksonXmlCData
   protected String msgType;
 
+
+  @XStreamAlias("Encrypt")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Encrypt")
+  @JacksonXmlCData
+  private String encrypt;
+
+  @XStreamAlias("MsgSignature")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "MsgSignature")
+  @JacksonXmlCData
+  private String msgSignature;
+
+  @XStreamAlias("TimeStamp")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "TimeStamp")
+  @JacksonXmlCData
+  private String timeStamp;
+
+  @XStreamAlias("Nonce")
+  @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Nonce")
+  @JacksonXmlCData
+  private String nonce;
+
   /**
    * 获得文本消息builder
    */
@@ -92,6 +129,21 @@ public String toXml() {
     return XStreamTransformer.toXml((Class) this.getClass(), this);
   }
 
+  /**
+   * 转换成加密的结果
+   */
+  public WxMpXmlOutMessage toEncrypted(WxMpConfigStorage wxMpConfigStorage) {
+    String plainXml = toXml();
+    WxMpCryptUtil pc = new WxMpCryptUtil(wxMpConfigStorage);
+    WxCryptUtil.EncryptContext context = pc.encryptContext(plainXml);
+    WxMpXmlOutMessage res = new WxMpXmlOutMessage() {};
+    res.setNonce(context.getNonce());
+    res.setEncrypt(context.getEncrypt());
+    res.setTimeStamp(context.getTimeStamp());
+    res.setMsgSignature(context.getSignature());
+    return res;
+  }
+
   /**
    * 转换成加密的xml格式
    */
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java
index 1124f45857..240b979fac 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -9,42 +12,55 @@
 
 import java.io.Serializable;
 
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 @EqualsAndHashCode(callSuper = true)
 public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage {
   private static final long serialVersionUID = -4159937804975448945L;
 
   @XStreamAlias("Music")
+  @JacksonXmlProperty(localName = "Music")
   protected final Music music = new Music();
 
   public WxMpXmlOutMusicMessage() {
     this.msgType = WxConsts.XmlMsgType.MUSIC;
   }
 
-  @XStreamAlias("Music")
   @Data
+  @XStreamAlias("Music")
+  @JacksonXmlRootElement(localName = "Music")
   public static class Music implements Serializable {
     private static final long serialVersionUID = -5492592401691895334L;
 
     @XStreamAlias("Title")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "Title")
+    @JacksonXmlCData
     private String title;
 
     @XStreamAlias("Description")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "Description")
+    @JacksonXmlCData
     private String description;
 
     @XStreamAlias("ThumbMediaId")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "ThumbMediaId")
+    @JacksonXmlCData
     private String thumbMediaId;
 
     @XStreamAlias("MusicUrl")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "MusicUrl")
+    @JacksonXmlCData
     private String musicUrl;
 
     @XStreamAlias("HQMusicUrl")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "HQMusicUrl")
+    @JacksonXmlCData
     private String hqMusicUrl;
   }
 
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java
index 00f8d70c88..192b24a354 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java
@@ -4,6 +4,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -15,8 +18,9 @@
  * 被动回复的图文消息xml.
  * @author chanjarster
  */
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 @EqualsAndHashCode(callSuper = true)
 public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage {
   private static final long serialVersionUID = -4604402850905714772L;
@@ -26,12 +30,14 @@ public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage {
    * 注意,如果图文数超过限制,则将只发限制内的条数
    */
   @XStreamAlias("Articles")
+  @JacksonXmlProperty(localName = "Articles")
   protected final List articles = new ArrayList<>();
   /**
    * 图文消息个数.
    * 当用户发送文本、图片、视频、图文、地理位置这五种消息时,开发者只能回复1条图文消息;其余场景最多可回复8条图文消息
    */
   @XStreamAlias("ArticleCount")
+  @JacksonXmlProperty(localName = "ArticleCount")
   protected int articleCount;
 
   public WxMpXmlOutNewsMessage() {
@@ -43,8 +49,9 @@ public void addArticle(Item item) {
     this.articleCount = this.articles.size();
   }
 
-  @XStreamAlias("item")
   @Data
+  @XStreamAlias("item")
+  @JacksonXmlRootElement(localName = "item")
   public static class Item implements Serializable {
     private static final long serialVersionUID = -4971456355028904754L;
 
@@ -53,6 +60,8 @@ public static class Item implements Serializable {
      */
     @XStreamAlias("Title")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "Title")
+    @JacksonXmlCData
     private String title;
 
     /**
@@ -60,6 +69,8 @@ public static class Item implements Serializable {
      */
     @XStreamAlias("Description")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "Description")
+    @JacksonXmlCData
     private String description;
 
     /**
@@ -68,6 +79,8 @@ public static class Item implements Serializable {
      */
     @XStreamAlias("PicUrl")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "PicUrl")
+    @JacksonXmlCData
     private String picUrl;
 
     /**
@@ -75,6 +88,8 @@ public static class Item implements Serializable {
      */
     @XStreamAlias("Url")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "Url")
+    @JacksonXmlCData
     private String url;
 
   }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java
index cbaa05abc3..b9c7747b0e 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -7,14 +10,17 @@
 import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
 
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 @EqualsAndHashCode(callSuper = true)
 public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage {
   private static final long serialVersionUID = -3972786455288763361L;
 
   @XStreamAlias("Content")
   @XStreamConverter(value = XStreamCDataConverter.class)
+  @JacksonXmlProperty(localName = "Content")
+  @JacksonXmlCData
   private String content;
 
   public WxMpXmlOutTextMessage() {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java
index 5b0857830e..1d70738616 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -9,26 +12,31 @@
 
 import java.io.Serializable;
 
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 @EqualsAndHashCode(callSuper = true)
 public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage {
   private static final long serialVersionUID = 1850903037285841322L;
 
   @XStreamAlias("TransInfo")
+  @JacksonXmlProperty(localName = "TransInfo")
   protected TransInfo transInfo;
 
   public WxMpXmlOutTransferKefuMessage() {
     this.msgType = WxConsts.KefuMsgType.TRANSFER_CUSTOMER_SERVICE;
   }
 
-  @XStreamAlias("TransInfo")
   @Data
+  @XStreamAlias("TransInfo")
+  @JacksonXmlRootElement(localName = "TransInfo")
   public static class TransInfo implements Serializable {
     private static final long serialVersionUID = -6317885617135706056L;
 
     @XStreamAlias("KfAccount")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "KfAccount")
+    @JacksonXmlCData
     private String kfAccount;
 
   }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java
index 7f43a56809..101fa9605b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -9,34 +12,43 @@
 
 import java.io.Serializable;
 
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 @EqualsAndHashCode(callSuper = true)
 public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage {
   private static final long serialVersionUID = 1745902309380113978L;
 
   @XStreamAlias("Video")
+  @JacksonXmlProperty(localName = "Video")
   protected final Video video = new Video();
 
   public WxMpXmlOutVideoMessage() {
     this.msgType = WxConsts.XmlMsgType.VIDEO;
   }
 
-  @XStreamAlias("Video")
   @Data
+  @XStreamAlias("Video")
+  @JacksonXmlRootElement(localName = "Video")
   public static class Video implements Serializable {
     private static final long serialVersionUID = -6445448977569651183L;
 
     @XStreamAlias("MediaId")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "MediaId")
+    @JacksonXmlCData
     private String mediaId;
 
     @XStreamAlias("Title")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "Title")
+    @JacksonXmlCData
     private String title;
 
     @XStreamAlias("Description")
     @XStreamConverter(value = XStreamCDataConverter.class)
+    @JacksonXmlProperty(localName = "Description")
+    @JacksonXmlCData
     private String description;
 
   }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java
index bd91b861ee..f8330efd70 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java
@@ -1,5 +1,8 @@
 package me.chanjar.weixin.mp.bean.message;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
 import lombok.Data;
@@ -7,14 +10,17 @@
 import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter;
 
-@XStreamAlias("xml")
 @Data
+@XStreamAlias("xml")
+@JacksonXmlRootElement(localName = "xml")
 @EqualsAndHashCode(callSuper = true)
 public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage {
   private static final long serialVersionUID = 240367390249860551L;
 
   @XStreamAlias("Voice")
   @XStreamConverter(value = XStreamMediaIdConverter.class)
+  @JacksonXmlProperty(localName = "Voice")
+  @JacksonXmlCData
   private String mediaId;
 
   public WxMpXmlOutVoiceMessage() {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java
index 4d22fab9e9..bfd8b6d8dd 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java
@@ -21,19 +21,16 @@ public class WxMpUser implements Serializable {
 
   private Boolean subscribe;
   private String openId;
-  private String nickname;
   /**
-   * 性别描述信息:男、女、未知等.
+   * @deprecated 2021年12月27日之后不再输出
    */
-  private String sexDesc;
+  @Deprecated
+  private String nickname;
+  private String language;
   /**
-   * 性别表示:1,2等数字.
+   * @deprecated 2021年12月27日之后不再输出
    */
-  private Integer sex;
-  private String language;
-  private String city;
-  private String province;
-  private String country;
+  @Deprecated
   private String headImgUrl;
   private Long subscribeTime;
   /**
@@ -56,8 +53,7 @@ public class WxMpUser implements Serializable {
   private String[] privileges;
 
   /**
-   * subscribe_scene 返回用户关注的渠道来源.
-   * ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENEPROFILE LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_OTHERS 其他
+   * subscribe_scene 返回用户关注的渠道来源,ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENE_PROFILE_LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告,ADD_SCENE_OTHERS 其他
    */
   private String subscribeScene;
 
@@ -71,7 +67,6 @@ public class WxMpUser implements Serializable {
    */
   private String qrSceneStr;
 
-
   public static WxMpUser fromJson(String json) {
     return WxMpGsonBuilder.create().fromJson(json, WxMpUser.class);
   }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessage.java
index 30ad3153a3..d2695959e8 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessage.java
@@ -11,7 +11,7 @@
 
 /**
  * @author Mklaus
- * @date 2018-01-22 下午12:18
+ * created on  2018-01-22 下午12:18
  */
 @Data
 @NoArgsConstructor
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryEnum.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryEnum.java
index 23ba2097e7..88ea47e5b6 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryEnum.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryEnum.java
@@ -2,15 +2,14 @@
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;
-import org.jetbrains.annotations.Nullable;
 
-import java.util.Objects;
+import java.util.Arrays;
 
 /**
  * 模版消息行业枚举.
  *
  * @author Binary Wang
- * @date 2019-10-18
+ * created on  2019-10-18
  */
 @Getter
 @AllArgsConstructor
@@ -176,9 +175,9 @@ public enum WxMpTemplateIndustryEnum {
    */
   PRINTING("印刷", "印刷", 40),
   /**
-   * 其它 - 其它
+   * 其他 - 其他
    */
-  OTHER("其它", "其它", 41);
+  OTHER("其他", "其他", 41);
 
   /**
    * 主行业(一级行业)
@@ -200,18 +199,11 @@ public enum WxMpTemplateIndustryEnum {
    * @param secondClass 副行业名称
    * @return 如果找不到, 返回null
    */
-  @Nullable
   public static WxMpTemplateIndustryEnum findByClass(String firstClass, String secondClass) {
-    for (WxMpTemplateIndustryEnum industryEnum : WxMpTemplateIndustryEnum.values()) {
-      if (industryEnum.firstClass.equals(firstClass) && industryEnum.secondClass.contains(secondClass)) {
-        return industryEnum;
-      }
-    }
-    if (Objects.equals(firstClass, "其他") && Objects.equals(secondClass, "其他")) {
-      //微信返回的其他行业实际上为"其他",而非"其它",此处兼容处理
-      return OTHER;
-    }
-    return null;
+    return Arrays.stream(WxMpTemplateIndustryEnum.values())
+      .filter(industryEnum -> industryEnum.firstClass.equals(firstClass)
+        && industryEnum.secondClass.contains(secondClass))
+      .findFirst().orElse(null);
   }
 
   /**
@@ -221,12 +213,8 @@ public static WxMpTemplateIndustryEnum findByClass(String firstClass, String sec
    * @return .
    */
   public static WxMpTemplateIndustryEnum findByCode(int code) {
-    for (WxMpTemplateIndustryEnum industryEnum : WxMpTemplateIndustryEnum.values()) {
-      if (industryEnum.code == code) {
-        return industryEnum;
-      }
-    }
-
-    return null;
+    return Arrays.stream(WxMpTemplateIndustryEnum.values())
+      .filter(industryEnum -> industryEnum.code == code)
+      .findFirst().orElse(null);
   }
 }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java
index 99c3df358e..a04d8bb896 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java
@@ -52,6 +52,11 @@ public class WxMpTemplateMessage implements Serializable {
    */
   private MiniProgram miniProgram;
 
+  /**
+   * 防重入id.
+   */
+  private String clientMsgId;
+
   /**
    * 模板数据.
    */
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/wifi/WxMpWifiShopDataResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/wifi/WxMpWifiShopDataResult.java
index 50aec028d1..9a5610ce0b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/wifi/WxMpWifiShopDataResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/wifi/WxMpWifiShopDataResult.java
@@ -11,7 +11,7 @@
  * 门店Wi-Fi信息.
  *
  * @author Binary Wang
- * @date 2019-06-16
+ * created on  2019-06-16
  */
 @Data
 public class WxMpWifiShopDataResult {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MpNewsArticleBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MpNewsArticleBuilder.java
new file mode 100644
index 0000000000..2d6babcf8a
--- /dev/null
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MpNewsArticleBuilder.java
@@ -0,0 +1,33 @@
+package me.chanjar.weixin.mp.builder.kefu;
+
+import me.chanjar.weixin.common.api.WxConsts;
+import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
+
+/**
+ * 图文消息builder
+ * 
+ * 用法:
+ * WxMpKefuMessage m = WxMpKefuMessage.MPNEWSARTICLE().articleId("xxxxx").toUser(...).build();
+ * 
+ * + * @author JCLee + */ +public final class MpNewsArticleBuilder extends BaseBuilder{ + private String articleId; + + public MpNewsArticleBuilder() { + this.msgType = WxConsts.KefuMsgType.MP_NEWS_ARTICLE; + } + + public MpNewsArticleBuilder articleId(String articleId) { + this.articleId = articleId; + return this; + } + + @Override + public WxMpKefuMessage build() { + WxMpKefuMessage m = super.build(); + m.setMpNewsArticleId(this.articleId); + return m; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/DeviceBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/DeviceBuilder.java index 664c2e3a02..53ab66d07f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/DeviceBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/DeviceBuilder.java @@ -1,48 +1,48 @@ -package me.chanjar.weixin.mp.builder.outxml; - -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutDeviceMessage; - -/** - * 设备消息 Builder - * @author biggates - * @see https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-2 - */ -public final class DeviceBuilder extends BaseBuilder { - - private String deviceId; - private String deviceType; - private String content; - private String sessionId; - - public DeviceBuilder deviceType(String deviceType) { - this.deviceType = deviceType; - return this; - } - - public DeviceBuilder deviceId(String deviceId) { - this.deviceId = deviceId; - return this; - } - - public DeviceBuilder content(String content) { - this.content = content; - return this; - } - - public DeviceBuilder sessionId(String sessionId) { - this.sessionId = sessionId; - return this; - } - - @Override - public WxMpXmlOutDeviceMessage build() { - WxMpXmlOutDeviceMessage m = new WxMpXmlOutDeviceMessage(); - setCommon(m); - m.setDeviceId(this.deviceId); - m.setDeviceType(this.deviceType); - m.setContent(this.content); - m.setSessionId(this.sessionId); - return m; - } - -} +package me.chanjar.weixin.mp.builder.outxml; + +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutDeviceMessage; + +/** + * 设备消息 Builder + * @author biggates + * @see 文档 + */ +public final class DeviceBuilder extends BaseBuilder { + + private String deviceId; + private String deviceType; + private String content; + private String sessionId; + + public DeviceBuilder deviceType(String deviceType) { + this.deviceType = deviceType; + return this; + } + + public DeviceBuilder deviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + public DeviceBuilder content(String content) { + this.content = content; + return this; + } + + public DeviceBuilder sessionId(String sessionId) { + this.sessionId = sessionId; + return this; + } + + @Override + public WxMpXmlOutDeviceMessage build() { + WxMpXmlOutDeviceMessage m = new WxMpXmlOutDeviceMessage(); + setCommon(m); + m.setDeviceId(this.deviceId); + m.setDeviceType(this.deviceType); + m.setContent(this.content); + m.setSessionId(this.sessionId); + return m; + } + +} 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 8604bfd720..148ad6ebef 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 @@ -20,6 +20,19 @@ public interface WxMpConfigStorage { */ String getAccessToken(); + /** + * Is use stable access token api + * @Link https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/getStableAccessToken.html + * @return the boolean + */ + boolean isStableAccessToken(); + + /** + * Set use stable access token api + * @param useStableAccessToken true is use, false is not + */ + void useStableAccessToken(boolean useStableAccessToken); + /** * Gets access token lock. * diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpHostConfig.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpHostConfig.java index 819215240a..d6850b8162 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpHostConfig.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpHostConfig.java @@ -5,20 +5,24 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + /** * 微信接口地址域名部分的自定义设置信息. * * @author Binary Wang - * @date 2019-06-09 + * created on 2019-06-09 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class WxMpHostConfig { +public class WxMpHostConfig implements Serializable { public static final String API_DEFAULT_HOST_URL = "https://api.weixin.qq.com"; public static final String MP_DEFAULT_HOST_URL = "https://mp.weixin.qq.com"; public static final String OPEN_DEFAULT_HOST_URL = "https://open.weixin.qq.com"; + private static final long serialVersionUID = 6998547464242356375L; + /** * 对应于:https://api.weixin.qq.com diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpDefaultConfigImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpDefaultConfigImpl.java index 0b31ade5cb..8c0ccfe666 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpDefaultConfigImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpDefaultConfigImpl.java @@ -24,6 +24,10 @@ public class WxMpDefaultConfigImpl implements WxMpConfigStorage, Serializable { protected volatile String appId; protected volatile String secret; + /** + * 是否使用稳定版 Access Token + */ + private boolean useStableAccessToken; protected volatile String token; protected volatile String templateId; protected volatile String accessToken; @@ -60,6 +64,16 @@ public class WxMpDefaultConfigImpl implements WxMpConfigStorage, Serializable { private WxMpHostConfig hostConfig = null; + @Override + public boolean isStableAccessToken() { + return this.useStableAccessToken; + } + + @Override + public void useStableAccessToken(boolean useStableAccessToken) { + this.useStableAccessToken = useStableAccessToken; + } + @Override public boolean isAccessTokenExpired() { return System.currentTimeMillis() > this.expiresTime; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpMapConfigImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpMapConfigImpl.java index 388f39b8fa..cd701d1efc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpMapConfigImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpMapConfigImpl.java @@ -7,7 +7,7 @@ /** * @author Brayden Wong - * @date 2021/1/16 + * created on 2021/1/16 * 提供accesstoken保存在concurrenthashmap中的实现,支持高并发。仅限于单机部署。 */ @Data 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 7f54eb0bb9..870fa1e276 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 @@ -68,7 +68,7 @@ public boolean isAccessTokenExpired() { @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { - redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds - 200, TimeUnit.SECONDS); + redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds, TimeUnit.SECONDS); } @Override 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 f1aa6b9ca7..e0d9e92af1 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 @@ -12,7 +12,7 @@ /** * @author wuxingye - * @date 2020/6/12 + * created on 2020/6/12 */ @EqualsAndHashCode(callSuper = true) @Data diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxCardType.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxCardType.java index 46cc43f887..568f3cdedb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxCardType.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxCardType.java @@ -4,7 +4,7 @@ * 微信卡券类型. * * @author chenyixin - * @date 2019-09-07 23:33 + * created on 2019-09-07 23:33 **/ public enum WxCardType { MEMBER_CARD("MEMBER_CARD"), diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java index 8f6cfeea4c..a9255f9dd4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java @@ -5,7 +5,10 @@ import me.chanjar.weixin.mp.config.WxMpConfigStorage; import me.chanjar.weixin.mp.config.WxMpHostConfig; -import static me.chanjar.weixin.mp.config.WxMpHostConfig.*; +import static me.chanjar.weixin.mp.config.WxMpHostConfig.API_DEFAULT_HOST_URL; +import static me.chanjar.weixin.mp.config.WxMpHostConfig.MP_DEFAULT_HOST_URL; +import static me.chanjar.weixin.mp.config.WxMpHostConfig.OPEN_DEFAULT_HOST_URL; +import static me.chanjar.weixin.mp.config.WxMpHostConfig.buildUrl; /** *
@@ -126,6 +129,10 @@ enum Other implements WxMpApiUrl {
      * 获取access_token.
      */
     GET_ACCESS_TOKEN_URL(API_DEFAULT_HOST_URL, "/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"),
+    /**
+     * 获取稳定版 access_token.
+     */
+    GET_STABLE_ACCESS_TOKEN_URL(API_DEFAULT_HOST_URL, "/cgi-bin/stable_token"),
     /**
      * 获得各种类型的ticket.
      */
@@ -1374,6 +1381,90 @@ enum Guide implements WxMpApiUrl {
     ;
 
 
+    private final String prefix;
+    private final String path;
+
+  }
+
+  /**
+   * 草稿箱 能力:
+   * 新建草稿
+   * 获取草稿
+   * 删除草稿
+   * 修改草稿
+   * 获取草稿总数
+   * 获取草稿列表
+   * MP端开关(仅内测期间使用)- 上线后废弃,没实现,可以自己去公众号后台开启草稿箱
+   */
+  @AllArgsConstructor
+  @Getter
+  enum Draft implements WxMpApiUrl {
+
+    /**
+     * 新建草稿
+     */
+    ADD_DRAFT(API_DEFAULT_HOST_URL, "/cgi-bin/draft/add"),
+    /**
+     * 修改草稿
+     */
+    UPDATE_DRAFT(API_DEFAULT_HOST_URL, "/cgi-bin/draft/update"),
+    /**
+     * 获取草稿
+     */
+    GET_DRAFT(API_DEFAULT_HOST_URL, "/cgi-bin/draft/get"),
+    /**
+     * 删除草稿
+     */
+    DEL_DRAFT(API_DEFAULT_HOST_URL, "/cgi-bin/draft/delete"),
+    /**
+     * 获取草稿列表
+     */
+    LIST_DRAFT(API_DEFAULT_HOST_URL, "/cgi-bin/draft/batchget"),
+    /**
+     * 获取草稿总数
+     */
+    COUNT_DRAFT(API_DEFAULT_HOST_URL, "/cgi-bin/draft/count");
+
+    private final String prefix;
+    private final String path;
+
+  }
+
+  /**
+   * 发布能力:
+   * 发布接口
+   * 发布状态轮询接口
+   * 事件推送发布结果 -- 是回调,没实现
+   * 删除发布
+   * 通过 article_id 获取已发布文章
+   * 获取成功发布列表
+   */
+  @AllArgsConstructor
+  @Getter
+  enum FreePublish implements WxMpApiUrl {
+
+    /**
+     * 发布接口
+     */
+    SUBMIT(API_DEFAULT_HOST_URL, "/cgi-bin/freepublish/submit"),
+    /**
+     * 通过 article_id 获取已发布文章
+     */
+    GET_ARTICLE(API_DEFAULT_HOST_URL, "/cgi-bin/freepublish/getarticle"),
+    /**
+     * 发布状态轮询接口
+     */
+    GET_PUSH_STATUS(API_DEFAULT_HOST_URL, "/cgi-bin/freepublish/get"),
+    /**
+     * 删除发布
+     */
+    DEL_PUSH(API_DEFAULT_HOST_URL, "/cgi-bin/freepublish/delete"),
+    /**
+     * 获取成功发布列表
+     */
+    BATCH_GET(API_DEFAULT_HOST_URL, "/cgi-bin/freepublish/batchget")
+    ;
+
     private final String prefix;
     private final String path;
 
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/WxMpConfigStorageHolder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/WxMpConfigStorageHolder.java
index e844c4866b..b5e0dd8847 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/WxMpConfigStorageHolder.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/WxMpConfigStorageHolder.java
@@ -2,10 +2,10 @@
 
 /**
  * @author yd
- * @date 2019-03-20 22:06
+ * created on  2019-03-20 22:06
  */
 public class WxMpConfigStorageHolder {
-  private final static ThreadLocal THREAD_LOCAL = new ThreadLocal() {
+  private static final ThreadLocal THREAD_LOCAL = new ThreadLocal() {
     @Override
     protected String initialValue() {
       return "default";
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 9f22dbed3e..b14023ef91 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
@@ -20,6 +20,9 @@
 import com.google.common.base.CharMatcher;
 import com.google.common.io.BaseEncoding;
 import me.chanjar.weixin.mp.config.WxMpConfigStorage;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Base64;
 
 public class WxMpCryptUtil extends me.chanjar.weixin.common.util.crypto.WxCryptUtil {
 
@@ -40,7 +43,7 @@ public WxMpCryptUtil(WxMpConfigStorage wxMpConfigStorage) {
 
     this.token = token;
     this.appidOrCorpid = appId;
-    this.aesKey = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey));
+    this.aesKey = Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " "));
   }
 
 }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java
index 5f762cc6dc..3aced61d3b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java
@@ -1,28 +1,34 @@
 package me.chanjar.weixin.mp.util.json;
 
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import me.chanjar.weixin.mp.bean.*;
 import me.chanjar.weixin.mp.bean.card.WxMpCard;
 import me.chanjar.weixin.mp.bean.card.WxMpCardResult;
+import me.chanjar.weixin.mp.bean.card.membercard.WxMpMemberCardActivateTempInfoResult;
+import me.chanjar.weixin.mp.bean.card.membercard.WxMpMemberCardUpdateResult;
+import me.chanjar.weixin.mp.bean.card.membercard.WxMpMemberCardUserInfoResult;
 import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
 import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
 import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
 import me.chanjar.weixin.mp.bean.material.*;
-import me.chanjar.weixin.mp.bean.card.membercard.WxMpMemberCardActivateTempInfoResult;
-import me.chanjar.weixin.mp.bean.card.membercard.WxMpMemberCardUpdateResult;
-import me.chanjar.weixin.mp.bean.card.membercard.WxMpMemberCardUserInfoResult;
 import me.chanjar.weixin.mp.bean.result.*;
 import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
 
+import java.io.File;
+import java.util.Objects;
+
 /**
  * @author someone
  */
 public class WxMpGsonBuilder {
 
   private static final GsonBuilder INSTANCE = new GsonBuilder();
+  private static volatile Gson GSON_INSTANCE;
 
   static {
     INSTANCE.disableHtmlEscaping();
@@ -61,10 +67,33 @@ public class WxMpGsonBuilder {
     INSTANCE.registerTypeAdapter(WxMpMemberCardUserInfoResult.class, new WxMpMemberCardUserInfoResultGsonAdapter());
     INSTANCE.registerTypeAdapter(WxMpMemberCardUpdateResult.class, new WxMpMemberCardUpdateResultGsonAdapter());
     INSTANCE.registerTypeAdapter(WxMpMemberCardActivateTempInfoResult.class, new WxMpMemberCardActivateTempInfoResultGsonAdapter());
+
+    INSTANCE.setExclusionStrategies(new ExclusionStrategy() {
+      @Override
+      public boolean shouldSkipField(FieldAttributes fieldAttributes) {
+        return false;
+      }
+
+      @Override
+      public boolean shouldSkipClass(Class aClass) {
+        if (aClass == File.class) {
+          return true;
+        }
+
+        return false;
+      }
+    });
   }
 
   public static Gson create() {
-    return INSTANCE.create();
+    if (Objects.isNull(GSON_INSTANCE)) {
+      synchronized (INSTANCE) {
+        if (Objects.isNull(GSON_INSTANCE)) {
+          GSON_INSTANCE = INSTANCE.create();
+        }
+      }
+    }
+    return GSON_INSTANCE;
   }
 
 }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java
index 30ac9c1a74..732f55643e 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java
@@ -10,7 +10,8 @@
 /**
  * @author miller
  */
-public class WxMpIndustryGsonAdapter implements JsonSerializer, JsonDeserializer {
+public class WxMpIndustryGsonAdapter implements JsonSerializer,
+  JsonDeserializer {
   @Override
   public JsonElement serialize(WxMpTemplateIndustry wxMpIndustry, Type type, JsonSerializationContext context) {
     JsonObject json = new JsonObject();
@@ -29,6 +30,10 @@ public WxMpTemplateIndustry deserialize(JsonElement jsonElement, Type type, Json
 
   private WxMpTemplateIndustryEnum convertFromJson(JsonObject json) {
     String firstClass = GsonHelper.getString(json, "first_class");
+    // 兼容微信接口实际返回跟官方文档不符的文字
+    if (firstClass != null) {
+      firstClass = firstClass.replace("医疗护理", "医药护理");
+    }
     String secondClass = GsonHelper.getString(json, "second_class");
     final WxMpTemplateIndustryEnum industryEnum = WxMpTemplateIndustryEnum.findByClass(firstClass, secondClass);
     if (industryEnum != null) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java
index 679f8db1ac..c4b1244526 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java
@@ -96,6 +96,11 @@ public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerial
           messageJson.add("msgmenu", msgmenuJsonObject);
         break;
       }
+      case KefuMsgType.MP_NEWS_ARTICLE:
+        JsonObject mpNewsArticleJson = new JsonObject();
+        mpNewsArticleJson.addProperty("article_id", message.getMpNewsArticleId());
+        messageJson.add("mpnewsarticle", mpNewsArticleJson);
+        break;
       default: {
         throw new WxRuntimeException("非法消息类型,暂不支持");
       }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java
index 10b1b72711..d8f3184943 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java
@@ -1,11 +1,13 @@
 package me.chanjar.weixin.mp.util.json;
 
 import com.google.gson.*;
+
 import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
 import org.apache.commons.lang3.StringUtils;
 
 import java.lang.reflect.Type;
+import java.util.List;
 
 /**
  * @author someone
@@ -39,8 +41,17 @@ public JsonElement serialize(WxMpMassOpenIdsMessage message, Type typeOfSrc, Jso
     }
     if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) {
       JsonObject sub = new JsonObject();
-      sub.addProperty("media_id", message.getMediaId());
-      messageJson.add(WxConsts.MassMsgType.IMAGE, sub);
+      List mediaIds = message.getMediaIds();
+      if (mediaIds != null && !mediaIds.isEmpty() ) {
+        JsonArray json = new JsonArray();
+        mediaIds.forEach(json::add);
+        sub.add("media_ids", json);
+        messageJson.add(WxConsts.MassMsgType.IMAGES, sub);
+      } else {
+        String mediaId = message.getMediaId();
+        sub.addProperty("media_id", mediaId);
+        messageJson.add(WxConsts.MassMsgType.IMAGE, sub);
+      }
     }
     if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) {
       JsonObject sub = new JsonObject();
@@ -64,4 +75,7 @@ public JsonElement serialize(WxMpMassOpenIdsMessage message, Type typeOfSrc, Jso
     return messageJson;
   }
 
+  public static void main(String[] args) {
+
+  }
 }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassSendResultAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassSendResultAdapter.java
index aebbca5ec8..fcc14b5ae4 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassSendResultAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassSendResultAdapter.java
@@ -1,6 +1,7 @@
 package me.chanjar.weixin.mp.util.json;
 
 import com.google.gson.*;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.json.GsonHelper;
 import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
 
@@ -16,8 +17,8 @@ public WxMpMassSendResult deserialize(JsonElement json, Type typeOfT, JsonDeseri
     WxMpMassSendResult sendResult = new WxMpMassSendResult();
     JsonObject sendResultJsonObject = json.getAsJsonObject();
 
-    if (sendResultJsonObject.get("errcode") != null && !sendResultJsonObject.get("errcode").isJsonNull()) {
-      sendResult.setErrorCode(GsonHelper.getAsString(sendResultJsonObject.get("errcode")));
+    if (sendResultJsonObject.get(WxConsts.ERR_CODE) != null && !sendResultJsonObject.get(WxConsts.ERR_CODE).isJsonNull()) {
+      sendResult.setErrorCode(GsonHelper.getAsString(sendResultJsonObject.get(WxConsts.ERR_CODE)));
     }
     if (sendResultJsonObject.get("errmsg") != null && !sendResultJsonObject.get("errmsg").isJsonNull()) {
       sendResult.setErrorMsg(GsonHelper.getAsString(sendResultJsonObject.get("errmsg")));
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java
index b73540d1f1..d2eeb62838 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java
@@ -1,14 +1,13 @@
 package me.chanjar.weixin.mp.util.json;
 
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
+import com.google.gson.*;
+
 import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
 import org.apache.commons.lang3.StringUtils;
 
 import java.lang.reflect.Type;
+import java.util.List;
 
 /**
  * 群发消息json转换适配器.
@@ -47,8 +46,17 @@ public JsonElement serialize(WxMpMassTagMessage message, Type typeOfSrc, JsonSer
     }
     if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) {
       JsonObject sub = new JsonObject();
-      sub.addProperty("media_id", message.getMediaId());
-      messageJson.add(WxConsts.MassMsgType.IMAGE, sub);
+      List mediaIds = message.getMediaIds();
+      if (mediaIds != null && !mediaIds.isEmpty() ) {
+        JsonArray json = new JsonArray();
+        mediaIds.forEach(json::add);
+        sub.add("media_ids", json);
+        messageJson.add(WxConsts.MassMsgType.IMAGES, sub);
+      } else {
+        String mediaId = message.getMediaId();
+        sub.addProperty("media_id", mediaId);
+        messageJson.add(WxConsts.MassMsgType.IMAGE, sub);
+      }
     }
     if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) {
       JsonObject sub = new JsonObject();
@@ -56,7 +64,7 @@ public JsonElement serialize(WxMpMassTagMessage message, Type typeOfSrc, JsonSer
       messageJson.add(WxConsts.MassMsgType.MPVIDEO, sub);
     }
     messageJson.addProperty("msgtype", message.getMsgType());
-    messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1);
+    messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 1 : 0);
 
     if (StringUtils.isNotEmpty(message.getClientMsgId())) {
       messageJson.addProperty("clientmsgid", message.getClientMsgId());
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardActivateTempInfoResultGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardActivateTempInfoResultGsonAdapter.java
index fc554c4807..99d37de176 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardActivateTempInfoResultGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardActivateTempInfoResultGsonAdapter.java
@@ -1,6 +1,7 @@
 package me.chanjar.weixin.mp.util.json;
 
 import com.google.gson.*;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.json.GsonHelper;
 import me.chanjar.weixin.mp.bean.card.membercard.MemberCardUserInfo;
 import me.chanjar.weixin.mp.bean.card.membercard.NameValues;
@@ -22,7 +23,7 @@ public WxMpMemberCardActivateTempInfoResult deserialize(JsonElement jsonElement,
 
     JsonObject jsonObject = jsonElement.getAsJsonObject();
 
-    result.setErrorCode(GsonHelper.getString(jsonObject, "errcode"));
+    result.setErrorCode(GsonHelper.getString(jsonObject, WxConsts.ERR_CODE));
     result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg"));
 
     JsonObject userInfoJsonObject = jsonObject.getAsJsonObject("info");
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java
index 2690d3416b..21703ea184 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java
@@ -5,6 +5,7 @@
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.json.GsonHelper;
 import me.chanjar.weixin.mp.bean.card.membercard.WxMpMemberCardUpdateResult;
 
@@ -27,7 +28,7 @@ public WxMpMemberCardUpdateResult deserialize(JsonElement jsonElement, Type type
     JsonObject jsonObject = jsonElement.getAsJsonObject();
 
     result.setOpenId(GsonHelper.getString(jsonObject, "openid"));
-    result.setErrorCode(GsonHelper.getString(jsonObject, "errcode"));
+    result.setErrorCode(GsonHelper.getString(jsonObject, WxConsts.ERR_CODE));
     result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg"));
     result.setResultBalance(GsonHelper.getDouble(jsonObject, "result_balance"));
     result.setResultBonus(GsonHelper.getInteger(jsonObject, "result_bonus"));
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java
index 270e67e8eb..9bb4c62518 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java
@@ -8,6 +8,7 @@
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
+import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.util.json.GsonHelper;
 import me.chanjar.weixin.mp.bean.card.membercard.MemberCardUserInfo;
 import me.chanjar.weixin.mp.bean.card.membercard.NameValues;
@@ -31,7 +32,7 @@ public WxMpMemberCardUserInfoResult deserialize(JsonElement jsonElement, Type ty
     JsonObject jsonObject = jsonElement.getAsJsonObject();
 
     result.setOpenId(getString(jsonObject, "openid"));
-    result.setErrorCode(getString(jsonObject, "errcode"));
+    result.setErrorCode(getString(jsonObject, WxConsts.ERR_CODE));
     result.setErrorMsg(getString(jsonObject, "errmsg"));
     result.setNickname(getString(jsonObject, "nickname"));
     result.setMembershipNumber(getString(jsonObject, "membership_number"));
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpSubscribeMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpSubscribeMessageGsonAdapter.java
index 01ee3c9a4b..5212a4d037 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpSubscribeMessageGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpSubscribeMessageGsonAdapter.java
@@ -10,7 +10,7 @@
 
 /**
  * @author Mklaus
- * @date 2018-01-22 下午12:31
+ * created on  2018-01-22 下午12:31
  */
 public class WxMpSubscribeMessageGsonAdapter implements JsonSerializer {
 
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java
index 73f8c4e3ab..b013ba52d9 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java
@@ -1,15 +1,18 @@
 package me.chanjar.weixin.mp.util.json;
 
-import java.lang.reflect.Type;
-
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
+import org.apache.commons.lang3.StringUtils;
+
+import java.lang.reflect.Type;
+
 
 /**
+ * 模板消息转Json类型转换器
  * @author chanjarster
  */
 public class WxMpTemplateMessageGsonAdapter implements JsonSerializer {
@@ -19,6 +22,9 @@ public JsonElement serialize(WxMpTemplateMessage message, Type typeOfSrc, JsonSe
     JsonObject messageJson = new JsonObject();
     messageJson.addProperty("touser", message.getToUser());
     messageJson.addProperty("template_id", message.getTemplateId());
+    if (StringUtils.isNotBlank(message.getClientMsgId())) {
+      messageJson.addProperty("client_msg_id", message.getClientMsgId());
+    }
     if (message.getUrl() != null) {
       messageJson.addProperty("url", message.getUrl());
     }
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java
index 910ae8c89f..f3a20fbcab 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java
@@ -20,13 +20,10 @@ public WxMpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationC
     if (subscribe != null) {
       user.setSubscribe(!new Integer(0).equals(subscribe));
     }
-    user.setCity(GsonHelper.getString(o, "city"));
-    user.setCountry(GsonHelper.getString(o, "country"));
     user.setHeadImgUrl(GsonHelper.getString(o, "headimgurl"));
     user.setLanguage(GsonHelper.getString(o, "language"));
     user.setNickname(GsonHelper.getString(o, "nickname"));
     user.setOpenId(GsonHelper.getString(o, "openid"));
-    user.setProvince(GsonHelper.getString(o, "province"));
     user.setSubscribeTime(GsonHelper.getLong(o, "subscribe_time"));
     user.setUnionId(GsonHelper.getString(o, "unionid"));
     user.setRemark(GsonHelper.getString(o, "remark"));
@@ -37,21 +34,6 @@ public WxMpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationC
     user.setQrScene(GsonHelper.getString(o, "qr_scene"));
     user.setQrSceneStr(GsonHelper.getString(o, "qr_scene_str"));
 
-    Integer sex = GsonHelper.getInteger(o, "sex");
-    if (sex != null) {
-      user.setSex(sex);
-      switch (sex) {
-        case 1:
-          user.setSexDesc("男");
-          break;
-        case 2:
-          user.setSexDesc("女");
-          break;
-        default:
-          user.setSexDesc("未知");
-      }
-
-    }
     return user;
   }
 
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteOkhttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteOkhttpRequestExecutor.java
index 87d8c3df93..ed9aaa8a84 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteOkhttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteOkhttpRequestExecutor.java
@@ -18,7 +18,7 @@
  * .
  *
  * @author ecoolper
- * @date 2017/5/5
+ * created on  2017/5/5
  */
 public class MaterialDeleteOkhttpRequestExecutor extends MaterialDeleteRequestExecutor {
   private final Logger logger = LoggerFactory.getLogger(this.getClass());
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoApacheHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoApacheHttpRequestExecutor.java
index d1326429df..a4c92cd55c 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoApacheHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoApacheHttpRequestExecutor.java
@@ -1,6 +1,7 @@
 package me.chanjar.weixin.mp.util.requestexecuter.material;
 
 import com.google.common.collect.ImmutableMap;
+import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.enums.WxType;
 import me.chanjar.weixin.common.error.WxError;
 import me.chanjar.weixin.common.error.WxErrorException;
@@ -15,8 +16,6 @@
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 
@@ -24,11 +23,11 @@
  * httpclient 实现的素材请求执行器.
  *
  * @author ecoolper
- * @date 2017/5/5
+ * created on  2017/5/5
  */
+@Slf4j
 public class MaterialNewsInfoApacheHttpRequestExecutor
-    extends MaterialNewsInfoRequestExecutor {
-  private final Logger logger = LoggerFactory.getLogger(this.getClass());
+  extends MaterialNewsInfoRequestExecutor {
 
   public MaterialNewsInfoApacheHttpRequestExecutor(RequestHttp requestHttp) {
     super(requestHttp);
@@ -45,7 +44,7 @@ public WxMpMaterialNews execute(String uri, String materialId, WxType wxType) th
     httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))));
     try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
       String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
-      this.logger.debug("响应原始数据:{}", responseContent);
+      log.debug("响应原始数据:{}", responseContent);
       WxError error = WxError.fromJson(responseContent, WxType.MP);
       if (error.getErrorCode() != 0) {
         throw new WxErrorException(error);
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoOkhttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoOkhttpRequestExecutor.java
index abee9055af..2e3f14dddd 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoOkhttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoOkhttpRequestExecutor.java
@@ -18,7 +18,7 @@
  * .
  *
  * @author ecoolper
- * @date 2017/5/5
+ * created on  2017/5/5
  */
 @Slf4j
 public class MaterialNewsInfoOkhttpRequestExecutor extends MaterialNewsInfoRequestExecutor {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeOkhttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeOkhttpRequestExecutor.java
index e6992e1e5e..f6f2036ce1 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeOkhttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeOkhttpRequestExecutor.java
@@ -22,7 +22,7 @@
 /**
  *
  * @author ecoolper
- * @date 2017/5/5
+ * created on  2017/5/5
  */
 public class QrCodeOkhttpRequestExecutor extends QrCodeRequestExecutor {
   private final Logger logger = LoggerFactory.getLogger(this.getClass());
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java
index c4b57ff13c..89b2224053 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java
@@ -211,6 +211,16 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
         return "模拟一个过期的access token:" + System.currentTimeMillis();
       }
 
+      @Override
+      protected String doGetAccessTokenRequest() throws IOException {
+        return null;
+      }
+
+      @Override
+      protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException {
+        return null;
+      }
+
       @Override
       public void initHttp() {
 
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImplTest.java
index 8efb70f9e3..0109f676ae 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImplTest.java
@@ -18,7 +18,7 @@
  * 测试类.
  *
  * @author Binary Wang
- * @date 2019-06-16
+ * created on  2019-06-16
  */
 
 @Test
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDraftServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDraftServiceImplTest.java
new file mode 100644
index 0000000000..2413c7fcaf
--- /dev/null
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDraftServiceImplTest.java
@@ -0,0 +1,127 @@
+package me.chanjar.weixin.mp.api.impl;
+
+import com.google.inject.Inject;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.api.test.ApiTestModule;
+import me.chanjar.weixin.mp.bean.draft.WxMpAddDraft;
+import me.chanjar.weixin.mp.bean.draft.WxMpDraftArticles;
+import me.chanjar.weixin.mp.bean.draft.WxMpDraftInfo;
+import me.chanjar.weixin.mp.bean.draft.WxMpDraftList;
+import me.chanjar.weixin.mp.bean.draft.WxMpUpdateDraft;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * 草稿箱单元测试.
+ *
+ * @author dragon
+ * created on  2021-10-22
+ */
+@Guice(modules = ApiTestModule.class)
+public class WxMpDraftServiceImplTest {
+
+  /**
+   * 1.先上传一个永久图片素材:me.chanjar.weixin.mp.api.impl.WxMpMaterialServiceImplTest.testUploadMaterial
+   * 2.后续图文需要设置一个永久素材id
+   */
+  final String thumbMediaId = "zUUtT8ZYeXzZ4slFbtnAkh7Yd-f45DbFoF9ERzVC6s4";
+
+  /**
+   * 新增草稿后返回的id,后续查询、修改、删除,获取等需要使用
+   */
+  final String mediaId = "zUUtT8ZYeXzZ4slFbtnAkpgGKyqnTsjtUvMdVBRWJVk";
+
+  @Inject
+  protected WxMpService wxService;
+
+  @Test
+  public void testAddDraft() throws WxErrorException {
+    // {"mediaId":"zUUtT8ZYeXzZ4slFbtnAkh7Yd-f45DbFoF9ERzVC6s4","url":"http://mmbiz.qpic.cn/mmbiz_jpg/fLtyChQRfH84IyicNUbGt3l3IlHxJRibSFz7Tky0ibmzKykzVbo9tZGYhXQGJ2npFtDPbvPhKYxBz6JxkYIibTmUicQ/0?wx_fmt=jpeg"}
+    this.wxService.getDraftService().addDraft("标题", "图文消息的具体内容", thumbMediaId);
+    // 【响应数据】:{"media_id":"zUUtT8ZYeXzZ4slFbtnAks-nZeGiPQmwvhShTh72CqM","item":[]}
+  }
+
+  @Test
+  public void testAddGuide_another() throws WxErrorException {
+    List draftArticleList = new ArrayList<>();
+    WxMpDraftArticles draftArticle = WxMpDraftArticles.builder()
+      .title("新建草稿-对象形式")
+      .author("dragon")
+      .digest("图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空")
+      .content("图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS")
+      .contentSourceUrl("https://github.com/Wechat-Group/WxJava")
+      .thumbMediaId(thumbMediaId)
+      // 显示封面、打开评论、所有人可评论
+      .showCoverPic(1).needOpenComment(1).onlyFansCanComment(0)
+      .build();
+    draftArticleList.add(draftArticle);
+
+    WxMpAddDraft addDraft = WxMpAddDraft.builder().articles(draftArticleList).build();
+    String mediaId = this.wxService.getDraftService().addDraft(addDraft);
+    // 【响应数据】:{"media_id":"zUUtT8ZYeXzZ4slFbtnAkpgGKyqnTsjtUvMdVBRWJVk","item":[]}
+    assertThat(mediaId).isNotNull();
+  }
+
+  @Test
+  public void testGetDraft() throws WxErrorException {
+    final WxMpDraftInfo draftInfo = this.wxService.getDraftService().getDraft(mediaId);
+    assertThat(draftInfo).isNotNull();
+    // 【响应数据】:{"news_item":[{"title":"标题","author":"","digest":"图文消息的具体内容","content":"图文消息的具体内容","content_source_url":"","thumb_media_id":"zUUtT8ZYeXzZ4slFbtnAkh7Yd-f45DbFoF9ERzVC6s4","show_cover_pic":1,"url":"http:\/\/mp.weixin.qq.com\/s?__biz=Mzk0OTI5MzM1OQ==&mid=100000006&idx=1&sn=89903965ae5ebd6014903c7c5ca34daa&chksm=435bd946742c5050d18da32289904db5ede8bbd157d181438231a1762b85030419b3c0ed4c00#rd","thumb_url":"http:\/\/mmbiz.qpic.cn\/mmbiz_jpg\/fLtyChQRfH84IyicNUbGt3l3IlHxJRibSFz7Tky0ibmzKykzVbo9tZGYhXQGJ2npFtDPbvPhKYxBz6JxkYIibTmUicQ\/0?wx_fmt=jpeg","need_open_comment":0,"only_fans_can_comment":0}],"create_time":1634886802,"update_time":1634886802}
+  }
+
+  @Test
+  public void testUpdateDraft() throws WxErrorException {
+    WxMpDraftArticles draftArticles = WxMpDraftArticles.builder()
+      .title("新标题").content("新图文消息的具体内容").thumbMediaId(thumbMediaId).build();
+    WxMpUpdateDraft updateDraft = WxMpUpdateDraft.builder()
+      .mediaId(mediaId)
+      .index(0)
+      .articles(draftArticles)
+      .build();
+    Boolean updateDraftResult = this.wxService.getDraftService().updateDraft(updateDraft);
+    // assertThat(updateDraftResult).isTrue();
+    assertThat(updateDraftResult).isTrue();
+  }
+
+  @Test
+  public void testDelDraft() throws WxErrorException {
+    Boolean delDraftResult = this.wxService.getDraftService().delDraft(mediaId);
+    // 【响应数据】:{"errcode":0,"errmsg":"ok"}
+    assertThat(delDraftResult).isTrue();
+  }
+
+  @Test
+  public void testListDraft() throws WxErrorException {
+    WxMpDraftList draftList = this.wxService.getDraftService().listDraft(0, 10);
+    /*
+    【响应数据】:{"item":[{"media_id":"zUUtT8ZYeXzZ4slFbtnAks-nZeGiPQmwvhShTh72CqM",
+    "content":{
+      "news_item":
+      [
+        {"title":"标题","author":"","digest":"图文消息的具体内容","content":"图文消息的具体内容",
+        "content_source_url":"","thumb_media_id":"zUUtT8ZYeXzZ4slFbtnAkh7Yd-f45DbFoF9ERzVC6s4",
+        "show_cover_pic":1,"url":"http:\/\/mp.weixin.qq.com\/s?__biz=Mzk0OTI5MzM1?wx_fmt=jpeg",
+        "need_open_comment":0,"only_fans_can_comment":0}],
+        "create_time":1634886802,"update_time":1634886802},"update_time":1634886802}
+      ]
+    ,"total_count":1,"item_count":1}
+
+    */
+    assertThat(draftList).isNotNull();
+  }
+
+  @Test
+  public void testCountDraft() throws WxErrorException {
+    Long countDraft = this.wxService.getDraftService().countDraft();
+    // 【响应数据】:{"total_count":1}
+    assertThat(countDraft).isNotNull();
+  }
+
+}
+
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpFreePublishServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpFreePublishServiceImplTest.java
new file mode 100644
index 0000000000..1c0cfa900b
--- /dev/null
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpFreePublishServiceImplTest.java
@@ -0,0 +1,109 @@
+package me.chanjar.weixin.mp.api.impl;
+
+import com.google.inject.Inject;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.api.test.ApiTestModule;
+import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishInfo;
+import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList;
+import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishStatus;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * 发布能力-单元测试.
+ *
+ * @author dragon
+ * created on  2021-10-23
+ */
+@Guice(modules = ApiTestModule.class)
+public class WxMpFreePublishServiceImplTest {
+
+  /**
+   * 新增草稿后返回的id,发布需要使用
+   */
+  final String mediaId = "HKVdzjkDfooMqBqJtvSs2EEeRAJaM33gJgkii_JDOHg";
+
+  /**
+   * 发布后的id,后续查询等需要使用
+   */
+  final String publishId = "2650177669";
+
+  /**
+   * 图文的 article_id,后续查询图文详情、删除发布内容 需要使用
+   * 要根据 publishId 来获取 article_id
+   *
+   * @see this.testGetPushStatus
+   */
+  final String articleId = "zjMKVd1g66BkEkpetwml4ElbDdniE8JeI2Ec324Sjqg";
+
+  @Inject
+  protected WxMpService wxService;
+
+  @Test
+  public void testSubmit() throws WxErrorException {
+    String submit = this.wxService.getFreePublishService().submit(mediaId);
+    assertThat(submit).isNotBlank();
+    // 【响应数据】:{"errcode":0,"errmsg":"ok","publish_id":2650177668}
+  }
+
+  @Test
+  public void testGetPushStatus() throws WxErrorException {
+    WxMpFreePublishStatus pushStatus = this.wxService.getFreePublishService().getPushStatus(publishId);
+    assertThat(pushStatus).isNotNull();
+    // 【响应数据】:{"publish_id":2650177668,"publish_status":0,"article_id":"zjMKVd1g66BkEkpetwml4J-4gNf4I1nsh-B-r_inemw",
+    // "article_detail":{"count":1,"item":
+    // [{"idx":1,"article_url":
+    // "https://mp.weixin.qq.com/s?__biz=MzAwMTE2MzA1xxxxxxxxxx"
+    // }]},"fail_idx":[]}
+    // article_url -> 已发布内容可被自定义菜单、自动回复、话题引用,也可用于公开传播
+  }
+
+  @Test
+  public void testGetArticleFromId() throws WxErrorException {
+    WxMpFreePublishInfo articleFromId = this.wxService.getFreePublishService().getArticleFromId(articleId);
+    assertThat(articleFromId).isNotNull();
+    /* 【响应数据】:{"news_item":[{"title":"欢迎你加入啊~ 这是我的第一条文字消息草稿","author":"","digest":"","content":"欢迎你加入啊~ 这是我的第一条文字消息草稿",
+    "content_source_url":"","thumb_media_id":"","show_cover_pic":0,"url":"http:\/\/mp.weixin.qq
+    .com\/s?__biz=MzAwMTE2MzA1Mg==&mid=2650177668","thumb_url":"","need_open_comment":1,"only_fans_can_comment":1,"is_deleted":false}],
+    "create_time":1634961670,"update_time":1634961672}
+     */
+  }
+
+  @Test
+  public void testDelPush() throws WxErrorException {
+    Boolean deletePush = this.wxService.getFreePublishService().deletePush(articleId, 0);
+    // 【响应数据】:{"errcode":0,"errmsg":"ok"}
+    assertThat(deletePush).isTrue();
+  }
+
+  @Test
+  public void testDeletePushAllArticle() throws WxErrorException {
+    Boolean deletePush = this.wxService.getFreePublishService().deletePushAllArticle(articleId);
+    // 【响应数据】:{"errcode":0,"errmsg":"ok"}
+    assertThat(deletePush).isTrue();
+  }
+
+  @Test
+  public void testGetPublicationRecords() throws WxErrorException {
+    WxMpFreePublishList publicationRecords = this.wxService.getFreePublishService().getPublicationRecords(0, 10, 0);
+    /*
+    【响应数据】:
+    {"item":[{"article_id":"zjMKVd1g66BkEkpetwml4BOSzatuEYNY3TFhCc0kSIE","content":{"news_item":[
+    {"title":"新建草稿-对象形式","author":"dragon","digest":"图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空",
+    "content":"图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS",
+    "content_source_url":"https:\/\/github.com\/Wechat-Group\/WxJava","thumb_media_id":"HKVdzjkDfooMqBqJtvSs2Ajz2v6L_vtGhyyr_mqKcPU",
+    "show_cover_pic":1,"url":"http:\/\/mp.weixin.qq.com\/s?__biz=MzAwMTE2MzA1Mg==&mid=26501776710e5adb91#rd",
+    "thumb_url":"http:\/\/mmbiz.qpic.cn\/mmbiz_jpg\/0QSAUfroWrUmxHthQ\/0?wx_fmt=jpeg",
+    "need_open_comment":1,"only_fans_can_comment":0,"is_deleted":false}],
+    "create_time":1634976306,"update_time":1634976318}}
+    ]
+    ,"total_count":1,"item_count":1}
+    */
+    assertThat(publicationRecords).isNotNull();
+  }
+
+}
+
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImplTest.java
index 6fd3dda3f0..675abe693b 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideBuyerServiceImplTest.java
@@ -15,7 +15,7 @@
 
 /**
  * @author 广州跨界-宋心成
- * @date 2021/5/13/013
+ * created on  2021/5/13/013
  */
 
 @Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImplTest.java
index 20621a34d4..111a8810c5 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMassedJobServiceImplTest.java
@@ -17,7 +17,7 @@
 
 /**
  * @author 广州跨界-宋心成
- * @date 2021/5/13/013
+ * created on  2021/5/13/013
  */
 
 @Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImplTest.java
index f1ffe8f9ff..58de66d5e2 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideMaterialServiceImplTest.java
@@ -19,7 +19,7 @@
 
 /**
  * @author 广州跨界-宋心成
- * @date 2021/5/13/013
+ * created on  2021/5/13/013
  */
 
 @Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImplTest.java
index 13ec80c168..b69d491750 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImplTest.java
@@ -17,7 +17,7 @@
  * 单元测试.
  *
  * @author Binary Wang
- * @date 2020-10-06
+ * created on  2020-10-06
  */
 @Guice(modules = ApiTestModule.class)
 public class WxMpGuideServiceImplTest {
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImplTest.java
index 6ba2fae1ff..c357406bb5 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGuideTagServiceImplTest.java
@@ -16,7 +16,7 @@
 
 /**
  * @author 广州跨界-宋心成
- * @date 2021/5/13/013
+ * created on  2021/5/13/013
  */
 
 @Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMarketingServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMarketingServiceImplTest.java
index dd15496e16..75637ceaa5 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMarketingServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMarketingServiceImplTest.java
@@ -13,7 +13,7 @@
  * 测试类.
  *
  * @author Binary Wang
- * @date 2019-07-14
+ * created on  2019-07-14
  */
 @Test
 @Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java
index b31cc748ea..4c8b1b670f 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java
@@ -1,6 +1,7 @@
 package me.chanjar.weixin.mp.api.impl;
 
 import com.google.inject.Inject;
+
 import me.chanjar.weixin.common.api.WxConsts;
 import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
 import me.chanjar.weixin.common.error.WxErrorException;
@@ -21,6 +22,8 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 import static org.testng.Assert.assertNotNull;
 
@@ -38,7 +41,7 @@ public class WxMpMassMessageServiceImplTest {
   @Test
   public void testTextMassOpenIdsMessageSend() throws WxErrorException {
     // 发送群发消息
-    TestConfigStorage configProvider = (TestConfigStorage) this.wxService      .getWxMpConfigStorage();
+    TestConfigStorage configProvider = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
     WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
     massMessage.setMsgType(WxConsts.MassMsgType.TEXT);
     massMessage.setContent("测试群发消息\n欢迎欢迎\n换行测试\n超链接:Hello World");
@@ -63,6 +66,30 @@ public void testMediaMassOpenIdsMessageSend(String massMsgType, String mediaId)
     assertNotNull(massResult.getMsgId());
   }
 
+  @Test
+  public void testImagesMassOpenIdsMessageSend() throws WxErrorException {
+    // 发送群发消息
+    List massMsg = new ArrayList<>();
+    for (int i = 0; i < 2; i++) {
+      try (InputStream inputStream = ClassLoader
+        .getSystemResourceAsStream(i + ".jpeg")) {
+        WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService().mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
+        assertNotNull(uploadMediaRes);
+        assertNotNull(uploadMediaRes.getMediaId());
+        massMsg.add(uploadMediaRes.getMediaId());
+      } catch (IOException e) {
+        e.printStackTrace();
+      }
+    }
+    WxMpMassTagMessage massMessage = new WxMpMassTagMessage();
+    massMessage.setMsgType(WxConsts.MassMsgType.IMAGE);
+    massMessage.setMediaIds(new ArrayList<>(massMsg));
+    massMessage.setSendAll(true);
+    WxMpMassSendResult massResult = this.wxService.getMassMessageService().massGroupMessageSend(massMessage);
+    assertNotNull(massResult);
+    assertNotNull(massResult.getMsgId());
+  }
+
   @Test
   public void testTextMassGroupMessageSend() throws WxErrorException {
     WxMpMassTagMessage massMessage = new WxMpMassTagMessage();
@@ -77,7 +104,7 @@ public void testTextMassGroupMessageSend() throws WxErrorException {
   }
 
   @Test(dataProvider = "massMessages")
-  public void testMediaMassGroupMessageSend(String massMsgType, String mediaId)    throws WxErrorException {
+  public void testMediaMassGroupMessageSend(String massMsgType, String mediaId) throws WxErrorException {
     WxMpMassTagMessage massMessage = new WxMpMassTagMessage();
     massMessage.setMsgType(massMsgType);
     massMessage.setMediaId(mediaId);
@@ -123,7 +150,8 @@ public Object[][] massMessages() throws WxErrorException, IOException {
         .mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
       assertNotNull(uploadMediaRes);
       assertNotNull(uploadMediaRes.getMediaId());
-      messages[1] = new Object[]{WxConsts.MassMsgType.IMAGE, uploadMediaRes.getMediaId()};
+      messages[1] = new Object[]{WxConsts.MassMsgType.IMAGE, uploadMediaRes.getMediaId()
+      };
     }
 
     /*
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImplTest.java
index 6004d3cbe2..3a094e4008 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImplTest.java
@@ -16,7 +16,7 @@
  * 测试类.
  *
  * @author Binary Wang
- * @date 2020-08-09
+ * created on  2020-08-09
  */
 @Test
 @Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImplTest.java
index b3f45eb8d8..2cc8b80119 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImplTest.java
@@ -32,7 +32,7 @@
  * 测试类.
  *
  * @author Binary Wang
- * @date 2019-06-22
+ * created on  2019-06-22
  */
 @Test
 @Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java
index c450775d25..636bedb855 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java
@@ -59,4 +59,15 @@ public void testRefreshAccessToken() throws WxErrorException {
     Assert.assertNotEquals(before, after);
     Assert.assertTrue(StringUtils.isNotBlank(after));
   }
+
+  public void testStableRefreshAccessToken() throws WxErrorException {
+    WxMpConfigStorage configStorage = this.wxService.getWxMpConfigStorage();
+    configStorage.useStableAccessToken(true);
+    String before = configStorage.getAccessToken();
+    this.wxService.getAccessToken(false);
+
+    String after = configStorage.getAccessToken();
+    Assert.assertNotEquals(before, after);
+    Assert.assertTrue(StringUtils.isNotBlank(after));
+  }
 }
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImplTest.java
index efa3e0a37d..79d705203f 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpSubscribeMsgServiceImplTest.java
@@ -12,7 +12,7 @@
 
 /**
  * @author Mklaus
- * @date 2018-01-22 下午2:02
+ * created on  2018-01-22 下午2:02
  */
 @Guice(modules = ApiTestModule.class)
 public class WxMpSubscribeMsgServiceImplTest {
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java
index ec754875da..e74f200b44 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java
@@ -166,4 +166,13 @@ public void testMsgMenuBuild() {
       "{\"touser\":\"OPENID\",\"msgtype\":\"msgmenu\",\"msgmenu\":{\"head_content\":\"head_content\",\"list\":[{\"id\":\"101\",\"content\":\"msgmenu1\"},{\"id\":\"102\",\"content\":\"msgmenu2\"}],\"tail_content\":\"tail_content\"}}");
   }
 
+  public void testMpNewsArticleBuilder() {
+    WxMpKefuMessage reply = WxMpKefuMessage.MPNEWSARTICLE()
+      .toUser("OPENID")
+      .articleId("ARTICLE_ID")
+      .build();
+    Assert.assertEquals(reply.toJson(),
+      "{\"touser\":\"OPENID\",\"msgtype\":\"mpnewsarticle\",\"mpnewsarticle\":{\"article_id\":\"ARTICLE_ID\"}}");
+  }
+
 }
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/marketing/WxMpUserActionTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/marketing/WxMpUserActionTest.java
index 3d18b1ebbc..500a9ed299 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/marketing/WxMpUserActionTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/marketing/WxMpUserActionTest.java
@@ -9,7 +9,7 @@
  * 老板加点注释吧.
  *
  * @author Binary Wang
- * @date 2019-07-14
+ * created on  2019-07-14
  */
 public class WxMpUserActionTest {
 
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResultTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResultTest.java
index 0b80ed083e..907bda15e1 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResultTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResultTest.java
@@ -8,7 +8,7 @@
 
 /**
  * @author Binary Wang
- * @date 2019-08-05
+ * created on  2019-08-05
  */
 public class WxMpGetSelfMenuInfoResultTest {
 
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpMenuTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpMenuTest.java
index 3577306608..bcbc071189 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpMenuTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpMenuTest.java
@@ -8,7 +8,7 @@
  * 单元测试.
  *
  * @author Binary Wang
- * @date 2020-11-05
+ * created on  2020-11-05
  */
 public class WxMpMenuTest {
 
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java
index b8d8843624..ba8dd1b802 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java
@@ -276,4 +276,85 @@ public void testFromXml_MASSSENDJOBFINISH() {
     assertThat(resultList.get(1).get("NeedReplaceContent")).isEqualTo("1");
     assertThat(resultList.get(1).get("NeedShowReprintSource")).isEqualTo("1");
   }
+
+  public void testSubMsgPopupFromXml() {
+
+    String xml = ""
+      + ""
+      + ""
+      + "1610969440"
+      + ""
+      + ""
+      + ""
+      + ""
+      + ""
+      + ""
+      + "2"
+      + ""
+      + ""
+      + ""
+      + ""
+      + "2"
+      + ""
+      + ""
+      + "";
+
+    WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml);
+    WxMpSubscribeMsgEvent.PopupEvent popupEvent = wxMessage.getSubscribeMsgPopupEvent().getList().get(0);
+    assertEquals(popupEvent.getTemplateId(), "VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc");
+    assertEquals(popupEvent.getSubscribeStatusString(), "accept");
+    assertEquals(popupEvent.getPopupScene(), "2");
+    WxMpSubscribeMsgEvent.PopupEvent popupEvent2 = wxMessage.getSubscribeMsgPopupEvent().getList().get(1);
+    assertEquals(popupEvent2.getTemplateId(), "9nLIlbOQZC5Y89AZteFEux3WCXRRRG5Wfzkpssu4bLI");
+    assertEquals(popupEvent2.getSubscribeStatusString(), "reject");
+    assertEquals(popupEvent2.getPopupScene(), "2");
+  }
+
+  public void testSubMsgChangeFromXml() {
+
+    String xml = ""
+      + ""
+      + ""
+      + "1610969440"
+      + ""
+      + ""
+      + ""
+      + ""
+      + ""
+      + ""
+      + ""
+      + ""
+      + "";
+
+    WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml);
+    WxMpSubscribeMsgEvent.ChangeEvent changeEvent = wxMessage.getSubscribeMsgChangeEvent().getList().get(0);
+    assertEquals(changeEvent.getTemplateId(), "VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc");
+    assertEquals(changeEvent.getSubscribeStatusString(), "reject");
+  }
+
+  public void testSubMsgSentFromXml() {
+
+    String xml = ""
+      + ""
+      + ""
+      + "1610969440"
+      + ""
+      + ""
+      + ""
+      + ""
+      + ""
+      + "1700827132819554304"
+      + "0"
+      + ""
+      + ""
+      + ""
+      + "";
+
+    WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml);
+    WxMpSubscribeMsgEvent.SentEvent sentEvent = wxMessage.getSubscribeMsgSentEvent().getList().get(0);
+    assertEquals(sentEvent.getTemplateId(), "VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc");
+    assertEquals(sentEvent.getMsgId(), "1700827132819554304");
+    assertEquals(sentEvent.getErrorCode(), "0");
+    assertEquals(sentEvent.getErrorStatus(), "success");
+  }
 }
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessageTest.java
index 61d3d6fa6f..078ad51570 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/subscribe/WxMpSubscribeMessageTest.java
@@ -6,7 +6,7 @@
 
 /**
  * @author Mklaus
- * @date 2018-01-22 下午1:41
+ * created on  2018-01-22 下午1:41
  */
 public class WxMpSubscribeMessageTest {
   @Test
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryTest.java
index c2ae722977..98999a5b1a 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustryTest.java
@@ -8,7 +8,7 @@
  * 测试类.
  *
  * @author Binary Wang
- * @date 2020-02-29
+ * created on  2020-02-29
  */
 public class WxMpTemplateIndustryTest {
 
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java
index 5a3f67fb1d..fa7cd92967 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java
@@ -19,14 +19,14 @@ public void testToJson() {
       .templateId("ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY")
       .miniProgram(new WxMpTemplateMessage.MiniProgram("xiaochengxuappid12345", "index?foo=bar",true))
       .url("http://weixin.qq.com/download")
+      .clientMsgId("MSG_000001")
       .build();
 
     tm.addData(
       new WxMpTemplateData("first", "haahah", "#FF00FF"));
     tm.addData(
       new WxMpTemplateData("remark", "heihei", "#FF00FF"));
-
-    assertEquals(tm.toJson(), "{\"touser\":\"OPENID\",\"template_id\":\"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\",\"url\":\"http://weixin.qq.com/download\",\"miniprogram\":{\"appid\":\"xiaochengxuappid12345\",\"pagepath\":\"index?foo=bar\"},\"data\":{\"first\":{\"value\":\"haahah\",\"color\":\"#FF00FF\"},\"remark\":{\"value\":\"heihei\",\"color\":\"#FF00FF\"}}}");
+    assertEquals(tm.toJson(), "{\"touser\":\"OPENID\",\"template_id\":\"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\",\"client_msg_id\":\"MSG_000001\",\"url\":\"http://weixin.qq.com/download\",\"miniprogram\":{\"appid\":\"xiaochengxuappid12345\",\"path\":\"index?foo=bar\"},\"data\":{\"first\":{\"value\":\"haahah\",\"color\":\"#FF00FF\"},\"remark\":{\"value\":\"heihei\",\"color\":\"#FF00FF\"}}}");
   }
 
 }
diff --git a/weixin-java-mp/src/test/resources/0.jpeg b/weixin-java-mp/src/test/resources/0.jpeg
new file mode 100644
index 0000000000..1d78d78017
Binary files /dev/null and b/weixin-java-mp/src/test/resources/0.jpeg differ
diff --git a/weixin-java-mp/src/test/resources/1.jpeg b/weixin-java-mp/src/test/resources/1.jpeg
new file mode 100644
index 0000000000..f083fd4f26
Binary files /dev/null and b/weixin-java-mp/src/test/resources/1.jpeg differ
diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml
index 2407c52146..079f821ca6 100644
--- a/weixin-java-open/pom.xml
+++ b/weixin-java-open/pom.xml
@@ -7,7 +7,7 @@
   
     com.github.binarywang
     wx-java
-    4.1.9.B
+    4.5.7.B
   
 
   weixin-java-open
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java
index c25acdf1aa..2e41205e02 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java
@@ -8,6 +8,7 @@
 import me.chanjar.weixin.open.bean.WxOpenCreateResult;
 import me.chanjar.weixin.open.bean.WxOpenGetResult;
 import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate;
+import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo;
 import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
 import me.chanjar.weixin.open.bean.minishop.*;
 import me.chanjar.weixin.open.bean.minishop.coupon.WxMinishopCoupon;
@@ -15,7 +16,10 @@
 import me.chanjar.weixin.open.bean.minishop.goods.*;
 import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountGoods;
 import me.chanjar.weixin.open.bean.result.*;
-import org.jetbrains.annotations.Nullable;
+import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest;
+import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse;
+import me.chanjar.weixin.open.bean.tcbComponent.GetShareCloudBaseEnvResponse;
+import me.chanjar.weixin.open.bean.tcbComponent.GetTcbEnvListResponse;
 
 import java.io.File;
 import java.util.List;
@@ -111,6 +115,11 @@ public interface WxOpenComponentService {
    */
   String GET_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/get";
 
+  /**
+   * 查询公众号/小程序是否绑定 open 帐号
+   */
+  String HAVE_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/have";
+
   /**
    * 快速创建小程序接口.
    */
@@ -120,6 +129,21 @@ public interface WxOpenComponentService {
    */
   String FAST_REGISTER_WEAPP_SEARCH_URL = "https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?action=search";
 
+  /**
+   * 快速创建个人小程序接口.
+   */
+  String FAST_REGISTER_PERSONAL_WEAPP_URL = "https://api.weixin.qq.com/wxa/component/fastregisterpersonalweapp?action=create";
+
+  /**
+   * 查询快速创建个人小程序任务状态接口.
+   */
+  String FAST_REGISTER_PERSONAL_WEAPP_SEARCH_URL = "https://api.weixin.qq.com/wxa/component/fastregisterpersonalweapp?action=query";
+
+  /**
+   * 快速创建试用小程序接口.
+   */
+  String FAST_REGISTER_BETA_WEAPP_URL = "https://api.weixin.qq.com/wxa/component/fastregisterbetaweapp";
+
   /**
    * 代小程序实现业务.
    * 小程序代码模版库管理:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1506504150_nMMh6&token=&lang=zh_CN
@@ -169,7 +193,15 @@ public interface WxOpenComponentService {
 
   String MINISHOP_GET_DELIVERY_COMPANY_URL = "https://api.weixin.qq.com/product/delivery/get_company_list";
 
+  String BATCH_GET_ENVID_URL = "https://api.weixin.qq.com/componenttcb/batchgetenvid";
+
+  String DESCRIBE_ENVS_URL = "https://api.weixin.qq.com/componenttcb/describeenvs";
+
+  String MODIFY_ENV_URL = "https://api.weixin.qq.com/tcb/modifyenv";
+
+  String BATCH_SHARE_ENV = "https://api.weixin.qq.com/componenttcb/batchshareenv";
 
+  String COMPONENT_CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2";
   /**
    * Gets wx mp service by appid.
    *
@@ -393,7 +425,7 @@ public interface WxOpenComponentService {
    * @return the wx mp o auth 2 access token
    * @throws WxErrorException the wx error exception
    * @see WxMpService#getOAuth2Service()
-   * @deprecated 2021-05-21: 已修正公众号相关接口,请使用:WxOpenCommpentService.getWxMpServiceByAppid(mpAppId).getOAuth2Service().getAccessToken(code)
+   * @deprecated 2021-05-21: 已修正公众号相关接口,请使用:WxOpenComponentService.getWxMpServiceByAppid(mpAppId).getOAuth2Service().getAccessToken(code)
    */
   @Deprecated
   WxOAuth2AccessToken oauth2getAccessToken(String appid, String code) throws WxErrorException;
@@ -469,7 +501,7 @@ public interface WxOpenComponentService {
    * @return 小程序代码模版列表 (templateId)
    * @throws WxErrorException 获取失败时返回,具体错误码请看此接口的注释文档
    */
-  List getTemplateList(@Nullable Integer templateType) throws WxErrorException;
+  List getTemplateList(Integer templateType) throws WxErrorException;
 
   /**
    * 请参考并使用 {@link #addToTemplate(long, int)}.
@@ -549,6 +581,16 @@ public interface WxOpenComponentService {
    */
   WxOpenGetResult getOpenAccount(String appId, String appIdType) throws WxErrorException;
 
+  /**
+   * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html
+   * 查询公众号/小程序是否绑定 open 帐号
+   *
+   * @return 是否绑定 open 帐号,true表示绑定;false表示未绑定任何 open 帐号
+   * @throws WxErrorException the wx error exception
+   */
+  WxOpenHaveResult haveOpen() throws WxErrorException;
+
+
   /**
    * https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21538208049W8uwq&token=&lang=zh_CN
    * 第三方平台快速创建小程序.
@@ -581,6 +623,39 @@ public interface WxOpenComponentService {
   WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWechat, String legalPersonaName) throws WxErrorException;
 
 
+  /**
+   * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/fastregisterpersonalweapp.html
+   * 快速创建个人小程序
+   *
+   * @param idname         个人用户名字
+   * @param wxuser         个人用户微信号
+   * @param componentPhone 第三方联系电话
+   * @return the wx open result
+   * @throws WxErrorException
+   */
+  WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeapp(String idname, String wxuser, String componentPhone) throws WxErrorException;
+
+  /**
+   * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/fastregisterpersonalweapp.html
+   * 查询个人小程序注册任务状态
+   *
+   * @param taskid 任务ID
+   * @return the wx open result
+   * @throws WxErrorException
+   */
+  WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeappSearch(String taskid) throws WxErrorException;
+
+  /**
+   * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastregister.html
+   * 注册试用小程序
+   *
+   * @param name   小程序名称
+   * @param openid 微信用户的openid(不是微信号)
+   * @return the wx open result
+   * @throws WxErrorException
+   */
+  WxOpenRegisterBetaWeappResult fastRegisterBetaWeapp(String name, String openid) throws WxErrorException;
+
   /**
    * https://api.weixin.qq.com/product/register/register_shop?component_access_token=xxxxxxxxx
    * 注册小商店账号
@@ -972,4 +1047,71 @@ public interface WxOpenComponentService {
    * @return
    */
   WxOpenResult updateLimitDiscountStatus(String appId, Long taskId, Integer status) throws WxErrorException;
+
+  /**
+   * 查询环境共享信息
+   * https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/getShareCloudbaseEnv.html
+   *
+   * @param appids 要查询的appid
+   * @return
+   */
+  GetShareCloudBaseEnvResponse getShareCloudBaseEnv(List appids) throws WxErrorException;
+
+
+  /**
+   * 获取环境信息
+   * https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/getTcbEnvList.html
+   *
+   * @return
+   * @throws WxErrorException
+   */
+  GetTcbEnvListResponse getTcbEnvList() throws WxErrorException;
+
+  /**
+   * 转换云环境
+   * https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/changeTcbEnv.html
+   *
+   * @param env 环境id
+   * @return
+   * @throws WxErrorException
+   */
+  WxOpenResult changeTcbEnv(String env) throws WxErrorException;
+
+
+  /**
+   * 环境共享
+   * https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/shareCloudbaseEnv.html
+   *
+   * @param request
+   * @return
+   * @throws WxErrorException
+   */
+  ShareCloudBaseEnvResponse shareCloudBaseEnv(ShareCloudBaseEnvRequest request) throws WxErrorException;
+
+  /**
+   * 使用 AppSecret 重置第三方平台 API 调用次数
+   * https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/openapi/clearComponentQuotaByAppSecret.html
+   *
+   * @param appid  授权用户appid
+   * @return
+   * @throws WxErrorException
+   */
+  WxOpenResult clearQuotaV2(String appid) throws WxErrorException;
+
+  //////////////////////////////////////////////////////////////
+  /**
+   * 申请设置订单页path信息
+   */
+  String OPEN_APPLY_SET_ORDER_PATH_INFO = "https://api.weixin.qq.com/wxa/security/applysetorderpathinfo";
+
+  /**
+   * 申请设置订单页path信息
+   * 注意:一次提交不超过100个appid
+   *
+   * @param info 订单页path信息
+   * @return .
+   * @throws WxErrorException .
+   */
+  WxOpenResult applySetOrderPathInfo(WxOpenMaApplyOrderPathInfo info) throws WxErrorException;
+
 }
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenFastMaService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenFastMaService.java
index 2114d1a816..b94774f791 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenFastMaService.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenFastMaService.java
@@ -10,7 +10,7 @@
  * 
* * @author Hipple - * @date 2019/01/23 + * created on 2019/01/23 * @deprecated 2021-06-23 本接口原有方法并非仅快速创建小程序的专用接口,普通小程序授权到第三方平台皆可使用,所以请使用 {@link WxOpenMaBasicService} 类替代。获取方法: WxOpenComponentService.getWxMaServiceByAppid(maApppId).getBasicService() */ @Deprecated diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaBasicService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaBasicService.java index 194da4b9b3..cae5faa783 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaBasicService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaBasicService.java @@ -2,6 +2,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.open.bean.ma.WxFastMaCategory; +import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo; import me.chanjar.weixin.open.bean.result.*; import java.util.List; @@ -69,6 +70,11 @@ public interface WxOpenMaBasicService { */ String OPEN_MODIFY_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/modifycategory"; + /** + * 获取订单页path信息 + */ + String OPEN_GET_ORDER_PATH_INFO = "https://api.weixin.qq.com/wxa/security/getorderpathinfo"; + /** * 1.获取小程序的信息 @@ -196,4 +202,13 @@ WxFastMaSetNickameResult setNickname(String nickname, String idCard, String lice * @throws WxErrorException . */ WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorException; + + /** + * 获取订单页Path信息 + * + * @param infoType 0:线上版,1:审核版 + * @return 订单页Path信息 + * @throws WxErrorException . + */ + WxOpenMaGetOrderPathResult getOrderPathInfo(int infoType) throws WxErrorException; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaPrivacyService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaPrivacyService.java new file mode 100644 index 0000000000..e8f4665d8f --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaPrivacyService.java @@ -0,0 +1,89 @@ +package me.chanjar.weixin.open.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.open.bean.ma.privacy.*; + +/** + * 微信第三方平台 小程序用户隐私保护指引接口 / 申请隐私接口 + * (从2022年4月18日开始,部分小程序前端 api 需申请后,方可使用。该接口用于获取“需申请并审核通过”后才可使用的接口列表。) + * 配置小程序用户隐私保护指引获取接口列表 + * + * @author 广州跨界 + */ +public interface WxOpenMaPrivacyService { + + /** + * 1 设置小程序用户隐私保护指引 + */ + String OPEN_SET_PRIVACY_SETTING = "https://api.weixin.qq.com/cgi-bin/component/setprivacysetting"; + + /** + * 2 查询小程序用户隐私保护指引 + */ + String OPEN_GET_PRIVACY_SETTING = "https://api.weixin.qq.com/cgi-bin/component/getprivacysetting"; + + /** + * 3 上传小程序用户隐私保护指引文件 + */ + String OPEN_UPLOAD_PRIVACY_FILE = "https://api.weixin.qq.com/cgi-bin/component/uploadprivacyextfile"; + + /** + * 4 获取接口列表 从2022年4月18日开始,部分小程序前端 api 需申请后 + */ + String GET_PRIVATE_INTERFACE = "https://api.weixin.qq.com/wxa/security/get_privacy_interface"; + + /** + * 5 申请接口 从2022年4月18日开始,部分小程序前端 api 需申请后 + */ + String APPLY_PRIVATE_INTERFACE = "https://api.weixin.qq.com/wxa/security/apply_privacy_interface"; + + /** + * 查询小程序用户隐私保护指引 + * + * @param privacyVer 1表示现网版本,即,传1则该接口返回的内容是现网版本的;2表示开发版,即,传2则该接口返回的内容是开发版本的。默认是2。 + * @return 查询结果 + * @throws WxErrorException 如果出错,抛出此异常 + */ + GetPrivacySettingResult getPrivacySetting(Integer privacyVer) throws WxErrorException; + + /** + * 设置小程序用户隐私保护指引 + * + * @param dto 参数对象 + * @throws WxErrorException 如果出错,抛出此异常 + */ + void setPrivacySetting(SetPrivacySetting dto) throws WxErrorException; + + /** + * 上传小程序用户隐私保护指引文件 + * 本接口用于上传自定义的小程序的用户隐私保护指引 + * 仅限文本文件, 限制文件大小为不超过100kb,否则会报错 + * 上传小程序用户隐私保护指引文件 + * + * @param content 文本文件内容 + * @return 上传结果 + * @throws WxErrorException 如果出错,抛出此异常 + */ + UploadPrivacyFileResult uploadPrivacyFile(String content) throws WxErrorException; + + /** + * 隐私接口-获取接口列表 + * 从2022年4月18日开始,部分小程序前端 api 需申请后,方可使用。该接口用于获取“需申请并审核通过”后才可使用的接口列表。 + * 隐私接口-获取接口列表 + * + * @return 获取结果 + * @throws WxErrorException 如果出错,抛出此异常 + */ + GetPrivacyInterfaceResult getPrivacyInterface() throws WxErrorException; + + /** + * 隐私接口-申请接口 + * 从2022年4月18日开始,部分小程序前端 api 需申请后,方可使用。该接口用于获取“需申请并审核通过”后才可使用的接口列表。 + * 隐私接口-申请接口 + * + * @param dto 请求参数 + * @return 获取结果 + * @throws WxErrorException 如果出错,抛出此异常 + */ + ApplyPrivacyInterfaceResult applyPrivacyInterface(ApplyPrivacyInterface dto) throws WxErrorException; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java index cbb4b23783..7b34d27617 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java @@ -3,6 +3,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaAuditMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.open.bean.ma.WxMaPrefetchDomain; import me.chanjar.weixin.open.bean.ma.WxMaScheme; import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; import me.chanjar.weixin.open.bean.result.*; @@ -12,13 +13,10 @@ import java.util.Map; /** - *
- *     微信开放平台代小程序实现服务能力
- *     https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1489144594_DhNoV&token=&lang=zh_CN
- * 
+ * 微信开放平台代小程序实现服务能力 * * @author yqx - * @date 2018 /9/12 + * created on 2018 /9/12 */ public interface WxOpenMaService extends WxMaService { /** @@ -44,6 +42,11 @@ public interface WxOpenMaService extends WxMaService { */ String API_SET_WEBVIEW_DOMAIN = "https://api.weixin.qq.com/wxa/setwebviewdomain"; + /** + * 获取业务域名校验文件(仅供第三方代小程序调用) + */ + String API_GET_WEBVIEW_DOMAIN_CONFIRM_FILE = "https://api.weixin.qq.com/wxa/get_webviewdomain_confirmfile"; + /** * 获取帐号基本信息 *
@@ -73,7 +76,7 @@ public interface WxOpenMaService extends WxMaService {
   /**
    * 以下接口基础信息设置
    * 

- * https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21517799059ZSEMr&token=6f965b5daf30a98a6bbd2a386faea5c934e929bf&lang=zh_CN + * ... *

* 1. 设置小程序隐私设置(是否可被搜索) */ @@ -98,7 +101,7 @@ public interface WxOpenMaService extends WxMaService { /** * 以下接口为三方平台代小程序实现的代码管理功能 *

- * https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1489140610_Uavc4&token=fe774228c66725425675810097f9e48d0737a4bf&lang=zh_CN + * ... *

* 1. 为授权的小程序帐号上传小程序代码 */ @@ -140,10 +143,15 @@ public interface WxOpenMaService extends WxMaService { String API_RELEASE = "https://api.weixin.qq.com/wxa/release"; /** - * 10. 修改小程序线上代码的可见状态(仅供第三方代小程序调用) + * 10.1 修改小程序线上代码的可见状态(仅供第三方代小程序调用) */ String API_CHANGE_VISITSTATUS = "https://api.weixin.qq.com/wxa/change_visitstatus"; + /** + * 10.2 查询小程序线上代码的可见状态(仅供第三方代小程序调用) + */ + String API_GET_VISITSTATUS = "https://api.weixin.qq.com/wxa/getvisitstatus"; + /** * 11.小程序版本回退(仅供第三方代小程序调用) */ @@ -162,7 +170,7 @@ public interface WxOpenMaService extends WxMaService { /** * 14.设置小程序“扫普通链接二维码打开小程序”能力 *

- * https://mp.weixin.qq.com/debug/wxadoc/introduction/qrcode.html + * ... * 14.1 增加或修改二维码规则 */ String API_QRCODE_JUMP_ADD = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpadd"; @@ -238,6 +246,27 @@ public interface WxOpenMaService extends WxMaService { */ String API_AUDIT_UPLOAD_MEDIA = "https://api.weixin.qq.com/wxa/uploadmedia"; + + /** + * 小程序管理-查询小程序版本信息 + */ + String API_GET_VERSION_INFO = "https://api.weixin.qq.com/wxa/getversioninfo"; + + /** + * 设置DNS预解析域名 + */ + String API_WX_SET_PREFETCH_DOMAIN = "https://api.weixin.qq.com/wxa/set_prefetchdnsdomain"; + + /** + * 获取DNS预解析域名 + */ + String API_GET_PREFETCH_DOMAIN = "https://api.weixin.qq.com/wxa/get_prefetchdnsdomain"; + + /** + * 申请开通直播 + */ + String API_WX_APPLY_LIVE_INFO = "https://api.weixin.qq.com/wxa/business/applyliveinfo"; + /** * 获得小程序的域名配置信息 * @@ -296,6 +325,14 @@ WxOpenMaDomainResult modifyDomain(String action, List requestDomains, Li */ WxOpenMaWebDomainResult setWebViewDomainInfo(String action, List domainList) throws WxErrorException; + /** + * 获取业务域名校验文件 + * + * @return 业务域名校验文件信息 + * @throws WxErrorException 操作失败时抛出,具体错误码请看文档 + */ + WxOpenMaDomainConfirmFileResult getWebviewDomainConfirmFile() throws WxErrorException; + /** * 获取小程序的信息 * @@ -458,7 +495,7 @@ WxOpenMaDomainResult modifyDomain(String action, List requestDomains, Li WxOpenResult releaseAudited() throws WxErrorException; /** - * 10. 修改小程序线上代码的可见状态(仅供第三方代小程序调用) + * 10.1 修改小程序线上代码的可见状态(仅供第三方代小程序调用) * * @param action the action * @return the wx open result @@ -466,6 +503,14 @@ WxOpenMaDomainResult modifyDomain(String action, List requestDomains, Li */ WxOpenResult changeVisitStatus(String action) throws WxErrorException; + /** + * 10.2 查询小程序服务状态(仅供第三方代小程序调用) + * + * @return 小程序服务状态 + * @throws WxErrorException 查询失败时返回,具体错误码请看此接口的注释文档 + */ + WxOpenMaVisitStatusResult getVisitStatus() throws WxErrorException; + /** * 11. 小程序版本回退(仅供第三方代小程序调用) * @@ -632,10 +677,59 @@ WxOpenMaDomainResult modifyDomain(String action, List requestDomains, Li */ WxOpenMaBasicService getBasicService(); + /** + * 小程序用户隐私保护指引服务 + * + * @return 小程序用户隐私保护指引服务 + */ + WxOpenMaPrivacyService getPrivacyService(); + + /** + * 购物订单 + * @return 购物订单服务 + */ + WxOpenMaShoppingOrdersService getShoppingOrdersService(); + /** * 小程序审核 提审素材上传接口 * * @return */ WxMaAuditMediaUploadResult uploadMedia(File file) throws WxErrorException; + + /** + * 查询小程序版本信息 + * + * @return the wx open result + * @throws WxErrorException the wx error exception + */ + WxOpenVersioninfoResult getVersionInfo() throws WxErrorException; + + /** + * 设置DNS预解析域名 + * + * @param domain 预解析域名列表 + * @return {@link WxOpenResult} + * @throws WxErrorException the wx error exception + */ + WxOpenResult setPrefetchDomain(WxMaPrefetchDomain domain) throws WxErrorException; + + /** + * 获取DNS预解析域名 + * + * @return {@link WxOpenMaPrefetchDomainResult} + * @throws WxErrorException he wx error exception + */ + WxOpenMaPrefetchDomainResult getPrefetchDomain() throws WxErrorException; + + /** + * 申请开通直播 + * 文档地址: + * https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/live-player/applyLivelnfo.html + * + * @return {@link WxOpenMaApplyLiveInfoResult} + * @throws WxErrorException the wx error exception + */ + WxOpenMaApplyLiveInfoResult applyLiveInfo() throws WxErrorException; + } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaShoppingOrdersService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaShoppingOrdersService.java new file mode 100644 index 0000000000..1cd96a2b3d --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaShoppingOrdersService.java @@ -0,0 +1,111 @@ +package me.chanjar.weixin.open.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.open.bean.result.WxOpenResult; +import me.chanjar.weixin.open.bean.shoppingOrders.*; + +/** + * @author xzh + * created on 2023/5/17 16:49 + */ +public interface WxOpenMaShoppingOrdersService { + + + /** + * 上传购物详情 + */ + String UPLOAD_SHOPPING_INFO = "https://api.weixin.qq.com/user-order/orders"; + + /** + * 上传物流信息 + */ + String UPLOAD_SHIPPING_INFO = "https://api.weixin.qq.com/user-order/orders/shippings"; + + /** + * 上传合单购物详情 + */ + String UPLOAD_COMBINED_SHOPPING_INFO = "https://api.weixin.qq.com/user-order/combine-orders"; + + /** + * 上传合单物流信息 + */ + String UPLOAD_COMBINED_SHIPPING_INFO = "https://api.weixin.qq.com/user-order/combine-orders/shippings"; + + /** + * 开通购物订单产品权限 + */ + String OPEN_SHOPPING_ORDER_PRODUCT_PERMISSION = "https://api.weixin.qq.com/user-order/orders-permission/open"; + + /** + * 提交购物订单接入审核 + */ + String CONFIRM_PRODUCT_PERMISSION = "https://api.weixin.qq.com/user-order/orders-permission/confirm"; + + /** + * 验证购物订单上传结果 + */ + String SHOPPING_INFO_VERIFY_UPLOAD_RESULT = "https://api.weixin.qq.com/user-order/shoppinginfo/verify"; + + + /** + * 上传购物详情 + * + * @param info 购物详情 + * @return WxOpenResult + * @throws WxErrorException + */ + WxOpenResult upload(ShoppingInfo info) throws WxErrorException; + + /** + * 上传物流信息 + * + * @param info 物流信息 + * @return WxOpenResult + * @throws WxErrorException + */ + WxOpenResult upload(ShippingInfo info) throws WxErrorException; + + /** + * 上传合单购物详情 + * + * @param info 购物详情 + * @return WxOpenResult + * @throws WxErrorException + */ + WxOpenResult upload(CombinedShoppingInfo info) throws WxErrorException; + + /** + * 上传合单物流信息 + * + * @param info 物流信息 + * @return WxOpenResult + * @throws WxErrorException + */ + WxOpenResult upload(CombinedShippingInfo info) throws WxErrorException; + + /** + * 开通购物订单产品权限 + * + * @return WxOpenResult + * @throws WxErrorException + */ + WxOpenResult openShoppingOrderProductPermission() throws WxErrorException; + + /** + * 提交购物订单接入审核 + * + * @return WxOpenShoppingOrdersConfirmResult + * @throws WxErrorException + */ + WxOpenShoppingOrdersConfirmResult confirmProductPermission() throws WxErrorException; + + /** + * 验证购物订单上传结果 + * + * @param info 信息 + * @return WxOpenResult + * @throws WxErrorException + */ + WxOpenShoppingInfoVerifyUploadResult verifyUploadResult(ShoppingInfoVerifyUpload info) throws WxErrorException; + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMinishopGoodsService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMinishopGoodsService.java index ffd41bc030..b403c2f4a1 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMinishopGoodsService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMinishopGoodsService.java @@ -1,9 +1,9 @@ package me.chanjar.weixin.open.api; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.open.bean.minishopGoods.AddMinishopGoodsSPU; -import me.chanjar.weixin.open.bean.minishopGoods.GoodsCatList; -import me.chanjar.weixin.open.bean.minishopGoods.ParentCatId; +import me.chanjar.weixin.open.bean.minishopgoods.AddMinishopGoodsSPU; +import me.chanjar.weixin.open.bean.minishopgoods.GoodsCatList; +import me.chanjar.weixin.open.bean.minishopgoods.ParentCatId; import me.chanjar.weixin.open.bean.result.WxOpenResult; /** diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMpService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMpService.java index 098600a07d..285241bc39 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMpService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMpService.java @@ -3,6 +3,8 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.open.bean.mp.FastRegisterResult; +import me.chanjar.weixin.open.bean.result.WxAmpLinkResult; +import me.chanjar.weixin.open.bean.result.WxOpenResult; /** *

@@ -24,6 +26,19 @@ public interface WxOpenMpService extends WxMpService {
    */
   String API_FAST_REGISTER = "https://api.weixin.qq.com/cgi-bin/account/fastregister";
 
+  /**
+   * 小程序管理-获取公众号关联的小程序
+   */
+  String API_WX_AMP_LINK_GET = "https://api.weixin.qq.com/cgi-bin/wxopen/wxamplinkget";
+  /**
+   * 小程序管理-关联小程序
+   */
+  String API_WX_AMP_LINK_CREATE = "https://api.weixin.qq.com/cgi-bin/wxopen/wxamplink";
+  /**
+   * 小程序管理-解除已关联的小程序
+   */
+  String API_WX_AMP_LINK_UN = "https://api.weixin.qq.com/cgi-bin/wxopen/wxampunlink";
+
   /**
    * 取复用公众号快速注册小程序的授权链接
    * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Official_Accounts/fast_registration_of_mini_program.html
@@ -44,4 +59,53 @@ public interface WxOpenMpService extends WxMpService {
    * @throws WxErrorException the wx error exception
    */
   FastRegisterResult fastRegister(String ticket) throws WxErrorException;
+
+  /**
+   * 
+   * 获取公众号关联的小程序
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://api.weixin.qq.com/cgi-bin/wxopen/wxamplinkget?access_token=TOKEN
+   * 文档地址:
+   * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html
+   * 
+   * @return 公众号关联的小程序
+   */
+  WxAmpLinkResult getWxAmpLink() throws WxErrorException;
+
+  /**
+   * 
+   * 关联小程序
+   * 关联流程(需要公众号和小程序管理员双方确认):
+   * 1、第三方平台调用接口发起关联
+   * 2、公众号管理员收到模板消息,同意关联小程序。
+   * 3、小程序管理员收到模板消息,同意关联公众号。
+   * 4、关联成功
+   * 等待管理员同意的中间状态可使用“获取公众号关联的小程序”接口进行查询。
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://api.weixin.qq.com/cgi-bin/wxopen/wxamplink?access_token=TOKEN
+   * 文档地址:
+   * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html
+   * 
+   * @param appid 小程序 appid
+   * @param notifyUsers 是否发送模板消息通知公众号粉丝
+   * @param showProfile 是否展示公众号主页中
+   * @return 响应结果
+   */
+  WxOpenResult wxAmpLink(String appid, String notifyUsers, String showProfile) throws WxErrorException;
+
+  /**
+   * 
+   * 解除已关联的小程序
+   * 请求方式:POST(HTTPS)
+   * 请求地址:
+   * https://api.weixin.qq.com/cgi-bin/wxopen/wxampunlink?access_token=TOKEN
+   * 文档地址:
+   * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html
+   * 
+   * @param appid 小程序 appid
+   * @return 响应结果
+   */
+  WxOpenResult wxAmpUnLink(String appid) throws WxErrorException;
 }
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/AbstractWxOpenInRedisConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/AbstractWxOpenInRedisConfigStorage.java
index 52799da57c..4109780194 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/AbstractWxOpenInRedisConfigStorage.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/AbstractWxOpenInRedisConfigStorage.java
@@ -5,19 +5,19 @@
 
 /**
  * @author yangyidian
- * @date 2020/01/09
+ * created on  2020/01/09
  **/
 public abstract class AbstractWxOpenInRedisConfigStorage extends WxOpenInMemoryConfigStorage {
-  protected final static String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:";
-  protected final static String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:";
+  protected static final String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:";
+  protected static final String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:";
 
-  protected final static String AUTHORIZER_REFRESH_TOKEN_KEY = "wechat_authorizer_refresh_token:";
-  protected final static String AUTHORIZER_ACCESS_TOKEN_KEY = "wechat_authorizer_access_token:";
+  protected static final String AUTHORIZER_REFRESH_TOKEN_KEY = "wechat_authorizer_refresh_token:";
+  protected static final String AUTHORIZER_ACCESS_TOKEN_KEY = "wechat_authorizer_access_token:";
 
-  protected final static String LOCK_KEY = "wechat_lock:";
+  protected static final String LOCK_KEY = "wechat_lock:";
 
-  protected final static String JSAPI_TICKET_KEY = "wechat_jsapi_ticket:";
-  protected final static String CARD_API_TICKET_KEY = "wechat_card_api_ticket:";
+  protected static final String JSAPI_TICKET_KEY = "wechat_jsapi_ticket:";
+  protected static final String CARD_API_TICKET_KEY = "wechat_card_api_ticket:";
 
   /**
    * redis 存储的 key 的前缀,可为空
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
index ac71523a7e..84be751697 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
@@ -1,6 +1,7 @@
 package me.chanjar.weixin.open.api.impl;
 
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import com.google.gson.Gson;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.reflect.TypeToken;
@@ -20,6 +21,7 @@
 import me.chanjar.weixin.open.api.*;
 import me.chanjar.weixin.open.bean.*;
 import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
+import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo;
 import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
 import me.chanjar.weixin.open.bean.minishop.*;
 import me.chanjar.weixin.open.bean.minishop.coupon.WxMinishopCoupon;
@@ -28,9 +30,12 @@
 import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountGoods;
 import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountSku;
 import me.chanjar.weixin.open.bean.result.*;
+import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest;
+import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse;
+import me.chanjar.weixin.open.bean.tcbComponent.GetShareCloudBaseEnvResponse;
+import me.chanjar.weixin.open.bean.tcbComponent.GetTcbEnvListResponse;
 import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
 import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.Nullable;
 
 import java.io.File;
 import java.math.BigDecimal;
@@ -467,8 +472,8 @@ public WxOAuth2AccessToken oauth2refreshAccessToken(String appId, String refresh
 
   @Override
   public String oauth2buildAuthorizationUrl(String appId, String redirectURI, String scope, String state) {
-    return String.format(CONNECT_OAUTH2_AUTHORIZE_URL,
-      appId, URIUtil.encodeURIComponent(redirectURI), scope, StringUtils.trimToEmpty(state), getWxOpenConfigStorage().getComponentAppId());
+    return String.format(CONNECT_OAUTH2_AUTHORIZE_URL, appId, URIUtil.encodeURIComponent(redirectURI), scope,
+      StringUtils.trimToEmpty(state), getWxOpenConfigStorage().getComponentAppId());
   }
 
   @Override
@@ -498,7 +503,7 @@ public List getTemplateList() throws WxErrorException {
   }
 
   @Override
-  public List getTemplateList(@Nullable Integer templateType) throws WxErrorException {
+  public List getTemplateList(Integer templateType) throws WxErrorException {
     String url = GET_TEMPLATE_LIST_URL + (templateType == null ? "" : "?template_type=" + templateType);
     String responseContent = get(url, "access_token");
     JsonObject response = GsonParser.parse(StringUtils.defaultString(responseContent, "{}"));
@@ -602,6 +607,12 @@ public WxOpenGetResult getOpenAccount(String appId, String appIdType) throws WxE
     return WxOpenGetResult.fromJson(json);
   }
 
+  @Override
+  public WxOpenHaveResult haveOpen() throws WxErrorException {
+    String json = post(GET_OPEN_URL, null);
+    return WxOpenHaveResult.fromJson(json);
+  }
+
 
   @Override
   public WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException {
@@ -626,6 +637,34 @@ public WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWech
     return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
   }
 
+  @Override
+  public WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeapp(String idname, String wxuser, String componentPhone) throws WxErrorException {
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.addProperty("idname", idname);
+    jsonObject.addProperty("wxuser", wxuser);
+    jsonObject.addProperty("component_phone", componentPhone);
+    String response = post(FAST_REGISTER_PERSONAL_WEAPP_URL, jsonObject.toString(), "component_access_token");
+    return WxOpenGsonBuilder.create().fromJson(response, WxOpenRegisterPersonalWeappResult.class);
+  }
+
+  @Override
+  public WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeappSearch(String taskid) throws WxErrorException {
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.addProperty("taskid", taskid);
+    String response = post(FAST_REGISTER_PERSONAL_WEAPP_SEARCH_URL, jsonObject.toString(), "component_access_token");
+    return WxOpenGsonBuilder.create().fromJson(response, WxOpenRegisterPersonalWeappResult.class);
+  }
+
+  @Override
+  public WxOpenRegisterBetaWeappResult fastRegisterBetaWeapp(String name, String openid) throws WxErrorException {
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.addProperty("name", name);
+    jsonObject.addProperty("openid", openid);
+    String response = wxOpenService.getWxOpenComponentService()
+      .post(FAST_REGISTER_BETA_WEAPP_URL, jsonObject.toString(), "access_token");
+    return WxOpenGsonBuilder.create().fromJson(response, WxOpenRegisterBetaWeappResult.class);
+  }
+
   @Override
   public WxOpenResult registerShop(String wxName, String idCardName, String idCardNumber, String channelId, Integer apiOpenstoreType, String authPageUrl) throws WxErrorException {
     JsonObject jsonObject = new JsonObject();
@@ -718,7 +757,7 @@ public MinishopCategories getMinishopCategories(String appId, Integer fCatId) th
     log.info("response: " + response);
     JsonObject respJson = GsonParser.parse(response);
     MinishopCategories categories = new MinishopCategories();
-    categories.setErrcode(respJson.get("errcode").getAsInt());
+    categories.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
     if (categories.getErrcode() == 0) {
       JsonArray catListJson = respJson.getAsJsonArray("cat_list");
       if (catListJson != null || catListJson.size() > 0) {
@@ -748,7 +787,7 @@ public MinishopBrandList getMinishopBrands(String appId) throws WxErrorException
     String response = getWxOpenService().post(url, jsonObject.toString());
     JsonObject respJson = GsonParser.parse(response);
     MinishopBrandList brandList = new MinishopBrandList();
-    brandList.setErrcode(respJson.get("errcode").getAsInt());
+    brandList.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
     if (brandList.getErrcode() == 0) {
       JsonArray brandArrayJson = respJson.get("brands").getAsJsonArray();
       if (brandArrayJson.size() > 0) {
@@ -785,7 +824,7 @@ public MinishopDeliveryTemplateResult getMinishopDeliveryTemplate(String appId)
     String response = getWxOpenService().post(url, jsonObject.toString());
     JsonObject respJson = GsonParser.parse(response);
     MinishopDeliveryTemplateResult templateResult = new MinishopDeliveryTemplateResult();
-    templateResult.setErrCode(respJson.get("errcode").getAsInt());
+    templateResult.setErrCode(respJson.get(WxConsts.ERR_CODE).getAsInt());
     if (templateResult.getErrCode() == 0) {
       JsonArray templateArrayJson = respJson.get("template_list").getAsJsonArray();
       if (templateArrayJson.size() > 0) {
@@ -818,7 +857,7 @@ public MinishopShopCatList getMinishopCatList(String appId) throws WxErrorExcept
     String response = getWxOpenService().post(url, jsonObject.toString());
     JsonObject respJson = GsonParser.parse(response);
     MinishopShopCatList shopCatList = new MinishopShopCatList();
-    shopCatList.setErrcode(respJson.get("errcode").getAsInt());
+    shopCatList.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
     if (shopCatList.getErrcode() == 0) {
       JsonArray shopcatArrayJson = respJson.get("shopcat_list").getAsJsonArray();
       if (shopcatArrayJson.size() > 0) {
@@ -852,7 +891,7 @@ public WxMinishopAddGoodsSpuResult> getMinishopD
 
     JsonObject respObj = GsonParser.parse(response);
     WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
-    result.setErrcode(respObj.get("errcode").getAsInt());
+    result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
     if (result.getErrcode() == 0) {
       JsonArray companyArray = respObj.get("company_list").getAsJsonArray();
       List companies = new ArrayList<>();
@@ -877,7 +916,7 @@ public Integer minishopCreateCoupon(String appId, WxMinishopCoupon couponInfo) t
     String response = getWxOpenService().post(url, jsonObject.toString());
     JsonObject respJson = GsonParser.parse(response);
     Integer couponId = -1;
-    if (respJson.get("errcode").getAsInt() == 0) {
+    if (respJson.get(WxConsts.ERR_CODE).getAsInt() == 0) {
       JsonObject dataJson = respJson.get("data").getAsJsonObject();
       couponId = dataJson.get("coupon_id").getAsInt();
     }
@@ -911,7 +950,7 @@ public Integer minishopUpdateCoupon(String appId, WxMinishopCoupon couponInfo) t
     String response = getWxOpenService().post(url, jsonObject.toString());
     JsonObject respJson = GsonParser.parse(response);
     Integer couponId = -1;
-    if (respJson.get("errcode").getAsInt() == 0) {
+    if (respJson.get(WxConsts.ERR_CODE).getAsInt() == 0) {
       JsonObject dataJson = respJson.get("data").getAsJsonObject();
       couponId = dataJson.get("coupon_id").getAsInt();
     }
@@ -940,7 +979,7 @@ public WxMinishopAddGoodsSpuResult minishopGoodsAddSp
 
     JsonObject respObj = GsonParser.parse(response);
     WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
-    result.setErrcode(respObj.get("errcode").getAsInt());
+    result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
 
     if (result.getErrcode() == 0) {
       JsonObject dataObj = respObj.get("data").getAsJsonObject();
@@ -978,7 +1017,7 @@ public WxMinishopAddGoodsSpuResult minishopGoodsUpdat
 
     JsonObject respObj = GsonParser.parse(response);
     WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
-    result.setErrcode(respObj.get("errcode").getAsInt());
+    result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
     if (result.getErrcode() == 0) {
       JsonObject dataObj = respObj.get("data").getAsJsonObject();
       WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
@@ -1028,7 +1067,7 @@ public WxMinishopAddGoodsSpuResult minishiopGoodsAddS
 
     JsonObject respObj = GsonParser.parse(response);
     WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
-    result.setErrcode(respObj.get("errcode").getAsInt());
+    result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
     if (result.getErrcode() == 0) {
       JsonObject dataObj = respObj.get("data").getAsJsonObject();
       WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
@@ -1133,7 +1172,7 @@ public Integer addLimitDiscountGoods(String appId, LimitDiscountGoods limitDisco
     String response = getWxOpenService().post(url, jsonObject.toString());
     JsonObject respObj = GsonParser.parse(response);
     Integer taskId = 0;
-    if (respObj.get("errcode").getAsInt() == 0) {
+    if (respObj.get(WxConsts.ERR_CODE).getAsInt() == 0) {
       taskId = respObj.get("task_id").getAsInt();
     }
     return taskId;
@@ -1149,7 +1188,7 @@ public List getLimitDiscountList(String appId, Integer statu
     String response = getWxOpenService().post(url, jsonObject.toString());
     JsonObject respObj = GsonParser.parse(response);
     List limitDiscountGoodsList = new ArrayList<>();
-    if (respObj.get("errcode").getAsInt() == 0) {
+    if (respObj.get(WxConsts.ERR_CODE).getAsInt() == 0) {
       //成功获取到秒杀活动列表
 
       JsonArray jsonArray = respObj.get("limited_discount_list").getAsJsonArray();
@@ -1194,4 +1233,62 @@ public WxOpenResult updateLimitDiscountStatus(String appId, Long taskId, Integer
 
     return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
   }
+
+  @Override
+  public GetShareCloudBaseEnvResponse getShareCloudBaseEnv(List appids) throws WxErrorException {
+    JsonObject jsonObject = new JsonObject();
+    JsonArray jsonArray = new JsonArray();
+    for (String appId : appids) {
+      jsonArray.add(appId);
+    }
+    jsonObject.add("appids", jsonArray);
+    String response = post(BATCH_GET_ENVID_URL, jsonObject.toString());
+    return WxOpenGsonBuilder.create().fromJson(response, GetShareCloudBaseEnvResponse.class);
+  }
+
+  @Override
+  public GetTcbEnvListResponse getTcbEnvList() throws WxErrorException {
+    String response = post(DESCRIBE_ENVS_URL, new JsonObject().toString());
+    return WxOpenGsonBuilder.create().fromJson(response, GetTcbEnvListResponse.class);
+  }
+
+  @Override
+  public WxOpenResult changeTcbEnv(String env) throws WxErrorException {
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.addProperty("env", env);
+    String response = post(MODIFY_ENV_URL, jsonObject.toString());
+    return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
+  }
+
+  @Override
+  public ShareCloudBaseEnvResponse shareCloudBaseEnv(ShareCloudBaseEnvRequest request) throws WxErrorException {
+    Gson gson = new Gson();
+    String response = post(BATCH_SHARE_ENV, gson.toJson(request));
+    return WxOpenGsonBuilder.create().fromJson(response, ShareCloudBaseEnvResponse.class);
+  }
+
+  @Override
+  public WxOpenResult clearQuotaV2(String appid) throws WxErrorException {
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.addProperty("appid", appid);
+    jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
+    jsonObject.addProperty("appsecret", getWxOpenConfigStorage().getComponentAppSecret());
+    String response = getWxOpenService().post(COMPONENT_CLEAR_QUOTA_URL, jsonObject.toString());
+    return WxOpenResult.fromJson(response);
+  }
+
+  /**
+   * 申请设置订单页path信息
+   * 注意:一次提交不超过100个appid
+   *
+   * @param info 订单页path信息
+   * @return .
+   * @throws WxErrorException .
+   */
+  @Override
+  public WxOpenResult applySetOrderPathInfo(WxOpenMaApplyOrderPathInfo info) throws WxErrorException {
+    Gson gson = new Gson();
+    String response = post(OPEN_APPLY_SET_ORDER_PATH_INFO, gson.toJson(info));
+    return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
+  }
 }
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImpl.java
index f5f2160d21..911488ffae 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImpl.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImpl.java
@@ -8,6 +8,7 @@
 import me.chanjar.weixin.open.api.WxOpenComponentService;
 import me.chanjar.weixin.open.api.WxOpenFastMaService;
 import me.chanjar.weixin.open.bean.ma.WxFastMaCategory;
+import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo;
 import me.chanjar.weixin.open.bean.result.*;
 import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
 
@@ -141,6 +142,18 @@ public WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorExce
     return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
   }
 
+  /**
+   * 获取订单页Path信息
+   *
+   * @param infoType 0:线上版,1:审核版
+   * @return 订单页Path信息
+   * @throws WxErrorException .
+   */
+  @Override
+  public WxOpenMaGetOrderPathResult getOrderPathInfo(int infoType) throws WxErrorException {
+    throw new UnsupportedOperationException();
+  }
+
   private JsonArray toJsonArray(List strList) {
     JsonArray jsonArray = new JsonArray();
     if (strList != null && !strList.isEmpty()) {
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java
index 4a01dd4ec2..43a351100e 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java
@@ -2,7 +2,10 @@
 
 
 import cn.binarywang.wx.miniapp.config.WxMaConfig;
+import lombok.AccessLevel;
 import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
 import me.chanjar.weixin.common.bean.WxAccessToken;
 import me.chanjar.weixin.common.enums.TicketType;
 import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
@@ -257,6 +260,13 @@ private static class WxOpenInnerConfigStorage implements WxMpConfigStorage, WxMa
     private final String appId;
     private WxMpHostConfig hostConfig;
     private String apiHostUrl;
+    private String accessTokenUrl;
+    /**
+     * 是否使用稳定版获取accessToken接口
+     */
+    @Getter(value = AccessLevel.NONE)
+    @Setter(value = AccessLevel.NONE)
+    private boolean useStableAccessToken;
 
     /**
      * 小程序原始ID
@@ -283,6 +293,16 @@ public String getAccessToken() {
       return wxOpenConfigStorage.getAuthorizerAccessToken(appId);
     }
 
+    @Override
+    public boolean isStableAccessToken() {
+      return this.useStableAccessToken;
+    }
+
+    @Override
+    public void useStableAccessToken(boolean useStableAccessToken) {
+      this.useStableAccessToken = useStableAccessToken;
+    }
+
     @Override
     public Lock getAccessTokenLock() {
       return this.accessTokenLock;
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisTemplateConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisTemplateConfigStorage.java
index da04b176b2..267a65c367 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisTemplateConfigStorage.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisTemplateConfigStorage.java
@@ -10,8 +10,6 @@
 import me.chanjar.weixin.common.redis.JedisWxRedisOps;
 import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
 import me.chanjar.weixin.common.redis.WxRedisOps;
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.util.Pool;
 
 /**
  * 
@@ -19,7 +17,7 @@
  * 
* * @author taneg - * @date 2021/05/13 11:12:35 + * created on 2021/05/13 11:12:35 */ public class WxOpenInRedisTemplateConfigStorage extends AbstractWxOpenInRedisConfigStorage { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedissonConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedissonConfigStorage.java index 070d9ebf88..7a3a9d79af 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedissonConfigStorage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedissonConfigStorage.java @@ -10,7 +10,7 @@ /** * @author yangyidian - * @date 2020/01/06 + * created on 2020/01/06 **/ public class WxOpenInRedissonConfigStorage extends AbstractWxOpenInRedisConfigStorage { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaBasicServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaBasicServiceImpl.java index 4e4db75257..943d610113 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaBasicServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaBasicServiceImpl.java @@ -6,6 +6,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.open.api.WxOpenMaBasicService; import me.chanjar.weixin.open.bean.ma.WxFastMaCategory; +import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo; import me.chanjar.weixin.open.bean.result.*; import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; @@ -123,6 +124,21 @@ public WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorExce return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); } + /** + * 获取订单页Path信息 + * + * @param infoType 0:线上版,1:审核版 + * @return 订单页Path信息 + * @throws WxErrorException . + */ + @Override + public WxOpenMaGetOrderPathResult getOrderPathInfo(int infoType) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("info_type", infoType); + String response = wxMaService.post(OPEN_GET_ORDER_PATH_INFO, params); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenMaGetOrderPathResult.class); + } + private JsonArray toJsonArray(List strList) { JsonArray jsonArray = new JsonArray(); if (strList != null && !strList.isEmpty()) { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaPrivacyServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaPrivacyServiceImpl.java new file mode 100644 index 0000000000..50e2f7efb1 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaPrivacyServiceImpl.java @@ -0,0 +1,64 @@ +package me.chanjar.weixin.open.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.open.api.WxOpenMaPrivacyService; +import me.chanjar.weixin.open.bean.ma.privacy.*; +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; + +import java.util.HashMap; +import java.util.Map; + +/** + * 微信第三方平台 小程序用户隐私保护指引接口 + * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/set_privacy_setting.html + * + * @author 广州跨界 + */ +@AllArgsConstructor +public class WxOpenMaPrivacyServiceImpl implements WxOpenMaPrivacyService { + + private final WxMaService wxMaService; + + + @Override + public GetPrivacySettingResult getPrivacySetting(Integer privacyVer) throws WxErrorException { + Map params = new HashMap<>(1); + if (privacyVer != null) { + params.put("privacy_ver", privacyVer); + } + String json = wxMaService.post(OPEN_GET_PRIVACY_SETTING, params); + return WxOpenGsonBuilder.create().fromJson(json, GetPrivacySettingResult.class); + } + + @Override + public void setPrivacySetting(SetPrivacySetting dto) throws WxErrorException { + wxMaService.post(OPEN_SET_PRIVACY_SETTING, dto); + } + + @SneakyThrows + @Override + public UploadPrivacyFileResult uploadPrivacyFile(String content) throws WxErrorException { + // TODO 应实现通过InputStream上传的功能,一下代码暂时无法正常运行 +// ByteArrayInputStream data = new ByteArrayInputStream(content.getBytes("GBK")); +// GenericUploadRequestExecutor executor = new GenericUploadRequestExecutor(wxMaService.getRequestHttp(), "POST", "file", "/temp.txt"); +// String json = wxMaService.execute(executor, OPEN_UPLOAD_PRIVACY_FILE, data); +// return WxOpenGsonBuilder.create().fromJson(json, UploadPrivacyFileResult.class); + throw new WxErrorException(new WxError(5003, "暂未实现用户隐私指引内容上传")); + } + + @Override + public GetPrivacyInterfaceResult getPrivacyInterface() throws WxErrorException { + String json = wxMaService.get(GET_PRIVATE_INTERFACE, ""); + return WxOpenGsonBuilder.create().fromJson(json, GetPrivacyInterfaceResult.class); + } + + @Override + public ApplyPrivacyInterfaceResult applyPrivacyInterface(ApplyPrivacyInterface dto) throws WxErrorException { + String json = wxMaService.post(APPLY_PRIVATE_INTERFACE, dto); + return WxOpenGsonBuilder.create().fromJson(json, ApplyPrivacyInterfaceResult.class); + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java index 4fb637b393..886fbe127b 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java @@ -13,9 +13,8 @@ import com.google.gson.JsonObject; import lombok.Getter; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.open.api.WxOpenComponentService; -import me.chanjar.weixin.open.api.WxOpenMaBasicService; -import me.chanjar.weixin.open.api.WxOpenMaService; +import me.chanjar.weixin.open.api.*; +import me.chanjar.weixin.open.bean.ma.WxMaPrefetchDomain; import me.chanjar.weixin.open.bean.ma.WxMaQrcodeParam; import me.chanjar.weixin.open.bean.ma.WxMaScheme; import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; @@ -34,7 +33,7 @@ * * @author 007 * @author yqx - * @date 2018-09-12 + * created on 2018-09-12 */ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaService { private final WxOpenComponentService wxOpenComponentService; @@ -42,12 +41,18 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ private final String appId; @Getter private final WxOpenMaBasicService basicService; + @Getter + private final WxOpenMaPrivacyService privacyService; + @Getter + private final WxOpenMaShoppingOrdersService shoppingOrdersService; public WxOpenMaServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMaConfig wxMaConfig) { this.wxOpenComponentService = wxOpenComponentService; this.appId = appId; this.wxMaConfig = wxMaConfig; this.basicService = new WxOpenMaBasicServiceImpl(this); + this.privacyService = new WxOpenMaPrivacyServiceImpl(this); + this.shoppingOrdersService = new WxOpenMaShoppingOrdersServiceImpl(this); initHttp(); } @@ -115,6 +120,11 @@ public WxOpenMaWebDomainResult setWebViewDomainInfo(String action, List return WxMaGsonBuilder.create().fromJson(response, WxOpenMaWebDomainResult.class); } + @Override + public WxOpenMaDomainConfirmFileResult getWebviewDomainConfirmFile() throws WxErrorException { + String responseContent = post(API_GET_WEBVIEW_DOMAIN_CONFIRM_FILE, "{}"); + return WxOpenMaDomainConfirmFileResult.fromJson(responseContent); + } @Override public String getAccountBasicInfo() throws WxErrorException { @@ -250,6 +260,12 @@ public WxOpenResult changeVisitStatus(String action) throws WxErrorException { return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); } + @Override + public WxOpenMaVisitStatusResult getVisitStatus() throws WxErrorException { + String responseContent = post(API_GET_VISITSTATUS, "{}"); + return WxOpenMaVisitStatusResult.fromJson(responseContent); + } + @Override public WxOpenResult revertCodeRelease() throws WxErrorException { String response = get(API_REVERT_CODE_RELEASE, null); @@ -411,4 +427,31 @@ private JsonArray toJsonArray(List strList) { } return jsonArray; } + + @Override + public WxOpenVersioninfoResult getVersionInfo() throws WxErrorException { + JsonObject params = new JsonObject(); + String response = post(API_GET_VERSION_INFO, GSON.toJson(params)); + return WxMaGsonBuilder.create().fromJson(response, WxOpenVersioninfoResult.class); + } + + @Override + public WxOpenResult setPrefetchDomain(WxMaPrefetchDomain domain) throws WxErrorException { + String response = post(API_WX_SET_PREFETCH_DOMAIN, GSON.toJson(domain)); + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + @Override + public WxOpenMaPrefetchDomainResult getPrefetchDomain() throws WxErrorException { + String response = get(API_GET_PREFETCH_DOMAIN, null); + return WxMaGsonBuilder.create().fromJson(response, WxOpenMaPrefetchDomainResult.class); + } + + @Override + public WxOpenMaApplyLiveInfoResult applyLiveInfo() throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("action", "apply"); + String response = post(API_WX_APPLY_LIVE_INFO, GSON.toJson(params)); + return WxMaGsonBuilder.create().fromJson(response, WxOpenMaApplyLiveInfoResult.class); + } } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaShoppingOrdersServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaShoppingOrdersServiceImpl.java new file mode 100644 index 0000000000..040a8d6381 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaShoppingOrdersServiceImpl.java @@ -0,0 +1,107 @@ +package me.chanjar.weixin.open.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.open.api.WxOpenMaShoppingOrdersService; +import me.chanjar.weixin.open.bean.result.WxOpenResult; +import me.chanjar.weixin.open.bean.shoppingOrders.*; +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; + +@Slf4j +@AllArgsConstructor +public class WxOpenMaShoppingOrdersServiceImpl implements WxOpenMaShoppingOrdersService { + + private final WxMaService wxMaService; + + /** + * 上传购物详情 + * + * @param info 购物详情 + * @return WxOpenResult + * @throws WxErrorException + */ + @Override + public WxOpenResult upload(ShoppingInfo info) throws WxErrorException { + String response = wxMaService.post(UPLOAD_SHOPPING_INFO, WxOpenGsonBuilder.create().toJson(info)); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * 上传物流信息 + * + * @param info 物流信息 + * @return WxOpenResult + * @throws WxErrorException + */ + @Override + public WxOpenResult upload(ShippingInfo info) throws WxErrorException { + String response = wxMaService.post(UPLOAD_SHIPPING_INFO, WxOpenGsonBuilder.create().toJson(info)); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * 上传合单购物详情 + * + * @param info 购物详情 + * @return WxOpenResult + * @throws WxErrorException + */ + @Override + public WxOpenResult upload(CombinedShoppingInfo info) throws WxErrorException { + String response = wxMaService.post(UPLOAD_COMBINED_SHOPPING_INFO, WxOpenGsonBuilder.create().toJson(info)); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * 上传合单物流信息 + * + * @param info 物流信息 + * @return WxOpenResult + * @throws WxErrorException + */ + @Override + public WxOpenResult upload(CombinedShippingInfo info) throws WxErrorException { + String response = wxMaService.post(UPLOAD_COMBINED_SHIPPING_INFO, WxOpenGsonBuilder.create().toJson(info)); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * 开通购物订单产品权限 + * + * @return WxOpenResult + * @throws WxErrorException + */ + @Override + public WxOpenResult openShoppingOrderProductPermission() throws WxErrorException { + String response = wxMaService.post(OPEN_SHOPPING_ORDER_PRODUCT_PERMISSION, ""); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * 提交购物订单接入审核 + * + * @return WxOpenShoppingOrdersConfirmResult + * @throws WxErrorException + */ + @Override + public WxOpenShoppingOrdersConfirmResult confirmProductPermission() throws WxErrorException { + String response = wxMaService.post(CONFIRM_PRODUCT_PERMISSION, ""); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenShoppingOrdersConfirmResult.class); + } + + /** + * 验证购物订单上传结果 + * + * @param info 信息 + * @return WxOpenResult + * @throws WxErrorException + */ + @Override + public WxOpenShoppingInfoVerifyUploadResult verifyUploadResult(ShoppingInfoVerifyUpload info) throws WxErrorException { + String response = wxMaService.post(SHOPPING_INFO_VERIFY_UPLOAD_RESULT, WxOpenGsonBuilder.create().toJson(info)); + return WxOpenGsonBuilder.create().fromJson(response, WxOpenShoppingInfoVerifyUploadResult.class); + } + +} 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 2e483fc0aa..7314bfd694 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 @@ -17,7 +17,7 @@ public WxOpenMessageRouter(WxOpenService wxOpenService) { } public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, String appId) { - return route(wxMessage, new HashMap(), appId); + return route(wxMessage, new HashMap<>(), appId); } public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map context, String appId) { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMinishopGoodsServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMinishopGoodsServiceImpl.java index 1e792e04e9..0ac4e165cc 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMinishopGoodsServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMinishopGoodsServiceImpl.java @@ -1,14 +1,12 @@ package me.chanjar.weixin.open.api.impl; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; -import com.google.gson.Gson; -import com.google.gson.JsonObject; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.open.api.WxOpenMinishopGoodsService; -import me.chanjar.weixin.open.bean.minishopGoods.AddMinishopGoodsSPU; -import me.chanjar.weixin.open.bean.minishopGoods.GoodsCatList; -import me.chanjar.weixin.open.bean.minishopGoods.ParentCatId; +import me.chanjar.weixin.open.bean.minishopgoods.AddMinishopGoodsSPU; +import me.chanjar.weixin.open.bean.minishopgoods.GoodsCatList; +import me.chanjar.weixin.open.bean.minishopgoods.ParentCatId; import me.chanjar.weixin.open.bean.result.WxOpenResult; @Slf4j diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpOAuth2ServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpOAuth2ServiceImpl.java index 406e363481..3f990ecfeb 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpOAuth2ServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpOAuth2ServiceImpl.java @@ -28,7 +28,7 @@ public WxOpenMpOAuth2ServiceImpl(WxOpenComponentService wxOpenComponentService, /** * 第三方平台代公众号发起网页授权 - * 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/Official_Accounts/official_account_website_authorization.html + * 文档地址:第三方平台代公众号发起网页授权 * * @param code 微信授权code * @return 微信用户信息 diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java index 8e55311536..576db4a22c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java @@ -1,16 +1,24 @@ package me.chanjar.weixin.open.api.impl; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import com.google.common.collect.ImmutableMap; +import com.google.gson.JsonObject; import lombok.SneakyThrows; import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.config.WxMpConfigStorage; import me.chanjar.weixin.open.api.WxOpenComponentService; import me.chanjar.weixin.open.api.WxOpenMpService; import me.chanjar.weixin.open.bean.mp.FastRegisterResult; +import me.chanjar.weixin.open.bean.result.WxAmpLinkResult; +import me.chanjar.weixin.open.bean.result.WxOpenResult; import java.net.URLEncoder; +import java.util.Map; import java.util.Objects; +import java.util.function.Function; /** * @author 007 @@ -20,13 +28,23 @@ public class WxOpenMpServiceImpl extends WxMpServiceImpl implements WxOpenMpServ private WxMpConfigStorage wxMpConfigStorage; private String appId; + /** + * + * @param wxOpenComponentService + * @param appId + * @param wxMpConfigStorage + */ public WxOpenMpServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMpConfigStorage wxMpConfigStorage) { // wxOpenComponentService.oauth2getAccessToken(appId) this.wxOpenComponentService = wxOpenComponentService; this.appId = appId; this.wxMpConfigStorage = wxMpConfigStorage; setOAuth2Service(new WxOpenMpOAuth2ServiceImpl(wxOpenComponentService, getOAuth2Service(), wxMpConfigStorage)); + //添加addConfigStorage是为了解决处理来自微信开放平台的异步消息时调用WxMpServiceImpl.switchoverTo(String, Function),因为configStorageMap没有任何公众号配置信息,最终会主动抛出无法找到对应公众号配置异常的问题。 + //Issue:https://gitee.com/binary/weixin-java-tools/issues/I81AAF + addConfigStorage(appId,wxMpConfigStorage); initHttp(); + } @Override @@ -53,4 +71,30 @@ public FastRegisterResult fastRegister(String ticket) throws WxErrorException { String json = post(API_FAST_REGISTER, ImmutableMap.of("ticket", ticket)); return FastRegisterResult.fromJson(json); } + + + @Override + public WxAmpLinkResult getWxAmpLink() throws WxErrorException { + String response = post(API_WX_AMP_LINK_GET, "{}"); + return WxMaGsonBuilder.create().fromJson(response, WxAmpLinkResult.class); + } + + @Override + public WxOpenResult wxAmpLink(String appid, String notifyUsers, String showProfile) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("appid", appid); + params.addProperty("notify_users", notifyUsers); + params.addProperty("show_profile", showProfile); + String response = post(API_WX_AMP_LINK_CREATE, params.toString()); + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + @Override + public WxOpenResult wxAmpUnLink(String appid) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("appid", appid); + String response = post(API_WX_AMP_LINK_UN, params.toString()); + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java index ce7e3af845..6f599dc299 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java @@ -20,7 +20,7 @@ * oauth2接口实现. * * @author Binary Wang - * @date 2020-10-19 + * created on 2020-10-19 */ @AllArgsConstructor public class WxOpenOAuth2ServiceImpl extends WxOpenServiceImpl implements WxOAuth2Service { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java index fa89d09377..845441c2d6 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.open.api.impl; +import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; @@ -17,8 +18,8 @@ /** * @author 007 */ +@Slf4j public abstract class WxOpenServiceAbstractImpl implements WxOpenService, RequestHttp { - private final Logger log = LoggerFactory.getLogger(this.getClass()); private WxOpenComponentService wxOpenComponentService = new WxOpenComponentServiceImpl(this); private WxOpenConfigStorage wxOpenConfigStorage; @@ -46,17 +47,17 @@ public void setWxOpenConfigStorage(WxOpenConfigStorage wxOpenConfigStorage) { protected T execute(RequestExecutor executor, String uri, E data) throws WxErrorException { try { T result = executor.execute(uri, data, WxType.Open); - this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uri, data, result); + log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uri, data, result); return result; } catch (WxErrorException e) { WxError error = e.getError(); if (error.getErrorCode() != 0) { - this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uri, data, error); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uri, data, error); throw new WxErrorException(error, e); } return null; } catch (IOException e) { - this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uri, data, e.getMessage()); + log.warn("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uri, data, e.getMessage()); throw new WxRuntimeException(e); } } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenMaCodeTemplate.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenMaCodeTemplate.java index d441906c80..e2ea54c1f3 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenMaCodeTemplate.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenMaCodeTemplate.java @@ -46,4 +46,40 @@ public class WxOpenMaCodeTemplate implements Serializable { */ @SerializedName(value = "createTime", alternate = "create_time") private Long createTime; + + /** + * 开发小程序的appid + */ + @SerializedName(value = "sourceMiniProgramAppid", alternate = "source_miniprogram_appid") + private String sourceMiniProgramAppid; + + /** + * 开发小程序的名称 + */ + @SerializedName(value = "sourceMiniProgram", alternate = "source_miniprogram") + private String sourceMiniProgram; + + /** + * 标准模板的场景标签;普通模板不返回该值 + */ + @SerializedName(value = "auditScene", alternate = "audit_scene") + private Integer auditScene; + + /** + * 标准模板的审核状态;普通模板不返回该值 + */ + @SerializedName(value = "auditStatus", alternate = "audit_status") + private Integer auditStatus; + + /** + * 标准模板的审核驳回的原因,;普通模板不返回该值 + */ + @SerializedName(value = "reason") + private String reason; + + /** + * 开发者 + */ + @SerializedName(value = "developer") + private String developer; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java index a80dab0307..0888a30d41 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java @@ -23,6 +23,16 @@ public class WxOpenAuthorizerInfo implements Serializable { private Map businessInfo; private String alias; private String qrcodeUrl; + /** + * 帐号状态 + * 类型 说明 + * 1 正常 + * 14 已注销 + * 16 已封禁 + * 18 已告警 + * 19 已冻结 + */ + private Integer accountStatus; /** * 账号介绍 */ @@ -33,8 +43,30 @@ public class WxOpenAuthorizerInfo implements Serializable { */ private MiniProgramInfo miniProgramInfo; + /** + * 小程序注册方式 + * 类型 说明 + * 0 普通方式注册 + * 2 通过复用公众号创建小程序 api 注册 + * 6 通过法人扫脸创建企业小程序 api 注册 + * 13 通过创建试用小程序 api 注册 + * 15 通过联盟控制台注册 + * 16 通过创建个人小程序 api 注册 + * 17 通过创建个人交易小程序 api 注册 + * 19 通过试用小程序转正 api 注册 + * 22 通过复用商户号创建企业小程序 api 注册 + * 23 通过复用商户号转正 api 注册 + */ + private Integer registerType; + + /** + * 小程序基础配置信息 + */ + private BasicConfig basicConfig; + @Data - public class MiniProgramInfo { + public static class MiniProgramInfo implements Serializable { + private static final long serialVersionUID = 8857028017332191988L; @SerializedName("visit_status") private Integer visitStatus; /** @@ -44,13 +76,15 @@ public class MiniProgramInfo { private List categories; @Data - public class Category { + public static class Category implements Serializable { + private static final long serialVersionUID = -5771529867281696141L; private String first; private String second; } @Data - public class Network { + public static class Network implements Serializable { + private static final long serialVersionUID = -18932624803859857L; @SerializedName("RequestDomain") private List requestDomain; @SerializedName("WsRequestDomain") @@ -63,4 +97,13 @@ public class Network { private List bizDomain; } } + + @Data + public static class BasicConfig implements Serializable { + private static final long serialVersionUID = -8857028017332191989L; + @SerializedName("is_phone_configured") + private Boolean isPhoneConfigured; + @SerializedName("is_email_configured") + private Boolean isEmailConfigured; + } } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitExtInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitExtInfo.java index 16439fa153..93d2a095b8 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitExtInfo.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitExtInfo.java @@ -43,7 +43,7 @@ *

* * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxMaOpenCommitExtInfo implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitStandardExt.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitStandardExt.java index 2d4b713919..a4039fb811 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitStandardExt.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenCommitStandardExt.java @@ -8,8 +8,9 @@ /** * 微信第三方平台上传代码到小程序代码标准模板时的参数 - * ext_json补充说明 - * 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/commit.html + *
+ * ext_json 补充说明
+ * 文档
  * 为了便于第三方平台使用同一个小程序模板为不同的小程序提供服务,第三方可以将自定义信息放置在 ext_json 中,在模板小程序中,可以使用 wx.getExtConfigSync 接口获取自定义信息,从而区分不同的小程序。详见:小程序模板开发
  * ext_json 中的参数可选,参数详见小程序配置;但是,如果是模板id为标准模板库的模板id,则ext_json可支持的参数为:{"extAppid":'', "ext": {}, "window": {}}
  * ext_json 中有限支持 pages,支持配置模板页面的子集(ext_json 中不可新增页面)。
@@ -28,20 +29,19 @@
  * subPackages整体替换
  * navigateToMiniProgaramAppIdList:整体替换
  * plugins整体替换
- * 

+ *
* * @author 广州跨界 * @since 2021/08/12 */ @Data public class WxMaOpenCommitStandardExt implements Serializable { - private static final long serialVersionUID = 4595618023108631477L; /** * 授权小程序Appid,可填入商户小程序AppID,以区分不同商户 */ - @SerializedName("create_time") + @SerializedName("extAppid") private String extAppId; /** diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenNetworkTimeout.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenNetworkTimeout.java index 9717f42af8..c1475fb7bc 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenNetworkTimeout.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenNetworkTimeout.java @@ -6,7 +6,7 @@ /** * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxMaOpenNetworkTimeout implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenPage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenPage.java index ca63fc3d8f..b1da3086df 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenPage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenPage.java @@ -6,7 +6,7 @@ /** * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxMaOpenPage implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenSubpackage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenSubpackage.java index 3f71c42855..86603b1af9 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenSubpackage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenSubpackage.java @@ -5,7 +5,7 @@ /** * @author momorans - * @create 2019-03-12 + * @since 2019-03-12 **/ @Data @Builder diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTab.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTab.java index 48e1044db8..9c7ccf2233 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTab.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTab.java @@ -7,7 +7,7 @@ /** * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxMaOpenTab implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTabBar.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTabBar.java index 6245c0331d..06fb2997c9 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTabBar.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenTabBar.java @@ -13,7 +13,7 @@ * tabBar对象 * * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data @NoArgsConstructor diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenWindow.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenWindow.java index 4848f8c7b1..d96ff5cb43 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenWindow.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenWindow.java @@ -8,7 +8,7 @@ * window对象 * * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxMaOpenWindow implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaPrefetchDomain.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaPrefetchDomain.java new file mode 100644 index 0000000000..29e484cad3 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaPrefetchDomain.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.open.bean.ma; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author 清心 + * create on 2022-10-01 18:07 + */ +@Data +public class WxMaPrefetchDomain implements Serializable { + private static final long serialVersionUID = 1593947263587362155L; + + @SerializedName("prefetch_dns_domain") + private List prefetchDnsDomain; + + @Data + public static class DnsDomain { + private String url; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaQrcodeParam.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaQrcodeParam.java index 2dafa037d6..998933264c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaQrcodeParam.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaQrcodeParam.java @@ -11,7 +11,7 @@ * 微信小程序体验二维码参数 * * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxMaQrcodeParam { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaScheme.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaScheme.java index faa56bec34..a3d9e7af07 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaScheme.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaScheme.java @@ -1,9 +1,13 @@ package me.chanjar.weixin.open.bean.ma; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.open.bean.result.WxOpenResult; @Data +@EqualsAndHashCode(callSuper = true) public class WxMaScheme extends WxOpenResult { + private static final long serialVersionUID = 6099475183322341647L; + private String openlink; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaApplyOrderPathInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaApplyOrderPathInfo.java new file mode 100644 index 0000000000..a25bf038c8 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaApplyOrderPathInfo.java @@ -0,0 +1,74 @@ +package me.chanjar.weixin.open.bean.ma; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xzh + * @Description 申请设置订单页path信息 接口的相关信息 + * @createTime 2023/05/23 15:19 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxOpenMaApplyOrderPathInfo implements Serializable { + + private static final long serialVersionUID = -1812688861780119219L; + /** + * 批量申请的信息 + */ + @SerializedName("batch_req") + private BatchReqBean batchReq; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class BatchReqBean implements Serializable { + + private static final long serialVersionUID = 1816976472441827961L; + /** + * 申请提交的订单页path + */ + @SerializedName("path") + private String path; + /** + * 申请提交的图片url,审核版会显示 + */ + @SerializedName("img_list") + private List imgList; + /** + * 申请提交的视频url,审核版会显示 + */ + @SerializedName("video") + private String video; + /** + * 申请提交的测试账号,审核版会显示 + */ + @SerializedName("test_account") + private String testAccount; + /** + * 申请提交的测试密码,审核版会显示 + */ + @SerializedName("test_pwd") + private String testPwd; + /** + * 申请提交的测试备注,审核版会显示 + */ + @SerializedName("test_remark") + private String testRemark; + /** + * 申请提交的批量的appid + * NOTE: 一次提交不超过100个appid + */ + @SerializedName("appid_list") + private List appIdList; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaCategory.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaCategory.java index f5f68df143..bcfb073308 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaCategory.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaCategory.java @@ -10,7 +10,7 @@ * 微信小程序分类目录. * * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxOpenMaCategory implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaMember.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaMember.java index dc939373ab..a9af022e19 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaMember.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaMember.java @@ -8,7 +8,7 @@ * 微信开放平台小程序成员对象 * * @author yqx - * @date 2018/9/12 + * created on 2018/9/12 */ @Data public class WxOpenMaMember implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaPreviewInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaPreviewInfo.java deleted file mode 100644 index 47f8b37a3e..0000000000 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaPreviewInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.chanjar.weixin.open.bean.ma; - -import com.google.gson.annotations.SerializedName; -import lombok.Data; - -/** - * @author zxfreedom - * @description - * @date 2019/12/30 - */ -@Data -public class WxOpenMaPreviewInfo { - - /** - * 录屏mediaid列表,可以通过提审素材上传接口获得 - */ - @SerializedName("video_id_list") - private String[] videoIdList; - - /** - * 截屏mediaid列表,可以通过提审素材上传接口获得 - */ - @SerializedName("pic_id_list") - private String[] picIdList; -} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaSubmitAudit.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaSubmitAudit.java deleted file mode 100644 index 9c9e712241..0000000000 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaSubmitAudit.java +++ /dev/null @@ -1,60 +0,0 @@ -package me.chanjar.weixin.open.bean.ma; - -import com.google.gson.annotations.SerializedName; -import lombok.Data; - -import java.io.Serializable; - -/** - * 三方平台提交小程序代码审核 - * - * @author yqx - * @date 2018/9/13 - */ -@Data -public class WxOpenMaSubmitAudit implements Serializable { - - - /** - * 小程序的页面,可通过“获取小程序的第三方提交代码的页面配置”接口获得 - */ - @SerializedName("address") - private String pagePath; - - /** - * 小程序的标签,多个标签用空格分隔,标签不能多于10个,标签长度不超过20 - */ - @SerializedName("tag") - private String tag; - - /** - * 类目名称,可通过“获取授权小程序帐号的可选类目”接口获得 - */ - @SerializedName("first_class") - private String firstClass; - - @SerializedName("second_class") - private String secondClass; - - @SerializedName("third_class") - private String thirdClass; - - /** - * 类目的ID,可通过“获取授权小程序帐号的可选类目”接口获得 - */ - @SerializedName("first_id") - private Integer firstId; - - @SerializedName("second_id") - private Integer secondId; - - @SerializedName("third_id") - private Integer thirdId; - - /** - * 小程序页面的标题,标题长度不超过32 - */ - @SerializedName("title") - private String title; - -} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/ApplyPrivacyInterface.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/ApplyPrivacyInterface.java new file mode 100644 index 0000000000..b92a680273 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/ApplyPrivacyInterface.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * 申请隐私接口 + * + * @author 广州跨界 + */ +@Getter +@Setter +public class ApplyPrivacyInterface { + + /** + * 接口英文名称,如:wx.chooseAddress/wx.choosePoi/wx.getLocation/wx.onLocationChange/wx.chooseLocation + */ + @SerializedName("api_name") + private String apiName; + + /** + * 申请说原因,不超过300个字符;需要以utf-8编码提交,否则会出现审核失败 + */ + @SerializedName("content") + private String content; + + /** + * (辅助网页)例如,上传官网网页链接用于辅助审核 + */ + @SerializedName("url_list") + private List urlList; + + /** + * (辅助图片)填写图片的url ,最多10个 + */ + @SerializedName("pic_list") + private List picList; + + /** + * (辅助视频)填写视频的链接 ,最多支持1个;视频格式只支持mp4格式 + */ + @SerializedName("video_list") + private List videoList; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/ApplyPrivacyInterfaceResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/ApplyPrivacyInterfaceResult.java new file mode 100644 index 0000000000..c394ad6877 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/ApplyPrivacyInterfaceResult.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +/** + * 获取接口列表 响应 + * + * @author 广州跨界 + */ +@Getter +@Setter +public class ApplyPrivacyInterfaceResult extends WxOpenResult { + + /** + * 审核ID + */ + @SerializedName("audit_id") + private Long auditId; + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/GetPrivacyInterfaceResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/GetPrivacyInterfaceResult.java new file mode 100644 index 0000000000..d016536c20 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/GetPrivacyInterfaceResult.java @@ -0,0 +1,92 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.open.bean.result.WxOpenResult; +import org.springframework.lang.Nullable; + +import java.util.List; + +/** + * 获取接口列表 响应 + * + * @author 广州跨界 + */ +@Getter +@Setter +public class GetPrivacyInterfaceResult extends WxOpenResult { + + /** + * 隐私接口列表 + */ + @SerializedName("interface_list") + private List interfaceList; + + + /** + * 隐私接口 + */ + @Getter + @Setter + public static class Interface { + + /** + * 接口英文名称,如:wx.chooseAddress/wx.choosePoi/wx.getLocation/wx.onLocationChange/wx.chooseLocation + */ + @SerializedName("api_name") + private String apiName; + + /** + * 接口中文名称,如:获取用户收货地址/选择位置,支持模糊定位(精确到市)和精确定位混选/获取当前的地理位置、速度/监听实时地理位置变化事件/打开地图选择位置 + */ + @SerializedName("api_ch_name") + private String apiChName; + + /** + * api描述 + */ + @SerializedName("api_desc") + private String apiDesc; + + /** + * 申请时间 ,该字段发起申请后才会有 + */ + @Nullable + @SerializedName("apply_time") + private String applyTime; + + /** + * 接口状态,该字段发起申请后才会有,1待申请开通,2无权限,3申请中,4申请失败,5已开通 + */ + @Nullable + @SerializedName("status") + private String status; + + /** + * 申请单号,该字段发起申请后才会有 + */ + @Nullable + @SerializedName("audit_id") + private String auditId; + + /** + * 申请被驳回原因或者无权限,该字段申请驳回时才会有 + */ + @Nullable + @SerializedName("fail_reason") + private String failReason; + + /** + * api文档链接 + */ + @SerializedName("api_link") + private String apiLink; + + /** + * 分组名,如:地理位置 + */ + @SerializedName("group_name") + private String groupName; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/GetPrivacySettingResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/GetPrivacySettingResult.java new file mode 100644 index 0000000000..a3b0a6ef1b --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/GetPrivacySettingResult.java @@ -0,0 +1,118 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +import java.util.List; + +/** + * 查询小程序用户隐私保护指引 响应 + * + * @author 广州跨界 + */ +@Getter +@Setter +public class GetPrivacySettingResult extends WxOpenResult { + + /** + * 代码是否存在, 0 不存在, 1 存在 。如果最近没有通过commit接口上传代码,则会出现 code_exist=0的情况。 + */ + @SerializedName("code_exist") + private Integer codeExist; + + /** + * 代码检测出来的用户信息类型(privacy_key) + */ + @SerializedName("privacy_list") + private List privacyList; + + /** + * 要收集的用户信息配置 + */ + @SerializedName("setting_list") + private List settingList; + + /** + * 更新时间 + */ + @SerializedName("update_time") + private Long updateTime; + + /** + * 收集方(开发者)信息配置 + */ + @SerializedName("owner_setting") + private PrivacyOwnerSetting ownerSetting; + + /** + * 收集方(开发者)信息配置 + */ + @SerializedName("privacy_desc") + private PrivacyDesc privacyDesc; + + + @Data + public static class Setting { + + /** + * 官方的可选值参考下方说明;该字段也支持自定义 + * + * @see PrivacyKeyEnum + * @see PrivacyKeyEnum#getKey() + */ + @SerializedName("privacy_key") + private String privacyKey; + + /** + * 请填写收集该信息的用途。例如privacy_key=Location(位置信息),那么privacy_text则填写收集位置信息的用途。 + * 无需再带上“为了”或者“用于”这些字眼,小程序端的显示格式是为了xxx,因此开发者只需要直接填写用途即可。 + */ + @SerializedName("privacy_text") + private String privacyText; + + /** + * 用户信息类型的中文名称 + * + * @see PrivacyKeyEnum#getDesc() () + */ + @SerializedName("privacy_label") + private String privacyLabel; + } + + + @Data + public static class PrivacyDesc { + + /** + * 用户信息类型 + */ + @SerializedName("privacy_desc_list") + private List privacyDescList; + } + + @Data + public static class PrivacyDescItem { + + /** + * 用户信息类型的英文key + * + * @see PrivacyKeyEnum + * @see PrivacyKeyEnum#getKey() + */ + @SerializedName("privacy_key") + private String privacyKey; + + /** + * 用户信息类型的中文描述 + * + * @see PrivacyKeyEnum#getDesc() + */ + @SerializedName("privacy_desc") + private String privacyDesc; + } + + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/PrivacyKeyEnum.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/PrivacyKeyEnum.java new file mode 100644 index 0000000000..c3d6af281a --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/PrivacyKeyEnum.java @@ -0,0 +1,62 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 隐私key枚举 + * + * @author 广州跨界 + */ +@Getter +@AllArgsConstructor +public enum PrivacyKeyEnum { + + USER_INFO("UserInfo", "用户信息(微信昵称、头像)"), + + LOCATION("Location", "位置信息"), + + ADDRESS("Address", "地址"), + + INVOICE("Invoice", "发票信息"), + + RUN_DATA("RunData", "微信运动数据"), + + RECORD("Record", "麦克风"), + + ALBUM("Album", "选中的照片或视频信息"), + + CAMERA("Camera", "摄像头"), + + PHONE_NUMBER("PhoneNumber", "手机号码"), + + CONTACT("Contact", "通讯录(仅写入)权限"), + + DEVICE_INFO("DeviceInfo", "设备信息"), + + EXID_NUMBER("EXIDNumber", "身份证号码"), + + EX_ORDER_INFO("EXOrderInfo", "订单信息"), + + EX_USER_PUBLISH_CONTENT("EXUserPublishContent", "发布内容"), + + EX_USER_FOLLOW_ACCT("EXUserFollowAcct", "所关注账号"), + + EX_USER_OP_LOG("EXUserOpLog", "操作日志"), + + ALBUM_WRITE_ONLY("AlbumWriteOnly", "相册(仅写入)权限"), + + LICENSE_PLATE("LicensePlate", "车牌号"), + + BLUE_TOOTH("BlueTooth", "蓝牙"), + + CALENDAR_WRITE_ONLY("CalendarWriteOnly", "日历(仅写入)权限"), + + EMAIL("Email", "邮箱"), + + MESSAGE_FILE("MessageFile", "选中的文件"), + ; + + private final String key; + private final String desc; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/PrivacyOwnerSetting.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/PrivacyOwnerSetting.java new file mode 100644 index 0000000000..a7ca6f105c --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/PrivacyOwnerSetting.java @@ -0,0 +1,63 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 小程序用户隐私保护指引 收集方(开发者)信息配置 + * + * @author 广州跨界 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PrivacyOwnerSetting { + + /** + * 信息收集方(开发者)的邮箱地址,4种联系方式至少要填一种 + */ + @SerializedName("contact_email") + private String contactEmail; + + /** + * 信息收集方(开发者)的手机号,4种联系方式至少要填一种 + */ + @SerializedName("contact_phone") + private String contactPhone; + + /** + * 信息收集方(开发者)的qq号,4种联系方式至少要填一种 + */ + @SerializedName("contact_qq") + private String contactQq; + + /** + * 信息收集方(开发者)的微信号,4种联系方式至少要填一种 + */ + @SerializedName("contact_weixin") + private String contactWeixin; + + /** + * 如果开发者不使用微信提供的标准化用户隐私保护指引模板,也可以上传自定义的用户隐私保护指引,通过上传接口上传后可获取media_id + */ + @SerializedName("ext_file_media_id") + private String extFileMediaId; + + /** + * 通知方式,指的是当开发者收集信息有变动时,通过该方式通知用户。这里服务商需要按照实际情况填写,例如通过弹窗或者公告或者其他方式。 + */ + @SerializedName("notice_method") + private String noticeMethod; + + /** + * 存储期限,指的是开发者收集用户信息存储多久。如果不填则展示为【开发者承诺,除法律法规另有规定,开发者对你的信息保存期限应当为实现处理目的所必要的最短时间】, + * 如果填请填数字+天,例如“30天”,否则会出现87072的报错。 + */ + @SerializedName("store_expire_timestamp") + private String storeExpireTimestamp; + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/SetPrivacySetting.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/SetPrivacySetting.java new file mode 100644 index 0000000000..5ce3de039e --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/SetPrivacySetting.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 设置小程序用户隐私保护指引参数 + * + * @author 广州跨界 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SetPrivacySetting implements Serializable { + private static final long serialVersionUID = -4309547831976480043L; + + /** + * 用户隐私保护指引的版本,1表示现网版本;2表示开发版。默认是2开发版。 + */ + @SerializedName("privacy_ver") + private Integer privacyVer; + + /** + * 收集方(开发者)信息配置 + */ + @SerializedName("owner_setting") + private PrivacyOwnerSetting ownerSetting; + + /** + * 要收集的用户信息配置 + */ + @SerializedName("setting_list") + private List settingList; + + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Setting implements Serializable { + private static final long serialVersionUID = 1141496605788764479L; + + /** + * 官方的可选值参考下方说明;该字段也支持自定义 + * + * @see PrivacyKeyEnum + * @see PrivacyKeyEnum#getKey() + */ + @SerializedName("privacy_key") + private String privacyKey; + + /** + * 请填写收集该信息的用途。例如privacy_key=Location(位置信息),那么privacy_text则填写收集位置信息的用途。 + * 无需再带上“为了”或者“用于”这些字眼,小程序端的显示格式是为了xxx,因此开发者只需要直接填写用途即可。 + */ + @SerializedName("privacy_text") + private String privacyText; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/UploadPrivacyFileResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/UploadPrivacyFileResult.java new file mode 100644 index 0000000000..d2fcfecc50 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/privacy/UploadPrivacyFileResult.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.open.bean.ma.privacy; + +import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +/** + * 上传小程序用户隐私保护指引文件 响应 + * + * @author 广州跨界 + */ +@Getter +@Setter +public class UploadPrivacyFileResult extends WxOpenResult { + + /** + * 文件的media_id + */ + @SerializedName("ext_file_media_id") + private String extFileMediaId; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenMaSubmitAuditMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenMaSubmitAuditMessage.java index d74f3d8d5a..d8c1461d67 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenMaSubmitAuditMessage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenMaSubmitAuditMessage.java @@ -1,9 +1,9 @@ package me.chanjar.weixin.open.bean.message; +import cn.binarywang.wx.miniapp.bean.code.WxMaCodeSubmitAuditItem; +import cn.binarywang.wx.miniapp.bean.code.WxMaCodeSubmitAuditPreviewInfo; import com.google.gson.annotations.SerializedName; import lombok.Data; -import me.chanjar.weixin.open.bean.ma.WxOpenMaPreviewInfo; -import me.chanjar.weixin.open.bean.ma.WxOpenMaSubmitAudit; import java.io.Serializable; import java.util.List; @@ -12,7 +12,7 @@ * 微信小程序代码包提交审核(仅供第三方开发者代小程序调用) * * @author yqx - * @date 2018/9/13 + * created on 2018/9/13 */ @Data public class WxOpenMaSubmitAuditMessage implements Serializable { @@ -22,13 +22,13 @@ public class WxOpenMaSubmitAuditMessage implements Serializable { * 提交审核项的一个列表(至少填写1项,至多填写5项) */ @SerializedName("item_list") - private List itemList; + private List itemList; /** * 预览信息(小程序页面截图和操作录屏) */ @SerializedName("preview_info") - private WxOpenMaPreviewInfo previewInfo; + private WxMaCodeSubmitAuditPreviewInfo previewInfo; /** * 小程序版本说明和功能解释 @@ -47,4 +47,16 @@ public class WxOpenMaSubmitAuditMessage implements Serializable { */ @SerializedName("feedback_stuff") private String feedbackStuff; + + /** + * 用于声明是否不使用“代码中检测出但是未配置的隐私相关接口” + */ + @SerializedName("privacy_api_not_use") + private Boolean privacyApiNotUse; + + /** + * 订单中心path + */ + @SerializedName("order_path") + private String orderPath; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java index 7a41355920..dc99fcc18c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java @@ -102,6 +102,21 @@ public static class Info implements Serializable { @XStreamAlias("component_phone") @XStreamConverter(value = XStreamCDataConverter.class) private String componentPhone; + + // 创建个人小程序审核通知数据 + @XStreamAlias("wxuser") + @XStreamConverter(value = XStreamCDataConverter.class) + private String wxuser; + + @XStreamAlias("idname") + @XStreamConverter(value = XStreamCDataConverter.class) + private String idname; + + // 创建试用小程序成功/失败的通知数据 + @XStreamAlias("unique_id") + @XStreamConverter(value = XStreamCDataConverter.class) + private String uniqueId; + } public static String wxMpOutXmlMessageToEncryptedXml(WxMpXmlOutMessage message, WxOpenConfigStorage wxOpenConfigStorage) { @@ -132,7 +147,7 @@ public static WxOpenXmlMessage fromXml(InputStream is) { public static WxOpenXmlMessage fromEncryptedXml(String encryptedXml, WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce, String msgSignature) { WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); - String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); + String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml); log.debug("解密后的原始xml消息内容:{}", plainText); return fromXml(plainText); } @@ -140,7 +155,7 @@ public static WxOpenXmlMessage fromEncryptedXml(String encryptedXml, WxOpenConfi public static WxMpXmlMessage fromEncryptedMpXml(String encryptedXml, WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce, String msgSignature) { WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); - String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); + String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml); return WxMpXmlMessage.fromXml(plainText); } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/AddMinishopGoodsSPU.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/AddMinishopGoodsSPU.java similarity index 97% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/AddMinishopGoodsSPU.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/AddMinishopGoodsSPU.java index 586605d2ce..044f25e8b3 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/AddMinishopGoodsSPU.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/AddMinishopGoodsSPU.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.Gson; import com.google.gson.JsonObject; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Attr.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Attr.java similarity index 91% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Attr.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Attr.java index 44a671fa67..2eb46d7560 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Attr.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Attr.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.JsonObject; import lombok.Data; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Cat.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Cat.java similarity index 92% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Cat.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Cat.java index dc72a998a3..a7c8042534 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Cat.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Cat.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.JsonObject; import lombok.Data; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/DescInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/DescInfo.java similarity index 90% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/DescInfo.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/DescInfo.java index eacb9767e7..6b6e68b044 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/DescInfo.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/DescInfo.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.Gson; import com.google.gson.JsonObject; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/ExpressInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/ExpressInfo.java similarity index 90% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/ExpressInfo.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/ExpressInfo.java index c2b34c2aae..8772526a89 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/ExpressInfo.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/ExpressInfo.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.JsonObject; import lombok.Data; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/GoodsCat.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/GoodsCat.java similarity index 91% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/GoodsCat.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/GoodsCat.java index 6869c17a7f..8984c534fc 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/GoodsCat.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/GoodsCat.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.JsonObject; import lombok.Data; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/GoodsCatList.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/GoodsCatList.java similarity index 77% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/GoodsCatList.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/GoodsCatList.java index 50d618bc2e..5f3d635f9c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/GoodsCatList.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/GoodsCatList.java @@ -1,12 +1,16 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.Gson; import com.google.gson.JsonObject; import lombok.Data; import lombok.experimental.Accessors; +import me.chanjar.weixin.common.api.WxConsts; import java.util.List; +/** + * @author kelvenlaw + */ @Data @Accessors(chain = true) public class GoodsCatList { @@ -26,7 +30,7 @@ public class GoodsCatList { public JsonObject toJsonObject() { Gson gson = new Gson(); JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("errcode", errcode); + jsonObject.addProperty(WxConsts.ERR_CODE, errcode); jsonObject.addProperty("errmsg", errmsg); jsonObject.addProperty("cat_list", gson.toJson(catList)); return jsonObject; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/ParentCatId.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/ParentCatId.java similarity index 84% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/ParentCatId.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/ParentCatId.java index 5a04debd25..07105237f6 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/ParentCatId.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/ParentCatId.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.JsonObject; import lombok.Data; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Sku.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Sku.java similarity index 95% rename from weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Sku.java rename to weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Sku.java index aefcabaa55..b27040bc29 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopGoods/Sku.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/minishopgoods/Sku.java @@ -1,11 +1,10 @@ -package me.chanjar.weixin.open.bean.minishopGoods; +package me.chanjar.weixin.open.bean.minishopgoods; import com.google.gson.Gson; import com.google.gson.JsonObject; import lombok.Data; import lombok.experimental.Accessors; -import java.util.Arrays; import java.util.List; @Data diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxAmpLinkResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxAmpLinkResult.java new file mode 100644 index 0000000000..f80249d8d0 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxAmpLinkResult.java @@ -0,0 +1,111 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * 公众号关联的小程序 + * + * @author zhongjun + * created on 2022/4/29 + **/ + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxAmpLinkResult extends WxOpenResult{ + + /** + * 关联的小程序列表,具有 items 字段,内带有参数 + */ + @SerializedName("wxopens") + private WxOpen wxOpen; + + @Getter + @Setter + public static class WxOpen{ + @SerializedName("items") + private List items; + } + + @Getter + @Setter + public static class Item{ + + /** + * 关联状态 + * 1:已关联; + * 2:等待小程序管理员确认中; + * 3:小程序管理员拒绝关联 + * 12:等待公众号管理员确认中; + */ + private Integer status; + + /** + * 小程序appid + */ + private String appid; + + /** + * 小程序 gh_id + */ + private String username; + + /** + * 小程序名称 + */ + private String nickname; + + /** + * 是否在公众号管理页展示中 + */ + private Integer selected; + + /** + * 是否展示在附近的小程序中 + */ + @SerializedName("nearby_display_status") + private Integer nearbyDisplayStatus; + + /** + * 是否已经发布 + */ + private Integer released; + + /** + * 头像 url + */ + @SerializedName("headimg_url") + private String headImgUrl; + + /** + * 小程序邮箱 + */ + private String email; + + /** + * 微信认证及支付信息 + */ + @SerializedName("func_info") + private List funcInfo; + + } + + @Getter + @Setter + public static class FuncInfo{ + /** + * 微信认证及支付信息,0 表示未开通,1 表示开通 + */ + private Integer status; + + private String name; + + private Long id; + + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResult.java index 66783f2fd8..aac97904d1 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResult.java @@ -51,12 +51,6 @@ public class WxFastMaAccountBasicInfoResult extends WxOpenResult { @SerializedName("nickname") private String nickname; - /** - * 名称信息 - */ - @SerializedName("nickname_info") - private NicknameInfo nicknameInfo; - /** * 微信认证信息 */ @@ -73,6 +67,43 @@ public class WxFastMaAccountBasicInfoResult extends WxOpenResult { @SerializedName("head_image_info") private HeadImageInfo headImageInfo; + /** + * 名称信息 + */ + @SerializedName("nickname_info") + private NicknameInfo nicknameInfo; + + /** + * 注册国家 + * 参考链接 + */ + @SerializedName("registered_country") + private Integer registeredCountry; + + /** + * 主体标识,非个人主体时返回的是企业或者政府或其他组织的代号 + */ + @SerializedName("credential") + private String credential; + + /** + * 认证类型;如果未完成微信认证则返回0;不同枚举值对应的类型说明看下方 + * 状态值 说明 + * 1 企业 + * 2 企业媒体 + * 3 政府 + * 4 非盈利组织 + * 5 民营非企业 + * 6 盈利组织 + * 8 社会团体 + * 9 事业媒体 + * 11 事业单位 + * 12 个体工商户 + * 14 海外企业 + */ + @SerializedName("customer_type") + private Integer customerType; + @Data public static class NicknameInfo { /** diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenHaveResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenHaveResult.java new file mode 100644 index 0000000000..5db81c7b1a --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenHaveResult.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 该 API 用于查询公众号或小程序是否绑定的开放平台帐号。 + * 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html + */ +@Data +@EqualsAndHashCode(callSuper = false) +public class WxOpenHaveResult extends WxOpenResult implements Serializable { + + @SerializedName("have_open") + private Boolean haveOpen; + + public static WxOpenHaveResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxOpenHaveResult.class); + } + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaApplyLiveInfoResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaApplyLiveInfoResult.java new file mode 100644 index 0000000000..d65e19b853 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaApplyLiveInfoResult.java @@ -0,0 +1,18 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author 清心 + * created at 2022-10-04 16:11 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxOpenMaApplyLiveInfoResult extends WxOpenResult{ + + @SerializedName("action") + private String action; + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java index 262f79b487..afef19761a 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java @@ -12,7 +12,7 @@ * 微信开放平台小程序分类目录列表返回 * * @author yqx - * @date 2018/9/12 + * created on 2018/9/12 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainConfirmFileResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainConfirmFileResult.java new file mode 100644 index 0000000000..595c298f41 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainConfirmFileResult.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +/** + * 业务域名校验文件 + * + * @author vostro2013 + * @date 2023/06/06 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxOpenMaDomainConfirmFileResult extends WxOpenResult { + /** + * 文件名 + */ + @SerializedName("file_name") + private String fileName; + + /** + * 文件内容 + */ + @SerializedName("file_content") + private String fileContent; + + public static WxOpenMaDomainConfirmFileResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxOpenMaDomainConfirmFileResult.class); + } +} \ No newline at end of file diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java index feccc786b6..028dd62e26 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java @@ -3,6 +3,7 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.EqualsAndHashCode; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.util.List; @@ -10,23 +11,56 @@ * 微信开放平台小程序域名设置返回对象. * * @author yqx - * @date 2018/9/12 + * created on 2018/9/12 */ @Data @EqualsAndHashCode(callSuper = true) public class WxOpenMaDomainResult extends WxOpenResult { private static final long serialVersionUID = 3406315629639573330L; + /** + * request合法域名 + */ @SerializedName("requestdomain") - List requestdomainList; - + private List requestDomain; + /** + * socket合法域名 + */ @SerializedName("wsrequestdomain") - List wsrequestdomainList; - + private List wsRequestDomain; + /** + * uploadFile合法域名 + */ @SerializedName("uploaddomain") - List uploaddomainList; - + private List uploadDomain; + /** + * downloadFile合法域名 + */ @SerializedName("downloaddomain") - List downloaddomainList; + private List downloadDomain; + /** + * request不合法域名 + */ + @SerializedName("invalid_requestdomain") + private List invalidRequestDomain; + /** + * socket不合法域名 + */ + @SerializedName("invalid_wsrequestdomain") + private List invalidWsRequestDomain; + /** + * uploadFile不合法域名 + */ + @SerializedName("invalid_uploaddomain") + private List invalidUploadDomain; + /** + * downloadFile不合法域名 + */ + @SerializedName("invalid_downloaddomain") + private List invalidDownloadDomain; + + public static WxOpenMaDomainResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxOpenMaDomainResult.class); + } } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaGetOrderPathResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaGetOrderPathResult.java new file mode 100644 index 0000000000..d1346e5772 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaGetOrderPathResult.java @@ -0,0 +1,75 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xzh + * @Description 获取订单页path信息接口返回结果 + * @createTime 2023/05/23 15:07 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxOpenMaGetOrderPathResult extends WxOpenResult { + + private static final long serialVersionUID = 1988636135032104851L; + + /** + * 订单页path信息 + */ + @SerializedName("msg") + private MsgBean msg; + + @Data + public static class MsgBean implements Serializable { + private static final long serialVersionUID = 2153432209800394925L; + + /** + * 订单页path + */ + @SerializedName("path") + private String path; + /** + * 申请提交的图片url,审核版会显示 + */ + @SerializedName("img_list") + private List imgList; + /** + * 申请提交的视频url,审核版会显示 + */ + @SerializedName("video") + private String video; + /** + * 申请提交的测试账号,审核版会显示 + */ + @SerializedName("test_account") + private String testAccount; + /** + * 申请提交的测试密码,审核版会显示 + */ + @SerializedName("test_pwd") + private String testPwd; + /** + * 申请提交的测试备注,审核版会显示 + */ + @SerializedName("test_remark") + private String testRemark; + /** + * 申请状态说明 + * 2 审核中 + * 3 审核失败 + * 4 审核通过 + */ + @SerializedName("status") + private int status; + /** + * 申请时间 + */ + @SerializedName("apply_time") + private long applyTime; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaHistoryVersionResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaHistoryVersionResult.java index 61b9f5dddf..d1e7ede13a 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaHistoryVersionResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaHistoryVersionResult.java @@ -18,8 +18,8 @@ public class WxOpenMaHistoryVersionResult extends WxOpenResult { private static final long serialVersionUID = 4102311851687901079L; - @SerializedName("template_list") - List templateList; + @SerializedName("version_list") + List versions; @Override public String toString() { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java index 9f7ee95f72..6c6acda55e 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java @@ -11,7 +11,7 @@ * 微信开放平台小程序第三方提交代码的页面配置列表. * * @author yqx - * @date 2018/9/12 + * created on 2018/9/12 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPrefetchDomainResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPrefetchDomainResult.java new file mode 100644 index 0000000000..2b74874eb5 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPrefetchDomainResult.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author 清心 + * create on 2022-10-01 18:25 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WxOpenMaPrefetchDomainResult extends WxOpenResult{ + + @SerializedName("prefetch_dns_domain") + private List prefetchDnsDomain; + + @SerializedName("size_limit") + private Integer sizeLimit; + + @Data + public static class PreDnsDomain { + + @SerializedName("url") + private String url; + + @SerializedName("status") + private Integer status; + } + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java index 3f01aa745c..7b50b6e326 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java @@ -8,7 +8,7 @@ * . * * @author yqx - * @date 2018/10/3 + * created on 2018/10/3 */ @Data @EqualsAndHashCode(callSuper = true) @@ -35,4 +35,19 @@ public class WxOpenMaQueryAuditResult extends WxOpenResult { */ @SerializedName(value = "screenshot") private String screenShot; + /** + * 审核版本 + */ + @SerializedName("user_version") + private String userVersion; + /** + * 版本描述 + */ + @SerializedName("user_desc") + private String userDesc; + /** + * 时间戳,提交审核的时间 + */ + @SerializedName("submit_audit_time") + private Long submitAuditTime; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java index 69774e8e4f..2645ecb915 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java @@ -8,7 +8,7 @@ * 微信开放平台小程序发布代码审核结果. * * @author yqx - * @date 2018/9/12 + * created on 2018/9/12 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java index 014381ea4f..755abed61a 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java @@ -12,7 +12,7 @@ * 微信开放平台小程序体验者列表返回. * * @author yqx - * @date 2018/9/12 + * created on 2018/9/12 */ @Data @EqualsAndHashCode(callSuper = false) diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaVisitStatusResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaVisitStatusResult.java new file mode 100644 index 0000000000..c319e89acb --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaVisitStatusResult.java @@ -0,0 +1,21 @@ +package me.chanjar.weixin.open.bean.result; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 小程序服务状态 + * + * @author vostro2013 + * @date 2023/06/06 + */ +@Data +@EqualsAndHashCode(callSuper = false) +public class WxOpenMaVisitStatusResult extends WxOpenResult { + private Integer status; + + public static WxOpenMaVisitStatusResult fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WxOpenMaVisitStatusResult.class); + } +} \ No newline at end of file diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenRegisterBetaWeappResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenRegisterBetaWeappResult.java new file mode 100644 index 0000000000..735a26eca8 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenRegisterBetaWeappResult.java @@ -0,0 +1,14 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxOpenRegisterBetaWeappResult extends WxOpenResult { + @SerializedName("authorize_url") + private String authorizeUrl; + @SerializedName("unique_id") + protected String uniqueId; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenRegisterPersonalWeappResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenRegisterPersonalWeappResult.java new file mode 100644 index 0000000000..18ef23e39d --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenRegisterPersonalWeappResult.java @@ -0,0 +1,15 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxOpenRegisterPersonalWeappResult extends WxOpenResult { + private String taskid; + @SerializedName("authorize_url") + private String authorizeUrl; + @SerializedName("status") + private Integer status; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java index 90433d945c..1bb810a193 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java @@ -11,7 +11,7 @@ * 基础的微信开放平台请求结果. * * @author yqx - * @date 2018/10/1 + * created on 2018/10/1 */ @Data public class WxOpenResult implements Serializable { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenVersioninfoResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenVersioninfoResult.java new file mode 100644 index 0000000000..30bf9127c9 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenVersioninfoResult.java @@ -0,0 +1,74 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 小程序版本信息 + * + * @author cocoa + * created on 20220727 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxOpenVersioninfoResult extends WxOpenResult { + + private static final long serialVersionUID = -1042219138582803275L; + + @SerializedName("exp_info") + ExpInfo expInfo; + + @SerializedName("release_info") + ReleaseInfo releaseInfo; + + @Override + public String toString() { + return WxOpenGsonBuilder.create().toJson(this); + } + + @Data + public static class ReleaseInfo { + /** + * 发布线上版的时间 + */ + @SerializedName("release_time") + private Long releaseTime; + /** + * 线上版版本信息 + */ + @SerializedName("release_version") + private String releaseVersion; + /** + * 线上版本描述 + */ + @SerializedName("release_desc") + private String releaseDesc; + } + + + @Data + public static class ExpInfo { + /** + * 提交体验版的时间 + */ + @SerializedName("exp_time") + private Long expTime; + /** + * 头像已使用修改次数(本月) + */ + @SerializedName("exp_version") + private String expVersion; + /** + * 头像修改次数总额度(本月) + */ + @SerializedName("exp_desc") + private String expDesc; + } + + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/CombinedShippingInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/CombinedShippingInfo.java new file mode 100644 index 0000000000..45abbf32ea --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/CombinedShippingInfo.java @@ -0,0 +1,77 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CombinedShippingInfo implements Serializable { + private static final long serialVersionUID = -2338140924295957062L; + /** + * 必填 + * 合单订单,需要上传物流详情的合单订单,根据订单类型二选一 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + /** + * 子单物流详情 + */ + @SerializedName("sub_orders") + private List subOrders; + + /** + * 必填 + * 支付者,支付者信息 + */ + @SerializedName("payer") + private PayerBean payer; + + + /** + * 必填 + * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 + */ + @SerializedName("upload_time") + private String uploadTime; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SubOrderListBean implements Serializable { + private static final long serialVersionUID = -8792281478692710237L; + + /** + * 必填 + * 订单,需要上传购物详情的订单,根据订单类型二选一 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + + /** + * 必填 + * 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) + * 示例值: UNIFIED_DELIVERY + */ + @SerializedName("delivery_mode") + private int deliveryMode; + + /** + * 必填 + * 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式,多重性: [1, 10] + */ + @SerializedName("shipping_list") + private List shippingList; + + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/CombinedShoppingInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/CombinedShoppingInfo.java new file mode 100644 index 0000000000..fa51d28f35 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/CombinedShoppingInfo.java @@ -0,0 +1,88 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CombinedShoppingInfo implements Serializable { + private static final long serialVersionUID = 8325009858985444023L; + /** + * 必填 + * 合单订单,需要上传购物详情的合单订单,根据订单类型二选一 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + /** + * 子单购物详情 + */ + @SerializedName("sub_orders") + private List subOrders; + + /** + * 必填 + * 支付者,支付者信息 + */ + @SerializedName("payer") + private PayerBean payer; + + + /** + * 必填 + * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 + */ + @SerializedName("upload_time") + private String uploadTime; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SubOrderListBean implements Serializable { + private static final long serialVersionUID = -8792281478692710237L; + + /** + * 必填 + * 订单,需要上传购物详情的订单,根据订单类型二选一 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + /** + * 必填 + * 商户交易订单编号,商户侧的交易订单详情页向用户展示的订单编号 + * 示例值: 232457563423 字符字节限制: [1, 64] + */ + @SerializedName("merchant_order_no") + private String merchantOrderNo; + + /** + * 必填 + * 商户交易订单详情页链接,用户查看“商城订单”时,跳转至商户侧查看交易订单详情页的链接。详情页类别可以为H5或小程序 + */ + @SerializedName("order_detail_jump_link") + private ShoppingInfo.OrderDetailBean orderDetailJumpLink; + + /** + * 订单购买的商品列表,用户在订单中购买的全部商品明细的列表,最多可以上传50个商品 + * 多重性: [1, 50] + */ + @SerializedName("item_list") + private List itemList; + /** + * 物流形式,订单商品配送的物流形式,默认为实体物流 + * 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 + */ + @SerializedName("logistics_type") + private int logisticsType; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ContactBean.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ContactBean.java new file mode 100644 index 0000000000..f083a1c40d --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ContactBean.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ContactBean implements Serializable { + private static final long serialVersionUID = 2256209964320569284L; + /** + * 寄件人联系方式,寄件人联系方式,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024 + */ + @SerializedName("consignor_contact") + private String consignorContact; + /** + * 收件人联系方式,收件人联系方式为,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024 + */ + @SerializedName("receiver_contact") + private String receiverContact; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/OrderKeyBean.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/OrderKeyBean.java new file mode 100644 index 0000000000..6b9cd1000f --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/OrderKeyBean.java @@ -0,0 +1,39 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderKeyBean implements Serializable { + + private static final long serialVersionUID = 1486092394664728388L; + /** + * 必填 + * 订单单号类型,用于确认需要上传详情的订单。枚举值1,使用下单商户号和商户侧单号;枚举值2,使用微信支付单号。 + */ + @SerializedName("order_number_type") + private int orderNumberType; + /** + * 原支付交易对应的微信订单号 + */ + @SerializedName("transaction_id") + private String transactionId; + /** + * 支付下单商户的商户号,由微信支付生成并下发。 + */ + @SerializedName("mchid") + private String mchId; + /** + * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一 + */ + @SerializedName("out_trade_no") + private String outTradeNo; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/PayerBean.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/PayerBean.java new file mode 100644 index 0000000000..ffd5713cb5 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/PayerBean.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PayerBean implements Serializable { + private static final long serialVersionUID = -7943088204264205895L; + /** + * 必填 + * 用户标识,用户在小程序appid下的唯一标识。 下单前需获取到用户的Openid 示例值: oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 字符字节限制: [1, 128] + */ + @SerializedName("openid") + private String openid; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShippingInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShippingInfo.java new file mode 100644 index 0000000000..c548cb2ec1 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShippingInfo.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ShippingInfo implements Serializable { + + private static final long serialVersionUID = 2105037984591600658L; + /** + * 必填 + * 订单,需要上传物流信息的订单 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + + /** + * 必填 + * 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) + * 示例值: UNIFIED_DELIVERY + */ + @SerializedName("delivery_mode") + private int deliveryMode; + + /** + * 必填 + * 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式,多重性: [1, 10] + */ + @SerializedName("shipping_list") + private List shippingList; + + /** + * 必填 + * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 + */ + @SerializedName("upload_time") + private String uploadTime; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShippingListBean.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShippingListBean.java new file mode 100644 index 0000000000..3111a10ba1 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShippingListBean.java @@ -0,0 +1,54 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ShippingListBean implements Serializable { + + private static final long serialVersionUID = -6884739637300493109L; + /** + * 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128] + */ + @SerializedName("tracking_no") + private String trackingNo; + /** + * 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128] + */ + @SerializedName("express_company") + private String expressCompany; + /** + * 物流关联的商品列表,当统一发货(单个物流单)时,该项不填;当分拆发货(多个物流单)时,需填入各物流单关联的商品列表 多重性: [0, 50] + */ + @SerializedName("item_list") + private List itemList; + /** + * 联系方式,当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一 + */ + @SerializedName("contact") + private ContactBean contact; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ShippingItemListBean implements Serializable { + + private static final long serialVersionUID = -1433227869321841858L; + /** + * 商户侧商品ID,商户系统内部商品编码,分拆发货模式下为必填,用于标识每笔物流单号内包含的商品,需与「上传购物详情」中传入的商品ID匹配 + * 示例值: 1246464644 字符字节限制: [1, 64] + */ + @SerializedName("merchant_item_id") + private String merchantItemId; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShoppingInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShoppingInfo.java new file mode 100644 index 0000000000..e913b3ba35 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShoppingInfo.java @@ -0,0 +1,166 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ShoppingInfo implements Serializable { + + private static final long serialVersionUID = 2105037984591600658L; + /** + * 必填 + * 订单,需要上传物流信息的订单 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + /** + * 购物详情列表 + */ + @SerializedName("order_list") + private List orderList; + + /** + * 必填 + * 支付者,支付者信息 + */ + @SerializedName("payer") + private PayerBean payer; + + /** + * 物流形式,订单商品配送的物流形式,默认为实体物流 + * 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 + */ + @SerializedName("logistics_type") + private int logisticsType; + + /** + * 必填 + * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 + */ + @SerializedName("upload_time") + private String uploadTime; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class OrderListBean implements Serializable { + private static final long serialVersionUID = -7690807867756471672L; + /** + * 必填 + * 商户交易订单编号,商户侧的交易订单详情页向用户展示的订单编号 + * 示例值: 232457563423 字符字节限制: [1, 64] + */ + @SerializedName("merchant_order_no") + private String merchantOrderNo; + + /** + * 必填 + * 商户交易订单详情页链接,用户查看“商城订单”时,跳转至商户侧查看交易订单详情页的链接。详情页类别可以为H5或小程序 + */ + @SerializedName("order_detail_jump_link") + private OrderDetailBean orderDetailJumpLink; + + /** + * 订单购买的商品列表,用户在订单中购买的全部商品明细的列表,最多可以上传50个商品 + * 多重性: [1, 50] + */ + @SerializedName("item_list") + private List itemList; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class OrderDetailBean implements Serializable { + private static final long serialVersionUID = -8002249022516272034L; + /** + * 链接地址(链接类型为H5时必填) + * 示例值: https://www.weixin.qq.com/wxpay/pay.php + * 字符字节限制: [1, 1024] + * 匹配正则表达式: ^https?😕/([^\s/?#[]@]+@)?([^\s/?#@:]+)(?::\d{2,5})?([^[]]*)$ + */ + @SerializedName("url") + private String url; + /** + * 小程序appid(链接类型为MINIAPP时必填) + * 示例值: wxd678efh567hg6787 字符字节限制: [1, 32] + */ + @SerializedName("appid") + private String appId; + /** + * 小程序path(链接类型为MINIAPP时必填) + * 示例值: /path/index/index 字符字节限制: [1, 512] + */ + @SerializedName("path") + private String path; + /** + * 必填 + * 链接类型枚举值:1、URL;2、MINI_PROGRAM + * 示例值: MINI_PROGRAM + */ + @SerializedName("type") + private int type; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class OrderItemListBean implements Serializable { + private static final long serialVersionUID = -2989527770771246748L; + /** + * 商户侧商品ID,商户系统内部商品编码,用于标识不同的商品。请注意,当发货模式选择“分拆发货”时,需要使用商户侧商品ID来标记各物流单中包含的具体商品 + * 示例值: 1246464644 字符字节限制: [1, 64] + */ + @SerializedName("merchant_item_id") + private String merchantItemId; + /** + * 必填 + * 商品名称 + * 示例值: iPhoneX 256G 字符长度限制: [1, 256] + */ + @SerializedName("name") + private String name; + /** + * 商品描述 + * 示例值: Image形象店-深圳腾大-QQ公仔 字符长度限制: [1, 512] + */ + @SerializedName("description") + private String description; + /** + * 必填 + * 商品单价(单位:分) + */ + @SerializedName("unit_price") + private long unitPrice; + /** + * 必填 + * 购买数量 + * 示例值: 2 + */ + @SerializedName("quantity") + private long quantity; + /** + * 商品图片链接 + * 示例值: https://qpic.cn/xxx + * 多重性: [1, 3] + * 字符字节限制: [1, 1024] + * 匹配正则表达式: ^https?😕/([^\s/?#[]@]+@)?([^\s/?#@:]+)(?::\d{2,5})?([^[]]*)$ + */ + @SerializedName("image_url") + private List imageUrl; + } + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShoppingInfoVerifyUpload.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShoppingInfoVerifyUpload.java new file mode 100644 index 0000000000..30b778f6f0 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/ShoppingInfoVerifyUpload.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ShoppingInfoVerifyUpload implements Serializable { + + private static final long serialVersionUID = 4295431037060277496L; + /** + * 必填 + * 订单,需要上传购物详情的订单,根据订单类型二选一 + */ + @SerializedName("order_key") + private OrderKeyBean orderKey; + + /** + * 必填 + * 支付者,支付者信息 + */ + @SerializedName("payer") + private PayerBean payer; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/WxOpenShoppingInfoVerifyUploadResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/WxOpenShoppingInfoVerifyUploadResult.java new file mode 100644 index 0000000000..8e602ed9bd --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/WxOpenShoppingInfoVerifyUploadResult.java @@ -0,0 +1,18 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxOpenShoppingInfoVerifyUploadResult extends WxOpenResult { + + private static final long serialVersionUID = -3223834939130803964L; + /** + * 验证结果 + */ + @SerializedName("verify_result") + private String verifyResult; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/WxOpenShoppingOrdersConfirmResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/WxOpenShoppingOrdersConfirmResult.java new file mode 100644 index 0000000000..6b1d379732 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/shoppingOrders/WxOpenShoppingOrdersConfirmResult.java @@ -0,0 +1,17 @@ +package me.chanjar.weixin.open.bean.shoppingOrders; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxOpenShoppingOrdersConfirmResult extends WxOpenResult { + private static final long serialVersionUID = 8534868743462740891L; + /** + * 最近一次审核的结果 + */ + @SerializedName("last_result") + private String lastResult; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcb/ShareCloudBaseEnvRequest.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcb/ShareCloudBaseEnvRequest.java new file mode 100644 index 0000000000..6dc74dbad8 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcb/ShareCloudBaseEnvRequest.java @@ -0,0 +1,41 @@ +package me.chanjar.weixin.open.bean.tcb; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ShareCloudBaseEnvRequest implements Serializable { + private static final long serialVersionUID = 410566969624593042L; + + @SerializedName("data") + private List data; + + /** + * 请求环境源,填 1,表示云托管环境 + */ + @SerializedName("source_type") + private Integer sourceType; + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class DataDTO implements Serializable { + private static final long serialVersionUID = -8117487215582856716L; + + @SerializedName("env") + private String env; + @SerializedName("appids") + private List appids; + } + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcb/ShareCloudBaseEnvResponse.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcb/ShareCloudBaseEnvResponse.java new file mode 100644 index 0000000000..ff40dd725e --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcb/ShareCloudBaseEnvResponse.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.open.bean.tcb; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +public class ShareCloudBaseEnvResponse extends WxOpenResult implements Serializable { + private static final long serialVersionUID = 316444074975118997L; + + @SerializedName("err_list") + private List errList; + + @Data + public static class ErrListDTO implements Serializable { + @SerializedName("env") + private String env; + @SerializedName("appid") + private String appid; + @SerializedName("errmsg") + private String errmsg; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcbComponent/GetShareCloudBaseEnvResponse.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcbComponent/GetShareCloudBaseEnvResponse.java new file mode 100644 index 0000000000..d498e30739 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcbComponent/GetShareCloudBaseEnvResponse.java @@ -0,0 +1,35 @@ +package me.chanjar.weixin.open.bean.tcbComponent; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +import java.io.Serializable; +import java.util.List; + +@Data +public class GetShareCloudBaseEnvResponse extends WxOpenResult implements Serializable { + private static final long serialVersionUID = -6267755285547585403L; + + @SerializedName("relation_data") + private List relationData; + + @SerializedName("err_list") + private List errList; + + @Data + public static class RelationDataDTO implements Serializable { + @SerializedName("appid") + private String appid; + @SerializedName("env_list") + private List envList; + } + + @Data + public static class ErrListDTO implements Serializable { + @SerializedName("appid") + private String appid; + @SerializedName("errmsg") + private String errmsg; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcbComponent/GetTcbEnvListResponse.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcbComponent/GetTcbEnvListResponse.java new file mode 100644 index 0000000000..6551b4d3db --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/tcbComponent/GetTcbEnvListResponse.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.open.bean.tcbComponent; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.open.bean.result.WxOpenResult; + +import java.io.Serializable; +import java.util.List; + +@Data +public class GetTcbEnvListResponse extends WxOpenResult implements Serializable { + private static final long serialVersionUID = -5896318347861752798L; + + @SerializedName("info_list") + private List infoList; + + @Data + public static class InfoListDTO implements Serializable { + @SerializedName("env") + private String env; + @SerializedName("alias") + private String alias; + @SerializedName("create_time") + private String createTime; + @SerializedName("update_time") + private String updateTime; + @SerializedName("status") + private String status; + @SerializedName("package_id") + private String packageId; + @SerializedName("package_name") + private String packageName; + @SerializedName("dbinstance_id") + private String dbinstanceId; + @SerializedName("bucket_id") + private String bucketId; + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/GenericUploadRequestExecutor.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/GenericUploadRequestExecutor.java new file mode 100644 index 0000000000..e2d43a96a8 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/GenericUploadRequestExecutor.java @@ -0,0 +1,184 @@ +package me.chanjar.weixin.open.executor; + +import com.google.common.io.Files; +import jodd.http.HttpConnectionProvider; +import jodd.http.HttpRequest; +import jodd.http.HttpResponse; +import jodd.http.ProxyInfo; +import lombok.Data; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.http.ResponseHandler; +import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; +import okhttp3.*; +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.*; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +/** + * 通用的上传请求执行器 + */ +public class GenericUploadRequestExecutor implements RequestExecutor { + + private final Executor executor; + + /** + * 构造通用执行器 + * + * @param requestHttp http请求 + * @param httpMethod http方法(POST PUT PATCH) + * @param paramName 参数名 + * @param fileName 文件名 + */ + @SuppressWarnings("all") + public GenericUploadRequestExecutor(RequestHttp requestHttp, String httpMethod, String paramName, String fileName) { + switch (requestHttp.getRequestType()) { + case APACHE_HTTP: + executor = new ApacheExecutor(); + break; + case OK_HTTP: + executor = new OkExecutor(); + break; + case JODD_HTTP: + executor = new JoddExecutor(); + break; + default: + throw new UnsupportedOperationException("使用了暂不支持的HTTP客户端:" + requestHttp.getRequestType()); + } + executor.setRequestHttp((RequestHttp) requestHttp); + executor.setHttpMethod(httpMethod); + executor.setParamName(paramName); + executor.setFileName(fileName); + } + + @Override + public String execute(String uri, InputStream data, WxType wxType) throws WxErrorException, IOException { + String json = executor.execute(uri, data, wxType); + WxError error = WxError.fromJson(json, wxType); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return json; + } + + @Override + public void execute(String uri, InputStream data, ResponseHandler handler, WxType wxType) throws WxErrorException, IOException { + handler.handle(this.execute(uri, data, wxType)); + } + + /** + * 内部请求执行器 + * + * @param http客户端 + * @param http代理 + */ + @Data + public static abstract class Executor { + + private RequestHttp requestHttp; + private String httpMethod; + private String paramName; + private String fileName; + + public abstract String execute(String uri, InputStream data, WxType wxType) throws WxErrorException, IOException; + } + + /** + * 阿帕奇执行器 + */ + public static class ApacheExecutor extends Executor { + + @Override + public String execute(String uri, InputStream data, WxType wxType) throws WxErrorException, IOException { + HttpEntityEnclosingRequestBase bodyRequest; + switch (getHttpMethod()) { + case "POST": + bodyRequest = new HttpPost(uri); + break; + case "PUT": + bodyRequest = new HttpPut(uri); + break; + case "PATCH": + bodyRequest = new HttpPatch(uri); + break; + default: + throw new IllegalAccessError("不支持的请求方式:" + getHttpMethod()); + } + if (getRequestHttp().getRequestHttpProxy() != null) { + RequestConfig config = RequestConfig.custom().setProxy(getRequestHttp().getRequestHttpProxy()).build(); + bodyRequest.setConfig(config); + } + + HttpEntity entity = MultipartEntityBuilder + .create() + .addBinaryBody(getParamName(), data, ContentType.create("multipart/form-data", StandardCharsets.UTF_8), + getFileName()) + .setMode(HttpMultipartMode.RFC6532) + .build(); + bodyRequest.setEntity(entity); + bodyRequest.setHeader("Content-Type", ContentType.MULTIPART_FORM_DATA.toString()); + + try (CloseableHttpResponse response = getRequestHttp().getRequestHttpClient().execute(bodyRequest)) { + return Utf8ResponseHandler.INSTANCE.handleResponse(response); + } finally { + bodyRequest.releaseConnection(); + } + } + } + + /** + * ok执行器 + */ + public static class OkExecutor extends Executor { + + @Override + public String execute(String uri, InputStream data, WxType wxType) throws WxErrorException, IOException { + OkHttpClient client = getRequestHttp().getRequestHttpClient(); + byte[] bytes = IOUtils.toByteArray(data); + RequestBody body = new MultipartBody.Builder() + .setType(Objects.requireNonNull(MediaType.parse("multipart/form-data"))) + .addFormDataPart("media", getFileName(), RequestBody.create(bytes, MediaType.parse("application/octet-stream"))) + .build(); + + Request request = new Request.Builder().url(uri).method(getHttpMethod(), body).build(); + Response response = client.newCall(request).execute(); + return response.body().string(); + } + } + + /** + * jodd执行器 + */ + public static class JoddExecutor extends Executor { + + @Override + public String execute(String uri, InputStream data, WxType wxType) throws WxErrorException, IOException { + HttpRequest request = HttpRequest.post(uri); + if (getRequestHttp().getRequestHttpProxy() != null) { + getRequestHttp().getRequestHttpClient().useProxy(getRequestHttp().getRequestHttpProxy()); + } + request.withConnectionProvider(getRequestHttp().getRequestHttpClient()); + + request.form(getParamName(), data); + + HttpResponse response = request.send(); + response.charset(StandardCharsets.UTF_8.name()); + return response.bodyText(); + } + } +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeApacheHttpRequestExecutor.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeApacheHttpRequestExecutor.java index 7f9b7694e5..c95748f8a1 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeApacheHttpRequestExecutor.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeApacheHttpRequestExecutor.java @@ -25,7 +25,7 @@ /** * @author yqx - * @date 2018-09-13 + * created on 2018-09-13 */ public class MaQrCodeApacheHttpRequestExecutor extends MaQrCodeRequestExecutor { public MaQrCodeApacheHttpRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java index fc664483e6..5eddf762b1 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java @@ -24,7 +24,7 @@ /** * @author yqx - * @date 2018-09-13 + * created on 2018-09-13 */ public class MaQrCodeJoddHttpRequestExecutor extends MaQrCodeRequestExecutor { public MaQrCodeJoddHttpRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeOkhttpRequestExecutor.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeOkhttpRequestExecutor.java index 4b8a754502..77816949d6 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeOkhttpRequestExecutor.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeOkhttpRequestExecutor.java @@ -20,7 +20,7 @@ /** * @author yqx - * @date 2018-09-13 + * created on 2018-09-13 */ public class MaQrCodeOkhttpRequestExecutor extends MaQrCodeRequestExecutor { public MaQrCodeOkhttpRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java index ac02c1ec3d..d37c31d05e 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java @@ -15,7 +15,7 @@ * 获得小程序体验QrCode图片 请求执行器. * * @author yqx - * @date 2018-09-13 + * created on 2018-09-13 */ public abstract class MaQrCodeRequestExecutor implements RequestExecutor { protected RequestHttp requestHttp; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java index b507e0daa4..e6c8ce992d 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java @@ -3,6 +3,9 @@ import com.google.common.base.CharMatcher; import com.google.common.io.BaseEncoding; import me.chanjar.weixin.open.api.WxOpenConfigStorage; +import org.apache.commons.lang3.StringUtils; + +import java.util.Base64; /** * @author 007 @@ -25,6 +28,6 @@ public WxOpenCryptUtil(WxOpenConfigStorage wxOpenConfigStorage) { this.token = token; this.appidOrCorpid = appId; - this.aesKey = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey)); + this.aesKey = Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " ")); } } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java index 2fb4e7957e..7e4439ec0c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java @@ -12,6 +12,12 @@ * @author 007 */ public class WxOpenAuthorizerInfoGsonAdapter implements JsonDeserializer { + + private static final String VERIFY_TYPE_INFO = "verify_type_info"; + private static final String SERVICE_TYPE_INFO = "service_type_info"; + private static final String MINI_PROGRAM_INFO = "MiniProgramInfo"; + private static final String BASIC_CONFIG = "basic_config"; + @Override public WxOpenAuthorizerInfo deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { WxOpenAuthorizerInfo authorizationInfo = new WxOpenAuthorizerInfo(); @@ -23,20 +29,27 @@ public WxOpenAuthorizerInfo deserialize(JsonElement jsonElement, Type type, Json authorizationInfo.setPrincipalName(GsonHelper.getString(jsonObject, "principal_name")); authorizationInfo.setAlias(GsonHelper.getString(jsonObject, "alias")); authorizationInfo.setQrcodeUrl(GsonHelper.getString(jsonObject, "qrcode_url")); + authorizationInfo.setAccountStatus(GsonHelper.getInteger(jsonObject, "account_status")); authorizationInfo.setSignature(GsonHelper.getString(jsonObject, "signature")); + authorizationInfo.setRegisterType(GsonHelper.getInteger(jsonObject, "register_type")); - if (jsonObject.has("service_type_info")) { - authorizationInfo.setServiceTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject("service_type_info"), "id")); + if (jsonObject.has(SERVICE_TYPE_INFO)) { + authorizationInfo.setServiceTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject(SERVICE_TYPE_INFO), "id")); + } + if (jsonObject.has(VERIFY_TYPE_INFO)) { + authorizationInfo.setVerifyTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject(VERIFY_TYPE_INFO), "id")); } - if (jsonObject.has("verify_type_info")) { - authorizationInfo.setVerifyTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject("verify_type_info"), "id")); + if(jsonObject.has(BASIC_CONFIG)){ + authorizationInfo.setBasicConfig(WxOpenGsonBuilder.create().fromJson(jsonObject.get(BASIC_CONFIG), + new TypeToken(){ + }.getType())); } Map businessInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get("business_info"), new TypeToken>() { }.getType()); authorizationInfo.setBusinessInfo(businessInfo); - if (jsonObject.has("MiniProgramInfo")) { - WxOpenAuthorizerInfo.MiniProgramInfo miniProgramInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get("MiniProgramInfo"), + if (jsonObject.has(MINI_PROGRAM_INFO)) { + WxOpenAuthorizerInfo.MiniProgramInfo miniProgramInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get(MINI_PROGRAM_INFO), new TypeToken() { }.getType()); authorizationInfo.setMiniProgramInfo(miniProgramInfo); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerListResultGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerListResultGsonAdapter.java index 68e6d92e4d..2128839c23 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerListResultGsonAdapter.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerListResultGsonAdapter.java @@ -8,8 +8,7 @@ import java.util.*; /** - * @author robgao - * @Email 315789501@qq.com + * @author robgao Email 315789501@qq.com */ public class WxOpenAuthorizerListResultGsonAdapter implements JsonDeserializer { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java index 325383ebf0..5dbae037a2 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java @@ -7,6 +7,7 @@ import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo; import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizerInfo; import me.chanjar.weixin.open.bean.result.*; +import java.util.Objects; /** * @author 007 @@ -14,6 +15,7 @@ public class WxOpenGsonBuilder { private static final GsonBuilder INSTANCE = new GsonBuilder(); + private static volatile Gson GSON_INSTANCE; static { INSTANCE.disableHtmlEscaping(); @@ -26,11 +28,17 @@ public class WxOpenGsonBuilder { INSTANCE.registerTypeAdapter(WxOpenAuthorizerOptionResult.class, new WxOpenAuthorizerOptionResultGsonAdapter()); INSTANCE.registerTypeAdapter(WxFastMaAccountBasicInfoResult.class, new WxFastMaAccountBasicInfoGsonAdapter()); INSTANCE.registerTypeAdapter(WxOpenAuthorizerListResult.class, new WxOpenAuthorizerListResultGsonAdapter()); - } public static Gson create() { - return INSTANCE.create(); + if (Objects.isNull(GSON_INSTANCE)) { + synchronized (INSTANCE) { + if (Objects.isNull(GSON_INSTANCE)) { + GSON_INSTANCE = INSTANCE.create(); + } + } + } + return GSON_INSTANCE; } } diff --git a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java index c9fefec022..497311e084 100644 --- a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java +++ b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java @@ -3,15 +3,24 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.open.api.WxOpenComponentService; +import me.chanjar.weixin.open.bean.result.WxOpenHaveResult; +import me.chanjar.weixin.open.bean.result.WxOpenResult; +import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest; +import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse; +import me.chanjar.weixin.open.bean.tcbComponent.GetShareCloudBaseEnvResponse; +import me.chanjar.weixin.open.bean.tcbComponent.GetTcbEnvListResponse; import me.chanjar.weixin.open.test.ApiTestModule; +import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; +import java.util.Arrays; + /** * 单元测试类. * * @author Binary Wang - * @date 2020-06-06 + * created on 2020-06-06 */ @Guice(modules = ApiTestModule.class) public class WxOpenComponentServiceImplTest { @@ -158,6 +167,11 @@ public void testUnbindOpenAccount() { @Test public void testGetOpenAccount() { } + @Test + public void testHaveOpen() throws WxErrorException { + WxOpenHaveResult wxOpenHaveResult = wxOpenComponentService.haveOpen(); + Assert.assertNotNull(wxOpenHaveResult); + } @Test public void testFastRegisterWeapp() { @@ -171,4 +185,39 @@ public void testFastRegisterWeappSearch() { public void testStartPushTicket() throws WxErrorException { wxOpenComponentService.startPushTicket(); } + + @Test + public void testGetShareCloudBaseEnv() throws WxErrorException { + GetShareCloudBaseEnvResponse response = wxOpenComponentService.getShareCloudBaseEnv(Arrays.asList("wxad2ee6fa2df2c46d")); + Assert.assertNotNull(response); + } + + @Test + public void testGetTcbEnvListv() throws WxErrorException { + GetTcbEnvListResponse response = wxOpenComponentService.getTcbEnvList(); + Assert.assertNotNull(response); + } + + @Test + public void testChangeTcbEnv() throws WxErrorException { + WxOpenResult response = wxOpenComponentService.changeTcbEnv("test"); + Assert.assertNotNull(response); + } + + @Test + public void testShareCloudBaseEnv() throws WxErrorException { + ShareCloudBaseEnvRequest request = ShareCloudBaseEnvRequest.builder() + .data(Arrays.asList(ShareCloudBaseEnvRequest.DataDTO.builder() + .env("test-env-6gni9ity244a6ea3").appids(Arrays.asList("wx5fe6bb43205e9e07")).build())) + .build(); + ShareCloudBaseEnvResponse response = wxOpenComponentService.shareCloudBaseEnv(request); + Assert.assertNotNull(response); + } + + + @Test + public void testClearQuotaV2() throws WxErrorException { + WxOpenResult wxOpenResult = wxOpenComponentService.clearQuotaV2(""); + Assert.assertNotNull(wxOpenResult); + } } diff --git a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImplTest.java b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImplTest.java index e5a255be1d..7cf3961006 100644 --- a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImplTest.java +++ b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImplTest.java @@ -4,7 +4,7 @@ /** * @author Binary Wang - * @date 2020-06-06 + * created on 2020-06-06 */ public class WxOpenFastMaServiceImplTest { diff --git a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImplTest.java b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImplTest.java index 5e5f3e6682..4d8e41b59e 100644 --- a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImplTest.java +++ b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImplTest.java @@ -4,7 +4,7 @@ /** * @author Binary Wang - * @date 2020-06-06 + * created on 2020-06-06 */ public class WxOpenMaServiceImplTest { diff --git a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java index c32eb1fcfe..e65a662411 100644 --- a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java +++ b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java @@ -9,7 +9,7 @@ * 单元测试. * * @author Binary Wang - * @date 2020-10-19 + * created on 2020-10-19 */ public class WxOpenOAuth2ServiceImplTest { private final WxOpenOAuth2ServiceImpl service = new WxOpenOAuth2ServiceImpl("123", ""); diff --git a/weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResultTest.java b/weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResultTest.java new file mode 100644 index 0000000000..0baf92f0be --- /dev/null +++ b/weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResultTest.java @@ -0,0 +1,131 @@ +package me.chanjar.weixin.open.bean.result; + +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; +import org.testng.annotations.Test; + +/** + * @title: 获取授权帐号详情 信息反序列化测试 + * @author: trifolium + * created on : 2022/6/7 + * @modified : + */ +public class WxOpenAuthorizerInfoResultTest { + + @Test + public void testDeserialization() { + + String json = "{\n" + + " \"authorizer_info\": {\n" + + " \"nick_name\": \"美妆饰品\",\n" + + " \"head_img\": \"http:\\/\\/wx.qlogo.cn\\/mmopen\\/jJSbu4Te5iuiaM0dFnKVUEE83n2yH5cQStb\\/0\",\n" + + " \"service_type_info\": {\n" + + " \"id\": 0\n" + + " },\n" + + " \"verify_type_info\": {\n" + + " \"id\": -1\n" + + " },\n" + + " \"user_name\": \"gh_c43395cb652e\",\n" + + " \"alias\": \"\",\n" + + " \"qrcode_url\": \"http:\\/\\/mmbiz.qpic.cn\\/mmbiz_jpg\\/kPmmhe6g\\/0\",\n" + + " \"business_info\": {\n" + + " \"open_pay\": 0,\n" + + " \"open_shake\": 0,\n" + + " \"open_scan\": 0,\n" + + " \"open_card\": 0,\n" + + " \"open_store\": 0\n" + + " },\n" + + " \"idc\": 1,\n" + + " \"principal_name\": \"个人\",\n" + + " \"signature\": \"做美装,精美饰品等搭配教学\",\n" + + " \"MiniProgramInfo\": {\n" + + " \"network\": {\n" + + " \"RequestDomain\": [\"https:\\/\\/weixin.qq.com\"],\n" + + " \"WsRequestDomain\": [\"wss:\\/\\/weixin.qq.com\"],\n" + + " \"UploadDomain\": [\"https:\\/\\/weixin.qq.com\"],\n" + + " \"DownloadDomain\": [\"https:\\/\\/weixin.qq.com\"],\n" + + " \"BizDomain\": [],\n" + + " \"UDPDomain\": [],\n" + + " \"TCPDomain\": [],\n" + + " \"PrefetchDNSDomain\": [],\n" + + " \"NewRequestDomain\": [],\n" + + " \"NewWsRequestDomain\": [],\n" + + " \"NewUploadDomain\": [],\n" + + " \"NewDownloadDomain\": [],\n" + + " \"NewBizDomain\": [],\n" + + " \"NewUDPDomain\": [],\n" + + " \"NewTCPDomain\": [],\n" + + " \"NewPrefetchDNSDomain\": []\n" + + " },\n" + + " \"categories\": [{\n" + + " \"first\": \"生活服务\",\n" + + " \"second\": \"丽人服务\"\n" + + " }, {\n" + + " \"first\": \"旅游服务\",\n" + + " \"second\": \"旅游资讯\"\n" + + " }, {\n" + + " \"first\": \"物流服务\",\n" + + " \"second\": \"查件\"\n" + + " }],\n" + + " \"visit_status\": 0\n" + + " },\n" + + " \"register_type\": 0,\n" + + " \"account_status\": 1,\n" + + " \"basic_config\": {\n" + + " \"is_phone_configured\": true,\n" + + " \"is_email_configured\": true\n" + + " }\n" + + " },\n" + + " \"authorization_info\": {\n" + + " \"authorizer_appid\": \"wx326eecacf7370d4e\",\n" + + " \"authorizer_refresh_token\": \"refreshtoken@@@RU0Sgi7bD6apS7frS9gj8Sbws7OoDejK9Z-cm0EnCzg\",\n" + + " \"func_info\": [{\n" + + " \"funcscope_category\": {\n" + + " \"id\": 3\n" + + " },\n" + + " \"confirm_info\": {\n" + + " \"need_confirm\": 0,\n" + + " \"already_confirm\": 0,\n" + + " \"can_confirm\": 0\n" + + " }\n" + + " }, {\n" + + " \"funcscope_category\": {\n" + + " \"id\": 7\n" + + " }\n" + + " }, {\n" + + " \"funcscope_category\": {\n" + + " \"id\": 17\n" + + " }\n" + + " }, {\n" + + " \"funcscope_category\": {\n" + + " \"id\": 18\n" + + " },\n" + + " \"confirm_info\": {\n" + + " \"need_confirm\": 0,\n" + + " \"already_confirm\": 0,\n" + + " \"can_confirm\": 0\n" + + " }\n" + + " }, {\n" + + " \"funcscope_category\": {\n" + + " \"id\": 19\n" + + " }\n" + + " }, {\n" + + " \"funcscope_category\": {\n" + + " \"id\": 30\n" + + " },\n" + + " \"confirm_info\": {\n" + + " \"need_confirm\": 0,\n" + + " \"already_confirm\": 0,\n" + + " \"can_confirm\": 0\n" + + " }\n" + + " }, {\n" + + " \"funcscope_category\": {\n" + + " \"id\": 115\n" + + " }\n" + + " }]\n" + + " }\n" + + "}\n"; + + System.out.println(WxOpenGsonBuilder.create().fromJson(json, WxOpenAuthorizerInfoResult.class)); + } + +} diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 097fd4cfc1..648f2836ad 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B 4.0.0 @@ -27,7 +27,12 @@ org.jodd jodd-http - compile + provided + + + org.jodd + jodd-util + 6.1.0 @@ -35,11 +40,6 @@ commons-lang3 - - commons-beanutils - commons-beanutils - 1.9.4 - org.bouncycastle bcpkix-jdk15on @@ -73,6 +73,11 @@ com.google.code.gson gson + + javax.servlet + javax.servlet-api + 4.0.1 + diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmCreateRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmCreateRequest.java new file mode 100644 index 0000000000..b95061461c --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmCreateRequest.java @@ -0,0 +1,819 @@ +package com.github.binarywang.wxpay.bean.applyconfirm; + +import com.github.binarywang.wxpay.bean.applyment.enums.*; +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 间连商户开户意愿确认 提交申请对象 + * + * @author Mr.Pan + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class ApplySubjectConfirmCreateRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 渠道商户号 + * 1、微信支付分配的渠道商户唯一标识 + * 2、当从业机构调用时,该字段必填,需填写从业机构下的渠道商户号 + * 3、当渠道商户调用时,该字段无需填写 + * 示例值:20001111 + */ + @SerializedName("channel_id") + private String channelId; + + /** + * 业务申请编号 + * 1、只能由数字、字母或下划线组成 + * 2、服务商自定义的唯一编号。每个编号对应一个申请单 + * 3、建议前缀带上服务商商户号,参看示例值 + * 示例值:1900013511_10000 + */ + @SerializedName("business_code") + private String businessCode; + /** + * 联系人信息 + * 联系人信息,联系人是商户的联系人,将接收开户信息及日常重要管理信息, + * 请确定联系人为商户法定代表人或经营者再进行操作。如联系人非商户法定代表人或经营者, + * 请提交经办人身份证件和业务办理授权函。 + */ + @SerializedName("contact_info") + @SpecEncrypt + private ApplySubConfirmContactInfo contactInfo; + + /** + * 主体资料 + */ + @SerializedName("subject_info") + @SpecEncrypt + private ApplySubConfirmSubjectInfo subjectInfo; + + /** + * 法人身份信息 + */ + @SerializedName("identification_info") + @SpecEncrypt + private ApplySubConfirmIdentificationInfo identityInfo; + + /** + * 最终受益人信息列表(UBO) + */ + @SerializedName("ubo_info_list") + @SpecEncrypt + private List uboInfoList; + + /** + * 补充材料 + */ + @SerializedName("addition_info") + private ApplySubConfirmAdditionInfo additionInfo; + + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmIdentificationInfo implements Serializable { + private static final long serialVersionUID = 1683704338370383827L; + + /** + * 证件持有人类型 + * 1. 主体类型为政府机关、事业单位时选传: + * (1)若上传的是法人证件,则不需要上传该字段。 + * (2)若因特殊情况,无法提供法人证件时,可上传经办人。 (经办人:经商户授权办理微信支付业务的人员,授权范围包括但不限于签约,入驻过程需完成账户验证)。 + * 2. 主体类型为企业、个体户、社会组织时,默认为经营者/法人,不需要上传该字段。 + * LEGAL:经营者/法人 + * SUPER:经办人 + * 示例值:LEGAL + * @see com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest 字段idHolderType + */ + @SerializedName("id_holder_type") + private String idHolderType; + + /** + * 证件类型 + * 1、当证件持有人类型为法人时,填写。其他情况,无需上传。 + * 2、个体户/企业/事业单位/社会组织:可选择任一证件类型,政府机关、小微仅支持中国大陆居民-身份证类型。 + * 枚举值: + * IDENTIFICATION_TYPE_IDCARD:中国大陆居民-身份证 + * IDENTIFICATION_TYPE_OVERSEA_PASSPORT:其他国家或地区居民-护照 + * IDENTIFICATION_TYPE_HONGKONG_PASSPORT:中国香港居民-来往内地通行证 + * IDENTIFICATION_TYPE_MACAO_PASSPORT:中国澳门居民-来往内地通行证 + * IDENTIFICATION_TYPE_TAIWAN_PASSPORT:中国台湾居民-来往大陆通行证 + * IDENTIFICATION_TYPE_FOREIGN_RESIDENT:外国人居留证 + * IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT:港澳居民证 + * IDENTIFICATION_TYPE_TAIWAN_RESIDENT:台湾居民证 + * 示例值:IDENTIFICATION_TYPE_IDCARD + */ + @SerializedName("id_doc_type") + private IdTypeEnum idDocType; + + /** + * 法定代表人说明函 + */ + @SerializedName("authorize_letter_copy") + private String authorizeLetterCopy; + + /** + * 证件姓名 + * 1、当证件持有人类型为法人时,请填写法人证件上的姓名。其他情况,无需上传。 + * 2、长度为2-100个字符 + * 3、前后不能有空格、制表符、换行符 + * 4、不能仅含数字、特殊字符 + * 5、仅能填写数字、英文字母、汉字及特殊字符 + * 6、该字段需进行加密处理,加密方法详见《敏感信息加密说明》 + * 示例值:pVd1HJ6zyvPedzGaV+X3IdGdbDnuC4Eelw/wDa4SzfeespQO/0kjiwfqdfg== + */ + @SerializedName("identification_name") + @SpecEncrypt + private String identificationName; + + /** + * 证件号码 + * 1、当证件持有人类型为法人时,请填写法人证件上的证件号码。其他情况,无需上传。 + * 2、可传身份证、来往内地通行证、来往大陆通行证、护照等证件号码,号码规范如下: + * 身份证(限中国大陆居民):17位数字+1位数字|X + * 护照(限境外人士):4-15位 数字|字母|连字符 + * 中国香港居民--来往内地通行证:H/h开头+8或10位数字/字母 + * 中国澳门居民--来往内地通行证:M/m开头+8或10位数字/字母 + * 中国台湾居民--来往大陆通行证:8位数字或10位数字 + * 外国人居留证:15位 数字|字母 + * 港澳居住证/台湾居住证:17位数字+1位数字|X + * 3、该字段需进行加密处理,加密方法详见《敏感信息加密说明》 + * 示例值:pVd1HJ6zmty7/mYNxLMpRSvMRtelw/wDa4SzfeespQO/0kjiwfqdfg== + */ + @SerializedName("identification_number") + @SpecEncrypt + private String identificationNumber; + + /** + * 证件有效日期 + * 1、日期格式应满足合法的YYYY-MM-DD格式,参见示例值 + * 2、若证件有效期为长期,请填写:fovever。 + * 3、开始时间不能大于等于当前日期,结束时间需大于开始时间。 + * 示例值:[\"2017-10-28\",\"forever\"] + */ + @SerializedName("identification_valid_date") + private String identificationValidDate; + + /** + * 证件有效日期 + * 1、主体类型为企业时,需要填写。其他主体类型,无需上传。 + * 2、请按照身份证住址填写,如广东省深圳市南山区xx路xx号xx室 + * 3、长度为4-128个字符 + * 4、前后不能有空格、制表符、换行符 + * 5、不能仅含数字、特殊字符 + * 6、仅能填写数字、英文字母、汉字及特殊字符 + * 7、仅支持utf-8格式 + * 8、该字段需进行加密处理,加密方法详见《敏感信息加密说明》。 + * 示例值:pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPROvwia4ib0NVa8MRtelw/wDa4SzfeespQO/0kjiwfqdfg== + */ + @SerializedName("identification_address") + @SpecEncrypt + private String identificationAddress; + + + /** + * 证件正面照片 + */ + @SerializedName("identification_front_copy") + private String identificationFrontCopy; + + /** + * 证件反面照片 + */ + @SerializedName("identification_back_copy") + private String identificationBackCopy; + + /** + * 经营者/法人是否为受益人 + */ + @SerializedName("owner") + private Boolean owner; + + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmUboInfo implements Serializable { + private static final long serialVersionUID = 7918585690831975042L; + /** + * 证件类型 + */ + @SerializedName("ubo_id_doc_type") + private IdTypeEnum uboIdDocType; + /** + * 证件正面照片 + */ + @SerializedName("ubo_id_doc_copy") + private String uboIdDocCopy; + /** + * 证件反面照片 + */ + @SerializedName("ubo_id_doc_copy_back") + private String uboIdDocCopyBack; + /** + * 证件姓名 + */ + @SerializedName("ubo_id_doc_name") + @SpecEncrypt + private String uboIdDocName; + /** + * 证件号码 + */ + @SerializedName("ubo_id_doc_number") + @SpecEncrypt + private String uboIdDocNumber; + /** + * 证件居住地址 + */ + @SerializedName("ubo_id_doc_address") + @SpecEncrypt + private String uboIdDocAddress; + /** + * 证件有效期开始时间 + */ + @SerializedName("ubo_period_begin") + private String uboPeriodBegin; + /** + * 证件有效期结束时间 + */ + @SerializedName("ubo_period_end") + private String uboPeriodEnd; + } + + + /** + * 超级管理员需在开户后进行签约,并接收日常重要管理信息和进行资金操作,请确定其为商户法定代表人或负责人。 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmContactInfo implements Serializable { + + private static final long serialVersionUID = -480297586102445959L; + /** + * 联系人类型 + * 1、主体为“小微/个人卖家 ”,可选择: + * LEGAL:经营者/法人。 + * 2、主体为“个体工商户/企业/政府机关/事业单位/社会组织”,可选择: + * LEGAL:经营者/法人、 + * SUPER:经办人。 (经办人:经商户授权办理微信支付业务的人员)。 + * 示例值:LEGAL + */ + @SerializedName("contact_type") + private String contactType; + + /** + * 超级管理员姓名 + */ + @SerializedName("name") + @SpecEncrypt + private String name; + + /** + * 联系人证件类型 + * 当联系人类型是经办人时,请上传联系人证件类型。 + * 枚举值: + * IDENTIFICATION_TYPE_IDCARD:中国大陆居民-身份证 + * IDENTIFICATION_TYPE_OVERSEA_PASSPORT:其他国家或地区居民-护照 + * IDENTIFICATION_TYPE_HONGKONG_PASSPORT:中国香港居民-来往内地通行证 + * IDENTIFICATION_TYPE_MACAO_PASSPORT:中国澳门居民-来往内地通行证 + * IDENTIFICATION_TYPE_TAIWAN_PASSPORT:中国台湾居民-来往大陆通行证 + * IDENTIFICATION_TYPE_FOREIGN_RESIDENT:外国人居留证 + * IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT:港澳居民证 + * IDENTIFICATION_TYPE_TAIWAN_RESIDENT:台湾居民证 + * 示例值:IDENTIFICATION_TYPE_IDCARD + */ + @SerializedName("contact_id_doc_type") + private String contactIdDocType; + + /** + * 联系人证件号码 + * 1、若联系人类型为法人,则该身份证号码需与法人身份证号码一致。若联系人类型为经办人,则可填写实际经办人的身份证号码。 + * 2、可传身份证、来往内地通行证、来往大陆通行证、护照等证件号码,规范如下: + * 身份证(限中国大陆居民):17位数字+1位数字|X + * 护照(限境外人士):4-15位 数字|字母|连字符 + * 中国香港居民--来往内地通行证:H/h开头+8或10位数字/字母 + * 中国澳门居民--来往内地通行证:M/m开头+8或10位数字/字母 + * 中国台湾居民--来往大陆通行证:8位数字或10位数字 + * 外国人居留证:15位 数字|字母 + * 港澳居住证/台湾居住证:17位数字+1位数字|X + * 3、联系人签约时,校验微信号绑定的银行卡实名信息,是否与该证件号码一致。 + * 4、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) + * 示例值:pVd1HJ6zmty7/mYNxLMpRSvMRtelw/wDa4SzfeespQO/0kjiwfqdfg== + */ + @SerializedName("id_card_number") + @SpecEncrypt + private String contactIdNumber; + + /** + * 联系人证件正面照片 + * 1、当联系人类型是经办人时,请上传联系人证件的正面照片。 + * 2、若证件类型为身份证,请上传人像面照片。 + * 3、正面拍摄、清晰、四角完整、无反光或遮挡;不得翻拍、截图、镜像、PS。 + * 4、请上传彩色照片or彩色扫描件,复印件需加盖公章鲜章,可添加“微信支付”相关水印(如微信支付认证),见【指引文档】 + * 5、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。 + * 示例值:jTpGmxUXqRTvDujqhThn4ReFxikqJ5YW6zFQ + */ + @SerializedName("contact_id_doc_copy") + private String contactIdDocCopy; + + /** + * 1、当联系人类型是经办人时,请上传联系人证件的反面照片。 + * 2、若证件类型为护照,无需上传反面照片。 + * 3、正面拍摄、清晰、四角完整、无反光或遮挡;不得翻拍、截图、镜像、PS。 + * 4、请上传彩色照片or彩色扫描件,复印件需加盖公章鲜章,可添加“微信支付”相关水印(如微信支付认证),见【指引文档】 + * 5、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。 + * 示例值:jTpGmxUX3FBWVQ5NJTZvvDujqhThn4ReFxikqJ5YW6zFQ + */ + @SerializedName("contact_id_doc_copy_back") + private String contactIdDocCopyBack; + + /** + * 联系人证件有效期开始时间 + * 1、当超级管理员类型是经办人时,请上传证件有效期开始时间。 + * 2、请按照示例值填写,日期格式应满足合法的YYYY-MM-DD格式 + * 3、开始时间不能小于1900-01-01,开始时间不能大于等于当前日期。 + * 示例值:2019-06-06 + */ + @SerializedName("contact_period_begin") + private String contactPeriodBegin; + + /** + * 联系人证件有效期结束时间 + * 1、当超级管理员类型是经办人时,请上传证件有效期结束时间。 + * 2、请按照示例值填写,日期格式应满足合法的YYYY-MM-DD格式,若证件有效期为长期,请填写:长期。 + * 3、结束时间大于开始时间。 + * 示例值:2026-06-06 + */ + @SerializedName("contact_period_end") + private String contactPeriodEnd; + + + /** + * 联系人手机号 + * 1、11位数字。 + * 2、用于接收微信支付的重要管理信息及日常操作验证码。 + */ + @SerializedName("mobile") + @SpecEncrypt + private String mobile; + + } + + /** + * 主体资料 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmSubjectInfo implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主体类型 + * 主体类型需与营业执照/登记证书上一致,可参考选择主体指引。 + * SUBJECT_TYPE_ENTERPRISE:企业 + * SUBJECT_TYPE_INSTITUTIONS_CLONED:事业单位 + * SUBJECT_TYPE_INDIVIDUAL:个体工商户 + * SUBJECT_TYPE_OTHERS:社会组织 + * SUBJECT_TYPE_MICRO:小微商户 + * SUBJECT_TYPE_GOVERNMENT:政府机关 + * 示例值:SUBJECT_TYPE_ENTERPRISE + */ + @SerializedName("subject_type") + private SubjectTypeEnum subjectType; + + /** + * 是否是金融机构 + * 选填,请根据申请主体的实际情况填写,可参考选择金融机构指引: + * 1、若商户主体是金融机构,则填写:true。 + * 2、若商户主体不是金融机构,则填写:false。 + * 若未传入将默认填写:false。 + * 示例值:true + */ + @SerializedName("finance_institution") + private Boolean financeInstitution; + + /** + * 营业执照 + */ + @SerializedName("business_license_info") + private ApplySubConfirmBusinessLicenseInfo businessLicenseInfo; + /** + * 登记证书 + */ + @SerializedName("certificate_info") + private ApplySubConfirmCertificateInfo certificateInfo; + + /** + * 单位证明函照片 + * 1、主体类型为政府机关/事业单位时,单位证明函照片必填。 + * 2、单位证明函格式参考示例 + * 3、请填写通过《图片上传API》预先上传图片生成好的MediaID + * 示例值:0P3ng6KTIW4-Q_l2FjKLZuhHjBWoMAjmVtCz7ScmhEIThCaV-4BBgVwtNkCHO_XXqK5dE5YdOmFJBZR9FwczhJehHhAZN6BKXQPcs-VvdSo + */ + @SerializedName("company_prove_copy") + private String companyProveCopy; + + /** + * 辅助证明材料信息 + * 主体类型为小微商户时,辅助证明材料信息必填 + */ + @SerializedName("assist_prove_info") + private ApplySubConfirmAssistProveInfo assistProveInfo; + + /** + * 经营许可证 + */ + @SerializedName("special_operation_list") + private List specialOperationList; + + /** + * 金融机构许可证信息 + */ + @SerializedName("finance_institution_info") + private ApplySubConfirmFinanceInstitutionInfo financeInstitutionInfo; + + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmBusinessLicenseInfo implements Serializable { + private static final long serialVersionUID = -1016615300418945838L; + /** + * 注册号/统一社会信用代码 + * 1、主体为“个体工商户”时,请填写营业执照上的注册号/统一社会信用代码,格式需满足以下任一条件: + * -15位数字 + * -18位阿拉伯数字或大写英文字母(不得包含英文字母I/O/Z/S/V),并且以9开头 + * 2、主体为“企业”时,请填写营业执照上的注册号/统一社会信用代码,格式如下: + * -18位阿拉伯数字或大写英文字母(不得包含英文字母I/O/Z/S/V),并且以9开头 + * 示例值:914201123033363296 + */ + @SerializedName("license_number") + private String licenseNumber; + + /** + * 营业执照照片 + * 1、照片应正面拍摄、清晰、四角完整、无反光或遮挡;不得翻拍、截图、镜像、PS; + * 2、上传彩色照片、彩色扫描件,复印件需加盖公章鲜章。 + * 3、水印仅限于微信支付业务相关。 + * 4、指引与示例可参考【指引文档】 + * 5、请填写通过《图片上传API》预先上传图片生成好的MediaID + * 示例值:0P3ng6KTIW4-Q_l2FjKLZuhHjBWoMAjmVtCz7ScmhEIThCaV-4BBgVwtNkCHO_XXqK5dE5YdOmFJBZR9FwczhJehHhAZN6BKXQPcs-VvdSo + */ + @SerializedName("license_copy") + private String licenseCopy; + + /** + * 商户名称 + * 1、长度为2-128个字符 + * 2、前后不能有空格、制表符、换行符 + * 3、不能仅含数字、特殊字符 + * 4、仅能填写数字、英文字母、汉字及特殊字符 + * 5、仅支持utf-8格式 + * 6、个体户证件为以下情况时,按照个体户XXX命名(XXX是营业执照经营人姓名):营业执照登记名称为空、仅含数字、仅含特殊字符、“无”、“无字号” + * 7、个体户不能使用“企业”“公司”或“农民专业合作社”结尾 + * 示例值:李四网络有限公司 + */ + @SerializedName("merchant_name") + private String merchantName; + /** + * 法人姓名 + * 请填写营业执照的经营者/法定代表人姓名 + * 1、长度为2-100个字符 + * 2、前后不能有空格、制表符、换行符 + * 3、不能仅含特殊字符 + * 4、仅能填写数字、英文字母、汉字及特殊字符 + * 示例值:李四 + */ + @SerializedName("legal_person") + private String legalPerson; + /** + * 注册地址 + * 建议填写营业执照的注册地址 + * 1、长度为4-128个字符 + * 2、前后不能有空格、制表符、换行符 + * 3、不能仅含数字、特殊字符 + * 4、仅能填写数字、英文字母、汉字及特殊字符 + * 5、仅支持utf-8格式 + * 示例值:广东省深圳市南山区xx路xx号 + */ + @SerializedName("company_address") + private String companyAddress; + /** + * 营业执照有效日期 + * 1、日期格式应满足合法的YYYY-MM-DD格式,参见示例值 + * 2、开始时间不能小于1900-01-01 + * 3、若证件有效期为长期,请填写:fovever。 + * 4、开始时间不能大于等于当前日期,结束时间需大于开始时间。 + * 示例值:[\"2017-10-28\",\"2037-10-28\"] + * + */ + @SerializedName("licence_valid_date") + private String periodBegin; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmCertificateInfo implements Serializable { + private static final long serialVersionUID = 5080675335337916895L; + + /** + * 登记证书照片 + * 1、照片应正面拍摄、清晰、四角完整、无反光或遮挡;不得翻拍、截图、镜像、PS; + * 2、上传彩色照片、彩色扫描件,复印件需加盖公章鲜章。 + * 3、水印仅限于微信支付业务相关。 + * 4、指引与示例可参考【指引文档】 + * 5、请填写通过《图片上传API》预先上传图片生成好的MediaID + * 示例值:0P3ng6KTIW4-Q_l2FjKLZuhHjBWoMAjmVtCz7ScmhEIThCaV-4BBgVwtNkCHO_XXqK5dE5YdOmFJBZR9FwczhJehHhAZN6BKXQPcs-VvdSo + */ + @SerializedName("cert_copy") + private String certCopy; + + /** + * 登记证书类型 + * 登记证书的类型。 + * 1、主体为“政府机关/事业单位/社会组织”时,请上传登记证书类型。 + * + * 当主体为事业单位时,选择此枚举值: + * CERTIFICATE_TYPE_2388:事业单位法人证书 + * + * 当主体为政府机关,选择此枚举值: + * CERTIFICATE_TYPE_2389:统一社会信用代码证书 + * + * 当主体为社会组织,选择以下枚举值之一: + * CERTIFICATE_TYPE_2389:统一社会信用代码证书 + * CERTIFICATE_TYPE_2394:社会团体法人登记证书 + * CERTIFICATE_TYPE_2395:民办非企业单位登记证书 + * CERTIFICATE_TYPE_2396:基金会法人登记证书 + * CERTIFICATE_TYPE_2520:执业许可证/执业证 + * CERTIFICATE_TYPE_2521:基层群众性自治组织特别法人统一社会信用代码证 + * CERTIFICATE_TYPE_2522:农村集体经济组织登记证 + * CERTIFICATE_TYPE_2399:宗教活动场所登记证 + * CERTIFICATE_TYPE_2400:政府部门下发的其他有效证明文件 + * 示例值:CERTIFICATE_TYPE_2388 + */ + @SerializedName("cert_type") + private CertTypeEnum certType; + + + /** + * 证书号 + * 请输入与所选证书类型相匹配且符合国家标准规范的证书号,其中除政府证明文件外,需满足18位阿拉伯数字或大写英文字母(不得包含英文字母I/O/Z/S/V) + * 示例值:111111111111 + */ + @SerializedName("cert_number") + private String certNumber; + + + /** + * 商户名称 + * 请填写登记证书上的商户名称 + * 1、长度为2-128个字符 + * 2、前后不能有空格、制表符、换行符 + * 3、不能仅含数字、特殊字符 + * 4、仅能填写数字、英文字母、汉字及特殊字符 + * 5、仅支持utf-8格式 + * 示例值:xx公益团体 + */ + @SerializedName("merchant_name") + private String merchantName; + + + /** + * 注册地址 + */ + @SerializedName("company_address") + private String companyAddress; + + + /** + * 法人姓名 + * 请填写登记证书上的法定代表人姓名 + * 1、长度为2-100个字符 + * 2、前后不能有空格、制表符、换行符 + * 3、不能仅含特殊字符 + * 4、仅能填写数字、英文字母、汉字及特殊字符 + * 示例值:李四 + */ + @SerializedName("legal_person") + private String legalPerson; + + + /** + * 证书有效日期 + * 1、日期格式应满足合法的YYYY-MM-DD格式,参见示例值 + * 2、若证件有效期为长期,请填写:fovever。 + * 3、开始时间不能大于等于当前日期,结束时间需大于开始时间。 + * 示例值:["2017-10-28","2037-10-28"] + */ + @SerializedName("cert_valid_date") + private String certValidDate; + + } + + /** + * 辅助证明材料信息 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmAssistProveInfo implements Serializable { + + private static final long serialVersionUID = -3394274542660805766L; + /** + * 小微经营类型 + * MICRO_TYPE_STORE:门店场所 + * MICRO_TYPE_MOBILE:流动经营/便民服务 + * MICRO_TYPE_ONLINE:线上商品/服务交易 + * 示例值:MICRO_TYPE_STORE + */ + @SerializedName("micro_biz_type") + private String microBizType; + /** + * 门店名称 + * 1、填写规范: + * 门店场所:填写门店名称 + * 流动经营/便民服务:填写经营/服务名称 + * 线上商品/服务交易:填写线上店铺名称 + * 2、格式规范: + * 长度为1-50个字符 + * 前后不能有空格、制表符、换行符 + * 不能仅含数字、特殊字符 + * 仅能填写数字、英文字母、汉字及特殊字符 + * 仅支持utf-8格式 + * 示例值:大郎烧饼 + */ + @SerializedName("store_name") + private String storeName; + /** + * 门店省市编码 + * 1、只能由数字组成 + * 2、详细参见微信支付提供的省市对照表 + * 3、填写规范: + * 门店场所:填写门店省市编码 + * 流动经营/便民服务:填写经营/服务所在地省市编码 + * 线上商品/服务交易:填写卖家所在地省市编码 + * 示例值:440305 + */ + @SerializedName("store_address_code") + private String storeAddressCode; + /** + * 门店地址 + * 1、填写规范: + * 门店场所:填写店铺详细地址,具体区/县及街道门牌号或大厦楼层 + * 流动经营/便民服务:填写“无” + * 线上商品/服务交易:填写电商平台名称 + * 2、格式规范: + * 长度为4-512个字符 + * 前后不能有空格、制表符、换行符 + * 不能仅含数字、特殊字符 + * 仅能填写数字、英文字母、汉字及特殊字符 + * 仅支持utf-8格式 + * 示例值:广东省深圳市南山区xx大厦x层xxxx室 + */ + @SerializedName("store_address") + private String storeAddress; + /** + * 门店门头照片 + * 1、请上传门头正面照片(要求门店招牌、门框完整、清晰、可辨识);若为停车场等无固定门头照片的经营场所,可上传岗亭/出入闸口。具体参考【指引文档】; + * 2、请填写通过《图片上传API》预先上传图片生成好的MediaID + * 示例值:0P3ng6KTIW4-Q_l2FjKLZuhHjBWoMAjmVtCz7ScmhEIThCaV-4BBgVwtNkCHO_XXqK5dE5YdOmFJBZR9FwczhJehHhAZN6BKXQPcs-VvdSo + */ + @SerializedName("store_header_copy") + private String storeHeaderCopy; + /** + * 店内环境照片 + * 1、请上传门店内部环境照片(可辨识经营内容)。若为停车场等无固定门头的经营场所,可上传停车场内部照片。具体参考【指引文档】; + * 2、请填写通过《图片上传API》预先上传图片生成好的MediaID + * 示例值:0P3ng6KTIW4-Q_l2FjKLZuhHjBWoMAjmVtCz7ScmhEIThCaV-4BBgVwtNkCHO_XXqK5dE5YdOmFJBZR9FwczhJehHhAZN6BKXQPcs-VvdSo + */ + @SerializedName("store_indoor_copy") + private String storeIndoorCopy; + + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmSpecialOperationList implements Serializable { + + private static final long serialVersionUID = 6016563999835704297L; + /** + * 行业类目id + * 参看微信支付提供的特殊行业id对照表 + * 示例值:100 + */ + @SerializedName("finance_type") + private Integer financeType; + + /** + * 行业经营许可证资质照片 + * 1、请根据特殊行业id对照表内指引,仅当所选择的行业为【必填经营许可证】的行业时,才需上传该项资料 + * 2、请填写通过《图片上传API》预先上传图片生成好的MediaID + * 3、每个行业最多支持5张资质照片 + * 示例值:0P3ng6KTIW4-Q_l2FjKLZuhHjBWoMAjmVtCz7ScmhEIThCaV-4BBgVwtNkCHO_XXqK5dE5YdOmFJBZR9FwczhJehHhAZN6BKXQPcs-VvdSo + */ + @SerializedName("operation_copy_list") + private List financeLicensePics; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmFinanceInstitutionInfo implements Serializable { + + private static final long serialVersionUID = 6016563999835704297L; + /** + * 金融机构类型 + * + * @see FinanceTypeEnum + */ + @SerializedName("finance_type") + private FinanceTypeEnum financeType; + + /** + * 金融机构许可证图片 + */ + @SerializedName("finance_license_pics") + private List financeLicensePics; + } + + + + + } + + + /** + * 补充材料 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class ApplySubConfirmAdditionInfo implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 法人开户承诺函 + */ + @SerializedName("legal_person_commitment") + private String legalPersonCommitment; + + /** + * 法人开户意愿视频 + */ + @SerializedName("legal_person_video") + private String legalPersonVideo; + + /** + * 补充材料 + */ + @SerializedName("business_addition_pics") + private List businessAdditionPics; + + /** + * 补充说明 + */ + @SerializedName("business_addition_msg") + private String businessAdditionMsg; + + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmCreateResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmCreateResult.java new file mode 100644 index 0000000000..5fc4930d29 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmCreateResult.java @@ -0,0 +1,31 @@ +package com.github.binarywang.wxpay.bean.applyconfirm; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +/** + * 间连商户开户意愿确认 提交申请结果响应 + * + * @author Mr.Pan + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class ApplySubjectConfirmCreateResult implements Serializable { + + private static final long serialVersionUID = 6171290256346697399L; + /** + * 微信支付申请单号 + */ + @SerializedName("applyment_id") + private String applymentId; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmMerchantStateQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmMerchantStateQueryResult.java new file mode 100644 index 0000000000..c155e1e6cd --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmMerchantStateQueryResult.java @@ -0,0 +1,30 @@ +package com.github.binarywang.wxpay.bean.applyconfirm; + +import com.github.binarywang.wxpay.bean.applyconfirm.enums.AuthorizeStateEnum; +import com.github.binarywang.wxpay.bean.applyment.enums.ApplymentStateEnum; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + *获取商户开户意愿确认状态返回对象信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class ApplySubjectConfirmMerchantStateQueryResult implements Serializable { + private static final long serialVersionUID = 3842134912775708112L; + + /** + * 授权状态 + */ + @SerializedName("authorize_state") + private AuthorizeStateEnum applymentState; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmStateQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmStateQueryResult.java new file mode 100644 index 0000000000..77ee4c51eb --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/ApplySubjectConfirmStateQueryResult.java @@ -0,0 +1,45 @@ +package com.github.binarywang.wxpay.bean.applyconfirm; + +import com.github.binarywang.wxpay.bean.applyment.enums.ApplymentStateEnum; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 查询申请单状态返回对象信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class ApplySubjectConfirmStateQueryResult implements Serializable { + private static final long serialVersionUID = 3842134912775708112L; + + /** + * 申请单状态 + */ + @SerializedName("applyment_state") + private ApplymentStateEnum applymentState; + /** + * 二维码图片 + */ + @SerializedName("qrcode_data") + private String qrcodeData; + /** + * 驳回参数 + */ + @SerializedName("reject_param") + private String rejectParam; + /** + * 驳回原因 + */ + @SerializedName("reject_reason") + private String rejectReason; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/enums/AuthorizeStateEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/enums/AuthorizeStateEnum.java new file mode 100644 index 0000000000..10542ce705 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyconfirm/enums/AuthorizeStateEnum.java @@ -0,0 +1,18 @@ +package com.github.binarywang.wxpay.bean.applyconfirm.enums; + + +/** + * 授权状态枚举类 + */ +public enum AuthorizeStateEnum { + /** + * 未授权 + */ + AUTHORIZE_STATE_UNAUTHORIZED, + + /** + * 已授权 + */ + AUTHORIZE_STATE_AUTHORIZED, + ; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/ModifySettlementRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/ModifySettlementRequest.java index 8623b5cd67..e374d952a6 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/ModifySettlementRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/ModifySettlementRequest.java @@ -26,6 +26,12 @@ public class ModifySettlementRequest implements Serializable { */ @SerializedName("account_type") private AccountTypeEnum accountType; + /** + * 开户名称 + */ + @SpecEncrypt + @SerializedName("account_name") + private String accountName; /** * 开户银行 */ diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementApplicationResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementApplicationResult.java new file mode 100644 index 0000000000..95b5f4d2c0 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementApplicationResult.java @@ -0,0 +1,76 @@ +package com.github.binarywang.wxpay.bean.applyment; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 查询结算账户修改申请状态 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class SettlementApplicationResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 开户名称 + */ + @SerializedName("account_name") + private String accountName; + + /** + * 账户类型 + */ + @SerializedName("account_type") + private String accountType; + + /** + * 开户银行 + */ + @SerializedName("account_bank") + private String accountBank; + + /** + * 开户银行全称(含支行) + */ + @SerializedName("bank_name") + private String bankName; + + /** + * 开户银行联行号 + */ + @SerializedName("bank_branch_id") + private String bankBranchId; + + /** + * 银行账号 + */ + @SerializedName("account_number") + private String accountNumber; + + /** + * 审核状态 + */ + @SerializedName("verify_result") + private String verifyResult; + + /** + * 审核驳回原因 + */ + @SerializedName("verify_fail_reason") + private String verifyFailReason; + + /** + * 审核结果更新时间 + */ + @SerializedName("verify_finish_time") + private String verifyFinishTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java index ffa3bf73e7..6c490a929a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java @@ -11,6 +11,8 @@ /** * 查询结算账户返回对象信息 + * + * @see 查询结算账户 */ @Data @Builder @@ -51,4 +53,12 @@ public class SettlementInfoResult implements Serializable { */ @SerializedName("verify_result") private String verifyResult; + /** + * 汇款验证失败原因 + * + * @since 4.4.0 + * @date 2022.12.09 + */ + @SerializedName("verify_fail_reason") + private String verifyFailReason; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementModifyStateQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementModifyStateQueryResult.java new file mode 100644 index 0000000000..41da7fee76 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementModifyStateQueryResult.java @@ -0,0 +1,80 @@ +package com.github.binarywang.wxpay.bean.applyment; + +import com.github.binarywang.wxpay.bean.applyment.enums.AccountTypeEnum; +import com.github.binarywang.wxpay.bean.applyment.enums.SettlementVerifyStateEnum; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + + +import java.io.Serializable; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class SettlementModifyStateQueryResult implements Serializable { + + private static final long serialVersionUID = 464614116838248296L; + /** + * 开户名称 + */ + @SerializedName("account_name") + private String accountName; + + /** + * 账户类型 + */ + @SerializedName("account_type") + private AccountTypeEnum accountType; + + /** + * 开户银行 + */ + @SerializedName("account_bank") + private String accountBank; + + /** + * 开户银行全称(含支行) + */ + @SerializedName("bank_name") + private String bankName; + + /** + * 开户银行联行号 + */ + @SerializedName("bank_branch_id") + private String bankBranchId; + + /** + * 银行账号 + */ + @SerializedName("account_number") + private String accountNumber; + + /** + * 审核状态 + * @see SettlementVerifyStateEnum + */ + @SerializedName("verify_result") + private SettlementVerifyStateEnum verifyResult; + + /** + * 审核驳回原因 + */ + @SerializedName("verify_fail_reason") + private String verifyFailReason; + + /** + * 审核结果更新时间 + */ + @SerializedName("verify_finish_time") + private String verifyFinishTime; + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/WxPayApplyment4SubCreateRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/WxPayApplyment4SubCreateRequest.java index fe956af236..c204e2911e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/WxPayApplyment4SubCreateRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/WxPayApplyment4SubCreateRequest.java @@ -64,7 +64,7 @@ public class WxPayApplyment4SubCreateRequest implements Serializable { private BankAccountInfo bankAccountInfo; /** - * 结算银行账户 + * 补充材料 */ @SerializedName("addition_info") private AdditionInfo additionInfo; @@ -80,6 +80,17 @@ public class WxPayApplyment4SubCreateRequest implements Serializable { public static class ContactInfo implements Serializable { private static final long serialVersionUID = 1L; + /** + * 超级管理员类型 + * 1、主体为“个体工商户/企业/政府机关/事业单位/社会组织”,可选择:LEGAL:经营者/法人,SUPER:经办人 。(经办人:经商户授权办理微信支付业务的人员)。 + * 枚举值: + * LEGAL:经营者/法人 + * SUPER:经办人 + * 示例值:LEGAL + */ + @SerializedName("contact_type") + private String contactType; + /** * 超级管理员姓名 */ @@ -87,6 +98,22 @@ public static class ContactInfo implements Serializable { @SpecEncrypt private String contactName; + /** + * 超级管理员证件类型 + * 当超级管理员类型是经办人时,请上传超级管理员证件类型。 + * IDENTIFICATION_TYPE_IDCARD:中国大陆居民-身份证 + * IDENTIFICATION_TYPE_OVERSEA_PASSPORT:其他国家或地区居民-护照 + * IDENTIFICATION_TYPE_HONGKONG_PASSPORT:中国香港居民-来往内地通行证 + * IDENTIFICATION_TYPE_MACAO_PASSPORT:中国澳门居民-来往内地通行证 + * IDENTIFICATION_TYPE_TAIWAN_PASSPORT:中国台湾居民-来往大陆通行证 + * IDENTIFICATION_TYPE_FOREIGN_RESIDENT:外国人居留证 + * IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT:港澳居民证 + * IDENTIFICATION_TYPE_TAIWAN_RESIDENT:台湾居民证 + * 示例值:IDENTIFICATION_TYPE_IDCARD + */ + @SerializedName("contact_id_doc_type") + private String contactIdDocType; + /** * 超级管理员身份证件号码 * 1、“超级管理员身份证号码”与“超级管理员微信openid”,二选一必填。 @@ -97,6 +124,58 @@ public static class ContactInfo implements Serializable { @SpecEncrypt private String contactIdNumber; + /** + * 超级管理员证件正面照片 + * 1、当超级管理员类型是经办人时,请上传超级管理员证件的正面照片。 + * 2、若证件类型为身份证,请上传人像面照片。 + * 3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。 + * 4、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。 + * 示例值:jTpGmxUXqRTvDujqhThn4ReFxikqJ5YW6zFQ + */ + @SerializedName("contact_id_doc_copy") + private String contactIdDocCopy; + + /** + * 超级管理员证件反面照片 + * 1、当超级管理员类型是经办人时,请上传超级管理员证件的反面照片。 + * 2、若证件类型为护照,无需上传反面照片。 + * 3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。 + * 4、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。 + * 示例值:jTpGmxUX3FBWVQ5NJTZvvDujqhThn4ReFxikqJ5YW6zFQ + */ + @SerializedName("contact_id_doc_copy_back") + private String contactIdDocCopyBack; + + /** + * 超级管理员证件有效期开始时间 + * 1、当超级管理员类型是经办人时,请上传证件有效期开始时间。 + * 2、请按照示例值填写。 + * 3、结束时间大于开始时间。 + * 示例值:2019-06-06 + */ + @SerializedName("contact_period_begin") + private String contactPeriodBegin; + + /** + * 超级管理员证件有效期结束时间 + * 1、当超级管理员类型是经办人时,请上传证件有效期结束时间。 + * 2、请按照示例值填写,若证件有效期为长期,请填写:长期。 + * 3、结束时间大于开始时间。 + * 示例值:2026-06-06 + */ + @SerializedName("contact_period_end") + private String contactPeriodEnd; + + /** + * 业务办理授权函 + * 1、当超级管理员类型是经办人时,请上传业务办理授权函。 + * 2、请参照[示例图]打印业务办理授权函,全部信息需打印,不支持手写商户信息,并加盖公章。 + * 3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。 + * 示例值:47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4 + */ + @SerializedName("business_authorization_letter") + private String businessAuthorizationLetter; + /** * 超级管理员微信openid * 1、“超级管理员身份证件号码”与“超级管理员微信openid”,二选一必填。 @@ -140,6 +219,12 @@ public static class SubjectInfo implements Serializable { @SerializedName("subject_type") private SubjectTypeEnum subjectType; + /** + * 是否是金融机构 + */ + @SerializedName("finance_institution") + private Boolean financeInstitution; + /** * 营业执照 */ @@ -151,18 +236,18 @@ public static class SubjectInfo implements Serializable { @SerializedName("certificate_info") private CertificateInfo certificateInfo; - /** - * 组织机构代码证 - */ - @SerializedName("organization_info") - private OrganizationInfo organizationInfo; - /** * 单位证明函照片 */ @SerializedName("certificate_letter_copy") private String certificateLetterCopy; + /** + * 金融机构许可证信息 + */ + @SerializedName("finance_institution_info") + private FinanceInstitutionInfo financeInstitutionInfo; + /** * 经营者/法人身份证件 */ @@ -171,17 +256,11 @@ public static class SubjectInfo implements Serializable { private IdentityInfo identityInfo; /** - * 最终受益人信息(UBO] + * 最终受益人信息列表(UBO) */ - @SerializedName("ubo_info") + @SerializedName("ubo_info_list") @SpecEncrypt - private UboInfo uboInfo; - - /** - * 小微辅助证明材料(subjectType为小微商户时必填) - */ - @SerializedName("micro_biz_info") - private MicroBizInfo microBizInfo; + private List uboInfoList; @Data @Builder @@ -210,6 +289,21 @@ public static class BusinessLicenseInfo implements Serializable { */ @SerializedName("legal_person") private String legalPerson; + /** + * 注册地址 + */ + @SerializedName("license_address") + private String licenseAddress; + /** + * 有效期限开始日期 + */ + @SerializedName("period_begin") + private String periodBegin; + /** + * 有效期限结束日期 + */ + @SerializedName("period_end") + private String periodEnd; } @Data @@ -255,7 +349,7 @@ public static class CertificateInfo implements Serializable { /** - * 法人姓名 + * 法定代表人 */ @SerializedName("legal_person") private String legalPerson; @@ -281,29 +375,22 @@ public static class CertificateInfo implements Serializable { @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) - public static class OrganizationInfo implements Serializable { - private static final long serialVersionUID = 6497045652770046337L; - /** - * 组织机构代码证照片 - */ - @SerializedName("organization_copy") - private String organizationCopy; - /** - * 组织机构代码 - */ - @SerializedName("organization_code") - private String organizationCode; + public static class FinanceInstitutionInfo implements Serializable { + + private static final long serialVersionUID = 6016563999835704297L; /** - * 组织机构代码证有效期开始日期 + * 金融机构类型 + * + * @see FinanceTypeEnum */ - @SerializedName("org_period_begin") - private String orgPeriodBegin; + @SerializedName("finance_type") + private FinanceTypeEnum financeType; + /** - * 组织机构代码证有效期结束日期 + * 金融机构许可证图片 */ - @SerializedName("org_period_end") - private String orgPeriodEnd; - + @SerializedName("finance_license_pics") + private List financeLicensePics; } @Data @@ -314,12 +401,28 @@ public static class OrganizationInfo implements Serializable { public static class IdentityInfo implements Serializable { private static final long serialVersionUID = 1683704338370383827L; + /** + * 证件持有人类型 + * LEGAL:法人 + * SUPER:经办人 + * 示例值:LEGAL + * @see com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest 字段idHolderType + */ + @SerializedName("id_holder_type") + private String idHolderType; + /** * 证件类型 */ @SerializedName("id_doc_type") private IdTypeEnum idDocType; + /** + * 法定代表人说明函 + */ + @SerializedName("authorize_letter_copy") + private String authorizeLetterCopy; + /** * 身份证信息 */ @@ -338,7 +441,7 @@ public static class IdentityInfo implements Serializable { * 经营者/法人是否为受益人 */ @SerializedName("owner") - private boolean owner; + private Boolean owner; @Data @Builder @@ -357,7 +460,6 @@ public static class IdCardInfo implements Serializable { */ @SerializedName("id_card_national") private String idCardNational; - /** * 身份证姓名 */ @@ -370,6 +472,12 @@ public static class IdCardInfo implements Serializable { @SerializedName("id_card_number") @SpecEncrypt private String idCardNumber; + /** + * 身份证居住地址 + */ + @SerializedName("id_card_address") + @SpecEncrypt + private String idCardAddress; /** * 身份证有效期开始时间 */ @@ -391,10 +499,15 @@ public static class IdCardInfo implements Serializable { public static class IdDocInfo implements Serializable { private static final long serialVersionUID = 7335589815924447719L; /** - * 证件照片 + * 证件正面照片 */ @SerializedName("id_doc_copy") private String idDocCopy; + /** + * 证件反面照片 + */ + @SerializedName("id_doc_copy_back") + private String idDocCopyBack; /** * 证件姓名 @@ -409,6 +522,12 @@ public static class IdDocInfo implements Serializable { @SerializedName("id_doc_number") @SpecEncrypt private String idDocNumber; + /** + * 证件居住地址 + */ + @SerializedName("id_doc_address") + @SpecEncrypt + private String idDocAddress; /** * 证件有效期开始时间 */ @@ -432,218 +551,46 @@ public static class UboInfo implements Serializable { /** * 证件类型 */ - @SerializedName("id_type") - private IdTypeEnum idType; + @SerializedName("ubo_id_doc_type") + private IdTypeEnum uboIdDocType; /** - * 身份证人像面照片 + * 证件正面照片 */ - @SerializedName("id_card_copy") - private String idCardCopy; + @SerializedName("ubo_id_doc_copy") + private String uboIdDocCopy; /** - * 身份证国徽面照片 + * 证件反面照片 */ - @SerializedName("id_card_national") - private String idCardNational; + @SerializedName("ubo_id_doc_copy_back") + private String uboIdDocCopyBack; /** - * 证件照片 + * 证件姓名 */ - @SerializedName("id_doc_copy") - private String idDocCopy; + @SerializedName("ubo_id_doc_name") + @SpecEncrypt + private String uboIdDocName; /** - * 受益人姓名 + * 证件号码 */ - @SerializedName("name") + @SerializedName("ubo_id_doc_number") @SpecEncrypt - private String name; + private String uboIdDocNumber; /** - * 证件号码 + * 证件居住地址 */ - @SerializedName("id_number") + @SerializedName("ubo_id_doc_address") @SpecEncrypt - private String idNumber; + private String uboIdDocAddress; /** * 证件有效期开始时间 */ - @SerializedName("id_period_begin") - private String idPeriodBegin; + @SerializedName("ubo_period_begin") + private String uboPeriodBegin; /** * 证件有效期结束时间 */ - @SerializedName("id_period_end") - private String idPeriodEnd; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Accessors(chain = true) - public static class MicroBizInfo implements Serializable { - private static final long serialVersionUID = -5679477993681265764L; - /** - * 小微经营类型 - */ - @SerializedName("micro_biz_type") - private MicroBizTypeEnum microBizType; - - /** - * 门店场所---经营类型为“门店场所”时填写 - */ - @SerializedName("micro_store_info") - private MicroStoreInfo microStoreInfo; - - /** - * 经营类型为“流动经营/便民服务”时填写 - */ - @SerializedName("micro_mobile_info") - private MicroMobileInfo microMobileInfo; - - /** - * 经营类型为“线上商品/服务交易”时填写 - */ - @SerializedName("micro_online_info") - private MicroOnlineInfo microOnlineInfo; - - /** - * 门店场所 - */ - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Accessors(chain = true) - public static class MicroStoreInfo implements Serializable { - private static final long serialVersionUID = 5277440587305558389L; - /** - * 门店名称 - */ - @SerializedName("micro_name") - private String microName; - /** - * 门店省市编码 填写门店省市编码,只能由数字组成,详细参见《微信支付提供的省市对照表》 - * - * @see 下载微信支付提供的省市对照表 - */ - @SerializedName("micro_address_code") - private String microAddressCode; - /** - * 门店地址(填写店铺详细地址,具体区/县及街道门牌号或大厦楼层) - */ - @SerializedName("micro_address") - private String microAddress; - /** - * 门店门头照片 - * - * 1、提交门店门口照片,要求招牌清晰可见 - * 2、可上传1张图片,请填写通过《图片上传API》预先上传图片生成好的MediaID - * - * - * @see 图片上传API - */ - @SerializedName("store_entrance_pic") - private String storeEntrancePic; - /** - * 店内环境照片 - * - * 1、提交店内环境照片 - * 2、可上传1张图片,请填写通过《图片上传API》预先上传图片生成好的MediaID - * - * - * @see 图片上传API - */ - @SerializedName("micro_indoor_copy") - private String microIndoorCopy; - /** - * 门店经度 - */ - @SerializedName("store_longitude") - private String storeLongitude; - /** - * 门店纬度 - */ - @SerializedName("store_latitude") - private String storeLatitude; - } - - /** - * 流动经营/便民服务 - */ - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Accessors(chain = true) - public static class MicroMobileInfo implements Serializable { - private static final long serialVersionUID = -1308090894511066935L; - /** - * 经营/服务名称 - */ - @SerializedName("micro_mobile_name") - private String microMobileName; - /** - * 经营/服务所在地省市 - */ - @SerializedName("micro_mobile_city") - private String microMobileCity; - /** - * 经营/服务所在地(不含省市) 填写“无" - */ - @SerializedName("micro_mobile_address") - private String microMobileAddress; - /** - * 经营/服务现场照片 - * - * 1、提交经营/服务现场照片 - * 2、可上传多张图片,请填写通过《图片上传API》预先上传图片生成好的MediaID - * - * - * @see 图片上传API - */ - @SerializedName("micro_mobile_pics") - private String microMobilePics; - } - - /** - * 线上商品/服务交易 - */ - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Accessors(chain = true) - public static class MicroOnlineInfo implements Serializable { - private static final long serialVersionUID = 9029168841403055743L; - /** - * 线上店铺名称 - */ - @SerializedName("micro_online_store") - private String microOnlineStore; - /** - * 电商平台名称 - */ - @SerializedName("micro_ec_name") - private String microEcName; - /** - * 店铺二维码 - * - * 1、店铺二维码或店铺链接二选一必填 - * 2、可上传多张图片,请填写通过《图片上传API》预先上传图片生成好的MediaID - * - * - * @see 图片上传API - */ - @SerializedName("micro_qrcode") - private String microQrcode; - /** - * 店铺二维码 - * - * 1、店铺二维码或店铺链接二选一必填 - * 2、请填写店铺主页链接,需符合网站规范 - * - */ - @SerializedName("micro_link") - private String microLink; - } + @SerializedName("ubo_period_end") + private String uboPeriodEnd; } } @@ -961,6 +908,18 @@ public static class SettlementInfo implements Serializable { @SerializedName("activities_rate") private String activitiesRate; + /** + * 非信用卡活动费率值 + */ + @SerializedName("debit_activities_rate") + private String debitActivitiesRate; + + /** + * 信用卡活动费率值 + */ + @SerializedName("credit_activities_rate") + private String creditActivitiesRate; + /** * 优惠费率活动补充材料 */ diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/CertTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/CertTypeEnum.java index f7415fdc3f..91d0c53704 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/CertTypeEnum.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/CertTypeEnum.java @@ -40,14 +40,6 @@ public enum CertTypeEnum { * 基金会法人登记证书 */ CERTIFICATE_TYPE_2396, - /** - * 慈善组织公开募捐资格证书 - */ - CERTIFICATE_TYPE_2397, - /** - * 农民专业合作社法人营业执照 - */ - CERTIFICATE_TYPE_2398, /** * 宗教活动场所登记证 */ @@ -56,5 +48,17 @@ public enum CertTypeEnum { * 其他证书/批文/证明 */ CERTIFICATE_TYPE_2400, + /** + * 执业许可证/执业证 + */ + CERTIFICATE_TYPE_2520, + /** + * 基层群众性自治组织特别法人统一社会信用代码证 + */ + CERTIFICATE_TYPE_2521, + /** + * 农村集体经济组织登记证 + */ + CERTIFICATE_TYPE_2522, ; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/FinanceTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/FinanceTypeEnum.java new file mode 100644 index 0000000000..59a2d2acd9 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/FinanceTypeEnum.java @@ -0,0 +1,33 @@ +package com.github.binarywang.wxpay.bean.applyment.enums; + +/** + * 金融机构类型 + **/ +public enum FinanceTypeEnum { + + /** + * 银行业, 适用于商业银行、政策性银行、农村合作银行、村镇银行、开发性金融机构等 + */ + BANK_AGENT, + + /** + * 支付机构, 适用于非银行类支付机构 + */ + PAYMENT_AGENT, + + /** + * 保险业, 适用于保险、保险中介、保险代理、保险经纪等保险类业务 + */ + INSURANCE, + + /** + * 交易及结算类金融机构, 适用于交易所、登记结算类机构、银行卡清算机构、资金清算中心等 + */ + TRADE_AND_SETTLE, + + /** + * 其他金融机构, 适用于财务公司、信托公司、金融资产管理公司、金融租赁公司、汽车金融公司、贷款公司、货币经纪公司、消费金融公司、证券业、金融控股公司、股票、期货、货币兑换、小额贷款公司、金融资产管理、担保公司、商业保理公司、典当行、融资租赁公司、财经咨询等其他金融业务 + */ + OTHER, + ; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/IdTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/IdTypeEnum.java index d65c502b89..ef92b1eca6 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/IdTypeEnum.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/IdTypeEnum.java @@ -3,6 +3,8 @@ /** * 个体户/企业/党政、机关及事业单位/其他组织:可选择任一证件类型。 * 枚举值 + * + * @author 叶枫 */ public enum IdTypeEnum { /** @@ -25,5 +27,17 @@ public enum IdTypeEnum { * 中国台湾居民-来往大陆通行证 */ IDENTIFICATION_TYPE_TAIWAN_PASSPORT, + /** + * 外国人居留证 + */ + IDENTIFICATION_TYPE_FOREIGN_RESIDENT, + /** + * 港澳居民证 + */ + IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT, + /** + * 台湾居民证 + */ + IDENTIFICATION_TYPE_TAIWAN_RESIDENT, ; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/SettlementVerifyStateEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/SettlementVerifyStateEnum.java new file mode 100644 index 0000000000..9ff3952adf --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/SettlementVerifyStateEnum.java @@ -0,0 +1,22 @@ +package com.github.binarywang.wxpay.bean.applyment.enums; + +/** + * 结算账户修改审核状态 + **/ +public enum SettlementVerifyStateEnum { + /** + * 审核成功 + */ + AUDIT_SUCCESS, + + /** + * 审核中 + */ + AUDITING, + + /** + * 审核驳回 + */ + AUDIT_FAIL, + ; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/SubjectTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/SubjectTypeEnum.java index 4a6c9d29e4..79950fd792 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/SubjectTypeEnum.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/enums/SubjectTypeEnum.java @@ -7,6 +7,10 @@ *
* * @author zhouyongshen + * @author 狂龙骄子 + * @since 2023.01.14 新增{@link #SUBJECT_TYPE_GOVERNMENT} + * @since 2023.09.19 移除SUBJECT_TYPE_MICRO小微主体 + * @see 服务商平台>>商户进件>>特约商户进件>>提交申请单>>请求参数>>主体资料>>主体类型 */ public enum SubjectTypeEnum { /** @@ -18,17 +22,16 @@ public enum SubjectTypeEnum { */ SUBJECT_TYPE_ENTERPRISE, /** - * (党政、机关及事业单位):包括国内各级、各类政府机构、事业单位等(如:公安、党团、司法、交通、旅游、工商税务、市政、医疗、教育、学校等机构); + * (事业单位):包括国内各类事业单位,如:医疗、教育、学校等单位; */ SUBJECT_TYPE_INSTITUTIONS, /** - * (其他组织):不属于企业、政府/事业单位的组织机构(如社会团体、民办非企业、基金会),要求机构已办理组织机构代码证。 + * (政府机关):包括各级、各类政府机关,如机关党委、税务、民政、人社、工商、商务、市监等; */ - SUBJECT_TYPE_OTHERS, + SUBJECT_TYPE_GOVERNMENT, /** - * (小微):无营业执照、免办理工商注册登记的实体商户 + * (社会组织):包括社会团体、民办非企业、基金会、基层群众性自治组织、农村集体经济组织等组织。 */ - SUBJECT_TYPE_MICRO, - ; + SUBJECT_TYPE_OTHERS, } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankAccountResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankAccountResult.java new file mode 100644 index 0000000000..5f67a2badf --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankAccountResult.java @@ -0,0 +1,30 @@ +package com.github.binarywang.wxpay.bean.bank; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 对私银行卡号开户银行信息 + * + * @author zhongjun + **/ +@Data +public class BankAccountResult implements Serializable { + + private static final long serialVersionUID = -8226859146533243501L; + + /** + * 根据卡号查询到的银行列表数据的总条数,未查询到对应银行列表时默认返回0,最大不超过两百条。 + */ + @SerializedName("total_count") + private Integer totalCount; + + @SerializedName("data") + private List data; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankBranchesResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankBranchesResult.java new file mode 100644 index 0000000000..72cc4f6a76 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankBranchesResult.java @@ -0,0 +1,176 @@ +package com.github.binarywang.wxpay.bean.bank; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 支行列表 + * + * @author hupeng + **/ +@Data +public class BankBranchesResult implements Serializable { + + private static final long serialVersionUID = -3500020131951579476L; + + /** + *
+   * 字段名:查询数据总条数
+   * 变量名:total_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  经过条件筛选,查询到的支行总数
+   *  示例值:10
+   * 
+ */ + @SerializedName("total_count") + private Integer totalCount; + + /** + *
+   * 字段名:本次查询条数
+   * 变量名:count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  本次查询到的支行数据条数
+   *  示例值:10
+   * 
+ */ + @SerializedName("count") + private Integer count; + + /** + *
+   * 字段名:支行列表
+   * 变量名:data
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  单次查询返回的支行列表结果数组
+   * 
+ */ + @SerializedName("data") + private List data; + + /** + *
+   * 字段名:本次查询偏移量
+   * 变量名:offset
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  该次请求资源的起始位置,请求中包含偏移量时应答消息返回相同偏移量,否则返回默认值0
+   *  示例值:0
+   * 
+ */ + @SerializedName("offset") + private Integer offset; + + /** + *
+   * 字段名:分页链接
+   * 变量名:offset
+   * 是否必填:是
+   * 类型:object
+   * 描述:
+   *  返回前后页和当前页面的访问链接
+   * 
+ */ + @SerializedName("links") + private PageLink links; + + /** + *
+   * 字段名:开户银行
+   * 变量名:account_bank
+   * 是否必填:是
+   * 类型:string[1, 128]
+   * 描述:
+   *  查询到的支行所属开户银行的名称,非直连银行统一为其他银行
+   *  示例值:招商银行其他银行
+   * 
+ */ + @SerializedName("account_bank") + private String accountBank; + + /** + *
+   * 字段名:开户银行编码
+   * 变量名:account_bank_code
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  查询到的支行所属开户银行的开户银行编码,可用于付款到银行卡等场景中指定银行卡的开户银行
+   *  示例值:1001
+   * 
+ */ + @SerializedName("account_bank_code") + private Integer accountBankCode; + + /** + *
+   * 字段名:银行别名
+   * 变量名:bank_alias
+   * 是否必填:是
+   * 类型:string[1, 128]
+   * 描述:
+   *  查询到的支行所属银行的银行别名
+   *  示例值:工商银行深圳前海微众银行
+   * 
+ */ + @SerializedName("bank_alias") + private String bankAlias; + + /** + *
+   * 字段名:银行别名编码
+   * 变量名:bank_alias_code
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  查询到的支行所属银行的银行别名编码,用于校验回包
+   *  示例值:1000006247
+   * 
+ */ + @SerializedName("bank_alias_code") + private String bankAliasCode; + + @Getter + @Setter + public static class BankBranch { + /** + *
+     * 字段名:开户银行支行名称
+     * 变量名:bank_branch_name
+     * 是否必填:是
+     * 类型:string[1, 128]
+     * 描述:
+     *  开户银行支行名称,用于开户银行为其他银行的情况下,在入驻、修改结算银行卡、企业付款等场景下填写结算银行卡信息。
+     *  示例值:中国工商银行上海市周浦支行
+     * 
+ */ + @SerializedName("bank_branch_name") + private String bankBranchName; + + /** + *
+     * 字段名:开户银行支行联行号
+     * 变量名:bank_branch_id
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  开户银行支行的联行号,用于开户银行为其他银行的情况下,在入驻、修改结算银行卡、企业付款等场景下填写结算银行卡信息。
+     *  示例值:102290072311
+     * 
+ */ + @SerializedName("bank_branch_id") + private String bankBranchId; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankInfo.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankInfo.java new file mode 100644 index 0000000000..89756b07d5 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankInfo.java @@ -0,0 +1,41 @@ +package com.github.binarywang.wxpay.bean.bank; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * 银行信息 + * + * @author zhongjun + * created on 2022/5/12 + **/ +@Data +public class BankInfo { + /** + * 银行别名 + */ + @SerializedName("bank_alias") + private String bankAlias; + /** + * 银行别名编码 + */ + @SerializedName("bank_alias_code") + private String bankAliasCode; + /** + * 开户银行 + */ + @SerializedName("account_bank") + private String accountBank; + /** + * 开户银行编码 + */ + @SerializedName("account_bank_code") + private Integer accountBankCode; + /** + * 是否需要填写支行 + */ + @SerializedName("need_bank_branch") + private Boolean needBankBranch; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankingResult.java new file mode 100644 index 0000000000..407ad5fc55 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/BankingResult.java @@ -0,0 +1,64 @@ +package com.github.binarywang.wxpay.bean.bank; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 个人业务的银行列表 + * + * @author zhongjun + **/ +@Data +public class BankingResult implements Serializable { + private static final long serialVersionUID = -8372812998971715894L; + + /** + * 银行列表数据的总条数,调用方需要根据总条数分页查询 + */ + @SerializedName("total_count") + private Integer totalCount; + + /** + * 本次查询银行列表返回的数据条数 + */ + @SerializedName("count") + private Integer count; + + /** + * 该次请求资源的起始位置,请求中包含偏移量时应答消息返回相同偏移量,否则返回默认值0。 + */ + @SerializedName("offset") + private Integer offset; + + @SerializedName("data") + private List data; + + @SerializedName("links") + private Link links; + + @Getter + @Setter + public static class Link { + /** + * 下一页链接 + */ + @SerializedName("next") + private String next; + /** + * 上一页链接 + */ + @SerializedName("prev") + private String prev; + /** + * 当前链接 + */ + @SerializedName("self") + private String self; + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/CitiesResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/CitiesResult.java new file mode 100644 index 0000000000..b5bf87c816 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/CitiesResult.java @@ -0,0 +1,80 @@ +package com.github.binarywang.wxpay.bean.bank; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 城市列表 + * + * @author hupeng + **/ +@Data +public class CitiesResult implements Serializable { + + private static final long serialVersionUID = -6089905695087974693L; + + /** + *
+   * 字段名:查询数据总条数
+   * 变量名:total_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  查询到的省份数据总条数
+   *  示例值:10
+   * 
+ */ + @SerializedName("total_count") + private Integer totalCount; + + /** + *
+   * 字段名:城市列表
+   * 变量名:data
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  查询返回的城市列表结果
+   * 
+ */ + @SerializedName("data") + private List data; + + @Getter + @Setter + public static class CityInfo { + /** + *
+     * 字段名:城市名称
+     * 变量名:city_name
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  城市名称
+     *  示例值:北京市
+     * 
+ */ + @SerializedName("city_name") + private String cityName; + + /** + *
+     * 字段名:城市编码
+     * 变量名:city_code
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  城市编码,唯一标识一座城市,用于结合银行别名编码查询支行列表
+     *  示例值:10
+     * 
+ */ + @SerializedName("city_code") + private Integer cityCode; + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/PageLink.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/PageLink.java new file mode 100644 index 0000000000..419cdc3c94 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/PageLink.java @@ -0,0 +1,62 @@ +package com.github.binarywang.wxpay.bean.bank; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 支行列表 + * + * @author hupeng + **/ +@Data +public class PageLink implements Serializable { + + private static final long serialVersionUID = -2624233403271204837L; + + /** + *
+   * 字段名:下一页链接
+   * 变量名:next
+   * 是否必填:否
+   * 类型:string[1, 2048]
+   * 描述:
+   *  使用同样的limit进行下一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果已经到最后时,为空
+   *  示例值:/v3/capital/capitallhh/banks/1001/branches?offset=10&limit=5
+   * 
+ */ + @SerializedName("next") + private String next; + + /** + *
+   * 字段名:上一页链接
+   * 变量名:prev
+   * 是否必填:否
+   * 类型:string[1, 2048]
+   * 描述:
+   *  使用同样的limit进行上一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果是第一页,为空
+   *  示例值:/v3/capital/capitallhh/banks/1001/branchesoffset=0&limit=5
+   * 
+ */ + @SerializedName("prev") + private String prev; + + /** + *
+   * 字段名:当前链接
+   * 变量名:self
+   * 是否必填:否
+   * 类型:string[1, 2048]
+   * 描述:
+   *  当前的相对请求链接,使用方需要自行根据当前域名进行拼接
+   *  示例值:/v3/capital/capitallhh/banks/1001/branches?offset=5&limit=5
+   * 
+ */ + @SerializedName("self") + private String self; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/ProvincesResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/ProvincesResult.java new file mode 100644 index 0000000000..6525fc1c91 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/bank/ProvincesResult.java @@ -0,0 +1,81 @@ +package com.github.binarywang.wxpay.bean.bank; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 省份列表 + * + * @author hupeng + **/ +@Data +public class ProvincesResult implements Serializable { + + private static final long serialVersionUID = -4118613374545722650L; + + /** + *
+   * 字段名:查询数据总条数
+   * 变量名:total_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  查询到的省份数据总条数
+   *  示例值:10
+   * 
+ */ + @SerializedName("total_count") + private Integer totalCount; + + /** + *
+   * 字段名:省份列表
+   * 变量名:data
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  查询到的省份列表数组
+   * 
+ */ + @SerializedName("data") + private List data; + + @Getter + @Setter + public static class ProvinceInfo { + + /** + *
+     * 字段名:省份名称
+     * 变量名:province_name
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  省份名称
+     *  示例值:广东省
+     * 
+ */ + @SerializedName("province_name") + private String provinceName; + + /** + *
+     * 字段名:省份编码
+     * 变量名:province_code
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  省份编码,唯一标识一个省份,用于根据省份编码查询省份下的城市列表数据
+     *  示例值:22
+     * 
+ */ + @SerializedName("province_code") + private Integer provinceCode; + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandMerchantBatchesQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandMerchantBatchesQueryRequest.java new file mode 100644 index 0000000000..1b6cbb48ff --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandMerchantBatchesQueryRequest.java @@ -0,0 +1,71 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 品牌红包商家批次单号查询批次单API参数 + * + * @author moran + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class BrandMerchantBatchesQueryRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:商家品牌红包批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  path商户系统内部的商家品牌红包批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:是否需要查询品牌红包明细单
+   * 变量名:need_query_detail
+   * 是否必填:否
+   * 类型:boolean
+   * 描述:
+   *  query枚举值:
+   * true:是;
+   * false:否,默认否。
+   * 商户可选择是否查询指定状态的品牌红包明细单,当品牌红包批次单状态为“FINISHED”(已完成)时,才会返回满足条件的品牌红包明细单
+   * 
+ */ + @SerializedName("need_query_detail") + private Boolean needQueryDetail; + + /** + *
+   * 字段名:品牌红包明细单状态
+   * 变量名:detail_state
+   * 是否必填:否
+   * 类型:string
+   * 描述:
+   *  query查询指定状态的品牌红包明细单信息
+   * DETAIL_VIEW_ALL - 全部,需要同时查询发送成功和发送失败的品牌红包明细单
+   * DETAIL_VIEW_SUCCESS - 发送成功,只查询发送成功的品牌红包明细单
+   * DETAIL_VIEW_FAIL - 发送失败,只查询发送失败的品牌红包明细单
+   * 示例值:DETAIL_VIEW_FAIL
+   * 
+ */ + @SerializedName("detail_state") + private String detailState; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandMerchantDetailsQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandMerchantDetailsQueryRequest.java new file mode 100644 index 0000000000..c04445c309 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandMerchantDetailsQueryRequest.java @@ -0,0 +1,52 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 品牌红包商家明细单号查询明细单API参数 + * + * @author moran + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class BrandMerchantDetailsQueryRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:商家品牌红包批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  path商户系统内部的商家品牌红包批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:商家品牌红包明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  path商户系统内部区分品牌红包批次单下不同品牌红包明细单的唯一标识,要求此参数只能由数字、大小写字母组成
+   * 示例值:x23zy545Bd5436
+   * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandTransferBatchesRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandTransferBatchesRequest.java new file mode 100644 index 0000000000..a65c146ac0 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandTransferBatchesRequest.java @@ -0,0 +1,249 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.request; + +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 发起品牌红包商家转账API参数 + * + * @author moran + **/ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class BrandTransferBatchesRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:品牌ID
+   * 变量名:brand_id
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  body品牌在微信支付进行品牌认证后的唯一标识品牌ID
+   * 示例值:1234
+   * 
+ */ + @SerializedName("brand_id") + private Integer brandId; + + /** + *
+   * 字段名:品牌AppID
+   * 变量名:brand_appid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  body品牌商户在微信申请公众号/小程序或移动应用成功后分配的账号ID,需与品牌有绑定关系,使用品牌的AppID时需要填写
+   * 示例值:wxf636efh567hg4356
+   * 
+ */ + @SerializedName("brand_appid") + private String brandAppid; + + /** + *
+   * 字段名:品牌红包发放场景
+   * 变量名:scene
+   * 是否必填:是
+   * 类型:string
+   * 描述:
+   *  body品牌红包发放场景,用户可以在指定的场景领取到红包
+   * CUSTOM_SEND - 自定义发放场景,自定义场景发放红包,使用已配置的自定义发放模板进行发红包
+   * 示例值:CUSTOM_SEND
+   * 
+ */ + @SerializedName("scene") + private String scene; + + /** + *
+   * 字段名:品牌红包模板ID
+   * 变量名:template_id
+   * 是否必填:是
+   * 类型:string[1, 128]
+   * 描述:
+   *  body品牌主配置的品牌红包模板ID
+   * 示例值:123400001
+   * 
+ */ + @SerializedName("template_id") + private String templateId; + + /** + *
+   * 字段名:商家品牌红包批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  body品牌商户系统内部的品牌红包批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:品牌红包批次名称
+   * 变量名:batch_name
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  body该品牌红包批次的名称,展示在用户红包领取通知的红包活动名称
+   * 示例值:双十一营销用品牌红包
+   * 
+ */ + @SerializedName("batch_name") + private String batchName; + + /** + *
+   * 字段名:品牌红包批次备注
+   * 变量名:batch_remark
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  body该批次品牌红包的备注,仅用于品牌商户内部管理
+   * 示例值:双十一营销用品牌红包
+   * 
+ */ + @SerializedName("batch_remark") + private String batchRemark; + + /** + *
+   * 字段名:总金额
+   * 变量名:total_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  body品牌红包总金额必须与品牌红包批次内所有品牌红包明细发送金额之和保持一致,否则无法发送品牌红包
+   * 示例值:10000
+   * 
+ */ + @SerializedName("total_amount") + private Integer totalAmount; + + /** + *
+   * 字段名:总笔数
+   * 变量名:total_num
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  body一个品牌红包批次单最多发送10笔品牌红包明细。品牌红包总笔数必须与批次内所有品牌红包明细之和保持一致,否则无法发送品牌红包
+   * 示例值:10
+   * 
+ */ + @SerializedName("total_num") + private Integer totalNum; + + /** + *
+   * 字段名:品牌红包明细列表
+   * 变量名:detail_list
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  body品牌红包明细列表,最多10笔
+   * 
+ */ + @SpecEncrypt + @SerializedName("detail_list") + private List detailList; + + @Data + @Builder(builderMethodName = "newBuilder") + @AllArgsConstructor + @NoArgsConstructor + public static class BrandTransferDetail { + + /** + *
+     * 字段名:商家品牌红包明细单号
+     * 变量名:out_detail_no
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  品牌商户系统内部区分品牌红包批次单下不同品牌红包明细单的唯一标识,要求此参数只能由数字、大小写字母组成
+     * 示例值:x23zy545Bd5436
+     * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+     * 字段名:红包金额(单位:分)
+     * 变量名:amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  红包金额单位为“分”,红包金额的最大限额取决于商户在商户平台的设置额度
+     * 示例值:100
+     * 
+ */ + @SerializedName("amount") + private Integer amount; + + /** + *
+     * 字段名:接收红包用户OpenID
+     * 变量名:openid
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  接收红包的用户OpenID,该OpenID为用户在上方指定的AppID下的唯一标识。
+     *  注:openid是微信用户在公众号appid下的唯一用户标识(appid不同,则获取到的openid就不同),可用于永久标记一个用户。
+     *  获取openid:https://pay.weixin.qq.com/wiki/doc/apiv3/terms_definition/chapter1_1_3.shtml
+     * 示例值:o-MYE42l80oelYMDE34nYD456Xoy
+     * 
+ */ + @SerializedName("openid") + private String openid; + + /** + *
+     * 字段名:接收红包用户姓名
+     * 变量名:user_name
+     * 是否必填:否
+     * 类型:string[1, 1024]
+     * 描述:
+     *  1、明细转账金额 >= 2,000,收款用户姓名必填;
+     *  2、同一批次转账明细中,收款用户姓名字段需全部填写、或全部不填写;
+     *  3、若传入收款用户姓名,微信支付会校验用户OpenID与姓名是否一致,并提供电子回单;
+     *  4、收款方姓名。采用标准RSA算法,公钥由微信侧提供
+     *  5、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     * 示例值:757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45
+     * 
+ */ + @SpecEncrypt + @SerializedName("user_name") + private String userName; + + /** + *
+     * 字段名:红包备注
+     * 变量名:remark
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  单个红包备注,会展示在客户端收款凭证的“红包说明”字段,UTF8编码,最多允许32个字符
+     * 示例值:来自XX的红包
+     * 
+ */ + @SerializedName("remark") + private String remark; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandWxBatchesQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandWxBatchesQueryRequest.java new file mode 100644 index 0000000000..e43a2818ca --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandWxBatchesQueryRequest.java @@ -0,0 +1,72 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 品牌红包微信支付批次单号查询批次单API参数 + * + * @author moran + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class BrandWxBatchesQueryRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:微信支付品牌红包批次单号
+   * 变量名:batch_no
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  path微信支付品牌红包批次单号,微信商家品牌红包系统返回的唯一标识
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_no") + private String batchNo; + + /** + *
+   * 字段名:是否需要查询品牌红包明细单
+   * 变量名:need_query_detail
+   * 是否必填:是
+   * 类型:boolean
+   * 描述:
+   *  query枚举值:
+   *  true:是;
+   *  false:否,默认否。
+   * 商户可选择是否查询指定状态的品牌红包明细单,当品牌红包批次单状态为“FINISHED”(已完成)时,才会返回满足条件的品牌红包明细单
+   * 示例值:true
+   * 
+ */ + @SerializedName("need_query_detail") + private Boolean needQueryDetail; + + /** + *
+   * 字段名:品牌红包明细单状态
+   * 变量名:detail_status
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  query查询指定状态的品牌红包明细单信息
+   * DETAIL_VIEW_ALL - 全部,需要同时查询发送成功和发送失败的品牌红包明细单
+   * DETAIL_VIEW_SUCCESS - 发送成功,只查询发送成功的品牌红包明细单
+   * DETAIL_VIEW_FAIL - 发送失败,只查询发送失败的品牌红包明细单
+   * 示例值:DETAIL_VIEW_FAIL
+   * 
+ */ + @SerializedName("detail_state") + private String detailState; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandWxDetailsQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandWxDetailsQueryRequest.java new file mode 100644 index 0000000000..045d054e04 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/request/BrandWxDetailsQueryRequest.java @@ -0,0 +1,52 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 品牌红包微信支付明细单号查询明细单API参数 + * + * @author moran + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class BrandWxDetailsQueryRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:微信支付品牌红包批次单号
+   * 变量名:batch_no
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  path微信支付品牌红包批次单号,微信商家品牌红包系统返回的唯一标识
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_no") + private String batchNo; + + /** + *
+   * 字段名:微信明细单号
+   * 变量名:detail_no
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  path微信支付系统内部区分品牌红包批次单下不同品牌红包明细单的唯一标识
+   * 示例值:1040000071100999991182020050700019500100
+   * 
+ */ + @SerializedName("detail_no") + private String detailNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandBatchesQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandBatchesQueryResult.java new file mode 100644 index 0000000000..bc3cc5fbca --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandBatchesQueryResult.java @@ -0,0 +1,354 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.result; + +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 查询批次单结果 + * + * @author moran + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class BrandBatchesQueryResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:品牌主商户号
+   * 变量名:brand_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,且已经认证品牌的品牌主商户号
+   * 示例值:1900001109
+   * 
+ */ + @SerializedName("brand_mchid") + private String brandMchid; + + /** + *
+   * 字段名:微信支付品牌红包批次单号
+   * 变量名:batch_no
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  品牌在微信支付进行品牌认证后的唯一标识品牌ID
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_no") + private String batchNo; + + /** + *
+   * 字段名:商家品牌红包批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  品牌商户系统内部的品牌红包批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:品牌ID
+   * 变量名:brand_id
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  品牌在微信支付进行品牌认证后的唯一标识品牌ID
+   * 示例值:1234
+   * 
+ */ + @SerializedName("brand_id") + private Integer brandId; + + /** + *
+   * 字段名:品牌红包模板ID
+   * 变量名:template_id
+   * 是否必填:否
+   * 类型:string[1, 128]
+   * 描述:
+   *  品牌主配置的品牌红包模板ID
+   * 示例值:12340000000001
+   * 
+ */ + @SerializedName("template_id") + private String templateId; + + /** + *
+   * 字段名:品牌AppID
+   * 变量名:brand_appid
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  品牌商户在微信申请公众号/小程序或移动应用成功后分配的账号ID,该AppID需与品牌ID有绑定关系(B-A绑定关系)
+   * 示例值:wxf636efh567hg4356
+   * 
+ */ + @SerializedName("brand_appid") + private String brandAppid; + + /** + *
+   * 字段名:品牌红包批次状态
+   * 变量名:batch_state
+   * 是否必填:是
+   * 类型:string
+   * 描述:
+   *  当前品牌红包批次状态
+   * WAIT_PAY - 待付款,商户员工确认付款阶段
+   * ACCEPTED - 已受理,批次已受理成功,若发起品牌红包的30分钟后,品牌红包批次单仍处于该状态,可能原因是商户账户余额不足等。商户可查询账户资金流水,若该笔品牌红包批次单的扣款已经发生,则表示批次已经进入发送中,请再次查单确认
+   * PROCESSING - 发送中,已开始处理批次内的品牌红包明细单
+   * FINISHED - 已完成,批次内的所有品牌红包明细单都已处理完成
+   * CLOSED - 已关闭,可查询具体的批次关闭原因确认
+   * 示例值:ACCEPTED
+   * 
+ */ + @SerializedName("batch_state") + private String batchState; + + /** + *
+   * 字段名:品牌红包批次名称
+   * 变量名:batch_name
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  该批次品牌红包的备注,用于品牌商户内部管理
+   * 示例值:双十一营销发放品牌红包
+   * 
+ */ + @SerializedName("batch_name") + private String batchName; + + /** + *
+   * 字段名:品牌红包批次备注
+   * 变量名:batch_remark
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  该批次品牌红包的备注,仅用于品牌商户内部管理
+   * 示例值:双十一营销发放品牌红包
+   * 
+ */ + @SerializedName("batch_remark") + private String batchRemark; + + /** + *
+   * 字段名:品牌红包批次单关闭原因
+   * 变量名:close_reason
+   * 是否必填:否
+   * 类型:string
+   * 描述:
+   *  品牌红包批次单状态为“CLOSED”(已关闭)时返回
+   * MERCHANT_REVOCATION - 商户主动撤销
+   * SYSTEM_OVERDUE_CLOSE - 系统超时关闭
+   * 示例值:SYSTEM_OVERDUE_CLOSE
+   * 
+ */ + @SerializedName("close_reason") + private String closeReason; + + /** + *
+   * 字段名:总金额
+   * 变量名:total_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  品牌红包金额单位为“分”
+   * 示例值:10000
+   * 
+ */ + @SerializedName("total_amount") + private Integer totalAmount; + + /** + *
+   * 字段名:总笔数
+   * 变量名:total_num
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  一个品牌红包批次单最多发送10笔品牌红包明细。品牌红包总笔数必须与批次内所有品牌红包明细之和保持一致,否则无法发送品牌红包
+   * 示例值:10
+   * 
+ */ + @SerializedName("total_num") + private Integer totalNum; + + /** + *
+   * 字段名:品牌红包批次创建时间
+   * 变量名:create_time
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  品牌红包批次受理成功时返回,遵循rfc3339标准格式,
+   *  格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   *  例如:2015-05-20T13:29:35+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35+08:00
+   * 
+ */ + @SerializedName("create_time") + private String createTime; + + /** + *
+   * 字段名:品牌红包批次更新时间
+   * 变量名:update_time
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  品牌红包批次最近一次状态变更时间,遵循rfc3339标准格式,
+   *  格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   *  例如:2015-05-20T13:29:35+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35+08:00
+   * 
+ */ + @SerializedName("update_time") + private String updateTime; + + /** + *
+   * 字段名:发放成功金额
+   * 变量名:success_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  品牌红包发放成功的金额,单位为“分”。当批次状态为“PROCESSING”(发送中)时,发放成功金额随时可能变化
+   * 示例值:5000
+   * 
+ */ + @SerializedName("success_amount") + private Integer successAmount; + + /** + *
+   * 字段名:发放成功笔数
+   * 变量名:success_num
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  品牌红包发放成功的笔数。当批次状态为“PROCESSING”(发放中)时,发放成功笔数随时可能变化
+   * 示例值:10
+   * 
+ */ + @SerializedName("success_num") + private Integer successNum; + + /** + *
+   * 字段名:发放失败金额
+   * 变量名:fail_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  品牌红包发放失败的金额,单位为“分”
+   * 示例值:5000
+   * 
+ */ + @SerializedName("fail_amount") + private Integer failAmount; + + /** + *
+   * 字段名:发放失败笔数
+   * 变量名:fail_num
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  品牌红包发放失败的笔数
+   * 示例值:10
+   * 
+ */ + @SerializedName("fail_num") + private Integer failNum; + + /** + *
+   * 字段名:品牌红包明细列表
+   * 变量名:detail_list
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  当批次状态为“FINISHED”(已完成),且成功查询到品牌红包明细单时返回。包括微信支付品牌红包明细单号、明细状态信息
+   * 
+ */ + @SpecEncrypt + @SerializedName("detail_list") + private List detailList; + + @Data + @Accessors(chain = true) + public static class BrandDetailResult implements Serializable { + + /** + *
+     * 字段名:微信支付品牌红包明细单号
+     * 变量名:transfer_detail_no
+     * 是否必填:是
+     * 类型:string[32, 64]
+     * 描述:
+     *  微信支付系统内部区分品牌红包批次单下不同品牌红包明细单的唯一标识
+     * 示例值:1220000071100999991182020050700019500100
+     * 
+ */ + @SerializedName("transfer_detail_no") + private String transferDetailNo; + + /** + *
+     * 字段名:商家品牌红包明细单号
+     * 变量名:out_detail_no
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  品牌商户系统内部区分品牌红包批次单下不同品牌红包明细单的唯一标识,要求此参数只能由数字、大小写字母组成
+     * 示例值:x23zy545Bd5436
+     * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+     * 字段名:品牌红包明细单状态
+     * 变量名:detail_state
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  品牌红包明细单的状态
+     * DETAIL_PROCESSING - 发送中,正在处理中,品牌红包发送结果尚未明确
+     * DETAIL_SUCCESS - 发送成功,发送成功
+     * DETAIL_FAIL - 发送失败,需要确认失败原因后,再决定是否重新对该笔品牌红包明细单进行发送(并非整个品牌红包批次单)
+     * 示例值:DETAIL_SUCCESS
+     * 
+ */ + @SerializedName("detail_state") + private String detailState; + + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandDetailsQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandDetailsQueryResult.java new file mode 100644 index 0000000000..451b77ae14 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandDetailsQueryResult.java @@ -0,0 +1,273 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.result; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 品牌红包微信明细单号查询明细单 响应实体、 + * + * @author moran + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class BrandDetailsQueryResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:品牌主商户号
+   * 变量名:brand_mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,且已经认证品牌的品牌主商户号
+   * 示例值:1900001109
+   * 
+ */ + @SerializedName("brand_mchid") + private String brandMchid; + + /** + *
+   * 字段名:商家品牌红包批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  商户系统内部的商家品牌红包批次单号,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:微信支付品牌红包批次单号
+   * 变量名:batch_no
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  微信支付品牌红包批次单号,微信商家品牌红包系统返回的唯一标识
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_no") + private String batchNo; + + /** + *
+   * 字段名:商家品牌红包明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  品牌商户系统内部的品牌红包批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:x23zy545Bd5436
+   * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+   * 字段名:微信支付品牌红包明细单号
+   * 变量名:detail_id
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  微信支付系统内部区分品牌红包批次单下不同品牌红包明细单的唯一标识
+   * 示例值:1040000071100999991182020050700019500100
+   * 
+ */ + @SerializedName("detail_no") + private String detailNo; + + /** + *
+   * 字段名:品牌红包明细单状态
+   * 变量名:detail_state
+   * 是否必填:是
+   * 类型:string
+   * 描述:
+   *  品牌红包明细单状态
+   * DETAIL_PROCESSING - 发送中,正在处理中,品牌红包发送结果尚未明确
+   * DETAIL_SUCCESS - 发送成功,发送成功
+   * DETAIL_FAIL - 发送失败,需要确认失败原因后,再决定是否重新对该笔品牌红包明细单进行发送(并非整个品牌红包批次单)
+   * 示例值:DETAIL_SUCCESS
+   * 
+ */ + @SerializedName("detail_state") + private String detailState; + + /** + *
+   * 字段名:红包金额
+   * 变量名:amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  红包金额单位为“分”
+   * 示例值:100
+   * 
+ */ + @SerializedName("amount") + private Integer amount; + + /** + *
+   * 字段名:红包备注
+   * 变量名:remark
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  单个品牌红包备注(微信用户会收到该备注),UTF8编码,最多允许32个字符
+   * 示例值:来自XX品牌红包
+   * 
+ */ + @SerializedName("remark") + private String remark; + + /** + *
+   * 字段名:明细失败原因
+   * 变量名:fail_reason
+   * 是否必填:否
+   * 类型:string
+   * 描述:
+   *  明细失败原因
+   * ACCOUNT_FROZEN - 该用户账户被冻结
+   * REAL_NAME_CHECK_FAIL - 收款人未实名认证,需要用户完成微信实名认证
+   * NAME_NOT_CORRECT - 收款人姓名校验不通过,请核实信息
+   * OPENID_INVALID - OpenID格式错误或者不属于商家公众账号
+   * TRANSFER_QUOTA_EXCEED - 超过用户单笔收款区间,核实产品设置是否准确
+   * DAY_RECEIVED_QUOTA_EXCEED - 超过用户单日收款额度,核实产品设置是否准确
+   * DAY_RECEIVED_COUNT_EXCEED - 超过用户单日收款次数,核实产品设置是否准确
+   * PRODUCT_AUTH_CHECK_FAIL - 未开通该权限或权限被冻结,请核实产品权限状态
+   * OVERDUE_CLOSE - 该笔转账已关闭
+   * ACCOUNT_NOT_EXIST - 该用户账户不存在
+   * TRANSFER_RISK - 该笔转账可能存在风险,已被微信拦截
+   * USER_ACCOUNT_LIMIT - 用户账户收款受限,请引导用户在微信支付查看详情
+   * FAIL_REASON_UNKNOWN - 失败原因未知
+   * PAYER_ACCOUNT_ABNORMAL - 商户账户付款受限,可前往商户平台获取解除功能限制指引
+   * PAYEE_ACCOUNT_ABNORMAL - 用户账户收款异常,请联系用户完善其在微信支付的身份信息以继续收款
+   * USER_RECEIVE_OVERDUE - 用户逾期未领取
+   * REMARK_NOT_CORRECT - 红包备注设置失败,请修改后再试
+   * 示例值:ACCOUNT_FROZEN
+   * 
+ */ + @SerializedName("fail_reason") + private String failReason; + + /** + *
+   * 字段名:接收红包用户OpenID
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  接收红包的用户OpenID,OpenID为用户在对应AppID下的唯一标识
+   * 示例值:o-MYE42l80oelYMDE34nYD456Xoy
+   * 
+ */ + @SerializedName("openid") + private String openid; + + /** + *
+   * 字段名:接收红包用户姓名
+   * 变量名:user_name
+   * 是否必填:否
+   * 类型:string[1,1024]
+   * 描述:
+   *  发放品牌红包时传入的接收红包用户姓名,已使用商户的私钥加密
+   * 示例值:757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45
+   * 
+ */ + @SerializedName("user_name") + private String userName; + + /** + *
+   * 字段名:品牌红包发起时间
+   * 变量名:initiate_time
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  品牌红包发起的时间,遵循rfc3339标准格式,
+   *  格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   *  例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("initiate_time") + private String initiateTime; + + /** + *
+   * 字段名:品牌红包更新时间
+   * 变量名:update_time
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  品牌红包明细单最后一次状态变更时间,遵循rfc3339标准格式,
+   *  格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   *  例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("update_time") + private String updateTime; + + /** + *
+   * 字段名:品牌ID
+   * 变量名:brand_id
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  品牌在微信支付进行品牌认证后的唯一标识品牌ID
+   * 示例值:1234
+   * 
+ */ + @SerializedName("brand_id") + private Integer brandId; + + /** + *
+   * 字段名:品牌红包模板ID
+   * 变量名:template_id
+   * 是否必填:是
+   * 类型:string[1, 128]
+   * 描述:
+   *  品牌主配置的品牌红包模板ID
+   * 示例值:12340000000001
+   * 
+ */ + @SerializedName("template_id") + private String templateId; + + /** + *
+   * 字段名:品牌AppID
+   * 变量名:brand_appid
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  品牌商户在微信申请公众号/小程序或移动应用成功后分配的账号ID,该AppID需与品牌ID有绑定关系(B-A绑定关系)
+   * 示例值:wxf636efh567hg4356
+   * 
+ */ + @SerializedName("brand_appid") + private String brandAppid; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandTransferBatchesResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandTransferBatchesResult.java new file mode 100644 index 0000000000..722a7e6b17 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/brandmerchanttransfer/result/BrandTransferBatchesResult.java @@ -0,0 +1,62 @@ +package com.github.binarywang.wxpay.bean.brandmerchanttransfer.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 品牌红包商家转账结果 + * + * @author moran + **/ +@Data +@NoArgsConstructor +public class BrandTransferBatchesResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:商家品牌红包批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  品牌商户系统内部区分品牌红包批次单下不同品牌红包明细单的唯一标识,要求此参数只能由数字、大小写字母组成
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:微信支付品牌红包批次单号
+   * 变量名:batch_no
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  微信批次单号,微信商家转账系统返回的唯一标识
+   * 示例值:1210000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_no") + private String batchNo; + + /** + *
+   * 字段名:品牌红包批次创建时间
+   * 变量名:create_time
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  批次受理成功时返回,遵循rfc3339标准格式,
+   *  格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   *  例如:2015-05-20T13:29:35+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35+08:00
+   * 
+ */ + @SerializedName("create_time") + private String createTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/businesscircle/PaidResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/businesscircle/PaidResult.java index ded872c79b..24f1fbdeb5 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/businesscircle/PaidResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/businesscircle/PaidResult.java @@ -54,7 +54,7 @@ public class PaidResult implements Serializable { * 示例值:123456 */ @SerializedName("shop_number") - private String shop_number; + private String shopNumber; /** * 小程序APPID diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintDetailRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintDetailRequest.java new file mode 100644 index 0000000000..48125557e6 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintDetailRequest.java @@ -0,0 +1,36 @@ +package com.github.binarywang.wxpay.bean.complaint; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 微信消费者投诉2.0 + * 查询投诉单详情请求实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ComplaintDetailRequest implements Serializable { + + private static final long serialVersionUID = 3244929701614280801L; + + /** + *
+   * 字段名:投诉单号
+   * 是否必填:是
+   * 描述:投诉单对应的投诉单号
+   * 
+ */ + @SerializedName("complaint_id") + private String complaintId; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintDetailResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintDetailResult.java new file mode 100644 index 0000000000..157e095bba --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintDetailResult.java @@ -0,0 +1,330 @@ +package com.github.binarywang.wxpay.bean.complaint; + + +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信消费者投诉2.0 + * 查询投诉单列表接口 和 查询投诉单详情接口返回的实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +public class ComplaintDetailResult implements Serializable { + private static final long serialVersionUID = -6201692411535927503L; + + /** + *
+   * 字段名:投诉单号
+   * 是否必填:是
+   * 描述:投诉单对应的投诉单号
+   * 
+ */ + @SerializedName("complaint_id") + private String complaintId; + + /** + *
+   * 字段名:投诉时间
+   * 是否必填:是
+   * 描述:投诉时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,
+   * T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   * 例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("complaint_time") + private String complaintTime; + + /** + *
+   * 字段名:投诉详情
+   * 是否必填:是
+   * 投诉的具体描述
+   * 
+ */ + @SerializedName("complaint_detail") + private String complaintDetail; + + /** + *
+   * 字段名:被诉商户号
+   * 是否必填:是
+   * 投诉单对应的被诉商户号。
+   * 
+ */ + @SerializedName("complainted_mchid") + private String complainedMchid; + + /** + *
+   * 字段名:投诉单状态
+   * 是否必填:是
+   * 标识当前投诉单所处的处理阶段,具体状态如下所示:
+   * PENDING:待处理
+   * PROCESSING:处理中
+   * PROCESSED:已处理完成
+   * 
+ */ + @SerializedName("complaint_state") + private String complaintState; + + /** + *
+   * 字段名:投诉人联系方式
+   * 是否必填:否
+   * 投诉人联系方式。该字段已做加密处理,具体解密方法详见敏感信息加密说明。
+   * 
+ */ + @SerializedName("payer_phone") + @SpecEncrypt + private String payerPhone; + + /** + *
+   * 字段名:投诉人openid
+   * 是否必填:是
+   * 投诉人在商户appid下的唯一标识
+   * 
+ */ + @SerializedName("payer_openid") + private String payerOpenid; + + + /** + *
+   * 字段名:投诉资料列表
+   * 是否必填:是
+   * 用户上传的投诉相关资料,包括图片凭证等
+   * 
+ */ + @SerializedName("complaint_media_list") + private List complaintMediaList; + + @Data + public static class ComplaintMedia implements Serializable { + private static final long serialVersionUID = 4240983048700956803L; + + /** + *
+     * 字段名:媒体文件业务类型
+     * 是否必填:是
+     * 描述:
+     * 媒体文件对应的业务类型
+     * USER_COMPLAINT_IMAGE:用户投诉图片,用户提交投诉时上传的图片凭证
+     * OPERATION_IMAGE:操作流水图片,用户、商户、微信支付客服在协商解决投诉时,上传的图片凭证
+     * 注:用户上传的图片凭证会以白名单的形式提供给商户,若希望查看用户图片,联系微信支付客服
+     * 示例值:USER_COMPLAINT_IMAGE
+     * 
+ */ + @SerializedName("media_type") + private String mediaType; + + /** + *
+     * 字段名:媒体文件请求url
+     * 是否必填:是
+     * 描述:
+     * 微信返回的媒体文件请求url
+     * 
+ */ + @SerializedName("media_url") + private List mediaUrl; + + } + + /** + *
+   * 字段名:投诉单关联订单信息
+   * 是否必填:是
+   * 投诉单关联订单信息
+   * 注:投诉单和订单目前是一对一关系,array是预留未来一对多的扩展
+   * 
+ */ + @SerializedName("complaint_order_info") + private List complaintOrderInfo; + + @Data + public static class ComplaintOrder implements Serializable { + private static final long serialVersionUID = 4240983048700956804L; + + /** + *
+     * 字段名:微信订单号
+     * 是否必填:是
+     * 描述:
+     * 投诉单关联的微信订单号
+     * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+     * 字段名:商户订单号
+     * 是否必填:是
+     * 描述:
+     * 投诉单关联的商户订单号
+     * 
+ */ + @SerializedName("out_trade_no") + private String outTradeNo; + + /** + *
+     * 字段名:订单金额
+     * 是否必填:是
+     * 描述:
+     * 订单金额,单位(分)
+     * 
+ */ + @SerializedName("amount") + private Integer amount; + + } + + /** + *
+   * 字段名:投诉单关联服务单信息
+   * 是否必填:否
+   * 投诉单关联服务单信息, 支付分服务单投诉时可能存在
+   * 
+ */ + @SerializedName("service_order_info") + private List serviceOrderInfo; + + /** + *
+  * 服务单信息
+  * 
+ */ + @Data + public static class ServiceOrder implements Serializable { + private static final long serialVersionUID = 4240983048700956805L; + + /** + *
+     * 字段名:微信支付服务订单号
+     * 是否必填:否
+     * 描述:
+     * 微信支付服务订单号,每个微信支付服务订单号与商户号下对应的商户服务订单号一一对应
+     * 
+ */ + @SerializedName("order_id") + private String orderId; + + /** + *
+     * 字段名:商户服务订单号
+     * 是否必填:否
+     * 描述:
+     * 商户系统内部服务订单号(不是交易单号),与创建订单时一致
+     * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+     * 字段名:支付分服务单状态
+     * 是否必填:否
+     * 描述:
+     * 此处上传的是用户发起投诉时的服务单状态,不会实时更新
+     * DOING:服务订单进行中
+     * REVOKED:商户取消服务订单
+     * WAITPAY:服务订单待支付
+     * DONE:服务订单已完成
+     * 
+ */ + @SerializedName("state") + private String state; + + } + + /** + *
+   * 字段名:投诉单是否已全额退款
+   * 是否必填:是
+   * 描述:
+   * 投诉单下所有订单是否已全部全额退款
+   * 
+ */ + @SerializedName("complaint_full_refunded") + private Boolean complaintFullRefunded; + + /** + *
+   * 字段名:是否有待回复的用户留言
+   * 是否必填:是
+   * 描述:
+   * 投诉单是否有待回复的用户留言
+   * 
+ */ + @SerializedName("incoming_user_response") + private Boolean incomingUserResponse; + + /** + *
+   * 字段名:问题描述
+   * 是否必填:是
+   * 描述:
+   * 用户发起投诉前选择的faq标题(2021年7月15日之后的投诉单均包含此信息)
+   * 
+ */ + @SerializedName("problem_description") + private String problemDescription; + + /** + *
+   * 字段名:用户投诉次数
+   * 是否必填:是
+   * 描述:
+   * 用户投诉次数。用户首次发起投诉记为1次,用户每有一次继续投诉就加1
+   * 
+ */ + @SerializedName("user_complaint_times") + private Integer userComplaintTimes; + + /** + *
+   * 字段名:问题类型
+   * 是否必填:否
+   * 描述:问题类型为申请退款的单据是需要最高优先处理的单据
+   * REFUND:申请退款
+   * SERVICE_NOT_WORK:服务权益未生效
+   * OTHERS:其他类型
+   * 示例值:REFUND
+   * 
+ */ + @SerializedName("problem_type") + private String problemType; + + /** + *
+   * 字段名:用户投诉次数
+   * 是否必填:否
+   * 描述:仅当问题类型为申请退款时, 有值, (单位:分)
+   * 示例值:10
+   * 
+ */ + @SerializedName("apply_refund_amount") + private Integer applyRefundAmount; + + /** + *
+   * 字段名:用户标签列表
+   * 是否必填:否
+   * 描述: TRUSTED:可信,此类用户满足极速退款条件
+   *       OTHERS:其它,此类用户不满足极速退款条件
+   * 示例值:[TRUSTED]
+   * 
+ */ + @SerializedName("user_tag_list") + private String[] userTagList; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintNotifyUrlRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintNotifyUrlRequest.java new file mode 100644 index 0000000000..19c9e16174 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintNotifyUrlRequest.java @@ -0,0 +1,36 @@ +package com.github.binarywang.wxpay.bean.complaint; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 微信消费者投诉2.0 + * 投诉通知请求实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ComplaintNotifyUrlRequest implements Serializable { + + private static final long serialVersionUID = -1L; + + /** + *
+   * 字段名:通知地址
+   * 是否必填:是
+   * 描述:通知地址,仅支持https。
+   * 
+ */ + @SerializedName("url") + private String url; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintNotifyUrlResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintNotifyUrlResult.java new file mode 100644 index 0000000000..bc7e066d31 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintNotifyUrlResult.java @@ -0,0 +1,44 @@ +package com.github.binarywang.wxpay.bean.complaint; + + +import com.github.binarywang.wxpay.bean.media.MarketingImageUploadResult; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信消费者投诉2.0 + * 投诉通知地址返回的实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +public class ComplaintNotifyUrlResult implements Serializable { + + private static final long serialVersionUID = -6201692411535927502L; + + /** + *
+   * 字段名:商户号
+   * 是否必填:是
+   * 描述:返回创建回调地址的商户号,由微信支付生成并下发。
+   * 
+ */ + @SerializedName("mchid") + private String mchid; + + /** + *
+   * 字段名:通知地址
+   * 是否必填:是
+   * 描述:通知地址,仅支持https。
+   * 
+ */ + @SerializedName("url") + private String url; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintRequest.java new file mode 100644 index 0000000000..9b66e6ba37 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintRequest.java @@ -0,0 +1,77 @@ +package com.github.binarywang.wxpay.bean.complaint; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 微信消费者投诉2.0 + * 查询投诉单列表请求实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ComplaintRequest implements Serializable { + + private static final long serialVersionUID = 3244929701614280800L; + + /** + *
+   * 字段名:分页大小
+   * 是否必填:否
+   * 描述:设置该次请求返回的最大投诉条数,范围【1,50】,商户自定义字段,不传默认为10。
+   * 注:如遇到提示“当前查询结果数据量过大”,是回包触发微信支付下行数据包大小限制,请缩小入参limit并重试。
+   * 
+ */ + @SerializedName("limit") + private Integer limit = 10; + + /** + *
+   * 字段名:分页开始位置
+   * 是否必填:否
+   * 描述:该次请求的分页开始位置,从0开始计数,例如offset=10,表示从第11条记录开始返回,不传默认为0 。
+   * 
+ */ + @SerializedName("offset") + private Integer offset = 0; + + /** + *
+   * 字段名:开始日期
+   * 是否必填:是
+   * 描述:投诉发生的开始日期,格式为yyyy-MM-DD。注意,查询日期跨度不超过30天,当前查询为实时查询
+   * 
+ */ + @SerializedName("begin_date") + private String beginDate; + + /** + *
+   * 字段名:结束日期
+   * 是否必填:是
+   * 描述:投诉发生的结束日期,格式为yyyy-MM-DD。注意,查询日期跨度不超过30天,当前查询为实时查询
+   * 
+ */ + @SerializedName("end_date") + private String endDate; + + /** + *
+   * 字段名:被诉商户号
+   * 是否必填:否
+   * 描述:投诉单对应的被诉商户号。
+   * 
+ */ + @SerializedName("complainted_mchid") + private String complaintedMchid; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintResult.java new file mode 100644 index 0000000000..5167d1dc54 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ComplaintResult.java @@ -0,0 +1,58 @@ +package com.github.binarywang.wxpay.bean.complaint; + + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信消费者投诉2.0 + * 查询投诉单列表返回的实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +public class ComplaintResult implements Serializable { + + private static final long serialVersionUID = -6201692411535927502L; + + /** + *
+   * 字段名:分页大小
+   * 是否必填:是
+   * 描述:设置该次请求返回的最大投诉条数,范围【1,50】
+   * 
+ */ + @SerializedName("limit") + private Integer limit; + + /** + *
+   * 字段名:分页开始位置
+   * 是否必填:是
+   * 描述:该次请求的分页开始位置,从0开始计数,例如offset=10,表示从第11条记录开始返回。
+   * 
+ */ + @SerializedName("offset") + private Integer offset; + + /** + *
+   * 字段名:投诉总条数
+   * 是否必填:否
+   * 描述:投诉总条数,当offset=0时返回
+   * 
+ */ + @SerializedName("total_count") + private Integer totalCount; + + /** + * 用户投诉信息详情 + */ + @SerializedName("data") + private List data; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/CompleteRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/CompleteRequest.java new file mode 100644 index 0000000000..b9789ba5a0 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/CompleteRequest.java @@ -0,0 +1,48 @@ +package com.github.binarywang.wxpay.bean.complaint; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 微信消费者投诉2.0 + * 反馈处理完成请求实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class CompleteRequest implements Serializable { + + private static final long serialVersionUID = 3243229701614220801L; + + /** + *
+   * 字段名:投诉单号
+   * 是否必填:是
+   * 描述:投诉单对应的投诉单号
+   * 
+ */ + @SerializedName("complaint_id") + @Expose + private String complaintId; + + /** + *
+   * 字段名:被诉商户号
+   * 是否必填:是
+   * 描述:投诉单对应的被诉商户号
+   * 
+ */ + @SerializedName("complainted_mchid") + private String complaintedMchid; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/NegotiationHistoryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/NegotiationHistoryRequest.java new file mode 100644 index 0000000000..16c9326936 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/NegotiationHistoryRequest.java @@ -0,0 +1,57 @@ +package com.github.binarywang.wxpay.bean.complaint; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 微信消费者投诉2.0 + * 查询投诉协商历史请求实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class NegotiationHistoryRequest implements Serializable { + + private static final long serialVersionUID = 3244929701614280806L; + + /** + *
+   * 字段名:投诉单号
+   * 是否必填:是
+   * 描述:投诉单对应的投诉单号
+   * 
+ */ + @SerializedName("complaint_id") + private String complaintId; + + /** + *
+   * 字段名:分页大小
+   * 是否必填:否
+   * 描述:设置该次请求返回的最大投诉条数,范围【1,50】,商户自定义字段,不传默认为10。
+   * 注:如遇到提示“当前查询结果数据量过大”,是回包触发微信支付下行数据包大小限制,请缩小入参limit并重试。
+   * 
+ */ + @SerializedName("limit") + private Integer limit = 10; + + /** + *
+   * 字段名:分页开始位置
+   * 是否必填:否
+   * 描述:该次请求的分页开始位置,从0开始计数,例如offset=10,表示从第11条记录开始返回,不传默认为0 。
+   * 
+ */ + @SerializedName("offset") + private Integer offset = 0; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/NegotiationHistoryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/NegotiationHistoryResult.java new file mode 100644 index 0000000000..2da216446d --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/NegotiationHistoryResult.java @@ -0,0 +1,189 @@ +package com.github.binarywang.wxpay.bean.complaint; + + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信消费者投诉2.0 + * 查询投诉单协商历史返回的实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +public class NegotiationHistoryResult implements Serializable { + private static final long serialVersionUID = -6201692411535927502L; + + /** + *
+   * 字段名:分页大小
+   * 是否必填:是
+   * 描述:设置该次请求返回的最大投诉条数,范围【1,50】
+   * 
+ */ + @SerializedName("limit") + private Integer limit; + + /** + *
+   * 字段名:分页开始位置
+   * 是否必填:是
+   * 描述:该次请求的分页开始位置,从0开始计数,例如offset=10,表示从第11条记录开始返回。
+   * 
+ */ + @SerializedName("offset") + private Integer offset; + + /** + *
+   * 字段名:投诉协商历史总条数
+   * 是否必填:否
+   * 描述:投诉协商历史总条数,当offset=0时返回
+   * 
+ */ + @SerializedName("total_count") + private Integer totalCount; + + /** + * 投诉协商历史 + */ + @SerializedName("data") + private List data; + + @Data + public static class NegotiationHistory implements Serializable { + private static final long serialVersionUID = 4240983048700956824L; + + /** + *
+     * 字段名:投诉资料列表
+     * 是否必填:是
+     * 用户上传的投诉相关资料,包括图片凭证等
+     * 
+ */ + @SerializedName("complaint_media_list") + private ComplaintMedia complaintMediaList; + + @Data + public static class ComplaintMedia implements Serializable { + private static final long serialVersionUID = 4240983048700956803L; + + /** + *
+       * 字段名:媒体文件业务类型
+       * 是否必填:是
+       * 描述:
+       * 媒体文件对应的业务类型
+       * USER_COMPLAINT_IMAGE:用户投诉图片,用户提交投诉时上传的图片凭证
+       * OPERATION_IMAGE:操作流水图片,用户、商户、微信支付客服在协商解决投诉时,上传的图片凭证
+       * 注:用户上传的图片凭证会以白名单的形式提供给商户,若希望查看用户图片,联系微信支付客服
+       * 示例值:USER_COMPLAINT_IMAGE
+       * 
+ */ + @SerializedName("media_type") + private String mediaType; + + /** + *
+       * 字段名:媒体文件请求url
+       * 是否必填:是
+       * 描述:
+       * 微信返回的媒体文件请求url
+       * 
+ */ + @SerializedName("media_url") + private List mediaUrl; + + } + + /** + *
+     * 字段名:操作流水号
+     * 是否必填:是
+     * 描述:
+     * 操作流水号
+     * 
+ */ + @SerializedName("log_id") + private String logId; + + /** + *
+     * 字段名:操作人
+     * 是否必填:是
+     * 描述:
+     * 当前投诉协商记录的操作人
+     * 
+ */ + @SerializedName("operator") + private String operator; + + /** + *
+     * 字段名:操作时间
+     * 是否必填:是
+     * 描述:
+     * 当前投诉协商记录的操作时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,
+     * T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     * 例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒。
+     * 示例值:2015-05-20T13:29:35.120+08:00
+     * 
+ */ + @SerializedName("operate_time") + private String operateTime; + + /** + *
+     * 字段名:操作类型
+     * 是否必填:是
+     * 描述:
+     * 当前投诉协商记录的操作类型,对应枚举:
+     * USER_CREATE_COMPLAINT:用户提交投诉
+     * USER_CONTINUE_COMPLAINT:用户继续投诉
+     * USER_RESPONSE:用户留言
+     * PLATFORM_RESPONSE:平台留言
+     * MERCHANT_RESPONSE:商户留言
+     * MERCHANT_CONFIRM_COMPLETE:商户申请结单
+     * COMPLAINT_FULL_REFUNDED:投诉单全额退款
+     * USER_CREATE_COMPLAINT_SYSTEM_MESSAGE:用户提交投诉系统通知
+     * COMPLAINT_FULL_REFUNDED_SYSTEM_MESSAGE:投诉单全额退款系统通知
+     * USER_CONTINUE_COMPLAINT_SYSTEM_MESSAGE:用户继续投诉系统通知
+     * MERCHANT_CONFIRM_COMPLETE_SYSTEM_MESSAGE:商户申请结单系统通知
+     * USER_REVOKE_COMPLAINT:用户主动撤诉(只存在于历史投诉单的协商历史中)
+     * PLATFORM_HELP_APPLICATION:平台问询
+     * USER_APPLY_PLATFORM_HELP:申请协助
+     * 
+ */ + @SerializedName("operate_type") + private String operateType; + + /** + *
+     * 字段名:操作内容
+     * 是否必填:否
+     * 描述:
+     * 当前投诉协商记录的具体内容
+     * 
+ */ + @SerializedName("operate_details") + private String operateDetails; + + /** + *
+     * 字段名:图片凭证
+     * 是否必填:是
+     * 描述:
+     * 当前投诉协商记录提交的图片凭证(url格式),最多返回4张图片,url有效时间为1小时。如未查询到协商历史图片凭证,则返回空数组。
+     * 注:本字段包含商户、微信支付客服在协商解决投诉时上传的图片凭证,若希望查看用户图片,请使用complaint_media_list字段并联系微信支付客服
+     * 
+ */ + @SerializedName("image_list") + private List imageList; + + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ResponseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ResponseRequest.java new file mode 100644 index 0000000000..6f582b9301 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/complaint/ResponseRequest.java @@ -0,0 +1,97 @@ +package com.github.binarywang.wxpay.bean.complaint; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信消费者投诉2.0 + * 提交回复请求实体 + * + * @author jmdhappy + * created on 2022-3-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ResponseRequest implements Serializable { + + private static final long serialVersionUID = 3244929701614220801L; + + /** + *
+   * 字段名:投诉单号
+   * 是否必填:是
+   * 描述:投诉单对应的投诉单号
+   * 
+ */ + @SerializedName("complaint_id") + @Expose + private String complaintId; + + /** + *
+   * 字段名:被诉商户号
+   * 是否必填:是
+   * 描述:投诉单对应的被诉商户号
+   * 
+ */ + @SerializedName("complainted_mchid") + private String complaintedMchid; + + /** + *
+   * 字段名:回复内容
+   * 是否必填:是
+   * 描述:具体的投诉处理方案,限制200个字符以内。
+   * 
+ */ + @SerializedName("response_content") + private String responseContent; + + /** + *
+   * 字段名:回复图片
+   * 是否必填:否
+   * 描述:
+   * 传入调用商户上传反馈图片接口返回的media_id,最多上传4张图片凭证
+   * 示例值:file23578_21798531.jpg
+   * 
+ */ + @SerializedName("response_images") + private List responseImages; + + /** + *
+   * 字段名:跳转链接
+   * 是否必填:是
+   * 描述:
+   * 商户可在回复中附加跳转链接,引导用户跳转至商户客诉处理页面,链接需满足https格式
+   * 注:配置文字链属于灰度功能, 若有需要请使用超管邮箱,按照要求发送邮件申请。邮件要求详情见:
+   * 商户申请开通留言链接白名单指南。
+   * 示例值:https://www.xxx.com/notify
+   * 
+ */ + @SerializedName("jump_url") + private String jumpUrl; + + /** + *
+   * 字段名:跳转链接文案
+   * 是否必填:否
+   * 描述:
+   * 实际展示给用户的文案,附在回复内容之后。用户点击文案,即可进行跳转。
+   * 注:若传入跳转链接,则跳转链接文案为必传项,二者缺一不可。
+   * 
+ */ + @SerializedName("jump_url_text") + private String jumpUrlText; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationQueryRequest.java new file mode 100644 index 0000000000..beaa3f2604 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationQueryRequest.java @@ -0,0 +1,125 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author xifenzhu + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class DeclarationQueryRequest implements Serializable { + + private static final long serialVersionUID = -251403491989628142L; + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:订单类型
+   * 变量名:order_type
+   * 是否必填:是
+   * 类型:string(16)
+   * 描述:
+   *  4种订单号类型,选择一种
+   *  out_trade_no   商户订单号
+   *  transaction_id  微信支付订单号
+   *  sub_order_no  商户子订单号
+   *  sub_order_id  微信子订单号
+   *  示例值:out_trade_no
+   * 
+ */ + @SerializedName(value = "order_type") + private String orderType; + + /** + *
+   * 字段名:订单号
+   * 变量名:order_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  根据订单号类型,传入不同的订单号码
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "order_no") + private String orderNo; + + /** + *
+   * 字段名:海关
+   * 变量名:customs
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  海关代码, 枚举值参见参数规定-海关列表(https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter2_3.shtml#menu11)
+   *  示例值:SHANGHAI_ZS
+   * 
+ */ + @SerializedName(value = "customs") + private String customs; + + /** + *
+   * 字段名:偏移量
+   * 变量名:offset
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  非0整数,该次请求资源的起始位置,从0开始计数。调用方选填,默认为0
+   *  示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private String offset; + + /** + *
+   * 字段名:请求最大记录条数
+   * 变量名:limit
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  非0非负的整数,该次请求可返回的最大资源条数。调用方选填,默认值建议为20
+   *  示例值:20
+   * 
+ */ + @SerializedName(value = "limit") + private String limit; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationQueryResult.java new file mode 100644 index 0000000000..e84370ca11 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationQueryResult.java @@ -0,0 +1,337 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xifenzhu + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class DeclarationQueryResult implements Serializable { + + private static final long serialVersionUID = 7776809282150143165L; + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:微信支付返回的订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:1000320306201511078440737890
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:核验机构
+   * 变量名:verify_department
+   * 是否必填:是
+   * 类型:string(16)
+   * 描述:
+   *  核验机构代码
+   *  UNIONPAY:银联
+   *  NETSUNION:网联
+   *  OTHERS:其他
+   *  示例值:UNIONPAY
+   * 
+ */ + @SerializedName(value = "verify_department") + private String verifyDepartment; + + /** + *
+   * 字段名:核验机构交易流水号
+   * 变量名:Verify_department_trade_id
+   * 是否必填:是
+   * 类型:string(64)
+   * 描述:
+   *  交易流水号,来自验核机构,如银联记录的交易流水号,供商户报备海关
+   *  示例值:2018112288340107038204310100000
+   * 
+ */ + @SerializedName(value = "verify_department_trade_id") + private String verifyDepartmentTradeId; + + /** + *
+   * 字段名:偏移量
+   * 变量名:offset
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  非0整数,该次请求资源的起始位置,从0开始计数。调用方选填,默认为0
+   *  示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private Integer offset; + + /** + *
+   * 字段名:请求最大记录条数
+   * 变量名:limit
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  非0非负的整数,该次请求可返回的最大资源条数。调用方选填,默认值建议为20
+   *  示例值:20
+   * 
+ */ + @SerializedName(value = "limit") + private Integer limit; + + /** + *
+   * 字段名:查询结果总条数
+   * 变量名:total_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  查询结果总条数
+   *  示例值:1
+   * 
+ */ + @SerializedName(value = "total_count") + private Integer totalCount; + + /** + *
+   * 字段名:报关数据包
+   * 变量名:data
+   * 是否必填:是
+   * 类型:array
+   * 描述:
+   *  报关单结果数组,具体内容参见下方描述
+   *  示例值:
+   * 
+ */ + @SerializedName(value = "data") + private List data; + + /** + * 驳回原因详情 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class DeclarationData { + /** + *
+     * 字段名:商户子订单号
+     * 变量名:sub_order_no
+     * 是否必填:否
+     * 类型:string(32)
+     * 描述:
+     *  微信子订单号,如有拆单则返回
+     *  示例值:20150806125346
+     * 
+ */ + @SerializedName(value = "sub_order_no") + private String subOrderNo; + + /** + *
+     * 字段名:微信子订单号
+     * 变量名:sub_order_id
+     * 是否必填:否
+     * 类型:string(32)
+     * 描述:
+     *  商户子订单号,如有拆单则必传
+     *  注意:仅适用于机构模式
+     *  示例值:20150806125346
+     * 
+ */ + @SerializedName(value = "sub_order_id") + private String subOrderId; + + /** + *
+     * 字段名:商户海关备案号
+     * 变量名:merchant_customs_no
+     * 是否必填:是
+     * 类型:string(32)
+     * 描述:
+     *  商户在海关登记的备案号
+     *  示例值:123456
+     * 
+ */ + @SerializedName(value = "mch_customs_no") + private String merchantCustomsNo; + + /** + *
+     * 字段名:海关
+     * 变量名:customs
+     * 是否必填:是
+     * 类型:string(32)
+     * 描述:
+     *  海关代码, 枚举值参见参数规定-海关列表(https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter2_3.shtml#menu11)
+     *  示例值:SHANGHAI_ZS
+     * 
+ */ + @SerializedName(value = "customs") + private String customs; + + /** + *
+     * 字段名:关税
+     * 变量名:duty
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  关税,以分为单位,非必填项,不会提交给海关
+     *  示例值:888
+     * 
+ */ + @SerializedName(value = "duty") + private Integer duty; + + /** + *
+     * 字段名:货币类型
+     * 变量名:fee_type
+     * 是否必填:否
+     * 类型:string(32)
+     * 描述:
+     *  微信支付订单支付时使用的币种,暂只支持人民币CNY,如有拆单则必传
+     *  示例值:CNY
+     * 
+ */ + @SerializedName(value = "fee_type") + private String feeType; + + /** + *
+     * 字段名:子订单金额
+     * 变量名:order_fee
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  子订单金额,以分为单位,不能超过原订单金额,order_fee=transport_fee+product_fee(应付金额=物流费+商品价格),如有拆单则必传
+     *  示例值:888
+     * 
+ */ + @SerializedName(value = "order_fee") + private Integer orderFee; + + /** + *
+     * 字段名:物流费用
+     * 变量名:transport_fee
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  物流费用,以分为单位,如有拆单则必传
+     *  示例值:888
+     * 
+ */ + @SerializedName(value = "transport_fee") + private Integer transportFee; + + /** + *
+     * 字段名:商品费用
+     * 变量名:product_fee
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  商品费用,以分为单位,如有拆单则必传
+     *  示例值:888
+     * 
+ */ + @SerializedName(value = "product_fee") + private Integer productFee; + + /** + *
+     * 字段名:报关状态
+     * 变量名:state
+     * 是否必填:是
+     * 类型:string(32)
+     * 描述:
+     *  申报结果状态码
+     *  PROCESSING:申报中
+     *  UNDECLARED:未申报
+     *  SUBMITTED:已修改未申报
+     *  SUCCESS:申报成功
+     *  FAIL:申报失败
+     *  EXCEPT:海关接口异常
+     *  示例值:PROCESSING
+     * 
+ */ + @SerializedName(value = "state") + private String state; + + /** + *
+     * 字段名:报关结果说明
+     * 变量名:explanation
+     * 是否必填:是
+     * 类型:string(128)
+     * 描述:
+     *  申报结果说明,如果状态是失败或异常,显示失败原因
+     *  示例值:支付单已存在并且为非退单状态
+     * 
+ */ + @SerializedName(value = "explanation") + private String explanation; + + /** + *
+     * 字段名:最后更新时间
+     * 变量名:modify_time
+     * 是否必填:是
+     * 类型:string(32)
+     * 描述:
+     *  最后更新时间,该时间取自微信服务器
+     *  示例值:2015-09-01T10:00:00+08:00
+     * 
+ */ + @SerializedName(value = "modify_time") + private String modifyTime; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationRequest.java new file mode 100644 index 0000000000..64cf86b036 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationRequest.java @@ -0,0 +1,191 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author xifenzhu + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class DeclarationRequest implements Serializable { + + private static final long serialVersionUID = -170115210896346836L; + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + + /** + *
+   * 字段名:微信支付返回的订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:1000320306201511078440737890
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:海关
+   * 变量名:customs
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  海关代码, 枚举值参见参数规定-海关列表(https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter2_3.shtml#menu11)
+   *  示例值:SHANGHAI_ZS
+   * 
+ */ + @SerializedName(value = "customs") + private String customs; + + /** + *
+   * 字段名:商户海关备案号
+   * 变量名:merchant_customs_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户在海关登记的备案号
+   *  示例值:123456
+   * 
+ */ + @SerializedName(value = "merchant_customs_no") + private String merchantCustomsNo; + + /** + *
+   * 字段名:关税
+   * 变量名:duty
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  关税,以分为单位,非必填项,不会提交给海关
+   *  示例值:888
+   * 
+ */ + @SerializedName(value = "duty") + private Integer duty; + + /** + *
+   * 字段名:商户子订单号
+   * 变量名:sub_order_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户子订单号,如有拆单则必传
+   *  注意:仅适用于机构模式
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_no") + private String subOrderNo; + + /** + *
+   * 字段名:货币类型
+   * 变量名:fee_type
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *  微信支付订单支付时使用的币种,暂只支持人民币CNY,如有拆单则必传
+   *  示例值:CNY
+   * 
+ */ + @SerializedName(value = "fee_type") + private String feeType; + + /** + *
+   * 字段名:子订单金额
+   * 变量名:order_fee
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  子订单金额,以分为单位,不能超过原订单金额,order_fee=transport_fee+product_fee(应付金额=物流费+商品价格),如有拆单则必传
+   *  示例值:888
+   * 
+ */ + @SerializedName(value = "order_fee") + private Integer orderFee; + + /** + *
+   * 字段名:物流费用
+   * 变量名:transport_fee
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  物流费用,以分为单位,如有拆单则必传
+   *  示例值:888
+   * 
+ */ + @SerializedName(value = "transport_fee") + private Integer transportFee; + + /** + *
+   * 字段名:商品费用
+   * 变量名:product_fee
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  商品费用,以分为单位,如有拆单则必传
+   *  示例值:888
+   * 
+ */ + @SerializedName(value = "product_fee") + private Integer productFee; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationResult.java new file mode 100644 index 0000000000..06f604f742 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/DeclarationResult.java @@ -0,0 +1,158 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author xifengzhu + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class DeclarationResult implements Serializable { + + private static final long serialVersionUID = -5895139329545995308L; + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "20150806125346") + private String outTradeNo; + + /** + *
+   * 字段名:微信支付返回的订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:1000320306201511078440737890
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:报关状态
+   * 变量名:state
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  申报结果状态码
+   *  PROCESSING:申报中
+   *  UNDECLARED:未申报
+   *  SUBMITTED:已修改未申报
+   *  SUCCESS:申报成功
+   *  FAIL:申报失败
+   *  EXCEPT:海关接口异常
+   *  示例值:PROCESSING
+   * 
+ */ + @SerializedName(value = "state") + private String state; + + /** + *
+   * 字段名:商户子订单号
+   * 变量名:sub_order_no
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *  微信子订单号,如有拆单则返回
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_no") + private String subOrderNo; + + /** + *
+   * 字段名:微信子订单号
+   * 变量名:sub_order_id
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *  商户子订单号,如有拆单则必传
+   *  注意:仅适用于机构模式
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_id") + private String subOrderId; + + /** + *
+   * 字段名:核验机构
+   * 变量名:verify_department
+   * 是否必填:是
+   * 类型:string(16)
+   * 描述:
+   *  核验机构代码
+   *  UNIONPAY:银联
+   *  NETSUNION:网联
+   *  OTHERS:其他
+   *  示例值:UNIONPAY
+   * 
+ */ + @SerializedName(value = "verify_department") + private String verifyDepartment; + + /** + *
+   * 字段名:核验机构交易流水号
+   * 变量名:Verify_department_trade_id
+   * 是否必填:是
+   * 类型:string(64)
+   * 描述:
+   *  交易流水号,来自验核机构,如银联记录的交易流水号,供商户报备海关
+   *  示例值:2018112288340107038204310100000
+   * 
+ */ + @SerializedName(value = "verify_department_trade_id") + private String verifyDepartmentTradeId; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/RedeclareRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/RedeclareRequest.java new file mode 100644 index 0000000000..d3645d13da --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/RedeclareRequest.java @@ -0,0 +1,136 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author xifengzhu + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class RedeclareRequest implements Serializable { + private static final long serialVersionUID = -5092107027805161479L; + + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:微信订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  out_trade_no, transaction_id二选一传入
+   *  示例值:1000320306201511078440737890
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  out_trade_no, transaction_id二选一传入
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + + /** + *
+   * 字段名:商户子订单号
+   * 变量名:sub_order_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户子订单号,如有拆单则必传
+   *  注意:仅适用于机构模式
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_no") + private String subOrderNo; + + /** + *
+   * 字段名:微信子订单号
+   * 变量名:sub_order_id
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *  商户子订单号,如有拆单则必传
+   *  注意:仅适用于机构模式
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_id") + private String subOrderId; + + /** + *
+   * 字段名:海关
+   * 变量名:customs
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  海关代码, 枚举值参见参数规定-海关列表(https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter2_3.shtml#menu11)
+   *  示例值:SHANGHAI_ZS
+   * 
+ */ + @SerializedName(value = "customs") + private String customs; + + /** + *
+   * 字段名:商户海关备案号
+   * 变量名:merchant_customs_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户在海关登记的备案号
+   *  示例值:123456
+   * 
+ */ + @SerializedName(value = "merchant_customs_no") + private String merchantCustomsNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/RedeclareResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/RedeclareResult.java new file mode 100644 index 0000000000..25e09d7c07 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/RedeclareResult.java @@ -0,0 +1,156 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author xifengzhu + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class RedeclareResult implements Serializable { + + private static final long serialVersionUID = 8863516626598050095L; + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:微信订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付返回的订单号
+   *  示例值:1000320306201511078440737890
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + + /** + *
+   * 字段名:商户子订单号
+   * 变量名:sub_order_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户子订单号,如有拆单则必传
+   *  注意:仅适用于机构模式
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_no") + private String subOrderNo; + + /** + *
+   * 字段名:微信子订单号
+   * 变量名:sub_order_id
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *  商户子订单号,如有拆单则必传
+   *  注意:仅适用于机构模式
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_id") + private String subOrderId; + + /** + *
+   * 字段名:报关状态
+   * 变量名:state
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  申报结果状态码
+   *  PROCESSING:申报中
+   *  UNDECLARED:未申报
+   *  SUBMITTED:已修改未申报
+   *  SUCCESS:申报成功
+   *  FAIL:申报失败
+   *  EXCEPT:海关接口异常
+   *  示例值:PROCESSING
+   * 
+ */ + @SerializedName(value = "state") + private String state; + + /** + *
+   * 字段名:报关结果说明
+   * 变量名:explanation
+   * 是否必填:是
+   * 类型:string(128)
+   * 描述:
+   *  申报结果说明,如果状态是失败或异常,显示失败原因
+   *  示例值:支付单已存在并且为非退单状态
+   * 
+ */ + @SerializedName(value = "explanation") + private String explanation; + + /** + *
+   * 字段名:最后更新时间
+   * 变量名:modify_time
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  最后更新时间,该时间取自微信服务器
+   *  示例值:2015-09-01T10:00:00+08:00
+   * 
+ */ + @SerializedName(value = "modify_time") + private String modifyTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/VerifyCertificateRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/VerifyCertificateRequest.java new file mode 100644 index 0000000000..767a4ce8d8 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/VerifyCertificateRequest.java @@ -0,0 +1,156 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author xifengzhu + */ +@Data +public class VerifyCertificateRequest implements Serializable { + private static final long serialVersionUID = 721089103541592315L; + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + + /** + *
+   * 字段名:微信支付返回的订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:1000320306201511078440737890
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:海关
+   * 变量名:customs
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  海关代码, 枚举值参见参数规定-海关列表(https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter2_3.shtml#menu11)
+   *  示例值:SHANGHAI_ZS
+   * 
+ */ + @SerializedName(value = "customs") + private String customs; + + /** + *
+   * 字段名:商户海关备案号
+   * 变量名:merchant_customs_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户在海关登记的备案号
+   *  示例值:123456
+   * 
+ */ + @SerializedName(value = "merchant_customs_no") + private String merchantCustomsNo; + + /** + *
+   * 字段名:商户子订单号
+   * 变量名:sub_order_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户子订单号,如有拆单则必传
+   *  注意:仅适用于机构模式
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "sub_order_no") + private String subOrderNo; + + /** + *
+   * 字段名:证件类型
+   * 变量名:certificate_type
+   * 是否必填:是
+   * 类型:string(16)
+   * 描述:
+   *  请传固定值IDCARD,暂只支持大陆身份证
+   *  示例值:IDCARD
+   * 
+ */ + @SerializedName(value = "certificate_type") + private String certificateType; + + /** + *
+   * 字段名:证件号
+   * 变量名:certificate_id
+   * 是否必填:是
+   * 类型:string
+   * 描述:
+   *  用户大陆身份证号,尾号为字母X的身份证号,请大写字母X。该字段需要进行加密
+   *  示例值:330821198809085211
+   * 
+ */ + @SerializedName(value = "certificate_id") + private String certificateId; + + /** + *
+   * 字段名:证件姓名
+   * 变量名:certificate_name
+   * 是否必填:是
+   * 类型:string
+   * 描述:
+   *  证件姓名,字段值需要进行加密
+   *  示例值:330821198809085211
+   * 
+ */ + @SerializedName(value = "certificate_name") + private String certificateName; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/VerifyCertificateResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/VerifyCertificateResult.java new file mode 100644 index 0000000000..d97049cb46 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/customs/VerifyCertificateResult.java @@ -0,0 +1,93 @@ +package com.github.binarywang.wxpay.bean.customs; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author xifengzhu + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class VerifyCertificateResult implements Serializable { + private static final long serialVersionUID = -8578640869555299753L; + /** + *
+   * 字段名:机构APPID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信支付分配的商户号
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
+   *  示例值:20150806125346
+   * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + + /** + *
+   * 字段名:微信支付返回的订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  微信分配的公众账号ID
+   *  示例值:1000320306201511078440737890
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:身份核验结果
+   * 变量名:certificate_check_result
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  订购人和支付人身份信息校验结果
+   *  SAME:身份信息校验匹配
+   *  DIFFERENT:身份信息校验不匹配
+   *  示例值:SAME
+   * 
+ */ + @SerializedName(value = "certificate_check_result") + private String certificateCheckResult; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ApplymentsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ApplymentsRequest.java index 41f222ca92..80a32a6e47 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ApplymentsRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ApplymentsRequest.java @@ -6,12 +6,13 @@ import lombok.NoArgsConstructor; import java.io.Serializable; +import java.util.List; /** *
  * 电商平台,可使用该接口,帮助其二级商户进件成为微信支付商户。
- * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_1.shtml
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_1_8.shtml
  * 
*/ @Data @@ -41,18 +42,37 @@ public class ApplymentsRequest implements Serializable { * 是否必填:是 * 类型:string(4) * 描述: - * 枚举值: - * 2401:小微商户,指无营业执照的商户。 + * 非小微的主体类型需与营业执照/登记证书上一致,可参考选择主体指引,枚举值如下。 + * 2401:小微商户,指无营业执照的个人商家。 + * 2500:个人卖家,指无营业执照,已持续从事电子商务经营活动满6个月,且期间经营收入累计超过20万元的个人商家。(若选择该主体,请在“补充说明”填写相关描述)。 * 4:个体工商户,营业执照上的主体类型一般为个体户、个体工商户、个体经营。 * 2:企业,营业执照上的主体类型一般为有限公司、有限责任公司。 - * 3:党政、机关及事业单位,包括国内各级、各类政府机构、事业单位等(如:公安、党团、司法、交通、旅游、工商税务、市政、医疗、教育、学校等机构)。 - * 1708:其他组织,不属于企业、政府/事业单位的组织机构(如社会团体、民办非企业、基金会),要求机构已办理组织机构代码证。 - * 示例值:2401 + * 3:事业单位,包括国内各类事业单位,如:医疗、教育、学校等单位。 + * 2502:政府机关,包括各级、各类政府机关,如机关党委、税务、民政、人社、工商、商务、市监等。 + * 1708:社会组织,包括社会团体、民办非企业、基金会、基层群众性自治组织、农村集体经济组织等组织。 + * 示例值:2 *
*/ @SerializedName(value = "organization_type") private String organizationType; + /** + *
+   * 字段名:是否金融机构
+   * 变量名:finance_institution
+   * 是否必填:条件选填
+   * 类型:bool
+   * 描述:
+   *  选填,请根据申请主体的实际情况填写,可参考选择金融机构指引:
+   *  1、若商户主体是金融机构,则填写:true。
+   *  2、若商户主体不是金融机构,则填写:false。
+   *  若未传入将默认填写:false。
+   *  示例值:true
+   * 
+ */ + @SerializedName(value = "finance_institution") + private Boolean financeInstitution; + /** *
    * 字段名:+营业执照/登记证书信息
@@ -60,9 +80,9 @@ public class ApplymentsRequest implements Serializable {
    * 是否必填:条件选填
    * 类型:object
    * 描述:
-   *  1、主体为“小微”时,不填。
+   *  1、主体为“小微/个人卖家”时,不填。
    *  2、主体为“个体工商户/企业”时,请上传营业执照。
-   *  3、主体为“党政、机关及事业单位/其他组织”时,请上传登记证书。
+   *  3、主体为“政府机关/事业单位/社会组织”时,请上传登记证书。
    * 
*/ @SerializedName(value = "business_license_info") @@ -70,38 +90,75 @@ public class ApplymentsRequest implements Serializable { /** *
-   * 字段名:+组织机构代码证信息
-   * 变量名:organization_cert_info
+   * 字段名:+金融机构许可证信息
+   * 变量名:finance_institution_info
    * 是否必填:条件选填
    * 类型:object
-   * 描述:主体为企业/党政、机关及事业单位/其他组织,且证件号码不是18位时必填。
+   * 描述:当主体是金融机构时,必填
    * 
*/ - @SerializedName(value = "organization_cert_info") - private OrganizationCertInfo organizationCertInfo; + @SerializedName(value = "finance_institution_info") + private FinanceInstitutionInfo financeInstitutionInfo; + + /** + * 字段名:证件持有人类型 + * 变量名:id_holder_type + * 是否必填:条件选填 + * 类型:string + * 描述: + * 1. 主体类型为政府机关/事业单位时选传: + * (1)若上传的是法人证件,则不需要上传该字段。 + * (2)若因特殊情况,无法提供法人证件时,可上传经办人。 (经办人:经商户授权办理微信支付业务的人员,授权范围包括但不限于签约,入驻过程需完成账户验证)。 + * 2. 主体类型为企业/个体户/社会组织时,默认为经营者/法人,不需要上传该字段。 + * LEGAL:法人 + * SUPER:经办人 + * 示例值:LEGAL + */ + @SerializedName(value = "id_holder_type") + private String idHolderType; /** *
    * 字段名:经营者/法人证件类型
    * 变量名:id_doc_type
-   * 是否必填:否
+   * 是否必填:条件选填
    * 类型:string(64)
    * 描述:
-   *  1、主体为“小微”,只可选择:身份证。
-   *  2、主体为“个体户/企业/党政、机关及事业单位/其他组织”,可选择:任一证件类型。
-   *  3、若没有填写,系统默认选择:身份证。
-   *  枚举值:
+   *  1、当证件持有人类型为经营者/法人时,需要填写。其他情况,无需上传。
+   *  2、主体为“小微/个人卖家”,可选择:身份证。
+   *  3、主体为“个体户/企业/事业单位/社会组织”:可选择任一证件类型,主体为“政府机关”仅支持中国大陆居民-身份证类型。
+   *  4、若没有填写,系统默认选择:身份证。
+   *  枚举值:
    *  IDENTIFICATION_TYPE_MAINLAND_IDCARD:中国大陆居民-身份证
    *  IDENTIFICATION_TYPE_OVERSEA_PASSPORT:其他国家或地区居民-护照
-   *  IDENTIFICATION_TYPE_HONGKONG:中国香港居民–来往内地通行证
-   *  IDENTIFICATION_TYPE_MACAO:中国澳门居民–来往内地通行证
-   *  IDENTIFICATION_TYPE_TAIWAN:中国台湾居民–来往大陆通行证
-   *  示例值:IDENTIFICATION_TYPE_MACAO
+   *  IDENTIFICATION_TYPE_HONGKONG:中国香港居民--来往内地通行证
+   *  IDENTIFICATION_TYPE_MACAO:中国澳门居民--来往内地通行证
+   *  IDENTIFICATION_TYPE_TAIWAN:中国台湾居民--来往大陆通行证
+   *  IDENTIFICATION_TYPE_FOREIGN_RESIDENT:外国人居留证
+   *  IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT:港澳居民证
+   *  IDENTIFICATION_TYPE_TAIWAN_RESIDENT:台湾居民证
+   *  示例值:IDENTIFICATION_TYPE_MAINLAND_IDCARD
    * 
*/ @SerializedName(value = "id_doc_type") private String idDocType; + /** + *
+   * 字段名:法定代表人说明函
+   * 变量名:authorize_letter_copy
+   * 是否必填:条件选填
+   * 类型:string(256)
+   * 描述:
+   *  1、当证件持有人类型为经办人时,必须上传。其他情况,无需上传。
+   *  2、若因特殊情况,无法提供法定代表人证件时,请参照示例图打印法定代表人说明函,全部信息需打印,不支持手写商户信息,并加盖公章。
+   *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+   *  示例值:47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+   * 
+ */ + @SerializedName(value = "authorize_letter_copy") + private String authorizeLetterCopy; + /** *
    * 字段名:+经营者/法人身份证信息
@@ -109,8 +166,7 @@ public class ApplymentsRequest implements Serializable {
    * 是否必填:条件选填
    * 类型:object
    * 描述:
-   *  请填写经营者/法人的身份证信息
-   *  证件类型为“身份证”时填写。
+   *  当证件持有人类型为经营者/法人且证件类型为“身份证”时填写。
    *
    * 
*/ @@ -124,7 +180,7 @@ public class ApplymentsRequest implements Serializable { * 变量名:id_doc_info * 是否必填:条件选填 * 类型:object - * 描述:证件类型为“来往内地通行证、来往大陆通行证、护照”时填写。 + * 描述:当证件持有人类型为经营者/法人且证件类型不为“身份证”时填写。 *
*/ @SerializedName(value = "id_doc_info") @@ -133,27 +189,44 @@ public class ApplymentsRequest implements Serializable { /** *
-   * 字段名:是否填写结算账户信息
-   * 变量名:need_account_info
-   * 是否必填:是
+   * 字段名:经营者/法人是否为受益人
+   * 变量名:owner
+   * 是否必填:条件选填
+   * 类型:bool
+   * 描述:主体类型为企业时,需要填写:1、若经营者/法人是最终受益人,则填写:true。2、若经营者/法人不是最终受益人,则填写:false。
+   * 示例值:true
+   * 
+ */ + @SerializedName(value = "owner") + private Boolean owner; + + /** + *
+   * 字段名:最终受益人信息列表
+   * 变量名:ubo_info_list
+   * 是否必填:条件选填
    * 类型:bool
    * 描述:
-   *  可根据实际情况,填写“true”或“false”。
-   *  1、若为“true”,则需填写结算账户信息。
-   *  2、若为“false”,则无需填写结算账户信息。
-   *  示例值:true
+   *  仅企业需要填写。
+   *  若经营者/法人不是最终受益所有人,则需提填写受益所有人信息,最多上传4个。
+   *  若经营者/法人是最终受益所有人之一,可在此填写其他受益所有人信息,最多上传3个。
+   *  根据国家相关法律法规,需要提供公司受益所有人信息,受益所有人需符合至少以下条件之一:
+   *  1、直接或者间接拥有超过25%公司股权或者表决权的自然人。
+   *  2、通过人事、财务等其他方式对公司进行控制的自然人。
+   *  3、公司的高级管理人员,包括公司的经理、副经理、财务负责人、上市公司董事会秘书和公司章程规定的其他人员。
    * 
*/ - @SerializedName(value = "need_account_info") - private Boolean needAccountInfo; + @SerializedName(value = "ubo_info_list") + @SpecEncrypt + private List uboInfoList; /** *
    * 字段名:+结算账户信息
    * 变量名:account_info
-   * 是否必填:条件选填
+   * 是否必填:是
    * 类型:object
-   * 描述:若"是否填写结算账户信息"填写为“true”, 则必填,填写为“false”不填 。
+   * 描述:请填写商家提现收款的银行账户信息
    * 
*/ @SerializedName(value = "account_info") @@ -187,6 +260,18 @@ public class ApplymentsRequest implements Serializable { @SerializedName(value = "sales_scene_info") private SalesSceneInfo salesSceneInfo; + /** + *
+   * 字段名:+结算规则
+   * 变量名:settlement_info
+   * 是否必填:否
+   * 类型:object
+   * 描述:请填写商家的结算费率规则、所属行业等信息。若电商平台未传入,系统将填写默认值
+   * 
+ */ + @SerializedName(value = "settlement_info") + private SettlementInfo settlementInfo; + /** *
    * 字段名:商户简称
@@ -194,7 +279,7 @@ public class ApplymentsRequest implements Serializable {
    * 是否必填:是
    * 类型:string(64)
    * 描述:
-   *  UTF-8格式,中文占3个字节,即最多16个汉字长度。将在支付完成页向买家展示,需与商家的实际售卖商品相符 。
+   *  UTF-8格式,中文占3个字节,即最多21个汉字长度。将在支付完成页向买家展示,需与商家的实际售卖商品相符 。
    *  示例值:腾讯
    * 
*/ @@ -208,9 +293,10 @@ public class ApplymentsRequest implements Serializable { * 是否必填:否 * 类型:string(1024) * 描述: - * 1、若店铺业务包含互联网售药,则需上传特殊资质-《互联网药品交易服务证》。 - * 2、最多可上传5张照片,请填写通过图片上传接口预先上传图片生成好的MediaID 。 - * 示例值:[\"jTpGmxUX3FBWVQ5NJInE4d2I6_H7I4\"] + * 1、根据商户经营业务要求提供相关资质,详情查看《行业对应特殊资质》。 + * 2、请提供为“申请商家主体”所属的特殊资质,可授权使用总公司/分公司的特殊资 质; + * 3、最多可上传5张照片,请填写通过图片上传接口预先上传图片生成好的MediaID 。 + * 示例值:jTpGmxUX3FBWVQ5NJInE4d2I6_H7I4 *
*/ @SerializedName(value = "qualifications") @@ -223,8 +309,8 @@ public class ApplymentsRequest implements Serializable { * 是否必填:否 * 类型:string(1024) * 描述: - * 最多可上传5张照片,请填写通过图片上传接口预先上传图片生成好的MediaID 。 - * 示例值:[\"jTpGmg05InE4d2I6_H7I4\"] + * 根据实际审核情况,额外要求提供。最多可上传5张照片,请填写通过图片上传接口预先上传图片生成好的MediaID 。 + * 示例值:jTpGmg05InE4d2I6_H7I4 *
*/ @SerializedName(value = "business_addition_pics") @@ -235,9 +321,9 @@ public class ApplymentsRequest implements Serializable { * 字段名:补充说明 * 变量名:business_addition_desc * 是否必填:否 - * 类型:string(256) + * 类型:string(512) * 描述: - * 可填写512字以内 。 + * 1、若主体为“个人卖家”,该字段必传,则需填写描述“ 该商户已持续从事电子商务经营活动满6个月,且期间经营收入累计超过20万元。” * 示例值:特殊情况,说明原因 *
*/ @@ -249,20 +335,52 @@ public class ApplymentsRequest implements Serializable { public static class BusinessLicenseInfo implements Serializable { /** *
-     * 字段名:证件扫描件
+     * 字段名:证书类型
+     * 变量名:cert_type
+     * 是否必填:条件选填
+     * 类型:string
+     * 描述:
+     *  1、主体为“政府机关/事业单位/社会组织”时,请上传登记证书类型。
+     *  2、主体为“个体工商户/企业”时,不填。
+     *
+     *  当主体为事业单位时,选择此枚举值:
+     *  CERTIFICATE_TYPE_2388:事业单位法人证书
+     *
+     *  当主体为政府机关,选择此枚举值:
+     *  CERTIFICATE_TYPE_2389:统一社会信用代码证书
+     *
+     *  当主体为社会组织,选择以下枚举值之一:
+     *  CERTIFICATE_TYPE_2389:统一社会信用代码证书
+     *  CERTIFICATE_TYPE_2394:社会团体法人登记证书
+     *  CERTIFICATE_TYPE_2395:民办非企业单位登记证书
+     *  CERTIFICATE_TYPE_2396:基金会法人登记证书
+     *  CERTIFICATE_TYPE_2399:宗教活动场所登记证
+     *  CERTIFICATE_TYPE_2400:政府部门下发的其他有效证明文件
+     *  CERTIFICATE_TYPE_2520:执业许可证/执业证
+     *  CERTIFICATE_TYPE_2521:基层群众性自治组织特别法人统一社会信用代码证
+     *  CERTIFICATE_TYPE_2522:农村集体经济组织登记证
+     *  示例值:CERTIFICATE_TYPE_2388
+     * 
+ */ + @SerializedName(value = "cert_type") + private String certType; + + /** + *
+     * 字段名:营业执照扫描件
      * 变量名:business_license_copy
      * 是否必填:是
      * 类型:string(256)
      * 描述:
      *  1、主体为“个体工商户/企业”时,请上传营业执照的证件图片。
-     *  2、主体为“党政、机关及事业单位/其他组织”时,请上传登记证书的证件图片。
-     *  3、可上传1张图片,请填写通过图片上传接口预先上传图片生成好的MediaID 。
+     *  2、主体为“政府机关/事业单位/社会组织”时,请上传登记证书的证件图片。
+     *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID 。
      *  4、图片要求:
      *  (1)请上传证件的彩色扫描件或彩色数码拍摄件,黑白复印件需加盖公章(公章信息需完整) 。
      *  (2)不得添加无关水印(非微信支付商户申请用途的其他水印)。
      *  (3)需提供证件的正面拍摄件,完整、照面信息清晰可见。信息不清晰、扭曲、压缩变形、反光、不完整均不接受。
      *  (4)不接受二次剪裁、翻拍、PS的证件照片。
-     *  示例值: 47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+     *  示例值:47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
      * 
*/ @SerializedName(value = "business_license_copy") @@ -270,15 +388,14 @@ public static class BusinessLicenseInfo implements Serializable { /** *
-     * 字段名:证件注册号
+     * 字段名:营业执照注册号
      * 变量名:business_license_number
      * 是否必填:是
      * 类型:string(18)
      * 描述:
-     *  1、主体为“个体工商户/企业”时,请填写营业执照上的注册号/统一社会信用代码,须为15位数字或 18位数字|大写字母。
-     *  2、主体为“党政、机关及事业单位/其他组织”时,请填写登记证书的证书编号。
+     *  1、主体为“个体工商户/企业”时,请填写营业执照上的注册号/统一社会信用代码,须为18位数字|大写字母。
+     *  2、主体为“政府机关/事业单位/社会组织”时,请填写登记证书的证书编号。
      *  示例值:123456789012345678
-     *  特殊规则:长度最小15个字节
      * 
*/ @SerializedName(value = "business_license_number") @@ -292,7 +409,7 @@ public static class BusinessLicenseInfo implements Serializable { * 类型:string(128) * 描述: * 1、请填写营业执照/登记证书的商家名称,2~110个字符,支持括号 。 - * 2、个体工商户/党政、机关及事业单位,不能以“公司”结尾。 + * 2、个体工商户/政府机关/事业单位/社会组织,不能以“公司”结尾。 * 3、个体工商户,若营业执照上商户名称为空或为“无”,请填写"个体户+经营者姓名",如“个体户张三” 。 * 示例值:腾讯科技有限公司 *
@@ -321,7 +438,7 @@ public static class BusinessLicenseInfo implements Serializable { * 是否必填:条件选填 * 类型:string(128) * 描述: - * 主体为“党政、机关及事业单位/其他组织”时必填,请填写登记证书的注册地址。 + * 主体为“政府机关/事业单位/社会组织”时必填,请填写登记证书的注册地址。 * 示例值:深圳南山区科苑路 *
*/ @@ -335,11 +452,10 @@ public static class BusinessLicenseInfo implements Serializable { * 是否必填:条件选填 * 类型:string(256) * 描述: - * 1、主体为“党政、机关及事业单位/其他组织”时必填,请填写证件有效期。 + * 1、主体为“政府机关/事业单位/社会组织”时必填,请填写证件有效期。 * 2、若证件有效期为长期,请填写:长期。 * 3、结束时间需大于开始时间。 - * 4、有效期必须大于60天,即结束时间距当前时间需超过60天。 - * 示例值:[\"2014-01-01\",\"长期\"] + * 示例值:["2014-01-01","长期"] *
*/ @SerializedName(value = "business_time") @@ -349,52 +465,41 @@ public static class BusinessLicenseInfo implements Serializable { @Data @NoArgsConstructor - public static class OrganizationCertInfo implements Serializable { + public static class FinanceInstitutionInfo implements Serializable { /** *
-     * 字段名:组织机构代码证照片
-     * 变量名:organization_copy
+     * 字段名:金融机构类型
+     * 变量名:finance_type
      * 是否必填:是
-     * 类型:string(256)
+     * 类型:string
      * 描述:
-     *  可上传1张图片,请填写通过图片上传接口预先上传图片生成好的MediaID。
-     *  示例值:vByf3Gjm7KE53JXv\prrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+     *  金融机构类型需与营业执照/登记证书上一致,可参考选择金融机构指引。
+     *  BANK_AGENT:银行业, 适用于商业银行、政策性银行、农村合作银行、村镇银行、开发性金融机构等
+     *  PAYMENT_AGENT:支付机构, 适用于非银行类支付机构
+     *  INSURANCE:保险业, 适用于保险、保险中介、保险代理、保险经纪等保险类业务
+     *  TRADE_AND_SETTLE:交易及结算类金融机构, 适用于交易所、登记结算类机构、银行卡清算机构、资金清算中心等
+     *  OTHER:其他金融机构, 适用于财务公司、信托公司、金融资产管理公司、金融租赁公司、汽车金融公司、贷款公司、货币经纪公司、消费金融公司、证券业、金融控股公司、股票、期货、货币兑换、小额贷款公司、金融资产管理、担保公司、商业保理公司、典当行、融资租赁公司、财经咨询等其他金融业务
+     *  示例值:BANK_AGENT
      * 
*/ - @SerializedName(value = "organization_copy") - private String organizationCopy; + @SerializedName(value = "finance_type") + private String financeType; /** *
-     * 字段名:组织机构代码
-     * 变量名:organization_number
+     * 字段名:金融机构许可证图片
+     * 变量名:finance_license_pics
      * 是否必填:是
-     * 类型:string(256)
+     * 类型:array
      * 描述:
-     *  1、请填写组织机构代码证上的组织机构代码。
-     *  2、可填写9或10位 数字|字母|连字符。
-     *  示例值:12345679-A
+     *  1、根据所属金融机构类型的许可证要求提供,详情查看金融机构指引。
+     *  2、请提供为“申请商家主体”所属的许可证,可授权使用总公司/分公司的特殊资质。
+     *  3、最多可上传5张照片,请填写通过图片上传API预先上传图片生成好的MediaID。
+     *  示例值:47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
      * 
*/ - @SerializedName(value = "organization_number") - private String organizationNumber; - - /** - *
-     * 字段名:组织机构代码有效期限
-     * 变量名:organization_time
-     * 是否必填:是
-     * 类型:string(256)
-     * 描述:
-     *  1、请填写组织机构代码证的有效期限,注意参照示例中的格式。
-     *  2、若证件有效期为长期,请填写:长期。
-     *  3、结束时间需大于开始时间。
-     *  4、有效期必须大于60天,即结束时间距当前时间需超过60天。
-     *  示例值:[\"2014-01-01\",\"长期\"]
-     * 
- */ - @SerializedName(value = "organization_time") - private String organizationTime; + @SerializedName(value = "finance_license_pics") + private List financeLicensePics; } @@ -408,9 +513,10 @@ public static class IdCardInfo implements Serializable { * 是否必填:是 * 类型:string(256) * 描述: - * 1、请上传经营者/法定代表人的身份证人像面照片。 - * 2、可上传1张图片,请填写通过图片上传接口预先上传图片生成好的MediaID。 - * 示例值:xpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ + * 1、证件类型为“身份证”时,上传身份证人像面照片。 + * 2、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。 + * 3、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。 + * 示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ *
*/ @SerializedName(value = "id_card_copy") @@ -423,9 +529,10 @@ public static class IdCardInfo implements Serializable { * 是否必填:是 * 类型:string(256) * 描述: - * 1、请上传经营者/法定代表人的身份证国徽面照片。 - * 2、可上传1张图片,请填写通过图片上传接口预先上传图片生成好的MediaID 。 - * 示例值:vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4 + * 1、证件类型为“身份证”时,上传身份证国徽面照片。 + * 2、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID 。 + * 3、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。 + * 示例值:47ZC6GC-vnrbEny__Ie_An5-tCpqxuZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4 *
*/ @SerializedName(value = "id_card_national") @@ -439,9 +546,8 @@ public static class IdCardInfo implements Serializable { * 类型:string(256) * 描述: * 1、请填写经营者/法定代表人对应身份证的姓名,2~30个中文字符、英文字符、符号。 - * 2、该字段需进行加密处理,加密方法详见敏感信息加密说明。 - * 示例值:pVd1HJ6v/69bDnuC4EL5Kz4jBHLiCa8MRtelw/wDa4SzfeespQO/0kjiwfqdfg== - * 字段加密:使用APIv3定义的方式加密 + * 2、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) + * 示例值:pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPROvwia4ibL+F6mfjbzQIzfb3HHLEjC4EL5Kz4jBHLiCyOb+tI0m2qhZ9evAM+Jv1z0NVa8MRtelw/wDa4SzfeespQO/0kjiwfqdfg== *
*/ @SerializedName(value = "id_card_name") @@ -453,12 +559,11 @@ public static class IdCardInfo implements Serializable { * 字段名:身份证号码 * 变量名:id_card_number * 是否必填:是 - * 类型:string(18) + * 类型:string(256) * 描述: * 1、请填写经营者/法定代表人对应身份证的号码。 - * 2、15位数字或17位数字+1位数字|X ,该字段需进行加密处理,加密方法详见敏感信息加密说明。 - * 示例值:zV+BEmytMNQCqQ8juwEc4P4TG5xzchG/5IL9DBd+Z0zZXkw==4 - * 特殊规则:长度最小15个字节 + * 2、15位数字或17位数字+1位数字|X ,该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) + * 示例值:AOZdYGISxo4y44/UgZ69bdu9X+tfMUJ9dl+LetjM45/zMbrYu+wWZ8gn4CT3JZKGZjduGdtkRJJp0/0eow96uY1Pk7Rq79Jtt7+I8juwEc4P4TG5xzchG/5IL9DBd+Z0zZXkw== *
*/ @SerializedName(value = "id_card_number") @@ -467,15 +572,46 @@ public static class IdCardInfo implements Serializable { /** *
-     * 字段名:身份证有效期限
+     * 字段名:身份证居住地址
+     * 变量名:id_card_address
+     * 是否必填:条件选填
+     * 类型:string(512)
+     * 描述:
+     *  1、主体类型为企业时,需要填写。其他主体类型,无需上传。
+     *  2、请按照身份证住址填写,如广东省深圳市南山区xx路xx号xx室
+     *  3、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:AOZdYGISxo4y44/UgZ69bdu9X+tfMUJ9dl+LetjM45/zMbrYu+wWZ8gn4CTdo+D/m9MrPg+V4p0/0eow96uY1Pk7Rq79Jtt7+I8juwEc4P4TG5xzchG/5IL9DBd+Z0zZXkw==
+     * 
+ */ + @SerializedName(value = "id_card_address") + @SpecEncrypt + private String idCardAddress; + + /** + *
+     * 字段名:身份证开始时间
+     * 变量名:id_card_valid_time_begin
+     * 是否必填:是
+     * 类型:string(128)
+     * 描述:
+     *  1、请按照示例值填写。
+     *  2、结束时间大于开始时间。
+     *  示例值:2019-06-06
+     * 
+ */ + @SerializedName(value = "id_card_valid_time_begin") + private String idCardValidTimeBegin; + + /** + *
+     * 字段名:身份证结束时间
      * 变量名:id_card_valid_time
      * 是否必填:是
      * 类型:string(128)
      * 描述:
-     *  1、请填写身份证有效期的结束时间,注意参照示例中的格式。
-     *  2、若证件有效期为长期,请填写:长期。
-     *  3、证件有效期需大于60天。
-     *  示例值:2026-06-06,长期
+     *  1、请按照示例值填写,若证件有效期为长期,请填写:长期。
+     *  2、结束时间大于开始时间。
+     *  示例值:2026-06-06
      * 
*/ @SerializedName(value = "id_card_valid_time") @@ -486,6 +622,39 @@ public static class IdCardInfo implements Serializable { @Data @NoArgsConstructor public static class IdDocInfo implements Serializable { + /** + *
+     * 字段名:证件正面照片
+     * 变量名:id_doc_copy
+     * 是否必填:是
+     * 类型:string(256)
+     * 描述:
+     *  1、证件类型不为“身份证”时,上传证件正面照片。
+     *  2、可上传1张图片,请填写通过图片图片上传API预先上传图片生成好的MediaID。
+     *  3、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。
+     *  示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ
+     * 
+ */ + @SerializedName(value = "id_doc_copy") + private String idDocCopy; + + /** + *
+     * 字段名:证件反面照片
+     * 变量名:id_doc_copy_back
+     * 是否必填:条件选填
+     * 类型:string(256)
+     * 描述:
+     *  1、若证件类型为来往通行证、外国人居留证、港澳居住证、台湾居住证时,上传证件反面照片。
+     *  2、若证件类型为护照,无需上传反面照片。
+     *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID 。
+     *  4、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。
+     *  示例值:47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+     * 
+ */ + @SerializedName(value = "id_doc_copy_back") + private String idDocCopyBack; + /** *
      * 字段名:证件姓名
@@ -493,8 +662,9 @@ public static class IdDocInfo implements Serializable {
      * 是否必填:是
      * 类型:string(128)
      * 描述:
-     *  请填写经营者/法人姓名。
-     *  示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4LC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ
+     *  1、请填写经营者/法人姓名。
+     *  2、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ
      * 
*/ @SerializedName(value = "id_doc_name") @@ -506,10 +676,11 @@ public static class IdDocInfo implements Serializable { * 字段名:证件号码 * 变量名:id_doc_number * 是否必填:是 - * 类型:string(128) + * 类型:string(256) * 描述: * 7~11位 数字|字母|连字符 。 - * 示例值:jTpGmxUX3FBWVQ5NJTZvlKX_go0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ + * 该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) + * 示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ *
*/ @SerializedName(value = "id_doc_number") @@ -518,29 +689,45 @@ public static class IdDocInfo implements Serializable { /** *
-     * 字段名:证件照片
-     * 变量名:id_doc_copy
+     * 字段名:证件居住地址
+     * 变量名:id_doc_address
+     * 是否必填:条件选填
+     * 类型:string(512)
+     * 描述:
+     *  1、主体类型为企业时,需要填写。其他主体类型,无需上传。
+     *  2、请按照证件上住址填写,若证件上无住址则按照实际住址填写,如广东省深圳市南山区xx路xx号xx室。
+     *  3、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ
+     * 
+ */ + @SerializedName(value = "id_doc_address") + @SpecEncrypt + private String idDocAddress; + + /** + *
+     * 字段名:证件有效期开始时间
+     * 变量名:doc_period_begin
      * 是否必填:是
-     * 类型:string(256)
+     * 类型:string(128)
      * 描述:
-     *  1、可上传1张图片,请填写通过图片上传接口预先上传图片生成好的MediaID。
-     *  2、2M内的彩色图片,格式可为bmp、png、jpeg、jpg或gif 。
-     *  示例值:xi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+     *  1、请按照示例值填写
+     *  2、结束时间大于开始时间
+     *  示例值:2019-06-06
      * 
*/ - @SerializedName(value = "id_doc_copy") - private String idDocCopy; + @SerializedName(value = "doc_period_begin") + private String docPeriodBegin; /** *
-     * 字段名:证件结束日期
+     * 字段名:证件有效期结束时间
      * 变量名:doc_period_end
      * 是否必填:是
      * 类型:string(128)
      * 描述:
-     *  1、请按照示例值填写。
-     *  2、若证件有效期为长期,请填写:长期。
-     *  3、证件有效期需大于60天 。
+     *  1、请按照示例值填写,若证件有效期为长期,请填写:长期。
+     *  2、结束时间大于开始时间。
      *  示例值:2020-01-02
      * 
*/ @@ -549,6 +736,144 @@ public static class IdDocInfo implements Serializable { } + @Data + @NoArgsConstructor + public static class UboInfo implements Serializable { + /** + *
+     * 字段名:证件类型
+     * 变量名:ubo_id_doc_type
+     * 是否必填:是
+     * 类型:string
+     * 描述:
+     *  请填写受益人的证件类型。
+     *  枚举值:
+     *  IDENTIFICATION_TYPE_MAINLAND_IDCARD:中国大陆居民-身份证
+     *  IDENTIFICATION_TYPE_OVERSEA_PASSPORT:其他国家或地区居民-护照
+     *  IDENTIFICATION_TYPE_HONGKONG:中国香港居民--来往内地通行证
+     *  IDENTIFICATION_TYPE_MACAO:中国澳门居民--来往内地通行证
+     *  IDENTIFICATION_TYPE_TAIWAN:中国台湾居民--来往大陆通行证
+     *  IDENTIFICATION_TYPE_FOREIGN_RESIDENT:外国人居留证
+     *  IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT:港澳居民证
+     *  IDENTIFICATION_TYPE_TAIWAN_RESIDENT:台湾居民证
+     *  示例值:IDENTIFICATION_TYPE_MAINLAND_IDCARD
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_type") + private String uboIdDocType; + + /** + *
+     * 字段名:证件正面照片
+     * 变量名:ubo_id_doc_copy
+     * 是否必填:是
+     * 类型:string(256)
+     * 描述:
+     *  1、请上传受益人证件的正面照片。
+     *  2、若证件类型为身份证,请上传人像面照片。
+     *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+     *  4、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。
+     *  示例值:jTpGmxUXqRTvDujqhThn4ReFxikqJ5YW6zFQ
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_copy") + private String uboIdDocCopy; + + /** + *
+     * 字段名:证件反面照片
+     * 变量名:ubo_id_doc_copy_back
+     * 是否必填:条件选填
+     * 类型:string(256)
+     * 描述:
+     *  1、请上传受益人证件的反面照片。
+     *  2、若证件类型为护照,无需上传反面照片。
+     *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+     *  4、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。
+     *  示例值:jTpGmxUX3FBWVQ5NJTZvvDujqhThn4ReFxikqJ5YW6zFQ
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_copy_back") + private String uboIdDocCopyBack; + + /** + *
+     * 字段名:证件姓名
+     * 变量名:ubo_id_doc_name
+     * 是否必填:是
+     * 类型:string(128)
+     * 描述:
+     *  该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:AOZdYGISxo4y44/Ug4P4TG5xzchG/5IL9DBd+Z0zZXkw==
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_name") + @SpecEncrypt + private String uboIdDocName; + + /** + *
+     * 字段名:证件号码
+     * 变量名:ubo_id_doc_number
+     * 是否必填:是
+     * 类型:string(256)
+     * 描述:
+     *  该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:AOZdYGISxo4y44/Ug4P4TG5xzchG/5IL9DBd+Z0zZXkw==
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_number") + @SpecEncrypt + private String uboIdDocNumber; + + /** + *
+     * 字段名:证件居住地址
+     * 变量名:ubo_id_doc_address
+     * 是否必填:条件选填
+     * 类型:string(512)
+     * 描述:
+     *  1、请按照证件上住址填写,若证件上无住址则按照实际住址填写,如广东省深圳市南山区xx路xx号xx室。
+     *  2、 该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPROvwia4ibL+F6mfjbzQIzfDa4SzfeespQO/0kjiwfqdfg==
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_address") + @SpecEncrypt + private String uboIdDocAddress; + + /** + *
+     * 字段名:证件有效期开始时间
+     * 变量名:ubo_id_doc_period_begin
+     * 是否必填:是
+     * 类型:string(128)
+     * 描述:
+     *  1、请按照示例值填写。
+     *  2、结束时间大于开始时间。
+     *  示例值:2019-06-06
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_period_begin") + private String uboIdDocPeriodBegin; + + /** + *
+     * 字段名:证件有效期结束时间
+     * 变量名:ubo_id_doc_period_end
+     * 是否必填:是
+     * 类型:string(128)
+     * 描述:
+     *  1、请按照示例值填写,若证件有效期为长期,请填写:长期。
+     *  2、结束时间大于开始时间。
+     *  示例值:2026-06-06
+     * 
+ */ + @SerializedName(value = "ubo_id_doc_period_end") + private String uboIdDocPeriodEnd; + + } + @Data @NoArgsConstructor public static class AccountInfo implements Serializable { @@ -559,9 +884,9 @@ public static class AccountInfo implements Serializable { * 是否必填:是 * 类型:string(2) * 描述: - * 1、若主体为企业/党政、机关及事业单位/其他组织,可填写:74-对公账户。 - * 2、若主体为小微,可填写:75-对私账户。 - * 3、若主体为个体工商户,可填写:74-对公账户或75-对私账户。 + * 1、若主体为企业/政府机关/事业单位/社会组织,可填写:74-对公账户。 + * 2、主体为小微/个人卖家,可选择:75-对私账户。 + * 3、若主体为个体工商户,可填写:74-对公账户、75-对私账户。 * 示例值:75 *
*/ @@ -575,7 +900,8 @@ public static class AccountInfo implements Serializable { * 是否必填:是 * 类型:string(10) * 描述: - * 详细参见开户银行对照表。 + * 对私银行调用:查询支持个人业务的银行列表API + * 对公银行调用:查询支持对公业务的银行列表API。 * 示例值:工商银行 *
*/ @@ -591,8 +917,8 @@ public static class AccountInfo implements Serializable { * 描述: * 1、选择经营者个人银行卡时,开户名称必须与身份证姓名一致。 * 2、选择对公账户时,开户名称必须与营业执照上的“商户名称”一致。 - * 3、该字段需进行加密处理,加密方法详见敏感信息加密说明。 - * 示例值:AOZdYGISxo4yw96uY1Pk7Rq79Jtt7+I8juwEc4P4TG5xzchG/5IL9DBd+Z0zZXkw== + * 3、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) + * 示例值:AOZdYGISxo4y44/UgZ69bdu9X+tfMUJ9dl+LetjM45/zMbrYu+wWZ8gn4CTdo+D/m9MrPg+V4sm73oxqdQu/hj7aWyDl4GQtPXVdaztB9jVbVZh3QFzV+BEmytMNQp9dt1uWJktlfdDdLR3AMWyMB377xd+m9bSr/ioDTzagEcGe+vLYiKrzcroQv3OR0p3ppFYoQ3IfYeU/04S4t9rNFL+kyblK2FCCqQ11NdbbHoCrJc7NV4oASq6ZFonjTtgjjgKsadIKHXtb3JZKGZjduGdtkRJJp0/0eow96uY1Pk7Rq79Jtt7+I8juwEc4P4TG5xzchG/5IL9DBd+Z0zZXkw== *
*/ @SerializedName(value = "account_name") @@ -607,6 +933,8 @@ public static class AccountInfo implements Serializable { * 类型:string(12) * 描述: * 至少精确到市,详细参见省市区编号对照表。 + * 注: + * 仅当省市区编号对照表中无对应的省市区编号时,可向上取该银行对应市级编号或省级编号。 * 示例值:110000 *
*/ @@ -620,8 +948,8 @@ public static class AccountInfo implements Serializable { * 是否必填:条件选填 * 类型:string(64) * 描述: - * 1、17家直连银行无需填写,如为其他银行,开户银行全称(含支行)和开户银行联行号二选一。 - * 2、详细参见开户银行全称(含支行)对照表。 + * 1、根据开户银行查询接口中的“是否需要填写支行”判断是否需要填写。如为其他银行,开户银行全称(含支行)和开户银行联行号二选一。 + * 2、详细需调用查询支行列表API查看查询结果。 * 示例值:402713354941 *
*/ @@ -635,10 +963,9 @@ public static class AccountInfo implements Serializable { * 是否必填:条件选填 * 类型:string(128) * 描述: - * 1、17家直连银行无需填写,如为其他银行,开户银行全称(含支行)和开户银行联行号二选一。 - * 2、需填写银行全称,如"深圳农村商业银行XXX支行" 。 - * 3、详细参见开户银行全称(含支行)对照表。 - * 示例值:施秉县农村信用合作联社城关信用社 + * 1、根据开户银行查询接口中的“是否需要填写支行”判断是否需要填写。如为其他银行,开户银行全称(含支行)和开户银行联行号二选一。 + * 2、详细需调用查询支行列表API查看查询结果。 + * 示例值:中国工商银行股份有限公司北京市分行营业部 * */ @SerializedName(value = "bank_name") @@ -652,7 +979,7 @@ public static class AccountInfo implements Serializable { * 类型:string(128) * 描述: * 1、数字,长度遵循系统支持的对公/对私卡号长度要求表。 - * 2、该字段需进行加密处理,加密方法详见敏感信息加密说明。 + * 2、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) * 示例值: d+xT+MQCvrLHUVDWv/8MR/dB7TkXLVfSrUxMPZy6jWWYzpRrEEaYQE8ZRGYoeorwC+w== * */ @@ -660,6 +987,70 @@ public static class AccountInfo implements Serializable { @SpecEncrypt private String accountNumber; + /** + *
+     * 字段名:+银行帐户证明材料
+     * 变量名:account_cert_info
+     * 是否必填:否
+     * 类型:string(128)
+     * 描述:
+     *  1. 当主体类型是“政府机关/事业单位”时或所属行业为“党费”时,支持在有合法资金管理关系的情况下结算账户设置为非同名。
+     *  2. 若结算账户设置为非同名,则需填写非同名证明材料,若结算账户为同名,则无需填写。
+     * 
+ */ + @SerializedName(value = "account_cert_info") + private AccountCertInfo accountCertInfo; + + @Data + @NoArgsConstructor + public static class AccountCertInfo implements Serializable { + /** + *
+       * 字段名:结算证明函
+       * 变量名:settlement_cert_pic
+       * 是否必填:是
+       * 类型:string(256)
+       * 描述:
+       *  1. 请参照示例图打印结算证明函。
+       *  2、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+       *  示例值:47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+       * 
+ */ + @SerializedName(value = "settlement_cert_pic") + private String settlementCertPic; + + /** + *
+       * 字段名:关系证明函
+       * 变量名:relation_cert_pic
+       * 是否必填:是
+       * 类型:string(256)
+       * 描述:
+       *  1. 请参照示例图打印关系证明函。
+       *  2、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+       *  示例值:47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+       * 
+ */ + @SerializedName(value = "relation_cert_pic") + private String relationCertPic; + + /** + *
+       * 字段名:其他补充证明
+       * 变量名:other_cert_pics
+       * 是否必填:是
+       * 类型:array
+       * 描述:
+       *  1. 请提供非同名结算的法律法规、政策通知、政府或上级部门公文等证明文件,以作上述材料的补充证明。
+       *  2、可上传1-3张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+       *  示例值:47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+       * 
+ */ + @SerializedName(value = "other_cert_pics") + private String otherCertPics; + + } + } @Data @@ -672,8 +1063,8 @@ public static class ContactInfo implements Serializable { * 是否必填:是 * 类型:string(2) * 描述: - * 1、小微商户,选择:65-法人/经营者。 - * 2、个体工商户/企业/党政、机关及事业单位/其他组织,可选择:65-法人/经营者、66- 负责人。 (负责人:经商户授权办理微信支付业务的人员,授权范围包括但不限于签约,入驻过程需完成账户验证)。 + * 1、主体为“小微/个人卖家 ”,可选择:65-经营者/法人。 + * 2、主体为“个体工商户/企业/政府机关/事业单位/社会组织”,可选择:65-经营者/法人、66- 经办人。 (经办人:经商户授权办理微信支付业务的人员)。 * 示例值:65 * */ @@ -688,8 +1079,8 @@ public static class ContactInfo implements Serializable { * 类型:string(256) * 描述: * 1、若管理员类型为“法人”,则该姓名需与法人身份证姓名一致。 - * 2、若管理员类型为“经办人”,则可填写实际经办人的姓名。 - * 3、该字段需进行加密处理,加密方法详见敏感信息加密说明。 + * 2、若管理员类型为“经办人”,则可填写实际负责人的姓名。 + * 3、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) * (后续该管理员需使用实名微信号完成签约) * 示例值: pVd1HJ6zyvPedzGaV+X3IdGdbDnuC4Eelw/wDa4SzfeespQO/0kjiwfqdfg== * @@ -698,24 +1089,128 @@ public static class ContactInfo implements Serializable { @SpecEncrypt private String contactName; + /** + *
+     * 字段名:超级管理员证件类型
+     * 变量名:contact_id_doc_type
+     * 是否必填:条件选填
+     * 类型:string
+     * 描述:
+     *  当超级管理员类型是经办人时,请上传超级管理员证件类型。
+     *  IDENTIFICATION_TYPE_MAINLAND_IDCARD:中国大陆居民-身份证
+     *  IDENTIFICATION_TYPE_OVERSEA_PASSPORT:其他国家或地区居民-护照
+     *  IDENTIFICATION_TYPE_HONGKONG:中国香港居民--来往内地通行证
+     *  IDENTIFICATION_TYPE_MACAO:中国澳门居民--来往内地通行证
+     *  IDENTIFICATION_TYPE_TAIWAN:中国台湾居民--来往大陆通行证
+     *  IDENTIFICATION_TYPE_FOREIGN_RESIDENT:外国人居留证
+     *  IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT:港澳居民证
+     *  IDENTIFICATION_TYPE_TAIWAN_RESIDENT:台湾居民证
+     *  示例值:IDENTIFICATION_TYPE_MAINLAND_IDCARD
+     * 
+ */ + @SerializedName(value = "contact_id_doc_type") + private String contactIdDocType; + /** *
      * 字段名:超级管理员身份证件号码
      * 变量名:contact_id_card_number
-     * 是否必填:是
+     * 是否必填:条件选填
      * 类型:string(256)
      * 描述:
-     *  1、若管理员类型为法人,则该身份证号码需与法人身份证号码一致。若管理员类型为经办人,则可填写实际经办人的身份证号码。
+     *  1、若超级管理员类型为法人,则该身份证号码需与法人身份证号码一致。若超级管理员类型为经办人,则可填写实际经办人的身份证号码。
      *  2、可传身份证、来往内地通行证、来往大陆通行证、护照等证件号码。
      *  3、超级管理员签约时,校验微信号绑定的银行卡实名信息,是否与该证件号码一致。
-     *  4、该字段需进行加密处理,加密方法详见敏感信息加密说明。
-     *  示例值:pVd1HJ6zmty7/mYNxLMpRSvMRtelw/wDa4SzfeespQO/0kjiwfqdfg==
+     *  4、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPROvwia4ibL+F6mfjbzQIzfb3HHDnuC4EL5Kz4jBHLiCyOb+tI0m2qhZ9evAM+Jv1z0NVa8MRtelw/wDa4SzfeespQO/0kjiwfqdfg==
      * 
*/ @SerializedName(value = "contact_id_card_number") @SpecEncrypt private String contactIdCardNumber; + /** + *
+     * 字段名:超级管理员证件正面照片
+     * 变量名:contact_id_doc_copy
+     * 是否必填:条件选填
+     * 类型:string(256)
+     * 描述:
+     *  1、当超级管理员类型是经办人时,请上传超级管理员证件的正面照片。
+     *  2、若证件类型为身份证,请上传人像面照片。
+     *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+     *  4、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。
+     *  示例值:jTpGmxUX3FBWVQ5NJTZvvDujqhThn4ReFxikqJ5YW6zFQ
+     * 
+ */ + @SerializedName(value = "contact_id_doc_copy") + private String contactIdDocCopy; + + /** + *
+     * 字段名:超级管理员证件反面照片
+     * 变量名:contact_id_doc_copy_back
+     * 是否必填:条件选填
+     * 类型:string(256)
+     * 描述:
+     *  1、当超级管理员类型是经办人时,请上传超级管理员证件的反面照片。
+     *  2、若证件类型为护照,无需上传反面照片。
+     *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+     *  4、请上传彩色照片or彩色扫描件or复印件(需加盖公章鲜章),可添加“微信支付”相关水印(如微信支付认证)。
+     *  示例值:jTpGmxUX3FBWVQ5NJTZvvDujqhThn4ReFxikqJ5YW6zFQ
+     * 
+ */ + @SerializedName(value = "contact_id_doc_copy_back") + private String contactIdDocCopyBack; + + /** + *
+     * 字段名:超级管理员证件有效期开始时间
+     * 变量名:contact_id_doc_period_begin
+     * 是否必填:条件选填
+     * 类型:string(128)
+     * 描述:
+     *  1、当超级管理员类型是经办人时,请上传证件有效期开始时间。
+     *  2、请按照示例值填写。
+     *  3、结束时间大于开始时间。
+     *  示例值:2019-06-06
+     * 
+ */ + @SerializedName(value = "contact_id_doc_period_begin") + private String contactIdDocPeriodBegin; + + /** + *
+     * 字段名:超级管理员证件有效期结束时间
+     * 变量名:contact_id_doc_period_end
+     * 是否必填:条件选填
+     * 类型:string(128)
+     * 描述:
+     *  1、当超级管理员类型是经办人时,请上传证件有效期结束时间。
+     *  2、请按照示例值填写,若证件有效期为长期,请填写:长期。
+     *  3、结束时间大于开始时间。
+     *  示例值:2026-06-06
+     * 
+ */ + @SerializedName(value = "contact_id_doc_period_end") + private String contactIdDocPeriodEnd; + + /** + *
+     * 字段名:业务办理授权函
+     * 变量名:business_authorization_letter
+     * 是否必填:条件选填
+     * 类型:string(256)
+     * 描述:
+     *  1、当超级管理员类型是经办人时,请上传业务办理授权函。
+     *  2、请参照示例图打印业务办理授权函,全部信息需打印,不支持手写商户信息,并加盖公章。
+     *  3、可上传1张图片,请填写通过图片上传API预先上传图片生成好的MediaID。
+     *  示例值:47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4
+     * 
+ */ + @SerializedName(value = "business_authorization_letter") + private String businessAuthorizationLetter; + /** *
      * 字段名:超级管理员手机
@@ -724,7 +1219,7 @@ public static class ContactInfo implements Serializable {
      * 类型:string(256)
      * 描述:
      *  1、请填写管理员的手机号,11位数字, 用于接收微信支付的重要管理信息及日常操作验证码 。
-     *  2、该字段需进行加密处理,加密方法详见敏感信息加密说明。
+     *  2、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
      *  示例值:pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPROvwia4ibL+F6mfjbzQIzfb3HHLEjZ4YiNWWNeespQO/0kjiwfqdfg==
      * 
*/ @@ -739,9 +1234,10 @@ public static class ContactInfo implements Serializable { * 是否必填:是 * 类型:string(256) * 描述: - * 1、用于接收微信支付的开户邮件及日常业务通知。 - * 2、需要带@,遵循邮箱格式校验 。 - * 3、该字段需进行加密处理,加密方法详见敏感信息加密说明。 + * 1、主体类型为“小微商户/个人卖家”可选填,其他主体需必填。 + * 2、用于接收微信支付的开户邮件及日常业务通知。 + * 3、需要带@,遵循邮箱格式校验 。 + * 4、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) * 示例值:pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPROvwia4ibL+FWWNUlw/wDa4SzfeespQO/0kjiwfqdfg== * */ @@ -787,9 +1283,13 @@ public static class SalesSceneInfo implements Serializable { *
      * 字段名:店铺二维码
      * 变量名:store_qr_code
-     * 是否必填:1、店铺二维码 or 店铺链接二选一必填。 2、若为电商小程序,可上传店铺页面的小程序二维码。 3、请填写通过图片上传接口预先上传图片生成好的MediaID,仅能上传1张图片 。 示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO1D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ
+     * 是否必填:二选一
      * 类型:string(256)
      * 描述:
+     *  1、店铺二维码 or 店铺链接二选一必填。
+     *  2、若为电商小程序,可上传店铺页面的小程序二维码。
+     *  3、请填写通过图片上传API预先上传图片生成好的MediaID,仅能上传1张图片 。
+     *  示例值:jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ
      * 
*/ @SerializedName(value = "store_qr_code") @@ -802,6 +1302,9 @@ public static class SalesSceneInfo implements Serializable { * 是否必填:否 * 类型:string(256) * 描述: + * 1、商户自定义字段,可填写已认证的小程序AppID,认证主体需与二级商户主体一致; + * 2、完成入驻后, 系统发起二级商户号与该AppID的绑定(即配置为sub_appid,可在发起支付时传入) + * 示例值:wxa123344545577 * */ @SerializedName(value = "mini_program_sub_appid") @@ -809,4 +1312,39 @@ public static class SalesSceneInfo implements Serializable { } + @Data + @NoArgsConstructor + public static class SettlementInfo implements Serializable { + /** + *
+     * 字段名:结算规则ID
+     * 变量名:settlement_id
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  1、选填,请选择二级商户的结算规则ID,需匹配电商平台开通工具箱选择的费率档位,详细参见电商二级商户结算规则对照表;https://kf.qq.com/faq/220228qEfuAz220228bMFji6.html
+     *  2、若电商平台未传入,将默认选择0.6%费率对应的结算规则id;
+     *  示例值:719
+     * 
+ */ + @SerializedName(value = "settlement_id") + private Integer settlementId; + + /** + *
+     * 字段名:所属行业
+     * 变量名:qualification_type
+     * 是否必填:二选一
+     * 类型:string[1, 200]
+     * 描述:
+     *  1、选填,请填写二级商户所属的行业名称,映射特殊资质要求,详细参见电商二级商户结算规则对照表;
+     *  2、若电商平台未传入,将默认填写无需特殊资质的行业名称;
+     *  示例值:零售批发/生活娱乐/其他
+     * 
+ */ + @SerializedName(value = "qualification_type") + private String qualificationType; + + } + } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FinishOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FinishOrderRequest.java index 0ab6b526e7..4994abcb24 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FinishOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FinishOrderRequest.java @@ -12,7 +12,7 @@ * * * @author f00lish - * @date 2020/09/12 + * created on 2020/09/12 */ @Data @Builder diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBalanceResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBalanceResult.java index af1d77ad75..a18a3d0f26 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBalanceResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBalanceResult.java @@ -6,7 +6,7 @@ /** * @author f00lish - * @date 2020/09/12 + * created on 2020/09/12 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java index c47a9a045f..95ce55f7d8 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java @@ -9,7 +9,7 @@ * 资金账单请求 * * @author f00lish - * @date 2020/09/28 + * created on 2020/09/28 */ @Data @Builder diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java index 54ab3a1653..206cd1218b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java @@ -9,7 +9,7 @@ * 资金账单结果 * * @author f00lish - * @date 2020/09/28 + * created on 2020/09/28 */ @Data @Builder diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsCloseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsCloseRequest.java index 0222e7145a..c09c1aede6 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsCloseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsCloseRequest.java @@ -10,7 +10,7 @@ * 关闭普通订单请求 * * @author f00lish - * @date 2020/12/09 + * created on 2020/12/09 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsRequest.java index ccfcc5f600..efe0978247 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsRequest.java @@ -1,6 +1,8 @@ package com.github.binarywang.wxpay.bean.ecommerce; import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @@ -11,13 +13,15 @@ /** * 普通支付(电商收付通)API *
- * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/e_transactions.shtml
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/e_transactions.shtml
  * 
* * @author cloudX */ @Data +@Builder @NoArgsConstructor +@AllArgsConstructor public class PartnerTransactionsRequest implements Serializable { private static final long serialVersionUID = -1550405819444680465L; @@ -34,7 +38,6 @@ public class PartnerTransactionsRequest implements Serializable { */ @SerializedName(value = "sp_appid") private String spAppid; - /** *
    * 字段名:服务商户号
@@ -48,7 +51,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "sp_mchid")
   private String spMchid;
-
   /**
    * 
    * 字段名:子商户公众号ID
@@ -75,7 +77,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "sub_mchid")
   private String subMchid;
-
   /**
    * 
    * 字段名:商品描述
@@ -89,7 +90,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "description")
   private String description;
-
   /**
    * 
    * 字段名:商户订单号
@@ -104,7 +104,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "out_trade_no")
   private String outTradeNo;
-
   /**
    * 
    * 字段名:交易结束时间
@@ -118,7 +117,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "time_expire")
   private String timeExpire;
-
   /**
    * 
    * 字段名:附加数据
@@ -132,7 +130,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "attach")
   private String attach;
-
   /**
    * 
    * 字段名:通知地址
@@ -146,7 +143,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "notify_url")
   private String notifyUrl;
-
   /**
    * 
    * 字段名:订单优惠标记
@@ -160,7 +156,17 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "goods_tag")
   private String goodsTag;
-
+  /**
+   * 
+   * 字段名:电子发票入口开放标识
+   * 变量名:support_fapiao
+   * 是否必填:否
+   * 类型:boolean
+   * 描述:传入true时,支付成功消息和支付详情页将出现开票入口。需要在微信支付商户平台或微信公众平台开通电子发票功能,传此字段才可生效。
+   * 
+ */ + @SerializedName(value = "support_fapiao") + private Boolean supportFapiao; /** *
    * 字段名:+结算信息
@@ -172,7 +178,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "settle_info")
   private SettleInfo settleInfo;
-
   /**
    * 
    * 字段名:订单金额
@@ -185,7 +190,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "amount")
   private Amount amount;
-
   /**
    * 
    * 字段名:优惠功能
@@ -198,7 +202,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "detail")
   private Discount detail;
-
   /**
    * 
    * 字段名:支付者
@@ -211,7 +214,6 @@ public class PartnerTransactionsRequest implements Serializable {
    */
   @SerializedName(value = "payer")
   private Payer payer;
-
   /**
    * 
    * 字段名:场景信息
@@ -245,7 +247,6 @@ public static class Discount implements Serializable {
      */
     @SerializedName(value = "cost_price")
     private Integer costPrice;
-
     /**
      * 
      * 字段名:商品小票ID
@@ -259,7 +260,6 @@ public static class Discount implements Serializable {
      */
     @SerializedName(value = "invoice_id")
     private String invoiceId;
-
     /**
      * 
      * 字段名:单品列表
@@ -277,6 +277,7 @@ public static class Discount implements Serializable {
 
   @Data
   @NoArgsConstructor
+  @AllArgsConstructor
   public static class Amount implements Serializable {
     private static final long serialVersionUID = -4967636398225864273L;
 
@@ -293,7 +294,6 @@ public static class Amount implements Serializable {
      */
     @SerializedName(value = "total")
     private Integer total;
-
     /**
      * 
      * 字段名:币类型
@@ -307,11 +307,11 @@ public static class Amount implements Serializable {
      */
     @SerializedName(value = "currency")
     private String currency;
-
   }
 
   @Data
   @NoArgsConstructor
+  @AllArgsConstructor
   public static class Payer implements Serializable {
     private static final long serialVersionUID = -3946401119476159971L;
 
@@ -328,7 +328,6 @@ public static class Payer implements Serializable {
      */
     @SerializedName(value = "sp_openid")
     private String spOpenid;
-
     /**
      * 
      * 字段名:用户子标识
@@ -342,7 +341,6 @@ public static class Payer implements Serializable {
      */
     @SerializedName(value = "sub_openid")
     private String subOpenid;
-
   }
 
   @Data
@@ -365,7 +363,6 @@ public static class SettleInfo implements Serializable {
      */
     @SerializedName(value = "profit_sharing")
     private Boolean profitSharing;
-
     /**
      * 
      * 字段名:补差金额
@@ -380,7 +377,6 @@ public static class SettleInfo implements Serializable {
      */
     @SerializedName(value = "subsidy_amount")
     private BigDecimal subsidyAmount;
-
   }
 
   @Data
@@ -401,7 +397,6 @@ public static class GoodsDetail implements Serializable {
      */
     @SerializedName(value = "merchant_goods_id")
     private String merchantGoodsId;
-
     /**
      * 
      * 字段名:微信侧商品编码
@@ -415,7 +410,6 @@ public static class GoodsDetail implements Serializable {
      */
     @SerializedName(value = "wechatpay_goods_id")
     private String wechatpayGoodsId;
-
     /**
      * 
      * 字段名:商品名称
@@ -429,7 +423,6 @@ public static class GoodsDetail implements Serializable {
      */
     @SerializedName(value = "goods_name")
     private String goodsName;
-
     /**
      * 
      * 字段名:商品数量
@@ -443,7 +436,6 @@ public static class GoodsDetail implements Serializable {
      */
     @SerializedName(value = "quantity")
     private Integer quantity;
-
     /**
      * 
      * 字段名:商品单价
@@ -478,7 +470,6 @@ public static class SceneInfo implements Serializable {
      */
     @SerializedName(value = "device_id")
     private String deviceId;
-
     /**
      * 
      * 字段名:用户终端IP
@@ -493,7 +484,6 @@ public static class SceneInfo implements Serializable {
      */
     @SerializedName(value = "payer_client_ip")
     private String payerClientIp;
-
     /**
      * 
      * 字段名:H5场景信息
@@ -506,7 +496,6 @@ public static class SceneInfo implements Serializable {
      */
     @SerializedName(value = "h5_info")
     private H5Info h5Info;
-
     /**
      * 
      * 字段名:商户门店信息
@@ -519,7 +508,6 @@ public static class SceneInfo implements Serializable {
      */
     @SerializedName(value = "store_info")
     private StoreInfo storeInfo;
-
   }
 
   @Data
@@ -543,7 +531,6 @@ public static class H5Info implements Serializable {
      */
     @SerializedName(value = "type")
     private String type;
-
     /**
      * 
      * 字段名:应用名称
@@ -557,7 +544,6 @@ public static class H5Info implements Serializable {
      */
     @SerializedName(value = "app_name")
     private String appName;
-
     /**
      * 
      * 字段名:网站URL
@@ -571,7 +557,6 @@ public static class H5Info implements Serializable {
      */
     @SerializedName(value = "app_url")
     private String appUrl;
-
     /**
      * 
      * 字段名:iOS平台BundleID
@@ -585,7 +570,6 @@ public static class H5Info implements Serializable {
      */
     @SerializedName(value = "bundle_id")
     private String bundleId;
-
     /**
      * 
      * 字段名:Android平台PackageName
@@ -599,7 +583,6 @@ public static class H5Info implements Serializable {
      */
     @SerializedName(value = "package_name")
     private String packageName;
-
   }
 
   @Data
@@ -620,7 +603,6 @@ public static class StoreInfo implements Serializable {
      */
     @SerializedName(value = "id")
     private String id;
-
     /**
      * 
      * 字段名:门店名称
@@ -634,7 +616,6 @@ public static class StoreInfo implements Serializable {
      */
     @SerializedName(value = "name")
     private String name;
-
     /**
      * 
      * 字段名:地区编码
@@ -648,7 +629,6 @@ public static class StoreInfo implements Serializable {
      */
     @SerializedName(value = "area_code")
     private String areaCode;
-
     /**
      * 
      * 字段名:详细地址
@@ -662,6 +642,5 @@ public static class StoreInfo implements Serializable {
      */
     @SerializedName(value = "address")
     private String address;
-
   }
 }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsResult.java
index a79dae78e5..2c9086e7f4 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsResult.java
@@ -12,10 +12,12 @@
  * 
  *   文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/e_transactions/chapter3_5.shtml
  * 
+ * @author cloudX */ @Data @NoArgsConstructor public class PartnerTransactionsResult implements Serializable { + private static final long serialVersionUID = 2371448241965534820L; /** *
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingOrdersUnSplitAmountRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingOrdersUnSplitAmountRequest.java
new file mode 100644
index 0000000000..9aca9d1df2
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingOrdersUnSplitAmountRequest.java
@@ -0,0 +1,36 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+/**
+ * 查询订单剩余待分金额API 请求对象
+ *
+ * @author mshyh
+ * created on  2022/05/26
+ */
+
+
+@Data
+@NoArgsConstructor
+public class ProfitSharingOrdersUnSplitAmountRequest {
+
+  /**
+   * 
+   * 字段名:微信订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:微信支付订单号
+   * 示例值:4208450740201411110007820472
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingOrdersUnSplitAmountResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingOrdersUnSplitAmountResult.java new file mode 100644 index 0000000000..a0c1a6f342 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingOrdersUnSplitAmountResult.java @@ -0,0 +1,47 @@ +package com.github.binarywang.wxpay.bean.ecommerce; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + + + +/** + * 查询订单剩余待分金额API 结果响应 + * + * @author mshyh + * created on 2022/05/26 + */ + +@Data +@NoArgsConstructor +public class ProfitSharingOrdersUnSplitAmountResult { + + /** + *
+   * 字段名:微信支付订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:微信支付订单号。
+   * 示例值:4208450740201411110007820472
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+   * 字段名:订单剩余待分金额
+   * 变量名:unsplit_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:订单剩余待分金额,整数,单位为分。
+   * 示例值:1000
+   * 
+ */ + @SerializedName(value = "unsplit_amount") + private Integer unsplitAmount; + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java index 1ae90c6b80..e41bbe7ed7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java @@ -15,7 +15,7 @@ *
* * @author f00lish - * @date 2020/09/12 + * created on 2020/09/12 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java index 09cc3e843c..8ce2db1a08 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java @@ -11,13 +11,13 @@ * 请求分账 结果响应 * * @author f00lish - * @date 2020/09/12 + * created on 2020/09/12 */ @Data @NoArgsConstructor public class ProfitSharingResult implements Serializable { - private static final long serialVersionUID = 9026456165403642050L; + /** *
    * 字段名:二级商户号
@@ -278,5 +278,18 @@ public static class Receiver implements Serializable {
      */
     @SerializedName(value = "receiver_account")
     private String receiverAccount;
+
+    /**
+     * 
+     * 字段名:分账明细单号
+     * 变量名:detail_id
+     * 类型:string[1,64]
+     * 是否必填:是 (查询明细结果时是必有的)
+     * 描述:微信分账明细单号,每笔分账业务执行的明细单号,可与资金账单对账使用
+     * 示例值:3601111111111111111111
+     * 
+ */ + @SerializedName(value = "detail_id") + private String detailId; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java index a2452a1bad..89ef5d0cbd 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java @@ -199,7 +199,7 @@ public static class Amount implements Serializable { *
*/ @SerializedName(value = "refund") - private String refund; + private Integer refund; /** *
@@ -227,7 +227,7 @@ public static class Amount implements Serializable {
      * 
*/ @SerializedName(value = "payer_refund") - private String payerRefund; + private Integer payerRefund; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java index 3666b43195..96e6c22fab 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java @@ -12,12 +12,12 @@ * *
* * @author f00lish - * @date 2020/09/14 + * created on 2020/09/14 */ @Data @Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor +@AllArgsConstructor public class RefundsRequest implements Serializable { private static final long serialVersionUID = -3186851559004865784L; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java index c83fdf4a5a..9637587409 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java @@ -2,7 +2,7 @@ /** * @author f00lish - * @date 2020/09/17 + * created on 2020/09/17 */ import com.google.gson.annotations.SerializedName; @@ -19,7 +19,7 @@ * *
* * @author f00lish - * @date 2020/09/14 + * created on 2020/09/14 */ @Data @NoArgsConstructor @@ -66,7 +66,7 @@ public class RefundsResult implements Serializable { *
*/ @SerializedName(value = "create_time") - private Date createTime; + private String createTime; /** *
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java
index 6eec6d8f2f..0b488da4a3 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java
@@ -12,7 +12,7 @@
  *  * 
* * @author wangrui - * @date 2021/02/20 + * created on 2021/02/20 */ @Data @Builder diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersRequest.java index 6c0197b722..e3e7c98e34 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersRequest.java @@ -12,7 +12,7 @@ * *
* * @author f00lish - * @date 2020/09/14 + * created on 2020/09/14 */ @Data @Builder diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java index 5655139d0f..b136844f86 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java @@ -9,7 +9,7 @@ /** * @author f00lish - * @date 2020/09/14 + * created on 2020/09/14 */ @Data @Builder @@ -163,6 +163,6 @@ public class ReturnOrdersResult implements Serializable { *
*/ @SerializedName(value = "finish_time") - private Date finishTime; + private String finishTime; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SignatureHeader.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SignatureHeader.java index bd50ac89d4..498a788c07 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SignatureHeader.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SignatureHeader.java @@ -1,5 +1,7 @@ package com.github.binarywang.wxpay.bean.ecommerce; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @@ -8,9 +10,13 @@ /** * 微信通知接口头部信息,需要做签名验证 * 文档地址: https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/qian-ming-yan-zheng + * + * @author cloudX */ @Data +@Builder @NoArgsConstructor +@AllArgsConstructor public class SignatureHeader implements Serializable { private static final long serialVersionUID = -6958015499416059949L; /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java index 1165722bf9..3f0ade6b23 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java @@ -13,7 +13,7 @@ *
* * @author f00lish - * @date 2020/10/27 + * created on 2020/10/27 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java index d76d4a5124..c835a1d3a0 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java @@ -13,7 +13,7 @@ *
* * @author f00lish - * @date 2020/10/27 + * created on 2020/10/27 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillRequest.java index f42127e824..f01079cc73 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillRequest.java @@ -9,7 +9,7 @@ * 交易账单请求 * * @author f00lish - * @date 2020/09/28 + * created on 2020/09/28 */ @Data @Builder diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillResult.java index 477c83aa38..e337bc8e0a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillResult.java @@ -9,7 +9,7 @@ * 交易账单结果 * * @author f00lish - * @date 2020/09/28 + * created on 2020/09/28 */ @Data @Builder diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/FundBillTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/FundBillTypeEnum.java index a5058e2ba7..c728cd8bfd 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/FundBillTypeEnum.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/FundBillTypeEnum.java @@ -7,7 +7,7 @@ * 账单类型 * * @author f00lish - * @date 2020/09/28 + * created on 2020/09/28 */ @Getter @AllArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/SpAccountTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/SpAccountTypeEnum.java index aa53db6c39..25d1148f02 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/SpAccountTypeEnum.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/SpAccountTypeEnum.java @@ -7,7 +7,7 @@ * 服务商账户类型 * * @author f00lish - * @date 2020/09/12 + * created on 2020/09/12 */ @Getter @AllArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryRequest.java index 74e5b4b1a0..87300e8178 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryRequest.java @@ -11,7 +11,7 @@ * 红包发送记录查询请求 * * @author wuyong - * @date 2019-12-01 17:19 + * created on 2019-12-01 17:19 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryResult.java index 996b4a51d1..ab61f72d6f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackQueryResult.java @@ -13,7 +13,7 @@ * 红包发送记录查询返回 * * @author wuyong - * @date 2019-12-01 17:23 + * created on 2019-12-01 17:23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackRequest.java index 762499e693..6ccaece292 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackRequest.java @@ -12,7 +12,7 @@ * 发送企业红包 * * @author wuyong - * @date 2019-12-1 + * created on 2019-12-1 */ @Data @EqualsAndHashCode(callSuper = true) @@ -148,6 +148,11 @@ protected boolean isWxWorkSign() { return true; } + @Override + protected String[] getIgnoredParamsForSign() { + return new String[]{"sign_type"}; + } + @Override protected void storeMap(Map map) { map.put("mch_billno", mchBillNo); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackResult.java index b6c2229d03..5d80354a01 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entpay/EntPayRedpackResult.java @@ -13,7 +13,7 @@ * 企业微信红包返回 * * @author wuyong - * @date 2019-12-01 11:31 + * created on 2019-12-01 11:31 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entwxpay/EntWxEmpPayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entwxpay/EntWxEmpPayRequest.java index 193c5293f7..e093a818da 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entwxpay/EntWxEmpPayRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/entwxpay/EntWxEmpPayRequest.java @@ -227,4 +227,9 @@ protected void storeMap(Map map) { map.put("approval_type", approvalType.toString()); map.put("agentid", agentId.toString()); } + + @Override + protected String[] getIgnoredParamsForSign() { + return new String[]{"sign_type"}; + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorCouponsGetResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorCouponsGetResult.java index 3b89cec058..ff4be12071 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorCouponsGetResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorCouponsGetResult.java @@ -142,6 +142,15 @@ public class FavorCouponsGetResult implements Serializable { @SerializedName("singleitem") private Boolean singleitem; + /** + * 商户单据号 + *

+ * 商户此次发放凭据号(格式:商户id+日期+流水号),可包含英文字母,数字,|,_,*,-等内容,不允许出现其他不合法符号,商户侧需保持唯一性。 + * 示例值: 89560002019101000121 + */ + @SerializedName("out_request_no") + private String outRequestNo; + /** * 满减券信息 *

diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksCreateRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksCreateRequest.java index 2225009075..855edc8528 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksCreateRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksCreateRequest.java @@ -314,8 +314,8 @@ public static class StockUseRule implements Serializable { @Data @NoArgsConstructor public static class PatternInfo implements Serializable { - private static final long serialVersionUID = 1L; + /** *

      * 字段名:使用说明
@@ -391,14 +391,14 @@ public static class PatternInfo implements Serializable {
      * 
*/ @SerializedName(value = "coupon_image") - private Boolean couponImage; + private String couponImage; } @Data @NoArgsConstructor public static class CouponUseRule implements Serializable { - private static final long serialVersionUID = 1L; + /** *
      * 字段名:券生效时间
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksGetResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksGetResult.java
index 7622a19fad..294f273def 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksGetResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksGetResult.java
@@ -34,7 +34,7 @@ public class FavorStocksGetResult implements Serializable {
    * 示例值:123456
    */
   @SerializedName("stock_creator_mchid")
-  private String stockCreatorMchid;
+  private String stockCreatorMchId;
 
   /**
    * 批次名称
@@ -67,7 +67,7 @@ public class FavorStocksGetResult implements Serializable {
    * 示例值:2015-05-20T13:29:35.120+08:00
    */
   @SerializedName("create_time")
-  private String create_time;
+  private String createTime;
 
   /**
    * 使用说明
@@ -112,7 +112,7 @@ public class FavorStocksGetResult implements Serializable {
    * 示例值:100
    */
   @SerializedName("distributed_coupons")
-  private Integer distributedCoupons;
+  private Long distributedCoupons;
 
   /**
    * 是否无资金流
@@ -160,7 +160,7 @@ public class FavorStocksGetResult implements Serializable {
    * 示例值:true
    */
   @SerializedName("singleitem")
-  private Boolean singleitem;
+  private Boolean singleItem;
 
   /**
    * 批次类型
@@ -186,7 +186,7 @@ public static class CutToMessage implements Serializable {
      * 示例值:100
      */
     @SerializedName(value = "single_price_max")
-    private Integer singlePriceMax;
+    private Long singlePriceMax;
 
     /**
      * 减至后的优惠单价
@@ -195,7 +195,7 @@ public static class CutToMessage implements Serializable {
      * 示例值:100
      */
     @SerializedName(value = "cut_to_price")
-    private Integer cutToPrice;
+    private Long cutToPrice;
   }
 
   @Data
@@ -210,7 +210,7 @@ public static class StockUseRule implements Serializable {
      * 示例值:100
      */
     @SerializedName(value = "max_coupons")
-    private Integer maxCoupons;
+    private Long maxCoupons;
 
     /**
      * 总预算
@@ -219,7 +219,7 @@ public static class StockUseRule implements Serializable {
      * 示例值:5000
      */
     @SerializedName(value = "max_amount")
-    private Integer maxAmount;
+    private Long maxAmount;
 
     /**
      * 单天发放上限金额
@@ -228,7 +228,7 @@ public static class StockUseRule implements Serializable {
      * 示例值:400
      */
     @SerializedName(value = "max_amount_by_day")
-    private Integer maxAmountByDay;
+    private Long maxAmountByDay;
 
     /**
      * 固定面额批次特定信息
@@ -245,7 +245,7 @@ public static class StockUseRule implements Serializable {
      * 示例值:3
      */
     @SerializedName(value = "max_coupons_per_user")
-    private Integer maxCouponsPerUser;
+    private Long maxCouponsPerUser;
 
     /**
      * 券类型
@@ -308,7 +308,7 @@ public static class FixedNormalCoupon implements Serializable {
      * 示例值:100
      */
     @SerializedName(value = "coupon_amount")
-    private Integer couponAmount;
+    private Long couponAmount;
 
     /**
      * 门槛
@@ -317,6 +317,6 @@ public static class FixedNormalCoupon implements Serializable {
      * 示例值:100
      */
     @SerializedName(value = "transaction_minimum")
-    private Integer transactionMinimum;
+    private Long transactionMinimum;
   }
 }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksPauseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksPauseResult.java
new file mode 100755
index 0000000000..91e10fbf28
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksPauseResult.java
@@ -0,0 +1,37 @@
+package com.github.binarywang.wxpay.bean.marketing;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 暂停代金券批次返回结果对象
+ *
+ * @author lichuang
+ */
+@NoArgsConstructor
+@Data
+public class FavorStocksPauseResult implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  /**
+   * 生效时间
+   * 

+ * 生效时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 + * 示例值:2015-05-20T13:29:35.120+08:00 + */ + @SerializedName("pause_time") + private String pauseTime; + + /** + * 批次号 + *

+ * 微信为每个代金券批次分配的唯一ID。 + * 示例值:98065001 + */ + @SerializedName("stock_id") + private String stockId; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksQueryRequest.java index 8e37d2f74c..8242f7cce5 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksQueryRequest.java @@ -73,8 +73,9 @@ public class FavorStocksQueryRequest implements Serializable { * 是否必填:否 * 类型:string[1,64] * 描述: - * 起始创建时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 - * 示例值:2015-05-20T13:29:35.120+08:00 + * 起始创建时间,起始创建时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 + * 校验规则:get请求,参数在 url中,需要进行 url 编码传递 + * 示例值:2015-05-20T13:29:35+08:00 *

*/ @SerializedName(value = "create_start_time") @@ -87,8 +88,9 @@ public class FavorStocksQueryRequest implements Serializable { * 是否必填:否 * 类型:string[1,64] * 描述: - * 终止创建时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 - * 示例值:2015-05-20T13:29:35.120+08:00 + * 终止创建时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 + * 校验规则:get请求,参数在 url中,需要进行 url 编码传递 + * 示例值:2015-05-20T13:29:35+08:00 *
*/ @SerializedName(value = "create_end_time") diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksRestartResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksRestartResult.java new file mode 100755 index 0000000000..b9078bca59 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksRestartResult.java @@ -0,0 +1,37 @@ +package com.github.binarywang.wxpay.bean.marketing; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 重启代金券批次返回结果对象 + * + * @author lichuang + */ +@NoArgsConstructor +@Data +public class FavorStocksRestartResult implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 生效时间 + *

+ * 生效时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 + * 示例值:2015-05-20T13:29:35.120+08:00 + */ + @SerializedName("restart_time") + private String restartTime; + + /** + * 批次号 + *

+ * 微信为每个代金券批次分配的唯一ID。 + * 示例值:98065001 + */ + @SerializedName("stock_id") + private String stockId; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthRecordRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthRecordRequest.java new file mode 100644 index 0000000000..cef3e10c1d --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthRecordRequest.java @@ -0,0 +1,135 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *

+ * 查询核身记录
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_5.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class AuthRecordRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:应用ID
+   * 变量名:appid
+   * 是否必填:二选一
+   * 类型:string[1, 32]
+   * 描述:
+   *   是服务商在微信申请公众号/小程序或移动应用成功后分配的账号ID(与服务商主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。
+   *  当输入应用ID时,会校验其与服务商商户号的绑定关系。服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:sub_appid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  是特约商户在微信申请公众号/小程序或移动应用成功后分配的账号ID(与特约商户主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。当输入子商户应用ID时,会校验其与特约商户号的绑定关系。 服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   * 示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:核身日期
+   * 变量名:authenticate_date
+   * 是否必填:是
+   * 类型:string[8, 8]
+   * 描述:
+   *  query核身日期,一次只能查询一天,最久可查询90天内的记录,格式为“YYYY-MM-DD”
+   *     示例值:2020-12-25
+   * 
+ */ + @SerializedName(value = "authenticate_date") + private String authenticateDate; + /** + *
+   * 字段名:核身状态
+   * 变量名:authenticate_state
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   * query核身状态,列表查询仅提供成功状态的核身记录查询,故此字段固定默认值即可
+   *     示例值:AUTHENTICATE_SUCCESS
+   * 
+ */ + @SerializedName(value = "authenticate_state") + private String authenticateState; + /** + *
+   * 字段名:本次查询偏移量
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   * query非负整数,表示该次请求资源的起始位置,从0开始计数。调用方选填,默认为0。offset为10,limit为10时,查询第10-19条数据
+   * 
+ */ + @SerializedName(value = "offset") + private Integer offset; + /** + *
+   * 字段名:本次请求最大查询条数
+   * 变量名:limit
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   * query非0非负的整数,该次请求可返回的最大资源条数,默认值为10,最大支持10条。
+   *     示例值:10
+   * 
+ */ + @SerializedName(value = "limit") + private Integer limit; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthRecordResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthRecordResult.java new file mode 100644 index 0000000000..56cc5f7a8a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthRecordResult.java @@ -0,0 +1,213 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 查询核身记录
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_5.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class AuthRecordResult implements Serializable { + private static final long serialVersionUID = 1L; + + @SerializedName(value = "data") + private List dataList; + + @Data + @NoArgsConstructor + public static class RecordData implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:商户号
+     * 变量名:mchid
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  微信服务商商户的商户号,由微信支付生成并下发。
+     *  示例值:1111111
+     * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + /** + *
+     * 字段名:子商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  微信服务商下特约商户的商户号,由微信支付生成并下发
+     *  示例值:111111
+     * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + /** + *
+     * 字段名:用户标识
+     * 变量名:openid
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  用户在商户对应appid下的唯一标识
+     *  示例值:onqOjjmo8wmTOOtSKwXtGjg9Gb58
+     * 
+ */ + @SerializedName(value = "openid") + private String openid; + /** + *
+     * 字段名:核身渠道
+     * 变量名:authenticate_scene
+     * 是否必填:是
+     * 类型:string[1, 16]
+     * 描述:
+     *  核身渠道,发起核身时的来源渠道,如通过小程序,硬件设备等
+     *         FROM_MINI_APP:来自小程序方式核身
+     *         FROM_HARDWARE:来自硬件设备方式核身
+     *  示例值:FROM_HARDWARE
+     * 
+ */ + @SerializedName(value = "authenticate_scene") + private String authenticateScene; + /** + *
+     * 字段名:核身渠道标识
+     * 变量名:authenticate_source
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  核身渠道标识,用于定位渠道具体来源,如果是扫码打卡渠道标识就是具体的小程序appid,若是硬件设备,则是设备的序列号等
+     *  示例值:wdiooewl7587443649000
+     * 
+ */ + @SerializedName(value = "authenticate_source") + private String authenticateSource; + /** + *
+     * 字段名:项目名称
+     * 变量名:project_name
+     * 是否必填:是
+     * 类型:string[1, 12]
+     * 描述:
+     *  该项目的名称
+     *  示例值:某项目
+     * 
+ */ + @SerializedName(value = "project_name") + private String projectName; + /** + *
+     * 字段名:单位名称
+     * 变量名:employer_name
+     * 是否必填:是
+     * 类型:string[1, 12]
+     * 描述:
+     *    该用户所属的单位名称。
+     *     示例值:某单位名称
+     * 
+ */ + @SerializedName(value = "employer_name") + private String employerName; + /** + *
+     * 字段名:核身状态
+     * 变量名:authenticate_state
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *    核身状态
+     *     AUTHENTICATE_PROCESSING:核身中
+     *     AUTHENTICATE_SUCCESS:核身成功
+     *     AUTHENTICATE_FAILED:核身失败
+     *  示例值:AUTHENTICATE_PROCESSING
+     * 
+ */ + @SerializedName(value = "authenticate_state") + private String authenticateState; + + /** + *
+     * 字段名:核身时间
+     * 变量名:authenticate_time
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *   核身时间,遵循RFC3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     *   示例值:2015-05-20T13:29:35+08:00
+     * 
+ */ + @SerializedName(value = "authenticate_time") + private String authenticateTime; + /** + *
+     * 字段名:商家核身单号
+     * 变量名:authenticate_number
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一
+     *  示例值:mcdhehfgisdhfjghed39384564i83
+     * 
+ */ + @SerializedName(value = "authenticate_number") + private String authenticateNumber; + } + + /** + *
+   * 字段名:总记录条数
+   * 变量名:total_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  经过条件筛选,查询到的记录总数
+   *  示例值:9
+   * 
+ */ + @SerializedName(value = "total_count") + private Integer totalCount; + + /** + *
+   * 字段名:记录起始位置
+   * 变量名:offset
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  该次请求资源的起始位置,请求中包含偏移量时应答消息返回相同偏移量,否则返回默认值0
+   * 
+ */ + @SerializedName(value = "offset") + private Integer offset; + + /** + *
+   * 字段名:本次返回条数
+   * 变量名:limit
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  经过条件筛选,本次查询到的记录条数
+   *  示例值:10
+   * 
+ */ + @SerializedName(value = "limit") + private Integer limit; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthenticationsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthenticationsResult.java new file mode 100644 index 0000000000..f9ffd6c00a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/AuthenticationsResult.java @@ -0,0 +1,182 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 获取核身结果
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_4.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/{authenticate_number}
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class AuthenticationsResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  query微信服务商下特约商户的商户号,由微信支付生成并下发
+   *     示例值:1111111
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  query微信服务商下特约商户的商户号,由微信支付生成并下发
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + /** + *
+   * 字段名:用户标识
+   * 变量名:authenticate_number
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   * 示例值:onqOjjmo8wmTOOtSKwXtGjg9Gb58
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:核身渠道
+   * 变量名:authenticate_scene
+   * 是否必填:是
+   * 类型:string[1, 16]
+   * 描述:
+   *   核身渠道,发起核身时的来源渠道,如通过小程序,硬件设备等
+   *     FROM_MINI_APP:来自小程序方式核身
+   *     FROM_HARDWARE:来自硬件设备方式核身
+   *  示例值:onqOjjmo8wmTOOtSKwXtGjg9Gb58
+   * 
+ */ + @SerializedName(value = "authenticate_scene") + private String authenticateScene; + + /** + *
+   * 字段名:核身渠道标识
+   * 变量名:authenticate_source
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *    核身渠道标识,用于定位渠道具体来源,如果是扫码打卡渠道标识就是具体的小程序appid,若是硬件设备,则是设备的序列号等
+   * 示例值:wdiooewl7587443649000
+   * 
+ */ + @SerializedName(value = "authenticate_source") + private String authenticateSource; + + /** + *
+   * 字段名:项目名称
+   * 变量名:project_name
+   * 是否必填:是
+   * 类型:string[1, 12]
+   * 描述:
+   *    该项目的名称
+   *  示例值:某项目
+   * 
+ */ + @SerializedName(value = "project_name") + private String projectName; + + /** + *
+   * 字段名:单位名称
+   * 变量名:employer_name
+   * 是否必填:是
+   * 类型:string[1, 12]
+   * 描述:
+   *    该用户所属的单位名称。
+   *  示例值:某单位名称
+   * 
+ */ + @SerializedName(value = "employer_name") + private String employerName; + + /** + *
+   * 字段名:核身状态
+   * 变量名:authenticate_state
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *    核身状态
+   *     AUTHENTICATE_PROCESSING:核身中
+   *     AUTHENTICATE_SUCCESS:核身成功
+   *     AUTHENTICATE_FAILED:核身失败
+   *  示例值:AUTHENTICATE_PROCESSING
+   * 
+ */ + @SerializedName(value = "authenticate_state") + private String authenticateState; + /** + *
+   * 字段名:核身时间
+   * 变量名:authenticate_time
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *   核身时间,遵循RFC3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   *   示例值:2015-05-20T13:29:35+08:00
+   * 
+ */ + @SerializedName(value = "authenticate_time") + private String authenticateTime; + /** + *
+   * 字段名:商家核身单号
+   * 变量名:authenticate_number
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一
+   *  示例值:mcdhehfgisdhfjghed39384564i83
+   * 
+ */ + @SerializedName(value = "authenticate_number") + private String authenticateNumber; + + /** + *
+   * 字段名:核身失败原因
+   * 变量名:authenticate_failed_reason
+   * 是否必填:否
+   * 类型:string[1, 128]
+   * 描述:
+   *  结果为核身失败时的原因描述,仅在失败记录返回
+   *  示例值:人脸验证未通过
+   * 
+ */ + @SerializedName(value = "authenticate_failed_reason") + private String authenticateFailedReason; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/MerchantIncomeRecordsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/MerchantIncomeRecordsRequest.java new file mode 100644 index 0000000000..7870c6f376 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/MerchantIncomeRecordsRequest.java @@ -0,0 +1,83 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 服务商银行来账查询
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_28.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/merchantfund/merchant/income-records
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/7 + */ +@Data +@NoArgsConstructor +public class MerchantIncomeRecordsRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:账户类型
+   * 变量名:account_type
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   * query需查询银行来账记录商户的账户类型。
+   *     枚举值:
+   *     BASIC:基本账户
+   *     OPERATION:运营账户
+   *     FEES:手续费账户
+   * 示例值:BASIC
+   * 
+ */ + @SerializedName(value = "account_type") + private String accountType; + /** + *
+   * 字段名:日期
+   * 变量名:date
+   * 是否必填:是
+   * 类型:string[10, 10]
+   * 描述:
+   * query查询的日期,一次只能查询一天,最久可查询90天内的记录,格式为“YYYY-MM-DD”。
+   * 示例值:2019-06-11
+   * 
+ */ + @SerializedName(value = "date") + private String date; + /** + *
+   * 字段名:本次查询偏移量
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   * query非负整数,表示该次请求资源的起始位置,从0开始计数。调用方选填,默认为0。offset为20,limit为100时,查询第20-119条数据。
+   * 示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private int offset; + /** + *
+   * 字段名:本次请求最大查询条数
+   * 变量名:limit
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * query非0非负的整数,该次请求可返回的最大资源条数,最大支持100条。
+   * 示例值:100
+   * 
+ */ + @SerializedName(value = "limit") + private int limit; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/MerchantIncomeRecordsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/MerchantIncomeRecordsResult.java new file mode 100644 index 0000000000..9da71743ab --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/MerchantIncomeRecordsResult.java @@ -0,0 +1,286 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 服务商银行来账查询
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_28.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/merchantfund/merchant/income-records
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/7 + */ +@Data +@NoArgsConstructor +public class MerchantIncomeRecordsResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:查询数据总条数
+   * 变量名:total_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  经过条件筛选,查询到的银行来账记录总数 。
+   * 示例值:20
+   * 
+ */ + @SerializedName(value = "total_count") + private int totalCount; + + /** + *
+   * 字段名:本次查询偏移量
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   * 该次请求资源的起始位置,请求中包含偏移量时应答消息返回相同偏移量,否则返回默认值0。
+   * 示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private int offset; + /** + *
+   * 字段名:本次请求最大查询条数
+   * 变量名:limit
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * 经过条件筛选,本次查询到的银行来账记录条数。
+   * 示例值:100
+   * 
+ */ + @SerializedName(value = "limit") + private int limit; + /** + *
+   * 字段名:银行来账记录列表
+   * 变量名:data
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  单次查询返回的银行来账记录列表结果,如果查询结果为空时,则为空数组。
+   * 
+ */ + @SerializedName(value = "data") + private List incomeRecordDataList; + + + @Data + @NoArgsConstructor + public static class IncomeRecordData implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+     * 字段名:商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  需查询银行来账记录列表的商户号
+     * 示例值:2480253391
+     * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+     * 字段名:账户类型
+     * 变量名:account_type
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  需查询银行来账记录商户的账户类型。
+     *     枚举值:
+     *     BASIC:基本账户
+     *     OPERATION:运营账户
+     *     FEES:手续费账户
+     * 示例值:BASIC
+     * 
+ */ + @SerializedName(value = "account_type") + private String accountType; + /** + *
+     * 字段名:银行来账类型
+     * 变量名:income_record_type
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  银行来账类型,后续会有所扩展。
+     *     枚举值:
+     *     OFFLINERECHARGE:转账充值
+     *     ENTERPRISEDIRECTREVENUE:企业直收
+     * 示例值:OFFLINERECHARGE
+     * 
+ */ + @SerializedName(value = "income_record_type") + private String incomeRecordType; + /** + *
+     * 字段名:银行来账微信单号
+     * 变量名:income_record_id
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  银行来账的微信单号
+     * 示例值:4200000811202011056138519459
+     * 
+ */ + @SerializedName(value = "income_record_id") + private String incomeRecordId; + /** + *
+     * 字段名:银行来账金额
+     * 变量名:amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  银行来账金额,单位为分,只能为整数。
+     * 示例值:2734921
+     * 
+ */ + @SerializedName(value = "amount") + private String amount; + /** + *
+     * 字段名:银行来账完成时间
+     * 变量名:success_time
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  银行来账完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * 示例值:2017-12-08T00:08:00.00+08:00
+     * 
+ */ + @SerializedName(value = "success_time") + private String successTime; + /** + *
+     * 字段名:付款方银行名称
+     * 变量名:bank_name
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  银行来账的付款方银行名称,由于部分银行的数据获取限制,该字段有可能为空。
+     * 示例值:招商银行
+     * 
+ */ + @SerializedName(value = "bank_name") + private String bankName; + /** + *
+     * 字段名:付款方银行户名
+     * 变量名:bank_account_name
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  银行来账的付款方银行账户信息,户名为全称、明文,由于部分银行的数据获取限制,该字段有可能为空。
+     * 示例值:北京三快科技有限公司
+     * 
+ */ + @SerializedName(value = "bank_account_name") + private String bankAccountName; + /** + *
+     * 字段名:付款方银行卡号
+     * 变量名:bank_account_number
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  四位掩码+付款方银行卡尾号后四位。
+     * 示例值:****6473
+     * 
+ */ + @SerializedName(value = "bank_account_number") + private String bankAccountNumber; + /** + *
+     * 字段名:银行备注
+     * 变量名:recharge_remark
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  随银行转账时,商户填入的附言、摘要等信息,目前支持的银行及填写指引请查看各银行对账详情
+     * 示例值:单号:202106010001
+     * 
+ */ + @SerializedName(value = "recharge_remark") + private String rechargeRemark; + } + + /** + *
+   * 字段名:分页链接
+   * 变量名:links
+   * 是否必填:是
+   * 类型:object
+   * 描述:
+   *  返回前后页和当前页面的访问链接
+   * 
+ */ + @SerializedName(value = "links") + private List linksDataList; + + + @Data + @NoArgsConstructor + public static class LinksData implements Serializable { + private static final long serialVersionUID = 109053454401492L; + + /** + *
+     * 字段名:下一页链接
+     * 变量名:next
+     * 是否必填:是
+     * 类型:string[1, 2048]
+     * 描述:
+     *  使用同样的limit进行下一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果已经到最后时,为空 。
+     * 示例值:/v3/merchantfund/partner/income-records?offset=10&limit=5
+     * 
+ */ + @SerializedName(value = "next") + private String next; + /** + *
+     * 字段名:上一页链接
+     * 变量名:prev
+     * 是否必填:是
+     * 类型:string[1, 2048]
+     * 描述:
+     *  使用同样的limit进行上一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果是第一页,为空。
+     * 示例值:/v3/merchantfund/partner/income-records?offset=0&limit=5
+     * 
+ */ + @SerializedName(value = "prev") + private String prev; + /** + *
+     * 字段名:当前链接
+     * 变量名:self
+     * 是否必填:是
+     * 类型:string[1, 2048]
+     * 描述:
+     *  当前的相对请求链接,使用方需要自行根据当前域名进行拼接。
+     * 示例值:/v3/merchantfund/partner/income-records?offset=5&limit=5
+     * 
+ */ + @SerializedName(value = "self") + private String self; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PartnerIncomeRecordsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PartnerIncomeRecordsRequest.java new file mode 100644 index 0000000000..0a4f1cd941 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PartnerIncomeRecordsRequest.java @@ -0,0 +1,97 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 特约商户银行来账查询
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_27.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/merchantfund/partner/income-records
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/7 + */ +@Data +@NoArgsConstructor +public class PartnerIncomeRecordsRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:特约商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  query需查询银行来账记录列表的特约商户的商户号,该商户号须为服务商的特约商户号。
+   *  示例值:2480253391
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:账户类型
+   * 变量名:account_type
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   * query需查询银行来账记录商户的账户类型。
+   *     枚举值:
+   *     BASIC:基本账户
+   *     OPERATION:运营账户
+   *     FEES:手续费账户
+   * 示例值:BASIC
+   * 
+ */ + @SerializedName(value = "account_type") + private String accountType; + /** + *
+   * 字段名:日期
+   * 变量名:date
+   * 是否必填:是
+   * 类型:string[10, 10]
+   * 描述:
+   * query查询的日期,一次只能查询一天,最久可查询90天内的记录,格式为“YYYY-MM-DD”。
+   * 示例值:2019-06-11
+   * 
+ */ + @SerializedName(value = "date") + private String date; + /** + *
+   * 字段名:本次查询偏移量
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   * query非负整数,表示该次请求资源的起始位置,从0开始计数。调用方选填,默认为0。offset为20,limit为100时,查询第20-119条数据。
+   * 示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private int offset; + /** + *
+   * 字段名:本次请求最大查询条数
+   * 变量名:limit
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * query非0非负的整数,该次请求可返回的最大资源条数,最大支持100条。
+   * 示例值:100
+   * 
+ */ + @SerializedName(value = "limit") + private int limit; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PartnerIncomeRecordsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PartnerIncomeRecordsResult.java new file mode 100644 index 0000000000..80b630303a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PartnerIncomeRecordsResult.java @@ -0,0 +1,286 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 特约商户银行来账查询
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_27.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/merchantfund/partner/income-records
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/7 + */ +@Data +@NoArgsConstructor +public class PartnerIncomeRecordsResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:查询数据总条数
+   * 变量名:total_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  经过条件筛选,查询到的银行来账记录总数 。
+   * 示例值:20
+   * 
+ */ + @SerializedName(value = "total_count") + private int totalCount; + + /** + *
+   * 字段名:本次查询偏移量
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   * 该次请求资源的起始位置,请求中包含偏移量时应答消息返回相同偏移量,否则返回默认值0。
+   * 示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private int offset; + /** + *
+   * 字段名:本次请求最大查询条数
+   * 变量名:limit
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * 经过条件筛选,本次查询到的银行来账记录条数。
+   * 示例值:100
+   * 
+ */ + @SerializedName(value = "limit") + private int limit; + /** + *
+   * 字段名:银行来账记录列表
+   * 变量名:data
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  单次查询返回的银行来账记录列表结果,如果查询结果为空时,则为空数组。
+   * 
+ */ + @SerializedName(value = "data") + private List incomeRecordDataList; + + + @Data + @NoArgsConstructor + public static class IncomeRecordData implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+     * 字段名:特约商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  需查询银行来账记录列表的特约商户的商户号,该商户号须为服务商的特约商户号。
+     * 示例值:2480253391
+     * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+     * 字段名:账户类型
+     * 变量名:account_type
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  需查询银行来账记录商户的账户类型。
+     *     枚举值:
+     *     BASIC:基本账户
+     *     OPERATION:运营账户
+     *     FEES:手续费账户
+     * 示例值:BASIC
+     * 
+ */ + @SerializedName(value = "account_type") + private String accountType; + /** + *
+     * 字段名:银行来账类型
+     * 变量名:income_record_type
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  银行来账类型,后续会有所扩展。
+     *     枚举值:
+     *     OFFLINERECHARGE:转账充值
+     *     ENTERPRISEDIRECTREVENUE:企业直收
+     * 示例值:OFFLINERECHARGE
+     * 
+ */ + @SerializedName(value = "income_record_type") + private String incomeRecordType; + /** + *
+     * 字段名:银行来账微信单号
+     * 变量名:income_record_id
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  银行来账的微信单号
+     * 示例值:4200000811202011056138519459
+     * 
+ */ + @SerializedName(value = "income_record_id") + private String incomeRecordId; + /** + *
+     * 字段名:银行来账金额
+     * 变量名:amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  银行来账金额,单位为分,只能为整数。
+     * 示例值:2734921
+     * 
+ */ + @SerializedName(value = "amount") + private String amount; + /** + *
+     * 字段名:银行来账完成时间
+     * 变量名:success_time
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  银行来账完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * 示例值:2017-12-08T00:08:00.00+08:00
+     * 
+ */ + @SerializedName(value = "success_time") + private String successTime; + /** + *
+     * 字段名:付款方银行名称
+     * 变量名:bank_name
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  银行来账的付款方银行名称,由于部分银行的数据获取限制,该字段有可能为空。
+     * 示例值:招商银行
+     * 
+ */ + @SerializedName(value = "bank_name") + private String bankName; + /** + *
+     * 字段名:付款方银行户名
+     * 变量名:bank_account_name
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  银行来账的付款方银行账户信息,户名为全称、明文,由于部分银行的数据获取限制,该字段有可能为空。
+     * 示例值:北京三快科技有限公司
+     * 
+ */ + @SerializedName(value = "bank_account_name") + private String bankAccountName; + /** + *
+     * 字段名:付款方银行卡号
+     * 变量名:bank_account_number
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  四位掩码+付款方银行卡尾号后四位。
+     * 示例值:****6473
+     * 
+ */ + @SerializedName(value = "bank_account_number") + private String bankAccountNumber; + /** + *
+     * 字段名:银行备注
+     * 变量名:recharge_remark
+     * 是否必填:是
+     * 类型:string[1, 256]
+     * 描述:
+     *  随银行转账时,商户填入的附言、摘要等信息,目前支持的银行及填写指引请查看各银行对账详情
+     * 示例值:单号:202106010001
+     * 
+ */ + @SerializedName(value = "recharge_remark") + private String rechargeRemark; + } + + /** + *
+   * 字段名:分页链接
+   * 变量名:links
+   * 是否必填:是
+   * 类型:object
+   * 描述:
+   *  返回前后页和当前页面的访问链接
+   * 
+ */ + @SerializedName(value = "links") + private List linksDataList; + + + @Data + @NoArgsConstructor + public static class LinksData implements Serializable { + private static final long serialVersionUID = 109053454401492L; + + /** + *
+     * 字段名:下一页链接
+     * 变量名:next
+     * 是否必填:是
+     * 类型:string[1, 2048]
+     * 描述:
+     *  使用同样的limit进行下一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果已经到最后时,为空 。
+     * 示例值:/v3/merchantfund/partner/income-records?offset=10&limit=5
+     * 
+ */ + @SerializedName(value = "next") + private String next; + /** + *
+     * 字段名:上一页链接
+     * 变量名:prev
+     * 是否必填:是
+     * 类型:string[1, 2048]
+     * 描述:
+     *  使用同样的limit进行上一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果是第一页,为空。
+     * 示例值:/v3/merchantfund/partner/income-records?offset=0&limit=5
+     * 
+ */ + @SerializedName(value = "prev") + private String prev; + /** + *
+     * 字段名:当前链接
+     * 变量名:self
+     * 是否必填:是
+     * 类型:string[1, 2048]
+     * 描述:
+     *  当前的相对请求链接,使用方需要自行根据当前域名进行拼接。
+     * 示例值:/v3/merchantfund/partner/income-records?offset=5&limit=5
+     * 
+ */ + @SerializedName(value = "self") + private String self; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderRequest.java new file mode 100644 index 0000000000..9bd1278dc1 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderRequest.java @@ -0,0 +1,125 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 微工卡核身预下单
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_3.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order
+ * 请求方式:POST
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class PreOrderRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:应用ID
+   * 变量名:appid
+   * 是否必填:二选一
+   * 类型:string[1, 32]
+   * 描述:
+   *   是服务商在微信申请公众号/小程序或移动应用成功后分配的账号ID(与服务商主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。
+   *  当输入应用ID时,会校验其与服务商商户号的绑定关系。服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   * 示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:sub_appid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  是特约商户在微信申请公众号/小程序或移动应用成功后分配的账号ID(与特约商户主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。当输入子商户应用ID时,会校验其与特约商户号的绑定关系。 服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + + /** + *
+   * 字段名:商家核身单号
+   * 变量名:authenticate_number
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  body商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一
+   *  示例值:mcdhehfgisdhfjghed39384564i83
+   * 
+ */ + @SerializedName(value = "authenticate_number") + private String authenticateNumber; + + /** + *
+   * 字段名:项目名称
+   * 变量名:project_name
+   * 是否必填:是
+   * 类型:string[1, 12]
+   * 描述:
+   * body该项目的名称
+   * 示例值:某项目
+   * 
+ */ + @SerializedName(value = "project_name") + private String projectName; + /** + *
+   * 字段名:单位名称
+   * 变量名:employer_name
+   * 是否必填:是
+   * 类型:string[1, 12]
+   * 描述:
+   * body该用户所属的单位名称
+   * 示例值:某单位名称
+   * 
+ */ + @SerializedName(value = "employer_name") + private String employerName; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderResult.java new file mode 100644 index 0000000000..04b5c6dd25 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderResult.java @@ -0,0 +1,111 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 微工卡核身预下单
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_3.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order
+ * 请求方式:POST
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class PreOrderResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:商家核身单号
+   * 变量名:authenticate_number
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一
+   *  示例值:mcdhehfgisdhfjghed39384564i83
+   * 
+ */ + @SerializedName(value = "authenticate_number") + private String authenticateNumber; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:服务商商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商商户的商户号,由微信支付生成并下发。
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:授权token
+   * 变量名:token
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   *  授权token
+   *  示例值:abcdefghijklmn
+   * 
+ */ + @SerializedName(value = "token") + private String token; + + /** + *
+   * 字段名:token有效时间
+   * 变量名:expires_in
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * token有效时间,单位秒
+   * 示例值:1800
+   * 
+ */ + @SerializedName(value = "expires_in") + private Integer expiresIn; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderWithAuthRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderWithAuthRequest.java new file mode 100644 index 0000000000..1556fbc343 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderWithAuthRequest.java @@ -0,0 +1,169 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 微工卡核身预下单(流程中完成授权)
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_1.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order-with-auth
+ * 请求方式:POST
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class PreOrderWithAuthRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:应用ID
+   * 变量名:appid
+   * 是否必填:二选一
+   * 类型:string[1, 32]
+   * 描述:
+   *   是服务商在微信申请公众号/小程序或移动应用成功后分配的账号ID(与服务商主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。
+   *  当输入应用ID时,会校验其与服务商商户号的绑定关系。服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   * 示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:sub_appid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  是特约商户在微信申请公众号/小程序或移动应用成功后分配的账号ID(与特约商户主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。当输入子商户应用ID时,会校验其与特约商户号的绑定关系。 服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + + /** + *
+   * 字段名:商家核身单号
+   * 变量名:authenticate_number
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一
+   *  示例值:mcdhehfgisdhfjghed39384564i83
+   * 
+ */ + @SerializedName(value = "authenticate_number") + private String authenticateNumber; + + /** + *
+   * 字段名:项目名称
+   * 变量名:project_name
+   * 是否必填:是
+   * 类型:string[1, 12]
+   * 描述:
+   *  该项目的名称
+   *  示例值:某项目
+   * 
+ */ + @SerializedName(value = "project_name") + private String projectName; + /** + *
+   * 字段名:用工单位名称
+   * 变量名:employer_name
+   * 是否必填:是
+   * 类型:string[1, 12]
+   * 描述:
+   *    该用户所属的单位名称。
+   *     示例值:某单位名称
+   * 
+ */ + @SerializedName(value = "employer_name") + private String employerName; + + /** + *
+   * 字段名:用户实名
+   * 变量名:user_name
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   *  用户证件号,该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+   * 示例值:7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5
+   * 
+ */ + @SerializedName(value = "user_name") + private String userName; + + /** + *
+   * 字段名:用户证件号
+   * 变量名:id_card_number
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   *  用户证件号,该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+   * 示例值:7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5
+   * 
+ */ + @SerializedName(value = "id_card_number") + private String idCardNumber; + + /** + *
+   * 字段名:用工类型
+   * 变量名:employment_type
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  微工卡服务仅支持用于与商户有用工关系的用户,需明确用工类型;参考值:
+   * LONG_TERM_EMPLOYMENT:长期用工,
+   * SHORT_TERM_EMPLOYMENT: 短期用工,
+   * COOPERATION_EMPLOYMENT:合作关系
+   * 示例值:LONG_TERM_EMPLOYMENT
+   * 
+ */ + @SerializedName(value = "employment_type") + private String employmentType; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderWithAuthResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderWithAuthResult.java new file mode 100644 index 0000000000..10873d0d3b --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/PreOrderWithAuthResult.java @@ -0,0 +1,110 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 微工卡核身预下单(流程中完成授权)
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_1.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order-with-auth
+ * 请求方式:POST
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class PreOrderWithAuthResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:商家核身单号
+   * 变量名:authenticate_number
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一
+   *  示例值:mcdhehfgisdhfjghed39384564i83
+   * 
+ */ + @SerializedName(value = "authenticate_number") + private String authenticateNumber; + + /** + *
+   * 字段名:用户标识
+   * 变量名:authenticate_number
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   * 示例值:onqOjjmo8wmTOOtSKwXtGjg9Gb58
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商商户的商户号,由微信支付生成并下发
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "mchid") + private Integer mchid; + + /** + *
+   * 字段名:特约商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   *  示例值:1900000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:授权token
+   * 变量名:token
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   *  授权token
+   *  示例值:abcdefghijklmn
+   * 
+ */ + @SerializedName(value = "token") + private String token; + + /** + *
+   * 字段名:token有效时间
+   * 变量名:expires_in
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * token有效时间,单位秒
+   * 示例值:300
+   * 
+ */ + @SerializedName(value = "expires_in") + private Integer expiresIn; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/RelationsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/RelationsRequest.java new file mode 100644 index 0000000000..33d13f6816 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/RelationsRequest.java @@ -0,0 +1,83 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 查询微工卡授权关系
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_2.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/relations/{openid}
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class RelationsRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   * 示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:应用ID
+   * 变量名:appid
+   * 是否必填:二选一
+   * 类型:string[1, 32]
+   * 描述:
+   *   是服务商在微信申请公众号/小程序或移动应用成功后分配的账号ID(与服务商主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。
+   *  当输入应用ID时,会校验其与服务商商户号的绑定关系。服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:sub_appid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  是特约商户在微信申请公众号/小程序或移动应用成功后分配的账号ID(与特约商户主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。当输入子商户应用ID时,会校验其与特约商户号的绑定关系。 服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/RelationsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/RelationsResult.java new file mode 100644 index 0000000000..172e983c35 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/RelationsResult.java @@ -0,0 +1,114 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 查询微工卡授权关系
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_2.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/relations/{openid}
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class RelationsResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:服务商商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商商户的商户号,由微信支付生成并下发。
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:授权状态
+   * 变量名:authorize_state
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  授权状态:
+   *      UNAUTHORIZED:未授权
+   *      AUTHORIZED:已授权
+   *      DEAUTHORIZED:已取消授权
+   * 示例值:UNAUTHORIZED
+   * 
+ */ + @SerializedName(value = "authorize_state") + private String authorizeState; + + /** + *
+   * 字段名:授权时间
+   * 变量名:authorize_time
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  授权时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒。
+   *  示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "authorize_time") + private String authorizeTime; + + /** + *
+   * 字段名:取消授权时间
+   * 变量名:deauthorize_time
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  取消授权时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒。
+   *  示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "deauthorize_time") + private String deauthorizeTime; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/SubFundFlowBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/SubFundFlowBillResult.java new file mode 100644 index 0000000000..c178707abf --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/SubFundFlowBillResult.java @@ -0,0 +1,100 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 申请单个子商户资金账单
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_25.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/bill/sub-merchant-fundflowbill
+ * 请求方式:GET
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/7 + */ +@Data +@NoArgsConstructor +public class SubFundFlowBillResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  query下载指定子商户的账单。
+   *  示例值:19000000001
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:账单日期
+   * 变量名:bill_date
+   * 是否必填:是
+   * 类型:string[10, 10]
+   * 描述:
+   *  query格式YYYY-MM-DD
+   *  示例值:2019-06-11
+   * 
+ */ + @SerializedName(value = "bill_date") + private String billDate; + + /** + *
+   * 字段名:资金账户类型
+   * 变量名:account_type
+   * 是否必填:是
+   * 类型:string[1, 16]
+   * 描述:
+   * query枚举值:
+   *     BASIC:基本账户
+   *     OPERATION:运营账户
+   *     FEES:手续费账户
+   * 示例值:BASIC
+   * 
+ */ + @SerializedName(value = "account_type") + private String accountType; + /** + *
+   * 字段名:加密算法
+   * 变量名:algorithm
+   * 是否必填:是
+   * 类型:string[1, 31]
+   * 描述:
+   * query枚举值:
+   *     AEAD_AES_256_GCM:AEAD_AES_256_GCM加密算法
+   * 示例值:AEAD_AES_256_GCM
+   * 
+ */ + @SerializedName(value = "algorithm") + private String algorithm; + /** + *
+   * 字段名:压缩格式
+   * 变量名:tar_type
+   * 是否必填:否
+   * 类型:string[1, 8]
+   * 描述:
+   * query不填则以不压缩的方式返回数据流
+   *     枚举值:
+   *     GZIP:返回格式为.gzip的压缩包账单
+   * 示例值:GZIP
+   * 
+ */ + @SerializedName(value = "tar_type") + private String tarType; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/TokensRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/TokensRequest.java new file mode 100644 index 0000000000..e8e41ce7c1 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/TokensRequest.java @@ -0,0 +1,128 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 生成授权token
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_1.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/tokens
+ * 请求方式:POST
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class TokensRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:应用ID
+   * 变量名:appid
+   * 是否必填:二选一
+   * 类型:string[1, 32]
+   * 描述:
+   *   是服务商在微信申请公众号/小程序或移动应用成功后分配的账号ID(与服务商主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。
+   *  当输入应用ID时,会校验其与服务商商户号的绑定关系。服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:sub_appid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  是特约商户在微信申请公众号/小程序或移动应用成功后分配的账号ID(与特约商户主体一致),登录平台为mp.weixin.qq.com或open.weixin.qq.com。当输入子商户应用ID时,会校验其与特约商户号的绑定关系。 服务商应用ID和与子商户应用ID至少输入一个,且必须要有拉起微工卡时使用的APPID。
+   *  示例值:wxa1111111
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   * 示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:用户实名
+   * 变量名:user_name
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   *  用户证件号,该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+   * 示例值:7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5
+   * 
+ */ + @SerializedName(value = "user_name") + private String userName; + + /** + *
+   * 字段名:用户证件号
+   * 变量名:id_card_number
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   *  用户证件号,该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+   * 示例值:7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5
+   * 
+ */ + @SerializedName(value = "id_card_number") + private String idCardNumber; + + /** + *
+   * 字段名:用工类型
+   * 变量名:employment_type
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  微工卡服务仅支持用于与商户有用工关系的用户,需明确用工类型;参考值:
+   * LONG_TERM_EMPLOYMENT:长期用工,
+   * SHORT_TERM_EMPLOYMENT: 短期用工,
+   * COOPERATION_EMPLOYMENT:合作关系
+   * 示例值:LONG_TERM_EMPLOYMENT
+   * 
+ */ + @SerializedName(value = "employment_type") + private String employmentType; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/TokensResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/TokensResult.java new file mode 100644 index 0000000000..28ff1db685 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/payroll/TokensResult.java @@ -0,0 +1,97 @@ +package com.github.binarywang.wxpay.bean.marketing.payroll; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 生成授权token
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_1_1.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/tokens
+ * 请求方式:POST
+ * 
+ * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Data +@NoArgsConstructor +public class TokensResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   *  用户在商户对应appid下的唯一标识
+   *  示例值:9x111111
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+   * 字段名:服务商商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商商户的商户号,由微信支付生成并下发。
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "mchid") + private String mchid; + + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信服务商下特约商户的商户号,由微信支付生成并下发
+   *  示例值:1111111
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:授权token
+   * 变量名:token
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   *  授权token
+   *  示例值:abcdefghijklmn
+   * 
+ */ + @SerializedName(value = "token") + private String token; + + /** + *
+   * 字段名:token有效时间
+   * 变量名:expires_in
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * token有效时间,单位秒
+   * 示例值:1800
+   * 
+ */ + @SerializedName(value = "expires_in") + private Integer expiresIn; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchDetailsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchDetailsRequest.java new file mode 100644 index 0000000000..9aa51ce742 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchDetailsRequest.java @@ -0,0 +1,53 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 微信支付明细单号查询明细单API
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer_partner/chapter3_3.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/batch-id/{batch_id}/details/detail-id/{detail_id}
+ * 请求方式:GET
+ * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。
+ * 
+ * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class BatchDetailsRequest implements Serializable { + public static final float serialVersionUID = 1L; + /** + *
+   * 字段名:微信支付批次单号
+   * 变量名:need_query_detail
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  path微信支付批次单号,微信商家转账系统返回的唯一标识
+   *  示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName(value = "batch_id") + private String batchId; + /** + *
+   * 字段名:微信明细单号
+   * 变量名:need_query_detail
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  path微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
+   *  示例值:1040000071100999991182020050700019500100
+   * 
+ */ + @SerializedName(value = "detail_id") + private String detailId; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchDetailsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchDetailsResult.java new file mode 100644 index 0000000000..437def08f2 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchDetailsResult.java @@ -0,0 +1,239 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.Date; + +/** + *
+ * 微信支付明细单号查询明细单API
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer_partner/chapter3_3.shtml
+ *
+ * 适用对象:服务商
+ * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/batch-id/{batch_id}/details/detail-id/{detail_id}
+ * 请求方式:GET
+ * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。
+ * 
+ * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class BatchDetailsResult implements Serializable { + public static final float serialVersionUID = 1L; + + @Override + public String toString() { + return WxGsonBuilder.create().toJson(this); + } + + /** + *
+   * 字段名:服务商商户号
+   * 变量名:sp_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信支付分配的商户号,此处为服务商商户号
+   *  示例值:1900001109
+   * 
+ */ + @SerializedName(value = "sp_mchid") + private String spMchid; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  商户系统内部的商家批次单号,在商户系统内部唯一
+   *     示例值:plfk2020042013
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + /** + *
+   * 字段名:微信支付批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  微信支付批次单号,微信商家转账系统返回的唯一标识
+   *     示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName(value = "batch_id") + private String batchId; + /** + *
+   * 字段名:商户的appid
+   * 变量名:
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   * 微信分配的特约商户公众账号ID。特约商户授权类型为 INFORMATION_AUTHORIZATION_TYPE和
+   *     INFORMATION_AND_FUND_AUTHORIZATION_TYPE时对应的是特约商户的appid,
+   *     特约商户授权类型为FUND_AUTHORIZATION_TYPE时为服务商的appid
+   * 例值:wxf636efh567hg4356
+   * 
+ */ + @Expose + @SerializedName(value = "appid") + private String appId; + /** + *
+   * 字段名:商家明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   * 商户系统内部区分转账批次单下不同转账明细单的唯一标识
+   *     示例值:x23zy545Bd5436
+   * 
+ */ + @SerializedName(value = "out_detail_no") + private String outDetailNo; + /** + *
+   * 字段名:微信支付明细单号
+   * 变量名:detail_id
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   * 微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
+   *     示例值:1040000071100999991182020050700019500100
+   * 
+ */ + @SerializedName(value = "detail_id") + private String detailId; + /** + *
+   * 字段名:明细状态
+   * 变量名:detail_status
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   * 枚举值:
+   *     PROCESSING:转账中。正在处理中,转账结果尚未明确
+   *     SUCCESS:转账成功
+   *     FAIL:转账失败。需要确认失败原因后,再决定是否重新发起对该笔明细单的转账(并非整个转账批次单)
+   * 示例值:SUCCESS
+   * 
+ */ + @SerializedName(value = "detail_status") + private String detailStatus; + /** + *
+   * 字段名:转账金额
+   * 变量名:transfer_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   * 转账金额单位为“分”
+   *     示例值:200000
+   * 
+ */ + @SerializedName(value = "transfer_amount") + private Integer transferAmount; + /** + *
+   * 字段名:转账备注
+   * 变量名:transfer_remark
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   * 单条转账备注(微信用户会收到该备注),UTF8编码,最多允许32个字符
+   *     示例值:2020年4月报销
+   * 
+ */ + @SerializedName(value = "transfer_remark") + private String transferRemark; + /** + *
+   * 字段名:明细失败原因
+   * 变量名:fail_reason
+   * 是否必填:否
+   * 类型:string[1, 64]
+   * 描述:
+   * 如果转账失败则有失败原因:
+   *     ACCOUNT_FROZEN:账户冻结
+   *     REAL_NAME_CHECK_FAIL:用户未实名
+   *     NAME_NOT_CORRECT:用户姓名校验失败
+   *     OPENID_INVALID:Openid校验失败
+   *     TRANSFER_QUOTA_EXCEED:超过用户单笔收款额度
+   *     DAY_RECEIVED_QUOTA_EXCEED:超过用户单日收款额度
+   *     MONTH_RECEIVED_QUOTA_EXCEED:超过用户单月收款额度
+   *     DAY_RECEIVED_COUNT_EXCEED:超过用户单日收款次数
+   *     PRODUCT_AUTH_CHECK_FAIL:产品权限校验失败
+   *     OVERDUE_CLOSE:转账关闭
+   *     ID_CARD_NOT_CORRECT:用户身份证校验失败
+   *     ACCOUNT_NOT_EXIST:用户账户不存在
+   *     TRANSFER_RISK:转账存在风险
+   * 示例值:ACCOUNT_FROZEN
+   * 
+ */ + @SerializedName(value = "fail_reason") + private String failReason; + /** + *
+   * 字段名:收款用户openid
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1, 64]
+   * 描述:
+   * 收款用户openid。如果转账特约商户授权类型是INFORMATION_AUTHORIZATION_TYPE,对应的是特约商户公众号下的openid;
+   *     如果转账特约商户授权类型是FUND_AUTHORIZATION_TYPE,对应的是服务商商户公众号下的openid。
+   * 示例值:o-MYE42l80oelYMDE34nYD456Xoy
+   * 
+ */ + @SerializedName(value = "openid") + private String openid; + /** + *
+   * 字段名:收款用户姓名
+   * 变量名:username
+   * 是否必填:是
+   * 类型:string[1, 1024]
+   * 描述:
+   * 1、收款方姓名。采用标准RSA算法,公钥由微信侧提供
+   * 2、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+   *     示例值:757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45
+   * 
+ */ + @SerializedName(value = "username") + private String userName; + /** + *
+   * 字段名:转账发起时间
+   * 变量名:initiate_time
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   * 转账发起的时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   *     示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "initiate_time") + private String initiateTime; + /** + *
+   * 字段名:明细更新时间
+   * 变量名:initiate_time
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   * 明细最后一次状态变更的时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   *     示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "update_time") + private String updateTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchNumberRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchNumberRequest.java new file mode 100644 index 0000000000..9f53843d66 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchNumberRequest.java @@ -0,0 +1,96 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 微信支付批次单号查询批次单API
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer_partner/chapter3_2.shtml
+ * 
+ * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class BatchNumberRequest implements Serializable { + public static final float serialVersionUID = 1L; + + /** + *
+   * 字段名:微信支付批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  path微信支付批次单号,微信商家转账系统返回的唯一标识
+   *  示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName(value = "batch_id") + private String batchId; + + /** + *
+   * 字段名:是否查询转账明细单
+   * 变量名:need_query_detail
+   * 是否必填:是
+   * 类型:boolean 默认否
+   * 描述:
+   *  商户可选择是否查询指定状态的转账明细单,当转账批次单状态为“FINISHED”(已完成)时,才会返回满足条件的转账明细单
+   *  示例值:true
+   * 
+ */ + @SerializedName(value = "need_query_detail") + private Boolean needQueryDetail; + + /** + *
+   * 字段名:请求资源起始位置
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求资源的起始位置。返回的明细是按照设置的明细条数进行分页展示的,一次查询可能无法返回所有明细,我们使用该参数标识查询开始位置,默认值为0
+   *  示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private Integer offset; + + /** + *
+   * 字段名:最大资源条数
+   * 变量名:limit
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求可返回的最大明细条数,最小20条,最大100条,不传则默认20条。不足20条按实际条数返回
+   * 示例值:20
+   * 
+ */ + @SerializedName(value = "limit") + private Integer limit; + + /** + *
+   * 字段名:明细状态
+   * 变量名:detail_status
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  query查询指定状态的转账明细单,不传没有明细状态信息返回。当need_query_detail为true时,该字段必填
+   *  枚举值:
+   *     ALL:全部。需要同时查询转账成功和转账失败的明细单
+   *     SUCCESS:转账成功。只查询转账成功的明细单
+   *     FAIL:转账失败。只查询转账失败的明细单
+   *  示例值:FAIL
+   * 
+ */ + @SerializedName(value = "detail_status") + private String detailStatus; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchNumberResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchNumberResult.java new file mode 100644 index 0000000000..1defcca943 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BatchNumberResult.java @@ -0,0 +1,393 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 微信支付批次单号查询批次单API
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer_partner/chapter3_2.shtml
+ * 
+ * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class BatchNumberResult implements Serializable { + public static final float serialVersionUID = 1L; + + @Override + public String toString() { + return WxGsonBuilder.create().toJson(this); + } + + /** + *
+   * 字段名:服务商商户号
+   * 变量名:sp_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信支付分配的服务商商户号
+   *  示例值:1900001109
+   * 
+ */ + @SerializedName(value = "sp_mchid") + private String spMchid; + + /** + *
+   * 字段名:特约商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信支付分配的特约商户号
+   *  示例值:1900000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  商户系统内部的商家批次单号,在商户系统内部唯一
+   *  示例值:plfk2020042013
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:微信支付批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  微信支付批次单号,微信商家转账系统返回的唯一标识
+   *  示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName(value = "batch_id") + private String batchId; + /** + *
+   * 字段名:特约商户appid
+   * 变量名:sub_appid
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  微信分配的特约商户公众账号ID。特约商户appid
+   *   示例值:wxf636efh567hg4356
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + /** + *
+   * 字段名:批次状态
+   * 变量名:batch_status
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  枚举值:
+   *     WAIT_PAY:待付款,商户员工确认付款阶段。
+   *     ACCEPTED:已受理。批次已受理成功,若发起批量转账的30分钟后,转账批次单仍处于该状态,可能原因是商户账户余额不足等。商户可查询账户资金流水,若该笔转账批次单的扣款已经发生,则表示批次已经进入转账中,请再次查单确认
+   *     PROCESSING:转账中。已开始处理批次内的转账明细单
+   *     FINISHED:已完成。批次内的所有转账明细单都已处理完成
+   *     CLOSED:已关闭。可查询具体的批次关闭原因确认
+   *  示例值:ACCEPTED
+   * 
+ */ + @SerializedName(value = "batch_status") + private String batchStatus; + + /** + *
+   * 字段名:批次类型
+   * 变量名:batch_type
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  枚举值:
+   *     API:API方式发起
+   *     WEB:页面方式发起
+   * 示例值:API
+   * 
+ */ + @SerializedName(value = "batch_type") + private String batchType; + + /** + *
+   * 字段名:特约商户授权类型
+   * 变量名:authorization_type
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  特约商户授权类型:
+   *     INFORMATION_AUTHORIZATION_TYPE:信息授权类型
+   *     FUND_AUTHORIZATION_TYPE:资金授权类型
+   *     INFORMATION_AND_FUND_AUTHORIZATION_TYPE:信息和资金授权类型
+   * 示例值:INFORMATION_AUTHORIZATION_TYPE
+   * 
+ */ + @SerializedName(value = "authorization_type") + private String authorizationType; + + /** + *
+   * 字段名:批次名称
+   * 变量名:batch_name
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   * 示例值:2019年1月深圳分部报销单
+   * 
+ */ + @SerializedName(value = "batch_name") + private String batchName; + + /** + *
+   * 字段名:批次备注
+   * 变量名:batch_remark
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *      转账说明,UTF8编码,最多允许32个字符
+   *  示例值:2019年1月深圳分部报销单
+   * 
+ */ + @SerializedName(value = "batch_remark") + private String batchRemark; + + /** + *
+   * 字段名:批次关闭原因
+   * 变量名:close_reason
+   * 是否必填:否
+   * 类型:string[1, 64]
+   * 描述:
+   *    如果批次单状态为“CLOSED”(已关闭),则有关闭原因:
+   *     MERCHANT_REVOCATION:商户主动撤销
+   *     OVERDUE_CLOSE:系统超时关闭
+   * 示例值:OVERDUE_CLOSE
+   * 
+ */ + @SerializedName(value = "close_reason") + private String closeReason; + + /** + *
+   * 字段名:转账总金额
+   * 变量名:total_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *   转账金额单位为“分”
+   * 示例值:4000000
+   * 
+ */ + @SerializedName(value = "total_amount") + private Integer totalAmount; + + /** + *
+   * 字段名:转账总笔数
+   * 变量名:total_num
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *   一个转账批次单最多发起三千笔转账
+   * 示例值:200
+   * 
+ */ + @SerializedName(value = "total_num") + private Integer totalNum; + /** + *
+   * 字段名:批次创建时间
+   * 变量名:create_time
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  批次受理成功时返回,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "create_time") + private String createTime; + /** + *
+   * 字段名:批次更新时间
+   * 变量名:update_time
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  批次最近一次状态变更的时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   *  示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "update_time") + private String updateTime; + /** + *
+   * 字段名:转账成功金额
+   * 变量名:success_amount
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  转账成功的金额,单位为“分”。当批次状态为“PROCESSING”(转账中)时,转账成功金额随时可能变化
+   *  示例值:3900000
+   * 
+ */ + @SerializedName(value = "success_amount") + private Integer successAmount; + /** + *
+   * 字段名:转账成功笔数
+   * 变量名:success_num
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  转账成功的笔数。当批次状态为“PROCESSING”(转账中)时,转账成功笔数随时可能变化
+   * 示例值:199
+   * 
+ */ + @SerializedName(value = "success_num") + private Integer successNum; + /** + *
+   * 字段名:转账失败金额
+   * 变量名:fail_amount
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  转账失败的金额,单位为“分”
+   *     示例值:100000
+   * 
+ */ + @SerializedName(value = "fail_amount") + private Integer failAmount; + /** + *
+   * 字段名:转账失败笔数
+   * 变量名:fail_amount
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  转账失败的笔数
+   *     示例值:1
+   * 
+ */ + @SerializedName(value = "fail_num") + private Integer failNum; + /** + *
+   * 字段名:转账明细单列表
+   * 变量名:transfer_detail_list
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  当批次状态为“FINISHED”(已完成),且成功查询到转账明细单时返回。包括微信明细单号、明细状态信息
+   * 
+ */ + @SerializedName(value = "transfer_detail_list") + private List transferDetailList; + + @Data + @NoArgsConstructor + public static class TransferDetail implements Serializable { + private static final long serialVersionUID = 10941148801492L; + /** + *
+     * 字段名:微信支付明细单号
+     * 变量名:detail_id
+     * 是否必填:是
+     * 类型:string[32, 64]
+     * 描述:
+     *  微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
+     *  示例值:1040000071100999991182020050700019500100
+     * 
+ */ + @SerializedName(value = "detail_id") + private String detailId; + + /** + *
+     * 字段名:商家明细单号
+     * 变量名:out_detail_no
+     * 是否必填:是
+     * 类型:string[5, 32]
+     * 描述:
+     *  商户系统内部区分转账批次单下不同转账明细单的唯一标识
+     *  示例值:x23zy545Bd5436
+     * 
+ */ + @SerializedName(value = "out_detail_no") + private String outDetailNo; + + /** + *
+     * 字段名:明细状态
+     * 变量名:detail_status
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *     枚举值:
+     *         PROCESSING:转账中。正在处理中,转账结果尚未明确
+     *         SUCCESS:转账成功
+     *         FAIL:转账失败。需要确认失败原因后,再决定是否重新发起对该笔明细单的转账(并非整个转账批次单)
+     * 示例值:SUCCESS
+     * 
+ */ + @SerializedName(value = "detail_status") + private String detailStatus; + } + + /** + *
+   * 字段名:服务商的appid
+   * 变量名:sp_appid
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *    微信分配的服务商商户公众账号ID,特约商户授权类型为FUND_AUTHORIZATION_TYPE时才有该字段
+   *     示例值:wxf636efh567hg4388
+   * 
+ */ + @SerializedName(value = "sp_appid") + private String spAppid; + /** + *
+   * 字段名:批量转账用途
+   * 变量名:transfer_purpose
+   * 是否必填:否
+   * 类型:string[1,16]
+   * 描述:
+   *   批量转账用途:
+   *     GOODSPAYMENT:货款
+   *     COMMISSION:佣金
+   *     REFUND:退款
+   *     REIMBURSEMENT:报销
+   *     FREIGHT:运费
+   *     OTHERS:其他
+   * 示例值:COMMISSION
+   * 
+ */ + @SerializedName(value = "transfer_purpose") + private String transferPurpose; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BillReceiptResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BillReceiptResult.java new file mode 100644 index 0000000000..ea83328308 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BillReceiptResult.java @@ -0,0 +1,143 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 转账电子回单申请受理API + * 接口说明 + * 适用对象:直连商户 服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/bill-receipt + * 请求方式:POST + * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class BillReceiptResult implements Serializable { + public static final float serialVersionUID = 1L; + + @Override + public String toString() { + return WxGsonBuilder.create().toJson(this); + } + + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5,32]
+   * 描述:
+   *  商户系统内部的商家批次单号,在商户系统内部唯一。需要电子回单的批次单号
+   *  示例值:plfk2020042013
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:电子回单申请单号
+   * 变量名:signature_no
+   * 是否必填:是
+   * 类型:string[3.45]
+   * 描述:
+   *  电子回单申请单号,申请单据的唯一标识
+   *     示例值:1050000010509999485212020110200058820001
+   * 
+ */ + @SerializedName(value = "signature_no") + private String signatureNo; + + /** + *
+   * 字段名:电子回单状态
+   * 变量名:signature_status
+   * 是否必填:否
+   * 类型:string[1,10]
+   * 描述:
+   *  枚举值:
+   *     ACCEPTED:已受理,电子签章已受理成功
+   *     FINISHED:已完成。电子签章已处理完成
+   *     示例值:ACCEPTED
+   * 
+ */ + @SerializedName(value = "signature_status") + private String signatureStatus; + + /** + *
+   * 字段名:电子回单文件的hash方法
+   * 变量名:hash_type
+   * 是否必填:否
+   * 类型:string[1,20]
+   * 描述:
+   *  电子回单文件的hash方法,回单状态为:FINISHED时返回。
+   *     示例值:SHA256
+   * 
+ */ + @SerializedName(value = "hash_type") + private String hashType; + + /** + *
+   * 字段名:电子回单文件的hash值
+   * 变量名:hash_value
+   * 是否必填:否
+   * 类型:string[3,1000]
+   * 描述:
+   *  电子回单文件的hash值,用于下载之后验证文件的完整、正确性,回单状态为:FINISHED时返回。
+   *     示例值:DE731F35146A0BEFADE5DB9D1E468D96C01CA8898119C674FEE9F11F4DBE5529
+   * 
+ */ + @SerializedName(value = "hash_value") + private String hashValue; + + + /** + *
+   * 字段名:电子回单文件的下载地址
+   * 变量名:hash_value
+   * 是否必填:否
+   * 类型:string[10,3000]
+   * 描述:
+   *  电子回单文件的下载地址,回单状态为:FINISHED时返回。URL有效时长为10分钟,10分钟后需要重新去获取下载地址
+   *     示例值:https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx
+   * 
+ */ + @SerializedName(value = "download_url") + private String downloadUrl; + + /** + *
+   * 字段名:创建时间
+   * 变量名:create_time
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   * 	电子签章单创建时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   *     示例值:2020-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "create_time") + private String createTime; + /** + *
+   * 字段名:更新时间
+   * 变量名:update_time
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   * 	电子签章单最近一次状态变更的时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   *     示例值:2020-05-21T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "update_time") + private String updateTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/DownloadRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/DownloadRequest.java new file mode 100644 index 0000000000..50ca1feac7 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/DownloadRequest.java @@ -0,0 +1,65 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 下载电子回单API + * 接口说明 + * 适用对象:直连商户 服务商 + * 请求URL:通过申请账单接口获取到“download_url”,URL有效期10min + * 请求方式:GET + * 前置条件:调用申请账单接口并获取到“download_url” + * 接口规则:https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml + * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class DownloadRequest implements Serializable { + public static final float serialVersionUID = 1L; + + /** + *
+   * 字段名:电子回单文件的hash方法
+   * 变量名:hash_type
+   * 是否必填:否
+   * 类型:string[1, 20]
+   * 描述:
+   *  电子回单文件的hash方法,回单状态为:FINISHED时返回
+   *  例值:SHA256
+   * 
+ */ + @SerializedName(value = "hash_type") + private String hashType; + /** + *
+   * 字段名:电子回单文件的hash值
+   * 变量名:hash_value
+   * 是否必填:否
+   * 类型:string[3, 1000]
+   * 描述:
+   *  电子回单文件的hash值,用于下载之后验证文件的完整、正确性,回单状态为:FINISHED时返回
+   *  示例值:DE731F35146A0BEFADE5DB9D1E468D96C01CA8898119C674FEE9F11F4DBE5529
+   * 
+ */ + @SerializedName(value = "hash_value") + private String hashValue; + /** + *
+   * 字段名:电子回单文件的下载地址
+   * 变量名:download_url
+   * 是否必填:否
+   * 类型:string[10, 3000]
+   * 描述:
+   *  电子回单文件的下载地址,回单状态为:FINISHED时返回。URL有效时长为10分钟,10分钟后需要重新去获取下载地址(但不需要走受理)
+   * 示例值:https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx
+   * 
+ */ + @SerializedName(value = "download_url") + private String downloadUrl; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ElectronicReceiptsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ElectronicReceiptsRequest.java new file mode 100644 index 0000000000..1f4d8134f4 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ElectronicReceiptsRequest.java @@ -0,0 +1,70 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 转账明细电子回单受理API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:POST + * 前置条件:只支持受理最近90天内的转账明细单 + * 接口规则:https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml + * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class ElectronicReceiptsRequest implements Serializable { + public static final float serialVersionUID = 1L; + /** + *
+   * 字段名:受理类型
+   * 变量名:accept_type
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  body电子回单受理类型:
+   *     BATCH_TRANSFER:批量转账明细电子回单
+   *     TRANSFER_TO_POCKET:企业付款至零钱电子回单
+   *     TRANSFER_TO_BANK:企业付款至银行卡电子回单
+   * 示例值:BATCH_TRANSFER
+   * 
+ */ + @SerializedName(value = "accept_type") + private String acceptType; + + /** + *
+   * 字段名:商家转账批次单号
+   * 变量名:out_batch_no
+   * 是否必填:否
+   * 类型:string[5, 32]
+   * 描述:
+   *  body需要电子回单的批量转账明细单所在的转账批次单号,该单号为商户申请转账时生成的商户单号。受理类型为BATCH_TRANSFER时该单号必填,否则该单号留空。
+   *  示例值:GD2021011610162610BBdkkIwcu3
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:商家转账明细单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  body该单号为商户申请转账时生成的商家转账明细单号。
+   *             1.受理类型为BATCH_TRANSFER时填写商家批量转账明细单号。
+   *             2. 受理类型为TRANSFER_TO_POCKET或TRANSFER_TO_BANK时填写商家转账单号。
+   *  示例值:mx0911231610162610v4CNkO4HAf
+   * 
+ */ + @SerializedName(value = "out_detail_no") + private String outDetailNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ElectronicReceiptsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ElectronicReceiptsResult.java new file mode 100644 index 0000000000..114b1982c3 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ElectronicReceiptsResult.java @@ -0,0 +1,137 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 转账明细电子回单受理API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:POST + * 前置条件:只支持受理最近90天内的转账明细单 + * 接口规则:https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml + * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class ElectronicReceiptsResult implements Serializable { + public static final float serialVersionUID = 1L; + /** + *
+   * 字段名:受理类型
+   * 变量名:accept_type
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  电子回单受理类型:
+   *     BATCH_TRANSFER:批量转账明细电子回单
+   *     TRANSFER_TO_POCKET:企业付款至零钱电子回单
+   *     TRANSFER_TO_BANK:企业付款至银行卡电子回单
+   *  示例值:BATCH_TRANSFER
+   * 
+ */ + @SerializedName(value = "accept_type") + private String acceptType; + + /** + *
+   * 字段名:商家转账批次单号
+   * 变量名:out_batch_no
+   * 是否必填:否
+   * 类型:string[5, 32]
+   * 描述:
+   *  需要电子回单的批量转账明细单所在的转账批次单号,该单号为商户申请转账时生成的商户单号。受理类型为BATCH_TRANSFER时该单号必填,否则该单号留空。
+   *  示例值:GD2021011610162610BBdkkIwcu3
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:商家转账明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  该单号为商户申请转账时生成的商家转账明细单号。
+   *     1.受理类型为BATCH_TRANSFER时填写商家批量转账明细单号。
+   *     2. 受理类型为TRANSFER_TO_POCKET或TRANSFER_TO_BANK时填写商家转账单号。
+   *  示例值:mx0911231610162610v4CNkO4HAf
+   * 
+ */ + @SerializedName(value = "out_detail_no") + private String outDetailNo; + /** + *
+   * 字段名:电子回单受理单号
+   * 变量名:signature_no
+   * 是否必填:是
+   * 类型:string[3, 256]
+   * 描述:
+   *  电子回单受理单号,受理单据的唯一标识
+   *  示例值:1050000010509999485212020110200058820001
+   * 
+ */ + @SerializedName(value = "signature_no") + private String signatureNo; + /** + *
+   * 字段名:电子回单状态
+   * 变量名:signature_status
+   * 是否必填:否
+   * 类型:string[1, 10]
+   * 描述:
+   *  枚举值:
+   *     ACCEPTED:已受理,电子签章已受理成功
+   *     FINISHED:已完成。电子签章已处理完成
+   *  示例值:ACCEPTED
+   * 
+ */ + @SerializedName(value = "signature_status") + private String signatureStatus; + /** + *
+   * 字段名:电子回单文件的hash方法
+   * 变量名:hash_type
+   * 是否必填:否
+   * 类型:string[1, 20]
+   * 描述:
+   *  电子回单文件的hash方法,回单状态为:FINISHED时返回
+   *  例值:SHA256
+   * 
+ */ + @SerializedName(value = "hash_type") + private String hashType; + /** + *
+   * 字段名:电子回单文件的hash值
+   * 变量名:hash_value
+   * 是否必填:否
+   * 类型:string[3, 1000]
+   * 描述:
+   *  电子回单文件的hash值,用于下载之后验证文件的完整、正确性,回单状态为:FINISHED时返回
+   *  示例值:DE731F35146A0BEFADE5DB9D1E468D96C01CA8898119C674FEE9F11F4DBE5529
+   * 
+ */ + @SerializedName(value = "hash_value") + private String hashValue; + /** + *
+   * 字段名:电子回单文件的下载地址
+   * 变量名:download_url
+   * 是否必填:否
+   * 类型:string[10, 3000]
+   * 描述:
+   *  电子回单文件的下载地址,回单状态为:FINISHED时返回。URL有效时长为10分钟,10分钟后需要重新去获取下载地址(但不需要走受理)
+   * 示例值:https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx
+   * 
+ */ + @SerializedName(value = "download_url") + private String downloadUrl; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/MerchantBatchRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/MerchantBatchRequest.java new file mode 100644 index 0000000000..fe6450b22e --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/MerchantBatchRequest.java @@ -0,0 +1,97 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 商家批次单号查询批次单API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/out-batch-no/{out_batch_no} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * 接口规则:https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml + * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class MerchantBatchRequest implements Serializable { + public static final float serialVersionUID = 1L; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  path商户系统内部的商家批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   *     示例值:plfk2020042013
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:是否查询转账明细单
+   * 变量名:need_query_detail
+   * 是否必填:是
+   * 类型:boolean 默认否
+   * 描述:
+   *  商户可选择是否查询指定状态的转账明细单,当转账批次单状态为“FINISHED”(已完成)时,才会返回满足条件的转账明细单
+   *  示例值:true
+   * 
+ */ + @SerializedName(value = "need_query_detail") + private Boolean needQueryDetail; + + /** + *
+   * 字段名:请求资源起始位置
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求资源的起始位置。返回的明细是按照设置的明细条数进行分页展示的,一次查询可能无法返回所有明细,我们使用该参数标识查询开始位置,默认值为0
+   *  示例值:0
+   * 
+ */ + @SerializedName(value = "offset") + private Integer offset; + + /** + *
+   * 字段名:最大资源条数
+   * 变量名:limit
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求可返回的最大明细条数,最小20条,最大100条,不传则默认20条。不足20条按实际条数返回
+   * 示例值:20
+   * 
+ */ + @SerializedName(value = "limit") + private Integer limit; + + /** + *
+   * 字段名:明细状态
+   * 变量名:detail_status
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  query查询指定状态的转账明细单,不传没有明细状态信息返回。当need_query_detail为true时,该字段必填
+   *  枚举值:
+   *     ALL:全部。需要同时查询转账成功和转账失败的明细单
+   *     SUCCESS:转账成功。只查询转账成功的明细单
+   *     FAIL:转账失败。只查询转账失败的明细单
+   *  示例值:FAIL
+   * 
+ */ + @SerializedName(value = "detail_status") + private String detailStatus; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/PartnerTransferRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/PartnerTransferRequest.java new file mode 100644 index 0000000000..bd06b5db4b --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/PartnerTransferRequest.java @@ -0,0 +1,289 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 发起批量转账API + *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer_partner/chapter3_1.shtml
+ * 
+ * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class PartnerTransferRequest implements Serializable { + public static final float serialVersionUID = 1L; + + /** + *
+   * 字段名:特约商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  特约商户号
+   *  示例值:1900000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:特约商户appid
+   * 变量名:sub_appid
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *  示例值:wxf636efh567hg4356
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + + /** + *
+   * 字段名:特约商户授权类型
+   * 变量名:authorization_type
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  特约商户授权类型:
+   *    INFORMATION_AUTHORIZATION_TYPE:特约商户信息授权类型
+   *    FUND_AUTHORIZATION_TYPE:特约商户资金授权类型
+   *    INFORMATION_AND_FUND_AUTHORIZATION_TYPE:特约商户信息和资金授权类型
+   * 示例值:INFORMATION_AUTHORIZATION_TYPE
+   * 
+ */ + @SerializedName(value = "authorization_type") + private String authorizationType; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string(5-32)
+   * 描述:
+   *    商户系统内部的商家批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   *    示例值:plfk2020042013
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:批次名称
+   * 变量名:batch_name
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  body该笔批量转账的名称
+   *  示例值:2019年1月深圳分部报销单
+   * 
+ */ + @SerializedName(value = "batch_name") + private String batchName; + + /** + *
+   * 字段名:批次备注
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  body转账说明,UTF8编码,最多允许32个字符
+   *   示例值:2019年1月深圳分部报销单
+   * 
+ */ + @SerializedName(value = "batch_remark") + private String batchRemark; + + /** + *
+   * 字段名:转账总金额
+   * 变量名:time_expire
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  body转账金额单位为“分”。转账总金额必须与批次内所有明细转账金额之和保持一致,否则无法发起转账操作
+   *  示例值:4000000
+   * 
+ */ + @SerializedName(value = "total_amount") + private Integer totalAmount; + + /** + *
+   * 字段名:转账总笔数
+   * 变量名:total_num
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  body一个转账批次单最多发起三千笔转账。转账总笔数必须与批次内所有明细之和保持一致,否则无法发起转账操作
+   *  示例值:200
+   * 
+ */ + @SerializedName(value = "total_num") + private Integer totalNum; + + /** + *
+   * 字段名:转账明细列表
+   * 变量名:transfer_detail_list
+   * 是否必填:是
+   * 类型:array
+   * 描述:
+   *  body发起批量转账的明细列表,最多三千笔
+   * 
+ */ + @SerializedName(value = "transfer_detail_list") + private List transferDetailList; + + @Data + @NoArgsConstructor + public static class TransferDetail implements Serializable { + private static final long serialVersionUID = 109053454401492L; + + /** + *
+     * 字段名:商家明细单号
+     * 变量名:out_detail_no
+     * 是否必填:是
+     * 类型:string[5, 32]
+     * 描述:
+     *  商户系统内部区分转账批次单下不同转账明细单的唯一标识,要求此参数只能由数字、大小写字母组成
+     *  示例值:x23zy545Bd5436
+     * 
+ */ + @SerializedName(value = "out_detail_no") + private String outDetailNo; + + + /** + *
+     * 字段名:转账金额
+     * 变量名:transfer_amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  转账金额单位为“分”
+     *  示例值:200000
+     * 
+ */ + @SerializedName(value = "transfer_amount") + private Integer transferAmount; + + /** + *
+     * 字段名:转账备注
+     * 变量名:transfer_amount
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  单条转账备注(微信用户会收到该备注),UTF8编码,最多允许32个字符
+     *  示例值:2020年4月报销
+     * 
+ */ + @SerializedName(value = "transfer_remark") + private String transferRemark; + + /** + *
+     * 字段名:收款用户openid
+     * 变量名:openid
+     * 是否必填:是
+     * 类型:string[1, 64]
+     * 描述:
+     *  收款用户openid。如果转账特约商户授权类型是INFORMATION_AUTHORIZATION_TYPE,对应的是特约商户公众号下的openid。
+     *  示例值:o-MYE42l80oelYMDE34nYD456Xoy
+     * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+     * 字段名:收款用户姓名
+     * 变量名:user_name
+     * 是否必填:是
+     * 类型:string[1, 1024]
+     * 描述:
+     *  1、收款用户姓名。采用标准RSA算法,公钥由微信侧提供
+     *  2、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45
+     * 
+ */ + @SerializedName(value = "user_name") + private String userName; + /** + *
+     * 字段名:收款用户身份证
+     * 变量名:user_id_card
+     * 是否必填:否
+     * 类型:string[1, 1024]
+     * 描述:
+     *  1、收款方身份证号,可不用填(采用标准RSA算法,公钥由微信侧提供)
+     *  2、该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     *  示例值:8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f
+     * 
+ */ + @SerializedName(value = "user_id_card") + private String userIdCard; + } + + /** + *
+   * 字段名:服务商的appid
+   * 变量名:sp_appid
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  特约商户授权类型为FUND_AUTHORIZATION_TYPE时需要填写
+   *  示例值:wxf636efh567hg4388
+   * 
+ */ + @SerializedName(value = "sp_appid") + private String spAppid; + + + /** + *
+   * 字段名:批量转账用途
+   * 变量名:transfer_purpose
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  body批量转账用途,枚举值:
+   *        GOODSPAYMENT:货款、COMMISSION:佣金、REFUND:退款、REIMBURSEMENT:报销
+   *        FREIGHT:运费、OTHERS:其他
+   *  示例值:COMMISSION
+   * 
+ */ + @SerializedName(value = "transfer_purpose") + private String transferPurpose; + + /** + *
+   * 字段名:转账场景【微工卡】
+   * 变量名:transfer_scene
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  body商户的转账场景
+   *     ORDINARY_TRANSFER:普通转账,可转入用户的零钱账户
+   *     PAYROLL_CARD_TRANSFER:微工卡转账,可转入用户在微工卡选择的收款账户(零钱/银行卡)
+   *  示例值:ORDINARY_TRANSFER
+   * 
+ */ + @SerializedName(value = "transfer_scene") + private String transferScene; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/PartnerTransferResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/PartnerTransferResult.java new file mode 100644 index 0000000000..cca369b408 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/PartnerTransferResult.java @@ -0,0 +1,67 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 发起批量转账API + *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer_partner/chapter3_1.shtml
+ * 
+ * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class PartnerTransferResult implements Serializable { + public static final float serialVersionUID = 1L; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  商户系统内部的商家批次单号,在商户系统内部唯一
+   *  示例值:plfk2020042013
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:微信支付批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[32, 64]
+   * 描述:
+   *  微信支付批次单号,微信商家转账系统返回的唯一标识
+   *  示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName(value = "batch_id") + private String batchId; + + /** + *
+   * 字段名:批次创建时间
+   * 变量名:create_time
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  批次受理成功时返回,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,
+   *  T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,
+   *  领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   *
+   *  示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "create_time") + private String createTime; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ReceiptBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ReceiptBillRequest.java new file mode 100644 index 0000000000..deda24d426 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ReceiptBillRequest.java @@ -0,0 +1,35 @@ +package com.github.binarywang.wxpay.bean.marketing.transfer; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 转账电子回单申请受理API + *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_1.shtml
+ * 
+ * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Data +@NoArgsConstructor +public class ReceiptBillRequest implements Serializable { + public static final float serialVersionUID = 1L; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5, 32]
+   * 描述:
+   *  body商户系统内部的商家批次单号,在商户系统内部唯一。需要电子回单的批次单号
+   *  示例值:plfk2020042013
+   * 
+ */ + @SerializedName(value = "out_batch_no") + private String outBatchNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/BatchesQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/BatchesQueryResult.java new file mode 100644 index 0000000000..17ecc2482b --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/BatchesQueryResult.java @@ -0,0 +1,388 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * The type Batches query result. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class BatchesQueryResult implements Serializable { + private static final long serialVersionUID = -4160610913430904527L; + /** + *
+   * 字段名:最大资源条数
+   * 变量名:limit
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求可返回的最大资源(转账明细单)条数,最小20条,最大100条,不传则默认20条。不足20条按实际条数返回
+   * 示例值:20
+   * 
+ */ + @SerializedName("limit") + private Integer limit; + + /** + *
+   * 字段名:请求资源起始位置
+   * 变量名:transfer_batch
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求资源(转账明细单)的起始位置,从0开始,转账明细单列表为空时不返回
+   * 示例值:1
+   * 
+ */ + @SerializedName("offset") + private Integer offset; + /** + *
+   * 字段名:转账批次单
+   * 变量名:transfer_batch
+   * 是否必填:是
+   * 类型:object
+   * 描述:
+   *  转账批次单基本信息
+   * 
+ */ + @SerializedName("transfer_batch") + private TransferBatch transferBatch; + + /** + *
+   * 字段名:转账明细单列表
+   * 变量名:transfer_detail_list
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  body发起批量转账的明细列表,最多三千笔
+   * 
+ */ + @SerializedName("transfer_detail_list") + private List transferDetailList; + + /** + * The type Transfer batch. + */ + @Data + @Accessors(chain = true) + public static class TransferBatch implements Serializable { + private static final long serialVersionUID = -5889662087155073442L; + + /** + *
+     * 字段名:商户号
+     * 变量名:mchid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  微信支付分配的商户号
+     * 示例值:1900001109
+     * 
+ */ + @SerializedName("mchid") + private String mchId; + + /** + *
+     * 字段名:商家批次单号
+     * 变量名:out_batch_no
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  商户系统内部的商家批次单号,在商户系统内部唯一
+     * 示例值:plfk2020042013
+     * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+     * 字段名:微信批次单号
+     * 变量名:batch_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  微信批次单号,微信商家转账系统返回的唯一标识
+     * 示例值:1030000071100999991182020050700019480001
+     * 
+ */ + @SerializedName("batch_id") + private String batchId; + + /** + *
+     * 字段名:直连商户的appid
+     * 变量名:appid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  申请商户号的appid或商户号绑定的appid(企业号corpid即为此appid)
+     * 示例值:wxf636efh567hg4356
+     * 
+ */ + @SerializedName("appid") + private String appid; + + /** + *
+     * 字段名:批次状态
+     * 变量名:batch_status
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  枚举值:
+     * WAIT_PAY:待付款,商户员工确认付款阶段
+     * ACCEPTED:已受理。批次已受理成功,若发起批量转账的30分钟后,转账批次单仍处于该状态,可能原因是商户账户余额不足等。商户可查询账户资金流水,若该笔转账批次单的扣款已经发生,则表示批次已经进入转账中,请再次查单确认
+     * PROCESSING:转账中。已开始处理批次内的转账明细单
+     * FINISHED:已完成。批次内的所有转账明细单都已处理完成
+     * CLOSED:已关闭。可查询具体的批次关闭原因确认
+     * 示例值:ACCEPTED
+     * 
+ */ + @SerializedName("batch_status") + private String batchStatus; + + /** + *
+     * 字段名:批次类型
+     * 变量名:batch_type
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  枚举值:
+     * API:API方式发起
+     * WEB:页面方式发起
+     * 示例值:API
+     * 
+ */ + @SerializedName("batch_type") + private String batchType; + + /** + *
+     * 字段名:批次名称
+     * 变量名:batch_name
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  该笔批量转账的名称
+     * 示例值:2019年1月深圳分部报销单
+     * 
+ */ + @SerializedName("batch_name") + private String batchName; + + /** + *
+     * 字段名:批次备注
+     * 变量名:batch_remark
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  转账说明,UTF8编码,最多允许32个字符
+     * 示例值:2019年1月深圳分部报销单
+     * 
+ */ + @SerializedName("batch_remark") + private String batchRemark; + + /** + *
+     * 字段名:批次关闭原因
+     * 变量名:close_reason
+     * 是否必填:否
+     * 类型:string[1,64]
+     * 描述:
+     *  如果批次单状态为“CLOSED”(已关闭),则有关闭原因
+     * MERCHANT_REVOCATION:商户主动撤销
+     * OVERDUE_CLOSE:系统超时关闭
+     * 示例值:OVERDUE_CLOSE
+     * 
+ */ + @SerializedName("close_reason") + private String closeReason; + + /** + *
+     * 字段名:转账总金额
+     * 变量名:total_amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  转账金额单位为分
+     * 示例值:4000000
+     * 
+ */ + @SerializedName("total_amount") + private Integer totalAmount; + + /** + *
+     * 字段名:转账总笔数
+     * 变量名:total_num
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  一个转账批次单最多发起三千笔转账
+     * 示例值:200
+     * 
+ */ + @SerializedName("total_num") + private Integer totalNum; + + /** + *
+     * 字段名:批次创建时间
+     * 变量名:create_time
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  批次受理成功时返回,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+     * 示例值:2015-05-20T13:29:35.120+08:00
+     * 
+ */ + @SerializedName("create_time") + private String createTime; + + /** + *
+     * 字段名:批次更新时间
+     * 变量名:update_time
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  批次最近一次状态变更的时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+     * 示例值:2015-05-20T13:29:35.120+08:00
+     * 
+ */ + @SerializedName("update_time") + private String updateTime; + + /** + *
+     * 字段名:转账成功金额
+     * 变量名:success_amount
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  转账成功的金额,单位为分。当批次状态为“PROCESSING”(转账中)时,转账成功金额随时可能变化
+     * 示例值:3900000
+     * 
+ */ + @SerializedName("success_amount") + private Integer successAmount; + + /** + *
+     * 字段名:转账成功笔数
+     * 变量名:success_num
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  转账成功的笔数。当批次状态为“PROCESSING”(转账中)时,转账成功笔数随时可能变化
+     * 示例值:199
+     * 
+ */ + @SerializedName("success_num") + private Integer successNum; + + /** + *
+     * 字段名:转账失败金额
+     * 变量名:fail_amount
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  转账失败的金额,单位为分
+     * 示例值:100000
+     * 
+ */ + @SerializedName("fail_amount") + private Integer failAmount; + + /** + *
+     * 字段名:转账失败笔数
+     * 变量名:fail_num
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  转账失败的笔数
+     * 示例值:1
+     * 
+ */ + @SerializedName("fail_num") + private Integer failNum; + } + + /** + * The type Transfer detail. + */ + @Data + @Accessors(chain = true) + public static class TransferDetail implements Serializable { + private static final long serialVersionUID = 172904924437448719L; + + /** + *
+     * 字段名:微信明细单号
+     * 变量名:detail_id
+     * 是否必填:是
+     * 类型:string[1,64]
+     * 描述:
+     *  微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
+     * 示例值:1040000071100999991182020050700019500100
+     * 
+ */ + @SerializedName("detail_id") + private String detailId; + + /** + *
+     * 字段名:商家明细单号
+     * 变量名:out_detail_no
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  商户系统内部区分转账批次单下不同转账明细单的唯一标识
+     * 示例值:x23zy545Bd5436
+     * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+     * 字段名:明细状态
+     * 变量名:detail_status
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  枚举值:
+     * PROCESSING:转账中。正在处理中,转账结果尚未明确
+     * SUCCESS:转账成功
+     * FAIL:转账失败。需要确认失败原因后,再决定是否重新发起对该笔明细单的转账(并非整个转账批次单)
+     * 示例值:SUCCESS
+     * 
+ */ + @SerializedName("detail_status") + private String detailStatus; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailElectronicBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailElectronicBillRequest.java new file mode 100644 index 0000000000..9016e892e8 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailElectronicBillRequest.java @@ -0,0 +1,71 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Detail electronic bill request. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class DetailElectronicBillRequest implements Serializable { + private static final long serialVersionUID = 716155129313310192L; + /** + *
+   * 字段名:受理类型
+   * 变量名:accept_type
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   * query电子回单受理类型:
+   * BATCH_TRANSFER:批量转账明细电子回单
+   * TRANSFER_TO_POCKET:企业付款至零钱电子回单
+   * TRANSFER_TO_BANK:企业付款至银行卡电子回单
+   * 示例值:BATCH_TRANSFER
+   * 
+ */ + @SerializedName("accept_type") + private String acceptType; + + /** + *
+   * 字段名:商家转账批次单号
+   * 变量名:out_batch_no
+   * 是否必填:否
+   * 类型:string[5,32]
+   * 描述:
+   * query需要电子回单的批量转账明细单所在的转账批次单号,该单号为商户申请转账时生成的商户单号。受理类型为BATCH_TRANSFER时该单号必填,否则该单号留空。
+   * 示例值:GD2021011610162610BBdkkIwcu3
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:商家转账明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[5,32]
+   * 描述:
+   * query该单号为商户申请转账时生成的商家转账明细单号。
+   * 1.受理类型为BATCH_TRANSFER时填写商家批量转账明细单号。
+   * 2. 受理类型为TRANSFER_TO_POCKET或TRANSFER_TO_BANK时填写商家转账单号。
+   * 示例值:mx0911231610162610v4CNkO4HAf
+   * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailElectronicBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailElectronicBillResult.java new file mode 100644 index 0000000000..ff70c06cc8 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailElectronicBillResult.java @@ -0,0 +1,143 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 查询转账明细电子回单受理结果响应实体 + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class DetailElectronicBillResult implements Serializable { + private static final long serialVersionUID = -6544648835213399159L; + /** + *
+   * 字段名:受理类型
+   * 变量名:accept_type
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  电子回单受理类型:
+   * BATCH_TRANSFER:批量转账明细电子回单
+   * TRANSFER_TO_POCKET:企业付款至零钱电子回单
+   * TRANSFER_TO_BANK:企业付款至银行卡电子回单
+   * 示例值:BATCH_TRANSFER
+   * 
+ */ + @SerializedName("accept_type") + private String acceptType; + + /** + *
+   * 字段名:商家转账批次单号
+   * 变量名:out_batch_no
+   * 是否必填:否
+   * 类型:string[5,32]
+   * 描述:
+   *  需要电子回单的批量转账明细单所在的转账批次单号,该单号为商户申请转账时生成的商户单号。受理类型为BATCH_TRANSFER时该单号必填,否则该单号留空。
+   * 示例值:GD2021011610162610BBdkkIwcu3
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:商家转账明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[5,32]
+   * 描述:
+   *  该单号为商户申请转账时生成的商家转账明细单号。
+   * 1.受理类型为BATCH_TRANSFER时填写商家批量转账明细单号。
+   * 2. 受理类型为TRANSFER_TO_POCKET或TRANSFER_TO_BANK时填写商家转账单号。
+   * 示例值:mx0911231610162610v4CNkO4HAf
+   * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+   * 字段名:电子回单受理单号
+   * 变量名:signature_no
+   * 是否必填:是
+   * 类型:string[3,256]
+   * 描述:
+   *  电子回单受理单号,受理单据的唯一标识
+   * 示例值:1050000010509999485212020110200058820001
+   * 
+ */ + @SerializedName("signature_no") + private String signatureNo; + + /** + *
+   * 字段名:电子回单状态
+   * 变量名:signature_status
+   * 是否必填:否
+   * 类型:string[1,10]
+   * 描述:
+   *  枚举值:
+   * ACCEPTED:已受理,电子签章已受理成功
+   * FINISHED:已完成。电子签章已处理完成
+   * 示例值:ACCEPTED
+   * 
+ */ + @SerializedName("signature_status") + private String signatureStatus; + + /** + *
+   * 字段名:电子回单文件的hash方法
+   * 变量名:hash_type
+   * 是否必填:否
+   * 类型:string[1,20]
+   * 描述:
+   *  电子回单文件的hash方法,回单状态为:FINISHED时返回
+   * 示例值:SHA256
+   * 
+ */ + @SerializedName("hash_type") + private String hashType; + + /** + *
+   * 字段名:电子回单文件的hash值
+   * 变量名:hash_value
+   * 是否必填:否
+   * 类型:string[3,1000]
+   * 描述:
+   *  电子回单文件的hash值,用于下载之后验证文件的完整、正确性,回单状态为:FINISHED时返回
+   * 示例值:DE731F35146A0BEFADE5DB9D1E468D96C01CA8898119C674FEE9F11F4DBE5529
+   * 
+ */ + @SerializedName("hash_value") + private String hashValue; + + /** + *
+   * 字段名:电子回单文件的下载地址
+   * 变量名:download_url
+   * 是否必填:否
+   * 类型:string[10,3000]
+   * 描述:
+   *  电子回单文件的下载地址,回单状态为:FINISHED时返回。URL有效时长为10分钟,10分钟后需要重新去获取下载地址(但不需要走受理)
+   * 示例值:https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx
+   * 
+ */ + @SerializedName("download_url") + private String downloadUrl; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailsQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailsQueryResult.java new file mode 100644 index 0000000000..79dbd3ace6 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/DetailsQueryResult.java @@ -0,0 +1,242 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 微信明细单号查询明细单 响应实体、 + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class DetailsQueryResult implements Serializable { + private static final long serialVersionUID = -6900642921137234815L; + /** + *
+   * 字段名:商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  微信支付分配的商户号
+   * 示例值:1900001109
+   * 
+ */ + @SerializedName("mchid") + private String mchid; + + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  商户系统内部的商家批次单号,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:微信批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[1,64]
+   * 描述:
+   *  微信批次单号,微信商家转账系统返回的唯一标识
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_id") + private String batchId; + + /** + *
+   * 字段名:直连商户的appid
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  申请商户号的appid或商户号绑定的appid(企业号corpid即为此appid)
+   * 示例值:wxf636efh567hg4356
+   * 
+ */ + @SerializedName("appid") + private String appid; + + /** + *
+   * 字段名:商家明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  商户系统内部区分转账批次单下不同转账明细单的唯一标识
+   * 示例值:x23zy545Bd5436
+   * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+   * 字段名:微信明细单号
+   * 变量名:detail_id
+   * 是否必填:是
+   * 类型:string[1,64]
+   * 描述:
+   *  微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
+   * 示例值:1040000071100999991182020050700019500100
+   * 
+ */ + @SerializedName("detail_id") + private String detailId; + + /** + *
+   * 字段名:明细状态
+   * 变量名:detail_status
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  枚举值:
+   * PROCESSING:转账中。正在处理中,转账结果尚未明确
+   * SUCCESS:转账成功
+   * FAIL:转账失败。需要确认失败原因后,再决定是否重新发起对该笔明细单的转账(并非整个转账批次单)
+   * 示例值:SUCCESS
+   * 
+ */ + @SerializedName("detail_status") + private String detailStatus; + + /** + *
+   * 字段名:转账金额
+   * 变量名:transfer_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  转账金额单位为分
+   * 示例值:200000
+   * 
+ */ + @SerializedName("transfer_amount") + private Integer transferAmount; + + /** + *
+   * 字段名:转账备注
+   * 变量名:transfer_remark
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  单条转账备注(微信用户会收到该备注),UTF8编码,最多允许32个字符
+   * 示例值:2020年4月报销
+   * 
+ */ + @SerializedName("transfer_remark") + private String transferRemark; + + /** + *
+   * 字段名:明细失败原因
+   * 变量名:fail_reason
+   * 是否必填:否
+   * 类型:string[1,64]
+   * 描述:
+   *  如果转账失败则有失败原因
+   * ACCOUNT_FROZEN:账户冻结
+   * REAL_NAME_CHECK_FAIL:用户未实名
+   * NAME_NOT_CORRECT:用户姓名校验失败
+   * OPENID_INVALID:Openid校验失败
+   * TRANSFER_QUOTA_EXCEED:超过用户单笔收款额度
+   * DAY_RECEIVED_QUOTA_EXCEED:超过用户单日收款额度
+   * MONTH_RECEIVED_QUOTA_EXCEED:超过用户单月收款额度
+   * DAY_RECEIVED_COUNT_EXCEED:超过用户单日收款次数
+   * PRODUCT_AUTH_CHECK_FAIL:产品权限校验失败
+   * OVERDUE_CLOSE:转账关闭
+   * ID_CARD_NOT_CORRECT:用户身份证校验失败
+   * ACCOUNT_NOT_EXIST:用户账户不存在
+   * TRANSFER_RISK:转账存在风险
+   * REALNAME_ACCOUNT_RECEIVED_QUOTA_EXCEED:用户账户收款受限,请引导用户在微信支付查看详情
+   * RECEIVE_ACCOUNT_NOT_PERMMIT:未配置该用户为转账收款人
+   * PAYER_ACCOUNT_ABNORMAL:商户账户付款受限,可前往商户平台-违约记录获取解除功能限制指引
+   * PAYEE_ACCOUNT_ABNORMAL:用户账户收款异常,请引导用户完善其在微信支付的身份信息以继续收款
+   * 示例值:ACCOUNT_FROZEN
+   * 
+ */ + @SerializedName("fail_reason") + private String failReason; + + /** + *
+   * 字段名:用户在直连商户应用下的用户标示
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:string[1,128]
+   * 描述:
+   *  用户在直连商户appid下的唯一标识
+   * 示例值:o-MYE42l80oelYMDE34nYD456Xoy
+   * 
+ */ + @SerializedName("openid") + private String openid; + + /** + *
+   * 字段名:收款用户姓名
+   * 变量名:user_name
+   * 是否必填:否
+   * 类型:string[1,1024]
+   * 描述:
+   *  1、商户转账时传入了收款用户姓名、查询时会返回收款用户姓名;
+   * 2、收款方姓名采用标准RSA算法,公钥由微信侧提供
+   * 3、 该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+   * 示例值:757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45
+   * 
+ */ + @SerializedName("user_name") + private String userName; + + /** + *
+   * 字段名:转账发起时间
+   * 变量名:initiate_time
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  转账发起的时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("initiate_time") + private String initiateTime; + + /** + *
+   * 字段名:明细更新时间
+   * 变量名:update_time
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  明细最后一次状态变更的时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("update_time") + private String updateTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillApplyRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillApplyRequest.java new file mode 100644 index 0000000000..363c0e357e --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillApplyRequest.java @@ -0,0 +1,38 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Electronic bill apply request. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class ElectronicBillApplyRequest implements Serializable { + private static final long serialVersionUID = -2121536206019844928L; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5,32]
+   * 描述:
+   *  body商户系统内部的商家批次单号,在商户系统内部唯一。需要电子回单的批次单号
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillResult.java new file mode 100644 index 0000000000..aaff96ad43 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillResult.java @@ -0,0 +1,138 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Electronic bill result. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class ElectronicBillResult implements Serializable { + private static final long serialVersionUID = 7528245102572829190L; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[5,32]
+   * 描述:
+   *  body商户系统内部的商家批次单号,在商户系统内部唯一。需要电子回单的批次单号
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:电子回单申请单号
+   * 变量名:signature_no
+   * 是否必填:是
+   * 类型:string[3,45]
+   * 描述:
+   *  电子回单申请单号,申请单据的唯一标识
+   * 示例值:1050000010509999485212020110200058820001
+   * 
+ */ + @SerializedName("signature_no") + private String signatureNo; + + /** + *
+   * 字段名:电子回单状态
+   * 变量名:signature_status
+   * 是否必填:否
+   * 类型:string[1,10]
+   * 描述:
+   *  枚举值:
+   * ACCEPTED:已受理,电子签章已受理成功
+   * FINISHED:已完成。电子签章已处理完成
+   * 示例值:ACCEPTED
+   * 
+ */ + @SerializedName("signature_status") + private String signatureStatus; + + /** + *
+   * 字段名:电子回单文件的hash方法
+   * 变量名:hash_type
+   * 是否必填:否
+   * 类型:string[1,20]
+   * 描述:
+   *  电子回单文件的hash方法,回单状态为:FINISHED时返回。
+   * 示例值:SHA256
+   * 
+ */ + @SerializedName("hash_type") + private String hashType; + + /** + *
+   * 字段名:电子回单文件的hash值
+   * 变量名:hash_value
+   * 是否必填:否
+   * 类型:string[3,1000]
+   * 描述:
+   *  电子回单文件的hash值,用于下载之后验证文件的完整、正确性,回单状态为:FINISHED时返回。
+   * 示例值:DE731F35146A0BEFADE5DB9D1E468D96C01CA8898119C674FEE9F11F4DBE5529
+   * 
+ */ + @SerializedName("hash_value") + private String hashValue; + + /** + *
+   * 字段名:电子回单文件的下载地址
+   * 变量名:download_url
+   * 是否必填:否
+   * 类型:string[10,3000]
+   * 描述:
+   *  电子回单文件的下载地址,回单状态为:FINISHED时返回。URL有效时长为10分钟,10分钟后需要重新去获取下载地址(但不需要走受理)
+   * 示例值:https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx
+   * 
+ */ + @SerializedName("download_url") + private String downloadUrl; + + /** + *
+   * 字段名:创建时间
+   * 变量名:create_time
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  电子签章单创建时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2020-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("create_time") + private String createTime; + + /** + *
+   * 字段名:更新时间
+   * 变量名:update_time
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  电子签章单最近一次状态变更的时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2020-05-21T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("update_time") + private String updateTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/MerchantBatchesQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/MerchantBatchesQueryRequest.java new file mode 100644 index 0000000000..0fec61e870 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/MerchantBatchesQueryRequest.java @@ -0,0 +1,99 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Merchant batches query request. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class MerchantBatchesQueryRequest implements Serializable { + private static final long serialVersionUID = 7074459219428697275L; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  path商户系统内部的商家批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:是否查询转账明细单
+   * 变量名:need_query_detail
+   * 是否必填:是
+   * 类型:boolean
+   * 描述:
+   *  query枚举值:
+   * true:是;
+   * false:否,默认否。
+   * 商户可选择是否查询指定状态的转账明细单,当转账批次单状态为“FINISHED”(已完成)时,才会返回满足条件的转账明细单
+   * 示例值:true
+   * 
+ */ + @SerializedName("need_query_detail") + private Boolean needQueryDetail; + + /** + *
+   * 字段名:请求资源起始位置
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求资源的起始位置,从0开始,默认值为0
+   * 
+ */ + @SerializedName("offset") + private Integer offset; + + /** + *
+   * 字段名:最大资源条数
+   * 变量名:limit
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求可返回的最大明细条数,最小20条,最大100条,不传则默认20条。不足20条按实际条数返回
+   * 示例值:20
+   * 
+ */ + @SerializedName("limit") + private Integer limit; + + /** + *
+   * 字段名:明细状态
+   * 变量名:detail_status
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  query查询指定状态的转账明细单,当need_query_detail为true时,该字段必填
+   * ALL:全部。需要同时查询转账成功和转账失败的明细单
+   * SUCCESS:转账成功。只查询转账成功的明细单
+   * FAIL:转账失败。只查询转账失败的明细单
+   * 示例值:FAIL
+   * 
+ */ + @SerializedName("detail_status") + private String detailStatus; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/MerchantDetailsQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/MerchantDetailsQueryRequest.java new file mode 100644 index 0000000000..335fcb7ae4 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/MerchantDetailsQueryRequest.java @@ -0,0 +1,52 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Merchant details query request. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class MerchantDetailsQueryRequest implements Serializable { + private static final long serialVersionUID = 3167548999175561804L; + /** + *
+   * 字段名:商家明细单号
+   * 变量名:out_detail_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   * path商户系统内部区分转账批次单下不同转账明细单的唯一标识,要求此参数只能由数字、大小写字母组成
+   * 示例值:x23zy545Bd5436
+   * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  path商户系统内部的商家批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/TransferCreateRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/TransferCreateRequest.java new file mode 100644 index 0000000000..38bfcb9ed0 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/TransferCreateRequest.java @@ -0,0 +1,222 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * The type Transfer create request. + * + * @author glz + * created on 2022-5-26 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class TransferCreateRequest implements Serializable { + private static final long serialVersionUID = -6865437704112740902L; + /** + *
+   * 字段名:直连商户的appid
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  申请商户号的appid或商户号绑定的appid(企业号corpid即为此appid)
+   * 示例值:wxf636efh567hg4356
+   * 
+ */ + @SerializedName("appid") + private String appid; + + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  path商户系统内部的商家批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:批次名称
+   * 变量名:batch_name
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  该笔批量转账的名称
+   * 示例值:2019年1月深圳分部报销单
+   * 
+ */ + @SerializedName("batch_name") + private String batchName; + + /** + *
+   * 字段名:批次备注
+   * 变量名:batch_remark
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  转账说明,UTF8编码,最多允许32个字符
+   * 示例值:2019年1月深圳分部报销单
+   * 
+ */ + @SerializedName("batch_remark") + private String batchRemark; + + /** + *
+   * 字段名:转账总金额
+   * 变量名:total_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  转账金额单位为分
+   * 示例值:4000000
+   * 
+ */ + @SerializedName("total_amount") + private Integer totalAmount; + + /** + *
+   * 字段名:转账总笔数
+   * 变量名:total_num
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  一个转账批次单最多发起三千笔转账
+   * 示例值:200
+   * 
+ */ + @SerializedName("total_num") + private Integer totalNum; + + /** + *
+   * 字段名:转账明细单列表
+   * 变量名:transfer_detail_list
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  body发起批量转账的明细列表,最多三千笔
+   * 
+ */ + @SerializedName("transfer_detail_list") + @SpecEncrypt + private List transferDetailList; + + /** + *
+   * 字段名:转账场景ID
+   * 变量名:transfer_scene_id
+   * 是否必填:否
+   * 类型:string(36)
+   * 描述:
+   *  该批次转账使用的转账场景,如不填写则使用商家的默认场景,如无默认场景可为空,可前往“商家转账到零钱-前往功能”中申请。
+   * 示例值:1001
+   * 
+ */ + @SerializedName("transfer_scene_id") + private String transferSceneId; + + + /** + * The type Transfer detail list. + */ + @Data + @Accessors(chain = true) + public static class TransferDetailList implements Serializable { + + /** + *
+     * 字段名:商家明细单号
+     * 变量名:out_detail_no
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  商户系统内部区分转账批次单下不同转账明细单的唯一标识
+     * 示例值:x23zy545Bd5436
+     * 
+ */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + *
+     * 字段名:转账金额
+     * 变量名:transfer_amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  转账金额单位为分
+     * 示例值:200000
+     * 
+ */ + @SerializedName("transfer_amount") + private Integer transferAmount; + + /** + *
+     * 字段名:转账备注
+     * 变量名:transfer_remark
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  单条转账备注(微信用户会收到该备注),UTF8编码,最多允许32个字符
+     * 示例值:2020年4月报销
+     * 
+ */ + @SerializedName("transfer_remark") + private String transferRemark; + + /** + *
+     * 字段名:用户在直连商户应用下的用户标示
+     * 变量名:openid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  用户在直连商户appid下的唯一标识
+     * 示例值:o-MYE42l80oelYMDE34nYD456Xoy
+     * 
+ */ + @SerializedName("openid") + private String openid; + + /** + *
+     * 字段名:收款用户姓名
+     * 变量名:user_name
+     * 是否必填:否
+     * 类型:string[1,1024]
+     * 描述:
+     *  1、商户转账时传入了收款用户姓名、查询时会返回收款用户姓名;
+     * 2、收款方姓名采用标准RSA算法,公钥由微信侧提供
+     * 3、 该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+     * 示例值:757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45
+     * 
+ */ + @SerializedName("user_name") + @SpecEncrypt + private String userName; + } +} + + diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/TransferCreateResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/TransferCreateResult.java new file mode 100644 index 0000000000..f2417c4687 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/TransferCreateResult.java @@ -0,0 +1,66 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Transfer create result. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class TransferCreateResult implements Serializable { + private static final long serialVersionUID = 586974090302358983L; + /** + *
+   * 字段名:商家批次单号
+   * 变量名:out_batch_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  商户系统内部的商家批次单号,在商户系统内部唯一
+   * 示例值:plfk2020042013
+   * 
+ */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + *
+   * 字段名:微信批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  微信批次单号,微信商家转账系统返回的唯一标识
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_id") + private String batchId; + + /** + *
+   * 字段名:批次创建时间
+   * 变量名:create_time
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  批次受理成功时返回,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示北京时间2015年05月20日13点29分35秒
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName("create_time") + private String createTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/WxBatchesQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/WxBatchesQueryRequest.java new file mode 100644 index 0000000000..ff672c93c6 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/WxBatchesQueryRequest.java @@ -0,0 +1,99 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Wx batches query request. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxBatchesQueryRequest implements Serializable { + private static final long serialVersionUID = 1030840820271586649L; + /** + *
+   * 字段名:微信批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[1,64]
+   * 描述:
+   *  path微信批次单号,微信商家转账系统返回的唯一标识
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_id") + private String batchId; + + /** + *
+   * 字段名:是否查询转账明细单
+   * 变量名:need_query_detail
+   * 是否必填:是
+   * 类型:boolean
+   * 描述:
+   *  query枚举值:
+   * true:是;
+   * false:否,默认否。
+   * 商户可选择是否查询指定状态的转账明细单,当转账批次单状态为“FINISHED”(已完成)时,才会返回满足条件的转账明细单
+   * 示例值:true
+   * 
+ */ + @SerializedName("need_query_detail") + private Boolean needQueryDetail; + + /** + *
+   * 字段名:请求资源起始位置
+   * 变量名:offset
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求资源的起始位置,从0开始,默认值为0
+   * 
+ */ + @SerializedName("offset") + private Integer offset; + + /** + *
+   * 字段名:最大资源条数
+   * 变量名:limit
+   * 是否必填:否
+   * 类型:int
+   * 描述:
+   *  query该次请求可返回的最大明细条数,最小20条,最大100条,不传则默认20条。不足20条按实际条数返回
+   * 示例值:20
+   * 
+ */ + @SerializedName("limit") + private Integer limit; + + /** + *
+   * 字段名:明细状态
+   * 变量名:detail_status
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  query查询指定状态的转账明细单,当need_query_detail为true时,该字段必填
+   * ALL:全部。需要同时查询转账成功和转账失败的明细单
+   * SUCCESS:转账成功。只查询转账成功的明细单
+   * FAIL:转账失败。只查询转账失败的明细单
+   * 示例值:FAIL
+   * 
+ */ + @SerializedName("detail_status") + private String detailStatus; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/WxDetailsQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/WxDetailsQueryRequest.java new file mode 100644 index 0000000000..f81826e024 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/WxDetailsQueryRequest.java @@ -0,0 +1,53 @@ +package com.github.binarywang.wxpay.bean.merchanttransfer; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * The type Wx details query request. + * + * @author glz + * created on 2022-6-11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxDetailsQueryRequest implements Serializable { + private static final long serialVersionUID = 4869511970509348272L; + + /** + *
+   * 字段名:微信批次单号
+   * 变量名:batch_id
+   * 是否必填:是
+   * 类型:string[1,64]
+   * 描述:
+   *  path微信批次单号,微信商家转账系统返回的唯一标识
+   * 示例值:1030000071100999991182020050700019480001
+   * 
+ */ + @SerializedName("batch_id") + private String batchId; + + /** + *
+   * 字段名:微信明细单号
+   * 变量名:detail_id
+   * 是否必填:是
+   * 类型:string[1,64]
+   * 描述:
+   *  path微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
+   * 示例值:1040000071100999991182020050700019500100
+   * 
+ */ + @SerializedName("detail_id") + private String detailId; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/CombineNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/CombineNotifyResult.java index 111deedb19..aba11d2dc0 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/CombineNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/CombineNotifyResult.java @@ -250,6 +250,34 @@ public static class SubOrders implements Serializable { */ @SerializedName(value = "out_trade_no") private String outTradeNo; + /** + *
+     * 字段名:子商户应用ID
+     * 变量名:sub_appid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  子商户申请的应用ID,全局唯一。请求基础下单接口时请注意APPID的应用属性,例如公众号场景下,
+     *  需使用应用属性为公众号的APPID 若sub_openid有传的情况下,
+     *  sub_appid必填,且sub_appid需与sub_openid对应
+     *  示例值:wxd678efh567hg6999
+     * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + /** + *
+     * 字段名:二级商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  二级商户商户号,由微信支付生成并下发。服务商子商户的商户号,被合单方。直连商户不用传二级商户号。
+     *  示例值:1900000109
+     * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; /** *
      * 字段名:订单金额
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/ComplaintNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/ComplaintNotifyResult.java
new file mode 100644
index 0000000000..a5d18df6df
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/ComplaintNotifyResult.java
@@ -0,0 +1,64 @@
+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/wiki/doc/apiv3/apis/chapter10_2_16.shtml
+ *
+ * @author jmdhappy
+ */
+@Data
+@NoArgsConstructor
+public class ComplaintNotifyResult implements Serializable {
+  private static final long serialVersionUID = -1L;
+  /**
+   * 源数据
+   */
+  private OriginNotifyResponse rawData;
+  /**
+   * 解密后的数据
+   */
+  private DecryptNotifyResult result;
+
+  @Data
+  @NoArgsConstructor
+  public static class DecryptNotifyResult implements Serializable {
+    private static final long serialVersionUID = -1L;
+
+    /**
+     * 
+     * 字段名:投诉单号
+     * 是否必填:是
+     * 描述:
+     *  投诉单对应的投诉单号
+     * 
+ */ + @SerializedName(value = "complaint_id") + private String complaintId; + + /** + *
+     * 字段名:动作类型
+     * 是否必填:是
+     * 描述:
+     * 触发本次投诉通知回调的具体动作类型,枚举如下:
+     * CREATE_COMPLAINT:用户提交投诉
+     * CONTINUE_COMPLAINT:用户继续投诉
+     * USER_RESPONSE:用户新留言
+     * RESPONSE_BY_PLATFORM:平台新留言
+     * SELLER_REFUND:收款方全额退款
+     * MERCHANT_RESPONSE:商户新回复
+     * MERCHANT_CONFIRM_COMPLETE:商户反馈处理完成
+     * 
+ */ + @SerializedName(value = "action_type") + private String actionType; + + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/SignatureHeader.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/SignatureHeader.java index d010637a8c..cd1fbc42dc 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/SignatureHeader.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/SignatureHeader.java @@ -1,5 +1,7 @@ package com.github.binarywang.wxpay.bean.notify; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @@ -8,9 +10,13 @@ /** * 微信通知接口头部信息,需要做签名验证 * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_1.shtml + * + * @author thinstar */ @Data +@Builder @NoArgsConstructor +@AllArgsConstructor public class SignatureHeader implements Serializable { private static final long serialVersionUID = -1L; /** 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 new file mode 100644 index 0000000000..86915d0956 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayBaseNotifyV3Result.java @@ -0,0 +1,30 @@ +package com.github.binarywang.wxpay.bean.notify; + +/** + * 微信支付公用回调 + * + * @author Pursuer + * @version 1.0 + * @date 2023/6/15 + */ +public interface WxPayBaseNotifyV3Result { + /** + * 设置原始数据 + * + * @param rawData 原始数据 + * @author Pursuer + * @date 2023/6/15 + * @since 1.0 + **/ + void setRawData(OriginNotifyResponse rawData); + + /** + * 解密后的数据 + * + * @param data 解密后的数据 + * @author Pursuer + * @date 2023/6/15 + * @since 1.0 + **/ + void setResult(T data); +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Response.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Response.java new file mode 100644 index 0000000000..b9d7f4d9f6 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Response.java @@ -0,0 +1,50 @@ +package com.github.binarywang.wxpay.bean.notify; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +/** + * 微信支付订单和退款的异步通知,V3版本共用的响应类. + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_11.shtml + * + * @author Wang_Wong + * created on 2022-08-15 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxPayNotifyV3Response { + + private static final transient String SUCCESS = "SUCCESS"; + private static final transient String FAIL = "FAIL"; + + private String code; + private String message; + + /** + * 返回成功 + * + * @param msg + * @return + */ + public static String success(String msg) { + WxPayNotifyV3Response response = new WxPayNotifyV3Response(SUCCESS, msg); + return WxGsonBuilder.create().toJson(response); + } + + /** + * 返回失败 + * + * @param msg 返回信息,如非空,为错误原因 + * @return + */ + public static String fail(String msg) { + WxPayNotifyV3Response response = new WxPayNotifyV3Response(FAIL, msg); + return WxGsonBuilder.create().toJson(response); + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Result.java similarity index 99% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyV3Result.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Result.java index 549e2af16c..22ed94fca3 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyV3Result.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Result.java @@ -15,7 +15,7 @@ */ @Data @NoArgsConstructor -public class WxPayOrderNotifyV3Result implements Serializable { +public class WxPayNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result { private static final long serialVersionUID = -1L; /** * 源数据 diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java index 34f7e2b23d..bd9a6f3ecf 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java @@ -121,7 +121,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa * 是否必填:是 * 类型:String(16) * 示例值:JSAPI - * JSA描述:PI、NATIVE、APP + * 描述:JSAPI、NATIVE、APP *
*/ @XStreamAlias("trade_type") diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayPartnerNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayPartnerNotifyV3Result.java new file mode 100644 index 0000000000..64671abd25 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayPartnerNotifyV3Result.java @@ -0,0 +1,596 @@ +package com.github.binarywang.wxpay.bean.notify; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信支付服务商下单回调,文档:文档 + * + * @author Pursuer + * @version 1.0 + * @date 2023/3/2 + */ +@Data +@NoArgsConstructor +public class WxPayPartnerNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result { + private static final long serialVersionUID = -1L; + /** + * 源数据 + */ + private OriginNotifyResponse rawData; + /** + * 解密后的数据 + */ + private DecryptNotifyResult result; + + @Data + @NoArgsConstructor + public static class DecryptNotifyResult implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:服务商应用ID
+     * 变量名:spAppid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  由微信生成的应用ID,全局唯一。请求统一下单接口时请注意APPID的应用属性,例如公众号场景下,需使用应用属性为公众号的APPID
+     *  示例值:wxd678efh567hg6787
+     * 
+ */ + @SerializedName(value = "sp_appid") + protected String spAppid; + /** + *
+     * 字段名:服务商商户号
+     * 变量名:spMchid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  服务商商户号,由微信支付生成并下发。
+     *  示例值:1230000109
+     * 
+ */ + @SerializedName(value = "sp_mchid") + protected String spMchid; + /** + *
+     * 字段名:子商户应用ID
+     * 变量名:subAppid
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  由微信生成的应用ID,全局唯一。请求统一下单接口时请注意APPID的应用属性,例如公众号场景下,需使用应用属性为公众号的APPID
+     *  示例值:wxd678efh567hg6787
+     * 
+ */ + @SerializedName(value = "sub_appid") + protected String subAppid; + /** + *
+     * 字段名:子商户商户号
+     * 变量名:subMchid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  子商户商户号,由微信支付生成并下发。
+     *  示例值:1230000109
+     * 
+ */ + @SerializedName(value = "sub_mchid") + protected String subMchid; + /** + *
+     * 字段名:商户订单号
+     * 变量名:out_trade_no
+     * 是否必填:是
+     * 类型:string[6,32]
+     * 描述:
+     *  商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一。
+     *  特殊规则:最小字符长度为6
+     *  示例值:1217752501201407033233368018
+     * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + /** + *
+     * 字段名:微信支付订单号
+     * 变量名:transaction_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  微信支付系统生成的订单号。
+     *  示例值:1217752501201407033233368018
+     * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + /** + *
+     * 字段名:交易类型
+     * 变量名:trade_type
+     * 是否必填:是
+     * 类型:string[1,16]
+     * 描述:
+     *  交易类型,枚举值:
+     *  JSAPI:公众号支付
+     *  NATIVE:扫码支付
+     *  APP:APP支付
+     *  MICROPAY:付款码支付
+     *  MWEB:H5支付
+     *  FACEPAY:刷脸支付
+     *  示例值:MICROPAY
+     * 
+ */ + @SerializedName(value = "trade_type") + private String tradeType; + /** + *
+     * 字段名:交易状态
+     * 变量名:trade_state
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  交易状态,枚举值:
+     *  SUCCESS:支付成功
+     *  REFUND:转入退款
+     *  NOTPAY:未支付
+     *  CLOSED:已关闭
+     *  REVOKED:已撤销(付款码支付)
+     *  USERPAYING:用户支付中(付款码支付)
+     *  PAYERROR:支付失败(其他原因,如银行返回失败)
+     *  示例值:SUCCESS
+     * 
+ */ + @SerializedName(value = "trade_state") + private String tradeState; + /** + *
+     * 字段名:交易状态描述
+     * 变量名:trade_state_desc
+     * 是否必填:是
+     * 类型:string[1,256]
+     * 描述:
+     *  交易状态描述
+     *  示例值:支付成功
+     * 
+ */ + @SerializedName(value = "trade_state_desc") + private String tradeStateDesc; + /** + *
+     * 字段名:付款银行
+     * 变量名:bank_type
+     * 是否必填:是
+     * 类型:string[1,16]
+     * 描述:
+     *  银行类型,采用字符串类型的银行标识。银行标识请参考《银行类型对照表》https://pay.weixin.qq.com/wiki/doc/apiv3/terms_definition/chapter1_1_3.shtml#part-6
+     *  示例值:CMC
+     * 
+ */ + @SerializedName(value = "bank_type") + private String bankType; + /** + *
+     * 字段名:附加数据
+     * 变量名:attach
+     * 是否必填:否
+     * 类型:string[1,128]
+     * 描述:
+     *  附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
+     *  示例值:自定义数据
+     * 
+ */ + @SerializedName(value = "attach") + private String attach; + /** + *
+     * 字段名:支付完成时间
+     * 变量名:success_time
+     * 是否必填:是
+     * 类型:string[1,64]
+     * 描述:
+     *  支付完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     *  示例值:2018-06-08T10:34:56+08:00
+     * 
+ */ + @SerializedName(value = "success_time") + private String successTime; + /** + *
+     * 字段名:支付者
+     * 变量名:payer
+     * 是否必填:是
+     * 类型:object
+     * 描述:
+     *  支付者信息
+     * 
+ */ + private Payer payer; + /** + *
+     * 字段名:订单金额
+     * 变量名:amount
+     * 是否必填:否
+     * 类型:object
+     * 描述:
+     *  订单金额信息
+     * 
+ */ + @SerializedName(value = "amount") + private Amount amount; + /** + *
+     * 字段名:场景信息
+     * 变量名:scene_info
+     * 是否必填:否
+     * 类型:object
+     * 描述:
+     *  支付场景信息描述
+     * 
+ */ + @SerializedName(value = "scene_info") + private SceneInfo sceneInfo; + /** + *
+     * 字段名:优惠功能
+     * 变量名:promotion_detail
+     * 是否必填:否
+     * 类型:array
+     * 描述:
+     *  优惠功能,享受优惠时返回该字段。
+     * 
+ */ + @SerializedName(value = "promotion_detail") + private List promotionDetails; + } + + @Data + @NoArgsConstructor + public static class Payer implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:用户标识
+     * 变量名:openid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  用户在直连商户appid下的唯一标识。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "openid") + private String openid; + + /** + *
+     * 字段名:用户服务标识
+     * 变量名:sp_openid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  用户在服务商appid下的唯一标识。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "sp_openid") + private String spOpenid; + + /** + *
+     * 字段名:用户子标识
+     * 变量名:sub_openid
+     * 是否必填:否
+     * 类型:string[1,128]
+     * 描述:
+     * 用户在子商户appid下的唯一标识。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "sub_openid") + private String subOpenid; + } + + @Data + @NoArgsConstructor + public static class Amount implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:总金额
+     * 变量名:total
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  订单总金额,单位为分。
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "total") + private Integer total; + /** + *
+     * 字段名:用户支付金额
+     * 变量名:payer_total
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  用户支付金额,单位为分。
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "payer_total") + private Integer payerTotal; + /** + *
+     * 字段名:货币类型
+     * 变量名:currency
+     * 是否必填:否
+     * 类型:string[1,16]
+     * 描述:
+     *  CNY:人民币,境内商户号仅支持人民币。
+     *  示例值:CNY
+     * 
+ */ + @SerializedName(value = "currency") + private String currency; + /** + *
+     * 字段名:用户支付币种
+     * 变量名:payer_currency
+     * 是否必填:否
+     * 类型:string[1,16]
+     * 描述:
+     *  用户支付币种
+     *  示例值: CNY
+     * 
+ */ + @SerializedName(value = "payer_currency") + private String payerCurrency; + } + + @Data + @NoArgsConstructor + public static class SceneInfo implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:商户端设备号
+     * 变量名:device_id
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  终端设备号(门店号或收银设备ID)。
+     *  示例值:013467007045764
+     * 
+ */ + @SerializedName(value = "device_id") + private String deviceId; + } + + @Data + @NoArgsConstructor + public static class PromotionDetail implements Serializable { + /** + *
+     * 字段名:券ID
+     * 变量名:coupon_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  券ID
+     *  示例值:109519
+     * 
+ */ + @SerializedName(value = "coupon_id") + private String couponId; + /** + *
+     * 字段名:优惠名称
+     * 变量名:name
+     * 是否必填:否
+     * 类型:string[1,64]
+     * 描述:
+     *  优惠名称
+     *  示例值:单品惠-6
+     * 
+ */ + @SerializedName(value = "name") + private String name; + /** + *
+     * 字段名:优惠范围
+     * 变量名:scope
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  GLOBAL:全场代金券
+     *  SINGLE:单品优惠
+     *  示例值:GLOBAL
+     * 
+ */ + @SerializedName(value = "scope") + private String scope; + /** + *
+     * 字段名:优惠类型
+     * 变量名:type
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  CASH:充值
+     *  NOCASH:预充值
+     *  示例值:CASH
+     * 
+ */ + @SerializedName(value = "type") + private String type; + /** + *
+     * 字段名:优惠券面额
+     * 变量名:amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  优惠券面额
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "amount") + private Integer amount; + /** + *
+     * 字段名:活动ID
+     * 变量名:stock_id
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  活动ID
+     *  示例值:931386
+     * 
+ */ + @SerializedName(value = "stock_id") + private String stockId; + /** + *
+     * 字段名:微信出资
+     * 变量名:wechatpay_contribute
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  微信出资,单位为分
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "wechatpay_contribute") + private Integer wechatpayContribute; + /** + *
+     * 字段名:商户出资
+     * 变量名:merchant_contribute
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  商户出资,单位为分
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "merchant_contribute") + private Integer merchantContribute; + /** + *
+     * 字段名:其他出资
+     * 变量名:other_contribute
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  其他出资,单位为分
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "other_contribute") + private Integer otherContribute; + /** + *
+     * 字段名:优惠币种
+     * 变量名:currency
+     * 是否必填:否
+     * 类型:string[1,16]
+     * 描述:
+     *  CNY:人民币,境内商户号仅支持人民币。
+     *  示例值:CNY
+     * 
+ */ + @SerializedName(value = "currency") + private String currency; + /** + *
+     * 字段名:单品列表
+     * 变量名:goods_detail
+     * 是否必填:否
+     * 类型:array
+     * 描述:
+     *  单品列表信息
+     * 
+ */ + @SerializedName(value = "goods_detail") + private List goodsDetails; + } + + @Data + @NoArgsConstructor + public static class GoodsDetail implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:商品编码
+     * 变量名:goods_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  商品编码
+     *  示例值:M1006
+     * 
+ */ + @SerializedName(value = "goods_id") + private String goodsId; + /** + *
+     * 字段名:商品数量
+     * 变量名:quantity
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  用户购买的数量
+     *  示例值:1
+     * 
+ */ + @SerializedName(value = "quantity") + private Integer quantity; + /** + *
+     * 字段名:商品单价
+     * 变量名:unit_price
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  商品单价,单位为分
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "unit_price") + private Integer unitPrice; + /** + *
+     * 字段名:商品优惠金额
+     * 变量名:discount_amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  商品优惠金额
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "discount_amount") + private Integer discountAmount; + /** + *
+     * 字段名:商品备注
+     * 变量名:goods_remark
+     * 是否必填:否
+     * 类型:string[1,128]
+     * 描述:
+     *  商品备注信息
+     *  示例值:商品备注信息
+     * 
+ */ + @SerializedName(value = "goods_remark") + private String goodsRemark; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayPartnerRefundNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayPartnerRefundNotifyV3Result.java new file mode 100644 index 0000000000..fc0007565d --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayPartnerRefundNotifyV3Result.java @@ -0,0 +1,230 @@ +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/wiki/doc/apiv3_partner/apis/chapter4_1_11.shtml + * + * @author Pursuer + * @version 1.0 + * @date 2023/3/2 + */ +@Data +@NoArgsConstructor +public class WxPayPartnerRefundNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result { + private static final long serialVersionUID = -1L; + /** + * 源数据 + */ + private OriginNotifyResponse rawData; + /** + * 解密后的数据 + */ + private DecryptNotifyResult result; + + @Data + @NoArgsConstructor + public static class DecryptNotifyResult implements Serializable { + private static final long serialVersionUID = -1L; + /** + *
+     * 字段名:服务商的商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  服务商的商户号,由微信支付生成并下发。
+     *  示例值:1230000109
+     * 
+ */ + @SerializedName(value = "sp_mchid") + private String spMchId; + /** + *
+     * 字段名:子商户的商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1, 32]
+     * 描述:
+     *  子商户商户号,由微信支付生成并下发。
+     *  示例值:1230000109
+     * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchId; + /** + *
+     * 字段名:商户订单号
+     * 变量名:out_trade_no
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  返回的商户订单号
+     *  示例值: 1217752501201407033233368018
+     * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + /** + *
+     * 字段名:微信支付订单号
+     * 变量名:transaction_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  微信支付订单号
+     *  示例值: 1217752501201407033233368018
+     * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + /** + *
+     * 字段名:商户退款单号
+     * 变量名:out_refund_no
+     * 是否必填:是
+     * 类型:string[1,64]
+     * 描述:
+     *  商户退款单号
+     *  示例值: 1217752501201407033233368018
+     * 
+ */ + @SerializedName(value = "out_refund_no") + private String outRefundNo; + /** + *
+     * 字段名:微信支付退款号
+     * 变量名:refund_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  微信退款单号
+     *  示例值: 1217752501201407033233368018
+     * 
+ */ + @SerializedName(value = "refund_id") + private String refundId; + /** + *
+     * 字段名:退款状态
+     * 变量名:refund_status
+     * 是否必填:是
+     * 类型:string[1,16]
+     * 描述:
+     *  退款状态,枚举值:
+     *  SUCCESS:退款成功
+     *  CLOSE:退款关闭
+     *  ABNORMAL:退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往【商户平台—>交易中心】,手动处理此笔退款
+     *  示例值:SUCCESS
+     * 
+ */ + @SerializedName(value = "refund_status") + private String refundStatus; + /** + *
+     * 字段名:退款成功时间
+     * 变量名:success_time
+     * 是否必填:否
+     * 类型:string[1,64]
+     * 描述:
+     *  1、退款成功时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
+     *  2、当退款状态为退款成功时返回此参数。
+     *  示例值:2018-06-08T10:34:56+08:00
+     * 
+ */ + @SerializedName(value = "success_time") + private String successTime; + /** + *
+     * 字段名:退款入账账户
+     * 变量名:user_received_account
+     * 是否必填:是
+     * 类型:string[1,64]
+     * 描述:
+     *  取当前退款单的退款入账方。
+     *  1、退回银行卡:{银行名称}{卡类型}{卡尾号}
+     *  2、退回支付用户零钱: 支付用户零钱
+     *  3、退还商户: 商户基本账户、商户结算银行账户
+     *  4、退回支付用户零钱通:支付用户零钱通
+     *  示例值:招商银行信用卡0403
+     * 
+ */ + @SerializedName(value = "user_received_account") + private String userReceivedAccount; + /** + *
+     * 字段名:金额信息
+     * 变量名:amount
+     * 是否必填:是
+     * 类型:object
+     * 描述:
+     *  金额信息
+     * 
+ */ + @SerializedName(value = "amount") + private Amount amount; + } + + @Data + @NoArgsConstructor + public static class Amount implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:订单金额
+     * 变量名:total
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  订单总金额,单位为分,只能为整数,详见支付金额
+     *  示例值:999
+     * 
+ */ + @SerializedName(value = "total") + private Integer total; + /** + *
+     * 字段名:退款金额
+     * 变量名:refund
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额,如果有使用券,后台会按比例退。
+     *  示例值:999
+     * 
+ */ + @SerializedName(value = "refund") + private Integer refund; + /** + *
+     * 字段名:用户支付金额
+     * 变量名:payer_total
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  用户实际支付金额,单位为分,只能为整数,详见支付金额
+     *  示例值:999
+     * 
+ */ + @SerializedName(value = "payer_total") + private Integer payerTotal; + /** + *
+     * 字段名:用户退款金额
+     * 变量名:payer_refund
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  退款给用户的金额,不包含所有优惠券金额
+     *  示例值:999
+     * 
+ */ + @SerializedName(value = "payer_refund") + private Integer payerRefund; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java index 961dbaa116..c3473ee465 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java @@ -14,7 +14,7 @@ */ @Data @NoArgsConstructor -public class WxPayRefundNotifyV3Result implements Serializable { +public class WxPayRefundNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result { private static final long serialVersionUID = -1L; /** * 源数据 @@ -184,7 +184,7 @@ public static class Amount implements Serializable { *
*/ @SerializedName(value = "refund") - private String refund; + private Integer refund; /** *
      * 字段名:用户支付金额
@@ -210,6 +210,6 @@ public static class Amount implements Serializable {
      * 
*/ @SerializedName(value = "payer_refund") - private String payerRefund; + private Integer payerRefund; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Detail.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Detail.java index b52c2abc1b..d576a97c34 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Detail.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Detail.java @@ -5,12 +5,13 @@ import lombok.NoArgsConstructor; import java.io.Serializable; +import java.util.List; /** * 明细. * * @author doger.wang - * @date 2020-05-19 + * created on 2020-05-19 */ @Data @NoArgsConstructor @@ -33,4 +34,6 @@ public class Detail implements Serializable { private String paidTime; @SerializedName("transaction_id") private String transactionId; + @SerializedName("promotion_detail") + private List promotionDetail; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/GoodsDetail.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/GoodsDetail.java new file mode 100644 index 0000000000..694c99f1a1 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/GoodsDetail.java @@ -0,0 +1,27 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 优惠商品信息 + **/ +@Data +@NoArgsConstructor +public class GoodsDetail implements Serializable { + + private static final long serialVersionUID = 7139782546598279686L; + @SerializedName("goods_id") + private String goodsId; + @SerializedName("quantity") + private Integer quantity; + @SerializedName("unit_price") + private Integer unitPrice; + @SerializedName("discount_amount") + private Integer discountAmount; + @SerializedName("goods_remark") + private String goodsRemark; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Location.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Location.java index b3c82f7d96..a73a69ce11 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Location.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/Location.java @@ -10,7 +10,7 @@ * 服务位置信息. * * @author doger.wang - * @date 2020-05-19 + * created on 2020-05-19 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PartnerUserSignPlanDetail.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PartnerUserSignPlanDetail.java new file mode 100644 index 0000000000..a17fb9d833 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PartnerUserSignPlanDetail.java @@ -0,0 +1,94 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.github.binarywang.wxpay.bean.payscore.enums.SignPlanServiceOrderPlanDetailStateEnum; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author UltramanNoa + * @className PartnerUserSignPlanDetail + * @description 签约计划明细列表 + * @createTime 2023/11/3 17:19 + **/ +@Data +@NoArgsConstructor +public class PartnerUserSignPlanDetail implements Serializable { + + private static final long serialVersionUID = 2089297485318293622L; + /** + * 计划明细序号 + */ + @SerializedName("plan_detail_no") + private Integer planDetailNo; + + /** + * 计划明细原支付金额(单位分) + */ + @SerializedName("original_price") + private Integer originalPrice; + + /** + * 计划明细优惠说明 + */ + @SerializedName("plan_discount_description") + private String planDiscountDescription; + + /** + * 计划明细实际支付金额(单位分) + */ + @SerializedName("actual_price") + private Integer actualPrice; + + /** + * 计划明细状态 + * + * @see SignPlanServiceOrderPlanDetailStateEnum + */ + @SerializedName("plan_detail_state") + private String planDetailState; + + /** + * 计划明细对应的支付分服务单号 + */ + @SerializedName("order_id") + private String orderId; + + /** + * 商户侧计划明细使用订单号 + */ + @SerializedName("merchant_plan_detail_no") + private String merchantPlanDetailNo; + + /** + * 计划详情名称 + */ + @SerializedName("plan_detail_name") + private String planDetailName; + + /** + * 计划明细对应订单实际支付金额(单位分) + */ + @SerializedName("actual_pay_price") + private Integer actualPayPrice; + + /** + * 详情使用时间 + */ + @SerializedName("use_time") + private String useTime; + + /** + * 详情完成时间 + */ + @SerializedName("complete_time") + private String completeTime; + + /** + * 详情取消时间 + */ + @SerializedName("cancel_time") + private String cancelTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PartnerUserSignPlanEntity.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PartnerUserSignPlanEntity.java new file mode 100644 index 0000000000..60b7898869 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PartnerUserSignPlanEntity.java @@ -0,0 +1,165 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.github.binarywang.wxpay.bean.payscore.enums.SignPlanServiceOrderStateEnum; +import com.github.binarywang.wxpay.bean.payscore.enums.UserSignPlanCancelSignTypeEnum; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * @author UltramanNoa + * @className PartnerUserSignPlanEntity + * @description 用户的签约计划 + * @createTime 2023/11/3 16:05 + **/ +@Data +@NoArgsConstructor +public class PartnerUserSignPlanEntity implements Serializable { + + private static final long serialVersionUID = -662901613603698430L; + + public static PartnerUserSignPlanEntity fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, PartnerUserSignPlanEntity.class); + } + + + /** + * 待创建服务订单对应的用户的签约计划 + */ + @SerializedName("sign_plan_id") + private String signPlanId; + + @SerializedName("openid") + private String openid; + + /** + *
+   * 字段名:二级商户用户标识
+   * 变量名:sub_openid
+   * 是否必填:否
+   * 类型:string(128)
+   * 描述:
+   *  用户在二级商户appid下的唯一标识。
+   *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+   * 
+ */ + @SerializedName(value = "sub_openid") + private String subOpenid; + + + @SerializedName("service_id") + private String serviceId; + + @SerializedName("mchid") + private String mchid; + + /** + * 子商户商户号 + */ + @SerializedName("sub_mchid") + private String subMchid; + + @SerializedName("appid") + private String appid; + + /** + * 子商户AppID + */ + @SerializedName("sub_appid") + private String subAppid; + + /** + * 商户签约计划单号 + */ + @SerializedName("merchant_sign_plan_no") + private String merchantSignPlanNo; + + /** + * 商户回调地址 + */ + @SerializedName("merchant_callback_url") + private String merchantCallbackUrl; + + /** + * 支付分计划ID + */ + @SerializedName("plan_id") + private String planId; + + /** + * 目前用户进行到的计划详情序号 + */ + @SerializedName("going_detail_no") + private Integer goingDetailNo; + + /** + * 计划签约状态 + * + * @see SignPlanServiceOrderStateEnum + */ + @SerializedName("sign_state") + private String signState; + + /** + * 签约计划取消时间 + */ + @SerializedName("cancel_sign_time") + private String cancelSignTime; + + /** + * 签约计划取消类型 + * + * @see UserSignPlanCancelSignTypeEnum + */ + @SerializedName("cancel_sign_type") + private String cancelSignType; + + /** + * 签约计划取消原因 + */ + @SerializedName("cancel_reason") + private String cancelReason; + + /** + * 签约计划的名称 + */ + @SerializedName("plan_name") + private String planName; + + /** + * 签约计划的过期时间 + */ + @SerializedName("plan_over_time") + private String planOverTime; + + /** + * 签约计划原总金额(单位分) + */ + @SerializedName("total_origin_price") + private Integer totalOriginPrice; + + /** + * 签约计划扣费次数 + */ + @SerializedName("deduction_quantity") + private Integer deductionQuantity; + + /** + * 签约计划实际总金额(单位分) + */ + @SerializedName("total_actual_price") + private Integer totalActualPrice; + + @SerializedName("signed_detail_list") + private List signedDetailList; + + /** + * 签约时间 + */ + @SerializedName("sign_time") + private String signTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScoreNotifyData.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScoreNotifyData.java index 82afdb4ce6..c16f397daf 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScoreNotifyData.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScoreNotifyData.java @@ -10,7 +10,7 @@ * 微信支付分确认订单跟支付回调对象 * * @author doger.wang - * @date 2020/5/14 12:18 + * created on 2020/5/14 12:18 */ @NoArgsConstructor @Data @@ -29,17 +29,24 @@ public class PayScoreNotifyData implements Serializable { @SerializedName("create_time") private String createTime; + /** + * 通知类型 + *

1、授权成功通知的类型为PAYSCORE.USER_OPEN_SERVICE

+ *

2、解除授权成功通知的类型为PAYSCORE.USER_CLOSE_SERVICE

+ *

3、用户确认成功通知的类型为PAYSCORE.USER_CONFIRM

+ *

4、支付成功通知的类型为PAYSCORE.USER_PAID

+ *

5、取消签约成功通知类型为PAYSCORE.USER_CANCEL_SIGN_PLAN

+ *

6、签约计划成功通知类型为PAYSCORE.USER_SIGN_PLAN

+ */ + @SerializedName("event_type") + private String eventType; + /** * 通知数据类型 */ @SerializedName("resource_type") private String resourceType; - /** - * 通知类型 - */ - @SerializedName("event_type") - private String eventType; /** * 通知数据 @@ -80,5 +87,11 @@ public static class Resource implements Serializable { */ @SerializedName("associated_data") private String associatedData; + + /** + * 原始回调类型,支付分的原始回调类型为payscore + */ + @SerializedName("original_type") + private String originalType; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetail.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetail.java new file mode 100644 index 0000000000..a0ed7ed123 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetail.java @@ -0,0 +1,49 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author UltramanNoa + * @className PayScorePlanDetail + * @description 支付分计划明细列表 + * @createTime 2023/11/3 11:22 + **/ +@Data +@NoArgsConstructor +public class PayScorePlanDetail implements Serializable { + + private static final long serialVersionUID = 999251141141181820L; + /** + * 计划明细原支付金额(单位分) + */ + @SerializedName("original_price") + private Integer originalPrice; + + /** + * 计划明细优惠说明 + */ + @SerializedName("plan_discount_description") + private String planDiscountDescription; + + /** + * 计划明细实际支付金额(单位分) + */ + @SerializedName("actual_price") + private String actualPrice; + + /** + * 计划明细名称 + */ + @SerializedName("plan_detail_name") + private String planDetailName; + + /** + * 计划明细序号(返回参数) + */ + @SerializedName("plan_detail_no") + private Integer planDetailNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetailRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetailRequest.java new file mode 100644 index 0000000000..2f639e7668 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetailRequest.java @@ -0,0 +1,43 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author UltramanNoa + * @className PayScorePlanDetail + * @description 支付分计划明细列表 + * @createTime 2023/11/3 11:22 + **/ +@Data +@NoArgsConstructor +public class PayScorePlanDetailRequest implements Serializable { + + private static final long serialVersionUID = 999251141141181820L; + /** + * 计划明细原支付金额(单位分) + */ + @SerializedName("original_price") + private Integer originalPrice; + + /** + * 计划明细优惠说明 + */ + @SerializedName("plan_discount_description") + private String planDiscountDescription; + + /** + * 计划明细实际支付金额(单位分) + */ + @SerializedName("actual_price") + private Long actualPrice; + + /** + * 计划明细名称 + */ + @SerializedName("plan_detail_name") + private String planDetailName; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetailResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetailResult.java new file mode 100644 index 0000000000..c4b3d3c042 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PayScorePlanDetailResult.java @@ -0,0 +1,25 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author UltramanNoa + * @className PayScorePlanDetail + * @description 支付分计划明细列表 + * @createTime 2023/11/3 11:22 + **/ +@Data +@NoArgsConstructor +public class PayScorePlanDetailResult extends PayScorePlanDetailRequest implements Serializable { + + private static final long serialVersionUID = -2195861995542633650L; + /** + * 计划明细序号(返回参数) + */ + @SerializedName("plan_detail_no") + private Integer planDetailNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostDiscount.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostDiscount.java index ebd2cf2b39..be41bd7289 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostDiscount.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostDiscount.java @@ -10,7 +10,7 @@ * 后付费商户优惠. * * @author doger.wang - * @date 2020-05-19 + * created on 2020-05-19 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostPayment.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostPayment.java index e40960a056..7583a67088 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostPayment.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PostPayment.java @@ -11,7 +11,7 @@ * 后付费项目. * * @author doger.wang - * @date 2020-05-19 + * created on 2020-05-19 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PromotionDetail.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PromotionDetail.java new file mode 100644 index 0000000000..78f88cc2ed --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/PromotionDetail.java @@ -0,0 +1,41 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 优惠详情 + **/ +@Data +@NoArgsConstructor +public class PromotionDetail implements Serializable { + + private static final long serialVersionUID = -4405156288317582934L; + + @SerializedName("coupon_id") + private String couponId; + @SerializedName("name") + private String name; + @SerializedName("scope") + private String scope; + @SerializedName("type") + private String type; + @SerializedName("amount") + private Integer amount; + @SerializedName("stock_id") + private String stockId; + @SerializedName("wechatpay_contribute") + private Integer wechatpayContribute; + @SerializedName("merchant_contribute") + private Integer merchantContribute; + @SerializedName("other_contribute") + private Integer otherContribute; + @SerializedName("currency") + private String currency; + @SerializedName("goods_detail") + private List goodsDetail; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/RiskFund.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/RiskFund.java index c6bd840186..e4e9ab1a3f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/RiskFund.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/RiskFund.java @@ -10,7 +10,7 @@ * 订单风险金信息. * * @author doger.wang - * @date 2020-05-19 + * created on 2020-05-19 */ @Data @NoArgsConstructor diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/SyncDetail.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/SyncDetail.java new file mode 100644 index 0000000000..8675299c88 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/SyncDetail.java @@ -0,0 +1,24 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @description 内容信息详情 + * createTime: 2023/9/19 16:39 + **/ +@Data +@NoArgsConstructor +public class SyncDetail implements Serializable { + + private static final long serialVersionUID = 8173356554917822934L; + @SerializedName("seq") + private int seq; + @SerializedName("paid_time") + private String paidTime; + @SerializedName("paid_amount") + private Integer paidAmount; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/TimeRange.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/TimeRange.java index a0a27693d7..3062f87212 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/TimeRange.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/TimeRange.java @@ -11,7 +11,7 @@ * 服务时间范围. * * @author doger.wang - * @date 2020-05-19 + * created on 2020-05-19 */ @Data @NoArgsConstructor @@ -26,4 +26,16 @@ public class TimeRange implements Serializable { private String startTime; @SerializedName("end_time") private String endTime; + + /** + * 服务开始时间备注 + */ + @SerializedName("start_time_remark") + private String startTimeRemark; + + /** + * 服务结束时间备注 + */ + @SerializedName("end_time_remark") + private String endTimeRemark; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/UserSignPlanDetailMerchatNo.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/UserSignPlanDetailMerchatNo.java new file mode 100644 index 0000000000..bd081cec85 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/UserSignPlanDetailMerchatNo.java @@ -0,0 +1,32 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author UltramanNoa + * @className UserSignPlanDetailMerchatNo + * @description 签约计划对应的计划详情列表的商户侧单号信息 + * @createTime 2023/11/3 15:51 + **/ +@Data +@NoArgsConstructor +public class UserSignPlanDetailMerchatNo implements Serializable { + + private static final long serialVersionUID = 2668791598158720023L; + + /** + * 计划明细序号 + */ + @SerializedName("plan_detail_no") + private Integer planDetailNo; + + /** + * 商户侧计划明细使用订单号 + */ + @SerializedName("merchant_plan_detail_no") + private String merchantPlanDetailNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreRequest.java new file mode 100644 index 0000000000..a29e08bd92 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreRequest.java @@ -0,0 +1,58 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import lombok.experimental.SuperBuilder; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + + +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class WxPartnerPayScoreRequest extends WxPayScoreRequest { + private static final long serialVersionUID = 6269843192878112955L; + + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + + /** + * 子商户appid + */ + @SerializedName("sub_appid") + private String subAppid; + + /** + * 子商户mchid + */ + @SerializedName("sub_mchid") + private String subMchid; + + /** + * 子商户公众号下的用户表示sub_openid + * 微信用户在子商户公众号sub_appid下的唯一标识; + * need_user_confirm为false时,1. openid与sub_openid必须填写并且只能填写一个 2. 如果填写了sub_openid,那么sub_appid必填 + */ + @SerializedName("sub_openid") + private String subOpenid; + + /** + * [收付通子商户申请绑定支付分服务]的商户系统内部服务订单号 + */ + @SerializedName("out_apply_no") + private String outApplyNo; + + /** + * [收付通子商户申请绑定支付分服务]的绑定结果通知地址 + */ + @SerializedName("result_notify_url") + private String resultNotifyUrl; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreResult.java new file mode 100644 index 0000000000..cc80cc08f4 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreResult.java @@ -0,0 +1,45 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +/** + * @author hallkk + * created on 2022/05/18 + */ +@Data +@NoArgsConstructor +public class WxPartnerPayScoreResult extends WxPayScoreResult { + private static final long serialVersionUID = 718267574622164410L; + + public static WxPartnerPayScoreResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxPartnerPayScoreResult.class); + } + + @SerializedName("sub_appid") + private String subAppid; + + @SerializedName("sub_mchid") + private String subMchid; + + /** + * 子商户公众号下的用户标识 + */ + @SerializedName("sub_openid") + private String subOpenId; + + @SerializedName("out_apply_no") + private String outApplyNo; + + @SerializedName("result_notify_url") + private String resultNotifyUrl; + + @SerializedName("apply_state") + private String applyState; + + @SerializedName("reject_reason") + private String rejectReason; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreSignPlanRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreSignPlanRequest.java new file mode 100644 index 0000000000..145dc8d2fb --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreSignPlanRequest.java @@ -0,0 +1,130 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import lombok.experimental.SuperBuilder; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.util.List; + +/** + * @author UltramanNoa + * @className WxPartnerPayScoreSignPlanRequest + * @description 支付分计划请求参数 + * @createTime 2023/11/3 09:54 + **/ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class WxPartnerPayScoreSignPlanRequest extends WxPayScoreRequest { + private static final long serialVersionUID = 6269843192878112955L; + + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + + /** + * 子商户appid + */ + @SerializedName("sub_appid") + private String subAppid; + + /** + * 子商户mchid + */ + @SerializedName("sub_mchid") + private String subMchid; + + /** + * 子商户公众号下的用户标识 + */ + @SerializedName("sub_openid") + private String subOpenid; + /** + * 支付分计划名称 + */ + @SerializedName("plan_name") + private String planName; + + /** + * 支付分计划有效期(单位天) + */ + @SerializedName("plan_duration") + private Integer planDuration; + + /** + * 支付分计划扣费次数 + */ + @SerializedName("deduction_quantity") + private Integer deductionQuantity; + + + /** + * 支付分计划原总金额(单位分) + */ + @SerializedName("total_original_price") + private Integer totalOriginalPrice; + + /** + * 支付分计划实际扣费总金额(单位分) + */ + @SerializedName("total_actual_price") + private Integer totalActualPrice; + + /** + * 支付分计划明细列表 + */ + @SerializedName("plan_detail_list") + private List planDetailList; + + /** + * 商户侧计划号 + */ + @SerializedName("merchant_plan_no") + private String merchantPlanNo; + + + /** + * 待创建服务订单对应的用户的签约计划 + */ + @SerializedName("sign_plan_id") + private String signPlanId; + + /** + * 待创建服务订单对应的用户的签约计划详情序号 + */ + @SerializedName("plan_detail_no") + private Integer planDetailNo; + + /** + * 商户侧订单号 + */ + @SerializedName("out_trade_no") + private String outTradeNo; + + /** + * 支付分计划ID + */ + @SerializedName("plan_id") + private String planId; + + /** + * 商户签约计划单号 + */ + @SerializedName("merchant_sign_plan_no") + private String merchantSignPlanNo; + + /** + * 签约计划对应的计划详情列表的商户侧单号信息 + */ + @SerializedName("sign_plan_detail") + private List signPlanDetail; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreSignPlanResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreSignPlanResult.java new file mode 100644 index 0000000000..294add7bad --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreSignPlanResult.java @@ -0,0 +1,104 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.util.List; + +/** + * @author UltramanNoa + * @className WxPartnerPayScoreSignPlanResult + * @description 支付分计划响应参数 + * @createTime 2023/11/3 10:11 + **/ +@Data +@NoArgsConstructor +public class WxPartnerPayScoreSignPlanResult extends WxPayScoreResult { + + private static final long serialVersionUID = 4048529978029913621L; + + public static WxPartnerPayScoreSignPlanResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxPartnerPayScoreSignPlanResult.class); + } + + /** + * 子商户AppID + */ + @SerializedName("sub_appid") + private String subAppid; + + /** + * 子商户商户号 + */ + @SerializedName("sub_mchid") + private String subMchid; + + /** + * 支付分计划ID + */ + @SerializedName("plan_id") + private String planId; + + /** + * 商户侧计划号 + */ + @SerializedName("merchant_plan_no") + private String merchantPlanNo; + + /** + * 支付分计划名称 + */ + @SerializedName("plan_name") + private String planName; + + /** + * 支付分计划有效期(单位天) + */ + @SerializedName("plan_duration") + private String planDuration; + + /** + * 支付分计划状态 + * + * @see + */ + @SerializedName("plan_state") + private String planState; + /** + * 支付分计划原总金额(单位分) + */ + @SerializedName("total_original_price") + private String totalOriginalPrice; + + /** + * 支付分计划扣费次数 + */ + @SerializedName("deduction_quantity") + private String deductionQuantity; + + /** + * 支付分计划实际扣费总金额(单位分) + */ + @SerializedName("total_actual_price") + private Integer totalActualPrice; + + /** + * 支付分计划明细列表 + */ + @SerializedName("plan_detail_list") + private List planDetailList; + + /** + * 终止方商户号 + */ + @SerializedName("stop_mchid") + private String stopMchid; + + /** + * 终止时间 + */ + @SerializedName("stop_time") + private String stopTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreUserSignPlanResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreUserSignPlanResult.java new file mode 100644 index 0000000000..4080d8168e --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerPayScoreUserSignPlanResult.java @@ -0,0 +1,31 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * @author UltramanNoa + * @className WxPartnerUserSignPlanResult + * @description 微信支付分用户签约计划返回 + * @createTime 2023/11/3 16:38 + **/ +@Data +@NoArgsConstructor +public class WxPartnerPayScoreUserSignPlanResult implements Serializable { + + private static final long serialVersionUID = 4148075707018175845L; + + public static WxPartnerPayScoreUserSignPlanResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxPartnerPayScoreUserSignPlanResult.class); + } + + @SerializedName("sign_plan") + private PartnerUserSignPlanEntity signPlan; + + @SerializedName("package") + private String pack; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerUserAuthorizationStatusNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerUserAuthorizationStatusNotifyResult.java new file mode 100644 index 0000000000..feeabaac16 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPartnerUserAuthorizationStatusNotifyResult.java @@ -0,0 +1,67 @@ +package com.github.binarywang.wxpay.bean.payscore; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 授权/解除授权服务回调通知结果 + *
+ *   文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter6_2_23.shtml
+ * 
+ */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class WxPartnerUserAuthorizationStatusNotifyResult extends UserAuthorizationStatusNotifyResult implements Serializable { + + private static final long serialVersionUID = 8809250065540275783L; + + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:sub_appid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  子商户申请的公众号或移动应用APPID。
+   * 示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppId; + + /** + *
+   * 字段名:子商户的商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  子商户商户号,由微信支付生成并下发。
+   * 示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchId; + + /** + *
+   * 字段名:子商户公众号下openid
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  微信用户在商户对应sub_appid下的唯一标识。(传了sub_appid的情况下则只返回sub_openid)。
+   * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+   * 
+ */ + @SerializedName(value = "sub_openid") + private String subOpenid; + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequest.java index 0f4b92a7b7..3c58a62e80 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequest.java @@ -1,23 +1,22 @@ package com.github.binarywang.wxpay.bean.payscore; -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.NoArgsConstructor; import lombok.experimental.Accessors; +import lombok.experimental.SuperBuilder; import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import java.io.Serializable; +import java.util.List; + /** * @author doger.wang - * @date 2020/5/12 16:36 + * created on 2020/5/12 16:36 */ @Data -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @@ -28,7 +27,7 @@ public String toJson() { return WxGsonBuilder.create().toJson(this); } - /** + /**` * out_order_no : 1234323JKHDFE1243252 * appid : wxd678efh567hg6787 * service_id : 500001 @@ -42,6 +41,7 @@ public String toJson() { * notify_url : https://api.test.com * openid : oUpF8uMuAJO_M2pxb1Q9zNjWeS6o * need_user_confirm : true + * profitSharing : false:不分账,默认:false,true:分账 */ @SerializedName("out_order_no") private String outOrderNo; @@ -80,8 +80,19 @@ public String toJson() { @SerializedName("type") private String type; @SerializedName("detail") - private Detail detail; + private SyncDetail detail; @SerializedName("authorization_code") - private String authorizationCode; + private String authorizationCode; + /** + * 完结服务时间 + * 时间使用ISO 8601所定义的格式。 + * 示例: + * - YYYY-MM-DDTHH:mm:ss.SSSZ + * - YYYY-MM-DDTHH:mm:ssZ + * - YYYY-MM-DDTHH:mm:ss.SSS+08:00 + * - YYYY-MM-DDTHH:mm:ss+08:00 + */ + @SerializedName("complete_time") + private String completeTime; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreResult.java index 266440d214..31942a954b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreResult.java @@ -11,7 +11,7 @@ /** * @author doger.wang - * @date 2020/5/12 17:05 + * created on 2020/5/12 17:05 */ @NoArgsConstructor @Data @@ -85,21 +85,47 @@ public static WxPayScoreResult fromJson(String json) { @SerializedName("payScoreSignInfo") private Map payScoreSignInfo; + @SerializedName("openid") + private String openid; + @SerializedName("apply_permissions_token") - private String applyPermissionsToken; + private String applyPermissionsToken; @SerializedName("authorization_code") - private String authorizationCode; + private String authorizationCode; @SerializedName("authorization_state") - private String authorizationState; + private String authorizationState; @SerializedName("cancel_authorization_time") - private String cancelAuthorizationTime; + private String cancelAuthorizationTime; @SerializedName("authorization_success_time") - private String authorizationSuccessTime; + private String authorizationSuccessTime; + + /** + * 用户分层 + */ + @SerializedName("user_risk_level") + private Integer userRiskLevel; + + /** + * 分层版本 + */ + @SerializedName("risk_level_version") + private Integer riskLevelVersion; + + /** + * 总金额 + */ + @SerializedName("total_amount") + private Integer totalAmount; + /** + * 渠道商商户号 + */ + @SerializedName("channel_id") + private String channelId; /** * 收款信息 diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/SignPlanServiceOrderPlanDetailStateEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/SignPlanServiceOrderPlanDetailStateEnum.java new file mode 100644 index 0000000000..38c2d58190 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/SignPlanServiceOrderPlanDetailStateEnum.java @@ -0,0 +1,30 @@ +package com.github.binarywang.wxpay.bean.payscore.enums; + +/** + * @author UltramanNoa + * @className SignPlanServiceOrderPlanDetailStateEnum + * @description 计划明细状态 + * @createTime 2023/11/3 17:43 + **/ +public enum SignPlanServiceOrderPlanDetailStateEnum { + /** + * 本计划详情还未使用 + */ + NOT_USED, + + /** + * 本计划详情使用中,已有对应的服务订单 + */ + USING, + + /** + * 本计划详情已使用,对应的服务订单已完成支付 + */ + USED, + + /** + * 本计划详情已取消使用,对应的服务订单已取消 + */ + SIGN_PLAN_DETAIL_CANCEL, + ; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/SignPlanServiceOrderStateEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/SignPlanServiceOrderStateEnum.java new file mode 100644 index 0000000000..1f0381dc69 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/SignPlanServiceOrderStateEnum.java @@ -0,0 +1,36 @@ +package com.github.binarywang.wxpay.bean.payscore.enums; + +/** + * @author UltramanNoa + * @className SignPlanServiceOrderStateEnum + * @description 签约计划服务订单状态 + * @createTime 2023/11/3 15:28 + **/ +public enum SignPlanServiceOrderStateEnum { + + /** + * 商户已创建服务订单 + */ + CREATED, + + /** + * 服务订单进行中 + */ + DOING, + + /** + * 服务订单完成 + */ + DONE, + + /** + * 商户取消服务订单 + */ + REVOKED, + + /** + * 服务订单已失效 + */ + EXPIRED, + ; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/UserSignPlanCancelSignTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/UserSignPlanCancelSignTypeEnum.java new file mode 100644 index 0000000000..f5669f95df --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/enums/UserSignPlanCancelSignTypeEnum.java @@ -0,0 +1,30 @@ +package com.github.binarywang.wxpay.bean.payscore.enums; + +/** + * @author UltramanNoa + * @className UserSignPlanCancelSignTypeEnum + * @description 签约计划取消类型 + * @createTime 2023/11/3 17:15 + **/ +public enum UserSignPlanCancelSignTypeEnum { + /** + * 用户已签约协议未取消 + */ + NOT_CANCEL, + + /** + * 用户取消已签约的协议 + */ + USER, + + /** + * 商户取消已签约的协议 + */ + MERCHANT, + + /** + * 用户解除服务授权时取消服务下的已签约协议 + */ + REVOKE_SERVICE, + ; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingResult.java deleted file mode 100644 index ce6a1f8e95..0000000000 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingResult.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.binarywang.wxpay.bean.profitsharing; - -import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; -import com.thoughtworks.xstream.annotations.XStreamAlias; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import org.w3c.dom.Document; - -import java.io.Serializable; - -/** - * @author Wang GuangXin 2019/10/22 10:06 - * @version 1.0 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@NoArgsConstructor -@XStreamAlias("xml") -public class ProfitSharingResult extends BaseWxPayResult implements Serializable { - private static final long serialVersionUID = 7435709584788869456L; - - /** - * 微信订单号. - */ - @XStreamAlias("transaction_id") - private String transactionId; - /** - * 商户分账单号. - */ - @XStreamAlias("out_order_no") - private String outOrderNo; - /** - * 微信分账单号. - */ - @XStreamAlias("order_id") - private String orderId; - - @Override - protected void loadXml(Document d) { - transactionId = readXmlString(d, "transaction_id"); - outOrderNo = readXmlString(d, "out_order_no"); - orderId = readXmlString(d, "order_id"); - } -} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/Receiver.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/Receiver.java index 671e2951d4..e9dfbf87cb 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/Receiver.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/Receiver.java @@ -1,8 +1,10 @@ package com.github.binarywang.wxpay.bean.profitsharing; +import com.github.binarywang.wxpay.v3.SpecEncrypt; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.annotations.SerializedName; import java.io.Serializable; @@ -11,12 +13,90 @@ * @version 1.0 */ public class Receiver implements Serializable { + /** + *
+   * 字段名:分账接收方类型
+   * 是否必填:是
+   * 描述:
+   * 1、MERCHANT_ID:商户号
+   * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+   * 
+ */ + @SerializedName("type") private String type; + /** + *
+   * 字段名:分账接收方帐号
+   * 是否必填:是
+   * 描述:
+   * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+   * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+   * 
+ */ + @SerializedName("account") private String account; + /** + *
+   * 字段名:分账金额
+   * 是否必填:是
+   * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+   * 
+ */ + @SerializedName("amount") private Integer amount; + /** + *
+   * 字段名:分账描述
+   * 是否必填:是
+   * 描述: 分账的原因描述,分账账单中需要体现
+   * 
+ */ + @SerializedName("description") private String description; + /** + *
+   * 字段名:分账个人接收方姓名
+   * 是否必填:否
+   * 描述:
+   * 可选项,在接收方类型为个人的时可选填,若有值,会检查与 name 是否实名匹配,不匹配会拒绝分账请求
+   * 1、分账接收方类型是PERSONAL_OPENID,是个人姓名的密文(选传,传则校验) 此字段的加密方法详见:敏感信息加密说明
+   * 2、使用微信支付平台证书中的公钥
+   * 3、使用RSAES-OAEP算法进行加密
+   * 4、将请求中HTTP头部的Wechatpay-Serial设置为证书序列号
+   * 
+ */ + @SerializedName("name") + @SpecEncrypt private String name; + /** + *
+   * 字段名:与分账方的关系类型
+   * 是否必填:是
+   * 描述:子商户与接收方的关系。 本字段值为枚举:
+   * STORE:门店
+   * STAFF:员工
+   * STORE_OWNER:店主
+   * PARTNER:合作伙伴
+   * HEADQUARTER:总部
+   * BRAND:品牌方
+   * DISTRIBUTOR:分销商
+   * USER:用户
+   * SUPPLIER: 供应商
+   * CUSTOM:自定义
+   * 
+ */ + @SerializedName("relation_type") private String relationType; + /** + *
+   * 字段名:自定义的分账关系
+   * 是否必填:是
+   * 描述:子商户与接收方具体的关系,本字段最多10个字。
+   * 当字段relationType的值为CUSTOM时,本字段必填;
+   * 当字段relationType的值不为CUSTOM时,本字段无需填写。
+   * 
+ */ + @SerializedName("custom_relation") private String customRelation; /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/notify/ProfitSharingNotifyV3Response.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/notify/ProfitSharingNotifyV3Response.java new file mode 100644 index 0000000000..ea147eea91 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/notify/ProfitSharingNotifyV3Response.java @@ -0,0 +1,140 @@ +package com.github.binarywang.wxpay.bean.profitsharing.notify; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * + * 微信V3接口 + * 通用通知实体 + * + * @author yuanbo + * @since 2022-04-26-21:33 PM + */ +@Data +@NoArgsConstructor +public class ProfitSharingNotifyV3Response implements Serializable{ + private static final long serialVersionUID = 4242383310854692441L; + + /** + *
+   * 字段名:通知ID
+   * 是否必填:是
+   * 描述:通知的唯一ID
+   * 
+ */ + @SerializedName("id") + private String id; + + /** + *
+   * 字段名:通知创建时间
+   * 是否必填:是
+   * 描述:通知创建的时间,Rfc3339标准
+   * 
+ */ + @SerializedName("create_time") + private String createTime; + + /** + *
+   * 字段名:通知数据类型
+   * 是否必填:是
+   * 描述:通知的资源数据类型
+   * 
+ */ + @SerializedName("resource_type") + private String resourceType; + + /** + *
+   * 字段名:通知类型
+   * 是否必填:是
+   * 描述:通知的类型
+   * 
+ */ + @SerializedName("event_type") + private String eventType; + + /** + *
+   * 字段名:通知数据
+   * 是否必填:是
+   * 描述:通知资源数据
+   * 
+ */ + @SerializedName("resource") + private Resource resource; + + /** + *
+   * 字段名:通知简要说明
+   * 是否必填:是
+   * 描述:通知简要说明
+   * 
+ */ + @SerializedName("summary") + private String summary; + + @Data + @NoArgsConstructor + public static class Resource implements Serializable { + + private static final long serialVersionUID = 8530711804335261449L; + + + /** + *
+     * 字段名:加密算法类型
+     * 是否必填:是
+     * 描述:对分账结果数据进行加密的加密算法,目前只支持AEAD_AES_256_GCM
+     * 
+ */ + @SerializedName("algorithm") + private String algorithm; + + + /** + *
+     * 字段名:加密前的对象类型
+     * 是否必填:是
+     * 描述:加密前的对象类型,分账动账通知的类型为profitsharing
+     * 
+ */ + @SerializedName("original_type") + private String originalType; + + /** + *
+     * 字段名:数据密文
+     * 是否必填:是
+     * 描述:Base64编码后的分账结果数据密文
+     * 
+ */ + @SerializedName("ciphertext") + private String cipherText; + + /** + *
+     * 字段名:随机串
+     * 是否必填:是
+     * 描述:加密使用的随机串
+     * 
+ */ + @SerializedName("nonce") + private String nonce; + + /** + *
+     * 字段名:附加数据
+     * 是否必填:否
+     * 描述:附加数据
+     * 
+ */ + @SerializedName("associated_data") + private String associatedData; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/notify/ProfitSharingNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/notify/ProfitSharingNotifyV3Result.java new file mode 100644 index 0000000000..0a86269da7 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/notify/ProfitSharingNotifyV3Result.java @@ -0,0 +1,148 @@ +package com.github.binarywang.wxpay.bean.profitsharing.notify; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * + * 微信V3接口 + * 分账动账通知解密后数据实体 + * + * @author yuanbo + * @since 2022-04-26-21:08 PM + */ +@Data +@NoArgsConstructor +public class ProfitSharingNotifyV3Result implements Serializable { + private static final long serialVersionUID = -2875006651351414624L; + + /** + *
+   * 字段名:直连商户号
+   * 是否必填:是
+   * 描述:直连模式分账发起和出资商户
+   * 
+ */ + @SerializedName("mchid") + private String mchId; + + /** + *
+   * 字段名:服务商商户号
+   * 是否必填:是
+   * 描述:服务商模式分账发起商户。
+   * 
+ */ + @SerializedName("sp_mchid") + private String spMchid; + + /** + *
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:服务商模式分账出资商户。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+   * 字段名:微信分账/回退单号
+   * 是否必填:是
+   * 描述:微信分账/回退单号
+   * 
+ */ + @SerializedName("order_id") + private String orderId; + + /** + *
+   * 字段名:商户分账/回退单号
+   * 是否必填:是
+   * 描述:分账方系统内部的分账/回退单号
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:分账接收方
+   * 是否必填:是
+   * 描述:分账接收方对象
+   * 
+ */ + @SerializedName("receiver") + private Receiver receiver; + + /** + *
+   * 字段名:成功时间
+   * 是否必填:是
+   * 描述:成功时间,Rfc3339标准
+   * 
+ */ + @SerializedName("success_time") + private String successTime; + + @Data + @NoArgsConstructor + public static class Receiver implements Serializable { + + private static final long serialVersionUID = -931070141604645363L; + + /** + *
+     * 字段名:分账接收方类型
+     * 是否必填:是
+     * 描述:MERCHANT_ID:商户号(mch_id或者sub_mch_id)
+     * 
+ */ + @SerializedName("type") + private String type; + + /** + *
+     * 字段名:分账接收方账号
+     * 是否必填:是
+     * 描述:申请本功能商户号
+     * 
+ */ + @SerializedName("account") + private String account; + + /** + *
+     * 字段名:分账动账金额
+     * 是否必填:是
+     * 描述:分账动账金额,单位为分,只能为整数
+     * 
+ */ + @SerializedName("amount") + private Integer amount; + + /** + *
+     * 字段名:分账/回退描述
+     * 是否必填:是
+     * 描述:分账/回退描述
+     * 
+ */ + @SerializedName("description") + private String description; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingBillV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingBillV3Request.java new file mode 100644 index 0000000000..dcda949dc1 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingBillV3Request.java @@ -0,0 +1,55 @@ +package com.github.binarywang.wxpay.bean.profitsharing.request; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 微信V3接口-申请分账账单请求类 + * + * @author 狂龙骄子 + * @since 4.4.0 + * @date 2022-12-09 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ProfitSharingBillV3Request implements Serializable { + private static final long serialVersionUID = 5200819754873844593L; + + /** + *
+   * 字段名:子商户号
+   * 是否必填:否
+   * 描述:不填则默认返回服务商下的所有分账账单。如需下载某个子商户下的分账账单,则填指定的子商户号。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + + /** + *
+   * 字段名:账单日期
+   * 是否必填:是
+   * 描述:格式yyyy-MM-DD,仅支持三个月内的账单下载申请。
+   * 
+ */ + @SerializedName("bill_date") + private String billDate; + + /** + *
+   * 字段名:压缩类型
+   * 是否必填:否
+   * 描述:不填则默认是数据流。枚举值:GZIP:返回格式为.gzip的压缩包账单。
+   * 
+ */ + @SerializedName("tar_type") + private String tarType; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingMerchantRatioQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingMerchantRatioQueryRequest.java similarity index 92% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingMerchantRatioQueryRequest.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingMerchantRatioQueryRequest.java index d8b1ff9619..43902c7829 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingMerchantRatioQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingMerchantRatioQueryRequest.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.request; import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; import com.github.binarywang.wxpay.constant.WxPayConstants; @@ -12,7 +12,7 @@ /** * @author : cofedream - * @date : 2020-12-28 + * created on : 2020-12-28 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingOrderAmountQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingOrderAmountQueryRequest.java similarity index 93% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingOrderAmountQueryRequest.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingOrderAmountQueryRequest.java index 5718860f9f..416c35d7df 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingOrderAmountQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingOrderAmountQueryRequest.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.request; import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; import com.github.binarywang.wxpay.constant.WxPayConstants; @@ -11,7 +11,7 @@ /** * @author : cofedream - * @date : 2020-12-29 + * created on : 2020-12-29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingQueryRequest.java similarity index 96% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryRequest.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingQueryRequest.java index d342153a94..56a0d58408 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingQueryRequest.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.request; import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; import com.github.binarywang.wxpay.constant.WxPayConstants; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingQueryV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingQueryV3Request.java new file mode 100644 index 0000000000..981adad59f --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingQueryV3Request.java @@ -0,0 +1,57 @@ +package com.github.binarywang.wxpay.bean.profitsharing.request; + +import com.google.gson.annotations.SerializedName; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; +import me.chanjar.weixin.common.annotation.Required; + +import java.io.Serializable; + +/** + * @author lyt 2023/08/21 15:44 + * @version 1.0 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ProfitSharingQueryV3Request implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:微信支付分配的子商户号,即分账的出资商户号。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + /** + *
+   * 字段名:微信支付订单号.
+   * 变量名:transaction_id
+   * 是否必填:是
+   * String(32)
+   * 示例值:4208450740201411110007820472
+   * 描述:微信支付订单号
+   * 
+ */ + @XStreamAlias("transaction_id") + @Required + private String transactionId; + + /** + *
+   * 字段名:商户分账单号.
+   * 变量名:out_order_no
+   * 是否必填:是
+   * String(64)
+   * 示例值:P20150806125346
+   * 描述:查询分账结果,输入申请分账时的商户分账单号; 查询分账完结的执行结果,输入发起分账完结时的商户分账单号
+   * 
+ */ + @XStreamAlias("out_order_no") + @Required + private String outOrderNo; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReceiverRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReceiverRequest.java similarity index 95% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReceiverRequest.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReceiverRequest.java index db64854395..5bca6b60fa 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReceiverRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReceiverRequest.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.request; import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; import com.github.binarywang.wxpay.constant.WxPayConstants; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReceiver.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReceiverV3Request.java similarity index 60% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReceiver.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReceiverV3Request.java index cbdeeba285..b8de4f5d5b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReceiver.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReceiverV3Request.java @@ -1,27 +1,38 @@ -package com.github.binarywang.wxpay.bean.profitsharingV3; +package com.github.binarywang.wxpay.bean.profitsharing.request; +import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.v3.SpecEncrypt; import com.google.gson.annotations.SerializedName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; +import me.chanjar.weixin.common.annotation.Required; import java.io.Serializable; +import java.util.Map; /** + * 添加/删除分账接受方请求对象 * - * 微信V3接口 分账接收方实体 - * @author pg - * @date 2021-6-25 - * + * @author lyt 2023-08-23 10:09:21 + * @version 1.0 */ @Data @Builder(builderMethodName = "newBuilder") @NoArgsConstructor @AllArgsConstructor -public class ProfitSharingReceiver implements Serializable { - private static final long serialVersionUID = -4391888575149767840L; +public class ProfitSharingReceiverV3Request implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:微信支付分配的子商户号,即分账的出资商户号。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; /** *
@@ -33,6 +44,16 @@ public class ProfitSharingReceiver implements Serializable {
   @SerializedName("appid")
   private String appid;
 
+  /**
+   * 
+   * 字段名:子商户应用ID
+   * 是否必填:否
+   * 描述:子商户的公众账号ID,分账接收方类型包含PERSONAL_SUB_OPENID时必填
+   * 
+ */ + @SerializedName("sub_appid") + private String subAppid; + /** *
    * 字段名:分账接收方类型
@@ -104,41 +125,4 @@ public class ProfitSharingReceiver implements Serializable {
    */
   @SerializedName("custom_relation")
   private String customRelation;
-
-  /**
-   * 
-   * 字段名:分账描述
-   * 是否必填:是
-   * 描述: 分账的原因描述,分账账单中需要体现
-   * 
- */ - private String description; - /** - *
-   * 字段名:分账金额
-   * 是否必填:是
-   * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
-   * 
- */ - private Long amount; - - /** - * 此构造函数用于分账接口 - * - * @param type MERCHANT_ID:商户ID - * PERSONAL_WECHATID:个人微信号PERSONAL_OPENID:个人openid(由父商户APPID转换得到)PERSONAL_SUB_OPENID: 个人sub_openid(由子商户APPID转换得到) - * @param account 类型是MERCHANT_ID时,是商户ID - * 类型是PERSONAL_WECHATID时,是个人微信号 - * 类型是PERSONAL_OPENID时,是个人openid - * 类型是PERSONAL_SUB_OPENID时,是个人sub_openid - * @param amount 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额 - * @param description 分账的原因描述,分账账单中需要体现 - */ - public ProfitSharingReceiver(String type, String account, Long amount, String description) { - this.type = type; - this.account = account; - this.amount = amount; - this.description = description; - } - } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingRequest.java similarity index 91% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingRequest.java index e3b1f5690c..95b5e67fc9 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingRequest.java @@ -1,12 +1,16 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.request; import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.Gson; +import com.google.gson.annotations.SerializedName; import com.thoughtworks.xstream.annotations.XStreamAlias; import lombok.*; import me.chanjar.weixin.common.annotation.Required; +import java.io.Serializable; import java.util.Map; /** @@ -21,7 +25,6 @@ @XStreamAlias("xml") public class ProfitSharingRequest extends BaseWxPayRequest { private static final long serialVersionUID = 212049937430575842L; - /** *
    * 字段名:微信订单号.
@@ -35,7 +38,6 @@ public class ProfitSharingRequest extends BaseWxPayRequest {
   @XStreamAlias("transaction_id")
   @Required
   private String transactionId;
-
   /**
    * 
    * 字段名:商户分账单号.
@@ -49,7 +51,6 @@ public class ProfitSharingRequest extends BaseWxPayRequest {
   @XStreamAlias("out_order_no")
   @Required
   private String outOrderNo;
-
   /**
    * 
    * 字段名:分账接收方列表.
@@ -77,7 +78,6 @@ public class ProfitSharingRequest extends BaseWxPayRequest {
   @Required
   private String receivers;
 
-
   @Override
   protected void checkConstraints() throws WxPayException {
     // 目前仅支持HMAC-SHA256.
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnQueryRequest.java
similarity index 97%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnQueryRequest.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnQueryRequest.java
index d3c7816027..8e6be32a2e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnQueryRequest.java
@@ -1,4 +1,4 @@
-package com.github.binarywang.wxpay.bean.profitsharing;
+package com.github.binarywang.wxpay.bean.profitsharing.request;
 
 import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
 import com.github.binarywang.wxpay.constant.WxPayConstants;
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnRequest.java
similarity index 98%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnRequest.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnRequest.java
index 3e389a467a..b2a1d9aae8 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnRequest.java
@@ -1,4 +1,4 @@
-package com.github.binarywang.wxpay.bean.profitsharing;
+package com.github.binarywang.wxpay.bean.profitsharing.request;
 
 import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
 import com.github.binarywang.wxpay.constant.WxPayConstants;
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnV3Request.java
similarity index 81%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnRequest.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnV3Request.java
index 31e26775fb..6f4fd90269 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingReturnV3Request.java
@@ -1,4 +1,4 @@
-package com.github.binarywang.wxpay.bean.profitsharingV3;
+package com.github.binarywang.wxpay.bean.profitsharing.request;
 
 import com.google.gson.annotations.SerializedName;
 import lombok.AllArgsConstructor;
@@ -13,15 +13,25 @@
  * 请求分账回退API请求实体
  *
  * @author pg
- * @date 2021-6-25
+ * created on  2021-6-25
  */
 @Data
 @Builder(builderMethodName = "newBuilder")
 @NoArgsConstructor
 @AllArgsConstructor
-public class ProfitSharingReturnRequest implements Serializable {
+public class ProfitSharingReturnV3Request implements Serializable {
   private static final long serialVersionUID = -2175582517588397426L;
 
+  /**
+   * 
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:分账回退的接收商户,对应原分账出资的分账方商户,填写微信支付分配的商户号
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + /** *
    * 字段名:微信分账单号
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingFinishRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingUnfreezeRequest.java
similarity index 92%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingFinishRequest.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingUnfreezeRequest.java
index 3bff328b80..5644ae475c 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingFinishRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingUnfreezeRequest.java
@@ -1,4 +1,4 @@
-package com.github.binarywang.wxpay.bean.profitsharing;
+package com.github.binarywang.wxpay.bean.profitsharing.request;
 
 import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
 import com.github.binarywang.wxpay.constant.WxPayConstants;
@@ -9,6 +9,7 @@
 import java.util.Map;
 
 /**
+ * 解冻剩余资金API请求实体
  * @author Wang GuangXin 2019/10/23 14:02
  * @version 1.0
  */
@@ -18,7 +19,7 @@
 @NoArgsConstructor
 @AllArgsConstructor
 @XStreamAlias("xml")
-public class ProfitSharingFinishRequest extends BaseWxPayRequest {
+public class ProfitSharingUnfreezeRequest extends BaseWxPayRequest {
 
   private static final long serialVersionUID = -4265779954583596627L;
 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingUnfreezeV3Request.java
similarity index 75%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeRequest.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingUnfreezeV3Request.java
index c79b9b6389..3ecc513c1b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingUnfreezeV3Request.java
@@ -1,4 +1,4 @@
-package com.github.binarywang.wxpay.bean.profitsharingV3;
+package com.github.binarywang.wxpay.bean.profitsharing.request;
 
 import com.google.gson.annotations.SerializedName;
 import lombok.AllArgsConstructor;
@@ -13,15 +13,25 @@
  * 解冻剩余资金API请求实体
  *
  * @author pg
- * @date 2021-6-25
+ * created on  2021-6-25
  */
 @Data
 @Builder(builderMethodName = "newBuilder")
 @NoArgsConstructor
 @AllArgsConstructor
-public class ProfitSharingUnfreezeRequest implements Serializable {
+public class ProfitSharingUnfreezeV3Request implements Serializable {
   private static final long serialVersionUID = 6835471990040104843L;
 
+  /**
+   * 
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:微信支付分配的子商户号,即分账的出资商户号。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + /** *
    * 字段名:微信订单号
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingV3Request.java
new file mode 100644
index 0000000000..9b8e0c1110
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/request/ProfitSharingV3Request.java
@@ -0,0 +1,196 @@
+package com.github.binarywang.wxpay.bean.profitsharing.request;
+
+import com.github.binarywang.wxpay.v3.SpecEncrypt;
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 微信V3接口
+ * 请求分账API请求实体
+ *
+ * @author pg
+ * created on  2021-6-24
+ */
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProfitSharingV3Request implements Serializable {
+  private static final long serialVersionUID = 3644929701624280800L;
+
+  /**
+   * 
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:微信支付分配的子商户号,即分账的出资商户号。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + + /** + *
+   * 字段名:应用ID
+   * 是否必填:是
+   * 描述:微信分配的商户appid
+   * 
+ */ + @SerializedName("appid") + private String appid; + + /** + *
+   * 字段名:子商户应用ID
+   * 是否必填:否
+   * 描述:子商户的公众账号ID,分账接收方类型包含PERSONAL_SUB_OPENID时必填
+   * 
+ */ + @SerializedName("sub_appid") + private String subAppid; + + /** + *
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:分账接收方列表
+   * 是否必填:是
+   * 描述:分账接收方列表,可以设置出资商户作为分账接受方,最多可有50个分账接收方
+   * 
+ */ + @SpecEncrypt + @SerializedName("receivers") + private List receivers; + + /** + *
+   * 字段名:是否解冻剩余未分资金
+   * 是否必填:是
+   * 描述:
+   * 1、如果为true,该笔订单剩余未分账的金额会解冻回分账方商户;
+   * 2、如果为false,该笔订单剩余未分账的金额不会解冻回分账方商户,可以对该笔订单再次进行分账。
+   * 
+ */ + @SerializedName("unfreeze_unsplit") + private boolean unfreezeUnsplit; + /** + * 分账接收方实体 + */ + @Data + @NoArgsConstructor + public static class Receiver implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:分账接收方类型
+     * 是否必填:是
+     * 描述:
+     * 1、MERCHANT_ID:商户号
+     * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+     * 
+ */ + @SerializedName("type") + private String type; + + /** + *
+     * 字段名:分账接收方帐号
+     * 是否必填:是
+     * 描述:
+     * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+     * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+     * 
+ */ + @SerializedName("account") + private String account; + + /** + *
+     * 字段名:分账金额
+     * 是否必填:是
+     * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+     * 
+ */ + @SerializedName("amount") + private Integer amount; + + /** + *
+     * 字段名:分账个人接收方姓名
+     * 是否必填:否
+     * 描述:
+     * 可选项,在接收方类型为个人的时可选填,若有值,会检查与 name 是否实名匹配,不匹配会拒绝分账请求
+     * 1、分账接收方类型是PERSONAL_OPENID,是个人姓名的密文(选传,传则校验) 此字段的加密方法详见:敏感信息加密说明
+     * 2、使用微信支付平台证书中的公钥
+     * 3、使用RSAES-OAEP算法进行加密
+     * 4、将请求中HTTP头部的Wechatpay-Serial设置为证书序列号
+     * 
+ */ + @SerializedName("name") + @SpecEncrypt + private String name; + + /** + *
+     * 字段名:与分账方的关系类型
+     * 是否必填:是
+     * 描述:子商户与接收方的关系。 本字段值为枚举:
+     * STORE:门店
+     * STAFF:员工
+     * STORE_OWNER:店主
+     * PARTNER:合作伙伴
+     * HEADQUARTER:总部
+     * BRAND:品牌方
+     * DISTRIBUTOR:分销商
+     * USER:用户
+     * SUPPLIER: 供应商
+     * CUSTOM:自定义
+     * 
+ */ + @SerializedName("relation_type") + private String relationType; + + /** + *
+     * 字段名:自定义的分账关系
+     * 是否必填:是
+     * 描述:子商户与接收方具体的关系,本字段最多10个字。
+     * 当字段relationType的值为CUSTOM时,本字段必填;
+     * 当字段relationType的值不为CUSTOM时,本字段无需填写。
+     * 
+ */ + @SerializedName("custom_relation") + private String customRelation; + /** + *
+     * 字段名:分账描述
+     * 是否必填:是
+     * 描述: 分账的原因描述,分账账单中需要体现
+     * 
+ */ + private String description; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingBillV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingBillV3Result.java new file mode 100644 index 0000000000..cc2ddd0098 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingBillV3Result.java @@ -0,0 +1,62 @@ +package com.github.binarywang.wxpay.bean.profitsharing.result; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 微信V3接口-申请分账账单结果类 + * + * @author 狂龙骄子 + * @since 4.4.0 + * @date 2022-12-09 + */ +@Data +@NoArgsConstructor +public class ProfitSharingBillV3Result implements Serializable { + private static final long serialVersionUID = -704896948531566657L; + + /** + *
+   * 字段名:账单下载地址
+   * 变量名:download_url
+   * 是否必填:是
+   * 类型:string[1,2048]
+   * 描述:
+   *  供下一步请求账单文件的下载地址,该地址30s内有效。
+   *  示例值:https://api.mch.weixin.qq.com/v3/bill/downloadurl?token=xxx
+   * 
+ */ + @SerializedName(value = "download_url") + private String downloadUrl; + + /** + *
+   * 字段名:哈希类型
+   * 变量名:hash_type
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  原始账单(gzip需要解压缩)的摘要值,用于校验文件的完整性。
+   *  示例值:SHA1
+   * 
+ */ + @SerializedName(value = "hash_type") + private String hashType; + + /** + *
+   * 字段名:哈希值
+   * 变量名:hash_value
+   * 是否必填:是
+   * 类型:string[1,1024]
+   * 描述:
+   *  原始账单(gzip需要解压缩)的摘要值,用于校验文件的完整性。
+   *  示例值:79bb0f45fc4c42234a918000b2668d689e2bde04
+   * 
+ */ + @SerializedName(value = "hash_value") + private String hashValue; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingMerchantRatioQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingMerchantRatioQueryResult.java similarity index 90% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingMerchantRatioQueryResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingMerchantRatioQueryResult.java index 5b57124b37..3630014ffb 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingMerchantRatioQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingMerchantRatioQueryResult.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; import com.thoughtworks.xstream.annotations.XStreamAlias; @@ -11,7 +11,7 @@ /** * @author : cofedream - * @date : 2020-12-28 + * created on : 2020-12-28 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingMerchantRatioQueryV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingMerchantRatioQueryV3Result.java new file mode 100644 index 0000000000..28c078e34b --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingMerchantRatioQueryV3Result.java @@ -0,0 +1,27 @@ +package com.github.binarywang.wxpay.bean.profitsharing.result; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * 微信V3接口-查询特约商户设置的允许服务商分账的最大比例结果类 + * + * @author 狂龙骄子 + * @since 4.4.0 + * @date 2022-12-09 + */ +@Data +public class ProfitSharingMerchantRatioQueryV3Result implements Serializable { + private static final long serialVersionUID = -6259241881199571683L; + + /** 子商户号 */ + @SerializedName("sub_mchid") + private String subMchId; + + /** 子商户允许服务商分账的最大比例,单位万分比,比如 2000表示20% */ + @SerializedName("max_ratio") + private Integer maxRatio; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingOrderAmountQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingOrderAmountQueryResult.java similarity index 91% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingOrderAmountQueryResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingOrderAmountQueryResult.java index 64d6c99b3a..4b79064b68 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingOrderAmountQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingOrderAmountQueryResult.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; import com.thoughtworks.xstream.annotations.XStreamAlias; @@ -11,7 +11,7 @@ /** * @author : cofedream - * @date : 2020-12-29 + * created on : 2020-12-29 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnsplitResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingOrderAmountQueryV3Result.java similarity index 80% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnsplitResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingOrderAmountQueryV3Result.java index 2cec40d2be..58e11b1bf0 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnsplitResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingOrderAmountQueryV3Result.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharingV3; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.google.gson.annotations.SerializedName; import lombok.Data; @@ -10,10 +10,10 @@ * 查询剩余待分金额API返回实体 * * @author pg - * @date 2021-6-25 + * created on 2021-6-25 */ @Data -public class ProfitSharingUnsplitResult implements Serializable { +public class ProfitSharingOrderAmountQueryV3Result implements Serializable { private static final long serialVersionUID = -7025255772409082288L; /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingQueryResult.java similarity index 94% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingQueryResult.java index 4eb7a4e23c..437a82e18f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingQueryResult.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; import com.google.gson.FieldNamingPolicy; @@ -121,6 +121,10 @@ public class Receiver { * 分账失败原因 */ private String failReason; + /** + * 分账明细单号 + */ + private String detailId; @Override public String toString() { @@ -132,6 +136,7 @@ public String toString() { ", result='" + result + '\'' + ", finishTime='" + finishTime + '\'' + ", failReason='" + failReason + '\'' + + ", detailId='" + detailId + '\'' + '}'; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReceiverResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReceiverResult.java similarity index 92% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReceiverResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReceiverResult.java index bcd7ac1e03..6047d4246e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReceiverResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReceiverResult.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; import com.thoughtworks.xstream.annotations.XStreamAlias; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReceiverV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReceiverV3Result.java new file mode 100644 index 0000000000..996bb5e789 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReceiverV3Result.java @@ -0,0 +1,102 @@ +package com.github.binarywang.wxpay.bean.profitsharing.result; + +import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.w3c.dom.Document; + +import java.io.Serializable; + +/** + * @author 添加/删除分账接收方结果 + * @version 1.0 + */ +@Data +public class ProfitSharingReceiverV3Result implements Serializable { + private static final long serialVersionUID = 876204163877798066L; + /** + *
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:微信支付分配的子商户号,即分账的出资商户号。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + + /** + *
+   * 字段名:分账接收方类型
+   * 是否必填:是
+   * 描述:
+   * 1、MERCHANT_ID:商户号
+   * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+   * 
+ */ + @SerializedName("type") + private String type; + + /** + *
+   * 字段名:分账接收方帐号
+   * 是否必填:是
+   * 描述:
+   * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+   * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+   * 
+ */ + @SerializedName("account") + private String account; + + /** + *
+   * 字段名:分账个人接收方姓名
+   * 是否必填:否
+   * 描述:
+   * 可选项,在接收方类型为个人的时可选填,若有值,会检查与 name 是否实名匹配,不匹配会拒绝分账请求
+   * 1、分账接收方类型是PERSONAL_OPENID,是个人姓名的密文(选传,传则校验) 此字段的加密方法详见:敏感信息加密说明
+   * 2、使用微信支付平台证书中的公钥
+   * 3、使用RSAES-OAEP算法进行加密
+   * 4、将请求中HTTP头部的Wechatpay-Serial设置为证书序列号
+   * 
+ */ + @SerializedName("name") + @SpecEncrypt + private String name; + + /** + *
+   * 字段名:与分账方的关系类型
+   * 是否必填:是
+   * 描述:子商户与接收方的关系。 本字段值为枚举:
+   * STORE:门店
+   * STAFF:员工
+   * STORE_OWNER:店主
+   * PARTNER:合作伙伴
+   * HEADQUARTER:总部
+   * BRAND:品牌方
+   * DISTRIBUTOR:分销商
+   * USER:用户
+   * SUPPLIER: 供应商
+   * CUSTOM:自定义
+   * 
+ */ + @SerializedName("relation_type") + private String relationType; + + /** + *
+   * 字段名:自定义的分账关系
+   * 是否必填:是
+   * 描述:子商户与接收方具体的关系,本字段最多10个字。
+   * 当字段relationType的值为CUSTOM时,本字段必填;
+   * 当字段relationType的值不为CUSTOM时,本字段无需填写。
+   * 
+ */ + @SerializedName("custom_relation") + private String customRelation; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingResult.java new file mode 100644 index 0000000000..fc07678a68 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingResult.java @@ -0,0 +1,224 @@ +package com.github.binarywang.wxpay.bean.profitsharing.result; + +import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.w3c.dom.Document; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; + +/** + * @author Wang GuangXin 2019/10/22 10:06 + * @version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@XStreamAlias("xml") +public class ProfitSharingResult extends BaseWxPayResult implements Serializable { + private static final long serialVersionUID = 7435709584788869456L; + + /** + * GSON工具 + */ + private static final Gson GSON = new GsonBuilder().create(); + + /** + * 微信订单号. + */ + @XStreamAlias("transaction_id") + private String transactionId; + /** + * 商户分账单号. + */ + @XStreamAlias("out_order_no") + private String outOrderNo; + /** + * 微信分账单号. + */ + @XStreamAlias("order_id") + private String orderId; + + /** + * 分账单状态. + */ + @XStreamAlias("status") + private String status; + + /** + * 分账接收方列表 + */ + @XStreamAlias("receivers") + private String receivers; + + /** + * 分账接收方列表 + */ + private List receiverList; + + /** + * 获取分账接收方列表方法 + * + */ + public List getReceiverList() { + if (receiverList != null) { + return receiverList; + } + + if (StringUtils.isNotEmpty(receivers)) { + this.receiverList = GSON.fromJson(receivers, new TypeToken>() { + }.getType()); + return receiverList; + } + + return Collections.emptyList(); + } + + @Override + protected void loadXml(Document d) { + transactionId = readXmlString(d, "transaction_id"); + outOrderNo = readXmlString(d, "out_order_no"); + orderId = readXmlString(d, "order_id"); + status = readXmlString(d, "status"); + receivers = readXmlString(d, "receivers"); + } + + /** + * 分账接收方列表对象 + */ + @Data + public static class Receiver implements Serializable { + private static final long serialVersionUID = 4240983048700956806L; + + /** + *
+     * 字段名:分账接收方类型
+     * 是否必填:是
+     * 描述:
+     * 枚举值:
+     * MERCHANT_ID:商户号(mch_id或者sub_mch_id)
+     * PERSONAL_OPENID:个人openid(由服务商的APPID转换得到)
+     * PERSONAL_SUB_OPENID:个人sub_openid(由品牌主的APPID转换得到)
+     * 
+ */ + @SerializedName("type") + private String type; + + /** + *
+     * 字段名:分账接收方帐号
+     * 是否必填:是
+     * 描述:
+     * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+     * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+     * 
+ */ + @SerializedName("account") + private String account; + + /** + *
+     * 字段名:分账金额
+     * 是否必填:是
+     * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+     * 
+ */ + @SerializedName("amount") + private Integer amount; + + /** + *
+     * 字段名:分账接收商户号
+     * 是否必填:是
+     * 描述: 仅分账接收方类型为MERCHANT_ID时,填写微信支付分配的商户号
+     * 
+ */ + @SerializedName(("receiver_mchid")) + private String receiverMchid; + + /** + *
+     * 字段名:分账描述
+     * 是否必填:是
+     * 描述: 分账的原因描述,分账账单中需要体现
+     * 
+ */ + @SerializedName("description") + private String description; + + /** + *
+     * 字段名:分账结果
+     * 是否必填:是
+     * 描述:
+     * 1、PENDING:待分账
+     * 2、SUCCESS:分账成功
+     * 3、CLOSED:已关闭
+     * 
+ */ + @SerializedName("result") + private String result; + + /** + *
+     * 字段名:分账失败原因
+     * 是否必填:是
+     * 描述:包含以下枚举值:
+     * 1、ACCOUNT_ABNORMAL : 分账接收账户异常
+     * 2、NO_RELATION : 分账关系已解除
+     * 3、RECEIVER_HIGH_RISK : 高风险接收方
+     * 4、RECEIVER_REAL_NAME_NOT_VERIFIED : 接收方未实名
+     * 5、NO_AUTH : 分账权限已解除
+     * 
+ */ + @SerializedName("fail_reason") + private String failReason; + + /** + *
+     * 字段名:分账创建时间
+     * 是否必填:是
+     * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+     * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+     * HH:mm:ss.sss表示时分秒毫秒,
+     * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * 
+ */ + @SerializedName("create_time") + private String createTime; + /** + *
+     * 字段名:分账完成时间
+     * 是否必填:是
+     * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+     * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+     * HH:mm:ss.sss表示时分秒毫秒,
+     * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * 
+ */ + @SerializedName("finish_time") + private String finishTime; + + /** + *
+     * 字段名:微信分账明细单号
+     * 是否必填:是
+     * 每笔分账业务执行的明细单号,可与资金账单对账使用,
+     * 例如:36011111111111111111111
+     * 
+ */ + @SerializedName("detail_id") + private String detailId; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReturnResult.java similarity index 97% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReturnResult.java index 7af95570c2..c366c3ca55 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReturnResult.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharing; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; import com.thoughtworks.xstream.annotations.XStreamAlias; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReturnV3Result.java similarity index 90% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReturnV3Result.java index 6e08a9a418..de6b633b52 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingReturnV3Result.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharingV3; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.google.gson.annotations.SerializedName; import lombok.Data; @@ -10,12 +10,22 @@ * 请求分账回退API返回实体 * * @author pg - * @date 2021-6-25 + * created on 2021-6-25 */ @Data -public class ProfitSharingReturnResult implements Serializable { +public class ProfitSharingReturnV3Result implements Serializable { private static final long serialVersionUID = -2175582517588397426L; + /** + *
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:分账回退的接收商户,对应原分账出资的分账方商户,填写微信支付分配的商户号
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + /** *
    * 字段名:微信分账单号
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingUnfreezeV3Result.java
similarity index 84%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeResult.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingUnfreezeV3Result.java
index 0e67eee4cd..a30017ade1 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingUnfreezeV3Result.java
@@ -1,21 +1,32 @@
-package com.github.binarywang.wxpay.bean.profitsharingV3;
+package com.github.binarywang.wxpay.bean.profitsharing.result;
 
 import com.google.gson.annotations.SerializedName;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * 微信V3接口
  * 解冻剩余资金API返回实体
  *
  * @author pg
- * @date 2021-6-25
+ * created on  2021-6-25
  */
 @Data
-public class ProfitSharingUnfreezeResult implements Serializable {
+public class ProfitSharingUnfreezeV3Result implements Serializable {
   private static final long serialVersionUID = 5053171678880645337L;
 
+  /**
+   * 
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:微信支付分配的子商户号,即分账的出资商户号
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchid; + /** *
    * 字段名:微信订单号
@@ -46,7 +57,6 @@ public class ProfitSharingUnfreezeResult implements Serializable {
   @SerializedName("order_id")
   private String orderId;
 
-
   /**
    * 
    * 字段名:分账单状态
@@ -59,6 +69,12 @@ public class ProfitSharingUnfreezeResult implements Serializable {
   @SerializedName("state")
   private String state;
 
+  /**
+   * 分账接收方列表
+   */
+  @SerializedName("receivers")
+  private List receivers;
+
   @Data
   public static class Receiver implements Serializable {
     private static final long serialVersionUID = 4240983048700956806L;
@@ -158,5 +174,15 @@ public static class Receiver implements Serializable {
      */
     @SerializedName("finish_time")
     private String finishTime;
+
+    /**
+     * 
+     * 字段名:分账明细单号
+     * 是否必填:是
+     * 描述:微信分账明细单号,每笔分账业务执行的明细单号,可与资金账单对账使用
+     * 
+ */ + @SerializedName("detail_id") + private String detailId; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingV3Result.java similarity index 86% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingV3Result.java index 6e0626f652..1038f4d64d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/result/ProfitSharingV3Result.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean.profitsharingV3; +package com.github.binarywang.wxpay.bean.profitsharing.result; import com.google.gson.annotations.SerializedName; @@ -12,12 +12,22 @@ * 请求分账API返回的分账结果实体 * * @author pg - * @date 2021-6-24 + * created on 2021-6-24 */ @Data -public class ProfitSharingResult implements Serializable { +public class ProfitSharingV3Result implements Serializable { private static final long serialVersionUID = -6201692412535987502L; + /** + *
+   * 字段名:子商户号
+   * 是否必填:是
+   * 描述:微信支付分配的子商户号,即分账的出资商户号。
+   * 
+ */ + @SerializedName("sub_mchid") + private String subMchId; + /** *
    * 字段名:微信订单号
@@ -102,7 +112,7 @@ public static class Receiver implements Serializable {
      * 
*/ @SerializedName("amount") - private Long amount; + private Integer amount; /** *
@@ -168,5 +178,16 @@ public static class Receiver implements Serializable {
      */
     @SerializedName("finish_time")
     private String finishTime;
+
+    /**
+     * 
+     * 字段名:微信分账明细单号
+     * 是否必填:是
+     * 每笔分账业务执行的明细单号,可与资金账单对账使用,
+     * 例如:36011111111111111111111
+     * 
+ */ + @SerializedName("detail_id") + private String detailId; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingRequest.java deleted file mode 100644 index 78122bfbf0..0000000000 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingRequest.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.github.binarywang.wxpay.bean.profitsharingV3; - -import com.google.gson.annotations.SerializedName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.util.List; - -/** - * 微信V3接口 - * 请求分账API请求实体 - * - * @author pg - * @date 2021-6-24 - */ -@Data -@Builder(builderMethodName = "newBuilder") -@NoArgsConstructor -@AllArgsConstructor -public class ProfitSharingRequest implements Serializable { - private static final long serialVersionUID = 3644929701624280800L; - - /** - *
-   * 字段名:应用ID
-   * 是否必填:是
-   * 描述:微信分配的商户appid
-   * 
- */ - @SerializedName("appid") - private String appid; - - /** - *
-   * 字段名:微信订单号
-   * 是否必填:是
-   * 描述:微信支付订单号
-   * 
- */ - @SerializedName("transaction_id") - private String transactionId; - - /** - *
-   * 字段名:商户分账单号
-   * 是否必填:是
-   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
-   * 
- */ - @SerializedName("out_order_no") - private String outOrderNo; - - /** - *
-   * 字段名:分账接收方列表
-   * 是否必填:是
-   * 描述:分账接收方列表,可以设置出资商户作为分账接受方,最多可有50个分账接收方
-   * 
- */ - @SerializedName("receivers") - private List receivers; - - /** - *
-   * 字段名:是否解冻剩余未分资金
-   * 是否必填:是
-   * 描述:
-   * 1、如果为true,该笔订单剩余未分账的金额会解冻回分账方商户;
-   * 2、如果为false,该笔订单剩余未分账的金额不会解冻回分账方商户,可以对该笔订单再次进行分账。
-   * 
- */ - @SerializedName("unfreeze_unsplit") - private boolean unfreezeUnsplit; -} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java index 394bc8969b..5eeeb36604 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java @@ -22,6 +22,7 @@ import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_SIGN_TYPES; @@ -149,6 +150,20 @@ public static Integer yuanToFen(String yuan) { return new BigDecimal(yuan).setScale(2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).intValue(); } + /** + * 元转分 + */ + public static Integer yuan2Fen(BigDecimal yuan) { + return yuan.multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP).intValue(); + } + + /** + * 分转元 + */ + public static BigDecimal fen2Yuan(BigDecimal fen) { + return fen.divide(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + } + /** * 检查请求参数内容,包括必填参数以及特殊约束. */ @@ -322,7 +337,7 @@ public Map getSignParams() { * * @param map 传入的属性Map */ - abstract protected void storeMap(Map map); + protected abstract void storeMap(Map map); /** *
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineTransactionsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineTransactionsRequest.java
index 036cfe9872..721d9a39e5 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineTransactionsRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineTransactionsRequest.java
@@ -240,6 +240,32 @@ public static class SubOrders implements Serializable {
      */
     @SerializedName(value = "out_trade_no")
     private String outTradeNo;
+    /**
+     * 
+     * 字段名:订单优惠标记
+     * 变量名:goods_tag
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  订单优惠标记,使用代金券或立减优惠功能时需要的参数,说明详见代金券或立减优惠
+     *  示例值:WXG
+     * 
+ */ + @SerializedName(value = "goods_tag") + private String goodsTag; + /** + *
+     * 字段名:二级商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  二级商户商户号,由微信支付生成并下发。服务商子商户的商户号,被合单方。直连商户不用传二级商户号。
+     *  示例值:1900000109
+     * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; /** *
      * 字段名:商品描述
@@ -264,6 +290,21 @@ public static class SubOrders implements Serializable {
      */
     @SerializedName(value = "settle_info")
     private SettleInfo settleInfo;
+    /**
+     * 
+     * 字段名:子商户应用ID
+     * 变量名:sub_appid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  子商户申请的应用ID,全局唯一。请求基础下单接口时请注意APPID的应用属性,例如公众号场景下,
+     *  需使用应用属性为公众号的APPID 若sub_openid有传的情况下,
+     *  sub_appid必填,且sub_appid需与sub_openid对应
+     *  示例值:wxd678efh567hg6999
+     * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; } @Data @@ -283,6 +324,21 @@ public static class CombinePayerInfo implements Serializable { */ @SerializedName(value = "openid") private String openid; + /** + *
+     * 字段名:子用户标识
+     * 变量名:sub_openid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  服务商模式下,使用某个子商户的Appid获取的对应用户Openid,
+     *  是用户在该子商户Appid下的唯一标识。openid和sub_openid可以选传其中之一,
+     *  如果选择传sub_openid,则必须传sub_appid。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "sub_openid") + private String subOpenid; } @Data diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxH5EntrustRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxH5EntrustRequest.java index 57f34eb136..ac60b31e33 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxH5EntrustRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxH5EntrustRequest.java @@ -9,7 +9,7 @@ /** * @author chenliang - * @date 2021-08-02 5:12 下午 + * created on 2021-08-02 5:12 下午 * *
  *   微信h5纯签约入参
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequest.java
index 0a9e8c2f24..33dc7ef8e0 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequest.java
@@ -13,7 +13,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:13 下午
+ * created on  2021-08-02 5:13 下午
  * 
  *   小程序纯签约入参
  * 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMpEntrustRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMpEntrustRequest.java index 0344f36d86..32e06109de 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMpEntrustRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMpEntrustRequest.java @@ -10,7 +10,7 @@ /** * @author chenliang - * @date 2021-08-02 5:17 下午 + * created on 2021-08-02 5:17 下午 * *
  *   公众号纯签约入参
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayApplyFundFlowBillV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayApplyFundFlowBillV3Request.java
index 251465e72e..4da2c9b55f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayApplyFundFlowBillV3Request.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayApplyFundFlowBillV3Request.java
@@ -16,6 +16,25 @@
 @Data
 @NoArgsConstructor
 public class WxPayApplyFundFlowBillV3Request implements Serializable {
+  /**
+   * 账户类型
+   */
+  public static class AccountType {
+    /**
+     * BASIC:基本账户
+     */
+    public static final String BASIC = "BASIC";
+    /**
+     * OPERATION:运营账户
+     */
+    public static final String OPERATION = "OPERATION";
+    /**
+     * FEES:手续费账户
+     */
+    public static final String FEES = "FEES";
+  }
+
+
   private static final long serialVersionUID = 1L;
   /**
    * 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadFundFlowRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadFundFlowRequest.java
index efb14fc7c0..5a75b1e484 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadFundFlowRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadFundFlowRequest.java
@@ -1,6 +1,5 @@
 package com.github.binarywang.wxpay.bean.request;
 
-import com.github.binarywang.wxpay.constant.WxPayConstants.AccountType;
 import com.github.binarywang.wxpay.exception.WxPayException;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import lombok.*;
@@ -26,6 +25,27 @@
 @AllArgsConstructor
 @XStreamAlias("xml")
 public class WxPayDownloadFundFlowRequest extends BaseWxPayRequest {
+
+  /**
+   * 账户类型
+   */
+  public static class AccountType {
+    /**
+     * BASIC:基本账户
+     */
+    public static final String BASIC = "Basic";
+    /**
+     * OPERATION:运营账户
+     */
+    public static final String OPERATION = "Operation";
+    /**
+     * FEES:手续费账户
+     */
+    public static final String FEES = "Fees";
+  }
+
+  private static final long serialVersionUID = -8352717499328292952L;
+
   private static final String[] ACCOUNT_TYPES = new String[]{AccountType.BASIC, AccountType.OPERATION, AccountType.FEES};
   private static final String SIGN_TYPE_HMAC_SHA256 = "HMAC-SHA256";
   private static final String TAR_TYPE_GZIP = "GZIP";
@@ -83,8 +103,9 @@ protected void checkConstraints() throws WxPayException {
       throw new WxPayException(String.format("account_type必须为%s其中之一,实际值:%s",
         Arrays.toString(ACCOUNT_TYPES), this.getAccountType()));
     }
-    /**
-     * 目前仅支持HMAC-SHA256
+
+    /*
+      目前仅支持HMAC-SHA256
      */
     this.setSignType(SIGN_TYPE_HMAC_SHA256);
   }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayEntrustRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayEntrustRequest.java
index 764e0e56af..9de5bfe72a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayEntrustRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayEntrustRequest.java
@@ -9,7 +9,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:18 下午
+ * created on  2021-08-02 5:18 下午
  * 
  *   支付中签约入参
  * 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerOrderCloseV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerOrderCloseV3Request.java new file mode 100644 index 0000000000..2696bcf60a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerOrderCloseV3Request.java @@ -0,0 +1,61 @@ +package com.github.binarywang.wxpay.bean.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 服务商关闭订单请求对象类 + * 文档见:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_3.shtml + * + * @author Pursuer + * @version 1.0 + * @date 2023/6/21 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +public class WxPayPartnerOrderCloseV3Request implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+   * 字段名:服务商商户号
+   * 变量名:sp_mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  服务商商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sp_mchid") + private String spMchId; + /** + *
+   * 字段名:特约商户商户号
+   * 变量名:sp_mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  特约商户商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchId; + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string[6,32]
+   * 描述:
+   *  商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
+   *  示例值:1217752501201407033233368018
+   * 
+ */ + private transient String outTradeNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerOrderQueryV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerOrderQueryV3Request.java new file mode 100644 index 0000000000..d22fcf395d --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerOrderQueryV3Request.java @@ -0,0 +1,76 @@ +package com.github.binarywang.wxpay.bean.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 服务商查询订单请求对象类 + * 文档见:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml + * + * @author Pursuer + * @version 1.0 + * @date 2023/6/25 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +public class WxPayPartnerOrderQueryV3Request implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+   * 字段名:服务商商户号
+   * 变量名:sp_mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  服务商商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sp_mchid") + private String spMchId; + /** + *
+   * 字段名:特约商户商户号
+   * 变量名:sp_mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  特约商户商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchId; + /** + *
+   * 字段名:微信支付订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  微信支付系统生成的订单号
+   *  示例值:1217752501201407033233368018
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一。
+   *  特殊规则:最小字符长度为6
+   *  示例值:1217752501201407033233368018
+   * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3Request.java new file mode 100644 index 0000000000..c522c90d88 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3Request.java @@ -0,0 +1,42 @@ +package com.github.binarywang.wxpay.bean.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信支付服务商退款请求 + * 文档见:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_9.shtml + * + * @author Pursuer + * @version 1.0 + * @date 2023/3/2 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +public class WxPayPartnerRefundV3Request extends WxPayRefundV3Request implements Serializable { + private static final long serialVersionUID = -1L; + /** + *
+   * 字段名:退款资金来源
+   * 变量名:funds_account
+   * 是否必填:否
+   * 类型:string[1, 32]
+   * 描述:
+   *  若传递此参数则使用对应的资金账户退款,否则默认使用未结算资金退款(仅对老资金流商户适用)
+   *  示例值:
+   *    UNSETTLED : 未结算资金
+   *    AVAILABLE : 可用余额
+   *    UNAVAILABLE : 不可用余额
+   *    OPERATION : 运营户
+   *    BASIC : 基本账户(含可用余额和不可用余额)
+   * 
+ */ + @SerializedName(value = "funds_account") + private String fundsAccount; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerUnifiedOrderV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerUnifiedOrderV3Request.java new file mode 100644 index 0000000000..b121170c31 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerUnifiedOrderV3Request.java @@ -0,0 +1,610 @@ +package com.github.binarywang.wxpay.bean.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 微信支付服务商下单请求对象 + * + * @author Pursuer + * @version 1.0 + * @date 2023/3/2 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +public class WxPayPartnerUnifiedOrderV3Request implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+   * 字段名:服务商应用ID
+   * 变量名:spAppid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  由微信生成的应用ID,全局唯一。请求统一下单接口时请注意APPID的应用属性,例如公众号场景下,需使用应用属性为公众号的APPID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "sp_appid") + protected String spAppid; + /** + *
+   * 字段名:服务商商户号
+   * 变量名:spMchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  服务商商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sp_mchid") + protected String spMchId; + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:subAppid
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  由微信生成的应用ID,全局唯一。请求统一下单接口时请注意APPID的应用属性,例如公众号场景下,需使用应用属性为公众号的APPID
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "sub_appid") + protected String subAppid; + /** + *
+   * 字段名:子商户商户号
+   * 变量名:subMchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  子商户商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + protected String subMchId; + /** + *
+   * 字段名:商品描述
+   * 变量名:description
+   * 是否必填:是
+   * 类型:string[1,127]
+   * 描述:
+   *  商品描述
+   *  示例值:Image形象店-深圳腾大-QQ公仔
+   * 
+ */ + @SerializedName(value = "description") + protected String description; + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string[6,32]
+   * 描述:
+   *  商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
+   *  示例值:1217752501201407033233368018
+   * 
+ */ + @SerializedName(value = "out_trade_no") + protected String outTradeNo; + /** + *
+   * 字段名:交易结束时间
+   * 变量名:time_expire
+   * 是否必填:是
+   * 类型:string[1,64]
+   * 描述:
+   *  订单失效时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
+   *  示例值:2018-06-08T10:34:56+08:00
+   * 
+ */ + @SerializedName(value = "time_expire") + protected String timeExpire; + /** + *
+   * 字段名:附加数据
+   * 变量名:attach
+   * 是否必填:否
+   * 类型:string[1,128]
+   * 描述:
+   *  附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
+   *  示例值:自定义数据
+   * 
+ */ + @SerializedName(value = "attach") + protected String attach; + /** + *
+   * 字段名:通知地址
+   * 变量名:notify_url
+   * 是否必填:是
+   * 类型:string[1,256]
+   * 描述:
+   *  通知URL必须为直接可访问的URL,不允许携带查询串,要求必须为https地址。
+   *  格式:URL
+   *  示例值:https://www.weixin.qq.com/wxpay/pay.php
+   * 
+ */ + @SerializedName(value = "notify_url") + private String notifyUrl; + /** + *
+   * 字段名:订单优惠标记
+   * 变量名:goods_tag
+   * 是否必填:否
+   * 类型:string[1,256]
+   * 描述:
+   *  订单优惠标记
+   *  示例值:WXG
+   * 
+ */ + @SerializedName(value = "goods_tag") + private String goodsTag; + /** + *
+   * 字段名:电子发票入口开放标识
+   * 变量名:support_fapiao
+   * 是否必填:否
+   * 类型:boolean
+   * 描述:传入true时,支付成功消息和支付详情页将出现开票入口。需要在微信支付商户平台或微信公众平台开通电子发票功能,传此字段才可生效。
+   * 
+ */ + @SerializedName(value = "support_fapiao") + private Boolean supportFapiao; + /** + *
+   * 字段名:订单金额
+   * 变量名:amount
+   * 是否必填:是
+   * 类型:object
+   * 描述:
+   *  订单金额信息
+   * 
+ */ + @SerializedName(value = "amount") + private Amount amount; + /** + *
+   * 字段名:支付者
+   * 变量名:payer
+   * 是否必填:是
+   * 类型:object
+   * 描述:
+   *  支付者信息
+   * 
+ */ + @SerializedName(value = "payer") + private Payer payer; + /** + *
+   * 字段名:优惠功能
+   * 变量名:detail
+   * 是否必填:否
+   * 类型:object
+   * 描述:
+   *  优惠功能
+   * 
+ */ + @SerializedName(value = "detail") + private Discount detail; + /** + *
+   * 字段名:场景信息
+   * 变量名:scene_info
+   * 是否必填:否
+   * 类型:object
+   * 描述:
+   *  支付场景描述
+   * 
+ */ + @SerializedName(value = "scene_info") + private SceneInfo sceneInfo; + /** + *
+   * 字段名:结算信息
+   * 变量名:settle_info
+   * 是否必填:否
+   * 类型:Object
+   * 描述:结算信息
+   * 
+ */ + @SerializedName(value = "settle_info") + private SettleInfo settleInfo; + + @Data + @NoArgsConstructor + public static class Amount implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:总金额
+     * 变量名:total
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  订单总金额,单位为分。
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "total") + private Integer total; + /** + *
+     * 字段名:币类型
+     * 变量名:currency
+     * 是否必填:否
+     * 类型:string[1,16]
+     * 描述:
+     *  CNY:人民币,境内商户号仅支持人民币。
+     *  示例值:CNY
+     * 
+ */ + @SerializedName(value = "currency") + private String currency; + } + + @Data + @NoArgsConstructor + public static class Payer implements Serializable { + private static final long serialVersionUID = -1L; + /** + *
+     * spOpenid 和 subOpenid二选一 参考官网
+     * 字段名:服务商用户标识
+     * 变量名:spOpenid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  用户在服务商appid下的唯一标识。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "sp_openid") + private String spOpenid; + /** + *
+     * 字段名:子商户应用用户标识
+     * 变量名:subOpenid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  用户在子商户appid下的唯一标识。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "sub_openid") + private String subOpenid; + } + + @Data + @NoArgsConstructor + public static class Discount implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:订单原价
+     * 变量名:cost_price
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  1、商户侧一张小票订单可能被分多次支付,订单原价用于记录整张小票的交易金额。
+     *  2、当订单原价与支付金额不相等,则不享受优惠。
+     *  3、该字段主要用于防止同一张小票分多次支付,以享受多次优惠的情况,正常支付订单不必上传此参数。
+     *  示例值:608800
+     * 
+ */ + @SerializedName(value = "cost_price") + private Integer costPrice; + /** + *
+     * 字段名:商品小票ID
+     * 变量名:invoice_id
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  商品小票ID
+     *  示例值:微信123
+     * 
+ */ + @SerializedName(value = "invoice_id") + private String invoiceId; + /** + *
+     * 字段名:单品列表
+     * 变量名:goods_detail
+     * 是否必填:否
+     * 类型:array
+     * 描述:
+     *  单品列表信息
+     *  条目个数限制:【1,6000】
+     * 
+ */ + @SerializedName(value = "goods_detail") + private List goodsDetails; + } + + @Data + @NoArgsConstructor + public static class GoodsDetail implements Serializable { + private static final long serialVersionUID = -1L; + /** + *
+     * 字段名:商户侧商品编码
+     * 变量名:merchant_goods_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  由半角的大小写字母、数字、中划线、下划线中的一种或几种组成。
+     *  示例值:商品编码
+     * 
+ */ + @SerializedName(value = "merchant_goods_id") + private String merchantGoodsId; + /** + *
+     * 字段名:微信侧商品编码
+     * 变量名:wechatpay_goods_id
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  微信支付定义的统一商品编号(没有可不传)
+     *  示例值:1001
+     * 
+ */ + @SerializedName(value = "wechatpay_goods_id") + private String wechatpayGoodsId; + /** + *
+     * 字段名:商品名称
+     * 变量名:goods_name
+     * 是否必填:否
+     * 类型:string[1,256]
+     * 描述:
+     *  商品的实际名称
+     *  示例值:iPhoneX 256G
+     * 
+ */ + @SerializedName(value = "goods_name") + private String goodsName; + /** + *
+     * 字段名:商品数量
+     * 变量名:quantity
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  用户购买的数量
+     *  示例值:1
+     * 
+ */ + @SerializedName(value = "quantity") + private Integer quantity; + /** + *
+     * 字段名:商品单价
+     * 变量名:unit_price
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  商品单价,单位为分
+     *  示例值:828800
+     * 
+ */ + @SerializedName(value = "unit_price") + private Integer unitPrice; + } + + @Data + @NoArgsConstructor + public static class SceneInfo implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:用户终端IP
+     * 变量名:payer_client_ip
+     * 是否必填:是
+     * 类型:string[1,45]
+     * 描述:
+     *  用户的客户端IP,支持IPv4和IPv6两种格式的IP地址。
+     *  示例值:14.23.150.211
+     * 
+ */ + @SerializedName(value = "payer_client_ip") + private String payerClientIp; + /** + *
+     * 字段名:商户端设备号
+     * 变量名:device_id
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  商户端设备号(门店号或收银设备ID)。
+     *  示例值:013467007045764
+     * 
+ */ + @SerializedName(value = "device_id") + private String deviceId; + /** + *
+     * 字段名:商户门店信息
+     * 变量名:store_info
+     * 是否必填:否
+     * 类型:object
+     * 描述:
+     *  商户门店信息
+     * 
+ */ + @SerializedName(value = "store_info") + private StoreInfo storeInfo; + /** + *
+     * 字段名:H5场景信息
+     * 变量名:h5_info
+     * 是否必填:否(H5支付必填)
+     * 类型:object
+     * 描述:
+     *  H5场景信息
+     * 
+ */ + @SerializedName(value = "h5_info") + private H5Info h5Info; + } + + @Data + @NoArgsConstructor + public static class StoreInfo implements Serializable { + private static final long serialVersionUID = -1L; + /** + *
+     * 字段名:门店编号
+     * 变量名:id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  商户侧门店编号
+     *  示例值:0001
+     * 
+ */ + @SerializedName(value = "id") + private String id; + /** + *
+     * 字段名:门店名称
+     * 变量名:name
+     * 是否必填:否
+     * 类型:string[1,256]
+     * 描述:
+     *  商户侧门店名称
+     *  示例值:腾讯大厦分店
+     * 
+ */ + @SerializedName(value = "name") + private String name; + /** + *
+     * 字段名:地区编码
+     * 变量名:area_code
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述: 地区编码, 详细请见省市区编号对照表。
+     * 示例值:440305
+     * 
+ */ + @SerializedName(value = "area_code") + private String areaCode; + /** + *
+     * 字段名:详细地址
+     * 变量名:address
+     * 是否必填:是
+     * 类型:string[1,512]
+     * 描述:
+     *  详细的商户门店地址
+     *  示例值:广东省深圳市南山区科技中一道10000号
+     * 
+ */ + @SerializedName(value = "address") + private String address; + } + + @Data + @NoArgsConstructor + public static class H5Info implements Serializable { + private static final long serialVersionUID = -1L; + /** + *
+     * 字段名:场景类型
+     * 变量名:type
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  场景类型
+     *  示例值:iOS, Android, Wap
+     * 
+ */ + @SerializedName(value = "type") + private String type; + /** + *
+     * 字段名:应用名称
+     * 变量名:app_name
+     * 是否必填:否
+     * 类型:string[1,64]
+     * 描述:
+     *  应用名称
+     *  示例值:王者荣耀
+     * 
+ */ + @SerializedName(value = "app_name") + private String appName; + /** + *
+     * 字段名:网站URL
+     * 变量名:app_url
+     * 是否必填:否
+     * 类型:string[1,128]
+     * 描述:
+     *  网站URL
+     *  示例值:https://pay.qq.com
+     * 
+ */ + @SerializedName(value = "app_url") + private String appUrl; + /** + *
+     * 字段名:iOS平台BundleID
+     * 变量名:bundle_id
+     * 是否必填:否
+     * 类型:string[1,128]
+     * 描述:
+     *  iOS平台BundleID
+     *  示例值:com.tencent.wzryiOS
+     * 
+ */ + @SerializedName(value = "bundle_id") + private String bundleId; + /** + *
+     * 字段名:Android平台PackageName
+     * 变量名:package_name
+     * 是否必填:否
+     * 类型:string[1,128]
+     * 描述:
+     *  Android平台PackageName
+     *  示例值:com.tencent.tmgp.sgame
+     * 
+ */ + @SerializedName(value = "package_name") + private String packageName; + } + + @Data + @NoArgsConstructor + public static class SettleInfo implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:是否指定分账
+     * 变量名:profit_sharing
+     * 是否必填:否
+     * 类型:boolean
+     * 描述:
+     *  是否指定分账
+     *  示例值:false
+     * 
+ */ + @SerializedName(value = "profit_sharing") + private Boolean profitSharing; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryExchangeRateRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryExchangeRateRequest.java index c4b453b9bd..96b8c3a5c9 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryExchangeRateRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryExchangeRateRequest.java @@ -11,7 +11,7 @@ * 查询汇率请求. * * @author Binary Wang - * @date 2020-05-23 + * created on 2020-05-23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryV3Request.java index d29f41a4c0..977ca9ce52 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryV3Request.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryV3Request.java @@ -19,16 +19,26 @@ public class WxPayRefundQueryV3Request implements Serializable { private static final long serialVersionUID = 1L; /** *
-   * 字段名:商户订单号
-   * 变量名:out_trade_no
+   * 字段名:商户退款单号
+   * 变量名:out_refund_no
    * 是否必填:是
-   * 类型:string[1,32]
-   * 描述:
-   *  商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一。
-   *  特殊规则:最小字符长度为6
-   *  示例值:1217752501201407033233368018
+   * 类型:string[1, 64]
+   * 描述:商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
+   * 示例值:1217752501201407033233368018
    * 
*/ - @SerializedName(value = "out_trade_no") - private String outTradeNo; + @SerializedName(value = "out_refund_no") + private String outRefundNo; + /** + *
+   * 字段名:子商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:子商户的商户号,由微信支付生成并下发。
+   * 示例值:1900000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundV3Request.java index da90306de4..e9f1f3b140 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundV3Request.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundV3Request.java @@ -143,7 +143,7 @@ public static class Amount implements Serializable { *
      * 字段名:币类型
      * 变量名:currency
-     * 是否必填:否
+     * 是否必填:是
      * 类型:string[1, 16]
      * 描述:
      *  符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
@@ -237,4 +237,18 @@ public static class GoodsDetail implements Serializable {
     @SerializedName(value = "refund_quantity")
     private Integer refundQuantity;
   }
+
+  /**
+   * 
+   * 字段名:子商户的商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string[1, 32]
+   * 描述:
+   *  子商户商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderV3Request.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderV3Request.java index c0bf417825..98dae388ef 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderV3Request.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderV3Request.java @@ -80,7 +80,7 @@ public class WxPayUnifiedOrderV3Request implements Serializable { /** *
    * 字段名:交易结束时间
-   * 变量名:out_trade_no
+   * 变量名:time_expire
    * 是否必填:是
    * 类型:string[1,64]
    * 描述:
@@ -130,6 +130,17 @@ public class WxPayUnifiedOrderV3Request implements Serializable {
    */
   @SerializedName(value = "goods_tag")
   private String goodsTag;
+  /**
+   * 
+   * 字段名:电子发票入口开放标识
+   * 变量名:support_fapiao
+   * 是否必填:否
+   * 类型:boolean
+   * 描述:传入true时,支付成功消息和支付详情页将出现开票入口。需要在微信支付商户平台或微信公众平台开通电子发票功能,传此字段才可生效。
+   * 
+ */ + @SerializedName(value = "support_fapiao") + private Boolean supportFapiao; /** *
    * 字段名:订单金额
@@ -451,8 +462,7 @@ public static class StoreInfo implements Serializable {
      * 变量名:area_code
      * 是否必填:否
      * 类型:string[1,32]
-     * 描述:
-     *  地区编码,详细请见省市区编号对照表(https://pay.weixin.qq.com/wiki/doc/apiv3/terms_definition/chapter1_1_3.shtml)。
+     * 描述: 地区编码, 详细请见省市区编号对照表。
      * 示例值:440305
      * 
*/ diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPreWithholdRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPreWithholdRequest.java index ed806afecf..1ba01c4af7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPreWithholdRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPreWithholdRequest.java @@ -10,7 +10,7 @@ /** * @author chenliang - * @date 2021-08-02 5:20 下午 + * created on 2021-08-02 5:20 下午 * *
  *   微信预扣款请求参数
@@ -28,7 +28,7 @@ public class WxPreWithholdRequest implements Serializable {
    * 委托代扣协议ID
    */
   @SerializedName(value = "contract_id")
-  private String contractId;
+  private transient String contractId;
 
   /**
    * 直连商户号
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxSignQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxSignQueryRequest.java
index 3ecee3fe81..9f5450407c 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxSignQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxSignQueryRequest.java
@@ -11,7 +11,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:23 下午
+ * created on  2021-08-02 5:23 下午
  * 
  *   微信签约状态查询入参
  * 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxTerminatedContractRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxTerminatedContractRequest.java index 2ebd96e780..90fb498acf 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxTerminatedContractRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxTerminatedContractRequest.java @@ -11,7 +11,7 @@ /** * @author chenliang - * @date 2021-08-02 5:24 下午 + * created on 2021-08-02 5:24 下午 * *
  *   微信api申请解约
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdOrderQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdOrderQueryRequest.java
index a94e0a4c16..66bd45b3c3 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdOrderQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdOrderQueryRequest.java
@@ -9,7 +9,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:25 下午
+ * created on  2021-08-02 5:25 下午
  *
  * 
代扣订单查询参数
*/ diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdRequest.java index d31e3a36ed..6431781928 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxWithholdRequest.java @@ -9,7 +9,7 @@ /** * @author chenliang - * @date 2021-08-02 5:26 下午 + * created on 2021-08-02 5:26 下午 * *
  *   发起微信委托代扣参数
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java
index 9f6f5e2700..0c288b5507 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java
@@ -27,6 +27,7 @@
 import javax.xml.xpath.XPathFactory;
 import java.io.ByteArrayInputStream;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
@@ -59,11 +60,18 @@ public abstract class BaseWxPayResult {
    */
   @XStreamAlias("result_code")
   private String resultCode;
+
   /**
    * 错误代码.
    */
   @XStreamAlias("err_code")
   private String errCode;
+  /**
+   * 错误代码描述.
+   */
+  @XStreamAlias("err_code_des")
+  private String errCodeDes;
+
   /**
    * 错误代码.
    */
@@ -72,8 +80,9 @@ public abstract class BaseWxPayResult {
   /**
    * 错误代码描述.
    */
-  @XStreamAlias("err_code_des")
-  private String errCodeDes;
+  @XStreamAlias("error_message")
+  private String errorMessage;
+
   /**
    * 公众账号ID.
    */
@@ -124,7 +133,7 @@ public abstract class BaseWxPayResult {
    * @return the string
    */
   public static String fenToYuan(Integer fen) {
-    return BigDecimal.valueOf(Double.valueOf(fen) / 100).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
+    return BigDecimal.valueOf(Double.valueOf(fen) / 100).setScale(2, RoundingMode.HALF_UP).toPlainString();
   }
 
   /**
@@ -150,6 +159,7 @@ public static  T fromXML(String xmlString, Class c
     }
     XStream xstream = XStreamInitializer.getInstance();
     xstream.processAnnotations(clz);
+    xstream.setClassLoader(BaseWxPayResult.class.getClassLoader());
     T result = (T) xstream.fromXML(xmlString);
     result.setXmlString(xmlString);
     return result;
@@ -229,6 +239,15 @@ protected static Integer readXmlInteger(Document d, String tagName) {
     return Integer.parseInt(content);
   }
 
+  protected static Long readXmlLong(Document d, String tagName) {
+    String content = readXmlString(d, tagName);
+    if (content == null || content.trim().length() == 0) {
+      return null;
+    }
+
+    return Long.parseLong(content);
+  }
+
   /**
    * Gets logger.
    *
@@ -369,7 +388,7 @@ public void checkResult(WxPayService wxPayService, String signType, boolean chec
           errorMsg.append(",错误详情:").append(getErrCodeDes());
         }
 
-        this.getLogger().error("\n结果业务代码异常,返回结果:{},\n{}", map, errorMsg.toString());
+        this.getLogger().error("\n结果业务代码异常,返回结果:{},\n{}", map, errorMsg);
         throw WxPayException.from(this);
       }
     }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/CombineTransactionsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/CombineTransactionsResult.java
index 2a073f6a4e..34512a4d05 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/CombineTransactionsResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/CombineTransactionsResult.java
@@ -69,6 +69,7 @@ public class CombineTransactionsResult implements Serializable {
   @Data
   @Accessors(chain = true)
   public static class JsapiResult implements Serializable {
+    private static final long serialVersionUID = -3485718620283251481L;
     private String appId;
     private String timeStamp;
     private String nonceStr;
@@ -84,6 +85,7 @@ private String getSignStr() {
   @Data
   @Accessors(chain = true)
   public static class AppResult implements Serializable {
+    private static final long serialVersionUID = -4462225641904225011L;
     private String appid;
     private String partnerid;
     private String prepayid;
@@ -95,6 +97,7 @@ public static class AppResult implements Serializable {
   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();
@@ -114,7 +117,8 @@ public  T getPayInfo(TradeTypeEnum tradeType, String appId, String mchId, Pri
         return (T) appResult;
       case NATIVE:
         return (T) this.codeUrl;
+      default:
+        throw new IllegalStateException("Unexpected value: " + tradeType);
     }
-    return null;
   }
 }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxH5EntrustResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxH5EntrustResult.java
index 3cd8daad71..15ffebaa6f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxH5EntrustResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxH5EntrustResult.java
@@ -10,7 +10,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:37 下午
+ * created on  2021-08-02 5:37 下午
  *
  * 
  *   h5纯签约后结果
@@ -19,6 +19,7 @@
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
+@XStreamAlias("xml")
 public class WxH5EntrustResult extends BaseWxPayResult implements Serializable {
 
   private static final long serialVersionUID = 1L;
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayApplyBillV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayApplyBillV3Result.java
index f5fbf764c3..11915538f5 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayApplyBillV3Result.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayApplyBillV3Result.java
@@ -41,8 +41,8 @@ public class WxPayApplyBillV3Result implements Serializable {
    *  示例值:79bb0f45fc4c42234a918000b2668d689e2bde04
    * 
*/ - @SerializedName(value = "out_refund_no") - private String outRefundNo; + @SerializedName(value = "hash_value") + private String hashValue; /** *
    * 字段名:账单下载地址
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayEntrustResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayEntrustResult.java
index 4dc6f19ae4..5d5d85e05e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayEntrustResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayEntrustResult.java
@@ -19,7 +19,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:38 下午
+ * created on  2021-08-02 5:38 下午
  *
  * 
  *   支付中签约返回结果
@@ -28,6 +28,7 @@
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
+@XStreamAlias("xml")
 public class WxPayEntrustResult extends BaseWxPayResult implements Serializable {
 
   private static final long serialVersionUID = 1L;
@@ -81,7 +82,7 @@ public class WxPayEntrustResult extends BaseWxPayResult implements Serializable
    * 非必传
    */
   @XStreamAlias("request_serial")
-  private Integer requestSerial;
+  private Long requestSerial;
 
   /**
    * 签约协议号
@@ -120,7 +121,7 @@ protected void loadXml(Document d) {
     tradeType = readXmlString(d, "trade_type");
     codeUrl = readXmlString(d, "code_url");
     planId = readXmlInteger(d, "plan_id");
-    requestSerial = readXmlInteger(d, "request_serial");
+    requestSerial = readXmlLong(d, "request_serial");
     contractCode = readXmlString(d, "contract_code");
     contractDisplayAccount = readXmlString(d, "contract_display_account");
     mwebUrl = readXmlString(d, "mweb_url");
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayPartnerOrderQueryV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayPartnerOrderQueryV3Result.java
new file mode 100644
index 0000000000..5e256c5427
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayPartnerOrderQueryV3Result.java
@@ -0,0 +1,572 @@
+package com.github.binarywang.wxpay.bean.result;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 服务商查询订单返回结果对象类
+ * 文档见:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml
+ *
+ * @author Pursuer
+ * @version 1.0
+ * @date 2023/6/25
+ */
+@Data
+@NoArgsConstructor
+public class WxPayPartnerOrderQueryV3Result implements Serializable {
+  private static final long serialVersionUID = 1L;
+  /**
+   * 
+   * 字段名:服务商应用ID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  服务商申请的公众号或移动应用appid。
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "sp_appid") + private String spAppid; + /** + *
+   * 字段名:服务商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  服务商户号,由微信支付生成并下发
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sp_mchid") + private String spMchId; + /** + *
+   * 字段名:子商户应用ID
+   * 变量名:appid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  子商户申请的公众号或移动应用appid。
+   *  示例值:wxd678efh567hg6787
+   * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + /** + *
+   * 字段名:子商户商户号
+   * 变量名:mchid
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  子商户的商户号,由微信支付生成并下发。
+   *  示例值:1230000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchId; + /** + *
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:string[6,32]
+   * 描述:
+   *  商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一,详见【商户订单号】。
+   *  示例值:1217752501201407033233368018
+   * 
+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + /** + *
+   * 字段名:微信支付订单号
+   * 变量名:transaction_id
+   * 是否必填:否
+   * 类型:string[1,32]
+   * 描述:
+   *  微信支付系统生成的订单号。
+   *  示例值:1217752501201407033233368018
+   * 
+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + /** + *
+   * 字段名:交易类型
+   * 变量名:trade_type
+   * 是否必填:否
+   * 类型:string[1,16]
+   * 描述:
+   *  交易类型,枚举值:
+   *  JSAPI:公众号支付
+   *  NATIVE:扫码支付
+   *  APP:APP支付
+   *  MICROPAY:付款码支付
+   *  MWEB:H5支付
+   *  FACEPAY:刷脸支付
+   *  示例值:MICROPAY
+   * 
+ */ + @SerializedName(value = "trade_type") + private String tradeType; + /** + *
+   * 字段名:交易状态
+   * 变量名:trade_state
+   * 是否必填:是
+   * 类型:string[1,32]
+   * 描述:
+   *  交易状态,枚举值:
+   *  SUCCESS:支付成功
+   *  REFUND:转入退款
+   *  NOTPAY:未支付
+   *  CLOSED:已关闭
+   *  REVOKED:已撤销(付款码支付)
+   *  USERPAYING:用户支付中(付款码支付)
+   *  PAYERROR:支付失败(其他原因,如银行返回失败)
+   *  ACCEPT:已接收,等待扣款
+   *  示例值:SUCCESS
+   * 
+ */ + @SerializedName(value = "trade_state") + private String tradeState; + /** + *
+   * 字段名:交易状态描述
+   * 变量名:trade_state_desc
+   * 是否必填:是
+   * 类型:string[1,256]
+   * 描述:
+   *  交易状态描述
+   *  示例值:支付成功
+   * 
+ */ + @SerializedName(value = "trade_state_desc") + private String tradeStateDesc; + /** + *
+   * 字段名:付款银行
+   * 变量名:bank_type
+   * 是否必填:否
+   * 类型:string[1,16]
+   * 描述:
+   *  银行类型,采用字符串类型的银行标识。
+   *  银行标识请参考《银行类型对照表》
+   *  示例值:CMC
+   * 
+ */ + @SerializedName(value = "bank_type") + private String bankType; + /** + *
+   * 字段名:附加数据
+   * 变量名:attach
+   * 是否必填:否
+   * 类型:string[1,128]
+   * 描述:
+   *  附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
+   *  示例值:自定义数据
+   * 
+ */ + @SerializedName(value = "attach") + private String attach; + /** + *
+   * 字段名:支付完成时间
+   * 变量名:success_time
+   * 是否必填:否
+   * 类型:string[1,64]
+   * 描述:
+   *  支付完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
+   *  示例值:2018-06-08T10:34:56+08:00
+   * 
+ */ + @SerializedName(value = "success_time") + private String successTime; + /** + *
+   * 字段名:支付者
+   * 变量名:payer
+   * 是否必填:是
+   * 类型:object
+   * 描述:
+   *  支付者信息
+   * 
+ */ + private Payer payer; + /** + *
+   * 字段名:订单金额
+   * 变量名:amount
+   * 是否必填:否
+   * 类型:object
+   * 描述:
+   *  订单金额信息,当支付成功时返回该字段。
+   * 
+ */ + @SerializedName(value = "amount") + private Amount amount; + /** + *
+   * 字段名:场景信息
+   * 变量名:scene_info
+   * 是否必填:否
+   * 类型:object
+   * 描述:
+   *  支付场景描述
+   * 
+ */ + @SerializedName(value = "scene_info") + private SceneInfo sceneInfo; + /** + *
+   * 字段名:优惠功能
+   * 变量名:promotion_detail
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  优惠功能,享受优惠时返回该字段。
+   * 
+ */ + @SerializedName(value = "promotion_detail") + private List promotionDetails; + + @Data + @NoArgsConstructor + public static class Payer implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:用户服务标识
+     * 变量名:sp_openid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  用户在服务商appid下的唯一标识。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "sp_openid") + private String spOpenid; + + /** + *
+     * 字段名:用户子标识
+     * 变量名:sub_openid
+     * 是否必填:是
+     * 类型:string[1,128]
+     * 描述:
+     *  用户在子商户appid下的唯一标识。如果返回sub_appid,那么sub_openid一定会返回。
+     *  示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+     * 
+ */ + @SerializedName(value = "sub_openid") + private String subOpenid; + + } + + @Data + @NoArgsConstructor + public static class Amount implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:总金额
+     * 变量名:total
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  订单总金额,单位为分。
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "total") + private Integer total; + /** + *
+     * 字段名:用户支付金额
+     * 变量名:payer_total
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  用户支付金额,单位为分。
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "payer_total") + private Integer payerTotal; + /** + *
+     * 字段名:货币类型
+     * 变量名:currency
+     * 是否必填:否
+     * 类型:string[1,16]
+     * 描述:
+     *  CNY:人民币,境内商户号仅支持人民币。
+     *  示例值:CNY
+     * 
+ */ + @SerializedName(value = "currency") + private String currency; + /** + *
+     * 字段名:用户支付币种
+     * 变量名:payer_currency
+     * 是否必填:否
+     * 类型:string[1,16]
+     * 描述:
+     *  用户支付币种
+     *  示例值: CNY
+     * 
+ */ + @SerializedName(value = "payer_currency") + private String payerCurrency; + } + + @Data + @NoArgsConstructor + public static class SceneInfo implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:商户端设备号
+     * 变量名:device_id
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  商户端设备号(发起扣款请求的商户服务器设备号)。
+     *  示例值:013467007045764
+     * 
+ */ + @SerializedName(value = "device_id") + private String deviceId; + } + + @Data + @NoArgsConstructor + public static class PromotionDetail implements Serializable { + private static final long serialVersionUID = -1953741394970145754L; + /** + *
+     * 字段名:券ID
+     * 变量名:coupon_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  券ID
+     *  示例值:109519
+     * 
+ */ + @SerializedName(value = "coupon_id") + private String couponId; + /** + *
+     * 字段名:优惠名称
+     * 变量名:name
+     * 是否必填:否
+     * 类型:string[1,64]
+     * 描述:
+     *  优惠名称
+     *  示例值:单品惠-6
+     * 
+ */ + @SerializedName(value = "name") + private String name; + /** + *
+     * 字段名:优惠范围
+     * 变量名:scope
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  GLOBAL:全场代金券
+     *  SINGLE:单品优惠
+     *  示例值:GLOBAL
+     * 
+ */ + @SerializedName(value = "scope") + private String scope; + /** + *
+     * 字段名:优惠类型
+     * 变量名:type
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  CASH:充值
+     *  NOCASH:预充值
+     *  示例值:CASH
+     * 
+ */ + @SerializedName(value = "type") + private String type; + /** + *
+     * 字段名:优惠券面额
+     * 变量名:amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  优惠券面额
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "amount") + private Integer amount; + /** + *
+     * 字段名:活动ID
+     * 变量名:stock_id
+     * 是否必填:否
+     * 类型:string[1,32]
+     * 描述:
+     *  活动ID
+     *  示例值:931386
+     * 
+ */ + @SerializedName(value = "stock_id") + private String stockId; + /** + *
+     * 字段名:微信出资
+     * 变量名:wechatpay_contribute
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  微信出资,单位为分
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "wechatpay_contribute") + private Integer wechatpayContribute; + /** + *
+     * 字段名:商户出资
+     * 变量名:merchant_contribute
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  商户出资,单位为分
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "merchant_contribute") + private Integer merchantContribute; + /** + *
+     * 字段名:其他出资
+     * 变量名:other_contribute
+     * 是否必填:否
+     * 类型:int
+     * 描述:
+     *  其他出资,单位为分
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "other_contribute") + private Integer otherContribute; + /** + *
+     * 字段名:优惠币种
+     * 变量名:currency
+     * 是否必填:否
+     * 类型:string[1,16]
+     * 描述:
+     *  CNY:人民币,境内商户号仅支持人民币。
+     *  示例值:CNY
+     * 
+ */ + @SerializedName(value = "currency") + private String currency; + /** + *
+     * 字段名:单品列表
+     * 变量名:goods_detail
+     * 是否必填:否
+     * 类型:array
+     * 描述:
+     *  单品列表信息
+     * 
+ */ + @SerializedName(value = "goods_detail") + private List goodsDetails; + } + + @Data + @NoArgsConstructor + public static class GoodsDetail implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+     * 字段名:商品编码
+     * 变量名:goods_id
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  商品编码
+     *  示例值:M1006
+     * 
+ */ + @SerializedName(value = "goods_id") + private String goodsId; + /** + *
+     * 字段名:商品数量
+     * 变量名:quantity
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  用户购买的数量
+     *  示例值:1
+     * 
+ */ + @SerializedName(value = "quantity") + private Integer quantity; + /** + *
+     * 字段名:商品单价
+     * 变量名:unit_price
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  商品单价,单位为分
+     *  示例值:100
+     * 
+ */ + @SerializedName(value = "unit_price") + private Integer unitPrice; + /** + *
+     * 字段名:商品优惠金额
+     * 变量名:discount_amount
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  商品优惠金额
+     *  示例值:0
+     * 
+ */ + @SerializedName(value = "discount_amount") + private Integer discountAmount; + /** + *
+     * 字段名:商品备注
+     * 变量名:goods_remark
+     * 是否必填:否
+     * 类型:string[1,128]
+     * 描述:
+     *  商品备注信息
+     *  示例值:商品备注信息
+     * 
+ */ + @SerializedName(value = "goods_remark") + private String goodsRemark; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayQueryExchangeRateResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayQueryExchangeRateResult.java index c6f9409933..45c23fd2d7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayQueryExchangeRateResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayQueryExchangeRateResult.java @@ -12,7 +12,7 @@ * 汇率查询响应. * * @author Binary Wang - * @date 2020-05-23 + * created on 2020-05-23 */ @Data @EqualsAndHashCode(callSuper = true) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundPromotionDetail.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundPromotionDetail.java index 414560b936..7fa4b630a7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundPromotionDetail.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundPromotionDetail.java @@ -10,7 +10,7 @@ * 营销详情 . * * @author Binary Wang - * @date 2020-06-07 + * created on 2020-06-07 */ @Data public class WxPayRefundPromotionDetail implements Serializable { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java index 6a2d3b46d6..372aeafd6b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java @@ -79,6 +79,45 @@ public class WxPayRefundQueryResult extends BaseWxPayResult implements Serializa @XStreamAlias("total_fee") private Integer totalFee; + /** + *
+   * 字段名:退款总金额.
+   * 变量名:refund_fee
+   * 是否必填:是
+   * 类型:Int
+   * 示例值:100
+   * 描述:各退款单的退款金额累加,单位为分,只能为整数,
+   * 
+ */ + @XStreamAlias("refund_fee") + private Integer refundFee; + + /** + *
+   * 字段名:代金券退款总金额.
+   * 变量名:coupon_refund_fee
+   * 是否必填:是
+   * 类型:Int
+   * 示例值:100
+   * 描述:各退款单的代金券退款金额累加,单位为分,只能为整数,
+   * 
+ */ + @XStreamAlias("coupon_refund_fee") + private Integer couponRefundFee; + + /** + *
+   * 字段名:用户退款金额.
+   * 变量名:cash_refund_fee
+   * 是否必填:是
+   * 类型:Int
+   * 示例值:100
+   * 描述:退款给用户的金额,不包含所有优惠券金额,单位为分,只能为整数,
+   * 
+ */ + @XStreamAlias("cash_refund_fee") + private Integer cashRefundFee; + /** *
    * 字段名:应结订单金额.
@@ -228,7 +267,8 @@ protected void loadXml(Document d) {
   @Builder(builderMethodName = "newBuilder")
   @NoArgsConstructor
   @AllArgsConstructor
-  public static class RefundRecord {
+  public static class RefundRecord  implements Serializable {
+    private static final long serialVersionUID=1L;
     /**
      * 
      * 字段名:商户退款单号.
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryV3Result.java
index c203d75699..2ebd035a74 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryV3Result.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryV3Result.java
@@ -17,6 +17,7 @@
 @Data
 @NoArgsConstructor
 public class WxPayRefundQueryV3Result implements Serializable {
+  private static final long serialVersionUID = 532057810377362827L;
   /**
    * 
    * 字段名:微信支付退款号
@@ -311,6 +312,12 @@ public static class Amount implements Serializable {
      */
     @SerializedName(value = "currency")
     private String currency;
+
+    /**
+     * 手续费退款金额
+     */
+    @SerializedName(value = "refund_fee")
+    private Integer refundFee;
   }
 
   @Data
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundV3Result.java
index 8930bac83c..eed6ff254e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundV3Result.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundV3Result.java
@@ -313,6 +313,12 @@ public static class Amount implements Serializable {
      */
     @SerializedName(value = "currency")
     private String currency;
+
+    /**
+     * 手续费退款金额
+     */
+    @SerializedName(value = "refund_fee")
+    private Integer refundFee;
   }
 
   @Data
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 492c6c9251..808b9d7ddf 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
@@ -3,6 +3,7 @@
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import me.chanjar.weixin.common.util.json.WxGsonBuilder;
 import org.w3c.dom.Document;
@@ -11,15 +12,17 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:40 下午
+ * created on  2021-08-02 5:40 下午
  *
  * 
  *   微信签约查询返回结果
  * 
*/ @Data +@EqualsAndHashCode(callSuper = true) @AllArgsConstructor @NoArgsConstructor +@XStreamAlias("xml") public class WxSignQueryResult extends BaseWxPayResult implements Serializable { private static final long serialVersionUID = 1L; @@ -27,7 +30,7 @@ public class WxSignQueryResult extends BaseWxPayResult implements Serializable { /** * 委托代扣协议ID */ - @XStreamAlias("contractId") + @XStreamAlias("contract_id") private String contractId; /** @@ -40,7 +43,7 @@ public class WxSignQueryResult extends BaseWxPayResult implements Serializable { * 请求序列号 */ @XStreamAlias("request_serial") - private Integer requestSerial; + private Long requestSerial; /** * 签约协议号 @@ -104,7 +107,7 @@ public class WxSignQueryResult extends BaseWxPayResult implements Serializable { protected void loadXml(Document d) { contractId = readXmlString(d, "contract_id"); planId = readXmlString(d, "plan_id"); - requestSerial = readXmlInteger(d, "request_serial"); + requestSerial = readXmlLong(d, "request_serial"); contractCode = readXmlString(d, "contract_code"); contractDisplayAccount = readXmlString(d, "contract_display_account"); contractState = readXmlInteger(d, "contract_state"); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignStatusNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignStatusNotifyResult.java index f55b576e36..c02cb36da0 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignStatusNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignStatusNotifyResult.java @@ -14,7 +14,7 @@ /** * @author chenliang - * @date 2021-08-02 4:59 下午 + * created on 2021-08-02 4:59 下午 *
  *   微信签约/解约 回调结果
  * 
@@ -81,7 +81,7 @@ public class WxSignStatusNotifyResult extends BaseWxPayResult { * 请求序列号 */ @XStreamAlias("request_serial") - private Integer requestSerial; + private Long requestSerial; @Override public void checkResult(WxPayService wxPayService, String signType, boolean checkSuccess) throws WxPayException { @@ -117,7 +117,7 @@ protected void loadXml(Document d) { contractId = readXmlString(d, "contract_id"); contractExpiredTime = readXmlString(d, "contract_expired_time"); contractTerminationMode = readXmlInteger(d, "contract_termination_mode"); - requestSerial = readXmlInteger(d, "request_serial"); + requestSerial = readXmlLong(d, "request_serial"); } @Override diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxTerminationContractResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxTerminationContractResult.java index 77067d0213..a02373f6d6 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxTerminationContractResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxTerminationContractResult.java @@ -11,7 +11,7 @@ /** * @author chenliang - * @date 2021-08-02 5:41 下午 + * created on 2021-08-02 5:41 下午 * *
  *   主动解约返回值
@@ -20,6 +20,7 @@
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
+@XStreamAlias("xml")
 public class WxTerminationContractResult extends BaseWxPayResult implements Serializable {
 
   private static final long serialVersionUID = 1L;
@@ -27,7 +28,7 @@ public class WxTerminationContractResult extends BaseWxPayResult implements Seri
   /**
    * 委托代扣协议ID
    */
-  @XStreamAlias("contractId")
+  @XStreamAlias("contract_id")
   private String contractId;
 
   /**
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java
index 87cbfd1b71..288e8b933f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java
@@ -21,7 +21,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:09 下午
+ * created on  2021-08-02 5:09 下午
  *
  * 
  *   微信代扣扣款回调结果
@@ -62,6 +62,13 @@ public class WxWithholdNotifyResult extends BaseWxPayResult {
   @XStreamAlias("is_subscribe")
   private String isSubscribe;
 
+  /**
+   * 是否关注子商户关联的公众号
+   * 非必传
+   */
+  @XStreamAlias("sub_is_subscribe")
+  private String subIsSubscribe;
+
   /**
    * 付款银行
    */
@@ -191,6 +198,7 @@ protected void loadXml(Document d) {
     deviceInfo = readXmlString(d, "device_info");
     openId = readXmlString(d, "openid");
     isSubscribe = readXmlString(d, "is_subscribe");
+    subIsSubscribe = readXmlString(d, "sub_is_subscribe");
     subOpenId = readXmlString(d, "sub_openid");
     bankType = readXmlString(d, "bank_type");
     totalFee = readXmlInteger(d, "total_fee");
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdOrderQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdOrderQueryResult.java
index 752bf7e64a..f625462e16 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdOrderQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdOrderQueryResult.java
@@ -13,7 +13,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:42 下午
+ * created on  2021-08-02 5:42 下午
  *
  * 
  *   代扣订单查询结果
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdResult.java
index a2c4dcf055..21a3a05ad8 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdResult.java
@@ -11,7 +11,7 @@
 
 /**
  * @author chenliang
- * @date 2021-08-02 5:39 下午
+ * created on  2021-08-02 5:39 下午
  *
  * 
  *   委托扣款返回值
@@ -20,6 +20,7 @@
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
+@XStreamAlias("xml")
 public class WxWithholdResult extends BaseWxPayResult implements Serializable {
 
   private static final long serialVersionUID = 1L;
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/enums/TradeTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/enums/TradeTypeEnum.java
index bdc5762b5a..80edf2d99b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/enums/TradeTypeEnum.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/enums/TradeTypeEnum.java
@@ -5,6 +5,8 @@
 
 /**
  * 支付方式
+ *
+ * @author thinsstar
  */
 @Getter
 @AllArgsConstructor
@@ -12,19 +14,19 @@ public enum TradeTypeEnum {
   /**
    * APP
    */
-  APP("/v3/pay/transactions/app", "/v3/combine-transactions/app"),
+  APP("/v3/pay/transactions/app", "/v3/combine-transactions/app", "/v3/pay/partner/transactions/app"),
   /**
    * JSAPI 或 小程序
    */
-  JSAPI("/v3/pay/transactions/jsapi", "/v3/combine-transactions/jsapi"),
+  JSAPI("/v3/pay/transactions/jsapi", "/v3/combine-transactions/jsapi", "/v3/pay/partner/transactions/jsapi"),
   /**
    * NATIVE
    */
-  NATIVE("/v3/pay/transactions/native", "/v3/combine-transactions/native"),
+  NATIVE("/v3/pay/transactions/native", "/v3/combine-transactions/native", "/v3/pay/partner/transactions/native"),
   /**
    * H5
    */
-  H5("/v3/pay/transactions/h5", "/v3/combine-transactions/h5");
+  H5("/v3/pay/transactions/h5", "/v3/combine-transactions/h5", "/v3/pay/partner/transactions/h5");
 
   /**
    * 单独下单url
@@ -35,4 +37,9 @@ public enum TradeTypeEnum {
    * 合并下单url
    */
   private final String combineUrl;
+
+  /**
+   * 服务商下单
+   */
+  private final String basePartnerUrl;
 }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/QueryTransferBatchesRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/QueryTransferBatchesRequest.java
new file mode 100644
index 0000000000..bfc9857599
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/QueryTransferBatchesRequest.java
@@ -0,0 +1,50 @@
+package com.github.binarywang.wxpay.bean.transfer;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 查询微信批次单号查询批次单API参数
+ *
+ * @author zhongjun
+ * created on  2022/6/17
+ **/
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
+public class QueryTransferBatchesRequest implements Serializable {
+  private static final long serialVersionUID = -2175582517588397426L;
+
+  /**
+   * 微信批次单号
+   */
+  private String batchId;
+
+  /**
+   * 是否查询转账明细单
+   */
+  private Boolean needQueryDetail;
+
+  private Integer offset;
+
+  private Integer limit;
+
+  /**
+   * 明细状态
+   * 查询指定状态的转账明细单,当need_query_detail为true时,该字段必填
+   * ALL:全部。需要同时查询转账成功和转账失败的明细单
+   * SUCCESS:转账成功。只查询转账成功的明细单
+   * FAIL:转账失败。只查询转账失败的明细单
+   */
+  private String detailStatus;
+
+  /**
+   * 商家批次单号
+   */
+  private String outBatchNo;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/QueryTransferBatchesResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/QueryTransferBatchesResult.java
new file mode 100644
index 0000000000..2dddba7c87
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/QueryTransferBatchesResult.java
@@ -0,0 +1,101 @@
+package com.github.binarywang.wxpay.bean.transfer;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 查询微信批次单号查询批次单API响应
+ *
+ * @author zhongjun
+ * created on  2022/6/17
+ **/
+@Data
+@NoArgsConstructor
+public class QueryTransferBatchesResult implements Serializable {
+  private static final long serialVersionUID = -2175582517588397426L;
+
+  @SerializedName("offset")
+  private Integer offset;
+
+  @SerializedName("limit")
+  private Integer limit;
+
+  @SerializedName("transfer_batch")
+  private TransferBatch transferBatch;
+
+  @SerializedName("transfer_detail_list")
+  private List transferDetailList;
+
+  @NoArgsConstructor
+  @Data
+  public static class TransferBatch {
+    @SerializedName("mchid")
+    private String mchid;
+
+    @SerializedName("out_batch_no")
+    private String outBatchNo;
+
+    @SerializedName("batch_id")
+    private String batchId;
+
+    @SerializedName("appid")
+    private String appid;
+
+    @SerializedName("batch_status")
+    private String batchStatus;
+
+    @SerializedName("batch_type")
+    private String batchType;
+
+    @SerializedName("batch_name")
+    private String batchName;
+
+    @SerializedName("batch_remark")
+    private String batchRemark;
+
+    @SerializedName("close_reason")
+    private String closeReason;
+
+    @SerializedName("total_amount")
+    private Integer totalAmount;
+
+    @SerializedName("total_num")
+    private Integer totalNum;
+
+    @SerializedName("create_time")
+    private String createTime;
+
+    @SerializedName("update_time")
+    private String updateTime;
+
+    @SerializedName("success_amount")
+    private Integer successAmount;
+
+    @SerializedName("success_num")
+    private Integer successNum;
+
+    @SerializedName("fail_amount")
+    private Integer failAmount;
+
+    @SerializedName("fail_num")
+    private Integer failNum;
+  }
+
+  @NoArgsConstructor
+  @Data
+  public static class TransferDetail {
+
+    @SerializedName("detail_id")
+    private String detailId;
+
+    @SerializedName("out_detail_no")
+    private String outDetailNo;
+
+    @SerializedName("detail_status")
+    private String detailStatus;
+  }
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchDetailResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchDetailResult.java
new file mode 100644
index 0000000000..8b76e445ed
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchDetailResult.java
@@ -0,0 +1,60 @@
+package com.github.binarywang.wxpay.bean.transfer;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 微信明细单号查询明细单API
+ *
+ * @author zhongjun
+ */
+@NoArgsConstructor
+@Data
+public class TransferBatchDetailResult implements Serializable {
+  private static final long serialVersionUID = -2175582517588397426L;
+
+  @SerializedName("mchid")
+  private String mchid;
+
+  @SerializedName("out_batch_no")
+  private String outBatchNo;
+
+  @SerializedName("batch_id")
+  private String batchId;
+
+  @SerializedName("appid")
+  private String appid;
+
+  @SerializedName("out_detail_no")
+  private String outDetailNo;
+
+  @SerializedName("detail_id")
+  private String detailId;
+
+  @SerializedName("detail_status")
+  private String detailStatus;
+
+  @SerializedName("transfer_amount")
+  private Integer transferAmount;
+
+  @SerializedName("transfer_remark")
+  private String transferRemark;
+
+  @SerializedName("fail_reason")
+  private String failReason;
+
+  @SerializedName("openid")
+  private String openid;
+
+  @SerializedName("user_name")
+  private String userName;
+
+  @SerializedName("initiate_time")
+  private String initiateTime;
+
+  @SerializedName("update_time")
+  private String updateTime;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesRequest.java
new file mode 100644
index 0000000000..6e6b3846d6
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesRequest.java
@@ -0,0 +1,112 @@
+package com.github.binarywang.wxpay.bean.transfer;
+
+import com.github.binarywang.wxpay.v3.SpecEncrypt;
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 发起商家转账API参数
+ *
+ * @author zhongjun
+ * created on  2022/6/17
+ **/
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
+public class TransferBatchesRequest implements Serializable {
+  private static final long serialVersionUID = -2175582517588397426L;
+
+  /**
+   * 直连商户的appid
+   */
+  @SerializedName("appid")
+  private String appid;
+
+  /**
+   * 商家批次单号
+   */
+  @SerializedName("out_batch_no")
+  private String outBatchNo;
+
+  /**
+   * 批次名称
+   */
+  @SerializedName("batch_name")
+  private String batchName;
+
+  /**
+   * 批次备注
+   */
+  @SerializedName("batch_remark")
+  private String batchRemark;
+
+  /**
+   * 转账总金额
+   */
+  @SerializedName("total_amount")
+  private Integer totalAmount;
+
+  /**
+   * 转账总笔数
+   */
+  @SerializedName("total_num")
+  private Integer totalNum;
+
+  /**
+   * 转账明细列表
+   */
+  @SpecEncrypt
+  @SerializedName("transfer_detail_list")
+  private List transferDetailList;
+
+  /**
+   * 转账场景ID
+   */
+  @SerializedName("transfer_scene_id")
+  private String transferSceneId;
+
+  @Data
+  @Builder(builderMethodName = "newBuilder")
+  @AllArgsConstructor
+  @NoArgsConstructor
+  public static class TransferDetail {
+
+    /**
+     * 商家明细单号
+     */
+    @SerializedName("out_detail_no")
+    private String outDetailNo;
+
+    /**
+     * 转账金额
+     */
+    @SerializedName("transfer_amount")
+    private Integer transferAmount;
+
+    /**
+     * 转账备注
+     */
+    @SerializedName("transfer_remark")
+    private String transferRemark;
+
+    /**
+     * 用户在直连商户应用下的用户标示
+     */
+    @SerializedName("openid")
+    private String openid;
+
+    /**
+     * 收款用户姓名
+     */
+    @SpecEncrypt
+    @SerializedName("user_name")
+    private String userName;
+  }
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesResult.java
new file mode 100644
index 0000000000..c863b75e6a
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesResult.java
@@ -0,0 +1,43 @@
+package com.github.binarywang.wxpay.bean.transfer;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 商家转账结果
+ *
+ * @author zhongjun
+ * created on  2022/6/17
+ **/
+@Data
+@NoArgsConstructor
+public class TransferBatchesResult implements Serializable {
+  private static final long serialVersionUID = -2175582517588397426L;
+
+  /**
+   * 商家批次单号
+   */
+  @SerializedName("out_batch_no")
+  private String outBatchNo;
+
+  /**
+   * 微信批次单号
+   */
+  @SerializedName("batch_id")
+  private String batchId;
+
+  /**
+   * 批次创建时间
+   */
+  @SerializedName("create_time")
+  private String createTime;
+
+  /**
+   * 批次状态
+   */
+  @SerializedName("batch_status")
+  private String batchStatus;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/HttpClientBuilderCustomizer.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/HttpClientBuilderCustomizer.java
new file mode 100644
index 0000000000..42f0003d00
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/HttpClientBuilderCustomizer.java
@@ -0,0 +1,11 @@
+package com.github.binarywang.wxpay.config;
+
+import org.apache.http.impl.client.HttpClientBuilder;
+
+/**
+ * @author dagewang
+ */
+@FunctionalInterface
+public interface HttpClientBuilderCustomizer {
+  void customize(HttpClientBuilder var1);
+}
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 a9092e2fda..daf8592f60 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
@@ -1,12 +1,15 @@
 package com.github.binarywang.wxpay.config;
 
 import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.util.HttpProxyUtils;
 import com.github.binarywang.wxpay.util.ResourcesUtils;
 import com.github.binarywang.wxpay.v3.WxPayV3HttpClientBuilder;
 import com.github.binarywang.wxpay.v3.auth.*;
 import com.github.binarywang.wxpay.v3.util.PemUtils;
-import lombok.*;
-import org.apache.commons.io.IOUtils;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.SneakyThrows;
+import lombok.ToString;
 import org.apache.commons.lang3.RegExUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -16,15 +19,17 @@
 import java.io.*;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.security.KeyStore;
 import java.security.PrivateKey;
 import java.security.cert.X509Certificate;
-import java.util.Collections;
+import java.util.Base64;
+import java.util.Optional;
 
 /**
  * 微信支付配置
  *
- * @author Binary Wang (https://github.com/binarywang)
+ * @author Binary Wang (...)
  */
 @Data
 @ToString(exclude = "verifier")
@@ -94,20 +99,43 @@ public class WxPayConfig {
    */
   private String signType;
   private SSLContext sslContext;
+  /**
+   * p12证书base64编码
+   */
+  private String keyString;
   /**
    * p12证书文件的绝对路径或者以classpath:开头的类路径.
    */
   private String keyPath;
 
+  /**
+   * apiclient_key.pem证书base64编码
+   */
+  private String privateKeyString;
   /**
    * apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径.
    */
   private String privateKeyPath;
+
+  /**
+   * apiclient_cert.pem证书base64编码
+   */
+  private String privateCertString;
   /**
    * apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径.
    */
   private String privateCertPath;
 
+  /**
+   * apiclient_key.pem证书文件内容的字节数组.
+   */
+  private byte[] privateKeyContent;
+
+  /**
+   * apiclient_cert.pem证书文件内容的字节数组.
+   */
+  private byte[] privateCertContent;
+
   /**
    * apiV3 秘钥值.
    */
@@ -135,6 +163,11 @@ public class WxPayConfig {
 
 
   private CloseableHttpClient apiV3HttpClient;
+  /**
+   * 支持扩展httpClientBuilder
+   */
+  private HttpClientBuilderCustomizer httpClientBuilderCustomizer;
+  private HttpClientBuilderCustomizer apiV3HttpClientBuilderCustomizer;
   /**
    * 私钥信息
    */
@@ -168,7 +201,7 @@ public class WxPayConfig {
 
   /**
    * v3接口下证书检验对象,通过改对象可以获取到X509Certificate,进一步对敏感信息加密
-   * 文档见 https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/min-gan-xin-xi-jia-mi
+   * 文档
    */
   private Verifier verifier;
 
@@ -205,17 +238,8 @@ public SSLContext initSSLContext() throws WxPayException {
       throw new WxPayException("请确保商户号mchId已设置");
     }
 
-    InputStream inputStream;
-    if (this.keyContent != null) {
-      inputStream = new ByteArrayInputStream(this.keyContent);
-    } else {
-      if (StringUtils.isBlank(this.getKeyPath())) {
-        throw new WxPayException("请确保证书文件地址keyPath已配置");
-      }
-      inputStream = this.loadConfigInputStream(this.getKeyPath());
-    }
-
-    try {
+    try (InputStream inputStream = this.loadConfigInputStream(this.keyString, this.getKeyPath(),
+      this.keyContent, "p12证书");) {
       KeyStore keystore = KeyStore.getInstance("PKCS12");
       char[] partnerId2charArray = this.getMchId().toCharArray();
       keystore.load(inputStream, partnerId2charArray);
@@ -223,9 +247,8 @@ public SSLContext initSSLContext() throws WxPayException {
       return this.sslContext;
     } catch (Exception e) {
       throw new WxPayException("证书文件有问题,请核实!", e);
-    } finally {
-      IOUtils.closeQuietly(inputStream);
     }
+
   }
 
   /**
@@ -236,81 +259,119 @@ public SSLContext initSSLContext() throws WxPayException {
    * @author doger.wang
    **/
   public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
-    val privateKeyPath = this.getPrivateKeyPath();
-    val privateCertPath = this.getPrivateCertPath();
-    val serialNo = this.getCertSerialNo();
-    val apiV3Key = this.getApiV3Key();
-    if (StringUtils.isBlank(privateKeyPath)) {
-      throw new WxPayException("请确保privateKeyPath已设置");
-    }
-    if (StringUtils.isBlank(privateCertPath)) {
-      throw new WxPayException("请确保privateCertPath已设置");
-    }
-//    if (StringUtils.isBlank(certSerialNo)) {
-//      throw new WxPayException("请确保certSerialNo证书序列号已设置");
-//    }
-    if (StringUtils.isBlank(apiV3Key)) {
+    if (StringUtils.isBlank(this.getApiV3Key())) {
       throw new WxPayException("请确保apiV3Key值已设置");
     }
 
-    InputStream keyInputStream = this.loadConfigInputStream(privateKeyPath);
-    InputStream certInputStream = this.loadConfigInputStream(privateCertPath);
+    InputStream keyInputStream = this.loadConfigInputStream(this.getPrivateKeyString(), this.getPrivateKeyPath(),
+      this.privateKeyContent, "privateKeyPath");
     try {
       PrivateKey merchantPrivateKey = PemUtils.loadPrivateKey(keyInputStream);
-      X509Certificate certificate = PemUtils.loadCertificate(certInputStream);
-      if(StringUtils.isBlank(serialNo)){
+      if (StringUtils.isBlank(this.getCertSerialNo())) {
+        InputStream certInputStream = this.loadConfigInputStream(this.getPrivateCertString(), this.getPrivateCertPath(),
+          this.privateCertContent, "privateCertPath");
+        X509Certificate certificate = PemUtils.loadCertificate(certInputStream);
         this.certSerialNo = certificate.getSerialNumber().toString(16).toUpperCase();
       }
+      //构造Http Proxy正向代理
+      WxPayHttpProxy wxPayHttpProxy = getWxPayHttpProxy();
 
-      AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(
+      AutoUpdateCertificatesVerifier certificatesVerifier = new AutoUpdateCertificatesVerifier(
         new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
-        apiV3Key.getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime());
+        this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(), wxPayHttpProxy);
 
-      CloseableHttpClient httpClient = WxPayV3HttpClientBuilder.create()
+      WxPayV3HttpClientBuilder wxPayV3HttpClientBuilder = WxPayV3HttpClientBuilder.create()
         .withMerchant(mchId, certSerialNo, merchantPrivateKey)
-        .withWechatpay(Collections.singletonList(certificate))
-        .withValidator(new WxPayValidator(verifier))
-        .build();
+        .withValidator(new WxPayValidator(certificatesVerifier));
+      //初始化V3接口正向代理设置
+      HttpProxyUtils.initHttpProxy(wxPayV3HttpClientBuilder, wxPayHttpProxy);
+
+      // 提供自定义wxPayV3HttpClientBuilder的能力
+      Optional.ofNullable(apiV3HttpClientBuilderCustomizer).ifPresent(e -> {
+        e.customize(wxPayV3HttpClientBuilder);
+      });
+      CloseableHttpClient httpClient = wxPayV3HttpClientBuilder.build();
+
       this.apiV3HttpClient = httpClient;
-      this.verifier=verifier;
+      this.verifier = certificatesVerifier;
       this.privateKey = merchantPrivateKey;
 
       return httpClient;
+    } catch (WxPayException e) {
+      throw e;
     } catch (Exception e) {
       throw new WxPayException("v3请求构造异常!", e);
     }
   }
 
+  /**
+   * 初始化一个WxPayHttpProxy对象
+   *
+   * @return 返回封装的WxPayHttpProxy对象。如未指定代理主机和端口,则默认返回null
+   */
+  private WxPayHttpProxy getWxPayHttpProxy() {
+    if (StringUtils.isNotBlank(this.getHttpProxyHost()) && this.getHttpProxyPort() > 0) {
+      return new WxPayHttpProxy(getHttpProxyHost(), getHttpProxyPort(), getHttpProxyUsername(), getHttpProxyPassword());
+    }
+    return null;
+  }
+
+  private InputStream loadConfigInputStream(String configString, String configPath, byte[] configContent,
+                                            String fileName) throws WxPayException {
+    InputStream inputStream;
+    if (configContent != null) {
+      inputStream = new ByteArrayInputStream(configContent);
+    } else if (StringUtils.isNotEmpty(configString)) {
+      configContent = Base64.getDecoder().decode(configString);
+      inputStream = new ByteArrayInputStream(configContent);
+    } else {
+      if (StringUtils.isBlank(configPath)) {
+        throw new WxPayException("请确保证书文件地址【" + fileName + "】或者内容已配置");
+      }
+      inputStream = this.loadConfigInputStream(configPath);
+    }
+    return inputStream;
+  }
+
+
   /**
    * 从配置路径 加载配置 信息(支持 classpath、本地路径、网络url)
+   *
    * @param configPath 配置路径
-   * @return
-   * @throws WxPayException
+   * @return .
+   * @throws WxPayException .
    */
   private InputStream loadConfigInputStream(String configPath) throws WxPayException {
-    InputStream inputStream;
-    final String prefix = "classpath:";
     String fileHasProblemMsg = String.format(PROBLEM_MSG, configPath);
     String fileNotFoundMsg = String.format(NOT_FOUND_MSG, configPath);
+
+    final String prefix = "classpath:";
+    InputStream inputStream;
     if (configPath.startsWith(prefix)) {
       String path = RegExUtils.removeFirst(configPath, prefix);
       if (!path.startsWith("/")) {
         path = "/" + path;
       }
+
       try {
         inputStream = ResourcesUtils.getResourceAsStream(path);
         if (inputStream == null) {
           throw new WxPayException(fileNotFoundMsg);
         }
+
+        return inputStream;
       } catch (Exception e) {
         throw new WxPayException(fileNotFoundMsg, e);
       }
-    } else if (configPath.startsWith("http://") || configPath.startsWith("https://")) {
+    }
+
+    if (configPath.startsWith("http://") || configPath.startsWith("https://")) {
       try {
         inputStream = new URL(configPath).openStream();
         if (inputStream == null) {
           throw new WxPayException(fileNotFoundMsg);
         }
+        return inputStream;
       } catch (IOException e) {
         throw new WxPayException(fileNotFoundMsg, e);
       }
@@ -321,11 +382,12 @@ private InputStream loadConfigInputStream(String configPath) throws WxPayExcepti
           throw new WxPayException(fileNotFoundMsg);
         }
 
-        inputStream = new FileInputStream(file);
+//        return Files.newInputStream(file.toPath());
+        return new FileInputStream(file);
       } catch (IOException e) {
         throw new WxPayException(fileHasProblemMsg, e);
       }
     }
-    return inputStream;
+
   }
 }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfigHolder.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfigHolder.java
index 98d064475e..2fd7260767 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfigHolder.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfigHolder.java
@@ -4,7 +4,7 @@
  * 微信支付配置策略.
  *
  * @author zenghao
- * @date 2021/3/12
+ * created on  2021/3/12
  */
 public class WxPayConfigHolder {
 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayHttpProxy.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayHttpProxy.java
new file mode 100755
index 0000000000..ed9b77e0cf
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayHttpProxy.java
@@ -0,0 +1,75 @@
+package com.github.binarywang.wxpay.config;
+
+
+import java.io.Serializable;
+
+/**
+ * 微信支付 HTTP Proxy 正向代理配置
+ *
+ * @author Long Yu
+ * created on  2021-12-28 15:49:03
+ */
+public class WxPayHttpProxy implements Serializable {
+
+  /**
+   * 代理主机
+   */
+  private String httpProxyHost;
+  /**
+   * 代理端口
+   */
+  private Integer httpProxyPort;
+  /**
+   * 代理用户名称
+   */
+  private String httpProxyUsername;
+  /**
+   * 代理密码
+   */
+  private String httpProxyPassword;
+
+  public WxPayHttpProxy() {
+  }
+
+  public WxPayHttpProxy(String httpProxyHost, Integer httpProxyPort, String httpProxyUsername, String httpProxyPassword) {
+    this.httpProxyHost = httpProxyHost;
+    this.httpProxyPort = httpProxyPort;
+    this.httpProxyUsername = httpProxyUsername;
+    this.httpProxyPassword = httpProxyPassword;
+  }
+
+  public String getHttpProxyHost() {
+    return httpProxyHost;
+  }
+
+  public void setHttpProxyHost(String httpProxyHost) {
+    this.httpProxyHost = httpProxyHost;
+  }
+
+  public Integer getHttpProxyPort() {
+    return httpProxyPort;
+  }
+
+  public void setHttpProxyPort(Integer httpProxyPort) {
+    this.httpProxyPort = httpProxyPort;
+  }
+
+  public String getHttpProxyUsername() {
+    return httpProxyUsername;
+  }
+
+  public void setHttpProxyUsername(String httpProxyUsername) {
+    this.httpProxyUsername = httpProxyUsername;
+  }
+
+  public String getHttpProxyPassword() {
+    return httpProxyPassword;
+  }
+
+  public void setHttpProxyPassword(String httpProxyPassword) {
+    this.httpProxyPassword = httpProxyPassword;
+  }
+
+
+
+}
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 fbc499fedd..819cdfe731 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
@@ -26,6 +26,17 @@ public class WxPayConstants {
    */
   public static final Format QUERY_COMMENT_DATE_FORMAT = FastDateFormat.getInstance("yyyyMMddHHmmss");
 
+  /**
+   * 币种类型.
+   */
+  public static class CurrencyType {
+    /**
+     * 人民币.
+     */
+    public static final String CNY = "CNY";
+
+  }
+
   /**
    * 校验用户姓名选项,企业付款时使用.
    */
@@ -159,24 +170,6 @@ public String getType() {
     }
   }
 
-  /**
-   * 账户类型
-   */
-  public static class AccountType {
-    /**
-     * 基本账户
-     */
-    public static final String BASIC = "Basic";
-    /**
-     * 运营账户
-     */
-    public static final String OPERATION = "Operation";
-    /**
-     * Fees
-     */
-    public static final String FEES = "Fees";
-  }
-
   /**
    * 签名类型.
    */
@@ -311,6 +304,7 @@ public static class RefundStatus {
     public static final String SUCCESS = "SUCCESS";
 
     /**
+     * v2
      * 退款关闭.
      */
     public static final String REFUND_CLOSE = "REFUNDCLOSE";
@@ -321,10 +315,23 @@ public static class RefundStatus {
     public static final String PROCESSING = "PROCESSING";
 
     /**
+     * v2
      * 退款异常.
      * 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。
      */
     public static final String CHANGE = "CHANGE";
+
+    /**
+     * v3
+     * 退款关闭
+     */
+    public static final String CLOSED = "CLOSED";
+
+    /**
+     * v3
+     * 退款异常
+     */
+    public static final String ABNORMAL = "ABNORMAL";
   }
 
   public static class ReceiverType {
@@ -345,4 +352,5 @@ public static class ReceiverType {
      */
     public static final String PERSONAL_SUB_OPENID = "PERSONAL_SUB_OPENID";
   }
+
 }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java
index 3fa2e5bf9c..0f01358633 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java
@@ -1,17 +1,7 @@
 package com.github.binarywang.wxpay.converter;
 
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyCoupon;
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
-import com.google.common.base.Function;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
@@ -22,6 +12,14 @@
 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
 import com.thoughtworks.xstream.mapper.Mapper;
+import org.apache.commons.lang3.StringUtils;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
 
 /**
  * The type Wxpay order notify result converter.
@@ -51,7 +49,7 @@ public void marshal(Object original, HierarchicalStreamWriter writer, Marshallin
     super.marshal(original, writer, context);
     WxPayOrderNotifyResult obj = (WxPayOrderNotifyResult) original;
     List list = obj.getCouponList();
-    if (list == null || list.size() == 0) {
+    if (list == null || list.isEmpty()) {
       return;
     }
     for (int i = 0; i < list.size(); i++) {
@@ -63,7 +61,7 @@ public void marshal(Object original, HierarchicalStreamWriter writer, Marshallin
       writer.setValue(coupon.getCouponType());
       writer.endNode();
       writer.startNode("coupon_fee_" + i);
-      writer.setValue(coupon.getCouponFee() + "");
+      writer.setValue(String.valueOf(coupon.getCouponFee()));
       writer.endNode();
     }
   }
@@ -112,8 +110,11 @@ private void setFieldValue(UnmarshallingContext context, WxPayOrderNotifyResult
     Object val = context.convertAnother(obj, field.getType());
     try {
       if (val != null) {
-    	//这里加一个看似多余的(String)强转可解决高jdk版本下的编译报错问题,详情见讨论https://github.com/vaadin/framework/issues/10737
-        PropertyDescriptor pd = new PropertyDescriptor((String)field.getName(), obj.getClass());
+        /*
+        这里加一个看似多余的(String)强转可解决高jdk版本下的编译报错问题,
+        详情见讨论https://github.com/vaadin/framework/issues/10737
+        */
+        PropertyDescriptor pd = new PropertyDescriptor((String) field.getName(), obj.getClass());
         pd.getWriteMethod().invoke(obj, val);
       }
     } catch (Exception ignored) {
@@ -121,22 +122,17 @@ private void setFieldValue(UnmarshallingContext context, WxPayOrderNotifyResult
   }
 
   private Map getFieldMap(List fields) {
-    return Maps.uniqueIndex(fields, new Function() {
-      @Override
-      public String apply(Field field) {
-        if (field.isAnnotationPresent(XStreamAlias.class)) {
-          return field.getAnnotation(XStreamAlias.class).value();
-        }
-        return field.getName();
+    return Maps.uniqueIndex(fields, field -> {
+      if (field.isAnnotationPresent(XStreamAlias.class)) {
+        return field.getAnnotation(XStreamAlias.class).value();
       }
+      return field.getName();
     });
   }
 
   private WxPayOrderNotifyCoupon getElement(Map coupons, String nodeName) {
     Integer index = Integer.valueOf(StringUtils.substringAfterLast(nodeName, "_"));
-    if (coupons.get(index) == null) {
-      coupons.put(index, new WxPayOrderNotifyCoupon());
-    }
+    coupons.computeIfAbsent(index, k -> new WxPayOrderNotifyCoupon());
 
     return coupons.get(index);
   }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/exception/WxPayException.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/exception/WxPayException.java
index a5a2552b3c..4f3e4b8226 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/exception/WxPayException.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/exception/WxPayException.java
@@ -89,7 +89,7 @@ private WxPayException(Builder builder) {
    * @return the wx pay exception
    */
   public static WxPayException from(BaseWxPayResult payBaseResult) {
-    return WxPayException.newBuilder()
+    WxPayException exception = WxPayException.newBuilder()
       .xmlString(payBaseResult.getXmlString())
       .returnMsg(payBaseResult.getReturnMsg())
       .returnCode(payBaseResult.getReturnCode())
@@ -97,6 +97,16 @@ public static WxPayException from(BaseWxPayResult payBaseResult) {
       .errCode(payBaseResult.getErrCode())
       .errCodeDes(payBaseResult.getErrCodeDes())
       .build();
+
+    if (payBaseResult.getErrorCode() != null) {
+      exception.setErrCode(payBaseResult.getErrorCode());
+    }
+
+    if (payBaseResult.getErrorMessage() != null) {
+      exception.setErrCodeDes(payBaseResult.getErrorMessage());
+    }
+
+    return exception;
   }
 
   /**
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Apply4SubjectConfirmService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Apply4SubjectConfirmService.java
new file mode 100644
index 0000000000..bb124bbd22
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Apply4SubjectConfirmService.java
@@ -0,0 +1,97 @@
+package com.github.binarywang.wxpay.service;
+
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmCreateRequest;
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmCreateResult;
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmMerchantStateQueryResult;
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmStateQueryResult;
+import com.github.binarywang.wxpay.exception.WxPayException;
+
+/**
+ * 
+ * 商户开户意愿确认
+ * 产品文档:商户开户意愿确认流程
+ * 
+ * + * @author Mr.Pan + */ +public interface Apply4SubjectConfirmService { + + /** + *
+   * 提交申请单
+   * 详情请见: 间连商户开户意愿确认(提交申请单)
+   * 
+ * + * @param request 申请请求参数 + * @return 审核结果 + * @throws WxPayException 异常 + */ + ApplySubjectConfirmCreateResult applyment(ApplySubjectConfirmCreateRequest request) throws WxPayException; + + /** + * + *
+   * 查询申请单审核结果
+   * 详情请见: 查询申请单审核结果
+   * 
+ * + * @param businessCode 业务申请编号 + * @return 审核结果 + * @throws WxPayException 异常 + */ + ApplySubjectConfirmStateQueryResult queryApplyStatusByBusinessCode(String businessCode) throws WxPayException; + + /** + * + *
+   * 查询申请单审核结果
+   * 详情请见: 查询申请单审核结果
+   * 
+ * + * @param applymentId 申请编号 + * @return 审核结果 + * @throws WxPayException 异常 + */ + ApplySubjectConfirmStateQueryResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException; + + + /** + * + *
+   * 获取商户开户意愿确认状态
+   * 详情请见: 获取商户开户意愿确认状态API
+   * 
+ * + * @param subMchId 微信支付分配的特约商户的唯一标识。 + * @return 确认状态结果 + * @throws WxPayException 异常 + */ + ApplySubjectConfirmMerchantStateQueryResult queryMerchantApplyStatusByMchId(String subMchId) throws WxPayException; + + + /** + * + *
+   * 撤销申请单
+   * 详情请见: 撤销申请单API
+   * 
+ * + * @param businessCode 业务申请编号 + * @throws WxPayException 异常 + */ + void cancelApplyByBusinessCode(String businessCode) throws WxPayException; + + /** + * + *
+   * 撤销申请单
+   * 详情请见: 撤销申请单API
+   * 
+ * + * @param applymentId 申请编号 + * @throws WxPayException 异常 + */ + void cancelApplyByApplymentId(String applymentId) throws WxPayException; + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java index ef937bab23..c0b443a0da 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java @@ -49,8 +49,8 @@ public interface Applyment4SubService { ApplymentStateQueryResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException; /** - * 通过申请单号查询申请状态 - * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_4.shtml + * 根据特约子商户ID查询结算账户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter11_1_4.shtml * 接口链接:https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/{sub_mchid}/settlement * * @param subMchid 本服务商进件、已签约的特约商户号。 @@ -61,7 +61,7 @@ public interface Applyment4SubService { /** * 修改结算帐号 - * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_3.shtml + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter11_1_3.shtml * 接口链接:https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/{sub_mchid}/modify-settlement * * @param subMchid 特约商户号 @@ -71,4 +71,18 @@ public interface Applyment4SubService { */ String modifySettlement(String subMchid, ModifySettlementRequest request) throws WxPayException; + /** + * 查询结算账户修改申请状态 + * + * @param subMchid 特约商户号 + * @param applicationNo 修改结算账户申请单号 + * + * @return {@link SettlementModifyStateQueryResult} + * @throws WxPayException + * @apiNote 查询结算账户修改申请状态 + * + *

接口链接:https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/{sub_mchid}/application/{applicationNo}

+ */ + SettlementModifyStateQueryResult querySettlementModifyStatusByApplicationNo(String subMchid, String applicationNo) throws WxPayException; + } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BankService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BankService.java new file mode 100644 index 0000000000..095510d4f4 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BankService.java @@ -0,0 +1,121 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.bank.*; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + *
+ * 微信支付-银行组件
+ * 
+ * + * @author zhongjun + **/ +public interface BankService { + /** + *
+   *
+   * 获取对私银行卡号开户银行
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:https://api.mch.weixin.qq.com/v3/capital/capitallhh/banks/search-banks-by-bank-account
+   *
+   * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_1.shtml
+   * 
+ * + * @param accountNumber 银行卡号 该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) + * @return BankAccountResult 对私银行卡号开户银行信息 + * @throws WxPayException . + */ + BankAccountResult searchBanksByBankAccount(String accountNumber) throws WxPayException; + + /** + *
+   *
+   * 查询支持个人业务的银行列表
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:https://api.mch.weixin.qq.com/v3/capital/capitallhh/banks/personal-banking
+   *
+   * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_2.shtml
+   * 
+ * + * @param offset 本次查询偏移量 + * @param limit 本次请求最大查询条数,最大值为200 + * @return PersonalBankingResult 支持个人业务的银行列表信息 + * @throws WxPayException . + */ + BankingResult personalBanking(Integer offset, Integer limit) throws WxPayException; + + /** + *
+   *
+   * 支持对公业务的银行列表
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:https://api.mch.weixin.qq.com/v3/capital/capitallhh/banks/corporate-banking
+   *
+   * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_3.shtml
+   * 
+ * + * @param offset 本次查询偏移量 + * @param limit 本次请求最大查询条数,最大值为200 + * @return BankingResult 支持对公业务的银行列表信息 + * @throws WxPayException . + */ + BankingResult corporateBanking(Integer offset, Integer limit) throws WxPayException; + + /** + *
+   *
+   * 查询省份列表API
+   * 通过本接口获取省份列表数据(不包含中国港澳台地区),可用于省份下的城市数据查询
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:https://api.mch.weixin.qq.com/v3/capital/capitallhh/areas/provinces
+   *
+   * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_4.shtml
+   * 
+ * + * @return ProvincesResult 省份列表信息 + * @throws WxPayException . + */ + ProvincesResult areasProvinces() throws WxPayException; + + /** + *
+   *
+   * 查询城市列表API
+   * 通过本接口根据省份编码获取省份下的城市列表信息,不包含中国港澳台地区城市信息,可用于支行数据过滤查询
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:https://api.mch.weixin.qq.com/v3/capital/capitallhh/areas/provinces/{province_code}/cities
+   *
+   * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_5.shtml
+   * 
+ * + * @return CitiesResult 城市列表信息 + * @throws WxPayException . + */ + CitiesResult areasCities(Integer provinceCode) throws WxPayException; + + /** + *
+   *
+   * 查询支行列表API
+   * 本接口可以用于根据银行别名编码(仅支持需要填写支行的银行别名编码)和城市编码过滤查询支行列表数据
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:https://api.mch.weixin.qq.com/v3/capital/capitallhh/banks/{bank_alias_code}/branches
+   *
+   * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_5.shtml
+   * 
+ * + * @param bankAliasCode 银行别名的编码,查询支行接口仅支持需要填写支行的银行别名编码。示例值:1000006247 + * @param cityCode 城市编码,唯一标识一座城市,用于结合银行别名编码查询支行列表。示例值:536 + * @param offset 非负整数,表示该次请求资源的起始位置,从0开始计数。调用方选填,默认为0。offset为20,limit为100时,查询第21-120条数据 + * @param limit 非0非负的整数,该次请求可返回的最大资源条数。示例值:200 + * @return BankBranchesResult 城市列表信息 + * @throws WxPayException . + */ + BankBranchesResult bankBranches(String bankAliasCode, Integer cityCode, Integer offset, Integer limit) throws WxPayException; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BrandMerchantTransferService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BrandMerchantTransferService.java new file mode 100644 index 0000000000..cd8d1de0f1 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BrandMerchantTransferService.java @@ -0,0 +1,93 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.request.*; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandBatchesQueryResult; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandDetailsQueryResult; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandTransferBatchesResult; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + * 品牌商户发放红包商家转账到零钱(直联商户) + * + * @author moran + */ +public interface BrandMerchantTransferService { + + /** + * 品牌商户发放红包API + *

+ * 适用对象:直连商户 + * 文档详见: + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-batches + * 请求方式:POST + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * 是否需要证书:是 + * + * @param request the request + * @return transfer create result + * @throws WxPayException the wx pay exception + */ + BrandTransferBatchesResult createBrandTransfer(BrandTransferBatchesRequest request) throws WxPayException; + + /** + * 品牌红包微信批次单号查询批次单API + *

+ * 适用对象:直连商户 + * 文档详见: + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-batches/{batch_no} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return batches query result + * @throws WxPayException the wx pay exception + */ + BrandBatchesQueryResult queryBrandWxBatches(BrandWxBatchesQueryRequest request) throws WxPayException; + + /** + * 品牌红包微信支付明细单号查询明细单API + *

+ * 适用对象:直连商户 + * 文档详见: + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-batches/{batch_no}/details/{detail_no} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return details query result + * @throws WxPayException the wx pay exception + */ + BrandDetailsQueryResult queryBrandWxDetails(BrandWxDetailsQueryRequest request) throws WxPayException; + + /** + * 品牌红包商家批次单号查询批次单API + *

+ * 适用对象:直连商户 + * 文档详见: + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-out-batches/{out_batch_no} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return batches query result + * @throws WxPayException the wx pay exception + */ + BrandBatchesQueryResult queryBrandMerchantBatches(BrandMerchantBatchesQueryRequest request) throws WxPayException; + + /** + * 品牌红包商家明细单号查询明细单API + *

+ * 适用对象:直连商户 + * 文档详见: + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-out-batches/{out_batch_no}/out-details/{out_detail_no} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return details query result + * @throws WxPayException the wx pay exception + */ + BrandDetailsQueryResult queryBrandMerchantDetails(BrandMerchantDetailsQueryRequest request) throws WxPayException; + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ComplaintService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ComplaintService.java new file mode 100644 index 0000000000..8e86692cd6 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ComplaintService.java @@ -0,0 +1,165 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.complaint.*; +import com.github.binarywang.wxpay.bean.media.ImageUploadResult; +import com.github.binarywang.wxpay.exception.WxPayException; + +import javax.crypto.BadPaddingException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +/** + *

+ * 微信支付 消费者投诉2.0 API.
+ * Created by jmdhappy on 2022/3/19.
+ * 
+ * + * @author jmdhappy + */ +public interface ComplaintService { + + /** + *
+   * 查询投诉单列表API
+   * 商户可通过调用此接口,查询指定时间段的所有用户投诉信息,以分页输出查询结果。
+   * 对于服务商、渠道商,可通过调用此接口,查询指定子商户号对应子商户的投诉信息,若不指定则查询所有子商户投诉信息。
+   * 文档详见: ...
+   * 
+ * + * @param request {@link ComplaintRequest} 查询投诉单列表请求数据 + * @return {@link ComplaintResult} 微信返回的投诉单列表 + * @throws WxPayException the wx pay exception + * @throws BadPaddingException . + */ + ComplaintResult queryComplaints(ComplaintRequest request) throws WxPayException, BadPaddingException; + + /** + *
+   * 查询投诉单详情API
+   * 商户可通过调用此接口,查询指定投诉单的用户投诉详情,包含投诉内容、投诉关联订单、投诉人联系方式等信息,方便商户处理投诉。
+   * 文档详见: ...
+   * 
+ * + * @param request {@link ComplaintDetailRequest} 投诉单详情请求数据 + * @return {@link ComplaintDetailResult} 微信返回的投诉单详情 + * @throws WxPayException the wx pay exception + * @throws BadPaddingException . + */ + ComplaintDetailResult getComplaint(ComplaintDetailRequest request) throws WxPayException, BadPaddingException; + + /** + *
+   * 查询投诉协商历史API
+   * 商户可通过调用此接口,查询指定投诉的用户商户协商历史,以分页输出查询结果,方便商户根据处理历史来制定后续处理方案。
+   * 文档详见: ...
+   * 
+ * + * @param request {@link NegotiationHistoryRequest} 请求数据 + * @return {@link NegotiationHistoryResult} 微信返回结果 + * @throws WxPayException the wx pay exception + */ + NegotiationHistoryResult queryNegotiationHistorys(NegotiationHistoryRequest request) throws WxPayException; + + /** + *
+   * 创建投诉通知回调地址API
+   * 商户通过调用此接口创建投诉通知回调URL,当用户产生新投诉且投诉状态已变更时,微信支付会通过回 调URL通知商户。对于服务商、渠道商,会收到所有子商户的投诉信息推送。
+   * 文档详见: ...
+   * 
+ * + * @param request {@link ComplaintDetailRequest} 请求数据 + * @return {@link ComplaintNotifyUrlResult} 微信返回结果 + * @throws WxPayException the wx pay exception + */ + ComplaintNotifyUrlResult addComplaintNotifyUrl(ComplaintNotifyUrlRequest request) throws WxPayException; + + /** + *
+   * 查询投诉通知回调地址API
+   * 商户通过调用此接口查询投诉通知的回调URL。
+   * 文档详见: ...
+   * 
+ * + * @return {@link ComplaintNotifyUrlResult} 微信返回结果 + * @throws WxPayException the wx pay exception + */ + ComplaintNotifyUrlResult getComplaintNotifyUrl() throws WxPayException; + + /** + *
+   * 更新投诉通知回调地址API
+   * 商户通过调用此接口更新投诉通知的回调URL。
+   * 文档详见: ...
+   * 
+ * + * @param request {@link ComplaintDetailRequest} 请求数据 + * @return {@link ComplaintNotifyUrlResult} 微信返回结果 + * @throws WxPayException the wx pay exception + */ + ComplaintNotifyUrlResult updateComplaintNotifyUrl(ComplaintNotifyUrlRequest request) throws WxPayException; + + /** + *
+   * 删除投诉通知回调地址API
+   * 当商户不再需要推送通知时,可通过调用此接口删除投诉通知的回调URL,取消通知回调。
+   * 文档详见: ...
+   * 
+ * + * @throws WxPayException the wx pay exception + */ + void deleteComplaintNotifyUrl() throws WxPayException; + + /** + *
+   * 提交回复API
+   * 商户可通过调用此接口,提交回复内容。其中上传图片凭证需首先调用商户上传反馈图片接口,得到图片id,再将id填入请求。
+   * 回复可配置文字链,传入跳转链接文案和跳转链接字段,用户点击即可跳转对应页面
+   * 文档详见: ...
+   * 
+ * + * @param request {@link ResponseRequest} 请求数据 + * @throws WxPayException the wx pay exception + */ + void submitResponse(ResponseRequest request) throws WxPayException; + + /** + *
+   * 反馈处理完成API
+   * 商户可通过调用此接口,反馈投诉单已处理完成。
+   * 文档详见: ...
+   * 
+ * + * @param request {@link CompleteRequest} 请求数据 + * @throws WxPayException the wx pay exception + */ + void complete(CompleteRequest request) throws WxPayException; + + /** + *
+   * 商户上传反馈图片API
+   * 文档详见: ...
+   * 接口链接:https://api.mch.weixin.qq.com/v3/merchant-service/images/upload
+   * 
+ * + * @param imageFile 需要上传的图片文件 + * @return ImageUploadResult 微信返回的媒体文件标识Id。示例值:BB04A5DEEFEA18D4F2554C1EDD3B610B.bmp + * @throws WxPayException the wx pay exception + */ + ImageUploadResult uploadResponseImage(File imageFile) throws WxPayException, IOException; + + /** + *
+   * 商户上传反馈图片API
+   * 文档详见: ...
+   * 接口链接:https://api.mch.weixin.qq.com/v3/merchant-service/images/upload
+   * 
+ * + * @param inputStream 需要上传的图片文件流 + * @param fileName 需要上传的图片文件名 + * @return ImageUploadResult 微信返回的媒体文件标识Id。示例值:BB04A5DEEFEA18D4F2554C1EDD3B610B.bmp + * @throws WxPayException the wx pay exception + */ + ImageUploadResult uploadResponseImage(InputStream inputStream, String fileName) throws WxPayException, IOException; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/CustomDeclarationService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/CustomDeclarationService.java new file mode 100644 index 0000000000..98f55d51dd --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/CustomDeclarationService.java @@ -0,0 +1,80 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.customs.*; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + *
+ * 微信支付 支付报关 API.
+ * Created by xifengzhu on 2022/05/05.
+ * 
+ * + * @author xifengzhu + */ +public interface CustomDeclarationService { + + /** + * The constant DECLARATION_BASE_URL. + */ + String DECLARATION_BASE_URL = "https://apihk.mch.weixin.qq.com/global/v3/customs"; + + /** + *
+   * 报关API
+   * 文档地址: ...
+   * 
+ * + * @param request the request + * @return 返回数据 declaration result + * @throws WxPayException the wx pay exception + */ + DeclarationResult declare(DeclarationRequest request) throws WxPayException; + + /** + *
+   * 报关查询API
+   * 文档地址: ...
+   * 
+ * + * @param request the request + * @return 返回数据 declaration query result + * @throws WxPayException the wx pay exception + */ + DeclarationQueryResult query(DeclarationQueryRequest request) throws WxPayException; + + /** + *
+   * 身份信息校验API
+   * 文档地址: ...
+   * 
+ * + * @param request the request + * @return 返回数据 verify certification result + * @throws WxPayException the wx pay exception + */ + VerifyCertificateResult verifyCertificate(VerifyCertificateRequest request) throws WxPayException; + + /** + *
+   * 报关信息修改API
+   * 文档地址: ...
+   * 
+ * + * @param request the request + * @return 返回数据 declaration result + * @throws WxPayException the wx pay exception + */ + DeclarationResult modify(DeclarationRequest request) throws WxPayException; + + /** + *
+   * 报关重推API
+   * 文档地址: ...
+   * 
+ * + * @param request the request + * @return 返回数据 redeclaration result + * @throws WxPayException the wx pay exception + */ + RedeclareResult redeclare(RedeclareRequest request) throws WxPayException; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java index 3f97b150a6..5b2a8beae7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java @@ -15,14 +15,14 @@ *
* * @author cloudX - * @date 2020 /08/17 + * created on 2020 /08/17 */ public interface EcommerceService { /** *
    * 二级商户进件API
    * 接口地址: https://api.mch.weixin.qq.com/v3/ecommerce/applyments/
-   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_1.shtml
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_1_8.shtml
    *
    * 
* @@ -215,6 +215,19 @@ public interface EcommerceService { */ FundBalanceResult subNowBalance(String subMchid) throws WxPayException; + /** + *
+   * 二级商户号账户实时余额
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_3_11.shtml
+   * 
+ * + * @param subMchid 二级商户号 + * @param accountType 账户类型 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + FundBalanceResult subNowBalance(String subMchid, SpAccountTypeEnum accountType) throws WxPayException; + /** *
    * 二级商户号账户日终余额
@@ -252,6 +265,18 @@ public interface EcommerceService {
    */
   ProfitSharingResult queryProfitSharing(ProfitSharingQueryRequest request) throws WxPayException;
 
+  /**
+   * 
+   * 查询订单剩余待分金额API
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_4_9.shtml
+   * 
+ * + * @param request 查询订单剩余待分金额请求 + * @return 返回数据 profit sharing UnSplitAmount result + * @throws WxPayException the wx pay exception + */ + ProfitSharingOrdersUnSplitAmountResult queryProfitSharingOrdersUnsplitAmount(ProfitSharingOrdersUnSplitAmountRequest request) throws WxPayException; + /** *
    * 添加分账接收方API
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MarketingFavorService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MarketingFavorService.java
index 5da11aabf3..ac0ed5212f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MarketingFavorService.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MarketingFavorService.java
@@ -187,10 +187,10 @@ public interface MarketingFavorService {
    * 
* * @param request 请求对象 - * @return FavorCallbacksSaveResult 微信返回的结果信息。 + * @return FavorStocksPauseResult 微信返回的结果信息。 * @throws WxPayException the wx pay exception */ - FavorStocksStartResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException; + FavorStocksPauseResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException; /** *
@@ -200,10 +200,10 @@ public interface MarketingFavorService {
    * 
* * @param request 请求对象 - * @return FavorCallbacksSaveResult 微信返回的结果信息。 + * @return FavorStocksRestartResult 微信返回的结果信息。 * @throws WxPayException the wx pay exception */ - FavorStocksStartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException; + FavorStocksRestartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException; UseNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java new file mode 100644 index 0000000000..585a96e763 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java @@ -0,0 +1,150 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.merchanttransfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + * 商家转账到零钱(直联商户) + * + * @author glz + * created on 2022-6-11 + */ +public interface MerchantTransferService { + + /** + * 发起商家转账API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_1.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/batches + * 请求方式:POST + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * 是否需要证书:是 + * + * @param request the request + * @return transfer create result + * @throws WxPayException the wx pay exception + */ + TransferCreateResult createTransfer(TransferCreateRequest request) throws WxPayException; + + /** + * 微信批次单号查询批次单API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_2.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/batches/batch-id/{batch_id} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return batches query result + * @throws WxPayException the wx pay exception + */ + BatchesQueryResult queryWxBatches(WxBatchesQueryRequest request) throws WxPayException; + + /** + * 微信明细单号查询明细单API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_3.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/batches/batch-id/{batch_id}/details/detail-id/{detail_id} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return details query result + * @throws WxPayException the wx pay exception + */ + DetailsQueryResult queryWxDetails(WxDetailsQueryRequest request) throws WxPayException; + + /** + * 商家批次单号查询批次单API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_5.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/batches/out-batch-no/{out_batch_no} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return batches query result + * @throws WxPayException the wx pay exception + */ + BatchesQueryResult queryMerchantBatches(MerchantBatchesQueryRequest request) throws WxPayException; + + /** + * 商家明细单号查询明细单API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_6.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/batches/out-batch-no/{out_batch_no}/details/out-detail-no/{out_detail_no} + * 请求方式:GET + * 接口限频: 单个商户 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return details query result + * @throws WxPayException the wx pay exception + */ + DetailsQueryResult queryMerchantDetails(MerchantDetailsQueryRequest request) throws WxPayException; + + /** + * 转账电子回单申请受理API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_7.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/bill-receipt + * 请求方式:POST + * 接口限频: 单个商户 20QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request the request + * @return electronic bill result + * @throws WxPayException the wx pay exception + */ + ElectronicBillResult applyElectronicBill(ElectronicBillApplyRequest request) throws WxPayException; + + /** + * 查询转账电子回单API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_8.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/bill-receipt/{out_batch_no} + * 请求方式:GET + * + * @param outBatchNo the out batch no + * @return electronic bill result + * @throws WxPayException the wx pay exception + */ + ElectronicBillResult queryElectronicBill(String outBatchNo) throws WxPayException; + + /** + * 转账明细电子回单受理API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_9.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:POST + * 接口限频: 单个商户 20QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * 前置条件:只支持受理最近30天内的转账明细单 + * + * @param request the request + * @return detail electronic bill result + * @throws WxPayException the wx pay exception + */ + DetailElectronicBillResult applyDetailElectronicBill(DetailElectronicBillRequest request) throws WxPayException; + + + /** + * 查询转账明细电子回单受理结果API + *

+ * 适用对象:直连商户 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_10.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:GET + * 前置条件:只支持查询最近90天内的转账明细单 + * + * @param request the request + * @return detail electronic bill result + * @throws WxPayException the wx pay exception + */ + DetailElectronicBillResult queryDetailElectronicBill(DetailElectronicBillRequest request) throws WxPayException; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerPayScoreService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerPayScoreService.java new file mode 100644 index 0000000000..c5c4e06796 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerPayScoreService.java @@ -0,0 +1,255 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; +import com.github.binarywang.wxpay.bean.payscore.PayScoreNotifyData; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreRequest; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreResult; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerUserAuthorizationStatusNotifyResult; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + *

+ *  服务商支付分相关服务类.
+ *   微信支付分是对个人的身份特质、支付行为、使用历史等情况的综合计算分值,旨在为用户提供更简单便捷的生活方式。
+ *   微信用户可以在具体应用场景中,开通微信支付分。开通后,用户可以在【微信—>钱包—>支付分】中查看分数和使用记录。
+ *   (即需在应用场景中使用过一次,钱包才会出现支付分入口)
+ *
+ * @author hallkk
+ * created on  2022/05/18
+ */
+public interface PartnerPayScoreService {
+
+
+  /**
+   * 商户预授权
+   * @param request {@link WxPartnerPayScoreRequest} 请求对象
+   *
+   * @return WxPartnerPayScoreResult wx  partner payscore result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 商户预授权
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/permissions
+   */
+  WxPartnerPayScoreResult permissions(WxPartnerPayScoreRequest request) throws WxPayException;
+
+
+  /**
+   * 商户查询与用户授权记录 (authorization_code)
+   * @apiNote 商户查询与用户授权记录
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/permissions/authorization-code/{authorization_code}
+   *
+   * @param serviceId 服务id
+   * @param subMchid 特约子商户号
+   * @param authorizationCode 授权协议号
+   *
+   * @return WxPayScoreResult wx partner payscore result
+   * @throws WxPayException the wx pay exception
+   */
+  WxPartnerPayScoreResult permissionsQueryByAuthorizationCode(String serviceId, String subMchid,
+                                                              String authorizationCode) throws WxPayException;
+
+
+  /**
+   * 商户解除用户授权关系(authorization_code)
+   *
+   * @param serviceId         服务id
+   * @param subMchid          特约子商户号
+   * @param authorizationCode 授权协议号
+   * @param reason            撤销原因
+   *
+   * @return WxPartnerPayScoreResult wx partner payscore result
+   * @throws WxPayException the wx pay exception
+   * @apiNote : 商户解除用户授权关系
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/permissions/authorization-code/{authorization_code}/terminate
+   */
+  WxPartnerPayScoreResult permissionsTerminateByAuthorizationCode(String serviceId, String subMchid,
+                                                                  String authorizationCode, String reason) throws WxPayException;
+
+
+  /**
+   * 商户查询与用户授权记录(OpenID)
+   *
+   * @param serviceId 服务id
+   * @param subMchid  特约子商户号
+   * @param appId     服务商的公众号ID
+   * @param subAppid  子商户的公众号ID
+   * @param openId    服务商的用户标识
+   * @param subOpenid 子商户的用户标识
+   *
+   * @return WxPayScoreResult wx partner payscore result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 商户查询与用户授权记录
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/permissions/search
+   */
+  WxPartnerPayScoreResult permissionsQueryByOpenId(String serviceId, String appId, String subMchid, String subAppid,
+                                                   String openId, String subOpenid) throws WxPayException;
+
+
+  /**
+   * 商户解除用户授权关系API(OpenID)
+   * @apiNote 商户解除用户授权关系API
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/permissions/terminate
+   *
+   * @param serviceId 服务id
+   * @param subMchid  特约子商户号
+   * @param appId     服务商的公众号ID
+   * @param subAppid  子商户的公众号ID
+   * @param openId    服务商的用户标识
+   * @param subOpenid 子商户的用户标识
+   * @param reason    取消理由
+   * @return WxPayScoreResult wx partner payscore result
+   * @throws WxPayException the wx pay exception
+   */
+  WxPartnerPayScoreResult permissionsTerminateByOpenId(String serviceId, String appId, String subMchid, String subAppid,
+                                                       String openId, String subOpenid, String reason) throws WxPayException;
+
+
+  /**
+   * 支付分创建订单API.
+   *
+   * @param request 请求对象
+   *
+   * @return WxPayScoreResult wx partner payscore result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 创建订单
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder
+   */
+  WxPartnerPayScoreResult createServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException;
+
+  /**
+   * 支付分查询订单API.
+   *
+   * @param serviceId  服务ID
+   * @param subMchid   子商户商户号
+   * @param outOrderNo 商户订单号
+   * @param queryId    单据查询ID
+   *
+   * @return the wx pay score result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 查询订单
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder
+   */
+  WxPartnerPayScoreResult queryServiceOrder(String serviceId, String subMchid,
+                                            String outOrderNo, String queryId) throws WxPayException;
+
+  /**
+   * 支付分取消订单API.
+   *
+   * @param serviceId  服务ID
+   * @param subMchid   子商户商户号
+   * @param outOrderNo 商户订单号
+   * @param reason     撤销原因
+   *
+   * @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult wx pay score result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 取消订单
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder/{out_order_no}/cancel
+   */
+  WxPartnerPayScoreResult cancelServiceOrder(String serviceId, String appId, String subMchid,
+                                             String outOrderNo, String reason) throws WxPayException;
+
+  /**
+   * 支付分修改订单金额API.
+   *
+   * @param request the request
+   *
+   * @return the wx pay score result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 修改订单金额
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder/{out_order_no}/modify
+   */
+  WxPartnerPayScoreResult modifyServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException;
+
+  /**
+   * 支付分完结订单API.
+   *
+   * @param request the request
+   *
+   * @return the wx pay score result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 完结订单
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder/{out_order_no}/complete
+   */
+  void completeServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException;
+
+  /**
+   * 订单收款
+   *
+   * @param serviceId  服务ID
+   * @param subMchid   子商户商户号
+   * @param outOrderNo 商户订单号
+   *
+   * @return the wx pay score result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 订单收款
+   * 请求URL:https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder/{out_order_no}/pay
+   */
+  WxPartnerPayScoreResult payServiceOrder(String serviceId, String appId, String subMchid, String outOrderNo) throws WxPayException;
+
+  /**
+   * 同步订单信息
+   *
+   * @param request the request
+   *
+   * @return the wx pay score result
+   * @throws WxPayException the wx pay exception
+   * @apiNote 同步订单信息
+   * 请求URL: https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder/{out_order_no}/sync
+   */
+  WxPartnerPayScoreResult syncServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException;
+
+  /**
+   * 
+   * 收付通子商户申请绑定支付分服务API.
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore_partner/chapter9_1.shtml
+   * 请求URL: https://api.mch.weixin.qq.com/v3/payscore/partner/service-account-applications
+   * 
+ * + * @param request the request + * @return the wx pay score result + * @throws WxPayException the wx pay exception + */ + WxPartnerPayScoreResult applyServiceAccount(WxPartnerPayScoreRequest request) throws WxPayException; + + /** + *
+   * 查询收付通子商户服务绑定结果API.
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore_partner/chapter9_2.shtml
+   * 请求URL: https://api.mch.weixin.qq.com/v3/payscore/partner/service-account-applications/{out_apply_no}
+   * 
+ * + * @param outApplyNo 商户申请绑定单号 + * @return the wx pay score result + * @throws WxPayException the wx pay exception + */ + WxPartnerPayScoreResult queryServiceAccountState(String outApplyNo) throws WxPayException; + + /** + * 授权/解除授权服务回调通知 + * + * @param notifyData 通知数据 + * @param header 通知头部数据,不传则表示不校验头 + * + * @return 解密后通知数据 return user authorization status notify result + * @throws WxPayException the wx pay exception + * @apiNote 授权/解除授权服务回调通知 + */ + WxPartnerUserAuthorizationStatusNotifyResult parseUserAuthorizationStatusNotifyResult(String notifyData, SignatureHeader header) throws WxPayException; + + /** + * 支付分回调内容解析方法 + * + * @param data the data + * @return the wx pay score result + */ + PayScoreNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException; + + /** + * 支付分回调NotifyData解密resource + * + * @param data the data + * @return the wx pay score result + * @throws WxPayException the wx pay exception + */ + WxPartnerPayScoreResult decryptNotifyDataResource(PayScoreNotifyData data) throws WxPayException; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerPayScoreSignPlanService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerPayScoreSignPlanService.java new file mode 100644 index 0000000000..3e51ebd7f0 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerPayScoreSignPlanService.java @@ -0,0 +1,138 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; +import com.github.binarywang.wxpay.bean.payscore.PartnerUserSignPlanEntity; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanRequest; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreUserSignPlanResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import org.checkerframework.checker.nullness.qual.NonNull; + +/** + * @author UltramanNoa + * @className PartnerPayScoreSignPlanService + * @description 微信支付分签约计划接口 + * @createTime 2023/11/3 09:16 + * + *
+ * @apiNote 微信支付分签约计划
+ * 
+ * 文档更新时间:2023.10.13 + *
+ * 微信支付分签约计划是不同模式的支付分接口(随着国家大力推广教培行业先享后付政策,微信支付也紧跟政策于2023.07.25上线第一版签约计划接口以适用教培行业先享后付。于2023.10.13文档推至官网文档中心) + *
+ * 免确认/需确认 用服务商创单接口 {@link PartnerPayScoreService} 需要用户授权 + *
+ * 签约计划,用单独创单接口 {@link PartnerPayScoreSignPlanService} 不需要用户授权 + *
+ **/ +public interface PartnerPayScoreSignPlanService { + + /** + *

description:创建支付分计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 11:58

+ *

version: v.1.0

+ * + * @param request {@link WxPartnerPayScoreSignPlanRequest} + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 创建支付分计划 + **/ + WxPartnerPayScoreSignPlanResult createPlans(WxPartnerPayScoreSignPlanRequest request) throws WxPayException; + + /** + *

description: 查询支付分计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 14:03

+ *

version: v.1.0

+ * + * @param merchantPlanNo 路径参数:支付分计划商户侧单号 + * @param subMchid 子商户号 + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 查询支付分计划 + **/ + WxPartnerPayScoreSignPlanResult queryPlans(@NonNull String merchantPlanNo, @NonNull String subMchid) throws WxPayException; + + /** + *

description: 停止支付分计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 14:24

+ *

version: v.1.0

+ * + * @param merchantPlanNo 路径参数:支付分计划商户侧单号 + * @param subMchid 子商户号 + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 停止支付分计划 + **/ + WxPartnerPayScoreSignPlanResult stopPlans(@NonNull String merchantPlanNo, @NonNull String subMchid) throws WxPayException; + + /** + *

description: 创建用户的签约计划详情对应的服务订单

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 14:53

+ *

version: v.1.0

+ * + * @param request {@link WxPartnerPayScoreSignPlanRequest} + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 创建用户的签约计划详情对应的服务订单 + **/ + WxPartnerPayScoreSignPlanResult signPlanServiceOrder(WxPartnerPayScoreSignPlanRequest request) throws WxPayException; + + /** + *

description: 创建用户的签约计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 17:48

+ *

version: v.1.0

+ * + * @param request {@link WxPartnerPayScoreSignPlanRequest} + * + * @return {@link WxPartnerPayScoreUserSignPlanResult} + * @apiNote 创建用户的签约计划 + **/ + WxPartnerPayScoreUserSignPlanResult createUserSignPlans(WxPartnerPayScoreSignPlanRequest request) throws WxPayException; + + /** + *

description: 查询用户的签约计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 18:01

+ *

version: v.1.0

+ * + * @param merchantSignPlanNo 路径参数 商户签约计划号 + * @param subMchid 子商户号 + * + * @return {@link PartnerUserSignPlanEntity} + * @apiNote 查询用户的签约计划 + **/ + PartnerUserSignPlanEntity queryUserSignPlans(@NonNull String merchantSignPlanNo, @NonNull String subMchid) throws WxPayException; + + /** + *

description: 取消用户的签约计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 18:01

+ *

version: v.1.0

+ * + * @param merchantSignPlanNo 路径参数 商户签约计划号 subMchid – 子商户号 + * @param subMchid 子商户号 + * @param stopReason 停止签约计划原因 + * + * @return {@link PartnerUserSignPlanEntity} + * @apiNote 取消用户的签约计划 + **/ + PartnerUserSignPlanEntity stopUserSignPlans(@NonNull String merchantSignPlanNo, @NonNull String subMchid, @NonNull String stopReason) throws WxPayException; + + /** + *

description: 回调通知校验解密

+ *

author:UltramanNoa

+ *

create Time: 2023/11/6 10:27

+ *

version: v.1.0

+ * @param + * @param notifyData + * @param header + * @return {@link PartnerUserSignPlanEntity} + **/ + PartnerUserSignPlanEntity parseSignPlanNotifyResult(String notifyData, SignatureHeader header) throws WxPayException; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerTransferService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerTransferService.java new file mode 100644 index 0000000000..b7397605ac --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerTransferService.java @@ -0,0 +1,201 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.ecommerce.FundBalanceResult; +import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum; +import com.github.binarywang.wxpay.bean.marketing.transfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; + +import javax.crypto.BadPaddingException; +import java.io.InputStream; + +/** + * 微信批量转账到零钱【V3接口】服务商API + * + * @author xiaoqiang + * created on 2021-12-06 + */ +public interface PartnerTransferService { + + /** + * 发起批量转账API + * 适用对象:服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter3_1.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches + * 请求方式:POST + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request 请求对象 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + PartnerTransferResult batchTransfer(PartnerTransferRequest request) throws WxPayException; + + /** + * 微信支付批次单号查询批次单API + * 接口说明 + * 适用对象:服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter3_2.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/batch-id/{batch_id} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request 请求对象 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + BatchNumberResult queryBatchByBatchId(BatchNumberRequest request) throws WxPayException; + + /** + * 微信支付明细单号查询明细单API + * 接口说明 + * 适用对象:服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter3_3.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/batch-id/{batch_id}/details/detail-id/{detail_id} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param batchId 微信批次单号 + * @param detailId 微信明细单号 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + * @throws BadPaddingException the wx decrypt exception + */ + BatchDetailsResult queryBatchDetailByWeChat(String batchId, String detailId) throws WxPayException, BadPaddingException; + + /** + * 商家批次单号查询批次单API + * 接口说明 + * 适用对象:服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter3_4.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/out-batch-no/{out_batch_no} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request 请求对象 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + BatchNumberResult queryBatchByOutBatchNo(MerchantBatchRequest request) throws WxPayException; + + /** + * 商家明细单号查询明细单API + * 接口说明 + * 适用对象:服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter3_5.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/out-batch-no/{out_batch_no}/details/out-detail-no/{out_detail_no} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param outBatchNo 商家明细单号 + * @param outDetailNo 商家批次单号 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + * @throws BadPaddingException the wx decrypt exception + */ + BatchDetailsResult queryBatchDetailByMch(String outBatchNo, String outDetailNo) throws WxPayException, BadPaddingException; + + + /** + * 转账电子回单申请受理API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_1.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/bill-receipt + * 请求方式:POST + * + * @param request 商家批次单号 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + BillReceiptResult receiptBill(ReceiptBillRequest request) throws WxPayException; + + + /** + * 查询转账电子回单API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_2.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/bill-receipt/{out_batch_no} + * 请求方式:GET + * + * @param outBatchNo 商家批次单号 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + BillReceiptResult queryBillReceipt(String outBatchNo) throws WxPayException; + + /** + * 转账明细电子回单受理API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_4.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:POST + * 前置条件:只支持受理最近90天内的转账明细单 + * + * @param request 请求对象 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + ElectronicReceiptsResult transferElectronic(ElectronicReceiptsRequest request) throws WxPayException; + + /** + * 查询转账明细电子回单受理结果API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_5.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:GET + * 前置条件:只支持查询最近90天内的转账明细单 + * + * @param request 请求对象 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + ElectronicReceiptsResult queryTransferElectronicResult(ElectronicReceiptsRequest request) throws WxPayException; + + /** + * 下载电子回单API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_3.shtml + * 请求URL:通过申请账单接口获取到“download_url”,URL有效期10min + * 请求方式:GET + * 前置条件:调用申请账单接口并获取到“download_url” + * + * @param url 微信返回的电子回单地址。 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + InputStream transferDownload(String url) throws WxPayException; + + /** + *
+   * 查询账户实时余额API
+   * 接口说明
+   * 适用对象:直连商户 服务商
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter5_1.shtml
+   * 请求URL:https://api.mch.weixin.qq.com/v3/merchant/fund/balance/{account_type}
+   * 请求方式:GET
+   * 
+ * + * @param accountType 服务商账户类型 {@link SpAccountTypeEnum} + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + FundBalanceResult fundBalance(SpAccountTypeEnum accountType) throws WxPayException; + + /** + *
+   * 服务商账户日终余额
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter5_2.shtml
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/amount.shtml
+   * 
+ * + * @param accountType 服务商账户类型 + * @param date 查询日期 2020-09-11 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + FundBalanceResult spDayEndBalance(SpAccountTypeEnum accountType, String date); +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayrollService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayrollService.java new file mode 100644 index 0000000000..b3f788815c --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayrollService.java @@ -0,0 +1,104 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.marketing.payroll.*; +import com.github.binarywang.wxpay.bean.result.WxPayApplyBillV3Result; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + * 微工卡-对接微信api + * + * @author xiaoqiang + * created on 2021/12/7 14:26 + */ +public interface PayrollService { + /** + * 生成授权token + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/tokens + * 请求方式:POST + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + TokensResult payrollCardTokens(TokensRequest request) throws WxPayException; + + /** + * 查询微工卡授权关系API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/relations/{openid} + * 请求方式:GET + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + RelationsResult payrollCardRelations(RelationsRequest request) throws WxPayException; + + /** + * 微工卡核身预下单API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order + * 请求方式:POST + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + PreOrderResult payrollCardPreOrder(PreOrderRequest request) throws WxPayException; + + /** + * 获取核身结果API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/{authenticate_number} + * 请求方式:GET + * + * @param subMchid 子商户号 + * @param authenticateNumber 商家核身单号 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + AuthenticationsResult payrollCardAuthenticationsNumber(String subMchid, String authenticateNumber) throws WxPayException; + + /** + * 查询核身记录API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications + * 请求方式:GET + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + AuthRecordResult payrollCardAuthentications(AuthRecordRequest request) throws WxPayException; + + /** + * 微工卡核身预下单(流程中完成授权) + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order-with-auth + * 请求方式:POST + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + PreOrderWithAuthResult payrollCardPreOrderWithAuth(PreOrderWithAuthRequest request) throws WxPayException; + + /** + * 按日下载提现异常文件API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/merchant/fund/withdraw/bill-type/{bill_type} + * 请求方式:GET + * + * @param billType 账单类型 + * NO_SUCC:提现异常账单,包括提现失败和提现退票账单。 + * 示例值:NO_SUCC + * @param billDate 账单日期 表示所在日期的提现账单,格式为YYYY-MM-DD。 + * 例如:2008-01-01日发起的提现,2008-01-03日银行返回提现失败,则该提现数据将出现在bill_date为2008-01-03日的账单中。 + * 示例值:2019-08-17 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + WxPayApplyBillV3Result merchantFundWithdrawBillType(String billType, String billDate, String tarType) throws WxPayException; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java index df21cfdabf..64e887282d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java @@ -1,6 +1,10 @@ package com.github.binarywang.wxpay.service; -import com.github.binarywang.wxpay.bean.profitsharing.*; +import com.github.binarywang.wxpay.bean.notify.SignatureHeader; +import com.github.binarywang.wxpay.bean.profitsharing.notify.ProfitSharingNotifyV3Response; +import com.github.binarywang.wxpay.bean.profitsharing.notify.ProfitSharingNotifyV3Result; +import com.github.binarywang.wxpay.bean.profitsharing.request.*; +import com.github.binarywang.wxpay.bean.profitsharing.result.*; import com.github.binarywang.wxpay.exception.WxPayException; /** @@ -41,6 +45,26 @@ public interface ProfitSharingService { */ ProfitSharingResult multiProfitSharing(ProfitSharingRequest request) throws WxPayException; + /** + *
+   * 请求分账API
+   *
+   * 微信订单支付成功后,商户发起分账请求,将结算后的资金分到分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_1.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders
+   *
+   * 注意:
+   * 对同一笔订单最多能发起20次分账请求,每次请求最多分给50个接收方
+   * 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
+   * 
+ * + * @param request {@link ProfitSharingV3Request} 针对某一笔支付订单的分账方法 + * @return {@link ProfitSharingV3Result} 微信返回的分账结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingV3Result profitSharingV3(ProfitSharingV3Request request) throws WxPayException; + /** *
    * 1、不需要进行分账的订单,可直接调用本接口将订单的金额全部解冻给特约商户
@@ -55,7 +79,7 @@ public interface ProfitSharingService {
    * @return .
    * @throws WxPayException the wx pay exception
    */
-  ProfitSharingResult profitSharingFinish(ProfitSharingFinishRequest request) throws WxPayException;
+  ProfitSharingResult profitSharingFinish(ProfitSharingUnfreezeRequest request) throws WxPayException;
 
   /**
    * 
@@ -83,6 +107,38 @@ public interface ProfitSharingService {
    */
   ProfitSharingReceiverResult removeReceiver(ProfitSharingReceiverRequest request) throws WxPayException;
 
+  /**
+   * 
+   * 添加分账接收方API
+   *
+   * 商户发起添加分账接收方请求,建立分账接收方列表。后续可通过发起分账请求,将分账方商户结算后的资金,分到该分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_8.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add
+   * 
+ * + * @param request 分账接收方实体 {@link ProfitSharingReceiverV3Request} + * @return {@link ProfitSharingReceiverV3Result} 微信返回的分账接收方结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReceiverV3Result addReceiverV3(ProfitSharingReceiverV3Request request) throws WxPayException; + + /** + *
+   * 删除分账接收方API
+   *
+   * 商户发起删除分账接收方请求。删除后,不支持将分账方商户结算后的资金,分到该分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_9.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/delete
+   * 
+ * + * @param request 分账接收方实体 {@link ProfitSharingReceiverV3Request} + * @return {@link ProfitSharingReceiverV3Result} 微信返回的删除的分账接收方结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReceiverV3Result removeReceiverV3(ProfitSharingReceiverV3Request request) throws WxPayException; + /** * TODO:微信返回签名失败 *
@@ -96,6 +152,66 @@ public interface ProfitSharingService {
    */
   ProfitSharingQueryResult profitSharingQuery(ProfitSharingQueryRequest request) throws WxPayException;
 
+  /**
+   * 
+   * 查询分账结果API(商户平台)
+   *
+   * 发起分账请求后,可调用此接口查询分账结果
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/orders/{out_order_no}
+   *
+   * 注意:
+   * • 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果
+   * 
+ * + * @param outOrderNo 商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@ 。 + * @param transactionId 微信支付订单号 + * @return {@link ProfitSharingV3Result} 微信返回的分账结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingV3Result profitSharingQueryV3(String outOrderNo, String transactionId) throws WxPayException; + + /** + *
+   * 查询分账结果API(服务商平台)
+   *
+   * 发起分账请求后,可调用此接口查询分账结果
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_2.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/orders/{out_order_no}
+   *
+   * 注意:
+   * • 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果
+   * 
+ * + * @param outOrderNo 商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@ 。 + * @param transactionId 微信支付订单号 + * @param subMchId 微信支付分配的子商户号,即分账的出资商户号。 + * @return {@link ProfitSharingV3Result} 微信返回的分账结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingV3Result profitSharingQueryV3(String outOrderNo, String transactionId, String subMchId) throws WxPayException; + + /** + *
+   * 请求分账查询API
+   *
+   * 发起分账请求后,可调用此接口查询分账结果
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders/{out_order_no}
+   *
+   * 注意:
+   * 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果
+   * 
+ * + * @param request {@link ProfitSharingQueryV3Request} 针对某一笔分账订单的分账方法 + * @return {@link ProfitSharingV3Result} 微信返回的分账查询结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingV3Result profitSharingQueryV3(ProfitSharingQueryV3Request request) throws WxPayException; + /** *
    * 服务商可通过调用此接口查询订单剩余待分金额。
@@ -110,6 +226,22 @@ public interface ProfitSharingService {
    */
   ProfitSharingOrderAmountQueryResult profitSharingOrderAmountQuery(ProfitSharingOrderAmountQueryRequest request) throws WxPayException;
 
+  /**
+   * 
+   * 查询剩余待分金额API
+   *
+   * 可调用此接口查询订单剩余待分金额
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_6.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/transactions/{transaction_id}/amounts
+   * 
+ * + * @param transactionId 微信订单号,微信支付订单号 + * @return {@link ProfitSharingOrderAmountQueryV3Result} 微信返回的订单剩余待分金额结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingOrderAmountQueryV3Result profitSharingUnsplitAmountQueryV3(String transactionId) throws WxPayException; + /** *
    * 服务商可以查询子商户设置的允许服务商分账的最大比例。
@@ -124,6 +256,24 @@ public interface ProfitSharingService {
    */
   ProfitSharingMerchantRatioQueryResult profitSharingMerchantRatioQuery(ProfitSharingMerchantRatioQueryRequest request) throws WxPayException;
 
+  /**
+   * 
+   * 查询最大分账比例
+   *
+   * 可调用此接口查询特约商户设置的允许服务商分账的最大比例
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_7.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/merchant-configs/{sub_mchid}
+   * 
+ * + * @param subMchId 子商户号(微信支付分配的子商户号,即分账的出资商户号) + * @return {@link ProfitSharingMerchantRatioQueryV3Result} 特约商户设置的允许服务商分账的最大比例结果 + * @throws WxPayException the wx pay exception + * @see 服务商平台>>API字典>>资金应用>>分账>>查询最大分账比例 + * @since 4.4.0 + * @date 2022-12-09 + */ + ProfitSharingMerchantRatioQueryV3Result profitSharingMerchantRatioQueryV3(String subMchId) throws WxPayException; + /** * TODO:这个接口用真实的数据返回【参数不正确】,我对比官方文档除了缺少sub_mch_id,和sub_appid之外其他相同,当我随便填了一个商户id的时候,提示【回退方没有开通分账回退功能】 *
@@ -142,6 +292,29 @@ public interface ProfitSharingService {
    */
   ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest returnRequest) throws WxPayException;
 
+  /**
+   * 
+   * 请求分账回退API
+   *
+   * 如果订单已经分账,在退款时,可以先调此接口,将已分账的资金从分账接收方的账户回退给分账方,再发起退款
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_3.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/return-orders
+   *
+   * 注意:
+   * • 分账回退以原分账单为依据,支持多次回退,申请回退总金额不能超过原分账单分给该接收方的金额
+   * • 此接口采用同步处理模式,即在接收到商户请求后,会实时返回处理结果
+   * • 对同一笔分账单最多能发起20次分账回退请求
+   * • 退款和分账回退没有耦合,分账回退可以先于退款请求,也可以后于退款请求
+   * • 此功能需要接收方在商户平台-交易中心-分账-分账接收设置下,开启同意分账回退后,才能使用
+   * 
+ * + * @param request {@link ProfitSharingReturnV3Request} 针对某一笔支付订单的分账方法 + * @return {@link ProfitSharingReturnV3Result} 微信返回的分账回退结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReturnV3Result profitSharingReturnV3(ProfitSharingReturnV3Request request) throws WxPayException; + /** * TODO:因profitsharingReturn接口无法使用,没有办法对这里进行真实的测试,模拟数据这里返回【记录不存在】 *
@@ -156,7 +329,101 @@ public interface ProfitSharingService {
    * @return .
    * @throws WxPayException .
    */
-  ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest)
-    throws WxPayException;
+  ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest) throws WxPayException;
 
+  /**
+   * 
+   * 查询分账回退结果API(商户平台)
+   *
+   * 商户需要核实回退结果,可调用此接口查询回退结果
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_4.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/return-orders/{out_return_no}
+   *
+   * 注意:
+   * • 如果分账回退接口返回状态为处理中,可调用此接口查询回退结果
+   * 
+ * + * @param outOrderNo 原发起分账请求时使用的商户系统内部的分账单号 + * @param outReturnNo 调用回退接口提供的商户系统内部的回退单号 + * @return {@link ProfitSharingReturnV3Result} 微信返回的分账回退结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReturnV3Result profitSharingReturnQueryV3(String outOrderNo, String outReturnNo) throws WxPayException; + + /** + *
+   * 查询分账回退结果API(服务商平台)
+   *
+   * 商户需要核实回退结果,可调用此接口查询回退结果
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_3.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/return-orders/{out_return_no}
+   *
+   * 注意:
+   * • 如果分账回退接口返回状态为处理中,可调用此接口查询回退结果
+   * 
+ * + * @param outOrderNo 原发起分账请求时使用的商户系统内部的分账单号 + * @param outReturnNo 调用回退接口提供的商户系统内部的回退单号 + * @param subMchId 微信支付分配的子商户号,即分账的回退方商户号。 + * @return {@link ProfitSharingReturnV3Result} 微信返回的分账回退结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReturnV3Result profitSharingReturnQueryV3(String outOrderNo, String outReturnNo, String subMchId) throws WxPayException; + + /** + *
+   * 解冻剩余资金API
+   *
+   * 不需要进行分账的订单,可直接调用本接口将订单的金额全部解冻给特约商户
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_5.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders/unfreeze
+   *
+   * 注意:
+   * • 调用分账接口后,需要解冻剩余资金时,调用本接口将剩余的分账金额全部解冻给特约商户
+   * • 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
+   * 
+ * + * @param request 解冻剩余资金请求实体 {@link ProfitSharingUnfreezeV3Request} + * @return {@link ProfitSharingReturnV3Result} 微信返回的解冻剩余资金结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingUnfreezeV3Result profitSharingUnfreeze(ProfitSharingUnfreezeV3Request request) throws WxPayException; + + /** + *
+   * 分账动账通知
+   *
+   * 分账或分账回退成功后,微信会把相关变动结果发送给分账接收方(只支持商户)。
+   * 对后台通知交互时,如果微信收到应答不是成功或超时,微信认为通知失败,微信会通过一定的策略定期重新发起通知,尽可能提高通知的成功率,但微信不保证通知最终能成功。
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml
+   * 
+ * + * @param notifyData 分账通知实体 + * @param header 分账通知头 {@link SignatureHeader} + * @return {@link ProfitSharingNotifyV3Response} 资源对象 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingNotifyV3Result parseProfitSharingNotifyResult(String notifyData, SignatureHeader header) throws WxPayException; + + /** + *
+   * 申请分账账单
+   *
+   * 微信支付按天提供分账账单文件,商户可以通过该接口获取账单文件的下载地址
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_11.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/bills
+   * 
+ * + * @param request 申请分账账单请求实体({@link ProfitSharingBillV3Request}) + * @return {@link ProfitSharingBillV3Result} 申请分账账单结果类 + * @throws WxPayException the wx pay exception + * @see 服务商平台>>API字典>>资金应用>>分账>>申请分账账单API + * @since 4.4.0 + * @date 2022-12-09 + */ + ProfitSharingBillV3Result profitSharingBill(ProfitSharingBillV3Request request) throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java deleted file mode 100644 index fcb87063a9..0000000000 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.github.binarywang.wxpay.service; - -import com.github.binarywang.wxpay.bean.profitsharingV3.*; -import com.github.binarywang.wxpay.exception.WxPayException; - -/** - * 微信支付V3-资金应用-分账 - * - * @author pg 2021-6-23 - * @date 2021-6-23 - */ -public interface ProfitSharingV3Service { - /** - *
-   * 请求分账API
-   *
-   * 微信订单支付成功后,商户发起分账请求,将结算后的资金分到分账接收方
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_1.shtml
-   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders
-   *
-   * 注意:
-   * 对同一笔订单最多能发起20次分账请求,每次请求最多分给50个接收方
-   * 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
-   * 
- * - * @param request {@link ProfitSharingRequest} 针对某一笔支付订单的分账方法 - * @return {@link ProfitSharingResult} 微信返回的分账结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException; - - /** - *
-   * 查询分账结果API
-   *
-   * 发起分账请求后,可调用此接口查询分账结果
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml
-   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/orders/{out_order_no}
-   *
-   * 注意:
-   * • 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果
-   * 
- * - * @param outOrderNo 商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@ 。 - * @param transactionId 微信支付订单号 - * @return {@link ProfitSharingResult} 微信返回的分账结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException; - - /** - *
-   * 请求分账回退API
-   *
-   * 如果订单已经分账,在退款时,可以先调此接口,将已分账的资金从分账接收方的账户回退给分账方,再发起退款
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_3.shtml
-   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/return-orders
-   *
-   * 注意:
-   * • 分账回退以原分账单为依据,支持多次回退,申请回退总金额不能超过原分账单分给该接收方的金额
-   * • 此接口采用同步处理模式,即在接收到商户请求后,会实时返回处理结果
-   * • 对同一笔分账单最多能发起20次分账回退请求
-   * • 退款和分账回退没有耦合,分账回退可以先于退款请求,也可以后于退款请求
-   * • 此功能需要接收方在商户平台-交易中心-分账-分账接收设置下,开启同意分账回退后,才能使用
-   * 
- * - * @param request {@link ProfitSharingReturnRequest} 针对某一笔支付订单的分账方法 - * @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest request) throws WxPayException; - - /** - *
-   * 查询分账回退结果API
-   *
-   * 商户需要核实回退结果,可调用此接口查询回退结果
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_4.shtml
-   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/return-orders/{out_return_no}
-   *
-   * 注意:
-   * • 如果分账回退接口返回状态为处理中,可调用此接口查询回退结果
-   * 
- * - * @param outOrderNo 原发起分账请求时使用的商户系统内部的分账单号 - * @param outReturnNo 调用回退接口提供的商户系统内部的回退单号 - * @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException; - - /** - *
-   * 解冻剩余资金API
-   *
-   * 不需要进行分账的订单,可直接调用本接口将订单的金额全部解冻给特约商户
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_5.shtml
-   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders/unfreeze
-   *
-   * 注意:
-   * • 调用分账接口后,需要解冻剩余资金时,调用本接口将剩余的分账金额全部解冻给特约商户
-   * • 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
-   * 
- * - * @param request 解冻剩余资金请求实体 {@link ProfitSharingUnfreezeRequest} - * @return {@link ProfitSharingReturnResult} 微信返回的解冻剩余资金结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingUnfreezeResult profitSharingUnfreeze(ProfitSharingUnfreezeRequest request) throws WxPayException; - - /** - *
-   * 查询剩余待分金额API
-   *
-   * 可调用此接口查询订单剩余待分金额
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_6.shtml
-   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/transactions/{transaction_id}/amounts
-   * 
- * - * @param transactionId 微信订单号,微信支付订单号 - * @return {@link ProfitSharingUnsplitResult} 微信返回的订单剩余待分金额结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingUnsplitResult getProfitSharingUnsplitAmount(String transactionId) throws WxPayException; - - /** - *
-   * 添加分账接收方API
-   *
-   * 商户发起添加分账接收方请求,建立分账接收方列表。后续可通过发起分账请求,将分账方商户结算后的资金,分到该分账接收方
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_8.shtml
-   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add
-   * 
- * - * @param receiver 分账接收方实体 {@link ProfitSharingReceiver} - * @return {@link ProfitSharingReceiver} 微信返回的分账接收方结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingReceiver addProfitSharingReceiver(ProfitSharingReceiver receiver) throws WxPayException; - - /** - *
-   * 删除分账接收方API
-   *
-   * 商户发起删除分账接收方请求。删除后,不支持将分账方商户结算后的资金,分到该分账接收方
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_9.shtml
-   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/delete
-   * 
- * - * @param receiver 分账接收方实体 {@link ProfitSharingReceiver} - * @return {@link ProfitSharingReceiver} 微信返回的删除的分账接收方结果 - * @throws WxPayException the wx pay exception - * @see 微信文档 - */ - ProfitSharingReceiver deleteProfitSharingReceiver(ProfitSharingReceiver receiver) throws WxPayException; - -} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RedpackService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RedpackService.java index 131205d07a..cf1adf1f21 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RedpackService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RedpackService.java @@ -12,7 +12,7 @@ * 红包相关接口. * * @author Binary Wang - * @date 2019-12-26 + * created on 2019-12-26 */ public interface RedpackService { /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/TransferService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/TransferService.java new file mode 100644 index 0000000000..8f29f7dce9 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/TransferService.java @@ -0,0 +1,102 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.transfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + * 商家转账到零钱 + * + * @author zhongjun + * created on 2022/6/17 + **/ +public interface TransferService { + + /** + *
+   *
+   * 发起商家转账API
+   *
+   * 请求方式:POST(HTTPS)
+   * 请求地址:请求地址
+   *
+   * 文档地址:发起商家转账API
+   * 
+ * + * @param request 转账请求参数 + * @return TransferBatchesResult 转账结果 + * @throws WxPayException . + */ + TransferBatchesResult transferBatches(TransferBatchesRequest request) throws WxPayException; + + /** + *
+   *
+   * 微信批次单号查询批次单API
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:请求地址
+   *
+   * 文档地址:微信批次单号查询批次单API
+   * 
+ * + * @param request 查询请求参数 + * @return TransferBatchesResult 查询结果 + * @throws WxPayException . + */ + QueryTransferBatchesResult transferBatchesBatchId(QueryTransferBatchesRequest request) throws WxPayException; + + /** + *
+   *
+   * 微信明细单号查询明细单API
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:请求地址
+   *
+   * 文档地址:微信明细单号查询明细单API
+   * 
+ * + * @param batchId 微信批次单号 + * @param detailId 微信明细单号 + * @return TransferBatchDetailResult 查询结果 + * @throws WxPayException . + */ + TransferBatchDetailResult transferBatchesBatchIdDetail(String batchId, String detailId) throws WxPayException; + + /** + *
+   *
+   * 商家批次单号查询批次单API
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:请求地址
+   *
+   * 文档地址:商家批次单号查询批次单API
+   * 
+ * + * @param request 查询请求参数 + * @return TransferBatchesResult 查询结果 + * @throws WxPayException . + * @throws WxPayException . + */ + QueryTransferBatchesResult transferBatchesOutBatchNo(QueryTransferBatchesRequest request) throws WxPayException; + + /** + *
+   *
+   * 商家明细单号查询明细单API
+   *
+   * 请求方式:GET(HTTPS)
+   * 请求地址:请求地址
+   *
+   * 文档地址:商家明细单号查询明细单API
+   * 
+ * + * @param outBatchNo 商家明细单号 + * @param outDetailNo 商家批次单号 + * @return TransferBatchDetailResult 查询结果 + * @throws WxPayException . + */ + TransferBatchDetailResult transferBatchesOutBatchNoDetail(String outBatchNo, String outDetailNo) throws WxPayException; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java index be76b34c47..168e43696a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java @@ -7,69 +7,64 @@ /** *
  *   微信签约代扣相关接口.
- *   https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter2_8.shtml
+ *   https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter2_8.shtml
  *  
* * @author chenliang - * @date 2021-08-02 4:50 下午 + * created on 2021 -08-02 4:50 下午 */ public interface WxEntrustPapService { /** - * *
    *   获取公众号纯签约链接,
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_1.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_1.shtml
    *   该接口返回一个签约链接,该链接只能在微信内打开
    * 
* - * @param wxMpEntrustRequest - * @return - * @throws WxPayException + * @param wxMpEntrustRequest the wx mp entrust request + * @return string + * @throws WxPayException the wx pay exception */ String mpSign(WxMpEntrustRequest wxMpEntrustRequest) throws WxPayException; /** - * *
    *   获取小程序纯签约参数json
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_3.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_3.shtml
    *   返回一个json 前端用来拉起一个新的签约小程序进行签约
    * 
* - * - * @param wxMaEntrustRequest - * @return - * @throws WxPayException + * @param wxMaEntrustRequest the wx ma entrust request + * @return string + * @throws WxPayException the wx pay exception */ String maSign(WxMaEntrustRequest wxMaEntrustRequest) throws WxPayException; /** - * *
    *   获取h5纯签约支付跳转链接
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_4.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_4.shtml
    *   返回一个签约链接  在浏览器请求链接拉起微信
    * 
* - * @param wxH5EntrustRequest - * @return - * @throws WxPayException + * @param wxH5EntrustRequest the wx h 5 entrust request + * @return wx h 5 entrust result + * @throws WxPayException the wx pay exception */ WxH5EntrustResult h5Sign(WxH5EntrustRequest wxH5EntrustRequest) throws WxPayException; /** - * *
    *   支付中签约
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_5.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_5.shtml
    *   请求微信 若微信内请求 需要构造json返回,
    *   若h5请求 直接使用mweb_url 链接即可拉起微信
    * 
* - * @param wxPayEntrustRequest - * @return - * @throws WxPayException + * @param wxPayEntrustRequest the wx pay entrust request + * @return wx pay entrust result + * @throws WxPayException the wx pay exception */ WxPayEntrustResult paySign(WxPayEntrustRequest wxPayEntrustRequest) throws WxPayException; @@ -77,7 +72,7 @@ public interface WxEntrustPapService { * 申请扣款 *
    *   申请扣款
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_8.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_8.shtml
    *   请求微信发起委托扣款,扣款额度和次数由使用的签约模板限制,
    *   该扣款接口是立即扣款 无延时 扣款前无消息通知。
    *
@@ -85,26 +80,44 @@ public interface WxEntrustPapService {
    *   从用户签约成功时间开始算,商户在12小时内发起的扣款,会被立即执行,无延迟。商户超过12小时以后发起的扣款,都按24小时扣费规则执行
    * 
* - * @param wxWithholdRequest - * @return - * @throws WxPayException + * @param wxWithholdRequest the wx withhold request + * @return wx withhold result + * @throws WxPayException the wx pay exception */ WxWithholdResult withhold(WxWithholdRequest wxWithholdRequest) throws WxPayException; + /** + * 服务商模式的申请扣款 + *
+   *   申请扣款
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter5_8.shtml
+   *   请求微信发起委托扣款,扣款额度和次数由使用的签约模板限制,
+   *   该扣款接口是立即扣款 无延时 扣款前无消息通知。
+   *
+   *   • 特殊情况:周期扣费为通知后24小时扣费方式情况下,如果用户为首次签约(包含解约后重新签约),
+   *   从用户签约成功时间开始算,商户在12小时内发起的扣款,会被立即执行,无延迟。商户超过12小时以后发起的扣款,都按24小时扣费规则执行
+   * 
+ * + * @param wxWithholdRequest the wx withhold request + * @return wx withhold result + * @throws WxPayException the wx pay exception + */ + WxPayCommonResult withholdPartner(WxWithholdRequest wxWithholdRequest) throws WxPayException; + /** * 预扣费通知 *
    *   预扣费接口
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_10.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_10.shtml
    *   商户进行委托代扣扣费前需要在可通知时间段内调用「预扣费通知」的接口为用户发送扣费提醒,
    *   并设定扣费持续天数和预计扣费金额,经过扣费等待期后,在可扣费期内可发起扣费,扣款金额不能高于预计扣费金额,
    *   扣费失败可主动发起重试扣费(重试次数由其他规则限制),直到扣费成功,或者可扣费期结束。
    *   商户只能在北京时间每天 6:00~22:00调用「预扣费通知」
    * 
* - * @param wxPreWithholdRequest - * @return - * @throws WxPayException + * @param wxPreWithholdRequest the wx pre withhold request + * @return string + * @throws WxPayException the wx pay exception */ String preWithhold(WxPreWithholdRequest wxPreWithholdRequest) throws WxPayException; @@ -112,13 +125,13 @@ public interface WxEntrustPapService { * 签约状态查询 *
    *   签约状态查询
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_7.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_7.shtml
    *   查询签约关系接口提供单笔签约关系查询。
    * 
* - * @param wxSignQueryRequest - * @return - * @throws WxPayException + * @param wxSignQueryRequest the wx sign query request + * @return wx sign query result + * @throws WxPayException the wx pay exception */ WxSignQueryResult querySign(WxSignQueryRequest wxSignQueryRequest) throws WxPayException; @@ -127,31 +140,30 @@ public interface WxEntrustPapService { * 申请解约 *
    *   申请解约
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_9.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_9.shtml
    *   商户与用户的签约关系有误或者商户主动要求与用户解除之前的签约协议时可调用此接口完成解约。
    *   商户可以在商户后台(pay.weixin.qq.com)设置解约回调地址,当发生解约关系的时候,微信服务器会向此地址通知解约信息,内容与签约返回一致
    * 
* - * @param wxTerminatedContractRequest - * @return - * @throws WxPayException + * @param wxTerminatedContractRequest the wx terminated contract request + * @return wx termination contract result + * @throws WxPayException the wx pay exception */ WxTerminationContractResult terminationContract(WxTerminatedContractRequest wxTerminatedContractRequest) throws WxPayException; /** - * *
    *   查询代扣订单
-   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter4_5.shtml
+   *   详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter4_5.shtml
    *   该接口仅提供微信扣款服务申请扣款接口创建的订单进行查询,商户可以通过该接口主动查询微信代扣订单状态,完成下一步的业务逻辑。
    *   ACCEPT等待扣款:为24小时延时扣费场景下独有的,当没有达到24小时前一直是这种状态;
    *   NOTPAY未支付:系统已经启动扣款流程,这个状态只是瞬间状态,很快会进入终态(SUCCESS、PAY_FAIL)
    *
    * 
* - * @param wxWithholdOrderQueryRequest - * @return - * @throws WxPayException + * @param wxWithholdOrderQueryRequest the wx withhold order query request + * @return wx withhold order query result + * @throws WxPayException the wx pay exception */ WxWithholdOrderQueryResult papOrderQuery(WxWithholdOrderQueryRequest wxWithholdOrderQueryRequest) 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 9b42bd75be..9aba25d049 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 @@ -35,17 +35,17 @@ public interface WxPayService { String getPayBaseUrl(); /** - * Map里 加入新的 {@link WxPayConfig},适用于动态添加新的微信公众号配置. + * Map里 加入新的 {@link WxPayConfig},适用于动态添加新的微信商户配置. * - * @param mchId 商户号id + * @param mchId 商户id * @param wxPayConfig 新的微信配置 */ void addConfig(String mchId, WxPayConfig wxPayConfig); /** - * 从 Map中 移除 {@link String mchId} 所对应的 {@link WxPayConfig},适用于动态移除微信公众号配置. + * 从 Map中 移除 {@link String mchId} 所对应的 {@link WxPayConfig},适用于动态移除微信商户配置. * - * @param mchId 对应公众号的标识 + * @param mchId 对应商户的标识 */ void removeConfig(String mchId); @@ -66,17 +66,17 @@ public interface WxPayService { void setMultiConfig(Map wxPayConfigs, String defaultMchId); /** - * 进行相应的公众号切换. + * 进行相应的商户切换. * - * @param mchId 公众号标识 + * @param mchId 商户标识 * @return 切换是否成功 boolean */ boolean switchover(String mchId); /** - * 进行相应的公众号切换. + * 进行相应的商户切换. * - * @param mchId 公众号标识 + * @param mchId 商户标识 * @return 切换成功 ,则返回当前对象,方便链式调用,否则抛出异常 */ WxPayService switchoverTo(String mchId); @@ -164,6 +164,17 @@ public interface WxPayService { */ String getV3(String url) throws WxPayException; + /** + * 发送get请求,得到响应字符串. + *

+ * 部分字段会包含敏感信息,所以在提交前需要在请求头中会包含"Wechatpay-Serial"信息 + * + * @param url 请求地址 + * @return 返回请求结果字符串 string + * @throws WxPayException the wx pay exception + */ + String getV3WithWechatPaySerial(String url) throws WxPayException; + /** * 发送下载 V3请求,得到响应流. * @@ -173,12 +184,46 @@ public interface WxPayService { */ InputStream downloadV3(String url) throws WxPayException; + /** + * 发送put V3请求,得到响应字符串. + * + * @param url 请求地址 + * @param requestStr 请求数据 + * @return 返回请求结果字符串 string + * @throws WxPayException the wx pay exception + */ + String putV3(String url, String requestStr) throws WxPayException; + + /** + * 发送delete V3请求,得到响应字符串. + * + * @param url 请求地址 + * @return 返回请求结果字符串 string + * @throws WxPayException the wx pay exception + */ + String deleteV3(String url) throws WxPayException; + /** * 获取微信签约代扣服务类 + * * @return entrust service */ WxEntrustPapService getWxEntrustPapService(); + /** + * 获取批量转账到零钱服务类. + * + * @return the Batch transfer to change service + */ + PartnerTransferService getPartnerTransferService(); + + /** + * 微工卡 + * + * @return the micro card + */ + PayrollService getPayrollService(); + /** * 获取企业付款服务类. * @@ -196,20 +241,13 @@ public interface WxPayService { /** * 获取分账服务类. *

- * V3接口 {@link WxPayService#getProfitSharingV3Service()} + * V3接口 {@link WxPayService#getProfitSharingService()} *

* * @return the ent pay service */ ProfitSharingService getProfitSharingService(); - /** - * 获取V3分账服务类. - * - * @return the ent pay service - */ - ProfitSharingV3Service getProfitSharingV3Service(); - /** * 获取支付分服务类. * @@ -259,6 +297,20 @@ public interface WxPayService { */ MarketingBusiFavorService getMarketingBusiFavorService(); + /** + * 获取商家转账到零钱服务类 + * + * @return the merchant transfer service + */ + MerchantTransferService getMerchantTransferService(); + + /** + * 获取品牌红包商家转账到零钱服务类 + * + * @return the brand merchant transfer service + */ + BrandMerchantTransferService getBrandMerchantTransferService(); + /** * 设置企业付款服务类,允许开发者自定义实现类. * @@ -308,7 +360,7 @@ public interface WxPayService { /** *
    * 查询订单
-   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml
+   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml
    * 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
    * 注意:
    *  查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
@@ -332,7 +384,7 @@ public interface WxPayService {
   /**
    * 
    * 查询订单
-   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml
+   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml
    * 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
    * 注意:
    *  查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
@@ -352,15 +404,62 @@ public interface WxPayService {
    */
   WxPayOrderQueryV3Result queryOrderV3(WxPayOrderQueryV3Request request) throws WxPayException;
 
+  /**
+   * 
+   * 服务商模式查询订单
+   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml
+   * 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
+   * 注意:
+   *  查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
+   * 需要调用查询接口的情况:
+   * ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知。
+   * ◆ 调用支付接口后,返回系统错误或未知交易状态情况。
+   * ◆ 调用付款码支付API,返回USERPAYING的状态。
+   * ◆ 调用关单或撤销接口API之前,需确认支付状态。
+   * 接口地址:
+   *  https://api.mch.weixin.qq.com/v3/pay/partner/transactions/id/{transaction_id}
+   *  https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/{out_trade_no}
+   * 
+ * + * @param transactionId 微信订单号 + * @param outTradeNo 商户系统内部的订单号,当没提供transactionId时需要传这个。 + * @return the wx pay order query result + * @throws WxPayException the wx pay exception + */ + WxPayPartnerOrderQueryV3Result queryPartnerOrderV3(String transactionId, String outTradeNo) throws WxPayException; + + /** + *
+   * 服务商模式查询订单
+   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml
+   * 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
+   * 注意:
+   *  查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
+   * 需要调用查询接口的情况:
+   * ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知。
+   * ◆ 调用支付接口后,返回系统错误或未知交易状态情况。
+   * ◆ 调用付款码支付API,返回USERPAYING的状态。
+   * ◆ 调用关单或撤销接口API之前,需确认支付状态。
+   * 接口地址:
+   *  https://api.mch.weixin.qq.com/v3/pay/partner/transactions/id/{transaction_id}
+   *  https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/{out_trade_no}
+   * 
+ * + * @param request 查询订单请求对象 + * @return the wx pay order query result + * @throws WxPayException the wx pay exception + */ + WxPayPartnerOrderQueryV3Result queryPartnerOrderV3(WxPayPartnerOrderQueryV3Request request) throws WxPayException; + /** *
    * 合单查询订单API
    * 请求URL: https://api.mch.weixin.qq.com/v3/combine-transactions/out-trade-no/{combine_out_trade_no}
-   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_11.shtml
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_11.shtml
    * 
* * @param combineOutTradeNo 合单商户订单号 - * @return 合单支付订单信息 + * @return 合单支付订单信息 combine query result * @throws WxPayException the wx pay exception */ CombineQueryResult queryCombine(String combineOutTradeNo) throws WxPayException; @@ -418,6 +517,23 @@ public interface WxPayService { */ void closeOrderV3(String outTradeNo) throws WxPayException; + /** + *
+   * 服务商关闭订单
+   * 应用场景
+   * 以下情况需要调用关单接口:
+   * 1、商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
+   * 2、系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
+   * 注意:关单没有时间限制,建议在订单生成后间隔几分钟(最短5分钟)再调用关单接口,避免出现订单状态同步不及时导致关单失败。
+   * 接口地址:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_3.shtml
+   * 
+ * + * @param outTradeNo 商户系统内部的订单号 + * @return the wx pay order close result + * @throws WxPayException the wx pay exception + */ + void closePartnerOrderV3(String outTradeNo) throws WxPayException; + /** *
    * 关闭订单
@@ -435,11 +551,28 @@ public interface WxPayService {
    */
   void closeOrderV3(WxPayOrderCloseV3Request request) throws WxPayException;
 
+  /**
+   * 
+   * 服务商关闭订单
+   * 应用场景
+   * 以下情况需要调用关单接口:
+   * 1、商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
+   * 2、系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
+   * 注意:关单没有时间限制,建议在订单生成后间隔几分钟(最短5分钟)再调用关单接口,避免出现订单状态同步不及时导致关单失败。
+   * 接口地址:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_3.shtml
+   * 
+ * + * @param request 关闭订单请求对象 + * @return the wx pay order close result + * @throws WxPayException the wx pay exception + */ + void closePartnerOrderV3(WxPayPartnerOrderCloseV3Request request) throws WxPayException; + /** *
    * 合单关闭订单API
    * 请求URL: https://api.mch.weixin.qq.com/v3/combine-transactions/out-trade-no/{combine_out_trade_no}/close
-   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_12.shtml
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_12.shtml
    * 
* * @param request 请求对象 @@ -465,7 +598,7 @@ public interface WxPayService { * @param request 统一下单请求参数,设定的 tradeType 及配置里的 tradeType 将被忽略,转而使用 specificTradeType * @return 返回 {@link WxPayConstants.TradeType.Specific} 指定的类 * @throws WxPayException the wx pay exception - * @see WxPayService#createOrder(WxPayUnifiedOrderRequest) WxPayService#createOrder(WxPayUnifiedOrderRequest) + * @see WxPayService#createOrder(WxPayUnifiedOrderRequest) WxPayService#createOrder(WxPayUnifiedOrderRequest)WxPayService#createOrder(WxPayUnifiedOrderRequest) */ T createOrder(WxPayConstants.TradeType.Specific specificTradeType, WxPayUnifiedOrderRequest request) throws WxPayException; @@ -483,17 +616,40 @@ public interface WxPayService { /** * 调用统一下单接口,并组装生成支付所需参数对象. * - * @param 请使用{@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段 - * @param request 统一下单请求参数 + * @param 请使用{@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段 + * @param tradeType the trade type + * @param request 统一下单请求参数 * @return 返回 {@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段 * @throws WxPayException the wx pay exception */ T createOrderV3(TradeTypeEnum tradeType, WxPayUnifiedOrderV3Request request) throws WxPayException; + /** + * 服务商模式调用统一下单接口,并组装生成支付所需参数对象. + * + * @param 请使用{@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段 + * @param tradeType the trade type + * @param request 统一下单请求参数 + * @return 返回 {@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段 + * @throws WxPayException the wx pay exception + */ + T createPartnerOrderV3(TradeTypeEnum tradeType, WxPayPartnerUnifiedOrderV3Request request) throws WxPayException; + /** * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" * - * @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置) + * @param tradeType the trade type + * @param request 请求对象,注意一些参数如spAppid、spMchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置) + * @return the wx pay unified order result + * @throws WxPayException the wx pay exception + */ + WxPayUnifiedOrderV3Result unifiedPartnerOrderV3(TradeTypeEnum tradeType, WxPayPartnerUnifiedOrderV3Request request) throws WxPayException; + + /** + * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" + * + * @param tradeType the trade type + * @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置) * @return the wx pay unified order result * @throws WxPayException the wx pay exception */ @@ -507,7 +663,7 @@ public interface WxPayService { * https://api.mch.weixin.qq.com/v3/combine-transactions/h5 * https://api.mch.weixin.qq.com/v3/combine-transactions/jsapi * https://api.mch.weixin.qq.com/v3/combine-transactions/native - * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml + * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml *
* * @param tradeType 支付方式 @@ -525,9 +681,10 @@ public interface WxPayService { * https://api.mch.weixin.qq.com/v3/combine-transactions/h5 * https://api.mch.weixin.qq.com/v3/combine-transactions/jsapi * https://api.mch.weixin.qq.com/v3/combine-transactions/native - * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml + * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml *
* + * @param the type parameter * @param tradeType 支付方式 * @param request 请求对象 * @return 调起支付需要的参数 t @@ -564,7 +721,7 @@ public interface WxPayService { /** *
    * 微信支付-申请退款.
-   * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
+   * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
    * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/refund
    * 
* @@ -577,7 +734,7 @@ public interface WxPayService { /** *
    * 申请退款API(支持单品).
-   * 详见 https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_103&index=3
+   * 详见 https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_103&index=3
    *
    * 应用场景
    * 当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,按照退款规则将支付款按原路退到买家帐号上。
@@ -604,7 +761,7 @@ public interface WxPayService {
   /**
    * 
    * 申请退款API(支持单品).
-   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml
+   * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml
    *
    * 应用场景
    * 当交易发生之后一年内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付金额退还给买家,微信支付将在收到退款请求并且验证成功之后,将支付款按原路退还至买家账号上。
@@ -634,7 +791,7 @@ public interface WxPayService {
    * 应用场景:
    *  提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,
    *  银行卡支付的退款3个工作日后重新查询退款状态。
-   * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5
+   * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5
    * 接口链接:https://api.mch.weixin.qq.com/pay/refundquery
    * 
* 以下四个参数四选一 @@ -655,7 +812,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 应用场景: * 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账, * 银行卡支付的退款3个工作日后重新查询退款状态。 - * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5 + * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5 * 接口链接:https://api.mch.weixin.qq.com/pay/refundquery *
* @@ -679,7 +836,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 接口地址 * https://api.mch.weixin.qq.com/pay/refundqueryv2 * https://api2.mch.weixin.qq.com/pay/refundqueryv2(备用域名)见跨城冗灾方案 - * 详见 https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_104&index=4 + * 详见 https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_104&index=4 *
* * @param request 微信退款单号 @@ -693,22 +850,22 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 微信支付-查询退款 * 应用场景: * 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,建议在提交退款申请后1分钟发起查询退款状态,一般来说零钱支付的退款5分钟内到账,银行卡支付的退款1-3个工作日到账。 - * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml + * 详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml * 接口链接:https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/{out_refund_no} *
* - * @param outTradeNo 商户订单号 + * @param outRefundNo 商户退款单号 * @return 退款信息 wx pay refund query result * @throws WxPayException the wx pay exception */ - WxPayRefundQueryV3Result refundQueryV3(String outTradeNo) throws WxPayException; + WxPayRefundQueryV3Result refundQueryV3(String outRefundNo) throws WxPayException; /** *
-   * 微信支付-查询退款
+   * 微信支付-查询退款-直连商户
    * 应用场景:
    *  提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,建议在提交退款申请后1分钟发起查询退款状态,一般来说零钱支付的退款5分钟内到账,银行卡支付的退款1-3个工作日到账。
-   *  详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml
+   *  详见 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml
    * 接口链接:https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/{out_refund_no}
    * 
* @@ -718,6 +875,21 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri */ WxPayRefundQueryV3Result refundQueryV3(WxPayRefundQueryV3Request request) throws WxPayException; + /** + *
+   * 微信支付-查询退款-服务商
+   * 应用场景:
+   *  提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,建议在提交退款申请后1分钟发起查询退款状态,一般来说零钱支付的退款5分钟内到账,银行卡支付的退款1-3个工作日到账。
+   *  详见 https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_10.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/{out_refund_no}?sub_mchid={sub_mchid}
+   * 
+ * + * @param request 微信退款单号 + * @return 退款信息 wx pay refund query result + * @throws WxPayException the wx pay exception + */ + WxPayRefundQueryV3Result refundPartnerQueryV3(WxPayRefundQueryV3Request request) throws WxPayException; + /** * 解析支付结果通知. * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 @@ -740,7 +912,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String signType) throws WxPayException; /** - * 解析支付结果v3通知. + * 解析支付结果v3通知. 直连商户模式 * 详见https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml * * @param notifyData 通知数据 @@ -748,12 +920,36 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * @return the wx pay order notify result * @throws WxPayException the wx pay exception */ - WxPayOrderNotifyV3Result parseOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException; + WxPayNotifyV3Result parseOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException; + + /** + * 服务商模式解析支付结果v3通知. + * 详见https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_5.shtml + * + * @param notifyData 通知数据 + * @param header 通知头部数据,不传则表示不校验头 + * @return the wx pay order notify result + * @throws WxPayException the wx pay exception + */ + WxPayPartnerNotifyV3Result parsePartnerOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException; + + /** + * 支付服务商和直连商户两种模式 + * 详见https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml + * + * @param notifyData 通知数据 + * @param header 通知头部数据,不传则表示不校验头 + * @param resultType 结果类型 + * @param dataType 结果数据类型 + * @return the wx pay order notify result + * @throws WxPayException the wx pay exception + */ + , E> T baseParseOrderNotifyV3Result(String notifyData, SignatureHeader header, Class resultType, Class dataType) throws WxPayException; /** *
    * 合单支付通知回调数据处理
-   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_13.shtml
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_13.shtml
    * 
* * @param notifyData 通知数据 @@ -774,7 +970,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws WxPayException; /** - * 解析退款结果通知 + * 解析直连商户退款结果通知 * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=9 * * @param notifyData 通知数据 @@ -784,6 +980,17 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri */ WxPayRefundNotifyV3Result parseRefundNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException; + /** + * 解析服务商模式退款结果通知 + * 详见https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_11.shtml + * + * @param notifyData 通知数据 + * @param header 通知头部数据,不传则表示不校验头 + * @return the wx pay refund notify result + * @throws WxPayException the wx pay exception + */ + WxPayPartnerRefundNotifyV3Result parsePartnerRefundNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException; + /** * 解析扫码支付回调通知 * 详见https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4 @@ -811,7 +1018,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 二维码中的内容为链接,形式为: * weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX * 其中XXXXX为商户需要填写的内容,商户将该链接生成二维码,如需要打印发布二维码,需要采用此格式。商户可调用第三方库生成二维码图片。 - * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4 *
* * @param productId 产品Id @@ -819,7 +1026,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * @param sideLength 要生成的二维码的边长,如果为空,则取默认值400 * @return 生成的二维码的字节数组 byte [ ] */ - byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength); + byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) throws Exception; /** *
@@ -827,7 +1034,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
    * 二维码中的内容为链接,形式为:
    * weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
    * 其中XXXXX为商户需要填写的内容,商户将该链接生成二维码,如需要打印发布二维码,需要采用此格式。商户可调用第三方库生成二维码图片。
-   * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
    * 
* * @param productId 产品Id @@ -840,7 +1047,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 扫码支付模式二生成二维码的方法. * 对应链接格式:weixin://wxpay/bizpayurl?sr=XXXXX。请商户调用第三方库将code_url生成二维码图片。 * 该模式链接较短,生成的二维码打印到结账小票上的识别率较高。 - * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5 *
* * @param codeUrl 微信返回的交易会话的二维码链接 @@ -848,7 +1055,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * @param sideLength 要生成的二维码的边长,如果为空,则取默认值400 * @return 生成的二维码的字节数组 byte [ ] */ - byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength); + byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) throws Exception; /** *
@@ -857,7 +1064,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
    *  商户在调用微信支付提供的相关接口时,会得到微信支付返回的相关信息以及获得整个接口的响应时间。
    *  为提高整体的服务水平,协助商户一起提高服务质量,微信支付提供了相关接口调用耗时和返回信息的主动上报接口,
    *  微信支付可以根据商户侧上报的数据进一步优化网络部署,完善服务监控,和商户更好的协作为用户提供更好的业务体验。
-   * 接口地址: https://api.mch.weixin.qq.com/payitil/report
+   * 接口地址: https://api.mch.weixin.qq.com/payitil/report
    * 是否需要证书:不需要
    * 
* @@ -875,7 +1082,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 2、微信在次日9点启动生成前一天的对账单,建议商户10点后再获取; * 3、对账单中涉及金额的字段单位为“元”。 * 4、对账单接口只能下载三个月以内的账单。 - * 接口链接:https://api.mch.weixin.qq.com/pay/downloadbill + * 接口链接:https://api.mch.weixin.qq.com/pay/downloadbill * 详情请见: 下载对账单 *
* @@ -994,7 +1201,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * • 微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致; * • 对账单中涉及金额的字段单位为“元”; * • 对账单接口只能下载三个月以内的账单。 - * 接口链接:https://api.mch.weixin.qq.com/v3/bill/tradebill + * 接口链接:https://api.mch.weixin.qq.com/v3/bill/tradebill * 详情请见: 申请交易账单 *
* @@ -1011,7 +1218,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 注意: * • 资金账单中的数据反映的是商户微信支付账户资金变动情况; * • 对账单中涉及金额的字段单位为“元”。 - * 接口链接:https://api.mch.weixin.qq.com/v3/bill/fundflowbill + * 接口链接:https://api.mch.weixin.qq.com/v3/bill/fundflowbill * 详情请见: 申请资金账单 *
* @@ -1042,12 +1249,12 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri /** *
    * 提交付款码支付.
-   * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
+   * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
    * 应用场景:
    * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台,由商户收银台或者商户后台调用该接口发起支付。
    * 提醒1:提交支付请求后微信会同步返回支付结果。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);
    * 提醒2:在调用查询接口返回后,如果交易状况不明晰,请调用【撤销订单API】,此时如果交易失败则关闭订单,该单不能再支付成功;如果交易成功,则将扣款退回到用户账户。当撤销无返回或错误时,请再次调用。注意:请勿扣款后立即调用【撤销订单API】,建议至少15秒后再调用。撤销订单API需要双向证书。
-   * 接口地址:   https://api.mch.weixin.qq.com/pay/micropay
+   * 接口地址:   https://api.mch.weixin.qq.com/pay/micropay
    * 是否需要证书:不需要。
    * 
* @@ -1081,10 +1288,10 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri *
    *  转换短链接.
    *  文档地址:
-   *     https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_9&index=8
+   *     https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_9&index=8
    *  应用场景:
    *     该接口主要用于扫码原生支付模式一中的二维码链接转成短链接(weixin://wxpay/s/XXXXXX),减小二维码数据量,提升扫描速度和精确度。
-   *  接口地址:https://api.mch.weixin.qq.com/tools/shorturl
+   *  接口地址:https://api.mch.weixin.qq.com/tools/shorturl
    *  是否需要证书:否
    * 
* @@ -1102,7 +1309,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * @param longUrl 需要被压缩的网址 * @return the string * @throws WxPayException the wx pay exception - * @see WxPayService#shorturl(WxPayShorturlRequest) WxPayService#shorturl(WxPayShorturlRequest)WxPayService#shorturl(WxPayShorturlRequest) + * @see WxPayService#shorturl(WxPayShorturlRequest) WxPayService#shorturl(WxPayShorturlRequest)WxPayService#shorturl(WxPayShorturlRequest)WxPayService#shorturl(WxPayShorturlRequest) */ String shorturl(String longUrl) throws WxPayException; @@ -1111,7 +1318,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 授权码查询OPENID接口. * 通过授权码查询公众号Openid,调用查询后,该授权码只能由此商户号发起扣款,直至授权码更新。 * 文档地址: - * https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9 + * https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9 * 接口链接: * https://api.mch.weixin.qq.com/tools/authcodetoopenid *
@@ -1130,14 +1337,14 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * @param authCode 授权码 * @return openid string * @throws WxPayException the wx pay exception - * @see WxPayService#authcode2Openid(WxPayAuthcode2OpenidRequest) WxPayService#authcode2Openid(WxPayAuthcode2OpenidRequest)WxPayService#authcode2Openid(WxPayAuthcode2OpenidRequest) + * @see WxPayService#authcode2Openid(WxPayAuthcode2OpenidRequest) WxPayService#authcode2Openid(WxPayAuthcode2OpenidRequest)WxPayService#authcode2Openid(WxPayAuthcode2OpenidRequest)WxPayService#authcode2Openid(WxPayAuthcode2OpenidRequest) */ String authcode2Openid(String authCode) throws WxPayException; /** *
    * 获取仿真测试系统的验签密钥.
-   * 请求Url: https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey
+   * 请求Url: https://api.mch.weixin.qq.com/xdc/apiv2getsignkey/sign/getsignkey
    * 是否需要证书: 否
    * 请求方式: POST
    * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_1
@@ -1282,4 +1489,50 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
    * @throws WxPayException .
    */
   WxPayQueryExchangeRateResult queryExchangeRate(String feeType, String date) throws WxPayException;
+
+  /**
+   * 解析投诉通知
+   * 详见https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter10_2_16.shtml
+   *
+   * @param notifyData 通知数据
+   * @param header     通知头部数据,不传则表示不校验头
+   * @return the wx pay refund notify result
+   * @throws WxPayException the wx pay exception
+   */
+  ComplaintNotifyResult parseComplaintNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
+
+  /**
+   * 获取消费者投诉服务类.
+   *
+   * @return the complaints service
+   */
+  ComplaintService getComplaintsService();
+
+
+  /**
+   * 获取银行组件服务
+   *
+   * @return 银行组件服务
+   */
+  BankService getBankService();
+
+  /**
+   * 获取商家转账到零钱服务类.
+   *
+   * @return the transfers service
+   */
+  TransferService getTransferService();
+
+  /**
+   * 获取服务商支付分服务类
+   *
+   * @return the partner pay score service
+   */
+  PartnerPayScoreService getPartnerPayScoreService();
+
+  /**
+   * 获取服务商直股份签约计划服务类
+   * @return  the partner pay score sign plan service
+   */
+  PartnerPayScoreSignPlanService getPartnerPayScoreSignPlanService();
 }
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Apply4SubjectConfirmServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Apply4SubjectConfirmServiceImpl.java
new file mode 100644
index 0000000000..55af095f66
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Apply4SubjectConfirmServiceImpl.java
@@ -0,0 +1,132 @@
+package com.github.binarywang.wxpay.service.impl;
+
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmCreateRequest;
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmCreateResult;
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmMerchantStateQueryResult;
+import com.github.binarywang.wxpay.bean.applyconfirm.ApplySubjectConfirmStateQueryResult;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.Apply4SubjectConfirmService;
+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 lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+
+/**
+ * 
+ * 商户开户意愿确认
+ * 产品文档:商户开户意愿确认流程
+ * 
+ * + * @author Mr.Pan + */ +@Slf4j +@RequiredArgsConstructor +public class Apply4SubjectConfirmServiceImpl implements Apply4SubjectConfirmService { + + private static final Gson GSON = new GsonBuilder().create(); + private final WxPayService payService; + + /** + *
+   * 提交申请单
+   * 详情请见: 间连商户开户意愿确认(提交申请单)
+   * 
+ * + * @param request 申请请求参数 + * @return 审核结果 + * @throws WxPayException 异常 + */ + @Override + public ApplySubjectConfirmCreateResult applyment(ApplySubjectConfirmCreateRequest request) throws WxPayException { + String url = String.format("%s/v3/apply4subject/applyment", this.payService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); + String result = payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(result, ApplySubjectConfirmCreateResult.class); + } + + /** + *
+   * 查询申请单审核结果
+   * 详情请见: 查询申请单审核结果
+   * 
+ * + * @param businessCode 业务申请编号 + * @return 审核结果 + * @throws WxPayException 异常 + */ + @Override + public ApplySubjectConfirmStateQueryResult queryApplyStatusByBusinessCode(String businessCode) throws WxPayException { + String url = String.format("%s/v3/apply4subject/applyment?business_code=%s", this.payService.getPayBaseUrl(), businessCode); + String result = payService.getV3(url); + return GSON.fromJson(result, ApplySubjectConfirmStateQueryResult.class); + } + + /** + *
+   * 查询申请单审核结果
+   * 详情请见: 查询申请单审核结果
+   * 
+ * + * @param applymentId 申请编号 + * @return 审核结果 + * @throws WxPayException 异常 + */ + @Override + public ApplySubjectConfirmStateQueryResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException { + String url = String.format("%s/v3/apply4subject/applyment?applyment_id=%s", this.payService.getPayBaseUrl(), applymentId); + String result = payService.getV3(url); + return GSON.fromJson(result, ApplySubjectConfirmStateQueryResult.class); + } + + /** + *
+   * 获取商户开户意愿确认状态
+   * 详情请见: 获取商户开户意愿确认状态API
+   * 
+ * + * @param subMchId 微信支付分配的特约商户的唯一标识。 + * @return 确认状态结果 + * @throws WxPayException 异常 + */ + @Override + public ApplySubjectConfirmMerchantStateQueryResult queryMerchantApplyStatusByMchId(String subMchId) throws WxPayException { + String url = String.format("%s/v3/apply4subject/applyment/merchants/%s/state", this.payService.getPayBaseUrl(), subMchId); + String result = payService.getV3(url); + return GSON.fromJson(result, ApplySubjectConfirmMerchantStateQueryResult.class); + } + + /** + *
+   * 撤销申请单
+   * 详情请见: 撤销申请单API
+   * 
+ * + * @param businessCode 业务申请编号 + * @return 返回结果 + * @throws WxPayException 异常 + */ + @Override + public void cancelApplyByBusinessCode(String businessCode) throws WxPayException { + String url = String.format("%s/v3/apply4subject/applyment/%s/cancel", this.payService.getPayBaseUrl(), businessCode); + payService.postV3WithWechatpaySerial(url, ""); + } + + /** + *
+   * 撤销申请单
+   * 详情请见: 撤销申请单API
+   * 
+ * + * @param applymentId 申请编号 + * @return 返回结果 + * @throws WxPayException 异常 + */ + @Override + public void cancelApplyByApplymentId(String applymentId) throws WxPayException { + String url = String.format("%s/v3/apply4subject/applyment/%s/cancel", this.payService.getPayBaseUrl(), applymentId); + payService.postV3WithWechatpaySerial(url, ""); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java index 8da4c40587..7fd655824a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java @@ -63,4 +63,11 @@ public String modifySettlement(String subMchid, ModifySettlementRequest request) encryptFiled(request); return payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); } + + @Override + public SettlementModifyStateQueryResult querySettlementModifyStatusByApplicationNo(String subMchid, String applicationNo) throws WxPayException { + String url = String.format("%s/v3/apply4sub/sub_merchants/%s/application/%s", this.payService.getPayBaseUrl(), subMchid, applicationNo); + String result = payService.getV3(url); + return GSON.fromJson(result, SettlementModifyStateQueryResult.class); + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BankServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BankServiceImpl.java new file mode 100644 index 0000000000..623a787d93 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BankServiceImpl.java @@ -0,0 +1,68 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.bank.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.BankService; +import com.github.binarywang.wxpay.service.WxPayService; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import lombok.RequiredArgsConstructor; + +/** + * 微信支付-银行组件 + * + * @author zhongjun + **/ +@RequiredArgsConstructor +public class BankServiceImpl implements BankService { + private final WxPayService payService; + private static final Gson GSON = new GsonBuilder().create(); + + @Override + public BankAccountResult searchBanksByBankAccount(String accountNumber) throws WxPayException { + String url = String.format("%s/v3/capital/capitallhh/banks/search-banks-by-bank-account?account_number=%s", this.payService.getPayBaseUrl(), accountNumber); + String response = payService.getV3WithWechatPaySerial(url); + return GSON.fromJson(response, BankAccountResult.class); + } + + @Override + public BankingResult personalBanking(Integer offset, Integer limit) throws WxPayException { + offset = offset == null ? 0 : offset; + limit = limit == null ? 200 : limit; + String url = String.format("%s/v3/capital/capitallhh/banks/personal-banking?offset=%s&limit=%s", this.payService.getPayBaseUrl(), offset, limit); + String response = payService.getV3(url); + return GSON.fromJson(response, BankingResult.class); + } + + @Override + public BankingResult corporateBanking(Integer offset, Integer limit) throws WxPayException { + offset = offset == null ? 0 : offset; + limit = limit == null ? 200 : limit; + String url = String.format("%s/v3/capital/capitallhh/banks/corporate-banking?offset=%s&limit=%s", this.payService.getPayBaseUrl(), offset, limit); + String response = payService.getV3(url); + return GSON.fromJson(response, BankingResult.class); + } + + @Override + public ProvincesResult areasProvinces() throws WxPayException { + String url = String.format("%s/v3/capital/capitallhh/areas/provinces", this.payService.getPayBaseUrl()); + String response = payService.getV3WithWechatPaySerial(url); + return GSON.fromJson(response, ProvincesResult.class); + } + + @Override + public CitiesResult areasCities(Integer provinceCode) throws WxPayException { + String url = String.format("%s/v3/capital/capitallhh/areas/provinces/%s/cities", this.payService.getPayBaseUrl(), provinceCode); + String response = payService.getV3WithWechatPaySerial(url); + return GSON.fromJson(response, CitiesResult.class); + } + + @Override + public BankBranchesResult bankBranches(String bankAliasCode, Integer cityCode, Integer offset, Integer limit) throws WxPayException { + offset = offset == null ? 0 : offset; + limit = limit == null ? 200 : limit; + String url = String.format("%s/v3/capital/capitallhh/banks/%s/branches?city_code=%s&offset=%s&limit=%s", this.payService.getPayBaseUrl(), bankAliasCode, cityCode, offset, limit); + String response = payService.getV3(url); + return GSON.fromJson(response, BankBranchesResult.class); + } +} 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 a80a7f4527..8466a5e91e 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 @@ -20,15 +20,18 @@ 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; import com.github.binarywang.wxpay.v3.util.AesUtils; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import jodd.io.ZipUtil; +import lombok.Getter; +import lombok.Setter; import me.chanjar.weixin.common.error.WxRuntimeException; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.reflect.ConstructorUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,86 +66,69 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { static ThreadLocal wxApiData = new ThreadLocal<>(); + + @Setter + @Getter private EntPayService entPayService = new EntPayServiceImpl(this); + + @Getter private final ProfitSharingService profitSharingService = new ProfitSharingServiceImpl(this); - private final ProfitSharingV3Service profitSharingV3Service = new ProfitSharingV3ServiceImpl(this); + + @Getter private final RedpackService redpackService = new RedpackServiceImpl(this); + + @Getter private final PayScoreService payScoreService = new PayScoreServiceImpl(this); + + @Getter private final EcommerceService ecommerceService = new EcommerceServiceImpl(this); + + @Getter private final BusinessCircleService businessCircleService = new BusinessCircleServiceImpl(this); - private final MerchantMediaService merchantMediaService = new MerchantMediaServiceImpl(this); - private final MarketingMediaService marketingMediaService = new MarketingMediaServiceImpl(this); - private final MarketingFavorService marketingFavorService = new MarketingFavorServiceImpl(this); - private final MarketingBusiFavorService marketingBusiFavorService = new MarketingBusiFavorServiceImpl(this); - private final WxEntrustPapService wxEntrustPapService = new WxEntrustPapServiceImpl(this); + @Getter + private final MerchantMediaService merchantMediaService = new MerchantMediaServiceImpl(this); - protected Map configMap; + @Getter + private final MarketingMediaService marketingMediaService = new MarketingMediaServiceImpl(this); - @Override - public EntPayService getEntPayService() { - return entPayService; - } + @Getter + private final MarketingFavorService marketingFavorService = new MarketingFavorServiceImpl(this); - @Override - public ProfitSharingService getProfitSharingService() { - return profitSharingService; - } + @Getter + private final MarketingBusiFavorService marketingBusiFavorService = new MarketingBusiFavorServiceImpl(this); - @Override - public ProfitSharingV3Service getProfitSharingV3Service() { - return profitSharingV3Service; - } + @Getter + private final WxEntrustPapService wxEntrustPapService = new WxEntrustPapServiceImpl(this); - @Override - public PayScoreService getPayScoreService() { - return payScoreService; - } + @Getter + private final PartnerTransferService partnerTransferService = new PartnerTransferServiceImpl(this); - @Override - public RedpackService getRedpackService() { - return this.redpackService; - } + @Getter + private final PayrollService payrollService = new PayrollServiceImpl(this); - @Override - public EcommerceService getEcommerceService() { - return ecommerceService; - } + @Getter + private final ComplaintService complaintsService = new ComplaintServiceImpl(this); - @Override - public BusinessCircleService getBusinessCircleService() { - return this.businessCircleService; - } + @Getter + private final BankService bankService = new BankServiceImpl(this); - @Override - public MerchantMediaService getMerchantMediaService() { - return this.merchantMediaService; - } + @Getter + private final TransferService transferService = new TransferServiceImpl(this); - @Override - public MarketingMediaService getMarketingMediaService() { - return this.marketingMediaService; - } + @Getter + private final PartnerPayScoreService partnerPayScoreService = new PartnerPayScoreServiceImpl(this); - @Override - public MarketingFavorService getMarketingFavorService() { - return this.marketingFavorService; - } + @Getter + private final PartnerPayScoreSignPlanService partnerPayScoreSignPlanService=new PartnerPayScoreSignPlanServiceImpl(this); - @Override - public MarketingBusiFavorService getMarketingBusiFavorService() { - return this.marketingBusiFavorService; - } + @Getter + private final MerchantTransferService merchantTransferService = new MerchantTransferServiceImpl(this); - @Override - public void setEntPayService(EntPayService entPayService) { - this.entPayService = entPayService; - } + @Getter + private final BrandMerchantTransferService brandMerchantTransferService = new BrandMerchantTransferServiceImpl(this); - @Override - public WxEntrustPapService getWxEntrustPapService() { - return wxEntrustPapService; - } + protected Map configMap = new HashMap<>(); @Override public WxPayConfig getConfig() { @@ -223,9 +209,11 @@ public WxPayService switchoverTo(String mchId) { @Override public String getPayBaseUrl() { if (this.getConfig().isUseSandboxEnv()) { - return this.getConfig().getPayBaseUrl() + "/sandboxnew"; + if (StringUtils.isNotBlank(this.getConfig().getApiV3Key())) { + throw new WxRuntimeException("微信支付V3 目前不支持沙箱模式!"); + } + return this.getConfig().getPayBaseUrl() + "/xdc/apiv2sandbox"; } - return this.getConfig().getPayBaseUrl(); } @@ -234,10 +222,6 @@ public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayExceptio request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/secapi/pay/refund"; - if (this.getConfig().isUseSandboxEnv()) { - url = this.getConfig().getPayBaseUrl() + "/sandboxnew/pay/refund"; - } - String responseContent = this.post(url, request.toXML(), true); WxPayRefundResult result = BaseWxPayResult.fromXML(responseContent, WxPayRefundResult.class); result.composeRefundCoupons(); @@ -250,10 +234,6 @@ public WxPayRefundResult refundV2(WxPayRefundRequest request) throws WxPayExcept request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/secapi/pay/refundv2"; - if (this.getConfig().isUseSandboxEnv()) { - url = this.getConfig().getPayBaseUrl() + "/sandboxnew/pay/refundv2"; - } - String responseContent = this.post(url, request.toXML(), true); WxPayRefundResult result = BaseWxPayResult.fromXML(responseContent, WxPayRefundResult.class); result.composePromotionDetails(); @@ -305,15 +285,22 @@ public WxPayRefundQueryResult refundQueryV2(WxPayRefundQueryRequest request) thr } @Override - public WxPayRefundQueryV3Result refundQueryV3(String outTradeNo) throws WxPayException { - String url = String.format("%s/v3/refund/domestic/refunds/%s", this.getPayBaseUrl(), outTradeNo); + public WxPayRefundQueryV3Result refundQueryV3(String outRefundNo) throws WxPayException { + String url = String.format("%s/v3/refund/domestic/refunds/%s", this.getPayBaseUrl(), outRefundNo); String response = this.getV3(url); return GSON.fromJson(response, WxPayRefundQueryV3Result.class); } @Override public WxPayRefundQueryV3Result refundQueryV3(WxPayRefundQueryV3Request request) throws WxPayException { - String url = String.format("%s/v3/refund/domestic/refunds/%s", this.getPayBaseUrl(), request.getOutTradeNo()); + String url = String.format("%s/v3/refund/domestic/refunds/%s", this.getPayBaseUrl(), request.getOutRefundNo()); + String response = this.getV3(url); + return GSON.fromJson(response, WxPayRefundQueryV3Result.class); + } + + @Override + public WxPayRefundQueryV3Result refundPartnerQueryV3(WxPayRefundQueryV3Request request) throws WxPayException { + String url = String.format("%s/v3/refund/domestic/refunds/%s?sub_mchid=%s", this.getPayBaseUrl(), request.getOutRefundNo(),request.getSubMchid()); String response = this.getV3(url); return GSON.fromJson(response, WxPayRefundQueryV3Result.class); } @@ -332,9 +319,10 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String sign if (result.getSignType() != null) { // 如果解析的通知对象中signType有值,则使用它进行验签 signType = result.getSignType(); - } else if (this.getConfig().getSignType() != null) { + } else if (configMap.get(result.getMchId()).getSignType() != null) { // 如果配置中signType有值,则使用它进行验签 - signType = this.getConfig().getSignType(); + signType = configMap.get(result.getMchId()).getSignType(); + this.switchover(result.getMchId()); } } @@ -350,8 +338,9 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String sign /** * 校验通知签名 + * * @param header 通知头信息 - * @param data 通知数据 + * @param data 通知数据 * @return true:校验通过 false:校验不通过 */ private boolean verifyNotifySign(SignatureHeader header, String data) { @@ -364,7 +353,17 @@ private boolean verifyNotifySign(SignatureHeader header, String data) { } @Override - public WxPayOrderNotifyV3Result parseOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException { + public WxPayNotifyV3Result parseOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException { + return baseParseOrderNotifyV3Result(notifyData, header, WxPayNotifyV3Result.class, WxPayNotifyV3Result.DecryptNotifyResult.class); + } + + @Override + public WxPayPartnerNotifyV3Result parsePartnerOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException { + return this.baseParseOrderNotifyV3Result(notifyData, header, WxPayPartnerNotifyV3Result.class, WxPayPartnerNotifyV3Result.DecryptNotifyResult.class); + } + + @Override + public , E> T baseParseOrderNotifyV3Result(String notifyData, SignatureHeader header, Class resultType, Class dataType) throws WxPayException { if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { throw new WxPayException("非法请求,头部信息验证失败"); } @@ -376,12 +375,12 @@ public WxPayOrderNotifyV3Result parseOrderNotifyV3Result(String notifyData, Sign String apiV3Key = this.getConfig().getApiV3Key(); try { String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); - WxPayOrderNotifyV3Result.DecryptNotifyResult decryptNotifyResult = GSON.fromJson(result, WxPayOrderNotifyV3Result.DecryptNotifyResult.class); - WxPayOrderNotifyV3Result notifyResult = new WxPayOrderNotifyV3Result(); + E decryptNotifyResult = GSON.fromJson(result, dataType); + T notifyResult = ConstructorUtils.invokeConstructor(resultType); notifyResult.setRawData(response); notifyResult.setResult(decryptNotifyResult); return notifyResult; - } catch (GeneralSecurityException | IOException e) { + } catch (Exception e) { throw new WxPayException("解析报文异常!", e); } } @@ -416,6 +415,7 @@ public WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws Wx WxPayRefundNotifyResult result; if (XmlConfig.fastMode) { result = BaseWxPayResult.fromXML(xmlData, WxPayRefundNotifyResult.class); + this.switchover(result.getMchId()); result.decryptReqInfo(this.getConfig().getMchKey()); } else { result = WxPayRefundNotifyResult.fromXML(xmlData, this.getConfig().getMchKey()); @@ -429,34 +429,22 @@ public WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws Wx @Override public WxPayRefundNotifyV3Result parseRefundNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException { - if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { - throw new WxPayException("非法请求,头部信息验证失败"); - } - OriginNotifyResponse response = GSON.fromJson(notifyData, OriginNotifyResponse.class); - OriginNotifyResponse.Resource resource = response.getResource(); - String cipherText = resource.getCiphertext(); - String associatedData = resource.getAssociatedData(); - String nonce = resource.getNonce(); - String apiV3Key = this.getConfig().getApiV3Key(); - try { - String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); - WxPayRefundNotifyV3Result.DecryptNotifyResult decryptNotifyResult = GSON.fromJson(result, WxPayRefundNotifyV3Result.DecryptNotifyResult.class); - WxPayRefundNotifyV3Result notifyResult = new WxPayRefundNotifyV3Result(); - notifyResult.setRawData(response); - notifyResult.setResult(decryptNotifyResult); - return notifyResult; - } catch (GeneralSecurityException | IOException e) { - throw new WxPayException("解析报文异常!", e); - } + return this.baseParseOrderNotifyV3Result(notifyData, header, WxPayRefundNotifyV3Result.class, WxPayRefundNotifyV3Result.DecryptNotifyResult.class); } @Override - public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, String signType) throws WxPayException { + public WxPayPartnerRefundNotifyV3Result parsePartnerRefundNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException { + return this.baseParseOrderNotifyV3Result(notifyData, header, WxPayPartnerRefundNotifyV3Result.class, WxPayPartnerRefundNotifyV3Result.DecryptNotifyResult.class); + } + + @Override + public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, @Deprecated String signType) throws WxPayException { try { log.debug("扫码支付回调通知请求参数:{}", xmlData); WxScanPayNotifyResult result = BaseWxPayResult.fromXML(xmlData, WxScanPayNotifyResult.class); + this.switchover(result.getMchId()); log.debug("扫码支付回调通知解析后的对象:{}", result); - result.checkResult(this, signType, false); + result.checkResult(this, this.getConfig().getSignType(), false); return result; } catch (WxPayException e) { throw e; @@ -467,8 +455,8 @@ public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, String sig @Override public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData) throws WxPayException { - final String signType = this.getConfig().getSignType(); - return this.parseScanPayNotifyResult(xmlData, signType); +// final String signType = this.getConfig().getSignType(); + return this.parseScanPayNotifyResult(xmlData, null); } @Override @@ -518,6 +506,31 @@ public WxPayOrderQueryV3Result queryOrderV3(WxPayOrderQueryV3Request request) th return GSON.fromJson(response, WxPayOrderQueryV3Result.class); } + @Override + public WxPayPartnerOrderQueryV3Result queryPartnerOrderV3(String transactionId, String outTradeNo) throws WxPayException { + WxPayPartnerOrderQueryV3Request request = new WxPayPartnerOrderQueryV3Request(); + request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); + request.setTransactionId(StringUtils.trimToNull(transactionId)); + return this.queryPartnerOrderV3(request); + } + + @Override + public WxPayPartnerOrderQueryV3Result queryPartnerOrderV3(WxPayPartnerOrderQueryV3Request request) throws WxPayException { + if (StringUtils.isBlank(request.getSpMchId())) { + request.setSpMchId(this.getConfig().getMchId()); + } + if (StringUtils.isBlank(request.getSubMchId())) { + request.setSubMchId(this.getConfig().getSubMchId()); + } + String url = String.format("%s/v3/pay/partner/transactions/out-trade-no/%s", this.getPayBaseUrl(), request.getOutTradeNo()); + if (Objects.isNull(request.getOutTradeNo())) { + url = String.format("%s/v3/pay/partner/transactions/id/%s", this.getPayBaseUrl(), request.getTransactionId()); + } + String query = String.format("?sp_mchid=%s&sub_mchid=%s", request.getSpMchId(), request.getSubMchId()); + String response = this.getV3(url + query); + return GSON.fromJson(response, WxPayPartnerOrderQueryV3Result.class); + } + @Override public CombineQueryResult queryCombine(String combineOutTradeNo) throws WxPayException { String url = String.format("%s/v3/combine-transactions/out-trade-no/%s", this.getPayBaseUrl(), combineOutTradeNo); @@ -559,6 +572,16 @@ public void closeOrderV3(String outTradeNo) throws WxPayException { this.closeOrderV3(request); } + @Override + public void closePartnerOrderV3(String outTradeNo) throws WxPayException { + if (StringUtils.isBlank(outTradeNo)) { + throw new WxPayException("out_trade_no不能为空"); + } + WxPayPartnerOrderCloseV3Request request = new WxPayPartnerOrderCloseV3Request(); + request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); + this.closePartnerOrderV3(request); + } + @Override public void closeOrderV3(WxPayOrderCloseV3Request request) throws WxPayException { if (StringUtils.isBlank(request.getMchid())) { @@ -568,6 +591,18 @@ public void closeOrderV3(WxPayOrderCloseV3Request request) throws WxPayException this.postV3(url, GSON.toJson(request)); } + @Override + public void closePartnerOrderV3(WxPayPartnerOrderCloseV3Request request) throws WxPayException { + if (StringUtils.isBlank(request.getSpMchId())) { + request.setSpMchId(this.getConfig().getMchId()); + } + if (StringUtils.isBlank(request.getSubMchId())) { + request.setSubMchId(this.getConfig().getSubMchId()); + } + String url = String.format("%s/v3/pay/partner/transactions/out-trade-no/%s/close", this.getPayBaseUrl(), request.getOutTradeNo()); + this.postV3(url, GSON.toJson(request)); + } + @Override public void closeCombine(CombineCloseRequest request) throws WxPayException { String url = String.format("%s/v3/combine-transactions/out-trade-no/%s/close", this.getPayBaseUrl(), request.getCombineOutTradeNo()); @@ -684,6 +719,41 @@ public T createOrderV3(TradeTypeEnum tradeType, WxPayUnifiedOrderV3Request r return result.getPayInfo(tradeType, request.getAppid(), request.getMchid(), this.getConfig().getPrivateKey()); } + @Override + public T createPartnerOrderV3(TradeTypeEnum tradeType, WxPayPartnerUnifiedOrderV3Request request) throws WxPayException { + WxPayUnifiedOrderV3Result result = this.unifiedPartnerOrderV3(tradeType, request); + //获取应用ID + String appId = StringUtils.isBlank(request.getSubAppid()) ? request.getSpAppid() : request.getSubAppid(); + return result.getPayInfo(tradeType, appId, request.getSubMchId(), this.getConfig().getPrivateKey()); + } + + @Override + public WxPayUnifiedOrderV3Result unifiedPartnerOrderV3(TradeTypeEnum tradeType, WxPayPartnerUnifiedOrderV3Request request) throws WxPayException { + if (StringUtils.isBlank(request.getSpAppid())) { + request.setSpAppid(this.getConfig().getAppId()); + } + + if (StringUtils.isBlank(request.getSpMchId())) { + request.setSpMchId(this.getConfig().getMchId()); + } + + if (StringUtils.isBlank(request.getNotifyUrl())) { + request.setNotifyUrl(this.getConfig().getNotifyUrl()); + } + + if (StringUtils.isBlank(request.getSubAppid())) { + request.setSubAppid(this.getConfig().getSubAppId()); + } + + if (StringUtils.isBlank(request.getSubMchId())) { + request.setSubMchId(this.getConfig().getSubMchId()); + } + + String url = this.getPayBaseUrl() + tradeType.getBasePartnerUrl(); + String response = this.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, WxPayUnifiedOrderV3Result.class); + } + @Override public WxPayUnifiedOrderV3Result unifiedOrderV3(TradeTypeEnum tradeType, WxPayUnifiedOrderV3Request request) throws WxPayException { if (StringUtils.isBlank(request.getAppid())) { @@ -692,6 +762,10 @@ public WxPayUnifiedOrderV3Result unifiedOrderV3(TradeTypeEnum tradeType, WxPayUn if (StringUtils.isBlank(request.getMchid())) { request.setMchid(this.getConfig().getMchId()); } + if (StringUtils.isBlank(request.getNotifyUrl())) { + request.setNotifyUrl(this.getConfig().getNotifyUrl()); + } + String url = this.getPayBaseUrl() + tradeType.getPartnerUrl(); String response = this.postV3(url, GSON.toJson(request)); return GSON.fromJson(response, WxPayUnifiedOrderV3Result.class); @@ -766,7 +840,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W } @Override - public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) { + public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) throws Exception { String content = this.createScanPayQrcodeMode1(productId); return this.createQrcode(content, logoFile, sideLength); } @@ -796,11 +870,11 @@ public String createScanPayQrcodeMode1(String productId) { } @Override - public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) { + public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) throws Exception { return this.createQrcode(codeUrl, logoFile, sideLength); } - private byte[] createQrcode(String content, File logoFile, Integer sideLength) { + private byte[] createQrcode(String content, File logoFile, Integer sideLength) throws Exception { if (sideLength == null || sideLength < 1) { return QrcodeUtils.createQrcode(content, logoFile); } @@ -880,7 +954,7 @@ private String handleGzipBill(String url, String requestStr) throws WxPayExcepti Path path = Paths.get(tempDirectory.toString(), System.currentTimeMillis() + ".gzip"); Files.write(path, responseBytes); try { - List allLines = Files.readAllLines(ZipUtil.ungzip(path.toFile()).toPath(), StandardCharsets.UTF_8); + List allLines = Files.readAllLines(ZipUtils.unGzip(path.toFile()).toPath(), StandardCharsets.UTF_8); return Joiner.on("\n").join(allLines); } catch (ZipException e) { if (e.getMessage().contains("Not in GZIP format")) { @@ -897,7 +971,6 @@ private String handleGzipBill(String url, String requestStr) throws WxPayExcepti @Override public WxPayFundFlowResult downloadFundFlow(String billDate, String accountType, String tarType) throws WxPayException { - WxPayDownloadFundFlowRequest request = new WxPayDownloadFundFlowRequest(); request.setBillDate(billDate); request.setAccountType(accountType); @@ -933,7 +1006,7 @@ private String handleGzipFundFlow(String url, String requestStr) throws WxPayExc Files.write(path, responseBytes); try { - List allLines = Files.readAllLines(ZipUtil.ungzip(path.toFile()).toPath(), StandardCharsets.UTF_8); + List allLines = Files.readAllLines(ZipUtils.unGzip(path.toFile()).toPath(), StandardCharsets.UTF_8); return Joiner.on("\n").join(allLines); } catch (ZipException e) { if (e.getMessage().contains("Not in GZIP format")) { @@ -1028,9 +1101,9 @@ public WxPayApplyBillV3Result applyTradeBill(WxPayApplyTradeBillV3Request reques public WxPayApplyBillV3Result applyFundFlowBill(WxPayApplyFundFlowBillV3Request request) throws WxPayException { String url; if (StringUtils.isBlank(request.getTarType())) { - url = String.format("%s/v3/bill/fundflowbill?bill_date=%s&bill_type=%s", this.getPayBaseUrl(), request.getBillDate(), request.getAccountType()); + url = String.format("%s/v3/bill/fundflowbill?bill_date=%s&account_type=%s", this.getPayBaseUrl(), request.getBillDate(), request.getAccountType()); } else { - url = String.format("%s/v3/bill/fundflowbill?bill_date=%s&bill_type=%s&tar_type=%s", this.getPayBaseUrl(), request.getBillDate(), request.getAccountType(), request.getTarType()); + url = String.format("%s/v3/bill/fundflowbill?bill_date=%s&account_type=%s&tar_type=%s", this.getPayBaseUrl(), request.getBillDate(), request.getAccountType(), request.getTarType()); } String response = this.getV3(url); return GSON.fromJson(response, WxPayApplyBillV3Result.class); @@ -1100,7 +1173,7 @@ public String getSandboxSignKey() throws WxPayException { WxPayDefaultRequest request = new WxPayDefaultRequest(); request.checkAndSign(this.getConfig()); - String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; + String url = "https://api.mch.weixin.qq.com/xdc/apiv2getsignkey/sign/getsignkey"; String responseContent = this.post(url, request.toXML(), false); WxPaySandboxSignKeyResult result = BaseWxPayResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class); result.checkResult(this, request.getSignType(), true); @@ -1215,4 +1288,42 @@ public WxPayQueryExchangeRateResult queryExchangeRate(String feeType, String dat result.checkResult(this, request.getSignType(), true); return result; } + + @Override + public ComplaintNotifyResult parseComplaintNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { + if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { + throw new WxPayException("非法请求,头部信息验证失败"); + } + OriginNotifyResponse response = GSON.fromJson(notifyData, OriginNotifyResponse.class); + OriginNotifyResponse.Resource resource = response.getResource(); + String cipherText = resource.getCiphertext(); + String associatedData = resource.getAssociatedData(); + String nonce = resource.getNonce(); + String apiV3Key = this.getConfig().getApiV3Key(); + try { + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); + ComplaintNotifyResult.DecryptNotifyResult decryptNotifyResult = GSON.fromJson(result, ComplaintNotifyResult.DecryptNotifyResult.class); + ComplaintNotifyResult notifyResult = new ComplaintNotifyResult(); + notifyResult.setRawData(response); + notifyResult.setResult(decryptNotifyResult); + return notifyResult; + } catch (GeneralSecurityException | IOException e) { + throw new WxPayException("解析报文异常!", e); + } + } + + @Override + public ComplaintService getComplaintsService() { + return complaintsService; + } + + @Override + public BankService getBankService() { + return bankService; + } + + @Override + public TransferService getTransferService() { + return transferService; + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BrandMerchantTransferServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BrandMerchantTransferServiceImpl.java new file mode 100644 index 0000000000..a9ee5d236d --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BrandMerchantTransferServiceImpl.java @@ -0,0 +1,87 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.request.*; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandBatchesQueryResult; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandDetailsQueryResult; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandTransferBatchesResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.BrandMerchantTransferService; +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 lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * 品牌商户发放红包商家转账到零钱(直联商户)实现 + * + * @author moran + */ +@Slf4j +@RequiredArgsConstructor +public class BrandMerchantTransferServiceImpl implements BrandMerchantTransferService { + private static final Gson GSON = (new GsonBuilder()).create(); + + private final WxPayService wxPayService; + + + @Override + public BrandTransferBatchesResult createBrandTransfer(BrandTransferBatchesRequest request) throws WxPayException { + + String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-batches", this.wxPayService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.wxPayService.getConfig().getVerifier().getValidCertificate()); + + String response = wxPayService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(response, BrandTransferBatchesResult.class); + } + + @Override + public BrandBatchesQueryResult queryBrandWxBatches(BrandWxBatchesQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-batches/%s", + this.wxPayService.getPayBaseUrl(), request.getBatchNo()); + + if (request.getNeedQueryDetail() != null) { + url = String.format("%s?need_query_detail=%b", url, request.getNeedQueryDetail()); + } + if (request.getDetailState() != null && request.getDetailState().length() != 0) { + url = String.format("%s&detail_state=%s", url, request.getDetailState()); + } + + String response = wxPayService.getV3(url); + return GSON.fromJson(response, BrandBatchesQueryResult.class); + } + + @Override + public BrandDetailsQueryResult queryBrandWxDetails(BrandWxDetailsQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-batches/%s/details/%s", + this.wxPayService.getPayBaseUrl(), request.getBatchNo(), request.getDetailNo()); + String response = wxPayService.getV3(url); + return GSON.fromJson(response, BrandDetailsQueryResult.class); + } + + @Override + public BrandBatchesQueryResult queryBrandMerchantBatches(BrandMerchantBatchesQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-out-batches/%s", + this.wxPayService.getPayBaseUrl(), request.getOutBatchNo()); + + if (request.getNeedQueryDetail() != null) { + url = String.format("%s?need_query_detail=%b", url, request.getNeedQueryDetail()); + } + if (request.getDetailState() != null && request.getDetailState().length() != 0) { + url = String.format("%s&detail_state=%s", url, request.getDetailState()); + } + + String response = wxPayService.getV3(url); + return GSON.fromJson(response, BrandBatchesQueryResult.class); + } + + @Override + public BrandDetailsQueryResult queryBrandMerchantDetails(BrandMerchantDetailsQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-out-batches/%s/out-details/%s", + this.wxPayService.getPayBaseUrl(), request.getOutBatchNo(), request.getOutDetailNo()); + String response = wxPayService.getV3(url); + return GSON.fromJson(response, BrandDetailsQueryResult.class); + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImpl.java new file mode 100644 index 0000000000..51d9609c41 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImpl.java @@ -0,0 +1,152 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.complaint.*; +import com.github.binarywang.wxpay.bean.media.ImageUploadResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.ComplaintService; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.v3.WechatPayUploadHttpPost; +import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import lombok.RequiredArgsConstructor; +import org.apache.commons.codec.digest.DigestUtils; + +import javax.crypto.BadPaddingException; +import java.io.*; +import java.net.URI; +import java.util.List; + +/** + *
+ * 消费者投诉2.0 实现.
+ * Created by jmdhappy on 2022/3/19.
+ * 
+ * + * @author jmdhappy + */ +@RequiredArgsConstructor +public class ComplaintServiceImpl implements ComplaintService { + private static final Gson GSON = new GsonBuilder().create(); + private final WxPayService payService; + + @Override + public ComplaintResult queryComplaints(ComplaintRequest request) throws WxPayException, BadPaddingException { + String url = String.format("%s/v3/merchant-service/complaints-v2?limit=%d&offset=%d&begin_date=%s&end_date=%s&complainted_mchid=%s", + this.payService.getPayBaseUrl(), request.getLimit(), request.getOffset(), request.getBeginDate(), request.getEndDate(), request.getComplaintedMchid()); + String response = this.payService.getV3(url); + ComplaintResult complaintResult = GSON.fromJson(response, ComplaintResult.class); + List data = complaintResult.getData(); + for (ComplaintDetailResult complaintDetailResult : data) { + // 对手机号进行解密操作 + if (complaintDetailResult.getPayerPhone() != null) { + String payerPhone = RsaCryptoUtil.decryptOAEP(complaintDetailResult.getPayerPhone(), this.payService.getConfig().getPrivateKey()); + complaintDetailResult.setPayerPhone(payerPhone); + } + } + return complaintResult; + } + + @Override + public ComplaintDetailResult getComplaint(ComplaintDetailRequest request) throws WxPayException, BadPaddingException { + String url = String.format("%s/v3/merchant-service/complaints-v2/%s", + this.payService.getPayBaseUrl(), request.getComplaintId()); + String response = this.payService.getV3(url); + ComplaintDetailResult result = GSON.fromJson(response, ComplaintDetailResult.class); + // 对手机号进行解密操作 + if (result.getPayerPhone() != null) { + String payerPhone = RsaCryptoUtil.decryptOAEP(result.getPayerPhone(), this.payService.getConfig().getPrivateKey()); + result.setPayerPhone(payerPhone); + } + return result; + } + + @Override + public NegotiationHistoryResult queryNegotiationHistorys(NegotiationHistoryRequest request) throws WxPayException { + String url = String.format("%s/v3/merchant-service/complaints-v2/%s/negotiation-historys?limit=%d&offset=%d", + this.payService.getPayBaseUrl(), request.getComplaintId(), request.getLimit(), request.getOffset()); + String response = this.payService.getV3(url); + return GSON.fromJson(response, NegotiationHistoryResult.class); + } + + @Override + public ComplaintNotifyUrlResult addComplaintNotifyUrl(ComplaintNotifyUrlRequest request) throws WxPayException { + String url = String.format("%s/v3/merchant-service/complaint-notifications", this.payService.getPayBaseUrl()); + String response = this.payService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, ComplaintNotifyUrlResult.class); + } + + @Override + public ComplaintNotifyUrlResult getComplaintNotifyUrl() throws WxPayException { + String url = String.format("%s/v3/merchant-service/complaint-notifications", this.payService.getPayBaseUrl()); + String response = this.payService.getV3(url); + return GSON.fromJson(response, ComplaintNotifyUrlResult.class); + } + + @Override + public ComplaintNotifyUrlResult updateComplaintNotifyUrl(ComplaintNotifyUrlRequest request) throws WxPayException { + String url = String.format("%s/v3/merchant-service/complaint-notifications", this.payService.getPayBaseUrl()); + String response = this.payService.putV3(url, GSON.toJson(request)); + return GSON.fromJson(response, ComplaintNotifyUrlResult.class); + } + + @Override + public void deleteComplaintNotifyUrl() throws WxPayException { + String url = String.format("%s/v3/merchant-service/complaint-notifications", this.payService.getPayBaseUrl()); + this.payService.deleteV3(url); + } + + @Override + public void submitResponse(ResponseRequest request) throws WxPayException { + String url = String.format("%s/v3/merchant-service/complaints-v2/%s/response", this.payService.getPayBaseUrl(), request.getComplaintId()); + // 上面url已经含有complaintId,这里设置为空,避免在body中再次传递,否则微信会报错 + request.setComplaintId(null); + this.payService.postV3(url, GSON.toJson(request)); + } + + @Override + public void complete(CompleteRequest request) throws WxPayException { + String url = String.format("%s/v3/merchant-service/complaints-v2/%s/complete", this.payService.getPayBaseUrl(), request.getComplaintId()); + // 上面url已经含有complaintId,这里设置为空,避免在body中再次传递,否则微信会报错 + request.setComplaintId(null); + this.payService.postV3(url, GSON.toJson(request)); + } + + @Override + public ImageUploadResult uploadResponseImage(File imageFile) throws WxPayException, IOException { + String url = String.format("%s/v3/merchant-service/images/upload", this.payService.getPayBaseUrl()); + + try (FileInputStream s1 = new FileInputStream(imageFile)) { + String sha256 = DigestUtils.sha256Hex(s1); + try (InputStream s2 = new FileInputStream(imageFile)) { + WechatPayUploadHttpPost request = new WechatPayUploadHttpPost.Builder(URI.create(url)) + .withImage(imageFile.getName(), sha256, s2) + .build(); + String result = this.payService.postV3(url, request); + return ImageUploadResult.fromJson(result); + } + } + } + + @Override + public ImageUploadResult uploadResponseImage(InputStream inputStream, String fileName) throws WxPayException, IOException { + String url = String.format("%s/v3/merchant-service/images/upload", this.payService.getPayBaseUrl()); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + //文件大小不能超过2M + byte[] buffer = new byte[2048]; + int len; + while ((len = inputStream.read(buffer)) > -1) { + bos.write(buffer, 0, len); + } + bos.flush(); + byte[] data = bos.toByteArray(); + String sha256 = DigestUtils.sha256Hex(data); + WechatPayUploadHttpPost request = new WechatPayUploadHttpPost.Builder(URI.create(url)) + .withImage(fileName, sha256, new ByteArrayInputStream(data)) + .build(); + String result = this.payService.postV3(url, request); + return ImageUploadResult.fromJson(result); + } + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImpl.java new file mode 100644 index 0000000000..d25ed7c0a2 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImpl.java @@ -0,0 +1,110 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.customs.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.CustomDeclarationService; +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 lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.error.WxRuntimeException; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.util.Base64; + +/** + *
+ * 支付报关 实现.
+ * Created by xifengzhu on 2022/05/05.
+ * 
+ * + * @author xifengzhu + */ +@RequiredArgsConstructor +public class CustomDeclarationServiceImpl implements CustomDeclarationService { + private static final Gson GSON = new GsonBuilder().create(); + private final WxPayService payService; + + @Override + public DeclarationResult declare(DeclarationRequest request) throws WxPayException { + String response = this.payService.postV3(DECLARATION_BASE_URL.concat("/orders"), GSON.toJson(request)); + return GSON.fromJson(response, DeclarationResult.class); + } + + @Override + public DeclarationQueryResult query(DeclarationQueryRequest request) throws WxPayException { + String url = String.format("%s/orders?appid=%s&mchid=%s&order_type=%s&order_no=%s&customs=%s&offset=%s&limit=%s", + DECLARATION_BASE_URL, + request.getAppid(), + request.getMchid(), + request.getOrderType(), + request.getOrderNo(), + request.getCustoms(), + request.getOffset(), + request.getLimit() + ); + String result = this.payService.getV3(url); + return GSON.fromJson(result, DeclarationQueryResult.class); + } + + @Override + public VerifyCertificateResult verifyCertificate(VerifyCertificateRequest request) throws WxPayException { + this.encryptFields(request); + String response = this.payService.postV3WithWechatpaySerial(DECLARATION_BASE_URL.concat("/verify-certificate"), GSON.toJson(request)); + return GSON.fromJson(response, VerifyCertificateResult.class); + } + + @Override + public DeclarationResult modify(DeclarationRequest request) throws WxPayException { + String response = this.payService.patchV3(DECLARATION_BASE_URL.concat("/orders"), GSON.toJson(request)); + return GSON.fromJson(response, DeclarationResult.class); + } + + @Override + public RedeclareResult redeclare(RedeclareRequest request) throws WxPayException { + String response = this.payService.postV3(DECLARATION_BASE_URL.concat("/redeclare"), GSON.toJson(request)); + return GSON.fromJson(response, RedeclareResult.class); + } + + private void encryptFields(VerifyCertificateRequest request) throws WxPayException { + try { + request.setCertificateId(encryptOAEP(request.getCertificateId())); + request.setCertificateName(encryptOAEP(request.getCertificateName())); + } catch (Exception e) { + throw new WxPayException("敏感信息加密失败", e); + } + } + + private X509Certificate getValidCertificate() { + return this.payService.getConfig().getVerifier().getValidCertificate(); + } + + private String encryptOAEP(String message) + throws IllegalBlockSizeException { + X509Certificate certificate = getValidCertificate(); + try { + // 身份信息校验 RSA 加密,填充方案使用 `RSAES-PKCS1-v1_5` + // https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_2.shtml + Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + cipher.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey()); + + byte[] data = message.getBytes(StandardCharsets.UTF_8); + byte[] ciphertext = cipher.doFinal(data); + return Base64.getEncoder().encodeToString(ciphertext); + } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { + throw new WxRuntimeException("当前Java环境不支持RSA v1.5/OAEP", e); + } catch (InvalidKeyException e) { + throw new IllegalArgumentException("无效的证书", e); + } catch (IllegalBlockSizeException | BadPaddingException e) { + throw new IllegalBlockSizeException("加密原串的长度不能超过214字节"); + } + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java index 4f13618f3b..3d9a1af626 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java @@ -12,24 +12,31 @@ import com.google.common.base.CaseFormat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.apache.commons.lang3.StringUtils; import lombok.RequiredArgsConstructor; -import org.apache.commons.beanutils.BeanMap; +import org.apache.commons.lang3.StringUtils; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; import java.io.IOException; import java.io.InputStream; -import java.net.URI; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; -import java.util.Iterator; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.text.DateFormat; +import java.util.*; @RequiredArgsConstructor public class EcommerceServiceImpl implements EcommerceService { private static final Gson GSON = new GsonBuilder().create(); + + // https://stackoverflow.com/questions/6873020/gson-date-format + // gson default date format not match, so custom DateFormat + // detail DateFormat: FULL,LONG,SHORT,MEDIUM + private static final Gson GSON_CUSTOM = new GsonBuilder().setDateFormat(DateFormat.FULL, DateFormat.FULL).create(); private final WxPayService payService; @Override @@ -71,7 +78,7 @@ public T combineTransactions(TradeTypeEnum tradeType, CombineTransactionsReq @Override public CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { - if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){ + if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { throw new WxPayException("非法请求,头部信息验证失败"); } NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class); @@ -81,7 +88,7 @@ public CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyDat String nonce = resource.getNonce(); String apiV3Key = this.payService.getConfig().getApiV3Key(); try { - String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key); + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); CombineTransactionsResult transactionsResult = GSON.fromJson(result, CombineTransactionsResult.class); CombineTransactionsNotifyResult notifyResult = new CombineTransactionsNotifyResult(); @@ -110,13 +117,14 @@ public TransactionsResult partner(TradeTypeEnum tradeType, PartnerTransactionsRe @Override public T partnerTransactions(TradeTypeEnum tradeType, PartnerTransactionsRequest request) throws WxPayException { TransactionsResult result = this.partner(tradeType, request); - return result.getPayInfo(tradeType, request.getSpAppid(), + String appId = request.getSubAppid() != null ? request.getSubAppid() : request.getSpAppid(); + return result.getPayInfo(tradeType, appId, request.getSpMchid(), payService.getConfig().getPrivateKey()); } @Override public PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { - if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){ + if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { throw new WxPayException("非法请求,头部信息验证失败"); } NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class); @@ -126,7 +134,7 @@ public PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyDat String nonce = resource.getNonce(); String apiV3Key = this.payService.getConfig().getApiV3Key(); try { - String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key); + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); PartnerTransactionsResult transactionsResult = GSON.fromJson(result, PartnerTransactionsResult.class); PartnerTransactionsNotifyResult notifyResult = new PartnerTransactionsNotifyResult(); @@ -176,6 +184,16 @@ public FundBalanceResult subNowBalance(String subMchid) throws WxPayException { return GSON.fromJson(response, FundBalanceResult.class); } + @Override + public FundBalanceResult subNowBalance(String subMchid, SpAccountTypeEnum accountType) throws WxPayException { + String url = String.format("%s/v3/ecommerce/fund/balance/%s", this.payService.getPayBaseUrl(), subMchid); + if (Objects.nonNull(accountType)) { + url += "?account_type=" + accountType.getValue(); + } + String response = this.payService.getV3(url); + return GSON.fromJson(response, FundBalanceResult.class); + } + @Override public FundBalanceResult subDayEndBalance(String subMchid, String date) throws WxPayException { String url = String.format("%s/v3/ecommerce/fund/enddaybalance/%s?date=%s", this.payService.getPayBaseUrl(), subMchid, date); @@ -199,6 +217,14 @@ public ProfitSharingResult queryProfitSharing(ProfitSharingQueryRequest request) return GSON.fromJson(response, ProfitSharingResult.class); } + @Override + public ProfitSharingOrdersUnSplitAmountResult queryProfitSharingOrdersUnsplitAmount(ProfitSharingOrdersUnSplitAmountRequest request) throws WxPayException { + String url = String.format("%s/v3/ecommerce/profitsharing/orders/%s/amounts", + this.payService.getPayBaseUrl(), request.getTransactionId()); + String response = this.payService.getV3(url); + return GSON.fromJson(response, ProfitSharingOrdersUnSplitAmountResult.class); + } + @Override public ProfitSharingReceiverResult addReceivers(ProfitSharingReceiverRequest request) throws WxPayException { String url = String.format("%s/v3/ecommerce/profitsharing/receivers/add", this.payService.getPayBaseUrl()); @@ -268,7 +294,7 @@ public RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRef @Override public RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { - if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){ + if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { throw new WxPayException("非法请求,头部信息验证失败"); } NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class); @@ -278,7 +304,7 @@ public RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHe String nonce = resource.getNonce(); String apiV3Key = this.payService.getConfig().getApiV3Key(); try { - String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key); + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); RefundNotifyResult notifyResult = GSON.fromJson(result, RefundNotifyResult.class); notifyResult.setRawData(response); return notifyResult; @@ -350,8 +376,9 @@ public InputStream downloadBill(String url) throws WxPayException { /** * 校验通知签名 + * * @param header 通知头信息 - * @param data 通知数据 + * @param data 通知数据 * @return true:校验通过 false:校验不通过 */ private boolean verifyNotifySign(SignatureHeader header, String data) { @@ -365,17 +392,18 @@ private boolean verifyNotifySign(SignatureHeader header, String data) { /** * 对象拼接到url + * * @param o 转换对象 - * @return 拼接好的string + * @return 拼接好的string */ private String parseURLPair(Object o) { - Map map = new BeanMap(o); + Map map = getObjectToMap(o); Set> set = map.entrySet(); Iterator> it = set.iterator(); StringBuilder sb = new StringBuilder(); while (it.hasNext()) { Map.Entry e = it.next(); - if ( !"class".equals(e.getKey()) && e.getValue() != null) { + if (!"class".equals(e.getKey()) && e.getValue() != null) { sb.append(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, String.valueOf(e.getKey()))) .append("=").append(e.getValue()).append("&"); } @@ -383,5 +411,27 @@ private String parseURLPair(Object o) { return sb.deleteCharAt(sb.length() - 1).toString(); } - + public static Map getObjectToMap(Object obj) { + try { + Map result = new LinkedHashMap<>(); + final Class beanClass = obj.getClass(); + final BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); + final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + if (propertyDescriptors != null) { + for (final PropertyDescriptor propertyDescriptor : propertyDescriptors) { + if (propertyDescriptor != null) { + final String name = propertyDescriptor.getName(); + final Method readMethod = propertyDescriptor.getReadMethod(); + if (readMethod != null) { + result.put(name, readMethod.invoke(obj)); + } + } + } + } + return result; + } catch (IllegalAccessException | IntrospectionException | InvocationTargetException ignored) { + return null; + } } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImpl.java index 5923d0e106..a10bbbb085 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImpl.java @@ -154,19 +154,19 @@ public FavorCallbacksSaveResult saveFavorCallbacksV3(FavorCallbacksSaveRequest r } @Override - public FavorStocksStartResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException { - String url = String.format("%s/v3/marketing/favor/stocks/%s/start", this.payService.getPayBaseUrl(), stockId); + public FavorStocksPauseResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException { + String url = String.format("%s/v3/marketing/favor/stocks/%s/pause", this.payService.getPayBaseUrl(), stockId); RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); - return GSON.fromJson(result, FavorStocksStartResult.class); + return GSON.fromJson(result, FavorStocksPauseResult.class); } @Override - public FavorStocksStartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException { - String url = String.format("%s/v3/marketing/favor/stocks/%s/start", this.payService.getPayBaseUrl(), stockId); + public FavorStocksRestartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException { + String url = String.format("%s/v3/marketing/favor/stocks/%s/restart", this.payService.getPayBaseUrl(), stockId); RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); - return GSON.fromJson(result, FavorStocksStartResult.class); + return GSON.fromJson(result, FavorStocksRestartResult.class); } /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java new file mode 100644 index 0000000000..8c4568a0f8 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java @@ -0,0 +1,127 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.merchanttransfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.MerchantTransferService; +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 lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +/** + * @author glz + * created on 2022/6/11 + */ +@Slf4j +@RequiredArgsConstructor +public class MerchantTransferServiceImpl implements MerchantTransferService { + private static final Gson GSON = (new GsonBuilder()).create(); + + private final WxPayService wxPayService; + + + @Override + public TransferCreateResult createTransfer(TransferCreateRequest request) throws WxPayException { + if (StringUtils.isEmpty(request.getAppid())) { + request.setAppid(this.wxPayService.getConfig().getAppId()); + } + + String url = String.format("%s/v3/transfer/batches", this.wxPayService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.wxPayService.getConfig().getVerifier().getValidCertificate()); + + String response = wxPayService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(response, TransferCreateResult.class); + } + + @Override + public BatchesQueryResult queryWxBatches(WxBatchesQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/batch-id/%s?need_query_detail=%b", + this.wxPayService.getPayBaseUrl(), request.getBatchId(), request.getNeedQueryDetail()); + + if (request.getOffset() != null) { + url = String.format("%s&offset=%d", url, request.getOffset()); + } + if (request.getLimit() != null) { + url = String.format("%s&limit=%d", url, request.getLimit()); + } + if (request.getDetailStatus() != null && request.getDetailStatus().length() != 0) { + url = String.format("%s&detail_status=%s", url, request.getDetailStatus()); + } + + String response = wxPayService.getV3(url); + return GSON.fromJson(response, BatchesQueryResult.class); + } + + @Override + public DetailsQueryResult queryWxDetails(WxDetailsQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/batch-id/%s/details/detail-id/%s", + this.wxPayService.getPayBaseUrl(), request.getBatchId(), request.getDetailId()); + String response = wxPayService.getV3(url); + return GSON.fromJson(response, DetailsQueryResult.class); + } + + @Override + public BatchesQueryResult queryMerchantBatches(MerchantBatchesQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/out-batch-no/%s?need_query_detail=%b", + this.wxPayService.getPayBaseUrl(), request.getOutBatchNo(), request.getNeedQueryDetail()); + + if (request.getOffset() != null) { + url = String.format("%s&offset=%d", url, request.getOffset()); + } + if (request.getLimit() != null) { + url = String.format("%s&limit=%d", url, request.getLimit()); + } + if (request.getDetailStatus() != null && request.getDetailStatus().length() != 0) { + url = String.format("%s&detail_status=%s", url, request.getDetailStatus()); + } + + String response = wxPayService.getV3(url); + return GSON.fromJson(response, BatchesQueryResult.class); + } + + @Override + public DetailsQueryResult queryMerchantDetails(MerchantDetailsQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/out-batch-no/%s/details/out-detail-no/%s", + this.wxPayService.getPayBaseUrl(), request.getOutBatchNo(), request.getOutDetailNo()); + String response = wxPayService.getV3(url); + return GSON.fromJson(response, DetailsQueryResult.class); + } + + @Override + public ElectronicBillResult applyElectronicBill(ElectronicBillApplyRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/bill-receipt", this.wxPayService.getPayBaseUrl()); + String response = wxPayService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, ElectronicBillResult.class); + } + + @Override + public ElectronicBillResult queryElectronicBill(String outBatchNo) throws WxPayException { + String url = String.format("%s/v3/transfer/bill-receipt/%s", this.wxPayService.getPayBaseUrl(), outBatchNo); + String response = wxPayService.getV3(url); + return GSON.fromJson(response, ElectronicBillResult.class); + } + + @Override + public DetailElectronicBillResult applyDetailElectronicBill(DetailElectronicBillRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer-detail/electronic-receipts", this.wxPayService.getPayBaseUrl()); + String response = wxPayService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, DetailElectronicBillResult.class); + } + + @Override + public DetailElectronicBillResult queryDetailElectronicBill(DetailElectronicBillRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer-detail/electronic-receipts?accept_type=%s&out_detail_no=%s", + this.wxPayService.getPayBaseUrl(), request.getAcceptType(), request.getOutDetailNo()); + + if (StringUtils.isNotEmpty(request.getOutBatchNo())) { + url = String.format("%s&out_batch_no=%s", url, request.getOutBatchNo()); + } + + String response = wxPayService.getV3(url); + return GSON.fromJson(response, DetailElectronicBillResult.class); + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreServiceImpl.java new file mode 100644 index 0000000000..55c913e79c --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreServiceImpl.java @@ -0,0 +1,354 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; +import com.github.binarywang.wxpay.bean.payscore.*; +import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.PartnerPayScoreService; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.v3.util.AesUtils; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.client.utils.URIBuilder; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @author hallkk + * created on 2022/05/18 + */ +@RequiredArgsConstructor +public class PartnerPayScoreServiceImpl implements PartnerPayScoreService { + private static final Gson GSON = new GsonBuilder().create(); + private final WxPayService payService; + + @Override + public WxPartnerPayScoreResult permissions(WxPartnerPayScoreRequest request) throws WxPayException { + String url = this.payService.getPayBaseUrl() + "/v3/payscore/partner/permissions"; + request.setAppid(request.getAppid()); + request.setServiceId(request.getServiceId()); + WxPayConfig config = this.payService.getConfig(); + if(StringUtils.isBlank(request.getAppid())){ + request.setAppid(config.getAppId()); + } + if(StringUtils.isBlank((request.getServiceId()))){ + request.setServiceId(config.getServiceId()); + } + if (StringUtils.isBlank(request.getNotifyUrl())) { + request.setNotifyUrl(config.getPayScorePermissionNotifyUrl()); + } + if (StringUtils.isBlank(request.getAuthorizationCode())) { + throw new WxPayException("authorizationCode不允许为空"); + } + String result = this.payService.postV3(url, request.toJson()); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerPayScoreResult permissionsQueryByAuthorizationCode(String serviceId, String subMchid, String authorizationCode) throws WxPayException { + if (StringUtils.isBlank(authorizationCode)) { + throw new WxPayException("authorizationCode不允许为空"); + } + String url = String.format("%s/v3/payscore/partner/permissions/authorization-code/%s", this.payService.getPayBaseUrl(), authorizationCode); + URIBuilder uriBuilder; + try { + uriBuilder = new URIBuilder(url); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + + uriBuilder.setParameter("service_id", serviceId); + uriBuilder.setParameter("sub_mchid", subMchid); + try { + String result = payService.getV3(uriBuilder.build().toString()); + return WxPartnerPayScoreResult.fromJson(result); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + } + + @Override + public WxPartnerPayScoreResult permissionsTerminateByAuthorizationCode(String serviceId, String subMchid, + String authorizationCode, String reason) throws WxPayException { + if (StringUtils.isBlank(authorizationCode)) { + throw new WxPayException("authorizationCode不允许为空"); + } + String url = String.format( + "%s/v3/payscore/partner/permissions/authorization-code/%s/terminate", + this.payService.getPayBaseUrl(), + authorizationCode + ); + Map map = new HashMap<>(4); + map.put("service_id", serviceId); + map.put("sub_mchid", subMchid); + map.put("reason", reason); + String result = payService.postV3(url, WxGsonBuilder.create().toJson(map)); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerPayScoreResult permissionsQueryByOpenId(String serviceId, String appId, String subMchid, + String subAppid, String openId, String subOpenid) throws WxPayException { + if (StringUtils.isAllEmpty(openId, subOpenid) || !StringUtils.isAnyEmpty(openId, subOpenid)) { + throw new WxPayException("open_id,sub_openid不允许都填写或都不填写"); + } + if (StringUtils.isBlank(subMchid)) { + throw new WxPayException("sub_mchid不允许都为空"); + } + String url = String.format("%s/v3/payscore/partner/permissions/search?", this.payService.getPayBaseUrl(), openId); + URIBuilder uriBuilder; + try { + uriBuilder = new URIBuilder(url); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + + uriBuilder.setParameter("appid", appId); + uriBuilder.setParameter("service_id", serviceId); + uriBuilder.setParameter("sub_mchid", subMchid); + uriBuilder.setParameter("sub_appid", subAppid); + uriBuilder.setParameter("openid", openId); + uriBuilder.setParameter("sub_openid", subOpenid); + + if (StringUtils.isNotEmpty(openId)) { + uriBuilder.setParameter("openid", openId); + } + if (StringUtils.isNotEmpty(subOpenid)) { + uriBuilder.setParameter("sub_openid", subOpenid); + } + + try { + String result = payService.getV3(uriBuilder.build().toString()); + return WxPartnerPayScoreResult.fromJson(result); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + } + + @Override + public WxPartnerPayScoreResult permissionsTerminateByOpenId(String serviceId, String appId, String subMchid, String subAppid, String openId, String subOpenid, String reason) throws WxPayException { + if (StringUtils.isAllEmpty(openId, subOpenid) || !StringUtils.isAnyEmpty(openId, subOpenid)) { + throw new WxPayException("open_id,sub_openid不允许都填写或都不填写"); + } + String url = String.format("%s/v3/payscore/partner/permissions/terminate", this.payService.getPayBaseUrl(), openId); + Map map = new HashMap<>(4); + map.put("appid", appId); + map.put("sub_appid", subAppid); + map.put("service_id", serviceId); + if (StringUtils.isNotEmpty(openId)) { + map.put("openid", openId); + } + if (StringUtils.isNotEmpty(subOpenid)) { + map.put("sub_openid", subOpenid); + } + map.put("sub_mchid", subMchid); + map.put("reason", reason); + String result = payService.postV3(url, WxGsonBuilder.create().toJson(map)); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerPayScoreResult createServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException { + String url = this.payService.getPayBaseUrl() + "/v3/payscore/partner/serviceorder"; + + WxPayConfig config = this.payService.getConfig(); + if(StringUtils.isBlank(request.getAppid())){ + request.setAppid(config.getAppId()); + } + if(StringUtils.isBlank((request.getServiceId()))){ + request.setServiceId(config.getServiceId()); + } + if(StringUtils.isBlank((request.getNotifyUrl()))){ + request.setNotifyUrl(config.getPayScoreNotifyUrl()); + } + String result = this.payService.postV3(url, request.toJson()); + + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerPayScoreResult queryServiceOrder(String serviceId, String subMchid, String outOrderNo, + String queryId) throws WxPayException { + String url = this.payService.getPayBaseUrl() + "/v3/payscore/partner/serviceorder"; + + URIBuilder uriBuilder; + try { + uriBuilder = new URIBuilder(url); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + uriBuilder.setParameter("service_id", serviceId); + uriBuilder.setParameter("sub_mchid", subMchid); + if (StringUtils.isAllEmpty(outOrderNo, queryId) || !StringUtils.isAnyEmpty(outOrderNo, queryId)) { + throw new WxPayException("out_order_no,query_id不允许都填写或都不填写"); + } + if (StringUtils.isNotEmpty(outOrderNo)) { + uriBuilder.setParameter("out_order_no", outOrderNo); + } + if (StringUtils.isNotEmpty(queryId)) { + uriBuilder.setParameter("query_id", queryId); + } + + try { + String result = payService.getV3(uriBuilder.build().toString()); + return WxPartnerPayScoreResult.fromJson(result); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + } + + @Override + public WxPartnerPayScoreResult cancelServiceOrder(String serviceId, String appId, String subMchid, String outOrderNo, String reason) throws WxPayException { + String url = String.format("%s/v3/payscore/partner/serviceorder/%s/cancel", this.payService.getPayBaseUrl(), outOrderNo); + Map map = new HashMap<>(4); + map.put("appid", appId); + map.put("service_id", serviceId); + map.put("sub_mchid", subMchid); + map.put("reason", reason); + if (StringUtils.isAnyEmpty(appId, serviceId, subMchid, reason)) { + throw new WxPayException("appid, service_id, sub_mchid, reason都不能为空"); + } + String result = payService.postV3(url, WxGsonBuilder.create().toJson(map)); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerPayScoreResult modifyServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException { + String outOrderNo = request.getOutOrderNo(); + String url = String.format("%s/v3/payscore/partner/serviceorder/%s/modify", this.payService.getPayBaseUrl(), outOrderNo); + request.setAppid(this.payService.getConfig().getAppId()); + request.setOutOrderNo(null); + String result = payService.postV3(url, request.toJson()); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public void completeServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException { + String outOrderNo = request.getOutOrderNo(); + String url = String.format("%s/v3/payscore/partner/serviceorder/%s/complete", this.payService.getPayBaseUrl(), outOrderNo); + WxPayConfig config = this.payService.getConfig(); + if (StringUtils.isBlank(request.getServiceId())) { + request.setServiceId(config.getServiceId()); + } + if (StringUtils.isBlank(request.getSubMchid())) { + request.setSubMchid(config.getSubMchId()); + } + request.setOutOrderNo(null); + this.payService.postV3(url, request.toJson()); + } + + @Override + public WxPartnerPayScoreResult payServiceOrder(String serviceId, String appId, String subMchid, String outOrderNo) throws WxPayException { + String url = String.format("%s/v3/payscore/partner/serviceorder/%s/pay", this.payService.getPayBaseUrl(), outOrderNo); + Map map = new HashMap<>(3); + map.put("appid", appId); + map.put("service_id", serviceId); + map.put("sub_mchid", subMchid); + if (StringUtils.isAnyEmpty(appId, serviceId, subMchid)) { + throw new WxPayException("appid, service_id, sub_mchid都不能为空"); + } + String result = payService.postV3(url, WxGsonBuilder.create().toJson(map)); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerPayScoreResult syncServiceOrder(WxPartnerPayScoreRequest request) throws WxPayException { + String outOrderNo = request.getOutOrderNo(); + String url = String.format("%s/v3/payscore/partner/serviceorder/%s/sync", this.payService.getPayBaseUrl(), outOrderNo); + if (StringUtils.isBlank(request.getAppid())) { + request.setAppid(this.payService.getConfig().getAppId()); + } + request.setOutOrderNo(null); + String result = payService.postV3(url, request.toJson()); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerPayScoreResult applyServiceAccount(WxPartnerPayScoreRequest request) throws WxPayException { + String url = String.format("%s/v3/payscore/partner/service-account-applications", this.payService.getPayBaseUrl()); + Map params = Maps.newHashMap(); + params.put("service_id", request.getServiceId()); + params.put("appid", request.getAppid()); + params.put("sub_mchid", request.getSubMchid()); + params.put("sub_appid", request.getSubAppid()); + params.put("out_apply_no", request.getOutApplyNo()); + params.put("result_notify_url", request.getResultNotifyUrl()); + + String result = payService.postV3(url, WxGsonBuilder.create().toJson(params)); + return WxPartnerPayScoreResult.fromJson(result); + + } + + @Override + public WxPartnerPayScoreResult queryServiceAccountState(String outApplyNo) throws WxPayException { + String url = String.format("%s/v3/payscore/partner/service-account-applications/%s", this.payService.getPayBaseUrl(), outApplyNo); + String result = payService.getV3(url); + return WxPartnerPayScoreResult.fromJson(result); + } + + @Override + public WxPartnerUserAuthorizationStatusNotifyResult parseUserAuthorizationStatusNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { + PayScoreNotifyData response = parseNotifyData(notifyData, header); + PayScoreNotifyData.Resource resource = response.getResource(); + String cipherText = resource.getCipherText(); + String associatedData = resource.getAssociatedData(); + String nonce = resource.getNonce(); + String apiV3Key = this.payService.getConfig().getApiV3Key(); + try { + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); + WxPartnerUserAuthorizationStatusNotifyResult notifyResult = GSON.fromJson(result, WxPartnerUserAuthorizationStatusNotifyResult.class); + notifyResult.setRawData(response); + return notifyResult; + } catch (GeneralSecurityException | IOException e) { + throw new WxPayException("解析报文异常!", e); + } + } + + @Override + public PayScoreNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException { + if (Objects.nonNull(header) && !this.verifyNotifySign(header, data)) { + throw new WxPayException("非法请求,头部信息验证失败"); + } + return GSON.fromJson(data, PayScoreNotifyData.class); + } + + @Override + public WxPartnerPayScoreResult decryptNotifyDataResource(PayScoreNotifyData data) throws WxPayException { + PayScoreNotifyData.Resource resource = data.getResource(); + String cipherText = resource.getCipherText(); + String associatedData = resource.getAssociatedData(); + String nonce = resource.getNonce(); + String apiV3Key = this.payService.getConfig().getApiV3Key(); + try { + return WxPartnerPayScoreResult.fromJson(AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key)); + } catch (GeneralSecurityException | IOException e) { + throw new WxPayException("解析报文异常!", e); + } + } + + /** + * 校验通知签名 + * + * @param header 通知头信息 + * @param data 通知数据 + * @return true:校验通过 false:校验不通过 + */ + private boolean verifyNotifySign(SignatureHeader header, String data) { + String beforeSign = String.format("%s\n%s\n%s\n", header.getTimeStamp(), header.getNonce(), data); + return this.payService.getConfig().getVerifier().verify( + header.getSerialNo(), + beforeSign.getBytes(StandardCharsets.UTF_8), + header.getSigned() + ); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreSignPlanServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreSignPlanServiceImpl.java new file mode 100644 index 0000000000..e81454bb75 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreSignPlanServiceImpl.java @@ -0,0 +1,308 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; +import com.github.binarywang.wxpay.bean.payscore.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.PartnerPayScoreService; +import com.github.binarywang.wxpay.service.PartnerPayScoreSignPlanService; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.v3.util.AesUtils; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import lombok.RequiredArgsConstructor; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.client.utils.URIBuilder; +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.util.Map; +import java.util.Objects; + + +/** + * @author UltramanNoa + * @className PartnerPayScoreSignPlanServiceImpl + * @description 微信支付分签约计划接口实现 + * @createTime 2023/11/3 09:23 + * + *
+ * @apiNote 微信支付分签约计划
+ * 
+ * 文档更新时间:2023.10.13 + *
+ * 微信支付分签约计划是不同模式的支付分接口(随着国家大力推广教培行业先享后付政策,微信支付也紧跟政策于2023.07.25上线第一版签约计划接口以适用教培行业先享后付。于2023.10.13文档推至官网文档中心) + *
+ * 免确认/需确认 用服务商创单接口 {@link PartnerPayScoreService} 需要用户授权 + *
+ * 签约计划,用单独创单接口 {@link PartnerPayScoreSignPlanService} 不需要用户授权 + *
+ **/ +@RequiredArgsConstructor +public class PartnerPayScoreSignPlanServiceImpl implements PartnerPayScoreSignPlanService { + private static final Gson GSON = new GsonBuilder().create(); + private final WxPayService payService ; + + /** + *

description:创建支付分计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 11:58

+ *

version: v.1.0

+ * + * @param request {@link WxPartnerPayScoreSignPlanRequest} + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 创建支付分计划 + **/ + @Override + public WxPartnerPayScoreSignPlanResult createPlans(WxPartnerPayScoreSignPlanRequest request) throws WxPayException { + String url = String.format("%s/v3/payscore/plan/partner/payscore-plans", payService.getPayBaseUrl()); + + if (StringUtils.isBlank(request.getAppid())) { + request.setAppid(payService.getConfig().getAppId()); + } + if (StringUtils.isBlank((request.getServiceId()))) { + request.setServiceId(payService.getConfig().getServiceId()); + } + + String result = payService.postV3(url, request.toJson()); + return WxPartnerPayScoreSignPlanResult.fromJson(result); + } + + /** + *

description: 查询支付分计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 14:03

+ *

version: v.1.0

+ * + * @param merchantPlanNo 路径参数:支付分计划商户侧单号 + * @param subMchid 子商户号 + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 查询支付分计划 + **/ + @Override + public WxPartnerPayScoreSignPlanResult queryPlans(@NonNull String merchantPlanNo, @NonNull String subMchid) throws WxPayException { + String url = String.format("%s/v3/payscore/plan/partner/payscore-plans/merchant-plan-no/%s", payService.getPayBaseUrl(), merchantPlanNo); + + try { + URI uri = new URIBuilder(url) + .setParameter("sub_mchid", subMchid) + .build(); + + String result = payService.getV3(uri.toString()); + + return WxPartnerPayScoreSignPlanResult.fromJson(result); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + } + + /** + *

description: 停止支付分计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 14:24

+ *

version: v.1.0

+ * + * @param merchantPlanNo 路径参数:支付分计划商户侧单号 + * @param subMchid 子商户号 + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 停止支付分计划 + **/ + @Override + public WxPartnerPayScoreSignPlanResult stopPlans(@NonNull String merchantPlanNo, @NonNull String subMchid) throws WxPayException { + String url = String.format("%s/v3/payscore/plan/partner/payscore-plans/merchant-plan-no/%s/stop", payService.getPayBaseUrl(), merchantPlanNo); + + Map params = Maps.newHashMap(); + params.put("sub_mchid", subMchid); + + String result = payService.postV3(url, WxGsonBuilder.create().toJson(params)); + return WxPartnerPayScoreSignPlanResult.fromJson(result); + } + + /** + *

description: 创建用户的签约计划详情对应的服务订单

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 14:53

+ *

version: v.1.0

+ * + * @param request {@link WxPartnerPayScoreSignPlanRequest} + * + * @return {@link WxPartnerPayScoreSignPlanResult} + * @apiNote 创建用户的签约计划详情对应的服务订单 + **/ + @Override + public WxPartnerPayScoreSignPlanResult signPlanServiceOrder(WxPartnerPayScoreSignPlanRequest request) throws WxPayException { + String url = String.format("%s/v3/payscore/sign-plan/partner/serviceorder", payService.getPayBaseUrl()); + + if (StringUtils.isBlank(request.getAppid())) { + request.setAppid(payService.getConfig().getAppId()); + } + if (StringUtils.isBlank((request.getServiceId()))) { + request.setServiceId(payService.getConfig().getServiceId()); + } + + String result = payService.postV3(url, request.toJson()); + return WxPartnerPayScoreSignPlanResult.fromJson(result); + } + + /** + *

description: 创建用户的签约计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 17:48

+ *

version: v.1.0

+ * + * @param request {@link WxPartnerPayScoreSignPlanRequest} + * + * @return {@link WxPartnerPayScoreUserSignPlanResult} + * @apiNote 创建用户的签约计划 + **/ + @Override + public WxPartnerPayScoreUserSignPlanResult createUserSignPlans(WxPartnerPayScoreSignPlanRequest request) throws WxPayException { + String url = String.format("%s/v3/payscore/sign-plan/partner/user-sign-plans", payService.getPayBaseUrl()); + + if (StringUtils.isBlank(request.getAppid())) { + request.setAppid(payService.getConfig().getAppId()); + } + if (StringUtils.isBlank((request.getServiceId()))) { + request.setServiceId(payService.getConfig().getServiceId()); + } + + String result = payService.postV3(url, request.toJson()); + return WxPartnerPayScoreUserSignPlanResult.fromJson(result); + } + + /** + *

description: 查询用户的签约计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 18:01

+ *

version: v.1.0

+ * + * @param merchantSignPlanNo 路径参数 商户签约计划号 + * @param subMchid 子商户号 + * + * @return {@link PartnerUserSignPlanEntity} + * @apiNote 查询用户的签约计划 + **/ + @Override + public PartnerUserSignPlanEntity queryUserSignPlans(@NonNull String merchantSignPlanNo, @NonNull String subMchid) throws WxPayException { + String url = String.format("%s/v3/payscore/sign-plan/partner/user-sign-plans/merchant-sign-plan-no/%s", payService.getPayBaseUrl(), merchantSignPlanNo); + + try { + URI uri = new URIBuilder(url) + .setParameter("sub_mchid", subMchid) + .build(); + + String result = payService.getV3(uri.toString()); + + return PartnerUserSignPlanEntity.fromJson(result); + } catch (URISyntaxException e) { + throw new WxPayException("未知异常!", e); + } + } + + /** + *

description: 取消用户的签约计划

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 18:01

+ *

version: v.1.0

+ * + * @param merchantSignPlanNo 路径参数 商户签约计划号 subMchid – 子商户号 + * @param subMchid 子商户号 + * @param stopReason 停止签约计划原因 + * + * @return {@link PartnerUserSignPlanEntity} + * @apiNote 取消用户的签约计划 + **/ + @Override + public PartnerUserSignPlanEntity stopUserSignPlans(@NonNull String merchantSignPlanNo, @NonNull String subMchid, @NonNull String stopReason) throws WxPayException { + String url = String.format("%s/v3/payscore/sign-plan/partner/user-sign-plans/merchant-sign-plan-no/%s/stop", payService.getPayBaseUrl(), merchantSignPlanNo); + + Map params = Maps.newHashMap(); + params.put("sub_mchid", subMchid); + params.put("stop_reason", stopReason); + + String result = payService.postV3(url, WxGsonBuilder.create().toJson(params)); + return PartnerUserSignPlanEntity.fromJson(result); + } + + + /** + *

description:回调通知

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 18:28

+ *

version: v.1.0

+ * + * @param notifyData 回调参数 + * @param header 签名 + * + * @return {@link PartnerUserSignPlanEntity} + **/ + @Override + public PartnerUserSignPlanEntity parseSignPlanNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { + PayScoreNotifyData response = parseNotifyData(notifyData, header); + return decryptNotifyDataResource(response); + } + + /** + *

description: 检验并解析通知参数

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 18:30

+ *

version: v.1.0

+ * @param data + * @param header + * @return {@link PayScoreNotifyData} + **/ + public PayScoreNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException { + if (Objects.nonNull(header) && !verifyNotifySign(header, data)) { + throw new WxPayException("非法请求,头部信息验证失败"); + } + return GSON.fromJson(data, PayScoreNotifyData.class); + } + + /** + *

description: 解析回调通知参数

+ *

author:UltramanNoa

+ *

create Time: 2023/11/3 18:27

+ *

version: v.1.0

+ * + * @param data {@link PayScoreNotifyData} + * + * @return {@link PartnerUserSignPlanEntity} + **/ + public PartnerUserSignPlanEntity decryptNotifyDataResource(PayScoreNotifyData data) throws WxPayException { + PayScoreNotifyData.Resource resource = data.getResource(); + String cipherText = resource.getCipherText(); + String associatedData = resource.getAssociatedData(); + String nonce = resource.getNonce(); + String apiV3Key = payService.getConfig().getApiV3Key(); + try { + return PartnerUserSignPlanEntity.fromJson(AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key)); + } catch (GeneralSecurityException | IOException e) { + throw new WxPayException("解析报文异常!", e); + } + } + + /** + * 校验通知签名 + * + * @param header 通知头信息 + * @param data 通知数据 + * + * @return true:校验通过 false:校验不通过 + */ + private boolean verifyNotifySign(SignatureHeader header, String data) { + String beforeSign = String.format("%s\n%s\n%s\n", header.getTimeStamp(), header.getNonce(), data); + return this.payService.getConfig().getVerifier().verify( + header.getSerialNo(), + beforeSign.getBytes(StandardCharsets.UTF_8), + header.getSigned() + ); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImpl.java new file mode 100644 index 0000000000..d5ee9dfebb --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImpl.java @@ -0,0 +1,330 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.ecommerce.FundBalanceResult; +import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum; +import com.github.binarywang.wxpay.bean.marketing.transfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.PartnerTransferService; +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 jodd.util.StringUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import java.io.InputStream; + +/** + * 批量转账到零钱(服务商) + * + * @author xiaoqiang + * created on 2021-12-06 + */ +@Slf4j +@RequiredArgsConstructor +public class PartnerTransferServiceImpl implements PartnerTransferService { + + private static final Gson GSON = new GsonBuilder().create(); + private final WxPayService payService; + + /** + * 发起批量转账API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches + * 请求方式:POST + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request 请求对象 + * @return 返回数据 {@link PartnerTransferResult} + * @throws WxPayException the wx pay exception + */ + @Override + public PartnerTransferResult batchTransfer(PartnerTransferRequest request) throws WxPayException { + request.getTransferDetailList().forEach(p -> { + try { + String userName = RsaCryptoUtil.encryptOAEP(p.getUserName(), + this.payService.getConfig().getVerifier().getValidCertificate()); + p.setUserName(userName); + + if (StringUtil.isNotBlank(p.getUserIdCard())) { + String userIdCard = RsaCryptoUtil.encryptOAEP(p.getUserIdCard(), + this.payService.getConfig().getVerifier().getValidCertificate()); + p.setUserIdCard(userIdCard); + } + } catch (IllegalBlockSizeException e) { + throw new RuntimeException("姓名或身份证转换异常!", e); + } + }); + String url = String.format("%s/v3/partner-transfer/batches", this.payService.getPayBaseUrl()); + String response = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(response, PartnerTransferResult.class); + } + + /** + * 微信支付批次单号查询批次单API + * 接口说明 + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/batch-id/{batch_id} + * https://api.mch.weixin.qq.com/v3/partner-transfer/batches/batch-id/1030000071100999991182020050700019480001 + * ?need_query_detail=true&offset=1 + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request 请求对象 + * @return 返回数据 {@link BatchNumberResult} + * @throws WxPayException the wx pay exception + */ + @Override + public BatchNumberResult queryBatchByBatchId(BatchNumberRequest request) throws WxPayException { + String url = String.format("%s/v3/partner-transfer/batches/batch-id/%s", this.payService.getPayBaseUrl(), + request.getBatchId()); + if (request.getOffset() == null) { + request.setOffset(0); + } + if (request.getLimit() == null || request.getLimit() <= 0) { + request.setLimit(20); + } + String detailStatus = StringUtil.isNotBlank(request.getDetailStatus()) ? request.getDetailStatus() : "ALL"; + + String query = String.format("?need_query_detail=%s&detail_status=%s&offset=%s&limit=%s", + request.getNeedQueryDetail(), detailStatus, request.getOffset(), request.getLimit()); + String response = this.payService.getV3(url + query); + return GSON.fromJson(response, BatchNumberResult.class); + } + + /** + * 商家批次单号查询批次单API + * 接口说明 + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/out-batch-no/{out_batch_no} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param request 请求对象 + * @return 返回数据 {@link BatchNumberResult} + * @throws WxPayException the wx pay exception + */ + @Override + public BatchNumberResult queryBatchByOutBatchNo(MerchantBatchRequest request) throws WxPayException { + String url = String.format("%s/v3/partner-transfer/batches/out-batch-no/%s", this.payService.getPayBaseUrl(), + request.getOutBatchNo()); + if (request.getOffset() == null) { + request.setOffset(0); + } + if (request.getLimit() == null || request.getLimit() <= 0) { + request.setLimit(20); + } + String query = String.format("?need_query_detail=%s&offset=%s&limit=%s", request.getNeedQueryDetail(), + request.getOffset(), request.getLimit()); + if (StringUtil.isNotBlank(request.getDetailStatus())) { + query += "&detail_status=" + request.getDetailStatus(); + } + String response = this.payService.getV3(url + query); + return GSON.fromJson(response, BatchNumberResult.class); + } + + /** + * 微信支付明细单号查询明细单API + * 接口说明 + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/batch-id/{batch_id}/details/detail-id/{detail_id} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param batchId 微信批次单号 + * @param detailId 微信明细单号 + * @return 返回数据 {@link BatchDetailsResult} + * @throws WxPayException the wx pay exception + * @throws BadPaddingException the wx decrypt exception + */ + @Override + public BatchDetailsResult queryBatchDetailByWeChat(String batchId, String detailId) throws WxPayException, + BadPaddingException { + String url = String.format("%s/v3/partner-transfer/batches/batch-id/%s/details/detail-id/%s", + this.payService.getPayBaseUrl(), batchId, detailId); + String response = this.payService.getV3(url); + BatchDetailsResult batchDetailsResult = GSON.fromJson(response, BatchDetailsResult.class); + String userName = RsaCryptoUtil.decryptOAEP(batchDetailsResult.getUserName(), + this.payService.getConfig().getPrivateKey()); + batchDetailsResult.setUserName(userName); + return batchDetailsResult; + } + + /** + * 商家明细单号查询明细单API + * 接口说明 + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/partner-transfer/batches/out-batch-no/{out_batch_no}/details/out-detail + * -no/{out_detail_no} + * 请求方式:GET + * 接口限频:单个服务商 50QPS,如果超过频率限制,会报错FREQUENCY_LIMITED,请降低频率请求。 + * + * @param outBatchNo 商家明细单号 + * @param outDetailNo 商家批次单号 + * @return 返回数据 {@link BatchDetailsResult} + * @throws WxPayException the wx pay exception + * @throws BadPaddingException the wx decrypt exception + */ + @Override + public BatchDetailsResult queryBatchDetailByMch(String outBatchNo, String outDetailNo) throws WxPayException, + BadPaddingException { + String url = String.format("%s/v3/partner-transfer/batches/out-batch-no/%s/details/out-detail-no/%s", + this.payService.getPayBaseUrl(), outBatchNo, outDetailNo); + String response = this.payService.getV3(url); + BatchDetailsResult batchDetailsResult = GSON.fromJson(response, BatchDetailsResult.class); + String userName = RsaCryptoUtil.decryptOAEP(batchDetailsResult.getUserName(), + this.payService.getConfig().getPrivateKey()); + batchDetailsResult.setUserName(userName); + return batchDetailsResult; + } + + + /** + * 转账电子回单申请受理API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_1.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/bill-receipt + * 请求方式:POST + * + * @param request 商家批次单号 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + @Override + public BillReceiptResult receiptBill(ReceiptBillRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/bill-receipt", this.payService.getPayBaseUrl()); + String response = this.payService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, BillReceiptResult.class); + } + + + /** + * 查询转账电子回单API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_2.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer/bill-receipt/{out_batch_no} + * 请求方式:GET + * + * @param outBatchNo 商家批次单号 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + @Override + public BillReceiptResult queryBillReceipt(String outBatchNo) throws WxPayException { + String url = String.format("%s/v3/transfer/bill-receipt/%s", this.payService.getPayBaseUrl(), outBatchNo); + String response = this.payService.getV3(url); + return GSON.fromJson(response, BillReceiptResult.class); + } + + /** + * 转账明细电子回单受理API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_4.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:POST + * 前置条件:只支持受理最近90天内的转账明细单 + * + * @param request 请求对象 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + @Override + public ElectronicReceiptsResult transferElectronic(ElectronicReceiptsRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer-detail/electronic-receipts", this.payService.getPayBaseUrl()); + String response = this.payService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, ElectronicReceiptsResult.class); + } + + + /** + * 查询转账明细电子回单受理结果API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_5.shtml + * 请求URL:https://api.mch.weixin.qq.com/v3/transfer-detail/electronic-receipts + * 请求方式:GET + * 前置条件:只支持查询最近90天内的转账明细单 + * + * @param request 请求对象 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + @Override + public ElectronicReceiptsResult queryTransferElectronicResult(ElectronicReceiptsRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer-detail/electronic-receipts", this.payService.getPayBaseUrl()); + String query = String.format("?accept_type=%s&out_batch_no=%s&out_detail_no=%s", request.getAcceptType(), + request.getOutBatchNo(), request.getOutDetailNo()); + String response = this.payService.getV3(url + query); + return GSON.fromJson(response, ElectronicReceiptsResult.class); + } + + /** + * 下载电子回单API + * 接口说明 + * 适用对象:直连商户 服务商 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter4_3.shtml + * 请求URL:通过申请账单接口获取到“download_url”,URL有效期10min + * 请求方式:GET + * 前置条件:调用申请账单接口并获取到“download_url” + * + * @param url 微信返回的电子回单地址。 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + @Override + public InputStream transferDownload(String url) throws WxPayException { + InputStream response = this.payService.downloadV3(url); + return response; + } + + /** + *
+   * 查询账户实时余额API
+   * 接口说明
+   * 适用对象:直连商户 服务商
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter5_1.shtml
+   * 请求URL:https://api.mch.weixin.qq.com/v3/merchant/fund/balance/{account_type}
+   * 请求方式:GET
+   * 
+ * + * @param accountType 服务商账户类型 {@link SpAccountTypeEnum} + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + @Override + public FundBalanceResult fundBalance(SpAccountTypeEnum accountType) throws WxPayException { + String url = String.format("%s/v3/merchant/fund/balance/%s", this.payService.getPayBaseUrl(), accountType); + String response = this.payService.getV3(url); + return GSON.fromJson(response, FundBalanceResult.class); + } + + /** + *
+   * 服务商账户日终余额
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer/chapter5_2.shtml
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/amount.shtml
+   * 
+ * + * @param accountType 服务商账户类型 + * @param date 查询日期 2020-09-11 + * @return 返回数据 fund balance result + * @throws WxPayException the wx pay exception + */ + @Override + public FundBalanceResult spDayEndBalance(SpAccountTypeEnum accountType, String date) { + try { + return this.payService.getEcommerceService().spDayEndBalance(accountType, date); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java index 0b237fda34..ed36bd7f08 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java @@ -10,6 +10,7 @@ import com.github.binarywang.wxpay.service.PayScoreService; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.v3.util.AesUtils; +import com.google.common.base.Strings; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lombok.RequiredArgsConstructor; @@ -27,7 +28,7 @@ /** * @author doger.wang - * @date 2020/5/14 9:43 + * created on 2020/5/14 9:43 */ @RequiredArgsConstructor public class PayScoreServiceImpl implements PayScoreService { @@ -38,17 +39,23 @@ public class PayScoreServiceImpl implements PayScoreService { public WxPayScoreResult permissions(WxPayScoreRequest request) throws WxPayException { WxPayConfig config = this.payService.getConfig(); String url = this.payService.getPayBaseUrl() + "/v3/payscore/permissions"; - request.setAppid(config.getAppId()); - request.setServiceId(config.getServiceId()); - String permissionNotifyUrl = config.getPayScorePermissionNotifyUrl(); - if (StringUtils.isBlank(permissionNotifyUrl)) { - throw new WxPayException("授权回调地址未配置"); + if(Strings.isNullOrEmpty(request.getAppid())){ + request.setAppid(config.getAppId()); + } + if(Strings.isNullOrEmpty(request.getServiceId())){ + request.setServiceId(config.getServiceId()); + } + if(Strings.isNullOrEmpty(request.getNotifyUrl())){ + String permissionNotifyUrl = config.getPayScorePermissionNotifyUrl(); + if (StringUtils.isBlank(permissionNotifyUrl)) { + throw new WxPayException("授权回调地址未配置"); + } + request.setNotifyUrl(permissionNotifyUrl); } String authorizationCode = request.getAuthorizationCode(); if (StringUtils.isBlank(authorizationCode)) { throw new WxPayException("authorizationCode不允许为空"); } - request.setNotifyUrl(permissionNotifyUrl); String result = this.payService.postV3(url, request.toJson()); return WxPayScoreResult.fromJson(result); @@ -139,9 +146,15 @@ public WxPayScoreResult createServiceOrder(WxPayScoreRequest request) throws WxP boolean needUserConfirm = request.getNeedUserConfirm(); WxPayConfig config = this.payService.getConfig(); String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder"; - request.setAppid(config.getAppId()); - request.setServiceId(config.getServiceId()); - request.setNotifyUrl(config.getPayScoreNotifyUrl()); + if(Strings.isNullOrEmpty(request.getAppid())){ + request.setAppid(config.getAppId()); + } + if(Strings.isNullOrEmpty(request.getServiceId())){ + request.setServiceId(config.getServiceId()); + } + if(Strings.isNullOrEmpty(request.getNotifyUrl())){ + request.setNotifyUrl(config.getPayScoreNotifyUrl()); + } String result = this.payService.postV3(url, request.toJson()); WxPayScoreResult wxPayScoreCreateResult = WxPayScoreResult.fromJson(result); @@ -213,8 +226,12 @@ public WxPayScoreResult modifyServiceOrder(WxPayScoreRequest request) throws WxP WxPayConfig config = this.payService.getConfig(); String outOrderNo = request.getOutOrderNo(); String url = String.format("%s/v3/payscore/serviceorder/%s/modify", this.payService.getPayBaseUrl(), outOrderNo); - request.setAppid(config.getAppId()); - request.setServiceId(config.getServiceId()); + if(Strings.isNullOrEmpty(request.getAppid())){ + request.setAppid(config.getAppId()); + } + if(Strings.isNullOrEmpty(config.getServiceId())){ + request.setServiceId(config.getServiceId()); + } request.setOutOrderNo(null); String result = payService.postV3(url, request.toJson()); return WxPayScoreResult.fromJson(result); @@ -225,8 +242,12 @@ public WxPayScoreResult completeServiceOrder(WxPayScoreRequest request) throws W WxPayConfig config = this.payService.getConfig(); String outOrderNo = request.getOutOrderNo(); String url = String.format("%s/v3/payscore/serviceorder/%s/complete", this.payService.getPayBaseUrl(), outOrderNo); - request.setAppid(config.getAppId()); - request.setServiceId(config.getServiceId()); + if(Strings.isNullOrEmpty(request.getAppid())){ + request.setAppid(config.getAppId()); + } + if(Strings.isNullOrEmpty(request.getServiceId())){ + request.setServiceId(config.getServiceId()); + } request.setOutOrderNo(null); String result = payService.postV3(url, request.toJson()); return WxPayScoreResult.fromJson(result); @@ -248,8 +269,12 @@ public WxPayScoreResult syncServiceOrder(WxPayScoreRequest request) throws WxPay WxPayConfig config = this.payService.getConfig(); String outOrderNo = request.getOutOrderNo(); String url = String.format("%s/v3/payscore/serviceorder/%s/sync", this.payService.getPayBaseUrl(), outOrderNo); - request.setAppid(config.getAppId()); - request.setServiceId(config.getServiceId()); + if(Strings.isNullOrEmpty(request.getAppid())){ + request.setAppid(config.getAppId()); + } + if(Strings.isNullOrEmpty(request.getServiceId())){ + request.setServiceId(config.getServiceId()); + } request.setOutOrderNo(null); String result = payService.postV3(url, request.toJson()); return WxPayScoreResult.fromJson(result); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayrollServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayrollServiceImpl.java new file mode 100644 index 0000000000..3d8c831271 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayrollServiceImpl.java @@ -0,0 +1,196 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.marketing.payroll.*; +import com.github.binarywang.wxpay.bean.result.WxPayApplyBillV3Result; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.PayrollService; +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 lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.crypto.IllegalBlockSizeException; + +/** + * 微信支付-微工卡 + * + * @author xiaoqiang + * created on 2021/12/2 + */ +@Slf4j +@RequiredArgsConstructor +public class PayrollServiceImpl implements PayrollService { + + private static final Gson GSON = new GsonBuilder().create(); + + private final WxPayService payService; + + /** + * 生成授权token + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/tokens + * 请求方式:POST + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + @Override + public TokensResult payrollCardTokens(TokensRequest request) throws WxPayException { + String url = String.format("%s/v3/payroll-card/tokens", payService.getPayBaseUrl()); + try { + String userName = RsaCryptoUtil.encryptOAEP(request.getUserName(), payService.getConfig().getVerifier().getValidCertificate()); + request.setUserName(userName); + String idCardNumber = RsaCryptoUtil.encryptOAEP(request.getIdCardNumber(), payService.getConfig().getVerifier().getValidCertificate()); + request.setIdCardNumber(idCardNumber); + } catch (IllegalBlockSizeException e) { + throw new RuntimeException("加密异常!", e); + } + String response = payService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, TokensResult.class); + } + + /** + * 查询微工卡授权关系API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/relations/{openid} + * 请求方式:GET + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + @Override + public RelationsResult payrollCardRelations(RelationsRequest request) throws WxPayException { + String url = String.format("%s/v3/payroll-card/relations/%s", + payService.getPayBaseUrl(), request.getOpenid()); + String query = String.format("?sub_mchid=%s", request.getSubMchid()); + if (StringUtils.isNotEmpty(request.getAppid())) { + query += "&appid=" + request.getAppid(); + } + if (StringUtils.isNotEmpty(request.getSubAppid())) { + query += "&sub_appid=" + request.getSubAppid(); + } + String response = payService.getV3(url + query); + return GSON.fromJson(response, RelationsResult.class); + } + + /** + * 微工卡核身预下单API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order + * 请求方式:POST + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + @Override + public PreOrderResult payrollCardPreOrder(PreOrderRequest request) throws WxPayException { + String url = String.format("%s/v3/payroll-card/authentications/pre-order", payService.getPayBaseUrl()); + String response = payService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, PreOrderResult.class); + } + + /** + * 获取核身结果API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/{authenticate_number} + * 请求方式:GET + * + * @param subMchid 子商户号 + * @param authenticateNumber 商家核身单号 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + @Override + public AuthenticationsResult payrollCardAuthenticationsNumber(String subMchid, String authenticateNumber) throws WxPayException { + String url = String.format("%s/v3/payroll-card/authentications/%s", payService.getPayBaseUrl(), authenticateNumber); + String query = String.format("?sub_mchid=%s", subMchid); + String response = payService.getV3(url + query); + return GSON.fromJson(response, AuthenticationsResult.class); + } + + /** + * 查询核身记录API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications + * 请求方式:GET + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + @Override + public AuthRecordResult payrollCardAuthentications(AuthRecordRequest request) throws WxPayException { + String url = String.format("%s/v3/payroll-card/authentications", payService.getPayBaseUrl()); + String query = String.format("?openid=%s&sub_mchid=%s&authenticate_date=%s", + request.getOpenid(), request.getAppid(), request.getSubMchid(), request.getAuthenticateDate()); + if (StringUtils.isNotEmpty(request.getAppid())) { + query += "&appid=" + request.getAppid(); + } + if (StringUtils.isNotEmpty(request.getAppid())) { + query += "&sub_appid=" + request.getSubAppid(); + } + if (StringUtils.isNotEmpty(request.getAuthenticateState())) { + query += "&authenticate_state=" + request.getAuthenticateState(); + } + String response = payService.getV3(url + query); + return GSON.fromJson(response, AuthRecordResult.class); + } + + /** + * 微工卡核身预下单(流程中完成授权) + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/payroll-card/authentications/pre-order-with-auth + * 请求方式:POST + * + * @param request 请求参数 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + @Override + public PreOrderWithAuthResult payrollCardPreOrderWithAuth(PreOrderWithAuthRequest request) throws WxPayException { + String url = String.format("%s/v3/payroll-card/authentications/pre-order-with-auth", payService.getPayBaseUrl()); + try { + String userName = RsaCryptoUtil.encryptOAEP(request.getUserName(), payService.getConfig().getVerifier().getValidCertificate()); + request.setUserName(userName); + String idCardNumber = RsaCryptoUtil.encryptOAEP(request.getIdCardNumber(), payService.getConfig().getVerifier().getValidCertificate()); + request.setIdCardNumber(idCardNumber); + } catch (IllegalBlockSizeException e) { + throw new RuntimeException("敏感信息加密异常!", e); + } + String response = payService.postV3(url, GSON.toJson(request)); + return GSON.fromJson(response, PreOrderWithAuthResult.class); + } + + /** + * 按日下载提现异常文件API + * 适用对象:服务商 + * 请求URL:https://api.mch.weixin.qq.com/v3/merchant/fund/withdraw/bill-type/{bill_type} + * 请求方式:GET + * + * @param billType 账单类型 + * NO_SUCC:提现异常账单,包括提现失败和提现退票账单。 + * 示例值:NO_SUCC + * @param billDate 账单日期 表示所在日期的提现账单,格式为YYYY-MM-DD。 + * 例如:2008-01-01日发起的提现,2008-01-03日银行返回提现失败,则该提现数据将出现在bill_date为2008-01-03日的账单中。 + * 示例值:2019-08-17 + * @return 返回数据 + * @throws WxPayException the wx pay exception + */ + @Override + public WxPayApplyBillV3Result merchantFundWithdrawBillType(String billType, String billDate, String tarType) throws WxPayException { + String url = String.format("%s/v3/merchant/fund/withdraw/bill-type/%s", payService.getPayBaseUrl(), billType); + String query = String.format("?bill_date=%s", billDate); + if (StringUtils.isNotBlank(tarType)) { + query += String.format("&tar_type=%s", tarType); + } + String response = payService.getV3(url + query); + return GSON.fromJson(response, WxPayApplyBillV3Result.class); + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java index 8d25a63d1a..7f46a3f303 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java @@ -1,10 +1,25 @@ package com.github.binarywang.wxpay.service.impl; -import com.github.binarywang.wxpay.bean.profitsharing.*; +import com.github.binarywang.wxpay.bean.notify.SignatureHeader; +import com.github.binarywang.wxpay.bean.profitsharing.notify.ProfitSharingNotifyV3Response; +import com.github.binarywang.wxpay.bean.profitsharing.notify.ProfitSharingNotifyV3Result; +import com.github.binarywang.wxpay.bean.profitsharing.request.*; +import com.github.binarywang.wxpay.bean.profitsharing.result.*; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.ProfitSharingService; import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.v3.auth.Verifier; +import com.github.binarywang.wxpay.v3.util.AesUtils; +import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.util.Objects; /** * @author Wang GuangXin 2019/10/22 10:13 @@ -12,6 +27,7 @@ */ public class ProfitSharingServiceImpl implements ProfitSharingService { private WxPayService payService; + private static final Gson GSON = new GsonBuilder().create(); public ProfitSharingServiceImpl(WxPayService payService) { this.payService = payService; @@ -40,7 +56,15 @@ public ProfitSharingResult multiProfitSharing(ProfitSharingRequest request) thro } @Override - public ProfitSharingResult profitSharingFinish(ProfitSharingFinishRequest request) throws WxPayException { + public ProfitSharingV3Result profitSharingV3(ProfitSharingV3Request request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/orders", this.payService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); + String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(result, ProfitSharingV3Result.class); + } + + @Override + public ProfitSharingResult profitSharingFinish(ProfitSharingUnfreezeRequest request) throws WxPayException { request.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharingfinish"; @@ -72,6 +96,22 @@ public ProfitSharingReceiverResult removeReceiver(ProfitSharingReceiverRequest r return result; } + @Override + public ProfitSharingReceiverV3Result addReceiverV3(ProfitSharingReceiverV3Request request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/receivers/add", this.payService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); + String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(result, ProfitSharingReceiverV3Result.class); + } + + @Override + public ProfitSharingReceiverV3Result removeReceiverV3(ProfitSharingReceiverV3Request request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/receivers/delete", this.payService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); + String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(result, ProfitSharingReceiverV3Result.class); + } + @Override public ProfitSharingQueryResult profitSharingQuery(ProfitSharingQueryRequest request) throws WxPayException { request.setAppid(null); @@ -86,6 +126,34 @@ public ProfitSharingQueryResult profitSharingQuery(ProfitSharingQueryRequest req return result; } + @Override + public ProfitSharingV3Result profitSharingQueryV3(String outOrderNo, String transactionId) throws WxPayException { + String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(), + outOrderNo, transactionId); + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingV3Result.class); + } + + @Override + public ProfitSharingV3Result profitSharingQueryV3(String outOrderNo, String transactionId, String subMchId) + throws WxPayException { + String url = String.format("%s/v3/profitsharing/orders/%s?sub_mchid=%s&transaction_id=%s", + this.payService.getPayBaseUrl(), outOrderNo, subMchId, transactionId); + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingV3Result.class); + } + + @Override + public ProfitSharingV3Result profitSharingQueryV3(ProfitSharingQueryV3Request request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(), + request.getOutOrderNo(), request.getOutOrderNo()); + if(StringUtils.isNotEmpty(request.getSubMchId())){ + url += "&sub_mchid=" + request.getSubMchId(); + } + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingV3Result.class); + } + @Override public ProfitSharingOrderAmountQueryResult profitSharingOrderAmountQuery(ProfitSharingOrderAmountQueryRequest request) throws WxPayException { request.checkAndSign(this.payService.getConfig()); @@ -97,6 +165,13 @@ public ProfitSharingOrderAmountQueryResult profitSharingOrderAmountQuery(ProfitS return result; } + @Override + public ProfitSharingOrderAmountQueryV3Result profitSharingUnsplitAmountQueryV3(String transactionId) throws WxPayException { + String url = String.format("%s/v3/profitsharing/transactions/%s/amounts", this.payService.getPayBaseUrl(), transactionId); + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingOrderAmountQueryV3Result.class); + } + @Override public ProfitSharingMerchantRatioQueryResult profitSharingMerchantRatioQuery(ProfitSharingMerchantRatioQueryRequest request) throws WxPayException { request.checkAndSign(this.payService.getConfig()); @@ -108,6 +183,13 @@ public ProfitSharingMerchantRatioQueryResult profitSharingMerchantRatioQuery(Pro return result; } + @Override + public ProfitSharingMerchantRatioQueryV3Result profitSharingMerchantRatioQueryV3(String subMchId) throws WxPayException { + String url = String.format("%s/v3/profitsharing/merchant-configs/%s", this.payService.getPayBaseUrl(), subMchId); + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingMerchantRatioQueryV3Result.class); + } + @Override public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest returnRequest) throws WxPayException { returnRequest.checkAndSign(this.payService.getConfig()); @@ -119,6 +201,14 @@ public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest return result; } + @Override + public ProfitSharingReturnV3Result profitSharingReturnV3(ProfitSharingReturnV3Request request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/return-orders", this.payService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); + String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(result, ProfitSharingReturnV3Result.class); + } + @Override public ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest) throws WxPayException { queryRequest.checkAndSign(this.payService.getConfig()); @@ -129,4 +219,86 @@ public ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQue result.checkResult(this.payService, queryRequest.getSignType(), true); return result; } + + @Override + public ProfitSharingReturnV3Result profitSharingReturnQueryV3(String outOrderNo, String outReturnNo) throws WxPayException { + String url = String.format("%s/v3/profitsharing/return-orders/%s?out_order_no=%s", this.payService.getPayBaseUrl(), + outReturnNo, outOrderNo); + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingReturnV3Result.class); + } + + @Override + public ProfitSharingReturnV3Result profitSharingReturnQueryV3(String outOrderNo, String outReturnNo, String subMchId) + throws WxPayException { + String url = String.format("%s/v3/profitsharing/return-orders/%s?sub_mchid=%s&out_order_no=%s", + this.payService.getPayBaseUrl(), outReturnNo, subMchId, outOrderNo); + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingReturnV3Result.class); + } + + @Override + public ProfitSharingUnfreezeV3Result profitSharingUnfreeze(ProfitSharingUnfreezeV3Request request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/orders/unfreeze", this.payService.getPayBaseUrl()); + RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); + String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(result, ProfitSharingUnfreezeV3Result.class); + } + + @Override + public ProfitSharingNotifyV3Result parseProfitSharingNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { + ProfitSharingNotifyV3Response response = parseNotifyData(notifyData, header); + ProfitSharingNotifyV3Response.Resource resource = response.getResource(); + String cipherText = resource.getCipherText(); + String associatedData = resource.getAssociatedData(); + String nonce = resource.getNonce(); + String apiV3Key = this.payService.getConfig().getApiV3Key(); + try { + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); + return GSON.fromJson(result, ProfitSharingNotifyV3Result.class); + } catch (GeneralSecurityException | IOException e) { + throw new WxPayException("解析报文异常!", e); + } + } + + @Override + public ProfitSharingBillV3Result profitSharingBill(ProfitSharingBillV3Request request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(), + request.getBillDate()); + + if (StringUtils.isNotBlank(request.getSubMchId())) { + url = String.format("%s&sub_mchid=%s", url, request.getSubMchId()); + } + if (StringUtils.isNotBlank(request.getTarType())) { + url = String.format("%s&tar_type=%s", url, request.getTarType()); + } + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingBillV3Result.class); + } + + + + private ProfitSharingNotifyV3Response parseNotifyData(String data, SignatureHeader header) throws WxPayException { + if (Objects.nonNull(header) && !this.verifyNotifySign(header, data)) { + throw new WxPayException("非法请求,头部信息验证失败"); + } + return GSON.fromJson(data, ProfitSharingNotifyV3Response.class); + } + + /** + * 校验通知签名 + * + * @param header 通知头信息 + * @param data 通知数据 + * @return true:校验通过 false:校验不通过 + */ + private boolean verifyNotifySign(SignatureHeader header, String data) throws WxPayException { + String beforeSign = String.format("%s%n%s%n%s%n", header.getTimeStamp(), header.getNonce(), data); + Verifier verifier = this.payService.getConfig().getVerifier(); + if (verifier == null) { + throw new WxPayException("证书检验对象为空"); + } + return verifier.verify(header.getSerial(), + beforeSign.getBytes(StandardCharsets.UTF_8), header.getSignature()); + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java deleted file mode 100644 index 539836de14..0000000000 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.github.binarywang.wxpay.service.impl; - -import com.github.binarywang.wxpay.bean.profitsharingV3.*; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.ProfitSharingV3Service; -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 lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -/** - * 微信支付V3-资金应用-分账Service - * - * @author pg 2021-6-23 - * @version 1.0 - */ -@Slf4j -@RequiredArgsConstructor -public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service { - private static final Gson GSON = new GsonBuilder().create(); - private final WxPayService payService; - - @Override - public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException { - String url = String.format("%s/v3/profitsharing/orders", this.payService.getPayBaseUrl()); - RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); - String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); - return GSON.fromJson(result, ProfitSharingResult.class); - } - - @Override - public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException { - String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, transactionId); - String result = this.payService.getV3(url); - return GSON.fromJson(result, ProfitSharingResult.class); - } - - @Override - public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest request) throws WxPayException { - String url = String.format("%s/v3/profitsharing/return-orders", this.payService.getPayBaseUrl()); - RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); - String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); - return GSON.fromJson(result, ProfitSharingReturnResult.class); - } - - @Override - public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException { - String url = String.format("%s/v3/profitsharing/return-orders/%s?out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, outOrderNo); - String result = this.payService.getV3(url); - return GSON.fromJson(result, ProfitSharingReturnResult.class); - } - - @Override - public ProfitSharingUnfreezeResult profitSharingUnfreeze(ProfitSharingUnfreezeRequest request) throws WxPayException { - String url = String.format("%s/v3/profitsharing/orders/unfreeze", this.payService.getPayBaseUrl()); - RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); - String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); - return GSON.fromJson(result, ProfitSharingUnfreezeResult.class); - } - - @Override - public ProfitSharingUnsplitResult getProfitSharingUnsplitAmount(String transactionId) throws WxPayException { - String url = String.format("%s/v3/profitsharing/transactions/%s/amounts", this.payService.getPayBaseUrl(), transactionId); - String result = this.payService.getV3(url); - return GSON.fromJson(result, ProfitSharingUnsplitResult.class); - } - - @Override - public ProfitSharingReceiver addProfitSharingReceiver(ProfitSharingReceiver request) throws WxPayException { - String url = String.format("%s/v3/profitsharing/receivers/add", this.payService.getPayBaseUrl()); - RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); - String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); - return GSON.fromJson(result, ProfitSharingReceiver.class); - } - - @Override - public ProfitSharingReceiver deleteProfitSharingReceiver(ProfitSharingReceiver request) throws WxPayException { - String url = String.format("%s/v3/profitsharing/receivers/delete", this.payService.getPayBaseUrl()); - RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); - String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); - return GSON.fromJson(result, ProfitSharingReceiver.class); - } -} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImpl.java index 03ce8333e2..2bdc15b6f7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImpl.java @@ -17,7 +17,7 @@ * 老板加点注释吧. * * @author Binary Wang - * @date 2019-12-26 + * created on 2019-12-26 */ @RequiredArgsConstructor public class RedpackServiceImpl implements RedpackService { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/TransferServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/TransferServiceImpl.java new file mode 100644 index 0000000000..b328ded73e --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/TransferServiceImpl.java @@ -0,0 +1,68 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.transfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.TransferService; +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 lombok.RequiredArgsConstructor; + +import java.security.cert.X509Certificate; +import java.util.List; + +/** + * 商家转账到零钱 + * + * @author zhongjun + * created on 2022/6/17 + **/ +@RequiredArgsConstructor +public class TransferServiceImpl implements TransferService { + + private static final Gson GSON = new GsonBuilder().create(); + private final WxPayService payService; + + @Override + public TransferBatchesResult transferBatches(TransferBatchesRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/batches", this.payService.getPayBaseUrl()); + List transferDetailList = request.getTransferDetailList(); + X509Certificate validCertificate = this.payService.getConfig().getVerifier().getValidCertificate(); + for (TransferBatchesRequest.TransferDetail detail : transferDetailList) { + RsaCryptoUtil.encryptFields(detail, validCertificate); + } + String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); + return GSON.fromJson(result, TransferBatchesResult.class); + } + + @Override + public QueryTransferBatchesResult transferBatchesBatchId(QueryTransferBatchesRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/batch-id/%s?need_query_detail=%s&offset=%s&limit=%s&detail_status=%s", + this.payService.getPayBaseUrl(), request.getBatchId(), request.getNeedQueryDetail(), request.getOffset(), request.getLimit(), request.getDetailStatus()); + String result = this.payService.getV3(url); + return GSON.fromJson(result, QueryTransferBatchesResult.class); + } + + @Override + public TransferBatchDetailResult transferBatchesBatchIdDetail(String batchId, String detailId) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/batch-id/%s/details/detail-id/%s", this.payService.getPayBaseUrl(), batchId, detailId); + String result = this.payService.getV3(url); + return GSON.fromJson(result, TransferBatchDetailResult.class); + } + + @Override + public QueryTransferBatchesResult transferBatchesOutBatchNo(QueryTransferBatchesRequest request) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/out-batch-no/%s?need_query_detail=%s&offset=%s&limit=%s&detail_status=%s", + this.payService.getPayBaseUrl(), request.getOutBatchNo(), request.getNeedQueryDetail(), request.getOffset(), request.getLimit(), request.getDetailStatus()); + String result = this.payService.getV3(url); + return GSON.fromJson(result, QueryTransferBatchesResult.class); + } + + @Override + public TransferBatchDetailResult transferBatchesOutBatchNoDetail(String outBatchNo, String outDetailNo) throws WxPayException { + String url = String.format("%s/v3/transfer/batches/out-batch-no/%s/details/out-detail-no/%s", this.payService.getPayBaseUrl(), outBatchNo, outDetailNo); + String result = this.payService.getV3(url); + return GSON.fromJson(result, TransferBatchDetailResult.class); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java index 7555425a81..951c1d5a8c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java @@ -15,7 +15,7 @@ /** * @author chenliang - * @date 2021-08-02 4:53 下午 + * created on 2021-08-02 4:53 下午 */ @Slf4j @RequiredArgsConstructor @@ -48,6 +48,8 @@ public String maSign(WxMaEntrustRequest wxMaEntrustRequest) throws WxPayExceptio @Override public WxH5EntrustResult h5Sign(WxH5EntrustRequest wxH5EntrustRequest) throws WxPayException { wxH5EntrustRequest.checkAndSign(payService.getConfig()); + // 微信最新接口signType不能参与签名,否则报错:签约参数签名校验错误 + wxH5EntrustRequest.setSignType(null); String sign = SignUtils.createSign(wxH5EntrustRequest, WxPayConstants.SignType.HMAC_SHA256, payService.getConfig().getMchKey(), null); /** @@ -99,6 +101,16 @@ public WxWithholdResult withhold(WxWithholdRequest wxWithholdRequest) throws WxP return result; } + @Override + public WxPayCommonResult withholdPartner(WxWithholdRequest wxWithholdRequest) throws WxPayException { + wxWithholdRequest.checkAndSign(payService.getConfig()); + String url = payService.getPayBaseUrl() + "/pay/partner/pappayapply"; + String responseContent = payService.post(url, wxWithholdRequest.toXML(), false); + WxPayCommonResult result = BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class); + result.checkResult(payService, wxWithholdRequest.getSignType(), true); + return result; + } + @Override public String preWithhold(WxPreWithholdRequest wxPreWithholdRequest) throws WxPayException { String requestParam = WxGsonBuilder.create().toJson(wxPreWithholdRequest); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index 87d5014acf..e2b6d43fa1 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -2,13 +2,12 @@ import com.github.binarywang.wxpay.bean.WxPayApiData; import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.v3.WxPayV3DownloadHttpGet; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import me.chanjar.weixin.common.util.json.GsonParser; import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; -import org.apache.http.HttpStatus; +import org.apache.http.*; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; @@ -28,6 +27,8 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.Objects; +import java.util.Optional; /** *
@@ -39,6 +40,10 @@
  */
 public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
 
+  private static final String ACCEPT = "Accept";
+  private static final String CONTENT_TYPE = "Content-Type";
+  private static final String APPLICATION_JSON = "application/json";
+
   @Override
   public byte[] postForBytes(String url, String requestStr, boolean useKey) throws WxPayException {
     try {
@@ -92,26 +97,25 @@ public String post(String url, String requestStr, boolean useKey) throws WxPayEx
   public String postV3(String url, String requestStr) throws WxPayException {
     CloseableHttpClient httpClient = this.createApiV3HttpClient();
     HttpPost httpPost = this.createHttpPost(url, requestStr);
-    httpPost.addHeader("Accept", "application/json");
-    httpPost.addHeader("Content-Type", "application/json");
+    httpPost.addHeader(ACCEPT, APPLICATION_JSON);
+    httpPost.addHeader(CONTENT_TYPE, APPLICATION_JSON);
     try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
       //v3已经改为通过状态码判断200 204 成功
       int statusCode = response.getStatusLine().getStatusCode();
       //post方法有可能会没有返回值的情况
-      String responseString;
-      if (response.getEntity() == null) {
-        responseString = null;
-      } else {
+      String responseString = null;
+      if (response.getEntity() != null) {
         responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
       }
+
       if (HttpStatus.SC_OK == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) {
         this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString);
         return responseString;
-      } else {
-        //有错误提示信息返回
-        JsonObject jsonObject = GsonParser.parse(responseString);
-        throw convertException(jsonObject);
       }
+
+      //有错误提示信息返回
+      JsonObject jsonObject = GsonParser.parse(responseString);
+      throw convertException(jsonObject);
     } catch (Exception e) {
       this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage());
       throw (e instanceof WxPayException) ? (WxPayException) e : new WxPayException(e.getMessage(), e);
@@ -134,26 +138,25 @@ public String patchV3(String url, String requestStr) throws WxPayException {
       .setSocketTimeout(this.getConfig().getHttpTimeout())
       .build());
 
-    httpPatch.addHeader("Accept", "application/json");
-    httpPatch.addHeader("Content-Type", "application/json");
+    httpPatch.addHeader(ACCEPT, APPLICATION_JSON);
+    httpPatch.addHeader(CONTENT_TYPE, APPLICATION_JSON);
     try (CloseableHttpResponse response = httpClient.execute(httpPatch)) {
       //v3已经改为通过状态码判断200 204 成功
       int statusCode = response.getStatusLine().getStatusCode();
       //post方法有可能会没有返回值的情况
-      String responseString;
-      if (response.getEntity() == null) {
-        responseString = null;
-      } else {
+      String responseString = null;
+      if (response.getEntity() != null) {
         responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
       }
+
       if (HttpStatus.SC_OK == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) {
         this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString);
         return responseString;
-      } else {
-        //有错误提示信息返回
-        JsonObject jsonObject = GsonParser.parse(responseString);
-        throw convertException(jsonObject);
       }
+
+      //有错误提示信息返回
+      JsonObject jsonObject = GsonParser.parse(responseString);
+      throw convertException(jsonObject);
     } catch (Exception e) {
       this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage());
       throw (e instanceof WxPayException) ? (WxPayException) e : new WxPayException(e.getMessage(), e);
@@ -166,8 +169,8 @@ public String patchV3(String url, String requestStr) throws WxPayException {
   public String postV3WithWechatpaySerial(String url, String requestStr) throws WxPayException {
     CloseableHttpClient httpClient = this.createApiV3HttpClient();
     HttpPost httpPost = this.createHttpPost(url, requestStr);
-    httpPost.addHeader("Accept", "application/json");
-    httpPost.addHeader("Content-Type", "application/json");
+    httpPost.addHeader(ACCEPT, APPLICATION_JSON);
+    httpPost.addHeader(CONTENT_TYPE, APPLICATION_JSON);
     String serialNumber = getConfig().getVerifier().getValidCertificate().getSerialNumber().toString(16).toUpperCase();
     httpPost.addHeader("Wechatpay-Serial", serialNumber);
     try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
@@ -182,11 +185,11 @@ public String postV3WithWechatpaySerial(String url, String requestStr) throws Wx
       if (HttpStatus.SC_OK == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) {
         this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString);
         return responseString;
-      } else {
-        //有错误提示信息返回
-        JsonObject jsonObject = GsonParser.parse(responseString);
-        throw convertException(jsonObject);
       }
+
+      //有错误提示信息返回
+      JsonObject jsonObject = GsonParser.parse(responseString);
+      throw convertException(jsonObject);
     } catch (Exception e) {
       this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage());
       e.printStackTrace();
@@ -214,20 +217,19 @@ public String requestV3(String url, HttpRequestBase httpRequest) throws WxPayExc
       //v3已经改为通过状态码判断200 204 成功
       int statusCode = response.getStatusLine().getStatusCode();
       //post方法有可能会没有返回值的情况
-      String responseString;
-      if (response.getEntity() == null) {
-        responseString = null;
-      } else {
+      String responseString = null;
+      if (response.getEntity() != null) {
         responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
       }
+
       if (HttpStatus.SC_OK == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) {
         this.log.info("\n【请求地址】:{}\n【响应数据】:{}", url, responseString);
         return responseString;
-      } else {
-        //有错误提示信息返回
-        JsonObject jsonObject = GsonParser.parse(responseString);
-        throw convertException(jsonObject);
       }
+
+      //有错误提示信息返回
+      JsonObject jsonObject = GsonParser.parse(responseString);
+      throw convertException(jsonObject);
     } catch (Exception e) {
       this.log.error("\n【请求地址】:{}\n【异常信息】:{}", url, e.getMessage());
       throw (e instanceof WxPayException) ? (WxPayException) e : new WxPayException(e.getMessage(), e);
@@ -239,28 +241,42 @@ public String requestV3(String url, HttpRequestBase httpRequest) throws WxPayExc
   @Override
   public String getV3(String url) throws WxPayException {
     HttpGet httpGet = new HttpGet(url);
-    httpGet.addHeader("Accept", "application/json");
-    httpGet.addHeader("Content-Type", "application/json");
-    return this.requestV3(url.toString(), httpGet);
+    httpGet.addHeader(ACCEPT, APPLICATION_JSON);
+    httpGet.addHeader(CONTENT_TYPE, APPLICATION_JSON);
+    return this.requestV3(url, httpGet);
+  }
+
+  @Override
+  public String getV3WithWechatPaySerial(String url) throws WxPayException {
+    HttpGet httpGet = new HttpGet(url);
+    httpGet.addHeader(ACCEPT, APPLICATION_JSON);
+    httpGet.addHeader(CONTENT_TYPE, APPLICATION_JSON);
+    String serialNumber = getConfig().getVerifier().getValidCertificate().getSerialNumber().toString(16).toUpperCase();
+    httpGet.addHeader("Wechatpay-Serial", serialNumber);
+    return this.requestV3(url, httpGet);
   }
 
   @Override
   public InputStream downloadV3(String url) throws WxPayException {
     CloseableHttpClient httpClient = this.createApiV3HttpClient();
-    HttpGet httpGet = new HttpGet(url);
-    httpGet.addHeader("Accept", ContentType.WILDCARD.getMimeType());
+    HttpGet httpGet = new WxPayV3DownloadHttpGet(url);
+    httpGet.addHeader(ACCEPT, ContentType.WILDCARD.getMimeType());
     try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
       //v3已经改为通过状态码判断200 204 成功
       int statusCode = response.getStatusLine().getStatusCode();
-      if (HttpStatus.SC_OK == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) {
+      Header contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE);
+      boolean isJsonContentType = Objects.nonNull(contentType) && ContentType.APPLICATION_JSON.getMimeType()
+        .equals(ContentType.parse(String.valueOf(contentType.getValue())).getMimeType());
+      if ((HttpStatus.SC_OK == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) && !isJsonContentType) {
         this.log.info("\n【请求地址】:{}\n", url);
         return response.getEntity().getContent();
-      } else {
-        //有错误提示信息返回
-        String responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
-        JsonObject jsonObject = GsonParser.parse(responseString);
-        throw convertException(jsonObject);
       }
+
+      //response里的header有content-type=json说明返回了错误信息
+      //有错误提示信息返回
+      String responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
+      JsonObject jsonObject = GsonParser.parse(responseString);
+      throw convertException(jsonObject);
     } catch (Exception e) {
       this.log.error("\n【请求地址】:{}\n【异常信息】:{}", url, e.getMessage());
       throw (e instanceof WxPayException) ? (WxPayException) e : new WxPayException(e.getMessage(), e);
@@ -269,6 +285,24 @@ public InputStream downloadV3(String url) throws WxPayException {
     }
   }
 
+  @Override
+  public String putV3(String url, String requestStr) throws WxPayException {
+    HttpPut httpPut = new HttpPut(url);
+    StringEntity entity = this.createEntry(requestStr);
+    httpPut.setEntity(entity);
+    httpPut.addHeader(ACCEPT, APPLICATION_JSON);
+    httpPut.addHeader(CONTENT_TYPE, APPLICATION_JSON);
+    return requestV3(url, httpPut);
+  }
+
+  @Override
+  public String deleteV3(String url) throws WxPayException {
+    HttpDelete httpDelete = new HttpDelete(url);
+    httpDelete.addHeader(ACCEPT, APPLICATION_JSON);
+    httpDelete.addHeader(CONTENT_TYPE, APPLICATION_JSON);
+    return requestV3(url, httpDelete);
+  }
+
   private CloseableHttpClient createApiV3HttpClient() throws WxPayException {
     CloseableHttpClient apiV3HttpClient = this.getConfig().getApiV3HttpClient();
     if (null == apiV3HttpClient) {
@@ -278,7 +312,7 @@ private CloseableHttpClient createApiV3HttpClient() throws WxPayException {
   }
 
   private StringEntity createEntry(String requestStr) {
-    return new StringEntity(requestStr, ContentType.create("application/json", "utf-8"));
+    return new StringEntity(requestStr, ContentType.create(APPLICATION_JSON, "utf-8"));
     //return new StringEntity(new String(requestStr.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
   }
 
@@ -295,11 +329,19 @@ private HttpClientBuilder createHttpClientBuilder(boolean useKey) throws WxPayEx
 
       // 使用代理服务器 需要用户认证的代理服务器
       CredentialsProvider provider = new BasicCredentialsProvider();
-      provider.setCredentials(new AuthScope(this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort()),
-        new UsernamePasswordCredentials(this.getConfig().getHttpProxyUsername(), this.getConfig().getHttpProxyPassword()));
-      httpClientBuilder.setDefaultCredentialsProvider(provider);
-      httpClientBuilder.setProxy(new HttpHost(this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort()));
+      provider.setCredentials(new AuthScope(this.getConfig().getHttpProxyHost(),
+          this.getConfig().getHttpProxyPort()),
+        new UsernamePasswordCredentials(this.getConfig().getHttpProxyUsername(),
+          this.getConfig().getHttpProxyPassword()));
+      httpClientBuilder.setDefaultCredentialsProvider(provider)
+        .setProxy(new HttpHost(this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort()));
     }
+
+    // 提供自定义httpClientBuilder的能力
+    Optional.ofNullable(getConfig().getHttpClientBuilderCustomizer()).ifPresent(e -> {
+      e.customize(httpClientBuilder);
+    });
+
     return httpClientBuilder;
   }
 
@@ -322,9 +364,8 @@ private void initSSLContext(HttpClientBuilder httpClientBuilder) throws WxPayExc
       sslContext = this.getConfig().initSSLContext();
     }
 
-    SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContext,
-      new DefaultHostnameVerifier());
-    httpClientBuilder.setSSLSocketFactory(connectionSocketFactory);
+    httpClientBuilder.setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext,
+      new DefaultHostnameVerifier()));
   }
 
 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
index 3745284544..5e6d23eac9 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
@@ -91,11 +91,26 @@ public String getV3(String url) throws WxPayException {
     return null;
   }
 
+  @Override
+  public String getV3WithWechatPaySerial(String url) throws WxPayException {
+    return null;
+  }
+
   @Override
   public InputStream downloadV3(String url) throws WxPayException {
     return null;
   }
 
+  @Override
+  public String putV3(String url, String requestStr) throws WxPayException {
+    return null;
+  }
+
+  @Override
+  public String deleteV3(String url) throws WxPayException {
+    return null;
+  }
+
   private HttpRequest buildHttpRequest(String url, String requestStr, boolean useKey) throws WxPayException {
     HttpRequest request = HttpRequest
       .post(url)
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/HttpProxyUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/HttpProxyUtils.java
new file mode 100755
index 0000000000..290aca302b
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/HttpProxyUtils.java
@@ -0,0 +1,49 @@
+package com.github.binarywang.wxpay.util;
+
+import com.github.binarywang.wxpay.config.WxPayHttpProxy;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClientBuilder;
+
+/**
+ * 微信支付 HTTP Proxy 工具类
+ *
+ * @author Long Yu
+ * created on  2021-12-28 15:58:03
+ */
+public class HttpProxyUtils {
+
+  /**
+   * 配置 http 正向代理 可以实现内网服务通过代理调用接口
+   * 参考代码: WxPayServiceApacheHttpImpl 中的方法 createHttpClientBuilder
+   *
+   * @param wxPayHttpProxy 代理配置
+   * @param httpClientBuilder http构造参数
+   */
+  public static void initHttpProxy(HttpClientBuilder httpClientBuilder, WxPayHttpProxy wxPayHttpProxy) {
+    if(wxPayHttpProxy == null){
+      return;
+    }
+    if (StringUtils.isNotBlank(wxPayHttpProxy.getHttpProxyHost()) && wxPayHttpProxy.getHttpProxyPort() > 0) {
+      if (StringUtils.isEmpty(wxPayHttpProxy.getHttpProxyUsername())) {
+        wxPayHttpProxy.setHttpProxyUsername("whatever");
+      }
+
+      // 使用代理服务器 需要用户认证的代理服务器
+      CredentialsProvider provider = new BasicCredentialsProvider();
+      provider.setCredentials(new AuthScope(wxPayHttpProxy.getHttpProxyHost(), wxPayHttpProxy.getHttpProxyPort()),
+        new UsernamePasswordCredentials(wxPayHttpProxy.getHttpProxyUsername(), wxPayHttpProxy.getHttpProxyPassword()));
+      httpClientBuilder.setDefaultCredentialsProvider(provider);
+      httpClientBuilder.setProxy(new HttpHost(wxPayHttpProxy.getHttpProxyHost(), wxPayHttpProxy.getHttpProxyPort()));
+    }
+  }
+
+
+
+
+
+}
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
new file mode 100644
index 0000000000..b641cbe537
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/RequestUtils.java
@@ -0,0 +1,49 @@
+package com.github.binarywang.wxpay.util;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedReader;
+import java.io.IOException;
+
+/**
+ * 
+ * 请求工具类.
+ * Created by Wang_Wong on 2023-04-14.
+ * 
+ * + * @author Wang_Wong + */ +public class RequestUtils { + + /** + * 获取请求头数据,微信V3版本回调使用 + * + * @param request + * @return 字符串 + */ + public static String readData(HttpServletRequest request) { + BufferedReader br = null; + StringBuilder result = new StringBuilder(); + try { + br = request.getReader(); + for (String line; (line = br.readLine()) != null; ) { + if (result.length() > 0) { + result.append("\n"); + } + result.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return result.toString(); + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/ZipUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/ZipUtils.java new file mode 100644 index 0000000000..f9c434196a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/ZipUtils.java @@ -0,0 +1,33 @@ +package com.github.binarywang.wxpay.util; + +import lombok.experimental.UtilityClass; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.GZIPInputStream; + +/** + * @author Binary Wang + */ +@UtilityClass +public class ZipUtils { + + /** + * 解压gzip文件 + */ + public static File unGzip(final File file) throws IOException { + File resultFile = new File(FilenameUtils.removeExtension(file.getAbsolutePath())); + resultFile.createNewFile(); + + try (FileOutputStream fos = new FileOutputStream(resultFile); + GZIPInputStream gzis = new GZIPInputStream(new FileInputStream(file));) { + IOUtils.copy(gzis, fos); + } + + return resultFile; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/SignatureExec.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/SignatureExec.java index 2345e3c68b..24d6f26eb5 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/SignatureExec.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/SignatureExec.java @@ -1,16 +1,12 @@ package com.github.binarywang.wxpay.v3; -import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; import org.apache.http.StatusLine; import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.client.methods.HttpExecutionAware; import org.apache.http.client.methods.HttpRequestWrapper; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.methods.RequestBuilder; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.entity.BufferedHttpEntity; @@ -18,6 +14,8 @@ import org.apache.http.impl.execchain.ClientExecChain; import org.apache.http.util.EntityUtils; +import java.io.IOException; + public class SignatureExec implements ClientExecChain { final ClientExecChain mainExec; final Credentials credentials; @@ -56,8 +54,9 @@ protected void convertToRepeatableRequestEntity(HttpRequestWrapper request) thro @Override public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request, - HttpClientContext context, HttpExecutionAware execAware) throws IOException, HttpException { - if (request.getURI().getHost().endsWith(".mch.weixin.qq.com")) { + HttpClientContext context, HttpExecutionAware execAware) + throws IOException, HttpException { + if (request.getURI().getHost() != null && request.getURI().getHost().endsWith(".mch.weixin.qq.com")) { return executeWithSignature(route, request, context, execAware); } else { return mainExec.execute(route, request, context, execAware); @@ -65,7 +64,8 @@ public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request } private CloseableHttpResponse executeWithSignature(HttpRoute route, HttpRequestWrapper request, - HttpClientContext context, HttpExecutionAware execAware) throws IOException, HttpException { + HttpClientContext context, HttpExecutionAware execAware) + throws IOException, HttpException { // 上传类不需要消耗两次故不做转换 if (!(request.getOriginal() instanceof WechatPayUploadHttpPost)) { convertToRepeatableRequestEntity(request); @@ -81,8 +81,10 @@ private CloseableHttpResponse executeWithSignature(HttpRoute route, HttpRequestW StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() >= 200 && statusLine.getStatusCode() < 300) { convertToRepeatableResponseEntity(response); - if (!validator.validate(response)) { - throw new HttpException("应答的微信支付签名验证失败"); + if (!(request.getOriginal() instanceof WxPayV3DownloadHttpGet)) { + if (!validator.validate(response)) { + throw new HttpException("应答的微信支付签名验证失败"); + } } } return response; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WxPayV3DownloadHttpGet.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WxPayV3DownloadHttpGet.java new file mode 100644 index 0000000000..a79dd06384 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WxPayV3DownloadHttpGet.java @@ -0,0 +1,21 @@ +package com.github.binarywang.wxpay.v3; + + +import org.apache.http.client.methods.HttpGet; + +import java.net.URI; + +public class WxPayV3DownloadHttpGet extends HttpGet { + + + public WxPayV3DownloadHttpGet() { + } + + public WxPayV3DownloadHttpGet(URI uri) { + super(uri); + } + + public WxPayV3DownloadHttpGet(String uri) { + super(uri); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WxPayV3HttpClientBuilder.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WxPayV3HttpClientBuilder.java index 986a8f4cb1..f479367239 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WxPayV3HttpClientBuilder.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WxPayV3HttpClientBuilder.java @@ -46,11 +46,6 @@ public WxPayV3HttpClientBuilder withCredentials(Credentials credentials) { return this; } - public WxPayV3HttpClientBuilder withWechatpay(List certificates) { - this.validator = new WxPayValidator(new CertificatesVerifier(certificates)); - return this; - } - public WxPayV3HttpClientBuilder withValidator(Validator validator) { this.validator = validator; return this; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java old mode 100644 new mode 100755 index d365ccaf4f..7b39aad36e --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java @@ -1,23 +1,24 @@ package com.github.binarywang.wxpay.v3.auth; +import com.github.binarywang.wxpay.config.WxPayHttpProxy; +import com.github.binarywang.wxpay.util.HttpProxyUtils; import com.github.binarywang.wxpay.v3.Credentials; -import com.github.binarywang.wxpay.v3.Validator; import com.github.binarywang.wxpay.v3.WxPayV3HttpClientBuilder; import com.github.binarywang.wxpay.v3.util.AesUtils; import com.github.binarywang.wxpay.v3.util.PemUtils; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.json.GsonParser; +import org.apache.http.HttpStatus; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; -import java.time.Instant; -import java.time.temporal.ChronoUnit; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -26,15 +27,19 @@ import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateNotYetValidException; import java.security.cert.X509Certificate; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.locks.ReentrantLock; /** * 在原有CertificatesVerifier基础上,增加自动更新证书功能 * * @author doger.wang + * @author Long Yu */ @Slf4j public class AutoUpdateCertificatesVerifier implements Verifier { @@ -61,6 +66,11 @@ public class AutoUpdateCertificatesVerifier implements Verifier { private final ReentrantLock lock = new ReentrantLock(); + /** + * 微信支付代理对象 + */ + private WxPayHttpProxy wxPayHttpProxy; + /** * 时间间隔枚举,支持一小时、六小时以及十二小时 */ @@ -88,9 +98,14 @@ public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key) } public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key, int minutesInterval) { + this(credentials,apiV3Key,minutesInterval,null); + } + + public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key, int minutesInterval,WxPayHttpProxy wxPayHttpProxy) { this.credentials = credentials; this.apiV3Key = apiV3Key; this.minutesInterval = minutesInterval; + this.wxPayHttpProxy = wxPayHttpProxy; //构造时更新证书 try { autoUpdateCert(); @@ -110,7 +125,7 @@ public boolean verify(String serialNumber, byte[] message, String signature) { * 检查证书是否在有效期内,如果不在有效期内则进行更新 */ private void checkAndAutoUpdateCert() { - if (instant == null || instant.plus(minutesInterval, ChronoUnit.MINUTES).compareTo(Instant.now()) >= 0) { + if (instant == null || instant.plus(minutesInterval, ChronoUnit.MINUTES).compareTo(Instant.now()) <= 0) { if (lock.tryLock()) { try { autoUpdateCert(); @@ -126,15 +141,17 @@ private void checkAndAutoUpdateCert() { } private void autoUpdateCert() throws IOException, GeneralSecurityException { - CloseableHttpClient httpClient = WxPayV3HttpClientBuilder.create() + WxPayV3HttpClientBuilder wxPayV3HttpClientBuilder = WxPayV3HttpClientBuilder.create() .withCredentials(credentials) - .withValidator(verifier == null ? new Validator() { - @Override - public boolean validate(CloseableHttpResponse response) throws IOException { - return true; - } - } : new WxPayValidator(verifier)) - .build(); + .withValidator(verifier == null ? response -> true : new WxPayValidator(verifier)); + + //调用自定义扩展设置设置HTTP PROXY对象 + HttpProxyUtils.initHttpProxy(wxPayV3HttpClientBuilder,this.wxPayHttpProxy); + + //增加自定义扩展点,子类可以设置其他构造参数 + this.customHttpClientBuilder(wxPayV3HttpClientBuilder); + + CloseableHttpClient httpClient = wxPayV3HttpClientBuilder.build(); HttpGet httpGet = new HttpGet(CERT_DOWNLOAD_PATH); httpGet.addHeader("Accept", "application/json"); @@ -142,18 +159,26 @@ public boolean validate(CloseableHttpResponse response) throws IOException { CloseableHttpResponse response = httpClient.execute(httpGet); int statusCode = response.getStatusLine().getStatusCode(); String body = EntityUtils.toString(response.getEntity()); - if (statusCode == 200) { + if (statusCode == HttpStatus.SC_OK) { List newCertList = deserializeToCerts(apiV3Key, body); if (newCertList.isEmpty()) { - log.warn("Cert list is empty"); - return; + throw new WxRuntimeException("Cert list is empty"); } this.verifier = new CertificatesVerifier(newCertList); } else { log.warn("Auto update cert failed, statusCode = " + statusCode + ",body = " + body); + throw new WxRuntimeException(this.getErrorMsg(body)); } } + + /** + * 子类可以自定义添加Http client builder的信息 + * @param builder httpclient构造器 + */ + public void customHttpClientBuilder(WxPayV3HttpClientBuilder builder) { + } + /** * 反序列化证书并解密 */ @@ -195,4 +220,11 @@ public X509Certificate getValidCertificate() { return verifier.getValidCertificate(); } + private String getErrorMsg(String body) { + return Optional + .ofNullable(GsonParser.parse(body).getAsJsonObject()) + .map(resp -> resp.get("message")) + .map(JsonElement::getAsString) + .orElse("update cert failed"); + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/WxPayValidator.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/WxPayValidator.java index e14d8b5b16..acb75bb6cd 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/WxPayValidator.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/WxPayValidator.java @@ -11,9 +11,12 @@ import java.io.IOException; +/** + * @author spvycf & F00lish + */ @Slf4j public class WxPayValidator implements Validator { - private Verifier verifier; + private final Verifier verifier; public WxPayValidator(Verifier verifier) { this.verifier = verifier; @@ -21,7 +24,8 @@ public WxPayValidator(Verifier verifier) { @Override public final boolean validate(CloseableHttpResponse response) throws IOException { - if (!ContentType.APPLICATION_JSON.getMimeType().equals(ContentType.parse(String.valueOf(response.getFirstHeader("Content-Type").getValue())).getMimeType())) { + if (!ContentType.APPLICATION_JSON.getMimeType().equals(ContentType.parse(String.valueOf(response.getFirstHeader( + "Content-Type").getValue())).getMimeType())) { return true; } Header serialNo = response.getFirstHeader("Wechatpay-Serial"); @@ -44,8 +48,8 @@ protected final String buildMessage(CloseableHttpResponse response) throws IOExc String body = getResponseBody(response); return timestamp + "\n" - + nonce + "\n" - + body + "\n"; + + nonce + "\n" + + body + "\n"; } protected final String getResponseBody(CloseableHttpResponse response) throws IOException { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java index 2c8c40252f..b4a97ba88f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java @@ -1,7 +1,5 @@ package com.github.binarywang.wxpay.v3.util; -import com.google.common.base.CharMatcher; -import com.google.common.io.BaseEncoding; import org.apache.commons.lang3.StringUtils; import javax.crypto.Cipher; @@ -10,6 +8,7 @@ import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -58,7 +57,7 @@ public static byte[] decryptToByte(byte[] associatedData, byte[] nonce, byte[] c } public String decryptToString(byte[] associatedData, byte[] nonce, String ciphertext) - throws GeneralSecurityException, IOException { + throws GeneralSecurityException, IOException { try { Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); @@ -68,7 +67,7 @@ public String decryptToString(byte[] associatedData, byte[] nonce, String cipher cipher.init(Cipher.DECRYPT_MODE, key, spec); cipher.updateAAD(associatedData); - return new String(cipher.doFinal(BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(ciphertext))), "utf-8"); + return new String(cipher.doFinal(Base64.getDecoder().decode(StringUtils.remove(ciphertext, " "))), StandardCharsets.UTF_8); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { throw new IllegalStateException(e); } catch (InvalidKeyException | InvalidAlgorithmParameterException e) { @@ -76,7 +75,7 @@ public String decryptToString(byte[] associatedData, byte[] nonce, String cipher } } - public static String decryptToString(String associatedData, String nonce, String ciphertext,String apiV3Key) + public static String decryptToString(String associatedData, String nonce, String ciphertext, String apiV3Key) throws GeneralSecurityException, IOException { try { Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); @@ -87,7 +86,7 @@ public static String decryptToString(String associatedData, String nonce, String cipher.init(Cipher.DECRYPT_MODE, key, spec); cipher.updateAAD(associatedData.getBytes()); - return new String(cipher.doFinal(Base64.getDecoder().decode(ciphertext)), "utf-8"); + return new String(cipher.doFinal(Base64.getDecoder().decode(ciphertext)), StandardCharsets.UTF_8); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { throw new IllegalStateException(e); } catch (InvalidKeyException | InvalidAlgorithmParameterException e) { @@ -116,9 +115,9 @@ public static String createSign(Map map, String mchKey) { public static String HMACSHA256(String data, String key) { try { Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); - SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256"); + SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256"); sha256_HMAC.init(secret_key); - byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8")); + byte[] array = sha256_HMAC.doFinal(data.getBytes(StandardCharsets.UTF_8)); StringBuilder sb = new StringBuilder(); for (byte item : array) { sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java index c039ccb636..1983fb3387 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java @@ -47,7 +47,7 @@ public static PrivateKey loadPrivateKey(InputStream inputStream) { public static X509Certificate loadCertificate(InputStream inputStream) { try { - CertificateFactory cf = CertificateFactory.getInstance("X509"); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate) cf.generateCertificate(inputStream); cert.checkValidity(); return cert; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java index 2953037403..d8fe3b35ba 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java @@ -47,7 +47,7 @@ private static void encryptField(Object encryptObject, X509Certificate certifica Object oldValue = field.get(encryptObject); if (oldValue != null) { String oldStr = (String) oldValue; - if (!oldStr.trim().equals("'")) { + if (!"".equals(oldStr.trim())) { field.set(encryptObject, encryptOAEP(oldStr, certificate)); } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/entpay/EntPayRequestTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/entpay/EntPayRequestTest.java index 5cd4dcdc10..b6f68b81c1 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/entpay/EntPayRequestTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/entpay/EntPayRequestTest.java @@ -6,7 +6,7 @@ * . * * @author Binary Wang - * @date 2019-08-18 + * created on 2019-08-18 */ public class EntPayRequestTest { diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java index 60be34e357..c15898b835 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.notify; +import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -8,10 +9,14 @@ * WxPayNotifyResponse 测试. * * @author Binary Wang - * @date 2019-06-30 + * created on 2019-06-30 */ +@Slf4j public class WxPayNotifyResponseTest { + /** + * V2版本 + */ @Test public void testSuccess() { final String result = WxPayNotifyResponse.success("OK"); @@ -38,4 +43,23 @@ public void testFailResp() { "" + ""); } + + /** + * V3版本 + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml + */ + @Test + public void testV3Fail() { + final String result = WxPayNotifyV3Response.fail("失败"); + log.info(result); + assertThat(result).isNotEmpty(); + } + + @Test + public void testV3Success() { + final String result = WxPayNotifyV3Response.success("成功"); + log.info(result); + assertThat(result).isNotEmpty(); + } + } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequestTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequestTest.java index 6976bba38c..5d29f15a76 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequestTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequestTest.java @@ -4,7 +4,7 @@ /** * @author Binary Wang - * @date 2020-07-11 + * created on 2020-07-11 */ public class WxPayScoreRequestTest { @Test @@ -14,7 +14,7 @@ public void testToJson() { .appid("123") .serviceId("345") .serviceIntroduction("租借服务") - .timeRange(new TimeRange("OnAccept", "20200520225840")) + .timeRange(new TimeRange("20230901011023", "20230930235959","开始时间","结束时间")) .build(); System.out.println(request.toJson()); /* { diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResultTest.java index 386101fed0..516b8e1b5a 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResultTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResultTest.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.profitsharing; +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingQueryResult; import org.testng.annotations.Test; import java.util.List; @@ -10,7 +11,7 @@ * 测试. * * @author Binary Wang - * @date 2020-03-22 + * created on 2020-03-22 */ @Test public class ProfitSharingQueryResultTest { diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingV3ResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingV3ResultTest.java new file mode 100644 index 0000000000..2d558b9b50 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingV3ResultTest.java @@ -0,0 +1,72 @@ +package com.github.binarywang.wxpay.bean.profitsharing; + +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingResult; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ProfitSharingV3ResultTest { + + @Test + public void testGetReceiverList() { + ProfitSharingResult profitSharingResult = ProfitSharingResult.fromXML("\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\n" + + "", ProfitSharingResult.class); + + List receiverList = profitSharingResult.getReceiverList(); + assertThat(receiverList).isNotEmpty(); + } +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequestTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequestTest.java index 1118edea87..7adeb5a7b8 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequestTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequestTest.java @@ -6,7 +6,7 @@ /** * @author Binary Wang - * @date 2020-06-07 + * created on 2020-06-07 */ public class WxPayRefundRequestTest { diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/config/CustomizedWxPayConfigTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/config/CustomizedWxPayConfigTest.java new file mode 100644 index 0000000000..a42026e3ee --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/config/CustomizedWxPayConfigTest.java @@ -0,0 +1,39 @@ +package com.github.binarywang.wxpay.config; + +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.CustomizedApiTestModule; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @author dagewang + */ +@Slf4j +@Test +@Guice(modules = CustomizedApiTestModule.class) +public class CustomizedWxPayConfigTest { + + @Inject + private WxPayService wxPayService; + + public void testCustomizerHttpClient() { + try { + wxPayService.queryOrder("a", null); + } catch (WxPayException e) { + // ignore + e.printStackTrace(); + } + } + + public void testCustomizerV3HttpClient() { + try { + wxPayService.queryOrderV3("a", null); + } catch (WxPayException e) { + // ignore + e.printStackTrace(); + } + } +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/config/WxPayConfigTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/config/WxPayConfigTest.java index 8b5a621b89..5a506e72f8 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/config/WxPayConfigTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/config/WxPayConfigTest.java @@ -37,4 +37,11 @@ public void testInitSSLContext() throws Exception { public void testHashCode() { payConfig.hashCode(); } + + @Test + public void testInitSSLContext_base64() throws Exception { + payConfig.setMchId("123"); + payConfig.setKeyString("MIIKmgIBAzCCCmQGCS..."); + payConfig.initSSLContext(); + } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImplTest.java index da268ce9e8..5f6f258010 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImplTest.java @@ -25,27 +25,27 @@ public class Applyment4SubServiceImplTest { @Test public void testCreateApply() throws WxPayException { - Applyment4SubService applyment4SubService=new Applyment4SubServiceImpl(wxPayService); - String requestParamStr="{}"; + Applyment4SubService applyment4SubService = new Applyment4SubServiceImpl(wxPayService); + String requestParamStr = "{}"; /* {"business_code":"1596785690732","contact_info":{"contact_name":"张三","contact_id_number":"110110202001011234","mobile_phone":"13112345678","contact_email":"abc@qq.com"},"subject_info":{"subject_type":"SUBJECT_TYPE_ENTERPRISE","business_license_info":{"license_copy":"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI","license_number":"123456789012345678","merchant_name":"腾讯科技有限公司","legal_person":"张三"},"identity_info":{"id_doc_type":"IDENTIFICATION_TYPE_IDCARD","id_card_info":{"id_card_copy":"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI","id_card_national":"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI","id_card_name":"张三","id_card_number":"110110202001011234","card_period_begin":"2016-06-06","card_period_end":"2026-06-06"},"owner":false},"ubo_info":{"id_type":"IDENTIFICATION_TYPE_IDCARD","id_card_copy":"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI","id_card_national":"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI","id_doc_copy":"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI","name":"张三","id_number":"110110202001011234","id_period_begin":"2016-06-06","id_period_end":"2026-06-06"}},"business_info":{"merchant_shortname":"商户简称","service_phone":"13212345678","sales_info":{"sales_scenes_type":["SALES_SCENES_MINI_PROGRAM"],"mini_program_info":{"mini_program_appid":"wxe5f52902cf4de896"}}},"settlement_info":{"settlement_id":"716","qualification_type":"餐饮"}} */ - requestParamStr="{\"business_code\":\"1596785690732\",\"contact_info\":{\"contact_name\":\"张三\",\"contact_id_number\":\"110110202001011234\",\"mobile_phone\":\"13112345678\",\"contact_email\":\"abc@qq.com\"},\"subject_info\":{\"subject_type\":\"SUBJECT_TYPE_ENTERPRISE\",\"business_license_info\":{\"license_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"license_number\":\"123456789012345678\",\"merchant_name\":\"腾讯科技有限公司\",\"legal_person\":\"张三\"},\"identity_info\":{\"id_doc_type\":\"IDENTIFICATION_TYPE_IDCARD\",\"id_card_info\":{\"id_card_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_card_national\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_card_name\":\"张三\",\"id_card_number\":\"110110202001011234\",\"card_period_begin\":\"2016-06-06\",\"card_period_end\":\"2026-06-06\"},\"owner\":false},\"ubo_info\":{\"id_type\":\"IDENTIFICATION_TYPE_IDCARD\",\"id_card_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_card_national\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_doc_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"name\":\"张三\",\"id_number\":\"110110202001011234\",\"id_period_begin\":\"2016-06-06\",\"id_period_end\":\"2026-06-06\"}},\"business_info\":{\"merchant_shortname\":\"商户简称\",\"service_phone\":\"13212345678\",\"sales_info\":{\"sales_scenes_type\":[\"SALES_SCENES_MINI_PROGRAM\"],\"mini_program_info\":{\"mini_program_appid\":\"wxe5f52902cf4de896\"}}},\"settlement_info\":{\"settlement_id\":\"716\",\"qualification_type\":\"餐饮\"}}"; + requestParamStr = "{\"business_code\":\"1596785690732\",\"contact_info\":{\"contact_name\":\"张三\",\"contact_id_number\":\"110110202001011234\",\"mobile_phone\":\"13112345678\",\"contact_email\":\"abc@qq.com\"},\"subject_info\":{\"subject_type\":\"SUBJECT_TYPE_ENTERPRISE\",\"business_license_info\":{\"license_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"license_number\":\"123456789012345678\",\"merchant_name\":\"腾讯科技有限公司\",\"legal_person\":\"张三\"},\"identity_info\":{\"id_doc_type\":\"IDENTIFICATION_TYPE_IDCARD\",\"id_card_info\":{\"id_card_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_card_national\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_card_name\":\"张三\",\"id_card_number\":\"110110202001011234\",\"card_period_begin\":\"2016-06-06\",\"card_period_end\":\"2026-06-06\"},\"owner\":false},\"ubo_info\":{\"id_type\":\"IDENTIFICATION_TYPE_IDCARD\",\"id_card_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_card_national\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"id_doc_copy\":\"mxX07DyfM-bJyGJYCTyW-4wrXpJ5fq_bgYfWkIZZgjenf6Ct1gKV_FpkzgyQrf5ETVEyOWhC_0cbhOATODuLBAkxGl6Cvj31lh6OFAIHnwI\",\"name\":\"张三\",\"id_number\":\"110110202001011234\",\"id_period_begin\":\"2016-06-06\",\"id_period_end\":\"2026-06-06\"}},\"business_info\":{\"merchant_shortname\":\"商户简称\",\"service_phone\":\"13212345678\",\"sales_info\":{\"sales_scenes_type\":[\"SALES_SCENES_MINI_PROGRAM\"],\"mini_program_info\":{\"mini_program_appid\":\"wxe5f52902cf4de896\"}}},\"settlement_info\":{\"settlement_id\":\"716\",\"qualification_type\":\"餐饮\"}}"; - WxPayApplyment4SubCreateRequest request=GSON.fromJson(requestParamStr,WxPayApplyment4SubCreateRequest.class); + WxPayApplyment4SubCreateRequest request = GSON.fromJson(requestParamStr, WxPayApplyment4SubCreateRequest.class); String businessCode = String.valueOf(System.currentTimeMillis()); request.setBusinessCode(businessCode); WxPayApplymentCreateResult apply = applyment4SubService.createApply(request); String applymentId = apply.getApplymentId(); - log.info("businessCode:[{}],applymentId:[{}]",businessCode,applymentId); + log.info("businessCode:[{}],applymentId:[{}]", businessCode, applymentId); } @Test public void testQueryApplyStatusByBusinessCode() throws WxPayException { - Applyment4SubService applyment4SubService=new Applyment4SubServiceImpl(wxPayService); - String businessCode="businessCode"; + Applyment4SubService applyment4SubService = new Applyment4SubServiceImpl(wxPayService); + String businessCode = "businessCode"; applyment4SubService.queryApplyStatusByBusinessCode(businessCode); @@ -54,8 +54,8 @@ public void testQueryApplyStatusByBusinessCode() throws WxPayException { @Test public void testQueryApplyStatusByApplymentId() throws WxPayException { - Applyment4SubService applyment4SubService=new Applyment4SubServiceImpl(wxPayService); - String applymentId="applymentId"; + Applyment4SubService applyment4SubService = new Applyment4SubServiceImpl(wxPayService); + String applymentId = "applymentId"; applyment4SubService.queryApplyStatusByApplymentId(applymentId); @@ -63,8 +63,8 @@ public void testQueryApplyStatusByApplymentId() throws WxPayException { @Test public void testQuerySettlementBySubMchid() throws WxPayException { - Applyment4SubService applyment4SubService=new Applyment4SubServiceImpl(wxPayService); - String subMchid="subMchid"; + Applyment4SubService applyment4SubService = new Applyment4SubServiceImpl(wxPayService); + String subMchid = "subMchid"; applyment4SubService.querySettlementBySubMchid(subMchid); @@ -72,16 +72,21 @@ public void testQuerySettlementBySubMchid() throws WxPayException { @Test public void testModifySettlement() throws WxPayException { - Applyment4SubService applyment4SubService=new Applyment4SubServiceImpl(wxPayService); - String subMchid="subMchid"; + Applyment4SubService applyment4SubService = new Applyment4SubServiceImpl(wxPayService); + String subMchid = "subMchid"; ModifySettlementRequest modifySettlementRequest = new ModifySettlementRequest(); - applyment4SubService.modifySettlement(subMchid,modifySettlementRequest); + applyment4SubService.modifySettlement(subMchid, modifySettlementRequest); } + @Test + public void testSettlementApplication() throws WxPayException { + Applyment4SubService applyment4SubService = new Applyment4SubServiceImpl(wxPayService); + String subMchid = "subMchid"; + String applymentId = "applymentId"; - - + applyment4SubService.querySettlementModifyStatusByApplicationNo(subMchid, applymentId); + } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java index e984b334fc..3990f5b61e 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java @@ -2,15 +2,16 @@ import com.github.binarywang.utils.qrcode.QrcodeUtils; import com.github.binarywang.wxpay.bean.coupon.*; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest; +import com.github.binarywang.wxpay.bean.notify.*; import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants.AccountType; +import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.bean.request.WxPayDownloadFundFlowRequest.AccountType; import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; @@ -18,6 +19,7 @@ import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.github.binarywang.wxpay.testbase.XmlWxPayConfig; +import com.github.binarywang.wxpay.util.RequestUtils; import com.github.binarywang.wxpay.util.XmlConfig; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -28,10 +30,15 @@ import org.testng.annotations.Guice; import org.testng.annotations.Test; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Path; import java.util.Calendar; import java.util.Date; +import java.util.Optional; +import java.util.UUID; import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; import static org.assertj.core.api.Assertions.assertThat; @@ -151,16 +158,16 @@ public void testCreateOrderSpecific() throws Exception { // Won't compile // WxPayMpOrderResult result = payService.createOrder(TradeType.Specific.APP, new WxPayUnifiedOrderRequest()); payService.createOrder( - TradeType.Specific.JSAPI, - WxPayUnifiedOrderRequest.newBuilder() - .body("我去") - .totalFee(1) - .productId("aaa") - .spbillCreateIp("11.1.11.1") - .notifyUrl("111111") - .outTradeNo("111111290") - .build() - ) + TradeType.Specific.JSAPI, + WxPayUnifiedOrderRequest.newBuilder() + .body("我去") + .totalFee(1) + .productId("aaa") + .spbillCreateIp("11.1.11.1") + .notifyUrl("111111") + .outTradeNo("111111290") + .build() + ) .getAppId(); } @@ -727,9 +734,9 @@ public void testUnifiedOrderV3() throws WxPayException { //构建金额信息 WxPayUnifiedOrderV3Request.Amount amount = new WxPayUnifiedOrderV3Request.Amount(); //设置币种信息 - amount.setCurrency("CNY"); + amount.setCurrency(WxPayConstants.CurrencyType.CNY); //设置金额 - amount.setTotal(1); + amount.setTotal(BaseWxPayRequest.yuan2Fen(BigDecimal.ONE)); request.setAmount(amount); WxPayUnifiedOrderV3Result.JsapiResult result = this.payService.createOrderV3(TradeTypeEnum.JSAPI, request); @@ -766,13 +773,138 @@ public void testRefundV3() throws WxPayException { System.out.println(GSON.toJson(result)); } + /** + * 测试V3支付成功回调 + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_5.shtml + * + * @throws Exception the exception + */ + @Test + public String testParseOrderNotifyV3Result(HttpServletRequest request, HttpServletResponse response) throws Exception { + + String timestamp = request.getHeader("Wechatpay-Timestamp"); + Optional.ofNullable(timestamp).orElseThrow(() -> new RuntimeException("时间戳不能为空")); + + String nonce = request.getHeader("Wechatpay-Nonce"); + Optional.ofNullable(nonce).orElseThrow(() -> new RuntimeException("nonce不能为空")); + + String serialNo = request.getHeader("Wechatpay-Serial"); + Optional.ofNullable(serialNo).orElseThrow(() -> new RuntimeException("serialNo不能为空")); + + String signature = request.getHeader("Wechatpay-Signature"); + Optional.ofNullable(signature).orElseThrow(() -> new RuntimeException("signature不能为空")); + + log.info("请求头参数为:timestamp:{} nonce:{} serialNo:{} signature:{}", timestamp, nonce, serialNo, signature); + + // V2版本请参考com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResultTest里的单元测试 + final WxPayNotifyV3Result wxPayOrderNotifyV3Result = this.payService.parseOrderNotifyV3Result(RequestUtils.readData(request), + new SignatureHeader(timestamp, nonce, signature, serialNo)); + log.info(GSON.toJson(wxPayOrderNotifyV3Result)); + + return WxPayNotifyV3Response.success("成功"); + } + + /** + * 测试V3退款成功回调 + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_11.shtml + * + * @throws Exception the exception + */ + @Test + public String testParseRefundNotifyV3Result(HttpServletRequest request, HttpServletResponse response) throws Exception { + + String timestamp = request.getHeader("Wechatpay-Timestamp"); + Optional.ofNullable(timestamp).orElseThrow(() -> new RuntimeException("时间戳不能为空")); + + String nonce = request.getHeader("Wechatpay-Nonce"); + Optional.ofNullable(nonce).orElseThrow(() -> new RuntimeException("nonce不能为空")); + + String serialNo = request.getHeader("Wechatpay-Serial"); + Optional.ofNullable(serialNo).orElseThrow(() -> new RuntimeException("serialNo不能为空")); + + String signature = request.getHeader("Wechatpay-Signature"); + Optional.ofNullable(signature).orElseThrow(() -> new RuntimeException("signature不能为空")); + + log.info("支付请求头参数为:timestamp:{} nonce:{} serialNo:{} signature:{}", timestamp, nonce, serialNo, signature); + + final WxPayRefundNotifyV3Result wxPayRefundNotifyV3Result = this.payService.parseRefundNotifyV3Result(RequestUtils.readData(request), + new SignatureHeader(timestamp, nonce, signature, serialNo)); + log.info(GSON.toJson(wxPayRefundNotifyV3Result)); + + // 退款金额 + final WxPayRefundNotifyV3Result.DecryptNotifyResult result = wxPayRefundNotifyV3Result.getResult(); + final BigDecimal total = BaseWxPayRequest.fen2Yuan(BigDecimal.valueOf(result.getAmount().getTotal())); + final BigDecimal payerRefund = BaseWxPayRequest.fen2Yuan(BigDecimal.valueOf(result.getAmount().getPayerRefund())); + + // 处理业务逻辑 ... + + return WxPayNotifyV3Response.success("成功"); + } + + @Test + public void testWxPayNotifyV3Response() { + System.out.println(WxPayNotifyV3Response.success("success")); + System.out.println(WxPayNotifyV3Response.fail("fail")); + } + @Test public void testRefundQueryV3() throws WxPayException { WxPayRefundQueryV3Request request = new WxPayRefundQueryV3Request(); -// request.setOutTradeNo("n1ZvYqjAg3D7LUBa"); - request.setOutTradeNo("123456789011"); +// request.setOutRefundNo("n1ZvYqjAg3D7LUBa"); + request.setOutRefundNo("123456789011"); WxPayRefundQueryV3Result result = this.payService.refundQueryV3(request); System.out.println(GSON.toJson(result)); } + /** + * 测试包含正向代理的测试 + * + * @throws WxPayException + */ + @Test + public void testQueryOrderV3WithProxy() { + try { + WxPayOrderQueryV3Request request = new WxPayOrderQueryV3Request(); + request.setOutTradeNo("n1ZvYqjAg3D3LUBa"); + WxPayConfig config = this.payService.getConfig(); + config.setPayBaseUrl("http://api.mch.weixin.qq.com"); + config.setHttpProxyHost("12.11.1.113"); + config.setHttpProxyPort(8015); + WxPayOrderQueryV3Result result = this.payService.queryOrderV3(request); + System.out.println(GSON.toJson(result)); + } catch (WxPayException e) { + } + + } + + @Test + public void testCreatePartnerOrderV3() throws WxPayException { + WxPayConfig wxPayConfig = new WxPayConfig(); + //服务商的参数 + wxPayConfig.setMchId("xxx"); + wxPayConfig.setApiV3Key("xxx"); + wxPayConfig.setPrivateKeyPath("xxx"); + wxPayConfig.setPrivateCertPath("xxx"); + wxPayConfig.setKeyPath("xxx"); + wxPayConfig.setAppId("xxx"); + wxPayConfig.setKeyPath("xxx"); + //如果有子商户的appId则配置 +// wxPayConfig.setSubAppId("xxx"); + //创建支付服务 + WxPayService wxPayService = new WxPayServiceImpl(); + wxPayService.setConfig(wxPayConfig); + //子商户的参数 + wxPayConfig.setSubMchId("xxx"); + + //构建请求 + WxPayPartnerUnifiedOrderV3Request request = new WxPayPartnerUnifiedOrderV3Request(); + request.setAmount(new WxPayPartnerUnifiedOrderV3Request.Amount().setTotal(1)); + request.setPayer(new WxPayPartnerUnifiedOrderV3Request.Payer().setSpOpenid("xxx")); + //如果有子商户的appId则配置 +// request.setPayer(new WxPayPartnerUnifiedOrderV3Request.Payer().setSubOpenid("xxx")); + request.setOutTradeNo(UUID.randomUUID().toString()); + + WxPayUnifiedOrderV3Result.JsapiResult result = payService.createPartnerOrderV3(TradeTypeEnum.JSAPI, request); + System.out.println(result); + } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BrandMerchantTransferServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BrandMerchantTransferServiceImplTest.java new file mode 100644 index 0000000000..612f78065d --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BrandMerchantTransferServiceImplTest.java @@ -0,0 +1,78 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.request.*; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandBatchesQueryResult; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandDetailsQueryResult; +import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandTransferBatchesResult; +import com.github.binarywang.wxpay.bean.merchanttransfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * 品牌红包商家转账到零钱(直连商户) + * @author moran + */ +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class BrandMerchantTransferServiceImplTest { + + @Inject + private WxPayService wxPayService; + + private static final Gson GSON = new GsonBuilder().create(); + + @Test + public void createBrandTransfer() throws WxPayException { + String requestParamStr = "{\"batch_name\":\"双十一营销用品牌红包\",\"batch_remark\":\"双十一营销用品牌红包\",\"brand_appid\":\"wxf636efh567hg4356\",\"brand_id\":1234,\"detail_list\":[{\"amount\":100,\"openid\":\"o-MYE42l80oelYMDE34nYD456Xoy\",\"out_detail_no\":\"x23zy545Bd5436\",\"remark\":\"来自XX的红包\",\"user_name\":\"757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45\"}],\"out_batch_no\":\"plfk2020042013\",\"scene\":\"CUSTOM_SEND\",\"template_id\":\"123400001\",\"total_amount\":10000,\"total_num\":10}"; + + BrandTransferBatchesRequest request = GSON.fromJson(requestParamStr, BrandTransferBatchesRequest.class); + BrandTransferBatchesResult result = wxPayService.getBrandMerchantTransferService().createBrandTransfer(request); + log.info(result.toString()); + } + + @Test + public void queryBrandWxBatches() throws WxPayException { + String requestParamStr = "{\"batch_no\":\"1030000071100999991182020050700019480001\",\"need_query_detail\":true,\"detail_status\":\"DETAIL_VIEW_FAIL\"}"; + + BrandWxBatchesQueryRequest request = GSON.fromJson(requestParamStr, BrandWxBatchesQueryRequest.class); + log.info("request:{}",request); + BrandBatchesQueryResult result = wxPayService.getBrandMerchantTransferService().queryBrandWxBatches(request); + log.info(result.toString()); + } + + @Test + public void queryBrandWxDetails() throws WxPayException { + String requestParamStr = "{\"batch_no\":\"1030000071100999991182020050700019480001\",\"detail_no\":\"1040000071100999991182020050700019500100\"}"; + + BrandWxDetailsQueryRequest request = GSON.fromJson(requestParamStr, BrandWxDetailsQueryRequest.class); + BrandDetailsQueryResult result = wxPayService.getBrandMerchantTransferService().queryBrandWxDetails(request); + log.info(result.toString()); + } + + @Test + public void queryBrandMerchantBatches() throws WxPayException { + String requestParamStr = "{\"out_batch_no\":\"plfk2020042013\",\"need_query_detail\":true,\"detail_status\":\"DETAIL_VIEW_FAIL\"}"; + + BrandMerchantBatchesQueryRequest request = GSON.fromJson(requestParamStr, BrandMerchantBatchesQueryRequest.class); + BrandBatchesQueryResult result = wxPayService.getBrandMerchantTransferService().queryBrandMerchantBatches(request); + log.info(result.toString()); + } + + @Test + public void queryBrandMerchantDetails() throws WxPayException { + String requestParamStr = "{\"out_batch_no\":\"plfk2020042013\",\"out_detail_no\":\"x23zy545Bd5436\"}"; + + BrandMerchantDetailsQueryRequest request = GSON.fromJson(requestParamStr, BrandMerchantDetailsQueryRequest.class); + BrandDetailsQueryResult result = wxPayService.getBrandMerchantTransferService().queryBrandMerchantDetails(request); + log.info(result.toString()); + } + +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImplTest.java new file mode 100644 index 0000000000..30d222d2f6 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImplTest.java @@ -0,0 +1,180 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.complaint.*; +import com.github.binarywang.wxpay.bean.media.ImageUploadResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import javax.crypto.BadPaddingException; +import java.io.File; +import java.io.IOException; + +/** + *
+ *  消费者投诉2.0 测试类
+ * 
+ * + * @author jmdhappy + */ +@Test +@Slf4j +@Guice(modules = ApiTestModule.class) +public class ComplaintServiceImplTest { + @Inject + private WxPayService payService; + + private static final String complaintId = "200231020220320120496109901"; + + /** + * 查询投诉单列表API + * + * @throws WxPayException + */ + @Test + public void testQueryComplaints() throws WxPayException, BadPaddingException { + ComplaintRequest request = ComplaintRequest + .newBuilder() + .offset(0) + .limit(10) + .beginDate("2022-03-01") + .endDate("2022-03-20") + .complaintedMchid(this.payService.getConfig().getMchId()) + .build(); + log.info(this.payService.getComplaintsService().queryComplaints(request).toString()); + } + + /** + * 查询投诉单详情API + * + * @throws WxPayException + */ + @Test + public void testGetComplaint() throws WxPayException, BadPaddingException { + ComplaintDetailRequest request = ComplaintDetailRequest + .newBuilder() + .complaintId(complaintId) + .build(); + log.info(this.payService.getComplaintsService().getComplaint(request).toString()); + } + + /** + * 查询投诉协商历史API + * + * @throws WxPayException + */ + @Test + public void testQueryNegotiationHistorys() throws WxPayException { + NegotiationHistoryRequest request = NegotiationHistoryRequest + .newBuilder() + .complaintId(complaintId) + .offset(0) + .limit(20) + .build(); + log.info(this.payService.getComplaintsService().queryNegotiationHistorys(request).toString()); + } + + /** + * 创建投诉通知回调地址API + * + * @throws WxPayException + */ + @Test + public void testAddComplaintNotifyUrl() throws WxPayException { + ComplaintNotifyUrlRequest request = ComplaintNotifyUrlRequest + .newBuilder() + .url("https://jeepay.natapp4.cc") + .build(); + log.info(this.payService.getComplaintsService().addComplaintNotifyUrl(request).toString()); + } + + /** + * 查询投诉通知回调地址API + * + * @throws WxPayException + */ + @Test + public void testGetComplaintNotifyUrl() throws WxPayException { + log.info(this.payService.getComplaintsService().getComplaintNotifyUrl().toString()); + } + + /** + * 更新投诉通知回调地址API + * + * @throws WxPayException + */ + @Test + public void testUpdateComplaintNotifyUrl() throws WxPayException { + ComplaintNotifyUrlRequest request = ComplaintNotifyUrlRequest + .newBuilder() + .url("https://jeepay1.natapp4.cc") + .build(); + log.info(this.payService.getComplaintsService().updateComplaintNotifyUrl(request).toString()); + } + + /** + * 删除投诉通知回调地址API + * + * @throws WxPayException + */ + @Test + public void testDeleteComplaintNotifyUrl() throws WxPayException { + this.payService.getComplaintsService().deleteComplaintNotifyUrl(); + } + + /** + * 提交回复API + * + * @throws WxPayException + */ + @Test + public void testSubmitResponse() throws WxPayException { + ResponseRequest request = ResponseRequest + .newBuilder() + .complaintId(complaintId) + .complaintedMchid(this.payService.getConfig().getMchId()) + .responseContent("测试投诉接口1233,正在处理,不要炸鸡") + //.jumpUrl("https://www.baidu.com") + //.jumpUrlText("问题解决方案") + .build(); + this.payService.getComplaintsService().submitResponse(request); + } + + /** + * 反馈处理完成API + * + * @throws WxPayException + */ + @Test + public void testComplete() throws WxPayException { + CompleteRequest request = CompleteRequest + .newBuilder() + .complaintId(complaintId) + .complaintedMchid(this.payService.getConfig().getMchId()) + .build(); + this.payService.getComplaintsService().complete(request); + } + + /** + * 商户上传反馈图片API + * + * @throws WxPayException + * @throws IOException + */ + @Test + public void testUploadResponseImage() throws WxPayException, IOException { + String filePath = "你的图片文件的路径地址"; +// String filePath="WxJava/images/banners/wiki.jpg"; + + File file = new File(filePath); + + ImageUploadResult imageUploadResult = this.payService.getComplaintsService().uploadResponseImage(file); + imageUploadResult.getMediaId(); + + } + +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImplTest.java new file mode 100644 index 0000000000..6a219ee2f3 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImplTest.java @@ -0,0 +1,74 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.customs.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.CustomDeclarationService; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class CustomDeclarationServiceImplTest { + private static final Gson GSON = new GsonBuilder().create(); + @Inject + private WxPayService wxPayService; + + @Test + public void testDeclare() throws WxPayException { + CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); + String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\"}"; + DeclarationRequest request = GSON.fromJson(requestParamStr, DeclarationRequest.class); + + DeclarationResult result = customDeclarationService.declare(request); + System.out.println("result = " + result); + } + + @Test + public void testQuery() throws WxPayException { + CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); + String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"order_type\":\"transaction_id\",\"order_no\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"offset\":\"0\",\"limit\":\"20\"}"; + DeclarationQueryRequest request = GSON.fromJson(requestParamStr, DeclarationQueryRequest.class); + + DeclarationQueryResult result = customDeclarationService.query(request); + System.out.println("result = " + result); + } + + @Test + public void testVerifyCertificate() throws WxPayException { + CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); + String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\",\"certificate_type\":\"IDCARD\",\"certificate_id\":\"430223199101264838\",\"certificate_name\":\"易株强\"}"; + VerifyCertificateRequest request = GSON.fromJson(requestParamStr, VerifyCertificateRequest.class); + + VerifyCertificateResult result = customDeclarationService.verifyCertificate(request); + System.out.println("result = " + result); + } + + @Test + public void testModify() throws WxPayException { + CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); + + String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\"}"; + + DeclarationRequest request = GSON.fromJson(requestParamStr, DeclarationRequest.class); + + DeclarationResult result = customDeclarationService.modify(request); + System.out.println("result = " + result); + } + + @Test + public void testRedeclare() throws WxPayException { + CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); + String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\"}"; + RedeclareRequest request = GSON.fromJson(requestParamStr, RedeclareRequest.class); + + RedeclareResult result = customDeclarationService.redeclare(request); + System.out.println("result = " + result); + } +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java index 10b1d80206..97e85f4139 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java @@ -7,6 +7,7 @@ import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingReceiverResult; import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; import com.github.binarywang.wxpay.bean.ecommerce.TransactionsResult; +import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum; import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; @@ -125,6 +126,12 @@ public void testSubNowBalance() throws WxPayException { wxPayService.getEcommerceService().subNowBalance(subMchid); } + @Test + public void testSubNowBalanceWithAccountType() throws WxPayException { + String subMchid = ""; + wxPayService.getEcommerceService().subNowBalance(subMchid, SpAccountTypeEnum.BASIC); + } + @Test public void testAddReceivers() throws WxPayException { ProfitSharingReceiverRequest request = new ProfitSharingReceiverRequest(); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImplTest.java index 142bbbc734..40efbb5a0e 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImplTest.java @@ -6,6 +6,7 @@ import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Guice; @@ -23,6 +24,7 @@ */ @Test @Guice(modules = ApiTestModule.class) +@Slf4j public class EntPayServiceImplTest { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -45,7 +47,7 @@ public void testEntPay() throws WxPayException { .description("描述信息") .build(); - this.logger.info(this.payService.getEntPayService().entPay(request).toString()); + log.info(this.payService.getEntPayService().entPay(request).toString()); } /** @@ -55,7 +57,7 @@ public void testEntPay() throws WxPayException { */ @Test public void testQueryEntPay() throws WxPayException { - this.logger.info(this.payService.getEntPayService().queryEntPay("11212121").toString()); + log.info(this.payService.getEntPayService().queryEntPay("11212121").toString()); } /** @@ -65,7 +67,7 @@ public void testQueryEntPay() throws WxPayException { */ @Test public void testGetPublicKey() throws Exception { - this.logger.info(this.payService.getEntPayService().getPublicKey()); + log.info(this.payService.getEntPayService().getPublicKey()); } /** @@ -83,7 +85,7 @@ public void testPayBank() throws Exception { .partnerTradeNo("3") .description("11") .build()); - this.logger.info(result.toString()); + log.info(result.toString()); } /** @@ -93,13 +95,13 @@ public void testPayBank() throws Exception { */ @Test public void testQueryPayBank() throws Exception { - this.logger.info(this.payService.getEntPayService().queryPayBank("123").toString()); + log.info(this.payService.getEntPayService().queryPayBank("123").toString()); } - /** * 发送企业红包 + * * @throws Exception the exception */ @Test @@ -107,7 +109,7 @@ public void testSendEnterpriseRedpack() { EntPayRedpackRequest request = new EntPayRedpackRequest(); request.setMchId("1"); //商户单号 - request.setMchBillNo(request.getMchId()+"20191202"+"1"); + request.setMchBillNo(request.getMchId() + "20191202" + "1"); //企业微信corpid即为此appId request.setWxAppId("1"); // request.setSenderName("1"); @@ -125,11 +127,12 @@ public void testSendEnterpriseRedpack() { redpackResult = this.payService.getEntPayService().sendEnterpriseRedpack(request); } catch (WxPayException e) { } - this.logger.info(redpackResult.toString()); + log.info(redpackResult.toString()); } /** * 查询企业红包 + * * @throws Exception */ @Test @@ -142,7 +145,7 @@ public void testQueryEnterpriseRedpack() throws Exception { try { EntPayRedpackQueryResult result = this.payService.getEntPayService().queryEnterpriseRedpack(request); - this.logger.info(result.toString()); + log.info(result.toString()); } catch (Exception e) { } TimeUnit.SECONDS.sleep(3); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImplTest.java index 48fdf8c8e5..7a532d6bdb 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImplTest.java @@ -175,7 +175,7 @@ public void testSaveFavorCallbacksV3() throws WxPayException { public void testPauseFavorStocksV3() throws WxPayException { FavorStocksSetRequest request = new FavorStocksSetRequest(); request.setStockCreatorMchid(wxPayService.getConfig().getMchId()); - FavorStocksStartResult result = wxPayService.getMarketingFavorService().pauseFavorStocksV3(stockId, request); + FavorStocksPauseResult result = wxPayService.getMarketingFavorService().pauseFavorStocksV3(stockId, request); log.info("result: {}", GSON.toJson(result)); } @@ -184,7 +184,7 @@ public void testPauseFavorStocksV3() throws WxPayException { public void testRestartFavorStocksV3() throws WxPayException { FavorStocksSetRequest request = new FavorStocksSetRequest(); request.setStockCreatorMchid(wxPayService.getConfig().getMchId()); - FavorStocksStartResult result = wxPayService.getMarketingFavorService().restartFavorStocksV3(stockId, request); + FavorStocksRestartResult result = wxPayService.getMarketingFavorService().restartFavorStocksV3(stockId, request); log.info("result: {}", GSON.toJson(result)); } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java new file mode 100644 index 0000000000..d578fcab93 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java @@ -0,0 +1,110 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.merchanttransfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * 商家转账到零钱(直连商户) + * @author glz + * created on 2022/6/11 + */ +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class MerchantTransferServiceImplTest { + + @Inject + private WxPayService wxPayService; + + private static final Gson GSON = new GsonBuilder().create(); + + @Test + public void createTransfer() throws WxPayException { + String requestParamStr = "{\"out_batch_no\":\"p11lfk2020042013\",\"batch_name\":\"xxx\",\"batch_remark\":\"xxx\",\"total_amount\":30,\"total_num\":1,\"transfer_detail_list\":[{\"out_detail_no\":\"x23zy545Bd5436\",\"transfer_amount\":30,\"transfer_remark\":\"5586提款\",\"openid\":\"or1b65DLMUir7F-_vLwKlutmm3qw\",\"user_name\":\"xxx\"}]}"; + + TransferCreateRequest request = GSON.fromJson(requestParamStr, TransferCreateRequest.class); + TransferCreateResult result = wxPayService.getMerchantTransferService().createTransfer(request); + log.info(result.toString()); + } + + @Test + public void queryWxBatches() throws WxPayException { + String requestParamStr = "{\"batch_id\":\"xxx\",\"need_query_detail\":true,\"offset\":0,\"limit\":20,\"detail_status\":\"ALL\"}"; + + WxBatchesQueryRequest request = GSON.fromJson(requestParamStr, WxBatchesQueryRequest.class); + log.info("request:{}",request); + BatchesQueryResult result = wxPayService.getMerchantTransferService().queryWxBatches(request); + log.info(result.toString()); + } + + @Test + public void queryWxDetails() throws WxPayException { + String requestParamStr = "{\"batch_id\":\"xxx\",\"detail_id\":\"xxx\"}"; + + WxDetailsQueryRequest request = GSON.fromJson(requestParamStr, WxDetailsQueryRequest.class); + DetailsQueryResult result = wxPayService.getMerchantTransferService().queryWxDetails(request); + log.info(result.toString()); + } + + @Test + public void queryMerchantBatches() throws WxPayException { + String requestParamStr = "{\"out_batch_no\":\"p11lfk2020042013\",\"need_query_detail\":true,\"offset\":0,\"limit\":20,\"detail_status\":\"ALL\"}"; + + MerchantBatchesQueryRequest request = GSON.fromJson(requestParamStr, MerchantBatchesQueryRequest.class); + BatchesQueryResult result = wxPayService.getMerchantTransferService().queryMerchantBatches(request); + log.info(result.toString()); + } + + @Test + public void queryMerchantDetails() throws WxPayException { + String requestParamStr = "{\"out_detail_no\":\"x23zy545Bd5436\",\"out_batch_no\":\"p11lfk2020042013\"}"; + + MerchantDetailsQueryRequest request = GSON.fromJson(requestParamStr, MerchantDetailsQueryRequest.class); + DetailsQueryResult result = wxPayService.getMerchantTransferService().queryMerchantDetails(request); + log.info(result.toString()); + } + + @Test + public void applyElectronicBill() throws WxPayException { + String requestParamStr = "{\"out_batch_no\":\"p11lfk2020042013\"}"; + + ElectronicBillApplyRequest request = GSON.fromJson(requestParamStr, ElectronicBillApplyRequest.class); + ElectronicBillResult result = wxPayService.getMerchantTransferService().applyElectronicBill(request); + log.info(result.toString()); + } + + @Test + public void queryElectronicBill() throws WxPayException { + String outBatchNo = "p11lfk2020042013"; + + ElectronicBillResult result = wxPayService.getMerchantTransferService().queryElectronicBill(outBatchNo); + log.info(result.toString()); + } + + @Test + public void applyDetailElectronicBill() throws WxPayException { + String requestParamStr = "{\"accept_type\":\"BATCH_TRANSFER\",\"out_batch_no\":\"p11lfk2020042013\",\"out_detail_no\":\"x23zy545Bd5436\"}"; + + DetailElectronicBillRequest request = GSON.fromJson(requestParamStr, DetailElectronicBillRequest.class); + DetailElectronicBillResult result = wxPayService.getMerchantTransferService().applyDetailElectronicBill(request); + log.info(result.toString()); + } + + @Test + public void queryDetailElectronicBill() throws WxPayException { + String requestParamStr = "{\"accept_type\":\"BATCH_TRANSFER\",\"out_batch_no\":\"p11lfk2020042013\",\"out_detail_no\":\"x23zy545Bd5436\"}"; + + DetailElectronicBillRequest request = GSON.fromJson(requestParamStr, DetailElectronicBillRequest.class); + DetailElectronicBillResult result = wxPayService.getMerchantTransferService().queryDetailElectronicBill(request); + log.info(result.toString()); + } + +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreSignPlanServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreSignPlanServiceImplTest.java new file mode 100644 index 0000000000..c10884049d --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerPayScoreSignPlanServiceImplTest.java @@ -0,0 +1,76 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanRequest; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.PartnerPayScoreSignPlanService; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * @className PartnerPayScoreSignPlanServiceImplTest + * @description + * @author + * @createTime 2023/11/6 10:30 + **/ +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class PartnerPayScoreSignPlanServiceImplTest { + @Inject + private WxPayService wxPayService; + + private static final Gson GSON = new GsonBuilder().create(); + + @Test + public void testcreatePlans()throws WxPayException{ + PartnerPayScoreSignPlanService scoreSignPlan=new PartnerPayScoreSignPlanServiceImpl(wxPayService); + WxPartnerPayScoreSignPlanRequest request=new WxPartnerPayScoreSignPlanRequest(); + request.setSubMchid("子商户号"); + scoreSignPlan.createPlans(request); + } + + @Test + public void testqueryPlans()throws WxPayException{ + PartnerPayScoreSignPlanService scoreSignPlan=new PartnerPayScoreSignPlanServiceImpl(wxPayService); + scoreSignPlan.queryPlans("merchantPlanNo","子商户号"); + } + + @Test + public void teststopPlans()throws WxPayException{ + PartnerPayScoreSignPlanService scoreSignPlan=new PartnerPayScoreSignPlanServiceImpl(wxPayService); + scoreSignPlan.stopPlans("merchantPlanNo","子商户号"); + } + + @Test + public void testsignPlanServiceOrder()throws WxPayException{ + PartnerPayScoreSignPlanService scoreSignPlan=new PartnerPayScoreSignPlanServiceImpl(wxPayService); + WxPartnerPayScoreSignPlanRequest request=new WxPartnerPayScoreSignPlanRequest(); + + scoreSignPlan.signPlanServiceOrder(request); + } + + @Test + public void testcreateUserSignPlans()throws WxPayException{ + PartnerPayScoreSignPlanService scoreSignPlan=new PartnerPayScoreSignPlanServiceImpl(wxPayService); + WxPartnerPayScoreSignPlanRequest request=new WxPartnerPayScoreSignPlanRequest(); + scoreSignPlan.createUserSignPlans(request); + } + + @Test + public void testqueryUserSignPlans()throws WxPayException{ + PartnerPayScoreSignPlanService scoreSignPlan=new PartnerPayScoreSignPlanServiceImpl(wxPayService); + scoreSignPlan.queryUserSignPlans("merchantPlanNo","子商户号"); + } + + @Test + public void teststopUserSignPlans()throws WxPayException{ + PartnerPayScoreSignPlanService scoreSignPlan=new PartnerPayScoreSignPlanServiceImpl(wxPayService); + scoreSignPlan.stopUserSignPlans("merchantPlanNo","子商户号","测试取消"); + } +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImplTest.java new file mode 100644 index 0000000000..fc7b9b9501 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImplTest.java @@ -0,0 +1,139 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.ecommerce.FundBalanceResult; +import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum; +import com.github.binarywang.wxpay.bean.marketing.transfer.*; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import javax.crypto.BadPaddingException; +import java.io.InputStream; + +/** + * 批量转账到零钱(服务商) + * + * @author xiaoqiang + * created on 2021/12/9 + */ +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class PartnerTransferServiceImplTest { + + @Inject + private WxPayService wxPayService; + + private static final Gson GSON = new GsonBuilder().create(); + + @Test + public void batchTransfer() throws WxPayException { + String requestParamStr = "{\"sub_mchid\":\"1608*****1\",\"authorization_type\":\"FUND_AUTHORIZATION_TYPE\",\"out_batch_no\":\"202108241345*****4618387\",\"batch_name\":\"用户提现批次单2021-12-13_13_45_50\",\"batch_remark\":\"用户>提现\",\"total_amount\":30,\"total_num\":1,\"transfer_detail_list\":[{\"out_detail_no\":\"DN202112131345506240631640467671\",\"transfer_amount\":30,\"transfer_remark\":\"钱包提现\",\"openid\":\"oUaIE6PdSuBpsHAOtvf_jsgtqu5I\",\"user_name\":\"Q2FoOMuf1Ulsab+j0nObLjkIZAUZan8Z7RaEU5qOjv1RUq5ImuqqAqoQZ4f/zD5CMxuLD7lM1TIdGIvrvO8pe2YOwoUdRxiRzDX+Z0Rsy5Y9QqEiuHHK1JTR7vC18eKp0a4PlY7K4jUl49jG0QE+6gOG83Cqj3Z9dupPor94fPRUM/ZIzF293ONgSJW1iuHkd6g7EHTpizHZ/r5XcT+qh*************************kqjtVkT3GiuDXmMA8d/hO85uY50ItNNa5Ov8kmJbLCgFreoS49LUEwj/yuDap6F4g\\u003d\\u003d\"}],\"sp_appid\":\"wx6aa************ef\",\"transfer_purpose\":\"OTHERS\"}"; + + PartnerTransferRequest request = GSON.fromJson(requestParamStr, PartnerTransferRequest.class); + + PartnerTransferResult partnerTransferResult = wxPayService.getPartnerTransferService().batchTransfer(request); + log.info(partnerTransferResult.toString()); + } + + + @Test + public void queryBatchByBatchId() throws WxPayException { + BatchNumberRequest request = new BatchNumberRequest(); + request.setBatchId("1030000071100999991182020050700019480001"); + request.setNeedQueryDetail(true); + request.setDetailStatus("ALL"); + BatchNumberResult batchResult = wxPayService.getPartnerTransferService().queryBatchByBatchId(request); + log.info(batchResult.toString()); + } + + + @Test + public void queryBatchDetailByWeChat() throws WxPayException, BadPaddingException { + String batchId = "1030000071100999991182020050700019480001"; + String detailId = "1040000071100999991182020050700019500100"; + BatchDetailsResult batchResult = wxPayService.getPartnerTransferService().queryBatchDetailByWeChat(batchId, detailId); + log.info(batchResult.toString()); + } + + @Test + public void queryBatchByOutBatchNo() throws WxPayException { + MerchantBatchRequest request = new MerchantBatchRequest(); + request.setOutBatchNo("10300000************0019480001"); + request.setDetailStatus("ALL"); + request.setNeedQueryDetail(true); + BatchNumberResult batchResult = wxPayService.getPartnerTransferService().queryBatchByOutBatchNo(request); + log.info(batchResult.toString()); + } + + @Test + public void queryBatchDetailByMch() throws WxPayException, BadPaddingException { + String outBatchNo = "10300000************0019480001"; + String outDetailNo = "10***********0019480001"; + BatchDetailsResult batchResult = wxPayService.getPartnerTransferService().queryBatchDetailByMch(outBatchNo, outDetailNo); + log.info(batchResult.toString()); + } + + @Test + public void receiptBill() throws WxPayException { + ReceiptBillRequest request = new ReceiptBillRequest(); + request.setOutBatchNo("10300000************0019480001"); + BillReceiptResult batchResult = wxPayService.getPartnerTransferService().receiptBill(request); + log.info(batchResult.toString()); + } + + @Test + public void queryBillReceipt() throws WxPayException { + String outBatchNo = "10300000************0019480001"; + BillReceiptResult batchResult = wxPayService.getPartnerTransferService().queryBillReceipt(outBatchNo); + log.info(batchResult.toString()); + } + + @Test + public void transferElectronic() throws WxPayException { + ElectronicReceiptsRequest request = new ElectronicReceiptsRequest(); + request.setAcceptType("BATCH_TRANSFER"); + request.setOutBatchNo("GD2021011610162610BBdkkIwcu3"); + request.setOutDetailNo("mx0911231610162610v4CNkO4HAf"); + ElectronicReceiptsResult batchResult = wxPayService.getPartnerTransferService().transferElectronic(request); + log.info(batchResult.toString()); + } + + @Test + public void queryTransferElectronicResult() throws WxPayException { + ElectronicReceiptsRequest request = new ElectronicReceiptsRequest(); + request.setAcceptType("BATCH_TRANSFER"); + request.setOutBatchNo("GD2021011610162610BBdkkIwcu3"); + request.setOutDetailNo("mx0911231610162610v4CNkO4HAf"); + ElectronicReceiptsResult batchResult = wxPayService.getPartnerTransferService().queryTransferElectronicResult(request); + log.info(batchResult.toString()); + } + + + @Test + public void transferDownload() throws WxPayException { + String url = "https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx"; + InputStream batchResult = wxPayService.getPartnerTransferService().transferDownload(url); + log.info(batchResult.toString()); + } + + @Test + public void fundBalance() throws WxPayException { + FundBalanceResult batchResult = wxPayService.getPartnerTransferService().fundBalance(SpAccountTypeEnum.BASIC); + log.info(batchResult.toString()); + } + + @Test + public void spDayEndBalance() { + String date = "2020-09-11"; + FundBalanceResult batchResult = wxPayService.getPartnerTransferService().spDayEndBalance(SpAccountTypeEnum.BASIC, date); + log.info(batchResult.toString()); + } + +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java index 425cf99c6c..3682d06f3e 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java @@ -14,7 +14,7 @@ * 测试代码,待补充完善. * * @author Binary Wang - * @date 2020-05-19 + * created on 2020-05-19 */ @Test @Guice(modules = ApiTestModule.class) diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayrollServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayrollServiceImplTest.java new file mode 100644 index 0000000000..03bbc8c593 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayrollServiceImplTest.java @@ -0,0 +1,128 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.marketing.payroll.*; +import com.github.binarywang.wxpay.bean.marketing.transfer.PartnerTransferRequest; +import com.github.binarywang.wxpay.bean.marketing.transfer.PartnerTransferResult; +import com.github.binarywang.wxpay.bean.result.WxPayApplyBillV3Result; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * 微工卡(服务商) + * + * @author xiaoqiang + * created on 2021/12/9 + */ +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class PayrollServiceImplTest { + + + @Inject + private WxPayService wxPayService; + + private static final Gson GSON = new GsonBuilder().create(); + + @Test + public void payrollCardTokens() throws WxPayException { + TokensRequest request = new TokensRequest(); + request.setOpenid("onqOjjmo8wmTOOtSKwXtGjg9Gb58"); + request.setAppid("wxa1111111"); + request.setSubMchid("1111111"); + request.setSubAppid("wxa1111111"); + request.setUserName("LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg"); + request.setIdCardNumber("7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5"); + request.setEmploymentType("LONG_TERM_EMPLOYMENT"); + TokensResult tokensResult = wxPayService.getPayrollService().payrollCardTokens(request); + log.info(tokensResult.toString()); + + } + + @Test + public void payrollCardRelations() throws WxPayException { + RelationsRequest request = new RelationsRequest(); + request.setOpenid("onqOjjmo8wmTOOtSKwXtGjg9Gb58"); + request.setSubMchid("1111111"); + request.setAppid("wxa1111111"); + request.setSubAppid("wxa1111111"); + RelationsResult relationsResult = wxPayService.getPayrollService().payrollCardRelations(request); + log.info(relationsResult.toString()); + + } + + + @Test + public void payrollCardPreOrder() throws WxPayException { + PreOrderRequest request = new PreOrderRequest(); + request.setOpenid("onqOjjmo8wmTOOtSKwXtGjg9Gb58"); + request.setSubMchid("1111111"); + request.setAppid("wxa1111111"); + request.setSubAppid("wxa1111111"); + request.setAuthenticateNumber("mcdhehfgisdhfjghed39384564i83"); + request.setProjectName("某项目"); + request.setEmployerName("某单位名称"); + PreOrderResult preOrderResult = wxPayService.getPayrollService().payrollCardPreOrder(request); + log.info(preOrderResult.toString()); + + } + + @Test + public void payrollCardAuthenticationsNumber() throws WxPayException { + String subMchid = "1111111"; + String authenticateNumber = "mcdhehfgisdhfjghed39384564i83"; + AuthenticationsResult authenticationsResult = wxPayService.getPayrollService().payrollCardAuthenticationsNumber(subMchid, authenticateNumber); + log.info(authenticationsResult.toString()); + + } + + @Test + public void payrollCardAuthentications() throws WxPayException { + AuthRecordRequest request = new AuthRecordRequest(); + request.setOpenid("onqOjjmo8wmTOOtSKwXtGjg9Gb58"); + request.setSubMchid("1111111"); + request.setAppid("wxa1111111"); + request.setSubAppid("wxa1111111"); + request.setAuthenticateDate("2020-12-25"); + request.setAuthenticateState("AUTHENTICATE_SUCCESS"); + request.setOffset(0); + request.setLimit(10); + AuthRecordResult authRecordResult = wxPayService.getPayrollService().payrollCardAuthentications(request); + log.info(authRecordResult.toString()); + + } + + @Test + public void payrollCardPreOrderWithAuth() throws WxPayException { + PreOrderWithAuthRequest request = new PreOrderWithAuthRequest(); + request.setOpenid("onqOjjmo8wmTOOtSKwXtGjg9Gb58"); + request.setSubMchid("1111111"); + request.setAppid("wxa1111111"); + request.setSubAppid("wxa1111111"); + request.setAuthenticateNumber("mcdhehfgisdhfjghed39384564i83"); + request.setEmployerName("某用工企业"); + request.setEmploymentType("LONG_TERM_EMPLOYMENT"); + request.setIdCardNumber("7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5"); + request.setProjectName("某项目"); + request.setUserName("LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg"); + PreOrderWithAuthResult preOrderWithAuthResult = wxPayService.getPayrollService().payrollCardPreOrderWithAuth(request); + log.info(preOrderWithAuthResult.toString()); + + } + + @Test + public void merchantFundWithdrawBillType() throws WxPayException { + String billType = "NO_SUCC"; + String billDate = "2019-08-17"; + WxPayApplyBillV3Result result = wxPayService.getPayrollService().merchantFundWithdrawBillType(billType, billDate, null); + log.info(result.toString()); + } + +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java index 2638630cb3..c0cc83bf7b 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java @@ -1,21 +1,24 @@ package com.github.binarywang.wxpay.service.impl; +import com.github.binarywang.wxpay.bean.notify.SignatureHeader; import com.github.binarywang.wxpay.bean.profitsharing.*; +import com.github.binarywang.wxpay.bean.profitsharing.request.*; +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingMerchantRatioQueryResult; +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingOrderAmountQueryResult; +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingQueryResult; import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; @Test +@Slf4j @Guice(modules = ApiTestModule.class) public class ProfitSharingServiceImplTest { - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - @Inject private WxPayService payService; @@ -33,7 +36,7 @@ public void testProfitSharing() throws WxPayException { .transactionId("4200000431201910234736634272") .receivers(instance.toJSONString()) .build(); - this.logger.info(this.payService.getProfitSharingService().profitSharing(request).toString()); + log.info(this.payService.getProfitSharingService().profitSharing(request).toString()); } @Test @@ -49,18 +52,18 @@ public void testMultiProfitSharing() throws WxPayException { .transactionId("4200000448201910238249687345")//order_id=30000102922019102310821824010 .receivers(instance.toJSONString()) .build(); - this.logger.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString()); + log.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString()); } @Test public void testProfitSharingFinish() throws WxPayException { - ProfitSharingFinishRequest request = ProfitSharingFinishRequest + ProfitSharingUnfreezeRequest request = ProfitSharingUnfreezeRequest .newBuilder() .outOrderNo("20191023103251431856285") .transactionId("4200000441201910238267278073") .description("分账完成") .build(); - this.logger.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString()); + log.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString()); } @Test @@ -74,7 +77,7 @@ public void testAddReceiver() throws WxPayException { .newBuilder() .receiver(receiver.toJSONString()) .build(); - this.logger.info(this.payService.getProfitSharingService().addReceiver(request).toString()); + log.info(this.payService.getProfitSharingService().addReceiver(request).toString()); } @Test @@ -85,7 +88,7 @@ public void testRemoveReceiver() throws WxPayException { .newBuilder() .receiver(receiver.toJSONString()) .build(); - this.logger.info(this.payService.getProfitSharingService().removeReceiver(request).toString()); + log.info(this.payService.getProfitSharingService().removeReceiver(request).toString()); } @Test @@ -96,8 +99,8 @@ public void testProfitSharingQuery() throws WxPayException { .transactionId("4200000431201910234736634272") .build(); ProfitSharingQueryResult result = this.payService.getProfitSharingService().profitSharingQuery(request); - this.logger.info(result.formatReceivers().toString()); - this.logger.info(result.toString()); + log.info(result.formatReceivers().toString()); + log.info(result.toString()); } @Test @@ -105,17 +108,17 @@ public void testProfitSharingMerchantRatioQuery() throws WxPayException { final String subMchId = "subMchid"; final ProfitSharingMerchantRatioQueryRequest request = new ProfitSharingMerchantRatioQueryRequest(subMchId); final ProfitSharingMerchantRatioQueryResult result = payService.getProfitSharingService().profitSharingMerchantRatioQuery(request); - logger.info(result.toString()); + log.info(result.toString()); } @Test - public void testProfitSharingOrderAmountQuery() throws WxPayException { + public void testProfitSharingOrderAmountQuery() throws WxPayException { final String transactionId = "4200000916202012281633853127"; final ProfitSharingOrderAmountQueryRequest request = ProfitSharingOrderAmountQueryRequest.newBuilder() .transactionId(transactionId) .build(); final ProfitSharingOrderAmountQueryResult result = payService.getProfitSharingService().profitSharingOrderAmountQuery(request); - logger.info(result.toString()); + log.info(result.toString()); } @Test @@ -129,7 +132,7 @@ public void testProfitSharingReturn() throws WxPayException { .returnAmount(2) .description("用户退款") .build(); - this.logger.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString()); + log.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString()); } @Test @@ -139,7 +142,18 @@ public void testProfitSharingReturnQuery() throws WxPayException { .outOrderNo("20191023154723316420060") .outReturnNo("R2019102315") .build(); - this.logger.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString()); + log.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString()); + } + + @Test + public void testProfitSharingNotifyData() throws WxPayException { + SignatureHeader header = new SignatureHeader(); + header.setSerial("Wechatpay-Serial"); + header.setTimeStamp("Wechatpay-Timestamp"); + header.setNonce("Wechatpay-Nonce"); + header.setSignature("Wechatpay-Signature"); + String data = "body"; + log.info(this.payService.getProfitSharingService().parseProfitSharingNotifyResult(data,header).toString()); } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImplTest.java index 161135b51f..b572518e95 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImplTest.java @@ -18,7 +18,7 @@ * 测试类. * * @author Binary Wang - * @date 2019-12-26 + * created on 2019-12-26 */ @Slf4j @Test diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/TransferServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/TransferServiceImplTest.java new file mode 100644 index 0000000000..7f89bd4721 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/TransferServiceImplTest.java @@ -0,0 +1,76 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.bean.transfer.QueryTransferBatchesRequest; +import com.github.binarywang.wxpay.bean.transfer.TransferBatchesRequest; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +/** + * 获取商家转账到零钱服务类API测试 + * + * @author zhongjun + * created on 2022/6/17 + **/ +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class TransferServiceImplTest { + + @Inject + private WxPayService payService; + + @Test + public void testTransferBatches() throws WxPayException { + List transferDetailList = new ArrayList<>(); + transferDetailList.add(TransferBatchesRequest.TransferDetail.newBuilder() + .outDetailNo("1655447989156") + .transferAmount(100) + .transferRemark("测试转账") + .openid("oX_7Jzr9gSZz4X_Xc9-_7HGf8XzI") + .userName("测试用户").build()); + TransferBatchesRequest batchesRequest = TransferBatchesRequest.newBuilder() + .appid("wxf636efh5xxxxx") + .outBatchNo("1655447999520") + .batchName("测试批次") + .batchRemark("测试批次备注") + .totalAmount(100) + .totalNum(1) + .transferDetailList(transferDetailList).build(); + log.info("发起商家转账:{}", this.payService.getTransferService().transferBatches(batchesRequest)); + } + + @Test + public void testTransferBatchesBatchId() throws WxPayException { + log.info("微信批次单号查询批次单:{}", this.payService.getTransferService().transferBatchesBatchId(QueryTransferBatchesRequest.newBuilder() + .batchId("1655448154148") + .needQueryDetail(true) + .build())); + + } + + @Test + public void testTransferBatchesBatchIdDetail() throws WxPayException { + log.info("微信明细单号查询明细单:{}", this.payService.getTransferService().transferBatchesBatchIdDetail("1030000071100999991182020050700019480001", "1040000071100999991182020050700019500100")); + } + + @Test + public void testTransferBatchesOutBatchNo() throws WxPayException { + log.info("商家批次单号查询批次单:{}", this.payService.getTransferService().transferBatchesOutBatchNo(QueryTransferBatchesRequest.newBuilder() + .outBatchNo("1655447999520") + .needQueryDetail(true) + .build())); + } + + @Test + public void testTransferBatchesOutBatchNoDetail() throws WxPayException { + log.info("商家明细单号查询明细单:{}", this.payService.getTransferService().transferBatchesOutBatchNoDetail("1655447999520", "1655447989156")); + } +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java index 9323108963..ca20d0c51d 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java @@ -14,7 +14,7 @@ /** * @author chenliang - * @date 2021-08-02 6:45 下午 + * created on 2021-08-02 6:45 下午 */ @Test @Guice(modules = ApiTestModule.class) @@ -177,6 +177,31 @@ public void testWithhold() { } } + @Test + public void testWithholdPartner() { + String outTradeNo = "101010101"; + WxWithholdRequest withholdRequest = WxWithholdRequest.newBuilder() + .attach("local") + .body("产品名字") + .contractId("202011065409471222") // 微信返回的签约协议号 + .detail("产品描述") + .feeType("CNY") + //.goodsTag() + .notifyUrl("http://domain.com/api/wxpay/withhold/callback.do") + .outTradeNo(outTradeNo) + .spbillCreateIp("127.0.0.1") + .totalFee(1) + .tradeType("PAP") + .build(); + + try { + WxPayCommonResult wxPayCommonResult = this.payService.getWxEntrustPapService().withholdPartner(withholdRequest); + logger.info(wxPayCommonResult.toString()); + } catch (WxPayException e) { + e.printStackTrace(); + } + } + @Test public void testPreWithhold() { WxPreWithholdRequest.EstimateAmount estimateAmount = new WxPreWithholdRequest.EstimateAmount(); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/CustomizedApiTestModule.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/CustomizedApiTestModule.java new file mode 100644 index 0000000000..a0cc399ea9 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/CustomizedApiTestModule.java @@ -0,0 +1,61 @@ +package com.github.binarywang.wxpay.testbase; + +import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; +import com.google.inject.Binder; +import com.google.inject.Module; +import com.thoughtworks.xstream.XStream; +import me.chanjar.weixin.common.error.WxRuntimeException; +import me.chanjar.weixin.common.util.xml.XStreamInitializer; +import org.apache.http.HttpRequestInterceptor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; + +/** + * The type Api test module. + */ +public class CustomizedApiTestModule implements Module { + private final Logger log = LoggerFactory.getLogger(this.getClass()); + private static final String TEST_CONFIG_XML = "test-config.xml"; + + @Override + public void configure(Binder binder) { + try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) { + if (inputStream == null) { + throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成"); + } + + XmlWxPayConfig config = this.fromXml(XmlWxPayConfig.class, inputStream); + config.setIfSaveApiData(true); + + config.setApiV3HttpClientBuilderCustomizer((builder) -> { + builder.addInterceptorLast((HttpRequestInterceptor) (r, c) -> System.out.println("--------> V3 HttpRequestInterceptor ...")); + }); + + config.setHttpClientBuilderCustomizer((builder) -> { + builder.addInterceptorLast((HttpRequestInterceptor) (r, c) -> System.out.println("--------> HttpRequestInterceptor ...")); + }); + + WxPayService wxService = new WxPayServiceImpl(); + wxService.setConfig(config); + + binder.bind(WxPayService.class).toInstance(wxService); + binder.bind(WxPayConfig.class).toInstance(config); + } catch (IOException e) { + this.log.error(e.getMessage(), e); + } + } + + @SuppressWarnings("unchecked") + private T fromXml(Class clazz, InputStream is) { + XStream xstream = XStreamInitializer.getInstance(); + xstream.alias("xml", clazz); + xstream.processAnnotations(clazz); + return (T) xstream.fromXML(is); + } + +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifierTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifierTest.java new file mode 100644 index 0000000000..e04ecf28e3 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifierTest.java @@ -0,0 +1,55 @@ +package com.github.binarywang.wxpay.v3.auth; + +import com.github.binarywang.wxpay.bean.merchanttransfer.TransferCreateRequest; +import com.github.binarywang.wxpay.bean.merchanttransfer.TransferCreateRequest.TransferDetailList; +import com.github.binarywang.wxpay.bean.merchanttransfer.TransferCreateResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.testbase.ApiTestModule; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.util.Asserts; +import org.assertj.core.util.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * 商家转账到零钱(直连商户)- 商户号配置信息错误时健壮性判断单元测试 + * @author imyzt + * created on 2022/10/23 + */ +@Slf4j +@Test +@Guice(modules = ApiTestModule.class) +public class AutoUpdateCertificatesVerifierTest { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Inject + private WxPayService payService; + + @Test + public void testVerify() throws WxPayException { + TransferDetailList transferDetailList = new TransferDetailList(); + transferDetailList.setOutDetailNo("test") + .setOpenid("test") + .setTransferAmount(1) + .setOutDetailNo("test") + .setUserName("test"); + TransferCreateRequest req = TransferCreateRequest.builder() + .appid("wxd930ea5d5a258f4f") + .batchName("test") + .outBatchNo("") + .totalAmount(1) + .totalNum(1) + .transferDetailList(Lists.newArrayList(transferDetailList)) + .build(); + TransferCreateResult transfer = payService.getMerchantTransferService().createTransfer(req); + Asserts.notNull(transfer, "transfer"); + + // 商户未申请过证书。请到商户平台上申请证书授权机构颁发的证书。详情可参考:http://kf.qq.com/faq/180824JvUZ3i180824YvMNJj.html + + } +} diff --git a/weixin-java-pay/src/test/resources/test-config.sample.xml b/weixin-java-pay/src/test/resources/test-config.sample.xml index 25ec4be056..a63cd8dc30 100644 --- a/weixin-java-pay/src/test/resources/test-config.sample.xml +++ b/weixin-java-pay/src/test/resources/test-config.sample.xml @@ -1,21 +1,24 @@ - 公众号appid + + + appid 微信商户平台ID + + 商户平台设置的API密钥 - 商户平台的证书文件地址 - 某个openId - apiV3 秘钥值. apiV3 证书序列号值 - --> + apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径. + apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径. + + + 某个openId diff --git a/weixin-java-qidian/pom.xml b/weixin-java-qidian/pom.xml index f36c374918..b33e1e80af 100644 --- a/weixin-java-qidian/pom.xml +++ b/weixin-java-qidian/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang wx-java - 4.1.9.B + 4.5.7.B weixin-java-qidian diff --git a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceOkHttpImpl.java b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceOkHttpImpl.java index 2399399de7..92cf51e670 100644 --- a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceOkHttpImpl.java +++ b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceOkHttpImpl.java @@ -3,6 +3,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpType; +import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import okhttp3.*; @@ -76,11 +77,8 @@ public void initHttp() { // 设置代理 if (wxMpConfigStorage.getHttpProxyHost() != null && wxMpConfigStorage.getHttpProxyPort() > 0) { httpProxy = OkHttpProxyInfo.httpProxy(wxMpConfigStorage.getHttpProxyHost(), wxMpConfigStorage.getHttpProxyPort(), - wxMpConfigStorage.getHttpProxyUsername(), wxMpConfigStorage.getHttpProxyPassword()); - } - - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); - if (httpProxy != null) { + wxMpConfigStorage.getHttpProxyUsername(), wxMpConfigStorage.getHttpProxyPassword()); + OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); clientBuilder.proxy(getRequestHttpProxy().getProxy()); // 设置授权 @@ -91,8 +89,10 @@ public Request authenticate(Route route, Response response) throws IOException { return response.request().newBuilder().header("Authorization", credential).build(); } }); + httpClient = clientBuilder.build(); + } else { + httpClient = DefaultOkHttpClientBuilder.get().build(); } - httpClient = clientBuilder.build(); } } diff --git a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/WxQidianHostConfig.java b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/WxQidianHostConfig.java index 677348863d..881538b9d0 100644 --- a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/WxQidianHostConfig.java +++ b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/WxQidianHostConfig.java @@ -9,7 +9,7 @@ * 企点接口地址域名部分的自定义设置信息. * * @author alegria - * @date 2020-12-24 + * created on 2020-12-24 */ @Data @Builder diff --git a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedissonConfigImpl.java b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedissonConfigImpl.java index 876922e061..ffb4033b4c 100644 --- a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedissonConfigImpl.java +++ b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedissonConfigImpl.java @@ -12,7 +12,7 @@ /** * @author wuxingye - * @date 2020/6/12 + * created on 2020/6/12 */ @EqualsAndHashCode(callSuper = true) @Data diff --git a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/WxQidianConfigStorageHolder.java b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/WxQidianConfigStorageHolder.java index 1177ce4ac6..ec2e872942 100644 --- a/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/WxQidianConfigStorageHolder.java +++ b/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/WxQidianConfigStorageHolder.java @@ -2,10 +2,10 @@ /** * @author alegria - * @date 2020年12月26日 + * created on 2020年12月26日 */ public class WxQidianConfigStorageHolder { - private final static ThreadLocal THREAD_LOCAL = new ThreadLocal() { + private static final ThreadLocal THREAD_LOCAL = new ThreadLocal() { @Override protected String initialValue() { return "default"; diff --git a/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImplTest.java b/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImplTest.java index e91d471c15..43e7ba299d 100644 --- a/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImplTest.java +++ b/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImplTest.java @@ -32,7 +32,7 @@ public void dial() throws WxErrorException { IVRListResponse iVRListResponse = this.wxService.getDialService().getIVRList(); Assert.assertEquals(iVRListResponse.getErrcode(), new Integer(0)); log.info("ivr size:" + iVRListResponse.getNode().size()); - Optional optional = iVRListResponse.getNode().stream().filter((o) -> o.getIvr_name().equals("自动接听需求测试")) + Optional optional = iVRListResponse.getNode().stream().filter(o -> o.getIvr_name().equals("自动接听需求测试")) .findFirst(); Assert.assertTrue(optional.isPresent()); Ivr ivr = optional.get();