Commit 345c553c authored by licc's avatar licc

月度最大进步奖 实现2

parent e5587b8f
......@@ -10,5 +10,7 @@ import lombok.Data;
public class TeamPerformanceSortVo {
private Double growthRate;
private Double monthPerformance;
private TeamPerformance teamPerformance;
}
......@@ -13,7 +13,6 @@ import cn.wisenergy.service.Manager.AccountManager;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -160,10 +159,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List<User> userList = usersMapper.getAllGoldUser();
for (User user : userList) {
boolean bool = monthlyIncome(totalMoney, user);
if (!bool) {
continue;
}
monthlyIncome(totalMoney, user);
}
}
return R.ok(0, true);
......@@ -192,10 +188,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//1、判断当前月是否是业绩开始的第一个月
List<TeamPerformance> teamPerformances = teamPerformanceMapper.getByBeforeTime(new Date());
//2、集合为空 是业绩开始的第一个月
if (CollectionUtils.isEmpty(teamPerformances)) {
//获取当月所有人业绩总额
Double totalMoney = teamPerformanceMapper.countByTime(new Date());
//2、集合为空 是业绩开始的第一个月
if (CollectionUtils.isEmpty(teamPerformances)) {
double number = Math.floor(totalMoney / 3980 / 12);
if (number != 0) {
//获取月业绩前20用户
......@@ -261,6 +258,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
}
teamVo.setGrowthRate(growthRate);
double monthPerformance;
if (null == teamPerformance.getMonthTeamPerformance()) {
monthPerformance = 0.00;
} else {
monthPerformance = teamPerformance.getMonthTeamPerformance().doubleValue();
}
teamVo.setMonthPerformance(monthPerformance);
teamVo.setTeamPerformance(teamPerformance);
listVo.add(teamVo);
}
......@@ -268,10 +272,59 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//对集合进行排序
listVo.sort(Comparator.comparing(TeamPerformanceSortVo::getGrowthRate).reversed());
if (listVo.size() >= 20) {
//计算前20的总业绩
double total = listVo.stream().mapToDouble(TeamPerformanceSortVo::getMonthPerformance).sum();
double number = Math.floor(totalMoney / 3980 / 12);
//取排名前20的
listVo.subList(0, 20);
return R.ok(0,true);
for (TeamPerformanceSortVo sortVo : listVo) {
String userId = sortVo.getTeamPerformance().getUserId();
Integer userLevel = sortVo.getTeamPerformance().getUserLevel();
//获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(userLevel, 3);
//计算收益
double userTeamPerformance = sortVo.getTeamPerformance().getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue();
double income = number * 3980 * percent * userTeamPerformance / total;
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(userId);
accountInfo.setPerformanceMonth(new BigDecimal(income));
//更新用户账户表
accountMapper.updateById(accountInfo);
}
return R.ok(0, true);
} else {
//计算总业绩
double total = listVo.stream().mapToDouble(TeamPerformanceSortVo::getMonthPerformance).sum();
double number = Math.floor(totalMoney / 3980 / 12);
for (TeamPerformanceSortVo sortVo : listVo) {
String userId = sortVo.getTeamPerformance().getUserId();
Integer userLevel = sortVo.getTeamPerformance().getUserLevel();
//获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(userLevel, 3);
//计算收益
double userTeamPerformance = sortVo.getTeamPerformance().getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue();
double income = number * 3980 * percent * userTeamPerformance / total;
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(userId);
accountInfo.setPerformanceMonth(new BigDecimal(income));
//更新用户账户表
accountMapper.updateById(accountInfo);
}
}
return R.ok(0, true);
}
public void getUser(List<User> list, String userId) {
......
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