Ejemplo n.º 1
0
  /** 浦发支付页面通知接口 */
  @RequestMapping(value = "/frontNotify")
  public String frontNotify(
      HttpServletRequest request,
      HttpServletResponse response,
      Model model,
      RedirectAttributes redirectAttributes) {
    BankReturnBean bankReturnBean = new BankReturnBean();
    String returnUrl = "";
    try {
      // 1 处理网关通知结果
      OperateResult operateResult =
          spdbService.frontNotifyPayment(request, response, bankReturnBean);
      if (!operateResult.isSuccess()) {
        model.addAttribute("message", operateResult.getMessage());
        return "/common/notifyerror";
      }
      // 订单信息获取//把订单号保存到Reference字段,因为传给浦发的订单号与数据库的订单号不一致。由于银行的订单号字段长度与本地不一致。

      Traderecord traderecord =
          traderecordService.getTraderecordSpdb(bankReturnBean.getResponseTrdeNo());
      logger.info("订单信息:" + traderecord);
      if (traderecord == null) {
        model.addAttribute("message", "不存在该订单");
        return "/common/notifyerror";
      }
      traderecord.setTrBankorderno(bankReturnBean.getResponseBankNo());
      traderecord.setTrBankdatetime(new Date());
      traderecord.setTrBanktradetime(bankReturnBean.getResponseTradeTime());
      traderecord.setTrQueryno(bankReturnBean.getResponseBankNo());
      traderecord.setTrBatchno(bankReturnBean.getResponseBatchNo());
      traderecord.setTrBankreturncode(bankReturnBean.getResponseCode());
      traderecord.setTrBankinfo(bankReturnBean.getResponseInfo());
      traderecord.setTrBankcurrency(traderecord.getTrCurrency());
      if (bankReturnBean.getResponseAmount() != null) {
        traderecord.setTrBankamout(new BigDecimal(bankReturnBean.getResponseAmount()));
      } else {
        traderecord.setTrBankamout(traderecord.getTrAmount());
      }
      if (ConstantsBean.TRADE_STATUS_SUCCESS
          == Integer.valueOf(bankReturnBean.getResponseStatus())) {
        traderecord.setTrStatus(1);
      } else if (ConstantsBean.TRADE_STATUS_FAIL
          == Integer.valueOf(bankReturnBean.getResponseStatus())) {
        traderecord.setTrStatus(0);
      } else {
        traderecord.setTrStatus(-2);
      }
      operateResult = traderecordService.saveOrUpdateTraderecord(traderecord);
      if (!operateResult.isSuccess()) {
        model.addAttribute("message", operateResult.getMessage());
        logger.info("更新数据失败 message " + operateResult.getMessage());
        return "/common/notifyerror";
      }
      Gateway gateway =
          gatewayService.getGateway(
              String.valueOf(traderecord.getTrMerNo()), String.valueOf(traderecord.getTrGwNo()));
      if (gateway == null) {
        model.addAttribute("message", "商户信息错误!");
        logger.info("message" + "商户信息错误!");
        return "/common/notifyerror";
      }

      InterfaceUtils.frontNotifyMer(traderecord, gateway, request, response);
      if (StringUtils.isBlank(traderecord.getTrPageReturnurl())) {
        return "common/paySuccess";
      }
    } catch (Exception e) {
      logger.error("错误信息:" + e.getMessage());
      return "/common/notifyerror";
    }

    return "tradeManage/sendtomer";
  }
Ejemplo n.º 2
0
  /** 浦发银行支付服务器通知接口 */
  @RequestMapping(value = "/backNotify")
  public void backNotify(
      HttpServletRequest request,
      HttpServletResponse response,
      Model model,
      RedirectAttributes redirectAttributes) {
    BankReturnBean bankReturnBean = new BankReturnBean();
    String returnUrl = "";
    try {
      /*
      Enumeration enu=request.getParameterNames();
      while(enu.hasMoreElements()){
      String paraName=(String)enu.nextElement();
      logger.info(paraName+": "+request.getParameter(paraName));
      } */

      // 1 处理网关通知结果
      OperateResult operateResult =
          spdbService.backNotifyPayment(request, response, bankReturnBean);

      if (!operateResult.isSuccess()) {
        logger.info(operateResult.getMessage());
        return;
      }

      // 订单信息获取
      Traderecord traderecord =
          traderecordService.getTraderecordSpdb(bankReturnBean.getResponseTrdeNo());
      logger.info("订单信息:" + traderecord);

      if (traderecord == null) {
        logger.info("不存在该订单");
        return;
      }

      traderecord.setTrBankorderno(bankReturnBean.getResponseBankNo());
      traderecord.setTrBankdatetime(new Date());
      traderecord.setTrBanktradetime(bankReturnBean.getResponseTradeTime());
      traderecord.setTrQueryno(bankReturnBean.getResponseBankNo());
      traderecord.setTrBatchno(bankReturnBean.getResponseBatchNo());
      traderecord.setTrBankreturncode(bankReturnBean.getResponseCode());
      traderecord.setTrBankinfo(bankReturnBean.getResponseInfo());
      traderecord.setTrBankcurrency(traderecord.getTrCurrency());
      if (bankReturnBean.getResponseAmount() != null) {
        traderecord.setTrBankamout(new BigDecimal(bankReturnBean.getResponseAmount()));
      } else {
        traderecord.setTrBankamout(traderecord.getTrAmount());
      }
      if (ConstantsBean.TRADE_STATUS_SUCCESS
          == Integer.valueOf(bankReturnBean.getResponseStatus())) {
        traderecord.setTrStatus(1);
      } else if (ConstantsBean.TRADE_STATUS_FAIL
          == Integer.valueOf(bankReturnBean.getResponseStatus())) {
        traderecord.setTrStatus(0);
      } else {
        traderecord.setTrStatus(-2);
      }

      operateResult = traderecordService.saveOrUpdateTraderecord(traderecord);

      if (!operateResult.isSuccess()) {
        logger.info(operateResult.getMessage());
        return;
      }

      Gateway gateway =
          gatewayService.getGateway(
              String.valueOf(traderecord.getTrMerNo()), String.valueOf(traderecord.getTrGwNo()));

      if (gateway == null) {
        logger.info("商户信息错误!");
        return;
      }

      InterfaceUtils.backNotifyMer(traderecord, gateway);

    } catch (Exception e) {
      logger.error(e.getMessage());
    }
  }