mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
#123 支持微信支付的服务商功能
This commit is contained in:
@@ -80,6 +80,16 @@ public interface WxMpConfigStorage {
|
||||
|
||||
String getAppId();
|
||||
|
||||
/**
|
||||
* 服务商模式下的子商户公众账号ID
|
||||
*/
|
||||
String getSubAppId();
|
||||
|
||||
/**
|
||||
* 服务商模式下的子商户号
|
||||
*/
|
||||
String getSubMchId();
|
||||
|
||||
String getSecret();
|
||||
|
||||
String getPartnerId();
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
|
||||
|
||||
protected volatile String appId;
|
||||
protected volatile String subAppId;
|
||||
protected volatile String subMchId;
|
||||
protected volatile String secret;
|
||||
protected volatile String partnerId;
|
||||
protected volatile String partnerKey;
|
||||
@@ -349,4 +351,22 @@ public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
|
||||
public boolean useSandboxForWxPay() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubAppId() {
|
||||
return subAppId;
|
||||
}
|
||||
|
||||
public void setSubAppId(String subAppId) {
|
||||
this.subAppId = subAppId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubMchId() {
|
||||
return subMchId;
|
||||
}
|
||||
|
||||
public void setSubMchId(String subMchId) {
|
||||
this.subMchId = subMchId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,9 +268,19 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
||||
if (StringUtils.isBlank(request.getAppid())) {
|
||||
request.setAppid(getConfig().getAppId());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(request.getMchId())) {
|
||||
request.setMchId(getConfig().getPartnerId());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(request.getSubAppId())) {
|
||||
request.setAppid(getConfig().getSubAppId());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(request.getSubMchId())) {
|
||||
request.setMchId(getConfig().getSubMchId());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(request.getNonceStr())) {
|
||||
request.setNonceStr(String.valueOf(System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user