Commit 1ff9bc6a71516a36247def8ea0a7a83601a97355
1 parent
cebdc190
code review:文章管理
Showing
14 changed files
with
33 additions
and
79 deletions
sql/mysql/member.sql deleted
sql/mysql/statistics.sql deleted
| 1 | --- 交易统计表 | ||
| 2 | -CREATE TABLE trade_statistics | ||
| 3 | -( | ||
| 4 | - id bigint AUTO_INCREMENT COMMENT '编号,主键自增' | ||
| 5 | - PRIMARY KEY, | ||
| 6 | - time datetime NOT NULL COMMENT '统计日期', | ||
| 7 | - order_create_count int DEFAULT 0 NOT NULL COMMENT '创建订单数', | ||
| 8 | - order_pay_count int DEFAULT 0 NOT NULL COMMENT '支付订单商品数', | ||
| 9 | - order_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额,单位:分', | ||
| 10 | - order_wallet_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额(余额),单位:分', | ||
| 11 | - after_sale_count int DEFAULT 0 NOT NULL COMMENT '退款订单数', | ||
| 12 | - after_sale_refund_price int DEFAULT 0 NOT NULL COMMENT '总退款金额,单位:分', | ||
| 13 | - brokerage_settlement_price int DEFAULT 0 NOT NULL COMMENT '佣金金额(已结算),单位:分', | ||
| 14 | - recharge_pay_count int DEFAULT 0 NOT NULL COMMENT '充值订单数', | ||
| 15 | - recharge_pay_price int DEFAULT 0 NOT NULL COMMENT '充值金额,单位:分', | ||
| 16 | - recharge_refund_count int DEFAULT 0 NOT NULL COMMENT '充值退款订单数', | ||
| 17 | - recharge_refund_price int DEFAULT 0 NOT NULL COMMENT '充值退款金额,单位:分', | ||
| 18 | - creator varchar(64) DEFAULT '' NULL COMMENT '创建者', | ||
| 19 | - create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间', | ||
| 20 | - updater varchar(64) DEFAULT '' NULL COMMENT '更新者', | ||
| 21 | - update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 22 | - deleted bit DEFAULT b'0' NOT NULL COMMENT '是否删除', | ||
| 23 | - tenant_id bigint DEFAULT 0 NOT NULL COMMENT '租户编号' | ||
| 24 | -) | ||
| 25 | - COMMENT '交易统计表'; | ||
| 26 | - | ||
| 27 | -CREATE INDEX trade_statistics_time_index | ||
| 28 | - ON trade_statistics (time); | ||
| 29 | - | ||
| 30 | --- 菜单 | ||
| 31 | -INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) | ||
| 32 | -VALUES ('统计管理', '', 1, 4, 0, '/statistics', 'ep:data-line', '', ''); | ||
| 33 | -SELECT @parentId := LAST_INSERT_ID(); | ||
| 34 | --- 交易统计 | ||
| 35 | -INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) | ||
| 36 | -VALUES ('交易统计', '', 2, 1, @parentId, 'trade', 'fa-solid:credit-card', 'statistics/trade/index', 'TradeStatistics'); | ||
| 37 | -SELECT @parentId := LAST_INSERT_ID(); | ||
| 38 | -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | ||
| 39 | -VALUES ('交易统计查询', 'statistics:trade:query', 3, 1, @parentId, '', '', '', 0); | ||
| 40 | -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | ||
| 41 | -VALUES ('交易统计导出', 'statistics:trade:export', 3, 2, @parentId, '', '', '', 0); | ||
| 42 | --- 会员统计 | ||
| 43 | -INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) | ||
| 44 | -VALUES ('会员统计', '', 2, 2, @parentId, 'member', 'ep:avatar', 'statistics/member/index', 'MemberStatistics'); | ||
| 45 | -SELECT @parentId := LAST_INSERT_ID(); | ||
| 46 | -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | ||
| 47 | -VALUES ('会员统计查询', 'statistics:member:query', 3, 1, @parentId, '', '', '', 0); | ||
| 48 | - | ||
| 49 | - |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java
| @@ -31,6 +31,7 @@ public class AppArticleCategoryController { | @@ -31,6 +31,7 @@ public class AppArticleCategoryController { | ||
| 31 | public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() { | 31 | public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() { |
| 32 | List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus( | 32 | List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus( |
| 33 | CommonStatusEnum.ENABLE.getStatus()); | 33 | CommonStatusEnum.ENABLE.getStatus()); |
| 34 | + // TODO @puhui999:排序下 | ||
| 34 | return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList)); | 35 | return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList)); |
| 35 | } | 36 | } |
| 36 | 37 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java
| @@ -39,7 +39,7 @@ public class AppArticleController { | @@ -39,7 +39,7 @@ public class AppArticleController { | ||
| 39 | @RequestParam(value = "recommendHot", required = false) Boolean recommendHot, | 39 | @RequestParam(value = "recommendHot", required = false) Boolean recommendHot, |
| 40 | @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { | 40 | @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { |
| 41 | return success(ArticleConvert.INSTANCE.convertList03( | 41 | return success(ArticleConvert.INSTANCE.convertList03( |
| 42 | - articleService.getArticleCategoryListByRecommendHotAndRecommendBanner(recommendHot, recommendBanner))); | 42 | + articleService.getArticleCategoryListByRecommend(recommendHot, recommendBanner))); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | @RequestMapping("/page") | 45 | @RequestMapping("/page") |
| @@ -55,4 +55,5 @@ public class AppArticleController { | @@ -55,4 +55,5 @@ public class AppArticleController { | ||
| 55 | return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id))); | 55 | return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id))); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | + // TODO @puhui999:增加浏览量,实现一个接口;先简单做,用户规模不大,只 +1 即可;ps:uniapp 那边也要接下噢 | ||
| 58 | } | 59 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| @@ -210,6 +210,7 @@ public interface CombinationActivityConvert { | @@ -210,6 +210,7 @@ public interface CombinationActivityConvert { | ||
| 210 | * @param virtualGroupHeadRecord 虚拟成团团长记录 | 210 | * @param virtualGroupHeadRecord 虚拟成团团长记录 |
| 211 | * @return 虚拟记录列表 | 211 | * @return 虚拟记录列表 |
| 212 | */ | 212 | */ |
| 213 | + // TODO @puhui999:1)方法名,建议改成 convertVirtualRecordList(CombinationRecordDO headRecord);2)第 220 到 225 可以搞成 mapstruct 一个方法,默认都 copy 进去,然后 set 第 226 到 232 的字段 | ||
| 213 | default List<CombinationRecordDO> convertVirtualGroupList(CombinationRecordDO virtualGroupHeadRecord) { | 214 | default List<CombinationRecordDO> convertVirtualGroupList(CombinationRecordDO virtualGroupHeadRecord) { |
| 214 | List<CombinationRecordDO> createRecords = new ArrayList<>(); | 215 | List<CombinationRecordDO> createRecords = new ArrayList<>(); |
| 215 | // 计算需要创建的虚拟成团记录数量 | 216 | // 计算需要创建的虚拟成团记录数量 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| @@ -140,7 +140,7 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -140,7 +140,7 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | default List<CombinationRecordDO> selectListByHeadId(Long headId) { | 142 | default List<CombinationRecordDO> selectListByHeadId(Long headId) { |
| 143 | - return selectList(new LambdaQueryWrapperX<CombinationRecordDO>().eq(CombinationRecordDO::getHeadId, headId)); | 143 | + return selectList(CombinationRecordDO::getHeadId, headId); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | } | 146 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java
| @@ -56,6 +56,7 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | @@ -56,6 +56,7 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | ||
| 56 | // 校验存在 | 56 | // 校验存在 |
| 57 | validateArticleCategoryExists(id); | 57 | validateArticleCategoryExists(id); |
| 58 | // 校验是不是存在关联文章 | 58 | // 校验是不是存在关联文章 |
| 59 | + // TODO @puhui999:最好获得数量哈; | ||
| 59 | List<ArticleDO> articleList = articleService.getArticleByCategoryId(id); | 60 | List<ArticleDO> articleList = articleService.getArticleByCategoryId(id); |
| 60 | if (CollUtil.isNotEmpty(articleList)) { | 61 | if (CollUtil.isNotEmpty(articleList)) { |
| 61 | throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES); | 62 | throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES); |
| @@ -83,6 +84,7 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | @@ -83,6 +84,7 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | ||
| 83 | 84 | ||
| 84 | @Override | 85 | @Override |
| 85 | public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { | 86 | public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { |
| 87 | + // TODO @puhui999:selectListByStatus | ||
| 86 | return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); | 88 | return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); |
| 87 | } | 89 | } |
| 88 | 90 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java
| @@ -62,7 +62,7 @@ public interface ArticleService { | @@ -62,7 +62,7 @@ public interface ArticleService { | ||
| 62 | * @param recommendBanner 是否轮播图 | 62 | * @param recommendBanner 是否轮播图 |
| 63 | * @return 文章详情列表 | 63 | * @return 文章详情列表 |
| 64 | */ | 64 | */ |
| 65 | - List<ArticleDO> getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner); | 65 | + List<ArticleDO> getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner); |
| 66 | 66 | ||
| 67 | /** | 67 | /** |
| 68 | * 获得文章详情分页 | 68 | * 获得文章详情分页 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java
| @@ -30,6 +30,7 @@ public class ArticleServiceImpl implements ArticleService { | @@ -30,6 +30,7 @@ public class ArticleServiceImpl implements ArticleService { | ||
| 30 | 30 | ||
| 31 | @Resource | 31 | @Resource |
| 32 | private ArticleMapper articleMapper; | 32 | private ArticleMapper articleMapper; |
| 33 | + | ||
| 33 | @Resource | 34 | @Resource |
| 34 | private ArticleCategoryService articleCategoryService; | 35 | private ArticleCategoryService articleCategoryService; |
| 35 | 36 | ||
| @@ -89,7 +90,7 @@ public class ArticleServiceImpl implements ArticleService { | @@ -89,7 +90,7 @@ public class ArticleServiceImpl implements ArticleService { | ||
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | @Override | 92 | @Override |
| 92 | - public List<ArticleDO> getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner) { | 93 | + public List<ArticleDO> getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner) { |
| 93 | return articleMapper.selectList(recommendHot, recommendBanner); | 94 | return articleMapper.selectList(recommendHot, recommendBanner); |
| 94 | } | 95 | } |
| 95 | 96 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| @@ -351,9 +351,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -351,9 +351,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 351 | convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); | 351 | convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); |
| 352 | Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId); | 352 | Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId); |
| 353 | 353 | ||
| 354 | - // 3. 改成“每个团”,处理一次哈;这样 handleExpireRecord、handleVirtualGroupRecord 都改成按团处理,每个是一个小事务; | 354 | + // 3. 逐个处理拼团,过期 or 虚拟成团 |
| 355 | KeyValue<Integer, Integer> keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团 | 355 | KeyValue<Integer, Integer> keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团 |
| 356 | for (CombinationRecordDO recordDO : headExpireRecords) { | 356 | for (CombinationRecordDO recordDO : headExpireRecords) { |
| 357 | + // TODO @puhui999:recordDO 非必要的情况下,不用带 DO;直接 record; | ||
| 357 | try { | 358 | try { |
| 358 | CombinationActivityDO activity = activityMap.get(recordDO.getActivityId()); | 359 | CombinationActivityDO activity = activityMap.get(recordDO.getActivityId()); |
| 359 | if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 | 360 | if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 |
| @@ -366,9 +367,9 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -366,9 +367,9 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 366 | keyValue.setValue(keyValue.getValue() + 1); | 367 | keyValue.setValue(keyValue.getValue() + 1); |
| 367 | } | 368 | } |
| 368 | } catch (Exception ignored) { // 处理异常继续循环 | 369 | } catch (Exception ignored) { // 处理异常继续循环 |
| 370 | + // TODO @puhui999:需要打印异常日志 | ||
| 369 | } | 371 | } |
| 370 | } | 372 | } |
| 371 | - | ||
| 372 | return keyValue; | 373 | return keyValue; |
| 373 | } | 374 | } |
| 374 | 375 | ||
| @@ -379,6 +380,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -379,6 +380,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 379 | */ | 380 | */ |
| 380 | @Transactional(rollbackFor = Exception.class) | 381 | @Transactional(rollbackFor = Exception.class) |
| 381 | public void handleExpireRecord(CombinationRecordDO headExpireRecord) { | 382 | public void handleExpireRecord(CombinationRecordDO headExpireRecord) { |
| 383 | + // TODO @puhui999:这里的 null 其实不用判断。真出现,应该要处个 npe,因为就是要错哈; | ||
| 384 | + // TODO @puhui999:headExpireRecord 可以简化成 headRecord | ||
| 382 | if (headExpireRecord == null) { | 385 | if (headExpireRecord == null) { |
| 383 | return; | 386 | return; |
| 384 | } | 387 | } |
| @@ -386,14 +389,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -386,14 +389,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 386 | // 1.更新拼团记录 | 389 | // 1.更新拼团记录 |
| 387 | List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecord, | 390 | List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecord, |
| 388 | CombinationRecordStatusEnum.FAILED); | 391 | CombinationRecordStatusEnum.FAILED); |
| 392 | + // TODO @puhui999:这里的 null 其实不用判断。真出现,应该要处个 npe,因为就是要错哈; | ||
| 389 | if (headsAndRecords == null) { | 393 | if (headsAndRecords == null) { |
| 390 | return; | 394 | return; |
| 391 | } | 395 | } |
| 392 | 396 | ||
| 393 | // 2.订单取消 | 397 | // 2.订单取消 |
| 394 | - headsAndRecords.forEach(item -> { | ||
| 395 | - tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()); | ||
| 396 | - }); | 398 | + headsAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId())); |
| 397 | } | 399 | } |
| 398 | 400 | ||
| 399 | /** | 401 | /** |
| @@ -403,6 +405,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -403,6 +405,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 403 | */ | 405 | */ |
| 404 | @Transactional(rollbackFor = Exception.class) | 406 | @Transactional(rollbackFor = Exception.class) |
| 405 | public void handleVirtualGroupRecord(CombinationRecordDO virtualGroupHeadRecord) { | 407 | public void handleVirtualGroupRecord(CombinationRecordDO virtualGroupHeadRecord) { |
| 408 | + // TODO @puhui999:这里的 null 其实不用判断。真出现,应该要处个 npe,因为就是要错哈; | ||
| 409 | + // TODO @puhui999:headExpireRecord 可以简化成 headRecord | ||
| 406 | if (virtualGroupHeadRecord == null) { | 410 | if (virtualGroupHeadRecord == null) { |
| 407 | return; | 411 | return; |
| 408 | } | 412 | } |
| @@ -413,18 +417,21 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -413,18 +417,21 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 413 | updateBatchCombinationRecords(virtualGroupHeadRecord, CombinationRecordStatusEnum.SUCCESS); | 417 | updateBatchCombinationRecords(virtualGroupHeadRecord, CombinationRecordStatusEnum.SUCCESS); |
| 414 | } | 418 | } |
| 415 | 419 | ||
| 420 | + // TODO @puhui999:写下方法注释; | ||
| 416 | private List<CombinationRecordDO> updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) { | 421 | private List<CombinationRecordDO> updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) { |
| 417 | // 1. 查询团成员(包含团长) | 422 | // 1. 查询团成员(包含团长) |
| 418 | List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadId(headRecord.getId()); | 423 | List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadId(headRecord.getId()); |
| 424 | + // TODO @puhui999:是不是不用判断空哈;例如说,就一个团长,然后过期。 | ||
| 419 | if (CollUtil.isEmpty(records)) { | 425 | if (CollUtil.isEmpty(records)) { |
| 420 | return null; | 426 | return null; |
| 421 | } | 427 | } |
| 422 | records.add(headRecord);// 把团长加进去 | 428 | records.add(headRecord);// 把团长加进去 |
| 423 | 429 | ||
| 424 | - // 2.批量更新拼团记录 status 和 失败/成团时间 | 430 | + // 2. 批量更新拼团记录 status 和 endTime |
| 425 | List<CombinationRecordDO> updateRecords = new ArrayList<>(records.size()); | 431 | List<CombinationRecordDO> updateRecords = new ArrayList<>(records.size()); |
| 426 | LocalDateTime now = LocalDateTime.now(); | 432 | LocalDateTime now = LocalDateTime.now(); |
| 427 | records.forEach(item -> { | 433 | records.forEach(item -> { |
| 434 | + // TODO @puhui999:record 改成 updateRecord | ||
| 428 | CombinationRecordDO record = new CombinationRecordDO().setId(item.getId()) | 435 | CombinationRecordDO record = new CombinationRecordDO().setId(item.getId()) |
| 429 | .setStatus(status.getStatus()).setEndTime(now); | 436 | .setStatus(status.getStatus()).setEndTime(now); |
| 430 | if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 | 437 | if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java
| @@ -92,20 +92,12 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { | @@ -92,20 +92,12 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { | ||
| 92 | default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { | 92 | default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { |
| 93 | return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); | 93 | return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); |
| 94 | } | 94 | } |
| 95 | - | ||
| 96 | - /** | ||
| 97 | - * 只针对 combinationActivityId 的查询 | ||
| 98 | - * | ||
| 99 | - * @param userId 用户编号 | ||
| 100 | - * @param activityId 拼团活动编号 | ||
| 101 | - * @param status 订单状态 | ||
| 102 | - * @return 交易订单 | ||
| 103 | - */ | ||
| 104 | - default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status) { | 95 | + |
| 96 | + default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long combinationActivityId, Integer status) { | ||
| 105 | return selectOne(new LambdaQueryWrapperX<TradeOrderDO>() | 97 | return selectOne(new LambdaQueryWrapperX<TradeOrderDO>() |
| 106 | .eq(TradeOrderDO::getUserId, userId) | 98 | .eq(TradeOrderDO::getUserId, userId) |
| 107 | .eq(TradeOrderDO::getStatus, status) | 99 | .eq(TradeOrderDO::getStatus, status) |
| 108 | - .eq(TradeOrderDO::getCombinationActivityId, activityId) | 100 | + .eq(TradeOrderDO::getCombinationActivityId, combinationActivityId) |
| 109 | ); | 101 | ); |
| 110 | } | 102 | } |
| 111 | 103 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java
| @@ -42,11 +42,11 @@ public interface TradeOrderQueryService { | @@ -42,11 +42,11 @@ public interface TradeOrderQueryService { | ||
| 42 | * 获得指定用户,指定活动,指定状态的交易订单 | 42 | * 获得指定用户,指定活动,指定状态的交易订单 |
| 43 | * | 43 | * |
| 44 | * @param userId 用户编号 | 44 | * @param userId 用户编号 |
| 45 | - * @param activityId 活动编号 | 45 | + * @param combinationActivityId 活动编号 |
| 46 | * @param status 订单状态 | 46 | * @param status 订单状态 |
| 47 | * @return 交易订单 | 47 | * @return 交易订单 |
| 48 | */ | 48 | */ |
| 49 | - TradeOrderDO getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status); | 49 | + TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status); |
| 50 | 50 | ||
| 51 | /** | 51 | /** |
| 52 | * 获得订单列表 | 52 | * 获得订单列表 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java
| @@ -71,8 +71,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { | @@ -71,8 +71,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | @Override | 73 | @Override |
| 74 | - public TradeOrderDO getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status) { | ||
| 75 | - return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, activityId, status); | 74 | + public TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status) { |
| 75 | + return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, combinationActivityId, status); | ||
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | @Override | 78 | @Override |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java
| @@ -49,7 +49,7 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | @@ -49,7 +49,7 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | ||
| 49 | order.getCombinationHeadId(), item.getSkuId(), item.getCount()); | 49 | order.getCombinationHeadId(), item.getSkuId(), item.getCount()); |
| 50 | 50 | ||
| 51 | // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 | 51 | // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 |
| 52 | - TradeOrderDO activityOrder = orderQueryService.getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus( | 52 | + TradeOrderDO activityOrder = orderQueryService.getOrderByUserIdAndStatusAndCombination( |
| 53 | order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); | 53 | order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); |
| 54 | if (activityOrder != null) { | 54 | if (activityOrder != null) { |
| 55 | throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID); | 55 | throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID); |
| @@ -69,9 +69,8 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | @@ -69,9 +69,8 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | ||
| 69 | CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord( | 69 | CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord( |
| 70 | TradeOrderConvert.INSTANCE.convert(order, item)); | 70 | TradeOrderConvert.INSTANCE.convert(order, item)); |
| 71 | 71 | ||
| 72 | - // 3. 更新拼团相关信息到订单 | ||
| 73 | - // 为什么几个字段都要更新?原因是: | ||
| 74 | - // 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,设置团长编号这个操作时在订单是否后创建拼团记录时才设置的。 | 72 | + // 3. 更新拼团相关信息到订单。为什么几个字段都要更新? |
| 73 | + // 原因是:如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,设置团长编号这个操作时在订单是否后创建拼团记录时才设置的。 | ||
| 75 | orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), | 74 | orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), |
| 76 | combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); | 75 | combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); |
| 77 | } | 76 | } |