新增游戏中奖通知发送公共消息

This commit is contained in:
tianfeng 2025-10-29 11:15:54 +08:00
parent 4c9acce3d6
commit 674c88f4a6
4 changed files with 69 additions and 17 deletions

View File

@ -126,4 +126,9 @@ public enum GroupMessageTypeEnum {
*/
SYS_ACTIVITY,
/**
* 百顺游戏中奖
*/
GAME_BAISHUN_WIN,
}

View File

@ -1,6 +1,7 @@
package com.red.circle.other.app.service.game;
import com.red.circle.auth.inner.endpoint.AuthClient;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.component.game.baishun.GameBaishunService;
import com.red.circle.component.game.baishun.error.BaishunErrorCode;
import com.red.circle.component.game.baishun.props.GameBaishunProperties;
@ -13,20 +14,18 @@ import com.red.circle.component.game.baishun.response.BaishunResponse;
import com.red.circle.component.game.baishun.response.BaishunTokenResponse;
import com.red.circle.component.game.baishun.response.BaishunUserProfileResponse;
import com.red.circle.component.redis.service.RedisService;
import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient;
import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd;
import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum;
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.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.exception.ResponseException;
import com.red.circle.framework.core.security.UserCredential;
import com.red.circle.mq.business.model.event.game.GameBaiShunTwoFunProperties;
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
import com.red.circle.other.infra.database.cache.service.other.GameListCacheService;
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.enums.config.EnumConfigKey;
@ -64,10 +63,10 @@ public class GameBaishunServiceImpl implements GameBaishunService {
private final UserProfileGateway userProfileGateway;
private final GameBaishunProperties gameBaishunProperties;
private final TaskMqMessage taskMqMessage;
private final OfficialNoticeClient officialNoticeClient;
private final UserProfileAppConvertor userProfileAppConvertor;
private final EnumConfigCacheService enumConfigCacheService;
private final GameListConfigService gameListConfigService;
private final ImGroupClient imGroupClient;
@Override
public BaishunResponse<BaishunTokenResponse> getToken(BaishunTokenRequest request) {
@ -175,7 +174,7 @@ public class GameBaishunServiceImpl implements GameBaishunService {
.build());
BigDecimal cost = enumConfigCacheService
.getValueBigDecimal(EnumConfigKey.HIGH_VALUE_GIFT_STANDARD, sysOrigin);
.getValueBigDecimal(EnumConfigKey.GAME_BROADCAST_AMOUNT, sysOrigin);
if (cost.compareTo(BigDecimal.ZERO) <= 0) {
cost = BigDecimal.valueOf(5000L);
}
@ -189,11 +188,13 @@ public class GameBaishunServiceImpl implements GameBaishunService {
Map<Object, Object> build = OfficialNoticeUtils.buildUserProfile(userProfile);
build.put("gameUrl", gameListConfig.getCover());
build.put("currencyDiff", request.getCurrencyDiff());
officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder()
.toAccount(userId)
.noticeType(OfficialNoticeTypeEnum.GAME_BAISHUN_WIN)
.templateParam(build)
.build()
imGroupClient.sendMessageBroadcast(
BroadcastGroupMsgBodyCmd.builder()
.toPlatform(SysOriginPlatformEnum.LIKEI)
.type(GroupMessageTypeEnum.GAME_BAISHUN_WIN)
.data(build)
.build()
);
}
}

View File

@ -121,7 +121,7 @@ public class GameListConfigServiceImpl extends
@Override
public GameListConfig getByGameId(String gameId, String sysOrigin) {
return query()
.likeRight(GameListConfig::getName, "_" + gameId) // 匹配 %_1345
.likeLeft(GameListConfig::getName, "_" + gameId) // 匹配 %_1345
.eq(GameListConfig::getSysOrigin, sysOrigin)
.last(PageConstant.LIMIT_ONE)
.getOne();

View File

@ -1,6 +1,20 @@
import com.red.circle.OtherServiceApplication;
import com.red.circle.other.app.scheduler.TeamBillTask;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.external.inner.endpoint.message.ImGroupClient;
import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient;
import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd;
import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd;
import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum;
import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.InviteUserGateway;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.parse.DataTypeUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@ -8,6 +22,8 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Objects;
@SpringBootTest(classes = OtherServiceApplication.class)
@RunWith(SpringRunner.class)
@ -15,12 +31,42 @@ public class SpringTest {
@Autowired
private InviteUserGateway inviteUserGateway;
@Autowired
private OfficialNoticeClient officialNoticeClient;
@Autowired
private UserProfileAppConvertor userProfileAppConvertor;
@Autowired
private EnumConfigCacheService enumConfigCacheService;
@Autowired
private GameListConfigService gameListConfigService;
@Autowired
private UserProfileGateway userProfileGateway;
@Autowired
private ImGroupClient imGroupClient;
@Test
public void execute() {
BigDecimal amount = new BigDecimal("100");
Long userId = 1963789902071508993L;
inviteUserGateway.getRechargeCommission(amount, "LIKEI", userId);
Long userId = 1954021558348390402L;
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
userProfileGateway.getByUserId(DataTypeUtils.toLong(userId)));
GameListConfig gameListConfig = gameListConfigService.getByGameId("1090", "LIKEI");
if (Objects.nonNull(gameListConfig)) {
Map<Object, Object> build = OfficialNoticeUtils.buildUserProfile(userProfile);
build.put("gameUrl", gameListConfig.getCover());
build.put("currencyDiff", 6000);
imGroupClient.sendMessageBroadcast(
BroadcastGroupMsgBodyCmd.builder()
.toPlatform(SysOriginPlatformEnum.LIKEI)
.type(GroupMessageTypeEnum.GAME_BAISHUN_WIN)
.data(build)
.build()
);
}
}
}