promotion:修复拼团下单时,相关字段记录不正确的情况。

This commit is contained in:
YunaiV 2023-10-07 07:09:15 +08:00
parent c8f1269d6e
commit c7b5df930e
7 changed files with 21 additions and 9 deletions

View File

@ -77,6 +77,7 @@ public interface CombinationRecordApi {
* @param count 数量
* @return 拼团信息
*/
// TODO @puhuiuserId 放最前面然后应该还有个 headId 参数
CombinationValidateJoinRespDTO validateJoinCombination(Long activityId, Long userId, Long skuId, Integer count);
}

View File

@ -108,7 +108,7 @@ public interface CombinationActivityConvert {
CombinationActivityDO activity, MemberUserRespDTO user,
ProductSpuRespDTO spu, ProductSkuRespDTO sku) {
return convert(reqDTO)
.setCount(reqDTO.getCount())
.setCount(reqDTO.getCount()).setUserCount(1)
.setVirtualGroup(false)
.setExpireTime(activity.getStartTime().plusHours(activity.getLimitDuration()))
.setUserSize(activity.getUserSize())

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.KeyValue;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
@ -97,8 +98,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
item.setStatus(CombinationRecordStatusEnum.SUCCESS.getStatus());
}
});
recordMapper.updateBatch(records);
}
recordMapper.updateBatch(records);
}
private CombinationRecordDO validateCombinationRecord(Long userId, Long orderId) {
@ -179,7 +180,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED);
}
// 3校验活动是否开启
if (LocalDateTime.now().isAfter(activity.getStartTime())) {
if (!LocalDateTimeUtils.beforeNow(activity.getStartTime())) {
throw exception(COMBINATION_RECORD_FAILED_TIME_NOT_START);
}
// 4校验当前活动是否过期

View File

@ -207,12 +207,16 @@ public interface TradeOrderConvert {
default TradePriceCalculateReqBO convert(Long userId, AppTradeOrderSettlementReqVO settlementReqVO,
List<CartDO> cartList) {
TradePriceCalculateReqBO reqBO = new TradePriceCalculateReqBO().setUserId(userId)
.setItems(new ArrayList<>(settlementReqVO.getItems().size()))
.setCouponId(settlementReqVO.getCouponId()).setPointStatus(settlementReqVO.getPointStatus())
// 物流信息
.setDeliveryType(settlementReqVO.getDeliveryType()).setAddressId(settlementReqVO.getAddressId())
.setPickUpStoreId(settlementReqVO.getPickUpStoreId())
.setItems(new ArrayList<>(settlementReqVO.getItems().size()))
// 各种活动
.setSeckillActivityId(settlementReqVO.getSeckillActivityId())
.setBargainRecordId(settlementReqVO.getBargainRecordId());
.setBargainRecordId(settlementReqVO.getBargainRecordId())
.setCombinationActivityId(settlementReqVO.getCombinationActivityId())
.setCombinationHeadId(settlementReqVO.getCombinationHeadId());
// 商品项的构建
Map<Long, CartDO> cartMap = convertMap(cartList, CartDO::getId);
for (AppTradeOrderSettlementReqVO.Item item : settlementReqVO.getItems()) {

View File

@ -318,10 +318,16 @@ public class TradeOrderDO extends BaseDO {
*/
private Long combinationActivityId;
/**
* 团长编号
* 拼团团长编号
*
* 关联 CombinationRecordDO headId 字段
*/
private Long combinationHeadId;
/**
* 拼团记录编号
*
* 关联 CombinationRecordDO id 字段
*/
private Long combinationHeadId;
private Long combinationRecordId;
}

View File

@ -47,7 +47,8 @@ public class TradeCombinationHandler implements TradeOrderHandler {
// 获取商品信息
TradeOrderItemDO item = orderItems.get(0);
// 创建砍价记录
// 创建拼团记录
// TODO puhui这里应该先不创建等支付好才去创建另外创建好后需要更新编号到订单
combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, item));
}

View File

@ -31,7 +31,6 @@ public class TradeCombinationActivityPriceCalculator implements TradePriceCalcul
if (param.getCombinationActivityId() == null) {
return;
}
Assert.isTrue(param.getItems().size() == 1, "拼团时,只允许选择一个商品");
// 2. 校验是否可以参与拼团
TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0);