mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
code review:拼团、砍价活动
This commit is contained in:
parent
20f5834d9a
commit
dc1347184f
@ -102,6 +102,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
return recordDO;
|
return recordDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @芋艿:在详细预览下;
|
||||||
@Override
|
@Override
|
||||||
public void validateCombinationRecord(Long activityId, Long userId, Long skuId, Integer count) {
|
public void validateCombinationRecord(Long activityId, Long userId, Long skuId, Integer count) {
|
||||||
// 1.1 校验拼团活动是否存在
|
// 1.1 校验拼团活动是否存在
|
||||||
@ -132,12 +133,14 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
}
|
}
|
||||||
// 5.1、查询关联的订单是否已经支付
|
// 5.1、查询关联的订单是否已经支付
|
||||||
// 当前 activityId 已经有未支付的订单,不允许在发起新的;要么支付,要么去掉先;
|
// 当前 activityId 已经有未支付的订单,不允许在发起新的;要么支付,要么去掉先;
|
||||||
|
// TODO 芋艿:看看是不是可以删除掉;
|
||||||
Integer orderStatus = tradeOrderApi.getOrderStatus(record.getOrderId());
|
Integer orderStatus = tradeOrderApi.getOrderStatus(record.getOrderId());
|
||||||
if (ObjectUtil.equal(orderStatus, TradeOrderStatusEnum.UNPAID.getStatus())) {
|
if (ObjectUtil.equal(orderStatus, TradeOrderStatusEnum.UNPAID.getStatus())) {
|
||||||
throw exception(COMBINATION_RECORD_FAILED_ORDER_STATUS_UNPAID);
|
throw exception(COMBINATION_RECORD_FAILED_ORDER_STATUS_UNPAID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO 芋艿:在详细 review 下;
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||||
|
@ -7,6 +7,7 @@ package cn.iocoder.yudao.module.trade.api.order;
|
|||||||
*/
|
*/
|
||||||
public interface TradeOrderApi {
|
public interface TradeOrderApi {
|
||||||
|
|
||||||
|
// TODO 芋艿:看看是不是可以删除掉;
|
||||||
/**
|
/**
|
||||||
* 获取订单状态
|
* 获取订单状态
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
|
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||||
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
|
||||||
@ -67,7 +68,7 @@ public class AppTradeOrderSettlementReqVO {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean isValidActivityItems() {
|
public boolean isValidActivityItems() {
|
||||||
// 校验是否是活动订单
|
// 校验是否是活动订单
|
||||||
if (seckillActivityId == null && combinationActivityId == null && combinationHeadId == null) {
|
if (ObjUtil.isAllEmpty(seckillActivityId, combinationActivityId, combinationHeadId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 校验订单项是否超出
|
// 校验订单项是否超出
|
||||||
|
@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
|||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class TradeBargainHandler extends TradeOrderDefaultHandler {
|
public class TradeBargainHandler implements TradeOrderHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BargainActivityApi bargainActivityApi;
|
private BargainActivityApi bargainActivityApi;
|
||||||
|
@ -17,7 +17,7 @@ import javax.annotation.Resource;
|
|||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class TradeCombinationHandler extends TradeOrderDefaultHandler {
|
public class TradeCombinationHandler implements TradeOrderHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CombinationRecordApi combinationRecordApi;
|
private CombinationRecordApi combinationRecordApi;
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.trade.service.order.handler;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.trade.service.order.bo.TradeAfterOrderCreateReqBO;
|
|
||||||
import cn.iocoder.yudao.module.trade.service.order.bo.TradeAfterPayOrderReqBO;
|
|
||||||
import cn.iocoder.yudao.module.trade.service.order.bo.TradeBeforeOrderCreateReqBO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单活动特殊逻辑处理器 handler 默认抽象实现类
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
public abstract class TradeOrderDefaultHandler implements TradeOrderHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeOrderCreate(TradeBeforeOrderCreateReqBO reqBO) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterOrderCreate(TradeAfterOrderCreateReqBO reqBO) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterPayOrder(TradeAfterPayOrderReqBO reqBO) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelOrder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -17,25 +17,25 @@ public interface TradeOrderHandler {
|
|||||||
*
|
*
|
||||||
* @param reqBO 请求
|
* @param reqBO 请求
|
||||||
*/
|
*/
|
||||||
void beforeOrderCreate(TradeBeforeOrderCreateReqBO reqBO);
|
default void beforeOrderCreate(TradeBeforeOrderCreateReqBO reqBO) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单创建后
|
* 订单创建后
|
||||||
*
|
*
|
||||||
* @param reqBO 请求
|
* @param reqBO 请求
|
||||||
*/
|
*/
|
||||||
void afterOrderCreate(TradeAfterOrderCreateReqBO reqBO);
|
default void afterOrderCreate(TradeAfterOrderCreateReqBO reqBO) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付订单后
|
* 支付订单后
|
||||||
*
|
*
|
||||||
* @param reqBO 请求
|
* @param reqBO 请求
|
||||||
*/
|
*/
|
||||||
void afterPayOrder(TradeAfterPayOrderReqBO reqBO);
|
default void afterPayOrder(TradeAfterPayOrderReqBO reqBO) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单取消
|
* 订单取消
|
||||||
*/
|
*/
|
||||||
void cancelOrder();
|
default void cancelOrder() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
|||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class TradeSeckillHandler extends TradeOrderDefaultHandler {
|
public class TradeSeckillHandler implements TradeOrderHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SeckillActivityApi seckillActivityApi;
|
private SeckillActivityApi seckillActivityApi;
|
||||||
|
@ -98,19 +98,9 @@ public class TradePriceCalculateRespBO {
|
|||||||
* VIP 减免金额,单位:分
|
* VIP 减免金额,单位:分
|
||||||
*/
|
*/
|
||||||
private Integer vipPrice;
|
private Integer vipPrice;
|
||||||
/**
|
|
||||||
* 秒杀、拼团、砍价活动商品的总金额,单位:分
|
|
||||||
*
|
|
||||||
* 基于 {@link OrderItem#getActivityPrice()} ()} * {@link OrderItem#getCount()} 求和
|
|
||||||
*/
|
|
||||||
private Integer activityPrice;
|
|
||||||
/**
|
/**
|
||||||
* 最终购买金额(总),单位:分
|
* 最终购买金额(总),单位:分
|
||||||
*
|
*
|
||||||
* ==========活动情况===========
|
|
||||||
* = {@link #activityPrice}
|
|
||||||
* + {@link #deliveryPrice}
|
|
||||||
* ==========正常情况===========
|
|
||||||
* = {@link #totalPrice}
|
* = {@link #totalPrice}
|
||||||
* - {@link #couponPrice}
|
* - {@link #couponPrice}
|
||||||
* - {@link #pointPrice}
|
* - {@link #pointPrice}
|
||||||
@ -186,16 +176,9 @@ public class TradePriceCalculateRespBO {
|
|||||||
* VIP 减免金额,单位:分
|
* VIP 减免金额,单位:分
|
||||||
*/
|
*/
|
||||||
private Integer vipPrice;
|
private Integer vipPrice;
|
||||||
/**
|
|
||||||
* 秒杀、拼团、砍价活动商品的金额,单位:分
|
|
||||||
*/
|
|
||||||
private Integer activityPrice;
|
|
||||||
/**
|
/**
|
||||||
* 应付金额(总),单位:分
|
* 应付金额(总),单位:分
|
||||||
* ==========活动情况===========
|
*
|
||||||
* = {@link #activityPrice} * {@link #count}
|
|
||||||
* + {@link #deliveryPrice}
|
|
||||||
* ==========正常情况===========
|
|
||||||
* = {@link #price} * {@link #count}
|
* = {@link #price} * {@link #count}
|
||||||
* - {@link #couponPrice}
|
* - {@link #couponPrice}
|
||||||
* - {@link #pointPrice}
|
* - {@link #pointPrice}
|
||||||
|
@ -105,9 +105,6 @@ public class TradePriceCalculatorHelper {
|
|||||||
if (!item.getSelected()) {
|
if (!item.getSelected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO puhui: 需要在这里计算活动的价格
|
|
||||||
// ========== 一、活动情况 ==========
|
|
||||||
// ========== 二、正常情况 ==========
|
|
||||||
price.setTotalPrice(price.getTotalPrice() + item.getPrice() * item.getCount());
|
price.setTotalPrice(price.getTotalPrice() + item.getPrice() * item.getCount());
|
||||||
price.setDiscountPrice(price.getDiscountPrice() + item.getDiscountPrice());
|
price.setDiscountPrice(price.getDiscountPrice() + item.getDiscountPrice());
|
||||||
price.setDeliveryPrice(price.getDeliveryPrice() + item.getDeliveryPrice());
|
price.setDeliveryPrice(price.getDeliveryPrice() + item.getDeliveryPrice());
|
||||||
|
@ -46,7 +46,7 @@ public class TradeSeckillActivityPriceCalculator implements TradePriceCalculator
|
|||||||
orderItem.getSkuId(), orderItem.getCount());
|
orderItem.getSkuId(), orderItem.getCount());
|
||||||
|
|
||||||
// 3.1 记录优惠明细
|
// 3.1 记录优惠明细
|
||||||
Integer discountPrice = orderItem.getPayPrice() - seckillActivity.getSeckillPrice();
|
Integer discountPrice = orderItem.getPayPrice() - seckillActivity.getSeckillPrice() * orderItem.getCount();
|
||||||
TradePriceCalculatorHelper.addPromotion(result, orderItem,
|
TradePriceCalculatorHelper.addPromotion(result, orderItem,
|
||||||
param.getSeckillActivityId(), seckillActivity.getName(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(),
|
param.getSeckillActivityId(), seckillActivity.getName(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(),
|
||||||
StrUtil.format("秒杀活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)),
|
StrUtil.format("秒杀活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)),
|
||||||
|
Loading…
Reference in New Issue
Block a user