From cc9d558c8cda42d53be7b4545d2f33db26edf777 Mon Sep 17 00:00:00 2001 From: gao <gaoleox@163> Date: Thu, 28 May 2020 16:46:18 +0800 Subject: [PATCH] Merge branch 'master' of https://chonggaoxiao:xcg523511090712@gitee.com/chonggaoxiao/new_excoin.git --- src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java | 262 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 161 insertions(+), 101 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java index f5ff2fb..719b6a8 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java @@ -2,26 +2,24 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; - import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.response.Result; import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao; -import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao; import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange; import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange; +import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo; +import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo; +import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinInfoVo; import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo; +import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletContractInfoVo; import com.xcong.excoin.modules.coin.service.CoinService; import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao; import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao; @@ -29,9 +27,10 @@ import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity; import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity; +import com.xcong.excoin.modules.platform.dao.CnyUsdtExchangeDao; import com.xcong.excoin.utils.MessageSourceUtils; - import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @Service @@ -53,111 +52,152 @@ @Override public Result getWalletCoin() { - try { - BigDecimal totalUsdt = BigDecimal.ZERO; //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); - CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne(); BigDecimal cnyUsdt = cnyUsdtExchange.getValue(); + BigDecimal totalUsdts = BigDecimal.ZERO; if(!StrUtil.isEmpty(memberId.toString())) { - List<MemberWalletCoinEntity> MemberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId); + List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId); + List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>(); - if(CollUtil.isNotEmpty(MemberWalletCoinlist)) { - for(MemberWalletCoinEntity walletCoin : MemberWalletCoinlist) { + if(CollUtil.isNotEmpty(memberWalletCoinlist)) { + for(MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) { + MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo(); + memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId()); + memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode()); + memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo); + } + } + + if(CollUtil.isNotEmpty(memberWalletCoinInfoVolist)) { + for(MemberWalletCoinInfoVo walletCoin : memberWalletCoinInfoVolist) { if(MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) { + BigDecimal totalUsdt = BigDecimal.ZERO; totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance()); + totalUsdts = totalUsdts.add(totalUsdt); BigDecimal totalCny = totalUsdt.multiply(cnyUsdt); walletCoin.setTotalBalance(totalCny.setScale(4, BigDecimal.ROUND_DOWN)); }else { BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance()); BigDecimal closePrice = new BigDecimal("10.0000"); + BigDecimal totalUsdt = BigDecimal.ZERO; //Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(walletCoin.getWalletCode()+"/USDT"); totalUsdt = totalUsdt.add(amount.multiply(closePrice)); - walletCoin.setTotalBalance(totalUsdt.multiply(closePrice).multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); + totalUsdts = totalUsdts.add(totalUsdt); + walletCoin.setTotalBalance(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); } } } MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo(); - memberWalletCoinVo.setTotalUsdt(totalUsdt.setScale(4, BigDecimal.ROUND_DOWN)); - memberWalletCoinVo.setTotalCny(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); - memberWalletCoinVo.setWalletCoinEntities(MemberWalletCoinlist); + memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinInfoVolist); return Result.ok(memberWalletCoinVo); }else { - List<MemberWalletCoinEntity> MemberWalletCoinlist = new ArrayList<MemberWalletCoinEntity>(); - MemberWalletCoinEntity coin = new MemberWalletCoinEntity(); + List<MemberWalletCoinInfoVo> memberWalletCoinlist = new ArrayList<MemberWalletCoinInfoVo>(); + MemberWalletCoinInfoVo coin = new MemberWalletCoinInfoVo(); coin.setAvailableBalance(BigDecimal.ZERO); coin.setTotalBalance(BigDecimal.ZERO); coin.setFrozenBalance(BigDecimal.ZERO); coin.setWalletCode(CoinTypeEnum.BTC.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); coin.setWalletCode(CoinTypeEnum.ETH.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); coin.setWalletCode(CoinTypeEnum.LTC.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); coin.setWalletCode(CoinTypeEnum.BCH.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); coin.setWalletCode(CoinTypeEnum.USDT.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); coin.setWalletCode(CoinTypeEnum.EOS.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); coin.setWalletCode(CoinTypeEnum.XRP.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); coin.setWalletCode(CoinTypeEnum.ETC.toString()); - MemberWalletCoinlist.add(coin); + memberWalletCoinlist.add(coin); + MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo(); - memberWalletCoinVo.setTotalUsdt(totalUsdt.setScale(4, BigDecimal.ROUND_DOWN)); - memberWalletCoinVo.setTotalCny(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); - memberWalletCoinVo.setWalletCoinEntities(MemberWalletCoinlist); + memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinlist);; return Result.ok(memberWalletCoinVo); } - } catch (Exception e) { - e.printStackTrace(); - return Result.fail(MessageSourceUtils.getString("member_service_0003")); - } } @Override - public Result getWalletCoinById(Long id) { - try { + public Result getWalletCoinBySymbol(String symbol) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); - MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectById(id); - + MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId,symbol); + MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo(); + memberWalletCoinInfoVo.setFrozenBalance(walletCoin.getFrozenBalance()); + memberWalletCoinInfoVo.setAvailableBalance(walletCoin.getAvailableBalance()); + memberWalletCoinInfoVo.setMemberId(memberId); + memberWalletCoinInfoVo.setWalletCode(symbol); if(!StrUtil.isEmpty(memberId.toString())) { CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne(); BigDecimal cnyUsdt = cnyUsdtExchange.getValue(); BigDecimal total = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance()); if(MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) { - walletCoin.setTotalBalance(total.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinInfoVo.setTotalBalance(total.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); }else { BigDecimal closePrice = new BigDecimal("10.0000"); //Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(wallet.getCode()+"/USDT"); - walletCoin.setTotalBalance(total.multiply(closePrice).multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletCoinInfoVo.setTotalBalance(total.multiply(closePrice).multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); } } - return Result.ok(walletCoin); - } catch (Exception e) { - e.printStackTrace(); - return Result.fail(MessageSourceUtils.getString("member_service_0003")); - } + return Result.ok(memberWalletCoinInfoVo); } @Override public Result getWalletContractById() { - return Result.fail(MessageSourceUtils.getString("member_service_0002")); - + //获取用户ID + Long memberId = LoginUserUtils.getAppLoginUser().getId(); + + CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne(); + BigDecimal cnyUsdt = cnyUsdtExchange.getValue(); + + String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); + MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode); + if(ObjectUtil.isEmpty(walletContract)) { + return Result.fail(MessageSourceUtils.getString("member_service_0001")); + } + /** + * todo + */ + //获取当前的合约持仓 + //获取实时盈亏 + BigDecimal profitAndLoss = new BigDecimal("50.000"); + //获取总付款 + BigDecimal totalPayment = new BigDecimal("50.000"); + BigDecimal lastTotalBalance = new BigDecimal("0"); + BigDecimal totalBalance = walletContract.getTotalBalance(); + lastTotalBalance = totalBalance.add(profitAndLoss); + if(lastTotalBalance.compareTo(BigDecimal.ZERO) < 0) { + lastTotalBalance = new BigDecimal("0"); + } + + MemberWalletContractInfoVo memberWalletContractInfoVo = new MemberWalletContractInfoVo(); + memberWalletContractInfoVo.setFrozenBalance(totalPayment.setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletContractInfoVo.setAvailableBalance(walletContract.getAvailableBalance()); + memberWalletContractInfoVo.setTotalBalance(lastTotalBalance.setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletContractInfoVo.setTotalRMBBalance(lastTotalBalance.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN)); + + return Result.ok(memberWalletContractInfoVo); } @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 +240,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 +285,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,32 +300,29 @@ 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")); } @Override - public Result findWalletContractBySymbol(String symbol) { - /** - * ---todo - */ - return null; + public Result findWalletContractBySymbol() { + //获取用户ID + Long memberId = LoginUserUtils.getAppLoginUser().getId(); + String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); + MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode); + BigDecimal availableBalance = walletContract.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN); + return Result.ok(availableBalance); } @Override @@ -301,26 +332,52 @@ MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol); BigDecimal availableBalance = walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN); - walletCoin.setAvailableBalance(availableBalance); - return Result.ok(walletCoin); + return Result.ok(availableBalance); } @Override public Result getWalletCoinRecords() { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); - List<MemberAccountMoneyChange> coinRecordList = memberAccountMoneyChangeDao.selectWalletCoinRecordsByMemIdTypeSymbol(memberId); - return Result.ok(coinRecordList); + List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>(); + if(CollUtil.isNotEmpty(coinRecordList)) { + for(MemberAccountMoneyChange memberAccountMoneyChange : coinRecordList) { + MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo(); + memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount()); + memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent()); + memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus()); + memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol()); + memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType()); + memberAccountMoneyChangeInfoVo.setUpdateTime(memberAccountMoneyChange.getUpdateTime()); + arrayList.add(memberAccountMoneyChangeInfoVo); + } + } + return Result.ok(arrayList); } @Override - public Result getWalletContractRecords(String symbol) { + public Result getWalletContractRecords() { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); - + String symbol = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); List<MemberAccountMoneyChange> contractRecordList = memberAccountMoneyChangeDao.selectWalletContractRecordsByMemIdTypeSymbol(symbol,memberId); - return Result.ok(contractRecordList); + + List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>(); + if(ObjectUtil.isNotNull(contractRecordList)) { + for(MemberAccountMoneyChange memberAccountMoneyChange : contractRecordList) { + MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo(); + memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount()); + memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent()); + memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus()); + memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol()); + memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType()); + memberAccountMoneyChangeInfoVo.setUpdateTime(memberAccountMoneyChange.getUpdateTime()); + arrayList.add(memberAccountMoneyChangeInfoVo); + } + } + + return Result.ok(arrayList); } @Override @@ -330,13 +387,26 @@ List<MemberAccountMoneyChange> contractRecordList = memberAccountMoneyChangeDao.selectWalletAgentRecordByMemIdTypeSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue(),memberId); - return Result.ok(contractRecordList); + + List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>(); + if(ObjectUtil.isNotNull(contractRecordList)) { + for(MemberAccountMoneyChange memberAccountMoneyChange : contractRecordList) { + MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo(); + memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount()); + memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent()); + memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus()); + memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol()); + memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType()); + memberAccountMoneyChangeInfoVo.setUpdateTime(memberAccountMoneyChange.getUpdateTime()); + arrayList.add(memberAccountMoneyChangeInfoVo); + } + } + return Result.ok(arrayList); } @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 +456,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 +480,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")); } @@ -439,15 +502,12 @@ CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne(); BigDecimal cnyUsdt = cnyUsdtExchange.getValue(); - BigDecimal multiply = availableBalance.multiply(cnyUsdt); - walletAgent.setAvailableBalance(availableBalance); - Map<String,Object> map = new HashMap<String, Object>(); - map.put(MemberWalletCoinEnum.WALLETCOINUSDT.getValue(), availableBalance.setScale(4, BigDecimal.ROUND_DOWN)); - map.put(MemberWalletCoinEnum.WALLETAGENTCNY.getValue(), walletAgent); - map.put(MemberWalletCoinEnum.WALLETCOINCNY.getValue(), multiply.setScale(4, BigDecimal.ROUND_DOWN)); - return Result.ok(map); + MemberWalletAgentInfoVo memberWalletAgentInfoVo = new MemberWalletAgentInfoVo(); + memberWalletAgentInfoVo.setTotalBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN)); + memberWalletAgentInfoVo.setTotalRMBBalance(multiply.setScale(4, BigDecimal.ROUND_DOWN)); + return Result.ok(memberWalletAgentInfoVo); } } -- Gitblit v1.9.1