火箭奖励先发送给在线的用户
This commit is contained in:
parent
6fe8e4101a
commit
172019c0b1
@ -1,5 +1,12 @@
|
||||
package com.red.circle.live.inner.endpoint.api;
|
||||
|
||||
import com.red.circle.framework.dto.ResultResponse;
|
||||
import com.red.circle.live.inner.model.LiveMicUserDTO;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 房间用户.
|
||||
*
|
||||
@ -9,5 +16,8 @@ public interface LiveRoomUserClientApi {
|
||||
|
||||
String API_PREFIX = "/live/room/user/client";
|
||||
|
||||
@GetMapping("/user/list")
|
||||
ResultResponse<List<LiveMicUserDTO>> userList(@RequestParam Long roomId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package com.red.circle.live.inner.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 直播麦克风用户.
|
||||
*
|
||||
* @author pengliang on 2023/12/8
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class LiveMicUserDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id.
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* CP用户id.
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long cpUserId;
|
||||
|
||||
/**
|
||||
* 账号.
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 头像.
|
||||
*/
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 用户昵称.
|
||||
*/
|
||||
private String userNickname;
|
||||
|
||||
/**
|
||||
* 用户性别:0 女,1 男.
|
||||
*/
|
||||
private Integer userSex;
|
||||
|
||||
/**
|
||||
* 角色.
|
||||
*/
|
||||
private String roles;
|
||||
|
||||
/**
|
||||
* 魅力等级.
|
||||
*/
|
||||
private Integer charmLevel;
|
||||
|
||||
|
||||
/**
|
||||
* 心动值
|
||||
*/
|
||||
private Long heartbeatVal;
|
||||
|
||||
/**
|
||||
* 是否幽灵用户
|
||||
*/
|
||||
private Boolean isGhost;
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.red.circle.live.inner.convert;
|
||||
|
||||
import com.red.circle.framework.core.convertor.ConvertorModel;
|
||||
import com.red.circle.live.app.dto.clientobject.LiveMicUserCO;
|
||||
import com.red.circle.live.inner.model.LiveMicUserDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper(componentModel = ConvertorModel.SPRING)
|
||||
public interface LiveMicUserConvertor {
|
||||
|
||||
List<LiveMicUserDTO> toMicUserDTO(List<LiveMicUserCO> coList);
|
||||
|
||||
}
|
||||
@ -1,13 +1,19 @@
|
||||
package com.red.circle.live.inner.endpoint;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
|
||||
import com.red.circle.framework.dto.ResultResponse;
|
||||
import com.red.circle.live.app.service.LiveRoomUserService;
|
||||
import com.red.circle.live.inner.convert.LiveMicUserConvertor;
|
||||
import com.red.circle.live.inner.endpoint.api.LiveRoomUserClientApi;
|
||||
import com.red.circle.live.inner.service.LiveRoomUserClientService;
|
||||
import com.red.circle.live.inner.model.LiveMicUserDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 房间用户.
|
||||
*
|
||||
@ -19,7 +25,15 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class LiveRoomUserEndpoint implements LiveRoomUserClientApi {
|
||||
|
||||
private final LiveRoomUserClientService liveRoomUserClientService;
|
||||
|
||||
private final LiveRoomUserService liveRoomUserService;
|
||||
private final LiveMicUserConvertor liveMicUserConvertor;
|
||||
|
||||
@Override
|
||||
public ResultResponse<List<LiveMicUserDTO>> userList(Long roomId) {
|
||||
AppRoomIdCmd cmd = new AppRoomIdCmd();
|
||||
cmd.setRoomId(roomId);
|
||||
return ResultResponse.success(liveMicUserConvertor.toMicUserDTO(
|
||||
liveRoomUserService.listUser(cmd)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
|
||||
import com.red.circle.external.inner.endpoint.message.ImGroupClient;
|
||||
import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd;
|
||||
import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum;
|
||||
import com.red.circle.live.inner.endpoint.LiveRoomUserClient;
|
||||
import com.red.circle.live.inner.model.LiveMicUserDTO;
|
||||
import com.red.circle.other.app.convertor.RocketConvertor;
|
||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||
import com.red.circle.other.app.dto.clientobject.RocketStatusCO;
|
||||
@ -26,6 +28,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -49,6 +52,8 @@ public class RocketLaunchCmdExe {
|
||||
private final ImGroupClient imGroupClient;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
private final RocketRewardClaimCmdExe rocketRewardClaimCmdExe;
|
||||
private final LiveRoomUserClient liveRoomUserClient;
|
||||
|
||||
/**
|
||||
* 执行火箭发射
|
||||
@ -118,6 +123,18 @@ public class RocketLaunchCmdExe {
|
||||
log.error("广播火箭升级消息失败: roomId={}", roomId, e);
|
||||
}
|
||||
|
||||
String roomAccount = roomProfileManagerService.getRoomAccount(roomId);
|
||||
|
||||
// 给所有在线的用户发送奖励
|
||||
try {
|
||||
List<LiveMicUserDTO> userDTOS = liveRoomUserClient.userList(roomId).getBody();
|
||||
userDTOS.forEach(userDTO -> {
|
||||
rocketRewardClaimCmdExe.executeAsync(roomId, roomAccount, userDTO.getId());
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.error("给所有在线的用户发送奖励失败: roomId={}", roomId, e);
|
||||
}
|
||||
|
||||
log.info("火箭发射并升级成功: roomId={}, 发射等级={}, 最终能量={}, 贡献者数={}, 升级到={}, 触发用户={}",
|
||||
roomId,
|
||||
launchedLevel,
|
||||
@ -129,7 +146,6 @@ public class RocketLaunchCmdExe {
|
||||
// 10. 推送升级后的状态消息
|
||||
try {
|
||||
RocketStatusCO newStatusCO = RocketConvertor.toStatusCO(rocketStatus);
|
||||
String roomAccount = roomProfileManagerService.getRoomAccount(roomId);
|
||||
rocketImPushManager.pushEnergyUpdate(roomAccount, newStatusCO);
|
||||
} catch (Exception e) {
|
||||
log.error("推送火箭升级消息失败: roomId={}", roomId, e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user