mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-03 04:13:37 +08:00
🎨 完善微信支付部分文档
This commit is contained in:
parent
05f0fa2ac3
commit
52471fce89
@ -8,6 +8,7 @@
|
||||
</dependency>
|
||||
```
|
||||
2. 添加配置(application.yml)
|
||||
###### 1)V2版本
|
||||
```yml
|
||||
wx:
|
||||
pay:
|
||||
@ -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:开头的类路径
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ import me.chanjar.weixin.cp.bean.WxCpInviteResult;
|
||||
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;
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import me.chanjar.weixin.cp.bean.WxCpInviteResult;
|
||||
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;
|
||||
|
||||
@ -231,7 +231,7 @@ public class WxCpUserServiceImpl implements WxCpUserService {
|
||||
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);
|
||||
@ -240,4 +240,19 @@ public class WxCpUserServiceImpl implements WxCpUserService {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -325,6 +325,8 @@ public interface WxCpApiPathConsts {
|
||||
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 {
|
||||
|
@ -72,6 +72,13 @@ public class WxCpDepartmentServiceImplTest {
|
||||
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列表");
|
||||
|
@ -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>
|
||||
@ -26,6 +29,7 @@ import static org.testng.Assert.*;
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxCpUserServiceImplTest {
|
||||
@Inject
|
||||
@ -129,4 +133,20 @@ public class WxCpUserServiceImplTest {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user