xiaoyong931011
2020-05-22 c58b804688f17bfb97532c8b9da0fcb1b77b58bb
src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
@@ -16,6 +16,7 @@
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
import com.xcong.excoin.common.exception.GlobalException;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao;
@@ -155,9 +156,8 @@
   }
   @Override
   @Transactional
   @Transactional(rollbackFor = Exception.class)
   public Result coinWalletTransferToContract(BigDecimal balance, String symbol) {
      try {
         if(balance.compareTo(BigDecimal.ZERO) <= 0) {
            return Result.fail(MessageSourceUtils.getString("member_service_0004"));
         }
@@ -200,31 +200,25 @@
            MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
            memberAccountRecord.setMemberId(memberId);
            memberAccountRecord.setPrice(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
            memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
            memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
            memberAccountRecord.setTime(new Date());
            memberAccountMoneyChangeDao.insert(memberAccountRecord);
            
            //添加合约资金划转历史记录
            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMWALLETCOIN.getValue());
            memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
            memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
            memberAccountMoneyChangeDao.insert(memberAccountRecord);
         }
      } catch (Exception e) {
         e.printStackTrace();
         return Result.fail(MessageSourceUtils.getString("member_service_0096"));
      }
      return Result.ok(MessageSourceUtils.getString("member_service_0006"));
   }
   @Override
   @Transactional
   @Transactional(rollbackFor = Exception.class)
   public Result contractTransferToWalletCoin(BigDecimal balance, String symbol) {
      try {
         if(balance.compareTo(BigDecimal.ZERO)<=0){
            return Result.fail(MessageSourceUtils.getString("member_service_0004"));
         }
@@ -251,12 +245,12 @@
         // 加币
         MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
         BigDecimal walletCoinAvailableBalance = walletCoin.getAvailableBalance();
         walletCoinAvailableBalance.add(balance);
         BigDecimal CoinAvailableBalance = walletCoinAvailableBalance.add(balance);
         BigDecimal walletCoinTotalBalance = walletCoin.getTotalBalance();
         walletCoinTotalBalance.add(balance);
         BigDecimal CoinTotalBalance = walletCoinTotalBalance.add(balance);
         
         walletCoin.setAvailableBalance(walletCoinAvailableBalance.setScale(4, BigDecimal.ROUND_DOWN));
         walletCoin.setTotalBalance(walletCoinTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
         walletCoin.setAvailableBalance(CoinAvailableBalance.setScale(4, BigDecimal.ROUND_DOWN));
         walletCoin.setTotalBalance(CoinTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
         int updateById = memberWalletCoinDao.updateById(walletCoin);
         if(updateById < 1) {
            return Result.fail(MessageSourceUtils.getString("member_service_0096"));
@@ -266,23 +260,18 @@
         MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
         memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
         memberAccountRecord.setMemberId(memberId);
         memberAccountRecord.setPrice(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
         memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
         memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
         memberAccountRecord.setSymbol(walletCode);
         memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
         memberAccountRecord.setTime(new Date());
         memberAccountMoneyChangeDao.insert(memberAccountRecord);
         
         //添加资金划转历史记录
         memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMCONTRACT.getValue());
         memberAccountRecord.setSymbol(walletCode);
         memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
         memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
         memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
         memberAccountMoneyChangeDao.insert(memberAccountRecord);
      } catch (Exception e) {
         e.printStackTrace();
         return Result.fail(MessageSourceUtils.getString("member_service_0096"));
      }
      return Result.ok(MessageSourceUtils.getString("member_service_0006"));
   }
@@ -334,9 +323,8 @@
   }
   @Override
   @Transactional
   @Transactional(rollbackFor = Exception.class)
   public Result agentTransferToWalletCoin(BigDecimal balance, Integer transfertype) {
      try {
         if(balance.compareTo(BigDecimal.ZERO) <= 0) {
            return Result.fail(MessageSourceUtils.getString("member_service_0004"));
         }
@@ -386,8 +374,7 @@
            memberAccountRecord.setSymbol(walletCode);
            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
            memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
            memberAccountRecord.setTime(new Date());
            memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountMoneyChangeDao.insert(memberAccountRecord);
            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
            
@@ -411,20 +398,14 @@
            memberAccountRecord.setSymbol(walletCode);
            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
            memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
            memberAccountRecord.setTime(new Date());
            memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
            memberAccountMoneyChangeDao.insert(memberAccountRecord);
            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
         }
         memberAccountRecord.setPrice(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
         memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
         memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_AGENT);
         memberAccountRecord.setTime(new Date());
         memberAccountMoneyChangeDao.insert(memberAccountRecord);
         
      } catch (Exception e) {
         e.printStackTrace();
         return Result.fail(MessageSourceUtils.getString("member_service_0096"));
      }
      return Result.ok(MessageSourceUtils.getString("member_service_0006"));
   }