|
|
@ -216,16 +216,16 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I |
|
|
|
CheckEthFeginResult.checkIsPassword(ethServerFegin.isPassword(password)); |
|
|
|
CheckEthFeginResult.checkIsPassword(ethServerFegin.isPassword(password)); |
|
|
|
|
|
|
|
|
|
|
|
//验证提现地址是否有效
|
|
|
|
//验证提现地址是否有效
|
|
|
|
JSONObject vaObj = null; |
|
|
|
// JSONObject vaObj = null;
|
|
|
|
try { |
|
|
|
// try {
|
|
|
|
vaObj = btcUtils.validateAddress(toAddress); |
|
|
|
// vaObj = btcUtils.validateAddress(toAddress);
|
|
|
|
} catch (Exception e) { |
|
|
|
// } catch (Exception e) {
|
|
|
|
throw new BtcException(BtcEnums.ADDRESS_ERROR); |
|
|
|
// throw new BtcException(BtcEnums.ADDRESS_ERROR);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
//验证提现地址是否有效
|
|
|
|
// //验证提现地址是否有效
|
|
|
|
if (!vaObj.getBoolean("isvalid")) { |
|
|
|
// if (!vaObj.getBoolean("isvalid")) {
|
|
|
|
throw new BtcException(BtcEnums.ADDRESS_ERROR); |
|
|
|
// throw new BtcException(BtcEnums.ADDRESS_ERROR);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//获取钱包余额
|
|
|
|
//获取钱包余额
|
|
|
|
BtcWalletDTO btcWalletDTO = btcWalletService.selectByUserOpenId(userOpenId, tokenId, walletType); |
|
|
|
BtcWalletDTO btcWalletDTO = btcWalletService.selectByUserOpenId(userOpenId, tokenId, walletType); |
|
|
@ -237,8 +237,6 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I |
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
//判断是否属于节点钱包
|
|
|
|
|
|
|
|
if (vaObj.getBoolean("ismine")) { |
|
|
|
|
|
|
|
//*********** 是,快速转账,数据库划转 ***********
|
|
|
|
//*********** 是,快速转账,数据库划转 ***********
|
|
|
|
|
|
|
|
|
|
|
|
//该用户减去提现可用余额、总额
|
|
|
|
//该用户减去提现可用余额、总额
|
|
|
@ -246,12 +244,12 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I |
|
|
|
if (countUb != 1) { |
|
|
|
if (countUb != 1) { |
|
|
|
throw new BtcException(BtcEnums.WITHDRAW_ERROR); |
|
|
|
throw new BtcException(BtcEnums.WITHDRAW_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
//接收用户加上可用余额、总额
|
|
|
|
// //接收用户加上可用余额、总额
|
|
|
|
int countUbR = btcWalletService.updateBalanceByAddrInRowLock(toAddress, tokenId, amount, 0.0, amount, now); |
|
|
|
// int countUbR = btcWalletService.updateBalanceByAddrInRowLock(toAddress, tokenId, amount, 0.0, amount, now);
|
|
|
|
if (countUbR != 1) { |
|
|
|
// if (countUbR != 1) {
|
|
|
|
throw new BtcException(BtcEnums.WITHDRAW_ERROR); |
|
|
|
// throw new BtcException(BtcEnums.WITHDRAW_ERROR);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
//不走链上,快速到账。
|
|
|
|
//并插入一条提现记录,站内快速转账
|
|
|
|
//并插入一条提现记录,站内快速转账
|
|
|
|
BtcWalletTransfer btcWalletTransfer = new BtcWalletTransfer(); |
|
|
|
BtcWalletTransfer btcWalletTransfer = new BtcWalletTransfer(); |
|
|
|
btcWalletTransfer.setId(UUID.randomUUID().toString()); |
|
|
|
btcWalletTransfer.setId(UUID.randomUUID().toString()); |
|
|
@ -270,47 +268,49 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I |
|
|
|
if (countIt != 1) { |
|
|
|
if (countIt != 1) { |
|
|
|
throw new BtcException(BtcEnums.WITHDRAW_ERROR); |
|
|
|
throw new BtcException(BtcEnums.WITHDRAW_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
//判断是否属于节点钱包
|
|
|
|
//*********** 否,区块链转账 ***********
|
|
|
|
// if (vaObj.getBoolean("ismine")) {
|
|
|
|
// 查询是否存在提现黑名单中
|
|
|
|
// } else {
|
|
|
|
// 抛出错误表示用户禁止提现
|
|
|
|
// //*********** 否,区块链转账 ***********
|
|
|
|
userServerFegin.verifyBanWithdraw(userOpenId); |
|
|
|
// // 查询是否存在提现黑名单中
|
|
|
|
// 判断用户是否存在提现白名单中
|
|
|
|
// // 抛出错误表示用户禁止提现
|
|
|
|
ResultDTO<Boolean> resultDTO = userServerFegin.verifyFreeWithdraw(userOpenId); |
|
|
|
// userServerFegin.verifyBanWithdraw(userOpenId);
|
|
|
|
if (resultDTO.getCode() != BaseConstant.REQUEST_SUCCESS) |
|
|
|
// // 判断用户是否存在提现白名单中
|
|
|
|
throw new RPCException(resultDTO.getCode(), resultDTO.getMsg()); |
|
|
|
// ResultDTO<Boolean> resultDTO = userServerFegin.verifyFreeWithdraw(userOpenId);
|
|
|
|
// 用户存在提现白名单中,设置提现手续费为零
|
|
|
|
// if (resultDTO.getCode() != BaseConstant.REQUEST_SUCCESS)
|
|
|
|
if (resultDTO.getData()) gasDTO.setGasPrice(BigDecimal.ZERO); |
|
|
|
// throw new RPCException(resultDTO.getCode(), resultDTO.getMsg());
|
|
|
|
// 余额加上扣除手续费
|
|
|
|
// // 用户存在提现白名单中,设置提现手续费为零
|
|
|
|
//该用户减去提现可用余额、加上冻结余额
|
|
|
|
// if (resultDTO.getData()) gasDTO.setGasPrice(BigDecimal.ZERO);
|
|
|
|
int countUb = btcWalletService.updateBalanceByAddrInRowLock(fromAddress, tokenId, -amount, amount, 0.0, now); |
|
|
|
// // 余额加上扣除手续费
|
|
|
|
if (countUb != 1) { |
|
|
|
// //该用户减去提现可用余额、加上冻结余额
|
|
|
|
throw new BtcException(BtcEnums.WITHDRAW_ERROR); |
|
|
|
// int countUb = btcWalletService.updateBalanceByAddrInRowLock(fromAddress, tokenId, -amount, amount, 0.0, now);
|
|
|
|
} |
|
|
|
// if (countUb != 1) {
|
|
|
|
//并插入一条提现记录
|
|
|
|
// throw new BtcException(BtcEnums.WITHDRAW_ERROR);
|
|
|
|
BtcWalletTransfer btcWalletTransfer = new BtcWalletTransfer(); |
|
|
|
// }
|
|
|
|
btcWalletTransfer.setId(UUID.randomUUID().toString()); |
|
|
|
// //并插入一条提现记录
|
|
|
|
// btcWalletTransfer.setHash(null);
|
|
|
|
// BtcWalletTransfer btcWalletTransfer = new BtcWalletTransfer();
|
|
|
|
btcWalletTransfer.setFromAddr(fromAddress); |
|
|
|
// btcWalletTransfer.setId(UUID.randomUUID().toString());
|
|
|
|
btcWalletTransfer.setToAddr(toAddress); |
|
|
|
//// btcWalletTransfer.setHash(null);
|
|
|
|
btcWalletTransfer.setAmount(Math.abs(amount)); |
|
|
|
// btcWalletTransfer.setFromAddr(fromAddress);
|
|
|
|
btcWalletTransfer.setTokenId(tokenId); |
|
|
|
// btcWalletTransfer.setToAddr(toAddress);
|
|
|
|
btcWalletTransfer.setTokenSymbol(tokenSymbol); |
|
|
|
// btcWalletTransfer.setAmount(Math.abs(amount));
|
|
|
|
//设置手续费
|
|
|
|
// btcWalletTransfer.setTokenId(tokenId);
|
|
|
|
//TODO 扣减不同币种手续费
|
|
|
|
// btcWalletTransfer.setTokenSymbol(tokenSymbol);
|
|
|
|
btcWalletTransfer.setGasPrice(gasDTO.getGasPrice().doubleValue()); |
|
|
|
// //设置手续费
|
|
|
|
btcWalletTransfer.setGasTokenType(gasDTO.getGasTokenType()); |
|
|
|
// //TODO 扣减不同币种手续费
|
|
|
|
btcWalletTransfer.setGasTokenSymbol(gasDTO.getGasTokenSymbol()); |
|
|
|
// btcWalletTransfer.setGasPrice(gasDTO.getGasPrice().doubleValue());
|
|
|
|
btcWalletTransfer.setGasTokenName(gasDTO.getGasTokenName()); |
|
|
|
// btcWalletTransfer.setGasTokenType(gasDTO.getGasTokenType());
|
|
|
|
btcWalletTransfer.setTransferType(BtcTransferConstans.TYPE_OUT); |
|
|
|
// btcWalletTransfer.setGasTokenSymbol(gasDTO.getGasTokenSymbol());
|
|
|
|
btcWalletTransfer.setStatus(BtcTransferConstans.STATUS_FIRST_TRIAL); |
|
|
|
// btcWalletTransfer.setGasTokenName(gasDTO.getGasTokenName());
|
|
|
|
btcWalletTransfer.setCreateTime(now); |
|
|
|
// btcWalletTransfer.setTransferType(BtcTransferConstans.TYPE_OUT);
|
|
|
|
btcWalletTransfer.setUpdateTime(now); |
|
|
|
// btcWalletTransfer.setStatus(BtcTransferConstans.STATUS_FIRST_TRIAL);
|
|
|
|
int countIt = insertTransfer(btcWalletTransfer); |
|
|
|
// btcWalletTransfer.setCreateTime(now);
|
|
|
|
if (countIt != 1) { |
|
|
|
// btcWalletTransfer.setUpdateTime(now);
|
|
|
|
throw new BtcException(BtcEnums.WITHDRAW_ERROR); |
|
|
|
// int countIt = insertTransfer(btcWalletTransfer);
|
|
|
|
} |
|
|
|
// if (countIt != 1) {
|
|
|
|
} |
|
|
|
// throw new BtcException(BtcEnums.WITHDRAW_ERROR);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//返回加减余额后的数据
|
|
|
|
//返回加减余额后的数据
|
|
|
|
return btcWalletService.selectByAddr(fromAddress, tokenId, walletType); |
|
|
|
return btcWalletService.selectByAddr(fromAddress, tokenId, walletType); |
|
|
|