Commit 89927325 authored by licc's avatar licc

月度最大进步奖接口自测优化1

parent 02cbc7e2
...@@ -300,7 +300,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -300,7 +300,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
tradeRecord.setUserId(user.getUserId()); tradeRecord.setUserId(user.getUserId());
tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode()); tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode());
tradeRecord.setTradeNo(null); tradeRecord.setTradeNo(null);
tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode()); tradeRecord.setStatus(TradeStatusEnum.NO_SETTLE_ACCOUNTS.getCode());
tradeRecord.setMoney(BigDecimal.valueOf(income));
tradeRecordList.add(tradeRecord); tradeRecordList.add(tradeRecord);
} }
......
...@@ -114,7 +114,14 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -114,7 +114,14 @@ public class MonthTaskServiceImpl implements MonthTaskService {
String userId = entity.getKey(); String userId = entity.getKey();
//1)、统计当前用户月度业绩 //1)、统计当前用户月度业绩
double userCount = entity.getValue(); double userCount = entity.getValue();
tempMap.put(userId, userCount); //key 存在 当前用户团队绩效 + 上级用户团队绩效
if (tempMap.containsKey(entity.getKey())) {
double teamMoney = userCount + tempMap.get(entity.getKey());
tempMap.put(entity.getKey(), teamMoney);
} else {
//key 不存在,加入集合 当前用户团队绩效
tempMap.put(entity.getKey(), userCount);
}
//2)、获取当前用户的上级用户列表 //2)、获取当前用户的上级用户列表
List<User> userList = accountService.getByList(userId); List<User> userList = accountService.getByList(userId);
...@@ -126,11 +133,11 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -126,11 +133,11 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//3)、统计当前用户的上级用户团队绩效 //3)、统计当前用户的上级用户团队绩效
//key 存在 当前用户团队绩效 + 上级用户团队绩效 //key 存在 当前用户团队绩效 + 上级用户团队绩效
if (tempMap.containsKey(userInfo.getUserId())) { if (tempMap.containsKey(userInfo.getUserId())) {
double teamMoney = userCount + map.get(userInfo.getUserId()); double teamMoney = userCount + tempMap.get(userInfo.getUserId());
map.put(userInfo.getUserId(), teamMoney); tempMap.put(userInfo.getUserId(), teamMoney);
} else { } else {
//key 不存在,加入集合 当前用户团队绩效 //key 不存在,加入集合 当前用户团队绩效
map.put(userInfo.getUserId(), userCount); tempMap.put(userInfo.getUserId(), userCount);
} }
} }
} }
...@@ -151,7 +158,6 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -151,7 +158,6 @@ public class MonthTaskServiceImpl implements MonthTaskService {
performance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue())); performance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
performance.setUserLevel(user.getUserLevel()); performance.setUserLevel(user.getUserLevel());
performance.setYearMonth(yearMonth); performance.setYearMonth(yearMonth);
teamPerformanceMapper.add(performance);
addList.add(performance); addList.add(performance);
} else { } else {
teamPerformance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue())); teamPerformance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
...@@ -160,8 +166,8 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -160,8 +166,8 @@ public class MonthTaskServiceImpl implements MonthTaskService {
} }
//4、更新账户月度绩效 //4、更新账户月度绩效
boolean updateBool=accountManager.updateAccountPerformanceMonth(addList, updateList); boolean updateBool = accountManager.updateAccountPerformanceMonth(addList, updateList);
if(!updateBool){ if (!updateBool) {
return R.ok(1, false); return R.ok(1, false);
} }
...@@ -214,6 +220,11 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -214,6 +220,11 @@ public class MonthTaskServiceImpl implements MonthTaskService {
List<AccountInfo> accountInfoList = new ArrayList<>(); List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>(); List<TradeRecord> tradeRecordList = new ArrayList<>();
for (TeamPerformance user : list) { for (TeamPerformance user : list) {
//用户是普通用户的,不计算最大进步奖
if (user.getUserLevel().equals(UserLevelEnum.NORMAL_USER.getCode())) {
continue;
}
//获取最大进步奖 百分比 //获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3); MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3);
...@@ -221,11 +232,18 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -221,11 +232,18 @@ public class MonthTaskServiceImpl implements MonthTaskService {
double userTeamPerformance = user.getMonthTeamPerformance().doubleValue(); double userTeamPerformance = user.getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue(); double percent = memberPercent.getPercent().doubleValue();
double income = number * 3980 * percent * userTeamPerformance / twentyTotal; double income = Math.floor(number * 3980 * percent * userTeamPerformance / twentyTotal);
//获取账户信息 //获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId()); AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
accountInfo.setEarningsMonth(new BigDecimal(income));
//用户月收益 =其他收益+最大进步奖收益
BigDecimal earningsMonth = accountInfo.getEarningsMonth().add(BigDecimal.valueOf(income));
accountInfo.setEarningsMonth(earningsMonth);
//用户总收益 =其他总收益 + earningsMonth
BigDecimal earningsTotal = accountInfo.getEarningsTotal().add(BigDecimal.valueOf(income));
accountInfo.setEarningsTotal(earningsTotal);
accountInfoList.add(accountInfo); accountInfoList.add(accountInfo);
//添加交易流水记录 //添加交易流水记录
...@@ -234,6 +252,7 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -234,6 +252,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode()); tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode());
tradeRecord.setTradeNo(null); tradeRecord.setTradeNo(null);
tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode()); tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode());
tradeRecord.setMoney(BigDecimal.valueOf(income));
tradeRecordList.add(tradeRecord); tradeRecordList.add(tradeRecord);
} }
......
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