From ce77d510bb7cc5a375960fa3615de9d7f89f779e Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 6 Oct 2023 20:27:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=8B=BC=E5=9B=A2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CombinationRecordController.java | 87 +++++++++++++++++++ .../vo/recrod/CombinationRecordReqPageVO.java | 38 ++++++++ .../vo/recrod/CombinationRecordRespVO.java | 60 +++++++++++++ .../CombinationActivityConvert.java | 3 + .../combination/CombinationRecordMapper.java | 61 +++++++++++++ .../combination/CombinationRecordService.java | 32 +++++++ .../CombinationRecordServiceImpl.java | 22 +++++ 7 files changed, 303 insertions(+) create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordRespVO.java diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java new file mode 100644 index 000000000..de24a7631 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java @@ -0,0 +1,87 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.combination; + +import cn.hutool.core.map.MapUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordRespVO; +import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; +import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.time.Duration; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; + +@Tag(name = "管理后台 - 拼团记录") +@RestController +@RequestMapping("/promotion/combination-record") +@Validated +public class CombinationRecordController { + + @Resource + private CombinationRecordService combinationRecordService; + /** + * {@link Map} 缓存,通过它异步刷新 {@link #getCombinationRecordSummary0()} 所要的拼团记录统计数据 + */ + private final LoadingCache> combinationRecordSummary = buildAsyncReloadingCache(Duration.ofSeconds(60L), + new CacheLoader>() { + + @Override + public Map load(String key) { + return getCombinationRecordSummary0(); + } + + }); + + @GetMapping("/page") + @Operation(summary = "获得拼团记录分页") + @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") + public CommonResult> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) { + return success(CombinationActivityConvert.INSTANCE.convert( + combinationRecordService.getBargainRecordPage(pageVO))); + } + + @GetMapping("/get-summary") + @Operation(summary = "获得拼团记录的概要信息", description = "用于拼团记录页面展示") + @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") + public CommonResult> getCombinationRecordSummary() { + return success(combinationRecordSummary.getUnchecked("")); // 缓存 + } + + @GetMapping("/get-count") + @Operation(summary = "获得拼团记录分页 tab count") + @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") + public CommonResult> getSpuCount() { + Map hashMap = MapUtil.newHashMap(7); + hashMap.put("all", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.ALL));// 全部 + hashMap.put("toDay", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.TO_DAY));// 今天 + hashMap.put("yesterday", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.YESTERDAY));// 昨天 + hashMap.put("lastSevenDays", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_SEVEN_DAYS));// 最近七天 + hashMap.put("last30Days", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_30_DAYS));// 最近 30 天 + hashMap.put("thisMonth", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_MONTH));// 本月 + hashMap.put("thisYear", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_YEAR));// 本年 + return success(hashMap); + } + + private Map getCombinationRecordSummary0() { + Map hashMap = MapUtil.newHashMap(3); + hashMap.put("userCount", combinationRecordService.getRecordsCount());// 获取所有拼团记录 + hashMap.put("successCount", combinationRecordService.getRecordsSuccessCount());// 获取成团记录 + hashMap.put("virtualGroupCount", combinationRecordService.getRecordsVirtualGroupCount());// 获取虚拟成团记录 + return hashMap; + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java new file mode 100644 index 000000000..bf99dcb7c --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 拼团记录分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CombinationRecordReqPageVO extends PageParam { + + public static final Integer ALL = 0; // 全部 + public static final Integer TO_DAY = 1; // 今天 + public static final Integer YESTERDAY = 2; // 昨天 + public static final Integer LAST_SEVEN_DAYS = 3; // 最近七天 + public static final Integer LAST_30_DAYS = 4; // 最近 30 天 + public static final Integer THIS_MONTH = 5; // 本月 + public static final Integer THIS_YEAR = 6; // 本年 + + @Schema(description = "日期类型", example = "0") + private Integer dateType; + + @Schema(description = "活动状态", example = "0") + private Integer status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordRespVO.java new file mode 100644 index 000000000..ab1a98607 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordRespVO.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 拼团记录 Response VO") +@Data +public class CombinationRecordRespVO { + + @Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long activityId; + + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "花开富贵") + private String nickname; + + @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + private String avatar; + + @Schema(description = "团长编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long headId; + + @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime expireTime; + + @Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") + private Integer userSize; + + @Schema(description = "已参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") + private Integer userCount; + + @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer status; + + @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") + private String spuName; + + @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + private String picUrl; + + @Schema(description = "是否虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") + private Boolean virtualGroup; + + @Schema(description = "开始时间 (订单付款后开始的时间)", requiredMode = Schema.RequiredMode.REQUIRED) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime startTime; + + @Schema(description = "结束时间(成团时间/失败时间)", requiredMode = Schema.RequiredMode.REQUIRED) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime endTime; + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java index ebbb252a3..5419f53a4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java @@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activit import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordRespVO; import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; @@ -146,4 +147,6 @@ public interface CombinationActivityConvert { AppCombinationRecordRespVO convert(CombinationRecordDO record); + PageResult convert(PageResult result); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java index 91117ad83..a9998852d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java @@ -1,10 +1,15 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.combination; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 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.dal.dataobject.combination.CombinationRecordDO; import org.apache.ibatis.annotations.Mapper; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.List; /** @@ -90,4 +95,60 @@ public interface CombinationRecordMapper extends BaseMapperX selectPage(CombinationRecordReqPageVO pageVO) { + // 兼容自选时间段 + if (pageVO.getDateType() != null) { + pageVO.setCreateTime(builderQueryTime(pageVO.getDateType())); + } + return selectPage(pageVO, new LambdaQueryWrapperX() + .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) + .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime())); + } + + default Long selectCount(Integer dateType) { + return selectCount(new LambdaQueryWrapperX() + .betweenIfPresent(CombinationRecordDO::getCreateTime, builderQueryTime(dateType))); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java index aeac753ad..e965764df 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java @@ -1,8 +1,10 @@ package cn.iocoder.yudao.module.promotion.service.combination; import cn.iocoder.yudao.framework.common.core.KeyValue; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; @@ -93,6 +95,28 @@ public interface CombinationRecordService { */ Long getRecordsCount(); + /** + * 获取成功记录数 + * + * @return 记录数 + */ + Long getRecordsSuccessCount(); + + /** + * 获取虚拟成团记录数 + * + * @return 记录数 + */ + Long getRecordsVirtualGroupCount(); + + /** + * 获取指定日期类型的记录数,比如说获取最近七天的拼团记录数 + * + * @param dateType 日期类型 + * @return 记录数 + */ + Long getRecordsCountByDateType(Integer dateType); + /** * 获取最近的 count 条拼团记录 * @@ -127,4 +151,12 @@ public interface CombinationRecordService { */ List getRecordListByHeadId(Long headId); + /** + * 获取拼团记录分页数据 + * + * @param pageVO 分页请求 + * @return 拼团记录分页数据 + */ + PageResult getBargainRecordPage(CombinationRecordReqPageVO pageVO); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index aa87fb880..83d1dc018 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; @@ -12,6 +13,7 @@ import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; @@ -225,6 +227,21 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { return recordMapper.selectCount(); } + @Override + public Long getRecordsSuccessCount() { + return recordMapper.selectCount(CombinationRecordDO::getStatus, CombinationRecordStatusEnum.SUCCESS.getStatus()); + } + + @Override + public Long getRecordsVirtualGroupCount() { + return recordMapper.selectCount(CombinationRecordDO::getVirtualGroup, true); + } + + @Override + public Long getRecordsCountByDateType(Integer dateType) { + return recordMapper.selectCount(dateType); + } + @Override public List getLatestRecordList(int count) { return recordMapper.selectLatestList(count); @@ -245,4 +262,9 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { return recordMapper.selectList(CombinationRecordDO::getHeadId, headId); } + @Override + public PageResult getBargainRecordPage(CombinationRecordReqPageVO pageVO) { + return recordMapper.selectPage(pageVO); + } + } From 6099786c1b7a7e8d9f93bb9edcc9fb5db364b3bd Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 6 Oct 2023 21:26:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=EF=BC=9A=E5=AE=8C=E5=96=84=E6=8B=BC=E5=9B=A2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CombinationRecordController.java | 22 +++++++++--------- .../AppCombinationRecordController.java | 14 +++++------ .../combination/CombinationRecordMapper.java | 6 +---- .../combination/CombinationRecordService.java | 23 +++++++++---------- .../CombinationRecordServiceImpl.java | 20 ++++++++-------- .../CombinationActivityServiceImplTest.java | 18 --------------- 6 files changed, 40 insertions(+), 63 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java index de24a7631..d8a3b5245 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java +++ b/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 { @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") public CommonResult> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) { return success(CombinationActivityConvert.INSTANCE.convert( - combinationRecordService.getBargainRecordPage(pageVO))); + combinationRecordService.getCombinationRecordPage(pageVO))); } @GetMapping("/get-summary") @@ -64,22 +64,22 @@ public class CombinationRecordController { @GetMapping("/get-count") @Operation(summary = "获得拼团记录分页 tab count") @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") - public CommonResult> getSpuCount() { + public CommonResult> getCombinationRecordCount() { Map hashMap = MapUtil.newHashMap(7); - hashMap.put("all", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.ALL));// 全部 - hashMap.put("toDay", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.TO_DAY));// 今天 - hashMap.put("yesterday", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.YESTERDAY));// 昨天 - hashMap.put("lastSevenDays", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_SEVEN_DAYS));// 最近七天 - hashMap.put("last30Days", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.LAST_30_DAYS));// 最近 30 天 - hashMap.put("thisMonth", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_MONTH));// 本月 - hashMap.put("thisYear", combinationRecordService.getRecordsCountByDateType(CombinationRecordReqPageVO.THIS_YEAR));// 本年 + hashMap.put("all", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.ALL));// 全部 + hashMap.put("toDay", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.TO_DAY));// 今天 + hashMap.put("yesterday", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.YESTERDAY));// 昨天 + hashMap.put("lastSevenDays", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.LAST_SEVEN_DAYS));// 最近七天 + hashMap.put("last30Days", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.LAST_30_DAYS));// 最近 30 天 + hashMap.put("thisMonth", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.THIS_MONTH));// 本月 + hashMap.put("thisYear", combinationRecordService.getCombinationRecordsCountByDateType(CombinationRecordReqPageVO.THIS_YEAR));// 本年 return success(hashMap); } private Map getCombinationRecordSummary0() { Map hashMap = MapUtil.newHashMap(3); - hashMap.put("userCount", combinationRecordService.getRecordsCount());// 获取所有拼团记录 - hashMap.put("successCount", combinationRecordService.getRecordsSuccessCount());// 获取成团记录 + hashMap.put("userCount", combinationRecordService.getCombinationRecordsCount());// 获取所有拼团记录 + hashMap.put("successCount", combinationRecordService.getCombinationRecordsSuccessCount());// 获取成团记录 hashMap.put("virtualGroupCount", combinationRecordService.getRecordsVirtualGroupCount());// 获取虚拟成团记录 return hashMap; } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java index 113492504..2d4b813ff 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java +++ b/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 { // TODO 芋艿:增加 @Cache 缓存,1 分钟过期 public CommonResult getCombinationRecordSummary() { // 获取所有拼团记录 - Long count = combinationRecordService.getRecordsCount(); + Long count = combinationRecordService.getCombinationRecordsCount(); AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); if (count == null || count == 0L) { summary.setAvatars(Collections.emptyList()); @@ -53,7 +53,7 @@ public class AppCombinationRecordController { summary.setUserCount(count); // TODO 只返回最近的 7 个 int num = 7; - summary.setAvatars(convertList(combinationRecordService.getLatestRecordList(num), CombinationRecordDO::getAvatar)); + summary.setAvatars(convertList(combinationRecordService.getLatestCombinationRecordList(num), CombinationRecordDO::getAvatar)); return success(summary); } @@ -69,7 +69,7 @@ public class AppCombinationRecordController { @RequestParam("status") Integer status, @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { return success(CombinationActivityConvert.INSTANCE.convertList3( - combinationRecordService.getRecordListWithHead(activityId, status, count))); + combinationRecordService.getCombinationRecordListWithHead(activityId, status, count))); } @GetMapping("/get-detail") @@ -77,7 +77,7 @@ public class AppCombinationRecordController { @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") public CommonResult getCombinationRecordDetail(@RequestParam("id") Long id) { // 1、查询这条记录 - CombinationRecordDO record = combinationRecordService.getRecordById(id); + CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id); if (record == null) { return success(null); } @@ -88,17 +88,17 @@ public class AppCombinationRecordController { if (record.getHeadId() == null) { detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record)); // 2.1、查找团员拼团记录 - records = combinationRecordService.getRecordListByHeadId(record.getId()); + records = combinationRecordService.getCombinationRecordListByHeadId(record.getId()); } else { // 2.2、查找团长拼团记录 - CombinationRecordDO headRecord = combinationRecordService.getRecordById(record.getHeadId()); + CombinationRecordDO headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId()); if (headRecord == null) { return success(null); } detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord)); // 2.3、查找团员拼团记录 - records = combinationRecordService.getRecordListByHeadId(headRecord.getId()); + records = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId()); } detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records)); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java index 14992772c..54f998d44 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java +++ b/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; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.hutool.core.util.ObjectUtil; 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.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; @@ -32,10 +32,6 @@ public interface CombinationRecordMapper extends BaseMapperX selectListByUserId(Long userId) { - return selectList(CombinationRecordDO::getUserId, userId); - } - default List selectListByUserIdAndStatus(Long userId, Integer status) { return selectList(new LambdaQueryWrapperX() .eq(CombinationRecordDO::getUserId, userId) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java index c64872fe1..ca651ce1a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java +++ b/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; import java.util.List; import java.util.Map; -// todo @PUHUI:方法名,还是带下 Combination 哈 /** * 拼团记录 Service 接口 * @@ -62,11 +61,11 @@ public interface CombinationRecordService { void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime); /** - * 获得拼团状态 + * 获得拼团记录 * * @param userId 用户编号 * @param orderId 订单编号 - * @return 拼团状态 + * @return 拼团记录 */ CombinationRecordDO getCombinationRecord(Long userId, Long orderId); @@ -77,7 +76,7 @@ public interface CombinationRecordService { * @param activityId 活动 id * @return 拼团记录列表 */ - List getRecordListByUserIdAndActivityId(Long userId, Long activityId); + List getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId); /** * 【下单前】校验是否满足拼团活动条件 @@ -97,14 +96,14 @@ public interface CombinationRecordService { * * @return 记录数 */ - Long getRecordsCount(); + Long getCombinationRecordsCount(); /** * 获取成功记录数 * * @return 记录数 */ - Long getRecordsSuccessCount(); + Long getCombinationRecordsSuccessCount(); /** * 获取虚拟成团记录数 @@ -119,7 +118,7 @@ public interface CombinationRecordService { * @param dateType 日期类型 * @return 记录数 */ - Long getRecordsCountByDateType(Integer dateType); + Long getCombinationRecordsCountByDateType(Integer dateType); /** * 获取最近的 count 条拼团记录 @@ -127,7 +126,7 @@ public interface CombinationRecordService { * @param count 限制数量 * @return 拼团记录列表 */ - List getLatestRecordList(int count); + List getLatestCombinationRecordList(int count); /** * 获得最近 n 条拼团记录(团长发起的) @@ -137,7 +136,7 @@ public interface CombinationRecordService { * @param count 数量 * @return 拼团记录列表 */ - List getRecordListWithHead(Long activityId, Integer status, Integer count); + List getCombinationRecordListWithHead(Long activityId, Integer status, Integer count); /** * 获取指定编号的拼团记录 @@ -145,7 +144,7 @@ public interface CombinationRecordService { * @param id 拼团记录编号 * @return 拼团记录 */ - CombinationRecordDO getRecordById(Long id); + CombinationRecordDO getCombinationRecordById(Long id); /** * 获取指定团长编号的拼团记录 @@ -153,7 +152,7 @@ public interface CombinationRecordService { * @param headId 团长编号 * @return 拼团记录列表 */ - List getRecordListByHeadId(Long headId); + List getCombinationRecordListByHeadId(Long headId); /** * 获取拼团记录分页数据 @@ -161,7 +160,7 @@ public interface CombinationRecordService { * @param pageVO 分页请求 * @return 拼团记录分页数据 */ - PageResult getBargainRecordPage(CombinationRecordReqPageVO pageVO); + PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO); /** * 【拼团活动】获得拼团记录数量 Map diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index dee4821d5..d6b9f84d7 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/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 { throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL); } // 3、校验是否有拼团记录 - List recordList = getRecordListByUserIdAndActivityId(userId, activityId); + List recordList = getCombinationRecordListByUserIdAndActivityId(userId, activityId); if (CollUtil.isEmpty(recordList)) { return new KeyValue<>(activity, product); } @@ -213,7 +213,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { } @Override - public List getRecordListByUserIdAndActivityId(Long userId, Long activityId) { + public List getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId) { return recordMapper.selectListByUserIdAndActivityId(userId, activityId); } @@ -227,12 +227,12 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { } @Override - public Long getRecordsCount() { + public Long getCombinationRecordsCount() { return recordMapper.selectCount(); } @Override - public Long getRecordsSuccessCount() { + public Long getCombinationRecordsSuccessCount() { return recordMapper.selectCount(CombinationRecordDO::getStatus, CombinationRecordStatusEnum.SUCCESS.getStatus()); } @@ -242,32 +242,32 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { } @Override - public Long getRecordsCountByDateType(Integer dateType) { + public Long getCombinationRecordsCountByDateType(Integer dateType) { return recordMapper.selectCount(dateType); } @Override - public List getLatestRecordList(int count) { + public List getLatestCombinationRecordList(int count) { return recordMapper.selectLatestList(count); } @Override - public List getRecordListWithHead(Long activityId, Integer status, Integer count) { + public List getCombinationRecordListWithHead(Long activityId, Integer status, Integer count) { return recordMapper.selectList(activityId, status, count); } @Override - public CombinationRecordDO getRecordById(Long id) { + public CombinationRecordDO getCombinationRecordById(Long id) { return recordMapper.selectById(id); } @Override - public List getRecordListByHeadId(Long headId) { + public List getCombinationRecordListByHeadId(Long headId) { return recordMapper.selectList(CombinationRecordDO::getHeadId, headId); } @Override - public PageResult getBargainRecordPage(CombinationRecordReqPageVO pageVO) { + public PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO) { return recordMapper.selectPage(pageVO); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java index 86d58d747..f1605dec8 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java +++ b/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 { o.setStartTime(null); o.setEndTime(null); o.setUserSize(null); - o.setTotalCount(null); - o.setSuccessCount(null); - o.setOrderUserCount(null); o.setVirtualGroup(null); o.setStatus(null); o.setLimitDuration(null); @@ -134,12 +131,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest { combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null))); // 测试 userSize 不匹配 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 不匹配 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null))); // 测试 status 不匹配 @@ -173,9 +164,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest { o.setStartTime(null); o.setEndTime(null); o.setUserSize(null); - o.setTotalCount(null); - o.setSuccessCount(null); - o.setOrderUserCount(null); o.setVirtualGroup(null); o.setStatus(null); o.setLimitDuration(null); @@ -196,12 +184,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest { combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null))); // 测试 userSize 不匹配 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 不匹配 combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null))); // 测试 status 不匹配