Commit 7df725d6 by chenxi

Revert "5.8.4 商品上架审核后,新增商品、套餐操作日志"

This reverts commit 3e69ee33.
1 parent 3e69ee33
......@@ -13,7 +13,6 @@ import cn.com.glsx.dj.smartcarlife.dto.ExpenseCategoryDTO;
import cn.com.glsx.dj.smartcarlife.dto.UpgradeGoodsDTO;
import cn.com.glsx.dj.smartcarlife.dto.goods.MerchantGoodsInfoDTO;
import cn.com.glsx.dj.smartcarlife.dto.goods.UpgradeGoodsAreaDTO;
import cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum.GoodsReviewTypeEnum;
import cn.com.glsx.dj.smartcarlife.enums.*;
import cn.com.glsx.dj.smartcarlife.enums.createBusinessApprove.ProductTypeEnum;
import cn.com.glsx.dj.smartcarlife.model.*;
......@@ -48,7 +47,6 @@ import org.springframework.transaction.support.TransactionSynchronizationAdapter
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -154,9 +152,6 @@ public class GoodsListingApprovalService {
private MerchantGoodsInfoRemote merchantGoodsInfoRemote;
@Autowired
private GoodsReviewLogMapper goodsReviewLogMapper;
@Autowired
private SmartcarSceneMerchantRefNewMapper smartcarSceneMerchantRefNewMapper;
@Autowired
......@@ -404,7 +399,6 @@ public class GoodsListingApprovalService {
try {
ApprovalPublishContext context = buildApprovalPublishContext(businessCode, updatedBy);
publishApprovedProducts(context);
createGoodsReviewLogsForListing(context);
publishApprovedRulesByMerchant(context);
goodsListingApprovalMapper.updateByPrimaryKeySelective(GoodsListingApproval.builder()
.id(context.approval.getId()).systemStatus(SystemStatus.APPROVED.getValue())
......@@ -2019,71 +2013,6 @@ public class GoodsListingApprovalService {
}
}
private void createGoodsReviewLogsForListing(ApprovalPublishContext context) {
List<GoodsListingLog> logs = goodsListingLogService.listByBusinessCode(context.businessCode);
GoodsListingLog initiateLog = logs.stream()
.filter(l -> Objects.equals(LogOperatorType.INITIATE.getValue(), l.getOperatorType()))
.findFirst().orElse(null);
GoodsListingLog approveLog = logs.stream()
.filter(l -> Objects.equals(LogOperatorType.APPROVE.getValue(), l.getOperatorType()))
.findFirst().orElse(null);
if (initiateLog == null || approveLog == null) {
log.warn("未找到完整的GoodsListingLog, 跳过GoodsReviewLog写入, businessCode={}", context.businessCode);
return;
}
Date initiateDate = initiateLog.getCreatedDate();
Date approveDate = approveLog.getCreatedDate();
List<GoodsReviewLog> allLogs = new ArrayList<>();
Set<String> loggedPackageCodes = new HashSet<>();
for (GoodsListingProductBaseDTO product : context.products) {
List<GoodsListingProductDetailDTO> details = getCachedList(context.detailsByProductBaseIdMap, product.getId());
if (Objects.equals(product.getProductType(), ProductTypeEnum.PACKAGE.getValue())) {
String packageCode = product.getPackageCode();
if (StringUtils.isNotBlank(packageCode) && loggedPackageCodes.add(packageCode)) {
allLogs.add(buildReviewLog(packageCode, null, GoodsReviewTypeEnum.CREATE, initiateLog.getCreatedBy(), initiateDate));
allLogs.add(buildReviewLog(packageCode, null, GoodsReviewTypeEnum.TO_AUDIT, initiateLog.getCreatedBy(), initiateDate));
allLogs.add(buildReviewLog(packageCode, null, GoodsReviewTypeEnum.AUDIT_TO_ON_SHELF, approveLog.getCreatedBy(), approveDate));
}
} else {
if (CollectionUtils.isNotEmpty(details)) {
for (GoodsListingProductDetailDTO detail : details) {
MerchantGoodsInfo condition = new MerchantGoodsInfo();
condition.setMerchantGoodsCode(detail.getMerchantGoodsCode());
condition.setDeletedFlag(DeletedFlagEnum.N.name());
MerchantGoodsInfo goodsInfo = smartcarMerchantGoodsInfoMapper.selectOne(condition);
if (goodsInfo != null) {
allLogs.add(buildReviewLog(null, goodsInfo.getId(), GoodsReviewTypeEnum.CREATE, initiateLog.getCreatedBy(), initiateDate));
allLogs.add(buildReviewLog(null, goodsInfo.getId(), GoodsReviewTypeEnum.TO_AUDIT, initiateLog.getCreatedBy(), initiateDate));
allLogs.add(buildReviewLog(null, goodsInfo.getId(), GoodsReviewTypeEnum.AUDIT_TO_ON_SHELF, approveLog.getCreatedBy(), approveDate));
}
}
}
}
}
if (CollectionUtils.isNotEmpty(allLogs)) {
goodsReviewLogMapper.insertList(allLogs);
}
}
private GoodsReviewLog buildReviewLog(String packageCode, Integer goodsId,
GoodsReviewTypeEnum type, String operator, Date reviewDate) {
GoodsReviewLog log = new GoodsReviewLog();
log.setPackageCode(packageCode);
log.setGoodsId(goodsId);
log.setReviewType(type.getValue());
log.setReviewMessage(MessageFormat.format(type.getReviewMessage(), operator));
log.setReviewDate(reviewDate);
log.setCreatedBy(operator);
log.setCreatedDate(reviewDate);
log.setUpdatedBy(operator);
log.setUpdatedDate(reviewDate);
log.setDeletedFlag(DeletedFlagEnum.N.name());
return log;
}
private static class ApprovalPublishContext {
private String businessCode;
private String updatedBy;
......
  • @wangxw1
    commented
    Master

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

    1. Revert 带来的关联功能影响评估

    • 问题描述:本次提交为 Revert 操作,完全移除了商品和套餐上架审核时写入 GoodsReviewLog(操作日志)的逻辑。
    • 影响分析:如果前端页面、运营后台或其他微服务(如下游数据统计)依赖 GoodsReviewLog 表进行审核轨迹的展示或查询,此次回退将导致新上架的商品和套餐缺乏日志数据,可能会引发前端展示空白或业务查询异常。
    • 优化建议:请与产品经理及前端开发人员确认,依赖 GoodsReviewLog 的下游业务或前端展示功能是否已同步回退或已评估过该影响,确保业务闭环不出问题。

    2. 潜在的无用代码(僵尸代码)清理

    • 问题描述:本次回退移除了 GoodsReviewLogMapper 以及 GoodsReviewTypeEnum 等依赖的调用逻辑。
    • 影响分析:如果 GoodsReviewLogMapper 接口、对应的 MyBatis XML 映射文件以及 GoodsReviewLog 实体类在项目中已无其他引用,保留它们会变成“僵尸代码”,增加后续项目的维护成本和认知负担。
    • 优化建议:建议在 IDE 中全局搜索 GoodsReviewLogMapper 和 GoodsReviewLog,如果确认已完全废弃,建议在本次或紧接着的提交中将其一并彻底删除。

    二、评分明细

    • 功能实现的正确性与健壮性(40 / 40分): 本次为标准的 Git Revert 提交,代码回退干净彻底。移除了相关的日志生成方法和 Mapper 依赖,未破坏原有的核心审批发布流程(processPublishApproval),逻辑正确。未涉及 MyBatis 子查询及 Dubbo Remote 接口参数变更。
    • 安全性与潜在风险(30 / 30分): 移除了部分业务代码,未引入新的外部参数,不存在 SQL 注入、XSS、越权或敏感信息泄露等安全隐患。
    • 最佳实践与可维护性(18 / 20分): 回退操作顺带清理了无用的 import 导入,保持了当前类的代码整洁。扣除 2 分是因为可能遗留了未被清理的 Mapper 接口及实体类(需视全局代码而定)。
    • 性能与资源利用(5 / 5分): 移除了额外的数据库查询和批量插入(insertList)操作,减少了数据库 IO 开销,客观上提升了该审批接口的响应性能。
    • 提交信息质量(5 / 5分): 使用了 Git 自动生成的标准 Revert 提交信息,明确指出了撤销的功能点(5.8.4 商品上架审核后,新增商品、套餐操作日志)以及被撤销的 Commit Hash,清晰且高度可追溯。

    总分:98分

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