mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0af2c704e | ||
|
|
320f05e6d6 | ||
|
|
4d7fd68fe5 | ||
|
|
388188b694 | ||
|
|
ecce9292b2 | ||
|
|
96a5cc995b | ||
|
|
4d66dd09ca | ||
|
|
08e2107667 | ||
|
|
f71ac2185c | ||
|
|
5bde717f8f | ||
|
|
8bacc9425e | ||
|
|
3e1a38a696 | ||
|
|
fefe737803 | ||
|
|
d0b7a526f6 | ||
|
|
47051bdf31 | ||
|
|
f5dd32de86 | ||
|
|
d776792bae | ||
|
|
1a74e3e3a8 | ||
|
|
2762a98279 | ||
|
|
04c162f03a | ||
|
|
5c2a36c538 | ||
|
|
2c4b5ea128 | ||
|
|
9a6db34b6a | ||
|
|
77b90626f3 | ||
|
|
063fbb7f19 | ||
|
|
a7b007f853 | ||
|
|
c91a5a8e22 | ||
|
|
a051587d3e | ||
|
|
245cf72104 | ||
|
|
fb57af7409 | ||
|
|
88a5bc4f43 | ||
|
|
dc674ce024 | ||
|
|
854b50bd51 | ||
|
|
2d8d1df00e | ||
|
|
2279105fef | ||
|
|
cbb3b24577 | ||
|
|
ddfbee25e1 | ||
|
|
6a4ed91ae2 | ||
|
|
59f5a99fda | ||
|
|
3718b499a0 | ||
|
|
bb76db052d | ||
|
|
e16e0e9373 | ||
|
|
89280abd00 |
4
.github/workflows
vendored
4
.github/workflows
vendored
@@ -1,4 +0,0 @@
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
94
.github/workflows/maven-publish.yml
vendored
Normal file
94
.github/workflows/maven-publish.yml
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
name: Publish to Maven Central
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: maven-publish-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Detect and tag release version from commit message
|
||||
id: version_detect
|
||||
run: |
|
||||
COMMIT_MSG=$(git log -1 --pretty=%B)
|
||||
VERSION=""
|
||||
TAG=""
|
||||
IS_RELEASE="false"
|
||||
if [[ "$COMMIT_MSG" =~ ^:bookmark:\ 发布\ ([0-9]+\.[0-9]+\.[0-9]+)\.B\ 测试版本 ]]; then
|
||||
BASE_VER="${BASH_REMATCH[1]}"
|
||||
VERSION="${BASE_VER}.B"
|
||||
TAG="v${BASE_VER}"
|
||||
IS_RELEASE="true"
|
||||
echo "Matched release commit: VERSION=$VERSION, TAG=$TAG"
|
||||
# 检查并打tag
|
||||
if git tag | grep -q "^$TAG$"; then
|
||||
echo "Tag $TAG already exists."
|
||||
else
|
||||
git config user.name "Binary Wang"
|
||||
git config user.email "a@binarywang.com"
|
||||
git tag -a "$TAG" -m "Release $TAG"
|
||||
git push origin "$TAG"
|
||||
echo "Tag $TAG created and pushed."
|
||||
fi
|
||||
fi
|
||||
echo "is_release=$IS_RELEASE" >> $GITHUB_OUTPUT
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
server-id: central
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
||||
cache: maven
|
||||
|
||||
- name: Verify GPG keys
|
||||
run: |
|
||||
echo "Available GPG Keys:"
|
||||
gpg --list-secret-keys --keyid-format LONG
|
||||
|
||||
- name: Generate and set version
|
||||
id: set_version
|
||||
run: |
|
||||
if [[ "${{ steps.version_detect.outputs.is_release }}" == "true" ]]; then
|
||||
VERSION="${{ steps.version_detect.outputs.version }}"
|
||||
else
|
||||
git describe --tags 2>/dev/null || echo "no tag"
|
||||
TIMESTAMP=$(date +'%Y%m%d.%H%M%S')
|
||||
GIT_DESCRIBE=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.1")
|
||||
VERSION="${GIT_DESCRIBE}-${TIMESTAMP}"
|
||||
fi
|
||||
echo "Final version: $VERSION"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
mvn versions:set -DnewVersion=$VERSION --no-transfer-progress
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
- name: Publish to Maven Central
|
||||
run: |
|
||||
mvn clean deploy -P release \
|
||||
-Dmaven.test.skip=true \
|
||||
-Dgpg.args="--batch --yes --pinentry-mode loopback" \
|
||||
--no-transfer-progress
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||
121
README.md
121
README.md
@@ -1,65 +1,65 @@
|
||||
## WxJava - 微信开发 Java SDK
|
||||
[](https://github.com/binarywang/WxJava)
|
||||
[](https://gitee.com/binary/weixin-java-tools)
|
||||
[](https://gitcode.com/binary/WxJava)
|
||||
|
||||
[](https://gitee.com/binary/weixin-java-tools)
|
||||
[](https://github.com/binarywang/WxJava)
|
||||
[](https://github.com/binarywang/WxJava/releases)
|
||||
[](http://mvnrepository.com/artifact/com.github.binarywang/wx-java)
|
||||
[](https://circleci.com/gh/binarywang/WxJava/tree/develop)
|
||||
[](https://github.com/binarywang/WxJava/releases)
|
||||
[](https://central.sonatype.com/artifact/com.github.binarywang/wx-java/versions)
|
||||
[](https://circleci.com/gh/binarywang/WxJava/tree/develop)
|
||||
[](https://www.jetbrains.com/?from=WxJava-weixin-java-tools)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
#### 微信`Java`开发工具包,支持包括微信支付、开放平台、公众号、企业微信、视频号、小程序等微信功能模块的后端开发。
|
||||
<div align="center">
|
||||
<a href="https://hellogithub.com/repository/6de6147050c94db4aedfd7098d19f8d8" target="_blank">
|
||||
<img src="https://api.hellogithub.com/v1/widgets/recommend.svg?rid=6de6147050c94db4aedfd7098d19f8d8&claim_uid=mwKh0tILBfjlezR" alt="Featured|HelloGitHub" width="250" height="54" />
|
||||
</a>
|
||||
<a href="https://trendshift.io/repositories/12152" target="_blank">
|
||||
<img src="https://trendshift.io/api/badge/repositories/12152" alt="binarywang%2FWxJava | 趋势转变" width="250" height="55" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
### 微信`Java`开发工具包,支持包括微信支付、开放平台、公众号、企业微信、视频号、小程序等微信功能模块的后端开发。
|
||||
<div align="center">
|
||||
<b>特别赞助</b>
|
||||
<table cellspacing="0" cellpadding="0" width="500">
|
||||
<tr>
|
||||
<td align="center" colspan="3">
|
||||
<a href="http://www.ccflow.org/?from=wxjava" target="_blank">
|
||||
<img height="120" src="https://ccfast.cc/AD/ccflow2.png" alt="ccflow">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan="2">
|
||||
<a href="https://www.jeequan.com/product/jeepay.html" target="_blank">
|
||||
<img height="120" src="https://jeequan.oss-cn-beijing.aliyuncs.com/jeepay/img/wxjava_jeepay.png" alt="计全支付Jeepay,开源支付系统">
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://www.mall4j.com/cn/?statId=9" target="_blank">
|
||||
<img height="120" src="https://img.mall4j.com/mall.png" alt="Mall4j">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="http://mp.weixin.qq.com/mp/homepage?__biz=MzI3MzAwMzk4OA==&hid=1&sn=f31af3bf562b116b061c9ab4edf70b61&scene=18#wechat_redirect" target="_blank">
|
||||
<img height="120" src="https://gitee.com/binary/weixin-java-tools/raw/develop/images/qrcodes/mp.png" alt="mp qrcode">
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://www.diboot.com?from=wxjava" target="_blank">
|
||||
<img height="120" src="https://www.diboot.com/img/diboot_ad.png" alt="diboot低代码开发平台">
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="#" target="_blank">
|
||||
<img height="120" src="images/banners/aliyun.jpg" alt="ad">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<table align="center" cellspacing="0" cellpadding="0" width="500">
|
||||
<tr>
|
||||
<td align="center" valign="middle" colspan="3">
|
||||
<a href="http://www.ccflow.org/?from=wxjava" target="_blank">
|
||||
<img height="120" src="https://ccfast.cc/AD/ccflow2.png" alt="ccflow">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="middle" colspan="2">
|
||||
<a href="https://www.jeequan.com/product/jeepay.html" target="_blank">
|
||||
<img height="120" src="https://jeequan.oss-cn-beijing.aliyuncs.com/jeepay/img/wxjava_jeepay.png" alt="计全支付Jeepay,开源支付系统">
|
||||
</a>
|
||||
</td>
|
||||
<td align="center" valign="middle" colspan="1">
|
||||
<a href="https://www.mall4j.com/cn/?statId=9" target="_blank">
|
||||
<img height="120" src="https://img.mall4j.com/mall.png" alt="Mall4j">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="middle">
|
||||
<a href="http://mp.weixin.qq.com/mp/homepage?__biz=MzI3MzAwMzk4OA==&hid=1&sn=f31af3bf562b116b061c9ab4edf70b61&scene=18#wechat_redirect" target="_blank">
|
||||
<img height="120" src="https://gitee.com/binary/weixin-java-tools/raw/develop/images/qrcodes/mp.png" alt="mp qrcode">
|
||||
</a>
|
||||
</td>
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://www.diboot.com?from=wxjava" target="_blank">
|
||||
<img height="120" src="https://www.diboot.com/img/diboot_ad.png" alt="diboot低代码开发平台"/>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://www.iyque.cn/" target="_blank">
|
||||
<img height="120" src="https://iyque-1251309172.cos.ap-nanjing.myqcloud.com/advert/wxjava.jpg" alt="aliyun ad">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center">
|
||||
<a href="https://hellogithub.com/repository/6de6147050c94db4aedfd7098d19f8d8" target="_blank">
|
||||
<img src="https://api.hellogithub.com/v1/widgets/recommend.svg?rid=6de6147050c94db4aedfd7098d19f8d8&claim_uid=mwKh0tILBfjlezR"
|
||||
alt="Featured|HelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" />
|
||||
</a>
|
||||
<a href="https://trendshift.io/repositories/12152" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12152" alt="binarywang%2FWxJava | 趋势转变" style="width: 250px; height: 55px;" width="250" height="55"/>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### 重要信息
|
||||
1. [`WxJava` 荣获 `GitCode` 2024年度十大开源社区奖项](https://mp.weixin.qq.com/s/wM_UlMsDm3IZ1CPPDvcvQw)。
|
||||
@@ -89,7 +89,7 @@
|
||||
|
||||
---------------------------------
|
||||
### Maven 引用方式
|
||||
注意:最新版本(包括测试版)为 [](http://mvnrepository.com/artifact/com.github.binarywang/wx-java),以下为最新正式版。
|
||||
注意:最新版本(包括测试版)为 [](https://central.sonatype.com/artifact/com.github.binarywang/wx-java/versions),以下为最新正式版。
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
@@ -113,10 +113,13 @@
|
||||
<details>
|
||||
<summary>点此展开查看</summary>
|
||||
|
||||
1. 本项目定为大约每两个月发布一次正式版(同时 `develop` 分支代码合并进入 `release` 分支),版本号格式为 `X.X.0`(如`2.1.0`,`2.2.0`等),遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request;
|
||||
2. BUG修复和新特性一般会先发布成小版本作为临时测试版本(如`3.6.8.B`,即尾号不为0,并添加B,以区别于正式版),代码仅存在于 `develop` 分支中;
|
||||
3. 目前最新版本号为 [](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)
|
||||
分别查看所有最新的版本。
|
||||
1. 本项目定为大约每半年左右发布一次正式版,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交 `Pull Request`;
|
||||
2. 每次代码更新都会自动构建出新版本方便及时尝鲜,版本号格式为 `x.x.x-时间戳`;
|
||||
3. 发布正式版时,`develop` 分支代码合并进入 `release` 分支),版本号格式为 `X.X.0`(如`2.1.0`,`2.2.0`等);
|
||||
4. 每隔一段时间后,会发布测试版本(如`3.6.8.B`,即尾号不为0,并添加B,以区别于正式版),代码仅存在于 `develop` 分支中;
|
||||
5. 目前最新版本号为 [](http://mvnrepository.com/artifact/com.github.binarywang/wx-java) ,也可以通过访问以下链接分别查看各个模块最新的版本:
|
||||
[【微信支付】](https://central.sonatype.com/artifact/com.github.binarywang/weixin-java-pay/versions) 、[【小程序】](https://central.sonatype.com/artifact/com.github.binarywang/weixin-java-miniapp/versions) 、[【公众号】](https://central.sonatype.com/artifact/com.github.binarywang/weixin-java-mp/versions) 、[【企业微信】](https://central.sonatype.com/artifact/com.github.binarywang/weixin-java-cp/versions)、[【开放平台】](https://central.sonatype.com/artifact/com.github.binarywang/weixin-java-open/versions)、[【视频号】](https://central.sonatype.com/artifact/com.github.binarywang/weixin-java-channel/versions)
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 241 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB |
47
pom.xml
47
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WxJava - Weixin/Wechat Java SDK</name>
|
||||
<description>微信开发Java SDK</description>
|
||||
@@ -136,10 +136,8 @@
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<httpclient.version>4.5.13</httpclient.version>
|
||||
<jetty.version>9.4.56.v20240826</jetty.version>
|
||||
<!-- 这个不能用10以上的版本,不支持jdk8-->
|
||||
<jetty.version>9.4.57.v20241219</jetty.version> <!-- 这个不能用10以上的版本,不支持jdk8-->
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -159,6 +157,12 @@
|
||||
<version>4.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<version>5.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
@@ -198,17 +202,19 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>32.1.2-jre</version>
|
||||
<version>33.3.1-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<version>2.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
<version>2.15.2</version>
|
||||
<groupId>com.fasterxml.jackson</groupId>
|
||||
<artifactId>jackson-bom</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 测试所用依赖 -->
|
||||
@@ -332,17 +338,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>doclint-java8-disable</id>
|
||||
@@ -432,14 +427,14 @@
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.3</version>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>0.7.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
<deploymentName>Release WxJava:${project.version}</deploymentName>
|
||||
<publishingServerId>central</publishingServerId>
|
||||
<autoPublish>true</autoPublish>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
@@ -14,7 +14,7 @@
|
||||
<description>WxJava 各个模块的 Solon Plugin</description>
|
||||
|
||||
<properties>
|
||||
<solon.version>3.0.1</solon.version>
|
||||
<solon.version>3.2.0</solon.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
92
solon-plugins/wx-java-channel-solon-plugin/README.md
Normal file
92
solon-plugins/wx-java-channel-solon-plugin/README.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# wx-java-channel-solon-plugin
|
||||
|
||||
## 快速开始
|
||||
1. 引入依赖
|
||||
```xml
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-channel-solon-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置存储方式为jedis 则引入jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置存储方式为redisson 则引入redisson -->
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>${redisson.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
2. 添加配置(app.properties)
|
||||
```properties
|
||||
# 视频号配置(必填)
|
||||
## 视频号小店的appId和secret
|
||||
wx.channel.app-id=@appId
|
||||
wx.channel.secret=@secret
|
||||
# 视频号配置 选填
|
||||
## 设置视频号小店消息服务器配置的token
|
||||
wx.channel.token=@token
|
||||
## 设置视频号小店消息服务器配置的EncodingAESKey
|
||||
wx.channel.aes-key=
|
||||
## 支持JSON或者XML格式,默认JSON
|
||||
wx.channel.msg-data-format=JSON
|
||||
## 是否使用稳定版 Access Token
|
||||
wx.channel.use-stable-access-token=false
|
||||
|
||||
|
||||
# ConfigStorage 配置(选填)
|
||||
## 配置类型: memory(默认), jedis, redisson, redis_template
|
||||
wx.channel.config-storage.type=memory
|
||||
## 相关redis前缀配置: wx:channel(默认)
|
||||
wx.channel.config-storage.key-prefix=wx:channel
|
||||
wx.channel.config-storage.redis.host=127.0.0.1
|
||||
wx.channel.config-storage.redis.port=6379
|
||||
wx.channel.config-storage.redis.password=123456
|
||||
|
||||
|
||||
# http 客户端配置(选填)
|
||||
## # http客户端类型: http_client(默认)
|
||||
wx.channel.config-storage.http-client-type=http_client
|
||||
wx.channel.config-storage.http-proxy-host=
|
||||
wx.channel.config-storage.http-proxy-port=
|
||||
wx.channel.config-storage.http-proxy-username=
|
||||
wx.channel.config-storage.http-proxy-password=
|
||||
## 最大重试次数,默认:5 次,如果小于 0,则为 0
|
||||
wx.channel.config-storage.max-retry-times=5
|
||||
## 重试时间间隔步进,默认:1000 毫秒,如果小于 0,则为 1000
|
||||
wx.channel.config-storage.retry-sleep-millis=1000
|
||||
```
|
||||
3. 自动注入的类型
|
||||
- `WxChannelService`
|
||||
- `WxChannelConfig`
|
||||
4. 使用样例
|
||||
|
||||
```java
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
@Component
|
||||
public class DemoService {
|
||||
@Inject
|
||||
private WxChannelService wxChannelService;
|
||||
|
||||
public String getShopInfo() throws WxErrorException {
|
||||
// 获取店铺基本信息
|
||||
ShopInfoResponse response = wxChannelService.getBasicService().getShopInfo();
|
||||
// 此处为演示,如果要返回response的结果,建议自己封装一个VO,避免直接返回response
|
||||
return JsonUtils.encode(response);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ import org.noear.solon.annotation.Condition;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.AppContext;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
import redis.clients.jedis.util.Pool;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -75,7 +77,7 @@ public class WxQidianStorageAutoConfiguration {
|
||||
}
|
||||
|
||||
private WxQidianConfigStorage jedisConfigStorage() {
|
||||
Pool jedisPool;
|
||||
Pool<Jedis> jedisPool;
|
||||
if (StringUtils.isNotEmpty(redisHost) || StringUtils.isNotEmpty(redisHost2)) {
|
||||
jedisPool = getJedisPool();
|
||||
} else {
|
||||
@@ -104,7 +106,7 @@ public class WxQidianStorageAutoConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
private Pool getJedisPool() {
|
||||
private Pool<Jedis> getJedisPool() {
|
||||
WxQidianProperties.ConfigStorage storage = wxQidianProperties.getConfigStorage();
|
||||
RedisProperties redis = storage.getRedis();
|
||||
|
||||
@@ -116,7 +118,7 @@ public class WxQidianStorageAutoConfiguration {
|
||||
config.setMaxIdle(redis.getMaxIdle());
|
||||
}
|
||||
if (redis.getMaxWaitMillis() != null) {
|
||||
config.setMaxWaitMillis(redis.getMaxWaitMillis());
|
||||
config.setMaxWait(Duration.ofMillis(redis.getMaxWaitMillis()));
|
||||
}
|
||||
if (redis.getMinIdle() != null) {
|
||||
config.setMinIdle(redis.getMinIdle());
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ 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.JedisPoolConfig;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
@@ -80,7 +81,7 @@ public class WxQidianStorageAutoConfiguration {
|
||||
}
|
||||
|
||||
private WxQidianConfigStorage jedisConfigStorage() {
|
||||
Pool jedisPool;
|
||||
Pool<Jedis> jedisPool;
|
||||
if (StringUtils.isNotEmpty(redisHost) || StringUtils.isNotEmpty(redisHost2)) {
|
||||
jedisPool = getJedisPool();
|
||||
} else {
|
||||
@@ -136,7 +137,7 @@ public class WxQidianStorageAutoConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
private Pool getJedisPool() {
|
||||
private Pool<Jedis> getJedisPool() {
|
||||
WxQidianProperties.ConfigStorage storage = wxQidianProperties.getConfigStorage();
|
||||
RedisProperties redis = storage.getRedis();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-graal</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-channel</artifactId>
|
||||
|
||||
@@ -131,5 +131,5 @@ public interface BaseWxChannelService extends WxService {
|
||||
*
|
||||
* @return . request http
|
||||
*/
|
||||
RequestHttp getRequestHttp();
|
||||
RequestHttp<?, ?> getRequestHttp();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.AfterSaleListParam;
|
||||
import me.chanjar.weixin.channel.bean.after.AfterSaleListResponse;
|
||||
import me.chanjar.weixin.channel.bean.after.AfterSaleReasonResponse;
|
||||
import me.chanjar.weixin.channel.bean.after.AfterSaleRejectReasonResponse;
|
||||
@@ -26,10 +27,22 @@ public interface WxChannelAfterSaleService {
|
||||
* @return 售后单列表
|
||||
*
|
||||
* @throws WxErrorException 异常
|
||||
* @deprecated 使用 {@link WxChannelAfterSaleService#listIds(AfterSaleListParam)}
|
||||
*/
|
||||
@Deprecated
|
||||
AfterSaleListResponse listIds(Long beginCreateTime, Long endCreateTime, String nextKey)
|
||||
throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取售后单列表
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 售后单列表
|
||||
*
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
AfterSaleListResponse listIds(AfterSaleListParam param) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取售后单详情
|
||||
*
|
||||
|
||||
@@ -34,6 +34,17 @@ public interface WxChannelOrderService {
|
||||
*/
|
||||
OrderInfoResponse getOrder(String orderId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
*
|
||||
* @param orderId 订单id
|
||||
* @param encodeSensitiveInfo 是否编码敏感信息
|
||||
* @return 订单详情
|
||||
*
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
OrderInfoResponse getOrder(String orderId, Boolean encodeSensitiveInfo) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
*
|
||||
@@ -128,7 +139,7 @@ public interface WxChannelOrderService {
|
||||
WxChannelBaseResponse closeOrder(String orderId);
|
||||
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
* 获取快递公司列表-旧
|
||||
*
|
||||
* @return 快递公司列表
|
||||
*
|
||||
@@ -136,6 +147,16 @@ public interface WxChannelOrderService {
|
||||
*/
|
||||
DeliveryCompanyResponse listDeliveryCompany() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
*
|
||||
* @param ewaybillOnly 是否仅返回支持电子面单功能的快递公司
|
||||
* @return 快递公司列表
|
||||
*
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
DeliveryCompanyResponse listDeliveryCompany(Boolean ewaybillOnly) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
*
|
||||
|
||||
@@ -15,43 +15,84 @@ public interface WxLeaguePromoterService {
|
||||
/**
|
||||
* 新增达人
|
||||
*
|
||||
* @param finderId 视频号finder_id
|
||||
* @param finderId 视频号finder_id,待废除
|
||||
* @return 结果
|
||||
* @deprecated 使用 {@link #addPromoterV2(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxChannelBaseResponse addPromoter(String finderId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 编辑达人
|
||||
*
|
||||
* @param finderId 视频号finder_id
|
||||
* @param finderId 视频号finder_id,待废除
|
||||
* @param type 操作 1取消邀请 2结束合作
|
||||
* @return 结果
|
||||
* @deprecated 使用 {@link #updatePromoterV2(String, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxChannelBaseResponse updatePromoter(String finderId, int type) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 删除达人
|
||||
*
|
||||
* @param finderId 视频号finder_id
|
||||
* @param finderId 视频号finder_id,待废除
|
||||
* @return 结果
|
||||
* @deprecated 使用 {@link #deletePromoterV2(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxChannelBaseResponse deletePromoter(String finderId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取达人详情信息
|
||||
*
|
||||
* @param finderId 视频号finder_id
|
||||
* @param finderId 视频号finder_id,待废除
|
||||
* @return 结果
|
||||
* @deprecated 使用 {@link #getPromoterInfoV2(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
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;
|
||||
/**
|
||||
* 新增达人
|
||||
*
|
||||
* @param promoterId 达人带货id
|
||||
* @return 结果
|
||||
*/
|
||||
WxChannelBaseResponse addPromoterV2(String promoterId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 编辑达人
|
||||
*
|
||||
* @param promoterId 达人带货id
|
||||
* @param type 操作 1取消邀请 2结束合作
|
||||
* @return 结果
|
||||
*/
|
||||
WxChannelBaseResponse updatePromoterV2(String promoterId, int type) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 删除达人
|
||||
*
|
||||
* @param promoterId 达人带货id
|
||||
* @return 结果
|
||||
*/
|
||||
WxChannelBaseResponse deletePromoterV2(String promoterId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取达人详情信息
|
||||
*
|
||||
* @param promoterId 达人带货id
|
||||
* @return 结果
|
||||
*/
|
||||
PromoterInfoResponse getPromoterInfoV2(String promoterId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取达人列表
|
||||
*
|
||||
* @param pageIndex 页面下标,下标从1开始,默认为1
|
||||
* @param pageSize 单页达人数(不超过200)
|
||||
* @param status 拉取该状态下的达人列表
|
||||
* @return 结果
|
||||
*/
|
||||
PromoterListResponse listPromoter(Integer pageIndex, Integer pageSize, Integer status) throws WxErrorException;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
|
||||
private int maxRetryTimes = 5;
|
||||
|
||||
@Override
|
||||
public RequestHttp getRequestHttp() {
|
||||
public RequestHttp<H, P> getRequestHttp() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
|
||||
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());
|
||||
log.error("Checking signature failed, and the reason is :{}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
protected String extractAccessToken(String resultContent) throws WxErrorException {
|
||||
log.debug("access-token response: " + resultContent);
|
||||
log.debug("access-token response: {}", resultContent);
|
||||
WxChannelConfig config = this.getConfig();
|
||||
WxError error = WxError.fromJson(resultContent, WxType.Channel);
|
||||
if (error.getErrorCode() != 0) {
|
||||
|
||||
@@ -28,7 +28,7 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assist
|
||||
public class WxAssistantServiceImpl implements WxAssistantService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
@Override
|
||||
public WxChannelBaseResponse addWindowProduct(AddWindowProductRequest req) throws WxErrorException {
|
||||
String resJson = shopService.post(ADD_WINDOW_PRODUCT_URL, "{}");
|
||||
|
||||
@@ -29,9 +29,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxChannelAddressServiceImpl implements WxChannelAddressService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelAddressServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelAddressServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,16 +23,22 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Compla
|
||||
public class WxChannelAfterSaleServiceImpl implements WxChannelAfterSaleService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelAfterSaleServiceImpl(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);
|
||||
AfterSaleListParam param = new AfterSaleListParam(beginCreateTime, endCreateTime, null, null, nextKey);
|
||||
String resJson = shopService.post(AFTER_SALE_LIST_URL, param);
|
||||
return ResponseUtils.decode(resJson, AfterSaleListResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AfterSaleListResponse listIds(AfterSaleListParam param) throws WxErrorException {
|
||||
String resJson = shopService.post(AFTER_SALE_LIST_URL, param);
|
||||
return ResponseUtils.decode(resJson, AfterSaleListResponse.class);
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
public class WxChannelBasicServiceImpl implements WxChannelBasicService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelBasicServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelBasicServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxChannelBrandServiceImpl implements WxChannelBrandService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelBrandServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelBrandServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
|
||||
public class WxChannelCategoryServiceImpl implements WxChannelCategoryService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelCategoryServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelCategoryServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class WxChannelCategoryServiceImpl implements WxChannelCategoryService {
|
||||
try {
|
||||
pid = Long.parseLong(parentId);
|
||||
} catch (Throwable e) {
|
||||
log.error("parentId必须为数字, " + parentId, e);
|
||||
log.error("parentId必须为数字, {}", parentId, e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String reqJson = "{\"f_cat_id\": " + pid + "}";
|
||||
@@ -80,7 +80,7 @@ public class WxChannelCategoryServiceImpl implements WxChannelCategoryService {
|
||||
try {
|
||||
catId = Long.parseLong(id);
|
||||
} catch (Throwable e) {
|
||||
log.error("id必须为数字, " + id, e);
|
||||
log.error("id必须为数字, {}", id, e);
|
||||
return ResponseUtils.internalError(CategoryDetailResult.class);
|
||||
}
|
||||
String reqJson = "{\"cat_id\": " + catId + "}";
|
||||
|
||||
@@ -20,9 +20,9 @@ public class WxChannelCompassFinderServiceImpl implements WxChannelCompassFinder
|
||||
/**
|
||||
* 微信商店服务
|
||||
*/
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelCompassFinderServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;}
|
||||
public WxChannelCompassFinderServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {this.shopService = shopService;}
|
||||
|
||||
@Override
|
||||
public OverallResponse getOverall(String ds) throws WxErrorException {
|
||||
|
||||
@@ -41,9 +41,9 @@ public class WxChannelCompassShopServiceImpl implements WxChannelCompassShopServ
|
||||
/**
|
||||
* 微信商店服务
|
||||
*/
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelCompassShopServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;}
|
||||
public WxChannelCompassShopServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {this.shopService = shopService;}
|
||||
|
||||
@Override
|
||||
public ShopOverallResponse getShopOverall(String ds) throws WxErrorException {
|
||||
|
||||
@@ -35,9 +35,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxChannelCouponServiceImpl implements WxChannelCouponService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelCouponServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelCouponServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@Slf4j
|
||||
public class WxChannelFreightTemplateServiceImpl implements WxChannelFreightTemplateService {
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelFreightTemplateServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelFreightTemplateServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ public class WxChannelFundServiceImpl implements WxChannelFundService {
|
||||
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelFundServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelFundServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ public class WxChannelLiveDashboardServiceImpl implements WxChannelLiveDashboard
|
||||
/**
|
||||
* 微信商店服务
|
||||
*/
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public WxChannelLiveDashboardServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;}
|
||||
public WxChannelLiveDashboardServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {this.shopService = shopService;}
|
||||
|
||||
@Override
|
||||
public LiveListResponse getLiveList(Long ds) throws WxErrorException {
|
||||
|
||||
@@ -1,24 +1,37 @@
|
||||
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_NEW_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Delivery.GET_DELIVERY_COMPANY_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.*;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.ACCEPT_ADDRESS_MODIFY_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.DECODE_SENSITIVE_INFO_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.ORDER_GET_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.ORDER_LIST_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.ORDER_SEARCH_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.REJECT_ADDRESS_MODIFY_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.UPDATE_ADDRESS_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.UPDATE_EXPRESS_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.UPDATE_PRICE_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.UPDATE_REMARK_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.UPLOAD_FRESH_INSPECT_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Order.VIRTUAL_TEL_NUMBER_URL;
|
||||
|
||||
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.PackageAuditInfo;
|
||||
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.delivery.FreshInspectParam;
|
||||
import me.chanjar.weixin.channel.bean.delivery.PackageAuditInfo;
|
||||
import me.chanjar.weixin.channel.bean.order.ChangeOrderInfo;
|
||||
import me.chanjar.weixin.channel.bean.order.DecodeSensitiveInfoResponse;
|
||||
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.OrderInfoParam;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderListParam;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderListResponse;
|
||||
@@ -39,15 +52,22 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxChannelOrderServiceImpl implements WxChannelOrderService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelOrderServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelOrderServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderInfoResponse getOrder(String orderId) throws WxErrorException {
|
||||
OrderIdParam param = new OrderIdParam(orderId);
|
||||
OrderInfoParam param = new OrderInfoParam(orderId, null);
|
||||
String resJson = shopService.post(ORDER_GET_URL, param);
|
||||
return ResponseUtils.decode(resJson, OrderInfoResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderInfoResponse getOrder(String orderId, Boolean encodeSensitiveInfo) throws WxErrorException {
|
||||
OrderInfoParam param = new OrderInfoParam(orderId, encodeSensitiveInfo);
|
||||
String resJson = shopService.post(ORDER_GET_URL, param);
|
||||
return ResponseUtils.decode(resJson, OrderInfoResponse.class);
|
||||
}
|
||||
@@ -119,6 +139,16 @@ public class WxChannelOrderServiceImpl implements WxChannelOrderService {
|
||||
return ResponseUtils.decode(resJson, DeliveryCompanyResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeliveryCompanyResponse listDeliveryCompany(Boolean ewaybillOnly) throws WxErrorException {
|
||||
String reqJson = "{}";
|
||||
if (ewaybillOnly != null) {
|
||||
reqJson = "{\"ewaybill_only\":" + ewaybillOnly + "}";
|
||||
}
|
||||
String resJson = shopService.post(GET_DELIVERY_COMPANY_NEW_URL, reqJson);
|
||||
return ResponseUtils.decode(resJson, DeliveryCompanyResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxChannelBaseResponse deliveryOrder(String orderId, List<DeliveryInfo> deliveryList)
|
||||
throws WxErrorException {
|
||||
|
||||
@@ -56,9 +56,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxChannelProductServiceImpl implements WxChannelProductService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelProductServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelProductServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.GET_ACCESS_TOKEN_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.GET_STABLE_ACCESS_TOKEN_URL;
|
||||
|
||||
import java.io.IOException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.channel.bean.token.StableTokenParam;
|
||||
import me.chanjar.weixin.channel.config.WxChannelConfig;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.util.http.HttpType;
|
||||
import me.chanjar.weixin.common.util.http.HttpClientType;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheBasicResponseHandler;
|
||||
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.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 static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.GET_ACCESS_TOKEN_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.GET_STABLE_ACCESS_TOKEN_URL;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@@ -63,8 +63,8 @@ public class WxChannelServiceHttpClientImpl extends BaseWxChannelServiceImpl<Htt
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpType getRequestType() {
|
||||
return HttpType.APACHE_HTTP;
|
||||
public HttpClientType getRequestType() {
|
||||
return HttpClientType.APACHE_HTTP;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,27 +76,12 @@ public class WxChannelServiceHttpClientImpl extends BaseWxChannelServiceImpl<Htt
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
HttpGet httpGet = new HttpGet(url);
|
||||
if (this.getRequestHttpProxy() != null) {
|
||||
RequestConfig requestConfig = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();
|
||||
httpGet.setConfig(requestConfig);
|
||||
}
|
||||
return getRequestHttpClient().execute(httpGet, ApacheBasicResponseHandler.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,10 +110,6 @@ public class WxChannelServiceHttpClientImpl extends BaseWxChannelServiceImpl<Htt
|
||||
assert requestJson != null;
|
||||
|
||||
httpPost.setEntity(new StringEntity(requestJson, ContentType.APPLICATION_JSON));
|
||||
try (CloseableHttpResponse response = getRequestHttpClient().execute(httpPost)) {
|
||||
return new BasicResponseHandler().handleResponse(response);
|
||||
} finally {
|
||||
httpPost.releaseConnection();
|
||||
}
|
||||
return getRequestHttpClient().execute(httpPost, ApacheBasicResponseHandler.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.channel.bean.token.StableTokenParam;
|
||||
import me.chanjar.weixin.channel.config.WxChannelConfig;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.util.http.HttpType;
|
||||
import me.chanjar.weixin.common.util.http.HttpClientType;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import okhttp3.Authenticator;
|
||||
@@ -65,8 +65,8 @@ public class WxChannelServiceOkHttpImpl extends BaseWxChannelServiceImpl<OkHttpC
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpType getRequestType() {
|
||||
return HttpType.OK_HTTP;
|
||||
public HttpClientType getRequestType() {
|
||||
return HttpClientType.OK_HTTP;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,9 +33,9 @@ import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
public class WxChannelSharerServiceImpl implements WxChannelSharerService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelSharerServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelSharerServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Vip.*;
|
||||
|
||||
@Slf4j
|
||||
public class WxChannelVipServiceImpl implements WxChannelVipService {
|
||||
private BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelVipServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelVipServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxChannelWarehouseServiceImpl implements WxChannelWarehouseService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelWarehouseServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxChannelWarehouseServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Finder
|
||||
public class WxFinderLiveServiceImpl implements WxFinderLiveService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
@Override
|
||||
public FinderAttrResponse getFinderAttrByAppid() throws WxErrorException {
|
||||
String resJson = shopService.post(GET_FINDER_ATTR_BY_APPID, "{}");
|
||||
|
||||
@@ -38,7 +38,7 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.LeadCo
|
||||
public class WxLeadComponentServiceImpl implements WxLeadComponentService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
@Override
|
||||
public LeadInfoResponse getLeadsInfoByComponentId(GetLeadInfoByComponentRequest req) throws WxErrorException {
|
||||
|
||||
@@ -32,9 +32,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxLeagueProductServiceImpl implements WxLeagueProductService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxLeagueProductServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxLeagueProductServiceImpl(BaseWxChannelServiceImpl<?, ?>shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxLeaguePromoterServiceImpl implements WxLeaguePromoterService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxLeaguePromoterServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxLeaguePromoterServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,34 @@ public class WxLeaguePromoterServiceImpl implements WxLeaguePromoterService {
|
||||
return ResponseUtils.decode(resJson, PromoterInfoResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxChannelBaseResponse addPromoterV2(String promoterId) throws WxErrorException {
|
||||
String reqJson = "{\"promoter_id\":\"" + promoterId + "\"}";
|
||||
String resJson = shopService.post(ADD_PROMOTER_URL, reqJson);
|
||||
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxChannelBaseResponse updatePromoterV2(String promoterId, int type) throws WxErrorException {
|
||||
String reqJson = "{\"promoter_id\":\"" + promoterId + "\",\"type\":" + type + "}";
|
||||
String resJson = shopService.post(EDIT_PROMOTER_URL, reqJson);
|
||||
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxChannelBaseResponse deletePromoterV2(String promoterId) throws WxErrorException {
|
||||
String reqJson = "{\"promoter_id\":\"" + promoterId + "\"}";
|
||||
String resJson = shopService.post(DELETE_PROMOTER_URL, reqJson);
|
||||
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PromoterInfoResponse getPromoterInfoV2(String promoterId) throws WxErrorException {
|
||||
String reqJson = "{\"promoter_id\":\"" + promoterId + "\"}";
|
||||
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 {
|
||||
|
||||
@@ -38,9 +38,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxLeagueSupplierServiceImpl implements WxLeagueSupplierService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxLeagueSupplierServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxLeagueSupplierServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxLeagueWindowServiceImpl implements WxLeagueWindowService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl shopService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxLeagueWindowServiceImpl(BaseWxChannelServiceImpl shopService) {
|
||||
public WxLeagueWindowServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxStoreCooperationServiceImpl implements WxStoreCooperationService {
|
||||
|
||||
/** 微信小店服务 */
|
||||
private final BaseWxChannelServiceImpl storeService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> storeService;
|
||||
|
||||
public WxStoreCooperationServiceImpl(BaseWxChannelServiceImpl storeService) {
|
||||
public WxStoreCooperationServiceImpl(BaseWxChannelServiceImpl<?, ?> storeService) {
|
||||
this.storeService = storeService;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
public class WxStoreHomePageServiceImpl implements WxStoreHomePageService {
|
||||
|
||||
/** 微信小店服务 */
|
||||
private final BaseWxChannelServiceImpl storeService;
|
||||
private final BaseWxChannelServiceImpl<?, ?> storeService;
|
||||
|
||||
public WxStoreHomePageServiceImpl(BaseWxChannelServiceImpl storeService) {
|
||||
public WxStoreHomePageServiceImpl(BaseWxChannelServiceImpl<?, ?> storeService) {
|
||||
this.storeService = storeService;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,14 @@ public class AfterSaleListParam implements Serializable {
|
||||
@JsonProperty("end_create_time")
|
||||
private Long endCreateTime;
|
||||
|
||||
/** 售后单更新起始时间 */
|
||||
@JsonProperty("begin_update_time")
|
||||
private Long beginUpdateTime;
|
||||
|
||||
/** 售后单更新结束时间,end_update_time减去begin_update_time不得大于24小时 */
|
||||
@JsonProperty("end_update_time")
|
||||
private Long endUpdateTime;
|
||||
|
||||
/** 翻页参数,从第二页开始传,来源于上一页的返回值 */
|
||||
@JsonProperty("next_key")
|
||||
private String nextKey;
|
||||
|
||||
@@ -18,11 +18,19 @@ import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
public class PromoterListResponse extends WxChannelBaseResponse {
|
||||
|
||||
private static final long serialVersionUID = 1411870432999885996L;
|
||||
/** 达人finder_id列表 */
|
||||
/** 达人finder_id列表,待废除后续以promoter_ids为准 */
|
||||
@JsonProperty("finder_ids")
|
||||
private List<String> finderIds;
|
||||
|
||||
/** 达人总数 */
|
||||
@JsonProperty("total_num")
|
||||
private Integer totalNum;
|
||||
|
||||
/** 后面是否还有(true: 还有内容; false: 已结束)*/
|
||||
@JsonProperty("continue_flag")
|
||||
private Boolean continueFlag;
|
||||
|
||||
/** 达人带货id列表 */
|
||||
@JsonProperty("promoter_ids")
|
||||
private List<String> promoterIds;
|
||||
}
|
||||
|
||||
@@ -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 <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class OrderCustomInfo implements Serializable {
|
||||
private static final long serialVersionUID = 6681266835402157651L;
|
||||
|
||||
/** 定制图片,custom_type=2时返回 */
|
||||
@JsonProperty("custom_img_url")
|
||||
private String customImgUrl;
|
||||
|
||||
/** 定制文字,custom_type=1时返回 */
|
||||
@JsonProperty("custom_word")
|
||||
private String customWord;
|
||||
|
||||
/** 定制类型,枚举值请参考CustomType枚举 */
|
||||
@JsonProperty("custom_type")
|
||||
private Integer customType;
|
||||
|
||||
/** 定制预览图片,开启了定制预览时返回 */
|
||||
@JsonProperty("custom_preview_img_url")
|
||||
private String customPreviewImgUrl;
|
||||
}
|
||||
@@ -61,7 +61,18 @@ public class OrderDetailInfo implements Serializable {
|
||||
private OrderAgentInfo agentInfo;
|
||||
|
||||
/** 订单来源信息 */
|
||||
@JsonProperty("source_info")
|
||||
private OrderSourceInfo sourceInfo;
|
||||
@JsonProperty("source_infos")
|
||||
private List<OrderSourceInfo> sourceInfos;
|
||||
|
||||
/** 订单退款信息 */
|
||||
@JsonProperty("refund_info")
|
||||
private OrderSourceInfo refundInfo;
|
||||
|
||||
/** 订单代写商品信息 */
|
||||
@JsonProperty("greeting_card_info")
|
||||
private OrderGreetingCardInfo greetingCardInfo;
|
||||
|
||||
/** 商品定制信息 */
|
||||
@JsonProperty("custom_info")
|
||||
private OrderCustomInfo customInfo;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.chanjar.weixin.channel.bean.order;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 订单商品贺卡信息
|
||||
*
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class OrderGreetingCardInfo implements Serializable {
|
||||
private static final long serialVersionUID = -6391443179945240242L;
|
||||
|
||||
/** 贺卡落款,用户选填 */
|
||||
@JsonProperty("giver_name")
|
||||
private String giverName;
|
||||
|
||||
/** 贺卡称谓,用户选填 */
|
||||
@JsonProperty("receiver_name")
|
||||
private String receiverName;
|
||||
|
||||
/** 贺卡内容,用户必填 */
|
||||
@JsonProperty("greeting_message")
|
||||
private String greetingMessage;
|
||||
}
|
||||
@@ -39,6 +39,26 @@ public class OrderInfo implements Serializable {
|
||||
@JsonProperty("aftersale_detail")
|
||||
protected AfterSaleDetail afterSaleDetail;
|
||||
|
||||
/** 是否为礼物订单 */
|
||||
@JsonProperty("is_present")
|
||||
private Boolean present;
|
||||
|
||||
/** 礼物订单ID */
|
||||
@JsonProperty("present_order_id_str")
|
||||
private String presentOrderId;
|
||||
|
||||
/** 礼物订单留言 */
|
||||
@JsonProperty("present_note")
|
||||
private String presentNote;
|
||||
|
||||
/** 礼物订单赠送者openid */
|
||||
@JsonProperty("present_giver_openid")
|
||||
private String presentGiverOpenid;
|
||||
|
||||
/** 礼物订单赠送者unionid */
|
||||
@JsonProperty("present_giver_unionid")
|
||||
private String presentGiverUnionid;
|
||||
|
||||
/** 创建时间 秒级时间戳 */
|
||||
@JsonProperty("create_time")
|
||||
protected Integer createTime;
|
||||
@@ -46,5 +66,4 @@ public class OrderInfo implements Serializable {
|
||||
/** 更新时间 秒级时间戳 */
|
||||
@JsonProperty("update_time")
|
||||
protected Integer updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.channel.bean.order;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 获取订单详情参数
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class OrderInfoParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 42L;
|
||||
|
||||
/** 订单ID */
|
||||
@JsonProperty("order_id")
|
||||
private String orderId;
|
||||
|
||||
/**
|
||||
* 用于商家提前测试订单脱敏效果,如果传true,即对订单进行脱敏,后期会默认对所有订单脱敏
|
||||
*/
|
||||
@JsonProperty("encode_sensitive_info")
|
||||
private Boolean encodeSensitiveInfo;
|
||||
}
|
||||
@@ -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 <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class OrderRefundInfo implements Serializable {
|
||||
private static final long serialVersionUID = -7257910073388645919L;
|
||||
|
||||
/** 退还运费金额,礼物订单(is_present=true)可能存在 */
|
||||
@JsonProperty("refund_freight")
|
||||
private Integer refundFreight;
|
||||
}
|
||||
@@ -25,6 +25,6 @@ public class OrderSearchParam extends StreamPageParam {
|
||||
private Integer onAfterSaleOrderExist;
|
||||
|
||||
/** 订单状态 {@link me.chanjar.weixin.channel.enums.WxOrderStatus} */
|
||||
@JsonProperty("on_aftersale_order_exist")
|
||||
@JsonProperty("status")
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -23,26 +23,44 @@ public class OrderSourceInfo implements Serializable {
|
||||
private String skuId;
|
||||
|
||||
/**
|
||||
* 带货账户类型,1:视频号,2:公众号,3:小程序
|
||||
* 带货账号类型,1:视频号,2:公众号,3:小程序,4:企业微信,5:带货达人,6:服务号,1000:带货机构
|
||||
*/
|
||||
@JsonProperty("account_type")
|
||||
private Integer accountType;
|
||||
|
||||
/**
|
||||
* 带货账户id,如果带货账户类型是视频号,此id为视频号id; 如果带货类型为 公众号/小程序, 此id 为对应 公众号/小程序 的appid
|
||||
* 带货账号id,取决于带货账号类型(分别为视频号id、公众号appid、小程序appid、企业微信id、带货达人appid、服务号appid、带货机构id)
|
||||
*/
|
||||
@JsonProperty("account_id")
|
||||
private String accountId;
|
||||
|
||||
/**
|
||||
* 销售渠道, 0:关联账号,1:合作账号,100:联盟达人带货
|
||||
* 账号关联类型,0:关联账号,1:合作账号,2:授权号,100:达人带货,101:带货机构推广
|
||||
*/
|
||||
@JsonProperty("sale_channel")
|
||||
private Integer saleChannel;
|
||||
|
||||
/**
|
||||
* 带货账户昵称
|
||||
* 带货账号昵称
|
||||
*/
|
||||
@JsonProperty("account_nickname")
|
||||
private String accountNickname;
|
||||
|
||||
/**
|
||||
* 带货内容类型,1:企微成员转发
|
||||
*/
|
||||
@JsonProperty("content_type")
|
||||
private String contentType;
|
||||
|
||||
/**
|
||||
* 带货内容id,取决于带货内容类型(企微成员user_id)
|
||||
*/
|
||||
@JsonProperty("content_id")
|
||||
private String contentId;
|
||||
|
||||
/**
|
||||
* 自营推客推广的带货机构id
|
||||
*/
|
||||
@JsonProperty("promoter_head_supplier_id")
|
||||
private String promoterHeadSupplierId;
|
||||
}
|
||||
|
||||
@@ -247,8 +247,9 @@ public class WxChannelApiUrlConstants {
|
||||
|
||||
/** 物流相关接口 */
|
||||
public interface Delivery {
|
||||
|
||||
/** 获取快递公司列表 */
|
||||
String GET_DELIVERY_COMPANY_NEW_URL = "https://api.weixin.qq.com/channels/ec/order/deliverycompanylist/new/get";
|
||||
/** 获取快递公司列表(旧) */
|
||||
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";
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
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;
|
||||
@@ -12,12 +9,14 @@ 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 视频号小店 图片上传接口 请求的参数是File, 返回的结果是String
|
||||
*
|
||||
@@ -46,11 +45,7 @@ public class ChannelFileUploadRequestExecutor implements RequestExecutor<String,
|
||||
.build();
|
||||
httpPost.setEntity(entity);
|
||||
}
|
||||
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
|
||||
return Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||
} finally {
|
||||
httpPost.releaseConnection();
|
||||
}
|
||||
return requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,8 +54,14 @@ public class ChannelFileUploadRequestExecutor implements RequestExecutor<String,
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<String, File> create(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
|
||||
return new ChannelFileUploadRequestExecutor(requestHttp);
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) throws WxErrorException {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ChannelFileUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
|
||||
default:
|
||||
throw new WxErrorException("不支持的http框架");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
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;
|
||||
@@ -30,6 +21,16 @@ import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
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 static org.apache.commons.io.FileUtils.openOutputStream;
|
||||
|
||||
/**
|
||||
* 下载媒体文件请求执行器
|
||||
*
|
||||
@@ -90,10 +91,7 @@ public class ChannelMediaDownloadRequestExecutor implements RequestExecutor<Chan
|
||||
extension = "unknown";
|
||||
}
|
||||
File file = createTmpFile(inputStream, baseName, extension, tmpDirFile);
|
||||
ChannelImageResponse result = new ChannelImageResponse(file, contentType);
|
||||
return result;
|
||||
} finally {
|
||||
httpGet.releaseConnection();
|
||||
return new ChannelImageResponse(file, contentType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +101,13 @@ public class ChannelMediaDownloadRequestExecutor implements RequestExecutor<Chan
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<ChannelImageResponse, String> create(RequestHttp requestHttp, File tmpDirFile) {
|
||||
return new ChannelMediaDownloadRequestExecutor(requestHttp, tmpDirFile);
|
||||
public static RequestExecutor<ChannelImageResponse, String> create(RequestHttp<?, ?> requestHttp, File tmpDirFile) throws WxErrorException {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ChannelMediaDownloadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp, tmpDirFile);
|
||||
default:
|
||||
throw new WxErrorException("不支持的http框架");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +141,7 @@ public class ChannelMediaDownloadRequestExecutor implements RequestExecutor<Chan
|
||||
}
|
||||
|
||||
private String extractFileNameFromContentString(String content) throws WxErrorException {
|
||||
if (content == null || content.length() == 0) {
|
||||
if (content == null || content.isEmpty()) {
|
||||
return createDefaultFileName();
|
||||
}
|
||||
Matcher m = PATTERN.matcher(content);
|
||||
|
||||
@@ -137,7 +137,7 @@ public class WxChannelMessageRouter {
|
||||
}
|
||||
}
|
||||
|
||||
if (matchRules.size() == 0) {
|
||||
if (matchRules.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final List<Future<?>> futures = new ArrayList<>();
|
||||
@@ -157,7 +157,7 @@ public class WxChannelMessageRouter {
|
||||
}
|
||||
}
|
||||
|
||||
if (futures.size() > 0) {
|
||||
if (!futures.isEmpty()) {
|
||||
this.executorService.submit(() -> {
|
||||
for (Future<?> future : futures) {
|
||||
try {
|
||||
|
||||
@@ -20,6 +20,7 @@ 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.OrderSearchCondition;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderSearchParam;
|
||||
import me.chanjar.weixin.channel.bean.order.VirtualTelNumberResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
@@ -45,6 +46,16 @@ public class WxChannelOrderServiceImplTest {
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrder2() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
String orderId = "";
|
||||
boolean encodeSensitiveInfo = true;
|
||||
OrderInfoResponse response = orderService.getOrder(orderId, encodeSensitiveInfo);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrders() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
@@ -58,6 +69,10 @@ public class WxChannelOrderServiceImplTest {
|
||||
public void testSearchOrder() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
OrderSearchParam param = new OrderSearchParam();
|
||||
param.setPageSize(100);
|
||||
OrderSearchCondition searchCondition = new OrderSearchCondition();
|
||||
searchCondition.setTitle("");
|
||||
param.setSearchCondition(searchCondition);
|
||||
OrderListResponse response = orderService.searchOrder(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
@@ -135,7 +150,7 @@ public class WxChannelOrderServiceImplTest {
|
||||
@Test
|
||||
public void testListDeliveryCompany() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
DeliveryCompanyResponse response = orderService.listDeliveryCompany();
|
||||
DeliveryCompanyResponse response = orderService.listDeliveryCompany(false);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.4.B</version>
|
||||
<version>4.7.6.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-common</artifactId>
|
||||
@@ -24,6 +24,11 @@
|
||||
<artifactId>okhttp</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
||||
@@ -431,7 +431,7 @@ public class WxConsts {
|
||||
*/
|
||||
public static final String WEAPP_AUDIT_FAIL = "weapp_audit_fail";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 小程序审核事件:审核延后
|
||||
*/
|
||||
@@ -622,4 +622,19 @@ public class WxConsts {
|
||||
*/
|
||||
public static final String MINI_TYPE = "mini";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建文章类型
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class ArticleType {
|
||||
/**
|
||||
* 图文消息
|
||||
*/
|
||||
public static final String NEWS = "news";
|
||||
/**
|
||||
* 图片消息
|
||||
*/
|
||||
public static final String NEWS_PIC = "newspic";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ 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.commons.lang3.StringUtils;
|
||||
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;
|
||||
@@ -52,19 +52,15 @@ public class CommonUploadRequestExecutorApacheImpl
|
||||
.build();
|
||||
httpPost.setEntity(entity);
|
||||
}
|
||||
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
|
||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||
if (responseContent == null || responseContent.isEmpty()) {
|
||||
throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
|
||||
}
|
||||
WxError error = WxError.fromJson(responseContent, wxType);
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
return responseContent;
|
||||
} finally {
|
||||
httpPost.releaseConnection();
|
||||
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
|
||||
if (StringUtils.isEmpty(responseContent)) {
|
||||
throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
|
||||
}
|
||||
WxError error = WxError.fromJson(responseContent, wxType);
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
return responseContent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,6 @@ 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;
|
||||
@@ -24,7 +23,7 @@ import java.io.IOException;
|
||||
* created on 2019/6/27 14:06
|
||||
*/
|
||||
public class OcrDiscernApacheHttpRequestExecutor extends OcrDiscernRequestExecutor<CloseableHttpClient, HttpHost> {
|
||||
public OcrDiscernApacheHttpRequestExecutor(RequestHttp requestHttp) {
|
||||
public OcrDiscernApacheHttpRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
|
||||
super(requestHttp);
|
||||
}
|
||||
|
||||
@@ -43,15 +42,11 @@ public class OcrDiscernApacheHttpRequestExecutor extends OcrDiscernRequestExecut
|
||||
.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 responseContent;
|
||||
} finally {
|
||||
httpPost.releaseConnection();
|
||||
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
|
||||
WxError error = WxError.fromJson(responseContent, wxType);
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
return responseContent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ 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 org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -18,7 +20,7 @@ import java.io.IOException;
|
||||
public abstract class OcrDiscernRequestExecutor<H, P> implements RequestExecutor<String, File> {
|
||||
protected RequestHttp<H, P> requestHttp;
|
||||
|
||||
public OcrDiscernRequestExecutor(RequestHttp requestHttp) {
|
||||
public OcrDiscernRequestExecutor(RequestHttp<H, P> requestHttp) {
|
||||
this.requestHttp = requestHttp;
|
||||
}
|
||||
|
||||
@@ -27,10 +29,11 @@ public abstract class OcrDiscernRequestExecutor<H, P> implements RequestExecutor
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<String, File> create(RequestHttp requestHttp) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new OcrDiscernApacheHttpRequestExecutor(requestHttp);
|
||||
return new OcrDiscernApacheHttpRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.chanjar.weixin.common.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.chanjar.weixin.common.annotation.Required;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class XmlUtils {
|
||||
final List<String> names = names(nodes);
|
||||
|
||||
// 判断节点下有无非文本节点(非Text和CDATA),如无,直接取Text文本内容
|
||||
if (names.size() < 1) {
|
||||
if (names.isEmpty()) {
|
||||
return element.getText();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.common.util.crypto;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.common.error.WxRuntimeException;
|
||||
|
||||
@@ -3,11 +3,17 @@ package me.chanjar.weixin.common.util.http;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.ProxyInfo;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheMediaDownloadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaDownloadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaDownloadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
/**
|
||||
* 下载媒体文件请求执行器.
|
||||
@@ -30,14 +36,15 @@ public abstract class BaseMediaDownloadRequestExecutor<H, P> implements RequestE
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<File, String> create(RequestHttp requestHttp, File tmpDirFile) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RequestExecutor<File, String> create(RequestHttp<?, ?> requestHttp, File tmpDirFile) {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ApacheMediaDownloadRequestExecutor(requestHttp, tmpDirFile);
|
||||
return new ApacheMediaDownloadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp, tmpDirFile);
|
||||
case JODD_HTTP:
|
||||
return new JoddHttpMediaDownloadRequestExecutor(requestHttp, tmpDirFile);
|
||||
return new JoddHttpMediaDownloadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp, tmpDirFile);
|
||||
case OK_HTTP:
|
||||
return new OkHttpMediaDownloadRequestExecutor(requestHttp, tmpDirFile);
|
||||
return new OkHttpMediaDownloadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp, tmpDirFile);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.common.util.http;
|
||||
/**
|
||||
* Created by ecoolper on 2017/4/28.
|
||||
*/
|
||||
public enum HttpType {
|
||||
public enum HttpClientType {
|
||||
/**
|
||||
* jodd-http.
|
||||
*/
|
||||
@@ -15,5 +15,9 @@ public enum HttpType {
|
||||
/**
|
||||
* okhttp.
|
||||
*/
|
||||
OK_HTTP
|
||||
OK_HTTP,
|
||||
/**
|
||||
* apache httpclient5.
|
||||
*/
|
||||
APACHE_HTTP_5
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import jodd.http.HttpResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import okhttp3.Response;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpResponseProxy;
|
||||
import me.chanjar.weixin.common.util.http.hc5.ApacheHttpClient5ResponseProxy;
|
||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpResponseProxy;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpResponseProxy;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
@@ -14,68 +14,33 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 三种http框架的response代理类,方便提取公共方法
|
||||
* http 框架的 response 代理类,方便提取公共方法
|
||||
* Created by Binary Wang on 2017-8-3.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public class HttpResponseProxy {
|
||||
public interface HttpResponseProxy {
|
||||
|
||||
private CloseableHttpResponse apacheHttpResponse;
|
||||
private HttpResponse joddHttpResponse;
|
||||
private Response okHttpResponse;
|
||||
|
||||
public HttpResponseProxy(CloseableHttpResponse apacheHttpResponse) {
|
||||
this.apacheHttpResponse = apacheHttpResponse;
|
||||
static ApacheHttpResponseProxy from(org.apache.http.client.methods.CloseableHttpResponse response) {
|
||||
return new ApacheHttpResponseProxy(response);
|
||||
}
|
||||
|
||||
public HttpResponseProxy(HttpResponse joddHttpResponse) {
|
||||
this.joddHttpResponse = joddHttpResponse;
|
||||
static ApacheHttpClient5ResponseProxy from(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response) {
|
||||
return new ApacheHttpClient5ResponseProxy(response);
|
||||
}
|
||||
|
||||
public HttpResponseProxy(Response okHttpResponse) {
|
||||
this.okHttpResponse = okHttpResponse;
|
||||
static JoddHttpResponseProxy from(jodd.http.HttpResponse response) {
|
||||
return new JoddHttpResponseProxy(response);
|
||||
}
|
||||
|
||||
public String getFileName() throws WxErrorException {
|
||||
//由于对象只能由一个构造方法实现,因此三个response对象必定且只有一个不为空
|
||||
if (this.apacheHttpResponse != null) {
|
||||
return this.getFileName(this.apacheHttpResponse);
|
||||
}
|
||||
|
||||
if (this.joddHttpResponse != null) {
|
||||
return this.getFileName(this.joddHttpResponse);
|
||||
}
|
||||
|
||||
if (this.okHttpResponse != null) {
|
||||
return this.getFileName(this.okHttpResponse);
|
||||
}
|
||||
|
||||
//cannot happen
|
||||
return null;
|
||||
static OkHttpResponseProxy from(okhttp3.Response response) {
|
||||
return new OkHttpResponseProxy(response);
|
||||
}
|
||||
|
||||
private String getFileName(CloseableHttpResponse response) throws WxErrorException {
|
||||
Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
|
||||
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
|
||||
throw new WxErrorException("无法获取到文件名,Content-disposition为空");
|
||||
}
|
||||
String getFileName() throws WxErrorException;
|
||||
|
||||
return extractFileNameFromContentString(contentDispositionHeader[0].getValue());
|
||||
}
|
||||
|
||||
private String getFileName(HttpResponse response) throws WxErrorException {
|
||||
String content = response.header("Content-disposition");
|
||||
return extractFileNameFromContentString(content);
|
||||
}
|
||||
|
||||
private String getFileName(Response response) throws WxErrorException {
|
||||
String content = response.header("Content-disposition");
|
||||
return extractFileNameFromContentString(content);
|
||||
}
|
||||
|
||||
public static String extractFileNameFromContentString(String content) throws WxErrorException {
|
||||
default String extractFileNameFromContentString(String content) throws WxErrorException {
|
||||
if (content == null || content.isEmpty()) {
|
||||
throw new WxErrorException("无法获取到文件名,content为空");
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.ProxyInfo;
|
||||
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 me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -18,7 +24,7 @@ import java.io.IOException;
|
||||
public abstract class MediaInputStreamUploadRequestExecutor<H, P> implements RequestExecutor<WxMediaUploadResult, InputStreamData> {
|
||||
protected RequestHttp<H, P> requestHttp;
|
||||
|
||||
public MediaInputStreamUploadRequestExecutor(RequestHttp requestHttp) {
|
||||
public MediaInputStreamUploadRequestExecutor(RequestHttp<H, P> requestHttp) {
|
||||
this.requestHttp = requestHttp;
|
||||
}
|
||||
|
||||
@@ -27,14 +33,14 @@ public abstract class MediaInputStreamUploadRequestExecutor<H, P> implements Req
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<WxMediaUploadResult, InputStreamData> create(RequestHttp requestHttp) {
|
||||
public static RequestExecutor<WxMediaUploadResult, InputStreamData> create(RequestHttp<?, ?> requestHttp) {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ApacheMediaInputStreamUploadRequestExecutor(requestHttp);
|
||||
return new ApacheMediaInputStreamUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
|
||||
case JODD_HTTP:
|
||||
return new JoddHttpMediaInputStreamUploadRequestExecutor(requestHttp);
|
||||
return new JoddHttpMediaInputStreamUploadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
|
||||
case OK_HTTP:
|
||||
return new OkHttpMediaInputStreamUploadRequestExecutor(requestHttp);
|
||||
return new OkHttpMediaInputStreamUploadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.ProxyInfo;
|
||||
import me.chanjar.weixin.common.bean.CommonUploadParam;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
@@ -8,6 +10,10 @@ import me.chanjar.weixin.common.service.WxService;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheMediaUploadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaUploadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaUploadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -25,7 +31,7 @@ import java.io.IOException;
|
||||
public abstract class MediaUploadRequestExecutor<H, P> implements RequestExecutor<WxMediaUploadResult, File> {
|
||||
protected RequestHttp<H, P> requestHttp;
|
||||
|
||||
public MediaUploadRequestExecutor(RequestHttp requestHttp) {
|
||||
public MediaUploadRequestExecutor(RequestHttp<H, P> requestHttp) {
|
||||
this.requestHttp = requestHttp;
|
||||
}
|
||||
|
||||
@@ -34,14 +40,14 @@ public abstract class MediaUploadRequestExecutor<H, P> implements RequestExecuto
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp requestHttp) {
|
||||
public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp<?, ?> requestHttp) {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ApacheMediaUploadRequestExecutor(requestHttp);
|
||||
return new ApacheMediaUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
|
||||
case JODD_HTTP:
|
||||
return new JoddHttpMediaUploadRequestExecutor(requestHttp);
|
||||
return new JoddHttpMediaUploadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
|
||||
case OK_HTTP:
|
||||
return new OkHttpMediaUploadRequestExecutor(requestHttp);
|
||||
return new OkHttpMediaUploadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.ProxyInfo;
|
||||
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheMinishopMediaUploadRequestCustomizeExecutor;
|
||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMinishopMediaUploadRequestCustomizeExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMinishopMediaUploadRequestCustomizeExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -16,7 +22,7 @@ public abstract class MinishopUploadRequestCustomizeExecutor<H, P> implements Re
|
||||
protected String uploadType;
|
||||
protected String imgUrl;
|
||||
|
||||
public MinishopUploadRequestCustomizeExecutor(RequestHttp requestHttp, String respType, String imgUrl) {
|
||||
public MinishopUploadRequestCustomizeExecutor(RequestHttp<H, P> requestHttp, String respType, String imgUrl) {
|
||||
this.requestHttp = requestHttp;
|
||||
this.respType = respType;
|
||||
if (imgUrl == null || imgUrl.isEmpty()) {
|
||||
@@ -33,14 +39,15 @@ public abstract class MinishopUploadRequestCustomizeExecutor<H, P> implements Re
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<WxMinishopImageUploadCustomizeResult, File> create(RequestHttp requestHttp, String respType, String imgUrl) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RequestExecutor<WxMinishopImageUploadCustomizeResult, File> create(RequestHttp<?, ?> requestHttp, String respType, String imgUrl) {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ApacheMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType, imgUrl);
|
||||
return new ApacheMinishopMediaUploadRequestCustomizeExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp, respType, imgUrl);
|
||||
case JODD_HTTP:
|
||||
return new JoddHttpMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType, imgUrl);
|
||||
return new JoddHttpMinishopMediaUploadRequestCustomizeExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp, respType, imgUrl);
|
||||
case OK_HTTP:
|
||||
return new OkHttpMinishopMediaUploadRequestCustomizeExecutor(requestHttp, respType, imgUrl);
|
||||
return new OkHttpMinishopMediaUploadRequestCustomizeExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp, respType, imgUrl);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.ProxyInfo;
|
||||
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheMinishopMediaUploadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMinishopMediaUploadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMinishopMediaUploadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -13,7 +19,7 @@ import java.io.IOException;
|
||||
public abstract class MinishopUploadRequestExecutor<H, P> implements RequestExecutor<WxMinishopImageUploadResult, File> {
|
||||
protected RequestHttp<H, P> requestHttp;
|
||||
|
||||
public MinishopUploadRequestExecutor(RequestHttp requestHttp) {
|
||||
public MinishopUploadRequestExecutor(RequestHttp<H, P> requestHttp) {
|
||||
this.requestHttp = requestHttp;
|
||||
}
|
||||
|
||||
@@ -22,14 +28,15 @@ public abstract class MinishopUploadRequestExecutor<H, P> implements RequestExec
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<WxMinishopImageUploadResult, File> create(RequestHttp requestHttp) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RequestExecutor<WxMinishopImageUploadResult, File> create(RequestHttp<?, ?> requestHttp) {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ApacheMinishopMediaUploadRequestExecutor(requestHttp);
|
||||
return new ApacheMinishopMediaUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
|
||||
case JODD_HTTP:
|
||||
return new JoddHttpMinishopMediaUploadRequestExecutor(requestHttp);
|
||||
return new JoddHttpMinishopMediaUploadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
|
||||
case OK_HTTP:
|
||||
return new OkHttpMinishopMediaUploadRequestExecutor(requestHttp);
|
||||
return new OkHttpMinishopMediaUploadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ public interface RequestHttp<H, P> {
|
||||
*
|
||||
* @return HttpType
|
||||
*/
|
||||
HttpType getRequestType();
|
||||
HttpClientType getRequestType();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
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.apache.ApacheSimpleGetRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimpleGetRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimpleGetRequestExecutor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -27,14 +33,15 @@ public abstract class SimpleGetRequestExecutor<H, P> implements RequestExecutor<
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RequestExecutor<String, String> create(RequestHttp<?, ?> requestHttp) {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new ApacheSimpleGetRequestExecutor(requestHttp);
|
||||
return new ApacheSimpleGetRequestExecutor((RequestHttp< CloseableHttpClient, HttpHost>) requestHttp);
|
||||
case JODD_HTTP:
|
||||
return new JoddHttpSimpleGetRequestExecutor(requestHttp);
|
||||
return new JoddHttpSimpleGetRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
|
||||
case OK_HTTP:
|
||||
return new OkHttpSimpleGetRequestExecutor(requestHttp);
|
||||
return new OkHttpSimpleGetRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
|
||||
default:
|
||||
throw new IllegalArgumentException("非法请求参数");
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user