| | |
| | | String partyBTC = Optional.ofNullable(RedisUtil.get(partyId + "_BTC")) |
| | | .map(Object::toString) |
| | | .orElse(""); |
| | | Address address3 = new Address(); |
| | | if(!StringUtils.isNotEmpty(partyBTC)){ |
| | | address3 = createAddress(f.getMainCoinType(),null,null,null); |
| | | Address address3 = createAddress(f.getMainCoinType(),null,null,null); |
| | | blockchainList.add(createElement("2c948a8280828d5f018084ff569b0002", "btc", "/qr/1be19b34fbb9406c8044c1a9b08a87ca.png", address3.getAddress(),"BTC")); |
| | | RedisUtil.set(partyId+ "_BTC",address3.getAddress()); |
| | | }else{ |
| | |
| | | String partyETH = Optional.ofNullable(RedisUtil.get(partyId + "_ETH")) |
| | | .map(Object::toString) |
| | | .orElse(""); |
| | | List<Map<String, Object>> ethData = new ArrayList<>(); |
| | | if(!StringUtils.isNotEmpty(partyETH)){ |
| | | Address address3 = createAddress(f.getMainCoinType(),null,null,null); |
| | | blockchainList.add(createElement("2c948a8280828d5f018084ff569b0002", "eth", "/qr/1be19b34fbb9406c8044c1a9b08a87ca.png", address3.getAddress(),"ETH")); |
| | |
| | | String partyUSDT = Optional.ofNullable(RedisUtil.get(partyId + "_USDT-ERC20")) |
| | | .map(Object::toString) |
| | | .orElse(""); |
| | | List<Map<String, Object>> usdtData = new ArrayList<>(); |
| | | if(!StringUtils.isNotEmpty(partyUSDT)){ |
| | | Address address3 = createAddress(f.getMainCoinType(),null,null,null); |
| | | blockchainList.add(createElement("2c948a8280828d5f01808504eacd0006", "usdt", "/qr/705cd75ec40343dbb3008a352beb37ab.png", address3.getAddress(),"ERC20")); |
| | |
| | | String partyUSDC = Optional.ofNullable(RedisUtil.get(partyId + "USDC")) |
| | | .map(Object::toString) |
| | | .orElse(""); |
| | | List<Map<String, Object>> usdcData = new ArrayList<>(); |
| | | if(!StringUtils.isNotEmpty(partyUSDC)){ |
| | | Address address3 = createAddress(f.getMainCoinType(),null,null,null); |
| | | blockchainList.add(createElement("2c948a8280828d5f01808504eacd0004", "usdc", "/qr/975f4666ed044efa9f0ee2fa81fa8f4a.png", address3.getAddress(),"ERC20")); |
| | | RedisUtil.set(partyId + "_USDT-ERC20",address3.getAddress()); |
| | | RedisUtil.set(partyId + "USDC",address3.getAddress()); |
| | | }else{ |
| | | blockchainList.add(createElement("2c948a8280828d5f01808504eacd0004", "usdc", "/qr/975f4666ed044efa9f0ee2fa81fa8f4a.png", partyUSDC,"ERC20")); |
| | | } |
| | |
| | | channelBlockchain.setBlockchain_name(blockchain_name); |
| | | return channelBlockchain; |
| | | } |
| | | |
| | | @RequestMapping(action +"rechargeCallback.action") |
| | | public ResultMsg rechargeCallback(HttpServletRequest request){ |
| | | String timestamp = request.getParameter("timestamp"); |
| | | String nonce = request.getParameter("nonce"); |
| | | String sign = request.getParameter("sign"); |
| | | String body = request.getParameter("body"); |
| | | try{ |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | Map<String, Object> map = objectMapper.readValue(body, HashMap.class); |
| | | double amounts = Double.parseDouble(map.get("amount").toString()); // 假设 amount 的值为 1000 |
| | | 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) |
| | | .eq(RechargeBlockchainOrder::getSucceeded, 0) |
| | | .eq(RechargeBlockchainOrder::getChannelAddress, address).last(" limit 1 ")); |
| | | if(ObjectUtil.isEmpty(blockchainOrder)){ |
| | | ResultMsg resultMsg = new ResultMsg(); |
| | | resultMsg.setCode(200); |
| | | return resultMsg; |
| | | } |
| | | SysUser user = sysUserService.getSysUserById( Long.getLong(blockchainOrder.getPartyId())); |
| | | rechargeBlockchainOrderService.manualReceipt(1,blockchainOrder.getPartyId(), BigDecimal.valueOf(success_amount),user.getUsername()); |
| | | ResultMsg resultMsg = new ResultMsg(); |
| | | resultMsg.setCode(200); |
| | | return resultMsg; |
| | | }catch (Exception e){ |
| | | ResultMsg resultMsg = new ResultMsg(); |
| | | resultMsg.setCode(500); |
| | | resultMsg.setMessage("回调处理失败"); |
| | | return resultMsg; |
| | | } |
| | | } |
| | | //回调地址关闭 |
| | | // @RequestMapping(action +"rechargeCallback.action") |
| | | // public ResultMsg rechargeCallback(HttpServletRequest request){ |
| | | // String timestamp = request.getParameter("timestamp"); |
| | | // String nonce = request.getParameter("nonce"); |
| | | // String sign = request.getParameter("sign"); |
| | | // String body = request.getParameter("body"); |
| | | // try{ |
| | | // ObjectMapper objectMapper = new ObjectMapper(); |
| | | // Map<String, Object> map = objectMapper.readValue(body, HashMap.class); |
| | | // double amounts = Double.parseDouble(map.get("amount").toString()); // 假设 amount 的值为 1000 |
| | | // 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) |
| | | // .eq(RechargeBlockchainOrder::getSucceeded, 0) |
| | | // .eq(RechargeBlockchainOrder::getChannelAddress, address).last(" limit 1 ")); |
| | | // if(ObjectUtil.isEmpty(blockchainOrder)){ |
| | | // ResultMsg resultMsg = new ResultMsg(); |
| | | // resultMsg.setCode(200); |
| | | // return resultMsg; |
| | | // } |
| | | // SysUser user = sysUserService.getSysUserById( Long.getLong(blockchainOrder.getPartyId())); |
| | | // rechargeBlockchainOrderService.manualReceipt(1,blockchainOrder.getPartyId(), BigDecimal.valueOf(success_amount),user.getUsername()); |
| | | // ResultMsg resultMsg = new ResultMsg(); |
| | | // resultMsg.setCode(200); |
| | | // return resultMsg; |
| | | // }catch (Exception e){ |
| | | // ResultMsg resultMsg = new ResultMsg(); |
| | | // resultMsg.setCode(500); |
| | | // resultMsg.setMessage("回调处理失败"); |
| | | // return resultMsg; |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 根据第三方充值链接 |