|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateRange;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.EnumUtil;
|
|
import cn.hutool.core.util.EnumUtil;
|
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.td.boss.common.service.CommonServiceImpl;
|
|
import com.td.boss.common.service.CommonServiceImpl;
|
|
@@ -77,11 +78,11 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
|
|
|
*
|
|
*
|
|
|
* @param userId
|
|
* @param userId
|
|
|
*/
|
|
*/
|
|
|
- @Transactional
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@Override
|
|
|
public void asyncDisaster(String userId) {
|
|
public void asyncDisaster(String userId) {
|
|
|
- //同步“链端接口”上周“收入支出数据”到数据库
|
|
|
|
|
- ComPlayerDisaster comPlayerDisaster = disasterService.save(userId);
|
|
|
|
|
|
|
+ //获取“收入支出数据”,下一步计算灾难场数
|
|
|
|
|
+ ComPlayerDisaster comPlayerDisaster = disasterService.getAndSave(userId);
|
|
|
//如果从链端接口拉到数据了。那么就计算灾难发生明细
|
|
//如果从链端接口拉到数据了。那么就计算灾难发生明细
|
|
|
if (comPlayerDisaster != null) {
|
|
if (comPlayerDisaster != null) {
|
|
|
//本周内应该出现的灾难次数
|
|
//本周内应该出现的灾难次数
|
|
@@ -119,12 +120,12 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
|
|
|
* @param pay_amount 支出对应
|
|
* @param pay_amount 支出对应
|
|
|
* @param swap_amount 收入对应
|
|
* @param swap_amount 收入对应
|
|
|
*/
|
|
*/
|
|
|
- private int getDisasterTimes(Double pay_amount, Double swap_amount) {
|
|
|
|
|
- if (pay_amount > swap_amount * 0.8) {
|
|
|
|
|
|
|
+ private int getDisasterTimes(double pay_amount, double swap_amount) {
|
|
|
|
|
+ if (pay_amount > NumberUtil.mul(swap_amount, 0.8)) {
|
|
|
return 6;
|
|
return 6;
|
|
|
- } else if (pay_amount > swap_amount * 0.5) {
|
|
|
|
|
|
|
+ } else if (pay_amount > NumberUtil.mul(swap_amount, 0.5)) {
|
|
|
return 4;
|
|
return 4;
|
|
|
- } else if (pay_amount > swap_amount * 0.3) {
|
|
|
|
|
|
|
+ } else if (pay_amount > NumberUtil.mul(swap_amount, 0.3)) {
|
|
|
return 2;
|
|
return 2;
|
|
|
} else {
|
|
} else {
|
|
|
return 1;
|
|
return 1;
|
|
@@ -169,7 +170,7 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
|
|
|
/**
|
|
/**
|
|
|
* 灾难模式天任务:触发所有用户今日灾难和保护机制
|
|
* 灾难模式天任务:触发所有用户今日灾难和保护机制
|
|
|
*/
|
|
*/
|
|
|
- @Transactional
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@Override
|
|
|
public void ComPlayerDisasterDayTask(ComPlayerDisasterLog disasterLog) {
|
|
public void ComPlayerDisasterDayTask(ComPlayerDisasterLog disasterLog) {
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
@@ -205,13 +206,12 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
|
|
|
|
|
|
|
|
log.info("灾难日志:{}", JSONUtil.toJsonStr(disasterLog));
|
|
log.info("灾难日志:{}", JSONUtil.toJsonStr(disasterLog));
|
|
|
comPlayerDisasterLogRepository.save(disasterLog);
|
|
comPlayerDisasterLogRepository.save(disasterLog);
|
|
|
- //todo 应该还有个减产的接口,此处但是先不做
|
|
|
|
|
|
|
+ //todo 减产接口 减产逻辑
|
|
|
if (!disasterLog.isProtect()) {
|
|
if (!disasterLog.isProtect()) {
|
|
|
log.info("灾难结果:减产");
|
|
log.info("灾难结果:减产");
|
|
|
} else {
|
|
} else {
|
|
|
log.info("灾难结果:已防御");
|
|
log.info("灾难结果:已防御");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|