mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2024-12-29 11:29:58 +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");
|
||||
payConfig.setTradeType(tradeType);
|
||||
// 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());
|
||||
} 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());
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||
@Override
|
||||
protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Exception {
|
||||
try {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||
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);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
|
@ -154,9 +154,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||
|
||||
@Override
|
||||
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);
|
||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||
return doParseOrderNotifyV3(body);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
|
@ -188,9 +188,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||
@Override
|
||||
protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable {
|
||||
try {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||
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);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
|
@ -256,9 +256,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||
@Override
|
||||
protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable {
|
||||
try {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||
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);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
|
@ -315,9 +315,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||
|
||||
@Override
|
||||
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);
|
||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3.getKey())) {
|
||||
} else if (Objects.equals(config.getApiVersion(), PayChannelVersion.V3_VERSION.getKey())) {
|
||||
return parseRefundNotifyV3(body);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
|
@ -351,9 +351,9 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||
@Override
|
||||
protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException {
|
||||
try {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2.getKey())) {
|
||||
if (Objects.equals(config.getApiVersion(), PayChannelVersion.V2_VERSION.getKey())) {
|
||||
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);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
|
|
|
@ -94,7 +94,7 @@ public class WxPayClientConfig implements PayClientConfig {
|
|||
|
||||
@Override
|
||||
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)) {
|
||||
throw new ConstraintViolationException(constraintViolations);
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ import lombok.NoArgsConstructor;
|
|||
public enum PayChannelVersion implements SkyeyeEnumClass {
|
||||
|
||||
// <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>
|
||||
V3_PROTOCOL("V3", "V3 协议", true, true);
|
||||
V3_VERSION("V3", "V3 协议", true, true);
|
||||
|
||||
private String key;
|
||||
|
||||
|
|
Loading…
Reference in a new issue