新版仿ok交易所-后端
1
zyy
2026-03-24 513e5442723f501525bf9ca6210b16561e5d3a2b
trading-order-service/src/main/java/com/yami/trading/service/item/ItemService.java
@@ -16,13 +16,14 @@
import com.yami.trading.bean.item.domain.Item;
import com.yami.trading.bean.item.dto.ItemDTO;
import com.yami.trading.bean.item.dto.ItemLeverageDTO;
import com.yami.trading.bean.robot.domain.Robot;
import com.yami.trading.common.util.ApplicationContextUtils;
import com.yami.trading.common.util.MarketOpenChecker;
import com.yami.trading.common.util.StringUtils;
import com.yami.trading.dao.item.ItemMapper;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -128,6 +129,13 @@
        return super.baseMapper.selectOne(queryWrapper);
    }
    public Item findCurrBySymbol(String symbol) {
        LambdaQueryWrapper<Item> queryWrapper = new LambdaQueryWrapper<Item>()
                .eq(Item::getSymbol, symbol)
                .last("LIMIT 1");
        return super.baseMapper.selectOne(queryWrapper);
    }
    /**
     * 根据id查询
@@ -180,6 +188,9 @@
        return super.removeById(id);
    }
    public void reloadListAndCache() {
        init();
    }
    /**
     * 获取品种精度
@@ -229,4 +240,40 @@
        Item bySymbol = findBySymbol(symbol);
        return MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType());
    }
    /**
     * 是否开放合约
     * @param item
     * @return
     */
    public boolean isContractTrading(Item item) {
        item = findBySymbol(item.getSymbol());
        //虚拟币新币才判断
        if (item.getType().equals(Item.cryptos) && (item.getCurrencyType() != null && item.getCurrencyType() == 1)) {
            if (item.getTradeType() != null && item.getTradeType().equals("0")) {
                return false;
            }
        }
        return true;
    }
    /**
     * 是否停牌状态
     * @return
     */
    public boolean isSuspended(String symbol) {
        //Item item = findBySymbol(symbol);
        Item item = getOne(new LambdaQueryWrapper<Item>().eq(Item::getSymbol, symbol));
        if (item != null) {
            //虚拟币新币才判断
            if (item.getType().equals(Item.cryptos) /*&& (item.getCurrencyType() != null && item.getCurrencyType() == 1)*/) {
                //item = getById(item.getUuid());
                if (item.getStatus() != null && item.getStatus() == 0) {
                    return true;
                }
            }
        }
        return false;
    }
}