| | |
| | | private TipService tipService; |
| | | |
| | | @Override |
| | | public void saveReject(String id, String failure_msg, String userName, String partyId, WalletGatherService walletGatherService) { |
| | | public void saveReject(String id, String failure_msg, String userName, String partyId) { |
| | | Withdraw withdraw = this.get(id); |
| | | |
| | | if (withdraw.getSucceeded() == 2 ) {// 通过后不可驳回 |
| | |
| | | symbol = "btc"; |
| | | } else if (withdraw.getMethod().indexOf("ETH") != -1) { |
| | | symbol = "eth"; |
| | | } else if (withdraw.getMethod().indexOf("USDC") != -1) { |
| | | symbol = "eth"; |
| | | } else { |
| | | symbol = "usdt"; |
| | | } |
| | | WalletGather walletGather = walletGatherService.getWalletGatherByPartyId(withdraw.getPartyId(),null); |
| | | double amount_before = 0; |
| | | if("usdt".equals(symbol)){ |
| | | amount_before = walletGather.getUsdtMoney(); |
| | | } else if ("btc".equals(symbol)) { |
| | | amount_before = walletGather.getBtcMoney(); |
| | | } else if ("eth".equals(symbol)) { |
| | | amount_before = walletGather.getEthMoney(); |
| | | } else if ("usdc".equals(symbol)) { |
| | | amount_before = walletGather.getUsdcMoney(); |
| | | if ("usdt".equals(symbol)) { |
| | | Wallet wallet = walletService.saveWalletByPartyId(withdraw.getPartyId()); |
| | | |
| | | double amount_before = wallet.getMoney(); |
| | | |
| | | walletService.update(wallet.getPartyId().toString(), |
| | | Arith.add(withdraw.getAmount(), withdraw.getAmount_fee())); |
| | | |
| | | /* |
| | | * 保存资金日志 |
| | | */ |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | | moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN); |
| | | moneyLog.setAmount_before(amount_before); |
| | | moneyLog.setAmount(Arith.add(withdraw.getAmount(), withdraw.getAmount_fee())); |
| | | moneyLog.setAmount_after( |
| | | Arith.add(amount_before, Arith.add(withdraw.getAmount(), withdraw.getAmount_fee()))); |
| | | |
| | | moneyLog.setLog("驳回提现[" + withdraw.getOrder_no() + "]"); |
| | | // moneyLog.setExtra(withdraw.getOrder_no()); |
| | | moneyLog.setPartyId(withdraw.getPartyId()); |
| | | moneyLog.setWallettype(Constants.WALLET); |
| | | moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW); |
| | | |
| | | moneyLogService.save(moneyLog); |
| | | } else { |
| | | WalletExtend walletExtend = walletService.saveExtendByPara(withdraw.getPartyId(), symbol); |
| | | double amount_before = walletExtend.getAmount(); |
| | | walletService.updateExtend(withdraw.getPartyId().toString(), symbol, withdraw.getVolume()); |
| | | |
| | | /* |
| | | * 保存资金日志 |
| | | */ |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | | moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN); |
| | | moneyLog.setAmount_before(amount_before); |
| | | moneyLog.setAmount(withdraw.getVolume()); |
| | | moneyLog.setAmount_after(Arith.add(amount_before, withdraw.getVolume())); |
| | | |
| | | moneyLog.setLog("驳回提现[" + withdraw.getOrder_no() + "]"); |
| | | // moneyLog.setExtra(withdraw.getOrder_no()); |
| | | moneyLog.setPartyId(withdraw.getPartyId()); |
| | | moneyLog.setWallettype(symbol.toUpperCase()); |
| | | moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW); |
| | | |
| | | moneyLogService.save(moneyLog); |
| | | } |
| | | //修改资金账户 |
| | | walletGatherService.update(walletGather.getPartyId().toString(),symbol,withdraw.getAmount(),"add"); |
| | | /* |
| | | * 保存资金日志 |
| | | */ |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | | moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN); |
| | | moneyLog.setAmount_before(amount_before); |
| | | moneyLog.setAmount(Arith.add(withdraw.getAmount(), withdraw.getAmount_fee())); |
| | | moneyLog.setAmount_after( |
| | | Arith.add(amount_before, Arith.add(withdraw.getAmount(), withdraw.getAmount_fee()))); |
| | | |
| | | moneyLog.setLog("驳回提现[" + withdraw.getOrder_no() + "]"); |
| | | // moneyLog.setExtra(withdraw.getOrder_no()); |
| | | moneyLog.setPartyId(withdraw.getPartyId()); |
| | | moneyLog.setWallettype(Constants.WALLET); |
| | | moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW); |
| | | |
| | | moneyLogService.save(moneyLog); |
| | | this.walletLogService.updateStatus(withdraw.getOrder_no(), withdraw.getSucceeded()); |
| | | |
| | | SecUser SecUser = secUserService.findUserByPartyId(withdraw.getPartyId()); |
| | |
| | | tipService.deleteTip(withdraw.getId().toString()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveSucceeded(String id, String safeword, String userName, String partyId) { |
| | | SecUser sec = this.secUserService.findUserByLoginName(userName); |
| | | String sysSafeword = sec.getSafeword(); |
| | | |
| | | String safeword_md5 = passwordEncoder.encodePassword(safeword, userName); |
| | | if (!safeword_md5.equals(sysSafeword)) { |
| | | SecUser var5 = this.secUserService.findUserByLoginName(userName); |
| | | String var6 = var5.getSafeword(); |
| | | String var7 = this.passwordEncoder.encodePassword(safeword, userName); |
| | | if (!var7.equals(var6)) { |
| | | throw new BusinessException("资金密码错误"); |
| | | } |
| | | } else { |
| | | Withdraw var8 = this.get(id); |
| | | Date var9 = new Date(); |
| | | var8.setReviewTime(var9); |
| | | if (var8 != null && var8.getSucceeded() == 0) { |
| | | String var10 = ""; |
| | | if (var8.getMethod().indexOf("BTC") != -1) { |
| | | var10 = "btc"; |
| | | } else if (var8.getMethod().indexOf("ETH") != -1) { |
| | | var10 = "eth"; |
| | | } else { |
| | | var10 = "usdt"; |
| | | } |
| | | |
| | | Withdraw withdraw = this.get(id); |
| | | Date date = new Date(); |
| | | withdraw.setReviewTime(date); |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | |
| | | if (withdraw != null && withdraw.getSucceeded() == 0) { |
| | | String symbol = ""; |
| | | String itemId = ""; |
| | | String coin = ""; |
| | | if (withdraw.getMethod().indexOf("BTC") != -1) { |
| | | symbol = "btc"; |
| | | itemId = "4"; |
| | | coin = "btc"; |
| | | } else if (withdraw.getMethod().indexOf("ETH") != -1) { |
| | | symbol = "eth"; |
| | | itemId = "3"; |
| | | coin = "eth"; |
| | | }else if(withdraw.getMethod().indexOf("TRC") != -1){ |
| | | symbol = "usdt"; |
| | | itemId = "1"; |
| | | coin = "trc"; |
| | | }else{ |
| | | symbol = "usdt"; |
| | | itemId = "1"; |
| | | coin = "erc"; |
| | | var8.setSucceeded(1); |
| | | this.updateWithdraw(var8); |
| | | this.walletLogService.updateStatus(var8.getOrder_no(), var8.getSucceeded()); |
| | | this.userDataService.saveWithdrawHandle(var8.getPartyId(), var8.getAmount(), var8.getAmount_fee(), var10); |
| | | SecUser var11 = this.secUserService.findUserByPartyId(var8.getPartyId()); |
| | | Log var12 = new Log(); |
| | | var12.setCategory("operation"); |
| | | var12.setExtra(var8.getOrder_no()); |
| | | var12.setOperator(userName); |
| | | var12.setUsername(var11.getUsername()); |
| | | var12.setPartyId(var11.getPartyId()); |
| | | var12.setLog("通过提现申请。订单号[" + var8.getOrder_no() + "]。"); |
| | | this.logService.saveSync(var12); |
| | | this.tipService.deleteTip(var8.getId().toString()); |
| | | } |
| | | |
| | | |
| | | withdraw.setSucceeded(4); |
| | | this.updateWithdraw(withdraw); |
| | | |
| | | this.walletLogService.updateStatus(withdraw.getOrder_no(), withdraw.getSucceeded()); |
| | | |
| | | //发送提现代付 |
| | | String usercode = jdbcTemplate.queryForObject("SELECT USERCODE FROM PAT_PARTY WHERE UUID=?", String.class,withdraw.getPartyId()); |
| | | String withdrawHash = walletWithdraw(usercode,coin,itemId,withdraw.getAddress(),withdraw.getAmount()); |
| | | jdbcTemplate.update("UPDATE T_WITHDRAW_ORDER SET WITHDRAW_HASH = ? WHERE ORDER_NO = ?",withdrawHash,withdraw.getOrder_no()); |
| | | /** |
| | | * 提现订单加入userdate |
| | | */ |
| | | this.userDataService.saveWithdrawHandle(withdraw.getPartyId(), withdraw.getAmount(), |
| | | withdraw.getAmount_fee(), symbol); |
| | | |
| | | SecUser SecUser = secUserService.findUserByPartyId(withdraw.getPartyId()); |
| | | Log log = new Log(); |
| | | log.setCategory(Constants.LOG_CATEGORY_OPERATION); |
| | | log.setExtra(withdraw.getOrder_no()); |
| | | log.setOperator(userName); |
| | | log.setUsername(SecUser.getUsername()); |
| | | log.setPartyId(SecUser.getPartyId()); |
| | | log.setLog("通过提现申请。订单号[" + withdraw.getOrder_no() + "]。"); |
| | | |
| | | logService.saveSync(log); |
| | | tipService.deleteTip(withdraw.getId().toString()); |
| | | } |
| | | } |
| | | |
| | | public String walletWithdraw(String userId,String coin,String itemId,String address,double num){ |
| | | try{ |
| | | //先生成备用地址 |
| | | Map<String,Object> generateMap = new HashMap<String, Object>(); |
| | | generateMap.put("item_id", itemId); |
| | | generateMap.put("user_id", userId); |
| | | generateMap.put("address", address); |
| | | generateMap.put("num", String.valueOf(num)); |
| | | System.out.println(coin+"生成备用地址提交字符串为:"+ JsonUtils.toJson(generateMap)); |
| | | HttpsTransport httpsTransport = new HttpsTransport(); |
| | | httpsTransport.setSendEncoding("UTF-8"); |
| | | httpsTransport.setUrl("http://18.163.120.125:999/"+coin+"/withdraw"); |
| | | System.out.println(coin+"提交地址:"+ "http://18.163.120.125:999/"+coin+"/withdraw"); |
| | | String response = (String) httpsTransport.submit(generateMap); |
| | | System.out.println(coin+"生成备用地址提响应字符串为:"+ JsonUtils.toJson(response)); |
| | | //8,返回参数转map |
| | | Map<String,Object> responseMap = JsonUtils.jsonToMap(response); |
| | | if(responseMap.get("status").toString().trim().equals("1")){ |
| | | Map<String,Object> addressMap = (Map)responseMap.get("result"); |
| | | return addressMap.get("withdraw_hash").toString(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改提现描述 |
| | | */ |