修复拼团商品使用优惠券无效问题,修复拼团活动延时任务无效问题

This commit is contained in:
paulGao 2021-12-31 15:19:17 +08:00
parent 20436653af
commit 0c4aef307a
9 changed files with 46 additions and 14 deletions

View File

@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import java.util.List;
/**
@ -122,4 +123,18 @@ public class GlobalControllerExceptionHandler {
return ResultUtil.error(ResultCode.PARAMS_ERROR);
}
/**
* bean校验未通过异常
*
* @see javax.validation.Valid
* @see org.springframework.validation.Validator
* @see org.springframework.validation.DataBinder
*/
@ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ResultMessage<Object> constraintViolationExceptionHandler(HttpServletRequest request, final Exception e, HttpServletResponse response) {
ConstraintViolationException exception = (ConstraintViolationException) e;
return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), exception.getMessage());
}
}

View File

@ -62,6 +62,22 @@ public class RenderStepStatement {
RenderStepEnums.DISTRIBUTION,
RenderStepEnums.PLATFORM_COMMISSION
};
/**
* 交易创建前渲染
* 渲染购物车 生成SN 分销人员佣金渲染 平台佣金渲染
*/
public static RenderStepEnums[] pintuanTradeRender = {
RenderStepEnums.CHECK_DATA,
RenderStepEnums.SKU_PROMOTION,
RenderStepEnums.COUPON,
RenderStepEnums.SKU_FREIGHT,
RenderStepEnums.CART_PRICE,
RenderStepEnums.CART_SN,
RenderStepEnums.DISTRIBUTION,
RenderStepEnums.PLATFORM_COMMISSION
};
/**
* 交易创建前渲染
* 渲染购物车 生成SN 分销人员佣金渲染 平台佣金渲染

View File

@ -71,6 +71,8 @@ public class TradeBuilder {
//需要对购物车渲染
if (isSingle(checkedWay)) {
renderCartBySteps(tradeDTO, RenderStepStatement.checkedSingleRender);
} else if (checkedWay.equals(CartTypeEnum.PINTUAN)) {
renderCartBySteps(tradeDTO, RenderStepStatement.pintuanTradeRender);
} else {
renderCartBySteps(tradeDTO, RenderStepStatement.checkedRender);
}
@ -93,7 +95,9 @@ public class TradeBuilder {
//需要对购物车渲染
if (isSingle(checkedWay)) {
renderCartBySteps(tradeDTO, RenderStepStatement.singleTradeRender);
} else {
} else if (checkedWay.equals(CartTypeEnum.PINTUAN)) {
renderCartBySteps(tradeDTO, RenderStepStatement.pintuanTradeRender);
} else {
renderCartBySteps(tradeDTO, RenderStepStatement.tradeRender);
}
@ -110,7 +114,7 @@ public class TradeBuilder {
private boolean isSingle(CartTypeEnum checkedWay) {
//拼团 积分 砍价商品
return (checkedWay.equals(CartTypeEnum.PINTUAN) || checkedWay.equals(CartTypeEnum.POINTS) || checkedWay.equals(CartTypeEnum.KANJIA));
return (checkedWay.equals(CartTypeEnum.POINTS) || checkedWay.equals(CartTypeEnum.KANJIA));
}
/**

View File

@ -587,6 +587,9 @@ public class CartServiceImpl implements CartService {
if (promotionsGoods != null && promotionsGoods.getPrice() != null) {
dataSku.setPromotionFlag(true);
dataSku.setPromotionPrice(promotionsGoods.getPrice());
} else {
dataSku.setPromotionFlag(false);
dataSku.setPromotionPrice(null);
}
}
}

View File

@ -367,7 +367,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//判断是否为拼团订单进行特殊处理
//判断订单类型进行不同的订单确认操作
if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderPromotionType())) {
this.checkPintuanOrder(order.getPromotionId(), order.getParentOrderSn());
String parentOrderSn = CharSequenceUtil.isEmpty(order.getParentOrderSn()) ? orderSn : order.getParentOrderSn();
this.checkPintuanOrder(order.getPromotionId(), parentOrderSn);
} else {
//判断订单类型
if (order.getOrderType().equals(OrderTypeEnum.NORMAL.name())) {
@ -789,10 +790,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
* @param parentOrderSn 拼团父订单编号
*/
private void checkPintuanOrder(String pintuanId, String parentOrderSn) {
//拼团有效参数判定
if (CharSequenceUtil.isEmpty(parentOrderSn)) {
return;
}
//获取拼团配置
Pintuan pintuan = pintuanService.getById(pintuanId);
List<Order> list = this.getPintuanOrder(pintuanId, parentOrderSn);
@ -800,7 +797,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
if (count == 1) {
//如果为开团订单则发布一个一小时的延时任务时间到达后如果未成团则自动结束未开启虚拟成团的情况下
PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage();
long startTime = DateUtil.offsetHour(new Date(), 1).getTime();
// long startTime = DateUtil.offsetHour(new Date(), 1).getTime();
long startTime = DateUtil.offsetMinute(new Date(), 2).getTime();
pintuanOrderMessage.setOrderSn(parentOrderSn);
pintuanOrderMessage.setPintuanId(pintuanId);
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR,

File diff suppressed because one or more lines are too long

View File

@ -126,7 +126,6 @@ public class PromotionServiceImpl implements PromotionService {
case PINTUAN:
Pintuan pintuan = pintuanService.getById(promotionGoods.getPromotionId());
promotionMap.put(esPromotionKey, pintuan);
index.setPromotionPrice(promotionGoods.getPrice());
break;
case FULL_DISCOUNT:
FullDiscount fullDiscount = fullDiscountService.getById(promotionGoods.getPromotionId());
@ -168,7 +167,6 @@ public class PromotionServiceImpl implements PromotionService {
seckill.setStartTime(promotionGoods.getStartTime());
seckill.setEndTime(promotionGoods.getEndTime());
promotionMap.put(seckillKey, seckill);
index.setPromotionPrice(promotionGoods.getPrice());
}
}

View File

@ -309,6 +309,7 @@ public class EsGoodsIndex implements Serializable {
this.intro = sku.getIntro();
this.grade = sku.getGrade();
this.recommend = sku.getRecommend();
this.goodsType = sku.getGoodsType();
this.releaseTime = new Date();
}
}

View File

@ -522,9 +522,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
//促销不为空则进行清洗
promotionMap.entrySet().removeIf(i -> {
BasePromotions promotion = (BasePromotions) i.getValue();
if (i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())) {
goodsIndex.setPromotionPrice(goodsIndex.getPrice());
}
return promotion.getEndTime() != null && promotion.getEndTime().getTime() < DateUtil.date().getTime();
});
}