11 Commits

50 changed files with 339 additions and 58 deletions

View File

@@ -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

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
<packaging>pom</packaging>
<name>WxJava - Weixin/Wechat Java SDK</name>
<description>微信开发Java SDK</description>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<packaging>pom</packaging>
<artifactId>wx-java-solon-plugins</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<packaging>pom</packaging>
<artifactId>wx-java-spring-boot-starters</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-graal</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-java-channel</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-java-common</artifactId>

View File

@@ -59,7 +59,7 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
* 设置为负数是使用系统默认设置(非3000ms的默认值,而是httpClient的默认设置).
* </p>
*/
private int connectionRequestTimeout = -1;
private int connectionRequestTimeout = 3000;
/**
* 建立链接的超时时间,默认为5000ms.由于是在链接池获取链接,此设置应该并不起什么作用

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-java-cp</artifactId>

View File

@@ -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;
}

View File

@@ -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;
/**
* 接待人员管理
* 获取某个客服帐号的接待人员列表

View File

@@ -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());
}
}

View File

@@ -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);
}

View File

@@ -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
}
}
}
}

View File

@@ -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";
}
/**

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-java-miniapp</artifactId>

View File

@@ -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));

View File

@@ -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";

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-java-mp</artifactId>

View File

@@ -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";

View File

@@ -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);
}
}

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-java-open</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -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;
}
}

View File

@@ -347,10 +347,14 @@ public class WxPayConfig {
}
private Verifier getVerifier(PrivateKey merchantPrivateKey, WxPayHttpProxy wxPayHttpProxy, PublicKey publicKey) {
Verifier certificatesVerifier = new AutoUpdateCertificatesVerifier(
new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
this.getPayBaseUrl(), wxPayHttpProxy);
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);

View File

@@ -323,14 +323,13 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
log.debug("微信支付异步通知请求参数:{}", xmlData);
WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
if (signType == null) {
String configKey = this.getConfigKey(result.getMchId(), result.getAppid());
this.switchover(result.getMchId(), result.getAppid());
if (result.getSignType() != null) {
// 如果解析的通知对象中signType有值则使用它进行验签
signType = result.getSignType();
} else if (configMap.get(configKey).getSignType() != null) {
} else if (this.getConfig().getSignType() != null) {
// 如果配置中signType有值则使用它进行验签
signType = configMap.get(configKey).getSignType();
this.switchover(result.getMchId(), result.getAppid());
signType = this.getConfig().getSignType();
}
}

View File

@@ -24,7 +24,7 @@ public class PublicCertificateVerifier implements Verifier{
@Override
public boolean verify(String serialNumber, byte[] message, String signature) {
if (!serialNumber.contains("PUB_KEY_ID")) {
if (!serialNumber.contains("PUB_KEY_ID") && this.certificateVerifier != null) {
return this.certificateVerifier.verify(serialNumber, message, signature);
}
try {

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.3.B</version>
<version>4.7.4.B</version>
</parent>
<artifactId>weixin-java-qidian</artifactId>