| | |
| | | package com.nq.utils.task.user; |
| | | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.UserMapper; |
| | | import com.nq.pojo.User; |
| | | import com.nq.service.IUserService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户资产清算模块,每天非节假日晚上8点固定的清算可用和可取资金 |
| | | * 用户资产清算:T+0 下仅修正可取资金超过可用的情况,不再将可用全量同步为可取 |
| | | */ |
| | | @Component |
| | | public class UserAssetAuditTask { |
| | | |
| | | @Autowired |
| | | private IUserService iUserService; |
| | | |
| | | @Autowired |
| | | private UserMapper userMapper; |
| | |
| | | */ |
| | | @Scheduled(cron = "0 0 20 * * MON-FRI") |
| | | public void doAuditTask(){ |
| | | int pageNo=1; |
| | | boolean hasNextPage=true; |
| | | while (hasNextPage&&pageNo<=300){ |
| | | ServerResponse serverResponse = iUserService.listByAdmin(null, null, null, null, pageNo, 30,null); |
| | | PageInfo pageInfo = (PageInfo) serverResponse.getData(); |
| | | hasNextPage=pageInfo.isHasNextPage(); |
| | | int pageNo = 1; |
| | | boolean hasNextPage = true; |
| | | while (hasNextPage && pageNo <= 300) { |
| | | PageHelper.startPage(pageNo, 30); |
| | | List<User> list = userMapper.listByAdmin(null, null, null, null); |
| | | PageInfo<User> pageInfo = new PageInfo<>(list); |
| | | hasNextPage = pageInfo.isHasNextPage(); |
| | | pageNo++; |
| | | List<User> list = pageInfo.getList(); |
| | | for(User u:list){ |
| | | //可用资金复制到可取资金操作 |
| | | u.setEnaleWithdrawAmt(u.getEnableAmt()); |
| | | userMapper.updateByPrimaryKeySelective(u); |
| | | log.info("[清算]id:{},withdraw:{}",u.getId(),u.getEnaleWithdrawAmt()); |
| | | for (User u : list) { |
| | | BigDecimal enable = u.getEnableAmt() == null ? BigDecimal.ZERO : u.getEnableAmt(); |
| | | BigDecimal withdraw = u.getEnaleWithdrawAmt() == null ? BigDecimal.ZERO : u.getEnaleWithdrawAmt(); |
| | | if (withdraw.compareTo(enable) > 0) { |
| | | u.setEnaleWithdrawAmt(enable); |
| | | userMapper.updateByPrimaryKeySelective(u); |
| | | log.info("[清算]id:{},withdraw capped to:{}", u.getId(), enable); |
| | | } |
| | | } |
| | | } |
| | | } |