Commit 6099786c1b7a7e8d9f93bb9edcc9fb5db364b3bd

Authored by puhui999
1 parent 8b480c52

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

yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java
... ... @@ -51,7 +51,7 @@ public class CombinationRecordController {
51 51 @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
52 52 public CommonResult<PageResult<CombinationRecordRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) {
53 53 return success(CombinationActivityConvert.INSTANCE.convert(
54   - combinationRecordService.getBargainRecordPage(pageVO)));
  54 + combinationRecordService.getCombinationRecordPage(pageVO)));
55 55 }
56 56  
57 57 @GetMapping("/get-summary")
... ... @@ -64,22 +64,22 @@ public class CombinationRecordController {
64 64 @GetMapping("/get-count")
65 65 @Operation(summary = "获得拼团记录分页 tab count")
66 66 @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
67   - public CommonResult<Map<String, Long>> getSpuCount() {
  67 + public CommonResult<Map<String, Long>> getCombinationRecordCount() {
68 68 Map<String, Long> hashMap = MapUtil.newHashMap(7);
69   - hashMap.put("all", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.ALL));// 全部
70   - hashMap.put("toDay", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.TO_DAY));// 今天
71   - hashMap.put("yesterday", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.YESTERDAY));// 昨天
72   - hashMap.put("lastSevenDays", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_SEVEN_DAYS));// 最近七天
73   - hashMap.put("last30Days", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_30_DAYS));// 最近 30 天
74   - hashMap.put("thisMonth", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_MONTH));// 本月
75   - hashMap.put("thisYear", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_YEAR));// 本年
  69 + hashMap.put("all", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.ALL));// 全部
  70 + hashMap.put("toDay", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.TO_DAY));// 今天
  71 + hashMap.put("yesterday", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.YESTERDAY));// 昨天
  72 + hashMap.put("lastSevenDays", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.LAST_SEVEN_DAYS));// 最近七天
  73 + hashMap.put("last30Days", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.LAST_30_DAYS));// 最近 30 天
  74 + hashMap.put("thisMonth", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.THIS_MONTH));// 本月
  75 + hashMap.put("thisYear", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.THIS_YEAR));// 本年
76 76 return success(hashMap);
77 77 }
78 78  
79 79 private Map<String, Long> getCombinationRecordSummary0() {
80 80 Map<String, Long> hashMap = MapUtil.newHashMap(3);
81   - hashMap.put("userCount", combinationRecordService.getRecordsCount());// 获取所有拼团记录
82   - hashMap.put("successCount", combinationRecordService.getRecordsSuccessCount());// 获取成团记录
  81 + hashMap.put("userCount", combinationRecordService.getCombinationRecordsCount());// 获取所有拼团记录
  82 + hashMap.put("successCount", combinationRecordService.getCombinationRecordsSuccessCount());// 获取成团记录
83 83 hashMap.put("virtualGroupCount", combinationRecordService.getRecordsVirtualGroupCount());// 获取虚拟成团记录
84 84 return hashMap;
85 85 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java
... ... @@ -42,7 +42,7 @@ public class AppCombinationRecordController {
42 42 // TODO 芋艿:增加 @Cache 缓存,1 分钟过期
43 43 public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
44 44 // 获取所有拼团记录
45   - Long count = combinationRecordService.getRecordsCount();
  45 + Long count = combinationRecordService.getCombinationRecordsCount();
46 46 AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
47 47 if (count == null || count == 0L) {
48 48 summary.setAvatars(Collections.emptyList());
... ... @@ -53,7 +53,7 @@ public class AppCombinationRecordController {
53 53 summary.setUserCount(count);
54 54 // TODO 只返回最近的 7 个
55 55 int num = 7;
56   - summary.setAvatars(convertList(combinationRecordService.getLatestRecordList(num), CombinationRecordDO::getAvatar));
  56 + summary.setAvatars(convertList(combinationRecordService.getLatestCombinationRecordList(num), CombinationRecordDO::getAvatar));
57 57 return success(summary);
58 58 }
59 59  
... ... @@ -69,7 +69,7 @@ public class AppCombinationRecordController {
69 69 @RequestParam("status") Integer status,
70 70 @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
71 71 return success(CombinationActivityConvert.INSTANCE.convertList3(
72   - combinationRecordService.getRecordListWithHead(activityId, status, count)));
  72 + combinationRecordService.getCombinationRecordListWithHead(activityId, status, count)));
73 73 }
74 74  
75 75 @GetMapping("/get-detail")
... ... @@ -77,7 +77,7 @@ public class AppCombinationRecordController {
77 77 @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
78 78 public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
79 79 // 1、查询这条记录
80   - CombinationRecordDO record = combinationRecordService.getRecordById(id);
  80 + CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id);
81 81 if (record == null) {
82 82 return success(null);
83 83 }
... ... @@ -88,17 +88,17 @@ public class AppCombinationRecordController {
88 88 if (record.getHeadId() == null) {
89 89 detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record));
90 90 // 2.1、查找团员拼团记录
91   - records = combinationRecordService.getRecordListByHeadId(record.getId());
  91 + records = combinationRecordService.getCombinationRecordListByHeadId(record.getId());
92 92 } else {
93 93 // 2.2、查找团长拼团记录
94   - CombinationRecordDO headRecord = combinationRecordService.getRecordById(record.getHeadId());
  94 + CombinationRecordDO headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId());
95 95 if (headRecord == null) {
96 96 return success(null);
97 97 }
98 98  
99 99 detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord));
100 100 // 2.3、查找团员拼团记录
101   - records = combinationRecordService.getRecordListByHeadId(headRecord.getId());
  101 + records = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId());
102 102  
103 103 }
104 104 detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records));
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
... ... @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.combination;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.map.MapUtil;
5   -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
6 5 import cn.hutool.core.util.ObjectUtil;
7 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  7 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
8 8 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
9 9 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
10 10 import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
... ... @@ -32,10 +32,6 @@ public interface CombinationRecordMapper extends BaseMapperX&lt;CombinationRecordDO
32 32 CombinationRecordDO::getOrderId, orderId);
33 33 }
34 34  
35   - default List<CombinationRecordDO> selectListByUserId(Long userId) {
36   - return selectList(CombinationRecordDO::getUserId, userId);
37   - }
38   -
39 35 default List<CombinationRecordDO> selectListByUserIdAndStatus(Long userId, Integer status) {
40 36 return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
41 37 .eq(CombinationRecordDO::getUserId, userId)
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
... ... @@ -15,7 +15,6 @@ import java.util.Collection;
15 15 import java.util.List;
16 16 import java.util.Map;
17 17  
18   -// todo @PUHUI:方法名,还是带下 Combination 哈
19 18 /**
20 19 * 拼团记录 Service 接口
21 20 *
... ... @@ -62,11 +61,11 @@ public interface CombinationRecordService {
62 61 void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime);
63 62  
64 63 /**
65   - * 获得拼团状态
  64 + * 获得拼团记录
66 65 *
67 66 * @param userId 用户编号
68 67 * @param orderId 订单编号
69   - * @return 拼团状态
  68 + * @return 拼团记录
70 69 */
71 70 CombinationRecordDO getCombinationRecord(Long userId, Long orderId);
72 71  
... ... @@ -77,7 +76,7 @@ public interface CombinationRecordService {
77 76 * @param activityId 活动 id
78 77 * @return 拼团记录列表
79 78 */
80   - List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId);
  79 + List<CombinationRecordDO> getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId);
81 80  
82 81 /**
83 82 * 【下单前】校验是否满足拼团活动条件
... ... @@ -97,14 +96,14 @@ public interface CombinationRecordService {
97 96 *
98 97 * @return 记录数
99 98 */
100   - Long getRecordsCount();
  99 + Long getCombinationRecordsCount();
101 100  
102 101 /**
103 102 * 获取成功记录数
104 103 *
105 104 * @return 记录数
106 105 */
107   - Long getRecordsSuccessCount();
  106 + Long getCombinationRecordsSuccessCount();
108 107  
109 108 /**
110 109 * 获取虚拟成团记录数
... ... @@ -119,7 +118,7 @@ public interface CombinationRecordService {
119 118 * @param dateType 日期类型
120 119 * @return 记录数
121 120 */
122   - Long getRecordsCountByDateType(Integer dateType);
  121 + Long getCombinationRecordsCountByDateType(Integer dateType);
123 122  
124 123 /**
125 124 * 获取最近的 count 条拼团记录
... ... @@ -127,7 +126,7 @@ public interface CombinationRecordService {
127 126 * @param count 限制数量
128 127 * @return 拼团记录列表
129 128 */
130   - List<CombinationRecordDO> getLatestRecordList(int count);
  129 + List<CombinationRecordDO> getLatestCombinationRecordList(int count);
131 130  
132 131 /**
133 132 * 获得最近 n 条拼团记录(团长发起的)
... ... @@ -137,7 +136,7 @@ public interface CombinationRecordService {
137 136 * @param count 数量
138 137 * @return 拼团记录列表
139 138 */
140   - List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count);
  139 + List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count);
141 140  
142 141 /**
143 142 * 获取指定编号的拼团记录
... ... @@ -145,7 +144,7 @@ public interface CombinationRecordService {
145 144 * @param id 拼团记录编号
146 145 * @return 拼团记录
147 146 */
148   - CombinationRecordDO getRecordById(Long id);
  147 + CombinationRecordDO getCombinationRecordById(Long id);
149 148  
150 149 /**
151 150 * 获取指定团长编号的拼团记录
... ... @@ -153,7 +152,7 @@ public interface CombinationRecordService {
153 152 * @param headId 团长编号
154 153 * @return 拼团记录列表
155 154 */
156   - List<CombinationRecordDO> getRecordListByHeadId(Long headId);
  155 + List<CombinationRecordDO> getCombinationRecordListByHeadId(Long headId);
157 156  
158 157 /**
159 158 * 获取拼团记录分页数据
... ... @@ -161,7 +160,7 @@ public interface CombinationRecordService {
161 160 * @param pageVO 分页请求
162 161 * @return 拼团记录分页数据
163 162 */
164   - PageResult<CombinationRecordDO> getBargainRecordPage(CombinationRecordReqPageVO pageVO);
  163 + PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO);
165 164  
166 165 /**
167 166 * 【拼团活动】获得拼团记录数量 Map
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
... ... @@ -139,7 +139,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
139 139 throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL);
140 140 }
141 141 // 3、校验是否有拼团记录
142   - List<CombinationRecordDO> recordList = getRecordListByUserIdAndActivityId(userId, activityId);
  142 + List<CombinationRecordDO> recordList = getCombinationRecordListByUserIdAndActivityId(userId, activityId);
143 143 if (CollUtil.isEmpty(recordList)) {
144 144 return new KeyValue<>(activity, product);
145 145 }
... ... @@ -213,7 +213,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
213 213 }
214 214  
215 215 @Override
216   - public List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) {
  216 + public List<CombinationRecordDO> getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId) {
217 217 return recordMapper.selectListByUserIdAndActivityId(userId, activityId);
218 218 }
219 219  
... ... @@ -227,12 +227,12 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
227 227 }
228 228  
229 229 @Override
230   - public Long getRecordsCount() {
  230 + public Long getCombinationRecordsCount() {
231 231 return recordMapper.selectCount();
232 232 }
233 233  
234 234 @Override
235   - public Long getRecordsSuccessCount() {
  235 + public Long getCombinationRecordsSuccessCount() {
236 236 return recordMapper.selectCount(CombinationRecordDO::getStatus, CombinationRecordStatusEnum.SUCCESS.getStatus());
237 237 }
238 238  
... ... @@ -242,32 +242,32 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
242 242 }
243 243  
244 244 @Override
245   - public Long getRecordsCountByDateType(Integer dateType) {
  245 + public Long getCombinationRecordsCountByDateType(Integer dateType) {
246 246 return recordMapper.selectCount(dateType);
247 247 }
248 248  
249 249 @Override
250   - public List<CombinationRecordDO> getLatestRecordList(int count) {
  250 + public List<CombinationRecordDO> getLatestCombinationRecordList(int count) {
251 251 return recordMapper.selectLatestList(count);
252 252 }
253 253  
254 254 @Override
255   - public List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count) {
  255 + public List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count) {
256 256 return recordMapper.selectList(activityId, status, count);
257 257 }
258 258  
259 259 @Override
260   - public CombinationRecordDO getRecordById(Long id) {
  260 + public CombinationRecordDO getCombinationRecordById(Long id) {
261 261 return recordMapper.selectById(id);
262 262 }
263 263  
264 264 @Override
265   - public List<CombinationRecordDO> getRecordListByHeadId(Long headId) {
  265 + public List<CombinationRecordDO> getCombinationRecordListByHeadId(Long headId) {
266 266 return recordMapper.selectList(CombinationRecordDO::getHeadId, headId);
267 267 }
268 268  
269 269 @Override
270   - public PageResult<CombinationRecordDO> getBargainRecordPage(CombinationRecordReqPageVO pageVO) {
  270 + public PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO) {
271 271 return recordMapper.selectPage(pageVO);
272 272 }
273 273  
... ...
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java
... ... @@ -111,9 +111,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
111 111 o.setStartTime(null);
112 112 o.setEndTime(null);
113 113 o.setUserSize(null);
114   - o.setTotalCount(null);
115   - o.setSuccessCount(null);
116   - o.setOrderUserCount(null);
117 114 o.setVirtualGroup(null);
118 115 o.setStatus(null);
119 116 o.setLimitDuration(null);
... ... @@ -134,12 +131,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
134 131 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
135 132 // 测试 userSize 不匹配
136 133 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
137   - // 测试 totalNum 不匹配
138   - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalCount(null)));
139   - // 测试 successNum 不匹配
140   - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSuccessCount(null)));
141   - // 测试 orderUserCount 不匹配
142   - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setOrderUserCount(null)));
143 134 // 测试 virtualGroup 不匹配
144 135 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
145 136 // 测试 status 不匹配
... ... @@ -173,9 +164,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
173 164 o.setStartTime(null);
174 165 o.setEndTime(null);
175 166 o.setUserSize(null);
176   - o.setTotalCount(null);
177   - o.setSuccessCount(null);
178   - o.setOrderUserCount(null);
179 167 o.setVirtualGroup(null);
180 168 o.setStatus(null);
181 169 o.setLimitDuration(null);
... ... @@ -196,12 +184,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
196 184 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
197 185 // 测试 userSize 不匹配
198 186 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
199   - // 测试 totalNum 不匹配
200   - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalCount(null)));
201   - // 测试 successNum 不匹配
202   - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSuccessCount(null)));
203   - // 测试 orderUserCount 不匹配
204   - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setOrderUserCount(null)));
205 187 // 测试 virtualGroup 不匹配
206 188 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
207 189 // 测试 status 不匹配
... ...