Commit 4701d0ab by 崔彦峰

feat(goods): 添加商品上架模式和相关字段支持

- 在GoodsListingApprovalPageRequest中添加shelfModel字段用于区分特殊商品和常规商品上架
- 在GoodsListingApprovalPageResponse中同步添加shelfModel返回字段
- 在GoodsListingApproval实体中添加shelfModel数据库映射字段
- 更新GoodsListingApprovalMapper.xml中的resultMap和查询SQL以包含shelfModel字段
- 在GoodsListingBaseRule实体中添加管理层市场费前置和一线阳光前置字段
- 更新GoodsListingBaseRuleMapper.xml以支持新增的业务字段映射
- 在GoodsListingProductBase实体中添加上架方式类型和原上架ID字段
- 更新GoodsListingProductBaseMapper.xml以包含新增字段的数据库操作支持
1 parent 52ea284b
......@@ -123,4 +123,11 @@ public class GoodsListingApproval implements Serializable {
@ApiModelProperty(name = "deletedFlag", notes = "删除标识(D:已删除;N:未删除)")
@Column(name = "deleted_flag")
private String deletedFlag;
/**
* 上架模式 1-特殊商品上架 2-常规商品上架
*/
@ApiModelProperty(name = "shelfModel", notes = "上架模式 1-特殊商品上架 2-常规商品上架")
@Column(name = "shelf_model")
private Byte shelfModel;
}
\ No newline at end of file
......@@ -160,6 +160,20 @@ public class GoodsListingBaseRule implements Serializable {
private Date updatedDate;
/**
* 管理层市场费是否前置:是-Y 否-N
*/
@ApiModelProperty(name = "managementMarketingFeesPrerequisite", notes = "管理层市场费是否前置:是-Y 否-N")
@Column(name = "management_marketing_fees_prerequisite")
private String managementMarketingFeesPrerequisite;
/**
* 一线阳光是否前置:是-Y 否-N
*/
@ApiModelProperty(name = "firstLineSunshinePrerequisite", notes = "一线阳光是否前置:是-Y 否-N")
@Column(name = "first_line_sunshine_prerequisite")
private String firstLineSunshinePrerequisite;
/**
* 删除标示(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标示(D:已删除;N:未删除)")
......
......@@ -222,6 +222,20 @@ public class GoodsListingProductBase implements Serializable {
private Date updatedDate;
/**
* 类型(上架方式):1-新增 2-修改
*/
@ApiModelProperty(name = "shelfStyle", notes = "类型(上架方式):1-新增 2-修改")
@Column(name = "shelf_style")
private Byte shelfStyle;
/**
* 原上架ID(原商户商品编码)
*/
@ApiModelProperty(name = "oldMerchantGoodsCode", notes = "原上架ID(原商户商品编码)")
@Column(name = "old_merchant_goods_code")
private String oldMerchantGoodsCode;
/**
* 删除标识(D:已删除;N:未删除)
*/
@ApiModelProperty(name = "deletedFlag", notes = "删除标识(D:已删除;N:未删除)")
......
......@@ -19,6 +19,7 @@
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="shelf_model" property="shelfModel" jdbcType="TINYINT" />
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.goods.listing.dto.GoodsListingApprovalDTO" extends="BaseResultMap">
......@@ -35,14 +36,14 @@
-->
id, business_code, uuid, shelf_type, system_status, rejected_reason, goods_create_excel,
base_scene_code, confirm_step, created_by, created_date, updated_by, updated_date,
deleted_flag
deleted_flag, shelf_model
</sql>
<select id="list" resultMap="DTOResultMap">
select
gla.id, gla.business_code, gla.uuid, gla.shelf_type, gla.system_status, gla.rejected_reason,
gla.goods_create_excel, gla.base_scene_code, gla.confirm_step, gla.created_by, gla.created_date,
gla.updated_by, gla.updated_date
gla.updated_by, gla.updated_date, gla.shelf_model
from dj_car_life_goods_listing_approval gla
<include refid="condition"></include>
order by gla.id desc
......@@ -69,6 +70,9 @@
<if test="baseSceneCode != null and baseSceneCode !=''">
and gla.base_scene_code = #{baseSceneCode}
</if>
<if test="shelfModel != null">
and gla.shelf_model = #{shelfModel}
</if>
</where>
</sql>
</mapper>
\ No newline at end of file
......@@ -24,6 +24,8 @@
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="management_marketing_fees_prerequisite" property="managementMarketingFeesPrerequisite" jdbcType="CHAR" />
<result column="first_line_sunshine_prerequisite" property="firstLineSunshinePrerequisite" jdbcType="CHAR" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
......@@ -34,6 +36,7 @@
partner_merchant_divide_target, partner_merchant2_auto_divide, partner_merchant2_divide_target,
other_fee_divide_target, first_line_sunshine_online_points_flag, first_line_sunshine2_online_points_flag,
reality_shop_merchant_id, reality_shop_merchant_name, reality_shop_user_type, reality_shop_level,
created_by, created_date, updated_by, updated_date, deleted_flag
created_by, created_date, updated_by, updated_date, management_marketing_fees_prerequisite,
first_line_sunshine_prerequisite, deleted_flag
</sql>
</mapper>
\ No newline at end of file
......@@ -33,6 +33,8 @@
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="shelf_style" property="shelfStyle" jdbcType="TINYINT" />
<result column="old_merchant_goods_code" property="oldMerchantGoodsCode" jdbcType="VARCHAR" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.goods.listing.dto.GoodsListingProductBaseDTO" extends="BaseResultMap">
......@@ -60,7 +62,7 @@
revenue, traffic_share_profit, service_provider_profit, dj_revenue, dj_cost, manager_market_fee,
manager_market_fee1, manager_market_fee2, first_line_sunshine_incentive_fee, first_line_sunshine2_incentive_fee,
resource_fee, labor_cost, dj_gross_profit, profit_rate, integrity, profit_rate_cal_finish,
created_by, created_date, updated_by, updated_date, deleted_flag
created_by, created_date, updated_by, updated_date, shelf_style, old_merchant_goods_code, deleted_flag
</sql>
<select id="listBase" parameterType="cn.com.glsx.dj.goods.listing.model.GoodsListingProductBase" resultMap="BaseResultMap">
......@@ -78,7 +80,7 @@
<select id="getDetailById" resultMap="DTOResultMap">
select
glpb.id, glpb.business_code, glpb.product_type, glpb.settlement_type, glpb.product_name,glpb.package_code,
glpb.package_alias,glpb.sales_proportion_percent,
glpb.package_alias,glpb.sales_proportion_percent, glpb.shelf_style, glpb.old_merchant_goods_code,
glpd.upgrade_goods_id, glpd.upgrade_commodity_code, glpd.upgrade_goods_name,
glpd.goods_alias, glpd.position, glpd.sell_price, glpd.min_sell_price, glpd.upgrade_product_cost, glpd.recovery_cost,
glpd.gift_cost, glpd.third_party_cost, glpd.inventory_type,glpd.merchant_goods_code
......@@ -92,7 +94,8 @@
id, business_code, product_type, settlement_type, product_name,package_code,package_alias, sales_proportion_percent,
revenue, traffic_share_profit, service_provider_profit, dj_revenue, dj_cost, manager_market_fee,
manager_market_fee1, manager_market_fee2, first_line_sunshine_incentive_fee, first_line_sunshine2_incentive_fee,
resource_fee, labor_cost, dj_gross_profit, profit_rate, integrity, profit_rate_cal_finish
resource_fee, labor_cost, dj_gross_profit, profit_rate, integrity, profit_rate_cal_finish,
shelf_style, old_merchant_goods_code
from dj_car_life_goods_listing_product_base glpb
<include refid="listCondition"/>
order by glpb.id asc
......
  • @wangxw1
    commented
    Master

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

    1. MyBatis 查询字段硬编码与复用性差(可维护性)

    • 问题描述:在 GoodsListingApprovalMapper.xml 和 GoodsListingProductBaseMapper.xml 中,存在多处 <select> 语句手动罗列查询字段的情况。本次新增字段时,开发者需要在多个查询中手动追加 shelf_model、shelf_style 等字段。
    • 影响分析:这种硬编码方式非常容易在后续迭代中发生遗漏,导致某些查询接口返回的对象缺少部分字段数据,增加了维护成本并容易引发线上 Bug。
    • 优化建议:建议充分利用 MyBatis 的 <sql> 片段功能,用 <include refid="Base_Column_List" /> 替代手动罗列的字段。如果特定查询涉及关联表,可以单独定义一个包含别名关联的 <sql> 片段进行复用。

    2. SQL 字段缺少表别名前缀(潜在风险)

    • 问题描述:在 GoodsListingProductBaseMapper.xml 的 getDetailById 等查询中,FROM 子句为表定义了别名 glpb,但是 SELECT 列表中的部分字段(如 id, business_code, product_type...)并没有加上 glpb. 的前缀。
    • 影响分析:虽然当前是单表查询或未产生字段名冲突,SQL 可以正常执行。但如果在后续迭代中,<include refid="listCondition"/> 引入了 JOIN 关联查询,或者增加了其他表,极易引发 Column 'xxx' in field list is ambiguous(字段不明确)的 SQL 语法错误。
    • 优化建议:保持 SQL 编写的严谨性和一致性,既然定义了表别名,建议在 SELECT 字段列表和 WHERE 条件中统一加上前缀。 xml <!-- 优化示例 --> select glpb.id, glpb.business_code, glpb.product_type, glpb.settlement_type, glpb.product_name ... from dj_car_life_goods_listing_product_base glpb

    3. "Y/N" 标识字段缺乏枚举约束(最佳实践)

    • 问题描述:GoodsListingBaseRule.java 中新增的 managementMarketingFeesPrerequisite 和 firstLineSunshinePrerequisite 字段,注释表明其值为 "Y" 或 "N",但代码中直接使用了 String 类型。
    • 影响分析:在业务逻辑中大量使用硬编码字符串(如 "Y".equals(rule.get...))容易产生拼写错误,且无法利用编译期检查,降低了代码的严谨性。
    • 优化建议:建议对于只有固定几个状态值的字段,使用枚举(Enum)进行管理,并在 MyBatis 中配置对应的 TypeHandler,或者在实体类中提供便捷的布尔转换方法,以提升代码的健壮性和可读性。

    二、评分明细

    1. 功能实现的正确性与健壮性(38/40分)

      • 理由:本次变更为基础的字段扩充,Java 实体与 MyBatis 映射关系的修改基本正确。严格检查了 MyBatis 文件,未发现使用违规的子查询,也未涉及 Dubbo 服务提供者接口参数变更。扣除 2 分是因为 SQL 编写缺乏足够的健壮性(别名未统一使用)。
    2. 安全性与潜在风险(30/30分)

      • 理由:代码修改仅涉及实体类属性和基础的 CRUD 映射,入参查询均使用了安全的 #{} 占位符,不存在 SQL 注入风险,未发现越权或敏感数据泄露隐患。
    3. 最佳实践与可维护性(15/20分)

      • 理由:代码结构清晰,注释完备。但 MyBatis XML 中存在较多硬编码字段,未充分利用 SQL 片段复用;标识类字段未使用枚举进行规范,在工程最佳实践上还有提升空间。
    4. 性能与资源利用(5/5分)

      • 理由:仅为单表字段扩充,无复杂的计算或全表扫描风险,对系统性能和资源利用无负面影响。
    5. 提交信息质量(5/5分)

      • 理由:Commit 提交信息格式规范,清晰详细地列出了涉及修改的文件、新增字段的用途及业务含义,可追溯性极强,值得表扬。

    总分:93分

  • @cuiyf

    mentioned in commit de09c957

    mentioned in commit de09c957

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