package com.nq.utils.task.user;
|
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.nq.dao.UserMapper;
|
import com.nq.pojo.User;
|
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;
|
|
/**
|
* 用户资产清算:T+0 下仅修正可取资金超过可用的情况,不再将可用全量同步为可取
|
*/
|
@Component
|
public class UserAssetAuditTask {
|
|
@Autowired
|
private UserMapper userMapper;
|
|
private static final Logger log = LoggerFactory.getLogger(UserAssetAuditTask.class);
|
|
/**
|
* 每天晚上8点执行清算
|
*/
|
@Scheduled(cron = "0 0 20 * * MON-FRI")
|
public void doAuditTask(){
|
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++;
|
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);
|
}
|
}
|
}
|
}
|
|
}
|