|  |  |  | 
|---|
|  |  |  | private MemberWalletCoinDao memberWalletCoinDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private UsdtEthService usdtEthService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private RedisUtils redisUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final static String EOS_SEQ_KEY = "eos_seq_key"; | 
|---|
|  |  |  | 
|---|
|  |  |  | BigDecimal newBalance = balance.subtract(early); | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(walletCoinEntity.getId(), newBalance, balance, 0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "ERC20", balance,null); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "ERC20", balance, null); | 
|---|
|  |  |  | // 插入财务记录 | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.USDT.name(), 1, 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BigDecimal newBalance = balance.subtract(early); | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.ETH.name(), null, balance,null); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.ETH.name(), null, balance, null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 插入财务记录 | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.ETH.name(), 1, 1); | 
|---|
|  |  |  | 
|---|
|  |  |  | BigDecimal newBalance = balance.subtract(early); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "OMNI", balance,null); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "OMNI", balance, null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ThreadPoolUtils.sendDingTalk(5); | 
|---|
|  |  |  | MemberEntity member = memberDao.selectById(memberId); | 
|---|
|  |  |  | 
|---|
|  |  |  | BigDecimal newBalance = balance.subtract(early); | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.BTC.name(), null, balance,null); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.BTC.name(), null, balance, null); | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.BTC.name(), 1, 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ThreadPoolUtils.sendDingTalk(5); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (memberCoinAddressEntity != null) { | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(memberWalletCoinEntity.getId(), amount, BigDecimal.ZERO, 0); | 
|---|
|  |  |  | // 添加冲币记录 | 
|---|
|  |  |  | String orderNo = insertCoinCharge(EosService.ACCOUNT, memberId, amount, CoinTypeEnum.EOS.name(), memo, BigDecimal.ZERO,null); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(EosService.ACCOUNT, memberId, amount, CoinTypeEnum.EOS.name(), memo, BigDecimal.ZERO, null); | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", amount, CoinTypeEnum.EOS.name(), 1, 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ThreadPoolUtils.sendDingTalk(5); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (memberCoinAddressEntity != null) { | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(memberWalletCoinEntity.getId(), amount, BigDecimal.ZERO, 0); | 
|---|
|  |  |  | // 添加冲币记录 | 
|---|
|  |  |  | String orderNo = insertCoinCharge(XrpService.ACCOUNT, memberId, amount, CoinTypeEnum.XRP.name(), memo, BigDecimal.ZERO,null); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(XrpService.ACCOUNT, memberId, amount, CoinTypeEnum.XRP.name(), memo, BigDecimal.ZERO, null); | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", amount, CoinTypeEnum.XRP.name(), 1, 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ThreadPoolUtils.sendDingTalk(5); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(memberWalletCoinEntity.getId(), amount, BigDecimal.ZERO, 0); | 
|---|
|  |  |  | // 添加冲币记录 | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, amount, CoinTypeEnum.USDT.name(), "TRC20", BigDecimal.ZERO,transactionId); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, amount, CoinTypeEnum.USDT.name(), "TRC20", BigDecimal.ZERO, transactionId); | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", amount, CoinTypeEnum.USDT.name(), 1, 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ThreadPoolUtils.sendDingTalk(5); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateRoc(RocTransferDetail transferDetail) { | 
|---|
|  |  |  | // 更新ROC | 
|---|
|  |  |  | // 增加用户余额 | 
|---|
|  |  |  | String address = transferDetail.getAddress(); | 
|---|
|  |  |  | BigDecimal balance = transferDetail.getBalance(); | 
|---|
|  |  |  | String symbol = transferDetail.getSymbol(); | 
|---|
|  |  |  | if (org.apache.commons.lang.StringUtils.isBlank(address) || org.apache.commons.lang.StringUtils.isBlank(symbol) || balance == null) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (balance.compareTo(new BigDecimal("0.0001")) <= 0) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MemberCoinAddressEntity memberCoinAddress = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, symbol); | 
|---|
|  |  |  | if (memberCoinAddress == null) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long memberId = memberCoinAddress.getMemberId(); | 
|---|
|  |  |  | // 查询钱包 并更新 | 
|---|
|  |  |  | MemberWalletCoinEntity walletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.ROC.name()); | 
|---|
|  |  |  | if (walletCoinEntity == null) { | 
|---|
|  |  |  | // 创建一个钱包 | 
|---|
|  |  |  | // 创建这个钱包 | 
|---|
|  |  |  | walletCoinEntity = new MemberWalletCoinEntity(); | 
|---|
|  |  |  | walletCoinEntity.setAvailableBalance(BigDecimal.ZERO); | 
|---|
|  |  |  | walletCoinEntity.setFrozenBalance(BigDecimal.ZERO); | 
|---|
|  |  |  | walletCoinEntity.setTotalBalance(BigDecimal.ZERO); | 
|---|
|  |  |  | walletCoinEntity.setBorrowedFund(BigDecimal.ZERO); | 
|---|
|  |  |  | walletCoinEntity.setMemberId(memberId); | 
|---|
|  |  |  | walletCoinEntity.setWalletCode(symbol); | 
|---|
|  |  |  | memberWalletCoinDao.insert(walletCoinEntity); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(walletCoinEntity.getId(), balance, BigDecimal.ZERO, 0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, balance, CoinTypeEnum.ROC.name(), "", BigDecimal.ZERO, null); | 
|---|
|  |  |  | // 插入财务记录 | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", balance, CoinTypeEnum.ROC.name(), 1, 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ThreadPoolUtils.sendDingTalk(5); | 
|---|
|  |  |  | MemberEntity member = memberDao.selectById(memberId); | 
|---|
|  |  |  | if (StrUtil.isNotBlank(member.getPhone())) { | 
|---|
|  |  |  | String amount = balance.toPlainString() + "ROC"; | 
|---|
|  |  |  | Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | SubMailSend.sendRechargeMail(member.getEmail(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | //e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void updateEthUsdtNew(EthUsdtChargeDto ethUsdtChargeDto) { | 
|---|
|  |  |  | String address = ethUsdtChargeDto.getAddress(); | 
|---|
|  |  |  | String hash = ethUsdtChargeDto.getHash(); | 
|---|
|  |  |  | // hash没有用过 | 
|---|
|  |  |  | Map<String,Object> param = new HashMap<>(); | 
|---|
|  |  |  | param.put("hash",hash); | 
|---|
|  |  |  | param.put("address",address); | 
|---|
|  |  |  | List<MemberCoinChargeEntity> memberCoinChargeEntities = memberCoinChargeDao.selectByMap(param); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(memberCoinChargeEntities)){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 校验这个交易是否成功 | 
|---|
|  |  |  | EthService ethService  = new EthService(); | 
|---|
|  |  |  | boolean b = ethService.checkTransferResult(hash); | 
|---|
|  |  |  | if(!b){ | 
|---|
|  |  |  | log.info("#USDT假充值:{}#", hash); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MemberCoinAddressEntity coinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, CoinTypeEnum.USDT.toString()); | 
|---|
|  |  |  | if (coinAddressEntity == null) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long memberId = coinAddressEntity.getMemberId(); | 
|---|
|  |  |  | BigDecimal balance = ethUsdtChargeDto.getBalance(); | 
|---|
|  |  |  | if (balance != null && balance.compareTo(new BigDecimal("0.1")) > 0) { | 
|---|
|  |  |  | balance = balance.setScale(8, RoundingMode.CEILING); | 
|---|
|  |  |  | BigDecimal early = BigDecimal.ZERO; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MemberWalletCoinEntity walletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name()); | 
|---|
|  |  |  | if (walletCoinEntity == null) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BigDecimal newBalance = balance.subtract(early); | 
|---|
|  |  |  | memberWalletCoinDao.updateBlockBalance(walletCoinEntity.getId(), newBalance, balance, 0); | 
|---|
|  |  |  | String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "ERC20", balance, ethUsdtChargeDto.getHash()); | 
|---|
|  |  |  | // 插入财务记录 | 
|---|
|  |  |  | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.USDT.name(), 1, 1); | 
|---|
|  |  |  | ThreadPoolUtils.sendDingTalk(5); | 
|---|
|  |  |  | MemberEntity member = memberDao.selectById(memberId); | 
|---|
|  |  |  | if (StrUtil.isNotBlank(member.getPhone())) { | 
|---|
|  |  |  | String amount = newBalance.toPlainString() + "USDT-ERC20"; | 
|---|
|  |  |  | Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | SubMailSend.sendRechargeMail(member.getEmail(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 同步 | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | usdtEthService.pollByAddress(address); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String generateNo() { | 
|---|
|  |  |  | // 生成订单号 | 
|---|
|  |  |  | Long timestamp = System.currentTimeMillis(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return String.valueOf(timestamp).substring(2) + random; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String insertCoinCharge(String address, Long memberId, BigDecimal newBalance, String symbol, String tag, BigDecimal lastAmount,String hash) { | 
|---|
|  |  |  | public String insertCoinCharge(String address, Long memberId, BigDecimal newBalance, String symbol, String tag, BigDecimal lastAmount, String hash) { | 
|---|
|  |  |  | MemberCoinChargeEntity memberCoinChargeEntity = new MemberCoinChargeEntity(); | 
|---|
|  |  |  | memberCoinChargeEntity.setAddress(address); | 
|---|
|  |  |  | memberCoinChargeEntity.setMemberId(memberId); | 
|---|
|  |  |  | 
|---|
|  |  |  | memberCoinChargeDao.insert(memberCoinChargeEntity); | 
|---|
|  |  |  | return orderNo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|