1
zj
2024-10-29 57c2b6875b5f026a1432f3209471d6b4503f43fc
src/main/java/com/nq/utils/task/stock/CarryPositionTask.java
@@ -5,14 +5,8 @@
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;
@@ -53,6 +47,9 @@
    @Autowired
    IUserAssetsServices userAssetsServices;
    @Autowired
    StockMapper stockMapper;
    private final Lock ballotLock = new ReentrantLock();
    private final Lock subscriptionLock = new ReentrantLock();
@@ -60,7 +57,7 @@
    private final AtomicBoolean ballot = new AtomicBoolean(false);
    @Scheduled(cron = "0 0/10 * * * ?")
    @Scheduled(cron = "0 0/1 * * * ?")
    public void ballot() {
        if (ballot.get()) { // 判断任务是否在处理中
            return;
@@ -112,7 +109,8 @@
                List<UserStockSubscribe> userStockSubscribes = userStockSubscribeMapper.selectList(new LambdaQueryWrapper<UserStockSubscribe>()
                        .eq(UserStockSubscribe::getStatus, 3));
                userStockSubscribes.forEach(f->{
                    UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("IN",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);