Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product

This commit is contained in:
owen 2023-10-11 15:06:09 +08:00
commit 66cdf4ca4c
45 changed files with 110 additions and 214 deletions

View File

@ -132,7 +132,9 @@ public class AreaUtils {
return convertList(areas.values(), func, area -> type.getType().equals(area.getType())); return convertList(areas.values(), func, area -> type.getType().equals(area.getType()));
} }
// TODO @疯狂注释写下
public static Integer getParentIdByType(Integer id, @NonNull AreaTypeEnum type) { public static Integer getParentIdByType(Integer id, @NonNull AreaTypeEnum type) {
// TODO @疯狂这种不要用 while true因为万一脏数据可能会死循环可以转换成 for (int i = 0; i < Byte.MAX; i++) 一般是优先层级
do { do {
Area area = AreaUtils.getArea(id); Area area = AreaUtils.getArea(id);
if (area == null) { if (area == null) {

View File

@ -6,8 +6,6 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidate
import javax.validation.Valid; import javax.validation.Valid;
// TODO @芋艿后面也再撸撸这几个接口
/** /**
* 拼团记录 API 接口 * 拼团记录 API 接口
* *
@ -30,7 +28,7 @@ public interface CombinationRecordApi {
* 创建开团记录 * 创建开团记录
* *
* @param reqDTO 请求 DTO * @param reqDTO 请求 DTO
* @return key 开团记录编号 value 团长编号 * @return key 开团记录编号value 团长编号
*/ */
KeyValue<Long, Long> createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); KeyValue<Long, Long> createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);

View File

@ -29,6 +29,7 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
recordService.validateCombinationRecord(userId, activityId, headId, skuId, count); recordService.validateCombinationRecord(userId, activityId, headId, skuId, count);
} }
// TODO @puhui999搞个创建的 RespDTO
@Override @Override
public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
return recordService.createCombinationRecord(reqDTO); return recordService.createCombinationRecord(reqDTO);

View File

@ -40,6 +40,9 @@ public class CombinationRecordController {
@Lazy @Lazy
private CombinationRecordService combinationRecordService; private CombinationRecordService combinationRecordService;
// TODO @puhui999getBargainRecordPage getBargainRecordPage 是不是可以合并然后 CombinationRecordReqPageVO 加一个 headId
// 然后如果 headId 非空并且第一页单独多查询一条 head 放到第 0 个位置相当于说第一页特殊一点
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得拼团记录分页") @Operation(summary = "获得拼团记录分页")
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
@ -47,6 +50,7 @@ public class CombinationRecordController {
PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO); PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO);
List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds( List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds(
convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); convertSet(recordPage.getList(), CombinationRecordDO::getActivityId));
// TODO @puhui999商品没读取
return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities)); return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities));
} }

View File

@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.context.annotation.Lazy;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -49,20 +48,15 @@ public class AppBargainRecordController {
@Resource @Resource
private BargainHelpService bargainHelpService; private BargainHelpService bargainHelpService;
@Resource @Resource
@Lazy
private BargainRecordService bargainRecordService; private BargainRecordService bargainRecordService;
@Resource @Resource
@Lazy
private BargainActivityService bargainActivityService; private BargainActivityService bargainActivityService;
@Resource @Resource
private TradeOrderApi tradeOrderApi; private TradeOrderApi tradeOrderApi;
@Resource @Resource
@Lazy
private MemberUserApi memberUserApi; private MemberUserApi memberUserApi;
@Resource @Resource
@Lazy
private ProductSpuApi productSpuApi; private ProductSpuApi productSpuApi;
@GetMapping("/get-summary") @GetMapping("/get-summary")

View File

@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityD
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection; import java.util.Collection;
@ -87,6 +86,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
.last("LIMIT " + count)); .last("LIMIT " + count));
} }
// TODO @puhui999是不是返回 BargainActivityDO 更干净哈
/** /**
* 查询出指定 spuId spu 参加的活动最接近现在的一条记录多个的话一个 spuId 对应一个最近的活动编号 * 查询出指定 spuId spu 参加的活动最接近现在的一条记录多个的话一个 spuId 对应一个最近的活动编号
* *
@ -94,7 +94,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
* @param status 状态 * @param status 状态
* @return 包含 spuId activityId map 对象列表 * @return 包含 spuId activityId map 对象列表
*/ */
default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection<Long> spuIds, @Param("status") Integer status) { default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
return selectMaps(new QueryWrapper<BargainActivityDO>() return selectMaps(new QueryWrapper<BargainActivityDO>()
.select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id
.in("spu_id", spuIds) .in("spu_id", spuIds)

View File

@ -120,6 +120,7 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
*/ */
default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) { default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) {
return selectCount(new QueryWrapper<CombinationRecordDO>() return selectCount(new QueryWrapper<CombinationRecordDO>()
// TODO @puhui999这种偏逻辑性的不要给 mapper 可以考虑拆成 2 mapper上层也是 2 service
.select(status == null && virtualGroup == null && headId == null, "DISTINCT (user_id)") .select(status == null && virtualGroup == null && headId == null, "DISTINCT (user_id)")
.eq(status != null, "status", status) .eq(status != null, "status", status)
.eq(virtualGroup != null, "virtual_group", virtualGroup) .eq(virtualGroup != null, "virtual_group", virtualGroup)

View File

@ -22,7 +22,7 @@ public class CombinationRecordExpireJob implements JobHandler {
@Override @Override
@TenantJob @TenantJob
public String execute(String param) throws Exception { public String execute(String param) {
KeyValue<Integer, Integer> keyValue = combinationRecordService.expireCombinationRecord(); KeyValue<Integer, Integer> keyValue = combinationRecordService.expireCombinationRecord();
return StrUtil.format("过期拼团 {} 个, 虚拟成团 {} 个", keyValue.getKey(), keyValue.getValue()); return StrUtil.format("过期拼团 {} 个, 虚拟成团 {} 个", keyValue.getKey(), keyValue.getValue());
} }

View File

@ -94,7 +94,6 @@ public class BargainActivityServiceImpl implements BargainActivityService {
} else if (count > 0) { } else if (count > 0) {
bargainActivityMapper.updateStock(id, count); bargainActivityMapper.updateStock(id, count);
} }
} }
private void validateBargainConflict(Long spuId, Long activityId) { private void validateBargainConflict(Long spuId, Long activityId) {
@ -184,12 +183,13 @@ public class BargainActivityServiceImpl implements BargainActivityService {
@Override @Override
public List<BargainActivityDO> getBargainActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) { public List<BargainActivityDO> getBargainActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
// 1.查询出指定 spuId spu 参加的活动最接近现在的一条记录多个的话一个 spuId 对应一个最近的活动编号 // 1. 查询出指定 spuId spu 参加的活动最接近现在的一条记录多个的话一个 spuId 对应一个最近的活动编号
// TODO @puhui999我想了下这种是不是只展示当前正在进行中的已经结束或者未开始的可能没啥意义
List<Map<String, Object>> spuIdAndActivityIdMaps = bargainActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); List<Map<String, Object>> spuIdAndActivityIdMaps = bargainActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status);
if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) {
return Collections.emptyList(); return Collections.emptyList();
} }
// 2.查询活动详情 // 2. 查询活动详情
return bargainActivityMapper.selectListByIds(convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId"))); return bargainActivityMapper.selectListByIds(convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")));
} }

View File

@ -146,7 +146,6 @@ public interface CombinationRecordService {
*/ */
PageResult<CombinationRecordDO> getCombinationRecordPage2(CombinationRecordReqPage2VO pageVO); PageResult<CombinationRecordDO> getCombinationRecordPage2(CombinationRecordReqPage2VO pageVO);
/** /**
* 拼团活动获得拼团记录数量 Map * 拼团活动获得拼团记录数量 Map
* *
@ -159,7 +158,6 @@ public interface CombinationRecordService {
@Nullable Integer status, @Nullable Integer status,
@Nullable Long headId); @Nullable Long headId);
/** /**
* 获取拼团记录 * 获取拼团记录
* *

View File

@ -23,7 +23,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationR
import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper;
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -52,7 +51,6 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
public class CombinationRecordServiceImpl implements CombinationRecordService { public class CombinationRecordServiceImpl implements CombinationRecordService {
@Resource @Resource
@Lazy
private CombinationActivityService combinationActivityService; private CombinationActivityService combinationActivityService;
@Resource @Resource
private CombinationRecordMapper combinationRecordMapper; private CombinationRecordMapper combinationRecordMapper;
@ -60,16 +58,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
@Resource @Resource
private MemberUserApi memberUserApi; private MemberUserApi memberUserApi;
@Resource @Resource
@Lazy
private ProductSpuApi productSpuApi; private ProductSpuApi productSpuApi;
@Resource @Resource
@Lazy
private ProductSkuApi productSkuApi; private ProductSkuApi productSkuApi;
@Resource @Resource
private TradeOrderApi tradeOrderApi; private TradeOrderApi tradeOrderApi;
// TODO @芋艿在详细预览下
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) { public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) {
@ -77,6 +72,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
CombinationRecordDO record = validateCombinationRecord(userId, orderId); CombinationRecordDO record = validateCombinationRecord(userId, orderId);
// 更新状态 // 更新状态
// TODO @puhui999不要整个更新new 一个出来why例如说两个线程都去更新这样存在相互覆盖的问题
record.setStatus(status); record.setStatus(status);
combinationRecordMapper.updateById(record); combinationRecordMapper.updateById(record);
} }
@ -169,16 +165,16 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
// 1.校验拼团活动 // 1. 校验拼团活动
KeyValue<CombinationActivityDO, CombinationProductDO> keyValue = validateCombinationRecord(reqDTO.getUserId(), KeyValue<CombinationActivityDO, CombinationProductDO> keyValue = validateCombinationRecord(reqDTO.getUserId(),
reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount()); reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount());
// 2.组合数据创建拼团记录 // 2. 组合数据创建拼团记录
MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()); MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId());
ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()); ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId());
ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()); ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId());
CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku); CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku);
// 2.1.如果是团长需要设置 headId CombinationRecordDO#HEAD_ID_GROUP // 2.1. 如果是团长需要设置 headId CombinationRecordDO#HEAD_ID_GROUP
if (record.getHeadId() == null) { if (record.getHeadId() == null) {
record.setStartTime(LocalDateTime.now()) record.setStartTime(LocalDateTime.now())
.setExpireTime(keyValue.getKey().getStartTime().plusHours(keyValue.getKey().getLimitDuration())) .setExpireTime(keyValue.getKey().getStartTime().plusHours(keyValue.getKey().getLimitDuration()))
@ -191,12 +187,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
} }
combinationRecordMapper.insert(record); combinationRecordMapper.insert(record);
if (ObjUtil.equal(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { // 3. 更新拼团记录
return new KeyValue<>(record.getId(), record.getHeadId()); if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) {
updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey());
} }
// 3更新拼团记录
updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey());
return new KeyValue<>(record.getId(), record.getHeadId()); return new KeyValue<>(record.getId(), record.getHeadId());
} }
@ -349,6 +343,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
@Override @Override
public KeyValue<Integer, Integer> expireCombinationRecord() { public KeyValue<Integer, Integer> expireCombinationRecord() {
// TODO @puhui999数字一般是 1. 2. 这种格式哈
// 1获取所有正在进行中的过期的父拼团 // 1获取所有正在进行中的过期的父拼团
List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt(
CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now());
@ -356,18 +351,21 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
return new KeyValue<>(0, 0); return new KeyValue<>(0, 0);
} }
// 2.获取拼团活动 // 2. 获取拼团活动
// TODO @puhui999在自己模块里变量可以简略点例如说 activityList
List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityListByIds( List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityListByIds(
convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); convertSet(headExpireRecords, CombinationRecordDO::getActivityId));
Map<Long, CombinationActivityDO> activityMap = convertMap(combinationActivities, CombinationActivityDO::getId); Map<Long, CombinationActivityDO> activityMap = convertMap(combinationActivities, CombinationActivityDO::getId);
// 3.校验是否虚拟成团 // TODO @puhui999job 一般不建议异步跑因为可能下次跑结果上次还没跑完
// TODO 这里我们可以每个 record 处理下然后按照是否需要虚拟拼团各搞一个方法逻辑 + 事务这样保证 job 里面尽量不要大事务而是 n 个独立小事务的处理
// 3. 校验是否虚拟成团
List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团
for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) {
CombinationRecordDO record = iterator.next(); CombinationRecordDO record = iterator.next();
// 3.1 不匹配则直接跳过 // 3.1 不匹配则直接跳过
CombinationActivityDO activityDO = activityMap.get(record.getActivityId()); CombinationActivityDO activity = activityMap.get(record.getActivityId());
if (activityDO == null || !activityDO.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的
continue; continue;
} }
// 3.2 匹配则移除添加到虚拟成团中并结束寻找 // 3.2 匹配则移除添加到虚拟成团中并结束寻找
@ -380,7 +378,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
getSelf().handleExpireRecord(headExpireRecords); getSelf().handleExpireRecord(headExpireRecords);
// 5.虚拟成团 // 5.虚拟成团
getSelf().handleVirtualGroupRecord(virtualGroupHeadRecords); getSelf().handleVirtualGroupRecord(virtualGroupHeadRecords);
return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size()); return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size());
} }
@ -401,7 +398,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
headsAndRecords.forEach(item -> { headsAndRecords.forEach(item -> {
tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()); tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId());
}); });
} }
@Async @Async
@ -410,9 +406,9 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
return; return;
} }
// 1.团员补齐 // 1. 团员补齐
combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecords)); combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecords));
// 2.更新拼团记录 // 2. 更新拼团记录
updateBatchCombinationRecords(virtualGroupHeadRecords, CombinationRecordStatusEnum.SUCCESS); updateBatchCombinationRecords(virtualGroupHeadRecords, CombinationRecordStatusEnum.SUCCESS);
} }

View File

@ -7,15 +7,17 @@ import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* API 访问日志统计 Mapper * API 访问日志统计 Mapper
* *
* @author owen * @author owen
*/ */
@Mapper @Mapper
public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> { public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> {
Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
} }

View File

@ -10,7 +10,7 @@ import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
* 会员统计 Mapper * 会员信息的统计 Mapper
* *
* @author owen * @author owen
*/ */
@ -21,6 +21,7 @@ public interface MemberStatisticsMapper extends BaseMapperX<Object> {
List<MemberSexStatisticsRespVO> selectSummaryListBySex(); List<MemberSexStatisticsRespVO> selectSummaryListBySex();
Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
} }

View File

@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 交易统计 Mapper * 支付钱包的统计 Mapper
* *
* @author owen * @author owen
*/ */
@ -29,6 +29,7 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO
@Param("endTime") LocalDateTime endTime, @Param("endTime") LocalDateTime endTime,
@Param("bizType") Integer bizType); @Param("bizType") Integer bizType);
// TODO @疯狂是不是搞个单独的 BO
MemberSummaryRespVO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime, MemberSummaryRespVO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime, @Param("endTime") LocalDateTime endTime,
@Param("payStatus") Boolean payStatus); @Param("payStatus") Boolean payStatus);

View File

@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 交易统计 Mapper * 售后订单的统计 Mapper
* *
* @author owen * @author owen
*/ */

View File

@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 交易统计 Mapper * 订单分销的统计 Mapper
* *
* @author owen * @author owen
*/ */

View File

@ -10,7 +10,7 @@ import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
* 交易统计 Mapper * 交易订单的统计 Mapper
* *
* @author owen * @author owen
*/ */

View File

@ -19,6 +19,7 @@ import java.util.List;
@Mapper @Mapper
public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
// TODO @疯狂这个要不要也挪到 xml 保持统一
@Select("SELECT IFNULL(SUM(order_create_count), 0) AS count, IFNULL(SUM(order_pay_price), 0) AS summary " + @Select("SELECT IFNULL(SUM(order_create_count), 0) AS count, IFNULL(SUM(order_pay_price), 0) AS summary " +
"FROM trade_statistics " + "FROM trade_statistics " +
"WHERE time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE") "WHERE time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE")
@ -33,4 +34,5 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime); @Param("endTime") LocalDateTime endTime);
} }

View File

@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.statistics.service.infra;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* API 访问日志统计 Service 接口 * API 访问日志统计 Service 接口
* *
* @author owen * @author owen
*/ */

View File

@ -8,7 +8,7 @@ import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* API 访问日志统计 Service 实现类 * API 访问日志统计 Service 实现类
* *
* @author owen * @author owen
*/ */

View File

@ -9,7 +9,7 @@ import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
* 会员统计 Service 接口 * 会员信息的统计 Service 接口
* *
* @author owen * @author owen
*/ */

View File

@ -24,7 +24,7 @@ import java.util.Optional;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/** /**
* 会员统计 Service 实现类 * 会员信息的统计 Service 实现类
* *
* @author owen * @author owen
*/ */

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 钱包统计 Service 接口 * 钱包统计 Service 接口
* *
* @author owen * @author owen
*/ */

View File

@ -12,7 +12,7 @@ import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 钱包统计 Service 实现类 * 钱包统计 Service 实现类
* *
* @author owen * @author owen
*/ */
@ -31,11 +31,10 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic
beginTime, endTime, PayRefundStatusEnum.SUCCESS.getStatus()); beginTime, endTime, PayRefundStatusEnum.SUCCESS.getStatus());
Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween( Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween(
beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType()); beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType());
// 拼接
paySummary.setOrderWalletPayPrice(walletPayPrice); paySummary.setOrderWalletPayPrice(walletPayPrice)
paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount()); .setRechargeRefundCount(refundSummary.getRechargeRefundCount())
paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); .setRechargeRefundPrice(refundSummary.getRechargeRefundPrice());
return paySummary; return paySummary;
} }

View File

@ -7,7 +7,7 @@ import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
* 交易订单统计 Service 接口 * 交易订单统计 Service 接口
* *
* @author owen * @author owen
*/ */

View File

@ -45,16 +45,15 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
@Override @Override
public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() { public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() {
// 昨天的数据 // 1.1 昨天的数据
TradeSummaryRespBO yesterdayData = getTradeSummaryByDays(-1); TradeSummaryRespBO yesterdayData = getTradeSummaryByDays(-1);
// 前天的数据用于对照昨天的数据 // 1.2 前天的数据用于对照昨天的数据
TradeSummaryRespBO beforeYesterdayData = getTradeSummaryByDays(-2); TradeSummaryRespBO beforeYesterdayData = getTradeSummaryByDays(-2);
// 2.1 本月数据
// 本月数据;
TradeSummaryRespBO monthData = getTradeSummaryByMonths(0); TradeSummaryRespBO monthData = getTradeSummaryByMonths(0);
// 上月数据用于对照本月的数据 // 2.2 上月数据用于对照本月的数据
TradeSummaryRespBO lastMonthData = getTradeSummaryByMonths(-1); TradeSummaryRespBO lastMonthData = getTradeSummaryByMonths(-1);
// 转换返回
return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData); return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData);
} }
@ -81,31 +80,31 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
@Override @Override
public String statisticsYesterdayTrade() { public String statisticsYesterdayTrade() {
// 处理统计参数
LocalDateTime yesterday = LocalDateTime.now().minusDays(1); LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
// 统计 // 1.1 统计订单
StopWatch stopWatch = new StopWatch("交易统计"); StopWatch stopWatch = new StopWatch("交易统计");
stopWatch.start("统计订单"); stopWatch.start("统计订单");
TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime);
stopWatch.stop(); stopWatch.stop();
// 1.2 统计售后
stopWatch.start("统计售后"); stopWatch.start("统计售后");
AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime);
stopWatch.stop(); stopWatch.stop();
// 1.3 统计佣金
stopWatch.start("统计佣金"); stopWatch.start("统计佣金");
Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime);
stopWatch.stop(); stopWatch.stop();
// 1.4 统计充值
stopWatch.start("统计充值"); stopWatch.start("统计充值");
WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime);
stopWatch.stop(); stopWatch.stop();
// 插入数据
TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary); // 2. 插入数据
TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary,
brokerageSettlementPrice, walletSummary);
tradeStatisticsMapper.insert(entity); tradeStatisticsMapper.insert(entity);
// 返回计时结果
return stopWatch.prettyPrint(); return stopWatch.prettyPrint();
} }

View File

@ -9,6 +9,7 @@ import lombok.Data;
*/ */
@Data @Data
public class WalletSummaryRespBO { public class WalletSummaryRespBO {
/** /**
* 总支付金额余额单位 * 总支付金额余额单位
*/ */

View File

@ -1,20 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper"> <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper">
<select id="selectCountByIp" resultType="java.lang.Integer"> <select id="selectCountByIp" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(1)
FROM infra_api_access_log FROM infra_api_access_log
WHERE deleted = FALSE WHERE create_time BETWEEN #{beginTime} AND #{endTime}
AND create_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE
GROUP BY user_ip GROUP BY user_ip
</select> </select>
<select id="selectCountByUserId" resultType="java.lang.Integer"> <select id="selectCountByUserId" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(1)
FROM infra_api_access_log FROM infra_api_access_log
WHERE user_id != 0 WHERE user_id > 0
AND deleted = FALSE
AND create_time BETWEEN #{beginTime} AND #{endTime} AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
GROUP BY user_id GROUP BY user_id
</select> </select>
</mapper> </mapper>

View File

@ -8,6 +8,7 @@
FROM member_user FROM member_user
WHERE deleted = FALSE WHERE deleted = FALSE
GROUP BY area_id GROUP BY area_id
<!-- TODO @疯狂order by 是不是交给内存哈 -->
ORDER BY userCount DESC ORDER BY userCount DESC
</select> </select>
@ -17,6 +18,7 @@
FROM member_user FROM member_user
WHERE deleted = FALSE WHERE deleted = FALSE
GROUP BY sex GROUP BY sex
<!-- TODO @疯狂order by 是不是交给内存哈 -->
ORDER BY userCount DESC ORDER BY userCount DESC
</select> </select>
@ -31,4 +33,5 @@
AND create_time &lt;= #{endTime} AND create_time &lt;= #{endTime}
</if> </if>
</select> </select>
</mapper> </mapper>

View File

@ -7,8 +7,8 @@
SUM(pay_price) AS rechargePayPrice SUM(pay_price) AS rechargePayPrice
FROM pay_wallet_recharge FROM pay_wallet_recharge
WHERE pay_status = #{payStatus} WHERE pay_status = #{payStatus}
AND deleted = FALSE
AND pay_time BETWEEN #{beginTime} AND #{endTime} AND pay_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
</select> </select>
<select id="selectRechargeSummaryByRefundTimeBetween" <select id="selectRechargeSummaryByRefundTimeBetween"
@ -17,16 +17,16 @@
SUM(pay_price) AS rechargeRefundPrice SUM(pay_price) AS rechargeRefundPrice
FROM pay_wallet_recharge FROM pay_wallet_recharge
WHERE refund_status = #{refundStatus} WHERE refund_status = #{refundStatus}
AND deleted = FALSE
AND refund_time BETWEEN #{beginTime} AND #{endTime} AND refund_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
</select> </select>
<select id="selectPriceSummaryByBizTypeAndCreateTimeBetween" resultType="java.lang.Integer"> <select id="selectPriceSummaryByBizTypeAndCreateTimeBetween" resultType="java.lang.Integer">
SELECT SUM(price) SELECT SUM(price)
FROM pay_wallet_transaction FROM pay_wallet_transaction
WHERE biz_type = #{bizType} WHERE biz_type = #{bizType}
AND deleted = FALSE
AND create_time BETWEEN #{beginTime} AND #{endTime} AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
</select> </select>
<select id="selectRechargeSummaryGroupByWalletId" <select id="selectRechargeSummaryGroupByWalletId"
@ -35,13 +35,14 @@
SUM(pay_price) AS rechargePrice SUM(pay_price) AS rechargePrice
FROM pay_wallet_recharge FROM pay_wallet_recharge
WHERE pay_status = #{payStatus} WHERE pay_status = #{payStatus}
AND deleted = FALSE
<if test="beginTime != null"> <if test="beginTime != null">
AND pay_time >= #{beginTime} AND pay_time >= #{beginTime}
</if> </if>
<if test="endTime != null"> <if test="endTime != null">
AND pay_time &lt;= #{endTime} AND pay_time &lt;= #{endTime}
</if> </if>
AND deleted = FALSE
GROUP BY wallet_id GROUP BY wallet_id
</select> </select>
</mapper> </mapper>

View File

@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper"> <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper">
<select id="selectSummaryByRefundTimeBetween" <select id="selectSummaryByRefundTimeBetween"
resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO"> resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO">
SELECT COUNT(1) AS afterSaleCount, SELECT COUNT(1) AS afterSaleCount,
SUM(refund_price) AS afterSaleRefundPrice SUM(refund_price) AS afterSaleRefundPrice
FROM trade_after_sale FROM trade_after_sale
WHERE deleted = FALSE WHERE refund_time BETWEEN #{beginTime} AND #{endTime}
AND refund_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE
</select> </select>
</mapper> </mapper>

View File

@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper"> <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper">
<select id="selectSummaryPriceByStatusAndUnfreezeTimeBetween" resultType="java.lang.Integer"> <select id="selectSummaryPriceByStatusAndUnfreezeTimeBetween" resultType="java.lang.Integer">
SELECT SUM(price) SELECT SUM(price)
FROM trade_brokerage_record FROM trade_brokerage_record
WHERE biz_type = #{bizType} WHERE biz_type = #{bizType}
AND status = #{status} AND status = #{status}
AND deleted = FALSE
AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} AND unfreeze_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
</select> </select>
</mapper> </mapper>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper"> <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper">
<select id="selectSummaryListByAreaId" <select id="selectSummaryListByAreaId"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
SELECT receiver_area_id AS areaId, SELECT receiver_area_id AS areaId,
@ -33,25 +34,25 @@
<select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(1)
FROM trade_order FROM trade_order
WHERE deleted = FALSE WHERE pay_time BETWEEN #{beginTime} AND #{endTime}
AND pay_status = TRUE AND pay_status = TRUE
AND pay_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE
GROUP BY user_id GROUP BY user_id
</select> </select>
<select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(1)
FROM trade_order FROM trade_order
WHERE deleted = FALSE WHERE create_time BETWEEN #{beginTime} AND #{endTime}
AND create_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE
</select> </select>
<select id="selectCountByPayTimeBetween" resultType="java.lang.Integer"> <select id="selectCountByPayTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(1)
FROM trade_order FROM trade_order
WHERE pay_status = TRUE WHERE pay_status = TRUE
AND deleted = FALSE
AND create_time BETWEEN #{beginTime} AND #{endTime} AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
</select> </select>
<select id="selectSummaryPriceByPayTimeBetween" resultType="java.lang.Integer"> <select id="selectSummaryPriceByPayTimeBetween" resultType="java.lang.Integer">
@ -61,4 +62,5 @@
AND deleted = FALSE AND deleted = FALSE
AND create_time BETWEEN #{beginTime} AND #{endTime} AND create_time BETWEEN #{beginTime} AND #{endTime}
</select> </select>
</mapper> </mapper>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper"> <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper">
<select id="selectByTimeBetween" <select id="selectByTimeBetween"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
SELECT SELECT
@ -48,4 +49,5 @@
AND time &lt;= #{endTime} AND time &lt;= #{endTime}
</if> </if>
</select> </select>
</mapper> </mapper>

View File

@ -1,10 +0,0 @@
package cn.iocoder.yudao.module.trade.api.aftersale;
/**
* 售后 API 接口
*
* @author owen
*/
public interface TradeAfterSaleApi {
}

View File

@ -1,10 +0,0 @@
package cn.iocoder.yudao.module.trade.api.brokerage;
/**
* 分销 API 接口
*
* @author owen
*/
public interface TradeBrokerageApi {
}

View File

@ -28,16 +28,7 @@ public interface TradeOrderApi {
*/ */
TradeOrderRespDTO getOrder(Long id); TradeOrderRespDTO getOrder(Long id);
/** // TODO 芋艿需要优化下
* 更新拼团相关信息到订单
*
* @param orderId 订单编号
* @param activityId 拼团活动编号
* @param combinationRecordId 拼团记录编号
* @param headId 团长编号
*/
void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId);
/** /**
* 取消支付订单 * 取消支付订单
* *

View File

@ -1,21 +0,0 @@
package cn.iocoder.yudao.module.trade.api.aftersale;
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* 售后 API 接口实现类
*
* @author owen
*/
@Service
@Validated
public class TradeAfterSaleApiImpl implements TradeAfterSaleApi {
@Resource
private AfterSaleService afterSaleService;
}

View File

@ -1,21 +0,0 @@
package cn.iocoder.yudao.module.trade.api.brokerage;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* 订单 API 接口实现类
*
* @author HUIHUI
*/
@Service
@Validated
public class TradeBrokerageApiImpl implements TradeBrokerageApi {
@Resource
private BrokerageRecordService brokerageRecordService;
}

View File

@ -2,10 +2,8 @@ package cn.iocoder.yudao.module.trade.api.order;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -13,9 +11,6 @@ import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
/** /**
* 订单 API 接口实现类 * 订单 API 接口实现类
* *
@ -28,7 +23,6 @@ public class TradeOrderApiImpl implements TradeOrderApi {
@Resource @Resource
private TradeOrderUpdateService tradeOrderUpdateService; private TradeOrderUpdateService tradeOrderUpdateService;
@Resource @Resource
@Lazy
private TradeOrderQueryService tradeOrderQueryService; private TradeOrderQueryService tradeOrderQueryService;
@Override @Override
@ -41,11 +35,6 @@ public class TradeOrderApiImpl implements TradeOrderApi {
return TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id)); return TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id));
} }
@Override
public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) {
tradeOrderUpdateService.updateOrderCombinationInfo(orderId, activityId, combinationRecordId, headId);
}
@Override @Override
public void cancelPaidOrder(Long userId, Long orderId) { public void cancelPaidOrder(Long userId, Long orderId) {
tradeOrderUpdateService.cancelPaidOrder(userId, orderId); tradeOrderUpdateService.cancelPaidOrder(userId, orderId);

View File

@ -93,6 +93,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode);
} }
// TODO @hui999是不是只针对 combinationActivityId 的查询呀
default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) {
return selectOne(new LambdaQueryWrapperX<TradeOrderDO>() return selectOne(new LambdaQueryWrapperX<TradeOrderDO>()
.and(q -> q.eq(TradeOrderDO::getUserId, userId) .and(q -> q.eq(TradeOrderDO::getUserId, userId)

View File

@ -657,7 +657,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) {
// 校验交易订单 // 校验交易订单
TradeOrderDO order = validateOrderExists(reqVO.getId()); TradeOrderDO order = validateOrderExists(reqVO.getId());
// 只有待发货状态才可以修改订单收货地址 // 只有待发货状态才可以修改订单收货地址
if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) { if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) {
throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED); throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED);
} }
@ -823,11 +823,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void cancelPaidOrder(Long userId, Long orderId) { public void cancelPaidOrder(Long userId, Long orderId) {
// TODO 芋艿这里实现要优化下
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId); TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
if (order == null) { if (order == null) {
throw exception(ORDER_NOT_FOUND); throw exception(ORDER_NOT_FOUND);
} }
cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
} }

View File

@ -10,7 +10,6 @@ import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -29,14 +28,11 @@ import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_DELIV
public class TradeCombinationOrderHandler implements TradeOrderHandler { public class TradeCombinationOrderHandler implements TradeOrderHandler {
@Resource @Resource
@Lazy
private TradeOrderUpdateService orderUpdateService; private TradeOrderUpdateService orderUpdateService;
@Resource @Resource
@Lazy
private TradeOrderQueryService orderQueryService; private TradeOrderQueryService orderQueryService;
@Resource @Resource
@Lazy
private CombinationRecordApi combinationRecordApi; private CombinationRecordApi combinationRecordApi;
@Override @Override
@ -51,7 +47,9 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler {
TradeOrderItemDO item = orderItems.get(0); TradeOrderItemDO item = orderItems.get(0);
combinationRecordApi.validateCombinationRecord(order.getUserId(), order.getCombinationActivityId(), combinationRecordApi.validateCombinationRecord(order.getUserId(), order.getCombinationActivityId(),
order.getCombinationHeadId(), item.getSkuId(), item.getCount()); order.getCombinationHeadId(), item.getSkuId(), item.getCount());
// 2. 校验该用户是否存在未支付的拼团活动订单就是还没支付的时候重复下单了需要校验下不然的话一个拼团可以下多个单子了
// 2. 校验该用户是否存在未支付的拼团活动订单避免一个拼团可以下多个单子了
// TODO @puhui999只校验未支付的拼团订单噢
TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus( TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus(
order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus());
if (activityOrder != null) { if (activityOrder != null) {

View File

@ -1,10 +0,0 @@
package cn.iocoder.yudao.module.pay.api.wallet;
/**
* 钱包 API 接口
*
* @author owen
*/
public interface PayWalletApi {
}

View File

@ -1,24 +0,0 @@
package cn.iocoder.yudao.module.pay.api.wallet;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* 钱包 API 接口实现类
*
* @author owen
*/
@Service
@Validated
public class PayWalletApiImpl implements PayWalletApi {
@Resource
private PayWalletRechargeService payWalletRechargeService;
@Resource
private PayWalletTransactionService payWalletTransactionService;
}