福袋上新-record增加luckyBagNum和giftNum
This commit is contained in:
@@ -16,7 +16,9 @@ public class LuckyBagMessage implements Serializable {
|
||||
private Long receiveUid; // 收礼人uid
|
||||
private Long roomUid; // 房主uid
|
||||
private Integer luckyBagId; // 福袋id
|
||||
private Integer luckyBagNum;
|
||||
private Integer giftId; // 礼物id
|
||||
private Integer giftNum;
|
||||
private Integer totalGoldNum; // 福袋时价
|
||||
private Date createTime; // 创建时间
|
||||
private Integer drawGiftGold; // 开出礼物价值
|
||||
|
@@ -28,19 +28,26 @@ public class LuckyBagRecord implements Serializable {
|
||||
private Long uid; // 赠送人uid
|
||||
private Long receiveUid; // 收礼人uid
|
||||
private Long roomUid; // 房主uid
|
||||
|
||||
private Integer luckyBagId; // 福袋id
|
||||
private Integer prizeLevel;
|
||||
private Integer giftId; // 礼物id
|
||||
private Integer luckyBagNum;
|
||||
private Integer totalGoldNum; // 福袋时价
|
||||
private Date createTime; // 创建时间
|
||||
// 奖池类型
|
||||
private Byte poolType;
|
||||
// 偏差池id
|
||||
private Integer deviateRangeId;
|
||||
|
||||
private Integer giftId; // 礼物id
|
||||
private Integer prizeLevel;
|
||||
private Integer giftNum;
|
||||
// 开出礼物名称
|
||||
private String giftName;
|
||||
// 开出礼物平台价值
|
||||
private Integer platformValue;
|
||||
|
||||
private Date createTime; // 创建时间
|
||||
|
||||
// 奖池类型
|
||||
private Byte poolType;
|
||||
// 偏差池id
|
||||
private Integer deviateRangeId;
|
||||
|
||||
private Long linearPoolId; //线性福袋ID
|
||||
private Byte linearPoolType; //线性福袋奖池类型
|
||||
}
|
||||
|
@@ -0,0 +1,46 @@
|
||||
package com.accompany.business.vo.luckybag;
|
||||
|
||||
import com.accompany.common.annotation.ReplaceAppDomain;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2023/7/13 11:30
|
||||
* @description:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class LuckyBagRecordRankItemVo {
|
||||
|
||||
private Long sendUid;
|
||||
private Long sendErbanNo;
|
||||
private String sendNick;
|
||||
@ReplaceAppDomain
|
||||
private String sendAvatar;
|
||||
|
||||
private Long receiveUid;
|
||||
private Long receiveErbanNo;
|
||||
private String receiveNick;
|
||||
@ReplaceAppDomain
|
||||
private String receiveAvatar;
|
||||
|
||||
|
||||
private Integer luckyBagId;
|
||||
private String luckyBagName;
|
||||
private Integer luckyBagNum;
|
||||
|
||||
private Integer giftId;
|
||||
/**
|
||||
* 礼物名称
|
||||
*/
|
||||
private String giftName;
|
||||
private Integer giftNum;
|
||||
@ReplaceAppDomain
|
||||
private String giftUrl;
|
||||
private Long goldPrice;
|
||||
|
||||
private Date createTime;
|
||||
}
|
@@ -902,9 +902,17 @@ public class GiftSendService extends BaseService {
|
||||
for (Long receiveUid : drawMap.keySet()) {
|
||||
// 用户抽到奖池礼物列表
|
||||
List<LuckyBagDrawItemVo> drawItems = drawMap.get(receiveUid);
|
||||
for (LuckyBagDrawItemVo drawItem : drawItems) {
|
||||
Map<Integer, List<LuckyBagDrawItemVo>> drawItemMap = drawItems.stream().collect(Collectors.groupingBy(LuckyBagDrawItemVo::getGiftId));
|
||||
Map<Integer, Long> drawGiftNumMap = drawItems.stream()
|
||||
.collect(Collectors.groupingBy(LuckyBagDrawItemVo::getGiftId, Collectors.counting()));
|
||||
|
||||
// 处理送礼记录
|
||||
for (Integer giftId : drawItemMap.keySet()) {
|
||||
LuckyBagDrawItemVo drawItem = drawItemMap.get(giftId).get(0);
|
||||
|
||||
Integer drawNum = drawGiftNumMap.get(giftId).intValue();
|
||||
Gift drawGift = giftMap.get(giftId);
|
||||
// 处理需要展示的礼物
|
||||
Gift drawGift = drawItem.getRefGift();
|
||||
if (drawGift.getGoldPrice() > displayGift[0].getGoldPrice()) {
|
||||
displayGift[0] = drawGift;
|
||||
}
|
||||
@@ -916,39 +924,31 @@ public class GiftSendService extends BaseService {
|
||||
}
|
||||
|
||||
// 处理需要需要插入记录的数据
|
||||
LuckyBagRecord record = LuckyBagRecord.builder().uid(sendUid).receiveUid(receiveUid)
|
||||
.roomUid(roomUid).luckyBagId(gift.getGiftId()).giftId(drawGift.getGiftId())
|
||||
.prizeLevel(prizeLevel)
|
||||
LuckyBagRecord record = LuckyBagRecord.builder().uid(sendUid).receiveUid(receiveUid).roomUid(roomUid)
|
||||
.luckyBagId(gift.getGiftId()).luckyBagNum(giftNum)
|
||||
.totalGoldNum(gift.getGoldPrice().intValue())
|
||||
.giftId(drawGift.getGiftId()).giftNum(drawNum).prizeLevel(prizeLevel)
|
||||
.giftName(drawGift.getGiftName()).platformValue(drawGift.getGoldPrice().intValue())
|
||||
.createTime(sendTime).poolType(drawItem.getPoolType())
|
||||
.deviateRangeId(drawItem.getDeviateRangeId()).giftName(drawGift.getGiftName())
|
||||
.platformValue(drawGift.getGoldPrice().intValue())
|
||||
.deviateRangeId(drawItem.getDeviateRangeId())
|
||||
.build();
|
||||
luckyBagRecordList.add(record);
|
||||
|
||||
// 发送福袋事件
|
||||
luckyBagSendService.sendLuckyBagMessage(null, sendUid, receiveUid, roomUid, gift.getGiftId(), drawGift.getGiftId(),
|
||||
gift.getGoldPrice().intValue(), sendTime, drawGift.getGoldPrice().intValue());
|
||||
}
|
||||
luckyBagSendService.sendLuckyBagMessage(sendUid, receiveUid, roomUid, gift.getGiftId(), giftNum, gift.getGoldPrice().intValue(),
|
||||
drawGift.getGiftId(), drawNum, drawGift.getGoldPrice().intValue(), sendTime);
|
||||
|
||||
Map<Integer, List<LuckyBagDrawItemVo>> drawItemMap = drawItems.stream().collect(Collectors.groupingBy(LuckyBagDrawItemVo::getGiftId));
|
||||
Map<Integer, Long> drawGiftNumMap = drawItems.stream()
|
||||
.collect(Collectors.groupingBy(LuckyBagDrawItemVo::getGiftId, Collectors.counting()));
|
||||
|
||||
// 处理送礼记录
|
||||
for (Integer giftId : drawItemMap.keySet()) {
|
||||
Long drawNum = drawGiftNumMap.get(giftId);
|
||||
Gift drawGift = giftMap.get(giftId);
|
||||
Long everyGoldNum = Math.abs(drawNum * drawGift.getGoldPrice()); // 礼物金币总数
|
||||
// 发送队列消息
|
||||
sendGiftMessage2MQ(sendUid, receiveUid, roomUid, drawGift.getGiftId(), drawGift.getConsumeType(), drawGift.getGiftType(), drawNum.intValue(), everyGoldNum,
|
||||
sendGiftMessage2MQ(sendUid, receiveUid, roomUid, drawGift.getGiftId(), drawGift.getConsumeType(), drawGift.getGiftType(), drawNum, everyGoldNum,
|
||||
sendType, roomType, msg, giftSource, true);
|
||||
// 更新房间礼物值
|
||||
updateRoomGiftValue(room, Arrays.asList(receiveUid), everyGoldNum, sendUid, false);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Long, Map<Integer, Integer>> map = new HashMap<>();
|
||||
// 异步插入记录
|
||||
luckyBagSendService.asyncSaveRecord(luckyBagRecordList);
|
||||
|
||||
// 更新用户福袋偏差
|
||||
List<LuckyBagDrawItemVo> allDrawGifts = new ArrayList<>();
|
||||
@@ -960,15 +960,12 @@ public class GiftSendService extends BaseService {
|
||||
for (LuckyBagDrawItemVo vo : drawLists) {
|
||||
a.put(vo.getGiftId(), a.getOrDefault(vo.getGiftId(), 0));
|
||||
}
|
||||
map.put(recvUid, a);
|
||||
}
|
||||
updateUserAndPlatformDeviate(spendGold, allDrawGifts, sendTime, sendUid, gift.getGiftId());
|
||||
|
||||
List<RoomGiftValueVo> giftValueVos = roomGiftValueService.getAllGiftValue(roomUid, recvUids);
|
||||
// 异步插入记录
|
||||
luckyBagSendService.asyncSaveRecord(luckyBagRecordList);
|
||||
// 异步飘屏通知
|
||||
if (notifyPoolMap.size() > 0) {
|
||||
if (!notifyPoolMap.isEmpty()) {
|
||||
luckyBagSendService.sendLuckyBagMsg(sendUid, room, gift, notifyPoolMap, prizeLevelMap);
|
||||
}
|
||||
List<Gift> displayGifts = new ArrayList<>(Arrays.asList(displayGift));
|
||||
@@ -1075,7 +1072,8 @@ public class GiftSendService extends BaseService {
|
||||
record.setUid(sendUid);
|
||||
record.setReceiveUid(recvUid);
|
||||
record.setRoomUid(roomUid);
|
||||
record.setLuckyBagId(gift.getGiftId());
|
||||
record.setLuckyBagId(luckyBagGiftId);
|
||||
record.setLuckyBagId(giftNum);
|
||||
record.setTotalGoldNum(luckyBagGoldPrice);
|
||||
|
||||
Integer giftId = record.getGiftId();
|
||||
@@ -1090,8 +1088,10 @@ public class GiftSendService extends BaseService {
|
||||
luckyBagRecordList.add(record);
|
||||
|
||||
// 发送福袋事件
|
||||
luckyBagSendService.sendLuckyBagMessage(null, record.getUid(), record.getReceiveUid(), record.getRoomUid(), record.getLuckyBagId(), record.getGiftId(),
|
||||
record.getTotalGoldNum(), record.getCreateTime(), record.getPlatformValue());
|
||||
luckyBagSendService.sendLuckyBagMessage(record.getUid(), record.getReceiveUid(), record.getRoomUid(),
|
||||
record.getLuckyBagId(), record.getLuckyBagNum(), record.getTotalGoldNum(),
|
||||
record.getGiftId(), record.getGiftNum(), record.getPlatformValue(),
|
||||
record.getCreateTime());
|
||||
|
||||
Integer num = giftIdNumMap.getOrDefault(giftId, 0);
|
||||
giftIdNumMap.put(giftId, ++num);
|
||||
|
@@ -159,10 +159,11 @@ public class LuckyBagSendService extends BaseService {
|
||||
|
||||
|
||||
@Async
|
||||
public void sendLuckyBagMessage(Long id,Long sendUid,Long recvUid,Long roomUid, Integer luckyBagId,
|
||||
Integer giftId,Integer totalGoldNum,Date date,
|
||||
Integer drawGiftPrice){
|
||||
LuckyBagMessage message = buildLuckyBagMessag(id, sendUid, recvUid, roomUid, luckyBagId, giftId, totalGoldNum, date, drawGiftPrice);
|
||||
public void sendLuckyBagMessage(Long sendUid,Long recvUid,Long roomUid,
|
||||
Integer luckyBagId, Integer luckyBagNum, Integer totalGoldNum,
|
||||
Integer giftId, Integer giftNum, Integer drawGiftPrice,
|
||||
Date date){
|
||||
LuckyBagMessage message = buildLuckyBagMessag(sendUid, recvUid, roomUid, luckyBagId, luckyBagNum, totalGoldNum, giftId, giftNum, drawGiftPrice, date);
|
||||
try {
|
||||
// 发送福袋事件
|
||||
applicationContext.publishEvent(new LuckyBagMessageEvent(message));
|
||||
@@ -171,16 +172,19 @@ public class LuckyBagSendService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
private LuckyBagMessage buildLuckyBagMessag(Long id,Long sendUid,Long recvUid,Long roomUid,
|
||||
Integer luckyBagId,Integer giftId,Integer totalGoldNum,Date date,
|
||||
Integer drawGiftPrice){
|
||||
private LuckyBagMessage buildLuckyBagMessag(Long sendUid,Long recvUid,Long roomUid,
|
||||
Integer luckyBagId, Integer luckyBagNum, Integer totalGoldNum,
|
||||
Integer giftId, Integer giftNum, Integer drawGiftPrice,
|
||||
Date date){
|
||||
LuckyBagMessage luckyBagMessage = new LuckyBagMessage();
|
||||
luckyBagMessage.setMessId(UUIDUtil.get());
|
||||
luckyBagMessage.setUid(sendUid);
|
||||
luckyBagMessage.setReceiveUid(recvUid);
|
||||
luckyBagMessage.setRoomUid(roomUid);
|
||||
luckyBagMessage.setLuckyBagId(luckyBagId);
|
||||
luckyBagMessage.setLuckyBagNum(luckyBagNum);
|
||||
luckyBagMessage.setGiftId(giftId);
|
||||
luckyBagMessage.setGiftNum(giftNum);
|
||||
luckyBagMessage.setTotalGoldNum(totalGoldNum);
|
||||
luckyBagMessage.setCreateTime(date);
|
||||
luckyBagMessage.setDrawGiftGold(drawGiftPrice);
|
||||
|
@@ -88,16 +88,15 @@ public class LuckyBagLinearPoolService extends ServiceImpl<LuckyBagLinearPoolMap
|
||||
LuckyBagLinearPoolItem item = entry.getKey();
|
||||
Integer itemNum = entry.getValue();
|
||||
|
||||
for (int i = 0; i < itemNum; i++) {
|
||||
LuckyBagRecord luckyBagRecord = new LuckyBagRecord();
|
||||
luckyBagRecord.setGiftId(item.getGiftId());
|
||||
luckyBagRecord.setPoolType((byte) 0);
|
||||
luckyBagRecord.setDeviateRangeId(0);
|
||||
luckyBagRecord.setLinearPoolId(item.getPoolId());
|
||||
luckyBagRecord.setLinearPoolType(item.getPoolType());
|
||||
luckyBagRecord.setCreateTime(now);
|
||||
recordList.add(luckyBagRecord);
|
||||
}
|
||||
LuckyBagRecord luckyBagRecord = new LuckyBagRecord();
|
||||
luckyBagRecord.setGiftId(item.getGiftId());
|
||||
luckyBagRecord.setGiftNum(itemNum);
|
||||
luckyBagRecord.setPoolType((byte) 0);
|
||||
luckyBagRecord.setDeviateRangeId(0);
|
||||
luckyBagRecord.setLinearPoolId(item.getPoolId());
|
||||
luckyBagRecord.setLinearPoolType(item.getPoolType());
|
||||
luckyBagRecord.setCreateTime(now);
|
||||
recordList.add(luckyBagRecord);
|
||||
|
||||
if (Constant.PrizePoolType.WHITE.equals(item.getPoolType())) {
|
||||
SpringContextHolder.getBean(LuckyBagLinearPoolService.class).sendHighOutPutBoard(luckyBagGiftId, item, sendUid, recvUid, itemNum);
|
||||
|
@@ -4,10 +4,18 @@ import com.accompany.business.dto.lucky.LuckyBagRecordDto;
|
||||
import com.accompany.business.model.Gift;
|
||||
import com.accompany.business.model.luckybag.LuckyBagRecord;
|
||||
import com.accompany.business.mybatismapper.luckybag.LuckyBagRecordMapper;
|
||||
import com.accompany.business.service.gift.GiftService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.luckybag.LuckyBagGiftIncomeVo;
|
||||
import com.accompany.business.vo.luckybag.LuckyBagRecordRankItemVo;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.redisson.api.RList;
|
||||
import org.redisson.api.RQueue;
|
||||
@@ -16,9 +24,10 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
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.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class LuckyBagRecordService extends ServiceImpl<LuckyBagRecordMapper, LuckyBagRecord> implements InitializingBean {
|
||||
@@ -26,6 +35,10 @@ public class LuckyBagRecordService extends ServiceImpl<LuckyBagRecordMapper, Luc
|
||||
private LuckyBagRecordMapper luckyBagRecordMapper;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private GiftService giftService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
|
||||
private RList<LuckyBagRecordDto> bannerRecordQueue;
|
||||
|
||||
@@ -67,6 +80,42 @@ public class LuckyBagRecordService extends ServiceImpl<LuckyBagRecordMapper, Luc
|
||||
return bannerRecordQueue.range(10);
|
||||
}
|
||||
|
||||
public List<LuckyBagRecordRankItemVo> getRank(Integer giftId) {
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
if (null == gift
|
||||
|| (Constant.GiftType.LUCKY_BAG != gift.getGiftType() && Constant.GiftType.LUCKY_BAG_LINEAR != gift.getGiftType())){
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
|
||||
QueryWrapper<LuckyBagRecord> queryWrapper = Wrappers.query();
|
||||
queryWrapper.lambda().eq(LuckyBagRecord::getLuckyBagId, giftId)
|
||||
.ge(LuckyBagRecord::getPrizeLevel, Constant.PrizePoolType.ORDINARY)
|
||||
.orderByDesc(LuckyBagRecord::getId, LuckyBagRecord::getPlatformValue);
|
||||
queryWrapper.last("limit 100");
|
||||
|
||||
List<LuckyBagRecord> list = list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<LuckyBagRecordRankItemVo> voList = new ArrayList<>();
|
||||
|
||||
List<Long> uidList = new ArrayList<>();
|
||||
for (LuckyBagRecord record: list) {
|
||||
uidList.add(record.getUid());
|
||||
uidList.add(record.getReceiveUid());
|
||||
}
|
||||
|
||||
Map<Long, Users> usersMap = usersService.getUsersMapByUids(uidList.stream().distinct().collect(Collectors.toList()));
|
||||
|
||||
for (LuckyBagRecord record: list) {
|
||||
LuckyBagRecordRankItemVo vo = new LuckyBagRecordRankItemVo();
|
||||
|
||||
}
|
||||
|
||||
return voList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
bannerRecordQueue = redissonClient.getList(RedisKey.lucky_bag_banner_record.getKey());
|
||||
|
@@ -4,6 +4,7 @@ import com.accompany.business.dto.lucky.LuckyBagRecordDto;
|
||||
import com.accompany.business.service.luckybag.LuckyBagLinearPoolService;
|
||||
import com.accompany.business.service.luckybag.LuckyBagPoolService;
|
||||
import com.accompany.business.service.luckybag.LuckyBagRecordService;
|
||||
import com.accompany.business.vo.luckybag.LuckyBagRecordRankItemVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
@@ -58,4 +59,14 @@ public class LuckyBagController {
|
||||
return new BusiResult<>(luckyBagRecordService.getBannerList());
|
||||
}
|
||||
|
||||
@ApiOperation("获取福袋礼物手气榜单")
|
||||
@GetMapping(value = "/getRank")
|
||||
public BusiResult<List<LuckyBagRecordRankItemVo>> getRank(Integer giftId) {
|
||||
if (null == giftId) {
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
List<LuckyBagRecordRankItemVo> rankVoList = luckyBagRecordService.getRank(giftId);
|
||||
return new BusiResult<>(rankVoList);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user