Commit 2d944a09 by chenxi

Merge remote-tracking branch 'origin/v5.8.3' into v5.8.3

2 parents bd40315f 976a80c8
...@@ -32,6 +32,10 @@ public class GoodsTypeInfoDTO implements Serializable { ...@@ -32,6 +32,10 @@ public class GoodsTypeInfoDTO implements Serializable {
@ApiModelProperty(notes = "商品类型名称") @ApiModelProperty(notes = "商品类型名称")
private String goodsTypeName; private String goodsTypeName;
/** 商品状态 */
@ApiModelProperty(notes = "商品状态")
private Integer goodsStatus;
/** 现售价 */ /** 现售价 */
@ApiModelProperty(notes = "现售价") @ApiModelProperty(notes = "现售价")
private BigDecimal currentPrice; private BigDecimal currentPrice;
......
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.persistence.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
...@@ -88,6 +90,10 @@ public class MarketingActivityProductReqDTO implements Serializable { ...@@ -88,6 +90,10 @@ public class MarketingActivityProductReqDTO implements Serializable {
@ApiModelProperty(notes = "内容详图URL") @ApiModelProperty(notes = "内容详图URL")
private String detailImageUrl; private String detailImageUrl;
@JsonIgnore
@Transient
private String carSeriesName;
/** 套餐子商品(productType=PACKAGE时) */ /** 套餐子商品(productType=PACKAGE时) */
@ApiModelProperty(notes = "套餐子商品列表(productType=PACKAGE时必填)") @ApiModelProperty(notes = "套餐子商品列表(productType=PACKAGE时必填)")
private List<MarketingActivityProductItemReqDTO> packageItems; private List<MarketingActivityProductItemReqDTO> packageItems;
......
...@@ -27,4 +27,6 @@ public interface MarketingPackageQueryMapper { ...@@ -27,4 +27,6 @@ public interface MarketingPackageQueryMapper {
@Param("merchantIds") List<Integer> merchantIds); @Param("merchantIds") List<Integer> merchantIds);
List<PackageItemRespDTO> findPackageItems(@Param("packageCode") String packageCode); List<PackageItemRespDTO> findPackageItems(@Param("packageCode") String packageCode);
PackageRespDTO findPackageByCode(@Param("packageCode") String packageCode);
} }
...@@ -54,6 +54,7 @@ public class MarketingActivityService { ...@@ -54,6 +54,7 @@ public class MarketingActivityService {
private final MarketingActivityProductItemMapper marketingActivityProductItemMapper; private final MarketingActivityProductItemMapper marketingActivityProductItemMapper;
private final MarketingActivityOperationLogMapper marketingActivityOperationLogMapper; private final MarketingActivityOperationLogMapper marketingActivityOperationLogMapper;
private final MarketingGoodsQueryMapper marketingGoodsQueryMapper; private final MarketingGoodsQueryMapper marketingGoodsQueryMapper;
private final MarketingPackageQueryMapper marketingPackageQueryMapper;
private final MerchantRemote merchantRemote; private final MerchantRemote merchantRemote;
...@@ -687,6 +688,7 @@ public class MarketingActivityService { ...@@ -687,6 +688,7 @@ public class MarketingActivityService {
// 构建当前车系下的商品/套餐 // 构建当前车系下的商品/套餐
if (!CollectionUtils.isEmpty(csReq.getProducts())) { if (!CollectionUtils.isEmpty(csReq.getProducts())) {
for (MarketingActivityProductReqDTO prodReq : csReq.getProducts()) { for (MarketingActivityProductReqDTO prodReq : csReq.getProducts()) {
prodReq.setCarSeriesName(csReq.getCarSeriesName());
MarketingActivityProduct product = buildProduct(activityId, targetCarSeriesId, prodReq, createdBy); MarketingActivityProduct product = buildProduct(activityId, targetCarSeriesId, prodReq, createdBy);
allProductList.add(product); allProductList.add(product);
allProductReqList.add(prodReq); allProductReqList.add(prodReq);
...@@ -704,7 +706,7 @@ public class MarketingActivityService { ...@@ -704,7 +706,7 @@ public class MarketingActivityService {
MarketingActivityProductReqDTO req = allProductReqList.get(i); MarketingActivityProductReqDTO req = allProductReqList.get(i);
if (ProductTypeEnum.PACKAGE.getValue().equals(req.getProductType()) if (ProductTypeEnum.PACKAGE.getValue().equals(req.getProductType())
&& !CollectionUtils.isEmpty(req.getPackageItems())) { && !CollectionUtils.isEmpty(req.getPackageItems())) {
batchInsertItems(p.getId(), req.getPackageCode(), req.getPackageItems(), createdBy); batchInsertItems(p.getId(), req, createdBy);
} }
} }
} }
...@@ -734,36 +736,50 @@ public class MarketingActivityService { ...@@ -734,36 +736,50 @@ public class MarketingActivityService {
p.setGoodsCode(req.getGoodsCode()); p.setGoodsCode(req.getGoodsCode());
p.setPackageCode(req.getPackageCode()); p.setPackageCode(req.getPackageCode());
if (!StringUtils.hasLength(req.getGoodsCode())) { String itemName = StringUtils.hasText(req.getCarSeriesName()) ? req.getCarSeriesName() + " " : "";
if (Objects.equals(req.getProductType(), ProductTypeEnum.GOODS.getValue())) { itemName += StringUtils.hasText(req.getProductName()) ? req.getProductName() : req.getTabName();
log.warn("商品编号为空,productType=GOODS,但goodsCode为空,tabName={}", req.getTabName());
ProductTypeEnum productTypeEnum = ProductTypeEnum.fromValue(req.getProductType());
RpcAssert.assertNotNull(productTypeEnum, DefaultErrorEnum.SERVER_ERROR, "商品类型错误");
switch (productTypeEnum) {
case PACKAGE:
RpcAssert.assertNotNull(req.getPackageCode(), DefaultErrorEnum.SERVER_ERROR, "套餐编号为空");
PackageRespDTO packageDTO = marketingPackageQueryMapper.findPackageByCode(req.getPackageCode());
if (Objects.isNull(packageDTO)) {
log.error("套餐不存在已上架记录,code:{}", req.getPackageCode());
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, itemName + "的产品信息存在变更,请重新选择");
} }
RpcAssert.assertIsTrue(!Objects.equals(req.getProductType(), ProductTypeEnum.GOODS.getValue()),
DefaultErrorEnum.SERVER_ERROR, "商品编号为空");
p.setCurrentPrice(req.getCurrentPrice()); p.setCurrentPrice(req.getCurrentPrice());
p.setMinimumPrice(req.getMinimumPrice()); p.setMinimumPrice(req.getMinimumPrice());
} else { break;
case GOODS:
RpcAssert.assertNotNull(req.getGoodsCode(), DefaultErrorEnum.SERVER_ERROR, "商品编号为空");
// 查询 goods_type/goods_type_name/现售价/最低限价(实时) // 查询 goods_type/goods_type_name/现售价/最低限价(实时)
GoodsTypeInfoDTO goodsTypeInfo = lookupGoodsTypeInfo(req.getGoodsCode()); GoodsTypeInfoDTO goodsTypeInfo = lookupGoodsTypeInfo(itemName, req.getGoodsCode());
if (!Objects.equals(goodsTypeInfo.getGoodsStatus(), 1)) {
log.error("商品未上架,goods:{}", goodsTypeInfo);
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, itemName + "的产品信息存在变更,请重新选择");
}
p.setGoodsType(goodsTypeInfo.getGoodsType()); p.setGoodsType(goodsTypeInfo.getGoodsType());
p.setGoodsTypeName(goodsTypeInfo.getGoodsTypeName()); p.setGoodsTypeName(goodsTypeInfo.getGoodsTypeName());
p.setCurrentPrice(goodsTypeInfo.getCurrentPrice()); p.setCurrentPrice(goodsTypeInfo.getCurrentPrice());
p.setMinimumPrice(goodsTypeInfo.getMinimumPrice()); p.setMinimumPrice(goodsTypeInfo.getMinimumPrice());
// 价格一致性校验:前端传入的现售价/最低限价必须与实时查询一致 // 价格一致性校验:前端传入的现售价/最低限价必须与实时查询一致
String itemName = StringUtils.hasText(req.getProductName()) ? req.getProductName() : req.getTabName(); if (req.getCurrentPrice().compareTo(p.getCurrentPrice()) != 0) {
if (req.getCurrentPrice() != null && goodsTypeInfo.getCurrentPrice() != null
&& req.getCurrentPrice().compareTo(goodsTypeInfo.getCurrentPrice()) != 0) {
log.warn("商品价格变更,现售价不一致,goodsCode={}, reqCurrentPrice={}, dbCurrentPrice={}", log.warn("商品价格变更,现售价不一致,goodsCode={}, reqCurrentPrice={}, dbCurrentPrice={}",
req.getGoodsCode(), req.getCurrentPrice(), goodsTypeInfo.getCurrentPrice()); req.getGoodsCode(), req.getCurrentPrice(), p.getCurrentPrice());
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, itemName + "的产品信息存在变更,请重新选择"); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, itemName + "的产品信息存在变更,请重新选择");
} }
if (req.getMinimumPrice() != null && goodsTypeInfo.getMinimumPrice() != null if (req.getMinimumPrice().compareTo(p.getMinimumPrice()) != 0) {
&& req.getMinimumPrice().compareTo(goodsTypeInfo.getMinimumPrice()) != 0) {
log.warn("商品价格变更,最低限价不一致,goodsCode={}, reqMinPrice={}, dbMinPrice={}", log.warn("商品价格变更,最低限价不一致,goodsCode={}, reqMinPrice={}, dbMinPrice={}",
req.getGoodsCode(), req.getMinimumPrice(), goodsTypeInfo.getMinimumPrice()); req.getGoodsCode(), req.getMinimumPrice(), p.getMinimumPrice());
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, itemName + "的产品信息存在变更,请重新选择"); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, itemName + "的产品信息存在变更,请重新选择");
} }
break;
default:
log.error("异常类型无匹配");
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "商品类型错误");
} }
p.setProductName(req.getProductName()); p.setProductName(req.getProductName());
...@@ -806,9 +822,15 @@ public class MarketingActivityService { ...@@ -806,9 +822,15 @@ public class MarketingActivityService {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private void batchInsertItems(Integer activityProductId, String packageCode, List<MarketingActivityProductItemReqDTO> items, String createdBy) { private void batchInsertItems(Integer activityProductId, MarketingActivityProductReqDTO productReq, String createdBy) {
String packageCode = productReq.getPackageCode();
List<MarketingActivityProductItemReqDTO> items = productReq.getPackageItems();
if (CollectionUtils.isEmpty(items)) return; if (CollectionUtils.isEmpty(items)) return;
List<MarketingActivityProductItem> list = items.stream().map(req -> { List<MarketingActivityProductItem> list = items.stream().map(req -> {
String itemLabel = StringUtils.hasText(productReq.getCarSeriesName()) ? productReq.getCarSeriesName() + " " : "";
itemLabel += StringUtils.hasText(req.getGoodsName()) ? req.getGoodsName() : req.getGoodsCode();
MarketingActivityProductItem item = new MarketingActivityProductItem(); MarketingActivityProductItem item = new MarketingActivityProductItem();
item.setActivityProductId(activityProductId); item.setActivityProductId(activityProductId);
item.setPackageCode(packageCode); item.setPackageCode(packageCode);
...@@ -817,19 +839,16 @@ public class MarketingActivityService { ...@@ -817,19 +839,16 @@ public class MarketingActivityService {
item.setUpgradeProductId(req.getUpgradeProductId()); item.setUpgradeProductId(req.getUpgradeProductId());
item.setGoodsAlias(req.getGoodsAlias()); item.setGoodsAlias(req.getGoodsAlias());
// 查询 goods_type/goods_type_name/最低限价(实时) // 查询 goods_type/goods_type_name/最低限价(实时)
GoodsTypeInfoDTO gti = lookupGoodsTypeInfo(req.getGoodsCode()); GoodsTypeInfoDTO gti = lookupGoodsTypeInfo(itemLabel, req.getGoodsCode());
item.setGoodsType(gti.getGoodsType()); item.setGoodsType(gti.getGoodsType());
item.setGoodsTypeName(gti.getGoodsTypeName()); item.setGoodsTypeName(gti.getGoodsTypeName());
item.setMinimumPrice(gti.getMinimumPrice()); item.setMinimumPrice(gti.getMinimumPrice());
// 价格一致性校验:前端传入的最低限价必须与实时查询一致 // 价格一致性校验:前端传入的最低限价必须与实时查询一致
String itemLabel = StringUtils.hasText(req.getGoodsName()) ? req.getGoodsName() : req.getGoodsCode(); if (req.getMinimumPrice().compareTo(item.getMinimumPrice()) != 0) {
if (req.getMinimumPrice() != null && gti.getMinimumPrice() != null
&& req.getMinimumPrice().compareTo(gti.getMinimumPrice()) != 0) {
log.warn("套餐子商品价格变更,最低限价不一致,goodsCode={}, reqMinPrice={}, dbMinPrice={}", log.warn("套餐子商品价格变更,最低限价不一致,goodsCode={}, reqMinPrice={}, dbMinPrice={}",
req.getGoodsCode(), req.getMinimumPrice(), gti.getMinimumPrice()); req.getGoodsCode(), req.getMinimumPrice(), item.getMinimumPrice());
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, itemLabel + "的产品信息存在变更,请重新选择");
itemLabel + "的产品信息存在变更,请重新选择");
} }
item.setCurrentPrice(req.getCurrentPrice()); item.setCurrentPrice(req.getCurrentPrice());
...@@ -846,14 +865,19 @@ public class MarketingActivityService { ...@@ -846,14 +865,19 @@ public class MarketingActivityService {
/** /**
* 根据 goodsCode 查询 goods_type/现售价/最低限价 * 根据 goodsCode 查询 goods_type/现售价/最低限价
*/ */
private GoodsTypeInfoDTO lookupGoodsTypeInfo(String goodsCode) { private GoodsTypeInfoDTO lookupGoodsTypeInfo(String errMsg, String goodsCode) {
if (StringUtils.hasLength(goodsCode)) { if (!StringUtils.hasLength(goodsCode)) {
GoodsTypeInfoDTO result = marketingGoodsQueryMapper.findGoodsTypeInfo(goodsCode); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "商品编码不能为空");
if (result != null) {
return result;
} }
GoodsTypeInfoDTO result = marketingGoodsQueryMapper.findGoodsTypeInfo(goodsCode);
if (result == null) {
log.error("查询商品信息异常, goodsCode:{}", goodsCode);
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, errMsg + "的产品信息存在变更,请重新选择");
} }
return new GoodsTypeInfoDTO(); // 置0,方便比对值
result.setCurrentPrice(Objects.isNull(result.getCurrentPrice()) ? BigDecimal.ZERO : result.getCurrentPrice());
result.setMinimumPrice(Objects.isNull(result.getMinimumPrice()) ? BigDecimal.ZERO : result.getMinimumPrice());
return result;
} }
private void saveOperationLog(Integer activityId, ActivityEventTypeEnum eventType, String operatorId, String operatorName) { private void saveOperationLog(Integer activityId, ActivityEventTypeEnum eventType, String operatorId, String operatorName) {
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
mgi.goods_alias AS goodsAlias, mgi.goods_alias AS goodsAlias,
gi.goods_type AS goodsType, gi.goods_type AS goodsType,
gi.goods_type_name AS goodsTypeName, gi.goods_type_name AS goodsTypeName,
mgi.status AS goodsStatus,
COALESCE(mgi.sell_price, 0) AS currentPrice, COALESCE(mgi.sell_price, 0) AS currentPrice,
COALESCE(mgi.min_sell_price, 0) AS minimumPrice COALESCE(mgi.min_sell_price, 0) AS minimumPrice
FROM dj_car_life_merchant_goods_info mgi FROM dj_car_life_merchant_goods_info mgi
......
...@@ -90,4 +90,17 @@ ...@@ -90,4 +90,17 @@
ORDER BY mgi.id ASC ORDER BY mgi.id ASC
</select> </select>
<select id="findPackageByCode" resultType="cn.com.glsx.dj.strategy.dto.PackageRespDTO">
SELECT
p.package_code AS packageId,
p.package_name AS packageName,
p.scene_type AS scene,
p.base_scene_code AS baseSceneCode
FROM dj_car_life_merchant_package_goods_info p
WHERE p.deleted_flag = 'N'
AND p.status = 1
AND p.package_code = #{packageCode}
limit 1
</select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!