Commit b02bbe31 by 叶立庆

增加支付方式字段导出

1 parent ba29ba1b
...@@ -117,5 +117,10 @@ public class GoodsOrderProfitAllocationShopExportVO implements Serializable { ...@@ -117,5 +117,10 @@ public class GoodsOrderProfitAllocationShopExportVO implements Serializable {
@ExcelProperty(converter= ReplaceByteToStringConvert.class) @ExcelProperty(converter= ReplaceByteToStringConvert.class)
private Byte orderStatus; private Byte orderStatus;
@ExcelMergeRow(columIndex = 24)
@ExcelValueReplace(replace={"线上微信支付_1","4s店支付_2","pos机支付_3","支付宝支付_4","嘀加收款_5"},repeatValue=true)
@ExcelProperty(converter= ReplaceByteToStringConvert.class)
private Byte payType;
private List<GoodsSubOrderProfitAllocationShopExportVO> list; private List<GoodsSubOrderProfitAllocationShopExportVO> list;
} }
...@@ -117,5 +117,10 @@ public class GoodsOrderProfitAllocationShopExportVO2 implements Serializable { ...@@ -117,5 +117,10 @@ public class GoodsOrderProfitAllocationShopExportVO2 implements Serializable {
@ExcelProperty(converter= ReplaceByteToStringConvert.class) @ExcelProperty(converter= ReplaceByteToStringConvert.class)
private Byte orderStatus; private Byte orderStatus;
@ExcelMergeRow(columIndex = 23)
@ExcelValueReplace(replace={"线上微信支付_1","4s店支付_2","pos机支付_3","支付宝支付_4","嘀加收款_5"},repeatValue=true)
@ExcelProperty(converter= ReplaceByteToStringConvert.class)
private Byte payType;
private List<GoodsSubOrderProfitAllocationShopExportVO> list; private List<GoodsSubOrderProfitAllocationShopExportVO> list;
} }
  • @wangxw1
    commented
    Master

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

    1. [可维护性] 严重的类冗余与代码重复(DRY 原则)

    • 问题描述:项目中同时存在 GoodsOrderProfitAllocationShopExportVO 和 GoodsOrderProfitAllocationShopExportVO2 两个高度相似的类,导致新增 payType 字段及复杂的注解逻辑需要重复编写两次。这严重违反了 DRY (Don't Repeat Yourself) 原则,后续维护极易出现漏改导致两边逻辑不一致的问题。
    • 优化建议:根据阿里巴巴开发手册的面向对象规约,建议提取两个 VO 类的公共字段到父类(如 BaseGoodsOrderProfitAllocationShopExportVO)中,或者通过组合模式复用代码,消除重复的类定义。

    2. [可维护性/正确性] 注解中存在“魔法值”与硬编码

    • 问题描述:@ExcelValueReplace 的 replace 属性中使用了大量的硬编码字符串(如 "线上微信支付_1","4s店支付_2" 等)。根据阿里巴巴 Java 开发手册,代码中严禁出现未经定义的魔法值。若支付方式发生变更或新增,需要在多个 VO 类中逐一修改注解,极易出错。
    • 优化建议:虽然注解属性必须是常量,但建议将这些映射关系定义为全局常量数组,或者更好的方式是:移除 @ExcelValueReplace,在 ReplaceByteToStringConvert 转换器内部结合支付方式枚举类(Enum)进行动态转换,以提升代码的健壮性。

    3. [健壮性] 脆弱的绝对列索引与命名拼写错误

    • 问题描述:
      • @ExcelMergeRow(columIndex = 24) 和 23 使用了硬编码的绝对列索引。如果未来在 VO 中间插入或删除其他字段,该索引将直接失效,导致 Excel 合并单元格错位。
      • 自定义注解属性 columIndex 存在明显的拼写错误(应为 columnIndex)。
    • 优化建议:建议重构 @ExcelMergeRow 的实现逻辑,支持通过反射自动获取字段在类中的排序位置来决定列索引,避免硬编码数字;同时修正注解属性的拼写错误(若为历史遗留自定义注解,建议标记 @Deprecated 并提供正确拼写的新属性)。

    二、评分明细

    • 功能实现的正确性与健壮性(40分):35分
      • 扣分原因:硬编码的绝对列索引(23/24)极易在后续字段增删时引发合并单元格错位的 Bug,健壮性较差。
    • 安全性与潜在风险(30分):30分
      • 评价:仅为 Excel 导出的视图对象(VO)层变更,无 SQL 注入、XSS 等安全风险,安全性良好。
    • 最佳实践与可维护性(20分):12分
      • 扣分原因:存在明显的 VO 类复制粘贴(VO 与 VO2)、注解中滥用魔法值、字段缺少 Javadoc 注释(虽然注解有说明,但标准实体类字段应有注释),且存在单词拼写错误。
    • 性能与资源利用(5分):5分
      • 评价:常规的 POJO 字段增加,无性能瓶颈。
    • 提交信息质量(5分):3分
      • 扣分原因:“增加支付方式字段导出 (by yelq);” 描述了做了什么,但缺乏标准格式(如 feat: 增加支付方式字段导出)且未关联具体的业务需求/缺陷 Issue ID。

    总分:85分

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