| | |
| | | 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;
|
| | |
| | |
|
| | | 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);
|
| | |
| | | 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) {
|
| | |
| | | }
|
| | |
|
| | | @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"));
|