赠送他人返回金币-改成判断接收者
This commit is contained in:
parent
69729a5201
commit
898bc5aed4
@ -69,6 +69,7 @@ import java.math.BigDecimal;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import kotlin.Pair;
|
import kotlin.Pair;
|
||||||
@ -493,6 +494,11 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
|
|
||||||
Map<Long, TeamMember> teamMemberMap = teamMemberService.mapByMemberIds(anchorUserIds);
|
Map<Long, TeamMember> teamMemberMap = teamMemberService.mapByMemberIds(anchorUserIds);
|
||||||
|
|
||||||
|
Set<Long> acceptUserIds = event.getAccepts().stream()
|
||||||
|
.map(GiveAwayGiftRoomAccepts::getAcceptUserId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<Long> teamMemberIds = new HashSet<>(teamMemberService.listMemberIds(acceptUserIds));
|
||||||
|
|
||||||
return event.getAccepts().stream().map(accept -> {
|
return event.getAccepts().stream().map(accept -> {
|
||||||
|
|
||||||
// 接受人区域与金币比例
|
// 接受人区域与金币比例
|
||||||
@ -545,8 +551,8 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
acceptAmount = giftValue.getGiftValue().multiply(acceptAssistRatio).setScale(0, RoundingMode.DOWN);
|
acceptAmount = giftValue.getGiftValue().multiply(acceptAssistRatio).setScale(0, RoundingMode.DOWN);
|
||||||
} else {
|
} else {
|
||||||
// 普通礼物
|
// 普通礼物
|
||||||
acceptAssistRatio = calculateAcceptAssistRatio(event, acceptRegion);
|
acceptAssistRatio = calculateAcceptAssistRatio(teamMemberIds, accept.getAcceptUserId(), acceptRegion);
|
||||||
BigDecimal effectiveSendRatio = calculateEffectiveSendRatio(event, sendRegion, sendAssistRatio, acceptRegion, accept);
|
BigDecimal effectiveSendRatio = calculateEffectiveSendRatio(event, sendRegion, sendAssistRatio, acceptRegion, accept, teamMemberIds);
|
||||||
|
|
||||||
acceptAmount = enumConfigCacheService.giftGoldRatioFormula(effectiveSendRatio, giftValue.getGiftValue());
|
acceptAmount = enumConfigCacheService.giftGoldRatioFormula(effectiveSendRatio, giftValue.getGiftValue());
|
||||||
targetAmount = giftValue.getGiftValue()
|
targetAmount = giftValue.getGiftValue()
|
||||||
@ -580,8 +586,8 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
/**
|
/**
|
||||||
* 计算接收方助力比例.
|
* 计算接收方助力比例.
|
||||||
*/
|
*/
|
||||||
private BigDecimal calculateAcceptAssistRatio(GiveAwayGiftBatchEvent event, RegionConfig acceptRegion) {
|
private BigDecimal calculateAcceptAssistRatio(Set<Long> teamMemberIds, Long acceptUserId, RegionConfig acceptRegion) {
|
||||||
if (userRegionGateway.isOrdinaryUser(event.getSendUserId())) {
|
if (!teamMemberIds.contains(acceptUserId)) {
|
||||||
return getAssistGiftToOtherGoldRatioNormal(acceptRegion.getId());
|
return getAssistGiftToOtherGoldRatioNormal(acceptRegion.getId());
|
||||||
}
|
}
|
||||||
return getAssistGiftToOtherGoldRatio(acceptRegion.getId());
|
return getAssistGiftToOtherGoldRatio(acceptRegion.getId());
|
||||||
@ -592,7 +598,7 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
*/
|
*/
|
||||||
private BigDecimal calculateEffectiveSendRatio(GiveAwayGiftBatchEvent event, RegionConfig sendRegion,
|
private BigDecimal calculateEffectiveSendRatio(GiveAwayGiftBatchEvent event, RegionConfig sendRegion,
|
||||||
BigDecimal sendAssistRatio, RegionConfig acceptRegion,
|
BigDecimal sendAssistRatio, RegionConfig acceptRegion,
|
||||||
GiveAwayGiftRoomAccepts accept) {
|
GiveAwayGiftRoomAccepts accept, Set<Long> teamMemberIds) {
|
||||||
// 送给自己
|
// 送给自己
|
||||||
if (Objects.equals(event.getSendUserId(), accept.getAcceptUserId())) {
|
if (Objects.equals(event.getSendUserId(), accept.getAcceptUserId())) {
|
||||||
if (userRegionGateway.isOrdinaryUser(event.getSendUserId())) {
|
if (userRegionGateway.isOrdinaryUser(event.getSendUserId())) {
|
||||||
@ -601,7 +607,7 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
return sendAssistRatio;
|
return sendAssistRatio;
|
||||||
}
|
}
|
||||||
// 送给别人
|
// 送给别人
|
||||||
return calculateAcceptAssistRatio(event, acceptRegion);
|
return calculateAcceptAssistRatio(teamMemberIds, accept.getAcceptUserId(), acceptRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user