Example #1
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;
  }
Example #2
0
  public CTripCalculatePriceResult getPrice(CalculatePriceParam param) {

    CTripCalculatePriceResult result = new CTripCalculatePriceResult();
    param.setCarTypeId(
        CarTypeContext.getInstance()
            .buildCarTypeForPricing(param.getCarTypeId(), CTripCarAdaptor.getInstance()));
    OrderPriceInfo data = otaOrderService.getPrice(param);
    if (data == null) {
      result.MsgCode = "ERROR";
      result.Message = "无报价信息";
      return result;
    }

    String priceMark = "0"; // default
    Integer urgentFlag = UrgentFlag.nomal.value; // default
    List<OrderPriceInfoQuoteVo> cars = data.getCars();
    if (cars != null && cars.size() > 0) {
      boolean hasNotPriceMark = true;
      Boolean supportBanner = data.getSupportBanner();
      Boolean supportChildseat = data.getSupportChildseat();

      // 拿齐所有在适配器里的车型
      List<CTripCalculatePriceDetail> queryResultList = new LinkedList<>();
      CTripCalculatePriceDetail taxi = null;
      for (int i = 0; i < cars.size(); i++) {
        OrderPriceInfoQuoteVo quoteVo = cars.get(i);
        CTripCalculatePriceDetail detail = new CTripCalculatePriceDetail();
        detail.IsSupportChildSeat = supportChildseat;
        detail.IsSupportPickup = supportBanner;
        detail.Price = quoteVo.getPrice();
        if (hasNotPriceMark) {
          urgentFlag = quoteVo.getUrgentFlag(); // 2015-12-19: v1.0同一个值
          priceMark = quoteVo.getPricemark(); // 2015-12-19: v1.0接送次都能保证所有priceMark是同一个值
          hasNotPriceMark = false;
        }

        // 适配车型
        int seatCategory = quoteVo.getSeatCategory();
        int carType = quoteVo.getCarType();
        List<Integer> carTypeList =
            CarTypeContext.getInstance()
                .toThirdCarType(carType, seatCategory, CTripCarAdaptor.getInstance());
        if (carTypeList != null && carTypeList.size() > 0) {
          // 如果是携程出租车车型(17)直接忽略
          if (carTypeList.get(0) == 17) {
            continue;
          }
          detail.VehicleType = carTypeList.get(0);
          // 如果是经济5座(1_5)的车型,记录到出租车(携程出租车 17)
          if (carType == 1 && seatCategory == 5) {
            taxi = new CTripCalculatePriceDetail();
            taxi.IsSupportChildSeat = supportChildseat;
            taxi.IsSupportPickup = supportBanner;
            taxi.Price = detail.Price;
            taxi.VehicleType = 17; // 携程出租车
          }
          queryResultList.add(detail);
        }
      }

      // 如果城市是曼谷(cityId=230)需要增加出租车报价,价格按照经济5座处理
      AirportBean airportBean = lcontrollerService.getAirportByCode(param.getFlightAirportCode());
      if (taxi != null && new Integer(230).equals(airportBean.getCityId())) {
        queryResultList.add(taxi);
      }
      result.QueryResultList = queryResultList;
    } else {
      result.MsgCode = "ERROR";
      result.Message = "无报价信息";
      return result;
    }
    result.Distance = data.getDistance(); // TODO 第二版
    result.EstTime = data.getEstTime(); // TODO 第二版
    result.PriceMark = priceMark; // TODO 第二版
    result.UrgentFlag = urgentFlag; // TODO 第二版
    logger.info("查价Service层返回:" + JSON.toJSONString(result));
    return result;
  }