主播游戏薪资操作fixed

This commit is contained in:
2025-08-04 17:49:51 +08:00
parent 258a4d01d5
commit fc383098d3
8 changed files with 82 additions and 56 deletions

View File

@@ -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<AnchorGameSalaryBillAdminVo> 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<AnchorGameSalaryBillAdminVo> anchorSalaryBillVos, String dateCycle, Integer partitionId) {
List<Long> guildMemberIds = anchorSalaryBillVos.stream().map(AnchorGameSalaryBillAdminVo::getGuildMemberId).collect(Collectors.toList());
List<GameDiamondStatDay> gameDiamondStatDays = gameDiamondStatDayService.listGuildGameMonthList(guildMemberIds, dateCycle);
if (CollectionUtils.isEmpty(gameDiamondStatDays)) {
return;
}
Map<Long, List<GameDiamondStatDay>> dayStatMap = gameDiamondStatDays.stream().collect(Collectors.groupingBy(GameDiamondStatDay::getGuildMemberId));
Map<Long, BigDecimal> gameUsdMap = new HashMap<>();
TreeMap<Integer, GameDiamondSalary> salaryMap = gameDiamondSalaryService.getDiamondSalaryMap(partitionId);
for (Map.Entry<Long, List<GameDiamondStatDay>> entry : dayStatMap.entrySet()) {
List<GameDiamondStatDay> 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<AnchorGameSalaryBillAdminVo> records) {
Set<Integer> hallIds = records.stream().map(AnchorGameSalaryBillAdminVo::getHallId).collect(Collectors.toSet());
Map<Integer, AgencyOwnerVo> agencyOwnerMapByHallIds = guildService.getAgencyOwnerMapByHallIds(hallIds);

View File

@@ -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;

View File

@@ -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;
/**
* 薪资兑换金币
*/

View File

@@ -21,7 +21,8 @@ public interface GameDiamondStatDayService extends IService<GameDiamondStatDay>
List<GameDiamondStatDay> getGuildGameMonthList(Long guildMemberId, String cycleDate);
List<GameDiamondStatDay> queryByGuildMemberIdAndCycleDate(Long guildMemberId, String cycleDate);
GameDiamondStatDay queryByGuildMemberIdAndStatDate(Long guildMemberId, String cycleDate, String statDate);
List<GameDiamondStatDay> listGuildGameMonthList(List<Long> guildMemberIds, String cycleDate);
}

View File

@@ -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<GameUsdBillRecordMappe
private RechargeUserService rechargeUserService;
@Autowired
private GameUsdWithdrawRecordService gameUsdWithdrawRecordService;
@Autowired
private GameDiamondStatDayService gameDiamondStatDayService;
public GameUsdBillRecord insert(String no, Integer partitionId, Long memberId, Integer guildId, Long uid, Long targetMemberId, Long targetUid, GameUsdOperateTypeEnum typeEnum,
UserPurse before, UserPurse after, BigDecimal gameUsdNum, BigDecimal currencyNum, Long recordId, String remark, Date statDate) {
@@ -70,7 +73,6 @@ public class GameUsdBillRecordService extends ServiceImpl<GameUsdBillRecordMappe
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(u.getPartitionId());
ZonedDateTime zdt = DateTimeUtil.convertWithZoneId(statDate, partitionEnum.getZoneId());
record.setCycleDate(GameTimeUtil.getCycleDate(zdt));
record.setStatDate(GameTimeUtil.getStatDate(zdt));
}
boolean usdIsOutput = CurrencyEnum.GAME_USD.equals(typeEnum.getOutputCurrency());
@@ -109,42 +111,6 @@ public class GameUsdBillRecordService extends ServiceImpl<GameUsdBillRecordMappe
}
public GameUsdBillRecord queryOne(Long guildMemberId, Long uid, String cycleDate, String statDate, GameUsdOperateTypeEnum typeEnum) {
LambdaQueryWrapper<GameUsdBillRecord> 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<String, GameUsdBillRecord> queryStatDateMap(Long guildMemberId, Long uid, String cycleDate, GameUsdOperateTypeEnum typeEnum) {
LambdaQueryWrapper<GameUsdBillRecord> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GameUsdBillRecord::getGuildMemberId, guildMemberId);
queryWrapper.eq(GameUsdBillRecord::getUid, uid)
.eq(GameUsdBillRecord::getType, typeEnum.getType())
.eq(GameUsdBillRecord::getCycleDate, cycleDate);
List<GameUsdBillRecord> 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<GameUsdBillRecord> listRechargeUserOrderByUsdDesc(List<Long> 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<GameUsdBillRecordMappe
Page<GameUsdBillRecord> ipage = new Page<>(pageParams.getPageNo(), pageParams.getPageSize());
Page<GameUsdBillRecord> anchorSalaryBillPage = this.baseMapper.listPage(ipage, pageParams.getPartitionId(), pageParams.getDateCycle(),
uid, receiveUid, pageParams.getStartTime(), pageParams.getEndTime(), salaryOperateType,hallId);
List<AnchorGameSalaryBillAdminVo> anchorSalaryBillVos = converAdminBillVo(anchorSalaryBillPage.getRecords());
List<AnchorGameSalaryBillAdminVo> anchorSalaryBillVos = converAdminBillVo(anchorSalaryBillPage.getRecords(), salaryOperateType);
Page<AnchorGameSalaryBillAdminVo> 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<GameUsdBillRecordMappe
}
}
private List<AnchorGameSalaryBillAdminVo> converAdminBillVo(List<GameUsdBillRecord> anchorSalaryBills) {
private List<AnchorGameSalaryBillAdminVo> converAdminBillVo(List<GameUsdBillRecord> anchorSalaryBills, Integer salaryOperateType) {
List<AnchorGameSalaryBillAdminVo> anchorSalaryBillAdminVos = new ArrayList<>();
if (CollectionUtils.isEmpty(anchorSalaryBills)) {
return anchorSalaryBillAdminVos;
}
Map<Long, String> receiveStatDateMap = new HashMap<>();
if (salaryOperateType ==GameUsdOperateTypeEnum.RECEIVE_USD.getType()) {
List<Long> statIds = anchorSalaryBills.stream().map(GameUsdBillRecord::getRecordId).collect(Collectors.toList());
List<GameDiamondStatDay> 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<GameUsdBillRecordMappe
anchorSalaryBillAdminVo.setAfterUsb(anchorSalaryBill.getAfterUsd().doubleValue());
anchorSalaryBillAdminVo.setAfterDiamond(null != anchorSalaryBill.getAfterCurrency()? anchorSalaryBill.getAfterCurrency().doubleValue(): 0d);
anchorSalaryBillAdminVo.setExDiamond(null != anchorSalaryBill.getOperateCurrency()? anchorSalaryBill.getOperateCurrency().doubleValue(): 0d);
anchorSalaryBillAdminVo.setReceiveStatDate(receiveStatDateMap.getOrDefault(anchorSalaryBill.getRecordId(), ""));
anchorSalaryBillAdminVos.add(anchorSalaryBillAdminVo);
}
return anchorSalaryBillAdminVos;

View File

@@ -224,7 +224,7 @@ public class GameUsdOperateService {
String objId = UUIDUtil.get();
GameUsdBillRecord billRecord = gameUsdBillRecordService.insert(objId, guildMember.getPartitionId(), guildMember.getId(), guildMember.getGuildId(), uid,
null != targetMember? targetMember.getId(): null, targetUid, typeEnum, before, after, gameUsdNum, currencyNum, recordId, null, null);
null != targetMember? targetMember.getId(): null, targetUid, typeEnum, before, after, gameUsdNum, currencyNum, recordId, null, new Date());
if (GameUsdOperateTypeEnum.USD_TO_GUILD_OWNER.equals(typeEnum) || GameUsdOperateTypeEnum.USD_TO_RECHARGE_USER.equals(typeEnum)) {
//小秘书
@@ -288,6 +288,6 @@ public class GameUsdOperateService {
String objId = UUIDUtil.get();
gameUsdBillRecordService.insert(objId, guildMember.getPartitionId(), null, guildId, null, guildMember.getId(), uid, GameUsdOperateTypeEnum.USD_WITHDRAW_REJECT,
null, before, gameUsdNum, null, null, null, null);
null, before, gameUsdNum, null, null, null, new Date());
}
}

View File

@@ -42,15 +42,6 @@ public class GameDiamondStatDayServiceImpl extends ServiceImpl<GameDiamondStatDa
return baseMapper.selectList(queryWrapper);
}
@Override
public List<GameDiamondStatDay> queryByGuildMemberIdAndCycleDate(Long guildMemberId, String cycleDate) {
LambdaQueryWrapper<GameDiamondStatDay> 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<GameDiamondStatDay> queryWrapper = new LambdaQueryWrapper<>();
@@ -59,4 +50,12 @@ public class GameDiamondStatDayServiceImpl extends ServiceImpl<GameDiamondStatDa
queryWrapper.eq(GameDiamondStatDay::getStatDate, statDate);
return baseMapper.selectOne(queryWrapper, false);
}
@Override
public List<GameDiamondStatDay> listGuildGameMonthList(List<Long> guildMemberIds, String cycleDate) {
LambdaQueryWrapper<GameDiamondStatDay> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(GameDiamondStatDay::getGuildMemberId, guildMemberIds);
queryWrapper.eq(GameDiamondStatDay::getCycleDate, cycleDate);
return baseMapper.selectList(queryWrapper);
}
}

View File

@@ -85,7 +85,7 @@
</select>
<select id="anchorSummary" resultType="com.accompany.business.vo.guildgame.AnchorGameSalaryBillAdminVo">
SELECT hm.uid,hm.guild_id hallId, hm.guild_id agencyId,
SELECT hm.uid,hm.guild_id hallId, hm.guild_id agencyId,hm.id guildMemberId,
IFNULL(a.receiveUsd,0) receiveUsd,
IFNULL(a.usbToGold,0) usbToGold,
IFNULL(a.usbToAgent,0) usbToAgent,
@@ -120,7 +120,7 @@
<if test="partitionId != null">
and hm.partition_id = #{partitionId}
</if>
group by hm.uid,hm.guild_id
group by hm.uid,hm.guild_id,hm.id
</select>
<select id="sumRechargeUsd" resultType="java.lang.Double">