Commit b200d473 authored by licc's avatar licc

新增运营中心补贴月定时任务

parent f7d325bc
......@@ -21,6 +21,11 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> {
*/
int edit(TeamPerformance teamPerformance);
/**
* 删除
* @param id 主键ID
* @return 1
*/
int delById(@Param("id") Integer id);
/**
......
......@@ -22,7 +22,9 @@ public enum TradeRecordEnum {
SALARY_REWARD(6, "工资奖励"),
PROGRESS_PRIZE(7, "最大进步奖");
PROGRESS_PRIZE(7, "最大进步奖"),
RUN_CENTER_SUBSIDY(8, "运营中心补贴");
private Integer code;
private String desc;
......
......@@ -3,16 +3,17 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
/**
*@ Description: 月定时任务接口定义
*@ Author : 86187
*@ Date : 2021/3/10 10:22
* @author 86187
* @ Description: 月定时任务接口定义
* @ Author : 86187
* @ Date : 2021/3/10 10:22
*/
public interface MonthTaskService {
/**
* 收益和业绩统计(月度肥料)-月任务
*
* @return true or false
*/
R<Boolean> performanceCount();
......@@ -28,4 +29,11 @@ public interface MonthTaskService {
* 账户表镜像---每月更新一次,保存上一个的数据
*/
void mirrorImage();
/**
* 运营中心补贴
*
* @return true or false
*/
R<Boolean> runCenterSubsidy();
}
......@@ -11,8 +11,6 @@ import cn.wisenergy.service.app.BankService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......
......@@ -268,7 +268,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//更新账户信息,添加交易流水记录
boolean bool = accountManager.updateAccountAddRecordAddPrize(accountInfoList, tradeRecordList,
addPrizeList,updatePrizeList);
addPrizeList, updatePrizeList);
if (!bool) {
return R.ok(1, false);
}
......@@ -323,6 +323,72 @@ public class MonthTaskServiceImpl implements MonthTaskService {
lastAccountMapper.deleteTable("month_account_image");
}
@Override
public R<Boolean> runCenterSubsidy() {
log.info("shop-mall[]MonthTaskServiceImpl[]runCenterSubsidy[]input.method");
//1、获取所有等级是西田森合伙人的用户
List<User> list = usersMapper.getByLevel(UserLevelEnum.PARTNER.getCode());
if (CollectionUtils.isEmpty(list)) {
return R.ok(0, true);
}
//2、获取每个用户上月的团队业绩
Date date = DateUtil.getLastMonth(new Date());
String yearMonth = DateUtil.convertDateToStr(date, "yyyy-MM");
//获取运营中心补贴比例
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(UserLevelEnum.PARTNER.getCode(),
MemberPercentEnum.RUN_CENTER_SUBSIDY.getCode());
if (null == memberPercent) {
return R.error("无运营中心补贴比例,请联系管理员添加!");
}
List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>();
for (User user : list) {
//获取团队业绩
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth);
if (null == teamPerformance) {
continue;
}
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
if (null == accountInfo) {
continue;
}
//计算运营中心补贴
BigDecimal money = teamPerformance.getMonthTeamPerformance().multiply(memberPercent.getPercent());
BigDecimal resultMoney = money.setScale(2, RoundingMode.HALF_UP);
BigDecimal extractMoney = accountInfo.getExtractMoney().add(resultMoney);
accountInfo.setExtractMoney(extractMoney);
BigDecimal earningsMonth = accountInfo.getEarningsMonth().add(resultMoney);
accountInfo.setExtractMoney(earningsMonth);
BigDecimal earningsTotal = accountInfo.getEarningsTotal().add(resultMoney);
accountInfo.setEarningsTotal(earningsTotal);
accountInfoList.add(accountInfo);
//添加交易流水记录
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(user.getUserId());
tradeRecord.setTradeType(TradeRecordEnum.RUN_CENTER_SUBSIDY.getCode());
tradeRecord.setTradeNo(null);
tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode());
tradeRecordList.add(tradeRecord);
}
//修改账户信息和保存交易记录
boolean bool = accountManager.updateAccountAddRecord(accountInfoList, tradeRecordList);
if (!bool) {
return R.ok(1, false);
}
return R.ok(0, true);
}
/**
* 如果会员等级是黄金以上,计算月度收益
......@@ -382,7 +448,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
BigDecimal bigDecimal = new BigDecimal(income).setScale(2,RoundingMode.HALF_UP);
BigDecimal bigDecimal = new BigDecimal(income).setScale(2, RoundingMode.HALF_UP);
BigDecimal performanceMonth = accountInfo.getEarningsMonth().add(bigDecimal);
accountInfo.setEarningsMonth(performanceMonth.setScale(2, RoundingMode.HALF_UP));
......@@ -589,6 +655,6 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//修改或保存最大进步奖信息
// flag 1: 日定时任务 2:月定时任务
int flag = 2;
return accountManager.updateOrSavePrize(listVo, updateAccountList, prizes,flag);
return accountManager.updateOrSavePrize(listVo, updateAccountList, prizes, flag);
}
}
\ No newline at end of file
......@@ -33,7 +33,7 @@ public class MonthTaskController {
return monthTaskService.progressPrizeCount();
}
@ApiOperation(value = "", notes = "账户表镜像---每月更新一次,保存上一个的数据", httpMethod = "GET")
@ApiOperation(value = "账户表镜像", notes = "账户表镜像---每月更新一次,保存上一个的数据", httpMethod = "GET")
@GetMapping("/mirrorImage")
public R<String> mirrorImage() {
monthTaskService.mirrorImage();
......@@ -41,4 +41,10 @@ public class MonthTaskController {
}
@ApiOperation(value = "运营中心补贴", notes = "运营中心补贴", httpMethod = "GET")
@GetMapping("/runCenterSubsidy")
public R<Boolean> runCenterSubsidy() {
return monthTaskService.runCenterSubsidy();
}
}
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