Commit a8c3dc79 by 林永健

feat(marketing): 添加商品价格一致性校验功能

- 移除车系列表为空检查,始终执行批量插入操作
- 在商品和套餐数据查询中添加实时最低限价字段
- 新增价格一致性校验逻辑,验证前端传入价格与实时查询价格是否一致
- 当价格信息发生变更时抛出异常并提示用户重新选择商品或套餐
- 更新数据库查询映射文件以支持最低限价字段查询
- 扩展DTO类以支持最小价格信息传输和校验
1 parent e400f241
......@@ -43,4 +43,8 @@ public class GoodsRespDTO implements Serializable {
/** 现售价 */
@ApiModelProperty(notes = "现售价")
private BigDecimal currentPrice;
/** 最低限价 */
@ApiModelProperty(notes = "最低限价")
private BigDecimal minimumPrice;
}
......@@ -32,6 +32,10 @@ public class MarketingActivityProductItemReqDTO implements Serializable {
@ApiModelProperty(notes = "子商品现售价", required = true)
private BigDecimal currentPrice;
/** 子商品最低限价(前端传入,后端实时校验) */
@ApiModelProperty(notes = "子商品最低限价(需与后端实时查询一致)", required = true)
private BigDecimal minimumPrice;
/** 优惠价 */
@ApiModelProperty(notes = "优惠价", required = true)
private BigDecimal discountPrice;
......
......@@ -49,10 +49,18 @@ public class MarketingActivityProductReqDTO implements Serializable {
@ApiModelProperty(notes = "选项卡描述,最多200字", required = true)
private String tabDescription;
/** 优惠价 */
@ApiModelProperty(notes = "优惠价(商品类型必填,>=最低限价且<=现售价)")
/** 优惠价(前端传入,后端校验) */
@ApiModelProperty(notes = "优惠价", required = true)
private BigDecimal discountPrice;
/** 现售价(前端传入,后端实时校验,用于价格一致性校验) */
@ApiModelProperty(notes = "现售价(需与后端实时查询一致)", required = true)
private BigDecimal currentPrice;
/** 最低限价(前端传入,后端实时校验,用于价格一致性校验) */
@ApiModelProperty(notes = "最低限价(需与后端实时查询一致)", required = true)
private BigDecimal minimumPrice;
/** 销售激励 */
@ApiModelProperty(notes = "销售激励金额(商品类型必填,>=0)", required = true)
private BigDecimal salesIncentive;
......
......@@ -31,4 +31,8 @@ public class PackageItemRespDTO implements Serializable {
/** 子商品现售价 */
@ApiModelProperty(notes = "子商品现售价")
private BigDecimal currentPrice;
/** 子商品最低限价 */
@ApiModelProperty(notes = "子商品最低限价")
private BigDecimal minimumPrice;
}
......@@ -39,4 +39,8 @@ public class PackageRespDTO implements Serializable {
/** 现售价 */
@ApiModelProperty(notes = "现售价")
private BigDecimal currentPrice;
/** 最低限价 */
@ApiModelProperty(notes = "最低限价")
private BigDecimal minimumPrice;
}
......@@ -195,9 +195,7 @@ public class MarketingActivityService {
batchInsertStores(activityId, request.getStoreIds(), activity.getCreatedBy());
// 3. 批量插入车系
if (!CollectionUtils.isEmpty(request.getCarSeriesList())) {
batchInsertCarSeries(activityId, request.getCarSeriesList(), activity.getCreatedBy());
}
batchInsertCarSeries(activityId, request.getCarSeriesList(), activity.getCreatedBy());
// 4. 批量插入商品/套餐及子商品
batchInsertProducts(activityId, request.getProducts(), activity.getCreatedBy());
......@@ -504,13 +502,25 @@ public class MarketingActivityService {
p.setPackageCode(req.getPackageCode());
p.setSortOrder(req.getSortOrder() != null ? req.getSortOrder() : i);
// 查询 goods_type/goods_type_name/现售价/最低限价
// 查询 goods_type/goods_type_name/现售价/最低限价(实时)
GoodsTypeInfoDTO goodsTypeInfo = lookupGoodsTypeInfo(req.getGoodsCode(), req.getPackageCode());
p.setGoodsType(goodsTypeInfo.getGoodsType());
p.setGoodsTypeName(goodsTypeInfo.getGoodsTypeName());
p.setCurrentPrice(goodsTypeInfo.getCurrentPrice());
p.setMinimumPrice(goodsTypeInfo.getMinimumPrice());
// 价格一致性校验:前端传入的现售价/最低限价必须与实时查询一致
if (req.getCurrentPrice() != null && goodsTypeInfo.getCurrentPrice() != null
&& req.getCurrentPrice().compareTo(goodsTypeInfo.getCurrentPrice()) != 0) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR,
"商品价格信息已变更,请重新选择商品或套餐");
}
if (req.getMinimumPrice() != null && goodsTypeInfo.getMinimumPrice() != null
&& req.getMinimumPrice().compareTo(goodsTypeInfo.getMinimumPrice()) != 0) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR,
"商品价格信息已变更,请重新选择商品或套餐");
}
p.setTabName(req.getTabName());
p.setTabDescription(req.getTabDescription());
p.setDiscountPrice(req.getDiscountPrice());
......@@ -552,11 +562,19 @@ public class MarketingActivityService {
item.setActivityProductId(activityProductId);
item.setGoodsCode(req.getGoodsCode());
item.setGoodsName(req.getGoodsName());
// 查询 goods_type/goods_type_name/最低限价
// 查询 goods_type/goods_type_name/最低限价(实时)
GoodsTypeInfoDTO gti = lookupGoodsTypeInfoByGoodsCode(req.getGoodsCode());
item.setGoodsType(gti.getGoodsType());
item.setGoodsTypeName(gti.getGoodsTypeName());
item.setMinimumPrice(gti.getMinimumPrice());
// 价格一致性校验:前端传入的最低限价必须与实时查询一致
if (req.getMinimumPrice() != null && gti.getMinimumPrice() != null
&& req.getMinimumPrice().compareTo(gti.getMinimumPrice()) != 0) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR,
"套餐商品价格信息已变更,请重新选择套餐");
}
item.setCurrentPrice(req.getCurrentPrice());
item.setDiscountPrice(req.getDiscountPrice());
item.setSalesIncentive(req.getSalesIncentive());
......
......@@ -9,7 +9,8 @@
ug.commodity_code AS listingId,
mgi.scene_type AS scene,
COUNT(DISTINCT mgr.merchant_id) AS storeCount,
mgi.sell_price AS currentPrice
mgi.sell_price AS currentPrice,
mgi.min_sell_price AS minimumPrice
FROM dj_car_life_merchant_goods_info mgi
LEFT JOIN dj_car_life_upgrade_goods ug ON ug.id = mgi.upgrade_goods_id AND ug.deleted_flag = 'N'
JOIN dj_car_life_merchant_goods_ref mgr ON mgr.merchant_goods_id = mgi.id AND mgr.deleted_flag = 'N'
......
......@@ -8,7 +8,8 @@
p.package_name AS packageName,
p.scene_type AS scene,
COUNT(DISTINCT mgr.merchant_id) AS storeCount,
COALESCE(SUM(mgi.sell_price), 0) AS currentPrice
COALESCE(SUM(mgi.sell_price), 0) AS currentPrice,
COALESCE(SUM(mgi.min_sell_price), 0) AS minimumPrice
FROM dj_car_life_merchant_package_goods_info p
LEFT JOIN dj_car_life_merchant_goods_info mgi ON mgi.package_code = p.package_code AND mgi.deleted_flag = 'N' AND mgi.status = 1
JOIN dj_car_life_merchant_goods_ref mgr ON mgr.merchant_goods_id = mgi.id AND mgr.deleted_flag = 'N'
......@@ -39,7 +40,8 @@
<select id="findPackageItems" resultType="cn.com.glsx.dj.strategy.dto.PackageItemRespDTO">
SELECT mgi.merchant_goods_code AS goodsCode,
mgi.goods_alias AS goodsName,
mgi.sell_price AS currentPrice
mgi.sell_price AS currentPrice,
mgi.min_sell_price AS minimumPrice
FROM dj_car_life_merchant_goods_info mgi
WHERE mgi.package_code = #{packageCode}
AND mgi.deleted_flag = 'N'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!