Compare commits
10 Commits
v4.7.9
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bf69cbbc6 | ||
|
|
aa94c5c4d4 | ||
|
|
4e46486f2c | ||
|
|
219a8f4f36 | ||
|
|
cd4317ab3e | ||
|
|
085125960b | ||
|
|
524762704c | ||
|
|
f7a196c129 | ||
|
|
3bf3595dc1 | ||
|
|
4d0617f7bf |
@@ -46,13 +46,20 @@ public class WxPayAutoConfiguration {
|
|||||||
payConfig.setSubMchId(StringUtils.trimToNull(this.properties.getSubMchId()));
|
payConfig.setSubMchId(StringUtils.trimToNull(this.properties.getSubMchId()));
|
||||||
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
|
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
|
||||||
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
|
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
|
||||||
|
payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
|
||||||
//以下是apiv3以及支付分相关
|
//以下是apiv3以及支付分相关
|
||||||
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
|
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
|
||||||
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));
|
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));
|
||||||
|
payConfig.setPayScorePermissionNotifyUrl(StringUtils.trimToNull(this.properties.getPayScorePermissionNotifyUrl()));
|
||||||
payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyPath()));
|
payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyPath()));
|
||||||
payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getPrivateCertPath()));
|
payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getPrivateCertPath()));
|
||||||
payConfig.setCertSerialNo(StringUtils.trimToNull(this.properties.getCertSerialNo()));
|
payConfig.setCertSerialNo(StringUtils.trimToNull(this.properties.getCertSerialNo()));
|
||||||
payConfig.setApiV3Key(StringUtils.trimToNull(this.properties.getApiv3Key()));
|
payConfig.setApiV3Key(StringUtils.trimToNull(this.properties.getApiv3Key()));
|
||||||
|
payConfig.setPublicKeyId(StringUtils.trimToNull(this.properties.getPublicKeyId()));
|
||||||
|
payConfig.setPublicKeyPath(StringUtils.trimToNull(this.properties.getPublicKeyPath()));
|
||||||
|
payConfig.setApiHostUrl(StringUtils.trimToNull(this.properties.getApiHostUrl()));
|
||||||
|
payConfig.setStrictlyNeedWechatPaySerial(this.properties.isStrictlyNeedWechatPaySerial());
|
||||||
|
payConfig.setFullPublicKeyModel(this.properties.isFullPublicKeyModel());
|
||||||
|
|
||||||
wxPayService.setConfig(payConfig);
|
wxPayService.setConfig(payConfig);
|
||||||
return wxPayService;
|
return wxPayService;
|
||||||
|
|||||||
@@ -82,4 +82,40 @@ public class WxPayProperties {
|
|||||||
*/
|
*/
|
||||||
private boolean useSandboxEnv;
|
private boolean useSandboxEnv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付异步回调地址,通知url必须为直接可访问的url,不能携带参数
|
||||||
|
*/
|
||||||
|
private String notifyUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付分授权回调地址
|
||||||
|
*/
|
||||||
|
private String payScorePermissionNotifyUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公钥ID
|
||||||
|
*/
|
||||||
|
private String publicKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pub_key.pem证书文件的绝对路径或者以classpath:开头的类路径.
|
||||||
|
*/
|
||||||
|
private String publicKeyPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义API主机地址,用于替换默认的 https://api.mch.weixin.qq.com
|
||||||
|
* 例如:http://proxy.company.com:8080
|
||||||
|
*/
|
||||||
|
private String apiHostUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否将全部v3接口的请求都添加Wechatpay-Serial请求头,默认不添加
|
||||||
|
*/
|
||||||
|
private boolean strictlyNeedWechatPaySerial = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否完全使用公钥模式(用以微信从平台证书到公钥的灰度切换),默认不使用
|
||||||
|
*/
|
||||||
|
private boolean fullPublicKeyModel = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@
|
|||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
|
<artifactId>httpclient5</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -39,6 +39,11 @@
|
|||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
|
<artifactId>httpclient5</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.binarywang.spring.starter.wxjava.mp.enums.HttpClientType;
|
|||||||
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
|
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
|
||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
|
||||||
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpComponentsImpl;
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceJoddHttpImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceJoddHttpImpl;
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl;
|
||||||
@@ -35,6 +36,9 @@ public class WxMpServiceAutoConfiguration {
|
|||||||
case HttpClient:
|
case HttpClient:
|
||||||
wxMpService = newWxMpServiceHttpClientImpl();
|
wxMpService = newWxMpServiceHttpClientImpl();
|
||||||
break;
|
break;
|
||||||
|
case HttpComponents:
|
||||||
|
wxMpService = newWxMpServiceHttpComponentsImpl();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
wxMpService = newWxMpServiceImpl();
|
wxMpService = newWxMpServiceImpl();
|
||||||
break;
|
break;
|
||||||
@@ -60,4 +64,8 @@ public class WxMpServiceAutoConfiguration {
|
|||||||
return new WxMpServiceJoddHttpImpl();
|
return new WxMpServiceJoddHttpImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WxMpService newWxMpServiceHttpComponentsImpl() {
|
||||||
|
return new WxMpServiceHttpComponentsImpl();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,4 +19,8 @@ public enum HttpClientType {
|
|||||||
* JoddHttp.
|
* JoddHttp.
|
||||||
*/
|
*/
|
||||||
JoddHttp,
|
JoddHttp,
|
||||||
|
/**
|
||||||
|
* HttpComponents (Apache HttpClient 5.x).
|
||||||
|
*/
|
||||||
|
HttpComponents,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public class WxPayAutoConfiguration {
|
|||||||
payConfig.setPublicKeyId(StringUtils.trimToNull(this.properties.getPublicKeyId()));
|
payConfig.setPublicKeyId(StringUtils.trimToNull(this.properties.getPublicKeyId()));
|
||||||
payConfig.setPublicKeyPath(StringUtils.trimToNull(this.properties.getPublicKeyPath()));
|
payConfig.setPublicKeyPath(StringUtils.trimToNull(this.properties.getPublicKeyPath()));
|
||||||
payConfig.setApiHostUrl(StringUtils.trimToNull(this.properties.getApiHostUrl()));
|
payConfig.setApiHostUrl(StringUtils.trimToNull(this.properties.getApiHostUrl()));
|
||||||
|
payConfig.setStrictlyNeedWechatPaySerial(this.properties.isStrictlyNeedWechatPaySerial());
|
||||||
|
payConfig.setFullPublicKeyModel(this.properties.isFullPublicKeyModel());
|
||||||
|
|
||||||
wxPayService.setConfig(payConfig);
|
wxPayService.setConfig(payConfig);
|
||||||
return wxPayService;
|
return wxPayService;
|
||||||
|
|||||||
@@ -106,4 +106,14 @@ public class WxPayProperties {
|
|||||||
*/
|
*/
|
||||||
private String apiHostUrl;
|
private String apiHostUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否将全部v3接口的请求都添加Wechatpay-Serial请求头,默认不添加
|
||||||
|
*/
|
||||||
|
private boolean strictlyNeedWechatPaySerial = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否完全使用公钥模式(用以微信从平台证书到公钥的灰度切换),默认不使用
|
||||||
|
*/
|
||||||
|
private boolean fullPublicKeyModel = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ public class WxChannelServiceOkHttpImpl extends BaseWxChannelServiceImpl<OkHttpC
|
|||||||
this.httpProxy = OkHttpProxyInfo.httpProxy(this.config.getHttpProxyHost(), this.config.getHttpProxyPort(), this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword());
|
this.httpProxy = OkHttpProxyInfo.httpProxy(this.config.getHttpProxyHost(), this.config.getHttpProxyPort(), this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword());
|
||||||
okhttp3.OkHttpClient.Builder clientBuilder = new okhttp3.OkHttpClient.Builder();
|
okhttp3.OkHttpClient.Builder clientBuilder = new okhttp3.OkHttpClient.Builder();
|
||||||
clientBuilder.proxy(this.getRequestHttpProxy().getProxy());
|
clientBuilder.proxy(this.getRequestHttpProxy().getProxy());
|
||||||
clientBuilder.authenticator(new Authenticator() {
|
clientBuilder.proxyAuthenticator(new Authenticator() {
|
||||||
@Override
|
@Override
|
||||||
public Request authenticate(Route route, Response response) throws IOException {
|
public Request authenticate(Route route, Response response) throws IOException {
|
||||||
String credential = Credentials.basic(WxChannelServiceOkHttpImpl.this.httpProxy.getProxyUsername(), WxChannelServiceOkHttpImpl.this.httpProxy.getProxyPassword());
|
String credential = Credentials.basic(WxChannelServiceOkHttpImpl.this.httpProxy.getProxyUsername(), WxChannelServiceOkHttpImpl.this.httpProxy.getProxyPassword());
|
||||||
return response.request().newBuilder().header("Authorization", credential).build();
|
return response.request().newBuilder().header("Proxy-Authorization", credential).build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.httpClient = clientBuilder.build();
|
this.httpClient = clientBuilder.build();
|
||||||
|
|||||||
@@ -86,12 +86,12 @@ public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkH
|
|||||||
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
|
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
|
||||||
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
||||||
//设置授权
|
//设置授权
|
||||||
clientBuilder.authenticator(new Authenticator() {
|
clientBuilder.proxyAuthenticator(new Authenticator() {
|
||||||
@Override
|
@Override
|
||||||
public Request authenticate(Route route, Response response) throws IOException {
|
public Request authenticate(Route route, Response response) throws IOException {
|
||||||
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
||||||
return response.request().newBuilder()
|
return response.request().newBuilder()
|
||||||
.header("Authorization", credential)
|
.header("Proxy-Authorization", credential)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -202,6 +202,12 @@ public class WxCpChatModel implements Serializable {
|
|||||||
@SerializedName("sphfeed")
|
@SerializedName("sphfeed")
|
||||||
private SphFeed sphFeed;
|
private SphFeed sphFeed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 音视频通话消息
|
||||||
|
*/
|
||||||
|
@SerializedName("voiptext")
|
||||||
|
private VoipText voipText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From json wx cp chat model.
|
* From json wx cp chat model.
|
||||||
*
|
*
|
||||||
@@ -1333,4 +1339,40 @@ public class WxCpChatModel implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 音视频通话消息
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public static class VoipText implements Serializable {
|
||||||
|
private static final long serialVersionUID = -5028321625140879571L;
|
||||||
|
|
||||||
|
@SerializedName("callduration")
|
||||||
|
private Integer callDuration;
|
||||||
|
|
||||||
|
@SerializedName("invitetype")
|
||||||
|
private Integer inviteType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From json voip text.
|
||||||
|
*
|
||||||
|
* @param json the json
|
||||||
|
* @return the voip text
|
||||||
|
*/
|
||||||
|
public static VoipText fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.create().fromJson(json, VoipText.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To json string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return WxCpGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ public class WxCpTpServiceOkHttpImpl extends BaseWxCpTpServiceImpl<OkHttpClient,
|
|||||||
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
|
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
|
||||||
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
||||||
//设置授权
|
//设置授权
|
||||||
clientBuilder.authenticator(new Authenticator() {
|
clientBuilder.proxyAuthenticator(new Authenticator() {
|
||||||
@Override
|
@Override
|
||||||
public Request authenticate(Route route, Response response) throws IOException {
|
public Request authenticate(Route route, Response response) throws IOException {
|
||||||
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
||||||
return response.request().newBuilder()
|
return response.request().newBuilder()
|
||||||
.header("Authorization", credential)
|
.header("Proxy-Authorization", credential)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import me.chanjar.weixin.cp.api.WxCpService;
|
|||||||
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult;
|
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult;
|
||||||
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalInfo;
|
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalInfo;
|
||||||
import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest;
|
import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest;
|
||||||
|
import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult;
|
||||||
import me.chanjar.weixin.cp.bean.oa.applydata.ApplyDataContent;
|
import me.chanjar.weixin.cp.bean.oa.applydata.ApplyDataContent;
|
||||||
import me.chanjar.weixin.cp.bean.oa.applydata.ContentValue;
|
import me.chanjar.weixin.cp.bean.oa.applydata.ContentValue;
|
||||||
|
|
||||||
@@ -86,14 +87,14 @@ public class WxCpApprovalWorkflowDemo {
|
|||||||
|
|
||||||
System.out.println("审批单号: " + detail.getSpNo());
|
System.out.println("审批单号: " + detail.getSpNo());
|
||||||
System.out.println("审批名称: " + detail.getSpName());
|
System.out.println("审批名称: " + detail.getSpName());
|
||||||
System.out.println("审批状态: " + detail.getSpStatus().getCode());
|
System.out.println("审批状态: " + detail.getSpStatus());
|
||||||
System.out.println("申请人: " + detail.getApplyer().getUserId());
|
System.out.println("申请人: " + detail.getApplier().getUserId());
|
||||||
System.out.println("申请时间: " + detail.getApplyTime());
|
System.out.println("申请时间: " + detail.getApplyTime());
|
||||||
|
|
||||||
// 打印审批记录
|
// 打印审批记录
|
||||||
if (detail.getSpRecord() != null) {
|
if (detail.getSpRecords() != null) {
|
||||||
detail.getSpRecord().forEach(record -> {
|
Arrays.stream(detail.getSpRecords()).forEach(record -> {
|
||||||
System.out.println("审批节点状态: " + record.getSpStatus());
|
System.out.println("审批节点状态: " + record.getStatus());
|
||||||
System.out.println("审批人: " + record.getDetails());
|
System.out.println("审批人: " + record.getDetails());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,7 @@ public class WxCpApprovalWorkflowDemo {
|
|||||||
WxCpApprovalInfo approvalInfo = wxCpService.getOaService()
|
WxCpApprovalInfo approvalInfo = wxCpService.getOaService()
|
||||||
.getApprovalInfo(startTime, endTime, "0", 100, null);
|
.getApprovalInfo(startTime, endTime, "0", 100, null);
|
||||||
|
|
||||||
System.out.println("获取到的审批单数量: " + approvalInfo.getCount());
|
System.out.println("获取到的审批单数量: " + (approvalInfo.getSpNoList() != null ? approvalInfo.getSpNoList().size() : 0));
|
||||||
|
|
||||||
// 遍历审批单号
|
// 遍历审批单号
|
||||||
if (approvalInfo.getSpNoList() != null) {
|
if (approvalInfo.getSpNoList() != null) {
|
||||||
@@ -130,7 +131,7 @@ public class WxCpApprovalWorkflowDemo {
|
|||||||
public void templateManagement() throws Exception {
|
public void templateManagement() throws Exception {
|
||||||
// 获取模板详情
|
// 获取模板详情
|
||||||
String templateId = "3Tka1eD6v6JfzhDMqPd3aMkFdxqtJMc2ZRioUBGCNS";
|
String templateId = "3Tka1eD6v6JfzhDMqPd3aMkFdxqtJMc2ZRioUBGCNS";
|
||||||
var templateResult = wxCpService.getOaService().getTemplateDetail(templateId);
|
WxCpOaApprovalTemplateResult templateResult = wxCpService.getOaService().getTemplateDetail(templateId);
|
||||||
|
|
||||||
System.out.println("模板名称: " + templateResult.getTemplateNames());
|
System.out.println("模板名称: " + templateResult.getTemplateNames());
|
||||||
System.out.println("模板内容: " + templateResult.getTemplateContent());
|
System.out.println("模板内容: " + templateResult.getTemplateContent());
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cn.binarywang.wx.miniapp.api;
|
package cn.binarywang.wx.miniapp.api;
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.bean.WxMaCode2VerifyInfoResult;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
||||||
@@ -87,4 +88,18 @@ public interface WxMaUserService {
|
|||||||
* @return .
|
* @return .
|
||||||
*/
|
*/
|
||||||
boolean checkUserInfo(String sessionKey, String rawData, String signature);
|
boolean checkUserInfo(String sessionKey, String rawData, String signature);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多端登录验证接口.
|
||||||
|
* <p>
|
||||||
|
* 通过 code 换取用户登录态信息,用于多端登录场景(如手表端)。
|
||||||
|
* </p>
|
||||||
|
* 文档地址:<a href="https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/openapi/code2Verifyinfo.html">多端登录</a>
|
||||||
|
*
|
||||||
|
* @param code 登录时获取的 code
|
||||||
|
* @param checkcode 手表授权页面返回的 checkcode
|
||||||
|
* @return 登录验证结果,包含 session_key、openid、unionid 和 is_limit 字段
|
||||||
|
* @throws WxErrorException 调用微信接口失败时抛出
|
||||||
|
*/
|
||||||
|
WxMaCode2VerifyInfoResult getCode2VerifyInfo(String code, String checkcode) throws WxErrorException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -912,6 +912,10 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
|||||||
String rndStr = UUID.randomUUID().toString().replace("-", "").substring(0, 30);
|
String rndStr = UUID.randomUUID().toString().replace("-", "").substring(0, 30);
|
||||||
String aesKey = this.getWxMaConfig().getApiSignatureAesKey();
|
String aesKey = this.getWxMaConfig().getApiSignatureAesKey();
|
||||||
String aesKeySn = this.getWxMaConfig().getApiSignatureAesKeySn();
|
String aesKeySn = this.getWxMaConfig().getApiSignatureAesKeySn();
|
||||||
|
String rsaKeySn = this.getWxMaConfig().getApiSignatureRsaPrivateKeySn();
|
||||||
|
if (rsaKeySn == null || rsaKeySn.isEmpty()) {
|
||||||
|
throw new SecurityException("ApiSignatureRsaPrivateKeySn不能为空,请检查配置");
|
||||||
|
}
|
||||||
|
|
||||||
jsonObject.addProperty("_n", rndStr);
|
jsonObject.addProperty("_n", rndStr);
|
||||||
jsonObject.addProperty("_appid", appId);
|
jsonObject.addProperty("_appid", appId);
|
||||||
@@ -956,7 +960,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
|||||||
String requestJson = reqData.toString();
|
String requestJson = reqData.toString();
|
||||||
|
|
||||||
// 计算签名 RSA
|
// 计算签名 RSA
|
||||||
String payload = urlPath + "\n" + appId + "\n" + timestamp + "\n" + requestJson;
|
String payload = urlPath + "\n" + appId + "\n" + timestamp + "\n" + rsaKeySn + "\n" + requestJson;
|
||||||
byte[] dataBuffer = payload.getBytes(StandardCharsets.UTF_8);
|
byte[] dataBuffer = payload.getBytes(StandardCharsets.UTF_8);
|
||||||
RSAPrivateKey priKey;
|
RSAPrivateKey priKey;
|
||||||
try {
|
try {
|
||||||
@@ -985,6 +989,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
|||||||
header.put("Wechatmp-Signature", signatureString);
|
header.put("Wechatmp-Signature", signatureString);
|
||||||
header.put("Wechatmp-Appid", appId);
|
header.put("Wechatmp-Appid", appId);
|
||||||
header.put("Wechatmp-TimeStamp", String.valueOf(timestamp));
|
header.put("Wechatmp-TimeStamp", String.valueOf(timestamp));
|
||||||
|
header.put("Wechatmp-Serial", rsaKeySn);
|
||||||
log.debug("发送请求uri:{}, headers:{}, postData:{}", url, header, requestJson);
|
log.debug("发送请求uri:{}, headers:{}, postData:{}", url, header, requestJson);
|
||||||
WxMaApiResponse response =
|
WxMaApiResponse response =
|
||||||
this.execute(ApiSignaturePostRequestExecutor.create(this), url, header, requestJson);
|
this.execute(ApiSignaturePostRequestExecutor.create(this), url, header, requestJson);
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ public class WxMaServiceOkHttpImpl extends BaseWxMaServiceImpl<OkHttpClient, OkH
|
|||||||
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
|
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
|
||||||
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
||||||
//设置授权
|
//设置授权
|
||||||
clientBuilder.authenticator(new Authenticator() {
|
clientBuilder.proxyAuthenticator(new Authenticator() {
|
||||||
@Override
|
@Override
|
||||||
public Request authenticate(Route route, Response response) throws IOException {
|
public Request authenticate(Route route, Response response) throws IOException {
|
||||||
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
||||||
return response.request().newBuilder()
|
return response.request().newBuilder()
|
||||||
.header("Authorization", credential)
|
.header("Proxy-Authorization", credential)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.binarywang.wx.miniapp.api.impl;
|
|||||||
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaUserService;
|
import cn.binarywang.wx.miniapp.api.WxMaUserService;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.WxMaCode2VerifyInfoResult;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
||||||
@@ -18,6 +19,7 @@ import org.apache.commons.codec.digest.DigestUtils;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.CODE_2_VERIFY_INFO_URL;
|
||||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.GET_PHONE_NUMBER_URL;
|
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.GET_PHONE_NUMBER_URL;
|
||||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.SET_USER_STORAGE;
|
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.SET_USER_STORAGE;
|
||||||
|
|
||||||
@@ -86,4 +88,13 @@ public class WxMaUserServiceImpl implements WxMaUserService {
|
|||||||
return generatedSignature.equals(signature);
|
return generatedSignature.equals(signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxMaCode2VerifyInfoResult getCode2VerifyInfo(String code, String checkcode) throws WxErrorException {
|
||||||
|
JsonObject param = new JsonObject();
|
||||||
|
param.addProperty("code", code);
|
||||||
|
param.addProperty("checkcode", checkcode);
|
||||||
|
String responseContent = this.service.post(CODE_2_VERIFY_INFO_URL, param.toString());
|
||||||
|
return WxMaCode2VerifyInfoResult.fromJson(responseContent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.binarywang.wx.miniapp.bean;
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 多端登录验证接口的响应
|
||||||
|
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/openapi/code2Verifyinfo.html
|
||||||
|
*
|
||||||
|
* 微信返回报文:{"errcode": 0, "errmsg": "ok", "session_key":"xxx", "openid":"xxx", "unionid":"xxx", "is_limit": false}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class WxMaCode2VerifyInfoResult implements Serializable {
|
||||||
|
private static final long serialVersionUID = -2468325025088437364L;
|
||||||
|
|
||||||
|
@SerializedName("session_key")
|
||||||
|
private String sessionKey;
|
||||||
|
|
||||||
|
@SerializedName("openid")
|
||||||
|
private String openid;
|
||||||
|
|
||||||
|
@SerializedName("unionid")
|
||||||
|
private String unionid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为受限用户
|
||||||
|
*/
|
||||||
|
@SerializedName("is_limit")
|
||||||
|
private Boolean isLimit;
|
||||||
|
|
||||||
|
public static WxMaCode2VerifyInfoResult fromJson(String json) {
|
||||||
|
return WxMaGsonBuilder.create().fromJson(json, WxMaCode2VerifyInfoResult.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -364,6 +364,8 @@ public class WxMaApiUrlConstants {
|
|||||||
String SET_USER_STORAGE =
|
String SET_USER_STORAGE =
|
||||||
"https://api.weixin.qq.com/wxa/set_user_storage?appid=%s&signature=%s&openid=%s&sig_method=%s";
|
"https://api.weixin.qq.com/wxa/set_user_storage?appid=%s&signature=%s&openid=%s&sig_method=%s";
|
||||||
String GET_PHONE_NUMBER_URL = "https://api.weixin.qq.com/wxa/business/getuserphonenumber";
|
String GET_PHONE_NUMBER_URL = "https://api.weixin.qq.com/wxa/business/getuserphonenumber";
|
||||||
|
/** 多端登录验证接口 */
|
||||||
|
String CODE_2_VERIFY_INFO_URL = "https://api.weixin.qq.com/wxa/sec/checkcode2verifyinfo";
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Ocr {
|
public interface Ocr {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public interface BusinessOperationTransferService {
|
|||||||
* 发起运营工具商家转账
|
* 发起运营工具商家转账
|
||||||
*
|
*
|
||||||
* 请求方式:POST(HTTPS)
|
* 请求方式:POST(HTTPS)
|
||||||
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills
|
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills
|
||||||
*
|
*
|
||||||
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
||||||
* </pre>
|
* </pre>
|
||||||
@@ -37,7 +37,7 @@ public interface BusinessOperationTransferService {
|
|||||||
* 查询运营工具转账结果
|
* 查询运营工具转账结果
|
||||||
*
|
*
|
||||||
* 请求方式:GET(HTTPS)
|
* 请求方式:GET(HTTPS)
|
||||||
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
|
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
|
||||||
*
|
*
|
||||||
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
||||||
* </pre>
|
* </pre>
|
||||||
@@ -53,7 +53,7 @@ public interface BusinessOperationTransferService {
|
|||||||
* 通过商户单号查询运营工具转账结果
|
* 通过商户单号查询运营工具转账结果
|
||||||
*
|
*
|
||||||
* 请求方式:GET(HTTPS)
|
* 请求方式:GET(HTTPS)
|
||||||
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
|
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
|
||||||
*
|
*
|
||||||
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
||||||
* </pre>
|
* </pre>
|
||||||
@@ -69,7 +69,7 @@ public interface BusinessOperationTransferService {
|
|||||||
* 通过微信转账单号查询运营工具转账结果
|
* 通过微信转账单号查询运营工具转账结果
|
||||||
*
|
*
|
||||||
* 请求方式:GET(HTTPS)
|
* 请求方式:GET(HTTPS)
|
||||||
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills/transfer-bill-no/{transfer_bill_no}
|
* 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills/transfer-bill-no/{transfer_bill_no}
|
||||||
*
|
*
|
||||||
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012711988">运营工具-商家转账API</a>
|
||||||
* </pre>
|
* </pre>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class BusinessOperationTransferServiceImpl implements BusinessOperationTr
|
|||||||
request.setAppid(this.wxPayService.getConfig().getAppId());
|
request.setAppid(this.wxPayService.getConfig().getAppId());
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = String.format("%s/v3/fund-app/operation/mch-transfer/transfer-bills", this.wxPayService.getPayBaseUrl());
|
String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills", this.wxPayService.getPayBaseUrl());
|
||||||
|
|
||||||
// 如果传入了用户姓名,需要进行RSA加密
|
// 如果传入了用户姓名,需要进行RSA加密
|
||||||
if (StringUtils.isNotEmpty(request.getUserName())) {
|
if (StringUtils.isNotEmpty(request.getUserName())) {
|
||||||
@@ -58,7 +58,7 @@ public class BusinessOperationTransferServiceImpl implements BusinessOperationTr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BusinessOperationTransferQueryResult queryOperationTransferByOutBillNo(String outBillNo) throws WxPayException {
|
public BusinessOperationTransferQueryResult queryOperationTransferByOutBillNo(String outBillNo) throws WxPayException {
|
||||||
String url = String.format("%s/v3/fund-app/operation/mch-transfer/transfer-bills/out-bill-no/%s",
|
String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/%s",
|
||||||
this.wxPayService.getPayBaseUrl(), outBillNo);
|
this.wxPayService.getPayBaseUrl(), outBillNo);
|
||||||
String response = wxPayService.getV3(url);
|
String response = wxPayService.getV3(url);
|
||||||
return GSON.fromJson(response, BusinessOperationTransferQueryResult.class);
|
return GSON.fromJson(response, BusinessOperationTransferQueryResult.class);
|
||||||
@@ -66,7 +66,7 @@ public class BusinessOperationTransferServiceImpl implements BusinessOperationTr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BusinessOperationTransferQueryResult queryOperationTransferByTransferBillNo(String transferBillNo) throws WxPayException {
|
public BusinessOperationTransferQueryResult queryOperationTransferByTransferBillNo(String transferBillNo) throws WxPayException {
|
||||||
String url = String.format("%s/v3/fund-app/operation/mch-transfer/transfer-bills/transfer-bill-no/%s",
|
String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills/transfer-bill-no/%s",
|
||||||
this.wxPayService.getPayBaseUrl(), transferBillNo);
|
this.wxPayService.getPayBaseUrl(), transferBillNo);
|
||||||
String response = wxPayService.getV3(url);
|
String response = wxPayService.getV3(url);
|
||||||
return GSON.fromJson(response, BusinessOperationTransferQueryResult.class);
|
return GSON.fromJson(response, BusinessOperationTransferQueryResult.class);
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public class PublicCertificateVerifier implements Verifier{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean verify(String serialNumber, byte[] message, String signature) {
|
public boolean verify(String serialNumber, byte[] message, String signature) {
|
||||||
// 如果序列号不包含"PUB_KEY_ID"且有证书验证器,先尝试证书验证
|
// 如果序列号不为空且不包含"PUB_KEY_ID"且有证书验证器,先尝试证书验证
|
||||||
if (!serialNumber.contains("PUB_KEY_ID") && this.certificateVerifier != null) {
|
if (serialNumber != null && !serialNumber.contains("PUB_KEY_ID") && this.certificateVerifier != null) {
|
||||||
try {
|
try {
|
||||||
if (this.certificateVerifier.verify(serialNumber, message, signature)) {
|
if (this.certificateVerifier.verify(serialNumber, message, signature)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ public class WxQidianServiceOkHttpImpl extends BaseWxQidianServiceImpl<OkHttpCli
|
|||||||
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
clientBuilder.proxy(getRequestHttpProxy().getProxy());
|
||||||
|
|
||||||
// 设置授权
|
// 设置授权
|
||||||
clientBuilder.authenticator(new Authenticator() {
|
clientBuilder.proxyAuthenticator(new Authenticator() {
|
||||||
@Override
|
@Override
|
||||||
public Request authenticate(Route route, Response response) throws IOException {
|
public Request authenticate(Route route, Response response) throws IOException {
|
||||||
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword());
|
||||||
return response.request().newBuilder().header("Authorization", credential).build();
|
return response.request().newBuilder().header("Proxy-Authorization", credential).build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
httpClient = clientBuilder.build();
|
httpClient = clientBuilder.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user