fix: grant work-center VIP for seven days

This commit is contained in:
zhx 2026-07-14 19:01:43 +08:00
parent cbb12ea13a
commit 1deda4c663
2 changed files with 112 additions and 5 deletions

View File

@ -75,6 +75,9 @@ import java.util.stream.Collectors;
@Slf4j
public class ManagerAuthServiceImpl implements ManagerAuthService {
/** work-center 赠送道具的固定有效期,需与 H5 展示保持一致。 */
private static final int WORK_CENTER_PROPS_VALID_DAYS = 7;
private final RoomManagerAuthsQueryExe roomManagerAuthsQueryExe;
private final ManagerApprovalNotPassCmdExe managerApprovalNotPassCmdExe;
private final PropsSourceRecordService propsSourceRecordService;
@ -300,7 +303,8 @@ public class ManagerAuthServiceImpl implements ManagerAuthService {
// UserProfile admin = userProfileGateway.getByUserId(cmd.requiredReqUserId());
int days = PropsCommodityType.NOBLE_VIP.name().equals(propsSourceRecord.getType()) ? 3 : 7;
// work-center 每次只赠送 7 VIP 主权益与其附带权益必须使用同一期限
int days = WORK_CENTER_PROPS_VALID_DAYS;
sendPropsRecord(cmd, propsSourceRecord.getType(), days);
//vip单独处理
if (propsSourceRecord.getType().equals(PropsCommodityType.NOBLE_VIP.name())) {
@ -309,25 +313,25 @@ public class ManagerAuthServiceImpl implements ManagerAuthService {
.equals(vipAbility.getCarId(), 0L)) {
cmd.setPropsId(vipAbility.getCarId());
sendPropsRecord(cmd, ConsolePropsTypeEnum.RIDE.getName(), 3);
sendPropsRecord(cmd, ConsolePropsTypeEnum.RIDE.getName(), days);
}
if (Objects.nonNull(vipAbility.getAvatarFrameId())
&& !Objects.equals(vipAbility.getAvatarFrameId(), 0L)) {
cmd.setPropsId(vipAbility.getAvatarFrameId());
sendPropsRecord(cmd, ConsolePropsTypeEnum.AVATAR_FRAME.getName(), 3);
sendPropsRecord(cmd, ConsolePropsTypeEnum.AVATAR_FRAME.getName(), days);
}
if (Objects.nonNull(vipAbility.getChatBubbleId())
&& !Objects.equals(vipAbility.getChatBubbleId(), 0L)) {
cmd.setPropsId(vipAbility.getChatBubbleId());
sendPropsRecord(cmd, ConsolePropsTypeEnum.CHAT_BUBBLE.getName(), 3);
sendPropsRecord(cmd, ConsolePropsTypeEnum.CHAT_BUBBLE.getName(), days);
}
if (Objects.nonNull(vipAbility.getDataCardId())
&& !Objects.equals(vipAbility.getDataCardId(), 0L)) {
cmd.setPropsId(vipAbility.getDataCardId());
sendPropsRecord(cmd, ConsolePropsTypeEnum.DATA_CARD.getName(), 3);
sendPropsRecord(cmd, ConsolePropsTypeEnum.DATA_CARD.getName(), days);
}
// 使用最大等级的VIP

View File

@ -0,0 +1,103 @@
package com.red.circle.other.app.service.user;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.red.circle.component.redis.service.RedisService;
import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.command.user.ManagerApprovalNotPassCmdExe;
import com.red.circle.other.app.command.user.query.RoomManagerAuthsQueryExe;
import com.red.circle.other.app.dto.cmd.material.PropsGiveAwayCmd;
import com.red.circle.other.domain.gateway.props.PropsNobleVipGateway;
import com.red.circle.other.domain.gateway.props.PropsStoreGateway;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
import com.red.circle.other.infra.convertor.material.PropsMaterialInfraConvertor;
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberService;
import com.red.circle.other.infra.database.mongo.service.team.team.TeamProfileService;
import com.red.circle.other.infra.database.mongo.service.user.profile.UserSpecialIdService;
import com.red.circle.other.infra.database.rds.entity.props.PropsSourceRecord;
import com.red.circle.other.infra.database.rds.entity.sys.Administrator;
import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordService;
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService;
import com.red.circle.other.inner.endpoint.material.props.PropsBackpackClient;
import com.red.circle.other.inner.endpoint.material.props.PropsNobleVipClient;
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
import com.red.circle.other.inner.enums.material.PropsCommodityType;
import com.red.circle.other.inner.model.cmd.material.GivePropsBackpackCmd;
import com.red.circle.other.inner.model.dto.material.props.PropsNobleVipAbilityDTO;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
class ManagerAuthServiceImplTest {
@Mock private RoomManagerAuthsQueryExe roomManagerAuthsQueryExe;
@Mock private ManagerApprovalNotPassCmdExe managerApprovalNotPassCmdExe;
@Mock private PropsSourceRecordService propsSourceRecordService;
@Mock private AdministratorService administratorService;
@Mock private PropsMaterialInfraConvertor propsMaterialInfraConvertor;
@Mock private UserProfileGateway userProfileGateway;
@Mock private UserRegionGateway userRegionGateway;
@Mock private RedisService redisService;
@Mock private PropsBackpackClient propsBackpackClient;
@Mock private PropsStoreGateway propsStoreGateway;
@Mock private BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService;
@Mock private TeamMemberService teamMemberService;
@Mock private TeamProfileService teamProfileService;
@Mock private UserSpecialIdService userSpecialIdService;
@Mock private PropsNobleVipGateway propsNobleVipGateway;
@Mock private UserProfileClient userProfileClient;
@Mock private OfficialNoticeClient officialNoticeClient;
@Mock private AdministratorAuthService administratorAuthService;
@Mock private PropsNobleVipClient propsNobleVipClient;
@InjectMocks private ManagerAuthServiceImpl managerAuthService;
@Test
void shouldGrantVipAndAllBundledBenefitsForSevenDays() {
long operatorId = 1001L;
long receiverId = 2001L;
long vipId = 3001L;
PropsGiveAwayCmd cmd = new PropsGiveAwayCmd();
cmd.setReqUserId(operatorId);
cmd.setAcceptUserId(receiverId);
cmd.setPropsId(vipId);
when(administratorService.getByUserId(operatorId))
.thenReturn(new Administrator().setUserId(operatorId).setStatus(Boolean.TRUE));
when(userRegionGateway.checkEqRegion(receiverId, operatorId)).thenReturn(Boolean.TRUE);
when(redisService.lock(anyString(), anyLong())).thenReturn(Boolean.TRUE);
when(propsSourceRecordService.getById(vipId))
.thenReturn(new PropsSourceRecord().setId(vipId).setType(PropsCommodityType.NOBLE_VIP.name()));
PropsNobleVipAbilityDTO vipAbility = new PropsNobleVipAbilityDTO();
vipAbility.setCarId(3002L);
vipAbility.setAvatarFrameId(3003L);
vipAbility.setChatBubbleId(3004L);
vipAbility.setDataCardId(3005L);
when(propsNobleVipGateway.getAbilityDTO(vipId)).thenReturn(vipAbility);
when(propsNobleVipClient.getUserMaxAbilityDTO(receiverId))
.thenReturn(ResultResponse.success(null));
managerAuthService.sendProps(cmd);
ArgumentCaptor<GivePropsBackpackCmd> grantCaptor =
ArgumentCaptor.forClass(GivePropsBackpackCmd.class);
verify(propsBackpackClient, times(5)).giveProps(grantCaptor.capture());
List<GivePropsBackpackCmd> grants = grantCaptor.getAllValues();
assertThat(grants).extracting(GivePropsBackpackCmd::getDays).containsOnly(7);
assertThat(grants).extracting(GivePropsBackpackCmd::getPropsId)
.containsExactly(3001L, 3002L, 3003L, 3004L, 3005L);
}
}