Commit 17d3f41f by chenxi

展业助手-查询营销活动bug修复,无法正确查询车系数据

1 parent 851b47dd
...@@ -54,9 +54,12 @@ public class MarketingActivityProductQueryService { ...@@ -54,9 +54,12 @@ public class MarketingActivityProductQueryService {
} }
// 4. 构建车系名称映射(按car_series_id去重) // 4. 构建车系名称映射(按car_series_id去重)
// 同时构建关联表主键 -> 实际车系ID的映射,用于后续产品分组
Map<Integer, String> carSeriesNameMap = new LinkedHashMap<>(); Map<Integer, String> carSeriesNameMap = new LinkedHashMap<>();
Map<Integer, Integer> relPkToCarSeriesIdMap = new LinkedHashMap<>();
for (MarketingActivityCarSeries cs : carSeriesList) { for (MarketingActivityCarSeries cs : carSeriesList) {
carSeriesNameMap.putIfAbsent(cs.getCarSeriesId(), cs.getCarSeriesName()); carSeriesNameMap.putIfAbsent(cs.getCarSeriesId(), cs.getCarSeriesName());
relPkToCarSeriesIdMap.put(cs.getId(), cs.getCarSeriesId());
} }
// 5. 转换商品模型 -> DTO,并分组 // 5. 转换商品模型 -> DTO,并分组
...@@ -70,8 +73,13 @@ public class MarketingActivityProductQueryService { ...@@ -70,8 +73,13 @@ public class MarketingActivityProductQueryService {
int targetCarSeriesId; int targetCarSeriesId;
if (activity.getCarSeriesMode() == 0) { if (activity.getCarSeriesMode() == 0) {
targetCarSeriesId = -1; targetCarSeriesId = -1;
} else if (p.getCarSeriesId() != null) {
// p.getCarSeriesId() 是 dj_marketing_activity_product.car_series_id,
// 即 dj_marketing_activity_car_series.id(关联表主键),
// 需转换为 dj_marketing_activity_car_series.car_series_id(实际车系ID)
targetCarSeriesId = relPkToCarSeriesIdMap.getOrDefault(p.getCarSeriesId(), -1);
} else { } else {
targetCarSeriesId = p.getCarSeriesId() != null ? p.getCarSeriesId() : -1; targetCarSeriesId = -1;
} }
ProductRespDTO dto = new ProductRespDTO(); ProductRespDTO dto = new ProductRespDTO();
......
...@@ -18,6 +18,33 @@ ...@@ -18,6 +18,33 @@
ORDER BY sort_order ORDER BY sort_order
</select> </select>
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.strategy.model.MarketingActivityProduct">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="activity_id" property="activityId" jdbcType="INTEGER"/>
<result column="car_series_id" property="carSeriesId" jdbcType="INTEGER"/>
<result column="product_type" property="productType" jdbcType="TINYINT"/>
<result column="goods_code" property="goodsCode" jdbcType="VARCHAR"/>
<result column="package_code" property="packageCode" jdbcType="VARCHAR"/>
<result column="sort_order" property="sortOrder" jdbcType="INTEGER"/>
<result column="goods_type" property="goodsType" jdbcType="INTEGER"/>
<result column="goods_type_name" property="goodsTypeName" jdbcType="VARCHAR"/>
<result column="tab_name" property="tabName" jdbcType="VARCHAR"/>
<result column="tab_description" property="tabDescription" jdbcType="VARCHAR"/>
<result column="discount_price" property="discountPrice" jdbcType="DECIMAL"/>
<result column="current_price" property="currentPrice" jdbcType="DECIMAL"/>
<result column="minimum_price" property="minimumPrice" jdbcType="DECIMAL"/>
<result column="sales_incentive" property="salesIncentive" jdbcType="DECIMAL"/>
<result column="is_main_push" property="isMainPush" jdbcType="TINYINT"/>
<result column="main_image_url" property="mainImageUrl" jdbcType="VARCHAR"/>
<result column="thumb_image_url" property="thumbImageUrl" jdbcType="VARCHAR"/>
<result column="detail_image_url" property="detailImageUrl" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<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="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
</resultMap>
<!-- 通用查询(DTO 映射) --> <!-- 通用查询(DTO 映射) -->
<resultMap id="ProductRespDTOResultMap" type="cn.com.glsx.dj.strategy.dto.MarketingActivityProductRespDTO"> <resultMap id="ProductRespDTOResultMap" type="cn.com.glsx.dj.strategy.dto.MarketingActivityProductRespDTO">
<id column="id" property="productId" jdbcType="INTEGER"/> <id column="id" property="productId" jdbcType="INTEGER"/>
...@@ -61,7 +88,7 @@ ...@@ -61,7 +88,7 @@
</if> </if>
</update> </update>
<select id="selectByActivityIds" resultType="cn.com.glsx.dj.strategy.model.MarketingActivityProduct"> <select id="selectByActivityIds" resultMap="BaseResultMap">
SELECT * FROM dj_marketing_activity_product SELECT * FROM dj_marketing_activity_product
WHERE activity_id IN WHERE activity_id IN
<foreach collection="activityIds" item="id" open="(" separator="," close=")"> <foreach collection="activityIds" item="id" open="(" separator="," close=")">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!