【同步】BOOT 和 CLOUD 的功能
This commit is contained in:
@@ -122,10 +122,8 @@ public interface CombinationActivityConvert {
|
||||
return convert(reqDTO).setVirtualGroup(false)
|
||||
.setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()) // 创建后默认状态为进行中
|
||||
.setUserSize(activity.getUserSize()).setUserCount(1) // 默认就是 1 插入后会接着更新一次所有的拼团记录
|
||||
// 用户信息
|
||||
.setNickname(user.getNickname()).setAvatar(user.getAvatar())
|
||||
// 商品信息
|
||||
.setSpuName(spu.getName()).setPicUrl(sku.getPicUrl());
|
||||
.setNickname(user.getNickname()).setAvatar(user.getAvatar()) // 用户信息
|
||||
.setSpuName(spu.getName()).setPicUrl(ObjectUtil.defaultIfBlank(sku.getPicUrl(), spu.getPicUrl())); // 商品信息
|
||||
}
|
||||
|
||||
default List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list,
|
||||
|
||||
@@ -31,9 +31,13 @@ import java.util.List;
|
||||
public class CouponTemplateDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 不限制领取数量
|
||||
* 领取数量 - 不限制
|
||||
*/
|
||||
public static final Integer TIME_LIMIT_COUNT_MAX = -1;
|
||||
public static final Integer TAKE_LIMIT_COUNT_MAX = -1;
|
||||
/**
|
||||
* 发放数量 - 不限制
|
||||
*/
|
||||
public static final Integer TOTAL_COUNT_MAX = -1;
|
||||
|
||||
// ========== 基本信息 BEGIN ==========
|
||||
/**
|
||||
|
||||
@@ -40,10 +40,16 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
|
||||
.orderByDesc(CouponTemplateDO::getId));
|
||||
}
|
||||
|
||||
default void updateTakeCount(Long id, Integer incrCount) {
|
||||
update(null, new LambdaUpdateWrapper<CouponTemplateDO>()
|
||||
default int updateTakeCount(Long id, Integer incrCount) {
|
||||
LambdaUpdateWrapper<CouponTemplateDO> updateWrapper = new LambdaUpdateWrapper<CouponTemplateDO>()
|
||||
.eq(CouponTemplateDO::getId, id)
|
||||
.setSql("take_count = take_count + " + incrCount));
|
||||
.setSql("take_count = take_count + " + incrCount);
|
||||
// 增加已领取的数量(incrCount 为正数),需要考虑发放数量 totalCount 的限制
|
||||
if (incrCount > 0) {
|
||||
updateWrapper.and(i -> i.apply("take_count < total_count")
|
||||
.or().eq(CouponTemplateDO::getTotalCount, CouponTemplateDO.TOTAL_COUNT_MAX));
|
||||
}
|
||||
return update(updateWrapper);
|
||||
}
|
||||
|
||||
default List<CouponTemplateDO> selectListByTakeType(Integer takeType) {
|
||||
|
||||
@@ -154,7 +154,7 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
||||
|
||||
@Override
|
||||
public List<BargainActivityDO> getBargainActivityList(Set<Long> ids) {
|
||||
return bargainActivityMapper.selectBatchIds(ids);
|
||||
return bargainActivityMapper.selectByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
||||
activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId));
|
||||
}
|
||||
// 查找是否有其它活动,选择了该产品
|
||||
List<CombinationActivityDO> matchActivityList = filterList(activityList, activity -> ObjectUtil.equal(activity.getId(), spuId));
|
||||
List<CombinationActivityDO> matchActivityList = filterList(activityList, activity -> ObjectUtil.equal(activity.getSpuId(), spuId));
|
||||
if (CollUtil.isNotEmpty(matchActivityList)) {
|
||||
throw exception(COMBINATION_ACTIVITY_SPU_CONFLICTS);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
||||
*/
|
||||
private void validateProductExists(Long spuId, List<CombinationProductBaseVO> products) {
|
||||
// 1. 校验商品 spu 是否存在
|
||||
ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData();
|
||||
ProductSpuRespDTO spu = productSpuApi.getSpu(spuId);
|
||||
if (spu == null) {
|
||||
throw exception(SPU_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@@ -50,8 +50,6 @@ import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.bef
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.MessageTemplateConstants.COMBINATION_SUCCESS;
|
||||
|
||||
// TODO 芋艿:等拼团记录做完,完整 review 下
|
||||
|
||||
/**
|
||||
* 拼团记录 Service 实现类
|
||||
*
|
||||
@@ -219,9 +217,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
|
||||
// 3. 拼团成功发送订阅消息
|
||||
if (updateSuccess && isFull) {
|
||||
records.forEach(item -> {
|
||||
getSelf().sendCombinationResultMessage(item);
|
||||
});
|
||||
records.forEach(item -> getSelf().sendCombinationResultMessage(item));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,6 @@ public class CouponServiceImpl implements CouponService {
|
||||
|
||||
// 4. 增加优惠劵模板的领取数量
|
||||
couponTemplateService.updateCouponTemplateTakeCount(template.getId(), userIds.size());
|
||||
|
||||
return convertMultiMap(couponList, CouponDO::getUserId, CouponDO::getId);
|
||||
}
|
||||
|
||||
@@ -281,7 +280,7 @@ public class CouponServiceImpl implements CouponService {
|
||||
}
|
||||
// 校验发放数量不能过小(仅在 CouponTakeTypeEnum.USER 用户领取时)
|
||||
if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType())
|
||||
&& ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
|
||||
&& ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TAKE_LIMIT_COUNT_MAX) // 非不限制
|
||||
&& couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
|
||||
throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 优惠劵模板 Service 实现类
|
||||
@@ -60,7 +59,7 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
|
||||
CouponTemplateDO couponTemplate = validateCouponTemplateExists(updateReqVO.getId());
|
||||
// 校验发放数量不能过小(仅在 CouponTakeTypeEnum.USER 用户领取时)
|
||||
if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType())
|
||||
&& ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
|
||||
&& ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TAKE_LIMIT_COUNT_MAX) // 非不限制
|
||||
&& updateReqVO.getTotalCount() < couponTemplate.getTakeCount()) {
|
||||
throw exception(COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL, couponTemplate.getTakeCount());
|
||||
}
|
||||
@@ -116,7 +115,10 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
|
||||
|
||||
@Override
|
||||
public void updateCouponTemplateTakeCount(Long id, int incrCount) {
|
||||
couponTemplateMapper.updateTakeCount(id, incrCount);
|
||||
int updateCount = couponTemplateMapper.updateTakeCount(id, incrCount);
|
||||
if (updateCount == 0) {
|
||||
throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,7 +134,7 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
|
||||
|
||||
@Override
|
||||
public List<CouponTemplateDO> getCouponTemplateList(Collection<Long> ids) {
|
||||
return couponTemplateMapper.selectBatchIds(ids);
|
||||
return couponTemplateMapper.selectByIds(ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpd
|
||||
import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyPageMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class DiyPageServiceImpl implements DiyPageService {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return diyPageMapper.selectBatchIds(ids);
|
||||
return diyPageMapper.selectByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,10 +11,10 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.Seck
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckill.SeckillConfigConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
@@ -132,7 +132,7 @@ public class SeckillConfigServiceImpl implements SeckillConfigService {
|
||||
return;
|
||||
}
|
||||
// 1. 如果有数量不匹配,说明有不存在的,则抛出 SECKILL_CONFIG_NOT_EXISTS 业务异常
|
||||
List<SeckillConfigDO> configs = seckillConfigMapper.selectBatchIds(ids);
|
||||
List<SeckillConfigDO> configs = seckillConfigMapper.selectByIds(ids);
|
||||
if (configs.size() != ids.size()) {
|
||||
throw exception(SECKILL_CONFIG_NOT_EXISTS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user