Commit 4a9d74b4 authored by codezwjava's avatar codezwjava

定时任务每月初进行清空用户直推表中的当月累计消费字段

parent f1f5d908
......@@ -52,4 +52,10 @@ public interface RecommendUserMapper extends BaseMapper<RecommendUser> {
* @return 结果
*/
int count( Map<String, Object> map);
/**
* 获取所有的用户
* @return
*/
List<RecommendUser> getAll();
}
......@@ -142,4 +142,11 @@
</where>
</select>
<select id="getAll" resultType="cn.wisenergy.model.app.RecommendUser">
select
<include refid="cols_all"/>
from
<include refid="table"/>
</select>
</mapper>
\ No newline at end of file
......@@ -22,4 +22,6 @@ public interface RecommendUserService {
* @return 列表
*/
R<PageInfo<RecommendUserVo>> getRecommendUserList(RecommendUserDto recommendUserDto);
void clearMonthCount();
}
......@@ -13,11 +13,13 @@ import cn.wisenergy.model.vo.RecommendUserVo;
import cn.wisenergy.model.vo.UserAndRecommendVo;
import cn.wisenergy.service.app.RecommendUserService;
import com.github.pagehelper.PageInfo;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
@Service
......@@ -124,4 +126,22 @@ public class RecommendUserServiceImpl implements RecommendUserService {
schemeVo.setPageSize(pageSize);
}
/**
* 每月初清空用户的当月累计消费
*/
@XxlJob("clearMonthCountTask")
@Override
public void clearMonthCount(){
log.info("月度任务执行--- > : 每月初清空用户的当月累计消费");
List<RecommendUser> recommendUserList = recommendUserMapper.getAll();
recommendUserList.stream().forEach(recommendUser ->{
recommendUser.setMonthyCount(new BigDecimal(0));
recommendUserMapper.updateById(recommendUser);
});
}
}
......@@ -37,6 +37,8 @@ public class UserLevelController {
private LastMonthUserInfoService lastMonthUserInfoService;
@Autowired
private UserLevelTaskService userLevelTaskService;
@Autowired
private RecommendUserService recommendUserService;
@ApiOperation(value = "用户升级接口测试", notes = "用户升级接口测试扫描订单", httpMethod = "GET")
@GetMapping("/test")
......@@ -115,4 +117,10 @@ public class UserLevelController {
public void monthUserlevelTask(){
userLevelTaskService.monthUserLevelUp();
}
@ApiOperation(value = "月度定时清空用户的当月累计消费", notes = "月度定时清空用户的当月累计消费", httpMethod = "GET")
@GetMapping("/clearMonthCount")
public void clearMonthCount(){
recommendUserService.clearMonthCount();
}
}
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