Merge branch 'test' into dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.sqx.modules.discSpinning.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -36,6 +37,7 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -160,7 +162,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
||||
try {
|
||||
withdraw(userInfo, money, title);
|
||||
transactionManager.commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
transactionManager.rollback(transactionStatus);
|
||||
throw e;
|
||||
}
|
||||
@@ -169,15 +171,20 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
||||
@Override
|
||||
@Transactional
|
||||
public DiscSpinningRecord draws(int drawCount, double orderAmount, Long sourceId, Long userId, Integer source) {
|
||||
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, null);
|
||||
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, BigDecimal.ZERO);
|
||||
List<DiscSpinning> prizes = baseMapper.selectList(new QueryWrapper<DiscSpinning>().eq("disc_type", source).orderByAsc("odds"));
|
||||
|
||||
if (CollectionUtil.isEmpty(prizes)) {
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), sourceId, userId, result.getUrl(), result.getType(),
|
||||
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
||||
recordService.save(record);
|
||||
return record;
|
||||
}
|
||||
Random random = new Random();
|
||||
double randomDouble;
|
||||
do {
|
||||
randomDouble = random.nextDouble();
|
||||
} while (randomDouble == 0);
|
||||
BigDecimal randomNum = new BigDecimal(randomDouble).multiply(new BigDecimal(10000)).divide(new BigDecimal(100));
|
||||
BigDecimal maxNumber = prizes.stream()
|
||||
.map(DiscSpinning::getNumber)
|
||||
.max(BigDecimal::compareTo)
|
||||
.orElse(null);
|
||||
BigDecimal randomNum = new BigDecimal(ThreadLocalRandom.current().nextDouble(0.0001, maxNumber.doubleValue()) * 10000 / 100);
|
||||
|
||||
List<DiscSpinningAmount> amounts = new ArrayList<>();
|
||||
Map<String, List<DiscSpinningAmount>> amountMaps = redisUtils.getMapData(RedisKeys.getDateKey("spinning:amount"), "setDiscSpinningAmounts", DiscSpinningAmount.class);
|
||||
@@ -222,7 +229,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
||||
}
|
||||
}
|
||||
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), sourceId, userId,result.getUrl(), result.getType(),
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), sourceId, userId, result.getUrl(), result.getType(),
|
||||
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
||||
recordService.save(record);
|
||||
return record;
|
||||
|
||||
@@ -20,6 +20,8 @@ public class TaskCenterReward extends Model<TaskCenterReward> {
|
||||
private Long id;
|
||||
@ApiModelProperty("任务Id")
|
||||
private Long taskId;
|
||||
@ApiModelProperty("图片")
|
||||
private String img;
|
||||
@ApiModelProperty("奖励名称")
|
||||
private String name;
|
||||
@ApiModelProperty("奖励类型 1 金币 2 现金红包 3 4 5 9 大转盘抽奖次数")
|
||||
|
||||
Reference in New Issue
Block a user