Commit 038e23a6b37755d4d11360b3dc6072f7bba22bc5
1 parent
0b2943ba
拼团活动:完善拼团 app-api 相关接口
Showing
8 changed files
with
169 additions
and
77 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
| @@ -27,6 +27,7 @@ import javax.annotation.Resource; | @@ -27,6 +27,7 @@ import javax.annotation.Resource; | ||
| 27 | import java.util.Collections; | 27 | import java.util.Collections; |
| 28 | import java.util.List; | 28 | import java.util.List; |
| 29 | 29 | ||
| 30 | +import static cn.hutool.core.util.ObjectUtil.defaultIfNull; | ||
| 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 31 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | 32 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| 32 | 33 | ||
| @@ -47,7 +48,7 @@ public class AppCombinationActivityController { | @@ -47,7 +48,7 @@ public class AppCombinationActivityController { | ||
| 47 | @Parameter(name = "count", description = "需要展示的数量", example = "6") | 48 | @Parameter(name = "count", description = "需要展示的数量", example = "6") |
| 48 | public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityList( | 49 | public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityList( |
| 49 | @RequestParam(name = "count", defaultValue = "6") Integer count) { | 50 | @RequestParam(name = "count", defaultValue = "6") Integer count) { |
| 50 | - List<CombinationActivityDO> list = activityService.getCombinationActivityListByCount(6); | 51 | + List<CombinationActivityDO> list = activityService.getCombinationActivityListByCount(defaultIfNull(count, 6)); |
| 51 | if (CollUtil.isEmpty(list)) { | 52 | if (CollUtil.isEmpty(list)) { |
| 52 | return success(Collections.emptyList()); | 53 | return success(Collections.emptyList()); |
| 53 | } | 54 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java
| 1 | package cn.iocoder.yudao.module.promotion.controller.app.combination; | 1 | package cn.iocoder.yudao.module.promotion.controller.app.combination; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.ObjectUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | 5 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; |
| 6 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; | 7 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; |
| 7 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO; | 8 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO; |
| 9 | +import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; | ||
| 8 | import io.swagger.v3.oas.annotations.Operation; | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | import io.swagger.v3.oas.annotations.Parameter; | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | +import io.swagger.v3.oas.annotations.Parameters; | ||
| 10 | import io.swagger.v3.oas.annotations.tags.Tag; | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | import org.springframework.validation.annotation.Validated; | 16 | import org.springframework.validation.annotation.Validated; |
| 12 | import org.springframework.web.bind.annotation.GetMapping; | 17 | import org.springframework.web.bind.annotation.GetMapping; |
| @@ -14,13 +19,14 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -14,13 +19,14 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
| 14 | import org.springframework.web.bind.annotation.RequestParam; | 19 | import org.springframework.web.bind.annotation.RequestParam; |
| 15 | import org.springframework.web.bind.annotation.RestController; | 20 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 21 | ||
| 22 | +import javax.annotation.Resource; | ||
| 17 | import javax.validation.constraints.Max; | 23 | import javax.validation.constraints.Max; |
| 18 | -import java.time.Duration; | ||
| 19 | -import java.time.LocalDateTime; | ||
| 20 | -import java.util.ArrayList; | 24 | +import java.util.Collections; |
| 21 | import java.util.List; | 25 | import java.util.List; |
| 22 | 26 | ||
| 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 27 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 28 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 29 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 24 | 30 | ||
| 25 | @Tag(name = "用户 APP - 拼团活动") | 31 | @Tag(name = "用户 APP - 拼团活动") |
| 26 | @RestController | 32 | @RestController |
| @@ -28,81 +34,78 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | @@ -28,81 +34,78 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 28 | @Validated | 34 | @Validated |
| 29 | public class AppCombinationRecordController { | 35 | public class AppCombinationRecordController { |
| 30 | 36 | ||
| 37 | + @Resource | ||
| 38 | + private CombinationRecordService combinationRecordService; | ||
| 39 | + | ||
| 31 | @GetMapping("/get-summary") | 40 | @GetMapping("/get-summary") |
| 32 | @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页") | 41 | @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页") |
| 33 | // TODO 芋艿:增加 @Cache 缓存,1 分钟过期 | 42 | // TODO 芋艿:增加 @Cache 缓存,1 分钟过期 |
| 34 | public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() { | 43 | public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() { |
| 44 | + // 获取所有拼团记录 | ||
| 45 | + Long count = combinationRecordService.getRecordsCount(); | ||
| 35 | AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); | 46 | AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); |
| 36 | - summary.setUserCount(1024); | ||
| 37 | - summary.setAvatars(new ArrayList<>()); | ||
| 38 | - summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLjFK35Wvia9lJKHoXfQuHhk0qZbvpPNxrAiaEKF7aL2k4I8kuqrdTWwliamdPHeyAA7DjAg725X2GIQ/132"); | ||
| 39 | - summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTK1pXgdj5DvBMwrbe8v3tFibSWeQATEsAibt3fllD8XwJ460P2r6KS3WCQvDefuv1bVpDhNCle6CTCA/132"); | ||
| 40 | - summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTL7KRGHBE62N0awFyBesmmxiaCicf1fJ7E7UCh6zA8GWlT1QC1zT01gG4OxI7BWDESkdPZ5o7tno4hA/132"); | ||
| 41 | - summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/ouwtwJycbic2JrCoZjETict0klxd1uRuicRneKk00ewMcCClxVcVHQT91Sh9MJGtwibf1fOicD1WpwSP4icJM6eQq1AA/132"); | ||
| 42 | - summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/RpUrhwens58qc99OcGs993xL4M5QPOe05ekqF9Eia440kRicAlicicIdQWicHBmy2bzLgHzHguWEzHHxnIgeictL7bLA/132"); | ||
| 43 | - summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/S4tfqmxc8GZGsKc1K4mnhpvtG16gtMrLnTQfDibhr7jJich9LRI5RQKZDoqEjZM3azMib5nic7F4ZXKMEgYyLO08KA/132"); | ||
| 44 | - summary.getAvatars().add("https://static.iocoder.cn/mall/132.jpeg"); | 47 | + if (count == null || count == 0L) { |
| 48 | + summary.setAvatars(Collections.emptyList()); | ||
| 49 | + summary.setUserCount(count); | ||
| 50 | + return success(summary); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + summary.setUserCount(count); | ||
| 54 | + // TODO 只返回最近的 7 个 | ||
| 55 | + int num = 7; | ||
| 56 | + summary.setAvatars(convertList(combinationRecordService.getLatestRecordList(num), CombinationRecordDO::getAvatar)); | ||
| 45 | return success(summary); | 57 | return success(summary); |
| 46 | } | 58 | } |
| 47 | 59 | ||
| 48 | @GetMapping("/get-head-list") | 60 | @GetMapping("/get-head-list") |
| 49 | @Operation(summary = "获得最近 n 条拼团记录(团长发起的)") | 61 | @Operation(summary = "获得最近 n 条拼团记录(团长发起的)") |
| 50 | - // TODO @芋艿:注解要补全 | 62 | + @Parameters({ |
| 63 | + @Parameter(name = "activityId", description = "拼团活动编号"), | ||
| 64 | + @Parameter(name = "status", description = "状态"), | ||
| 65 | + @Parameter(name = "count", description = "数量") | ||
| 66 | + }) | ||
| 51 | public CommonResult<List<AppCombinationRecordRespVO>> getHeadCombinationRecordList( | 67 | public CommonResult<List<AppCombinationRecordRespVO>> getHeadCombinationRecordList( |
| 52 | @RequestParam(value = "activityId", required = false) Long activityId, | 68 | @RequestParam(value = "activityId", required = false) Long activityId, |
| 53 | @RequestParam("status") Integer status, | 69 | @RequestParam("status") Integer status, |
| 54 | @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { | 70 | @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { |
| 55 | - List<AppCombinationRecordRespVO> list = new ArrayList<>(); | ||
| 56 | - for (int i = 1; i <= count; i++) { | ||
| 57 | - AppCombinationRecordRespVO record = new AppCombinationRecordRespVO(); | ||
| 58 | - record.setId((long) i); | ||
| 59 | - record.setNickname("用户" + i); | ||
| 60 | - record.setAvatar("头像" + i); | ||
| 61 | - record.setExpireTime(LocalDateTime.now()); | ||
| 62 | - record.setUserSize(10); | ||
| 63 | - record.setUserCount(i); | ||
| 64 | - record.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg"); | ||
| 65 | - record.setActivityId(1L); | ||
| 66 | - record.setSpuName("活动:" + i); | ||
| 67 | - list.add(record); | ||
| 68 | - } | ||
| 69 | - return success(list); | 71 | + return success(CombinationActivityConvert.INSTANCE.convertList3( |
| 72 | + combinationRecordService.getRecordListWithHead(activityId, status, count))); | ||
| 70 | } | 73 | } |
| 71 | 74 | ||
| 72 | @GetMapping("/get-detail") | 75 | @GetMapping("/get-detail") |
| 73 | @Operation(summary = "获得拼团记录明细") | 76 | @Operation(summary = "获得拼团记录明细") |
| 74 | @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") | 77 | @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") |
| 75 | public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) { | 78 | public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) { |
| 79 | + // 1、查询这条记录 | ||
| 80 | + CombinationRecordDO record = combinationRecordService.getRecordById(id); | ||
| 81 | + if (record == null) { | ||
| 82 | + return success(null); | ||
| 83 | + } | ||
| 84 | + | ||
| 76 | AppCombinationRecordDetailRespVO detail = new AppCombinationRecordDetailRespVO(); | 85 | AppCombinationRecordDetailRespVO detail = new AppCombinationRecordDetailRespVO(); |
| 77 | - // 团长 | ||
| 78 | - AppCombinationRecordRespVO headRecord = new AppCombinationRecordRespVO(); | ||
| 79 | - headRecord.setId(1L); | ||
| 80 | - headRecord.setNickname("用户" + 1); | ||
| 81 | - headRecord.setAvatar("头像" + 1); | ||
| 82 | - headRecord.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(1))); | ||
| 83 | - headRecord.setUserSize(10); | ||
| 84 | - headRecord.setUserCount(3); | ||
| 85 | - headRecord.setStatus(1); | ||
| 86 | - headRecord.setActivityId(10L); | ||
| 87 | - headRecord.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg"); | ||
| 88 | - headRecord.setCombinationPrice(100); | ||
| 89 | - detail.setHeadRecord(headRecord); | ||
| 90 | - // 团员 | ||
| 91 | - List<AppCombinationRecordRespVO> list = new ArrayList<>(); | ||
| 92 | - for (int i = 1; i <= 2; i++) { | ||
| 93 | - AppCombinationRecordRespVO record = new AppCombinationRecordRespVO(); | ||
| 94 | - record.setId((long) i); | ||
| 95 | - record.setNickname("用户" + i); | ||
| 96 | - record.setAvatar("头像" + i); | ||
| 97 | - record.setExpireTime(LocalDateTime.now()); | ||
| 98 | - record.setUserSize(10); | ||
| 99 | - record.setUserCount(i); | ||
| 100 | - record.setStatus(1); | ||
| 101 | - list.add(record); | 86 | + List<CombinationRecordDO> records; |
| 87 | + // 2、判断是否为团长 | ||
| 88 | + if (record.getHeadId() == null) { | ||
| 89 | + detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record)); | ||
| 90 | + // 2.1、查找团员拼团记录 | ||
| 91 | + records = combinationRecordService.getRecordListByHeadId(record.getId()); | ||
| 92 | + } else { | ||
| 93 | + // 2.2、查找团长拼团记录 | ||
| 94 | + CombinationRecordDO headRecord = combinationRecordService.getRecordById(record.getHeadId()); | ||
| 95 | + if (headRecord == null) { | ||
| 96 | + return success(null); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord)); | ||
| 100 | + // 2.3、查找团员拼团记录 | ||
| 101 | + records = combinationRecordService.getRecordListByHeadId(headRecord.getId()); | ||
| 102 | + | ||
| 102 | } | 103 | } |
| 103 | - detail.setMemberRecords(list); | ||
| 104 | - // 订单编号 | ||
| 105 | - detail.setOrderId(100L); | 104 | + detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records)); |
| 105 | + | ||
| 106 | + // 3、获取当前用户参团记录订单编号 | ||
| 107 | + CombinationRecordDO userRecord = CollectionUtils.findFirst(records, r -> ObjectUtil.equal(r.getUserId(), getLoginUserId())); | ||
| 108 | + detail.setOrderId(userRecord == null ? null : userRecord.getOrderId()); // 如果没参团,返回 null | ||
| 106 | return success(detail); | 109 | return success(detail); |
| 107 | } | 110 | } |
| 108 | 111 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java
| @@ -16,7 +16,6 @@ public class AppCombinationRecordDetailRespVO { | @@ -16,7 +16,6 @@ public class AppCombinationRecordDetailRespVO { | ||
| 16 | private List<AppCombinationRecordRespVO> memberRecords; | 16 | private List<AppCombinationRecordRespVO> memberRecords; |
| 17 | 17 | ||
| 18 | @Schema(description = "当前用户参团记录对应的订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 18 | @Schema(description = "当前用户参团记录对应的订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 19 | - // 如果没参团,返回 null | ||
| 20 | private Long orderId; | 19 | private Long orderId; |
| 21 | 20 | ||
| 22 | } | 21 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java
| @@ -10,9 +10,9 @@ import java.util.List; | @@ -10,9 +10,9 @@ import java.util.List; | ||
| 10 | public class AppCombinationRecordSummaryRespVO { | 10 | public class AppCombinationRecordSummaryRespVO { |
| 11 | 11 | ||
| 12 | @Schema(description = "拼团用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 12 | @Schema(description = "拼团用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 13 | - private Integer userCount; | 13 | + private Long userCount; |
| 14 | 14 | ||
| 15 | - @Schema(description = "拼团用户头像列表", requiredMode = Schema.RequiredMode.REQUIRED) // 只返回最近的 7 个 | 15 | + @Schema(description = "拼团用户头像列表", requiredMode = Schema.RequiredMode.REQUIRED) |
| 16 | private List<String> avatars; | 16 | private List<String> avatars; |
| 17 | 17 | ||
| 18 | } | 18 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| @@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product | @@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product | ||
| 14 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; | 14 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; |
| 15 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; | 15 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; |
| 16 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; | 16 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; |
| 17 | +import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; | ||
| 17 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; | 18 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 18 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; | 19 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; |
| 19 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; | 20 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| @@ -141,4 +142,8 @@ public interface CombinationActivityConvert { | @@ -141,4 +142,8 @@ public interface CombinationActivityConvert { | ||
| 141 | return convert2(combinationActivity).setProducts(convertList1(products)); | 142 | return convert2(combinationActivity).setProducts(convertList1(products)); |
| 142 | } | 143 | } |
| 143 | 144 | ||
| 145 | + List<AppCombinationRecordRespVO> convertList3(List<CombinationRecordDO> records); | ||
| 146 | + | ||
| 147 | + AppCombinationRecordRespVO convert(CombinationRecordDO record); | ||
| 148 | + | ||
| 144 | } | 149 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| @@ -29,6 +29,7 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -29,6 +29,7 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 29 | .eq(CombinationRecordDO::getUserId, userId) | 29 | .eq(CombinationRecordDO::getUserId, userId) |
| 30 | .eq(CombinationRecordDO::getStatus, status)); | 30 | .eq(CombinationRecordDO::getStatus, status)); |
| 31 | } | 31 | } |
| 32 | + | ||
| 32 | /** | 33 | /** |
| 33 | * 查询拼团记录 | 34 | * 查询拼团记录 |
| 34 | * | 35 | * |
| @@ -47,10 +48,6 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -47,10 +48,6 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 47 | .eq(CombinationRecordDO::getStatus, status)); | 48 | .eq(CombinationRecordDO::getStatus, status)); |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | - default List<CombinationRecordDO> selectListByStatus(Integer status) { | ||
| 51 | - return selectList(CombinationRecordDO::getStatus, status); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | /** | 51 | /** |
| 55 | * 查询拼团记录 | 52 | * 查询拼团记录 |
| 56 | * | 53 | * |
| @@ -63,4 +60,34 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -63,4 +60,34 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 63 | .eq(CombinationRecordDO::getUserId, userId) | 60 | .eq(CombinationRecordDO::getUserId, userId) |
| 64 | .eq(CombinationRecordDO::getActivityId, activityId)); | 61 | .eq(CombinationRecordDO::getActivityId, activityId)); |
| 65 | } | 62 | } |
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 获取最近的 count 条数据 | ||
| 66 | + * | ||
| 67 | + * @param count 数量 | ||
| 68 | + * @return 拼团记录列表 | ||
| 69 | + */ | ||
| 70 | + default List<CombinationRecordDO> selectLatestList(int count) { | ||
| 71 | + return selectList(new LambdaQueryWrapperX<CombinationRecordDO>() | ||
| 72 | + .orderByDesc(CombinationRecordDO::getCreateTime) | ||
| 73 | + .last("LIMIT " + count)); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 获得最近 count 条拼团记录(团长发起的) | ||
| 78 | + * | ||
| 79 | + * @param activityId 拼团活动编号 | ||
| 80 | + * @param status 记录状态 | ||
| 81 | + * @param count 数量 | ||
| 82 | + * @return 拼团记录列表 | ||
| 83 | + */ | ||
| 84 | + default List<CombinationRecordDO> selectList(Long activityId, Integer status, Integer count) { | ||
| 85 | + return selectList(new LambdaQueryWrapperX<CombinationRecordDO>() | ||
| 86 | + .eqIfPresent(CombinationRecordDO::getActivityId, activityId) | ||
| 87 | + .eqIfPresent(CombinationRecordDO::getStatus, status) | ||
| 88 | + .eq(CombinationRecordDO::getHeadId, null) // TODO 团长的 headId 是不是 null 还是自己的记录编号来着? | ||
| 89 | + .orderByDesc(CombinationRecordDO::getCreateTime) | ||
| 90 | + .last("LIMIT " + count)); | ||
| 91 | + } | ||
| 92 | + | ||
| 66 | } | 93 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| @@ -20,8 +20,8 @@ public interface CombinationRecordService { | @@ -20,8 +20,8 @@ public interface CombinationRecordService { | ||
| 20 | /** | 20 | /** |
| 21 | * 更新拼团状态 | 21 | * 更新拼团状态 |
| 22 | * | 22 | * |
| 23 | - * @param status 状态 | ||
| 24 | - * @param userId 用户编号 | 23 | + * @param status 状态 |
| 24 | + * @param userId 用户编号 | ||
| 25 | * @param orderId 订单编号 | 25 | * @param orderId 订单编号 |
| 26 | */ | 26 | */ |
| 27 | void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId); | 27 | void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId); |
| @@ -48,9 +48,9 @@ public interface CombinationRecordService { | @@ -48,9 +48,9 @@ public interface CombinationRecordService { | ||
| 48 | /** | 48 | /** |
| 49 | * 更新拼团状态和开始时间 | 49 | * 更新拼团状态和开始时间 |
| 50 | * | 50 | * |
| 51 | - * @param status 状态 | ||
| 52 | - * @param userId 用户编号 | ||
| 53 | - * @param orderId 订单编号 | 51 | + * @param status 状态 |
| 52 | + * @param userId 用户编号 | ||
| 53 | + * @param orderId 订单编号 | ||
| 54 | * @param startTime 开始时间 | 54 | * @param startTime 开始时间 |
| 55 | */ | 55 | */ |
| 56 | void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime); | 56 | void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime); |
| @@ -86,4 +86,45 @@ public interface CombinationRecordService { | @@ -86,4 +86,45 @@ public interface CombinationRecordService { | ||
| 86 | */ | 86 | */ |
| 87 | CombinationValidateJoinRespDTO validateJoinCombination(Long activityId, Long userId, Long skuId, Integer count); | 87 | CombinationValidateJoinRespDTO validateJoinCombination(Long activityId, Long userId, Long skuId, Integer count); |
| 88 | 88 | ||
| 89 | + /** | ||
| 90 | + * 获取所有拼团记录数 | ||
| 91 | + * | ||
| 92 | + * @return 记录数 | ||
| 93 | + */ | ||
| 94 | + Long getRecordsCount(); | ||
| 95 | + | ||
| 96 | + /** | ||
| 97 | + * 获取最近的 count 条拼团记录 | ||
| 98 | + * | ||
| 99 | + * @param count 限制数量 | ||
| 100 | + * @return 拼团记录列表 | ||
| 101 | + */ | ||
| 102 | + List<CombinationRecordDO> getLatestRecordList(int count); | ||
| 103 | + | ||
| 104 | + /** | ||
| 105 | + * 获得最近 n 条拼团记录(团长发起的) | ||
| 106 | + * | ||
| 107 | + * @param activityId 拼团活动编号 | ||
| 108 | + * @param status 状态 | ||
| 109 | + * @param count 数量 | ||
| 110 | + * @return 拼团记录列表 | ||
| 111 | + */ | ||
| 112 | + List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count); | ||
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * 获取指定编号的拼团记录 | ||
| 116 | + * | ||
| 117 | + * @param id 拼团记录编号 | ||
| 118 | + * @return 拼团记录 | ||
| 119 | + */ | ||
| 120 | + CombinationRecordDO getRecordById(Long id); | ||
| 121 | + | ||
| 122 | + /** | ||
| 123 | + * 获取指定团长编号的拼团记录 | ||
| 124 | + * | ||
| 125 | + * @param headId 团长编号 | ||
| 126 | + * @return 拼团记录列表 | ||
| 127 | + */ | ||
| 128 | + List<CombinationRecordDO> getRecordListByHeadId(Long headId); | ||
| 129 | + | ||
| 89 | } | 130 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| @@ -232,13 +232,29 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -232,13 +232,29 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 232 | .setCombinationPrice(keyValue.getValue().getCombinationPrice()); | 232 | .setCombinationPrice(keyValue.getValue().getCombinationPrice()); |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | - /** | ||
| 236 | - * APP 端获取开团记录 | ||
| 237 | - * | ||
| 238 | - * @return 开团记录 | ||
| 239 | - */ | ||
| 240 | - public List<CombinationRecordDO> getRecordListByStatus(Integer status) { | ||
| 241 | - return recordMapper.selectListByStatus(status); | 235 | + @Override |
| 236 | + public Long getRecordsCount() { | ||
| 237 | + return recordMapper.selectCount(); | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + @Override | ||
| 241 | + public List<CombinationRecordDO> getLatestRecordList(int count) { | ||
| 242 | + return recordMapper.selectLatestList(count); | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + @Override | ||
| 246 | + public List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count) { | ||
| 247 | + return recordMapper.selectList(activityId, status, count); | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + @Override | ||
| 251 | + public CombinationRecordDO getRecordById(Long id) { | ||
| 252 | + return recordMapper.selectById(id); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + @Override | ||
| 256 | + public List<CombinationRecordDO> getRecordListByHeadId(Long headId) { | ||
| 257 | + return recordMapper.selectList(CombinationRecordDO::getHeadId, headId); | ||
| 242 | } | 258 | } |
| 243 | 259 | ||
| 244 | } | 260 | } |