From fc383098d343b22c2da85ca3cce19b63cc8d14cf Mon Sep 17 00:00:00 2001 From: hokli <2629910752@qq.com> Date: Mon, 4 Aug 2025 17:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E6=92=AD=E6=B8=B8=E6=88=8F=E8=96=AA?= =?UTF-8?q?=E8=B5=84=E6=93=8D=E4=BD=9Cfixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameUsdBillRecordAdminService.java | 35 ++++++++++- .../model/guildgame/GameUsdBillRecord.java | 1 - .../AnchorGameSalaryBillAdminVo.java | 13 ++++ .../guildgame/GameDiamondStatDayService.java | 5 +- .../guildgame/GameUsdBillRecordService.java | 59 +++++++------------ .../guildgame/GameUsdOperateService.java | 4 +- .../impl/GameDiamondStatDayServiceImpl.java | 17 +++--- .../sqlmappers/GameUsdBillRecordMapper.xml | 4 +- 8 files changed, 82 insertions(+), 56 deletions(-) diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/guildgame/GameUsdBillRecordAdminService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/guildgame/GameUsdBillRecordAdminService.java index a780db103..e916db1d3 100644 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/guildgame/GameUsdBillRecordAdminService.java +++ b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/guildgame/GameUsdBillRecordAdminService.java @@ -6,9 +6,13 @@ import com.accompany.business.constant.guildgame.GameTimeUtil; import com.accompany.business.model.UserPurse; import com.accompany.business.model.guild.Guild; import com.accompany.business.model.guild.GuildMember; +import com.accompany.business.model.guildgame.GameDiamondSalary; +import com.accompany.business.model.guildgame.GameDiamondStatDay; import com.accompany.business.param.BasePageParams; import com.accompany.business.service.guild.GuildMemberService; import com.accompany.business.service.guild.GuildService; +import com.accompany.business.service.guildgame.GameDiamondSalaryService; +import com.accompany.business.service.guildgame.GameDiamondStatDayService; import com.accompany.business.service.guildgame.GameUsdBillRecordService; import com.accompany.business.service.purse.UserPurseService; import com.accompany.business.service.user.UsersService; @@ -25,11 +29,12 @@ import com.accompany.core.service.partition.PartitionInfoService; import com.accompany.core.service.region.RegionInfoService; import com.accompany.core.vo.BaseResponseVO; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.*; @@ -58,6 +63,10 @@ public class GameUsdBillRecordAdminService { private PartitionInfoService partitionInfoService; @Autowired private RegionInfoService regionInfoService; + @Autowired + private GameDiamondStatDayService gameDiamondStatDayService; + @Autowired + private GameDiamondSalaryService gameDiamondSalaryService; public Page chargeAgentList(BasePageParams basePageParams, Long chargeAgentErbanNo, Long erbanNo) { @@ -159,6 +168,7 @@ public class GameUsdBillRecordAdminService { return anchorSalaryBillAdminVoPage; } fillUserInfo(anchorSalaryBillAdminVoPage.getRecords()); + fillGameUsd(anchorSalaryBillAdminVoPage.getRecords(), dateCycle, basePageParams.getPartitionId()); fillAgencyInfo(anchorSalaryBillAdminVoPage.getRecords()); fillAgencyPurse(anchorSalaryBillAdminVoPage.getRecords()); return anchorSalaryBillAdminVoPage; @@ -178,6 +188,29 @@ public class GameUsdBillRecordAdminService { } } + private void fillGameUsd(List anchorSalaryBillVos, String dateCycle, Integer partitionId) { + List guildMemberIds = anchorSalaryBillVos.stream().map(AnchorGameSalaryBillAdminVo::getGuildMemberId).collect(Collectors.toList()); + List gameDiamondStatDays = gameDiamondStatDayService.listGuildGameMonthList(guildMemberIds, dateCycle); + if (CollectionUtils.isEmpty(gameDiamondStatDays)) { + return; + } + Map> dayStatMap = gameDiamondStatDays.stream().collect(Collectors.groupingBy(GameDiamondStatDay::getGuildMemberId)); + Map gameUsdMap = new HashMap<>(); + TreeMap salaryMap = gameDiamondSalaryService.getDiamondSalaryMap(partitionId); + + for (Map.Entry> entry : dayStatMap.entrySet()) { + List value = entry.getValue(); + BigDecimal gameUsd = BigDecimal.ZERO; + for (GameDiamondStatDay gameDiamondStatDay : value) { + gameUsd = gameUsd.add(salaryMap.headMap(gameDiamondStatDay.getPlayGameNum(), true).lastEntry().getValue().getBaseSalary()); + } + gameUsdMap.put(entry.getKey(), gameUsd); + } + for (AnchorGameSalaryBillAdminVo anchorSalaryBillVo : anchorSalaryBillVos) { + anchorSalaryBillVo.setGameUsd(gameUsdMap.getOrDefault(anchorSalaryBillVo.getGuildMemberId(), BigDecimal.ZERO)); + } + } + private void fillAgencyInfo(List records) { Set hallIds = records.stream().map(AnchorGameSalaryBillAdminVo::getHallId).collect(Collectors.toSet()); Map agencyOwnerMapByHallIds = guildService.getAgencyOwnerMapByHallIds(hallIds); diff --git a/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/model/guildgame/GameUsdBillRecord.java b/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/model/guildgame/GameUsdBillRecord.java index 6f379e117..13b3c8b7c 100644 --- a/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/model/guildgame/GameUsdBillRecord.java +++ b/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/model/guildgame/GameUsdBillRecord.java @@ -30,7 +30,6 @@ public class GameUsdBillRecord implements Serializable { private Long targetGuildMemberId; private Long targetUid; private String cycleDate; - private String statDate; private BigDecimal beforeUsd; private BigDecimal operateUsd; private BigDecimal afterUsd; diff --git a/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/vo/guildgame/AnchorGameSalaryBillAdminVo.java b/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/vo/guildgame/AnchorGameSalaryBillAdminVo.java index 889e16319..95e904f71 100644 --- a/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/vo/guildgame/AnchorGameSalaryBillAdminVo.java +++ b/accompany-business/accompany-business-sdk/src/main/java/com/accompany/business/vo/guildgame/AnchorGameSalaryBillAdminVo.java @@ -4,6 +4,7 @@ import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import lombok.*; +import java.math.BigDecimal; import java.util.Date; /** @@ -57,6 +58,11 @@ public class AnchorGameSalaryBillAdminVo { private Date createTime; @ExcelProperty("时间") private String createTimeStr; + /** + * 薪资产生时间 + */ + @ExcelIgnore + private String receiveStatDate; @ExcelIgnore private Double usb; @ExcelIgnore @@ -66,6 +72,11 @@ public class AnchorGameSalaryBillAdminVo { */ @ExcelIgnore private Integer hallId; + /** + * 公会主键id + */ + @ExcelIgnore + private Long guildMemberId; /** * 公会id */ @@ -85,6 +96,8 @@ public class AnchorGameSalaryBillAdminVo { */ @ExcelIgnore private Double receiveUsd; + @ExcelIgnore + private BigDecimal gameUsd; /** * 薪资兑换金币 */ diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameDiamondStatDayService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameDiamondStatDayService.java index 0b92df573..b91cf7179 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameDiamondStatDayService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameDiamondStatDayService.java @@ -21,7 +21,8 @@ public interface GameDiamondStatDayService extends IService List getGuildGameMonthList(Long guildMemberId, String cycleDate); - List queryByGuildMemberIdAndCycleDate(Long guildMemberId, String cycleDate); - GameDiamondStatDay queryByGuildMemberIdAndStatDate(Long guildMemberId, String cycleDate, String statDate); + + + List listGuildGameMonthList(List guildMemberIds, String cycleDate); } diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameUsdBillRecordService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameUsdBillRecordService.java index e77890ac2..1c76c146b 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameUsdBillRecordService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/guildgame/GameUsdBillRecordService.java @@ -3,6 +3,7 @@ package com.accompany.business.service.guildgame; import com.accompany.business.constant.guildgame.GameTimeUtil; import com.accompany.business.constant.guildgame.GameUsdOperateTypeEnum; import com.accompany.business.model.UserPurse; +import com.accompany.business.model.guildgame.GameDiamondStatDay; import com.accompany.business.model.guildgame.GameUsdBillRecord; import com.accompany.business.model.guildgame.GameUsdWithdrawRecord; import com.accompany.business.mybatismapper.guildgame.GameUsdBillRecordMapper; @@ -52,6 +53,8 @@ public class GameUsdBillRecordService extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(GameUsdBillRecord::getGuildMemberId, guildMemberId); - queryWrapper.eq(GameUsdBillRecord::getUid, uid) - .eq(GameUsdBillRecord::getType, typeEnum.getType()) - .eq(GameUsdBillRecord::getCycleDate, cycleDate) - .eq(GameUsdBillRecord::getStatDate, statDate); - return baseMapper.selectOne(queryWrapper, false); - } - - /** - * KEY 为 guildMemberId_statDate - * @param guildMemberId - * @param uid - * @param cycleDate - * @param typeEnum - * @return - */ - public Map queryStatDateMap(Long guildMemberId, Long uid, String cycleDate, GameUsdOperateTypeEnum typeEnum) { - - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(GameUsdBillRecord::getGuildMemberId, guildMemberId); - queryWrapper.eq(GameUsdBillRecord::getUid, uid) - .eq(GameUsdBillRecord::getType, typeEnum.getType()) - .eq(GameUsdBillRecord::getCycleDate, cycleDate); - - List gameUsdBillRecords = baseMapper.selectList(queryWrapper); - - if (CollectionUtils.isEmpty(gameUsdBillRecords)) { - return Collections.emptyMap(); - } - return gameUsdBillRecords.stream().collect(Collectors.toMap(x -> String.format("%s_%s", x.getGuildMemberId(), x.getStatDate()), - x -> x)); - } - - public List listRechargeUserOrderByUsdDesc(List rechargeUserUidList, String zoneId){ String cycleDate = CycleTimeUtil.getCurCycleDateByZoneId(zoneId); return this.baseMapper.listRechargeUserOrderByUsdDesc(rechargeUserUidList, cycleDate, GameUsdOperateTypeEnum.USD_TO_RECHARGE_USER.getType()); @@ -297,11 +263,16 @@ public class GameUsdBillRecordService extends ServiceImpl ipage = new Page<>(pageParams.getPageNo(), pageParams.getPageSize()); Page anchorSalaryBillPage = this.baseMapper.listPage(ipage, pageParams.getPartitionId(), pageParams.getDateCycle(), uid, receiveUid, pageParams.getStartTime(), pageParams.getEndTime(), salaryOperateType,hallId); - List anchorSalaryBillVos = converAdminBillVo(anchorSalaryBillPage.getRecords()); + List anchorSalaryBillVos = converAdminBillVo(anchorSalaryBillPage.getRecords(), salaryOperateType); Page page = new Page<>(); page.setTotal(anchorSalaryBillPage.getTotal()); page.setRecords(anchorSalaryBillVos); + + if (CollectionUtils.isEmpty(page.getRecords())) { + return page; + } + fillUserInfo(page.getRecords()); fillReceiveUserInfo(page.getRecords()); return page; @@ -344,8 +315,17 @@ public class GameUsdBillRecordService extends ServiceImpl converAdminBillVo(List anchorSalaryBills) { + private List converAdminBillVo(List anchorSalaryBills, Integer salaryOperateType) { List anchorSalaryBillAdminVos = new ArrayList<>(); + if (CollectionUtils.isEmpty(anchorSalaryBills)) { + return anchorSalaryBillAdminVos; + } + Map receiveStatDateMap = new HashMap<>(); + if (salaryOperateType ==GameUsdOperateTypeEnum.RECEIVE_USD.getType()) { + List statIds = anchorSalaryBills.stream().map(GameUsdBillRecord::getRecordId).collect(Collectors.toList()); + List gameDiamondStatDays = gameDiamondStatDayService.listByIds(statIds); + receiveStatDateMap = gameDiamondStatDays.stream().collect(Collectors.toMap(GameDiamondStatDay::getId, GameDiamondStatDay::getStatDate)); + } for (GameUsdBillRecord anchorSalaryBill : anchorSalaryBills) { AnchorGameSalaryBillAdminVo anchorSalaryBillAdminVo = new AnchorGameSalaryBillAdminVo(); anchorSalaryBillAdminVo.setCreateTime(anchorSalaryBill.getCreateTime()); @@ -360,6 +340,7 @@ public class GameUsdBillRecordService extends ServiceImpl queryByGuildMemberIdAndCycleDate(Long guildMemberId, String cycleDate) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(GameDiamondStatDay::getGuildMemberId, guildMemberId); - queryWrapper.eq(GameDiamondStatDay::getCycleDate, cycleDate); - queryWrapper.orderByDesc(GameDiamondStatDay::getStatDate); - return baseMapper.selectList(queryWrapper); - } - @Override public GameDiamondStatDay queryByGuildMemberIdAndStatDate(Long guildMemberId, String cycleDate, String statDate) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); @@ -59,4 +50,12 @@ public class GameDiamondStatDayServiceImpl extends ServiceImpl listGuildGameMonthList(List guildMemberIds, String cycleDate) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(GameDiamondStatDay::getGuildMemberId, guildMemberIds); + queryWrapper.eq(GameDiamondStatDay::getCycleDate, cycleDate); + return baseMapper.selectList(queryWrapper); + } } diff --git a/accompany-business/accompany-business-service/src/main/resources/accompany/sqlmappers/GameUsdBillRecordMapper.xml b/accompany-business/accompany-business-service/src/main/resources/accompany/sqlmappers/GameUsdBillRecordMapper.xml index b39fafd12..cc783ee9c 100644 --- a/accompany-business/accompany-business-service/src/main/resources/accompany/sqlmappers/GameUsdBillRecordMapper.xml +++ b/accompany-business/accompany-business-service/src/main/resources/accompany/sqlmappers/GameUsdBillRecordMapper.xml @@ -85,7 +85,7 @@