From e9e44deb4220fb247f7b654d9ff2b6568789d564 Mon Sep 17 00:00:00 2001 From: bootx Date: Sun, 12 May 2024 21:42:15 +0800 Subject: [PATCH] =?UTF-8?q?ref=20=E5=90=8C=E6=AD=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/annotation/QueryParam.java | 4 +-- .../common/core/annotation/Translate.java | 2 +- .../exception/ErrorCodeRuntimeException.java | 7 ++-- .../platform/common/core/rest/PageResult.java | 19 ++--------- .../log/ip2region/IpToRegionService.java | 2 +- .../auth/redis/SaTokenRedisConfiguration.java | 2 +- .../DataChangeRecorderInnerInterceptor.java | 2 +- .../common/mybatisplus/impl/BaseManager.java | 6 ++-- .../core/auth/service/AuthAssistService.java | 4 ++- .../service/UserTiredOperateService.java | 3 +- .../sdk/model/sync/RefundSyncModel.java | 32 ----------------- .../{PaySyncModel.java => SyncModel.java} | 12 ++----- .../single/sdk/param/sync/PaySyncParam.java | 9 +++-- .../sdk/param/sync/RefundSyncParam.java | 8 ++--- .../single/sdk/payment/PayOrderSyncTest.java | 8 ++--- .../sdk/payment/RefundOrderSyncTest.java | 4 +-- .../daxpay/single/result/pay/SyncResult.java | 6 ---- .../notice/service/ClientNoticeService.java | 2 +- .../payment/sync/service/PaySyncService.java | 34 ++++++++----------- .../sync/service/RefundSyncService.java | 29 +++++++--------- .../service/sdk/union/api/UnionPayKit.java | 17 +++++----- qodana.yaml | 31 +++++++++++++++++ 22 files changed, 104 insertions(+), 139 deletions(-) delete mode 100644 daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/RefundSyncModel.java rename daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/{PaySyncModel.java => SyncModel.java} (61%) create mode 100644 qodana.yaml diff --git a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/QueryParam.java b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/QueryParam.java index a3d89271e..50b3c2433 100644 --- a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/QueryParam.java +++ b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/QueryParam.java @@ -68,7 +68,7 @@ public @interface QueryParam { IS_NULL, /** 排序 */ - SORT; + SORT } /** @@ -81,7 +81,7 @@ public @interface QueryParam { /** 转换为下划线 */ UNDER_LINE, /** 不进行处理 */ - NONE; + NONE } diff --git a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/Translate.java b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/Translate.java index 74e88cc2a..b1d151b52 100644 --- a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/Translate.java +++ b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/annotation/Translate.java @@ -43,7 +43,7 @@ public @interface Translate { /** 字典 */ DICT, /** 数据表 暂未实现 */ - TABLE; + TABLE } diff --git a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/exception/ErrorCodeRuntimeException.java b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/exception/ErrorCodeRuntimeException.java index 4173fb360..26b0d5258 100644 --- a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/exception/ErrorCodeRuntimeException.java +++ b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/exception/ErrorCodeRuntimeException.java @@ -1,10 +1,13 @@ package cn.bootx.platform.common.core.exception; +import lombok.Getter; + import java.io.Serializable; /** * 错误码异常基类 */ +@Getter public abstract class ErrorCodeRuntimeException extends RuntimeException implements Serializable { private static final long serialVersionUID = 1724988277326336635L; @@ -20,10 +23,6 @@ public abstract class ErrorCodeRuntimeException extends RuntimeException impleme super(); } - public int getCode() { - return code; - } - public void setCode(int code) { this.code = code; } diff --git a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/rest/PageResult.java b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/rest/PageResult.java index 4cedead3e..debe413a5 100644 --- a/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/rest/PageResult.java +++ b/bootx-platform/bootx-common-core/src/main/java/cn/bootx/platform/common/core/rest/PageResult.java @@ -1,5 +1,7 @@ package cn.bootx.platform.common.core.rest; +import lombok.Getter; + import java.io.Serializable; import java.util.Collections; import java.util.List; @@ -10,6 +12,7 @@ import java.util.List; * @author xxm * @since 2020/4/21 14:37 */ +@Getter public class PageResult implements Serializable { private static final long serialVersionUID = -739437195275623607L; @@ -34,37 +37,21 @@ public class PageResult implements Serializable { */ private long current = 1; - public List getRecords() { - return records; - } - public PageResult setRecords(List records) { this.records = records; return this; } - public long getTotal() { - return total; - } - public PageResult setTotal(long total) { this.total = total; return this; } - public long getSize() { - return size; - } - public PageResult setSize(long size) { this.size = size; return this; } - public long getCurrent() { - return current; - } - public PageResult setCurrent(long current) { this.current = current; return this; diff --git a/bootx-platform/bootx-common-starters/common-starter-audit-log/src/main/java/cn/bootx/platform/starter/audit/log/ip2region/IpToRegionService.java b/bootx-platform/bootx-common-starters/common-starter-audit-log/src/main/java/cn/bootx/platform/starter/audit/log/ip2region/IpToRegionService.java index 4cb65b7b7..3fac2ef3f 100644 --- a/bootx-platform/bootx-common-starters/common-starter-audit-log/src/main/java/cn/bootx/platform/starter/audit/log/ip2region/IpToRegionService.java +++ b/bootx-platform/bootx-common-starters/common-starter-audit-log/src/main/java/cn/bootx/platform/starter/audit/log/ip2region/IpToRegionService.java @@ -125,7 +125,7 @@ public class IpToRegionService { searcher.close(); } catch (IOException e) { // 这句不会执行, finally中try无效 - throw new BizException("IP查询器关闭失败"); + log.error("关闭Ip地址库失败"); } } } diff --git a/bootx-platform/bootx-common-starters/common-starter-auth/src/main/java/cn/bootx/platform/starter/auth/redis/SaTokenRedisConfiguration.java b/bootx-platform/bootx-common-starters/common-starter-auth/src/main/java/cn/bootx/platform/starter/auth/redis/SaTokenRedisConfiguration.java index b0152beb0..90363a19e 100644 --- a/bootx-platform/bootx-common-starters/common-starter-auth/src/main/java/cn/bootx/platform/starter/auth/redis/SaTokenRedisConfiguration.java +++ b/bootx-platform/bootx-common-starters/common-starter-auth/src/main/java/cn/bootx/platform/starter/auth/redis/SaTokenRedisConfiguration.java @@ -57,7 +57,7 @@ public class SaTokenRedisConfiguration { // 获取自定义Redis对象 RedisProperties aloneRedis = saTokenDaoRedisProperties.getAloneRedis(); if (alone) { - RedisConfiguration redisConfig = new RedisStandaloneConfiguration(); + RedisConfiguration redisConfig; // 单机模式/集群模式 if (aloneRedis.getCluster() == null || CollUtil.isEmpty(aloneRedis.getCluster().getNodes())) { diff --git a/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/extension/DataChangeRecorderInnerInterceptor.java b/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/extension/DataChangeRecorderInnerInterceptor.java index 57ab743bb..4274eeb98 100644 --- a/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/extension/DataChangeRecorderInnerInterceptor.java +++ b/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/extension/DataChangeRecorderInnerInterceptor.java @@ -86,7 +86,7 @@ public class DataChangeRecorderInnerInterceptor implements InnerInterceptor { long startTs = System.currentTimeMillis(); DataVersionLog dataVersion; try { - Statement statement = null; + Statement statement; try { statement = CCJSqlParserUtil.parse(mpBs.sql()); } catch (JSQLParserException e) { diff --git a/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/impl/BaseManager.java b/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/impl/BaseManager.java index 9f81bf0d2..4886e4642 100644 --- a/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/impl/BaseManager.java +++ b/bootx-platform/bootx-commons/common-mybatis-plus/src/main/java/cn/bootx/platform/common/mybatisplus/impl/BaseManager.java @@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.kotlin.KtQueryChainWrapper; import com.baomidou.mybatisplus.extension.kotlin.KtUpdateChainWrapper; import com.baomidou.mybatisplus.extension.toolkit.ChainWrappers; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import lombok.Getter; import org.apache.ibatis.binding.MapperMethod; import org.apache.ibatis.logging.Log; import org.apache.ibatis.logging.LogFactory; @@ -45,14 +46,11 @@ public class BaseManager, T> { protected Log log = LogFactory.getLog(getClass()); + @Getter @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") @Autowired protected M baseMapper; - public M getBaseMapper() { - return baseMapper; - } - public Class getEntityClass() { return currentModelClass(); } diff --git a/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/auth/service/AuthAssistService.java b/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/auth/service/AuthAssistService.java index 43645283a..dbe0c26cf 100644 --- a/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/auth/service/AuthAssistService.java +++ b/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/auth/service/AuthAssistService.java @@ -12,6 +12,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Objects; + /** * 认证支撑服务 * @@ -36,7 +38,7 @@ public class AuthAssistService { // 判断用户是否存在 UserInfo userInfo = userInfoManager.findByPhone(phone).orElseThrow(UserInfoNotExistsException::new); - if (userInfo.getStatus() != UserStatusCode.NORMAL) { + if (!Objects.equals(userInfo.getStatus(), UserStatusCode.NORMAL)) { throw new BizException("用户状态异常"); } // 有效期5分钟 diff --git a/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/third/service/UserTiredOperateService.java b/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/third/service/UserTiredOperateService.java index 6f19003ce..bc06ea456 100644 --- a/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/third/service/UserTiredOperateService.java +++ b/bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/third/service/UserTiredOperateService.java @@ -8,6 +8,7 @@ import cn.bootx.platform.iam.core.third.entity.UserThird; import cn.bootx.platform.iam.core.third.entity.UserThirdInfo; import cn.bootx.platform.iam.core.user.dao.UserInfoManager; import cn.bootx.platform.iam.core.user.entity.UserInfo; +import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -73,7 +74,7 @@ public class UserTiredOperateService { .setNickname(authUser.getNickname()) .setAvatar(authUser.getAvatar()) .setThirdUserId(authUser.getUuid()); - this.bindOpenInfo(userThirdInfo); + SpringUtil.getBean(this.getClass()).bindOpenInfo(userThirdInfo); } /** diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/RefundSyncModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/RefundSyncModel.java deleted file mode 100644 index 4d83f3c83..000000000 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/RefundSyncModel.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.daxpay.single.sdk.model.sync; - -import cn.daxpay.single.sdk.code.RefundSyncStatusEnum; -import cn.daxpay.single.sdk.net.DaxPayResponseModel; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * 退款信息同步结果 - * @author xxm - * @since 2024/2/7 - */ -@Getter -@Setter -@ToString -public class RefundSyncModel extends DaxPayResponseModel { - - /** - * 支付网关同步结果 - * @see RefundSyncStatusEnum - * - */ - private String status; - - /** 是否进行了修复 */ - private boolean repair; - - /** 修复号 */ - private String repairOrderNo; - -} diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/PaySyncModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/SyncModel.java similarity index 61% rename from daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/PaySyncModel.java rename to daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/SyncModel.java index a5c6b138c..33688137b 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/PaySyncModel.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/sync/SyncModel.java @@ -7,25 +7,19 @@ import lombok.Setter; import lombok.ToString; /** - * 支付订单同步结果 + * 交易同步结果 * @author xxm * @since 2023/12/27 */ @Getter @Setter @ToString -public class PaySyncModel extends DaxPayResponseModel { +public class SyncModel extends DaxPayResponseModel { /** * 支付订单同步结果 * @see PaySyncStatusEnum */ - private String status; - - /** 是否进行了修复 */ - private boolean repair; - - /** 修复号 */ - private String repairOrderNo; + private Boolean status; } diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/PaySyncParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/PaySyncParam.java index 8a9483d03..ece4b87f6 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/PaySyncParam.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/PaySyncParam.java @@ -1,6 +1,6 @@ package cn.daxpay.single.sdk.param.sync; -import cn.daxpay.single.sdk.model.sync.PaySyncModel; +import cn.daxpay.single.sdk.model.sync.SyncModel; import cn.daxpay.single.sdk.net.DaxPayRequest; import cn.daxpay.single.sdk.response.DaxPayResult; import cn.hutool.core.lang.TypeReference; @@ -15,8 +15,7 @@ import lombok.Setter; */ @Getter @Setter -public class PaySyncParam extends DaxPayRequest { - +public class PaySyncParam extends DaxPayRequest { /** 订单号 */ private String orderNo; @@ -36,7 +35,7 @@ public class PaySyncParam extends DaxPayRequest { * 将请求返回结果反序列化为实体类 */ @Override - public DaxPayResult toModel(String json) { - return JSONUtil.toBean(json, new TypeReference>() {}, false); + public DaxPayResult toModel(String json) { + return JSONUtil.toBean(json, new TypeReference>() {}, false); } } diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/RefundSyncParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/RefundSyncParam.java index b9adb5211..910fc220f 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/RefundSyncParam.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/sync/RefundSyncParam.java @@ -1,6 +1,6 @@ package cn.daxpay.single.sdk.param.sync; -import cn.daxpay.single.sdk.model.sync.RefundSyncModel; +import cn.daxpay.single.sdk.model.sync.SyncModel; import cn.daxpay.single.sdk.net.DaxPayRequest; import cn.daxpay.single.sdk.response.DaxPayResult; import cn.hutool.core.lang.TypeReference; @@ -15,7 +15,7 @@ import lombok.Setter; */ @Getter @Setter -public class RefundSyncParam extends DaxPayRequest { +public class RefundSyncParam extends DaxPayRequest { /** 退款号 */ private String refundNo; @@ -35,7 +35,7 @@ public class RefundSyncParam extends DaxPayRequest { * 将请求返回结果反序列化为实体类 */ @Override - public DaxPayResult toModel(String json) { - return JSONUtil.toBean(json, new TypeReference>() {}, false); + public DaxPayResult toModel(String json) { + return JSONUtil.toBean(json, new TypeReference>() {}, false); } } diff --git a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayOrderSyncTest.java b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayOrderSyncTest.java index ca78a80db..958a20a89 100644 --- a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayOrderSyncTest.java +++ b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayOrderSyncTest.java @@ -1,7 +1,7 @@ package cn.daxpay.single.sdk.payment; import cn.daxpay.single.sdk.code.SignTypeEnum; -import cn.daxpay.single.sdk.model.sync.PaySyncModel; +import cn.daxpay.single.sdk.model.sync.SyncModel; import cn.daxpay.single.sdk.net.DaxPayConfig; import cn.daxpay.single.sdk.net.DaxPayKit; import cn.daxpay.single.sdk.param.sync.PaySyncParam; @@ -31,10 +31,8 @@ public class PayOrderSyncTest { @Test public void testPay() { PaySyncParam param = new PaySyncParam(); - - param.setBizOrderNo("P0001"); - - DaxPayResult execute = DaxPayKit.execute(param); + param.setBizOrderNo("SDK_1715341621498"); + DaxPayResult execute = DaxPayKit.execute(param); System.out.println(execute); System.out.println(execute.getData()); } diff --git a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/RefundOrderSyncTest.java b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/RefundOrderSyncTest.java index 21c5cb433..b7d74fd1a 100644 --- a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/RefundOrderSyncTest.java +++ b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/RefundOrderSyncTest.java @@ -1,7 +1,7 @@ package cn.daxpay.single.sdk.payment; import cn.daxpay.single.sdk.code.SignTypeEnum; -import cn.daxpay.single.sdk.model.sync.RefundSyncModel; +import cn.daxpay.single.sdk.model.sync.SyncModel; import cn.daxpay.single.sdk.net.DaxPayConfig; import cn.daxpay.single.sdk.net.DaxPayKit; import cn.daxpay.single.sdk.param.sync.RefundSyncParam; @@ -34,7 +34,7 @@ public class RefundOrderSyncTest { param.setRefundNo("R0001"); - DaxPayResult execute = DaxPayKit.execute(param); + DaxPayResult execute = DaxPayKit.execute(param); System.out.println(execute); System.out.println(execute.getData()); } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/SyncResult.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/SyncResult.java index 7c80e360a..3a3dfd673 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/SyncResult.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/SyncResult.java @@ -31,10 +31,4 @@ public class SyncResult extends PaymentCommonResult { @Schema(description = "支付网关同步状态") private String status = FAIL.getCode(); - @Schema(description = "是否进行了修复") - private Boolean repair; - - @Schema(description = "修复号") - private String repairNo; - } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java index 491fcf6b5..de897473d 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java @@ -176,7 +176,7 @@ public class ClientNoticeService { throw new RepetitiveOperationException("支付同步处理中,请勿重复操作"); } // 查询任务, 进行发送 - ClientNoticeTask task = null; + ClientNoticeTask task; try { task = taskManager.findById(taskId).orElse(null); // 不存在任务直接跳过 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java index 668273e57..d482db5de 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java @@ -1,6 +1,5 @@ package cn.daxpay.single.service.core.payment.sync.service; -import cn.bootx.platform.common.core.exception.BizException; import cn.bootx.platform.common.core.exception.RepetitiveOperationException; import cn.bootx.platform.common.core.util.LocalDateTimeUtil; import cn.daxpay.single.code.PayChannelEnum; @@ -65,7 +64,7 @@ public class PaySyncService { @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public SyncResult sync(PaySyncParam param) { PayOrder payOrder = payOrderQueryService.findByBizOrOrderNo(param.getOrderNo(), param.getBizOrderNo()) - .orElseThrow(() -> new BizException("支付订单不存在")); + .orElseThrow(() -> new PayFailureException("支付订单不存在")); // 钱包支付钱包不需要 if (PayChannelEnum.WALLET.getCode().equals(payOrder.getChannel())){ throw new PayFailureException("订单没有异步支付方式,不需要同步"); @@ -92,20 +91,20 @@ public class PaySyncService { AbsPaySyncStrategy syncPayStrategy = PaySyncStrategyFactory.create(payOrder.getChannel()); syncPayStrategy.initPayParam(payOrder); // 执行操作, 获取支付网关同步的结果 - PaySyncResult syncResult = syncPayStrategy.doSyncStatus(); + PaySyncResult paySyncResult = syncPayStrategy.doSyncStatus(); // 判断是否同步成功 - if (Objects.equals(syncResult.getSyncStatus(), PaySyncStatusEnum.FAIL)){ + if (Objects.equals(paySyncResult.getSyncStatus(), PaySyncStatusEnum.FAIL)){ // 同步失败, 返回失败响应, 同时记录失败的日志 - this.saveRecord(payOrder, syncResult, false, null, syncResult.getErrorMsg()); - throw new PayFailureException(syncResult.getErrorMsg()); + this.saveRecord(payOrder, paySyncResult, false, null, paySyncResult.getErrorMsg()); + throw new PayFailureException(paySyncResult.getErrorMsg()); } // 支付订单的网关订单号是否一致, 不一致进行更新 - if (!Objects.equals(syncResult.getOutOrderNo(), payOrder.getOutOrderNo())){ - payOrder.setOutOrderNo(syncResult.getOutOrderNo()); + if (!Objects.equals(paySyncResult.getOutOrderNo(), payOrder.getOutOrderNo())){ + payOrder.setOutOrderNo(paySyncResult.getOutOrderNo()); payOrderService.updateById(payOrder); } // 判断网关状态是否和支付单一致, 同时特定情况下更新网关同步状态 - boolean statusSync = this.checkAndAdjustSyncStatus(syncResult,payOrder); + boolean statusSync = this.checkAndAdjustSyncStatus(paySyncResult,payOrder); PayRepairResult repairResult = new PayRepairResult(); try { // 状态不一致,执行支付单修复逻辑 @@ -116,22 +115,19 @@ public class PaySyncService { repairInfo.setSource(PayRepairSourceEnum.SYNC); } // 设置支付单完成时间 - repairInfo.setFinishTime(syncResult.getPayTime()); - repairResult = this.repairHandler(syncResult, payOrder); + repairInfo.setFinishTime(paySyncResult.getPayTime()); + repairResult = this.repairHandler(paySyncResult, payOrder); } } catch (PayFailureException e) { // 同步失败, 返回失败响应, 同时记录失败的日志 - syncResult.setSyncStatus(PaySyncStatusEnum.FAIL); - this.saveRecord(payOrder, syncResult, false, null, e.getMessage()); + paySyncResult.setSyncStatus(PaySyncStatusEnum.FAIL); + this.saveRecord(payOrder, paySyncResult, false, null, e.getMessage()); throw e; } // 同步成功记录日志 - this.saveRecord( payOrder, syncResult, !statusSync, repairResult.getRepairNo(), null); - return new SyncResult() - .setStatus(syncResult.getSyncStatus().getCode()) - .setRepair(!statusSync) - .setRepairNo(repairResult.getRepairNo()); + this.saveRecord( payOrder, paySyncResult, !statusSync, repairResult.getRepairNo(), null); + return new SyncResult().setStatus(paySyncResult.getSyncStatus().getCode()); } finally { lockTemplate.releaseLock(lock); } @@ -223,7 +219,7 @@ public class PaySyncService { break; } default: { - throw new BizException("代码有问题"); + throw new PayFailureException("代码有问题"); } } return repair; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java index 100c11551..c4f41419c 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java @@ -83,21 +83,21 @@ public class RefundSyncService { // 同步前处理, 主要预防请求过于迅速 syncPayStrategy.doBeforeHandler(); // 执行操作, 获取支付网关同步的结果 - RefundSyncResult syncResult = syncPayStrategy.doSyncStatus(); + RefundSyncResult refundSyncResult = syncPayStrategy.doSyncStatus(); // 判断是否同步成功 - if (Objects.equals(syncResult.getSyncStatus(), RefundSyncStatusEnum.FAIL)) { + if (Objects.equals(refundSyncResult.getSyncStatus(), RefundSyncStatusEnum.FAIL)) { // 同步失败, 返回失败响应, 同时记录失败的日志 - this.saveRecord(refundOrder, syncResult, false, null, syncResult.getErrorMsg()); - throw new PayFailureException(syncResult.getErrorMsg()); + this.saveRecord(refundOrder, refundSyncResult, false, null, refundSyncResult.getErrorMsg()); + throw new PayFailureException(refundSyncResult.getErrorMsg()); } // 订单的通道交易号是否一致, 不一致进行更新 - if (Objects.nonNull(syncResult.getOutRefundNo()) && !Objects.equals(syncResult.getOutRefundNo(), refundOrder.getOutRefundNo())){ - refundOrder.setOutRefundNo(syncResult.getOutRefundNo()); + if (Objects.nonNull(refundSyncResult.getOutRefundNo()) && !Objects.equals(refundSyncResult.getOutRefundNo(), refundOrder.getOutRefundNo())){ + refundOrder.setOutRefundNo(refundSyncResult.getOutRefundNo()); refundOrderManager.updateById(refundOrder); } // 判断网关状态是否和支付单一致 - boolean statusSync = this.checkSyncStatus(syncResult, refundOrder); + boolean statusSync = this.checkSyncStatus(refundSyncResult, refundOrder); RefundRepairResult repairResult = new RefundRepairResult(); try { // 状态不一致,执行退款单修复逻辑 @@ -107,21 +107,18 @@ public class RefundSyncService { if (Objects.isNull(repairInfo.getSource())){ repairInfo.setSource(PayRepairSourceEnum.SYNC); } - repairInfo.setFinishTime(syncResult.getFinishTime()); - repairResult = this.repairHandler(syncResult, refundOrder); + repairInfo.setFinishTime(refundSyncResult.getFinishTime()); + repairResult = this.repairHandler(refundSyncResult, refundOrder); } } catch (PayFailureException e) { // 同步失败, 返回失败响应, 同时记录失败的日志 - syncResult.setSyncStatus(RefundSyncStatusEnum.FAIL); - this.saveRecord(refundOrder, syncResult, false, null, e.getMessage()); + refundSyncResult.setSyncStatus(RefundSyncStatusEnum.FAIL); + this.saveRecord(refundOrder, refundSyncResult, false, null, e.getMessage()); throw e; } // 同步成功记录日志 - this.saveRecord(refundOrder, syncResult, !statusSync, repairResult.getRepairNo(), null); - return new SyncResult() - .setStatus(syncResult.getSyncStatus().getCode()) - .setRepair(!statusSync) - .setRepairNo(repairResult.getRepairNo()); + this.saveRecord(refundOrder, refundSyncResult, !statusSync, repairResult.getRepairNo(), null); + return new SyncResult().setStatus(refundSyncResult.getSyncStatus().getCode()); } finally { lockTemplate.releaseLock(lock); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/sdk/union/api/UnionPayKit.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/sdk/union/api/UnionPayKit.java index 4fa059b6c..9e85509f6 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/sdk/union/api/UnionPayKit.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/sdk/union/api/UnionPayKit.java @@ -366,11 +366,11 @@ public class UnionPayKit extends UnionPayService { X509CertSelector selector = new X509CertSelector(); selector.setCertificate(cert); - Set trustAnchors = new HashSet(); + Set trustAnchors = new HashSet<>(); trustAnchors.add(new TrustAnchor(rootCert, null)); PKIXBuilderParameters pkixParams = new PKIXBuilderParameters(trustAnchors, selector); - Set intermediateCerts = new HashSet(); + Set intermediateCerts = new HashSet<>(); intermediateCerts.add(rootCert); intermediateCerts.add(middleCert); intermediateCerts.add(cert); @@ -389,9 +389,6 @@ public class UnionPayKit extends UnionPayService { catch (java.security.cert.CertPathBuilderException e) { LOG.error("verify certificate chain fail.", e); } - catch (CertificateExpiredException e) { - LOG.error("", e); - } catch (GeneralSecurityException e) { LOG.error("", e); } @@ -516,9 +513,13 @@ public class UnionPayKit extends UnionPayService { @Override public String buildRequest(Map orderInfo, MethodType method) { StringBuffer sf = new StringBuffer(); - sf.append(""); - sf.append("
"); - if (null != orderInfo && 0 != orderInfo.size()) { + sf.append(""); + sf.append(""); + if (null != orderInfo && !orderInfo.isEmpty()) { for (Map.Entry entry : orderInfo.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); diff --git a/qodana.yaml b/qodana.yaml new file mode 100644 index 000000000..4e2698583 --- /dev/null +++ b/qodana.yaml @@ -0,0 +1,31 @@ +#-------------------------------------------------------------------------------# +# Qodana analysis is configured by qodana.yaml file # +# https://www.jetbrains.com/help/qodana/qodana-yaml.html # +#-------------------------------------------------------------------------------# +version: "1.0" + +#Specify inspection profile for code analysis +profile: + name: qodana.starter + +#Enable inspections +#include: +# - name: + +#Disable inspections +#exclude: +# - name: +# paths: +# - + +projectJDK: 8 #(Applied in CI/CD pipeline) + +#Execute shell command before Qodana execution (Applied in CI/CD pipeline) +#bootstrap: sh ./prepare-qodana.sh + +#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) +#plugins: +# - id: #(plugin id can be found at https://plugins.jetbrains.com) + +#Specify Qodana linter for analysis (Applied in CI/CD pipeline) +linter: jetbrains/qodana-jvm:latest