From 474eebd8c9e91e6f271d5cbb4ea3c01e0a0073ce Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 6 Oct 2023 00:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E6=B4=BB=E5=8A=A8=EF=BC=9A?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=88=9B=E5=BB=BA=E6=8B=BC=E5=9B=A2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E7=9A=84=E6=A0=A1=E9=AA=8C=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CombinationRecordServiceImpl.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index f21e1942e..d4f948f6e 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java @@ -164,22 +164,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { @Transactional(rollbackFor = Exception.class) public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { // 1.1、 校验拼团活动 - CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(reqDTO.getActivityId()); - // 1.2 校验是否超出单次限购数量 - if (reqDTO.getCount() > activity.getSingleLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); - } - // 1.3、校验是否有拼团记录 - List records = getRecordListByUserIdAndActivityId(reqDTO.getUserId(), reqDTO.getActivityId()); - if (CollUtil.isEmpty(records)) { - return; - } - // 1.4、校验是否超出总限购数量 - Integer sumValue = getSumValue(convertList(records, CombinationRecordDO::getCount, - item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())), i -> i, Integer::sum); - if ((sumValue + reqDTO.getCount()) > activity.getTotalLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); - } + KeyValue keyValue = validateCombinationRecord( + reqDTO.getActivityId(), reqDTO.getUserId(), reqDTO.getSkuId(), reqDTO.getCount()); + CombinationActivityDO activity = keyValue.getKey(); + // 2、 校验用户是否参加了其它拼团 List recordDOList = recordMapper.selectListByUserIdAndStatus(reqDTO.getUserId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); if (CollUtil.isNotEmpty(recordDOList)) {