release: 美化中奖通知

release-2024-04-25
huangyw 1 month ago
parent 231d490989
commit 32f48d6da8

@ -3,9 +3,11 @@ package com.luoo.user.service;
import com.luoo.user.dao.LotteryDao;
import com.luoo.user.dao.LotteryRegionDao;
import com.luoo.user.dao.LotteryUserDao;
import com.luoo.user.dao.UserInfoDao;
import com.luoo.user.pojo.Lottery;
import com.luoo.user.pojo.LotteryRegion;
import com.luoo.user.pojo.LotteryUser;
import com.luoo.user.pojo.UserInfo;
import constants.Constants;
import constants.ErrorConstants;
import dto.UserLoginDto;
@ -31,6 +33,24 @@ import java.util.*;
@Service
public class DrawLotteryService {
// 中奖信息
String[] winLotteryMessages = {
"恭喜你中奖了,你的运气真是太好了,连我都想跟你借钱买彩票了!",
"看来你的运气被幸运星咬了一口,中了个大奖!",
"你这是中了头奖,是不是昨晚做梦都在笑啊?",
"你的手气真是好得不得了,我都怀疑你是不是偷偷摸摸地跟财神爷打了招呼!",
"恭喜你中奖,你这是要发家致富的节奏啊!",
"你这是要把彩票中心吃垮的节奏啊,中了这么多奖!",
"你的运气真是好得让人眼红,我都想拜你为师,学学怎么中奖!",
"你的中奖概率比被闪电击中还低,你真是天生的幸运儿!",
"你的中奖记录比我的恋爱记录还丰富,真是让人羡慕嫉妒恨!",
"恭喜你中奖,你这是要成为我们朋友圈的土豪啊!",
"你这是要把彩票中心的钱都赢光,让他们破产吗?",
"你的中奖运气真是让人羡慕,我都想去拜拜财神爷,看看能不能沾沾你的光!",
"你的中奖记录比我的考试成绩还高,真是让人佩服得五体投地!",
"恭喜你中奖,你这是要成为我们村里的大富翁啊!"
};
private final LotteryDao lotteryDao;
private final LotteryRegionDao lotteryRegionDao;
@ -41,12 +61,15 @@ public class DrawLotteryService {
private final UserMessageService userMessageService;
public DrawLotteryService(LotteryDao lotteryDao, LotteryRegionDao lotteryRegionDao, LotteryUserDao lotteryUserDao, JwtUtil jwtUtil, UserMessageService userMessageService) {
private final UserInfoDao userInfoDao;
public DrawLotteryService(LotteryDao lotteryDao, LotteryRegionDao lotteryRegionDao, LotteryUserDao lotteryUserDao, JwtUtil jwtUtil, UserMessageService userMessageService, UserInfoDao userInfoDao) {
this.lotteryDao = lotteryDao;
this.lotteryRegionDao = lotteryRegionDao;
this.lotteryUserDao = lotteryUserDao;
this.jwtUtil = jwtUtil;
this.userMessageService = userMessageService;
this.userInfoDao = userInfoDao;
}
public List<Lottery> findSigningList() {
@ -82,7 +105,7 @@ public class DrawLotteryService {
List<LotteryUser> lotteryUserList = lotteryUserDao.findByLotteryIdAndRegionIdAndShowTime(id,
lotteryRegion.getRegionId(), lotteryRegion.getShowTime());
lotteryFunc(token, lotteryUserList, num);
lotteryFunc(token, lotteryUserList, num, lottery);
}
});
@ -91,7 +114,7 @@ public class DrawLotteryService {
// 实物抽奖业务
List<LotteryUser> byLotteryId = lotteryUserDao.findByLotteryId(id);
lotteryFunc(token, byLotteryId, lottery.getNum());
lotteryFunc(token, byLotteryId, lottery.getNum(), lottery);
}
// 抽奖状态为报名中,自动抽奖
@ -106,8 +129,9 @@ public class DrawLotteryService {
* @param token
* @param lotteryUserList
* @param num
* @param lottery
*/
private void lotteryFunc(String token, List<LotteryUser> lotteryUserList, Integer num) {
private void lotteryFunc(String token, List<LotteryUser> lotteryUserList, Integer num, Lottery lottery) {
List<LotteryUser> winnerList = new ArrayList<>();
if (lotteryUserList.size() > num) {
// 抽奖人数大于设定人数
@ -132,8 +156,14 @@ public class DrawLotteryService {
userMessageDto.setType(MessageTypeEnum.PRIVATE_MESSAGE.getType());
userMessageDto.setSendUserId(StringUtils.isNotBlank(token) ? jwtUtil.getUserLoginDto(token).getUserId() : null);
userMessageDto.setTitle("恭喜中奖!");
userMessageDto.setContent("恭喜中奖请加微信XXXXXX");
userMessageDto.setUserId(lotteryUser.getUserId());
String userId = lotteryUser.getUserId();
UserInfo userInfo = userInfoDao.getById(userId);
String content = "亲爱的" + userInfo.getNickName() + ",您在积分抽奖 " + lottery.getTitle() + " 中幸运中奖,可以加微信号 indier 联系到我们。";
// winLotteryMessages 随机选取一条
userMessageDto.setContent(content + winLotteryMessages[new Random().nextInt(winLotteryMessages.length)]);
userMessageDto.setUserId(userId);
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX + (StringUtils.isNotBlank(token) ? jwtUtil.getUserLoginDto(token).getAvatar() : null));
userMessageDto.setSendUserNickName(StringUtils.isNotBlank(token) ? jwtUtil.getUserLoginDto(token).getNickName() : null);
userMessageService.sendUserMessage(userMessageDto);

Loading…
Cancel
Save