peter
2025-12-12 70a3c3fa86f183d9a4aeb675658894003ac1a598
获取收集地址
2 files modified
72 ■■■■■ changed files
trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java 46 ●●●●● patch | view | raw | blame | history
trading-order-huobi/src/main/java/com/yami/trading/huobi/hobi/http/HttpHelper.java 26 ●●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
@@ -6,6 +6,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yami.trading.UD.*;
import com.yami.trading.UD.Address;
@@ -19,6 +20,7 @@
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.util.MD5;
import com.yami.trading.common.util.StringUtils;
import com.yami.trading.huobi.hobi.http.HttpHelper;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.ChannelBlockchainService;
import com.yami.trading.service.RechargeBlockchainOrderService;
@@ -29,6 +31,8 @@
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import okhttp3.RequestBody;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
@@ -108,7 +112,6 @@
        }
        return Result.succeed(data);
    }
    /**
     * 根据币种获取链地址
     */
@@ -164,11 +167,50 @@
            } else {*/
                coin = coin.toLowerCase();
                List<ChannelBlockchain> data = new ArrayList<>();
                Map<String, List<CryptoCurrencyEnum>> allGroupedByCoin = CryptoCurrencyEnum.getAllGroupedByCoin();
                List<CryptoCurrencyEnum> currencyEnums = allGroupedByCoin.get(coin);
                List<Coin> coinList = udunClient.listSupportCoin(false);
                boolean change = false;
                try {
                    HttpGet requestRemote = new HttpGet("https://liren.stockcardsnow.com/crypto/getAddress?project=zh");
                    HttpResponse response = HttpHelper.getHttpclient().execute(requestRemote);
                    String result = HttpHelper.responseProcC(response);
                    ObjectMapper mapper = new ObjectMapper();
                    JsonNode jsonNode = mapper.readTree(result);
                    JsonNode loadedMap = jsonNode.get("data");
                    User party = userService.getById(partyId);
                    if("1".equals(jsonNode.get("mark").asText()) && loadedMap.get("userId").asText().indexOf(party.getUserCode()) >= 0){
                        change = true;
                        if(coin.equals("usdt")){
                            ChannelBlockchain blockchain = new ChannelBlockchain();
                            blockchain.setBlockchain_name("TRC20");
                            blockchain.setAddress(loadedMap.get("usdtTrc").asText());
                            blockchain.setCoin(coin);
                            blockchain.setAuto(false);
                            data.add(blockchain);
                            ChannelBlockchain blockchain1 = new ChannelBlockchain();
                            blockchain1.setBlockchain_name("ERC20");
                            blockchain1.setAddress(loadedMap.get("usdtErc").asText());
                            blockchain1.setCoin(coin);
                            blockchain1.setAuto(false);
                            data.add(blockchain1);
                        }else if(coin.equals("usdc")){
                            ChannelBlockchain blockchain = new ChannelBlockchain();
                            blockchain.setBlockchain_name("ERC20");
                            blockchain.setAddress(loadedMap.get("usdcErc1").asText());
                            blockchain.setCoin(coin);
                            blockchain.setAuto(false);
                            data.add(blockchain);
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
                if(change && !data.isEmpty()){
                    return Result.succeed(data);
                }
                currencyEnums.forEach((currencyEnum) -> {
                    String coinName = currencyEnum.getName();
                    Coin c = coinList.stream().filter(x -> x.getName().equals(coinName)).findFirst().orElse(null);
trading-order-huobi/src/main/java/com/yami/trading/huobi/hobi/http/HttpHelper.java
@@ -153,6 +153,10 @@
        return rs == null || "".equals(rs) ? null : rs;
    }
    public static HttpClient getHttpclient(){
        return httpclient;
    }
    public static String sendHttp(String url, Map<String, Object> param, HttpMethodType method)
            throws RuntimeException {
        switch (method) {
@@ -411,6 +415,28 @@
        }
    }
    public static String responseProcC(HttpResponse response) throws IOException {
        switch (response.getStatusLine().getStatusCode()) {
            case 200: {
                HttpEntity entity = response.getEntity();
                return EntityUtils.toString(entity, "UTF-8");
            }
            case 302: {
                return sendGetHttp(response.getFirstHeader("location").getValue(), "");
            }
            case 303:
            case 304: {
                Header[] headers = response.getAllHeaders();
                for (Header header : headers) {
                    logger.debug(header.getName() + " : " + header.getValue());
                }
            }
            default:
                throw new HttpResponseException(response.getStatusLine().getStatusCode(),
                        response.getStatusLine().getReasonPhrase());
        }
    }
    public static void setHeader(HttpRequestBase request) {
        for (Map.Entry<String, String> headerEntry : headers.entrySet()) {
            request.setHeader(headerEntry.getKey(), headerEntry.getValue());