1
zj
4 days ago 2e26306ed035bf60e6789dc1bbdabd914f630df8
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiContractApplyOrderController.java
@@ -22,6 +22,7 @@
import com.yami.trading.common.util.ThreadUtils;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.MarketOpenChecker;
import com.yami.trading.service.RealNameAuthRecordService;
import com.yami.trading.service.SessionTokenService;
import com.yami.trading.service.WalletService;
import com.yami.trading.service.contract.ContractApplyOrderService;
@@ -96,6 +97,8 @@
    private SessionTokenService sessionTokenService;
    @Autowired
    TipService tipService;
    @Autowired
    private RealNameAuthRecordService realNameAuthRecordService;
//    @Autowired
//    private ExchangeRateService exchangeRateService;
@@ -215,7 +218,7 @@
        RLock rLock = null;
        boolean lockResult = false;
        try {
           String partyId = SecurityUtils.getUser().getUserId();
           String partyId = SecurityUtils.getCurrentUserId();
            rLock = redissonClient.getLock("contract_open_" + partyId);
            
            lockResult = rLock.tryLock(5, TimeUnit.SECONDS);
@@ -227,14 +230,13 @@
            if (!user.isEnabled()) {
                throw new YamiShopBindException("用户已锁定");
            }
            validateTradePermission(user);
            realNameAuthRecordService.requireApproved(user, true);
            Syspara syspara = sysparaService.find("stop_user_internet");
            String stopUserInternet = syspara.getSvalue();
            if(org.apache.commons.lang3.StringUtils.isNotEmpty(stopUserInternet)) {
                String[] stopUsers = stopUserInternet.split(",");
                System.out.println("userName = " + user.getUserName());
                System.out.println("stopUserInternet = " + stopUserInternet);
                if(Arrays.asList(stopUsers).contains(user.getUserName())){
                    throw new YamiShopBindException("无网络");
@@ -294,14 +296,12 @@
            if (!user.isEnabled()) {
                throw new YamiShopBindException("用户已锁定");
            }
            validateTradePermission(user);
            Syspara syspara = sysparaService.find("stop_user_internet");
            String stopUserInternet = syspara.getSvalue();
            if(org.apache.commons.lang3.StringUtils.isNotEmpty(stopUserInternet)) {
                String[] stopUsers = stopUserInternet.split(",");
                System.out.println("userName = " + user.getUserName());
                System.out.println("stopUserInternet = " + stopUserInternet);
                if(Arrays.asList(stopUsers).contains(user.getUserName())){
                    throw new YamiShopBindException("无网络");
@@ -312,7 +312,7 @@
            order.setPartyId(partyId);
            order.setSymbol(closeAction.getSymbol());
            order.setDirection(closeAction.getDirection());
            order.setOffset(ContractApplyOrder.OFFSET_OPEN);
            order.setOffset(ContractApplyOrder.OFFSET_CLOSE);
            order.setVolume(closeAction.getAmount());
            order.setVolumeOpen(closeAction.getAmount());
            order.setPrice(closeAction.getPrice());
@@ -392,6 +392,7 @@
        map.put("amount", order.getVolume().multiply(order.getUnitAmount()).setScale(4, RoundingMode.FLOOR));
        map.put("amount_open", order.getVolumeOpen().multiply(order.getUnitAmount()));
        map.put("fee", order.getFee());
        map.put("funding_fee", order.getFundingFee());
        map.put("deposit", order.getDeposit());
        return Result.succeed(map);
    }
@@ -578,4 +579,14 @@
        dateN.put("count", count);
        return Result.ok(dateN);
    }
    private void validateTradePermission(User user) {
        if (user == null) {
            throw new YamiShopBindException("用户不存在");
        }
        // 模拟账户不做二步校验限制
        if (user.getAccountType() != null && user.getAccountType() == 1) {
            return;
        }
    }
}