mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 07:11:52 +08:00
promotion:code review 拼团相关的部分代码
This commit is contained in:
parent
ec2c3e508a
commit
c917f01d83
@ -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) {
|
||||
|
@ -16,7 +16,7 @@ public enum TradeOrderOperateTypeEnum {
|
||||
MEMBER_CREATE(1, "用户下单"),
|
||||
ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,实际支付金额为 {newPayPrice} 元"),
|
||||
MEMBER_PAY(10, "用户付款成功"),
|
||||
SYSTEM_UP_ADDRESS(11, "订单 {orderId} 收货地址修改"),
|
||||
ADMIN_UPDATE_ADDRESS(11, "收货地址修改"),
|
||||
ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"),
|
||||
MEMBER_RECEIVE(30, "用户已收货"),
|
||||
SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"),
|
||||
|
@ -738,19 +738,18 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_UP_ADDRESS)
|
||||
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS)
|
||||
public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) {
|
||||
// 校验交易订单
|
||||
TradeOrderDO order = validateOrderExists(reqVO.getId());
|
||||
// TODO @puhui999:是否需要校验订单是否发货
|
||||
// TODO 发货后是否支持修改收货地址
|
||||
// TODO 发货后是否支持修改收货地址;回答:发货后,不允许修改;
|
||||
|
||||
// 更新
|
||||
tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO));
|
||||
|
||||
// 记录订单日志
|
||||
TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(),
|
||||
MapUtil.<String, Object>builder().put("orderId", order.getId()).build());
|
||||
TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user