mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-01-01 12:55:05 +08:00
feat: 枚举类修改
This commit is contained in:
parent
011401e7be
commit
fa68a440d3
3 changed files with 17 additions and 17 deletions
|
@ -68,9 +68,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
BeanUtil.copyProperties(config, payConfig, "keyContent", "privateKeyContent");
|
BeanUtil.copyProperties(config, payConfig, "keyContent", "privateKeyContent");
|
||||||
payConfig.setTradeType(tradeType);
|
payConfig.setTradeType(tradeType);
|
||||||
// weixin-pay-java 无法设置内容,只允许读取文件,所以这里要创建临时文件来解决
|
// weixin-pay-java 无法设置内容,只允许读取文件,所以这里要创建临时文件来解决
|
||||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||||
payConfig.setKeyPath(FileUtil.createTempFile(Base64.decode(config.getKeyContent())).getPath());
|
payConfig.setKeyPath(FileUtil.createTempFile(Base64.decode(config.getKeyContent())).getPath());
|
||||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||||
payConfig.setPrivateKeyPath(FileUtil.createTempFile(config.getPrivateKeyContent()).getPath());
|
payConfig.setPrivateKeyPath(FileUtil.createTempFile(config.getPrivateKeyContent()).getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,9 +84,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
@Override
|
@Override
|
||||||
protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Exception {
|
protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Exception {
|
||||||
try {
|
try {
|
||||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||||
return doUnifiedOrderV2(reqDTO);
|
return doUnifiedOrderV2(reqDTO);
|
||||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||||
return doUnifiedOrderV3(reqDTO);
|
return doUnifiedOrderV3(reqDTO);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
@ -154,9 +154,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PayOrderRespDTO doParseOrderNotify(Map<String, String> params, String body) throws WxPayException {
|
public PayOrderRespDTO doParseOrderNotify(Map<String, String> params, String body) throws WxPayException {
|
||||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||||
return doParseOrderNotifyV2(body);
|
return doParseOrderNotifyV2(body);
|
||||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||||
return doParseOrderNotifyV3(body);
|
return doParseOrderNotifyV3(body);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
@ -188,9 +188,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
@Override
|
@Override
|
||||||
protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable {
|
protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable {
|
||||||
try {
|
try {
|
||||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||||
return doGetOrderV2(outTradeNo);
|
return doGetOrderV2(outTradeNo);
|
||||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||||
return doGetOrderV3(outTradeNo);
|
return doGetOrderV3(outTradeNo);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
@ -256,9 +256,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
@Override
|
@Override
|
||||||
protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable {
|
protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable {
|
||||||
try {
|
try {
|
||||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||||
return doUnifiedRefundV2(reqDTO);
|
return doUnifiedRefundV2(reqDTO);
|
||||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||||
return doUnifiedRefundV3(reqDTO);
|
return doUnifiedRefundV3(reqDTO);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
@ -315,9 +315,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PayRefundRespDTO doParseRefundNotify(Map<String, String> params, String body) throws WxPayException {
|
public PayRefundRespDTO doParseRefundNotify(Map<String, String> params, String body) throws WxPayException {
|
||||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||||
return doParseRefundNotifyV2(body);
|
return doParseRefundNotifyV2(body);
|
||||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||||
return parseRefundNotifyV3(body);
|
return parseRefundNotifyV3(body);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
@ -351,9 +351,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
@Override
|
@Override
|
||||||
protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException {
|
protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException {
|
||||||
try {
|
try {
|
||||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||||
return doGetRefundV2(outTradeNo, outRefundNo);
|
return doGetRefundV2(outTradeNo, outRefundNo);
|
||||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||||
return doGetRefundV3(outTradeNo, outRefundNo);
|
return doGetRefundV3(outTradeNo, outRefundNo);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class WxPayClientConfig implements PayClientConfig {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(Validator validator) {
|
public void validate(Validator validator) {
|
||||||
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(this, PayChannelVersion.V2.getKey().equals(this.getApiVersion()) ? V2.class : V3.class);
|
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(this, PayChannelVersion.V2_VERSION.getKey().equals(this.getApiVersion()) ? V2.class : V3.class);
|
||||||
if (CollUtil.isNotEmpty(constraintViolations)) {
|
if (CollUtil.isNotEmpty(constraintViolations)) {
|
||||||
throw new ConstraintViolationException(constraintViolations);
|
throw new ConstraintViolationException(constraintViolations);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ import lombok.NoArgsConstructor;
|
||||||
public enum PayChannelVersion implements SkyeyeEnumClass {
|
public enum PayChannelVersion implements SkyeyeEnumClass {
|
||||||
|
|
||||||
// <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_1">V2 协议说明</a>
|
// <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_1">V2 协议说明</a>
|
||||||
V2_PROTOCOL("V2", "V2 协议", true, false),
|
V2_VERSION("V2", "V2 协议", true, false),
|
||||||
// <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml">V3 协议说明</a>
|
// <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml">V3 协议说明</a>
|
||||||
V3_PROTOCOL("V3", "V3 协议", true, true);
|
V3_VERSION("V3", "V3 协议", true, true);
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue