mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-09 15:51:52 +08:00
promotion:code review 拼团相关的部分代码
This commit is contained in:
@@ -52,11 +52,11 @@ public class AppActivityController {
|
||||
@Operation(summary = "获得多个商品,近期参与的每个活动") // 每种活动,只返回一个;key 为 SPU 编号
|
||||
@Parameter(name = "spuIds", description = "商品编号数组", required = true)
|
||||
public CommonResult<Map<Long, List<AppActivityRespVO>>> getActivityListBySpuIds(@RequestParam("spuIds") List<Long> spuIds) {
|
||||
|
||||
if (CollUtil.isEmpty(spuIds)) {
|
||||
return success(MapUtil.empty());
|
||||
}
|
||||
|
||||
// TODO @puhui999:要避免这种 1+n 的查询
|
||||
Map<Long, List<AppActivityRespVO>> map = new HashMap<>(spuIds.size());
|
||||
spuIds.forEach(spuId -> {
|
||||
map.put(spuId, getAppActivityRespVOList(spuId));
|
||||
@@ -65,35 +65,38 @@ public class AppActivityController {
|
||||
}
|
||||
|
||||
private List<AppActivityRespVO> getAppActivityRespVOList(Long spuId) {
|
||||
List<AppActivityRespVO> respList = new ArrayList<>();
|
||||
List<AppActivityRespVO> activityList = new ArrayList<>();
|
||||
// 拼团活动
|
||||
CombinationActivityDO combination = combinationActivityService.getCombinationActivityBySpuId(spuId);
|
||||
if (combination != null) {
|
||||
respList.add(new AppActivityRespVO()
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(combination.getId())
|
||||
.setType(PromotionTypeEnum.COMBINATION_ACTIVITY.getType())
|
||||
.setName(combination.getName())
|
||||
.setStartTime(combination.getStartTime())
|
||||
.setEndTime(combination.getEndTime()));
|
||||
}
|
||||
// 秒杀活动
|
||||
SeckillActivityDO seckill = seckillActivityService.getSeckillActivityBySpuId(spuId);
|
||||
if (seckill != null) {
|
||||
respList.add(new AppActivityRespVO()
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(seckill.getId())
|
||||
.setType(PromotionTypeEnum.SECKILL_ACTIVITY.getType())
|
||||
.setName(seckill.getName())
|
||||
.setStartTime(seckill.getStartTime())
|
||||
.setEndTime(seckill.getEndTime()));
|
||||
}
|
||||
// 秒杀活动
|
||||
BargainActivityDO bargain = bargainActivityService.getBargainActivityBySpuId(spuId);
|
||||
if (bargain != null) {
|
||||
respList.add(new AppActivityRespVO()
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(bargain.getId())
|
||||
.setType(PromotionTypeEnum.BARGAIN_ACTIVITY.getType())
|
||||
.setName(bargain.getName())
|
||||
.setStartTime(bargain.getStartTime())
|
||||
.setEndTime(bargain.getEndTime()));
|
||||
}
|
||||
return respList;
|
||||
return activityList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -76,6 +76,8 @@ public class CombinationRecordDO extends BaseDO {
|
||||
* 用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
// TODO @puhui999:要不去掉这 2 个字段,通过读取解决?如果去掉,相关接口都要处理下哈;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
|
@@ -83,6 +83,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
|
||||
.last("LIMIT " + count));
|
||||
}
|
||||
|
||||
// TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢
|
||||
default BargainActivityDO selectOne(Long spuId) {
|
||||
return selectOne(new LambdaQueryWrapperX<BargainActivityDO>()
|
||||
.eq(BargainActivityDO::getSpuId, spuId)
|
||||
|
@@ -40,6 +40,7 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi
|
||||
.last("LIMIT " + count));
|
||||
}
|
||||
|
||||
// TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢
|
||||
default CombinationActivityDO selectOne(Long spuId) {
|
||||
return selectOne(new LambdaQueryWrapperX<CombinationActivityDO>()
|
||||
.eq(CombinationActivityDO::getSpuId, spuId)
|
||||
|
@@ -84,8 +84,8 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
||||
default List<CombinationRecordDO> selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status,
|
||||
Long headId, Integer count) {
|
||||
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||
.eq(CombinationRecordDO::getActivityId, activityId)
|
||||
.eq(CombinationRecordDO::getStatus, status)
|
||||
.eqIfPresent(CombinationRecordDO::getActivityId, activityId)
|
||||
.eqIfPresent(CombinationRecordDO::getStatus, status)
|
||||
.eq(CombinationRecordDO::getHeadId, headId)
|
||||
.orderByDesc(CombinationRecordDO::getId)
|
||||
.last("LIMIT " + count));
|
||||
|
@@ -56,6 +56,7 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
|
||||
.apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0"));
|
||||
}
|
||||
|
||||
// TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢;
|
||||
default SeckillActivityDO selectOne(Long spuId) {
|
||||
return selectOne(new LambdaQueryWrapperX<SeckillActivityDO>()
|
||||
.eq(SeckillActivityDO::getSpuId, spuId)
|
||||
|
@@ -67,6 +67,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
@Resource
|
||||
private TradeOrderApi tradeOrderApi;
|
||||
|
||||
// TODO @芋艿:在详细预览下;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) {
|
||||
@@ -78,6 +79,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
recordMapper.updateById(record);
|
||||
}
|
||||
|
||||
// TODO @芋艿:在详细预览下;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime) {
|
||||
|
Reference in New Issue
Block a user