| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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.*; |
| | |
| | | } |
| | | return Result.succeed(data); |
| | | } |
| | | |
| | | /** |
| | | * 根据币种获取链地址 |
| | | */ |
| | |
| | | } 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); |