Commit 5e6ba3d8 by 叶立庆

Merge branch 'master' into 'v5.8.6'

上线合并

See merge request !53
2 parents 4f065e31 4ec05a03
package cn.com.glsx.dj.smartcarlife.service;
import cn.com.glsx.dj.platform.payment.model.PaymentTradeNotify;
import cn.com.glsx.dj.platform.payment.remote.YsepayPaymentRemote;
import cn.com.glsx.dj.smartcarlife.dto.GoodsOrderApplyRecordDTO;
import cn.com.glsx.dj.smartcarlife.dto.GoodsOrderApplyRecordLogDTO;
import cn.com.glsx.dj.smartcarlife.dto.GoodsOrderDTO;
......@@ -16,6 +18,7 @@ import cn.com.glsx.dj.smartcarlife.service.vd.VdQuotationService;
import cn.com.glsx.dj.smartcarlife.util.CommonUtil;
import cn.com.glsx.framework.core.beans.BaseModel;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
......@@ -60,6 +63,8 @@ public class GoodsOrderApplyRecordService {
@Autowired
private PayOrderService payOrderService;
@Autowired
private YsepayPaymentRemote ysepayPaymentRemote;
@Autowired
private WaitInputOrderService waitInputOrderService;
@Autowired
private ShopMerchantDirectorConfigService shopMerchantDirectorConfigService;
......@@ -336,6 +341,21 @@ public class GoodsOrderApplyRecordService {
WaitInputOrderDTO addWaitInputOrderDTO = WaitInputOrderDTO.builder().outTradeNo(oldPayOrder.getOutTradeNo()).tradeNo(oldPayOrder.getTradeNo()).payOrderId(oldPayOrder.getId())
.totalFee(oldPayOrder.getOrderMoney().movePointRight(2).longValue()).accountDate(oldPayOrder.getSuccessDate()).yqMerchantId(oldPayOrder.getYqMerchantId())
.yqMerchantName(oldPayOrder.getYqMerchantName()).payType(oldPayOrder.getPayType()).updatedBy(oldPayOrder.getCreatedBy()).build();
// POS支付从支付平台补充终端号和终端流水号
if (Objects.equals(oldPayOrder.getPayType(), CarLifeEnum.PayType.POS.getValue())) {
try {
String outTradeNo = oldPayOrder.getOutTradeNo();
RpcResponse<PaymentTradeNotify> paymentTradeNotifyRes = ysepayPaymentRemote.selectTradeNotifyByOutTradeNo(outTradeNo);
log.info("查询POS机支付交易信息,outTradeNo:{}, result:{}", outTradeNo, paymentTradeNotifyRes);
if (paymentTradeNotifyRes != null && paymentTradeNotifyRes.getResult() != null) {
PaymentTradeNotify paymentTradeNotify = paymentTradeNotifyRes.getResult();
addWaitInputOrderDTO.setPosTrmNo(paymentTradeNotify.getPosTrmNo());
addWaitInputOrderDTO.setPosCseqNo(paymentTradeNotify.getPosCseqNo());
}
} catch (Exception e) {
log.warn("查询POS支付交易信息失败,outTradeNo:{}", oldPayOrder.getOutTradeNo(), e);
}
}
waitInputOrderService.addAuditRefuseWaitInputOrder(addWaitInputOrderDTO);
}
......
......@@ -321,7 +321,7 @@ public class WaitInputOrderService {
checkForSave(record);
WaitInputOrder existRecord = getByTradeNo(record.getTradeNo());
if (existRecord == null) {
compileForNew(record);
compileForAuditReject(record);
waitInputOrderMapper.insertUseGeneratedKeys(record);
}else{
record.setId(existRecord.getId());
......@@ -531,6 +531,26 @@ public class WaitInputOrderService {
record.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
}
/**
* @description: 特殊订单审核驳回待补录订单信息补充
* @param: [record]
* @return: void
* @author: lqWang
* @date: 2026/9/1 16:19
*/
private void compileForAuditReject(WaitInputOrderDTO record) {
final Date now = new Date();
//待补录订单没有关联园区店时,其状态为“未关联”
record.setInputStatus(Objects.isNull(record.getYqMerchantId()) ? InputStatusEnum.NOT_RELATED.getValue() : InputStatusEnum.NOT_INPUT.getValue() );
record.setNotifyStatus(NotifyStatusEnum.NOT_NOTIFY.getValue());
record.setRefundStatus(InputRefundStatusEnum.NOT_REFUNDED.getValue());
record.setDistributeStatus(InputDistributeStatusEnum.NOT_DISTRIBUTED.getValue());
record.setCreatedBy(record.getUpdatedBy());
record.setCreatedDate(now);
record.setUpdatedDate(now);
record.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
}
private void compileYqInfoByPosTrmNo(WaitInputOrderDTO record) {
YqPosTrm yqPosTrm = yqPosTrmService.getByPosTrmNo(record.getPosTrmNo());
if (yqPosTrm != null) {
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 3)

    1. 性能与稳定性风险:潜在的事务中包含同步 RPC 调用

    • 问题描述:在 GoodsOrderApplyRecordService 中,新增了对 ysepayPaymentRemote.selectTradeNotifyByOutTradeNo(outTradeNo) 的同步 RPC 调用。从上下文推测,该代码块可能处于一个包含数据库操作的较大业务方法中(如订单审核驳回),且该方法极大概率被 @Transactional 注解修饰。
    • 影响分析:在数据库事务中进行同步 RPC 调用是典型的反模式。如果 RPC 服务网络抖动、响应缓慢或发生超时,会导致当前数据库事务迟迟无法提交,长时间占用数据库连接。在并发量较高时,极易引发数据库连接池耗尽,从而导致整个服务不可用。
    • 优化建议:
      1. 检查外层方法是否开启了事务。如果开启了,建议将此 RPC 调用移至事务开启前获取,或在事务提交完成后通过异步事件/消息队列机制进行信息补充。
      2. 如果由于业务强耦合必须在此处同步调用,请务必确保该 RPC 接口在 Dubbo 消费者端配置了极短的超时时间(如 500ms~1s),防止长时间阻塞。

    2. 功能实现的健壮性:RPC 响应结果校验不严谨

    • 问题描述:代码在处理 RPC 响应时,仅校验了 paymentTradeNotifyRes != null && paymentTradeNotifyRes.getResult() != null,未对 RPC 调用的业务成功状态进行判断。
    • 影响分析:在标准的 RPC 响应体(如 RpcResponse)设计规范中,即使 result 字段非空,该响应也可能是包含错误码(Code)和错误信息(Message)的失败响应。如果不判断业务状态而直接使用 result 中的数据,可能会将无效或错误的数据(如默认值、空对象)写入到业务订单中,引发后续业务逻辑异常。
    • 优化建议:增加对 RPC 响应成功状态的校验(如调用 isSuccess() 或校验状态码)。 java // 建议优化为: if (paymentTradeNotifyRes != null && paymentTradeNotifyRes.isSuccess() && paymentTradeNotifyRes.getResult() != null) { PaymentTradeNotify paymentTradeNotify = paymentTradeNotifyRes.getResult(); addWaitInputOrderDTO.setPosTrmNo(paymentTradeNotify.getPosTrmNo()); addWaitInputOrderDTO.setPosCseqNo(paymentTradeNotify.getPosCseqNo()); }

    3. 最佳实践与可维护性:Javadoc 注释存在时间笔误

    • 问题描述:在 WaitInputOrderService.java 新增的方法 compileForAuditReject 的 Javadoc 注释中,@date 字段被错误地写成了未来时间 2026/9/1 16:19。
    • 影响分析:虽然对代码运行无任何实质性影响,但错误的注释信息会给后续接手维护的开发者带来困惑,不符合严谨的工程最佳实践规范。
    • 优化建议:修正日期为实际的开发提交时间。

    二、评分明细

    • 功能实现的正确性与健壮性(36 / 40分) 理由:整体业务逻辑实现正确,新增的 RPC 调用进行了 try-catch 异常捕获,保证了即使查询失败也不会阻断核心的主业务流程,设计合理。扣分点在于对 RPC 响应状态的校验不够严谨,存在获取到异常数据的隐患。

    • 安全性与潜在风险(30 / 30分) 理由:未发现 SQL 注入、XSS、越权或敏感信息泄露等安全隐患。新增的远程调用未修改原有 Remote 接口参数,符合安全规范。

    • 最佳实践与可维护性(18 / 20分) 理由:代码结构清晰,使用了 Builder 模式,变量命名能够准确表达业务含义。扣分点在于 Javadoc 注释中出现了明显的年份笔误(2026年)。

    • 性能与资源利用(3 / 5分) 理由:在可能存在 @Transactional 事务的上下文中直接发起同步 RPC 调用,存在拉长数据库事务、占用数据库连接资源的性能隐患。

    • 提交信息质量(5 / 5分) 理由:Commit message 格式规范(使用了 feat 和 fix 标识),分点清晰地描述了本次提交的变更内容、目的及异常处理机制,具有很高的可追溯性。

    总分:92分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!