mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0423e6849d | ||
|
|
833ff70680 | ||
|
|
373c1e65cb | ||
|
|
b44dd2e347 | ||
|
|
b6c3d74cba | ||
|
|
0452a05dd4 | ||
|
|
4828a314e9 | ||
|
|
3f0b8d4e2b | ||
|
|
dd407141b0 | ||
|
|
b225afbd68 | ||
|
|
5604a16ae8 | ||
|
|
25309e06ad | ||
|
|
5ac9922f8d | ||
|
|
03790d64bc | ||
|
|
1f0dbcc2aa | ||
|
|
404102a4c8 | ||
|
|
5decfcb917 | ||
|
|
44a95578d9 | ||
|
|
2bf31411c0 | ||
|
|
71fbc2b1e8 | ||
|
|
15b7460d92 | ||
|
|
933840e3b2 | ||
|
|
5da939647c | ||
|
|
22ec3f0eca | ||
|
|
410cc9dfd7 | ||
|
|
783c89523d |
@@ -28,7 +28,7 @@ $ git push
|
||||
* 定期使用项目仓库内容更新自己仓库内容。
|
||||
|
||||
```bash
|
||||
$ git remote add upstream https://github.com/Wechat-Group/WxJava
|
||||
$ git remote add upstream https://github.com/binarywang/WxJava
|
||||
$ git fetch upstream
|
||||
$ git checkout develop
|
||||
$ git rebase upstream/develop
|
||||
|
||||
13
README.md
13
README.md
@@ -21,24 +21,29 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="middle" colspan="3">
|
||||
<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="left" valign="middle">
|
||||
<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 valign="middle">
|
||||
<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="right" valign="middle">
|
||||
<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>
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WxJava - Weixin/Wechat Java SDK</name>
|
||||
<description>微信开发Java SDK</description>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-solon-plugins</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.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.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-graal</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-channel</artifactId>
|
||||
|
||||
@@ -42,4 +42,8 @@ public class OrderCommissionInfo implements Serializable {
|
||||
/** 达人openfinderid */
|
||||
@JsonProperty("openfinderid")
|
||||
private String openFinderId;
|
||||
|
||||
/** 新带货平台 id */
|
||||
@JsonProperty("talent_id")
|
||||
private String talentId;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-common</artifactId>
|
||||
|
||||
@@ -59,7 +59,7 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
|
||||
* 设置为负数是使用系统默认设置(非3000ms的默认值,而是httpClient的默认设置).
|
||||
* </p>
|
||||
*/
|
||||
private int connectionRequestTimeout = -1;
|
||||
private int connectionRequestTimeout = 3000;
|
||||
|
||||
/**
|
||||
* 建立链接的超时时间,默认为5000ms.由于是在链接池获取链接,此设置应该并不起什么作用
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-cp</artifactId>
|
||||
|
||||
@@ -36,4 +36,12 @@ public interface WxCpAgentWorkBenchService {
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
void setWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* Batch sets work bench data.
|
||||
*
|
||||
* @param wxCpAgentWorkBench the wx cp agent work bench
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
void batchSetWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public interface WxCpExternalContactService {
|
||||
* 用户需要妥善存储返回的config_id,config_id丢失可能导致用户无法编辑或删除「联系我」。
|
||||
* 临时会话模式不占用「联系我」数量,但每日最多添加10万个,并且仅支持单人。
|
||||
* 临时会话模式的二维码,添加好友完成后该二维码即刻失效。
|
||||
* <a href="https://developer.work.weixin.qq.com/document/path/92228">文档地址</a>
|
||||
* </pre>
|
||||
*
|
||||
* @param info 客户联系「联系我」方式
|
||||
@@ -59,6 +60,25 @@ public interface WxCpExternalContactService {
|
||||
*/
|
||||
WxCpContactWayInfo getContactWay(String configId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取企业已配置的「联系我」列表
|
||||
*
|
||||
* <pre>
|
||||
* 获取企业配置的「联系我」二维码和「联系我」小程序插件列表。不包含临时会话。
|
||||
* 注意,<b>该接口仅可获取2021年7月10日以后创建的「联系我」</b>
|
||||
* </pre>
|
||||
*
|
||||
* 文档地址: <a href="https://developer.work.weixin.qq.com/document/path/92228#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E5%88%97%E8%A1%A8">获取企业已配置的「联系我」列表</a>
|
||||
*
|
||||
* @param startTime 「联系我」创建起始时间戳, 默认为90天前
|
||||
* @param endTime 「联系我」创建结束时间戳, 默认为当前时间
|
||||
* @param cursor 分页查询使用的游标,为上次请求返回的 next_cursor
|
||||
* @param limit 每次查询的分页大小,默认为100条,最多支持1000条
|
||||
* @return contact way configId
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpContactWayList listContactWay(Long startTime, Long endTime, String cursor, Long limit) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 更新企业已配置的「联系我」方式
|
||||
*
|
||||
|
||||
@@ -75,6 +75,19 @@ public interface WxCpKfService {
|
||||
*/
|
||||
WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接待人员管理
|
||||
* 添加指定客服账号的接待人员,每个客服账号目前最多可添加2000个接待人员,20个部门。
|
||||
* userid_list和department_id_list至少需要填其中一个
|
||||
*
|
||||
* @param openKfid 客服帐号ID
|
||||
* @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。
|
||||
* @param departmentIdList 接待人员部门id列表 可填充个数:0 ~ 20。
|
||||
* @return 添加客服账号结果 wx cp kf servicer op resp
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList,List<String> departmentIdList) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接待人员管理
|
||||
* 从客服帐号删除接待人员
|
||||
@@ -86,6 +99,19 @@ public interface WxCpKfService {
|
||||
*/
|
||||
WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接待人员管理
|
||||
* 从客服帐号删除接待人员
|
||||
* userid_list和department_id_list至少需要填其中一个
|
||||
*
|
||||
* @param openKfid 客服帐号ID
|
||||
* @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。
|
||||
* @param departmentIdList 接待人员部门id列表 可填充个数:0 ~ 100。超过100个需分批调用。
|
||||
* @return 删除客服账号结果 wx cp kf servicer op resp
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList, List<String> departmentIdList) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接待人员管理
|
||||
* 获取某个客服帐号的接待人员列表
|
||||
|
||||
@@ -38,4 +38,10 @@ public class WxCpAgentWorkBenchServiceImpl implements WxCpAgentWorkBenchService
|
||||
final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WORKBENCH_DATA_SET));
|
||||
this.mainService.post(url, wxCpAgentWorkBench.toUserDataString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSetWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException {
|
||||
final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WORKBENCH_BATCH_DATA_SET));
|
||||
this.mainService.post(url, wxCpAgentWorkBench.toBatchUserDataString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,17 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
|
||||
return WxCpContactWayInfo.fromJson(this.mainService.post(url, json.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpContactWayList listContactWay(Long startTime, Long endTime, String cursor, Long limit) throws WxErrorException {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("start_time", startTime);
|
||||
json.addProperty("end_time", endTime);
|
||||
json.addProperty("cursor", cursor);
|
||||
json.addProperty("limit", limit);
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_CONTACT_WAY);
|
||||
return WxCpContactWayList.fromJson(this.mainService.post(url, json.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp updateContactWay(WxCpContactWayInfo info) throws WxErrorException {
|
||||
if (StringUtils.isBlank(info.getContactWay().getConfigId())) {
|
||||
|
||||
@@ -70,23 +70,62 @@ public class WxCpKfServiceImpl implements WxCpKfService {
|
||||
|
||||
@Override
|
||||
public WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException {
|
||||
return servicerOp(openKfid, userIdList, SERVICER_ADD);
|
||||
return servicerOp(openKfid, userIdList, null, SERVICER_ADD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpKfServicerOpResp addServicer(String openKfId, List<String> userIdList, List<String> departmentIdList) throws WxErrorException {
|
||||
validateParameters(SERVICER_ADD, userIdList, departmentIdList);
|
||||
return servicerOp(openKfId, userIdList, departmentIdList, SERVICER_ADD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException {
|
||||
return servicerOp(openKfid, userIdList, SERVICER_DEL);
|
||||
return servicerOp(openKfid, userIdList, null, SERVICER_DEL);
|
||||
}
|
||||
|
||||
private WxCpKfServicerOpResp servicerOp(String openKfid, List<String> userIdList, String uri) throws WxErrorException {
|
||||
@Override
|
||||
public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList, List<String> departmentIdList) throws WxErrorException {
|
||||
validateParameters(SERVICER_DEL, userIdList, departmentIdList);
|
||||
return servicerOp(openKfid, userIdList, departmentIdList, SERVICER_DEL);
|
||||
}
|
||||
|
||||
private void validateParameters(String uri, List<String> userIdList, List<String> departmentIdList) {
|
||||
if ((userIdList == null || userIdList.isEmpty()) && (departmentIdList == null || departmentIdList.isEmpty())) {
|
||||
throw new IllegalArgumentException("userid_list和department_id_list至少需要填其中一个");
|
||||
}
|
||||
if (SERVICER_DEL.equals(uri)) {
|
||||
if (userIdList != null && userIdList.size() > 100) {
|
||||
throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。");
|
||||
}
|
||||
if (departmentIdList != null && departmentIdList.size() > 100) {
|
||||
throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。");
|
||||
}
|
||||
} else {
|
||||
if (userIdList != null && userIdList.size() > 100) {
|
||||
throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。");
|
||||
}
|
||||
if (departmentIdList != null && departmentIdList.size() > 20) {
|
||||
throw new IllegalArgumentException("可填充个数:0 ~ 20。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private WxCpKfServicerOpResp servicerOp(String openKfid, List<String> userIdList, List<String> departmentIdList, String uri) throws WxErrorException {
|
||||
String url = cpService.getWxCpConfigStorage().getApiUrl(uri);
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("open_kfid", openKfid);
|
||||
JsonArray userIdArray = new JsonArray();
|
||||
userIdList.forEach(userIdArray::add);
|
||||
json.add("userid_list", userIdArray);
|
||||
|
||||
if (userIdList != null && !userIdList.isEmpty()) {
|
||||
JsonArray userIdArray = new JsonArray();
|
||||
userIdList.forEach(userIdArray::add);
|
||||
json.add("userid_list", userIdArray);
|
||||
}
|
||||
if (departmentIdList != null && !departmentIdList.isEmpty()) {
|
||||
JsonArray departmentIdArray = new JsonArray();
|
||||
departmentIdList.forEach(departmentIdArray::add);
|
||||
json.add("department_id_list", departmentIdArray);
|
||||
}
|
||||
String responseContent = cpService.post(url, json.toString());
|
||||
return WxCpKfServicerOpResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import me.chanjar.weixin.cp.bean.WxCpUserDetail;
|
||||
import me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificationInfo;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.*;
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.OAuth2.*;
|
||||
|
||||
@@ -74,9 +76,9 @@ public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service {
|
||||
JsonObject jo = GsonParser.parse(responseText);
|
||||
|
||||
return WxCpOauth2UserInfo.builder()
|
||||
.userId(GsonHelper.getString(jo, "UserId"))
|
||||
.userId(Optional.ofNullable(GsonHelper.getString(jo, "UserId")).orElse(GsonHelper.getString(jo, "userid")))
|
||||
.deviceId(GsonHelper.getString(jo, "DeviceId"))
|
||||
.openId(GsonHelper.getString(jo, "OpenId"))
|
||||
.openId(Optional.ofNullable(GsonHelper.getString(jo, "OpenId")).orElse(GsonHelper.getString(jo, "openid")))
|
||||
.userTicket(GsonHelper.getString(jo, "user_ticket"))
|
||||
.expiresIn(GsonHelper.getString(jo, "expires_in"))
|
||||
.externalUserId(GsonHelper.getString(jo, "external_userid"))
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
import me.chanjar.weixin.cp.bean.workbench.WorkBenchKeyData;
|
||||
import me.chanjar.weixin.cp.bean.workbench.WorkBenchList;
|
||||
import me.chanjar.weixin.cp.constant.WxCpConsts;
|
||||
@@ -33,6 +34,10 @@ public class WxCpAgentWorkBench implements Serializable {
|
||||
* 用户的userid
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 用户的userIds
|
||||
*/
|
||||
private List<String> useridList;
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
@@ -58,6 +63,15 @@ public class WxCpAgentWorkBench implements Serializable {
|
||||
* 参考示例:<a href="wxwork://openurl?url=https%3A%2F%2Fwork.weixin.qq.com%2F">今日要闻</a>
|
||||
*/
|
||||
private Boolean enableWebviewClick;
|
||||
/**
|
||||
* 高度。可以有两种选择:single_row与double_row。当为single_row时,高度为106px(如果隐藏标题则为147px)。
|
||||
* 当为double_row时,高度固定为171px(如果隐藏标题则为212px)。默认值为double_row
|
||||
*/
|
||||
private String height;
|
||||
/**
|
||||
* 是否要隐藏展示了应用名称的标题部分,默认值为false。
|
||||
*/
|
||||
private Boolean hideTitle;
|
||||
|
||||
private List<WorkBenchKeyData> keyDataList;
|
||||
|
||||
@@ -93,6 +107,20 @@ public class WxCpAgentWorkBench implements Serializable {
|
||||
return userDataObject.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成批量用户数据Json字符串
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String toBatchUserDataString() {
|
||||
JsonObject userDataObject = new JsonObject();
|
||||
userDataObject.addProperty("agentid", this.agentId);
|
||||
JsonArray useridList = WxGsonBuilder.create().toJsonTree(this.useridList).getAsJsonArray();
|
||||
userDataObject.add("userid_list", useridList);
|
||||
this.handleBatch(userDataObject);
|
||||
return userDataObject.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理不用类型的工作台数据
|
||||
*/
|
||||
@@ -140,9 +168,9 @@ public class WxCpAgentWorkBench implements Serializable {
|
||||
webview.addProperty("url", this.url);
|
||||
webview.addProperty("jump_url", this.jumpUrl);
|
||||
webview.addProperty("pagepath", this.pagePath);
|
||||
if (null != this.enableWebviewClick) {
|
||||
webview.addProperty("enable_webview_click", this.enableWebviewClick);
|
||||
}
|
||||
webview.addProperty("enable_webview_click", this.enableWebviewClick);
|
||||
webview.addProperty("height", this.height);
|
||||
webview.addProperty("hide_title", this.hideTitle);
|
||||
templateObject.add("webview", webview);
|
||||
break;
|
||||
}
|
||||
@@ -152,4 +180,75 @@ public class WxCpAgentWorkBench implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理不用类型的工作台数据
|
||||
*/
|
||||
private void handleBatch(JsonObject templateObject) {
|
||||
switch (this.getType()) {
|
||||
case WxCpConsts.WorkBenchType.KEYDATA: {
|
||||
JsonArray keyDataArray = new JsonArray();
|
||||
JsonObject itemsObject = new JsonObject();
|
||||
for (WorkBenchKeyData keyDataItem : this.keyDataList) {
|
||||
JsonObject keyDataObject = new JsonObject();
|
||||
keyDataObject.addProperty("key", keyDataItem.getKey());
|
||||
keyDataObject.addProperty("data", keyDataItem.getData());
|
||||
keyDataObject.addProperty("jump_url", keyDataItem.getJumpUrl());
|
||||
keyDataObject.addProperty("pagepath", keyDataItem.getPagePath());
|
||||
keyDataArray.add(keyDataObject);
|
||||
}
|
||||
itemsObject.add("items", keyDataArray);
|
||||
JsonObject dataObject = new JsonObject();
|
||||
dataObject.addProperty("type", WxCpConsts.WorkBenchType.KEYDATA);
|
||||
dataObject.add("keydata", itemsObject);
|
||||
templateObject.add("data", dataObject);
|
||||
break;
|
||||
}
|
||||
case WxCpConsts.WorkBenchType.IMAGE: {
|
||||
JsonObject image = new JsonObject();
|
||||
image.addProperty("url", this.url);
|
||||
image.addProperty("jump_url", this.jumpUrl);
|
||||
image.addProperty("pagepath", this.pagePath);
|
||||
JsonObject dataObject = new JsonObject();
|
||||
dataObject.addProperty("type", WxCpConsts.WorkBenchType.IMAGE);
|
||||
dataObject.add("image", image);
|
||||
templateObject.add("data", dataObject);
|
||||
break;
|
||||
}
|
||||
case WxCpConsts.WorkBenchType.LIST: {
|
||||
JsonArray listArray = new JsonArray();
|
||||
JsonObject itemsObject = new JsonObject();
|
||||
for (WorkBenchList listItem : this.lists) {
|
||||
JsonObject listObject = new JsonObject();
|
||||
listObject.addProperty("title", listItem.getTitle());
|
||||
listObject.addProperty("jump_url", listItem.getJumpUrl());
|
||||
listObject.addProperty("pagepath", listItem.getPagePath());
|
||||
listArray.add(listObject);
|
||||
}
|
||||
itemsObject.add("items", listArray);
|
||||
JsonObject dataObject = new JsonObject();
|
||||
dataObject.addProperty("type", WxCpConsts.WorkBenchType.LIST);
|
||||
dataObject.add("list", itemsObject);
|
||||
templateObject.add("data", dataObject);
|
||||
break;
|
||||
}
|
||||
case WxCpConsts.WorkBenchType.WEBVIEW: {
|
||||
JsonObject webview = new JsonObject();
|
||||
webview.addProperty("url", this.url);
|
||||
webview.addProperty("jump_url", this.jumpUrl);
|
||||
webview.addProperty("pagepath", this.pagePath);
|
||||
webview.addProperty("enable_webview_click", this.enableWebviewClick);
|
||||
webview.addProperty("height", this.height);
|
||||
webview.addProperty("hide_title", this.hideTitle);
|
||||
JsonObject dataObject = new JsonObject();
|
||||
dataObject.addProperty("type", WxCpConsts.WorkBenchType.WEBVIEW);
|
||||
dataObject.add("webview", webview);
|
||||
templateObject.add("data", dataObject);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -152,6 +152,13 @@ public class WxCpContactWayInfo implements Serializable {
|
||||
@SerializedName("unionid")
|
||||
private String unionId;
|
||||
|
||||
|
||||
/**
|
||||
*非必填,是否开启同一外部企业客户只能添加同一个员工,默认为否,开启后,同一个企业的客户会优先添加到同一个跟进人
|
||||
*/
|
||||
@SerializedName("is_exclusive")
|
||||
private boolean isExclusive;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
|
||||
63
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayList.java
vendored
Normal file
63
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayList.java
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
package me.chanjar.weixin.cp.bean.external;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 「联系我」方式 列表返回对象
|
||||
*
|
||||
* @author <a href="https://github.com/imyzt">imyzt</a>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class WxCpContactWayList extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -8697184659526210472L;
|
||||
|
||||
@SerializedName("contact_way")
|
||||
private List<ContactWay> contactWay;
|
||||
|
||||
/**
|
||||
* The type Contact way.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ContactWay implements Serializable {
|
||||
private static final long serialVersionUID = -8697184659526210472L;
|
||||
|
||||
/**
|
||||
* 联系方式的配置id
|
||||
*/
|
||||
@SerializedName("config_id")
|
||||
private String configId;
|
||||
}
|
||||
|
||||
/**
|
||||
* From json wx cp contact way list.
|
||||
*
|
||||
* @param json the json
|
||||
* @return the wx cp contact way list
|
||||
*/
|
||||
public static WxCpContactWayList fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* To json string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -130,6 +130,10 @@ public interface WxCpApiPathConsts {
|
||||
* The constant WORKBENCH_DATA_SET.
|
||||
*/
|
||||
String WORKBENCH_DATA_SET = "/cgi-bin/agent/set_workbench_data";
|
||||
/**
|
||||
* The constant WORKBENCH_BATCH_DATA_SET.
|
||||
*/
|
||||
String WORKBENCH_BATCH_DATA_SET = "/cgi-bin/agent/batch_set_workbench_data";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1085,6 +1089,10 @@ public interface WxCpApiPathConsts {
|
||||
* The constant GET_CONTACT_WAY.
|
||||
*/
|
||||
String GET_CONTACT_WAY = "/cgi-bin/externalcontact/get_contact_way";
|
||||
/**
|
||||
* The constant LIST_CONTACT_WAY.
|
||||
*/
|
||||
String LIST_CONTACT_WAY = "/cgi-bin/externalcontact/list_contact_way";
|
||||
/**
|
||||
* The constant UPDATE_CONTACT_WAY.
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,9 @@ import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
@@ -90,6 +93,20 @@ public class WxCpExternalContactServiceImplTest {
|
||||
assertNotNull(contactWayInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test list contact way.
|
||||
*
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
@Test
|
||||
public void testListContactWay() throws WxErrorException {
|
||||
long startTime = LocalDateTime.now().minusDays(1).toEpochSecond(ZoneOffset.of("+8"));
|
||||
long endTime = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
|
||||
WxCpContactWayList wxCpContactWayList = this.wxCpService.getExternalContactService().listContactWay(startTime, endTime, null, 100L);
|
||||
System.out.println(wxCpContactWayList.toJson());
|
||||
assertNotNull(wxCpContactWayList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update contact way.
|
||||
*
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-miniapp</artifactId>
|
||||
|
||||
@@ -207,7 +207,7 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
|
||||
|
||||
@Override
|
||||
public WxMaBaseResponse updateWaybillGoods(UpdateWaybillGoodsRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(InstantDelivery.GET_DELIVERY_LIST_URL,request);
|
||||
String responseContent = this.wxMaService.post(InstantDelivery.UPDATE_WAYBILL_GOODS_URL,request);
|
||||
WxMaBaseResponse response = WxMaGsonBuilder.create().fromJson(responseContent, WxMaBaseResponse.class);
|
||||
if (response.getErrcode() == -1) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
|
||||
@@ -31,7 +31,7 @@ public class WxMaMessage implements Serializable {
|
||||
private static final long serialVersionUID = -3586245291677274914L;
|
||||
|
||||
/**
|
||||
* 使用dom4j解析的存放所有xml属性和值的map.
|
||||
* 使用dom4j解析的存放所有xml或json属性和值的map.
|
||||
*/
|
||||
private Map<String, Object> allFieldsMap;
|
||||
|
||||
@@ -287,6 +287,7 @@ public class WxMaMessage implements Serializable {
|
||||
}
|
||||
message.setUselessMsg(null);
|
||||
}
|
||||
message.setAllFieldsMap(WxMaGsonBuilder.create().fromJson(json, Map.class));
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@@ -626,7 +626,7 @@ public class WxMaApiUrlConstants {
|
||||
String GET_DELIVERY_LIST_URL =
|
||||
"https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/get_delivery_list";
|
||||
|
||||
/** 获取运力id列表get_delivery_list 商户使用此接口获取所有运力id的列表 */
|
||||
/** 物流服务-查询组件-更新物品信息接口 update_waybill_goods 更新物品信息 */
|
||||
String UPDATE_WAYBILL_GOODS_URL =
|
||||
"https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/update_waybill_goods";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
|
||||
@@ -50,12 +50,12 @@ public class WxMpServiceOkHttpImpl extends BaseWxMpServiceImpl<OkHttpClient, OkH
|
||||
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
||||
|
||||
//设置授权
|
||||
clientBuilder.authenticator(new Authenticator() {
|
||||
clientBuilder.proxyAuthenticator(new Authenticator() {
|
||||
@Override
|
||||
public Request authenticate(Route route, Response response) throws IOException {
|
||||
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
||||
return response.request().newBuilder()
|
||||
.header("Authorization", credential)
|
||||
.header("Proxy-Authorization", credential)
|
||||
.build();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -186,6 +186,22 @@ public class WxMpXmlMessage implements Serializable {
|
||||
@JacksonXmlCData
|
||||
private String unionId;
|
||||
|
||||
@XStreamAlias("ret")
|
||||
@JacksonXmlProperty(localName = "ret")
|
||||
private Integer ret;
|
||||
|
||||
@XStreamAlias("nickname")
|
||||
@JacksonXmlProperty(localName = "nickname")
|
||||
private String nickname;
|
||||
|
||||
@XStreamAlias("first")
|
||||
@JacksonXmlProperty(localName = "first")
|
||||
private String first;
|
||||
|
||||
@XStreamAlias("second")
|
||||
@JacksonXmlProperty(localName = "second")
|
||||
private String second;
|
||||
|
||||
///////////////////////////////////////
|
||||
// 群发消息返回的结果
|
||||
///////////////////////////////////////
|
||||
|
||||
@@ -15,7 +15,7 @@ public class WxMpMapConfigImpl extends WxMpDefaultConfigImpl {
|
||||
|
||||
private static final long serialVersionUID = 5311395137835650104L;
|
||||
|
||||
private static final ConcurrentHashMap<String, String> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(1);
|
||||
private final ConcurrentHashMap<String, String> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(1);
|
||||
|
||||
private static final String MAP_KEY = "access_token";
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.test.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl;
|
||||
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* 测试 ConcurrentHashMap 保存配置信息
|
||||
* @author jimmyjimmy-sw
|
||||
*/
|
||||
@Test
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpMapConfigImplTest {
|
||||
|
||||
@Inject
|
||||
private WxMpService wxService;
|
||||
|
||||
/**
|
||||
* 测试多租户保存 WxMpMapConfigImpl 到 WxMpService,切换之后能获取到租户各自AppId对应的token
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public void testAppidSwitch() throws WxErrorException {
|
||||
// 保存租户A的配置信息,并获取token
|
||||
WxMpMapConfigImpl configAppA = new WxMpMapConfigImpl();
|
||||
String appidA = "APPID_A";
|
||||
configAppA.setAppId(appidA);
|
||||
configAppA.setSecret("APP_SECRET_A");
|
||||
configAppA.useStableAccessToken(true);
|
||||
String tokenA = "TOKEN_A";
|
||||
configAppA.updateAccessToken(tokenA,60 * 60 * 1);
|
||||
wxService.addConfigStorage(appidA, configAppA);
|
||||
WxMpConfigStorageHolder.set(appidA);
|
||||
assertEquals(this.wxService.getAccessToken(),tokenA);
|
||||
|
||||
// 保存租户B的配置信息,并获取token
|
||||
WxMpMapConfigImpl configAppB = new WxMpMapConfigImpl();
|
||||
String appidB = "APPID_B";
|
||||
configAppB.setAppId(appidB);
|
||||
configAppB.setSecret("APP_SECRET_B");
|
||||
configAppB.useStableAccessToken(true);
|
||||
String tokenB = "TOKEN_B";
|
||||
configAppB.updateAccessToken(tokenB,60 * 60 * 1);
|
||||
wxService.addConfigStorage(appidB, configAppB);
|
||||
WxMpConfigStorageHolder.set(appidB);
|
||||
assertEquals(this.wxService.getAccessToken(),tokenB);
|
||||
|
||||
// 上下文切换到租户A 获取租户A的token
|
||||
WxMpConfigStorageHolder.set(appidA);
|
||||
assertEquals(this.wxService.getAccessToken(),tokenA);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-open</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -327,4 +327,141 @@ public class ComplaintDetailResult implements Serializable {
|
||||
*/
|
||||
@SerializedName("user_tag_list")
|
||||
private String[] userTagList;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:补充信息
|
||||
* 是否必填:否
|
||||
* 描述: 用在特定行业或场景下返回的补充信息
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("additional_info")
|
||||
private AdditionalInfo additionalInfo;
|
||||
|
||||
@Data
|
||||
public static class AdditionalInfo implements Serializable {
|
||||
private static final long serialVersionUID = 7917816070738944147L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:补充信息类型
|
||||
* 是否必填:否
|
||||
* 描述: 补充信息类型
|
||||
* 示例值:SHARE_POWER_TYPE: 充电宝投诉相关行业
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:充电宝投诉相关信息
|
||||
* 是否必填:否
|
||||
* 描述:当type为充电宝投诉相关时有值
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("share_power_info")
|
||||
private SharePowerInfo sharePowerInfo;
|
||||
|
||||
/**
|
||||
* 充电宝投诉相关信息
|
||||
*/
|
||||
@Data
|
||||
public static class SharePowerInfo implements Serializable {
|
||||
private static final long serialVersionUID = -2878382307459369354L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:归还时间
|
||||
* 是否必填:否
|
||||
* 描述:遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,
|
||||
* yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
|
||||
* HH:mm:ss表示时分秒,
|
||||
* TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
|
||||
* 示例值:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("return_time")
|
||||
private String returnTime;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:归还地点信息
|
||||
* 是否必填:否
|
||||
* 描述: 归还地点信息
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("return_address_info")
|
||||
private ReturnAddressInfo returnAddressInfo;
|
||||
|
||||
@Data
|
||||
public static class ReturnAddressInfo implements Serializable {
|
||||
private static final long serialVersionUID = -7649986542568217256L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:归还地点
|
||||
* 是否必填:否 string(256)
|
||||
* 描述:归还地点
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("return_address")
|
||||
private String returnAddress;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:归还地点经度
|
||||
* 是否必填:否 string(32)
|
||||
* 描述:经度,字符串,范围为-180~180,负数表示西经。使用GCJ-02坐标系
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("longitude")
|
||||
private String longitude;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:归还地点纬度
|
||||
* 是否必填:否 string(32)
|
||||
* 描述:纬度,字符串,范围为-90~90,负数表示南纬。使用GCJ-02坐标系
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("latitude")
|
||||
private String latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:是否归还同一柜机
|
||||
* 是否必填:否
|
||||
* 描述:用户声明是否将充电宝归还至与借取时同一柜机
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("is_returned_to_same_machine")
|
||||
private Boolean isReturnedToSameMachine;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:是否在平台协助中
|
||||
* 是否必填:否
|
||||
* 描述:标识当前投诉单是否正处在平台协助流程中。
|
||||
* 注:在协助期间由微信支付客服为用户服务,期间商户向用户发送的留言用户不可见
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("in_platform_service")
|
||||
private Boolean inPlatformService;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:是否需即时服务用户
|
||||
* 是否必填:否
|
||||
* 描述:因用户诉求紧急度、用户界面差异等因素,部分投诉单建议商户更即时地响应用户诉求。
|
||||
* 如此处标识为“是”,建议商户提升服务时效,给用户带来更好的体验
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("need_immediate_service")
|
||||
private Boolean needImmediateService;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -142,20 +142,30 @@ public class NegotiationHistoryResult implements Serializable {
|
||||
* 是否必填:是
|
||||
* 描述:
|
||||
* 当前投诉协商记录的操作类型,对应枚举:
|
||||
* USER_CREATE_COMPLAINT:用户提交投诉
|
||||
* USER_CONTINUE_COMPLAINT:用户继续投诉
|
||||
* USER_RESPONSE:用户留言
|
||||
* PLATFORM_RESPONSE:平台留言
|
||||
* MERCHANT_RESPONSE:商户留言
|
||||
* MERCHANT_CONFIRM_COMPLETE:商户申请结单
|
||||
* COMPLAINT_FULL_REFUNDED:投诉单全额退款
|
||||
* USER_CREATE_COMPLAINT_SYSTEM_MESSAGE:用户提交投诉系统通知
|
||||
* COMPLAINT_FULL_REFUNDED_SYSTEM_MESSAGE:投诉单全额退款系统通知
|
||||
* USER_CONTINUE_COMPLAINT_SYSTEM_MESSAGE:用户继续投诉系统通知
|
||||
* MERCHANT_CONFIRM_COMPLETE_SYSTEM_MESSAGE:商户申请结单系统通知
|
||||
* USER_REVOKE_COMPLAINT:用户主动撤诉(只存在于历史投诉单的协商历史中)
|
||||
* PLATFORM_HELP_APPLICATION:平台问询
|
||||
* USER_APPLY_PLATFORM_HELP:申请协助
|
||||
* USER_CREATE_COMPLAINT: 用户提交投诉
|
||||
* USER_CONTINUE_COMPLAINT: 用户继续投诉
|
||||
* USER_RESPONSE: 用户留言
|
||||
* PLATFORM_RESPONSE: 平台留言
|
||||
* MERCHANT_RESPONSE: 商户留言
|
||||
* MERCHANT_CONFIRM_COMPLETE: 商户申请结单
|
||||
* USER_CREATE_COMPLAINT_SYSTEM_MESSAGE: 用户提交投诉系统通知
|
||||
* COMPLAINT_FULL_REFUNDED_SYSTEM_MESSAGE: 投诉单发起全额退款系统通知
|
||||
* USER_CONTINUE_COMPLAINT_SYSTEM_MESSAGE: 用户继续投诉系统通知
|
||||
* USER_REVOKE_COMPLAINT: 用户主动撤诉(只存在于历史投诉单的协商历史中)
|
||||
* USER_COMFIRM_COMPLAINT: 用户确认投诉解决(只存在于历史投诉单的协商历史中)
|
||||
* PLATFORM_HELP_APPLICATION: 平台催办
|
||||
* USER_APPLY_PLATFORM_HELP: 用户申请平台协助
|
||||
* MERCHANT_APPROVE_REFUND: 商户同意退款申请
|
||||
* MERCHANT_REFUSE_RERUND: 商户拒绝退款申请, 此时操作内容里展示拒绝原因
|
||||
* USER_SUBMIT_SATISFACTION: 用户提交满意度调查结果,此时操作内容里会展示满意度分数
|
||||
* SERVICE_ORDER_CANCEL: 服务订单已取消
|
||||
* SERVICE_ORDER_COMPLETE: 服务订单已完成
|
||||
* COMPLAINT_PARTIAL_REFUNDED_SYSTEM_MESSAGE: 投诉单发起部分退款系统通知
|
||||
* COMPLAINT_REFUND_RECEIVED_SYSTEM_MESSAGE: 投诉单退款到账系统通知
|
||||
* COMPLAINT_ENTRUSTED_REFUND_SYSTEM_MESSAGE: 投诉单受托退款系统通知
|
||||
* USER_APPLY_PLATFORM_SERVICE: 用户申请平台协助
|
||||
* USER_CANCEL_PLATFORM_SERVICE: 用户取消平台协助
|
||||
* PLATFORM_SERVICE_FINISHED: 客服结束平台协助
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("operate_type")
|
||||
@@ -179,11 +189,32 @@ public class NegotiationHistoryResult implements Serializable {
|
||||
* 描述:
|
||||
* 当前投诉协商记录提交的图片凭证(url格式),最多返回4张图片,url有效时间为1小时。如未查询到协商历史图片凭证,则返回空数组。
|
||||
* 注:本字段包含商户、微信支付客服在协商解决投诉时上传的图片凭证,若希望查看用户图片,请使用complaint_media_list字段并联系微信支付客服
|
||||
* 注:此字段不包含用户提交的图片凭证,建议统一使用complaint_media_list字段接收和请求资料凭证,未来该字段将废弃
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("image_list")
|
||||
private List<String> imageList;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:用户申请平台协助原因
|
||||
* 是否必填:否
|
||||
* 描述:用户此次申请平台协助时选择的申请协助原因
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("user_appy_platform_service_reason")
|
||||
private String userApplyPlatformServiceReason;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:用户申请平台协助原因描述
|
||||
* 是否必填:否
|
||||
* 描述:用户此次申请平台协助时填写的具体申请协助原因描述
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("user_appy_platform_service_reason_description")
|
||||
private String userApplyPlatformServiceReasonDescription;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,4 +94,57 @@ public class ResponseRequest implements Serializable {
|
||||
@SerializedName("jump_url_text")
|
||||
private String jumpUrlText;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:跳转小程序信息
|
||||
* 是否必填:否
|
||||
* 描述:商户可在回复中附加小程序信息,引导用户跳转至商户客诉处理小程序。
|
||||
* 注:配置小程序属于灰度功能,若有需要请联系对接的行业运营进行咨询。
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("mini_program_jump_info")
|
||||
private MiniProgramJumpInfo miniProgramJumpInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 跳转小程序信息
|
||||
*/
|
||||
@Data
|
||||
public static class MiniProgramJumpInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1169503275787468380L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:跳转小程序APPID
|
||||
* 是否必填:是
|
||||
* 描述:商户可在回复中附加小程序页面路径,引导用户跳转至商户服务工具页面。
|
||||
* 该字段为小程序APPID。
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("appid")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:跳转小程序页面PATH
|
||||
* 是否必填:是
|
||||
* 描述:商户可在回复中附加小程序页面路径,引导用户跳转至商户服务工具页面。
|
||||
* 该字段为小程序路径。
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("path")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:跳转小程序页面名称
|
||||
* 是否必填:是
|
||||
* 描述:商户可在回复中附加小程序页面路径,引导用户跳转至商户服务工具页面。
|
||||
* 该字段为商户可自定义的页面名称。
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("text")
|
||||
private String text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class UpdateRefundProgressRequest implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:拒绝退款原因
|
||||
* 是否必填:否
|
||||
* 是否必填:否 string(200)
|
||||
* 描述:在拒绝退款时返回拒绝退款的原因
|
||||
* </pre>
|
||||
*/
|
||||
@@ -72,7 +72,9 @@ public class UpdateRefundProgressRequest implements Serializable {
|
||||
* <pre>
|
||||
* 字段名:拒绝退款的举证图片列表
|
||||
* 是否必填:否
|
||||
* 描述:在拒绝退款时,如果有拒绝的图片举证,可以提供 最多上传4张图片, 传入调用“商户上传反馈图片”接口返回的media_id,最多上传4张图片凭证
|
||||
* 描述:在拒绝退款时,如果有拒绝的图片举证,可以提供 最多上传4张图片,
|
||||
* 传入调用“商户上传反馈图片”接口返回的media_id,最多上传4张图片凭证
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("reject_media_list")
|
||||
@@ -81,7 +83,7 @@ public class UpdateRefundProgressRequest implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:备注
|
||||
* 是否必填:否
|
||||
* 是否必填:否 string(200)
|
||||
* 描述:任何需要向微信支付客服反馈的信息
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
@@ -47,13 +47,23 @@ public class ComplaintNotifyResult implements Serializable {
|
||||
* 是否必填:是
|
||||
* 描述:
|
||||
* 触发本次投诉通知回调的具体动作类型,枚举如下:
|
||||
* 常规通知:
|
||||
* CREATE_COMPLAINT:用户提交投诉
|
||||
* CONTINUE_COMPLAINT:用户继续投诉
|
||||
* USER_RESPONSE:用户新留言
|
||||
* RESPONSE_BY_PLATFORM:平台新留言
|
||||
* SELLER_REFUND:收款方全额退款
|
||||
* SELLER_REFUND:商户发起全额退款
|
||||
* MERCHANT_RESPONSE:商户新回复
|
||||
* MERCHANT_CONFIRM_COMPLETE:商户反馈处理完成
|
||||
* USER_APPLY_PLATFORM_SERVICE:用户申请平台协助
|
||||
* USER_CANCEL_PLATFORM_SERVICE:用户取消平台协助
|
||||
* PLATFORM_SERVICE_FINISHED:客服结束平台协助
|
||||
*
|
||||
* 申请退款单的附加通知:
|
||||
* 以下通知会更新投诉单状态,建议收到后查询投诉单详情。
|
||||
* MERCHANT_APPROVE_REFUND:商户同意退款
|
||||
* MERCHANT_REJECT_REFUND:商户驳回退款
|
||||
* REFUND_SUCCESS:退款到账
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "action_type")
|
||||
|
||||
@@ -250,6 +250,12 @@ public class WxPayUnifiedOrderV3Request implements Serializable {
|
||||
*/
|
||||
@SerializedName(value = "openid")
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 实名支付用户身份标识
|
||||
*/
|
||||
@SerializedName(value = "identity")
|
||||
private Identity identity;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -572,4 +578,36 @@ public class WxPayUnifiedOrderV3Request implements Serializable {
|
||||
@SerializedName(value = "profit_sharing")
|
||||
private Boolean profitSharing;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class Identity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 证件类型
|
||||
* IDCARD:身份证
|
||||
* HONGKONG_MACAO:港澳回乡证
|
||||
* HONGKONG_MACAO_RESIDENT:港澳居住证
|
||||
* TAIWAN_RESIDENT:台湾居住证
|
||||
* FOREIGN_RESIDENT:外国人永居证
|
||||
* OVERSEA_PASSPORT:护照
|
||||
*/
|
||||
@SerializedName(value = "type")
|
||||
private String type;
|
||||
/**
|
||||
* 证件号
|
||||
* 证件号,如身份证号。
|
||||
* 示例值:43102119910910512X
|
||||
*/
|
||||
@SerializedName(value = "number")
|
||||
private String number;
|
||||
/**
|
||||
* 证件姓名。
|
||||
* 示例值:周星星
|
||||
*/
|
||||
@SerializedName(value = "name")
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,17 @@ import com.github.binarywang.wxpay.util.ResourcesUtils;
|
||||
import com.github.binarywang.wxpay.v3.WxPayV3HttpClientBuilder;
|
||||
import com.github.binarywang.wxpay.v3.auth.*;
|
||||
import com.github.binarywang.wxpay.v3.util.PemUtils;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.ssl.SSLContexts;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -16,16 +27,6 @@ import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Base64;
|
||||
import java.util.Optional;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.ssl.SSLContexts;
|
||||
|
||||
/**
|
||||
* 微信支付配置
|
||||
@@ -310,8 +311,8 @@ public class WxPayConfig {
|
||||
PublicKey publicKey = null;
|
||||
if (this.getPublicKeyString() != null || this.getPublicKeyPath() != null || this.publicKeyContent != null) {
|
||||
try (InputStream pubInputStream =
|
||||
this.loadConfigInputStream(this.getPublicKeyString(), this.getPublicKeyPath(),
|
||||
this.publicKeyContent, "publicKeyPath")) {
|
||||
this.loadConfigInputStream(this.getPublicKeyString(), this.getPublicKeyPath(),
|
||||
this.publicKeyContent, "publicKeyPath")) {
|
||||
publicKey = PemUtils.loadPublicKey(pubInputStream);
|
||||
}
|
||||
}
|
||||
@@ -319,16 +320,7 @@ public class WxPayConfig {
|
||||
//构造Http Proxy正向代理
|
||||
WxPayHttpProxy wxPayHttpProxy = getWxPayHttpProxy();
|
||||
|
||||
Verifier certificatesVerifier;
|
||||
if (publicKey == null) {
|
||||
certificatesVerifier =
|
||||
new AutoUpdateCertificatesVerifier(
|
||||
new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
||||
this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
|
||||
this.getPayBaseUrl(), wxPayHttpProxy);
|
||||
} else {
|
||||
certificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
|
||||
}
|
||||
Verifier certificatesVerifier = getVerifier(merchantPrivateKey, wxPayHttpProxy, publicKey);
|
||||
|
||||
WxPayV3HttpClientBuilder wxPayV3HttpClientBuilder = WxPayV3HttpClientBuilder.create()
|
||||
.withMerchant(mchId, certSerialNo, merchantPrivateKey)
|
||||
@@ -354,6 +346,23 @@ public class WxPayConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private Verifier getVerifier(PrivateKey merchantPrivateKey, WxPayHttpProxy wxPayHttpProxy, PublicKey publicKey) {
|
||||
Verifier certificatesVerifier = null;
|
||||
// 如果配置了平台证书,则初始化验证器以备v2版本接口验签(公钥灰度实现)
|
||||
if (this.getPrivateCertPath() != null && this.getPrivateKeyPath() != null) {
|
||||
certificatesVerifier = new AutoUpdateCertificatesVerifier(
|
||||
new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
||||
this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
|
||||
this.getPayBaseUrl(), wxPayHttpProxy);
|
||||
}
|
||||
if (publicKey != null) {
|
||||
Verifier publicCertificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
|
||||
publicCertificatesVerifier.setOtherVerifier(certificatesVerifier);
|
||||
certificatesVerifier = publicCertificatesVerifier;
|
||||
}
|
||||
return certificatesVerifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个WxPayHttpProxy对象
|
||||
*
|
||||
@@ -366,21 +375,32 @@ public class WxPayConfig {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从指定参数加载输入流
|
||||
*
|
||||
* @param configString 证书内容进行Base64加密后的字符串
|
||||
* @param configPath 证书路径
|
||||
* @param configContent 证书内容的字节数组
|
||||
* @param certName 证书的标识
|
||||
* @return 输入流
|
||||
* @throws WxPayException 异常
|
||||
*/
|
||||
private InputStream loadConfigInputStream(String configString, String configPath, byte[] configContent,
|
||||
String fileName) throws WxPayException {
|
||||
InputStream inputStream;
|
||||
String certName) throws WxPayException {
|
||||
if (configContent != null) {
|
||||
inputStream = new ByteArrayInputStream(configContent);
|
||||
} else if (StringUtils.isNotEmpty(configString)) {
|
||||
configContent = Base64.getDecoder().decode(configString);
|
||||
inputStream = new ByteArrayInputStream(configContent);
|
||||
} else {
|
||||
if (StringUtils.isBlank(configPath)) {
|
||||
throw new WxPayException("请确保证书文件地址【" + fileName + "】或者内容已配置");
|
||||
}
|
||||
inputStream = this.loadConfigInputStream(configPath);
|
||||
return new ByteArrayInputStream(configContent);
|
||||
}
|
||||
return inputStream;
|
||||
|
||||
if (StringUtils.isNotEmpty(configString)) {
|
||||
configContent = Base64.getDecoder().decode(configString);
|
||||
return new ByteArrayInputStream(configContent);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(configPath)) {
|
||||
throw new WxPayException(String.format("请确保【%s】的文件地址【%s】存在", certName, configPath));
|
||||
}
|
||||
|
||||
return this.loadConfigInputStream(configPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public interface ComplaintService {
|
||||
/**
|
||||
* <pre>
|
||||
* 商户上传反馈图片API
|
||||
* 文档详见: <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter10_2_10.shtml">...</a>
|
||||
* 文档详见: <a href="https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/images/create-images.html">...</a>
|
||||
* 接口链接:https://api.mch.weixin.qq.com/v3/merchant-service/images/upload
|
||||
* </pre>
|
||||
*
|
||||
@@ -165,7 +165,7 @@ public interface ComplaintService {
|
||||
/**
|
||||
* <pre>
|
||||
* 商户上传反馈图片API
|
||||
* 文档详见: <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter10_2_10.shtml">...</a>
|
||||
* 文档详见: <a href="https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/images/create-images.html">...</a>
|
||||
* 接口链接:https://api.mch.weixin.qq.com/v3/merchant-service/images/upload
|
||||
* </pre>
|
||||
*
|
||||
|
||||
@@ -323,13 +323,13 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
log.debug("微信支付异步通知请求参数:{}", xmlData);
|
||||
WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
|
||||
if (signType == null) {
|
||||
this.switchover(result.getMchId(), result.getAppid());
|
||||
if (result.getSignType() != null) {
|
||||
// 如果解析的通知对象中signType有值,则使用它进行验签
|
||||
signType = result.getSignType();
|
||||
} else if (configMap.get(result.getMchId()).getSignType() != null) {
|
||||
} else if (this.getConfig().getSignType() != null) {
|
||||
// 如果配置中signType有值,则使用它进行验签
|
||||
signType = configMap.get(result.getMchId()).getSignType();
|
||||
this.switchover(result.getMchId(), result.getAppid());
|
||||
signType = this.getConfig().getSignType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,7 +808,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
@Override
|
||||
public <T> T combineTransactions(TradeTypeEnum tradeType, CombineTransactionsRequest request) throws WxPayException {
|
||||
CombineTransactionsResult result = this.combine(tradeType, request);
|
||||
return result.getPayInfo(tradeType, request.getCombineAppid(), request.getCombineAppid(), this.getConfig().getPrivateKey());
|
||||
return result.getPayInfo(tradeType, request.getCombineAppid(), request.getCombineMchid(), this.getConfig().getPrivateKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,6 +100,8 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
|
||||
HttpPost httpPost = this.createHttpPost(url, requestStr);
|
||||
httpPost.addHeader(ACCEPT, APPLICATION_JSON);
|
||||
httpPost.addHeader(CONTENT_TYPE, APPLICATION_JSON);
|
||||
String serialNumber = getWechatpaySerial(getConfig());
|
||||
httpPost.addHeader("Wechatpay-Serial", serialNumber);
|
||||
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
||||
//v3已经改为通过状态码判断200 204 成功
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
@@ -387,10 +389,9 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
|
||||
* @return
|
||||
*/
|
||||
private String getWechatpaySerial(WxPayConfig wxPayConfig) {
|
||||
String serialNumber = wxPayConfig.getVerifier().getValidCertificate().getSerialNumber().toString(16).toUpperCase();
|
||||
if (StringUtils.isNotBlank(wxPayConfig.getPublicKeyId())) {
|
||||
serialNumber = wxPayConfig.getPublicKeyId();
|
||||
return wxPayConfig.getPublicKeyId();
|
||||
}
|
||||
return serialNumber;
|
||||
return wxPayConfig.getVerifier().getValidCertificate().getSerialNumber().toString(16).toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ public class PublicCertificateVerifier implements Verifier{
|
||||
|
||||
private final PublicKey publicKey;
|
||||
|
||||
private Verifier certificateVerifier;
|
||||
|
||||
private final X509PublicCertificate publicCertificate;
|
||||
|
||||
public PublicCertificateVerifier(PublicKey publicKey, String publicId) {
|
||||
@@ -16,8 +18,15 @@ public class PublicCertificateVerifier implements Verifier{
|
||||
this.publicCertificate = new X509PublicCertificate(publicKey, publicId);
|
||||
}
|
||||
|
||||
public void setOtherVerifier(Verifier verifier) {
|
||||
this.certificateVerifier = verifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verify(String serialNumber, byte[] message, String signature) {
|
||||
if (!serialNumber.contains("PUB_KEY_ID") && this.certificateVerifier != null) {
|
||||
return this.certificateVerifier.verify(serialNumber, message, signature);
|
||||
}
|
||||
try {
|
||||
Signature sign = Signature.getInstance("SHA256withRSA");
|
||||
sign.initVerify(publicKey);
|
||||
|
||||
@@ -7,4 +7,6 @@ public interface Verifier {
|
||||
|
||||
|
||||
X509Certificate getValidCertificate();
|
||||
|
||||
default void setOtherVerifier(Verifier verifier) {};
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>4.7.2.B</version>
|
||||
<version>4.7.4.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-qidian</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user