Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions spring-boot-starters/wx-java-pay-spring-boot-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</dependency>
```
2. 添加配置(application.yml)
###### 1)V2版本
```yml
wx:
pay:
Expand All @@ -18,6 +19,17 @@ wx:
subMchId:
keyPath:
```
###### 2)V3版本
```yml
wx:
pay:
appId: xxxxxxxxxxx
mchId: 15xxxxxxxxx #商户id
apiV3Key: Dc1DBwSc094jACxxxxxxxxxxxxxxx #V3密钥
certSerialNo: 62C6CEAA360BCxxxxxxxxxxxxxxx
privateKeyPath: classpath:cert/apiclient_key.pem #apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径
privateCertPath: classpath:cert/apiclient_cert.pem #apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径
```



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult;

import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -224,9 +225,25 @@ public interface WxCpUserService {
* userid转换为open_userid
* 将自建应用或代开发应用获取的userid转换为第三方应用的userid
* https://developer.work.weixin.qq.com/document/path/95603
*
* @param useridList
* @return the WxCpUseridToOpenUseridResult
* @throws WxErrorException
*/
WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridList) throws WxErrorException;

/**
* 获取成员ID列表
* 获取企业成员的userid与对应的部门ID列表,预计于2022年8月8号发布。若需要获取其他字段,参见「适配建议」。
* <p>
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token=ACCESS_TOKEN
*
* @param cursor
* @param limit
* @return
* @throws WxErrorException
*/
WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import org.apache.commons.lang3.time.FastDateFormat;

Expand Down Expand Up @@ -231,7 +231,7 @@ public Integer getActiveStat(Date date) throws WxErrorException {
public WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridList) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray();
for(String userid:useridList){
for (String userid : useridList) {
jsonArray.add(userid);
}
jsonObject.add("userid_list", jsonArray);
Expand All @@ -240,4 +240,19 @@ public WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridL
return WxCpUseridToOpenUseridResult.fromJson(responseContent);
}

@Override
public WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException {
String apiUrl = this.mainService.getWxCpConfigStorage().getApiUrl(USER_LIST_ID);
JsonObject jsonObject = new JsonObject();
if (cursor != null) {
jsonObject.addProperty("cursor", cursor);
}
if (limit != null) {
jsonObject.addProperty("limit", limit);
}
String responseContent = this.mainService.post(apiUrl, jsonObject.toString());
return WxCpDeptUserResult.fromJson(responseContent);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package me.chanjar.weixin.cp.bean.user;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.Getter;
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;

/**
* 获取成员ID列表返回参数
*
* @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a>
* @date 2022/08/09
*/
@Data
public class WxCpDeptUserResult extends WxCpBaseResp {
private static final long serialVersionUID = 1420065684270213578L;

@SerializedName("next_cursor")
private String nextCursor;

@SerializedName("dept_user")
private List<DeptUserList> deptUser;

@Getter
@Setter
public static class DeptUserList implements Serializable {
private static final long serialVersionUID = 1420065684270213578L;

@SerializedName("userid")
private String userId;

@SerializedName("department")
private Long department;

public static DeptUserList fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, DeptUserList.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}

public static WxCpDeptUserResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpDeptUserResult.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ interface User {
String GET_JOIN_QR_CODE = "/cgi-bin/corp/get_join_qrcode?size_type=";
String GET_ACTIVE_STAT = "/cgi-bin/user/get_active_stat";
String USERID_TO_OPEN_USERID = "/cgi-bin/batch/userid_to_openuserid";

String USER_LIST_ID = "/cgi-bin/user/list_id";
}

interface ExternalContact {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public void testDelete() throws Exception {
this.wxCpService.getDepartmentService().delete(this.depart.getId());
}

/**
* 获取子部门ID列表
* https://developer.work.weixin.qq.com/document/path/95350
*
* @param id
* @throws WxErrorException
*/
@Test(dataProvider = "departIds")
public void testSimpleList(Long id) throws WxErrorException {
System.out.println("=================获取子部门ID列表");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package me.chanjar.weixin.cp.api.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.testng.annotations.*;

import com.google.common.collect.Lists;
import com.google.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.Gender;
import me.chanjar.weixin.cp.bean.WxCpInviteResult;
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;

import static org.testng.Assert.*;
import java.util.Date;
import java.util.List;
import java.util.Map;

import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;

/**
* <pre>
Expand All @@ -26,6 +29,7 @@
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Slf4j
@Guice(modules = ApiTestModule.class)
public class WxCpUserServiceImplTest {
@Inject
Expand Down Expand Up @@ -129,4 +133,20 @@ public void testGetActiveStat() throws WxErrorException {
System.out.printf("active stat: %d", activeStat);
assertNotNull(activeStat);
}

/**
* 获取成员ID列表
* 获取企业成员的userid与对应的部门ID列表,预计于2022年8月8号发布。若需要获取其他字段,参见「适配建议」。
* <p>
* https://developer.work.weixin.qq.com/document/40856
*
* @throws WxErrorException
*/
@Test
public void testGetUserListId() throws WxErrorException {
WxCpDeptUserResult result = this.wxCpService.getUserService().getUserListId(null, 10);
log.info("返回结果为:{}", result.toJson());
assertNotNull(result);
}

}
25 changes: 13 additions & 12 deletions weixin-java-pay/src/test/resources/test-config.sample.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<xml>
<appId>公众号appid</appId>
<mchId>微信商户平台ID</mchId>
<mchKey>商户平台设置的API密钥</mchKey>
<!---
以下为官网文档所提供样例参数,仅供部分接口测试使用
<appId>wxd930ea5d5a258f4f</appId>
<mchId>10000100</mchId>
<mchKey>192006250b4c09247ec02edce69f6a2d</mchKey>
-->
以下为官网文档所提供样例参数,仅供部分接口测试使用
<appId>wxd930ea5d5a258f4f</appId>
<mchId>10000100</mchId>
<mchKey>192006250b4c09247ec02edce69f6a2d</mchKey>
-->
<!-- v2版本 -->
<mchKey>商户平台设置的API密钥</mchKey>
<keyPath>商户平台的证书文件地址</keyPath>
<openid>某个openId</openid>

<!--
apiv3 模式下所需配置
<privateKeyPath>apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径.</privateKeyPath>
<privateCertPath>apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径.</privateCertPath>
<!-- v3版本 模式下所需配置 -->
<apiV3Key> apiV3 秘钥值.</apiV3Key>
<certSerialNo>apiV3 证书序列号值</certSerialNo>
-->
<privateKeyPath>apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径.</privateKeyPath>
<privateCertPath>apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径.</privateCertPath>

<!-- other配置 -->
<openid>某个openId</openid>
</xml>