mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
!654 拼团记录:完善拼团记录后台管理接口
Merge pull request !654 from puhui999/feature/mall_product
This commit is contained in:
commit
1d9db4874f
@ -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<String, Map<String, Long>> combinationRecordSummary = buildAsyncReloadingCache(Duration.ofSeconds(60L),
|
||||||
|
new CacheLoader<String, Map<String, Long>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Long> load(String key) {
|
||||||
|
return getCombinationRecordSummary0();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得拼团记录分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
|
||||||
|
public CommonResult<PageResult<CombinationRecordRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) {
|
||||||
|
return success(CombinationActivityConvert.INSTANCE.convert(
|
||||||
|
combinationRecordService.getCombinationRecordPage(pageVO)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get-summary")
|
||||||
|
@Operation(summary = "获得拼团记录的概要信息", description = "用于拼团记录页面展示")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
|
||||||
|
public CommonResult<Map<String, Long>> getCombinationRecordSummary() {
|
||||||
|
return success(combinationRecordSummary.getUnchecked("")); // 缓存
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get-count")
|
||||||
|
@Operation(summary = "获得拼团记录分页 tab count")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
|
||||||
|
public CommonResult<Map<String, Long>> getCombinationRecordCount() {
|
||||||
|
Map<String, Long> hashMap = MapUtil.newHashMap(7);
|
||||||
|
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<String, Long> getCombinationRecordSummary0() {
|
||||||
|
Map<String, Long> hashMap = MapUtil.newHashMap(3);
|
||||||
|
hashMap.put("userCount", combinationRecordService.getCombinationRecordsCount());// 获取所有拼团记录
|
||||||
|
hashMap.put("successCount", combinationRecordService.getCombinationRecordsSuccessCount());// 获取成团记录
|
||||||
|
hashMap.put("virtualGroupCount", combinationRecordService.getRecordsVirtualGroupCount());// 获取虚拟成团记录
|
||||||
|
return hashMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -42,7 +42,7 @@ public class AppCombinationRecordController {
|
|||||||
// TODO 芋艿:增加 @Cache 缓存,1 分钟过期
|
// TODO 芋艿:增加 @Cache 缓存,1 分钟过期
|
||||||
public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
|
public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
|
||||||
// 获取所有拼团记录
|
// 获取所有拼团记录
|
||||||
Long count = combinationRecordService.getRecordsCount();
|
Long count = combinationRecordService.getCombinationRecordsCount();
|
||||||
AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
|
AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
|
||||||
if (count == null || count == 0L) {
|
if (count == null || count == 0L) {
|
||||||
summary.setAvatars(Collections.emptyList());
|
summary.setAvatars(Collections.emptyList());
|
||||||
@ -53,7 +53,7 @@ public class AppCombinationRecordController {
|
|||||||
summary.setUserCount(count);
|
summary.setUserCount(count);
|
||||||
// TODO 只返回最近的 7 个
|
// TODO 只返回最近的 7 个
|
||||||
int num = 7;
|
int num = 7;
|
||||||
summary.setAvatars(convertList(combinationRecordService.getLatestRecordList(num), CombinationRecordDO::getAvatar));
|
summary.setAvatars(convertList(combinationRecordService.getLatestCombinationRecordList(num), CombinationRecordDO::getAvatar));
|
||||||
return success(summary);
|
return success(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public class AppCombinationRecordController {
|
|||||||
@RequestParam("status") Integer status,
|
@RequestParam("status") Integer status,
|
||||||
@RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
|
@RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
|
||||||
return success(CombinationActivityConvert.INSTANCE.convertList3(
|
return success(CombinationActivityConvert.INSTANCE.convertList3(
|
||||||
combinationRecordService.getRecordListWithHead(activityId, status, count)));
|
combinationRecordService.getCombinationRecordListWithHead(activityId, status, count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-detail")
|
@GetMapping("/get-detail")
|
||||||
@ -77,7 +77,7 @@ public class AppCombinationRecordController {
|
|||||||
@Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
|
||||||
public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
|
public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
|
||||||
// 1、查询这条记录
|
// 1、查询这条记录
|
||||||
CombinationRecordDO record = combinationRecordService.getRecordById(id);
|
CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id);
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
return success(null);
|
return success(null);
|
||||||
}
|
}
|
||||||
@ -88,17 +88,17 @@ public class AppCombinationRecordController {
|
|||||||
if (record.getHeadId() == null) {
|
if (record.getHeadId() == null) {
|
||||||
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record));
|
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record));
|
||||||
// 2.1、查找团员拼团记录
|
// 2.1、查找团员拼团记录
|
||||||
records = combinationRecordService.getRecordListByHeadId(record.getId());
|
records = combinationRecordService.getCombinationRecordListByHeadId(record.getId());
|
||||||
} else {
|
} else {
|
||||||
// 2.2、查找团长拼团记录
|
// 2.2、查找团长拼团记录
|
||||||
CombinationRecordDO headRecord = combinationRecordService.getRecordById(record.getHeadId());
|
CombinationRecordDO headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId());
|
||||||
if (headRecord == null) {
|
if (headRecord == null) {
|
||||||
return success(null);
|
return success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord));
|
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord));
|
||||||
// 2.3、查找团员拼团记录
|
// 2.3、查找团员拼团记录
|
||||||
records = combinationRecordService.getRecordListByHeadId(headRecord.getId());
|
records = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records));
|
detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records));
|
||||||
|
@ -13,6 +13,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.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.CombinationProductBaseVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO;
|
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.AppCombinationActivityDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
||||||
@ -155,4 +156,6 @@ public interface CombinationActivityConvert {
|
|||||||
|
|
||||||
AppCombinationRecordRespVO convert(CombinationRecordDO record);
|
AppCombinationRecordRespVO convert(CombinationRecordDO record);
|
||||||
|
|
||||||
|
PageResult<CombinationRecordRespVO> convert(PageResult<CombinationRecordDO> result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,18 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.combination;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.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.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -27,10 +32,6 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||||||
CombinationRecordDO::getOrderId, orderId);
|
CombinationRecordDO::getOrderId, orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<CombinationRecordDO> selectListByUserId(Long userId) {
|
|
||||||
return selectList(CombinationRecordDO::getUserId, userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<CombinationRecordDO> selectListByUserIdAndStatus(Long userId, Integer status) {
|
default List<CombinationRecordDO> selectListByUserIdAndStatus(Long userId, Integer status) {
|
||||||
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
|
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||||
.eq(CombinationRecordDO::getUserId, userId)
|
.eq(CombinationRecordDO::getUserId, userId)
|
||||||
@ -115,4 +116,60 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||||||
record -> MapUtil.getInt(record, "recordCount" ));
|
record -> MapUtil.getInt(record, "recordCount" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LocalDateTime[] builderQueryTime(Integer dateType) {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime[] createTime = null; // 全部时间段
|
||||||
|
// 今天-一天开始到结束
|
||||||
|
if (ObjectUtil.equal(dateType, CombinationRecordReqPageVO.TO_DAY)) {
|
||||||
|
createTime = new LocalDateTime[]{now.toLocalDate().atStartOfDay(), now.toLocalDate().atTime(LocalTime.MAX)};
|
||||||
|
}
|
||||||
|
// 昨天-昨天开始和结束
|
||||||
|
if (ObjectUtil.equal(dateType, CombinationRecordReqPageVO.YESTERDAY)) {
|
||||||
|
createTime = new LocalDateTime[]{now.minusDays(1).toLocalDate().atStartOfDay(),
|
||||||
|
now.minusDays(1).toLocalDate().atTime(LocalTime.MAX)};
|
||||||
|
}
|
||||||
|
// 最近七天
|
||||||
|
if (ObjectUtil.equal(dateType, CombinationRecordReqPageVO.LAST_SEVEN_DAYS)) {
|
||||||
|
createTime = new LocalDateTime[]{now.minusDays(7).toLocalDate().atStartOfDay(),
|
||||||
|
now.toLocalDate().atTime(LocalTime.MAX)};
|
||||||
|
}
|
||||||
|
// 最近 30 天
|
||||||
|
if (ObjectUtil.equal(dateType, CombinationRecordReqPageVO.LAST_30_DAYS)) {
|
||||||
|
createTime = new LocalDateTime[]{now.minusDays(30).toLocalDate().atStartOfDay(),
|
||||||
|
now.toLocalDate().atTime(LocalTime.MAX)};
|
||||||
|
}
|
||||||
|
// 本月
|
||||||
|
if (ObjectUtil.equal(dateType, CombinationRecordReqPageVO.THIS_MONTH)) {
|
||||||
|
// 获取本月的开始时间
|
||||||
|
LocalDateTime startTime = now.withDayOfMonth(1).toLocalDate().atStartOfDay();
|
||||||
|
// 获取下个月的开始时间,然后减去一秒以获取本月的结束时间
|
||||||
|
LocalDateTime endTime = now.withDayOfMonth(1).plusMonths(1).toLocalDate().atStartOfDay().minusSeconds(1);
|
||||||
|
createTime = new LocalDateTime[]{startTime, endTime};
|
||||||
|
}
|
||||||
|
// 本年
|
||||||
|
if (ObjectUtil.equal(dateType, CombinationRecordReqPageVO.THIS_YEAR)) {
|
||||||
|
// 获取本年的开始时间
|
||||||
|
LocalDateTime startTime = now.withDayOfYear(1).toLocalDate().atStartOfDay();
|
||||||
|
// 获取下一年的开始时间,然后减去一秒以获取本年的结束时间
|
||||||
|
LocalDateTime endTime = now.withDayOfYear(1).plusYears(1).toLocalDate().atStartOfDay().minusSeconds(1);
|
||||||
|
createTime = new LocalDateTime[]{startTime, endTime};
|
||||||
|
}
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
default PageResult<CombinationRecordDO> selectPage(CombinationRecordReqPageVO pageVO) {
|
||||||
|
// 兼容自选时间段
|
||||||
|
if (pageVO.getDateType() != null) {
|
||||||
|
pageVO.setCreateTime(builderQueryTime(pageVO.getDateType()));
|
||||||
|
}
|
||||||
|
return selectPage(pageVO, new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||||
|
.eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus())
|
||||||
|
.betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
default Long selectCount(Integer dateType) {
|
||||||
|
return selectCount(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||||
|
.betweenIfPresent(CombinationRecordDO::getCreateTime, builderQueryTime(dateType)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.service.combination;
|
package cn.iocoder.yudao.module.promotion.service.combination;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
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.CombinationRecordCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
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.CombinationActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||||
@ -13,7 +15,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
// todo @PUHUI:方法名,还是带下 Combination 哈
|
|
||||||
/**
|
/**
|
||||||
* 拼团记录 Service 接口
|
* 拼团记录 Service 接口
|
||||||
*
|
*
|
||||||
@ -60,11 +61,11 @@ public interface CombinationRecordService {
|
|||||||
void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime);
|
void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得拼团状态
|
* 获得拼团记录
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param orderId 订单编号
|
* @param orderId 订单编号
|
||||||
* @return 拼团状态
|
* @return 拼团记录
|
||||||
*/
|
*/
|
||||||
CombinationRecordDO getCombinationRecord(Long userId, Long orderId);
|
CombinationRecordDO getCombinationRecord(Long userId, Long orderId);
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ public interface CombinationRecordService {
|
|||||||
* @param activityId 活动 id
|
* @param activityId 活动 id
|
||||||
* @return 拼团记录列表
|
* @return 拼团记录列表
|
||||||
*/
|
*/
|
||||||
List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId);
|
List<CombinationRecordDO> getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【下单前】校验是否满足拼团活动条件
|
* 【下单前】校验是否满足拼团活动条件
|
||||||
@ -95,7 +96,29 @@ public interface CombinationRecordService {
|
|||||||
*
|
*
|
||||||
* @return 记录数
|
* @return 记录数
|
||||||
*/
|
*/
|
||||||
Long getRecordsCount();
|
Long getCombinationRecordsCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取成功记录数
|
||||||
|
*
|
||||||
|
* @return 记录数
|
||||||
|
*/
|
||||||
|
Long getCombinationRecordsSuccessCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取虚拟成团记录数
|
||||||
|
*
|
||||||
|
* @return 记录数
|
||||||
|
*/
|
||||||
|
Long getRecordsVirtualGroupCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定日期类型的记录数,比如说获取最近七天的拼团记录数
|
||||||
|
*
|
||||||
|
* @param dateType 日期类型
|
||||||
|
* @return 记录数
|
||||||
|
*/
|
||||||
|
Long getCombinationRecordsCountByDateType(Integer dateType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取最近的 count 条拼团记录
|
* 获取最近的 count 条拼团记录
|
||||||
@ -103,7 +126,7 @@ public interface CombinationRecordService {
|
|||||||
* @param count 限制数量
|
* @param count 限制数量
|
||||||
* @return 拼团记录列表
|
* @return 拼团记录列表
|
||||||
*/
|
*/
|
||||||
List<CombinationRecordDO> getLatestRecordList(int count);
|
List<CombinationRecordDO> getLatestCombinationRecordList(int count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得最近 n 条拼团记录(团长发起的)
|
* 获得最近 n 条拼团记录(团长发起的)
|
||||||
@ -113,7 +136,7 @@ public interface CombinationRecordService {
|
|||||||
* @param count 数量
|
* @param count 数量
|
||||||
* @return 拼团记录列表
|
* @return 拼团记录列表
|
||||||
*/
|
*/
|
||||||
List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count);
|
List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定编号的拼团记录
|
* 获取指定编号的拼团记录
|
||||||
@ -121,7 +144,7 @@ public interface CombinationRecordService {
|
|||||||
* @param id 拼团记录编号
|
* @param id 拼团记录编号
|
||||||
* @return 拼团记录
|
* @return 拼团记录
|
||||||
*/
|
*/
|
||||||
CombinationRecordDO getRecordById(Long id);
|
CombinationRecordDO getCombinationRecordById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定团长编号的拼团记录
|
* 获取指定团长编号的拼团记录
|
||||||
@ -129,7 +152,15 @@ public interface CombinationRecordService {
|
|||||||
* @param headId 团长编号
|
* @param headId 团长编号
|
||||||
* @return 拼团记录列表
|
* @return 拼团记录列表
|
||||||
*/
|
*/
|
||||||
List<CombinationRecordDO> getRecordListByHeadId(Long headId);
|
List<CombinationRecordDO> getCombinationRecordListByHeadId(Long headId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取拼团记录分页数据
|
||||||
|
*
|
||||||
|
* @param pageVO 分页请求
|
||||||
|
* @return 拼团记录分页数据
|
||||||
|
*/
|
||||||
|
PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【拼团活动】获得拼团记录数量 Map
|
* 【拼团活动】获得拼团记录数量 Map
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
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.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
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.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
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.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.convert.combination.CombinationActivityConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
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.CombinationProductDO;
|
||||||
@ -137,7 +139,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL);
|
throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL);
|
||||||
}
|
}
|
||||||
// 3、校验是否有拼团记录
|
// 3、校验是否有拼团记录
|
||||||
List<CombinationRecordDO> recordList = getRecordListByUserIdAndActivityId(userId, activityId);
|
List<CombinationRecordDO> recordList = getCombinationRecordListByUserIdAndActivityId(userId, activityId);
|
||||||
if (CollUtil.isEmpty(recordList)) {
|
if (CollUtil.isEmpty(recordList)) {
|
||||||
return new KeyValue<>(activity, product);
|
return new KeyValue<>(activity, product);
|
||||||
}
|
}
|
||||||
@ -211,7 +213,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) {
|
public List<CombinationRecordDO> getCombinationRecordListByUserIdAndActivityId(Long userId, Long activityId) {
|
||||||
return recordMapper.selectListByUserIdAndActivityId(userId, activityId);
|
return recordMapper.selectListByUserIdAndActivityId(userId, activityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,30 +227,50 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getRecordsCount() {
|
public Long getCombinationRecordsCount() {
|
||||||
return recordMapper.selectCount();
|
return recordMapper.selectCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CombinationRecordDO> getLatestRecordList(int count) {
|
public Long getCombinationRecordsSuccessCount() {
|
||||||
|
return recordMapper.selectCount(CombinationRecordDO::getStatus, CombinationRecordStatusEnum.SUCCESS.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getRecordsVirtualGroupCount() {
|
||||||
|
return recordMapper.selectCount(CombinationRecordDO::getVirtualGroup, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getCombinationRecordsCountByDateType(Integer dateType) {
|
||||||
|
return recordMapper.selectCount(dateType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CombinationRecordDO> getLatestCombinationRecordList(int count) {
|
||||||
return recordMapper.selectLatestList(count);
|
return recordMapper.selectLatestList(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CombinationRecordDO> getRecordListWithHead(Long activityId, Integer status, Integer count) {
|
public List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count) {
|
||||||
return recordMapper.selectList(activityId, status, count);
|
return recordMapper.selectList(activityId, status, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CombinationRecordDO getRecordById(Long id) {
|
public CombinationRecordDO getCombinationRecordById(Long id) {
|
||||||
return recordMapper.selectById(id);
|
return recordMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CombinationRecordDO> getRecordListByHeadId(Long headId) {
|
public List<CombinationRecordDO> getCombinationRecordListByHeadId(Long headId) {
|
||||||
return recordMapper.selectList(CombinationRecordDO::getHeadId, headId);
|
return recordMapper.selectList(CombinationRecordDO::getHeadId, headId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO) {
|
||||||
|
return recordMapper.selectPage(pageVO);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
||||||
@Nullable Integer status, @Nullable Integer headId) {
|
@Nullable Integer status, @Nullable Integer headId) {
|
||||||
|
@ -111,9 +111,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
|
|||||||
o.setStartTime(null);
|
o.setStartTime(null);
|
||||||
o.setEndTime(null);
|
o.setEndTime(null);
|
||||||
o.setUserSize(null);
|
o.setUserSize(null);
|
||||||
o.setTotalCount(null);
|
|
||||||
o.setSuccessCount(null);
|
|
||||||
o.setOrderUserCount(null);
|
|
||||||
o.setVirtualGroup(null);
|
o.setVirtualGroup(null);
|
||||||
o.setStatus(null);
|
o.setStatus(null);
|
||||||
o.setLimitDuration(null);
|
o.setLimitDuration(null);
|
||||||
@ -134,12 +131,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
|
|||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
|
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
|
||||||
// 测试 userSize 不匹配
|
// 测试 userSize 不匹配
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
|
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
|
||||||
// 测试 totalNum 不匹配
|
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalCount(null)));
|
|
||||||
// 测试 successNum 不匹配
|
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSuccessCount(null)));
|
|
||||||
// 测试 orderUserCount 不匹配
|
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setOrderUserCount(null)));
|
|
||||||
// 测试 virtualGroup 不匹配
|
// 测试 virtualGroup 不匹配
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
|
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
|
||||||
// 测试 status 不匹配
|
// 测试 status 不匹配
|
||||||
@ -173,9 +164,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
|
|||||||
o.setStartTime(null);
|
o.setStartTime(null);
|
||||||
o.setEndTime(null);
|
o.setEndTime(null);
|
||||||
o.setUserSize(null);
|
o.setUserSize(null);
|
||||||
o.setTotalCount(null);
|
|
||||||
o.setSuccessCount(null);
|
|
||||||
o.setOrderUserCount(null);
|
|
||||||
o.setVirtualGroup(null);
|
o.setVirtualGroup(null);
|
||||||
o.setStatus(null);
|
o.setStatus(null);
|
||||||
o.setLimitDuration(null);
|
o.setLimitDuration(null);
|
||||||
@ -196,12 +184,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
|
|||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
|
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null)));
|
||||||
// 测试 userSize 不匹配
|
// 测试 userSize 不匹配
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
|
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null)));
|
||||||
// 测试 totalNum 不匹配
|
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalCount(null)));
|
|
||||||
// 测试 successNum 不匹配
|
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSuccessCount(null)));
|
|
||||||
// 测试 orderUserCount 不匹配
|
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setOrderUserCount(null)));
|
|
||||||
// 测试 virtualGroup 不匹配
|
// 测试 virtualGroup 不匹配
|
||||||
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
|
combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null)));
|
||||||
// 测试 status 不匹配
|
// 测试 status 不匹配
|
||||||
|
Loading…
Reference in New Issue
Block a user