From 7ba7366a8c6ce8019339e433b218386645cb5312 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Mon, 28 Dec 2020 17:38:53 +0800 Subject: [PATCH] Merge branch 'piot' of https://gitee.com/chonggaoxiao/new_excoin_manage into piot --- src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java | 519 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 405 insertions(+), 114 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java index aef4b35..02b733b 100644 --- a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java @@ -1,5 +1,9 @@ package com.xcong.excoin.modules.member.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; @@ -7,27 +11,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.excoin.common.entity.FebsResponse; import com.xcong.excoin.common.entity.QueryRequest; +import com.xcong.excoin.common.utils.RedisUtils; +import com.xcong.excoin.common.utils.TRC20ApiUtils; import com.xcong.excoin.modules.Sms106Send; import com.xcong.excoin.modules.member.dto.MemberDetailConfirmDto; -import com.xcong.excoin.modules.member.entity.AgentFriendRelationEntity; -import com.xcong.excoin.modules.member.entity.MemberAccountMoneyChangeEntity; -import com.xcong.excoin.modules.member.entity.MemberAuthenticationEntity; -import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity; -import com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity; -import com.xcong.excoin.modules.member.entity.MemberCoinWithdrawEntity; -import com.xcong.excoin.modules.member.entity.MemberEntity; -import com.xcong.excoin.modules.member.entity.MemberQuickBuySaleEntity; -import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; -import com.xcong.excoin.modules.member.mapper.AgentFriendRelationMapper; -import com.xcong.excoin.modules.member.mapper.MemberAccountMoneyChangeMapper; -import com.xcong.excoin.modules.member.mapper.MemberAuthenticationMapper; -import com.xcong.excoin.modules.member.mapper.MemberCoinAddressMapper; -import com.xcong.excoin.modules.member.mapper.MemberCoinChargeMapper; -import com.xcong.excoin.modules.member.mapper.MemberCoinWithdrawMapper; -import com.xcong.excoin.modules.member.mapper.MemberMapper; -import com.xcong.excoin.modules.member.mapper.MemberQuickBuySaleMapper; -import com.xcong.excoin.modules.member.mapper.MemberWalletCoinMapper; +import com.xcong.excoin.modules.member.entity.*; +import com.xcong.excoin.modules.member.mapper.*; +import com.xcong.excoin.modules.member.service.EthService; import com.xcong.excoin.modules.member.service.IMemberService; +import com.xcong.excoin.modules.member.service.RocService; import com.xcong.excoin.modules.member.vo.MemberAuthenticationVo; import com.xcong.excoin.modules.member.vo.MemberCoinChargeVo; import com.xcong.excoin.modules.member.vo.MemberCoinWithdrawVo; @@ -46,6 +38,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ExecutionException; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -80,6 +73,12 @@ private final MemberAuthenticationMapper memberAuthenticationMapper; private final AgentFriendRelationMapper agentFriendRelationMapper; + + private final TdFinancialReordDao tdFinancialReordDao; + + private final RedisUtils redisUtils; + + private final TrcAddressDao trcAddressDao; @Override public IPage<AgentFriendRelationEntity> findAgentInfoListInPage(AgentFriendRelationEntity agentFriendRelationEntity, @@ -196,7 +195,11 @@ String firstName = (memberEntitys.getFirstName() == null ? "" : memberEntitys.getFirstName()); String secondName = (memberEntitys.getSecondName() == null ? "" : memberEntitys.getSecondName()); memberEntitys.setRealName(firstName+secondName); - } + + HashMap<String, Object> coinMap = memberWalletCoinMapper.selectMemberWalletCoinByMemberId(memberEntitys.getId()); + memberEntitys.setUsdtAmount((BigDecimal) coinMap.get("usdt")); + memberEntitys.setRfncAmount((BigDecimal) coinMap.get("rfnc")); + } } return selectMemberListInPage; } @@ -396,6 +399,23 @@ QueryRequest request) { Page<MemberCoinChargeEntity> page = new Page<>(request.getPageNum(), request.getPageSize()); IPage<MemberCoinChargeVo> findmemberQuickBuySaleListInPage = memberCoinChargeMapper.findMemberApplyCoinListInPage(page, memberCoinChargeEntity); + List<MemberCoinChargeVo> records = findmemberQuickBuySaleListInPage.getRecords(); + if(CollUtil.isNotEmpty(records)) { + for(MemberCoinChargeVo memberCoinChargeVo : records) { + Long memberId = memberCoinChargeVo.getMemberId(); + Map<String, Object> columnMap = new HashMap<>(); + columnMap.put("member_id", memberId); + List<MemberAuthenticationEntity> selectByMap = memberAuthenticationMapper.selectByMap(columnMap ); + if(selectByMap != null && selectByMap.size() > 0) { + MemberAuthenticationEntity memberAuthenticationEntity = selectByMap.get(0); + String firstName = memberAuthenticationEntity.getFirstName(); + String secondName = memberAuthenticationEntity.getSecondName(); + String realName = firstName + secondName; + memberCoinChargeVo.setRealName(realName); + } + } + } + return findmemberQuickBuySaleListInPage; } @@ -408,10 +428,27 @@ List<MemberCoinWithdrawVo> records = findmemberQuickBuySaleListInPage.getRecords(); if(records != null && records.size() > 0) { for(MemberCoinWithdrawVo memberCoinWithdrawVo : records) { + + Long memberId = memberCoinWithdrawVo.getMemberId(); + Map<String, Object> columnMap = new HashMap<>(); + columnMap.put("member_id", memberId); + List<MemberAuthenticationEntity> selectByMap = memberAuthenticationMapper.selectByMap(columnMap ); + if(selectByMap != null && selectByMap.size() > 0) { + MemberAuthenticationEntity memberAuthenticationEntity = selectByMap.get(0); + String firstName = memberAuthenticationEntity.getFirstName(); + String secondName = memberAuthenticationEntity.getSecondName(); + String realName = firstName + secondName; + memberCoinWithdrawVo.setRealName(realName); + } + BigDecimal amount = memberCoinWithdrawVo.getAmount(); BigDecimal feeAmount = memberCoinWithdrawVo.getFeeAmount(); BigDecimal subtract = amount.subtract(feeAmount); memberCoinWithdrawVo.setRealAmount(subtract); + if("Y".equals(memberCoinWithdrawVo.getIsInside())){ + // 是内部转账 查询对应的地址 + + } } } return findmemberQuickBuySaleListInPage; @@ -419,17 +456,27 @@ @Override @Transactional(rollbackFor = Exception.class) - public FebsResponse memberWithdrawCoinConfirm(@NotNull(message = "{required}") Long id) { + public FebsResponse memberWithdrawCoinConfirm(@NotNull(message = "{required}") Long id) throws ExecutionException, InterruptedException { MemberCoinWithdrawEntity selectById = memberCoinWithdrawMapper.selectById(id); Long memberId = selectById.getMemberId(); String symbol = selectById.getSymbol(); String address = selectById.getAddress(); int status = selectById.getStatus(); + BigDecimal amount = selectById.getAmount(); if(status != 1) { return new FebsResponse().fail().message("只有等待审核的状态才能确认!"); } - + // 转币 需要扣除手续费 + amount = amount.subtract(selectById.getFeeAmount()); + if("RFNC".equals(symbol) && !"Y".equals(selectById.getIsInside())){ + // 如果是ROC 则自动转 + String transfer = RocService.transfer(amount, address, "RFNC"); + if(!"success".equals(transfer)){ + FebsResponse febsResponse = new FebsResponse(); + return febsResponse.fail().message(transfer); + } + } // 查询币币钱包 MemberWalletCoinEntity walletCoin = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(memberId, symbol); @@ -441,36 +488,94 @@ memberWalletCoinMapper.updateById(walletCoin); if ("Y".equals(selectById.getIsInside())) { - Map<String, Object> columnMap = new HashMap<>(); - columnMap.put("symbol", symbol); - columnMap.put("address", address); - // 如果是内部转账 则需要将币加到内部地址 - List<MemberCoinAddressEntity> selectByMap = memberCoinAddressMapper.selectByMap(columnMap); - if(selectByMap == null || selectByMap.isEmpty()) { - return new FebsResponse().fail().message("地址有误,请拒绝!"); + // 查询算力系统中是否存在该地址 + TdCoinWallet tdCoinWallet = memberWalletCoinMapper.selectTdCoinWalletByAddress(address, "USDT"); + TrcAddressEntity trcAddressEntity = trcAddressDao.selectTrcAddressByAddress(address); + // 判断是否为TRC20地址 + if (trcAddressEntity == null) { + if (tdCoinWallet != null) { + // 更新算力系统中用户钱包余额 + memberWalletCoinMapper.updateTdCoinWalletAvaliable(amount, address); + + TdFinancialReord tdFinancialReord = new TdFinancialReord(); + tdFinancialReord.setAmount(amount); + tdFinancialReord.setCreateTime(new Date()); + tdFinancialReord.setMemId(tdCoinWallet.getMemId()); + tdFinancialReord.setSymbol("USDT"); + tdFinancialReord.setTitle("USDT交易所转账"); + tdFinancialReord.setContent("USDT交易所转账"); + // 插入算力系统中财务记录 + tdFinancialReordDao.insert(tdFinancialReord); + } else { + Map<String, Object> columnMap = new HashMap<>(); + columnMap.put("symbol", symbol); + columnMap.put("address", address); + // 如果是内部转账 则需要将币加到内部地址 + List<MemberCoinAddressEntity> selectByMap = memberCoinAddressMapper.selectByMap(columnMap); + if (selectByMap == null || selectByMap.isEmpty()) { + return new FebsResponse().fail().message("地址有误,请拒绝!"); + } + Long aimMemberId = selectByMap.get(0).getMemberId(); + MemberWalletCoinEntity aimWalletCoin = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(aimMemberId, symbol); + + BigDecimal addTotal = aimWalletCoin.getTotalBalance().add(amount); + BigDecimal addAvailable = aimWalletCoin.getAvailableBalance().add(amount); + aimWalletCoin.setTotalBalance(addTotal); + aimWalletCoin.setAvailableBalance(addAvailable); + + memberWalletCoinMapper.updateById(aimWalletCoin); + + MemberAccountMoneyChangeEntity memberAccountMoneyChangeEntity = new MemberAccountMoneyChangeEntity(); + memberAccountMoneyChangeEntity.setContent("收款"); + memberAccountMoneyChangeEntity.setMemberId(aimMemberId); + memberAccountMoneyChangeEntity.setAmount(amount); + memberAccountMoneyChangeEntity.setStatus(MemberAccountMoneyChangeEntity.STATUS_SUCCESS_INTEGER); + memberAccountMoneyChangeEntity.setSymbol(selectById.getSymbol()); + memberAccountMoneyChangeEntity.setType(MemberAccountMoneyChangeEntity.TYPE_WALLET_COIN); + memberAccountMoneyChangeEntity.setCreateBy(selectById.getCreateBy()); + memberAccountMoneyChangeEntity.setCreateTime(new Date()); + memberAccountMoneyChangeEntity.setUpdateBy(selectById.getCreateBy()); + memberAccountMoneyChangeEntity.setUpdateTime(new Date()); + memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity); + } + } else { + if (trcAddressEntity.getSystemFlag().equals(TrcAddressEntity.SYSTEM_FLAG_SL)) { + memberWalletCoinMapper.updateTdCoinWalletTrc20(amount, trcAddressEntity.getMemberId()); + + TdFinancialReord tdFinancialReord = new TdFinancialReord(); + tdFinancialReord.setAmount(amount); + tdFinancialReord.setCreateTime(new Date()); + tdFinancialReord.setMemId(trcAddressEntity.getMemberId()); + tdFinancialReord.setSymbol("USDT"); + tdFinancialReord.setTitle("USDT交易所转账"); + tdFinancialReord.setContent("USDT交易所转账"); + // 插入算力系统中财务记录 + tdFinancialReordDao.insert(tdFinancialReord); + } else { + Long aimMemberId = trcAddressEntity.getMemberId(); + MemberWalletCoinEntity aimWalletCoin = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(aimMemberId, symbol); + + BigDecimal addTotal = aimWalletCoin.getTotalBalance().add(amount); + BigDecimal addAvailable = aimWalletCoin.getAvailableBalance().add(amount); + aimWalletCoin.setTotalBalance(addTotal); + aimWalletCoin.setAvailableBalance(addAvailable); + + memberWalletCoinMapper.updateById(aimWalletCoin); + + MemberAccountMoneyChangeEntity memberAccountMoneyChangeEntity = new MemberAccountMoneyChangeEntity(); + memberAccountMoneyChangeEntity.setContent("收款"); + memberAccountMoneyChangeEntity.setMemberId(aimMemberId); + memberAccountMoneyChangeEntity.setAmount(amount); + memberAccountMoneyChangeEntity.setStatus(MemberAccountMoneyChangeEntity.STATUS_SUCCESS_INTEGER); + memberAccountMoneyChangeEntity.setSymbol(selectById.getSymbol()); + memberAccountMoneyChangeEntity.setType(MemberAccountMoneyChangeEntity.TYPE_WALLET_COIN); + memberAccountMoneyChangeEntity.setCreateBy(selectById.getCreateBy()); + memberAccountMoneyChangeEntity.setCreateTime(new Date()); + memberAccountMoneyChangeEntity.setUpdateBy(selectById.getCreateBy()); + memberAccountMoneyChangeEntity.setUpdateTime(new Date()); + memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity); + } } - Long aimMemberId = selectByMap.get(0).getMemberId(); - MemberWalletCoinEntity aimWalletCoin = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(aimMemberId, symbol); - - BigDecimal addTotal = aimWalletCoin.getTotalBalance().add(selectById.getAmount()); - BigDecimal addAvailable = aimWalletCoin.getAvailableBalance().add(selectById.getAmount()); - aimWalletCoin.setTotalBalance(addTotal); - aimWalletCoin.setAvailableBalance(addAvailable); - - memberWalletCoinMapper.updateById(aimWalletCoin); - - MemberAccountMoneyChangeEntity memberAccountMoneyChangeEntity = new MemberAccountMoneyChangeEntity(); - memberAccountMoneyChangeEntity.setContent("收款"); - memberAccountMoneyChangeEntity.setMemberId(aimMemberId); - memberAccountMoneyChangeEntity.setAmount(selectById.getAmount()); - memberAccountMoneyChangeEntity.setStatus(MemberAccountMoneyChangeEntity.STATUS_SUCCESS_INTEGER); - memberAccountMoneyChangeEntity.setSymbol(selectById.getSymbol()); - memberAccountMoneyChangeEntity.setType(MemberAccountMoneyChangeEntity.TYPE_WALLET_COIN); - memberAccountMoneyChangeEntity.setCreateBy(selectById.getCreateBy()); - memberAccountMoneyChangeEntity.setCreateTime(new Date()); - memberAccountMoneyChangeEntity.setUpdateBy(selectById.getCreateBy()); - memberAccountMoneyChangeEntity.setUpdateTime(new Date()); - memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity); } Map<String, Object> columnMaps = new HashMap<>(); @@ -484,16 +589,49 @@ selectById.setStatus(MemberCoinWithdrawEntity.IS_STATUS_Y); memberCoinWithdrawMapper.updateById(selectById); + + if (!"Y".equals(selectById.getIsInside())) { + if ("TRC20".equals(selectById.getLabel())) { + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + log.info("远程调用TRC执行:{}", selectById.getId()); + String orderNo = generateOrderNo(memberId); + TRC20ApiUtils.coinApply(orderNo, memberId.toString(), selectById.getSymbol(), selectById.getAmount().subtract(selectById.getFeeAmount()).toPlainString(), selectById.getAddress()); + selectById.setTag(orderNo); + memberCoinWithdrawMapper.updateById(selectById); + } + }); + thread.start(); + } + } + MemberEntity memberEntity = memberMapper.selectById(memberId); String phone = memberEntity.getPhone(); //String email = memberEntity.getEmail(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String time = format.format(new Date()); // 将当前时间袼式化为指定的格式 - log.info("---->{}", phone); if(StrUtil.isNotBlank(phone)) { Sms106Send.sendWithdrawalCoinMsg(phone, time); } + if("USDT".equals(symbol) && !"Y".equals(selectById.getIsInside())){ +// EthService ethService = new EthService(); +// // 查询余额是否足够 +// BigDecimal bigDecimal = ethService.tokenGetBalance(EthService.TOTAL_ADDRESS); +// if(bigDecimal==null ||bigDecimal.compareTo(amount)<0 ){ +// FebsResponse fail = new FebsResponse().fail(); +// fail.message("总钱包余额不足"); +// return fail; +// } +// amount = amount.multiply(new BigDecimal("1000000")); +// String usdtStr = amount.toPlainString(); +// if (usdtStr.contains(".")) { +// usdtStr = usdtStr.substring(0, usdtStr.lastIndexOf(".")); +// } +// String s = ethService.tokenSend(address, usdtStr, null); + } + /** //短信提醒 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); @@ -504,6 +642,29 @@ SmsUtils.hxSmsSend(member.getPhone(), smsContent); */ return new FebsResponse().success(); + } + + public String generateOrderNo(Long mid) { + StringBuilder orderNo = new StringBuilder(); + String date = DateUtil.format(new Date(), "yyyyMMdd"); + orderNo.append(date); + orderNo.append(mid); + orderNo.append(RandomUtil.randomNumbers(2)); + + Object countObj = redisUtils.get(date); + if (countObj == null) { + countObj = 0; + } + int count = (int) countObj; + count++; + redisUtils.set(date, count, 24 * 60 * 60); + + int size = 4; + for (int i = 0; i < size - String.valueOf(count).length(); i++) { + orderNo.append("0"); + } + orderNo.append(count); + return orderNo.toString(); } @Override @@ -618,6 +779,10 @@ String walletNum = memberMapper.selectBBZCForBasicRealData(); String walletCoinNum = memberMapper.selectHYZCForBasicRealData(); String agentNum = memberMapper.selectDLZCForBasicRealData(); + double allCoin = 0 ; + allCoin = (walletNum == null ? 0 : Double.parseDouble(walletNum)) + +(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)) + +(agentNum == null ? 0 : Double.parseDouble(agentNum)); double platformProfitAndLoss = 0 ; platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); @@ -642,6 +807,7 @@ memberDataInfoVo.setWalletNum(walletNum == null ? "0" : walletNum); memberDataInfoVo.setWalletCoinNum(walletCoinNum == null ? "0" : walletCoinNum); memberDataInfoVo.setAgentNum(agentNum == null ? "0" : agentNum); + memberDataInfoVo.setAllCoin(allCoin); } selectMemberListInPage.setTotal(1); return selectMemberListInPage; @@ -666,38 +832,38 @@ @Override public FebsResponse addCoinConfirm(@Valid MemberEntity memberEntity) { - Long memberId = memberEntity.getId(); - String walletCode = "USDT"; - BigDecimal amountUsdt = memberEntity.getCoinNumber(); - - MemberEntity selectById = this.baseMapper.selectById(memberId); - if(ObjectUtils.isEmpty(selectById)) { - return new FebsResponse().message("用户已不存在"); - } - //获取币币钱包 - MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(memberId,walletCode); - BigDecimal availableBalance = memberWalletCoinEntity.getAvailableBalance(); - BigDecimal totalBalance = memberWalletCoinEntity.getTotalBalance(); - - memberWalletCoinEntity.setAvailableBalance(availableBalance.add(amountUsdt)); - memberWalletCoinEntity.setTotalBalance(totalBalance.add(amountUsdt)); - // 更新 - memberWalletCoinMapper.updateById(memberWalletCoinEntity); - - //添加币币资金划转历史记录 - MemberAccountMoneyChangeEntity memberAccountMoneyChangeEntity = new MemberAccountMoneyChangeEntity(); - memberAccountMoneyChangeEntity.setContent("充值"); - memberAccountMoneyChangeEntity.setMemberId(memberId); - memberAccountMoneyChangeEntity.setAmount(amountUsdt); - memberAccountMoneyChangeEntity.setStatus(MemberAccountMoneyChangeEntity.STATUS_SUCCESS_INTEGER); - memberAccountMoneyChangeEntity.setSymbol("USDT"); - memberAccountMoneyChangeEntity.setType(MemberAccountMoneyChangeEntity.TYPE_WALLET_COIN); - memberAccountMoneyChangeEntity.setCreateBy(selectById.getCreateBy()); - memberAccountMoneyChangeEntity.setCreateTime(new Date()); - memberAccountMoneyChangeEntity.setUpdateBy(selectById.getCreateBy()); - memberAccountMoneyChangeEntity.setUpdateTime(new Date()); - - memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity); +// Long memberId = memberEntity.getId(); +// String walletCode = "USDT"; +// BigDecimal amountUsdt = memberEntity.getCoinNumber(); +// +// MemberEntity selectById = this.baseMapper.selectById(memberId); +// if(ObjectUtils.isEmpty(selectById)) { +// return new FebsResponse().message("用户已不存在"); +// } +// //获取币币钱包 +// MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(memberId,walletCode); +// BigDecimal availableBalance = memberWalletCoinEntity.getAvailableBalance(); +// BigDecimal totalBalance = memberWalletCoinEntity.getTotalBalance(); +// +// memberWalletCoinEntity.setAvailableBalance(availableBalance.add(amountUsdt)); +// memberWalletCoinEntity.setTotalBalance(totalBalance.add(amountUsdt)); +// // 更新 +// memberWalletCoinMapper.updateById(memberWalletCoinEntity); +// +// //添加币币资金划转历史记录 +// MemberAccountMoneyChangeEntity memberAccountMoneyChangeEntity = new MemberAccountMoneyChangeEntity(); +// memberAccountMoneyChangeEntity.setContent("充值"); +// memberAccountMoneyChangeEntity.setMemberId(memberId); +// memberAccountMoneyChangeEntity.setAmount(amountUsdt); +// memberAccountMoneyChangeEntity.setStatus(MemberAccountMoneyChangeEntity.STATUS_SUCCESS_INTEGER); +// memberAccountMoneyChangeEntity.setSymbol("USDT"); +// memberAccountMoneyChangeEntity.setType(MemberAccountMoneyChangeEntity.TYPE_WALLET_COIN); +// memberAccountMoneyChangeEntity.setCreateBy(selectById.getCreateBy()); +// memberAccountMoneyChangeEntity.setCreateTime(new Date()); +// memberAccountMoneyChangeEntity.setUpdateBy(selectById.getCreateBy()); +// memberAccountMoneyChangeEntity.setUpdateTime(new Date()); +// +// memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity); /** * todo SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); @@ -719,47 +885,51 @@ MemberInfoDetailVo memberInfoDetailVo = new MemberInfoDetailVo(); //USDT充币总额+USDT提币总额 - String totalAmountUsdtB = memberMapper.selectTotalAmountUsdtBForBasicRealDataBymemberId(memberId); + String totalAmountUsdtB = memberMapper.selectTotalAmountUsdtBForBasicRealDataBymemberId(memberId,"USDT"); + String totalAmountUsdtBRoc = memberMapper.selectTotalAmountUsdtBForBasicRealDataBymemberId(memberId,"ROC"); memberInfoDetailVo.setChargeCoin(totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); + memberInfoDetailVo.setChargeCoinRoc(totalAmountUsdtBRoc == null ? 0 : Double.parseDouble(totalAmountUsdtBRoc)); String totalAmountUsdtS = memberMapper.selectTotalAmountUsdtSForBasicRealDataBymemberId(memberId); memberInfoDetailVo.setAppealCoin(totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); //USDT充值总额+USDT提现总额 - String totalAmountUsdtCZ = memberMapper.selectTotalAmountUsdtCZForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setChargeUsdt(totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); - String totalAmountUsdtTX = memberMapper.selectTotalAmountUsdtTXForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setAppealUsdt(totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); +// String totalAmountUsdtCZ = memberMapper.selectTotalAmountUsdtCZForBasicRealDataBymemberId(memberId); +// memberInfoDetailVo.setChargeUsdt(totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); +// String totalAmountUsdtTX = memberMapper.selectTotalAmountUsdtTXForBasicRealDataBymemberId(memberId); +// memberInfoDetailVo.setAppealUsdt(totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); //总剩余 - double platformProfitAndLoss = 0 ; - platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); - platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); - platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); - platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); - memberInfoDetailVo.setTotalCoin(platformProfitAndLoss); +// double platformProfitAndLoss = 0 ; +// platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); +// platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); +// platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); +// platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); +// memberInfoDetailVo.setTotalCoin(platformProfitAndLoss); //佣金 - String returnMoneyByMid = memberMapper.selectReturnMoneyForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setFee(returnMoneyByMid == null ? 0 : Double.parseDouble(returnMoneyByMid)); +// String returnMoneyByMid = memberMapper.selectReturnMoneyForBasicRealDataBymemberId(memberId); +// memberInfoDetailVo.setFee(returnMoneyByMid == null ? 0 : Double.parseDouble(returnMoneyByMid)); //开仓手续费总额 - String closingpriceByMid = memberMapper.selectClosingpriceForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setClosingPrice(closingpriceByMid == null ? 0 : Double.parseDouble(closingpriceByMid)); +// String closingpriceByMid = memberMapper.selectClosingpriceForBasicRealDataBymemberId(memberId); +// memberInfoDetailVo.setClosingPrice(closingpriceByMid == null ? 0 : Double.parseDouble(closingpriceByMid)); //平仓总手续费 - String sellClosingpriceByMid = memberMapper.selectSellClosingpriceForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setSellClosingPrice(sellClosingpriceByMid == null ? 0 : Double.parseDouble(sellClosingpriceByMid)); +// String sellClosingpriceByMid = memberMapper.selectSellClosingpriceForBasicRealDataBymemberId(memberId); +// memberInfoDetailVo.setSellClosingPrice(sellClosingpriceByMid == null ? 0 : Double.parseDouble(sellClosingpriceByMid)); - //总盈亏 - String rewardratioByMid = memberMapper.selectRewardratioForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setPlatformProfitAndLoss(rewardratioByMid == null ? 0 : Double.parseDouble(rewardratioByMid)); +// //总盈亏 +// String rewardratioByMid = memberMapper.selectRewardratioForBasicRealDataBymemberId(memberId); +// memberInfoDetailVo.setPlatformProfitAndLoss(rewardratioByMid == null ? 0 : Double.parseDouble(rewardratioByMid)); //持仓手续费 - String doingPrice = memberMapper.selectprepriceForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setDoingPrice(doingPrice == null ? 0 : Double.parseDouble(doingPrice)); +// String doingPrice = memberMapper.selectprepriceForBasicRealDataBymemberId(memberId); +// memberInfoDetailVo.setDoingPrice(doingPrice == null ? 0 : Double.parseDouble(doingPrice)); //账户金额 - String walletNum = memberMapper.selectBBZCForBasicRealDataBymemberId(memberId); + String walletNum = memberMapper.selectBBZCForBasicRealDataBymemberId(memberId,"USDT"); + String walletNumRoc = memberMapper.selectBBZCForBasicRealDataBymemberId(memberId,"ROC"); memberInfoDetailVo.setWalletCoinNum(walletNum == null ? 0 : Double.parseDouble(walletNum)); - String walletCoinNum = memberMapper.selectHYZCForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setTotalContract(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)); - String agentNum = memberMapper.selectDLZCForBasicRealDataBymemberId(memberId); - memberInfoDetailVo.setAgentNum(agentNum == null ? 0 : Double.parseDouble(agentNum)); + memberInfoDetailVo.setWalletCoinNumRoc(walletNumRoc == null ? 0 : Double.parseDouble(walletNumRoc)); + //String walletCoinNum = memberMapper.selectHYZCForBasicRealDataBymemberId(memberId); + //memberInfoDetailVo.setTotalContract(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)); + //String agentNum = memberMapper.selectDLZCForBasicRealDataBymemberId(memberId); + //memberInfoDetailVo.setAgentNum(agentNum == null ? 0 : Double.parseDouble(agentNum)); return memberInfoDetailVo; } @@ -871,6 +1041,10 @@ String walletNum = memberMapper.selectBBZCForBasicRealDataAlone(); String walletCoinNum = memberMapper.selectHYZCForBasicRealDataAlone(); String agentNum = memberMapper.selectDLZCForBasicRealDataAlone(); + double allCoin = 0 ; + allCoin = (walletNum == null ? 0 : Double.parseDouble(walletNum)) + +(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)) + +(agentNum == null ? 0 : Double.parseDouble(agentNum)); double platformProfitAndLoss = 0 ; platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); @@ -895,6 +1069,7 @@ memberDataInfoVo.setWalletNum(walletNum == null ? "0" : walletNum); memberDataInfoVo.setWalletCoinNum(walletCoinNum == null ? "0" : walletCoinNum); memberDataInfoVo.setAgentNum(agentNum == null ? "0" : agentNum); + memberDataInfoVo.setAllCoin(allCoin); } selectMemberListInPage.setTotal(1); return selectMemberListInPage; @@ -934,6 +1109,10 @@ String walletNum = memberMapper.selectBBZCForBasicData(); String walletCoinNum = memberMapper.selectHYZCForBasicData(); String agentNum = memberMapper.selectDLZCForBasicData(); + double allCoin = 0 ; + allCoin = (walletNum == null ? 0 : Double.parseDouble(walletNum)) + +(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)) + +(agentNum == null ? 0 : Double.parseDouble(agentNum)); double platformProfitAndLoss = 0 ; platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); @@ -958,6 +1137,7 @@ memberDataInfoVo.setWalletNum(walletNum == null ? "0" : walletNum); memberDataInfoVo.setWalletCoinNum(walletCoinNum == null ? "0" : walletCoinNum); memberDataInfoVo.setAgentNum(agentNum == null ? "0" : agentNum); + memberDataInfoVo.setAllCoin(allCoin); } selectMemberListInPage.setTotal(1); return selectMemberListInPage; @@ -998,6 +1178,10 @@ String walletNum = memberMapper.selectBBZCForBasicAllDataAlone(); String walletCoinNum = memberMapper.selectHYZCForBasicAllDataAlone(); String agentNum = memberMapper.selectDLZCForBasicAllDataAlone(); + double allCoin = 0 ; + allCoin = (walletNum == null ? 0 : Double.parseDouble(walletNum)) + +(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)) + +(agentNum == null ? 0 : Double.parseDouble(agentNum)); double platformProfitAndLoss = 0 ; platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); @@ -1022,6 +1206,7 @@ memberDataInfoVo.setWalletNum(walletNum == null ? "0" : walletNum); memberDataInfoVo.setWalletCoinNum(walletCoinNum == null ? "0" : walletCoinNum); memberDataInfoVo.setAgentNum(agentNum == null ? "0" : agentNum); + memberDataInfoVo.setAllCoin(allCoin); } selectMemberListInPage.setTotal(1); return selectMemberListInPage; @@ -1124,6 +1309,7 @@ //USDT充币总额+USDT提币总额 String totalAmountUsdtB = memberMapper.selectTotalAmountUsdtBForBasicRealTestDataAlone(); String totalAmountUsdtS = memberMapper.selectTotalAmountUsdtSForBasicRealTestDataAlone(); + //USDT充值总额+USDT提现总额 String totalAmountUsdtCZ = memberMapper.selectTotalAmountUsdtCZForBasicRealTestDataAlone(); String totalAmountUsdtTX = memberMapper.selectTotalAmountUsdtTXForBasicRealTestDataAlone(); @@ -1150,18 +1336,25 @@ String walletNum = memberMapper.selectBBZCForBasicRealTestDataAlone(); String walletCoinNum = memberMapper.selectHYZCForBasicRealTestDataAlone(); String agentNum = memberMapper.selectDLZCForBasicRealTestDataAlone(); + double allCoin = 0 ; + allCoin = (walletNum == null ? 0 : Double.parseDouble(walletNum)) + +(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)) + +(agentNum == null ? 0 : Double.parseDouble(agentNum)); double platformProfitAndLoss = 0 ; + + + platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); - platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); + platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtS == null ? 0 : (Double.parseDouble(totalAmountUsdtS)-6780)); platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); List<MemberDataInfoVo> records = selectMemberListInPage.getRecords(); for(MemberDataInfoVo memberDataInfoVo : records) { memberDataInfoVo.setChargeUsdt(totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); memberDataInfoVo.setAppealUsdt(totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); memberDataInfoVo.setChargeCoin(totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); - memberDataInfoVo.setAppealCoin(totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); + memberDataInfoVo.setAppealCoin(totalAmountUsdtS == null ? 0 : (Double.parseDouble(totalAmountUsdtS)-6780)); memberDataInfoVo.setClosingPrice(closingpriceByMid == null ? "0" : closingpriceByMid); memberDataInfoVo.setSellClosingPrice(sellClosingpriceByMid == null ? "0" : sellClosingpriceByMid); memberDataInfoVo.setFee(returnMoneyByMid == null ? "0" : returnMoneyByMid); @@ -1174,6 +1367,7 @@ memberDataInfoVo.setWalletNum(walletNum == null ? "0" : walletNum); memberDataInfoVo.setWalletCoinNum(walletCoinNum == null ? "0" : walletCoinNum); memberDataInfoVo.setAgentNum(agentNum == null ? "0" : agentNum); + memberDataInfoVo.setAllCoin(allCoin); } selectMemberListInPage.setTotal(1); return selectMemberListInPage; @@ -1214,18 +1408,22 @@ String walletNum = memberMapper.selectBBZCForBasicRealTestAllDataAlone(); String walletCoinNum = memberMapper.selectHYZCForBasicRealTestAllDataAlone(); String agentNum = memberMapper.selectDLZCForBasicRealTestAllDataAlone(); + double allCoin = 0 ; + allCoin = (walletNum == null ? 0 : Double.parseDouble(walletNum)) + +(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)) + +(agentNum == null ? 0 : Double.parseDouble(agentNum)); double platformProfitAndLoss = 0 ; platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); - platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); + platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtS == null ? 0 : (Double.parseDouble(totalAmountUsdtS)-6780)); platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); List<MemberDataInfoVo> records = selectMemberListInPage.getRecords(); for(MemberDataInfoVo memberDataInfoVo : records) { memberDataInfoVo.setChargeUsdt(totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); memberDataInfoVo.setAppealUsdt(totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); memberDataInfoVo.setChargeCoin(totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); - memberDataInfoVo.setAppealCoin(totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); + memberDataInfoVo.setAppealCoin(totalAmountUsdtS == null ? 0 : (Double.parseDouble(totalAmountUsdtS)-6780)); memberDataInfoVo.setClosingPrice(closingpriceByMid == null ? "0" : closingpriceByMid); memberDataInfoVo.setSellClosingPrice(sellClosingpriceByMid == null ? "0" : sellClosingpriceByMid); memberDataInfoVo.setFee(returnMoneyByMid == null ? "0" : returnMoneyByMid); @@ -1238,9 +1436,102 @@ memberDataInfoVo.setWalletNum(walletNum == null ? "0" : walletNum); memberDataInfoVo.setWalletCoinNum(walletCoinNum == null ? "0" : walletCoinNum); memberDataInfoVo.setAgentNum(agentNum == null ? "0" : agentNum); + memberDataInfoVo.setAllCoin(allCoin); } selectMemberListInPage.setTotal(1); return selectMemberListInPage; } + + @Override + public MemberInfoDetailVo selectMemberInfoDetailByInviteId(String inviteId) { + String id = memberMapper.selectMemberInfoDetailByInviteId(inviteId); + Long memberId = Long.parseLong(id); + MemberInfoDetailVo memberInfoDetailVo = new MemberInfoDetailVo(); + + //USDT充币总额+USDT提币总额 + String totalAmountUsdtB = memberMapper.selectTotalAmountUsdtBForBasicRealDataBymemberId(memberId,"USDT"); + memberInfoDetailVo.setChargeCoin(totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); + String totalAmountUsdtS = memberMapper.selectTotalAmountUsdtSForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setAppealCoin(totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); + //USDT充值总额+USDT提现总额 + String totalAmountUsdtCZ = memberMapper.selectTotalAmountUsdtCZForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setChargeUsdt(totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); + String totalAmountUsdtTX = memberMapper.selectTotalAmountUsdtTXForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setAppealUsdt(totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); + //总剩余 + double platformProfitAndLoss = 0 ; + platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtB == null ? 0 : Double.parseDouble(totalAmountUsdtB)); + platformProfitAndLoss = platformProfitAndLoss + (totalAmountUsdtCZ == null ? 0 : Double.parseDouble(totalAmountUsdtCZ)); + platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtS == null ? 0 : Double.parseDouble(totalAmountUsdtS)); + platformProfitAndLoss = platformProfitAndLoss - (totalAmountUsdtTX == null ? 0 : Double.parseDouble(totalAmountUsdtTX)); + memberInfoDetailVo.setTotalCoin(platformProfitAndLoss); + //佣金 + String returnMoneyByMid = memberMapper.selectReturnMoneyForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setFee(returnMoneyByMid == null ? 0 : Double.parseDouble(returnMoneyByMid)); + //开仓手续费总额 + String closingpriceByMid = memberMapper.selectClosingpriceForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setClosingPrice(closingpriceByMid == null ? 0 : Double.parseDouble(closingpriceByMid)); + //平仓总手续费 + String sellClosingpriceByMid = memberMapper.selectSellClosingpriceForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setSellClosingPrice(sellClosingpriceByMid == null ? 0 : Double.parseDouble(sellClosingpriceByMid)); + + //总盈亏 + String rewardratioByMid = memberMapper.selectRewardratioForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setPlatformProfitAndLoss(rewardratioByMid == null ? 0 : Double.parseDouble(rewardratioByMid)); + + //持仓手续费 + String doingPrice = memberMapper.selectprepriceForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setDoingPrice(doingPrice == null ? 0 : Double.parseDouble(doingPrice)); + + //账户金额 + String walletNum = memberMapper.selectBBZCForBasicRealDataBymemberId(memberId,"USDT"); + memberInfoDetailVo.setWalletCoinNum(walletNum == null ? 0 : Double.parseDouble(walletNum)); + String walletCoinNum = memberMapper.selectHYZCForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setTotalContract(walletCoinNum == null ? 0 : Double.parseDouble(walletCoinNum)); + String agentNum = memberMapper.selectDLZCForBasicRealDataBymemberId(memberId); + memberInfoDetailVo.setAgentNum(agentNum == null ? 0 : Double.parseDouble(agentNum)); + + return memberInfoDetailVo; + } + + + @Override + public IPage<MemberEntity> memberDataInfoListSearchs(MemberEntity member, QueryRequest request) { + + Page<MemberEntity> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<MemberEntity> selectMemberListInPage = this.baseMapper.selectDataInfoListSearchs(page, member); + List<MemberEntity> records = selectMemberListInPage.getRecords(); + Set<MemberEntity> set = new HashSet<>(); + if(CollUtil.isNotEmpty(records)) { + if(StrUtil.isNotBlank(member.getAccount())) { + MemberEntity memberEntity = records.get(0); + //当前查询下级关系 + String inviteId = memberEntity.getInviteId(); + List<MemberEntity> members = memberMapper.selectMemberDataInfoListSearchs(inviteId); + if(CollUtil.isNotEmpty(members)) { + for(MemberEntity semberEntity : members) { + set.add(semberEntity); + } + } + //当前查询上级关系 + String refererIds = memberEntity.getRefererIds(); + String[] strs = refererIds.split(","); + if(ObjectUtil.isNotEmpty(strs)) { + for(int i=0,len=strs.length;i<len;i++){ + String string = strs[i].toString(); + if(StrUtil.isNotEmpty(string)) { + MemberEntity mem = memberMapper.selectMemberByInviteId(string); + set.add(mem); + } + } + } + } + if(set.size() > 0) { + records.addAll(set); + } + } + return selectMemberListInPage; + } + } -- Gitblit v1.9.1