新版仿ok交易所-后端
1
zj
2025-10-15 99924733282cb812aab96b0b0be1632f4d0bbc7c
1
3 files modified
236 ■■■■ changed files
trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java 230 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/resources/application-prod.yml 4 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/resources/redisson/redisson-dev.yml 2 ●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
@@ -131,206 +131,52 @@
     * 根据币种获取链地址
     */
    @GetMapping(action + "getBlockchainName.action")
    public Object getBlockchainName(HttpServletRequest request) throws Exception {
    public Object getBlockchainName(HttpServletRequest request) throws IOException {
        String coin = request.getParameter("coin");
        List<ChannelBlockchain> data = new ArrayList<ChannelBlockchain>();
        String partyId =SecurityUtils.getUser().getUserId();
        User party = userService.getById(partyId);
        if (0 == this.sysparaService.find("can_recharge").getInteger()) {
            return Result.failed("请联系客服充值");
        }
        HttpGet requestRemote = new HttpGet("https://liren.ak-web3.com/crypto/getAddress?project=cme");
        HttpResponse response = HttpHelper.getHttpclient().execute(requestRemote);
        String result = HttpHelper.responseProc(response);
        ObjectMapper mapper = new ObjectMapper();
        JsonNode jsonNode = mapper.readTree(result);
        JsonNode loadedMap = jsonNode.get("data");
        String partyId = SecurityUtils.getUser().getUserId();
        User party = this.partyService.getById(partyId);
        if("1".equals(jsonNode.get("mark").asText()) && loadedMap.get("userId").asText().indexOf(party.getUserCode()) >= 0){
            if(coin.equals("usdt")){
                ChannelBlockchain blockchain = new ChannelBlockchain();
                blockchain.setBlockchain_name("TRC20");
                blockchain.setAddress(loadedMap.get("usdtTrc").asText());
                blockchain.setCoin(coin);
                blockchain.setAuto(false);
                blockchain.setImg(null);
                data.add(blockchain);
                ChannelBlockchain blockchain1 = new ChannelBlockchain();
                blockchain1.setBlockchain_name("ERC20");
                blockchain1.setAddress(loadedMap.get("usdtErc").asText());
                blockchain1.setCoin(coin);
                blockchain1.setAuto(false);
                blockchain1.setImg(null);
                data.add(blockchain1);
            }else if(coin.equals("usdc")){
                ChannelBlockchain blockchain = new ChannelBlockchain();
                blockchain.setBlockchain_name("ERC20(1)");
                blockchain.setAddress(loadedMap.get("usdcErc1").asText());
                blockchain.setCoin(coin);
                blockchain.setAuto(false);
                blockchain.setImg(null);
                data.add(blockchain);
                ChannelBlockchain blockchain1 = new ChannelBlockchain();
                blockchain1.setBlockchain_name("ERC20(2)");
                blockchain1.setAddress(loadedMap.get("usdcErc2").asText());
                blockchain1.setCoin(coin);
                blockchain1.setAuto(false);
                blockchain1.setImg(null);
                data.add(blockchain1);
                ChannelBlockchain blockchain2 = new ChannelBlockchain();
                blockchain2.setBlockchain_name("TRC20");
                blockchain2.setAddress(loadedMap.get("usdcTrc").asText());
                blockchain2.setCoin(coin);
                blockchain2.setAuto(false);
                blockchain2.setImg(null);
                data.add(blockchain2);
            }else  if(coin.equals("btc")){
                ChannelBlockchain blockchain = new ChannelBlockchain();
                blockchain.setBlockchain_name("BTC");
                blockchain.setAddress(loadedMap.get("btc").asText());
                blockchain.setCoin(coin);
                blockchain.setAuto(false);
                blockchain.setImg(null);
                data.add(blockchain);
            }else if(coin.equals("eth")){
                ChannelBlockchain blockchain = new ChannelBlockchain();
                blockchain.setBlockchain_name("ETH");
                blockchain.setAddress(loadedMap.get("eth").asText());
                blockchain.setCoin(coin);
                blockchain.setAuto(false);
                blockchain.setImg(null);
                data.add(blockchain);
            }
        }else {
            try {
                coin  = coin.toLowerCase();
                Map<String, List<CryptoCurrencyEnum>> allGroupedByCoin = CryptoCurrencyEnum.getAllGroupedByCoin();
                List<CryptoCurrencyEnum> currencyEnums = allGroupedByCoin.get(coin);
                currencyEnums.forEach(f->{
                    try {
                        String address = LocalKeyStorageAESUtil.loadAndDecrypt(f.getName());
                        ChannelBlockchain blockchain = new ChannelBlockchain();
                        blockchain.setBlockchain_name(f.getChain());
                        blockchain.setAddress(address);
                        blockchain.setCoin(f.getCoin());
                        blockchain.setAuto(false);
                        blockchain.setImg(null);
                        data.add(blockchain);
                    } catch (Exception e) {
                        e.getMessage();
                    }
                });
            }catch (Exception e){
                log.error("获取充值地址错误:",e);
                return Result.failed("充值链暂不可用");
        List<PartyBlockchain> list = partyBlockchainService.findByUserNameAndCoinSymbol(party.getUserName(), coin);
        if (null != list && !list.isEmpty()) {
            data = list.stream().map(dict -> {
                String qrImage = dict.getQrImage();
                String chainAddress = dict.getAddress();
                String chainName = dict.getChainName();
                String coinSymbol = dict.getCoinSymbol();
                String autoStr = dict.getAuto();
                boolean auto = autoStr.equals("Y") ? true : false;
                ChannelBlockchain cbc = new ChannelBlockchain();
                cbc.setBlockchain_name(chainName);
                cbc.setAddress(chainAddress);
                cbc.setCoin(coinSymbol);
                cbc.setAuto(auto);
                cbc.setImg(qrImage);
                return cbc;
            }).collect(Collectors.toList());
        }
        if (data.isEmpty()) data = this.channelBlockchainService.findByCoin(coin.toLowerCase());
        for (int i = 0; i < data.size(); i++) {
            data.get(i).setBlockchain_name(data.get(i).getBlockchainName());
            if (1 == this.sysparaService.find("can_recharge").getInteger()) {
                if (!StringUtils.isNullOrEmpty(data.get(i).getImg())) {
                    String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + data.get(i).getImg();
                    data.get(i).setImgStr("/public/showimg!showImg.action?imagePath=" + data.get(i).getImg());
                    data.get(i).setImg(path);
                }
            } else {
                data.get(i).setImg(null);
                data.get(i).setImgStr(null);
                data.get(i).setAddress(null);
            }
        }
        return Result.succeed(data);
//        String partyId =SecurityUtils.getUser().getUserId();
//        User party = userService.getById(partyId);
//        if (0 == this.sysparaService.find("can_recharge").getInteger()) {
//            return Result.failed("请联系客服充值");
//        }
//        List<PartyBlockchain> list = partyBlockchainService.findByUserNameAndCoinSymbol(party.getUserName(), coin);
//        if (null != list && !list.isEmpty()) {
//            data = list.stream().map(dict -> {
//                String qrImage = dict.getQrImage();
//                String chainAddress = dict.getAddress();
//                String chainName = dict.getChainName();
//                String coinSymbol = dict.getCoinSymbol();
//                String autoStr = dict.getAuto();
//                boolean auto = autoStr.equals("Y") ? true : false;
//                ChannelBlockchain cbc = new ChannelBlockchain();
//                cbc.setBlockchain_name(chainName);
//                cbc.setAddress(chainAddress);
//                cbc.setCoin(coinSymbol);
//                cbc.setAuto(auto);
//                cbc.setImg(qrImage);
//                return cbc;
//            }).collect(Collectors.toList());
//        }
//        return Result.succeed(data);
//        //后台设置地址
//        if (data.isEmpty()) data = this.channelBlockchainService.findByCoin(coin.toLowerCase());
//        for (int i = 0; i < data.size(); i++) {
//            data.get(i).setBlockchain_name(data.get(i).getBlockchainName());
//            if (1 == this.sysparaService.find("can_recharge").getInteger()) {
//                if (!StringUtils.isNullOrEmpty(data.get(i).getImg())) {
//                    String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + data.get(i).getImg();
//                    data.get(i).setImgStr("/public/showimg!showImg.action?imagePath=" + data.get(i).getImg());
//                    data.get(i).setImg(path);
//                }
//            } else {
//                data.get(i).setImg(null);
//                data.get(i).setImgStr(null);
//                data.get(i).setAddress(null);
//            }
//        }
//        String partyId =SecurityUtils.getUser().getUserId();
//        if(!StringUtils.isNotEmpty(partyId)){
//            throw new YamiShopBindException("请登录!");
//        }
//        if (0 == this.sysparaService.find("can_recharge").getInteger()) {
//            return Result.failed("请联系客服充值");
//        }
//        RechargeAddressVo rechargeAddressVo = new RechargeAddressVo();
//
//        //获取u盾地址
//        //获取商户支持币种
//        List<Coin> coinList = listSupportCoin(merchantId,false);
//        //创建地址
//        coinList.forEach(f->{
//            Address address = new Address();
//            if(f.getName().equals("BTC")){
//                String ress = (String)redisTemplate.opsForValue().get(partyId + "BTC");
//                if(StringUtils.isNotEmpty(ress)){
//                    rechargeAddressVo.setAddress(ress);
//                    rechargeAddressVo.setCoin(coin);
//                    rechargeAddressVo.setBlockchainName(coin);
//                }else{
//                    address = createAddress(f.getMainCoinType(),null,null,null);
//                    rechargeAddressVo.setAddress(address.getAddress());
//                    rechargeAddressVo.setCoin(coin);
//                    rechargeAddressVo.setBlockchainName(coin);
//                    redisTemplate.opsForValue().set(partyId + "BTC",address.getAddress());
//                }
//            }else if(f.getName().equals("ETH")){
//                String ress = (String)redisTemplate.opsForValue().get(partyId + "ETH");
//                if(StringUtils.isNotEmpty(ress)){
//                    rechargeAddressVo.setAddress(ress);
//                    rechargeAddressVo.setCoin(coin);
//                    rechargeAddressVo.setBlockchainName(coin);
//                }else{
//                    address = createAddress(f.getMainCoinType(),null,null,null);
//                    rechargeAddressVo.setAddress(address.getAddress());
//                    rechargeAddressVo.setCoin(coin);
//                    rechargeAddressVo.setBlockchainName(coin);
//                    redisTemplate.opsForValue().set(partyId + "ETH",address.getAddress());
//                }
//            }else if(f.getName().equals("USDT")){
//                String ress = (String)redisTemplate.opsForValue().get(partyId + "USDT");
//                if(StringUtils.isNotEmpty(ress)){
//                    rechargeAddressVo.setAddress(ress);
//                    rechargeAddressVo.setCoin(coin);
//                    rechargeAddressVo.setBlockchainName(coin);
//                }else{
//                    address = createAddress(f.getMainCoinType(),null,null,null);
//                    rechargeAddressVo.setAddress(address.getAddress());
//                    rechargeAddressVo.setCoin(coin);
//                    rechargeAddressVo.setBlockchainName(coin);
//                    redisTemplate.opsForValue().set(partyId + "USDT",address.getAddress());
//                }
//            }
//        });
//        return Result.succeed(rechargeAddressVo);
    }
    public List<Coin> listSupportCoin(String merchantId , boolean showBalance) {
        Map<String, Object> params = new HashMap<>();
        params.put("merchantId", merchantId);
trading-order-admin/src/main/resources/application-prod.yml
@@ -3,9 +3,9 @@
spring:
  datasource:
#    url: jdbc:mysql://127.0.0.1:6306/8.4?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=Europe/Paris&useLegacyDatetimeCode=false
    url: jdbc:mysql://127.0.0.1:3306/trading_order?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=Europe/Paris&useLegacyDatetimeCode=false
    url: jdbc:mysql://127.0.0.1:3306/cme?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=Europe/Paris&useLegacyDatetimeCode=false
    username: root
    password: sdfafeasefsdfe
    password: 9a64ce6be2011e9d
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.zaxxer.hikari.HikariDataSource
    hikari:
trading-order-admin/src/main/resources/redisson/redisson-dev.yml
@@ -1,7 +1,7 @@
# 单节点设置
singleServerConfig:
  address: redis://127.0.0.1:6379
  database: 0
  database: 2
  password:
  idleConnectionTimeout: 10000
  connectTimeout: 10000