拼团活动:完善 review 提到的问题
This commit is contained in:
parent
c8a9d68933
commit
c71bdd158a
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.controller.app.activity;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.activity.vo.AppActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
|
@ -21,12 +22,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap;
|
||||
|
||||
@Tag(name = "用户 APP - 营销活动") // 用于提供跨多个活动的 HTTP 接口
|
||||
@RestController
|
||||
|
@ -42,59 +41,72 @@ public class AppActivityController {
|
|||
private BargainActivityService bargainActivityService;
|
||||
|
||||
@GetMapping("/list-by-spu-id")
|
||||
@Operation(summary = "获得单个商品,近期参与的每个活动") // 每种活动,只返回一个
|
||||
@Operation(summary = "获得单个商品,近期参与的每个活动")
|
||||
@Parameter(name = "spuId", description = "商品编号", required = true)
|
||||
public CommonResult<List<AppActivityRespVO>> getActivityListBySpuId(@RequestParam("spuId") Long spuId) {
|
||||
return success(getAppActivityRespVOList(spuId));
|
||||
// 每种活动,只返回一个
|
||||
return success(getAppActivityRespVOList(Collections.singletonList(spuId)));
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-spu-ids")
|
||||
@Operation(summary = "获得多个商品,近期参与的每个活动") // 每种活动,只返回一个;key 为 SPU 编号
|
||||
@Operation(summary = "获得多个商品,近期参与的每个活动")
|
||||
@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));
|
||||
});
|
||||
return success(map);
|
||||
// 每种活动,只返回一个;key 为 SPU 编号
|
||||
return success(convertMultiMap(getAppActivityRespVOList(spuIds), AppActivityRespVO::getSpuId));
|
||||
}
|
||||
|
||||
private List<AppActivityRespVO> getAppActivityRespVOList(Long spuId) {
|
||||
private List<AppActivityRespVO> getAppActivityRespVOList(Collection<Long> spuIds) {
|
||||
if (CollUtil.isEmpty(spuIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<AppActivityRespVO> activityList = new ArrayList<>();
|
||||
// 拼团活动
|
||||
CombinationActivityDO combination = combinationActivityService.getCombinationActivityBySpuId(spuId);
|
||||
if (combination != null) {
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(combination.getId())
|
||||
.setType(PromotionTypeEnum.COMBINATION_ACTIVITY.getType())
|
||||
.setName(combination.getName())
|
||||
.setStartTime(combination.getStartTime())
|
||||
.setEndTime(combination.getEndTime()));
|
||||
List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityBySpuIdsAndStatus(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus());
|
||||
if (CollUtil.isNotEmpty(combinationActivities)) {
|
||||
combinationActivities.forEach(item -> {
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(item.getId())
|
||||
.setType(PromotionTypeEnum.COMBINATION_ACTIVITY.getType())
|
||||
.setName(item.getName())
|
||||
.setSpuId(item.getSpuId())
|
||||
.setStartTime(item.getStartTime())
|
||||
.setEndTime(item.getEndTime()));
|
||||
});
|
||||
}
|
||||
// 秒杀活动
|
||||
SeckillActivityDO seckill = seckillActivityService.getSeckillActivityBySpuId(spuId);
|
||||
if (seckill != null) {
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(seckill.getId())
|
||||
.setType(PromotionTypeEnum.SECKILL_ACTIVITY.getType())
|
||||
.setName(seckill.getName())
|
||||
.setStartTime(seckill.getStartTime())
|
||||
.setEndTime(seckill.getEndTime()));
|
||||
List<SeckillActivityDO> seckillActivities = seckillActivityService.getSeckillActivityBySpuIdsAndStatus(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus());
|
||||
if (CollUtil.isNotEmpty(seckillActivities)) {
|
||||
seckillActivities.forEach(item -> {
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(item.getId())
|
||||
.setType(PromotionTypeEnum.SECKILL_ACTIVITY.getType())
|
||||
.setName(item.getName())
|
||||
.setSpuId(item.getSpuId())
|
||||
.setStartTime(item.getStartTime())
|
||||
.setEndTime(item.getEndTime()));
|
||||
});
|
||||
}
|
||||
// 秒杀活动
|
||||
BargainActivityDO bargain = bargainActivityService.getBargainActivityBySpuId(spuId);
|
||||
if (bargain != null) {
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(bargain.getId())
|
||||
.setType(PromotionTypeEnum.BARGAIN_ACTIVITY.getType())
|
||||
.setName(bargain.getName())
|
||||
.setStartTime(bargain.getStartTime())
|
||||
.setEndTime(bargain.getEndTime()));
|
||||
// 砍价活动
|
||||
List<BargainActivityDO> bargainActivities = bargainActivityService.getBargainActivityBySpuIdsAndStatus(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus());
|
||||
if (CollUtil.isNotEmpty(bargainActivities)) {
|
||||
bargainActivities.forEach(item -> {
|
||||
activityList.add(new AppActivityRespVO()
|
||||
.setId(item.getId())
|
||||
.setType(PromotionTypeEnum.BARGAIN_ACTIVITY.getType())
|
||||
.setName(item.getName())
|
||||
.setSpuId(item.getSpuId())
|
||||
.setStartTime(item.getStartTime())
|
||||
.setEndTime(item.getEndTime()));
|
||||
});
|
||||
}
|
||||
return activityList;
|
||||
}
|
||||
|
|
|
@ -13,12 +13,14 @@ public class AppActivityRespVO {
|
|||
private Long id;
|
||||
|
||||
@Schema(description = "活动类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
// 对应 PromotionTypeEnum 枚举
|
||||
private Integer type;
|
||||
private Integer type; // 对应 PromotionTypeEnum 枚举
|
||||
|
||||
@Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大促")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "spu 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "618")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.Ba
|
|||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -83,12 +85,23 @@ 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)
|
||||
.orderByDesc(BargainActivityDO::getCreateTime)
|
||||
, false);
|
||||
}
|
||||
/**
|
||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||
*
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 砍价活动列表
|
||||
*/
|
||||
@Select("SELECT p1.* " +
|
||||
"FROM promotion_bargain_activity p1 " +
|
||||
"INNER JOIN ( " +
|
||||
" SELECT spu_id, MAX(DISTINCT(create_time)) AS max_create_time " +
|
||||
" FROM promotion_bargain_activity " +
|
||||
" WHERE spu_id IN #{spuIds} " +
|
||||
" GROUP BY spu_id " +
|
||||
") p2 " +
|
||||
"ON p1.spu_id = p2.spu_id AND p1.create_time = p2.max_create_time AND p1.status = #{status} " +
|
||||
"ORDER BY p1.create_time DESC;")
|
||||
List<BargainActivityDO> selectListBySpuIds(Collection<Long> spuIds, Integer status);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -40,12 +43,23 @@ 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)
|
||||
.orderByDesc(CombinationActivityDO::getCreateTime)
|
||||
, false);
|
||||
}
|
||||
/**
|
||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||
*
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 拼团活动列表
|
||||
*/
|
||||
@Select("SELECT p1.* " +
|
||||
"FROM promotion_combination_activity p1 " +
|
||||
"INNER JOIN ( " +
|
||||
" SELECT spu_id, MAX(DISTINCT(create_time)) AS max_create_time " +
|
||||
" FROM promotion_combination_activity " +
|
||||
" WHERE spu_id IN #{spuIds} " +
|
||||
" GROUP BY spu_id " +
|
||||
") p2 " +
|
||||
"ON p1.spu_id = p2.spu_id AND p1.create_time = p2.max_create_time AND p1.status = #{status} " +
|
||||
"ORDER BY p1.create_time DESC;")
|
||||
List<CombinationActivityDO> selectListBySpuIds(@Param("spuIds") Collection<Long> spuIds, @Param("status") Integer status);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppS
|
|||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -56,12 +58,23 @@ 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)
|
||||
.orderByDesc(SeckillActivityDO::getCreateTime)
|
||||
, false);
|
||||
}
|
||||
/**
|
||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||
*
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 秒杀活动列表
|
||||
*/
|
||||
@Select("SELECT p1.* " +
|
||||
"FROM promotion_seckill_activity p1 " +
|
||||
"INNER JOIN ( " +
|
||||
" SELECT spu_id, MAX(DISTINCT(create_time)) AS max_create_time " +
|
||||
" FROM promotion_seckill_activity " +
|
||||
" WHERE spu_id IN #{spuIds} " +
|
||||
" GROUP BY spu_id " +
|
||||
") p2 " +
|
||||
"ON p1.spu_id = p2.spu_id AND p1.create_time = p2.max_create_time AND p1.status = #{status} " +
|
||||
"ORDER BY p1.create_time DESC;")
|
||||
List<SeckillActivityDO> selectListBySpuIds(Collection<Long> spuIds, Integer status);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.Ba
|
|||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -99,11 +100,12 @@ public interface BargainActivityService {
|
|||
List<BargainActivityDO> getBargainActivityListByCount(Integer count);
|
||||
|
||||
/**
|
||||
* 获取指定 spu 编号的活动
|
||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||
*
|
||||
* @param spuId spu 编号
|
||||
* @return 砍价活动
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 砍价活动列表
|
||||
*/
|
||||
BargainActivityDO getBargainActivityBySpuId(Long spuId);
|
||||
List<BargainActivityDO> getBargainActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status);
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -176,8 +177,8 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BargainActivityDO getBargainActivityBySpuId(Long spuId) {
|
||||
return bargainActivityMapper.selectOne(spuId);
|
||||
public List<BargainActivityDO> getBargainActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||
return bargainActivityMapper.selectListBySpuIds(spuIds, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -118,11 +118,12 @@ public interface CombinationActivityService {
|
|||
CombinationProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId);
|
||||
|
||||
/**
|
||||
* 获取指定 spu 编号的活动
|
||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||
*
|
||||
* @param spuId spu 编号
|
||||
* @return 拼团活动
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 拼团活动列表
|
||||
*/
|
||||
CombinationActivityDO getCombinationActivityBySpuId(Long spuId);
|
||||
List<CombinationActivityDO> getCombinationActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status);
|
||||
|
||||
}
|
||||
|
|
|
@ -227,8 +227,8 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
|||
}
|
||||
|
||||
@Override
|
||||
public CombinationActivityDO getCombinationActivityBySpuId(Long spuId) {
|
||||
return combinationActivityMapper.selectOne(spuId);
|
||||
public List<CombinationActivityDO> getCombinationActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||
return combinationActivityMapper.selectListBySpuIds(spuIds, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -120,11 +120,12 @@ public interface SeckillActivityService {
|
|||
SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count);
|
||||
|
||||
/**
|
||||
* 获取指定 spu 编号的活动
|
||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||
*
|
||||
* @param spuId spu 编号
|
||||
* @return 秒杀活动
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 秒杀活动列表
|
||||
*/
|
||||
SeckillActivityDO getSeckillActivityBySpuId(Long spuId);
|
||||
List<SeckillActivityDO> getSeckillActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status);
|
||||
|
||||
}
|
||||
|
|
|
@ -311,8 +311,8 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SeckillActivityDO getSeckillActivityBySpuId(Long spuId) {
|
||||
return seckillActivityMapper.selectOne(spuId);
|
||||
public List<SeckillActivityDO> getSeckillActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||
return seckillActivityMapper.selectListBySpuIds(spuIds, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1_011_000_028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元");
|
||||
ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1_011_000_029, "交易订单删除失败,订单不是【已取消】状态");
|
||||
ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】");
|
||||
ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单已发货");
|
||||
|
||||
// ========== After Sale 模块 1-011-000-100 ==========
|
||||
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");
|
||||
|
|
|
@ -15,4 +15,12 @@ public interface RedisKeyConstants {
|
|||
*/
|
||||
String TRADE_NO = "trade_no:";
|
||||
|
||||
/**
|
||||
* 交易序号的缓存
|
||||
*
|
||||
* KEY 格式:express_track:{code-logisticsNo-receiverMobile}
|
||||
* VALUE 数据格式 String, 物流信息集合
|
||||
*/
|
||||
String EXPRESS_TRACK = "express_track";
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.service.order;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
|
@ -14,11 +15,13 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
|||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper;
|
||||
import cn.iocoder.yudao.module.trade.dal.redis.RedisKeyConstants;
|
||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -143,7 +146,6 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
|
|||
return tradeOrderItemMapper.selectProductSumByOrderId(convertSet(orders, TradeOrderDO::getId));
|
||||
}
|
||||
|
||||
// TODO @puhui999:可以加个 spring 缓存,30 分钟;主要考虑及时性要求不高,但是每次调用需要钱;
|
||||
/**
|
||||
* 获得订单的物流轨迹
|
||||
*
|
||||
|
@ -160,10 +162,25 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
|
|||
throw exception(EXPRESS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
return getSelf().getExpressTrackList(express.getCode(), order.getLogisticsNo(), order.getReceiverMobile());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物流轨迹
|
||||
* 加个 spring 缓存,30 分钟;主要考虑及时性要求不高,但是每次调用需要钱;TODO @艿艿:这个时间不会搞了。。。交给你了哈哈哈
|
||||
*
|
||||
* @param code 快递公司编码
|
||||
* @param logisticsNo 发货快递单号
|
||||
* @param receiverMobile 收、寄件人的电话号码
|
||||
* @return 物流轨迹
|
||||
*/
|
||||
@Cacheable(cacheNames = RedisKeyConstants.EXPRESS_TRACK, key = "#code + '-' + #logisticsNo + '-' + #receiverMobile",
|
||||
condition = "#result != null")
|
||||
public List<ExpressTrackRespDTO> getExpressTrackList(String code, String logisticsNo, String receiverMobile) {
|
||||
// 查询物流轨迹
|
||||
return expressClientFactory.getDefaultExpressClient().getExpressTrackList(
|
||||
new ExpressTrackQueryReqDTO().setExpressCode(express.getCode()).setLogisticsNo(order.getLogisticsNo())
|
||||
.setPhone(order.getReceiverMobile()));
|
||||
new ExpressTrackQueryReqDTO().setExpressCode(code).setLogisticsNo(logisticsNo)
|
||||
.setPhone(receiverMobile));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,4 +216,13 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
|
|||
return tradeOrderItemMapper.selectListByOrderId(orderIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得自身的代理对象,解决 AOP 生效问题
|
||||
*
|
||||
* @return 自己
|
||||
*/
|
||||
private TradeOrderQueryServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -742,8 +742,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||
public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) {
|
||||
// 校验交易订单
|
||||
TradeOrderDO order = validateOrderExists(reqVO.getId());
|
||||
// TODO @puhui999:是否需要校验订单是否发货
|
||||
// TODO 发货后是否支持修改收货地址;回答:发货后,不允许修改;
|
||||
// 发货后,不允许修改;
|
||||
if (TradeOrderStatusEnum.isDelivered(order.getStatus())) {
|
||||
throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED);
|
||||
}
|
||||
|
||||
// 更新
|
||||
tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO));
|
||||
|
|
|
@ -176,7 +176,7 @@ public class DeptServiceImpl implements DeptService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false) // 禁用数据权限,避免简历不正确的缓存
|
||||
@DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
|
||||
@Cacheable(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST, key = "#id")
|
||||
public Set<Long> getChildDeptIdListFromCache(Long id) {
|
||||
List<DeptDO> children = getChildDeptList(id);
|
||||
|
|
Loading…
Reference in New Issue