bravo-goldIncomeListener
This commit is contained in:
@@ -44,6 +44,7 @@ public class WebSecurityConfig {
|
||||
private String callBattleDingPushKey;
|
||||
//
|
||||
private String lucky24StockWarningPushKey;
|
||||
private String bravoStockWarningPushKey;
|
||||
|
||||
public void setJwtWebKey(String jwtWebKey) {
|
||||
WebSecurityConfig.jwtWebKey = jwtWebKey;
|
||||
|
@@ -356,6 +356,10 @@ public class Constant {
|
||||
public static int SUPER_LUCKY_GIFT_ROOM_SCREEN = 1061;
|
||||
public static int SUPER_LUCKY_GIFT_TIP = 1062;
|
||||
public static int SUPER_LUCKY_GIFT_FLOAT = 1063;
|
||||
// 超级幸运礼物公屏
|
||||
public static int BRAVO_GIFT_ROOM_SCREEN = 1064;
|
||||
public static int BRAVO_GIFT_TIP = 1065;
|
||||
public static int BRAVO_GIFT_FLOAT = 1066;
|
||||
|
||||
/**
|
||||
* 通用飘屏
|
||||
|
@@ -0,0 +1,10 @@
|
||||
package com.accompany.business.event;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
public class BravoGiftGoldIncomeMessageEvent extends ApplicationEvent {
|
||||
|
||||
public BravoGiftGoldIncomeMessageEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.accompany.business.message;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class BravoGiftGoldIncomeMessage implements Serializable {
|
||||
|
||||
private Long senderUid; // 赠送人uid
|
||||
private Long receiverUid;
|
||||
private Long roomUid; // 房主uid
|
||||
private Integer giftId; // 福袋id
|
||||
private Integer giftNum;
|
||||
private Long totalGoldNum; // 福袋时价
|
||||
private Double totalDiamondNum; // 开出礼物价值
|
||||
private Date createTime; // 创建时间
|
||||
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package com.accompany.business.event.listener;
|
||||
|
||||
import com.accompany.business.event.BravoGiftGoldIncomeMessageEvent;
|
||||
import com.accompany.business.message.BravoGiftGoldIncomeMessage;
|
||||
import com.accompany.business.service.SendSysMsgService;
|
||||
import com.accompany.business.service.rank.RankService;
|
||||
import com.accompany.business.service.room.RoomLevelService;
|
||||
import com.accompany.business.service.room.RoomRankService;
|
||||
import com.accompany.business.service.room.RoomService;
|
||||
import com.accompany.business.service.room.RoomServiceFactory;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BravoGiftGoldIncomeListener implements ApplicationListener<BravoGiftGoldIncomeMessageEvent> {
|
||||
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private RoomRankService roomRankService;
|
||||
@Autowired
|
||||
private RankService rankService;
|
||||
@Autowired
|
||||
private RoomService roomService;
|
||||
@Autowired
|
||||
private SendSysMsgService sendSysMsgService;
|
||||
@Autowired
|
||||
private RoomLevelService roomLevelService;
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(BravoGiftGoldIncomeMessageEvent event) {
|
||||
BravoGiftGoldIncomeMessage message = (BravoGiftGoldIncomeMessage) event.getSource();
|
||||
log.info("BravoGiftGoldIncomeListener message:{}", JSONObject.toJSONString(message));
|
||||
Long receiverUid = message.getReceiverUid();
|
||||
Users receiver = usersService.getNotNullUsersByUid(receiverUid);
|
||||
Double totalDiamondNum = message.getTotalDiamondNum();
|
||||
Long sendUid = message.getSenderUid();
|
||||
Long recvUid = message.getReceiverUid();
|
||||
Long roomUid = message.getRoomUid();
|
||||
Date messTime = message.getCreateTime();
|
||||
Integer partitionId = receiver.getPartitionId();
|
||||
try {
|
||||
rankService.updateAllRank(sendUid, recvUid, roomUid, totalDiamondNum, messTime.getTime(), partitionId);
|
||||
roomRankService.updateRoomRank(roomUid, sendUid, recvUid, totalDiamondNum, messTime, Boolean.FALSE, partitionId);
|
||||
//发送榜单更新
|
||||
if (roomUid != null) {
|
||||
Room room = roomService.getRoomByUid(roomUid);
|
||||
roomLevelService.updateRoomLevelExp(partitionId, roomUid, totalDiamondNum, room);
|
||||
if (room != null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("serialValue", RoomServiceFactory.getServiceByType(room.getType()).roomSerialValue(roomUid, partitionId));
|
||||
sendSysMsgService.sendSingleRoomMessage(room.getRoomId(), String.valueOf(roomUid), Constant.DefMsgType.RANK, Constant.DefMsgType.RANK_UPDATE, jsonObject);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("BravoGiftGoldIncomeListener updateAllRank-updateRoomRank:{}, e:{}", JSONObject.toJSONString(message), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -49,7 +49,7 @@ public class BravoGiftSendService {
|
||||
@Autowired
|
||||
private BravoSettlementService settlementService;
|
||||
@Autowired
|
||||
private Lucky24RobotMsgService robotMsgService;
|
||||
private BravoRobotMsgService robotMsgService;
|
||||
@Autowired
|
||||
private RocketMQService rocketMQService;
|
||||
@Autowired
|
||||
|
@@ -21,7 +21,7 @@ public class BravoMessageService extends BaseService {
|
||||
@Autowired
|
||||
private BravoRecordService recordService;
|
||||
@Autowired
|
||||
private Lucky24RobotMsgService robotMsgService;
|
||||
private BravoRobotMsgService robotMsgService;
|
||||
@Autowired
|
||||
private BravoSettlementService settlementService;
|
||||
@Autowired
|
||||
|
@@ -0,0 +1,311 @@
|
||||
package com.accompany.business.service.gift;
|
||||
|
||||
import com.accompany.business.enums.lucky.LuckyGiftRewardTypeEnum;
|
||||
import com.accompany.business.enums.message.ContentTypeEnum;
|
||||
import com.accompany.business.model.Gift;
|
||||
import com.accompany.business.model.lucky.LuckyGiftReward;
|
||||
import com.accompany.business.service.SendSysMsgService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.message.ImageSpan;
|
||||
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.core.enumeration.I18nAlertEnum;
|
||||
import com.accompany.core.model.PartitionInfo;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.partition.PartitionInfoService;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BravoMsgSendService {
|
||||
|
||||
@Autowired
|
||||
private SendSysMsgService sendSysMsgService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private PartitionInfoService partitionInfoService;
|
||||
|
||||
@Async
|
||||
public void sendRoomScreen(long senderUid, Room room, Gift gift, int giftNum, Map<Long, Map<LuckyGiftReward, Integer>> drawResult) {
|
||||
Users sender = usersService.getUsersByUid(senderUid);
|
||||
if (null == sender) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Long, Users> receiverMap = usersService.getUsersMapByUids(new ArrayList<>(drawResult.keySet()));
|
||||
if (CollectionUtils.isEmpty(receiverMap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PartitionInfo> partitionInfoList = partitionInfoService.listAll();
|
||||
if (CollectionUtils.isEmpty(partitionInfoList)){
|
||||
return;
|
||||
}
|
||||
|
||||
drawResult.keySet().parallelStream().forEach(receiverUid -> {
|
||||
Users receiver = receiverMap.get(receiverUid);
|
||||
if (null == receiver) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<LuckyGiftReward, Integer> receiverResultMap = drawResult.get(receiverUid);
|
||||
|
||||
List<LuckyGiftReward> rewardList = receiverResultMap.keySet().stream()
|
||||
.filter(key -> LuckyGiftRewardTypeEnum.NONE.ordinal() != key.getRewardType())
|
||||
.sorted(Comparator.comparing(LuckyGiftReward::getRewardType)
|
||||
.thenComparing((l1, l2) -> l2.getRewardPrice().compareTo(l1.getRewardPrice())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
MessageTemplate messageTemplate = new MessageTemplate();
|
||||
|
||||
TextSpan senderNickSpan = new TextSpan();
|
||||
senderNickSpan.setKey("senderNick");
|
||||
senderNickSpan.setMessage("[" + sender.getNick() + "]");
|
||||
senderNickSpan.setTextColor("#FFBC51");
|
||||
messageTemplate.addSpan(senderNickSpan);
|
||||
|
||||
TextSpan receiverNickSpan = new TextSpan();
|
||||
receiverNickSpan.setKey("receiverNick");
|
||||
receiverNickSpan.setMessage("[" + receiver.getNick() + "]");
|
||||
receiverNickSpan.setTextColor("#FFBC51");
|
||||
messageTemplate.addSpan(receiverNickSpan);
|
||||
|
||||
TextSpan giftNameSpan = new TextSpan();
|
||||
giftNameSpan.setKey("giftName");
|
||||
messageTemplate.addSpan(giftNameSpan);
|
||||
|
||||
String giftNameI18nId = String.join(".","Gift", gift.getGiftName());
|
||||
|
||||
TextSpan giftNumSpan = new TextSpan();
|
||||
giftNumSpan.setKey("giftNum");
|
||||
giftNumSpan.setMessage(String.valueOf(giftNum));
|
||||
messageTemplate.addSpan(giftNumSpan);
|
||||
|
||||
for (PartitionInfo partitionInfo : partitionInfoList) {
|
||||
Integer partitionId = partitionInfo.getId();
|
||||
|
||||
Locale locale = partitionInfoService.getDefaultLang(partitionId);
|
||||
|
||||
String giftNameMessage = I18NMessageSourceUtil.getMessage(giftNameI18nId, null, gift.getGiftName(), locale);
|
||||
giftNameSpan.setMessage("[" + giftNameMessage + "]", partitionInfo.getLanguages());
|
||||
|
||||
StringBuilder template = new StringBuilder(I18NMessageSourceUtil.getMessage(I18nAlertEnum.SUPER_LUCKY_GIFT_ROOM_SCREEN, new Object[]{"senderNick", "receiverNick", "giftName", "giftNum"}, partitionId));
|
||||
|
||||
String getPhrase = I18NMessageSourceUtil.getMessage(I18nAlertEnum.SUPER_LUCKY_GIFT_GET_PHRASE, null, locale);
|
||||
String diamondPhrase = I18NMessageSourceUtil.getMessage(I18nAlertEnum.SUPER_LUCKY_GIFT_DIAMOND_PHRASE, null, locale);
|
||||
|
||||
if (!CollectionUtils.isEmpty(rewardList)) {
|
||||
// 合并钻石
|
||||
boolean hasPrintDiamond = false;
|
||||
long diamondNum = 0L;
|
||||
for (LuckyGiftReward reward : rewardList) {
|
||||
if (LuckyGiftRewardTypeEnum.DIAMOND.ordinal() != reward.getRewardType()) {
|
||||
continue;
|
||||
}
|
||||
int num = receiverResultMap.get(reward);
|
||||
diamondNum += reward.getRewardPrice() * num;
|
||||
}
|
||||
|
||||
int index = 1;
|
||||
for (LuckyGiftReward reward : rewardList) {
|
||||
if (LuckyGiftRewardTypeEnum.DIAMOND.ordinal() == reward.getRewardType()) {
|
||||
if (hasPrintDiamond) {
|
||||
continue;
|
||||
}
|
||||
hasPrintDiamond = true;
|
||||
}
|
||||
|
||||
template.append(index == 1 ? getPhrase : "、");
|
||||
|
||||
String rewardIcon = "rewardIcon" + index;
|
||||
String rewardIconTemplate = "{" + rewardIcon + "}";
|
||||
|
||||
template.append(rewardIconTemplate);
|
||||
|
||||
ImageSpan imageSpan = new ImageSpan();
|
||||
imageSpan.setKey(rewardIcon);
|
||||
imageSpan.setType(ContentTypeEnum.IMAGE.name());
|
||||
imageSpan.setImage(reward.getRewardIcon());
|
||||
imageSpan.setWidth(20);
|
||||
imageSpan.setHeight(20);
|
||||
|
||||
messageTemplate.addSpan(imageSpan);
|
||||
|
||||
//
|
||||
if (LuckyGiftRewardTypeEnum.GIFT.ordinal() == reward.getRewardType()) {
|
||||
//
|
||||
String rewardName = "rewardName" + index;
|
||||
String rewardNameTemplate = "{" + rewardName + "}";
|
||||
|
||||
template.append(rewardNameTemplate);
|
||||
|
||||
String rewardNameI18nId = "Gift." + reward.getRewardName();
|
||||
String rewardNameMessage = I18NMessageSourceUtil.getMessage(rewardNameI18nId, null, reward.getRewardName(), locale);
|
||||
|
||||
TextSpan rewardNameSpan = new TextSpan();
|
||||
rewardNameSpan.setKey(rewardName);
|
||||
rewardNameSpan.setType(ContentTypeEnum.TEXT.name());
|
||||
rewardNameSpan.setMessage(rewardNameMessage, partitionInfo.getLanguages());
|
||||
|
||||
messageTemplate.addSpan(rewardNameSpan);
|
||||
|
||||
String rewardValue = "rewardValue" + index;
|
||||
String rewardValueTemplate = "{" + rewardValue + "}";
|
||||
|
||||
template.append("(").append(rewardValueTemplate).append(diamondPhrase).append(")");
|
||||
|
||||
TextSpan rewardValueSpan = new TextSpan();
|
||||
rewardValueSpan.setKey(rewardValue);
|
||||
rewardValueSpan.setType(ContentTypeEnum.TEXT.name());
|
||||
rewardValueSpan.setMessage(reward.getRewardPrice().toString());
|
||||
|
||||
messageTemplate.addSpan(rewardValueSpan);
|
||||
}
|
||||
|
||||
//
|
||||
String rewardNum = "rewardNum" + index;
|
||||
String rewardNumTemplate = "{" + rewardNum + "}";
|
||||
|
||||
template.append("*").append(rewardNumTemplate);
|
||||
|
||||
String num = LuckyGiftRewardTypeEnum.DIAMOND.ordinal() == reward.getRewardType() ?
|
||||
String.valueOf(diamondNum) : receiverResultMap.get(reward).toString();
|
||||
|
||||
TextSpan rewardNumSpan = new TextSpan();
|
||||
rewardNumSpan.setKey(rewardNum);
|
||||
rewardNumSpan.setMessage(num);
|
||||
|
||||
messageTemplate.addSpan(rewardNumSpan);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
messageTemplate.setMessage(template.toString(), partitionInfo.getLanguages());
|
||||
}
|
||||
|
||||
messageTemplate.setPartitionId(room.getPartitionId());
|
||||
sendSysMsgService.sendTemplateMessage(room.getRoomId(), room.getUid(),
|
||||
Constant.DefMsgType.SUPER_LUCKY_GIFT, Constant.DefMsgType.BRAVO_GIFT_ROOM_SCREEN, messageTemplate);
|
||||
});
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendAllRoomScreen(long senderUid, Room room, Gift gift, BigDecimal outputValue) {
|
||||
Users sender = usersService.getUsersByUid(senderUid);
|
||||
if (null == sender) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PartitionInfo> partitionInfoList = partitionInfoService.listAll();
|
||||
if (CollectionUtils.isEmpty(partitionInfoList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MessageTemplate allRoomTemplate = new MessageTemplate();
|
||||
|
||||
TextSpan senderNickSpan = new TextSpan();
|
||||
senderNickSpan.setKey("senderNick");
|
||||
senderNickSpan.setMessage("[" + sender.getNick() + "]");
|
||||
senderNickSpan.setTextColor("#FFBC51");
|
||||
allRoomTemplate.addSpan(senderNickSpan);
|
||||
|
||||
TextSpan giftNameSpan = new TextSpan();
|
||||
giftNameSpan.setKey("giftName");
|
||||
allRoomTemplate.addSpan(giftNameSpan);
|
||||
|
||||
String giftNameI18nId = String.join(".","Gift", gift.getGiftName());
|
||||
|
||||
TextSpan roomTitleSpan = new TextSpan();
|
||||
roomTitleSpan.setKey("roomTitle");
|
||||
roomTitleSpan.setMessage("[" + room.getTitle() + "]");
|
||||
roomTitleSpan.setTextColor("#FFBC51");
|
||||
allRoomTemplate.addSpan(roomTitleSpan);
|
||||
|
||||
TextSpan outputValueSpan = new TextSpan();
|
||||
outputValueSpan.setKey("outputValue");
|
||||
outputValueSpan.setMessage(outputValue.toPlainString());
|
||||
allRoomTemplate.addSpan(outputValueSpan);
|
||||
|
||||
for (PartitionInfo partitionInfo : partitionInfoList) {
|
||||
Integer partitionId = partitionInfo.getId();
|
||||
|
||||
Locale locale = partitionInfoService.getDefaultLang(partitionId);
|
||||
|
||||
String giftNameMessage = I18NMessageSourceUtil.getMessage(giftNameI18nId, null, gift.getGiftName(), locale);
|
||||
giftNameSpan.setMessage("[" + giftNameMessage + "]", partitionInfo.getLanguages());
|
||||
|
||||
String allRoomText = I18NMessageSourceUtil.getMessage(I18nAlertEnum.SUPER_LUCKY_GIFT_ALL_ROOM_SCREEN,
|
||||
new Object[]{"senderNick", "roomTitle", "giftName", "outputValue"}, partitionInfo.getId());
|
||||
allRoomTemplate.setMessage(allRoomText, partitionInfo.getLanguages());
|
||||
}
|
||||
|
||||
allRoomTemplate.setPartitionId(room.getPartitionId());
|
||||
sendSysMsgService.sendTemplateMessage(Constant.DefMsgType.SUPER_LUCKY_GIFT, Constant.DefMsgType.BRAVO_GIFT_ROOM_SCREEN, allRoomTemplate);
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendTip(long senderUid, Room room, BigDecimal outputValue, BigDecimal multi, int level) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("roomUid", room.getUid());
|
||||
params.put("roomId", room.getRoomId());
|
||||
params.put("uid", senderUid);
|
||||
params.put("times", multi.toPlainString());
|
||||
params.put("coins", outputValue.toPlainString());
|
||||
params.put("level", level);
|
||||
params.put("intratemporals", multi.toPlainString());
|
||||
params.put("tangerines", outputValue.toPlainString());
|
||||
sendSysMsgService.sendSingleRoomMessage(room.getRoomId(), String.valueOf(room.getUid()),
|
||||
Constant.DefMsgType.SUPER_LUCKY_GIFT, Constant.DefMsgType.BRAVO_GIFT_TIP, params);
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendFloating(Room room, long senderUid, Gift gift, BigDecimal multi, BigDecimal outputValue) {
|
||||
Users sender = usersService.getUsersByUid(senderUid);
|
||||
if (null == sender) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PartitionInfo> partitionInfoList = partitionInfoService.listAll();
|
||||
if (CollectionUtils.isEmpty(partitionInfoList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> giftNameMap = new HashMap<>();
|
||||
for (PartitionInfo partitionInfo: partitionInfoList){
|
||||
Locale locale = partitionInfoService.getDefaultLang(partitionInfo.getId());
|
||||
String giftNameI18nId = String.join(".", "Gift", gift.getGiftName());
|
||||
String text = I18NMessageSourceUtil.getMessage(giftNameI18nId, null, gift.getGiftName(), locale);
|
||||
giftNameMap.put(locale.getLanguage(), text);
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("sender", usersService.getSimpleUserVo(sender));
|
||||
params.put("giftNameMap", giftNameMap);
|
||||
params.put("roomUid", room.getUid());
|
||||
params.put("times", multi.toPlainString());
|
||||
params.put("coins", outputValue.toPlainString());
|
||||
params.put("intratemporals", multi.toPlainString());
|
||||
params.put("tangerines", outputValue.toPlainString());
|
||||
|
||||
Attach attach = new Attach();
|
||||
attach.setFirst(Constant.DefMsgType.SUPER_LUCKY_GIFT);
|
||||
attach.setSecond(Constant.DefMsgType.BRAVO_GIFT_FLOAT);
|
||||
attach.setData(params);
|
||||
|
||||
sendSysMsgService.sendMessageToAllValidRooms(attach, room);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
package com.accompany.business.service.lucky;
|
||||
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.config.WebSecurityConfig;
|
||||
import com.accompany.common.constant.AppEnum;
|
||||
import com.accompany.common.push.MarkdownMessage;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.model.PartitionInfo;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.message.MessageRobotPushService;
|
||||
import com.accompany.core.service.partition.PartitionInfoService;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class BravoRobotMsgService {
|
||||
|
||||
@Autowired
|
||||
private WebSecurityConfig webSecurityConfig;
|
||||
@Autowired
|
||||
private MessageRobotPushService messageRobotPushService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private PartitionInfoService partitionInfoService;
|
||||
|
||||
@Async
|
||||
public void pushStockNotEnough(int partitionId, BigDecimal afterStock) {
|
||||
RBucket<MarkdownMessage> stockCache = redissonClient.getBucket(RedisKey.bravo_robot_push_msg.getKey("stock"));
|
||||
if (stockCache.isExists()){
|
||||
return;
|
||||
}
|
||||
|
||||
PartitionInfo partitionInfo = partitionInfoService.getById(partitionId);
|
||||
|
||||
MarkdownMessage markdownMessage = new MarkdownMessage();
|
||||
markdownMessage.addTitle(AppEnum.getCurApp().getValue() + "Bravo库存告急");
|
||||
markdownMessage.add("当前库存:" + afterStock.toPlainString());
|
||||
if (null != partitionInfo){
|
||||
markdownMessage.add("分区:" + partitionInfo.getDesc());
|
||||
}
|
||||
messageRobotPushService.pushMessageByKey(webSecurityConfig.getBravoStockWarningPushKey(), markdownMessage, false);
|
||||
|
||||
stockCache.set(markdownMessage, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Async
|
||||
public void pushSuperMulti(long senderUid, long receiverUid, long multi, long input, long output, Long roomUid) {
|
||||
RBucket<MarkdownMessage> multiCache = redissonClient.getBucket(RedisKey.bravo_robot_push_msg.getKey("multi", String.valueOf(senderUid)));
|
||||
if (multiCache.isExists()){
|
||||
return;
|
||||
}
|
||||
|
||||
Users sender = usersService.getNotNullUsersByUid(senderUid);
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(sender.getPartitionId());
|
||||
|
||||
Users receiver = usersService.getNotNullUsersByUid(receiverUid);
|
||||
Users room = null != roomUid? usersService.getNotNullUsersByUid(roomUid) : null;
|
||||
|
||||
MarkdownMessage markdownMessage = new MarkdownMessage();
|
||||
markdownMessage.addTitle(AppEnum.getCurApp().getValue() + "Bravo 1000通知");
|
||||
markdownMessage.add("送礼用户:" + String.format("%s(%d)%s", sender.getNick(), sender.getErbanNo(), partitionEnum.getDesc()));
|
||||
markdownMessage.add("收礼用户:" + String.format("%s(%d)", receiver.getNick(), receiver.getErbanNo()));
|
||||
markdownMessage.add("出发倍数:" + multi);
|
||||
markdownMessage.add("进入:" + input);
|
||||
markdownMessage.add("返回:" + output);
|
||||
if (null != room) {
|
||||
markdownMessage.add("房间id:" + room.getErbanNo());
|
||||
}
|
||||
markdownMessage.add("分区:" + partitionEnum.getDesc());
|
||||
messageRobotPushService.pushMessageByKey(webSecurityConfig.getBravoStockWarningPushKey(), markdownMessage, false);
|
||||
|
||||
multiCache.set(markdownMessage, 30, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Async
|
||||
public void pushFollowUser(long senderUid, long receiverUid, Long roomUid) {
|
||||
RBucket<MarkdownMessage> followCache = redissonClient.getBucket(RedisKey.bravo_robot_push_msg.getKey("follow"));
|
||||
if (followCache.isExists()){
|
||||
return;
|
||||
}
|
||||
|
||||
Users sender = usersService.getNotNullUsersByUid(senderUid);
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(sender.getPartitionId());
|
||||
|
||||
Users receiver = usersService.getNotNullUsersByUid(receiverUid);
|
||||
Users room = null != roomUid? usersService.getNotNullUsersByUid(roomUid) : null;
|
||||
|
||||
MarkdownMessage markdownMessage = new MarkdownMessage();
|
||||
markdownMessage.addTitle(AppEnum.getCurApp().getValue() + "Bravo用户上线通知");
|
||||
markdownMessage.add("送礼用户:" + String.format("%s(%d)%s", sender.getNick(), sender.getErbanNo(), partitionEnum.getDesc()));
|
||||
markdownMessage.add("收礼用户:" + String.format("%s(%d)", receiver.getNick(), receiver.getErbanNo()));
|
||||
markdownMessage.add("上线时间:" + DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATETIME_PATTERN));
|
||||
if (null != room) {
|
||||
markdownMessage.add("房间id:" + room.getErbanNo());
|
||||
}
|
||||
markdownMessage.add("分区:" + partitionEnum.getDesc());
|
||||
messageRobotPushService.pushMessageByKey(webSecurityConfig.getLucky24StockWarningPushKey(), markdownMessage, false);
|
||||
|
||||
followCache.set(markdownMessage, 30, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
}
|
@@ -1,10 +1,13 @@
|
||||
package com.accompany.business.service.lucky;
|
||||
|
||||
import com.accompany.business.dto.lucky.BravoGiftConfig;
|
||||
import com.accompany.business.event.BravoGiftGoldIncomeMessageEvent;
|
||||
import com.accompany.business.message.BravoGiftGoldIncomeMessage;
|
||||
import com.accompany.business.model.Gift;
|
||||
import com.accompany.business.service.gift.SuperLuckyGiftSendService;
|
||||
import com.accompany.business.service.gift.BravoMsgSendService;
|
||||
import com.accompany.business.service.purse.UserPurseService;
|
||||
import com.accompany.business.service.record.BillRecordService;
|
||||
import com.accompany.core.base.SpringContextHolder;
|
||||
import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.sharding.model.BravoRecord;
|
||||
@@ -24,7 +27,7 @@ public class BravoSettlementService {
|
||||
@Autowired
|
||||
private BillRecordService billRecordService;
|
||||
@Autowired
|
||||
private SuperLuckyGiftSendService superLuckyGiftSendService;
|
||||
private BravoMsgSendService msgSendService;
|
||||
|
||||
@Async
|
||||
public void sendReward(BravoGiftConfig config, long senderUid, Room room, Gift gift, BigDecimal winGoldNum, BigDecimal afterMultiple){
|
||||
@@ -33,17 +36,17 @@ public class BravoSettlementService {
|
||||
|
||||
//飘屏
|
||||
if (null != room){
|
||||
superLuckyGiftSendService.sendTip(senderUid, room, winGoldNum, afterMultiple,
|
||||
msgSendService.sendTip(senderUid, room, winGoldNum, afterMultiple,
|
||||
afterMultiple.compareTo(config.getSpecialTipMulti()) >= 0 ? 2 : 1);
|
||||
|
||||
if (winGoldNum.compareTo(config.getAllRoomChatToastValue()) > 0){
|
||||
superLuckyGiftSendService.sendAllRoomScreen(senderUid, room, gift, winGoldNum);
|
||||
msgSendService.sendAllRoomScreen(senderUid, room, gift, winGoldNum);
|
||||
}
|
||||
|
||||
//飘屏
|
||||
if (winGoldNum.compareTo(config.getSpecialFloatValue()) >= 0
|
||||
|| afterMultiple.compareTo(config.getSpecialFloatMulti()) >= 0) {
|
||||
superLuckyGiftSendService.sendFloating(room, senderUid, gift, afterMultiple, winGoldNum);
|
||||
msgSendService.sendFloating(room, senderUid, gift, afterMultiple, winGoldNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,6 +58,8 @@ public class BravoSettlementService {
|
||||
(userPurse)-> billRecordService.insertGiftSendBillRecord(record.getReceiverUid(), record.getUid(), record.getRoomUid(), null,
|
||||
BillObjTypeEnum.BRAVO_INCOME_ALLOT, income, record.getGiftId(), record.getGiftNum(), giftTotalGoldNum, record.getCreateTime(), userPurse));
|
||||
|
||||
//todo event
|
||||
BravoGiftGoldIncomeMessage goldIncomeMessage = new BravoGiftGoldIncomeMessage(
|
||||
record.getUid(), record.getReceiverUid(), record.getRoomUid(), record.getGiftId(), record.getGiftNum(), giftTotalGoldNum, income, record.getCreateTime());
|
||||
SpringContextHolder.getApplicationContext().publishEvent(new BravoGiftGoldIncomeMessageEvent(goldIncomeMessage));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user