Commit 16964532 authored by licc's avatar licc

优化月度肥料任务

parent 05ea4456
......@@ -212,7 +212,7 @@ public class DayTaskServiceImpl implements DayTaskService {
return R.ok(0, true);
}
//如果用户的团队业绩不存在的,新增本月团队业绩
//6、如果用户的团队业绩不存在的,新增本月团队业绩
addTeamPerformance(userList);
boolean bool = monthlyIncome(totalMoney, userList);
......@@ -466,18 +466,17 @@ public class DayTaskServiceImpl implements DayTaskService {
if (null != memberPercent) {
//获取本月团队总金额
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth);
if(null ==teamPerformance){
}
//获取该等级团队总金额
Double teamTotal = teamPerformanceMapper.countTeamMoney(user.getUserLevel(), yearMonth);
if (null != teamPerformance && null != teamTotal) {
if (null != teamPerformance && null != teamTotal && teamTotal != 0) {
double month = teamPerformance.getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue();
//计算收益 todo
//计算收益
double teamMoney = ((moneyMonth * 3980) + lastMonthAward) * percent * month;
DecimalFormat df = new DecimalFormat("######0.00");
double income = Double.parseDouble(df.format(teamMoney / teamTotal));
double income = teamMoney / teamTotal;
if (income == 0) {
continue;
}
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
......
......@@ -193,6 +193,9 @@ public class MonthTaskServiceImpl implements MonthTaskService {
return R.ok(0, true);
}
//6、如果用户的团队业绩不存在的,新增本月团队业绩
addTeamPerformance(userList);
//6、计算收益
boolean bool = monthlyIncome(totalMoney, userList);
if (!bool) {
......@@ -558,12 +561,14 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//获取上月该等级团队总金额
Double teamTotal = teamPerformanceMapper.countTeamMoney(user.getUserLevel(), lastMonth);
if (null != teamPerformance && null != teamTotal) {
if (null != teamPerformance && null != teamTotal && teamTotal != 0) {
double month = teamPerformance.getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue();
//计算收益
double income = ((moneyMonth * 3980) + lastMonthAward) * percent * month / teamTotal;
if (income == 0) {
continue;
}
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
BigDecimal bigDecimal = new BigDecimal(income).setScale(2, RoundingMode.HALF_UP);
......@@ -804,4 +809,23 @@ public class MonthTaskServiceImpl implements MonthTaskService {
}
return true;
}
private void addTeamPerformance(List<User> userList) {
Date lastMonth = DateUtil.getLastMonth(new Date());
String yearMonth = DateUtil.convertDateToStr(lastMonth, "yyyy-MM");
if (!CollectionUtils.isEmpty(userList)) {
for (User user : userList) {
//获取团队业绩信息
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth);
if (null == teamPerformance) {
TeamPerformance addTeam = new TeamPerformance();
addTeam.setMonthTeamPerformance(new BigDecimal(0));
addTeam.setYearMonth(yearMonth);
addTeam.setUserLevel(user.getUserLevel());
addTeam.setUserId(user.getUserId());
teamPerformanceMapper.add(addTeam);
}
}
}
}
}
\ 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