| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.StockSubscribeMapper; |
| | | import com.nq.dao.UserAssetsMapper; |
| | | import com.nq.dao.UserMapper; |
| | | import com.nq.dao.UserStockSubscribeMapper; |
| | | import com.nq.pojo.StockSubscribe; |
| | | import com.nq.pojo.User; |
| | | import com.nq.pojo.UserAssets; |
| | | import com.nq.pojo.UserStockSubscribe; |
| | | import com.nq.dao.*; |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.IUserAssetsServices; |
| | | import com.nq.service.IUserPositionService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Autowired |
| | | IUserAssetsServices userAssetsServices; |
| | | |
| | | @Autowired |
| | | StockMapper stockMapper; |
| | | |
| | | private final Lock ballotLock = new ReentrantLock(); |
| | | |
| | | private final Lock subscriptionLock = new ReentrantLock(); |
| | |
| | | private final AtomicBoolean ballot = new AtomicBoolean(false); |
| | | |
| | | |
| | | @Scheduled(cron = "0 0/10 * * * ?") |
| | | @Scheduled(cron = "0 0/1 * * * ?") |
| | | public void ballot() { |
| | | if (ballot.get()) { // 判断任务是否在处理中 |
| | | return; |
| | |
| | | List<UserStockSubscribe> userStockSubscribes = userStockSubscribeMapper.selectList(new LambdaQueryWrapper<UserStockSubscribe>() |
| | | .eq(UserStockSubscribe::getStatus, 3)); |
| | | userStockSubscribes.forEach(f->{ |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("JP",f.getUserId()); |
| | | Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<>(Stock.class).eq(Stock::getStockCode, f.getNewCode())); |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId(stock.getStockType(),f.getUserId()); |
| | | if(null != userAssets && userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) == 0){ |
| | | f.setStatus(4); |
| | | userStockSubscribeMapper.updateById(f); |