From caa90edd0fcd0e4f4e920bcc744eef12fee82ae6 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 25 May 2020 11:07:34 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin.git
---
src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java | 61 ++++++++++++++++++++----------
1 files changed, 40 insertions(+), 21 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 1a392da..7f8ea9e 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
@@ -18,6 +18,7 @@
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.MemberWalletCoinInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
import com.xcong.excoin.modules.coin.service.CoinService;
import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
@@ -60,10 +61,23 @@
if(!StrUtil.isEmpty(memberId.toString())) {
- List<MemberWalletCoinEntity> MemberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
+ List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
- if(CollUtil.isNotEmpty(MemberWalletCoinlist)) {
- for(MemberWalletCoinEntity walletCoin : MemberWalletCoinlist) {
+ List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>();
+ MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
+ if(ObjectUtil.isNotEmpty(memberWalletCoinlist)) {
+ for(MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
+ memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance());
+ memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance());
+ memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
+ memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance());
+ memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
+ }
+ }
+
+
+ if(CollUtil.isNotEmpty(memberWalletCoinlist)) {
+ for(MemberWalletCoinEntity walletCoin : memberWalletCoinlist) {
if(MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
@@ -80,34 +94,35 @@
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.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.setMemberWalletCoinInfoVo(memberWalletCoinlist);;
return Result.ok(memberWalletCoinVo);
}
} catch (Exception e) {
@@ -117,27 +132,31 @@
}
@Override
- public Result getWalletCoinById(Long id) {
+ public Result getWalletCoinBySymbol(String symbol) {
try {
//获取用户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);
+ return Result.ok(memberWalletCoinInfoVo);
} catch (Exception e) {
e.printStackTrace();
return Result.fail(MessageSourceUtils.getString("member_service_0003"));
--
Gitblit v1.9.1