1
1
package cn .binarywang .wx .miniapp .api ;
2
2
3
+ import cn .binarywang .wx .miniapp .bean .WxMaApiResponse ;
3
4
import cn .binarywang .wx .miniapp .bean .WxMaJscode2SessionResult ;
4
5
import cn .binarywang .wx .miniapp .config .WxMaConfig ;
6
+ import cn .binarywang .wx .miniapp .executor .ApiSignaturePostRequestExecutor ;
7
+ import com .google .gson .JsonObject ;
8
+ import java .util .Map ;
5
9
import java .util .function .Function ;
6
10
import me .chanjar .weixin .common .error .WxErrorException ;
7
11
import me .chanjar .weixin .common .service .WxImgProcService ;
11
15
import me .chanjar .weixin .common .util .http .RequestExecutor ;
12
16
import me .chanjar .weixin .common .util .http .RequestHttp ;
13
17
14
- import java .util .Map ;
15
-
16
18
/**
17
19
* The interface Wx ma service.
18
20
*
19
21
* @author <a href="https://github.com/binarywang">Binary Wang</a>
20
22
*/
21
23
public interface WxMaService extends WxService {
22
- /**
23
- * 获取access_token.
24
- */
25
- String GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s" ;
26
- String GET_STABLE_ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/stable_token" ;
24
+ /** 获取access_token. */
25
+ String GET_ACCESS_TOKEN_URL =
26
+ "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s" ;
27
27
28
+ String GET_STABLE_ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/stable_token" ;
28
29
29
- /**
30
- * The constant JSCODE_TO_SESSION_URL.
31
- */
30
+ /** The constant JSCODE_TO_SESSION_URL. */
32
31
String JSCODE_TO_SESSION_URL = "https://api.weixin.qq.com/sns/jscode2session" ;
33
- /**
34
- * getPaidUnionId
35
- */
32
+
33
+ /** getPaidUnionId */
36
34
String GET_PAID_UNION_ID_URL = "https://api.weixin.qq.com/wxa/getpaidunionid" ;
37
35
38
- /**
39
- * 导入抽样数据
40
- */
36
+ /** 导入抽样数据 */
41
37
String SET_DYNAMIC_DATA_URL = "https://api.weixin.qq.com/wxa/setdynamicdata" ;
42
38
43
39
/**
@@ -51,28 +47,31 @@ public interface WxMaService extends WxService {
51
47
52
48
/**
53
49
* 导入抽样数据
50
+ *
54
51
* <pre>
55
52
* 第三方通过调用微信API,将数据写入到setdynamicdata这个API。每个Post数据包不超过5K,若数据过多可开多进(线)程并发导入数据(例如:数据量为十万量级可以开50个线程并行导数据)。
56
53
* 文档地址:https://wsad.weixin.qq.com/wsad/zh_CN/htmledition/widget-docs-v3/html/custom/quickstart/implement/import/index.html
57
54
* http请求方式:POST http(s)://api.weixin.qq.com/wxa/setdynamicdata?access_token=ACCESS_TOKEN
58
55
* </pre>
59
56
*
60
57
* @param lifespan 数据有效时间,秒为单位,一般为86400,一天一次导入的频率
61
- * @param type 用于标识数据所属的服务类目
62
- * @param scene 1代表用于搜索的数据
63
- * @param data 推送到微信后台的数据列表,该数据被微信用于流量分配,注意该字段为string类型而不是object
58
+ * @param type 用于标识数据所属的服务类目
59
+ * @param scene 1代表用于搜索的数据
60
+ * @param data 推送到微信后台的数据列表,该数据被微信用于流量分配,注意该字段为string类型而不是object
64
61
* @throws WxErrorException .
65
62
*/
66
63
void setDynamicData (int lifespan , String type , int scene , String data ) throws WxErrorException ;
67
64
68
65
/**
66
+ *
67
+ *
69
68
* <pre>
70
69
* 验证消息的确来自微信服务器.
71
70
* 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN
72
71
* </pre>
73
72
*
74
73
* @param timestamp the timestamp
75
- * @param nonce the nonce
74
+ * @param nonce the nonce
76
75
* @param signature the signature
77
76
* @return the boolean
78
77
*/
@@ -88,6 +87,8 @@ public interface WxMaService extends WxService {
88
87
String getAccessToken () throws WxErrorException ;
89
88
90
89
/**
90
+ *
91
+ *
91
92
* <pre>
92
93
* 获取access_token,本方法线程安全.
93
94
* 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限
@@ -106,6 +107,8 @@ public interface WxMaService extends WxService {
106
107
String getAccessToken (boolean forceRefresh ) throws WxErrorException ;
107
108
108
109
/**
110
+ *
111
+ *
109
112
* <pre>
110
113
* 用户支付完成后,获取该用户的 UnionId,无需用户授权。本接口支持第三方平台代理查询。
111
114
*
@@ -114,33 +117,45 @@ public interface WxMaService extends WxService {
114
117
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api/getPaidUnionId.html
115
118
* </pre>
116
119
*
117
- * @param openid 必填 支付用户唯一标识
120
+ * @param openid 必填 支付用户唯一标识
118
121
* @param transactionId 非必填 微信支付订单号
119
- * @param mchId 非必填 微信支付分配的商户号,和商户订单号配合使用
120
- * @param outTradeNo 非必填 微信支付商户订单号,和商户号配合使用
122
+ * @param mchId 非必填 微信支付分配的商户号,和商户订单号配合使用
123
+ * @param outTradeNo 非必填 微信支付商户订单号,和商户号配合使用
121
124
* @return UnionId. paid union id
122
125
* @throws WxErrorException .
123
126
*/
124
- String getPaidUnionId (String openid , String transactionId , String mchId , String outTradeNo ) throws WxErrorException ;
127
+ String getPaidUnionId (String openid , String transactionId , String mchId , String outTradeNo )
128
+ throws WxErrorException ;
125
129
126
130
/**
131
+ *
132
+ *
127
133
* <pre>
128
134
* Service没有实现某个API的时候,可以用这个,
129
135
* 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。
130
136
* 可以参考,{@link MediaUploadRequestExecutor}的实现方法
131
137
* </pre>
132
138
*
133
- * @param <T> .
134
- * @param <E> .
139
+ * @param <T> .
140
+ * @param <E> .
135
141
* @param executor 执行器
136
- * @param uri 接口请求地址
137
- * @param data 参数或请求数据
142
+ * @param uri 接口请求地址
143
+ * @param data 参数或请求数据
138
144
* @return . t
139
145
* @throws WxErrorException the wx error exception
140
146
*/
141
147
<T , E > T execute (RequestExecutor <T , E > executor , String uri , E data ) throws WxErrorException ;
142
148
149
+ WxMaApiResponse execute (
150
+ ApiSignaturePostRequestExecutor executor ,
151
+ String uri ,
152
+ Map <String , String > headers ,
153
+ String data )
154
+ throws WxErrorException ;
155
+
143
156
/**
157
+ *
158
+ *
144
159
* <pre>
145
160
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试.
146
161
* 默认:1000ms
@@ -151,6 +166,8 @@ public interface WxMaService extends WxService {
151
166
void setRetrySleepMillis (int retrySleepMillis );
152
167
153
168
/**
169
+ *
170
+ *
154
171
* <pre>
155
172
* 设置当微信系统响应系统繁忙时,最大重试次数.
156
173
* 默认:5次
@@ -177,7 +194,7 @@ public interface WxMaService extends WxService {
177
194
/**
178
195
* Map里 加入新的 {@link WxMaConfig},适用于动态添加新的微信公众号配置.
179
196
*
180
- * @param miniappId 小程序标识
197
+ * @param miniappId 小程序标识
181
198
* @param configStorage 新的微信配置
182
199
*/
183
200
void addConfig (String miniappId , WxMaConfig configStorage );
@@ -190,8 +207,8 @@ public interface WxMaService extends WxService {
190
207
void removeConfig (String miniappId );
191
208
192
209
/**
193
- * 注入多个 {@link WxMaConfig} 的实现. 并为每个 {@link WxMaConfig} 赋予不同的 {@link String mpId} 值
194
- * 随机采用一个{@link String mpId}进行Http初始化操作
210
+ * 注入多个 {@link WxMaConfig} 的实现. 并为每个 {@link WxMaConfig} 赋予不同的 {@link String mpId} 值 随机采用一个{@link
211
+ * String mpId}进行Http初始化操作
195
212
*
196
213
* @param configs WxMaConfig map
197
214
*/
@@ -200,7 +217,7 @@ public interface WxMaService extends WxService {
200
217
/**
201
218
* 注入多个 {@link WxMaConfig} 的实现. 并为每个 {@link WxMaConfig} 赋予不同的 {@link String label} 值
202
219
*
203
- * @param configs WxMaConfig map
220
+ * @param configs WxMaConfig map
204
221
* @param defaultMiniappId 设置一个{@link WxMaConfig} 所对应的{@link String defaultMiniappId}进行Http初始化
205
222
*/
206
223
void setMultiConfigs (Map <String , WxMaConfig > configs , String defaultMiniappId );
@@ -328,9 +345,7 @@ public interface WxMaService extends WxService {
328
345
*/
329
346
WxMaPluginService getPluginService ();
330
347
331
- /**
332
- * 初始化http请求对象.
333
- */
348
+ /** 初始化http请求对象. */
334
349
void initHttp ();
335
350
336
351
/**
@@ -403,15 +418,13 @@ public interface WxMaService extends WxService {
403
418
*/
404
419
WxMaShopAfterSaleService getShopAfterSaleService ();
405
420
406
-
407
421
/**
408
422
* 返回小程序交易组件-物流服务接口
409
423
*
410
424
* @return
411
425
*/
412
426
WxMaShopDeliveryService getShopDeliveryService ();
413
427
414
-
415
428
/**
416
429
* 返回小程序交易组件-订单服务接口
417
430
*
@@ -544,18 +557,21 @@ public interface WxMaService extends WxService {
544
557
* @return getWxMaOpenApiService
545
558
*/
546
559
WxMaOpenApiService getWxMaOpenApiService ();
560
+
547
561
/**
548
562
* 小程序短剧管理
549
563
*
550
564
* @return getWxMaVodService
551
565
*/
552
566
WxMaVodService getWxMaVodService ();
567
+
553
568
/**
554
569
* 小程序虚拟支付
555
570
*
556
571
* @return getWxMaXPayService
557
572
*/
558
573
WxMaXPayService getWxMaXPayService ();
574
+
559
575
WxMaExpressDeliveryReturnService getWxMaExpressDeliveryReturnService ();
560
576
561
577
/**
@@ -564,4 +580,14 @@ public interface WxMaService extends WxService {
564
580
* @return WxMaPromotionService
565
581
*/
566
582
WxMaPromotionService getWxMaPromotionService ();
583
+
584
+ String postWithSignature (String url , Object obj ) throws WxErrorException ;
585
+
586
+ String postWithSignature (String url , JsonObject jsonObject ) throws WxErrorException ;
587
+
588
+ /**
589
+ * 微信物流服务 -- 同城配送
590
+ * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/intracity_service.html
591
+ */
592
+ WxMaIntracityService getIntracityService ();
567
593
}
0 commit comments