Commit 1c3070c3 authored by licc's avatar licc

优化月度任务

parent 1504d2d1
...@@ -35,4 +35,13 @@ public interface ProgressPrizeMapper extends BaseMapper<ProgressPrize> { ...@@ -35,4 +35,13 @@ public interface ProgressPrizeMapper extends BaseMapper<ProgressPrize> {
* @return 最大进步奖用户列表 * @return 最大进步奖用户列表
*/ */
List<ProgressPrizeVo> getByTime(@Param("yearMonth") String yearMonth); List<ProgressPrizeVo> getByTime(@Param("yearMonth") String yearMonth);
/**
* 根据 userId 年月 获取月的最大进步奖用户
*
* @param yearMonth 年月
* @return 最大进步奖用户列表
*/
ProgressPrize getByUserIdYearMonth(@Param("userId") String userId,@Param("yearMonth") String yearMonth);
} }
...@@ -79,9 +79,7 @@ ...@@ -79,9 +79,7 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="yearMonth != null"> <if test="yearMonth != null">
AND( `year_month` = #{yearMonth}
YEAR(`year_month`) = YEAR(#{yearMonth})
AND MONTH(`year_month`) = MONTH(#{yearMonth}))
</if> </if>
</where> </where>
</select> </select>
...@@ -96,4 +94,19 @@ ...@@ -96,4 +94,19 @@
order by p.`growth_rate` desc,p.award_money desc,u.create_time desc order by p.`growth_rate` desc,p.award_money desc,u.create_time desc
</select> </select>
<select id="getByUserIdYearMonth" resultType="cn.wisenergy.model.app.ProgressPrize">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="userId != null and userId != ''">
user_id=#{userId}
</if>
<if test="yearMonth != null">
and `year_month`= #{yearMonth}
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -263,7 +263,7 @@ public class AccountManager { ...@@ -263,7 +263,7 @@ public class AccountManager {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean updateAccountAddRecordAddPrize(List<AccountInfo> accountInfoList, List<TradeRecord> recordList, public Boolean updateAccountAddRecordAddPrize(List<AccountInfo> accountInfoList, List<TradeRecord> recordList,
List<ProgressPrize> prizeList) { List<ProgressPrize> addPrizeList,List<ProgressPrize> updatePrizeList) {
//更新月收益 //更新月收益
if (!CollectionUtils.isEmpty(accountInfoList)) { if (!CollectionUtils.isEmpty(accountInfoList)) {
...@@ -286,14 +286,24 @@ public class AccountManager { ...@@ -286,14 +286,24 @@ public class AccountManager {
} }
//新增最大进步奖信息 //新增最大进步奖信息
if (!CollectionUtils.isEmpty(prizeList)) { if (!CollectionUtils.isEmpty(addPrizeList)) {
for (ProgressPrize progressPrize : prizeList) { for (ProgressPrize progressPrize : addPrizeList) {
int count = progressPrizeMapper.add(progressPrize); int count = progressPrizeMapper.add(progressPrize);
if (count == 0) { if (count == 0) {
return false; return false;
} }
} }
} }
//编辑最大进步奖信息
if (!CollectionUtils.isEmpty(updatePrizeList)) {
for (ProgressPrize progressPrize : updatePrizeList) {
int count = progressPrizeMapper.edit(progressPrize);
if (count == 0) {
return false;
}
}
}
return true; return true;
} }
......
...@@ -267,7 +267,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -267,7 +267,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
Double twentyTotal = teamPerformanceMapper.countTwenty(yearMonth); Double twentyTotal = teamPerformanceMapper.countTwenty(yearMonth);
List<AccountInfo> accountInfoList = new ArrayList<>(); List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>(); List<TradeRecord> tradeRecordList = new ArrayList<>();
List<ProgressPrize> prizeList = new ArrayList<>(); List<ProgressPrize> addPrizeList = new ArrayList<>();
List<ProgressPrize> updatePrizeList = new ArrayList<>();
for (TeamPerformance user : list) { for (TeamPerformance user : list) {
//获取最大进步奖 百分比 //获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(),
...@@ -290,14 +291,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -290,14 +291,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
accountInfo.setEarningsTotal(earningsTotal); accountInfo.setEarningsTotal(earningsTotal);
accountInfoList.add(accountInfo); accountInfoList.add(accountInfo);
//添加最大进步奖信息 //添加最大进步奖信息 不存在:新增 存在,修改
ProgressPrize prize = new ProgressPrize();
BigDecimal awardMoney = new BigDecimal(income).setScale(2, RoundingMode.HALF_UP); BigDecimal awardMoney = new BigDecimal(income).setScale(2, RoundingMode.HALF_UP);
prize.setAwardMoney(awardMoney.doubleValue()); ProgressPrize progressPrize = progressPrizeMapper.getByUserIdYearMonth(user.getUserId(), yearMonth);
prize.setUserId(user.getUserId()); if (null == progressPrize) {
prize.setGrowthRate(0.0); ProgressPrize prize = new ProgressPrize();
prize.setYearMonth(yearMonth); prize.setAwardMoney(awardMoney.doubleValue());
prizeList.add(prize); prize.setUserId(user.getUserId());
prize.setGrowthRate(0.0);
prize.setYearMonth(yearMonth);
addPrizeList.add(prize);
} else {
progressPrize.setYearMonth(yearMonth);
progressPrize.setAwardMoney(awardMoney.doubleValue());
updatePrizeList.add(progressPrize);
}
//添加交易流水记录 //添加交易流水记录
TradeRecord tradeRecord = new TradeRecord(); TradeRecord tradeRecord = new TradeRecord();
...@@ -310,7 +318,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -310,7 +318,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
} }
//更新账户信息,添加交易流水记录 //更新账户信息,添加交易流水记录
boolean bool = accountManager.updateAccountAddRecordAddPrize(accountInfoList, tradeRecordList, prizeList); boolean bool = accountManager.updateAccountAddRecordAddPrize(accountInfoList, tradeRecordList,
addPrizeList,updatePrizeList);
if (!bool) { if (!bool) {
return R.ok(1, false); return R.ok(1, false);
} }
...@@ -399,8 +408,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -399,8 +408,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
double percent = memberPercent.getPercent().doubleValue(); double percent = memberPercent.getPercent().doubleValue();
//计算收益 //计算收益
double teamMoney = (moneyMonth + lastMonthAward) * 3980 * percent * month; double teamMoney = (moneyMonth + lastMonthAward) * 3980 * percent * month;
DecimalFormat df = new DecimalFormat("######0.00"); DecimalFormat df = new DecimalFormat("######0.00");
double income=Double.parseDouble(df.format(teamMoney/teamTotal)); double income = Double.parseDouble(df.format(teamMoney / teamTotal));
//获取账户信息 //获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId()); AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
......
...@@ -219,7 +219,8 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -219,7 +219,8 @@ public class MonthTaskServiceImpl implements MonthTaskService {
Double twentyTotal = teamPerformanceMapper.countTwenty(lastMonth); Double twentyTotal = teamPerformanceMapper.countTwenty(lastMonth);
List<AccountInfo> accountInfoList = new ArrayList<>(); List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>(); List<TradeRecord> tradeRecordList = new ArrayList<>();
List<ProgressPrize> prizeList = new ArrayList<>(); List<ProgressPrize> addPrizeList = new ArrayList<>();
List<ProgressPrize> updatePrizeList = new ArrayList<>();
for (TeamPerformance user : list) { for (TeamPerformance user : list) {
//获取最大进步奖 百分比 //获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3); MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3);
...@@ -239,14 +240,21 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -239,14 +240,21 @@ public class MonthTaskServiceImpl implements MonthTaskService {
accountInfo.setEarningsTotal(earningsTotal.setScale(2, RoundingMode.HALF_UP)); accountInfo.setEarningsTotal(earningsTotal.setScale(2, RoundingMode.HALF_UP));
accountInfoList.add(accountInfo); accountInfoList.add(accountInfo);
//添加最大进步奖信息 //添加最大进步奖信息 不存在:新增 存在,修改
ProgressPrize prize = new ProgressPrize();
BigDecimal awardMoney = new BigDecimal(income).setScale(2, RoundingMode.HALF_UP); BigDecimal awardMoney = new BigDecimal(income).setScale(2, RoundingMode.HALF_UP);
prize.setAwardMoney(awardMoney.doubleValue()); ProgressPrize progressPrize = progressPrizeMapper.getByUserIdYearMonth(user.getUserId(), lastMonth);
prize.setUserId(user.getUserId()); if (null == progressPrize) {
prize.setGrowthRate(0.0); ProgressPrize prize = new ProgressPrize();
prize.setYearMonth(lastMonth); prize.setAwardMoney(awardMoney.doubleValue());
prizeList.add(prize); prize.setUserId(user.getUserId());
prize.setGrowthRate(0.0);
prize.setYearMonth(lastMonth);
addPrizeList.add(prize);
} else {
progressPrize.setYearMonth(lastMonth);
progressPrize.setAwardMoney(awardMoney.doubleValue());
updatePrizeList.add(progressPrize);
}
//添加交易流水记录 //添加交易流水记录
TradeRecord tradeRecord = new TradeRecord(); TradeRecord tradeRecord = new TradeRecord();
...@@ -259,7 +267,8 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -259,7 +267,8 @@ public class MonthTaskServiceImpl implements MonthTaskService {
} }
//更新账户信息,添加交易流水记录 //更新账户信息,添加交易流水记录
boolean bool = accountManager.updateAccountAddRecordAddPrize(accountInfoList, tradeRecordList, prizeList); boolean bool = accountManager.updateAccountAddRecordAddPrize(accountInfoList, tradeRecordList,
addPrizeList,updatePrizeList);
if (!bool) { if (!bool) {
return R.ok(1, false); return R.ok(1, false);
} }
......
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