红包、任务需求
This commit is contained in:
parent
33b970a033
commit
3e4251ba3b
@ -1,2 +1,10 @@
|
|||||||
spring:
|
spring:
|
||||||
|
|
||||||
|
task:
|
||||||
|
center:
|
||||||
|
go:
|
||||||
|
enabled: ${TASK_CENTER_GO_ENABLED:true}
|
||||||
|
base-url: ${TASK_CENTER_GO_URL:${LIKEI_GATEWAY_ROUTE_GO_URI:http://golang:2900}}
|
||||||
|
internal-token: ${GAME_INTERNAL_CALLBACK_SECRET:}
|
||||||
|
timeout-millis: ${TASK_CENTER_GO_TIMEOUT_MILLIS:3000}
|
||||||
|
|
||||||
|
|||||||
@ -71,3 +71,11 @@ red-circle:
|
|||||||
telegram:
|
telegram:
|
||||||
bot-token: ${LIKEI_ORDER_TELEGRAM_BOT_TOKEN}
|
bot-token: ${LIKEI_ORDER_TELEGRAM_BOT_TOKEN}
|
||||||
webhook-url: ${LIKEI_ORDER_TELEGRAM_WEBHOOK_URL}
|
webhook-url: ${LIKEI_ORDER_TELEGRAM_WEBHOOK_URL}
|
||||||
|
|
||||||
|
task:
|
||||||
|
center:
|
||||||
|
go:
|
||||||
|
enabled: ${TASK_CENTER_GO_ENABLED:true}
|
||||||
|
base-url: ${TASK_CENTER_GO_URL:${LIKEI_GATEWAY_ROUTE_GO_URI:http://golang:2900}}
|
||||||
|
internal-token: ${GAME_INTERNAL_CALLBACK_SECRET:}
|
||||||
|
timeout-millis: ${TASK_CENTER_GO_TIMEOUT_MILLIS:3000}
|
||||||
|
|||||||
@ -115,6 +115,22 @@ invite:
|
|||||||
internal-token: ${GAME_INTERNAL_CALLBACK_SECRET:}
|
internal-token: ${GAME_INTERNAL_CALLBACK_SECRET:}
|
||||||
timeout-millis: ${INVITE_CAMPAIGN_GO_TIMEOUT_MILLIS:10000}
|
timeout-millis: ${INVITE_CAMPAIGN_GO_TIMEOUT_MILLIS:10000}
|
||||||
|
|
||||||
|
task:
|
||||||
|
center:
|
||||||
|
go:
|
||||||
|
enabled: ${TASK_CENTER_GO_ENABLED:true}
|
||||||
|
base-url: ${TASK_CENTER_GO_URL:${LIKEI_GATEWAY_ROUTE_GO_URI:http://golang:2900}}
|
||||||
|
internal-token: ${GAME_INTERNAL_CALLBACK_SECRET:}
|
||||||
|
timeout-millis: ${TASK_CENTER_GO_TIMEOUT_MILLIS:3000}
|
||||||
|
|
||||||
|
voice-room:
|
||||||
|
region-broadcast:
|
||||||
|
go:
|
||||||
|
enabled: ${VOICE_ROOM_REGION_BROADCAST_GO_ENABLED:true}
|
||||||
|
base-url: ${VOICE_ROOM_REGION_BROADCAST_GO_URL:${TASK_CENTER_GO_URL:${LIKEI_GATEWAY_ROUTE_GO_URI:http://golang:2900}}}
|
||||||
|
internal-token: ${GAME_INTERNAL_CALLBACK_SECRET:}
|
||||||
|
timeout-millis: ${VOICE_ROOM_REGION_BROADCAST_GO_TIMEOUT_MILLIS:3000}
|
||||||
|
|
||||||
activity:
|
activity:
|
||||||
ranking:
|
ranking:
|
||||||
reward:
|
reward:
|
||||||
|
|||||||
@ -22,6 +22,11 @@ public enum GiftSpecialEnum {
|
|||||||
*/
|
*/
|
||||||
NOTICE,
|
NOTICE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局广播礼物.
|
||||||
|
*/
|
||||||
|
GLOBAL_GIFT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 周星.
|
* 周星.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import com.red.circle.live.domain.online.LiveRoomUser;
|
|||||||
import com.red.circle.live.infra.database.cache.service.LiveMicCacheService;
|
import com.red.circle.live.infra.database.cache.service.LiveMicCacheService;
|
||||||
import com.red.circle.live.infra.database.cache.service.LiveMicUserCacheService;
|
import com.red.circle.live.infra.database.cache.service.LiveMicUserCacheService;
|
||||||
import com.red.circle.live.infra.database.cache.service.LiveRoomCacheService;
|
import com.red.circle.live.infra.database.cache.service.LiveRoomCacheService;
|
||||||
|
import com.red.circle.live.infra.client.TaskCenterGoClient;
|
||||||
import com.red.circle.live.infra.util.DateTimeAsiaRiyadhUtils;
|
import com.red.circle.live.infra.util.DateTimeAsiaRiyadhUtils;
|
||||||
import com.red.circle.mq.business.model.event.user.UserHeartbeatEvent;
|
import com.red.circle.mq.business.model.event.user.UserHeartbeatEvent;
|
||||||
import com.red.circle.mq.rocket.business.producer.UserMqMessageService;
|
import com.red.circle.mq.rocket.business.producer.UserMqMessageService;
|
||||||
@ -80,6 +81,7 @@ public class UserHeartbeatListener implements MessageListener {
|
|||||||
private final AgoraRoomStateService agoraRoomStateService;
|
private final AgoraRoomStateService agoraRoomStateService;
|
||||||
private final AgoraMicMissingConfirmService agoraMicMissingConfirmService;
|
private final AgoraMicMissingConfirmService agoraMicMissingConfirmService;
|
||||||
private final AgoraMicStateCleanupService agoraMicStateCleanupService;
|
private final AgoraMicStateCleanupService agoraMicStateCleanupService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
|
|
||||||
private static final int HEARTBEAT_INTERVAL_SECONDS = 60;
|
private static final int HEARTBEAT_INTERVAL_SECONDS = 60;
|
||||||
|
|
||||||
@ -336,8 +338,18 @@ public class UserHeartbeatListener implements MessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long previousRefreshTime = liveMicrophone.getRefreshTime();
|
||||||
liveMicrophone.updateLastActivityTime();
|
liveMicrophone.updateLastActivityTime();
|
||||||
|
Long currentRefreshTime = liveMicrophone.getRefreshTime();
|
||||||
liveMicCacheService.goUp(roomProfile.getId(), liveMicrophone.getMicIndex(), liveMicrophone);
|
liveMicCacheService.goUp(roomProfile.getId(), liveMicrophone.getMicIndex(), liveMicrophone);
|
||||||
|
taskCenterGoClient.reportMicDuration(
|
||||||
|
Objects.nonNull(event.getSysOrigin()) ? event.getSysOrigin().name() : "",
|
||||||
|
roomProfile.getId(),
|
||||||
|
liveMicrophone.getMicIndex(),
|
||||||
|
event.getUserId(),
|
||||||
|
previousRefreshTime,
|
||||||
|
currentRefreshTime,
|
||||||
|
"HEARTBEAT");
|
||||||
liveMicrophoneGateway.refreshNotActiveUser(roomProfile);
|
liveMicrophoneGateway.refreshNotActiveUser(roomProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,156 @@
|
|||||||
|
package com.red.circle.live.infra.client;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.red.circle.live.domain.constant.ActiveSecondConstant;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class TaskCenterGoClient {
|
||||||
|
|
||||||
|
private static final String EVENT_TYPE_MIC_DURATION_SECONDS = "MIC_DURATION_SECONDS";
|
||||||
|
|
||||||
|
@Value("${task.center.go.enabled:true}")
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Value("${task.center.go.base-url:}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
@Value("${task.center.go.internal-token:}")
|
||||||
|
private String internalToken;
|
||||||
|
|
||||||
|
@Value("${task.center.go.timeout-millis:3000}")
|
||||||
|
private Integer timeoutMillis;
|
||||||
|
|
||||||
|
public void reportMicDuration(String sysOrigin,
|
||||||
|
Long roomId,
|
||||||
|
Integer micIndex,
|
||||||
|
Long userId,
|
||||||
|
Long previousRefreshTime,
|
||||||
|
Long currentTime,
|
||||||
|
String source) {
|
||||||
|
if (Objects.isNull(userId) || Objects.isNull(previousRefreshTime) || Objects.isNull(currentTime)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long deltaSeconds = calculateMicDurationSeconds(previousRefreshTime, currentTime);
|
||||||
|
if (deltaSeconds <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("source", source);
|
||||||
|
payload.put("roomId", roomId);
|
||||||
|
payload.put("micIndex", micIndex);
|
||||||
|
payload.put("previousRefreshTime", previousRefreshTime);
|
||||||
|
payload.put("currentTime", currentTime);
|
||||||
|
|
||||||
|
reportEvent(new TaskCenterEventRequest()
|
||||||
|
.setSysOrigin(sysOrigin)
|
||||||
|
.setEventId("MIC_DURATION:" + Objects.toString(source, "UNKNOWN")
|
||||||
|
+ ":" + Objects.toString(roomId, "")
|
||||||
|
+ ":" + Objects.toString(micIndex, "")
|
||||||
|
+ ":" + userId
|
||||||
|
+ ":" + previousRefreshTime
|
||||||
|
+ ":" + currentTime)
|
||||||
|
.setEventType(EVENT_TYPE_MIC_DURATION_SECONDS)
|
||||||
|
.setUserId(userId)
|
||||||
|
.setDeltaValue(deltaSeconds)
|
||||||
|
.setOccurredAt(Instant.ofEpochMilli(currentTime).toString())
|
||||||
|
.setPayload(payload));
|
||||||
|
}
|
||||||
|
|
||||||
|
private long calculateMicDurationSeconds(long previousRefreshTime, long currentTime) {
|
||||||
|
long deltaSeconds = (currentTime - previousRefreshTime) / 1000;
|
||||||
|
if (deltaSeconds <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return Math.min(deltaSeconds, ActiveSecondConstant.MIC_EXPIRATION_SECOND);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reportEvent(TaskCenterEventRequest request) {
|
||||||
|
if (!enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String normalizedBaseUrl = trimRightSlash(Objects.toString(baseUrl, "").trim());
|
||||||
|
if (normalizedBaseUrl.isEmpty()) {
|
||||||
|
log.warn("Task center go baseUrl is blank, skip event report. eventId={}", request.getEventId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpURLConnection connection = null;
|
||||||
|
try {
|
||||||
|
URL url = new URL(normalizedBaseUrl + "/internal/task-center/event");
|
||||||
|
connection = (HttpURLConnection) url.openConnection();
|
||||||
|
int timeout = Objects.requireNonNullElse(timeoutMillis, 3000);
|
||||||
|
connection.setConnectTimeout(timeout);
|
||||||
|
connection.setReadTimeout(timeout);
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
connection.setRequestProperty("Accept", "application/json");
|
||||||
|
connection.setRequestProperty("X-Internal-Token", Objects.toString(internalToken, ""));
|
||||||
|
|
||||||
|
byte[] body = JSON.toJSONString(request).getBytes(StandardCharsets.UTF_8);
|
||||||
|
try (OutputStream outputStream = connection.getOutputStream()) {
|
||||||
|
outputStream.write(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = connection.getResponseCode();
|
||||||
|
if (status < 200 || status >= 300) {
|
||||||
|
log.warn("Task center go report failed. status={}, body={}, eventId={}",
|
||||||
|
status, readResponse(connection), request.getEventId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Task center go report error. eventId={}", request.getEventId(), e);
|
||||||
|
} finally {
|
||||||
|
if (Objects.nonNull(connection)) {
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String readResponse(HttpURLConnection connection) {
|
||||||
|
try (InputStream inputStream = connection.getErrorStream() != null
|
||||||
|
? connection.getErrorStream()
|
||||||
|
: connection.getInputStream()) {
|
||||||
|
if (Objects.isNull(inputStream)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String trimRightSlash(String value) {
|
||||||
|
while (value.endsWith("/")) {
|
||||||
|
value = value.substring(0, value.length() - 1);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
private static class TaskCenterEventRequest {
|
||||||
|
private String sysOrigin;
|
||||||
|
private String eventId;
|
||||||
|
private String eventType;
|
||||||
|
private Long userId;
|
||||||
|
private Long deltaValue;
|
||||||
|
private String occurredAt;
|
||||||
|
private Map<String, Object> payload;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -17,6 +17,7 @@ import com.red.circle.live.domain.live.dto.LiveMicrophoneDTO;
|
|||||||
import com.red.circle.live.domain.live.dto.LiveMicrophoneNoticeDTO;
|
import com.red.circle.live.domain.live.dto.LiveMicrophoneNoticeDTO;
|
||||||
import com.red.circle.live.domain.online.LiveRoomUser;
|
import com.red.circle.live.domain.online.LiveRoomUser;
|
||||||
import com.red.circle.live.domain.online.LiveRoomUserRefresh;
|
import com.red.circle.live.domain.online.LiveRoomUserRefresh;
|
||||||
|
import com.red.circle.live.infra.client.TaskCenterGoClient;
|
||||||
import com.red.circle.live.infra.database.cache.service.LiveRoomCacheService;
|
import com.red.circle.live.infra.database.cache.service.LiveRoomCacheService;
|
||||||
import com.red.circle.live.infra.repository.dto.RefreshOnlineUserNoticeDTO;
|
import com.red.circle.live.infra.repository.dto.RefreshOnlineUserNoticeDTO;
|
||||||
import com.red.circle.live.infra.repository.dto.RefreshOnlineUserNoticeDTO.RefreshOnlineUserType;
|
import com.red.circle.live.infra.repository.dto.RefreshOnlineUserNoticeDTO.RefreshOnlineUserType;
|
||||||
@ -93,6 +94,7 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
private final UserOnlineClient userOnlineClient;
|
private final UserOnlineClient userOnlineClient;
|
||||||
private final UserCpClient userCpClient;
|
private final UserCpClient userCpClient;
|
||||||
private final LiveRoomCacheService liveRoomCacheService;
|
private final LiveRoomCacheService liveRoomCacheService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
// private final RedissonClient redissonClient;
|
// private final RedissonClient redissonClient;
|
||||||
@Value("${rtc.authKey}")
|
@Value("${rtc.authKey}")
|
||||||
private String authKey;
|
private String authKey;
|
||||||
@ -194,12 +196,15 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
// 下掉已上麦克风
|
// 下掉已上麦克风
|
||||||
List<LiveMicrophone> lives = liveMicCacheService.listLiveMicrophone(roomId, userId);
|
List<LiveMicrophone> lives = liveMicCacheService.listLiveMicrophone(roomId, userId);
|
||||||
if (CollectionUtils.isNotEmpty(lives)) {
|
if (CollectionUtils.isNotEmpty(lives)) {
|
||||||
List<Integer> goDownMicIndex = lives.stream()
|
List<LiveMicrophone> goDownMicrophones = lives.stream()
|
||||||
|
.filter(mic -> !Objects.equals(mic.getMicIndex(), micIndex))
|
||||||
|
.toList();
|
||||||
|
List<Integer> goDownMicIndex = goDownMicrophones.stream()
|
||||||
.map(LiveMicrophone::getMicIndex)
|
.map(LiveMicrophone::getMicIndex)
|
||||||
.filter(index -> !Objects.equals(index, micIndex))
|
|
||||||
.toList();
|
.toList();
|
||||||
if (CollectionUtils.isNotEmpty(goDownMicIndex)) {
|
if (CollectionUtils.isNotEmpty(goDownMicIndex)) {
|
||||||
liveMicCacheService.goDown(roomId, goDownMicIndex);
|
liveMicCacheService.goDown(roomId, goDownMicIndex);
|
||||||
|
reportMicDuration(roomProfile, roomId, goDownMicrophones, "SWITCH_MIC");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +252,10 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
userId
|
userId
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
LiveMicrophone liveMicrophone = liveMicCacheService.getLiveMicrophone(roomId, micIndex);
|
||||||
// 下麦克风
|
// 下麦克风
|
||||||
goDownMic(roomId, micIndex, roomProfile);
|
goDownMic(roomId, micIndex, roomProfile);
|
||||||
|
reportMicDuration(roomProfile, roomId, liveMicrophone, "GO_DOWN");
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
ResponseAssert.isTrue(RoomErrorCode.ROOM_MEMBER_IS_MAX,false);
|
ResponseAssert.isTrue(RoomErrorCode.ROOM_MEMBER_IS_MAX,false);
|
||||||
} finally {
|
} finally {
|
||||||
@ -289,6 +296,7 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
RoomUserRolesEnum.valueOf(liveMicrophone.getUser().getRoles()));
|
RoomUserRolesEnum.valueOf(liveMicrophone.getUser().getRoles()));
|
||||||
|
|
||||||
goDownMic(roomId, micIndex, roomProfile);
|
goDownMic(roomId, micIndex, roomProfile);
|
||||||
|
reportMicDuration(roomProfile, roomId, liveMicrophone, "KILL_MIC");
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
micOpsUnlock(roomId, micIndex);
|
micOpsUnlock(roomId, micIndex);
|
||||||
@ -304,6 +312,36 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
micUserChangeNotice(roomProfile);
|
micUserChangeNotice(roomProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportMicDuration(RoomProfileDTO roomProfile,
|
||||||
|
Long roomId,
|
||||||
|
List<LiveMicrophone> microphones,
|
||||||
|
String source) {
|
||||||
|
if (Objects.isNull(roomProfile) || CollectionUtils.isEmpty(microphones)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
microphones.forEach(microphone -> reportMicDuration(roomProfile, roomId, microphone, source));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reportMicDuration(RoomProfileDTO roomProfile,
|
||||||
|
Long roomId,
|
||||||
|
LiveMicrophone liveMicrophone,
|
||||||
|
String source) {
|
||||||
|
if (Objects.isNull(roomProfile)
|
||||||
|
|| Objects.isNull(liveMicrophone)
|
||||||
|
|| Objects.isNull(liveMicrophone.getUser())
|
||||||
|
|| Objects.isNull(liveMicrophone.getUser().getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
taskCenterGoClient.reportMicDuration(
|
||||||
|
roomProfile.getSysOrigin(),
|
||||||
|
roomId,
|
||||||
|
liveMicrophone.getMicIndex(),
|
||||||
|
liveMicrophone.getUser().getId(),
|
||||||
|
liveMicrophone.getRefreshTime(),
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
source);
|
||||||
|
}
|
||||||
|
|
||||||
private void checkKillMicRoleOpsPermissions(RoomUserRolesEnum reqUserRole,
|
private void checkKillMicRoleOpsPermissions(RoomUserRolesEnum reqUserRole,
|
||||||
RoomUserRolesEnum micUserRole) {
|
RoomUserRolesEnum micUserRole) {
|
||||||
ResponseAssert.isFalse(LiveMicErrorCode.MIC_PERMISSIONS,
|
ResponseAssert.isFalse(LiveMicErrorCode.MIC_PERMISSIONS,
|
||||||
@ -336,8 +374,10 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
ResponseAssert.notNull(LiveMicErrorCode.MIC_INDEX_NOT_FOUND, settingSeat);
|
ResponseAssert.notNull(LiveMicErrorCode.MIC_INDEX_NOT_FOUND, settingSeat);
|
||||||
settingSeat.setMicLock(Objects.equals(lock, Boolean.TRUE));
|
settingSeat.setMicLock(Objects.equals(lock, Boolean.TRUE));
|
||||||
liveMicSettingService.updateMicSeat(roomId, settingSeat);
|
liveMicSettingService.updateMicSeat(roomId, settingSeat);
|
||||||
|
LiveMicrophone liveMicrophone = liveMicCacheService.getLiveMicrophone(roomId, mickIndex);
|
||||||
// 下麦克风
|
// 下麦克风
|
||||||
liveMicCacheService.goDown(roomId, mickIndex);
|
liveMicCacheService.goDown(roomId, mickIndex);
|
||||||
|
reportMicDuration(roomProfile, roomId, liveMicrophone, "MIC_LOCK");
|
||||||
// 清理活跃用户
|
// 清理活跃用户
|
||||||
liveMicCacheService.refreshNotActiveUser(roomId);
|
liveMicCacheService.refreshNotActiveUser(roomId);
|
||||||
// 发送通知
|
// 发送通知
|
||||||
@ -366,15 +406,17 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMickSize(Long roomId, Integer micSize) {
|
public void updateMickSize(Long roomId, Integer micSize) {
|
||||||
|
List<LiveMicrophone> microphones = liveMicCacheService.listLiveMicrophone(roomId);
|
||||||
LiveMicSetting liveMicSetting = liveMicSettingService.updateMicSize(roomId, micSize);
|
LiveMicSetting liveMicSetting = liveMicSettingService.updateMicSize(roomId, micSize);
|
||||||
|
|
||||||
// T下所有麦克风用户
|
// T下所有麦克风用户
|
||||||
if (CollectionUtils.isEmpty(liveMicSetting.getMicSeats())) {
|
if (CollectionUtils.isEmpty(liveMicSetting.getMicSeats())) {
|
||||||
liveMicCacheService.goDownAll(roomId);
|
liveMicCacheService.goDownAll(roomId);
|
||||||
|
reportMicDuration(roomManagerClient.getById(roomId).getBody(), roomId, microphones, "MIC_SIZE_UPDATE");
|
||||||
|
micUserChangeNotice(liveMicSetting);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<LiveMicrophone> microphones = liveMicCacheService.listLiveMicrophone(roomId);
|
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(microphones)) {
|
if (CollectionUtils.isNotEmpty(microphones)) {
|
||||||
|
|
||||||
List<Integer> existsMicIndex = microphones.stream().map(LiveMicrophone::getMicIndex)
|
List<Integer> existsMicIndex = microphones.stream().map(LiveMicrophone::getMicIndex)
|
||||||
@ -387,7 +429,13 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
|||||||
.filter(micIndex -> !thisNewSeats.contains(micIndex))
|
.filter(micIndex -> !thisNewSeats.contains(micIndex))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
liveMicCacheService.goDown(roomId, removeMicIndex);
|
if (CollectionUtils.isNotEmpty(removeMicIndex)) {
|
||||||
|
List<LiveMicrophone> removedMicrophones = microphones.stream()
|
||||||
|
.filter(mic -> removeMicIndex.contains(mic.getMicIndex()))
|
||||||
|
.toList();
|
||||||
|
liveMicCacheService.goDown(roomId, removeMicIndex);
|
||||||
|
reportMicDuration(roomManagerClient.getById(roomId).getBody(), roomId, removedMicrophones, "MIC_SIZE_UPDATE");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
micUserChangeNotice(liveMicSetting);
|
micUserChangeNotice(liveMicSetting);
|
||||||
|
|||||||
@ -0,0 +1,143 @@
|
|||||||
|
package com.red.circle.order.app.common.task;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class TaskCenterGoClient {
|
||||||
|
|
||||||
|
private static final String EVENT_TYPE_RECHARGE_GOLD = "RECHARGE_GOLD";
|
||||||
|
|
||||||
|
@Value("${task.center.go.enabled:true}")
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Value("${task.center.go.base-url:}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
@Value("${task.center.go.internal-token:}")
|
||||||
|
private String internalToken;
|
||||||
|
|
||||||
|
@Value("${task.center.go.timeout-millis:3000}")
|
||||||
|
private Integer timeoutMillis;
|
||||||
|
|
||||||
|
public void reportRechargeGold(String sysOrigin,
|
||||||
|
Long userId,
|
||||||
|
Long purchaseHistoryId,
|
||||||
|
BigDecimal candyQuantity,
|
||||||
|
String platform,
|
||||||
|
String payPlatform,
|
||||||
|
Instant occurredAt) {
|
||||||
|
if (Objects.isNull(userId) || Objects.isNull(purchaseHistoryId) || Objects.isNull(candyQuantity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long deltaValue = candyQuantity.setScale(0, RoundingMode.DOWN).longValue();
|
||||||
|
if (deltaValue <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("purchaseHistoryId", purchaseHistoryId);
|
||||||
|
payload.put("candyQuantity", candyQuantity);
|
||||||
|
payload.put("platform", platform);
|
||||||
|
payload.put("payPlatform", payPlatform);
|
||||||
|
|
||||||
|
reportEvent(new TaskCenterEventRequest()
|
||||||
|
.setSysOrigin(sysOrigin)
|
||||||
|
.setEventId("RECHARGE_GOLD:" + purchaseHistoryId)
|
||||||
|
.setEventType(EVENT_TYPE_RECHARGE_GOLD)
|
||||||
|
.setUserId(userId)
|
||||||
|
.setDeltaValue(deltaValue)
|
||||||
|
.setOccurredAt(Objects.requireNonNullElse(occurredAt, Instant.now()).toString())
|
||||||
|
.setPayload(payload));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reportEvent(TaskCenterEventRequest request) {
|
||||||
|
if (!enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String normalizedBaseUrl = trimRightSlash(Objects.toString(baseUrl, "").trim());
|
||||||
|
if (normalizedBaseUrl.isEmpty()) {
|
||||||
|
log.warn("Task center go baseUrl is blank, skip event report. eventId={}", request.getEventId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpURLConnection connection = null;
|
||||||
|
try {
|
||||||
|
URL url = new URL(normalizedBaseUrl + "/internal/task-center/event");
|
||||||
|
connection = (HttpURLConnection) url.openConnection();
|
||||||
|
int timeout = Objects.requireNonNullElse(timeoutMillis, 3000);
|
||||||
|
connection.setConnectTimeout(timeout);
|
||||||
|
connection.setReadTimeout(timeout);
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
connection.setRequestProperty("Accept", "application/json");
|
||||||
|
connection.setRequestProperty("X-Internal-Token", Objects.toString(internalToken, ""));
|
||||||
|
|
||||||
|
byte[] body = JSON.toJSONString(request).getBytes(StandardCharsets.UTF_8);
|
||||||
|
try (OutputStream outputStream = connection.getOutputStream()) {
|
||||||
|
outputStream.write(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = connection.getResponseCode();
|
||||||
|
if (status < 200 || status >= 300) {
|
||||||
|
log.warn("Task center go report failed. status={}, body={}, eventId={}",
|
||||||
|
status, readResponse(connection), request.getEventId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Task center go report error. eventId={}", request.getEventId(), e);
|
||||||
|
} finally {
|
||||||
|
if (Objects.nonNull(connection)) {
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String readResponse(HttpURLConnection connection) {
|
||||||
|
try (InputStream inputStream = connection.getErrorStream() != null
|
||||||
|
? connection.getErrorStream()
|
||||||
|
: connection.getInputStream()) {
|
||||||
|
if (Objects.isNull(inputStream)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String trimRightSlash(String value) {
|
||||||
|
while (value.endsWith("/")) {
|
||||||
|
value = value.substring(0, value.length() - 1);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
private static class TaskCenterEventRequest {
|
||||||
|
private String sysOrigin;
|
||||||
|
private String eventId;
|
||||||
|
private String eventType;
|
||||||
|
private Long userId;
|
||||||
|
private Long deltaValue;
|
||||||
|
private String occurredAt;
|
||||||
|
private Map<String, Object> payload;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -17,6 +17,7 @@ import com.red.circle.framework.dto.ResultResponse;
|
|||||||
import com.red.circle.mq.business.model.event.pay.BuySuccessEvent;
|
import com.red.circle.mq.business.model.event.pay.BuySuccessEvent;
|
||||||
import com.red.circle.mq.business.model.event.pay.PurchaseProductEvent;
|
import com.red.circle.mq.business.model.event.pay.PurchaseProductEvent;
|
||||||
import com.red.circle.mq.rocket.business.streams.BuySuccessSink;
|
import com.red.circle.mq.rocket.business.streams.BuySuccessSink;
|
||||||
|
import com.red.circle.order.app.common.task.TaskCenterGoClient;
|
||||||
import com.red.circle.other.inner.endpoint.activity.CumulativeRechargeClient;
|
import com.red.circle.other.inner.endpoint.activity.CumulativeRechargeClient;
|
||||||
import com.red.circle.other.inner.endpoint.activity.PropsActivityClient;
|
import com.red.circle.other.inner.endpoint.activity.PropsActivityClient;
|
||||||
import com.red.circle.other.inner.endpoint.sys.EnumConfigClient;
|
import com.red.circle.other.inner.endpoint.sys.EnumConfigClient;
|
||||||
@ -69,6 +70,7 @@ public class BuySuccessListener implements MessageListener {
|
|||||||
private final UserOneTimeTaskClient userOneTimeTaskClient;
|
private final UserOneTimeTaskClient userOneTimeTaskClient;
|
||||||
private final CumulativeRechargeClient cumulativeRechargeClient;
|
private final CumulativeRechargeClient cumulativeRechargeClient;
|
||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Action consume(ConsumerMessage message) {
|
public Action consume(ConsumerMessage message) {
|
||||||
@ -124,6 +126,14 @@ public class BuySuccessListener implements MessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taskCenterGoClient.reportRechargeGold(eventBody.getSysOrigin(),
|
||||||
|
eventBody.getUserId(),
|
||||||
|
eventBody.getPurchaseHistoryId(),
|
||||||
|
eventBody.getCandyQuantity(),
|
||||||
|
eventBody.getPlatform(),
|
||||||
|
eventBody.getPayPlatform(),
|
||||||
|
Objects.nonNull(eventBody.getBuyDateTime()) ? eventBody.getBuyDateTime().toInstant() : null);
|
||||||
|
|
||||||
userExpandClient.updatePurchasingToTrue(eventBody.getUserId());
|
userExpandClient.updatePurchasingToTrue(eventBody.getUserId());
|
||||||
|
|
||||||
//累计今日充值,每日累计充值抽奖活动
|
//累计今日充值,每日累计充值抽奖活动
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import com.red.circle.framework.web.annotation.IgnoreResultResponse;
|
|||||||
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
||||||
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
||||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
|
import com.red.circle.other.app.common.task.TaskCenterGoClient;
|
||||||
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.game.GameLxwlUpdateBalanceCmd;
|
import com.red.circle.other.app.dto.cmd.game.GameLxwlUpdateBalanceCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.game.GameLxwlUserInfoCmd;
|
import com.red.circle.other.app.dto.cmd.game.GameLxwlUserInfoCmd;
|
||||||
@ -50,6 +51,7 @@ import com.red.circle.tool.core.text.StringUtils;
|
|||||||
import com.red.circle.tool.crypto.SecurityUtils;
|
import com.red.circle.tool.crypto.SecurityUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -89,6 +91,7 @@ public class GameHkysRestController {
|
|||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
private final ActivityRechargeTicketService activityRechargeTicketService;
|
private final ActivityRechargeTicketService activityRechargeTicketService;
|
||||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
|
|
||||||
@IgnoreResultResponse
|
@IgnoreResultResponse
|
||||||
@PostMapping("/getUserInfo")
|
@PostMapping("/getUserInfo")
|
||||||
@ -196,6 +199,9 @@ public class GameHkysRestController {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
updateRoomDailyTask(cmd.getCoin(), userId);
|
updateRoomDailyTask(cmd.getCoin(), userId);
|
||||||
|
reportTaskCenterGameEvents(sysOrigin, userId, "LINGXIAN", cmd.getOrderId(),
|
||||||
|
Math.abs(cmd.getCoin()), gameTaskPayload("LINGXIAN", cmd.getOrderId(), cmd.getGameId(),
|
||||||
|
cmd.getRoundId(), cmd.getRoomId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -217,6 +223,25 @@ public class GameHkysRestController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportTaskCenterGameEvents(String sysOrigin,
|
||||||
|
Long userId,
|
||||||
|
String provider,
|
||||||
|
String orderId,
|
||||||
|
Long consumeGold,
|
||||||
|
Map<String, Object> payload) {
|
||||||
|
taskCenterGoClient.reportGameConsumeGold(sysOrigin, userId, provider, orderId, consumeGold, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> gameTaskPayload(String provider, String orderId, String gameId, String roundId, String roomId) {
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("provider", provider);
|
||||||
|
payload.put("orderId", orderId);
|
||||||
|
payload.put("gameId", gameId);
|
||||||
|
payload.put("roundId", roundId);
|
||||||
|
payload.put("roomId", roomId);
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
private void incGameRankingRecord(GameLxwlUpdateBalanceCmd request, GameListConfig gameListConfig) {
|
private void incGameRankingRecord(GameLxwlUpdateBalanceCmd request, GameListConfig gameListConfig) {
|
||||||
if (request.getType() != 2 || gameListConfig == null || request.getCoin() <= 0) {
|
if (request.getType() != 2 || gameListConfig == null || request.getCoin() <= 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.red.circle.other.app.command.game.ludo;
|
|||||||
|
|
||||||
|
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
|
import com.red.circle.other.app.common.task.TaskCenterGoClient;
|
||||||
import com.red.circle.other.app.common.game.GameTurntableCommon;
|
import com.red.circle.other.app.common.game.GameTurntableCommon;
|
||||||
import com.red.circle.other.app.dto.cmd.game.GameTurntableGameIdCmd;
|
import com.red.circle.other.app.dto.cmd.game.GameTurntableGameIdCmd;
|
||||||
import com.red.circle.other.infra.database.cache.key.GameListKeys;
|
import com.red.circle.other.infra.database.cache.key.GameListKeys;
|
||||||
@ -15,6 +16,8 @@ import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd;
|
|||||||
import com.red.circle.wallet.inner.model.dto.WalletReceiptDTO;
|
import com.red.circle.wallet.inner.model.dto.WalletReceiptDTO;
|
||||||
import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
|
import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
|
||||||
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -33,6 +36,7 @@ public class GameJoinCmdExe {
|
|||||||
private final WalletGoldClient walletGoldClient;
|
private final WalletGoldClient walletGoldClient;
|
||||||
private final GameTurntableCommon gameTurntableCommon;
|
private final GameTurntableCommon gameTurntableCommon;
|
||||||
private final RoomTurntableGameMongoService roomTurntableGameMongoService;
|
private final RoomTurntableGameMongoService roomTurntableGameMongoService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加入游戏.
|
* 加入游戏.
|
||||||
@ -70,6 +74,7 @@ public class GameJoinCmdExe {
|
|||||||
ResponseAssert.isTrue(RoomErrorCode.GAME_THE_NUMBER_FULL,
|
ResponseAssert.isTrue(RoomErrorCode.GAME_THE_NUMBER_FULL,
|
||||||
getJoinQuantity(cmd.getGameId()) <= 12);
|
getJoinQuantity(cmd.getGameId()) <= 12);
|
||||||
gameTurntableCommon.join(cmd.getReqUserId(), roomTurntableGame);
|
gameTurntableCommon.join(cmd.getReqUserId(), roomTurntableGame);
|
||||||
|
reportTaskCenterGameEvents(cmd, roomTurntableGame);
|
||||||
WalletReceiptDTO walletReceiptDTO = new WalletReceiptDTO();
|
WalletReceiptDTO walletReceiptDTO = new WalletReceiptDTO();
|
||||||
walletReceiptDTO.setBalance(walletReceipt.getBalance().getDollarAmount());
|
walletReceiptDTO.setBalance(walletReceipt.getBalance().getDollarAmount());
|
||||||
walletReceiptDTO.setProcessAmount(walletReceipt.getOpAmount().getDollarAmount());
|
walletReceiptDTO.setProcessAmount(walletReceipt.getOpAmount().getDollarAmount());
|
||||||
@ -88,4 +93,15 @@ public class GameJoinCmdExe {
|
|||||||
return GameListKeys.getKey("TGAME_JOINED:" + gameId, String.valueOf(userId));
|
return GameListKeys.getKey("TGAME_JOINED:" + gameId, String.valueOf(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportTaskCenterGameEvents(GameTurntableGameIdCmd cmd, RoomTurntableGame roomTurntableGame) {
|
||||||
|
Long consumeGold = roomTurntableGame.getGameGolds().longValue();
|
||||||
|
String orderId = roomTurntableGame.getGameId() + ":" + cmd.getReqUserId();
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("provider", "TURNTABLE");
|
||||||
|
payload.put("gameId", roomTurntableGame.getGameId());
|
||||||
|
payload.put("roomId", roomTurntableGame.getRoomId());
|
||||||
|
taskCenterGoClient.reportGameConsumeGold(cmd.requireReqSysOrigin(), cmd.getReqUserId(),
|
||||||
|
"TURNTABLE", orderId, consumeGold, payload);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.red.circle.other.app.command.game.ludo;
|
package com.red.circle.other.app.command.game.ludo;
|
||||||
|
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
|
import com.red.circle.other.app.common.task.TaskCenterGoClient;
|
||||||
import com.red.circle.other.app.convertor.game.GameLudoAppConvertor;
|
import com.red.circle.other.app.convertor.game.GameLudoAppConvertor;
|
||||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
import com.red.circle.other.app.dto.cmd.game.GameLudoJoinCmd;
|
import com.red.circle.other.app.dto.cmd.game.GameLudoJoinCmd;
|
||||||
@ -20,6 +21,8 @@ import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
|
|||||||
import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd;
|
import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd;
|
||||||
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -39,6 +42,7 @@ public class GameLudoJoinCmdExe {
|
|||||||
private final GameLudoRunService gameLudoRunService;
|
private final GameLudoRunService gameLudoRunService;
|
||||||
private final GameLudoAppConvertor gameLudoAppConvertor;
|
private final GameLudoAppConvertor gameLudoAppConvertor;
|
||||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
|
|
||||||
public void execute(GameLudoJoinCmd cmd) {
|
public void execute(GameLudoJoinCmd cmd) {
|
||||||
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
|
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
|
||||||
@ -72,6 +76,7 @@ public class GameLudoJoinCmdExe {
|
|||||||
);
|
);
|
||||||
gameLudoRunService.resetPlayers(gameLudoRun.getId(), gameLudoRun.getPlayers());
|
gameLudoRunService.resetPlayers(gameLudoRun.getId(), gameLudoRun.getPlayers());
|
||||||
gameCacheService.setJoinGameLudo(gameLudoRun.getId(), cmd.getPlayerUserId());
|
gameCacheService.setJoinGameLudo(gameLudoRun.getId(), cmd.getPlayerUserId());
|
||||||
|
reportTaskCenterGameEvents(cmd, gameLudoRun, consumeAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal executeConsumeAmount(GameLudoJoinCmd cmd, BigDecimal amount) {
|
private BigDecimal executeConsumeAmount(GameLudoJoinCmd cmd, BigDecimal amount) {
|
||||||
@ -88,4 +93,14 @@ public class GameLudoJoinCmdExe {
|
|||||||
.build())
|
.build())
|
||||||
).getBalance().getDollarAmount();
|
).getBalance().getDollarAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportTaskCenterGameEvents(GameLudoJoinCmd cmd, GameLudoRun gameLudoRun, BigDecimal consumeAmount) {
|
||||||
|
String orderId = gameLudoRun.getId() + ":" + cmd.getPlayerUserId();
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("provider", "LUDO");
|
||||||
|
payload.put("gameId", gameLudoRun.getId());
|
||||||
|
payload.put("roomId", gameLudoRun.getRoomId());
|
||||||
|
taskCenterGoClient.reportGameConsumeGold(cmd.requireReqSysOrigin(), cmd.getPlayerUserId(),
|
||||||
|
"LUDO", orderId, consumeAmount.longValue(), payload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,89 @@
|
|||||||
|
package com.red.circle.other.app.common.gift;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class VoiceRoomRegionBroadcastGoClient {
|
||||||
|
|
||||||
|
@Value("${voice-room.region-broadcast.go.enabled:true}")
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Value("${voice-room.region-broadcast.go.base-url:}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
@Value("${voice-room.region-broadcast.go.internal-token:}")
|
||||||
|
private String internalToken;
|
||||||
|
|
||||||
|
@Value("${voice-room.region-broadcast.go.timeout-millis:3000}")
|
||||||
|
private Integer timeoutMillis;
|
||||||
|
|
||||||
|
public boolean send(RegionBroadcastRequest request) {
|
||||||
|
if (!enabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String normalizedBaseUrl = trimRightSlash(Objects.toString(baseUrl, "").trim());
|
||||||
|
if (normalizedBaseUrl.isEmpty()) {
|
||||||
|
log.warn("Voice room region broadcast go baseUrl is blank, skip broadcast. type={}, senderUserId={}",
|
||||||
|
request.getType(), request.getSenderUserId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (HttpResponse response = HttpUtil.createPost(normalizedBaseUrl
|
||||||
|
+ "/internal/voice-room/region-broadcast")
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.header("Accept", "application/json")
|
||||||
|
.header("X-Internal-Token", Objects.toString(internalToken, ""))
|
||||||
|
.timeout(Objects.requireNonNullElse(timeoutMillis, 3000))
|
||||||
|
.body(JSON.toJSONString(request))
|
||||||
|
.execute()) {
|
||||||
|
String responseBody = response.body();
|
||||||
|
if (response.getStatus() < 200 || response.getStatus() >= 300) {
|
||||||
|
log.warn("Voice room region broadcast go http failed. status={}, body={}, type={}, senderUserId={}",
|
||||||
|
response.getStatus(), responseBody, request.getType(), request.getSenderUserId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (responseBody == null || responseBody.trim().isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
JSONObject root = JSON.parseObject(responseBody);
|
||||||
|
if (root != null && root.containsKey("status") && !root.getBooleanValue("status")) {
|
||||||
|
log.warn("Voice room region broadcast go business failed. body={}, type={}, senderUserId={}",
|
||||||
|
responseBody, request.getType(), request.getSenderUserId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Voice room region broadcast go error. type={}, senderUserId={}",
|
||||||
|
request.getType(), request.getSenderUserId(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String trimRightSlash(String value) {
|
||||||
|
while (value.endsWith("/")) {
|
||||||
|
value = value.substring(0, value.length() - 1);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public static class RegionBroadcastRequest {
|
||||||
|
private String sysOrigin;
|
||||||
|
private String regionCode;
|
||||||
|
private Long senderUserId;
|
||||||
|
private String type;
|
||||||
|
private Object data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.red.circle.other.app.common.task;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class TaskCenterGoClient {
|
||||||
|
|
||||||
|
private static final String EVENT_TYPE_GAME_CONSUME_GOLD = "GAME_CONSUME_GOLD";
|
||||||
|
|
||||||
|
@Value("${task.center.go.enabled:true}")
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Value("${task.center.go.base-url:}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
@Value("${task.center.go.internal-token:}")
|
||||||
|
private String internalToken;
|
||||||
|
|
||||||
|
@Value("${task.center.go.timeout-millis:3000}")
|
||||||
|
private Integer timeoutMillis;
|
||||||
|
|
||||||
|
public void reportGameConsumeGold(String sysOrigin,
|
||||||
|
Long userId,
|
||||||
|
String provider,
|
||||||
|
String orderId,
|
||||||
|
Long deltaGold,
|
||||||
|
Map<String, Object> payload) {
|
||||||
|
if (Objects.isNull(userId) || Objects.isNull(deltaGold) || deltaGold <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String eventId = "GAME_CONSUME:" + Objects.toString(provider, "UNKNOWN") + ":"
|
||||||
|
+ Objects.toString(orderId, "");
|
||||||
|
reportEvent(new TaskCenterEventRequest()
|
||||||
|
.setSysOrigin(sysOrigin)
|
||||||
|
.setEventId(eventId)
|
||||||
|
.setEventType(EVENT_TYPE_GAME_CONSUME_GOLD)
|
||||||
|
.setUserId(userId)
|
||||||
|
.setDeltaValue(deltaGold)
|
||||||
|
.setOccurredAt(Instant.now().toString())
|
||||||
|
.setPayload(payload));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reportEvent(TaskCenterEventRequest request) {
|
||||||
|
if (!enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String normalizedBaseUrl = trimRightSlash(Objects.toString(baseUrl, "").trim());
|
||||||
|
if (normalizedBaseUrl.isEmpty()) {
|
||||||
|
log.warn("Task center go baseUrl is blank, skip event report. eventId={}", request.getEventId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (HttpResponse response = HttpUtil.createPost(normalizedBaseUrl + "/internal/task-center/event")
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.header("Accept", "application/json")
|
||||||
|
.header("X-Internal-Token", Objects.toString(internalToken, ""))
|
||||||
|
.timeout(Objects.requireNonNullElse(timeoutMillis, 3000))
|
||||||
|
.body(JSON.toJSONString(request))
|
||||||
|
.execute()) {
|
||||||
|
if (response.getStatus() < 200 || response.getStatus() >= 300) {
|
||||||
|
log.warn("Task center go report failed. status={}, body={}, eventId={}",
|
||||||
|
response.getStatus(), response.body(), request.getEventId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Task center go report error. eventId={}", request.getEventId(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String trimRightSlash(String value) {
|
||||||
|
while (value.endsWith("/")) {
|
||||||
|
value = value.substring(0, value.length() - 1);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
private static class TaskCenterEventRequest {
|
||||||
|
private String sysOrigin;
|
||||||
|
private String eventId;
|
||||||
|
private String eventType;
|
||||||
|
private Long userId;
|
||||||
|
private Long deltaValue;
|
||||||
|
private String occurredAt;
|
||||||
|
private Map<String, Object> payload;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,6 +33,7 @@ import com.red.circle.other.app.command.game.burstcrystal.GameBurstCrystalSchedu
|
|||||||
import com.red.circle.other.app.command.game.roompk.GameRoomPkUserCmdExe;
|
import com.red.circle.other.app.command.game.roompk.GameRoomPkUserCmdExe;
|
||||||
import com.red.circle.other.app.command.game.teampk.GameTeamPkBaseInfoCmdExe;
|
import com.red.circle.other.app.command.game.teampk.GameTeamPkBaseInfoCmdExe;
|
||||||
import com.red.circle.other.app.common.gift.GameLuckyGiftCommon;
|
import com.red.circle.other.app.common.gift.GameLuckyGiftCommon;
|
||||||
|
import com.red.circle.other.app.common.gift.VoiceRoomRegionBroadcastGoClient;
|
||||||
import com.red.circle.other.app.dto.clientobject.game.*;
|
import com.red.circle.other.app.dto.clientobject.game.*;
|
||||||
import com.red.circle.other.app.dto.clientobject.gift.SendGiftNotifyCO;
|
import com.red.circle.other.app.dto.clientobject.gift.SendGiftNotifyCO;
|
||||||
import com.red.circle.other.app.dto.cmd.game.barrage.GameUserEffectsCmd;
|
import com.red.circle.other.app.dto.cmd.game.barrage.GameUserEffectsCmd;
|
||||||
@ -93,6 +94,7 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
private final UserRegionGateway userRegionGateway;
|
private final UserRegionGateway userRegionGateway;
|
||||||
private final MessageEventProcess messageEventProcess;
|
private final MessageEventProcess messageEventProcess;
|
||||||
private final GameLuckyGiftCommon gameLuckyGiftCommon;
|
private final GameLuckyGiftCommon gameLuckyGiftCommon;
|
||||||
|
private final VoiceRoomRegionBroadcastGoClient voiceRoomRegionBroadcastGoClient;
|
||||||
private final TeamBillCycleService teamBillCycleService;
|
private final TeamBillCycleService teamBillCycleService;
|
||||||
private final TeamPolicyManagerService teamPolicyManagerService;
|
private final TeamPolicyManagerService teamPolicyManagerService;
|
||||||
private final EnumConfigCacheService enumConfigCacheService;
|
private final EnumConfigCacheService enumConfigCacheService;
|
||||||
@ -418,7 +420,12 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String special = event.getGiftConfig().getSpecial();
|
String special = event.getGiftConfig().getSpecial();
|
||||||
if (StringUtils.isBlank(special) || !special.contains(GiftSpecialEnum.NOTICE.name())) {
|
if (StringUtils.isBlank(special)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean noticeGift = special.contains(GiftSpecialEnum.NOTICE.name());
|
||||||
|
boolean globalGift = special.contains(GiftSpecialEnum.GLOBAL_GIFT.name());
|
||||||
|
if (!noticeGift && !globalGift) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,15 +449,30 @@ public class GiveGiftsListener implements MessageListener {
|
|||||||
.setActualAmount(runningWater.getGiftValue().getActualAmount())
|
.setActualAmount(runningWater.getGiftValue().getActualAmount())
|
||||||
.setGiftType(runningWater.getGiftValue().getGiftType());
|
.setGiftType(runningWater.getGiftValue().getGiftType());
|
||||||
|
|
||||||
imGroupClient.sendMessageBroadcast(
|
if (globalGift) {
|
||||||
BroadcastGroupMsgBodyCmd.builder()
|
boolean success = voiceRoomRegionBroadcastGoClient.send(
|
||||||
.toPlatform(event.getSysOrigin())
|
new VoiceRoomRegionBroadcastGoClient.RegionBroadcastRequest()
|
||||||
.type(GroupMessageTypeEnum.SEND_GIFT)
|
.setSysOrigin(event.getSysOrigin().name())
|
||||||
.data(notify)
|
.setSenderUserId(event.getSendUserId())
|
||||||
.build()
|
.setType(GroupMessageTypeEnum.SEND_GIFT.name())
|
||||||
);
|
.setData(notify)
|
||||||
log.warn("NOTICE礼物全服通报成功, trackId={}, giftId={}, sendUserId={}",
|
);
|
||||||
event.getTrackId(), event.getGiftConfig().getId(), event.getSendUserId());
|
log.warn("GLOBAL_GIFT礼物区域广播{}, trackId={}, giftId={}, sendUserId={}",
|
||||||
|
success ? "成功" : "失败", event.getTrackId(), event.getGiftConfig().getId(),
|
||||||
|
event.getSendUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noticeGift) {
|
||||||
|
imGroupClient.sendMessageBroadcast(
|
||||||
|
BroadcastGroupMsgBodyCmd.builder()
|
||||||
|
.toPlatform(event.getSysOrigin())
|
||||||
|
.type(GroupMessageTypeEnum.SEND_GIFT)
|
||||||
|
.data(notify)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
log.warn("NOTICE礼物全服通报成功, trackId={}, giftId={}, sendUserId={}",
|
||||||
|
event.getTrackId(), event.getGiftConfig().getId(), event.getSendUserId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<GiftGiveRunningWater,Boolean> saveRunningWater(GiveAwayGiftBatchEvent event) {
|
private Pair<GiftGiveRunningWater,Boolean> saveRunningWater(GiveAwayGiftBatchEvent event) {
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import com.red.circle.framework.core.security.UserCredential;
|
|||||||
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
|
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
|
||||||
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
||||||
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
||||||
|
import com.red.circle.other.app.common.task.TaskCenterGoClient;
|
||||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
|
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
|
||||||
@ -57,6 +58,7 @@ import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd.GoldReceiptCmdBuilde
|
|||||||
import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
|
import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
|
||||||
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -92,6 +94,7 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
private final GameActivityService gameActivityService;
|
private final GameActivityService gameActivityService;
|
||||||
private final ActivityRechargeTicketService activityRechargeTicketService;
|
private final ActivityRechargeTicketService activityRechargeTicketService;
|
||||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
@Value("${red-circle.game-rank.gameid}")
|
@Value("${red-circle.game-rank.gameid}")
|
||||||
private String gameId;
|
private String gameId;
|
||||||
|
|
||||||
@ -229,6 +232,9 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
// activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, request.getCurrencyDiff(), MonthlyRechargeType.UNDEFINED);
|
// activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, request.getCurrencyDiff(), MonthlyRechargeType.UNDEFINED);
|
||||||
} else {
|
} else {
|
||||||
updateRoomDailyTask(request.getCurrencyDiff(), userId);
|
updateRoomDailyTask(request.getCurrencyDiff(), userId);
|
||||||
|
reportTaskCenterGameEvents(sysOrigin, userId, "BAISHUN_LEGACY", request.getOrderId(),
|
||||||
|
Math.abs(request.getCurrencyDiff()), gameTaskPayload("BAISHUN_LEGACY",
|
||||||
|
request.getOrderId(), request.getGameId(), request.getGameRoundId(), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +273,25 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportTaskCenterGameEvents(String sysOrigin,
|
||||||
|
Long userId,
|
||||||
|
String provider,
|
||||||
|
String orderId,
|
||||||
|
Long consumeGold,
|
||||||
|
Map<String, Object> payload) {
|
||||||
|
taskCenterGoClient.reportGameConsumeGold(sysOrigin, userId, provider, orderId, consumeGold, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> gameTaskPayload(String provider, String orderId, String gameId, String roundId, String roomId) {
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("provider", provider);
|
||||||
|
payload.put("orderId", orderId);
|
||||||
|
payload.put("gameId", gameId);
|
||||||
|
payload.put("roundId", roundId);
|
||||||
|
payload.put("roomId", roomId);
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
private void sendBroadcast(BaishunChangeCurrencyRequest request, GameListConfig gameListConfig) {
|
private void sendBroadcast(BaishunChangeCurrencyRequest request, GameListConfig gameListConfig) {
|
||||||
if (gameListConfig == null) {
|
if (gameListConfig == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import com.red.circle.framework.core.exception.ResponseException;
|
|||||||
import com.red.circle.framework.core.security.UserCredential;
|
import com.red.circle.framework.core.security.UserCredential;
|
||||||
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
||||||
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
||||||
|
import com.red.circle.other.app.common.task.TaskCenterGoClient;
|
||||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
|
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
|
||||||
@ -96,6 +97,7 @@ public class HotGameServiceImpl implements HotGameService {
|
|||||||
private final GameVipLevelWeeklyService gameVipLevelWeeklyService;
|
private final GameVipLevelWeeklyService gameVipLevelWeeklyService;
|
||||||
private final ActivityRechargeTicketService activityRechargeTicketService;
|
private final ActivityRechargeTicketService activityRechargeTicketService;
|
||||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
|
|
||||||
@Value("${red-circle.game-rank.gameid}")
|
@Value("${red-circle.game-rank.gameid}")
|
||||||
private String gameId;
|
private String gameId;
|
||||||
@ -341,6 +343,9 @@ public class HotGameServiceImpl implements HotGameService {
|
|||||||
// 处理游戏消费人任务
|
// 处理游戏消费人任务
|
||||||
else {
|
else {
|
||||||
updateRoomDailyTask(param.getCoin(), userId);
|
updateRoomDailyTask(param.getCoin(), userId);
|
||||||
|
reportTaskCenterGameEvents(sysOrigin, userId, "HOTGAME", param.getOrderId(),
|
||||||
|
Math.abs(param.getCoin()), gameTaskPayload("HOTGAME", param.getOrderId(),
|
||||||
|
param.getGameId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HotGameResponse<HotGameCoin>()
|
return new HotGameResponse<HotGameCoin>()
|
||||||
@ -376,6 +381,23 @@ public class HotGameServiceImpl implements HotGameService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportTaskCenterGameEvents(String sysOrigin,
|
||||||
|
Long userId,
|
||||||
|
String provider,
|
||||||
|
String orderId,
|
||||||
|
Long consumeGold,
|
||||||
|
Map<String, Object> payload) {
|
||||||
|
taskCenterGoClient.reportGameConsumeGold(sysOrigin, userId, provider, orderId, consumeGold, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> gameTaskPayload(String provider, String orderId, String gameId) {
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("provider", provider);
|
||||||
|
payload.put("orderId", orderId);
|
||||||
|
payload.put("gameId", gameId);
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
private void incGameRankingTmpActivity(HotGameUserCoinUpdate request) {
|
private void incGameRankingTmpActivity(HotGameUserCoinUpdate request) {
|
||||||
if (ZonedDateTimeAsiaRiyadhUtils.now().isAfter(getFinishTime())) {
|
if (ZonedDateTimeAsiaRiyadhUtils.now().isAfter(getFinishTime())) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.red.circle.framework.core.dto.ReqSysOrigin;
|
|||||||
import com.red.circle.framework.core.security.UserCredential;
|
import com.red.circle.framework.core.security.UserCredential;
|
||||||
import com.red.circle.framework.dto.ResultResponse;
|
import com.red.circle.framework.dto.ResultResponse;
|
||||||
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
||||||
|
import com.red.circle.other.app.common.task.TaskCenterGoClient;
|
||||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.party3rd.*;
|
import com.red.circle.other.app.dto.cmd.party3rd.*;
|
||||||
@ -76,6 +77,7 @@ public class YomiGameServiceImpl implements YomiGameService {
|
|||||||
private final ActivityRechargeTicketService activityRechargeTicketService;
|
private final ActivityRechargeTicketService activityRechargeTicketService;
|
||||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
|
private final TaskCenterGoClient taskCenterGoClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YomiTokenCO getToken(YomiGetTokenCmd cmd) {
|
public YomiTokenCO getToken(YomiGetTokenCmd cmd) {
|
||||||
@ -188,6 +190,9 @@ public class YomiGameServiceImpl implements YomiGameService {
|
|||||||
// activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, Math.abs(changeValue.longValue()), MonthlyRechargeType.UNDEFINED);
|
// activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, Math.abs(changeValue.longValue()), MonthlyRechargeType.UNDEFINED);
|
||||||
} else {
|
} else {
|
||||||
updateRoomDailyTask(changeValue.longValue(), userId);
|
updateRoomDailyTask(changeValue.longValue(), userId);
|
||||||
|
reportTaskCenterGameEvents(sysOrigin, userId, "YOMI", cmd.getRecordId(),
|
||||||
|
Math.abs(changeValue.longValue()), gameTaskPayload("YOMI", cmd.getRecordId(),
|
||||||
|
cmd.getGameId(), cmd.getRoundId(), cmd.getRoomId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new YomiBalanceCO(currentBalance);
|
return new YomiBalanceCO(currentBalance);
|
||||||
@ -212,6 +217,25 @@ public class YomiGameServiceImpl implements YomiGameService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportTaskCenterGameEvents(String sysOrigin,
|
||||||
|
Long userId,
|
||||||
|
String provider,
|
||||||
|
String orderId,
|
||||||
|
Long consumeGold,
|
||||||
|
Map<String, Object> payload) {
|
||||||
|
taskCenterGoClient.reportGameConsumeGold(sysOrigin, userId, provider, orderId, consumeGold, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> gameTaskPayload(String provider, String orderId, String gameId, String roundId, String roomId) {
|
||||||
|
Map<String, Object> payload = new HashMap<>();
|
||||||
|
payload.put("provider", provider);
|
||||||
|
payload.put("orderId", orderId);
|
||||||
|
payload.put("gameId", gameId);
|
||||||
|
payload.put("roundId", roundId);
|
||||||
|
payload.put("roomId", roomId);
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isConsume(YomiChangeBalanceCmd cmd) {
|
private static boolean isConsume(YomiChangeBalanceCmd cmd) {
|
||||||
return "bet".equals(cmd.getChangeCause());
|
return "bet".equals(cmd.getChangeCause());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import com.red.circle.other.app.command.game.burstcrystal.GameBurstCrystalSchedu
|
|||||||
import com.red.circle.other.app.command.game.roompk.GameRoomPkUserCmdExe;
|
import com.red.circle.other.app.command.game.roompk.GameRoomPkUserCmdExe;
|
||||||
import com.red.circle.other.app.command.game.teampk.GameTeamPkBaseInfoCmdExe;
|
import com.red.circle.other.app.command.game.teampk.GameTeamPkBaseInfoCmdExe;
|
||||||
import com.red.circle.other.app.common.gift.GameLuckyGiftCommon;
|
import com.red.circle.other.app.common.gift.GameLuckyGiftCommon;
|
||||||
|
import com.red.circle.other.app.common.gift.VoiceRoomRegionBroadcastGoClient;
|
||||||
import com.red.circle.other.app.dto.clientobject.gift.SendGiftNotifyCO;
|
import com.red.circle.other.app.dto.clientobject.gift.SendGiftNotifyCO;
|
||||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||||
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
||||||
@ -45,6 +46,8 @@ import org.mockito.ArgumentCaptor;
|
|||||||
class GiveGiftsListenerTest {
|
class GiveGiftsListenerTest {
|
||||||
|
|
||||||
private final ImGroupClient imGroupClient = mock(ImGroupClient.class);
|
private final ImGroupClient imGroupClient = mock(ImGroupClient.class);
|
||||||
|
private final VoiceRoomRegionBroadcastGoClient voiceRoomRegionBroadcastGoClient = mock(
|
||||||
|
VoiceRoomRegionBroadcastGoClient.class);
|
||||||
private final RoomProfileManagerService roomProfileManagerService = mock(
|
private final RoomProfileManagerService roomProfileManagerService = mock(
|
||||||
RoomProfileManagerService.class);
|
RoomProfileManagerService.class);
|
||||||
private final GiveGiftsListener listener = new GiveGiftsListener(
|
private final GiveGiftsListener listener = new GiveGiftsListener(
|
||||||
@ -54,6 +57,7 @@ class GiveGiftsListenerTest {
|
|||||||
mock(UserRegionGateway.class),
|
mock(UserRegionGateway.class),
|
||||||
mock(MessageEventProcess.class),
|
mock(MessageEventProcess.class),
|
||||||
mock(GameLuckyGiftCommon.class),
|
mock(GameLuckyGiftCommon.class),
|
||||||
|
voiceRoomRegionBroadcastGoClient,
|
||||||
mock(TeamBillCycleService.class),
|
mock(TeamBillCycleService.class),
|
||||||
mock(TeamPolicyManagerService.class),
|
mock(TeamPolicyManagerService.class),
|
||||||
mock(EnumConfigCacheService.class),
|
mock(EnumConfigCacheService.class),
|
||||||
@ -101,11 +105,35 @@ class GiveGiftsListenerTest {
|
|||||||
assertEquals("NORMAL", data.getGiftType());
|
assertEquals("NORMAL", data.getGiftType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sendNoticeGiftBroadcastShouldSendGlobalGiftToRegionBroadcastGo() {
|
||||||
|
when(voiceRoomRegionBroadcastGoClient.send(any())).thenReturn(true);
|
||||||
|
|
||||||
|
listener.sendNoticeGiftBroadcast(
|
||||||
|
event(GiftSpecialEnum.GLOBAL_GIFT.name(), "GOLD"),
|
||||||
|
runningWater()
|
||||||
|
);
|
||||||
|
|
||||||
|
ArgumentCaptor<VoiceRoomRegionBroadcastGoClient.RegionBroadcastRequest> captor =
|
||||||
|
ArgumentCaptor.forClass(VoiceRoomRegionBroadcastGoClient.RegionBroadcastRequest.class);
|
||||||
|
verify(voiceRoomRegionBroadcastGoClient).send(captor.capture());
|
||||||
|
verify(imGroupClient, never()).sendMessageBroadcast(any());
|
||||||
|
|
||||||
|
VoiceRoomRegionBroadcastGoClient.RegionBroadcastRequest request = captor.getValue();
|
||||||
|
assertEquals(SysOriginPlatformEnum.LIKEI.name(), request.getSysOrigin());
|
||||||
|
assertEquals(3001L, request.getSenderUserId());
|
||||||
|
assertEquals(GroupMessageTypeEnum.SEND_GIFT.name(), request.getType());
|
||||||
|
SendGiftNotifyCO data = (SendGiftNotifyCO) request.getData();
|
||||||
|
assertTrue(data.getGlobalNews());
|
||||||
|
assertEquals(5001L, data.getGiftId());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void sendNoticeGiftBroadcastShouldIgnoreNonNoticeGift() {
|
void sendNoticeGiftBroadcastShouldIgnoreNonNoticeGift() {
|
||||||
listener.sendNoticeGiftBroadcast(event("ANIMATION", "GOLD"), runningWater());
|
listener.sendNoticeGiftBroadcast(event("ANIMATION", "GOLD"), runningWater());
|
||||||
|
|
||||||
verify(imGroupClient, never()).sendMessageBroadcast(any());
|
verify(imGroupClient, never()).sendMessageBroadcast(any());
|
||||||
|
verify(voiceRoomRegionBroadcastGoClient, never()).send(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -114,6 +142,7 @@ class GiveGiftsListenerTest {
|
|||||||
runningWater());
|
runningWater());
|
||||||
|
|
||||||
verify(imGroupClient, never()).sendMessageBroadcast(any());
|
verify(imGroupClient, never()).sendMessageBroadcast(any());
|
||||||
|
verify(voiceRoomRegionBroadcastGoClient, never()).send(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
private GiveAwayGiftBatchEvent event(String special, String giftTab) {
|
private GiveAwayGiftBatchEvent event(String special, String giftTab) {
|
||||||
|
|||||||
@ -1,9 +1,93 @@
|
|||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
ALTER TABLE `user_login_logger`
|
SET @current_schema = DATABASE();
|
||||||
ADD COLUMN `ip_country_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '登录IP国家码' AFTER `ip`,
|
|
||||||
ADD COLUMN `ip_country_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '登录IP国家/地区名称' AFTER `ip_country_code`,
|
SET @ddl = IF(
|
||||||
ADD COLUMN `ip_region` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '登录IP地区/省' AFTER `ip_country_name`,
|
EXISTS (
|
||||||
ADD COLUMN `req_zone_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '请求时区' AFTER `ip_region`,
|
SELECT 1
|
||||||
ADD COLUMN `login_blocked` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否被登录访问校验屏蔽' AFTER `req_zone_id`,
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
ADD COLUMN `block_reason` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '登录访问校验屏蔽原因' AFTER `login_blocked`;
|
WHERE TABLE_SCHEMA = @current_schema
|
||||||
|
AND TABLE_NAME = 'user_login_logger'
|
||||||
|
AND COLUMN_NAME = 'ip_country_code'
|
||||||
|
),
|
||||||
|
'SELECT 1',
|
||||||
|
'ALTER TABLE `user_login_logger` ADD COLUMN `ip_country_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '''' COMMENT ''登录IP国家码'' AFTER `ip`'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @ddl;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
SET @ddl = IF(
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @current_schema
|
||||||
|
AND TABLE_NAME = 'user_login_logger'
|
||||||
|
AND COLUMN_NAME = 'ip_country_name'
|
||||||
|
),
|
||||||
|
'SELECT 1',
|
||||||
|
'ALTER TABLE `user_login_logger` ADD COLUMN `ip_country_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '''' COMMENT ''登录IP国家/地区名称'' AFTER `ip_country_code`'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @ddl;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
SET @ddl = IF(
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @current_schema
|
||||||
|
AND TABLE_NAME = 'user_login_logger'
|
||||||
|
AND COLUMN_NAME = 'ip_region'
|
||||||
|
),
|
||||||
|
'SELECT 1',
|
||||||
|
'ALTER TABLE `user_login_logger` ADD COLUMN `ip_region` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '''' COMMENT ''登录IP地区/省'' AFTER `ip_country_name`'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @ddl;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
SET @ddl = IF(
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @current_schema
|
||||||
|
AND TABLE_NAME = 'user_login_logger'
|
||||||
|
AND COLUMN_NAME = 'req_zone_id'
|
||||||
|
),
|
||||||
|
'SELECT 1',
|
||||||
|
'ALTER TABLE `user_login_logger` ADD COLUMN `req_zone_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '''' COMMENT ''请求时区'' AFTER `ip_region`'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @ddl;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
SET @ddl = IF(
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @current_schema
|
||||||
|
AND TABLE_NAME = 'user_login_logger'
|
||||||
|
AND COLUMN_NAME = 'login_blocked'
|
||||||
|
),
|
||||||
|
'SELECT 1',
|
||||||
|
'ALTER TABLE `user_login_logger` ADD COLUMN `login_blocked` tinyint(1) NOT NULL DEFAULT 0 COMMENT ''是否被登录访问校验屏蔽'' AFTER `req_zone_id`'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @ddl;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
SET @ddl = IF(
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @current_schema
|
||||||
|
AND TABLE_NAME = 'user_login_logger'
|
||||||
|
AND COLUMN_NAME = 'block_reason'
|
||||||
|
),
|
||||||
|
'SELECT 1',
|
||||||
|
'ALTER TABLE `user_login_logger` ADD COLUMN `block_reason` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '''' COMMENT ''登录访问校验屏蔽原因'' AFTER `login_blocked`'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @ddl;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|||||||
117
sql/20260508_payment_manager_menu.sql
Normal file
117
sql/20260508_payment_manager_menu.sql
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
SET @payment_manager_menu_id := (
|
||||||
|
SELECT `id` FROM `sys_menu` WHERE `alias` = 'PaymentManager' LIMIT 1
|
||||||
|
);
|
||||||
|
SET @payment_manager_menu_id := IFNULL(@payment_manager_menu_id, 1700000600);
|
||||||
|
|
||||||
|
INSERT INTO `sys_menu` (
|
||||||
|
`id`, `parent_id`, `menu_name`, `path`, `menu_type`, `icon`, `create_user`, `update_user`,
|
||||||
|
`sort`, `status`, `router`, `alias`
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
@payment_manager_menu_id, 0, '支付管理', '/payment/manager', 1, 'lucide:credit-card',
|
||||||
|
'0', '0', 193, 0, '/payment/manager', 'PaymentManager'
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_menu` WHERE `alias` = 'PaymentManager'
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET
|
||||||
|
`parent_id` = 0,
|
||||||
|
`menu_name` = '支付管理',
|
||||||
|
`path` = '/payment/manager',
|
||||||
|
`menu_type` = 1,
|
||||||
|
`icon` = 'lucide:credit-card',
|
||||||
|
`create_user` = '0',
|
||||||
|
`update_user` = '0',
|
||||||
|
`sort` = 193,
|
||||||
|
`status` = 0,
|
||||||
|
`router` = '/payment/manager'
|
||||||
|
WHERE `alias` = 'PaymentManager';
|
||||||
|
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET
|
||||||
|
`parent_id` = @payment_manager_menu_id,
|
||||||
|
`menu_name` = '订单列表',
|
||||||
|
`path` = 'operate/order-details',
|
||||||
|
`menu_type` = 2,
|
||||||
|
`icon` = 'form',
|
||||||
|
`sort` = 1,
|
||||||
|
`status` = 0,
|
||||||
|
`router` = 'payment/manager/order/list'
|
||||||
|
WHERE `alias` = 'OrderDetails';
|
||||||
|
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET
|
||||||
|
`parent_id` = @payment_manager_menu_id,
|
||||||
|
`path` = 'operate/pay-country',
|
||||||
|
`menu_type` = 2,
|
||||||
|
`icon` = 'form',
|
||||||
|
`sort` = CASE `alias` WHEN 'PayCountry' THEN 2 ELSE 7 END,
|
||||||
|
`status` = 0,
|
||||||
|
`router` = 'payment/manager/country'
|
||||||
|
WHERE `alias` IN ('PayCountry', 'openPayCountry');
|
||||||
|
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET
|
||||||
|
`parent_id` = @payment_manager_menu_id,
|
||||||
|
`path` = 'operate/region-relation',
|
||||||
|
`menu_type` = 2,
|
||||||
|
`icon` = 'form',
|
||||||
|
`sort` = 3,
|
||||||
|
`status` = 0,
|
||||||
|
`router` = 'payment/manager/region/relation'
|
||||||
|
WHERE `alias` = 'RegionRelation';
|
||||||
|
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET
|
||||||
|
`parent_id` = @payment_manager_menu_id,
|
||||||
|
`path` = 'operate/pay-application',
|
||||||
|
`menu_type` = 2,
|
||||||
|
`icon` = 'form',
|
||||||
|
`sort` = 4,
|
||||||
|
`status` = 0,
|
||||||
|
`router` = 'payment/manager/application'
|
||||||
|
WHERE `alias` = 'PayApplication';
|
||||||
|
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET
|
||||||
|
`parent_id` = @payment_manager_menu_id,
|
||||||
|
`path` = 'operate/pay-factory',
|
||||||
|
`menu_type` = 2,
|
||||||
|
`icon` = 'form',
|
||||||
|
`sort` = 5,
|
||||||
|
`status` = 0,
|
||||||
|
`router` = 'payment/manager/factory'
|
||||||
|
WHERE `alias` = 'PayFactory';
|
||||||
|
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET
|
||||||
|
`parent_id` = @payment_manager_menu_id,
|
||||||
|
`path` = 'operate/pay-channel',
|
||||||
|
`menu_type` = 2,
|
||||||
|
`icon` = 'form',
|
||||||
|
`sort` = 6,
|
||||||
|
`status` = 0,
|
||||||
|
`router` = 'payment/manager/channel'
|
||||||
|
WHERE `alias` = 'PayChannel';
|
||||||
|
|
||||||
|
INSERT INTO `sys_role_menu` (`role_id`, `menu_id`)
|
||||||
|
SELECT DISTINCT source.`role_id`, @payment_manager_menu_id
|
||||||
|
FROM `sys_role_menu` source
|
||||||
|
JOIN `sys_menu` child_menu ON child_menu.`id` = source.`menu_id`
|
||||||
|
WHERE child_menu.`alias` IN (
|
||||||
|
'OrderDetails',
|
||||||
|
'PayCountry',
|
||||||
|
'openPayCountry',
|
||||||
|
'RegionRelation',
|
||||||
|
'PayApplication',
|
||||||
|
'PayFactory',
|
||||||
|
'PayChannel'
|
||||||
|
)
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_role_menu` target
|
||||||
|
WHERE target.`role_id` = source.`role_id`
|
||||||
|
AND target.`menu_id` = @payment_manager_menu_id
|
||||||
|
);
|
||||||
Loading…
x
Reference in New Issue
Block a user