@Override public void validate(Parameter request) throws ClientException { if (request == null || request.getBody() == null) { throw new ClientException("E120001", UserError.E120001); } AccountRechargeByTransferReq req = (AccountRechargeByTransferReq) request.getBody(); if (StringUtils.isBlank(req.getUserId())) { throw new ClientException("E240009", PayError.E240009); } if (StringUtils.isBlank(req.getPayerName())) { throw new ClientException("E170001", PayerError.E170001); } if (StringUtils.isBlank(req.getPayAccount())) { throw new ClientException("E160002", MoneyError.E160002); } if (StringUtils.isBlank(req.getPayee()) || StringUtils.isBlank(req.getPayeeName())) { throw new ClientException("E190001", PayeeRrror.E190001); } if (StringUtils.isBlank(req.getRemittance())) { throw new ClientException("E160002", MoneyError.E160002); } }
@Override public Body execute(Parameter request, Object... obj) throws ClientException { AccountRechargeByTransferRsp rsp = new AccountRechargeByTransferRsp(); AccountRechargeByTransferReq req = null; try { req = (AccountRechargeByTransferReq) request.getBody(); logger.info(String.format("账号充值申请服务", JSONObject.fromObject(req))); logger.info(String.format("上传凭证图片操作")); Map<String, Object> params = new HashMap<String, Object>(); String picUrl = this.uploadImage(params, (File[]) obj[0], (String[]) obj[1]); // 清空参数重新赋值 // 凭证图片地址 params.put("voucherFileName", picUrl); // 申请人标识(统一认证UUID) params.put("applyId", req.getUserId()); // 付款人标识(统一认证UUID) req.setPayer(req.getUserId()); params.put("remitterId", req.getPayer()); // 付款人姓名 params.put("remitterName", req.getPayerName()); // 付款人银行卡号或账号 params.put("remitterBankcardNo", req.getPayAccount()); // 交易金额(小写) params.put("tradeAmount", req.getRemittance()); // 交易类型,1:充值,2:扣款 params.put("tradeType", "1"); // 收款人账号 params.put("payeeNo", req.getPayee()); // 收款人名称 params.put("payeeName", req.getPayeeName()); // 申请时间 params.put("applyTime", req.getPayTime()); // 资金确认时间 params.put("amountArriveTime", DateUtil.getCurrentUtcMsTime().toString()); params.put("insideAccountNo", req.getInsideAccountNo()); params.put("approvalPersonName", req.getPayerName()); UppResult uppResult = this.callUPP(params, "UPP_ACCOUNT_RECHARGE_BY_TRANSFER"); if (uppResult.getResult().equals(UppResult.FAILURE)) { throw new ClientException(PayError.E240001, uppResult.getError()); } rsp.setAttachId(picUrl); rsp.setResult("0"); } catch (ClientException e) { logger.error(e.getMessage(), e); throw e; } catch (Exception e) { rsp.setResult("1"); logger.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); logger.error("账户充值失败:" + e); logger.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); throw new ClientException("资金账户充值失败,userId=" + req.getUserId(), e); } return rsp; }