Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 拼团记录,虚拟成团数有误 #720

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public CommonResult<CombinationRecordSummaryVO> getCombinationRecordSummary() {
summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount( // 获取成团记录
CombinationRecordStatusEnum.SUCCESS.getStatus(), null, CombinationRecordDO.HEAD_ID_GROUP));
summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(// 获取虚拟成团记录
null, Boolean.TRUE, CombinationRecordDO.HEAD_ID_GROUP));
null, Boolean.TRUE, null));
return success(summaryVO);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean v
.eqIfPresent(CombinationRecordDO::getHeadId, headId));
}

/**
* 查询虚拟成团的记录数,先按head_id分组,然后再count
* @return
*/
default Long selectCountByVirtualGroupTrue(){
return selectCount(new QueryWrapper<CombinationRecordDO>()
.select("DISTINCT(head_id)")
.eq("virtual_group", true));
}

/**
* 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,13 @@ public CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long

@Override
public Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, @Nullable Long headId) {
return combinationRecordMapper.selectCountByHeadAndStatusAndVirtualGroup(status, virtualGroup, headId);
// virtualGroup 为 null,或者为 false 的时候,走原流程
if (virtualGroup == null || !virtualGroup) {
return combinationRecordMapper.selectCountByHeadAndStatusAndVirtualGroup(status, virtualGroup, headId);
}

// virtualGroup 为 true 的时候,查询虚拟成团的数量
return combinationRecordMapper.selectCountByVirtualGroupTrue();
}

@Override
Expand Down