Skip to content

Commit f72f748

Browse files
lixizebinarywang
authored andcommitted
🎨 #3426【视频号】更新视频号小店/微信小店类目、订单、商品、主页管理等相关接口
1 parent 524ff80 commit f72f748

File tree

124 files changed

+3961
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+3961
-229
lines changed

solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/AbstractWxChannelConfiguration.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected WxChannelMultiServices wxChannelMultiServices(WxChannelMultiProperties
5959
WxChannelDefaultConfigImpl storage = this.wxChannelConfigStorage(wxChannelMultiProperties);
6060
this.configApp(storage, wxChannelSingleProperties);
6161
this.configHttp(storage, wxChannelMultiProperties.getConfigStorage());
62-
WxChannelService wxChannelService = this.wxChannelService(storage, wxChannelMultiProperties, wxChannelSingleProperties.isUseStableAccessToken());
62+
WxChannelService wxChannelService = this.wxChannelService(storage, wxChannelMultiProperties);
6363
services.addWxChannelService(tenantId, wxChannelService);
6464
}
6565
return services;
@@ -73,7 +73,7 @@ protected WxChannelMultiServices wxChannelMultiServices(WxChannelMultiProperties
7373
*/
7474
protected abstract WxChannelDefaultConfigImpl wxChannelConfigStorage(WxChannelMultiProperties wxChannelMultiProperties);
7575

76-
public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig, WxChannelMultiProperties wxChannelMultiProperties, boolean useStableAccessToken) {
76+
public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig, WxChannelMultiProperties wxChannelMultiProperties) {
7777
WxChannelMultiProperties.ConfigStorage storage = wxChannelMultiProperties.getConfigStorage();
7878
HttpClientType httpClientType = storage.getHttpClientType();
7979
WxChannelService wxChannelService;
@@ -82,7 +82,7 @@ public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig, WxChan
8282
// wxChannelService = new WxChannelServiceOkHttpImpl(false, false);
8383
// break;
8484
case HTTP_CLIENT:
85-
wxChannelService = new WxChannelServiceHttpClientImpl(useStableAccessToken, false);
85+
wxChannelService = new WxChannelServiceHttpClientImpl();
8686
break;
8787
default:
8888
wxChannelService = new WxChannelServiceImpl();
@@ -108,6 +108,7 @@ private void configApp(WxChannelDefaultConfigImpl config, WxChannelSinglePropert
108108
String appSecret = wxChannelSingleProperties.getSecret();
109109
String token = wxChannelSingleProperties.getToken();
110110
String aesKey = wxChannelSingleProperties.getAesKey();
111+
boolean useStableAccessToken = wxChannelSingleProperties.isUseStableAccessToken();
111112

112113
config.setAppid(appId);
113114
config.setSecret(appSecret);
@@ -117,6 +118,7 @@ private void configApp(WxChannelDefaultConfigImpl config, WxChannelSinglePropert
117118
if (StringUtils.isNotBlank(aesKey)) {
118119
config.setAesKey(aesKey);
119120
}
121+
config.setStableAccessToken(useStableAccessToken);
120122
}
121123

122124
private void configHttp(WxChannelDefaultConfigImpl config, WxChannelMultiProperties.ConfigStorage storage) {

solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/AbstractWxChannelConfigStorageConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ protected WxChannelDefaultConfigImpl config(WxChannelDefaultConfigImpl config, W
1515
config.setToken(StringUtils.trimToNull(properties.getToken()));
1616
config.setAesKey(StringUtils.trimToNull(properties.getAesKey()));
1717
config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat()));
18+
config.setStableAccessToken(properties.isUseStableAccessToken());
1819

1920
WxChannelProperties.ConfigStorage configStorageProperties = properties.getConfigStorage();
2021
config.setHttpProxyHost(configStorageProperties.getHttpProxyHost());

solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public class WxChannelProperties {
4242
*/
4343
private String msgDataFormat = "JSON";
4444

45+
/**
46+
* 是否使用稳定版 Access Token
47+
*/
48+
private boolean useStableAccessToken = false;
49+
4550
/**
4651
* 存储策略
4752
*/

spring-boot-starters/wx-java-channel-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/configuration/services/AbstractWxChannelConfiguration.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected WxChannelMultiServices wxChannelMultiServices(WxChannelMultiProperties
5959
WxChannelDefaultConfigImpl storage = this.wxChannelConfigStorage(wxChannelMultiProperties);
6060
this.configApp(storage, wxChannelSingleProperties);
6161
this.configHttp(storage, wxChannelMultiProperties.getConfigStorage());
62-
WxChannelService wxChannelService = this.wxChannelService(storage, wxChannelMultiProperties, wxChannelSingleProperties.isUseStableAccessToken());
62+
WxChannelService wxChannelService = this.wxChannelService(storage, wxChannelMultiProperties);
6363
services.addWxChannelService(tenantId, wxChannelService);
6464
}
6565
return services;
@@ -73,7 +73,7 @@ protected WxChannelMultiServices wxChannelMultiServices(WxChannelMultiProperties
7373
*/
7474
protected abstract WxChannelDefaultConfigImpl wxChannelConfigStorage(WxChannelMultiProperties wxChannelMultiProperties);
7575

76-
public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig, WxChannelMultiProperties wxChannelMultiProperties, boolean useStableAccessToken) {
76+
public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig, WxChannelMultiProperties wxChannelMultiProperties) {
7777
WxChannelMultiProperties.ConfigStorage storage = wxChannelMultiProperties.getConfigStorage();
7878
HttpClientType httpClientType = storage.getHttpClientType();
7979
WxChannelService wxChannelService;
@@ -82,7 +82,7 @@ public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig, WxChan
8282
// wxChannelService = new WxChannelServiceOkHttpImpl(false, false);
8383
// break;
8484
case HTTP_CLIENT:
85-
wxChannelService = new WxChannelServiceHttpClientImpl(useStableAccessToken, false);
85+
wxChannelService = new WxChannelServiceHttpClientImpl();
8686
break;
8787
default:
8888
wxChannelService = new WxChannelServiceImpl();
@@ -108,6 +108,7 @@ private void configApp(WxChannelDefaultConfigImpl config, WxChannelSinglePropert
108108
String appSecret = wxChannelSingleProperties.getSecret();
109109
String token = wxChannelSingleProperties.getToken();
110110
String aesKey = wxChannelSingleProperties.getAesKey();
111+
boolean useStableAccessToken = wxChannelSingleProperties.isUseStableAccessToken();
111112

112113
config.setAppid(appId);
113114
config.setSecret(appSecret);
@@ -117,6 +118,7 @@ private void configApp(WxChannelDefaultConfigImpl config, WxChannelSinglePropert
117118
if (StringUtils.isNotBlank(aesKey)) {
118119
config.setAesKey(aesKey);
119120
}
121+
config.setStableAccessToken(useStableAccessToken);
120122
}
121123

122124
private void configHttp(WxChannelDefaultConfigImpl config, WxChannelMultiProperties.ConfigStorage storage) {
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# wx-java-channel-spring-boot-starter
2+
3+
## 快速开始
4+
1. 引入依赖
5+
```xml
6+
<dependencies>
7+
<dependency>
8+
<groupId>com.github.binarywang</groupId>
9+
<artifactId>wx-java-channel-multi-spring-boot-starter</artifactId>
10+
<version>${version}</version>
11+
</dependency>
12+
13+
<!-- 配置存储方式为jedis 则引入jedis -->
14+
<dependency>
15+
<groupId>redis.clients</groupId>
16+
<artifactId>jedis</artifactId>
17+
<version>${jedis.version}</version>
18+
</dependency>
19+
20+
<!-- 配置存储方式为redisson 则引入redisson -->
21+
<dependency>
22+
<groupId>org.redisson</groupId>
23+
<artifactId>redisson</artifactId>
24+
<version>${redisson.version}</version>
25+
</dependency>
26+
27+
<!-- 配置存储方式为redis_template 则引入spring data redis -->
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-data-redis</artifactId>
31+
</dependency>
32+
</dependencies>
33+
```
34+
2. 添加配置(application.properties)
35+
```properties
36+
# 视频号配置(必填)
37+
## 视频号小店的appId和secret
38+
wx.channel.app-id=@appId
39+
wx.channel.secret=@secret
40+
# 视频号配置 选填
41+
## 设置视频号小店消息服务器配置的token
42+
wx.channel.token=@token
43+
## 设置视频号小店消息服务器配置的EncodingAESKey
44+
wx.channel.aes-key=
45+
## 支持JSON或者XML格式,默认JSON
46+
wx.channel.msg-data-format=JSON
47+
## 是否使用稳定版 Access Token
48+
wx.channel.use-stable-access-token=false
49+
50+
51+
# ConfigStorage 配置(选填)
52+
## 配置类型: memory(默认), jedis, redisson, redis_template
53+
wx.channel.config-storage.type=memory
54+
## 相关redis前缀配置: wx:channel(默认)
55+
wx.channel.config-storage.key-prefix=wx:channel
56+
wx.channel.config-storage.redis.host=127.0.0.1
57+
wx.channel.config-storage.redis.port=6379
58+
wx.channel.config-storage.redis.password=123456
59+
60+
# redis_template 方式使用spring data redis配置
61+
spring.data.redis.database=0
62+
spring.data.redis.host=127.0.0.1
63+
spring.data.redis.password=123456
64+
spring.data.redis.port=6379
65+
66+
# http 客户端配置(选填)
67+
## # http客户端类型: http_client(默认)
68+
wx.channel.config-storage.http-client-type=http_client
69+
wx.channel.config-storage.http-proxy-host=
70+
wx.channel.config-storage.http-proxy-port=
71+
wx.channel.config-storage.http-proxy-username=
72+
wx.channel.config-storage.http-proxy-password=
73+
## 最大重试次数,默认:5 次,如果小于 0,则为 0
74+
wx.channel.config-storage.max-retry-times=5
75+
## 重试时间间隔步进,默认:1000 毫秒,如果小于 0,则为 1000
76+
wx.channel.config-storage.retry-sleep-millis=1000
77+
```
78+
3. 自动注入的类型
79+
- `WxChannelService`
80+
- `WxChannelConfig`
81+
4. 使用样例
82+
```java
83+
import me.chanjar.weixin.channel.api.WxChannelService;
84+
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
85+
import me.chanjar.weixin.channel.util.JsonUtils;
86+
import me.chanjar.weixin.common.error.WxErrorException;
87+
import org.springframework.beans.factory.annotation.Autowired;
88+
import org.springframework.stereotype.Service;
89+
90+
@Service
91+
public class DemoService {
92+
@Autowired
93+
private WxChannelService wxChannelService;
94+
95+
public String getShopInfo() throws WxErrorException {
96+
// 获取店铺基本信息
97+
ShopInfoResponse response = wxChannelService.getBasicService().getShopInfo();
98+
// 此处为演示,如果要返回response的结果,建议自己封装一个VO,避免直接返回response
99+
return JsonUtils.encode(response);
100+
}
101+
}
102+
```
103+

spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/config/storage/AbstractWxChannelConfigStorageConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ protected WxChannelDefaultConfigImpl config(WxChannelDefaultConfigImpl config, W
1515
config.setToken(StringUtils.trimToNull(properties.getToken()));
1616
config.setAesKey(StringUtils.trimToNull(properties.getAesKey()));
1717
config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat()));
18+
config.setStableAccessToken(properties.isUseStableAccessToken());
1819

1920
WxChannelProperties.ConfigStorage configStorageProperties = properties.getConfigStorage();
2021
config.setHttpProxyHost(configStorageProperties.getHttpProxyHost());

spring-boot-starters/wx-java-channel-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/channel/properties/WxChannelProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public class WxChannelProperties {
4141
*/
4242
private String msgDataFormat = "JSON";
4343

44+
/**
45+
* 是否使用稳定版 Access Token
46+
*/
47+
private boolean useStableAccessToken = false;
48+
4449
/**
4550
* 存储策略
4651
*/

weixin-java-channel/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
<artifactId>weixin-java-channel</artifactId>
1313
<name>WxJava - Channel Java SDK</name>
14-
<description>微信视频号 Java SDK</description>
14+
<description>微信视频号/微信小店 Java SDK</description>
1515

1616
<properties>
17-
<jackson.version>2.15.0</jackson.version>
17+
<jackson.version>2.18.1</jackson.version>
1818
</properties>
1919

2020
<dependencies>

0 commit comments

Comments
 (0)