This commit is contained in:
2025-10-14 17:07:29 +08:00
parent fa0f377797
commit 9e0f5e9752
4 changed files with 39 additions and 8 deletions

View File

@@ -9,7 +9,7 @@ import com.accompany.business.model.guild.BdGuild;
import com.accompany.business.model.guild.BdInfo;
import com.accompany.business.model.guild.Guild;
import com.accompany.business.param.BdInfoAdminVO;
import com.accompany.business.service.family.FamilyGiftRecordService;
import com.accompany.business.service.family.FamilyMemberSerialService;
import com.accompany.business.service.guild.BdGuildService;
import com.accompany.business.service.guild.BdInfoService;
import com.accompany.business.service.guild.GuildDiamondStatisticsDayService;
@@ -55,7 +55,7 @@ public class BdInfoAdminService {
@Autowired
private GuildDiamondStatisticsDayService guildDiamondStatisticsDayService;
@Autowired
private FamilyGiftRecordService familyGiftRecordService;
private FamilyMemberSerialService familyMemberSerialService;
public final int BOUND_EXPIRE_LIMIT_DAY = 7;
@@ -134,7 +134,7 @@ public class BdInfoAdminService {
Map<Integer, Double> guildDiamondOrGoldMap;
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
if (Constant.ClanMode.FAMILY.equals(partitionEnum.getClanMode())) {
guildDiamondOrGoldMap = familyGiftRecordService.mapByFamilyId(DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime), guildIdList)
guildDiamondOrGoldMap = familyMemberSerialService.mapByFamilyId(DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime), guildIdList)
.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().doubleValue()));
} else {
guildDiamondOrGoldMap = guildDiamondStatisticsDayService.mapByStatDate(DateUtil.formatDate(beginTime), DateUtil.formatDate(endTime), partitionId, guildIdList);
@@ -351,7 +351,7 @@ public class BdInfoAdminService {
List<GuildInfoVo> records = guilds.getRecords();
if (records != null) {
List<Integer> familyIds = records.stream().map(x -> x.getGuildId().intValue()).collect(Collectors.toList());
Map<Integer, Double> guildDiamondMap = familyGiftRecordService.mapByFamilyId(DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime), familyIds)
Map<Integer, Double> guildDiamondMap = familyMemberSerialService.mapByFamilyId(DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime), familyIds)
.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, x -> x.getValue().doubleValue()));
for (GuildInfoVo record : records) {
record.setGoldNum(BigDecimal.valueOf(guildDiamondMap.getOrDefault(record.getGuildId(), 0D)));

View File

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public interface FamilyMemberSerialMapper extends BaseMapper<FamilyMemberSerial> {
@@ -27,4 +28,7 @@ public interface FamilyMemberSerialMapper extends BaseMapper<FamilyMemberSerial>
@Param("bdId")Long bdId);
IPage<GuildInfoVo> listBdFamilyInfo(@Param("ipage") IPage<GuildInfoVo> ipage, @Param("bdId")Long bdId, @Param("seq") Integer seq);
List<FamilyMemberSerial> listTotalGoldGroupByFamily(@Param("startDate") String startDate, @Param("endDate") String endDate,
@Param("familyIdList") List<Integer> familyIdList);
}

View File

@@ -6,10 +6,15 @@ 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.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class FamilyMemberSerialService extends ServiceImpl<FamilyMemberSerialMapper, FamilyMemberSerial> {
@@ -37,4 +42,11 @@ public class FamilyMemberSerialService extends ServiceImpl<FamilyMemberSerialMap
return baseMapper.listBdFamilyInfo(page, bdId, orderBy);
}
public Map<Integer, BigDecimal> mapByFamilyId(String startDate, String endDate, List<Integer> familyIds) {
List<FamilyMemberSerial> familyGiftRecords = baseMapper.listTotalGoldGroupByFamily(startDate, endDate, familyIds);
if (CollectionUtils.isEmpty(familyGiftRecords)) {
return new HashMap<>();
}
return familyGiftRecords.stream().collect(Collectors.toMap(FamilyMemberSerial::getFamilyId, x -> x.getSerialValue()));
}
}

View File

@@ -19,7 +19,7 @@
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
where f.`enable` = 1 and b.bd_id = #{bdId} and b.`status` = 1
</select>
<select id="totalBdFamilyCount" resultType="java.lang.Long">
@@ -62,7 +62,7 @@
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
where f.`enable` = 1 and b.bd_id = #{bdId} and b.`status` = 1
<choose>
<when test="seq == 0">
order by f.create_time asc
@@ -72,4 +72,19 @@
</when>
</choose>
</select>
<select id="listTotalGoldGroupByFamily" resultType="com.accompany.business.model.family.FamilyMemberSerial">
select family_id, family_member_id, sum(serial_value) `serial_value`
from family_member_serial fms
where 1=1
<if test="startDate != null and startDate != ''">
and fms.`date` &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and fms.`date` &lt;= #{endDate}
</if>
<if test="familyIdList != null and familyIdList.size() > 0">
and family_id in <foreach collection="familyIdList" item="familyId" separator="," open="(" close=")">#{familyId}</foreach>
</if>
group by family_id, family_member_Id
</select>
</mapper>