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 @@ -12,6 +12,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;

import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -123,6 +124,21 @@ default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean v
.eqIfPresent(CombinationRecordDO::getHeadId, headId));
}

/**
* 查询指定活动编号数组,指定状态,指定团长编号的记录数
*
* @param activityIds 活动编号数组
* @param status 状态
* @param headId 团长编号
* @return
*/
default Long selectCountByHeadAndStatusAndActivityIds(@NotEmpty Collection<Long> activityIds, Integer status, Long headId) {
return selectCount(new LambdaQueryWrapperX<CombinationRecordDO>()
.in(CombinationRecordDO::getActivityId, activityIds)
.eqIfPresent(CombinationRecordDO::getStatus, status)
.eqIfPresent(CombinationRecordDO::getHeadId, headId));
}

/**
* 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@ default List<CombinationProductDO> getCombinationProductsByActivityId(Long activ
*/
CombinationActivityDO getMatchCombinationActivityBySpuId(Long spuId);

/**
* 查询虚拟成团的拼团活动
*
* @return 拼团活动列表
*/
List<CombinationActivityDO> getByVirtualGroup();
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,10 @@ public CombinationActivityDO getMatchCombinationActivityBySpuId(Long spuId) {
return combinationActivityMapper.selectBySpuIdAndStatusAndNow(spuId, CommonStatusEnum.ENABLE.getStatus());
}

@Override
public List<CombinationActivityDO> getByVirtualGroup() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

具体查询,建议放到 mapper 里。

service 不要有 dao 操作

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return combinationActivityMapper.selectList(
CombinationActivityDO::getVirtualGroup, Boolean.TRUE
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,19 @@ 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 的时候,查询虚拟成团的数量
List<CombinationActivityDO> activities = combinationActivityService.getByVirtualGroup();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个,是不是只查询数量?不要返回 list 去求 count

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的主要目的是查activityIds

if (CollUtil.isEmpty(activities)) {
return 0L;
}

List<Long> activityIds = convertList(activities, CombinationActivityDO::getId);
return combinationRecordMapper.selectCountByHeadAndStatusAndActivityIds(activityIds, status, headId);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是不用 activityIds 过滤???

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要activityIds过滤。从数据上看,虚拟成团(virtual_group)在 promotion_combination_record ,真实用户记 true。虚拟用户记 false。导致只能依靠activityIds筛选出虚拟成团的数据。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是不拿 activityIds 过滤,直接通过 “真实用户记 true。虚拟用户记 false”,也可以呀?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有个疑问:在拼团活动支持虚拟成团的情况下,一个队伍(全是真实用户),一个队伍(存在虚拟用户),那么在统计页面【拼团记录——虚拟成团(个)】预期是2 还是1?

}

@Override
Expand Down