| | |
| | | @Override |
| | | public void save_api(RechargeBlockchain recharge) { |
| | | |
| | | if (!"ETH".equals(recharge.getSymbol().toUpperCase())) { |
| | | ChannelBlockchain channel = channelBlockchainService.findByNameAndCoinAndAdd(recharge.getBlockchain_name(), |
| | | recharge.getSymbol(), recharge.getChannel_address()); |
| | | |
| | | if (channel == null || !recharge.getSymbol().toUpperCase().equals(channel.getCoin())) { |
| | | throw new BusinessException("充值链错误"); |
| | | } |
| | | } |
| | | |
| | | double recharge_limit_min = Double.valueOf(sysparaService.find("recharge_limit_min").getValue()); |
| | | double recharge_limit_max = Double.valueOf(sysparaService.find("recharge_limit_max").getValue()); |
| | | if ("usdt".equals(recharge.getSymbol())) { |
| | |
| | | * 根据区块地址获取充值订单 |
| | | */ |
| | | public RechargeBlockchain getAddress(String address) { |
| | | List<RechargeBlockchain> list = jdbcTemplate.query("SELECT * FROM T_RECHARGE_BLOCKCHAIN_ORDER WHERE blockchain_name=?", RecordObjectMapper.newInstance(RechargeBlockchain.class), address); |
| | | List<RechargeBlockchain> list = jdbcTemplate.query("SELECT * FROM T_RECHARGE_BLOCKCHAIN_ORDER WHERE succeeded = 0 and CHANNEL_ADDRESS=?", RecordObjectMapper.newInstance(RechargeBlockchain.class), address); |
| | | if (null != list && list.size() > 0) { |
| | | return list.get(0); |
| | | } |
| | |
| | | try { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | Map<String, Object> map = objectMapper.readValue(body, HashMap.class); |
| | | double amounts = Double.parseDouble(map.get("fee").toString()); // 假设 amount 的值为 1000 |
| | | 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); |
| | | RechargeBlockchain recharge = this.getAddress(map.get("address").toString()); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<RechargeBlockchain> getByAddressUndone(String channelAddress) { |
| | | return getUndone(channelAddress); |
| | | } |
| | | public List<RechargeBlockchain> getUndone(String channelAddress){ |
| | | List<RechargeBlockchain> list = jdbcTemplate.query("SELECT * FROM T_RECHARGE_BLOCKCHAIN_ORDER WHERE succeeded = 0 and CHANNEL_ADDRESS=?", RecordObjectMapper.newInstance(RechargeBlockchain.class), channelAddress); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | public void insertRechargeBlockchain(RechargeBlockchain rechargeBlockchain) { |
| | | Object[] jdbcParams = ApplicationUtil.getInsertStatement(rechargeBlockchain); |
| | | String insertUserSql = (String)jdbcParams[0]; |