| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.xcong.excoin.common.enumerates.CoinTypeEnum; |
| | | import com.xcong.excoin.modules.blackchain.service.BtcService; |
| | | import com.xcong.excoin.modules.blackchain.service.EthService; |
| | | import com.xcong.excoin.modules.blackchain.service.UsdtService; |
| | | import com.xcong.excoin.modules.coin.service.BlockCoinService; |
| | | import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao; |
| | | import com.xcong.excoin.modules.member.dao.MemberCoinChargeDao; |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void updateEth() { |
| | | List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbol(CoinTypeEnum.ETH.name()); |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void updateBtcUsdt() { |
| | | List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbolAndTag(CoinTypeEnum.USDT.name(), "OMNI"); |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | UsdtService usdtService = UsdtService.getInstance(); |
| | | |
| | | for (MemberCoinAddressEntity coinAddressEntity : list) { |
| | | String address = coinAddressEntity.getAddress(); |
| | | Long memberId = coinAddressEntity.getMemberId(); |
| | | |
| | | BigDecimal balance = usdtService.getBalance(address); |
| | | if (balance != null && balance.compareTo(new BigDecimal("0.1")) > 0) { |
| | | MemberCoinChargeEntity memberCoinChargeEntity = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.USDT.name(), "OMNI"); |
| | | BigDecimal early = BigDecimal.ZERO; |
| | | if (memberCoinChargeEntity != null) { |
| | | BigDecimal lastAmount = memberCoinChargeEntity.getLastAmount(); |
| | | if (lastAmount != null) { |
| | | early = lastAmount; |
| | | } |
| | | } |
| | | |
| | | MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name()); |
| | | if (walletCoin == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (balance.compareTo(early) > 0) { |
| | | BigDecimal newBalance = balance.subtract(early); |
| | | |
| | | memberWalletCoinDao.updateBlockBalance(memberId, newBalance, balance, 0); |
| | | insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "OMNI", balance); |
| | | |
| | | // TODO 钉钉消息, 短信提醒 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void updateBtc() { |
| | | List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbol(CoinTypeEnum.BTC.name()); |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | BtcService btcService = BtcService.getInstance(); |
| | | for (MemberCoinAddressEntity coinAddressEntity : list) { |
| | | String address = coinAddressEntity.getAddress(); |
| | | Long memberId = coinAddressEntity.getMemberId(); |
| | | |
| | | BigDecimal balance = btcService.getBalance(address); |
| | | |
| | | if (balance != null && balance.compareTo(new BigDecimal("0.00012")) > 0) { |
| | | MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.BTC.name()); |
| | | if (walletCoin == null) { |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal early = BigDecimal.ZERO; |
| | | MemberCoinChargeEntity coinCharge = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.BTC.name(), null); |
| | | if (coinCharge != null) { |
| | | BigDecimal lastAmount = coinCharge.getLastAmount(); |
| | | if (lastAmount != null) { |
| | | early = lastAmount; |
| | | } |
| | | } |
| | | |
| | | if (balance.compareTo(early) > 0) { |
| | | log.info("#btc同步:{}, {}, {}#", memberId, balance, early); |
| | | BigDecimal newBalance = balance.subtract(early); |
| | | memberWalletCoinDao.updateBlockBalance(memberId, newBalance, balance, 0); |
| | | |
| | | insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.BTC.name(), null, balance); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.BTC.name(), 1, 1); |
| | | |
| | | // TODO 钉钉提醒, 短信提醒 |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String generateNo() { |