Commit 412a09fe authored by licc's avatar licc

优化最大进步奖

parent ebc0dbf0
...@@ -739,52 +739,54 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -739,52 +739,54 @@ public class MonthTaskServiceImpl implements MonthTaskService {
String yearMonth = DateUtil.convertDateToStr(lastMonth, PATTERN); String yearMonth = DateUtil.convertDateToStr(lastMonth, PATTERN);
List<ProgressPrize> addList = new ArrayList<>(); List<ProgressPrize> addList = new ArrayList<>();
List<ProgressPrize> updateList = new ArrayList<>(); List<ProgressPrize> updateList = new ArrayList<>();
if (number > 0) {
for (TeamPerformanceSortVo teamPerformanceSortVo : listVo) { for (TeamPerformanceSortVo teamPerformanceSortVo : listVo) {
String userId = teamPerformanceSortVo.getTeamPerformance().getUserId(); String userId = teamPerformanceSortVo.getTeamPerformance().getUserId();
Integer userLevel = teamPerformanceSortVo.getTeamPerformance().getUserLevel(); Integer userLevel = teamPerformanceSortVo.getTeamPerformance().getUserLevel();
//获取最大进步奖 百分比 //获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(userLevel, 3); MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(userLevel, 3);
//计算收益 //计算收益
double userTeamPerformance = teamPerformanceSortVo.getTeamPerformance().getMonthTeamPerformance().doubleValue(); double userTeamPerformance = teamPerformanceSortVo.getTeamPerformance().getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue(); double percent = memberPercent.getPercent().doubleValue();
double income = number * 3980 * percent * userTeamPerformance / total; double income = number * 3980 * percent * userTeamPerformance / total;
//获取账户信息 //获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(userId); AccountInfo accountInfo = accountMapper.getByUserId(userId);
//用户月收益 =其他收益+最大进步奖收益 //用户月收益 =其他收益+最大进步奖收益
BigDecimal earningsMonth = accountInfo.getEarningsMonth().add(BigDecimal.valueOf(income)); BigDecimal earningsMonth = accountInfo.getEarningsMonth().add(BigDecimal.valueOf(income));
accountInfo.setEarningsMonth(earningsMonth); accountInfo.setEarningsMonth(earningsMonth);
//用户总收益 =其他总收益 + 最大进步奖收益 //用户总收益 =其他总收益 + 最大进步奖收益
BigDecimal earningsTotal = accountInfo.getEarningsTotal().add(BigDecimal.valueOf(income)); BigDecimal earningsTotal = accountInfo.getEarningsTotal().add(BigDecimal.valueOf(income));
accountInfo.setEarningsTotal(earningsTotal); accountInfo.setEarningsTotal(earningsTotal);
updateAccountList.add(accountInfo); updateAccountList.add(accountInfo);
//最大进步奖信息 //最大进步奖信息
ProgressPrize progressPrize = progressPrizeMapper.getByUserIdYearMonth(userId, yearMonth); ProgressPrize progressPrize = progressPrizeMapper.getByUserIdYearMonth(userId, yearMonth);
if (null == progressPrize) { if (null == progressPrize) {
//新增 //新增
ProgressPrize addPrize = new ProgressPrize(); ProgressPrize addPrize = new ProgressPrize();
addPrize.setAwardMoney(income); addPrize.setAwardMoney(income);
addPrize.setYearMonth(yearMonth); addPrize.setYearMonth(yearMonth);
addPrize.setGrowthRate(0.0); addPrize.setGrowthRate(0.0);
addPrize.setUserId(userId); addPrize.setUserId(userId);
addList.add(addPrize); addList.add(addPrize);
} else { } else {
progressPrize.setGrowthRate(teamPerformanceSortVo.getGrowthRate()); progressPrize.setGrowthRate(teamPerformanceSortVo.getGrowthRate());
progressPrize.setAwardMoney(income); progressPrize.setAwardMoney(income);
updateList.add(progressPrize); updateList.add(progressPrize);
}
} }
}
//获取本月存在的最大进步奖列表 //获取本月存在的最大进步奖列表
List<ProgressPrize> prizes = progressPrizeMapper.getByYearMonth(yearMonth); List<ProgressPrize> prizes = progressPrizeMapper.getByYearMonth(yearMonth);
//修改或保存最大进步奖信息 //修改或保存最大进步奖信息
// flag 1: 日定时任务 2:月定时任务 // flag 1: 日定时任务 2:月定时任务
int flag = 2; int flag = 2;
return accountManager.updateOrSavePrize(updateAccountList, prizes, addList, updateList, flag); return accountManager.updateOrSavePrize(updateAccountList, prizes, addList, updateList, flag);
}
return true;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment