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 | 148 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 96 insertions(+), 52 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 edf2822..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
@@ -77,6 +77,8 @@
private final TdFinancialReordDao tdFinancialReordDao;
private final RedisUtils redisUtils;
+
+ private final TrcAddressDao trcAddressDao;
@Override
public IPage<AgentFriendRelationEntity> findAgentInfoListInPage(AgentFriendRelationEntity agentFriendRelationEntity,
@@ -488,50 +490,91 @@
if ("Y".equals(selectById.getIsInside())) {
// 查询算力系统中是否存在该地址
TdCoinWallet tdCoinWallet = memberWalletCoinMapper.selectTdCoinWalletByAddress(address, "USDT");
- if (tdCoinWallet != null) {
- // 更新算力系统中用户钱包余额
- memberWalletCoinMapper.updateTdCoinWalletAvaliable(amount, address);
+ 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("地址有误,请拒绝!");
+ 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);
}
- Long aimMemberId = selectByMap.get(0).getMemberId();
- MemberWalletCoinEntity aimWalletCoin = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(aimMemberId, symbol);
+ } else {
+ if (trcAddressEntity.getSystemFlag().equals(TrcAddressEntity.SYSTEM_FLAG_SL)) {
+ memberWalletCoinMapper.updateTdCoinWalletTrc20(amount, trcAddressEntity.getMemberId());
- BigDecimal addTotal = aimWalletCoin.getTotalBalance().add(amount);
- BigDecimal addAvailable = aimWalletCoin.getAvailableBalance().add(amount);
- aimWalletCoin.setTotalBalance(addTotal);
- aimWalletCoin.setAvailableBalance(addAvailable);
+ 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);
- memberWalletCoinMapper.updateById(aimWalletCoin);
+ BigDecimal addTotal = aimWalletCoin.getTotalBalance().add(amount);
+ BigDecimal addAvailable = aimWalletCoin.getAvailableBalance().add(amount);
+ aimWalletCoin.setTotalBalance(addTotal);
+ aimWalletCoin.setAvailableBalance(addAvailable);
- 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);
+ 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);
+ }
}
}
@@ -547,18 +590,20 @@
selectById.setStatus(MemberCoinWithdrawEntity.IS_STATUS_Y);
memberCoinWithdrawMapper.updateById(selectById);
- 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().toPlainString(), selectById.getAddress());
- selectById.setTag(orderNo);
- memberCoinWithdrawMapper.updateById(selectById);
- }
- });
- thread.start();
+ 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);
@@ -567,7 +612,6 @@
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);
}
--
Gitblit v1.9.1