Exemplo n.º 1
0
  private List<TradeRefund> msgHandle(String msg) {
    AliRefundNotifyParam refundNotifyParam = JSON.parseObject(msg, AliRefundNotifyParam.class);
    String batchNo = refundNotifyParam.getBatch_no();
    String redetail = refundNotifyParam.getResult_details();
    int succesNum = Integer.parseInt(refundNotifyParam.getSuccess_num());

    String[] reundStrs = redetail.split(";");
    List<TradeRefund> refundList = new ArrayList<TradeRefund>();
    for (String refundStr : reundStrs) {
      String[] refundInfos = refundStr.split("\\^");
      if (refundInfos.length == 3) {
        String tradeNo = refundInfos[0];
        double refundMoney = Double.parseDouble(refundInfos[1]);
        String refundResult = refundInfos[2];

        TradePayment tradePayment = paymentService.queryByTradeNo(tradeNo);
        TradeRefund tradeRefund =
            notifyRefundService.queryRefundByBathNOOrderNo(
                tradePayment.getPayNo(), tradePayment.getOrderNo());
        if ("SUCCESS".equalsIgnoreCase(refundResult)) {
          if (!tradeRefund.getRefundMoney().equals(refundMoney)) {
            tradeRefund.setRefundError("退款通知 金额 [" + refundMoney + "] 和 退款金额不等 ");
          }
          RefundStatus refundStatus = RefundStatus.getType(tradeRefund.getRefundStatus());
          if (refundStatus.equals(RefundStatus.UNKNOWN)) {
            tradeRefund.setRefundStatus(RefundStatus.SUCCESS.value);
          } else {
            log.warn(tradeRefund.getRefundNo() + " 退款状态可能异常" + refundStatus + " ");
            tradeRefund.setRefundStatus(RefundStatus.SUCCESS.value);
          }
          tradeRefund.setRefundResponse(msg);
          refundList.add(tradeRefund);
        } else {
          log.info(tradePayment.getOrderNo() + "支付宝 退款 失败 " + msg);
        }
      } else {
        log.error("支付宝 退款 格式错误 " + msg);
      }
    }

    return refundList;
  }
Exemplo n.º 2
0
  @Transactional
  public void payByOnlyCoup(OrderBean orderBean, CoupParm coupParm) {
    couponServiceParty.lockCoup(orderBean.getOrderNo(), coupParm.getCoupId());
    couponServiceParty.useCoup(coupParm.getCoupId(), orderBean.getOrderNo());
    orderService.updateOrderStatus(
        orderBean.getOrderNo(), OrderStatus.INITSTATE, OrderStatus.PAYSUCCESS);

    OrderType orderType = OrderType.getType(orderBean.getOrderType());
    BizType bizType = FundBizEnumConvter.getFundBizType(orderType);

    TradePayment tradePayment = new TradePayment();
    Date curtime = new Date(System.currentTimeMillis());
    tradePayment.setCreateTime(curtime);
    tradePayment.setOrderNo(orderBean.getOrderNo());
    tradePayment.setOrderPrice(orderBean.getPriceChannel());
    tradePayment.setPayActual(0.00d);
    tradePayment.setPayFee(0.00d);
    tradePayment.setPayNo(IDGenerotor.generatePayNo());
    tradePayment.setPaySubject("HBC券支付");
    tradePayment.setPayShould(orderBean.getPriceChannel());
    tradePayment.setPayGetway(GetWayEnum.COUP.value);
    tradePayment.setPayGatewayName(GetWayEnum.COUP.name);
    tradePayment.setUserAccountNo(orderBean.getUserAccount());
    tradePayment.setCoupId(coupParm.getCoupId());
    tradePayment.setCoupPay(
        DoubleUtil.subtractionDouble(orderBean.getPriceChannel(), coupParm.getcActualPrice()));
    tradePayment.setCouponInfo(coupParm.getCoupInfo());
    tradePayment.setPayStatus(PayStatus.SUCCESS.value);
    if (tradePaymentMapper.insert(tradePayment) == 0) {
      throw new PayException(PayReturnCodeEnum.PAY_INSERT_FAILED, orderBean.getOrderNo());
    }

    orderService.updateCoupInfos(orderBean, coupParm.getCoupId(), tradePayment);

    fundAccountService.pay(
        AccountEnums.HBC_COUP.value, tradePayment.getCoupPay(), bizType, orderBean.getOrderNo());
    fundAccountService.pay(
        AccountEnums.HBC_Guarantee.value,
        orderBean.getPriceChannel(),
        bizType,
        orderBean.getOrderNo());

    OrderLogParamBean orderLogParamBean = new OrderLogParamBean();
    orderLogParamBean.setContent(
        OrderLogType.PAYMENT_RESULT_CONTENT(
            orderBean.getAgentName(),
            orderBean.getUserName(),
            coupParm.getCoupId(),
            JSON.toJSONString(coupParm)));
    orderLogParamBean.setLogType(OrderLogType.PAYMENT_RESULT.type);
    orderLogParamBean.setOpType(OperationType.CUSTOMER.value);
    orderLogParamBean.setOpUserId(orderBean.getUserId());
    orderLogParamBean.setOpUserName(orderBean.getUserName());
    orderLogParamBean.setOrderNo(orderBean.getOrderNo());
    orderLogService.insertOrderLog(orderLogParamBean);
  }