修复首冲
This commit is contained in:
parent
35458a674e
commit
0bf810261f
@ -120,8 +120,6 @@ public class ResidentCpActivityServiceImpl implements ResidentCpActivityService
|
|||||||
private void validateConfig(ResidentCpConfigSaveCmd cmd) {
|
private void validateConfig(ResidentCpConfigSaveCmd cmd) {
|
||||||
ResponseAssert.notBlank(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getSysOrigin());
|
ResponseAssert.notBlank(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getSysOrigin());
|
||||||
List<ResidentCpLevelConfigSaveCmd> levels = sortedLevels(cmd.getLevels());
|
List<ResidentCpLevelConfigSaveCmd> levels = sortedLevels(cmd.getLevels());
|
||||||
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
|
|
||||||
"CP levels must contain exactly 6 items.", levels.size() == CP_LEVEL_COUNT);
|
|
||||||
Set<Integer> levelSet = new HashSet<>();
|
Set<Integer> levelSet = new HashSet<>();
|
||||||
long previousRequiredValue = -1L;
|
long previousRequiredValue = -1L;
|
||||||
for (ResidentCpLevelConfigSaveCmd level : levels) {
|
for (ResidentCpLevelConfigSaveCmd level : levels) {
|
||||||
|
|||||||
@ -1,12 +1,17 @@
|
|||||||
package com.red.circle.console.app.service.app.activity;
|
package com.red.circle.console.app.service.app.activity;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
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.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
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 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.ResidentCpConfigCO;
|
||||||
import com.red.circle.console.app.dto.clienobject.app.activity.cp.ResidentCpLevelConfigCO;
|
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.console.app.service.app.sys.CpCabinConfigService;
|
||||||
import com.red.circle.framework.dto.PageResult;
|
import com.red.circle.framework.dto.PageResult;
|
||||||
import com.red.circle.other.inner.model.cmd.sys.SysCpCabinConfigQryCmd;
|
import com.red.circle.other.inner.model.cmd.sys.SysCpCabinConfigQryCmd;
|
||||||
@ -41,6 +46,29 @@ class ResidentCpActivityServiceImplTest {
|
|||||||
assertEquals(0L, result.getLevels().get(5).getRequiredIntimacyValue());
|
assertEquals(0L, result.getLevels().get(5).getRequiredIntimacyValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void saveConfigShouldNotRequireExactLevelCount() {
|
||||||
|
CpCabinConfigService cpCabinConfigService = mock(CpCabinConfigService.class);
|
||||||
|
ResidentCpActivityServiceImpl service = new ResidentCpActivityServiceImpl(
|
||||||
|
cpCabinConfigService);
|
||||||
|
PageResult<SysCpCabinConfigDTO> 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) {
|
private static SysCpCabinConfigDTO config(Long id, Long sort, Long unlockValue) {
|
||||||
return new SysCpCabinConfigDTO()
|
return new SysCpCabinConfigDTO()
|
||||||
.setId(id)
|
.setId(id)
|
||||||
@ -48,4 +76,11 @@ class ResidentCpActivityServiceImplTest {
|
|||||||
.setCabinUnlockValue(unlockValue)
|
.setCabinUnlockValue(unlockValue)
|
||||||
.setSort(sort);
|
.setSort(sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ResidentCpLevelConfigSaveCmd level(Integer level, Long requiredValue) {
|
||||||
|
return new ResidentCpLevelConfigSaveCmd()
|
||||||
|
.setLevel(level)
|
||||||
|
.setLevelName("CP " + level + "级")
|
||||||
|
.setRequiredIntimacyValue(requiredValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,6 +71,12 @@ public class SendCpApplyCmdExe {
|
|||||||
|
|
||||||
public boolean autoCreateFromCpGift(Long sendUserId, Long acceptUserId, String sysOrigin,
|
public boolean autoCreateFromCpGift(Long sendUserId, Long acceptUserId, String sysOrigin,
|
||||||
String relationTypeValue) {
|
String relationTypeValue) {
|
||||||
|
if (Objects.equals(sendUserId, acceptUserId)) {
|
||||||
|
log.info(
|
||||||
|
"[CP] skip auto create cp apply from self gift, sendUserId={}, relationType={}",
|
||||||
|
sendUserId, relationTypeValue);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
process(sendUserId, acceptUserId, sysOrigin, relationTypeValue, false);
|
process(sendUserId, acceptUserId, sysOrigin, relationTypeValue, false);
|
||||||
return true;
|
return true;
|
||||||
@ -156,6 +162,11 @@ public class SendCpApplyCmdExe {
|
|||||||
Map<Object, Object> map = OfficialNoticeUtils.buildUserProfile(userProfile);
|
Map<Object, Object> map = OfficialNoticeUtils.buildUserProfile(userProfile);
|
||||||
map.put("applyType", isReconcile ? "RECONCILE" : "APPLY");
|
map.put("applyType", isReconcile ? "RECONCILE" : "APPLY");
|
||||||
map.put("relationType", relationType.name());
|
map.put("relationType", relationType.name());
|
||||||
|
map.put("acceptUserId", acceptUserProfile.getId());
|
||||||
|
map.put("acceptAccount", acceptUserProfile.getAccount());
|
||||||
|
map.put("acceptActualAccount", acceptUserProfile.actualAccount());
|
||||||
|
map.put("acceptNickname", acceptUserProfile.getUserNickname());
|
||||||
|
map.put("acceptUserAvatar", acceptUserProfile.getUserAvatar());
|
||||||
officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder()
|
officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder()
|
||||||
.toAccount(acceptUserId)
|
.toAccount(acceptUserId)
|
||||||
.noticeType(OfficialNoticeTypeEnum.CP_BUILD)
|
.noticeType(OfficialNoticeTypeEnum.CP_BUILD)
|
||||||
|
|||||||
@ -49,9 +49,19 @@ class SendCpApplyCmdExeTest {
|
|||||||
verify(fixture.cpApplyService, never()).save(any(CpApply.class));
|
verify(fixture.cpApplyService, never()).save(any(CpApply.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 static class Fixture {
|
||||||
|
|
||||||
private final CpApplyService cpApplyService = mock(CpApplyService.class);
|
private final CpApplyService cpApplyService = mock(CpApplyService.class);
|
||||||
|
private final UserRegionGateway userRegionGateway = mock(UserRegionGateway.class);
|
||||||
private final SendCpApplyCmdExe exe;
|
private final SendCpApplyCmdExe exe;
|
||||||
|
|
||||||
private Fixture(Integer sendSex, Integer acceptSex) {
|
private Fixture(Integer sendSex, Integer acceptSex) {
|
||||||
@ -62,8 +72,6 @@ class SendCpApplyCmdExeTest {
|
|||||||
EnumConfigCacheService enumConfigCacheService = mock(EnumConfigCacheService.class);
|
EnumConfigCacheService enumConfigCacheService = mock(EnumConfigCacheService.class);
|
||||||
UserProfileGateway userProfileGateway = mock(UserProfileGateway.class);
|
UserProfileGateway userProfileGateway = mock(UserProfileGateway.class);
|
||||||
UserProfileAppConvertor userProfileAppConvertor = mock(UserProfileAppConvertor.class);
|
UserProfileAppConvertor userProfileAppConvertor = mock(UserProfileAppConvertor.class);
|
||||||
UserRegionGateway userRegionGateway = mock(UserRegionGateway.class);
|
|
||||||
|
|
||||||
UserProfile sendProfile = new UserProfile();
|
UserProfile sendProfile = new UserProfile();
|
||||||
UserProfile acceptProfile = new UserProfile();
|
UserProfile acceptProfile = new UserProfile();
|
||||||
UserProfileDTO sendProfileDTO = profile(1001L, sendSex);
|
UserProfileDTO sendProfileDTO = profile(1001L, sendSex);
|
||||||
|
|||||||
@ -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.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||||
import com.red.circle.other.domain.gateway.props.ActivitySourceGroupGateway;
|
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.common.props.PropsResourcesCommon;
|
||||||
import com.red.circle.other.infra.convertor.material.PropsActivityInfraConvertor;
|
import com.red.circle.other.infra.convertor.material.PropsActivityInfraConvertor;
|
||||||
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig;
|
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig;
|
||||||
@ -383,8 +382,6 @@ public class ActivitySourceGroupGatewayImpl implements ActivitySourceGroupGatewa
|
|||||||
return rewardGroupConfigMap.values().stream()
|
return rewardGroupConfigMap.values().stream()
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.filter(config -> PropsActivityRewardEnum.PROPS.eq(config.getType()))
|
.filter(config -> PropsActivityRewardEnum.PROPS.eq(config.getType()))
|
||||||
.filter(config -> Objects.equals(config.getDetailType(),
|
|
||||||
VipActivityRewardCommon.VIP_DETAIL_TYPE))
|
|
||||||
.map(config -> DataTypeUtils.toLong(config.getContent()))
|
.map(config -> DataTypeUtils.toLong(config.getContent()))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
@ -408,7 +405,6 @@ public class ActivitySourceGroupGatewayImpl implements ActivitySourceGroupGatewa
|
|||||||
|
|
||||||
private boolean isVipLevelReward(PropsActivityRewardConfig rewardConfig, Set<Long> vipConfigIds) {
|
private boolean isVipLevelReward(PropsActivityRewardConfig rewardConfig, Set<Long> vipConfigIds) {
|
||||||
return PropsActivityRewardEnum.PROPS.eq(rewardConfig.getType())
|
return PropsActivityRewardEnum.PROPS.eq(rewardConfig.getType())
|
||||||
&& Objects.equals(rewardConfig.getDetailType(), VipActivityRewardCommon.VIP_DETAIL_TYPE)
|
|
||||||
&& vipConfigIds.contains(DataTypeUtils.toLong(rewardConfig.getContent()));
|
&& vipConfigIds.contains(DataTypeUtils.toLong(rewardConfig.getContent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.red.circle.common.business.enums.PropsActivityRewardEnum;
|
import com.red.circle.common.business.enums.PropsActivityRewardEnum;
|
||||||
import com.red.circle.framework.dto.PageResult;
|
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.convertor.material.PropsInnerConvertor;
|
||||||
import com.red.circle.other.app.inner.service.material.props.PropsActivityRewardGroupClientService;
|
import com.red.circle.other.app.inner.service.material.props.PropsActivityRewardGroupClientService;
|
||||||
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig;
|
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig;
|
||||||
@ -354,8 +353,6 @@ public class PropsActivityRewardGroupClientServiceImpl implements
|
|||||||
private Set<Long> getVipLevelConfigIds(List<PropsActivityRewardConfig> configs) {
|
private Set<Long> getVipLevelConfigIds(List<PropsActivityRewardConfig> configs) {
|
||||||
return configs.stream()
|
return configs.stream()
|
||||||
.filter(config -> Objects.equals(config.getType(), PropsActivityRewardEnum.PROPS.name()))
|
.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()))
|
.map(config -> DataTypeUtils.toLong(config.getContent()))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
@ -375,7 +372,6 @@ public class PropsActivityRewardGroupClientServiceImpl implements
|
|||||||
private boolean isVipLevelReward(PropsActivityRewardConfig config,
|
private boolean isVipLevelReward(PropsActivityRewardConfig config,
|
||||||
Map<Long, VipLevelConfig> vipConfigMap) {
|
Map<Long, VipLevelConfig> vipConfigMap) {
|
||||||
return Objects.equals(config.getType(), PropsActivityRewardEnum.PROPS.name())
|
return Objects.equals(config.getType(), PropsActivityRewardEnum.PROPS.name())
|
||||||
&& Objects.equals(config.getDetailType(), VipActivityRewardCommon.VIP_DETAIL_TYPE)
|
|
||||||
&& vipConfigMap.containsKey(DataTypeUtils.toLong(config.getContent()));
|
&& vipConfigMap.containsKey(DataTypeUtils.toLong(config.getContent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user