多语言-修改许愿礼物和星级厨房的公屏
This commit is contained in:
@@ -6,7 +6,7 @@ import com.accompany.admin.dto.NameplateDto;
|
||||
import com.accompany.admin.model.AdminUser;
|
||||
import com.accompany.admin.service.base.BaseService;
|
||||
import com.accompany.admin.service.system.AdminUserService;
|
||||
import com.accompany.admin.util.I18NMessageSourceUtil;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import com.accompany.admin.vo.dress.NameplateAdminVo;
|
||||
import com.accompany.business.constant.nameplate.NameplateStyleTypeEnum;
|
||||
import com.accompany.business.constant.nameplate.NameplateTypeEnum;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.accompany.admin.service.room;
|
||||
|
||||
import com.accompany.admin.util.I18NMessageSourceUtil;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import com.accompany.admin.vo.roomtab.RoomTabAdminVo;
|
||||
import com.accompany.business.model.roomtab.RoomTab;
|
||||
import com.accompany.business.mybatismapper.RoomTabMapper;
|
||||
|
@@ -2,7 +2,7 @@ package com.accompany.admin.service.world;
|
||||
|
||||
import com.accompany.admin.dto.WorldSearchDto;
|
||||
import com.accompany.admin.service.base.BaseService;
|
||||
import com.accompany.admin.util.I18NMessageSourceUtil;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import com.accompany.admin.vo.WorldAdminVo;
|
||||
import com.accompany.business.sensitvienew.SensitiveFilterUtil;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
@@ -13,7 +13,6 @@ import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.common.JedisLockService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.accompany.world.common.ParamUtils;
|
||||
import com.accompany.world.common.WorldException;
|
||||
import com.accompany.world.constant.WorldConstant;
|
||||
import com.accompany.world.entity.World;
|
||||
|
@@ -7,6 +7,8 @@ package com.accompany.common.constant;
|
||||
*/
|
||||
public enum I18nAlertEnum {
|
||||
|
||||
PROMISE_STAR_SCREEN;
|
||||
PROMISE_STAR_SCREEN,
|
||||
|
||||
LUCKY_SEA_SCREEN;
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.accompany.admin.util;
|
||||
package com.accompany.core.util;
|
||||
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.base.SpringContextHolder;
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.business.service.activities.luckySea.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.business.enums.message.ContentTypeEnum;
|
||||
import com.accompany.business.model.activity.luckysea.LuckySeaRoomTipConfig;
|
||||
import com.accompany.business.model.activity.luckysea.LuckySeaUserDrawRecord;
|
||||
@@ -12,9 +13,11 @@ import com.accompany.business.vo.message.MessageTemplate;
|
||||
import com.accompany.business.vo.message.TextSpan;
|
||||
import com.accompany.common.constant.Attach;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.constant.I18nAlertEnum;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -110,11 +113,11 @@ public class LuckySeaPushMsgService {
|
||||
String nickText = String.format("[%s]", nick);
|
||||
String goldNumText = String.format("[%d鉆石]", goldNum);
|
||||
String tip = "恭喜 {" + nickText + "} 在瘋狂動物園中運氣爆棚,獲得 {" + goldNumText + "} 獎勵!";
|
||||
String i18nId = I18nAlertEnum.class.getSimpleName() + StrUtil.DOT + I18nAlertEnum.LUCKY_SEA_SCREEN.name();
|
||||
Map<String, String> messageMap = I18NMessageSourceUtil.getMessageMap(i18nId, new Object[]{nickText, goldNumText});
|
||||
|
||||
MessageTemplate messageTemplate = new MessageTemplate();
|
||||
Map<String, String> template = new HashMap<>();
|
||||
template.put("zh-CN", tip);
|
||||
messageTemplate.setTemplate(template);
|
||||
messageTemplate.setTemplate(messageMap);
|
||||
List<BaseSpan> contentList = new ArrayList<>();
|
||||
messageTemplate.setContents(contentList);
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import com.accompany.business.vo.promisestar.PromiseStarRoundUserRecordVo;
|
||||
import com.accompany.business.vo.promisestar.PromiseStarRoundVo;
|
||||
import com.accompany.common.config.SystemConfig;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.constant.I18nAlertEnum;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.RandomUtil;
|
||||
@@ -29,6 +30,7 @@ import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RLock;
|
||||
@@ -89,28 +91,28 @@ public class PromiseStarService {
|
||||
.orderByAsc(PromiseStarConfig::getSeqNo)
|
||||
.list();
|
||||
|
||||
if (CollectionUtils.isEmpty(configList)){
|
||||
if (CollectionUtils.isEmpty(configList)) {
|
||||
return vo;
|
||||
}
|
||||
|
||||
toVo(roundVoList, configList);
|
||||
|
||||
List<Long> roundIdList = configList.stream()
|
||||
.filter(config->null != config.getLastestRoundId())
|
||||
.filter(config -> null != config.getLastestRoundId())
|
||||
.map(PromiseStarConfig::getLastestRoundId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(roundIdList)){
|
||||
if (CollectionUtils.isEmpty(roundIdList)) {
|
||||
return vo;
|
||||
}
|
||||
|
||||
Map<Long, PromiseStarRound> roundMap = roundService.lambdaQuery()
|
||||
.in(PromiseStarRound::getId, roundIdList)
|
||||
.list().stream()
|
||||
.collect(Collectors.toMap(PromiseStarRound::getId, round->round));
|
||||
.collect(Collectors.toMap(PromiseStarRound::getId, round -> round));
|
||||
|
||||
if (CollectionUtils.isEmpty(roundMap)){
|
||||
if (CollectionUtils.isEmpty(roundMap)) {
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -135,9 +137,9 @@ public class PromiseStarService {
|
||||
roundVo.setRoundId(round.getId());
|
||||
|
||||
roundVo.setMax(round.getTargetNum());
|
||||
roundVo.setProcess(nonStock? 0: round.getProcessNum());
|
||||
roundVo.setProcess(nonStock ? 0 : round.getProcessNum());
|
||||
|
||||
if (nonStock){
|
||||
if (nonStock) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -153,7 +155,7 @@ public class PromiseStarService {
|
||||
Map<Integer, Gift> giftMap = giftService.getGiftByIdsFromDb(giftIdList)
|
||||
.stream().collect(Collectors.toMap(Gift::getGiftId, gift -> gift));
|
||||
|
||||
for (PromiseStarConfig config: configList){
|
||||
for (PromiseStarConfig config : configList) {
|
||||
PromiseStarRoundVo roundVo = new PromiseStarRoundVo();
|
||||
roundVo.setConfigId(config.getId());
|
||||
roundVo.setRoundId(config.getLastestRoundId());
|
||||
@@ -164,7 +166,7 @@ public class PromiseStarService {
|
||||
roundVo.setGift(giftVo);
|
||||
|
||||
Gift gift = giftMap.get(config.getGiftId());
|
||||
if (null != gift){
|
||||
if (null != gift) {
|
||||
giftVo.setGiftName(gift.getGiftName());
|
||||
giftVo.setGoldPrice(gift.getGoldPrice());
|
||||
giftVo.setPicUrl(gift.getPicUrl());
|
||||
@@ -184,12 +186,12 @@ public class PromiseStarService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void promise(Long uid, Long configId, Integer num) {
|
||||
PromiseStarConfig config = configService.getById(configId);
|
||||
if (null == config){
|
||||
if (null == config) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
int userStickNum = stickService.getUserStickNum(uid);
|
||||
if (userStickNum < num){
|
||||
if (userStickNum < num) {
|
||||
throw new ServiceException(BusiStatus.UNENOUGH_ACT_PROP_ITEM);
|
||||
}
|
||||
|
||||
@@ -200,22 +202,22 @@ public class PromiseStarService {
|
||||
RLock lock = redissonClient.getLock(lockKey);
|
||||
try {
|
||||
locked = lock.tryLock(5, TimeUnit.SECONDS);
|
||||
if (!locked){
|
||||
if (!locked) {
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
||||
// double check lastestRoundId
|
||||
config = configService.getById(configId);
|
||||
if (null == config){
|
||||
if (null == config) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
if (config.getStockNum() < 1 && null == config.getLastestRoundId()){
|
||||
if (config.getStockNum() < 1 && null == config.getLastestRoundId()) {
|
||||
throw new ServiceException(BusiStatus.STOCK_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
PromiseStarRound round = null;
|
||||
if (null != config.getLastestRoundId()){
|
||||
if (null != config.getLastestRoundId()) {
|
||||
round = roundService.getById(config.getLastestRoundId());
|
||||
} else {
|
||||
// 初始化
|
||||
@@ -224,11 +226,11 @@ public class PromiseStarService {
|
||||
|
||||
// 支持达到库存后,后台增加库存
|
||||
if (null != round && round.getProcessNum().compareTo(round.getTargetNum()) >= 0
|
||||
&& config.getStockNum().compareTo(round.getPromiseRoundNum()) > 0){
|
||||
&& config.getStockNum().compareTo(round.getPromiseRoundNum()) > 0) {
|
||||
round = createRound(config, round.getPromiseRoundNum(), now);
|
||||
}
|
||||
|
||||
if (null == round){
|
||||
if (null == round) {
|
||||
throw new ServiceException(BusiStatus.SERVERERROR);
|
||||
}
|
||||
|
||||
@@ -246,12 +248,12 @@ public class PromiseStarService {
|
||||
userRecordService.saveUserRecord(uid, config, thisNum, now);
|
||||
|
||||
// 不满足本轮上限,无需开奖
|
||||
if (round.getProcessNum() < round.getTargetNum()){
|
||||
if (round.getProcessNum() < round.getTargetNum()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 还有库存,创建新一轮
|
||||
if (round.getPromiseRoundNum() < config.getStockNum()){
|
||||
if (round.getPromiseRoundNum() < config.getStockNum()) {
|
||||
createRound(config, round.getPromiseRoundNum(), now);
|
||||
}
|
||||
|
||||
@@ -262,7 +264,7 @@ public class PromiseStarService {
|
||||
//todo
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (locked){
|
||||
if (locked) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
@@ -273,9 +275,9 @@ public class PromiseStarService {
|
||||
Date now = new Date();
|
||||
|
||||
List<PromiseStarUserRecord> recordList = userRecordService.lambdaQuery()
|
||||
.eq(PromiseStarUserRecord:: getRoundId, round.getId())
|
||||
.eq(PromiseStarUserRecord::getRoundId, round.getId())
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(recordList)){
|
||||
if (CollectionUtils.isEmpty(recordList)) {
|
||||
//todo
|
||||
throw new ServiceException(BusiStatus.SERVERERROR);
|
||||
}
|
||||
@@ -296,7 +298,7 @@ public class PromiseStarService {
|
||||
sendSecretTip(round, winnerUid, uidList);
|
||||
}
|
||||
|
||||
private void sendRoomTip(Integer giftId, Long winnerUid){
|
||||
private void sendRoomTip(Integer giftId, Long winnerUid) {
|
||||
//公屏
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
String giftName = StrUtil.EMPTY;
|
||||
@@ -312,9 +314,10 @@ public class PromiseStarService {
|
||||
Users winner = usersBaseService.getUsersByUid(winnerUid);
|
||||
if (winner != null) {
|
||||
MessageTemplate messageTemplate = new MessageTemplate();
|
||||
Map<String, String> template = new HashMap<>();
|
||||
template.put("zh-CN", "恭喜被幸運神附體的 " + winner.getNick() + ",在許願之星獲得了禮物【" + giftName + "(" + goldPrice + "鑽)】!");
|
||||
messageTemplate.setTemplate(template);
|
||||
String className = I18nAlertEnum.class.getSimpleName();
|
||||
String i18nId = className + StrUtil.DOT + I18nAlertEnum.PROMISE_STAR_SCREEN.name();
|
||||
Map<String, String> messageMap = I18NMessageSourceUtil.getMessageMap(i18nId, new Object[]{winner.getNick(), giftName, goldPrice});
|
||||
messageTemplate.setTemplate(messageMap);
|
||||
List<BaseSpan> contents = new ArrayList<>();
|
||||
messageTemplate.setContents(contents);
|
||||
sendSysMsgService.sendTemplateMessage(messageTemplate);
|
||||
@@ -328,7 +331,7 @@ public class PromiseStarService {
|
||||
.in(PromiseStarRoundWhite::getUid, uidList)
|
||||
.list().stream().map(PromiseStarRoundWhite::getUid)
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(whiteUidList)){
|
||||
if (!CollectionUtils.isEmpty(whiteUidList)) {
|
||||
Collections.shuffle(whiteUidList);
|
||||
Long winnerUid = whiteUidList.get(0);
|
||||
|
||||
@@ -341,7 +344,7 @@ public class PromiseStarService {
|
||||
|
||||
int weightSum = 0;
|
||||
SortedMap<Integer, Long> weightMap = new TreeMap<>();
|
||||
for (PromiseStarUserRecord record: recordList){
|
||||
for (PromiseStarUserRecord record : recordList) {
|
||||
weightSum += record.getStickNum();
|
||||
weightMap.put(weightSum, record.getUid());
|
||||
}
|
||||
@@ -368,15 +371,15 @@ public class PromiseStarService {
|
||||
sendSysMsgService.sendPersonTextMsg(SystemConfig.secretaryUid, winnerUid, winnerTip);
|
||||
|
||||
String otherTip = String.format("你參与的[%s]的許願之星活動的本輪結果已產出,很遺憾幸運之神與你擦肩而過,下次請再接再厲哦~", gift.getGiftName());
|
||||
for (Long otherUid: uidList){
|
||||
if (otherUid.equals(winnerUid)){
|
||||
for (Long otherUid : uidList) {
|
||||
if (otherUid.equals(winnerUid)) {
|
||||
continue;
|
||||
}
|
||||
sendSysMsgService.sendPersonTextMsg(SystemConfig.secretaryUid, otherUid, otherTip);
|
||||
}
|
||||
}
|
||||
|
||||
private PromiseStarRound createRound(PromiseStarConfig config, Integer promiseRoundNum, Date now){
|
||||
private PromiseStarRound createRound(PromiseStarConfig config, Integer promiseRoundNum, Date now) {
|
||||
PromiseStarRound newRound = roundService.createRound(config, promiseRoundNum);
|
||||
config.setLastestRoundId(newRound.getId());
|
||||
config.setUpdateTime(now);
|
||||
|
Reference in New Issue
Block a user