新版仿ok交易所-后端
zyy
2025-09-01 69b5fdc593fa73424448df0c911c5177f7497e7c
trading-order-service/src/main/java/com/yami/trading/service/item/ItemService.java
@@ -16,11 +16,13 @@
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.common.exception.YamiShopBindException;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -48,7 +50,6 @@
    private ItemLeverageService itemLeverageService;
    private Map<String, Integer> symbolDecimal = Maps.newHashMap();
    @Autowired
    private CacheManager cacheManager;
@@ -162,7 +163,7 @@
    @Cached(name = ITEM_CACHE, key = "'all'", expire = 3600)
    @Override
    public List<Item> list() {
        List<Item> list = super.list();
        List<Item> list = super.list(new LambdaQueryWrapper<>(Item.class).eq(Item::getType,Item.cryptos));
        symbolDecimal = list.stream()
                .collect(Collectors.toMap(Item::getSymbol, Item::getDecimals, (s1, s2) -> s2));
        return list;
@@ -203,7 +204,7 @@
    }
    public List<Item> cacheGetAll() {
        return ApplicationContextUtils.getApplicationContext().getBean(ItemService.class).list();
        return ApplicationContextUtils.getApplicationContext().getBean(ItemService.class).list(new LambdaQueryWrapper<>(Item.class).eq(Item::getType,Item.cryptos));
    }
@@ -229,4 +230,35 @@
        Item bySymbol = findBySymbol(symbol);
        return MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType());
    }
    /**
     * 是否开放合约
     * @param item
     * @return
     */
    public boolean isContractTrading(Item item) {
        //虚拟币新币才判断
        if (item.getType().equals(Item.cryptos) && (item.getCurrencyType() != null && item.getCurrencyType() == 1)) {
            if (item.getTradeType() != null && item.getTradeType().equals("0")) {
                return false;
            }
        }
        return true;
    }
    /**
     * 是否停牌状态
     * @param item
     * @return
     */
    public boolean isSuspended(Item item) {
        //虚拟币新币才判断
        if (item.getType().equals(Item.cryptos) && (item.getCurrencyType() != null && item.getCurrencyType() == 1)) {
            if (item.getStatus() != null && item.getStatus() == 0) {
                return true;
            }
        }
        return false;
    }
}