Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
  @Transactional
  private OrderBean addTradeOrder(OrderSubmitParam param, Timestamp curtime) {
    log.info("OTA下单,StandardService参数适配结果:" + JSON.toJSONString(param));

    OrderBean orderBean = param.getOrderBean();
    OrderBeanExample example = new OrderBeanExample();
    example
        .createCriteria()
        .andThirdTradeNoEqualTo(orderBean.getThirdTradeNo())
        .andOrderChannelEqualTo(orderBean.getOrderChannel());
    if (orderBeanMapper.countByExample(example) > 0) {
      log.error("订单已存在,不可重复下单。");
      throw new TradeException(
          new ReturnCode() {
            @Override
            public String getMessage() {
              return QunarErrorCode.CANNOT_CREATE_THE_SAME_ORDER.name();
            }

            @Override
            public int getCode() {
              return QunarErrorCode.CANNOT_CREATE_THE_SAME_ORDER.code();
            }
          });
    }

    TradeThirdOrder thirdOrderBean = param.getThirdOrderBean();
    orderBean.setPriceBase(thirdOrderBean.getPrice());
    orderBean.setPriceChannel(thirdOrderBean.getPrice());
    orderBean.setPriceGuide(thirdOrderBean.getPrice());
    orderBean.setPriceGuideBase(thirdOrderBean.getPrice());
    orderBean.setPriceTicket(thirdOrderBean.getPrice());
    orderBean.setCreateTime(curtime);
    orderBean.setUpdateTime(curtime);
    orderBean.setCheckInPrice(
        orderBean.getCheckInPrice() == null ? 0.0 : orderBean.getCheckInPrice());
    String flightCode =
        orderBean.getFlightAirportCode() == null
            ? orderBean.getFlightDestCode()
            : orderBean.getFlightAirportCode();
    AirportBean airportBean = controllerService.getAirportByCode(flightCode); // validated
    orderBean.setServiceCityId(airportBean.getCityId());
    orderBean.setOrderSource(OrderSource.OTA.value);
    String orderNo = orderService.addOrderProccess(orderBean); // validated
    orderBean.setOrderNo(orderNo);
    log.info("OTA新订单下单成功,结果OrderBean:" + JSON.toJSONString(orderBean));
    return orderBean;
  }