新增游戏中奖通知

This commit is contained in:
tianfeng 2025-10-28 20:50:08 +08:00
parent 8313c3536f
commit 4c9acce3d6
4 changed files with 64 additions and 3 deletions

View File

@ -195,7 +195,12 @@ public enum OfficialNoticeTypeEnum {
/**
* 用户关注
*/
USER_FOLLOW
USER_FOLLOW,
/**
* 百顺游戏中奖
*/
GAME_BAISHUN_WIN,
;

View File

@ -13,6 +13,9 @@ 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.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.exception.ResponseException;
import com.red.circle.framework.core.security.UserCredential;
@ -20,7 +23,13 @@ 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;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.DateUtils;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
@ -32,6 +41,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.enums.GoldOrigin;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
@ -54,8 +64,10 @@ public class GameBaishunServiceImpl implements GameBaishunService {
private final UserProfileGateway userProfileGateway;
private final GameBaishunProperties gameBaishunProperties;
private final TaskMqMessage taskMqMessage;
private final GameBaiShunTwoFunProperties gameBaiShunTwoFunProperties;
private final OfficialNoticeClient officialNoticeClient;
private final UserProfileAppConvertor userProfileAppConvertor;
private final EnumConfigCacheService enumConfigCacheService;
private final GameListConfigService gameListConfigService;
@Override
public BaishunResponse<BaishunTokenResponse> getToken(BaishunTokenRequest request) {
@ -148,6 +160,8 @@ public class GameBaishunServiceImpl implements GameBaishunService {
WalletReceiptResDTO receiptRes = walletGoldClient.changeBalance(createReceipt(request))
.getBody();
String sysOrigin = UserCredential.parseToken(request.getToken()).getSysOrigin();
//游玩一句游戏结束 每日任务 baishun
Long userId = DataTypeUtils.toLong(request.getUserId());
taskMqMessage.sendTask(TaskApprovalEvent.builder()
@ -155,10 +169,35 @@ public class GameBaishunServiceImpl implements GameBaishunService {
.userId(userId)
.day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd"))
.currencyDiff(request.getCurrencyDiff())
.sysOrigin(UserCredential.parseToken(request.getToken()).getSysOrigin())
.sysOrigin(sysOrigin)
.gameName(GoldOrigin.BAISHUN_GAME.name())
.gameId(Long.parseLong(request.getGameId()))
.build());
BigDecimal cost = enumConfigCacheService
.getValueBigDecimal(EnumConfigKey.HIGH_VALUE_GIFT_STANDARD, sysOrigin);
if (cost.compareTo(BigDecimal.ZERO) <= 0) {
cost = BigDecimal.valueOf(5000L);
}
if (request.getCurrencyDiff() >= cost.longValue()) {
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
userProfileGateway.getByUserId(DataTypeUtils.toLong(request.getUserId())));
GameListConfig gameListConfig = gameListConfigService.getByGameId(request.getGameId(), sysOrigin);
if (Objects.nonNull(gameListConfig)) {
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()
);
}
}
log.warn("{} 发送游戏获奖通知--金币数量{}", GoldOrigin.BAISHUN_GAME.name(), request.getCurrencyDiff());
return BaishunResponse.success(new BaishunChangeCurrencyResponse()
.setCurrencyBalance(receiptRes.getBalance().getDollarAmount().stripTrailingZeros()),

View File

@ -42,6 +42,11 @@ public interface GameListConfigService extends BaseService<GameListConfig> {
*/
GameListConfig getByGameCode(String gameCode, String sysOrigin);
/**
* 查询游戏信息
*/
GameListConfig getByGameId(String gameId, String sysOrigin);
/**
* 校验是否有游戏下架
*/

View File

@ -115,6 +115,18 @@ public class GameListConfigServiceImpl extends
.getOne();
}
/**
* @param gameId 1345
*/
@Override
public GameListConfig getByGameId(String gameId, String sysOrigin) {
return query()
.likeRight(GameListConfig::getName, "_" + gameId) // 匹配 %_1345
.eq(GameListConfig::getSysOrigin, sysOrigin)
.last(PageConstant.LIMIT_ONE)
.getOne();
}
@Override
public Boolean checkGameUnshelve(Set<Long> gameIds) {
return Optional.ofNullable(query()