Commit 393f95f5 authored by m1991's avatar m1991

Merge remote-tracking branch 'origin/master'

parents 09098a4e 69fc9a94
...@@ -260,12 +260,12 @@ public class AccountManager { ...@@ -260,12 +260,12 @@ public class AccountManager {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean updateAccountAddRecordAndManure(List<AccountInfo> accountInfoList, public Boolean updateAccountAddRecordAndManure(List<AccountInfo> accountInfoList,
List<TradeRecord> recordList, List<TradeRecord> recordList,
MonthManure manure) { MonthManure manure, MonthManure monthManure) {
//更新月收益 //更新月收益
if (!CollectionUtils.isEmpty(accountInfoList)) { if (!CollectionUtils.isEmpty(accountInfoList)) {
for (AccountInfo accountInfo : accountInfoList) { for (AccountInfo accountInfo : accountInfoList) {
int count = accountMapper.updateById(accountInfo); int count = accountMapper.edit(accountInfo);
if (count == 0) { if (count == 0) {
return false; return false;
} }
...@@ -282,8 +282,17 @@ public class AccountManager { ...@@ -282,8 +282,17 @@ public class AccountManager {
} }
} }
//新增上月剩余月度肥料奖金 //判断是否存在月度肥料奖金信息
int count = monthManureMapper.add(manure); if (null == monthManure) {
return count != 0; //新增上月剩余月度肥料奖金
int count = monthManureMapper.add(manure);
return count != 0;
} else {
//编辑
monthManure.setManureAward(manure.getManureAward());
monthManure.setYearMonth(manure.getYearMonth());
int count = monthManureMapper.edit(monthManure);
return count != 0;
}
} }
} }
...@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; ...@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
/** /**
...@@ -325,19 +326,22 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -325,19 +326,22 @@ public class MonthTaskServiceImpl implements MonthTaskService {
* @return * @return
*/ */
private boolean monthlyIncome(BigDecimal totalMoney, List<User> userList) { private boolean monthlyIncome(BigDecimal totalMoney, List<User> userList) {
double total = totalMoney.doubleValue(); //上月
Date date = new Date(); Date date = DateUtil.getLastMonth(new Date());
String lastMonth = DateUtil.convertDateToStr(date, PATTERN); String lastMonth = DateUtil.convertDateToStr(date, PATTERN);
//上上月
String time = DateUtil.convertDateToStr(date, "yyyy-MM-dd");
Date timeString = DateUtil.convertStrToDate(time, "yyyy-MM-dd");
Date lastAndLast = DateUtil.getLastMonth(timeString);
String yearMonthTime = DateUtil.convertDateToStr(lastAndLast, PATTERN);
//当月所有人订单成交总金额/3980/12 向下取整 //当月所有人订单成交总金额/3980/12 向下取整
double total = totalMoney.doubleValue();
double moneyMonth = Math.floor(total / 3980 / 12); double moneyMonth = Math.floor(total / 3980 / 12);
List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>();
//获取上上月未分配完的奖金 //获取上上月未分配完的奖金
double lastMonthAward; double lastMonthAward;
Date lastAndLast = DateUtil.convertStrToDate(lastMonth, "yyyy-MM-dd");
String yearMonthTime = DateUtil.convertDateToStr(lastAndLast, PATTERN);
MonthManure monthManure = monthManureMapper.queryByTime(yearMonthTime); MonthManure monthManure = monthManureMapper.queryByTime(yearMonthTime);
if (null == monthManure) { if (null == monthManure) {
lastMonthAward = 0.00; lastMonthAward = 0.00;
...@@ -346,9 +350,13 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -346,9 +350,13 @@ public class MonthTaskServiceImpl implements MonthTaskService {
} }
moneyMonth = moneyMonth + lastMonthAward; moneyMonth = moneyMonth + lastMonthAward;
//判断每个等级是否都有用户,没有用户的,记录下剩余奖金 //1、判断每个等级是否都有用户,没有用户的,记录下剩余奖金
MonthManure manure = checkUserLevel(moneyMonth); MonthManure manure = checkUserLevel(moneyMonth);
//获取上月是否有月度剩余奖金信息
MonthManure lastMonthManure = monthManureMapper.queryByTime(lastMonth);
List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>();
for (User user : userList) { for (User user : userList) {
if (moneyMonth != 0) { if (moneyMonth != 0) {
//获取等级优惠百分比 //获取等级优惠百分比
...@@ -370,10 +378,10 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -370,10 +378,10 @@ public class MonthTaskServiceImpl implements MonthTaskService {
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId()); AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
BigDecimal bigDecimal = new BigDecimal(income); BigDecimal bigDecimal = new BigDecimal(income);
BigDecimal performanceMonth = accountInfo.getEarningsMonth().add(bigDecimal); BigDecimal performanceMonth = accountInfo.getEarningsMonth().add(bigDecimal);
accountInfo.setEarningsMonth(performanceMonth); accountInfo.setEarningsMonth(performanceMonth.setScale(2, RoundingMode.HALF_UP));
BigDecimal performanceTotal = accountInfo.getEarningsMonth().add(bigDecimal); BigDecimal performanceTotal = accountInfo.getEarningsMonth().add(bigDecimal);
accountInfo.setEarningsMonth(performanceTotal); accountInfo.setEarningsMonth(performanceTotal.setScale(2, RoundingMode.HALF_UP));
accountInfoList.add(accountInfo); accountInfoList.add(accountInfo);
...@@ -382,6 +390,8 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -382,6 +390,8 @@ public class MonthTaskServiceImpl implements MonthTaskService {
tradeRecord.setUserId(user.getUserId()); tradeRecord.setUserId(user.getUserId());
tradeRecord.setTradeType(TradeRecordEnum.MONTHLY_FERTILIZER.getCode()); tradeRecord.setTradeType(TradeRecordEnum.MONTHLY_FERTILIZER.getCode());
tradeRecord.setTradeNo(null); tradeRecord.setTradeNo(null);
BigDecimal big = new BigDecimal(income);
tradeRecord.setMoney(big.setScale(2, RoundingMode.HALF_UP));
tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode()); tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode());
tradeRecordList.add(tradeRecord); tradeRecordList.add(tradeRecord);
} }
...@@ -389,7 +399,7 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -389,7 +399,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
} }
} }
//更新账户信息,新增交易流水记录 //更新账户信息,新增交易流水记录
return accountManager.updateAccountAddRecordAndManure(accountInfoList, tradeRecordList, manure); return accountManager.updateAccountAddRecordAndManure(accountInfoList, tradeRecordList, manure, lastMonthManure);
} }
/** /**
...@@ -435,7 +445,7 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -435,7 +445,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//3、判断是否有森林之星等级的用户 //3、判断是否有森林之星等级的用户
List<User> startList = usersMapper.getByLevel(UserLevelEnum.FOREST_START.getCode()); List<User> startList = usersMapper.getByLevel(UserLevelEnum.FOREST_START.getCode());
if (CollectionUtils.isEmpty(startList)) { if (!CollectionUtils.isEmpty(startList)) {
//获取等级优惠百分比 //获取等级优惠百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(UserLevelEnum.FOREST_START.getCode(), MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(UserLevelEnum.FOREST_START.getCode(),
MemberPercentEnum.MONTH_MANURE.getCode()); MemberPercentEnum.MONTH_MANURE.getCode());
......
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