幸运数字瓜分记录支持配置添加池子,结算的时候算到总数中去
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package com.accompany.admin.service.luckynumber;
|
||||
|
||||
import com.accompany.admin.vo.LuckyNumberActInputRecordAdminVo;
|
||||
import com.accompany.business.dto.activity.LuckyNumberActConfig;
|
||||
import com.accompany.business.model.activity.LuckyNumberActInputRecord;
|
||||
import com.accompany.business.model.activity.LuckyNumberActRound;
|
||||
import com.accompany.business.service.activity.LuckyNumberActPlayerRecordService;
|
||||
import com.accompany.business.service.activity.LuckyNumberActRoundService;
|
||||
import com.accompany.business.service.activity.LuckyNumberActService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.result.PageResult;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
@@ -18,6 +22,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -32,6 +41,8 @@ public class LuckyNumberActAdminService {
|
||||
private LuckyNumberActPlayerRecordService luckyNumberActPlayerRecordService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private LuckyNumberActService luckyNumberActService;
|
||||
|
||||
public BusiResult<PageResult<LuckyNumberActInputRecordAdminVo>> list(Integer partitionId, String date, String startDate, String endDate, Integer pageNo, Integer pageSize) {
|
||||
if (partitionId == null || partitionId == 0) {
|
||||
@@ -65,13 +76,29 @@ public class LuckyNumberActAdminService {
|
||||
Map<Long, Users> usersMap = usersService.getUsersMapByUids(uids);
|
||||
List<LuckyNumberActRound> roundByDates = luckyNumberActRoundService.getByDates(new ArrayList<>(dateStrs), partitionId);
|
||||
Map<String, LuckyNumberActRound> roundMap = roundByDates.stream().collect(Collectors.toMap(LuckyNumberActRound::getDate, x -> x));
|
||||
LuckyNumberActConfig config = luckyNumberActService.getConfig();
|
||||
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
ZonedDateTime now = DateTimeUtil.getDateTimeByZoneId(partitionEnum.getZoneId());
|
||||
String nowDate = now.format(DateTimeUtil.dateFormatter);
|
||||
LocalDate today = LocalDate.now();
|
||||
ZoneId zoneId = ZoneId.of(partitionEnum.getZoneId());
|
||||
ZonedDateTime roundWaitTime = LocalDateTime.of(today, config.getRoundWaitTime()).atZone(zoneId);
|
||||
ZonedDateTime roundEndTime = LocalDateTime.of(today, config.getRoundEndTime()).atZone(zoneId);
|
||||
|
||||
byte status = now.compareTo(roundWaitTime) < 0? Constant.status.delete:
|
||||
now.compareTo(roundEndTime) < 0? Constant.status.valid: Constant.status.invalid;
|
||||
boolean statusFlag = status <= Constant.status.valid;
|
||||
|
||||
for (LuckyNumberActInputRecord inputRecord : inputRecords) {
|
||||
LuckyNumberActInputRecordAdminVo luckyNumberActInputRecordAdminVo = new LuckyNumberActInputRecordAdminVo();
|
||||
LuckyNumberActRound luckyNumberActRound = roundMap.get(inputRecord.getDate());
|
||||
luckyNumberActInputRecordAdminVo.setLuckyNumber(luckyNumberActRound.getLuckyNumber());
|
||||
luckyNumberActInputRecordAdminVo.setJackpot(luckyNumberActRound.getJackpot());
|
||||
BigDecimal jackpot = luckyNumberActRound.getJackpot();
|
||||
if (nowDate.equals(inputRecord.getDate()) && statusFlag) {
|
||||
jackpot = jackpot.add(config.getConfigAddJackpot());
|
||||
}
|
||||
luckyNumberActInputRecordAdminVo.setJackpot(jackpot);
|
||||
luckyNumberActInputRecordAdminVo.setPartitionId(partitionId);
|
||||
luckyNumberActInputRecordAdminVo.setPartitionDesc(partitionEnum.getDesc());
|
||||
luckyNumberActInputRecordAdminVo.setDate(inputRecord.getDate());
|
||||
|
@@ -39,7 +39,8 @@ public class LuckyNumberActConfigAdminService {
|
||||
@SneakyThrows
|
||||
public void updateConfig(LuckyNumberAdminVo vo) {
|
||||
LuckyNumberActConfig config = luckyNumberActService.getConfig();
|
||||
LuckyNumberActConfig partitionConfig = config.getPartitionMap().computeIfAbsent(vo.getPartitionId(), k -> new LuckyNumberActConfig());
|
||||
Integer partitionId = vo.getPartitionId();
|
||||
LuckyNumberActConfig partitionConfig = config.getPartitionMap().computeIfAbsent(partitionId, k -> new LuckyNumberActConfig());
|
||||
if (null != vo.getJackpotRatio()) {
|
||||
partitionConfig.setJackpotRatio(vo.getJackpotRatio());
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ public class LuckyNumberActRound {
|
||||
private Integer playerNum;
|
||||
private BigDecimal jackpot;
|
||||
private BigDecimal lastJackpot;
|
||||
private BigDecimal configJackpot;
|
||||
private Integer luckyNumber;
|
||||
private Integer luckyPlayerNumber;
|
||||
private String endTime;
|
||||
|
@@ -10,7 +10,6 @@ public interface LuckyNumberActRoundMapper extends BaseMapper<LuckyNumberActRoun
|
||||
|
||||
void updateJackpot(@Param("date") String date, @Param("partitionId") Integer partitionId,
|
||||
@Param("jackpot") BigDecimal jackpot);
|
||||
|
||||
void initJackpot(@Param("date") String date, @Param("partitionId") Integer partitionId,
|
||||
@Param("lastJackpot") BigDecimal lastJackpot);
|
||||
|
||||
|
@@ -84,12 +84,14 @@ public class LuckyNumberActRoundService extends ServiceImpl<LuckyNumberActRoundM
|
||||
.collect(Collectors.toMap(LuckyNumberActRound::getDate, v -> v));
|
||||
}
|
||||
|
||||
public boolean saveLuckyNumber(String date, Integer partitionId, int luckyNumber, int luckyPlayerNum, String endTime) {
|
||||
public boolean saveLuckyNumber(String date, Integer partitionId, int luckyNumber, int luckyPlayerNum, String endTime, BigDecimal configAddJackpot) {
|
||||
return update(Wrappers.<LuckyNumberActRound>lambdaUpdate()
|
||||
.set(LuckyNumberActRound::getLuckyNumber, luckyNumber)
|
||||
.set(LuckyNumberActRound::getLuckyPlayerNumber, luckyPlayerNum)
|
||||
.set(LuckyNumberActRound::getEndTime, endTime)
|
||||
.set(LuckyNumberActRound::getUpdateTime, new Date())
|
||||
.set(LuckyNumberActRound::getConfigJackpot, configAddJackpot)
|
||||
.setIncrBy(LuckyNumberActRound::getJackpot, configAddJackpot)
|
||||
.eq(LuckyNumberActRound::getDate, date)
|
||||
.eq(LuckyNumberActRound::getPartitionId, partitionId)
|
||||
.isNull(LuckyNumberActRound::getLuckyNumber)
|
||||
|
@@ -3,7 +3,6 @@ package com.accompany.business.service.activity;
|
||||
|
||||
import com.accompany.business.common.constant.RewardTypeEnum;
|
||||
import com.accompany.business.constant.activity.ActivityRewardStatus;
|
||||
import com.accompany.business.constant.activity.ActivitySkipType;
|
||||
import com.accompany.business.constant.activity.ActivityType;
|
||||
import com.accompany.business.dto.activity.LuckyNumberActConfig;
|
||||
import com.accompany.business.model.activity.LuckyNumberActInputRecord;
|
||||
@@ -101,7 +100,9 @@ public class LuckyNumberActService {
|
||||
byte status = now.compareTo(roundWaitTime) < 0? Constant.status.delete:
|
||||
now.compareTo(roundEndTime) < 0? Constant.status.valid: Constant.status.invalid;
|
||||
|
||||
long countDownSecond = status <= Constant.status.valid? Duration.between(now, roundEndTime).getSeconds(): 0L;
|
||||
boolean statusFlag = status <= Constant.status.valid;
|
||||
|
||||
long countDownSecond = statusFlag ? Duration.between(now, roundEndTime).getSeconds(): 0L;
|
||||
|
||||
LuckyNumberActRoundVo vo = new LuckyNumberActRoundVo();
|
||||
vo.setUid(uid);
|
||||
@@ -113,7 +114,11 @@ public class LuckyNumberActService {
|
||||
vo.setPlayerNum(round.getPlayerNum());
|
||||
vo.setLuckyNumber(round.getLuckyNumber());
|
||||
vo.setLuckyPlayerNum(round.getLuckyPlayerNumber());
|
||||
vo.setJackpot(round.getJackpot());
|
||||
BigDecimal jackpot = round.getJackpot();
|
||||
if (statusFlag) {//还未开奖,需要加上配置补的
|
||||
jackpot = jackpot.add(config.getConfigAddJackpot());
|
||||
}
|
||||
vo.setJackpot(jackpot);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -397,10 +402,11 @@ public class LuckyNumberActService {
|
||||
}
|
||||
|
||||
if (null == luckyNumber){
|
||||
luckyNumber = RandomUtil.randomByRange(0, 99);
|
||||
luckyNumber = RandomUtil.randomByRange(0, config.getMaxSelectNumber());
|
||||
}
|
||||
|
||||
log.info("[luckyNumber] luckyNumber {} date {} partitionId {}", luckyNumber, date, partitionId);
|
||||
round.setJackpot(round.getJackpot().add(config.getConfigAddJackpot()));
|
||||
log.info("[luckyNumber] luckyNumber {} date {} partitionId {},configAddJackpot:{}", luckyNumber, date, partitionId, config.getConfigAddJackpot());
|
||||
|
||||
List<LuckyNumberActInputRecord> inputRecordList = playerRecordService.list(Wrappers.<LuckyNumberActInputRecord>lambdaQuery()
|
||||
.eq(LuckyNumberActInputRecord::getDate, date)
|
||||
@@ -422,7 +428,7 @@ public class LuckyNumberActService {
|
||||
|
||||
String endTime = LocalDateTime.of(LocalDate.parse(date, DateTimeUtil.dateFormatter), config.getRoundEndTime())
|
||||
.atZone(ZoneId.of(partitionEnum.getZoneId())).format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
|
||||
if (!roundService.saveLuckyNumber(date, partitionId, luckyNumber, luckyerMap.size(), endTime)){
|
||||
if (!roundService.saveLuckyNumber(date, partitionId, luckyNumber, luckyerMap.size(), endTime, config.getConfigAddJackpot())){
|
||||
log.error("[luckyNumber] saveLuckyNumber failure !!! date {} partitionId {} luckyNumber {}", luckyNumber, date, partitionId);
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
Reference in New Issue
Block a user