zainali5120
2020-09-25 286ea89f5f6cade73276f865effa5dcd2b19406d
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
@@ -482,8 +482,58 @@
    }
    @Override
    public void updateRoc() {
    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();
        }
    }