コード例 #1
0
  @Override
  @Transactional(rollbackFor = Exception.class)
  public void receiveOperationPostCallback(ServletRequest request)
      throws TrusteeshipReturnException {

    try {
      request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }

    String resp = request.getParameter("resp");
    String sign = request.getParameter("sign");
    log.debug(resp);
    log.debug(sign);
    boolean flag = CFCASignUtil.isVerifySign(resp, sign);
    log.debug(flag);
    if (flag) {
      // 处理账户开通成功
      @SuppressWarnings("unchecked")
      Map<String, String> resultMap = Dom4jUtil.xmltoMap(resp);
      String code = resultMap.get("code");
      String requestNo =
          resultMap
              .get("requestNo")
              .replaceFirst(YeePayConstants.RequestNoPre.UNBINDING_YEEPAY_BANKCARD, "");
      String description = resultMap.get("description");
      TrusteeshipOperation to =
          trusteeshipOperationBO.get(
              YeePayConstants.OperationType.UNBINDING_YEEPAY_BANKCARD,
              requestNo,
              requestNo,
              "yeepay");
      if ("1".equals(code)) {
        BankCard bc = ht.get(BankCard.class, requestNo);
        if (bc != null) {
          bc.setStatus(BankCardConstants.BankCardStatus.DELETED);
          ht.update(bc);
        }
        to.setStatus(TrusteeshipConstants.Status.PASSED);
        to.setResponseTime(new Date());
        to.setResponseData(resp);
        ht.update(to);
      } else {
        to.setStatus(TrusteeshipConstants.Status.REFUSED);
        to.setResponseTime(new Date());
        to.setResponseData(description);
        ht.update(to);
        // 真实错误原因
        throw new TrusteeshipReturnException(code + ":" + description);
      }
    }
  }
コード例 #2
0
  @Override
  @Transactional(rollbackFor = Exception.class)
  public void receiveOperationS2SCallback(ServletRequest request, ServletResponse response) {

    try {
      request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    String notifyXML = request.getParameter("notify");
    String sign = request.getParameter("sign");
    @SuppressWarnings("unchecked")
    Map<String, String> resultMap = Dom4jUtil.xmltoMap(notifyXML);
    String cardNo =
        resultMap
            .get("requestNo")
            .replaceFirst(YeePayConstants.RequestNoPre.UNBINDING_YEEPAY_BANKCARD, "");
    //		String cardNo = resultMap.get("cardNo");
    //		String bank = resultMap.get("bank");
    //		String cardStatus = resultMap.get("cardStatus");
    //		String platformUserNo = resultMap.get("platformUserNo");
    boolean flag = CFCASignUtil.isVerifySign(notifyXML, sign);
    log.debug(notifyXML);
    if (flag) {
      BankCard bc = ht.get(BankCard.class, cardNo);
      if (bc != null) {
        bc.setStatus(BankCardConstants.BankCardStatus.DELETED);
        ht.update(bc);
      }
      try {
        response.getWriter().print("SUCCESS");
        FacesUtil.getCurrentInstance().responseComplete();
      } catch (IOException e) {
        log.debug("trusteeshipBindingBancCard S2S response" + e.getMessage());
        throw new RuntimeException(e.getMessage());
      }
    }
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  @Override
  @Transactional(rollbackFor = Exception.class)
  public void receiveOperationS2SCallback(ServletRequest request, ServletResponse response) {
    try {
      request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }

    String respXML = request.getParameter("notify"); // 响应的参数 为xml格式
    log.debug("债权转让s2sCallback respXML:" + respXML.toString());
    String sign = request.getParameter("sign"); // 签名
    boolean flag = CFCASignUtil.isVerifySign(respXML, sign);

    if (flag) { // 验签成功

      Map<String, String> map = Dom4jUtil.xmltoMap(respXML);
      String code = map.get("code");
      String requestNo =
          map.get("requestNo").replaceFirst(YeePayConstants.RequestNoPre.TRANSFER, "");
      if ("1".equals(code)) { // 易宝冻结金额成功

        TrusteeshipOperation to =
            trusteeshipOperationBO.get(YeePayConstants.OperationType.TRANSFER, requestNo, "yeepay");
        ht.evict(to);
        to =
            trusteeshipOperationBO.get(YeePayConstants.OperationType.TRANSFER, requestNo, "yeepay");
        ht.evict(to);
        to = ht.get(TrusteeshipOperation.class, to.getId(), LockMode.UPGRADE);
        String[] params = to.getOperator().split("&");
        Invest invest = ht.get(Invest.class, requestNo); // 债权购买人购买的债权转换成的一笔投资
        TransferApply ta = ht.get(TransferApply.class, invest.getTransferApply().getId()); // 债权转让申请
        if (TrusteeshipConstants.Status.PASSED.equals(to.getStatus())) {
          return;
        }
        // 调用易宝转账确认端口
        boolean result =
            yeepayCpTransacionOperation.transactionComform(
                YeePayConstants.RequestNoPre.TRANSFER + requestNo, "CONFIRM");
        if (result) { // 易宝转账确认成功

          to.setStatus(TrusteeshipConstants.Status.PASSED);
          ht.update(to);

          /**
           * ***********************************平台操作begin**************************************************
           */
          if (invest != null && ta != null) {

            invest.setStatus(InvestConstants.InvestStatus.REPAYING);
            invest.setTime(new Date()); // 成交时间

            Invest orignInvest = ta.getInvest(); // 债权转让人转让的一笔投资
            double investReaminCorpus =
                ArithUtil.sub(orignInvest.getMoney(), invest.getMoney()); // 原投资债权转让后剩余的投资金额
            if (investReaminCorpus == 0.0) {
              orignInvest.setStatus(InvestStatus.COMPLETE);
            }
            orignInvest.setMoney(investReaminCorpus);

            double remainCorpus = transferService.calculateRemainCorpus(ta.getId()); // 未转出的本金
            if (remainCorpus > 0.0) { // 债权未全部转出
              ta.setStatus(TransferStatus.TRANSFERING);
            } else { // 债权全部转出
              ta.setStatus(TransferStatus.TRANSFED);
            }
            // 债权的购买金额
            double buyPrice = Double.parseDouble(params[0]);
            // 购买时候,扣除手续费,从转让人收到的金额中扣除。费用根据购买价格计算
            double fee =
                feeConfigBO.getFee(FeePoint.TRANSFER, FeeType.FACTORAGE, null, null, buyPrice);
            // 购买时候,扣除手续费,从转让人收到的金额中扣除。费用根据购买价格计算
            try {
              userBillBO.transferOutFromBalance(
                  invest.getUser().getId(),
                  buyPrice,
                  OperatorInfo.TRANSFER_BUY,
                  "债权:" + invest.getId() + "购买成功");
              userBillBO.transferIntoBalance(
                  ta.getInvest().getUser().getId(),
                  buyPrice,
                  OperatorInfo.TRANSFER,
                  "债权:" + invest.getId() + "转让成功");
              if (fee > 0.0) {
                sbs.transferInto(fee, OperatorInfo.TRANSFER, "购买债权手续费,编号:" + invest.getId());
                userBillBO.transferOutFromBalance(
                    ta.getInvest().getUser().getId(),
                    fee,
                    OperatorInfo.TRANSFER,
                    "债权转让成功手续费,编号:" + ta.getId());
              }
            } catch (InsufficientBalance e) {
              log.debug("s2sCallback债权转让平台划款时出错!");
              // throw new RuntimeException("债权转让平台划款时出错!");
            }

            ta.setInvest(orignInvest);
            ht.update(invest);
            ht.update(ta);

            double corpusRate = Double.parseDouble(params[1]); // 购买的本金占剩余本金的比例
            generateTransferRepay(
                ta.getInvest().getInvestRepays(), invest, corpusRate); // 生成购买债权后的还款数据,调整之前的还款数据

            /**
             * ***********************************平台操作end*********************************************************
             */
          }

        } else { // 易宝转账确认失败

          to.setStatus(TrusteeshipConstants.Status.REFUSED);
          ht.update(to);

          /**
           * ***********************************平台操作begin**************************************************
           * if(invest != null && ta != null){
           * invest.setStatus(InvestConstants.InvestStatus.CANCEL);
           * ta.setStatus(TransferStatus.TRANSFERING); double buyPrice
           * =Double.parseDouble(params[0]) ;//债权的购买金额 try {
           * userBillBO.unfreezeMoney(invest.getUser().getId(),buyPrice,OperatorInfo.TRANSFER, "债权:"
           * + invest.getId()+ "购买失败"); } catch (InsufficientBalance e) { throw new
           * RuntimeException("购买债权:"+ invest.getId() + "失败,解冻金额时出错!"); } ht.update(invest);
           * ht.update(ta); }
           * ***********************************平台操作end**************************************************
           */
          // throw new YeePayOperationException("债权转让易宝转账确认失败");
        }
      }

    } else { // 验签失败
      log.debug("债权转让验签失败");
    }
  }