mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
拼团活动:完善 review 提到的问题
This commit is contained in:
parent
99649bfdb8
commit
c8a9d68933
@ -25,15 +25,6 @@ public class CollectionUtils {
|
||||
return Arrays.stream(collections).anyMatch(CollectionUtil::isEmpty);
|
||||
}
|
||||
|
||||
// TODO @puhui999: list.sort(); 可以替代呀;
|
||||
public static <T, U extends Comparable<? super U>> List<T> sortedAsc(
|
||||
Collection<T> from, Function<? super T, ? extends U> keyExtractor) {
|
||||
// 按照升序排序
|
||||
return from.stream()
|
||||
.sorted(Comparator.comparing(keyExtractor))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static <T> boolean anyMatch(Collection<T> from, Predicate<T> predicate) {
|
||||
return from.stream().anyMatch(predicate);
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ public class CombinationRecordCreateReqDTO {
|
||||
/**
|
||||
* 团长编号
|
||||
*/
|
||||
@NotNull(message = "团长编号不能为空")
|
||||
private Long headId;
|
||||
/**
|
||||
* 拼团商品单价
|
||||
|
@ -1,16 +1,19 @@
|
||||
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.CombinationRecordPageItemRespVO;
|
||||
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.controller.admin.combination.vo.recrod.CombinationRecordSummaryVO;
|
||||
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.CombinationRecordDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -19,11 +22,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
@Tag(name = "管理后台 - 拼团记录")
|
||||
@RestController
|
||||
@ -32,44 +34,31 @@ import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsync
|
||||
public class CombinationRecordController {
|
||||
|
||||
@Resource
|
||||
private CombinationActivityService combinationActivityService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private CombinationRecordService combinationRecordService;
|
||||
|
||||
// TODO @puhui999:这个缓存不用做哈;主要管理后台,对性能要求不高;不像前段;
|
||||
/**
|
||||
* {@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)));
|
||||
public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) {
|
||||
PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO);
|
||||
List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds(
|
||||
convertSet(recordPage.getList(), CombinationRecordDO::getActivityId));
|
||||
return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities));
|
||||
}
|
||||
|
||||
// TODO @puhui999:Map 改成对象,尽量避免 Map 返回结果哈;然后 getCombinationRecordCount、getCombinationRecordsSuccessCount、getRecordsVirtualGroupCount 三个方法,可以合并成一个方法哈,返回这个 vo
|
||||
@GetMapping("/get-summary")
|
||||
@Operation(summary = "获得拼团记录的概要信息", description = "用于拼团记录页面展示")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
|
||||
public CommonResult<Map<String, Long>> getCombinationRecordSummary() {
|
||||
return success(combinationRecordSummary.getUnchecked("")); // 缓存
|
||||
}
|
||||
|
||||
private Map<String, Long> getCombinationRecordSummary0() {
|
||||
Map<String, Long> hashMap = MapUtil.newHashMap(3); // TODO @puhui999:Maps.newHashMapWithExpectedSize()
|
||||
hashMap.put("userCount", combinationRecordService.getCombinationRecordCount()); // 获取所有拼团记录
|
||||
hashMap.put("successCount", combinationRecordService.getCombinationRecordsSuccessCount()); // 获取成团记录
|
||||
hashMap.put("virtualGroupCount", combinationRecordService.getRecordsVirtualGroupCount()); // 获取虚拟成团记录
|
||||
return hashMap;
|
||||
public CommonResult<CombinationRecordSummaryVO> getCombinationRecordSummary() {
|
||||
CombinationRecordSummaryVO summaryVO = new CombinationRecordSummaryVO();
|
||||
summaryVO.setUserCount(combinationRecordService.getCombinationRecordCount(null, null)); // 获取所有拼团记录
|
||||
summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount(
|
||||
CombinationRecordStatusEnum.SUCCESS.getStatus(), null));// 获取成团记录
|
||||
summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(null, Boolean.TRUE));// 获取虚拟成团记录
|
||||
return success(summaryVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,14 +4,19 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
// TODO @puhui999:可以参考 BargainRecordPageItemRespVO、BargainRecordRespVO 分成两个;一个给记录列表,一个给记录分页
|
||||
@Schema(description = "管理后台 - 拼团记录 Response VO")
|
||||
/**
|
||||
* 拼团记录 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class CombinationRecordRespVO {
|
||||
public class CombinationRecordBaseVO {
|
||||
|
||||
@Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
@ -19,15 +24,37 @@ public class CombinationRecordRespVO {
|
||||
@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, example = "9430")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户昵称", example = "老芋艿")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg")
|
||||
private String avatar;
|
||||
|
||||
// ========== 商品相关 ==========
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622")
|
||||
@NotNull(message = "商品 SPU 编号不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950")
|
||||
@NotNull(message = "商品 SKU 编号不能为空")
|
||||
private Long skuId;
|
||||
|
||||
@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)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime expireTime;
|
||||
@ -41,12 +68,6 @@ public class CombinationRecordRespVO {
|
||||
@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;
|
||||
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 拼团记录的分页项 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CombinationRecordPageItemRespVO extends CombinationRecordBaseVO {
|
||||
|
||||
// ========== 活动相关 ==========
|
||||
|
||||
private CombinationActivityRespVO activity;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 拼团记录信息统计 Response VO")
|
||||
@Data
|
||||
public class CombinationRecordSummaryVO {
|
||||
|
||||
@Schema(description = "所有拼团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long userCount;
|
||||
|
||||
@Schema(description = "成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long successCount;
|
||||
|
||||
@Schema(description = "虚拟成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long virtualGroupCount;
|
||||
|
||||
}
|
@ -47,7 +47,7 @@ public class AppCombinationRecordController {
|
||||
public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
|
||||
AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
|
||||
// 1. 获得拼团记录数量
|
||||
Long count = combinationRecordService.getCombinationRecordCount();
|
||||
Long count = combinationRecordService.getCombinationRecordCount(null, null);
|
||||
if (count == 0) {
|
||||
summary.setAvatars(Collections.emptyList());
|
||||
summary.setUserCount(count);
|
||||
|
@ -14,7 +14,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.admin.combination.vo.recrod.CombinationRecordPageItemRespVO;
|
||||
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.AppCombinationRecordDetailRespVO;
|
||||
@ -79,6 +79,7 @@ public interface CombinationActivityConvert {
|
||||
});
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
PageResult<CombinationActivityPageItemRespVO> convertPage(PageResult<CombinationActivityDO> page);
|
||||
|
||||
List<CombinationProductRespVO> convertList2(List<CombinationProductDO> productDOs);
|
||||
@ -113,9 +114,8 @@ public interface CombinationActivityConvert {
|
||||
CombinationActivityDO activity, MemberUserRespDTO user,
|
||||
ProductSpuRespDTO spu, ProductSkuRespDTO sku) {
|
||||
return convert(reqDTO)
|
||||
.setHeadId(reqDTO.getHeadId()) // 显示性再设置一下
|
||||
.setCount(reqDTO.getCount())
|
||||
.setVirtualGroup(false)
|
||||
.setVirtualGroup(false) // 默认 false 拼团过期都还没有成功,则按照 CombinationActivityDO#virtualGroup 来如果为 true 则执行虚拟成团的逻辑
|
||||
.setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()) // 创建后默认状态为进行中
|
||||
.setStartTime(LocalDateTime.now())
|
||||
.setExpireTime(activity.getStartTime().plusHours(activity.getLimitDuration()))
|
||||
@ -176,7 +176,20 @@ public interface CombinationActivityConvert {
|
||||
|
||||
AppCombinationRecordRespVO convert(CombinationRecordDO record);
|
||||
|
||||
PageResult<CombinationRecordRespVO> convert(PageResult<CombinationRecordDO> result);
|
||||
PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> result);
|
||||
|
||||
default PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> recordPage, List<CombinationActivityDO> activities) {
|
||||
PageResult<CombinationRecordPageItemRespVO> result = convert(recordPage);
|
||||
Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId);
|
||||
result.setList(CollectionUtils.convertList(result.getList(), item -> {
|
||||
findAndThen(activityMap, item.getActivityId(), activity -> {
|
||||
item.setActivity(convert(activity));
|
||||
});
|
||||
return item;
|
||||
}));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
default AppCombinationRecordDetailRespVO convert(Long userId, CombinationRecordDO headRecord, List<CombinationRecordDO> memberRecords) {
|
||||
AppCombinationRecordDetailRespVO respVO = new AppCombinationRecordDetailRespVO()
|
||||
|
@ -77,7 +77,6 @@ public class CombinationRecordDO extends BaseDO {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
// TODO @puhui999:要不去掉这 2 个字段,通过读取解决?如果去掉,相关接口都要处理下哈;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
|
@ -100,4 +100,12 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
||||
.betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()));
|
||||
}
|
||||
|
||||
default Long selectRecordCount(Integer status, Boolean virtualGroup) {
|
||||
return selectCount(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||
.eq(status != null || virtualGroup != null,
|
||||
CombinationRecordDO::getHeadId, CombinationRecordDO.HEAD_ID_GROUP) // 统计团信息则指定团长
|
||||
.eqIfPresent(CombinationRecordDO::getStatus, status)
|
||||
.eqIfPresent(CombinationRecordDO::getVirtualGroup, virtualGroup));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,6 +84,14 @@ public interface CombinationActivityService {
|
||||
*/
|
||||
List<CombinationProductDO> getCombinationProductListByActivityIds(Collection<Long> activityIds);
|
||||
|
||||
/**
|
||||
* 获得拼团活动列表
|
||||
*
|
||||
* @param ids 拼团活动 ids
|
||||
* @return 拼团活动的列表
|
||||
*/
|
||||
List<CombinationActivityDO> getCombinationActivityListByIds(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获取正在进行的活动分页数据
|
||||
*
|
||||
|
@ -204,6 +204,11 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
||||
return combinationProductMapper.selectListByActivityIds(activityIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CombinationActivityDO> getCombinationActivityListByIds(Collection<Long> ids) {
|
||||
return combinationActivityMapper.selectList(CombinationActivityDO::getId, ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CombinationActivityDO> getCombinationActivityListByCount(Integer count) {
|
||||
return combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus(), count);
|
||||
|
@ -84,25 +84,13 @@ public interface CombinationRecordService {
|
||||
CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, Long skuId, Integer count);
|
||||
|
||||
/**
|
||||
* 获取所有拼团记录数
|
||||
* 获取拼团记录数
|
||||
*
|
||||
* @param status 状态-允许为空
|
||||
* @param virtualGroup 是否虚拟成团-允许为空
|
||||
* @return 记录数
|
||||
*/
|
||||
Long getCombinationRecordCount();
|
||||
|
||||
/**
|
||||
* 获取成功记录数
|
||||
*
|
||||
* @return 记录数
|
||||
*/
|
||||
Long getCombinationRecordsSuccessCount();
|
||||
|
||||
/**
|
||||
* 获取虚拟成团记录数
|
||||
*
|
||||
* @return 记录数
|
||||
*/
|
||||
Long getRecordsVirtualGroupCount();
|
||||
Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup);
|
||||
|
||||
/**
|
||||
* 获取最近的 count 条拼团记录
|
||||
|
@ -177,8 +177,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
CombinationRecordDO recordDO = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku);
|
||||
recordMapper.insert(recordDO);
|
||||
|
||||
// 3、如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP
|
||||
if (ObjUtil.equal(CombinationRecordDO.HEAD_ID_GROUP, reqDTO.getHeadId())) {
|
||||
// 3、如果是团长(CombinationRecordCreateReqDTO#headId 为 null 时)需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP
|
||||
if (reqDTO.getHeadId() == null) {
|
||||
recordMapper.updateById(new CombinationRecordDO().setId(recordDO.getId()).setHeadId(CombinationRecordDO.HEAD_ID_GROUP));
|
||||
return;
|
||||
}
|
||||
@ -256,20 +256,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCombinationRecordCount() {
|
||||
return recordMapper.selectCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCombinationRecordsSuccessCount() {
|
||||
// TODO @puhui999:这个应该要多查询 headId
|
||||
return recordMapper.selectCount(CombinationRecordDO::getStatus, CombinationRecordStatusEnum.SUCCESS.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRecordsVirtualGroupCount() {
|
||||
// TODO @puhui999:这个应该要多查询 headId;然后,recordMapper 要明确的查询哈,不要直接使用 mapper 来拼接查询条件
|
||||
return recordMapper.selectCount(CombinationRecordDO::getVirtualGroup, true);
|
||||
public Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup) {
|
||||
return recordMapper.selectRecordCount(status, virtualGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -325,9 +313,9 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
return;
|
||||
}
|
||||
// 按照创建时间升序排序
|
||||
List<CombinationRecordDO> recordsSort = sortedAsc(list, CombinationRecordDO::getCreateTime);
|
||||
CombinationRecordDO newHead = recordsSort.get(0); // 新团长继位
|
||||
recordsSort.forEach(item -> {
|
||||
list.sort(Comparator.comparing(CombinationRecordDO::getCreateTime)); // 影响原 list
|
||||
CombinationRecordDO newHead = list.get(0); // 新团长继位
|
||||
list.forEach(item -> {
|
||||
CombinationRecordDO recordDO = new CombinationRecordDO();
|
||||
recordDO.setId(item.getId());
|
||||
if (ObjUtil.equal(item.getId(), newHead.getId())) { // 新团长
|
||||
@ -335,7 +323,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
} else {
|
||||
recordDO.setHeadId(newHead.getId());
|
||||
}
|
||||
recordDO.setUserCount(recordsSort.size());
|
||||
recordDO.setUserCount(list.size());
|
||||
updateRecords.add(recordDO);
|
||||
});
|
||||
} else { // 情况二:团员
|
||||
|
Loading…
Reference in New Issue
Block a user