diff --git a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java index ac6c1f2c..728b0c11 100644 --- a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java +++ b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java @@ -146,15 +146,21 @@ public class DatavRestController extends BaseController { } LocalDate parsedStartDate = LocalDate.parse(startDate); LocalDate parsedEndDate = LocalDate.parse(endDate); - List refreshedTimezones = countryDashboardBackfillLockService.call( - () -> countryDashboardGameMetricService.refreshRange( - parsedStartDate, parsedEndDate, sysOrigin, statTimezones)); + Map refreshed = countryDashboardBackfillLockService.call(() -> { + List countryTimezones = countryDashboardDailyMetricService.refreshRange( + parsedStartDate, parsedEndDate, sysOrigin, statTimezones); + List gameTimezones = countryDashboardGameMetricService.refreshRange( + parsedStartDate, parsedEndDate, sysOrigin, statTimezones); + return Map.of( + "countryStatTimezones", countryTimezones, + "gameStatTimezones", gameTimezones); + }); return Map.of( "status", "success", "startDate", parsedStartDate.toString(), "endDate", parsedEndDate.toString(), "sysOrigin", sysOrigin, - "statTimezones", refreshedTimezones); + "statTimezones", refreshed); } private CountryDashboardCO emptyCountryDashboard(CountryDashboardQryCmd cmd) { diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImpl.java index 33af9773..1f569458 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImpl.java @@ -133,8 +133,6 @@ public class ResidentCpActivityServiceImpl implements ResidentCpActivityService private void validateConfig(ResidentCpConfigSaveCmd cmd) { ResponseAssert.notBlank(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getSysOrigin()); List levels = sortedLevels(cmd.getLevels()); - ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, - "CP levels must contain exactly 6 items.", levels.size() == CP_LEVEL_COUNT); Set levelSet = new HashSet<>(); long previousRequiredValue = -1L; for (ResidentCpLevelConfigSaveCmd level : levels) { diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/datav/CountryDashboardServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/datav/CountryDashboardServiceImpl.java index f0a227aa..fb134cf3 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/datav/CountryDashboardServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/datav/CountryDashboardServiceImpl.java @@ -292,7 +292,7 @@ public class CountryDashboardServiceImpl implements CountryDashboardService { limit = Math.min(100, limit); QueryCondition condition = QueryCondition.of(cmd); - String countryCodes = trimToNull(cmd == null ? null : cmd.getCountryCodes()); + String countryCodes = QueryCondition.trimToNull(cmd == null ? null : cmd.getCountryCodes()); long total = safeLong(countryDashboardDAO.countRechargeDetails( condition.startTime, condition.endTime, condition.countryKeyword, countryCodes, condition.sysOrigin, condition.storageTimezoneOffset, condition.statTimezoneOffset)); diff --git a/rc-service/rc-service-console/console-application/src/test/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImplTest.java b/rc-service/rc-service-console/console-application/src/test/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImplTest.java index b47bb751..2ddd8433 100644 --- a/rc-service/rc-service-console/console-application/src/test/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImplTest.java +++ b/rc-service/rc-service-console/console-application/src/test/java/com/red/circle/console/app/service/app/activity/ResidentCpActivityServiceImplTest.java @@ -1,12 +1,17 @@ package com.red.circle.console.app.service.app.activity; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.red.circle.console.app.dto.clienobject.app.activity.cp.ResidentCpConfigCO; import com.red.circle.console.app.dto.clienobject.app.activity.cp.ResidentCpLevelConfigCO; +import com.red.circle.console.app.dto.cmd.app.activity.cp.ResidentCpConfigSaveCmd; +import com.red.circle.console.app.dto.cmd.app.activity.cp.ResidentCpLevelConfigSaveCmd; import com.red.circle.console.app.service.app.sys.CpCabinConfigService; import com.red.circle.framework.dto.PageResult; import com.red.circle.other.inner.model.cmd.sys.SysCpCabinConfigQryCmd; @@ -41,6 +46,29 @@ class ResidentCpActivityServiceImplTest { assertEquals(0L, result.getLevels().get(5).getRequiredIntimacyValue()); } + @Test + void saveConfigShouldNotRequireExactLevelCount() { + CpCabinConfigService cpCabinConfigService = mock(CpCabinConfigService.class); + ResidentCpActivityServiceImpl service = new ResidentCpActivityServiceImpl( + cpCabinConfigService); + PageResult page = new PageResult<>(); + page.setRecords(List.of()); + when(cpCabinConfigService.getCpCabin(any(SysCpCabinConfigQryCmd.class))).thenReturn(page); + + ResidentCpConfigSaveCmd cmd = new ResidentCpConfigSaveCmd() + .setSysOrigin("likei") + .setLevels(List.of( + level(0, 0L), + level(1, 100L), + level(2, 200L), + level(3, 300L), + level(4, 400L) + )); + + assertDoesNotThrow(() -> service.saveConfig(cmd)); + verify(cpCabinConfigService, times(5)).addCpCabin(any(SysCpCabinConfigDTO.class)); + } + private static SysCpCabinConfigDTO config(Long id, Long sort, Long unlockValue) { return new SysCpCabinConfigDTO() .setId(id) @@ -48,4 +76,11 @@ class ResidentCpActivityServiceImplTest { .setCabinUnlockValue(unlockValue) .setSort(sort); } + + private static ResidentCpLevelConfigSaveCmd level(Integer level, Long requiredValue) { + return new ResidentCpLevelConfigSaveCmd() + .setLevel(level) + .setLevelName("CP " + level + "级") + .setRequiredIntimacyValue(requiredValue); + } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java index c2f984af..18cb6dc9 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java @@ -78,6 +78,12 @@ public class SendCpApplyCmdExe { public boolean autoCreateFromCpGift(Long sendUserId, Long acceptUserId, String sysOrigin, String relationTypeValue, BigDecimal applyConsumeGold) { + if (Objects.equals(sendUserId, acceptUserId)) { + log.info( + "[CP] skip auto create cp apply from self gift, sendUserId={}, relationType={}", + sendUserId, relationTypeValue); + return false; + } try { process(sendUserId, acceptUserId, sysOrigin, relationTypeValue, false, applyConsumeGold); return true; @@ -166,7 +172,7 @@ public class SendCpApplyCmdExe { sendCpBuildIm(sendUserId, acceptUserId, cpApply.getId(), userProfile, acceptUserProfile, isReconcile, relationType, applyText); - + userMqMessageService.cpApplyDelayed( new CpApplyEvent() .setId(cpApply.getId()) diff --git a/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/command/user/SendCpApplyCmdExeTest.java b/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/command/user/SendCpApplyCmdExeTest.java index 3a510efc..2ece84b9 100644 --- a/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/command/user/SendCpApplyCmdExeTest.java +++ b/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/command/user/SendCpApplyCmdExeTest.java @@ -109,12 +109,22 @@ class SendCpApplyCmdExeTest { assertTrue(data.get("content").toString().contains("\"relationType\":\"" + relationType + "\"")); } + @Test + void autoCreateFromCpGiftShouldSkipSelfGift() { + Fixture fixture = new Fixture(1, 1); + + assertFalse(fixture.exe.autoCreateFromCpGift(1001L, 1001L, "LIKEI", "BROTHER")); + verify(fixture.cpApplyService, never()).save(any(CpApply.class)); + verify(fixture.userRegionGateway, never()).checkEqRegion(any(), any()); + } + private static class Fixture { private final CpApplyService cpApplyService = mock(CpApplyService.class); private final ImMessageClient imMessageClient = mock(ImMessageClient.class); private final UserMqMessageService userMqMessageService = mock(UserMqMessageService.class); private final CpRelationshipService cpRelationshipService = mock(CpRelationshipService.class); + private final UserRegionGateway userRegionGateway = mock(UserRegionGateway.class); private final SendCpApplyCmdExe exe; private long nextApplyId = 3001L; @@ -123,8 +133,6 @@ class SendCpApplyCmdExeTest { EnumConfigCacheService enumConfigCacheService = mock(EnumConfigCacheService.class); UserProfileGateway userProfileGateway = mock(UserProfileGateway.class); UserProfileAppConvertor userProfileAppConvertor = mock(UserProfileAppConvertor.class); - UserRegionGateway userRegionGateway = mock(UserRegionGateway.class); - UserProfile sendProfile = new UserProfile(); sendProfile.setId(1001L); UserProfile acceptProfile = new UserProfile(); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/props/ActivitySourceGroupGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/props/ActivitySourceGroupGatewayImpl.java index 7661e137..5437b727 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/props/ActivitySourceGroupGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/props/ActivitySourceGroupGatewayImpl.java @@ -5,7 +5,6 @@ import com.red.circle.common.business.enums.PropsActivityRewardEnum; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.other.domain.gateway.props.ActivitySourceGroupGateway; -import com.red.circle.other.infra.common.activity.VipActivityRewardCommon; import com.red.circle.other.infra.common.props.PropsResourcesCommon; import com.red.circle.other.infra.convertor.material.PropsActivityInfraConvertor; import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig; @@ -383,8 +382,6 @@ public class ActivitySourceGroupGatewayImpl implements ActivitySourceGroupGatewa return rewardGroupConfigMap.values().stream() .flatMap(Collection::stream) .filter(config -> PropsActivityRewardEnum.PROPS.eq(config.getType())) - .filter(config -> Objects.equals(config.getDetailType(), - VipActivityRewardCommon.VIP_DETAIL_TYPE)) .map(config -> DataTypeUtils.toLong(config.getContent())) .filter(Objects::nonNull) .collect(Collectors.toSet()); @@ -408,7 +405,6 @@ public class ActivitySourceGroupGatewayImpl implements ActivitySourceGroupGatewa private boolean isVipLevelReward(PropsActivityRewardConfig rewardConfig, Set vipConfigIds) { return PropsActivityRewardEnum.PROPS.eq(rewardConfig.getType()) - && Objects.equals(rewardConfig.getDetailType(), VipActivityRewardCommon.VIP_DETAIL_TYPE) && vipConfigIds.contains(DataTypeUtils.toLong(rewardConfig.getContent())); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsActivityRewardGroupClientServiceImpl.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsActivityRewardGroupClientServiceImpl.java index 3bd230ef..e42396d5 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsActivityRewardGroupClientServiceImpl.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsActivityRewardGroupClientServiceImpl.java @@ -4,7 +4,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.red.circle.common.business.enums.PropsActivityRewardEnum; import com.red.circle.framework.dto.PageResult; -import com.red.circle.other.infra.common.activity.VipActivityRewardCommon; import com.red.circle.other.app.inner.convertor.material.PropsInnerConvertor; import com.red.circle.other.app.inner.service.material.props.PropsActivityRewardGroupClientService; import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig; @@ -354,8 +353,6 @@ public class PropsActivityRewardGroupClientServiceImpl implements private Set getVipLevelConfigIds(List configs) { return configs.stream() .filter(config -> Objects.equals(config.getType(), PropsActivityRewardEnum.PROPS.name())) - .filter(config -> Objects.equals(config.getDetailType(), - VipActivityRewardCommon.VIP_DETAIL_TYPE)) .map(config -> DataTypeUtils.toLong(config.getContent())) .filter(Objects::nonNull) .collect(Collectors.toSet()); @@ -375,7 +372,6 @@ public class PropsActivityRewardGroupClientServiceImpl implements private boolean isVipLevelReward(PropsActivityRewardConfig config, Map vipConfigMap) { return Objects.equals(config.getType(), PropsActivityRewardEnum.PROPS.name()) - && Objects.equals(config.getDetailType(), VipActivityRewardCommon.VIP_DETAIL_TYPE) && vipConfigMap.containsKey(DataTypeUtils.toLong(config.getContent())); }