BD-分区调整

This commit is contained in:
2025-10-13 16:14:19 +08:00
parent 5cedfa6b51
commit 8ea098eb64
6 changed files with 105 additions and 16 deletions

View File

@@ -132,7 +132,8 @@ public class BdInfoAdminService {
beginTime = DateUtil.offsetDay(DateUtil.beginOfDay(endTime), -7);
}
Map<Integer, Double> guildDiamondOrGoldMap;
if (PartitionEnum.ENGLISH.getId() == partitionId) {
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
if (Constant.ClanMode.FAMILY.equals(partitionEnum.getClanMode())) {
guildDiamondOrGoldMap = familyGiftRecordService.mapByFamilyId(DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime), guildIdList)
.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().doubleValue()));
} else {

View File

@@ -1,8 +1,11 @@
package com.accompany.business.mybatismapper.family;
import com.accompany.business.model.family.FamilyMemberSerial;
import com.accompany.business.vo.guild.GuildInfoVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Date;
@@ -16,4 +19,12 @@ public interface FamilyMemberSerialMapper extends BaseMapper<FamilyMemberSerial>
@Param("serialValue") BigDecimal serialValue,
@Param("time") Date time);
BigDecimal totalBdFamilyGoldNum(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("bdId")Long bdId);
Long totalBdFamilyCount(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("bdId")Long bdId);
IPage<GuildInfoVo> listBdFamilyGoldNum(@Param("ipage") IPage<GuildInfoVo> ipage, @Param("startDate")String startDate, @Param("endDate")String endDate,
@Param("bdId")Long bdId);
IPage<GuildInfoVo> listBdFamilyInfo(@Param("ipage") IPage<GuildInfoVo> ipage, @Param("bdId")Long bdId, @Param("seq") Integer seq);
}

View File

@@ -3,8 +3,11 @@ package com.accompany.business.service.family;
import com.accompany.business.model.family.FamilyMember;
import com.accompany.business.model.family.FamilyMemberSerial;
import com.accompany.business.mybatismapper.family.FamilyMemberSerialMapper;
import com.accompany.business.vo.guild.GuildInfoVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
@@ -18,4 +21,20 @@ public class FamilyMemberSerialService extends ServiceImpl<FamilyMemberSerialMap
serialValue, now);
}
public IPage<GuildInfoVo> listBdFamilyGoldNum(IPage<GuildInfoVo> page, String statDate, String endDate, Long bdId) {
return baseMapper.listBdFamilyGoldNum(page,statDate, endDate, bdId);
}
public BigDecimal totalBdFamilyGoldNum(String statDate, String endDate, Long bdId){
return baseMapper.totalBdFamilyGoldNum(statDate, endDate, bdId);
}
public Long totalBdFamilyCount(String statDate, String endDate, Long bdId){
return baseMapper.totalBdFamilyCount(statDate, endDate, bdId);
}
public IPage<GuildInfoVo> listBdFamilyInfo(IPage<GuildInfoVo> page, Long bdId, Integer orderBy){
return baseMapper.listBdFamilyInfo(page, bdId, orderBy);
}
}

View File

@@ -3,11 +3,11 @@ package com.accompany.business.service.guild;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.accompany.business.model.guild.BdInfo;
import com.accompany.business.model.guild.Guild;
import com.accompany.business.service.family.FamilyGiftRecordService;
import com.accompany.business.service.family.FamilyMemberSerialService;
import com.accompany.business.service.user.UsersService;
import com.accompany.business.vo.guild.BdGuildCenterVo;
import com.accompany.business.vo.guild.GuildInfoVo;
import com.accompany.common.constant.Constant;
import com.accompany.common.result.BusiResult;
import com.accompany.common.status.BusiStatus;
import com.accompany.common.utils.DateTimeUtil;
@@ -19,7 +19,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestHeader;
import java.math.BigDecimal;
import java.util.Date;
@@ -27,7 +26,6 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.accompany.common.constant.ApplicationConstant.PublicParameters.PUB_UID;
import static java.util.Collections.EMPTY_LIST;
@Service
@@ -41,7 +39,7 @@ public class BdGuildCenterService {
@Autowired
private GuildDiamondStatisticsDayService guildDiamondStatisticsDayService;
@Autowired
private FamilyGiftRecordService familyGiftRecordService;
private FamilyMemberSerialService familyMemberSerialService;
public BusiResult<BdGuildCenterVo> center(Long uid, String startDate, String endDate, Integer pageNo, Integer pageSize) {
@@ -65,14 +63,13 @@ public class BdGuildCenterService {
IPage<GuildInfoVo> guildInfoVoIPage;
IPage<GuildInfoVo> page = new Page<>(pageNo, pageSize, false);
if (PartitionEnum.ENGLISH.getId() == partitionId) {
Date beginTime = DateUtil.parseDate(startDate);
Date endTime = DateUtil.endOfDay(DateUtil.parseDate(endDate));
BigDecimal totalDiamonds = familyGiftRecordService.totalBdFamilyGoldNum(beginTime, endTime, bdId);
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
if (Constant.ClanMode.FAMILY.equals(partitionEnum.getClanMode())) {
BigDecimal totalDiamonds = familyMemberSerialService.totalBdFamilyGoldNum(startDate, endDate, bdId);
bdGuildCenterVo.setDiamondNum(totalDiamonds);
Long guildCount = familyGiftRecordService.totalBdFamilyCount(beginTime, endTime, bdId);
Long guildCount = familyMemberSerialService.totalBdFamilyCount(startDate, endDate, bdId);
bdGuildCenterVo.setGuildNum(guildCount);
guildInfoVoIPage = familyGiftRecordService.listBdFamilyGoldNum(page, beginTime, endTime, bdId);
guildInfoVoIPage = familyMemberSerialService.listBdFamilyGoldNum(page, startDate, endDate, bdId);
} else {
BigDecimal totalDiamonds = guildDiamondStatisticsDayService.totalBdGuildDiamondNum(startDate, endDate, bdId);
bdGuildCenterVo.setDiamondNum(totalDiamonds);
@@ -85,7 +82,6 @@ public class BdGuildCenterService {
if (CollectionUtils.isNotEmpty(records)) {
List<Long> ownerUids = records.stream().filter(x -> x.getOwnerUid()!=null).map(GuildInfoVo::getOwnerUid).collect(Collectors.toList());
Map<Long, Users> usersMapByUids = usersService.getUsersMapByUids(ownerUids);
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
for (GuildInfoVo record : records) {
if (record.getCreateTime() != null) {
record.setCreateTimeStr(DateTimeUtil.convertWithZoneId(record.getCreateTime(), partitionEnum.getZoneId())
@@ -113,7 +109,7 @@ public class BdGuildCenterService {
Integer partitionId = users.getPartitionId();
IPage<GuildInfoVo> page = new Page<>(pageNo, pageSize, false);
if (PartitionEnum.ENGLISH.getId() == partitionId) {
page = familyGiftRecordService.listBdFamilyInfo(page, bdInfo.getId(), orderBy);
page = familyMemberSerialService.listBdFamilyInfo(page, bdInfo.getId(), orderBy);
} else {
page = guildDiamondStatisticsDayService.listBdGuildInfo(page, bdInfo.getId(), orderBy);
}

View File

@@ -172,7 +172,7 @@
and `date` &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and `date &lt;= #{endTime}
and `date` &lt;= #{endTime}
</if>
group by family_member_id) fg ON fg.family_member_id = gm.id
<where>

View File

@@ -9,5 +9,67 @@
serial_value = serial_value + #{serialValue},
update_time = #{time}
</update>
<select id="totalBdFamilyGoldNum" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(fgr.serial_value),0)
FROM
bd_guild b
LEFT JOIN family f ON b.guild_id = f.id
left join family_member fm on f.id = fm.family_id and fm.`enable` = 1
left join family_member_serial fgr on fgr.family_id = fm.family_id and fm.uid = fgr.uid
and fgr.`date` &gt;=#{startDate} and fgr.`date` &lt;=#{endDate}
where f.`enable` = 1 and b.partition_id = 1 and b.bd_id = #{bdId} and b.`status` = 1
</select>
<select id="totalBdFamilyCount" resultType="java.lang.Long">
SELECT
COUNT(DISTINCT b.guild_id)
FROM
bd_guild b
LEFT JOIN family f ON b.guild_id = f.id
left join family_member fm on f.id = fm.family_id and fm.`enable` = 1
left join family_member_serial fgr on fgr.family_id = fm.family_id and fm.uid = fgr.uid
and fgr.`date` &gt;=#{startDate} and fgr.`date` &lt;=#{endDate}
where f.`enable` = 1 and b.bd_id = #{bdId} and b.`status` = 1 AND IFNULL(fgr.serial_value, 0) > 0
</select>
<select id="listBdFamilyGoldNum" resultType="com.accompany.business.vo.guild.GuildInfoVo">
SELECT
b.guild_id guildId,
f.create_time createTime,
f.avatar avatar,
f.`name` guildName,
f.owner_uid ownerUid,
ifnull(sum(fgr.serial_value), 0) diamondNum
FROM
bd_guild b
LEFT JOIN family f ON b.guild_id = f.id
left join family_member fm on f.id = fm.family_id and fm.`enable` = 1
left join family_member_serial fgr on fgr.family_id = fm.family_id and fm.uid = fgr.uid
and fgr.`date` &gt;=#{startDate} and fgr.`date` &lt;=#{endDate}
where f.`enable` = 1 and b.bd_id = #{bdId} and b.`status` = 1
group by b.guild_id
</select>
<select id="listBdFamilyInfo" resultType="com.accompany.business.vo.guild.GuildInfoVo">
SELECT
b.guild_id guildId,
f.create_time createTime,
f.avatar avatar,
f.`name` guildName,
f.owner_uid ownerUid
FROM
bd_guild b
LEFT JOIN family f ON b.guild_id = f.id
where f.`enable` = 1 and b.bd_id = #{bdId} and b.`status` = 1 and b.partition_id = 1
<choose>
<when test="seq == 0">
order by f.create_time asc
</when>
<when test="seq == 1">
order by f.create_time desc
</when>
</choose>
</select>
</mapper>