拼团记录:完善拼团记录后台管理接口

This commit is contained in:
puhui999 2023-10-06 21:26:53 +08:00
parent 8b480c52cc
commit 6099786c1b
6 changed files with 40 additions and 63 deletions

View File

@ -51,7 +51,7 @@ public class CombinationRecordController {
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
public CommonResult<PageResult<CombinationRecordRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) { public CommonResult<PageResult<CombinationRecordRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) {
return success(CombinationActivityConvert.INSTANCE.convert( return success(CombinationActivityConvert.INSTANCE.convert(
combinationRecordService.getBargainRecordPage(pageVO))); combinationRecordService.getCombinationRecordPage(pageVO)));
} }
@GetMapping("/get-summary") @GetMapping("/get-summary")
@ -64,22 +64,22 @@ public class CombinationRecordController {
@GetMapping("/get-count") @GetMapping("/get-count")
@Operation(summary = "获得拼团记录分页 tab count") @Operation(summary = "获得拼团记录分页 tab count")
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
public CommonResult<Map<String, Long>> getSpuCount() { public CommonResult<Map<String, Long>> getCombinationRecordCount() {
Map<String, Long> hashMap = MapUtil.newHashMap(7); Map<String, Long> hashMap = MapUtil.newHashMap(7);
hashMap.put("all", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.ALL));// 全部 hashMap.put("all", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.ALL));// 全部
hashMap.put("toDay", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.TO_DAY));// 今天 hashMap.put("toDay", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.TO_DAY));// 今天
hashMap.put("yesterday", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.YESTERDAY));// 昨天 hashMap.put("yesterday", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.YESTERDAY));// 昨天
hashMap.put("lastSevenDays", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_SEVEN_DAYS));// 最近七天 hashMap.put("lastSevenDays", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.LAST_SEVEN_DAYS));// 最近七天
hashMap.put("last30Days", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_30_DAYS));// 最近 30 hashMap.put("last30Days", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.LAST_30_DAYS));// 最近 30
hashMap.put("thisMonth", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_MONTH));// 本月 hashMap.put("thisMonth", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.THIS_MONTH));// 本月
hashMap.put("thisYear", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_YEAR));// 本年 hashMap.put("thisYear", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.THIS_YEAR));// 本年
return success(hashMap); return success(hashMap);
} }
private Map<String, Long> getCombinationRecordSummary0() { private Map<String, Long> getCombinationRecordSummary0() {
Map<String, Long> hashMap = MapUtil.newHashMap(3); Map<String, Long> hashMap = MapUtil.newHashMap(3);
hashMap.put("userCount", combinationRecordService.getRecordsCount());// 获取所有拼团记录 hashMap.put("userCount", combinationRecordService.getCombinationRecordsCount());// 获取所有拼团记录
hashMap.put("successCount", combinationRecordService.getRecordsSuccessCount());// 获取成团记录 hashMap.put("successCount", combinationRecordService.getCombinationRecordsSuccessCount());// 获取成团记录
hashMap.put("virtualGroupCount", combinationRecordService.getRecordsVirtualGroupCount());// 获取虚拟成团记录 hashMap.put("virtualGroupCount", combinationRecordService.getRecordsVirtualGroupCount());// 获取虚拟成团记录
return hashMap; return hashMap;
} }

View File

@ -42,7 +42,7 @@ public class AppCombinationRecordController {
// TODO 芋艿增加 @Cache 缓存1 分钟过期 // TODO 芋艿增加 @Cache 缓存1 分钟过期
public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() { public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
// 获取所有拼团记录 // 获取所有拼团记录
Long count = combinationRecordService.getRecordsCount(); Long count = combinationRecordService.getCombinationRecordsCount();
AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
if (count == null || count == 0L) { if (count == null || count == 0L) {
summary.setAvatars(Collections.emptyList()); summary.setAvatars(Collections.emptyList());
@ -53,7 +53,7 @@ public class AppCombinationRecordController {
summary.setUserCount(count); summary.setUserCount(count);
// TODO 只返回最近的 7 // TODO 只返回最近的 7
int num = 7; int num = 7;
summary.setAvatars(convertList(combinationRecordService.getLatestRecordList(num), CombinationRecordDO::getAvatar)); summary.setAvatars(convertList(combinationRecordService.getLatestCombinationRecordList(num), CombinationRecordDO::getAvatar));
return success(summary); return success(summary);
} }
@ -69,7 +69,7 @@ public class AppCombinationRecordController {
@RequestParam("status") Integer status, @RequestParam("status") Integer status,
@RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
return success(CombinationActivityConvert.INSTANCE.convertList3( return success(CombinationActivityConvert.INSTANCE.convertList3(
combinationRecordService.getRecordListWithHead(activityId, status, count))); combinationRecordService.getCombinationRecordListWithHead(activityId, status, count)));
} }
@GetMapping("/get-detail") @GetMapping("/get-detail")
@ -77,7 +77,7 @@ public class AppCombinationRecordController {
@Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) { public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
// 1查询这条记录 // 1查询这条记录
CombinationRecordDO record = combinationRecordService.getRecordById(id); CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id);
if (record == null) { if (record == null) {
return success(null); return success(null);
} }
@ -88,17 +88,17 @@ public class AppCombinationRecordController {
if (record.getHeadId() == null) { if (record.getHeadId() == null) {
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record)); detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record));
// 2.1查找团员拼团记录 // 2.1查找团员拼团记录
records = combinationRecordService.getRecordListByHeadId(record.getId()); records = combinationRecordService.getCombinationRecordListByHeadId(record.getId());
} else { } else {
// 2.2查找团长拼团记录 // 2.2查找团长拼团记录
CombinationRecordDO headRecord = combinationRecordService.getRecordById(record.getHeadId()); CombinationRecordDO headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId());
if (headRecord == null) { if (headRecord == null) {
return success(null); return success(null);
} }
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord)); detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord));
// 2.3查找团员拼团记录 // 2.3查找团员拼团记录
records = combinationRecordService.getRecordListByHeadId(headRecord.getId()); records = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId());
} }
detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records)); detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records));

View File

@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.combination;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
@ -32,10 +32,6 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
CombinationRecordDO::getOrderId, orderId); CombinationRecordDO::getOrderId, orderId);
} }
default List<CombinationRecordDO> selectListByUserId(Long userId) {
return selectList(CombinationRecordDO::getUserId, userId);
}
default List<CombinationRecordDO> selectListByUserIdAndStatus(Long userId, Integer status) { default List<CombinationRecordDO> selectListByUserIdAndStatus(Long userId, Integer status) {
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>() return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
.eq(CombinationRecordDO::getUserId, userId) .eq(CombinationRecordDO::getUserId, userId)

View File

@ -15,7 +15,6 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
// todo @PUHUI方法名还是带下 Combination
/** /**
* 拼团记录 Service 接口 * 拼团记录 Service 接口
* *
@ -62,11 +61,11 @@ public interface CombinationRecordService {
void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime); void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime);
/** /**
* 获得拼团状态 * 获得拼团记录
* *
* @param userId 用户编号 * @param userId 用户编号
* @param orderId 订单编号 * @param orderId 订单编号
* @return 拼团状态 * @return 拼团记录
*/ */
CombinationRecordDO getCombinationRecord(Long userId, Long orderId); CombinationRecordDO getCombinationRecord(Long userId, Long orderId);
@ -77,7 +76,7 @@ public interface CombinationRecordService {
* @param activityId 活动 id * @param activityId 活动 id
* @return 拼团记录列表 * @return 拼团记录列表
*/ */
List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId); List<CombinationRecordDO> getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId);
/** /**
* 下单前校验是否满足拼团活动条件 * 下单前校验是否满足拼团活动条件
@ -97,14 +96,14 @@ public interface CombinationRecordService {
* *
* @return 记录数 * @return 记录数
*/ */
Long getRecordsCount(); Long getCombinationRecordsCount();
/** /**
* 获取成功记录数 * 获取成功记录数
* *
* @return 记录数 * @return 记录数
*/ */
Long getRecordsSuccessCount(); Long getCombinationRecordsSuccessCount();
/** /**
* 获取虚拟成团记录数 * 获取虚拟成团记录数
@ -119,7 +118,7 @@ public interface CombinationRecordService {
* @param dateType 日期类型 * @param dateType 日期类型
* @return 记录数 * @return 记录数
*/ */
Long getRecordsCountByDateType(Integer dateType); Long getCombinationRecordsCountByDateType(Integer dateType);
/** /**
* 获取最近的 count 条拼团记录 * 获取最近的 count 条拼团记录
@ -127,7 +126,7 @@ public interface CombinationRecordService {
* @param count 限制数量 * @param count 限制数量
* @return 拼团记录列表 * @return 拼团记录列表
*/ */
List<CombinationRecordDO> getLatestRecordList(int count); List<CombinationRecordDO> getLatestCombinationRecordList(int count);
/** /**
* 获得最近 n 条拼团记录团长发起的 * 获得最近 n 条拼团记录团长发起的
@ -137,7 +136,7 @@ public interface CombinationRecordService {
* @param count 数量 * @param count 数量
* @return 拼团记录列表 * @return 拼团记录列表
*/ */
List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count); List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count);
/** /**
* 获取指定编号的拼团记录 * 获取指定编号的拼团记录
@ -145,7 +144,7 @@ public interface CombinationRecordService {
* @param id 拼团记录编号 * @param id 拼团记录编号
* @return 拼团记录 * @return 拼团记录
*/ */
CombinationRecordDO getRecordById(Long id); CombinationRecordDO getCombinationRecordById(Long id);
/** /**
* 获取指定团长编号的拼团记录 * 获取指定团长编号的拼团记录
@ -153,7 +152,7 @@ public interface CombinationRecordService {
* @param headId 团长编号 * @param headId 团长编号
* @return 拼团记录列表 * @return 拼团记录列表
*/ */
List<CombinationRecordDO> getRecordListByHeadId(Long headId); List<CombinationRecordDO> getCombinationRecordListByHeadId(Long headId);
/** /**
* 获取拼团记录分页数据 * 获取拼团记录分页数据
@ -161,7 +160,7 @@ public interface CombinationRecordService {
* @param pageVO 分页请求 * @param pageVO 分页请求
* @return 拼团记录分页数据 * @return 拼团记录分页数据
*/ */
PageResult<CombinationRecordDO> getBargainRecordPage(CombinationRecordReqPageVO pageVO); PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO);
/** /**
* 拼团活动获得拼团记录数量 Map * 拼团活动获得拼团记录数量 Map

View File

@ -139,7 +139,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL); throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL);
} }
// 3校验是否有拼团记录 // 3校验是否有拼团记录
List<CombinationRecordDO> recordList = getRecordListByUserIdAndActivityId(userId, activityId); List<CombinationRecordDO> recordList = getCombinationRecordListByUserIdAndActivityId(userId, activityId);
if (CollUtil.isEmpty(recordList)) { if (CollUtil.isEmpty(recordList)) {
return new KeyValue<>(activity, product); return new KeyValue<>(activity, product);
} }
@ -213,7 +213,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
} }
@Override @Override
public List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) { public List<CombinationRecordDO> getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId) {
return recordMapper.selectListByUserIdAndActivityId(userId, activityId); return recordMapper.selectListByUserIdAndActivityId(userId, activityId);
} }
@ -227,12 +227,12 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
} }
@Override @Override
public Long getRecordsCount() { public Long getCombinationRecordsCount() {
return recordMapper.selectCount(); return recordMapper.selectCount();
} }
@Override @Override
public Long getRecordsSuccessCount() { public Long getCombinationRecordsSuccessCount() {
return recordMapper.selectCount(CombinationRecordDO::getStatus, CombinationRecordStatusEnum.SUCCESS.getStatus()); return recordMapper.selectCount(CombinationRecordDO::getStatus, CombinationRecordStatusEnum.SUCCESS.getStatus());
} }
@ -242,32 +242,32 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
} }
@Override @Override
public Long getRecordsCountByDateType(Integer dateType) { public Long getCombinationRecordsCountByDateType(Integer dateType) {
return recordMapper.selectCount(dateType); return recordMapper.selectCount(dateType);
} }
@Override @Override
public List<CombinationRecordDO> getLatestRecordList(int count) { public List<CombinationRecordDO> getLatestCombinationRecordList(int count) {
return recordMapper.selectLatestList(count); return recordMapper.selectLatestList(count);
} }
@Override @Override
public List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count) { public List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count) {
return recordMapper.selectList(activityId, status, count); return recordMapper.selectList(activityId, status, count);
} }
@Override @Override
public CombinationRecordDO getRecordById(Long id) { public CombinationRecordDO getCombinationRecordById(Long id) {
return recordMapper.selectById(id); return recordMapper.selectById(id);
} }
@Override @Override
public List<CombinationRecordDO> getRecordListByHeadId(Long headId) { public List<CombinationRecordDO> getCombinationRecordListByHeadId(Long headId) {
return recordMapper.selectList(CombinationRecordDO::getHeadId, headId); return recordMapper.selectList(CombinationRecordDO::getHeadId, headId);
} }
@Override @Override
public PageResult<CombinationRecordDO> getBargainRecordPage(CombinationRecordReqPageVO pageVO) { public PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO) {
return recordMapper.selectPage(pageVO); return recordMapper.selectPage(pageVO);
} }

View File

@ -111,9 +111,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
o.setStartTime(null); o.setStartTime(null);
o.setEndTime(null); o.setEndTime(null);
o.setUserSize(null); o.setUserSize(null);
o.setTotalCount(null);
o.setSuccessCount(null);
o.setOrderUserCount(null);
o.setVirtualGroup(null); o.setVirtualGroup(null);
o.setStatus(null); o.setStatus(null);
o.setLimitDuration(null); o.setLimitDuration(null);
@ -134,12 +131,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null))); combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
// 测试 userSize 不匹配 // 测试 userSize 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null))); combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
// 测试 totalNum 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalCount(null)));
// 测试 successNum 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSuccessCount(null)));
// 测试 orderUserCount 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setOrderUserCount(null)));
// 测试 virtualGroup 不匹配 // 测试 virtualGroup 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null))); combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
// 测试 status 不匹配 // 测试 status 不匹配
@ -173,9 +164,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
o.setStartTime(null); o.setStartTime(null);
o.setEndTime(null); o.setEndTime(null);
o.setUserSize(null); o.setUserSize(null);
o.setTotalCount(null);
o.setSuccessCount(null);
o.setOrderUserCount(null);
o.setVirtualGroup(null); o.setVirtualGroup(null);
o.setStatus(null); o.setStatus(null);
o.setLimitDuration(null); o.setLimitDuration(null);
@ -196,12 +184,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null))); combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
// 测试 userSize 不匹配 // 测试 userSize 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null))); combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
// 测试 totalNum 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalCount(null)));
// 测试 successNum 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSuccessCount(null)));
// 测试 orderUserCount 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setOrderUserCount(null)));
// 测试 virtualGroup 不匹配 // 测试 virtualGroup 不匹配
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null))); combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
// 测试 status 不匹配 // 测试 status 不匹配