斋月活动-发奖励fixed2
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.accompany.business.mapper;
|
||||
|
||||
import com.accompany.business.activity.model.RamadanGiftSendTopReward;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 斋月送礼榜金币瓜分记录 Mapper 接口
|
||||
*
|
||||
* @author
|
||||
* @since 2025-02-24
|
||||
*/
|
||||
public interface RamadanGiftSendTopRewardMapper extends BaseMapper<RamadanGiftSendTopReward> {
|
||||
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.accompany.business.mapper.RamadanGiftSendTopRewardMapper">
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,64 @@
|
||||
package com.accompany.business.activity.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 斋月送礼榜金币瓜分记录实体类
|
||||
*
|
||||
* @author
|
||||
* @since 2025-02-24
|
||||
*/
|
||||
@Data
|
||||
public class RamadanGiftSendTopReward implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 奖励日期
|
||||
*/
|
||||
private String rewardDate;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long uid;
|
||||
/**
|
||||
* 排名
|
||||
*/
|
||||
private Integer rankTop;
|
||||
/**
|
||||
* 奖池总数
|
||||
*/
|
||||
private Double goldPool;
|
||||
/**
|
||||
* 送礼总数
|
||||
*/
|
||||
private Double sendGoldNum;
|
||||
/**
|
||||
* 前十总数
|
||||
*/
|
||||
private Double topGoldTotal;
|
||||
/**
|
||||
* 奖池瓜分比例
|
||||
*/
|
||||
private Double rewardGoldRate;
|
||||
/**
|
||||
* 瓜分金币
|
||||
*/
|
||||
private Double rewardGold;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package com.accompany.business.activity.service;
|
||||
|
||||
import com.accompany.business.activity.model.RamadanGiftSendTopReward;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 斋月送礼榜金币瓜分记录 服务类
|
||||
*
|
||||
* @author
|
||||
* @since 2025-02-24
|
||||
*/
|
||||
public interface RamadanGiftSendTopRewardService extends IService<RamadanGiftSendTopReward> {
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.accompany.business.activity.service.impl;
|
||||
|
||||
import com.accompany.business.activity.model.RamadanGiftSendTopReward;
|
||||
import com.accompany.business.activity.service.RamadanGiftSendTopRewardService;
|
||||
import com.accompany.business.mapper.RamadanGiftSendTopRewardMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 斋月送礼榜金币瓜分记录 服务实现类
|
||||
*
|
||||
* @author
|
||||
* @since 2025-02-24
|
||||
*/
|
||||
@Service
|
||||
public class RamadanGiftSendTopRewardServiceImpl extends ServiceImpl<RamadanGiftSendTopRewardMapper, RamadanGiftSendTopReward> implements RamadanGiftSendTopRewardService {
|
||||
|
||||
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
package com.accompany.business.ramadan.service;
|
||||
|
||||
import com.accompany.business.activity.model.RamadanGiftSendTopReward;
|
||||
import com.accompany.business.activity.service.RamadanGiftSendTopRewardService;
|
||||
import com.accompany.business.constant.activity.ActivityH5RedisKey;
|
||||
import com.accompany.business.constant.activity.ActivityType;
|
||||
import com.accompany.business.ramadan.constant.RamadanConstant;
|
||||
@@ -66,6 +68,9 @@ public class RamadanGiftSendService {
|
||||
@Autowired
|
||||
private BillRecordService billRecordService;
|
||||
|
||||
@Autowired
|
||||
private RamadanGiftSendTopRewardService ramadanGiftSendTopRewardService;
|
||||
|
||||
private static final String lastSendTimeAllFlag = "ALL";
|
||||
|
||||
public void calRamadanData(Byte giftType, Long goldNum, Long sendUid, Integer partitionId, Long luckyGiftGoldNum) {
|
||||
@@ -160,7 +165,8 @@ public class RamadanGiftSendService {
|
||||
activityH5RankVo.setStartTimeStr(config.getStartTime().format(DateTimeUtil.datetimeFormatter));
|
||||
activityH5RankVo.setEndTimeStr(config.getEndTime().format(DateTimeUtil.datetimeFormatter));
|
||||
}
|
||||
|
||||
activityH5RankVo.setMyRank(new ActivityH5UserVo());
|
||||
activityH5RankVo.setRankList(new ArrayList<>());
|
||||
calList(activityH5RankVo, pubUid, activityType, redisKeyAppend, lastSendTimeMap, size);
|
||||
|
||||
return BusiResult.success(ramadanRankVo);
|
||||
@@ -218,27 +224,34 @@ public class RamadanGiftSendService {
|
||||
BigDecimal topRanTenGoldNum =
|
||||
BigDecimal.valueOf(rankUserVos.stream().collect(Collectors.summingDouble(ActivityH5UserVo::getTotalNum)));
|
||||
Map<Long, BigDecimal> rankUserGoldRateMap = new HashMap<>();
|
||||
Map<Long, Integer> rankMap = new HashMap<>();
|
||||
Map<Long, Double> sendGoldMap = new HashMap<>();
|
||||
int rank = 1;
|
||||
for (ActivityH5UserVo rankUserVo : rankUserVos) {
|
||||
rankUserGoldRateMap.put(rankUserVo.getUid(), BigDecimal.valueOf(rankUserVo.getTotalNum()).divide(topRanTenGoldNum, 2, RoundingMode.DOWN));
|
||||
rankMap.put(rankUserVo.getUid(), rank++);
|
||||
sendGoldMap.put(rankUserVo.getUid(), rankUserVo.getTotalNum());
|
||||
}
|
||||
log.info("RamadanGiftSendService.dayTask-partitionId-{}-lastDayFormat{}-yesterdayPoolGold-{},, topRanTenGoldNum:{},rankUserGoldRateMap:{}",
|
||||
partitionId, lastDayFormat,yesterdayPoolGold, topRanTenGoldNum, JSONObject.toJSONString(rankUserGoldRateMap));
|
||||
Map<Long, BigDecimal> sendMap = new HashMap<>();
|
||||
BigDecimal bigDecimalYesterdayPoolGold = BigDecimal.valueOf(yesterdayPoolGold);
|
||||
BigDecimal needSendGold = BigDecimal.ZERO;
|
||||
Map<Long, BigDecimal> sendMap = new HashMap<>();
|
||||
for (Map.Entry<Long, BigDecimal> decimalEntry : rankUserGoldRateMap.entrySet()) {
|
||||
BigDecimal addGold = decimalEntry.getValue().multiply(bigDecimalYesterdayPoolGold).setScale(0, RoundingMode.DOWN);
|
||||
if (addGold.doubleValue() == 0) {
|
||||
continue;
|
||||
}
|
||||
sendMap.put(decimalEntry.getKey(), addGold);
|
||||
needSendGold = needSendGold.add(needSendGold.add(addGold));
|
||||
needSendGold = needSendGold.add(addGold);
|
||||
}
|
||||
if (needSendGold.doubleValue() > yesterdayPoolGold) {
|
||||
log.info("RamadanGiftSendService.dayTask-错误计算,不发奖励-partitionId-{}-lastDayFormat{}-yesterdayPoolGold-{},, topRanTenGoldNum:{},sendMap:{}",
|
||||
partitionId, lastDayFormat,yesterdayPoolGold, topRanTenGoldNum, JSONObject.toJSONString(sendMap));
|
||||
log.info("RamadanGiftSendService.dayTask-错误计算,不发奖励-partitionId-{}-lastDayFormat{}-yesterdayPoolGold-{},needSendGold:{}, topRanTenGoldNum:{},sendMap:{}",
|
||||
partitionId, lastDayFormat,yesterdayPoolGold, needSendGold,topRanTenGoldNum, JSONObject.toJSONString(sendMap));
|
||||
return;
|
||||
}
|
||||
List<RamadanGiftSendTopReward> records = new ArrayList<>();
|
||||
String format = zonedDateTime.minusDays(1).format(DateTimeUtil.dateFormatter);
|
||||
for (Map.Entry<Long, BigDecimal> decimalEntry : sendMap.entrySet()) {
|
||||
Long uid = decimalEntry.getKey();
|
||||
RSet<Long> rSet = activityRankRuleService.activityRewardSignLong(RAMADAN_GIFT_SEND_GOLD_POOL, lastDayFormat, partitionId);
|
||||
@@ -253,6 +266,20 @@ public class RamadanGiftSendService {
|
||||
String objId = RAMADAN_GIFT_SEND_GOLD_POOL.getName() + lastDayFormat + entryValue;
|
||||
userPurseService.addDiamond(uid, entryValue.doubleValue(), BillObjTypeEnum.RAMADAN_GIFT_SEND_RANK_GOLD,
|
||||
(up)-> billRecordService.insertGeneralBillRecord(uid, objId, BillObjTypeEnum.RAMADAN_GIFT_SEND_RANK_GOLD, entryValue.doubleValue(), up));
|
||||
RamadanGiftSendTopReward reward = new RamadanGiftSendTopReward();
|
||||
reward.setRewardDate(format);
|
||||
reward.setUid(uid);
|
||||
reward.setRankTop(rankMap.get(uid));
|
||||
reward.setGoldPool(bigDecimalYesterdayPoolGold.doubleValue());
|
||||
reward.setSendGoldNum(sendGoldMap.get(uid));
|
||||
reward.setTopGoldTotal(topRanTenGoldNum.doubleValue());
|
||||
BigDecimal bigDecimal = rankUserGoldRateMap.get(uid);
|
||||
if (bigDecimal != null) {
|
||||
reward.setRewardGoldRate(bigDecimal.doubleValue());
|
||||
}
|
||||
reward.setRewardGold(entryValue.doubleValue());
|
||||
reward.setCreateTime(nowDate);
|
||||
records.add(reward);
|
||||
}
|
||||
//备份
|
||||
activityRankRuleService.addTotalNum4String(RAMADAN_GIFT_SEND_GOLD_POOL_BAK, lastDayFormat, yesterdayPoolGold, partitionId.toString());
|
||||
@@ -262,6 +289,8 @@ public class RamadanGiftSendService {
|
||||
activityRankRuleService.getRankKey4String(RAMADAN_GIFT_SEND_GOLD_POOL, partitionId.toString()).expire(activityRankRuleService.expire, TimeUnit.DAYS);
|
||||
activityRankRuleService.getRankKey4String(RAMADAN_GIFT_SEND_GOLD_POOL_BAK, partitionId.toString()).expire(activityRankRuleService.expire, TimeUnit.DAYS);
|
||||
activityRankRuleService.getRankKey(RAMADAN_GIFT_SEND, lastDayFormat, partitionId.toString()).expire(activityRankRuleService.expire, TimeUnit.DAYS);
|
||||
|
||||
ramadanGiftSendTopRewardService.saveBatch(records);
|
||||
} catch (Exception e) {
|
||||
log.info("RamadanGiftSendService.totalTask-partitionId:{},e:{}", partitionId, e.getMessage(), e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user