diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/user/RegionAssistTypeEnum.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/user/RegionAssistTypeEnum.java index d3a3920b..dfb6e696 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/user/RegionAssistTypeEnum.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/user/RegionAssistTypeEnum.java @@ -33,6 +33,16 @@ public enum RegionAssistTypeEnum { */ GIFT_TO_OTHER_GOLD_RATIO_AGENCY("接收他人礼物获得金币比例(%)-代理"), + /** + * 接收自己礼物获得金币比例(%).普通用户 + */ + GIFT_TO_OWN_GOLD_RATIO_NORMAL("接收自己礼物获得金币比例(%)-普通用户"), + + /** + * 接收他人礼物获得金币比例(%).普通用户 + */ + GIFT_TO_OTHER_GOLD_RATIO_NORMAL("接收他人礼物获得金币比例(%)-普通用户"), + /** * 接收礼物获得目标比例(%). */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java index b5a2849b..7bb7a461 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java @@ -522,8 +522,8 @@ public class GiveGiftsListener implements MessageListener { acceptRegion.getRegionCode()), Boolean.TRUE); if (Boolean.FALSE.equals(isConflicts)) { - // 幸运礼物 - if (event.checkLuckyGift()) { + // 幸运礼物 不计算金额,GiftPrizeAcceptStrategy不发送 + /*if (event.checkLuckyGift()) { // 幸运礼物目标 = 礼物价值 * 比例 targetAmount = giftValue.getGiftValue().multiply(luckyGiftRatio).setScale(0, RoundingMode.DOWN); @@ -532,14 +532,24 @@ public class GiveGiftsListener implements MessageListener { // 赠送礼物给别人返还金币比例 acceptAssistRatio = luckyGiftRatio; - } else { + }*/ + if (!event.checkLuckyGift()) { // 赠送礼物给别人返还金币比例 acceptAssistRatio = getAssistGiftToOtherGoldRatio(acceptRegion.getId()); + // 发送人是普通用户 + BigDecimal sendAssistRatioNormal = null; + if (userRegionGateway.isOrdinaryUser(event.getSendUserId())) { + acceptAssistRatio = getAssistGiftToOtherGoldRatioNormal(acceptRegion.getId()); + sendAssistRatioNormal = getAssistGiftToOwnGoldRatioNormal(acceptRegion.getId()); + + } + // 普通礼物,接受人可获得金额 acceptAmount = enumConfigCacheService.giftGoldRatioFormula(Objects.equals(event.getSendUserId(), accept.getAcceptUserId()) - ? sendAssistRatio : acceptAssistRatio, giftValue.getGiftValue()); + ? (sendAssistRatioNormal != null ? sendAssistRatioNormal : sendAssistRatio) + : acceptAssistRatio, giftValue.getGiftValue()); BigDecimal assistGiftTargetRatio = getAssistGiftTargetRatio(acceptRegion.getId()); @@ -840,6 +850,20 @@ public class GiveGiftsListener implements MessageListener { return userRegionGateway.getAssistGiftToOwnGoldRatioAgency(regionId); } + /** + * 赠送礼物给别人返还金币比例-普通用户 + */ + private BigDecimal getAssistGiftToOtherGoldRatioNormal(String regionId) { + return userRegionGateway.getAssistGiftToOtherGoldRatioNormal(regionId); + } + + /** + * 赠送礼物给自己返还金币比例-普通用户 + */ + private BigDecimal getAssistGiftToOwnGoldRatioNormal(String regionId) { + return userRegionGateway.getAssistGiftToOwnGoldRatioNormal(regionId); + } + /** * 接收礼物获得目标比例. */ diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/UserRegionGateway.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/UserRegionGateway.java index 1b71eab7..62cff9a3 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/UserRegionGateway.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/UserRegionGateway.java @@ -52,6 +52,11 @@ public interface UserRegionGateway { */ boolean checkBusinessRegion(Long userId, Long compareUserId); + /** + * 是否普通用户 + * true: team_member没有用户信息 + */ + boolean isOrdinaryUser(Long userId); /** * 检查两个code在业务分区是否一致. @@ -87,6 +92,16 @@ public interface UserRegionGateway { BigDecimal getAssistGiftToOwnGoldRatioAgency(String regionId); + /** + * 接收他人礼物获得金币比例-普通用户 + */ + BigDecimal getAssistGiftToOtherGoldRatioNormal(String regionId); + + /** + * 接收自己礼物获得金币比例-普通用户 + */ + BigDecimal getAssistGiftToOwnGoldRatioNormal(String regionId); + BigDecimal getGiftToOtherDiamondRatio(String regionId,Boolean isHost); /** diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRegionGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRegionGatewayImpl.java index 34e744fc..98a399e9 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRegionGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRegionGatewayImpl.java @@ -332,6 +332,11 @@ public class UserRegionGatewayImpl implements UserRegionGateway { return checkBusinessRegionCode(regionOne, regionTwo); } + @Override + public boolean isOrdinaryUser(Long userId) { + return teamMemberService.getByMemberId(userId) == null; + } + /** * 检查两个code在业务分区是否一致. *

在一些特效情况下, 运营对当前区域进行整合, 如: 阿拉伯+土耳其可以互相访问

@@ -517,6 +522,38 @@ public class UserRegionGatewayImpl implements UserRegionGateway { defaultRatio); } + /** + * 接收他人礼物获得金币比例.代理 + */ + @Override + public BigDecimal getAssistGiftToOtherGoldRatioNormal(String regionId) { + + BigDecimal defaultRatio = BigDecimal.valueOf(0.1); + if (StringUtils.isBlank(regionId)) { + return defaultRatio; + } + + return getAssistRatio(sysRegionAssistConfigService + .getRegionAssistConfig(RegionAssistTypeEnum.GIFT_TO_OTHER_GOLD_RATIO_NORMAL, regionId), + defaultRatio); + } + + + /** + * 接收自己礼物获得金币比例. + */ + @Override + public BigDecimal getAssistGiftToOwnGoldRatioNormal(String regionId) { + BigDecimal defaultRatio = BigDecimal.valueOf(0.1); + if (StringUtils.isBlank(regionId)) { + return defaultRatio; + } + + return getAssistRatio(sysRegionAssistConfigService + .getRegionAssistConfig(RegionAssistTypeEnum.GIFT_TO_OWN_GOLD_RATIO_NORMAL, regionId), + defaultRatio); + } + @Override public BigDecimal getGiftToOtherDiamondRatio(String regionId,Boolean isHost) { BigDecimal defaultRatio = BigDecimal.valueOf(0.1); diff --git a/rc-service/rc-service-other/other-start/src/test/java/ApiTest.java b/rc-service/rc-service-other/other-start/src/test/java/ApiTest.java index 3e2e1de8..8a3cd191 100644 --- a/rc-service/rc-service-other/other-start/src/test/java/ApiTest.java +++ b/rc-service/rc-service-other/other-start/src/test/java/ApiTest.java @@ -1,3 +1,4 @@ +import com.red.circle.tool.crypto.SecurityUtils; import org.junit.Test; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -8,5 +9,10 @@ public class ApiTest { System.out.println(new BCryptPasswordEncoder().encode("8826681")); } + @Test + public void test1() { + System.out.println(SecurityUtils.md5("1957345312961527809")); + } + }