1
zj
13 hours ago f658569891db433854221b80f0a9fa99608cff64
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiContractApplyOrderController.java
@@ -215,7 +215,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 +227,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("无网络");
@@ -294,14 +292,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("无网络");
@@ -392,6 +388,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 +575,17 @@
        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;
        }
        if (!user.isGoogleAuthBind() || StringUtils.isEmptyString(user.getSafePassword())) {
            throw new YamiShopBindException("请先完成两步认证并设置资金密码后再交易");
        }
    }
}