Commit 53caafc8 authored by licc's avatar licc

优化月度任务接口2

parent 44413526
......@@ -49,4 +49,11 @@ public interface OrderMapper extends BaseMapper<OrderInfo> {
* @return 订单列表
*/
List<OrderInfo> getListBySuccessTime(@Param("successTime") Date successTime);
/**
* 更据创建订单时间获取订单列表
* @param createTime 创建订单时间
* @return 订单列表
*/
List<OrderInfo> getByCreateTime(@Param("createTime") Date createTime);
}
......@@ -140,4 +140,17 @@
</where>
</select>
<select id="getByCreateTime" resultType="cn.wisenergy.model.app.OrderInfo">
SELECT
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="successTime != null ">
YEAR(create_time) = YEAR(#{successTime})
AND MONTH(create_time) = MONTH(#{successTime})
</if>
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -29,11 +29,9 @@ public interface AccountService {
/**
* 收益和业绩统计(月度肥料 -日)
*
* @param list 订单信息
* @return true or false
*/
R<Boolean> performanceCount(List<OrderInfo> list);
R<Boolean> performanceCount();
/**
* 获取用户的商机信息
......
......@@ -21,11 +21,9 @@ public interface MonthTaskService {
/**
* 收益和业绩统计(月度肥料)-月任务
*
* @param list 订单信息
* @return true or false
*/
R<Boolean> performanceCount(List<OrderInfo> list);
R<Boolean> performanceCount();
/**
* 进步奖收益统计(最大进步奖) -月任务
......
......@@ -113,7 +113,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
@Override
public R<Boolean> performanceCount(List<OrderInfo> list) {
public R<Boolean> performanceCount() {
//获取本月订单
List<OrderInfo> list = orderMapper.getByCreateTime(new Date());
log.info("shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
return R.ok(0, true);
......
......@@ -76,7 +76,10 @@ public class MonthTaskServiceImpl implements MonthTaskService {
}
@Override
public R<Boolean> performanceCount(List<OrderInfo> list) {
public R<Boolean> performanceCount() {
//获取上月订单
Date lastMonth = DateUtil.getLastMonth(new Date());
List<OrderInfo> list = orderMapper.getByCreateTime(lastMonth);
log.info("shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
return R.ok(0, true);
......@@ -99,47 +102,46 @@ public class MonthTaskServiceImpl implements MonthTaskService {
for (OrderInfo orderInfo : list) {
long createTime = orderInfo.getCreated().getTime();
long time = System.currentTimeMillis();
if (createTime <= time) {
//获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId());
if (null == user) {
continue;
}
List<TeamPerformance> teamPerformances = new ArrayList<>();
//获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId());
if (null == user) {
continue;
}
//获取团队业绩信息
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth);
if (null == teamPerformance) {
continue;
}
List<TeamPerformance> teamPerformances = new ArrayList<>();
//1、统计当前用户月度业绩
BigDecimal userCount = teamPerformance.getMonthTeamPerformance().add(orderInfo.getPayment());
teamPerformance.setMonthTeamPerformance(userCount);
teamPerformances.add(teamPerformance);
//获取团队业绩信息
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth);
if (null == teamPerformance) {
continue;
}
//2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
List<User> userList = accountService.getByList(user.getUserId());
if (CollectionUtils.isEmpty(userList)) {
continue;
}
//1、统计当前用户月度业绩
BigDecimal userCount = teamPerformance.getMonthTeamPerformance().add(orderInfo.getPayment());
teamPerformance.setMonthTeamPerformance(userCount);
teamPerformances.add(teamPerformance);
//3、统计当前用户上级月度绩效
for (User userInfo : userList) {
TeamPerformance team = teamPerformanceMapper.getByUserIdAndTime(userInfo.getUserId(), yearMonth);
if (null == team) {
continue;
}
//1)、统计当前用户月度绩效
BigDecimal monthCount = team.getMonthTeamPerformance().add(orderInfo.getPayment());
team.setMonthTeamPerformance(monthCount);
teamPerformances.add(team);
}
//2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
List<User> userList = accountService.getByList(user.getUserId());
if (CollectionUtils.isEmpty(userList)) {
continue;
}
//4、更新账户月度绩效
accountManager.updateAccountPerformanceMonth(teamPerformances);
//3、统计当前用户上级月度绩效
for (User userInfo : userList) {
TeamPerformance team = teamPerformanceMapper.getByUserIdAndTime(userInfo.getUserId(), yearMonth);
if (null == team) {
continue;
}
//1)、统计当前用户月度绩效
BigDecimal monthCount = team.getMonthTeamPerformance().add(orderInfo.getPayment());
team.setMonthTeamPerformance(monthCount);
teamPerformances.add(team);
}
//4、更新账户月度绩效
accountManager.updateAccountPerformanceMonth(teamPerformances);
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List<User> userList = usersMapper.getAllGoldUser();
......
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