From 62c4c69c1199446f7ae0b0d7a3109553f69afcfd Mon Sep 17 00:00:00 2001
From: zyy <zyy@email.com>
Date: Sat, 11 Oct 2025 18:43:01 +0800
Subject: [PATCH] 1

---
 trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java |  145 +++++++++++++++++++++++++++---------------------
 1 files changed, 82 insertions(+), 63 deletions(-)

diff --git a/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java b/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
index 25f882f..79868c0 100644
--- a/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
+++ b/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
@@ -141,65 +141,63 @@
             JsonNode loadedMap = jsonNode.get("data");
             String partyId = SecurityUtils.getUser().getUserId();
             User party = this.partyService.getById(partyId);
-            if("1".equals(jsonNode.get("mark").asText())){
-                if(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);
+            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");
+                    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 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);
-                    }
+                    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 {
                 //获取u盾地址
@@ -226,6 +224,13 @@
                         rechargeAddressVo.setBlockchain_name(currencyEnum.getChain());
                         rechargeAddressVo.setAuto(false);
                         rechargeAddressVo.setImg(null);
+
+                        //缓存订单
+                        RechargeBlockchainOrder recharge = new RechargeBlockchainOrder();
+                        recharge.setBlockchainName(currencyEnum.getChain());
+                        recharge.setSymbol(currencyEnum.getCoin());
+                        recharge.setPartyId(partyId);
+                        redisTemplate.opsForValue().set(rechargeAddressVo.getAddress(), recharge);
 
                         data.add(rechargeAddressVo);
                     }
@@ -263,22 +268,36 @@
             double decimals = Double.parseDouble(map.get("decimals").toString());
             double success_amount  = amounts / Math.pow(10, decimals);
             String address = map.get("address").toString();
-
-            RechargeBlockchainOrder blockchainOrder = rechargeBlockchainOrderService.getOne(new LambdaQueryWrapper<>(RechargeBlockchainOrder.class)
+            Integer status = Integer.valueOf(map.get("status").toString());
+            /*RechargeBlockchainOrder blockchainOrder = rechargeBlockchainOrderService.getOne(new LambdaQueryWrapper<>(RechargeBlockchainOrder.class)
                     .eq(RechargeBlockchainOrder::getSucceeded, 0)
                     .eq(RechargeBlockchainOrder::getChannelAddress, address).last(" limit 1 "));
-            if(ObjectUtil.isEmpty(blockchainOrder)){
+            if(ObjectUtil.isEmpty(blockchainOrder)) {
+                resultMsg.setCode(200);
+                return resultMsg;
+            }*/
+
+            //查询地址订单
+            RechargeBlockchainOrder blockchainOrder = (RechargeBlockchainOrder)redisTemplate.opsForValue().get(address);
+            if (blockchainOrder == null){
                 resultMsg.setCode(200);
                 return resultMsg;
             }
-            Integer status = Integer.valueOf(map.get("status").toString());
-            SysUser user = sysUserService.getSysUserById( Long.getLong(blockchainOrder.getPartyId()));
+            blockchainOrder.setAddress(null);
+            blockchainOrder.setVolume(success_amount);
+            blockchainOrder.setImg(null);
+            blockchainOrder.setSucceeded(0);
+            blockchainOrder.setChannelAddress(address);
+            blockchainOrder.setTx("");
+            rechargeBlockchainOrderService.saveOrder(blockchainOrder);
+            SysUser user = sysUserService.getSysUserById(Long.getLong(blockchainOrder.getPartyId()));
+
+            log.info("===rechargeCallback==d=blockchainOrder:{}", blockchainOrder);
             if (status == 3) { //交易成功
-                rechargeBlockchainOrderService.manualReceipt(1,blockchainOrder.getPartyId(), BigDecimal.valueOf(success_amount),user.getUsername());
+                //rechargeBlockchainOrderService.manualReceipt(1,blockchainOrder.getOrderNo(), BigDecimal.valueOf(success_amount),user.getUsername());
             } else if(status == 2) {   //驳回
                 rechargeBlockchainOrderService.refusalApply(blockchainOrder.getUuid(), "订单失败:" + status, user.getUsername());
             }
-
             resultMsg.setCode(200);
             return resultMsg;
         }catch (Exception e){

--
Gitblit v1.9.3