/**
   * 构造订单时需要凭证对象和履行对象,避免service内部调用远程方法 此serviceImpl是代理类
   *
   * @param buyInfo
   * @param bcertTargetMap
   * @param performTargetMap
   */
  private void buildMetaProductId(
      BuyInfo buyInfo,
      Map<Long, SupBCertificateTarget> bcertTargetMap,
      Map<Long, List<SupPerformTarget>> performTargetMap,
      Map<Long, OrdOrderItemMeta> ordOrderItemMateMap) {
    Map<Item, List<ProdProductBranchItem>> branchItemMap =
        this.buildOrderService.buildProductBranchItem(buyInfo);
    List<SupPerformTarget> performTargetList = null;
    List<SupBCertificateTarget> bcertTargetList = null;
    for (Item item : branchItemMap.keySet()) {
      List<ProdProductBranchItem> branchItemList = branchItemMap.get(item);
      for (ProdProductBranchItem branchItem : branchItemList) {
        bcertTargetList =
            this.bCertificateTargetService.selectSuperMetaBCertificateByMetaProductId(
                branchItem.getMetaProductId());
        if (bcertTargetList != null && bcertTargetList.size() > 0) {
          bcertTargetMap.put(branchItem.getMetaProductId(), bcertTargetList.get(0));
        }
        performTargetList =
            this.performTargetService.findSuperSupPerformTargetByMetaProductId(
                branchItem.getMetaProductId());
        if (performTargetList != null && performTargetList.size() > 0) {
          performTargetMap.put(branchItem.getMetaProductId(), performTargetList);
        }

        initOrdOrderItemMeta(ordOrderItemMateMap, branchItem, item.getVisitTime());
        // 初始化机票相关信息
        initFlightInfo(ordOrderItemMateMap, branchItem, item.getVisitTime());
      }
    }
  }
  /**
   * 初始化机票相关信息
   *
   * @param ordOrderItemMateMap
   * @param branchItem
   */
  private void initFlightInfo(
      Map<Long, OrdOrderItemMeta> ordOrderItemMateMap,
      ProdProductBranchItem branchItem,
      Date visitTime) {

    MetaProduct metaProduct = metaProductDAO.getMetaProductByPk(branchItem.getMetaProductId());

    if (Constant.PRODUCT_TYPE.TRAFFIC.name().equals(metaProduct.getProductType())) { // 交通

      if (Constant.SUB_PRODUCT_TYPE.FLIGHT.name().equals(metaProduct.getSubProductType())) { // 机票	

        MetaProductTraffic metaProductTraffic =
            (MetaProductTraffic)
                metaProductDAO.getMetaProduct(
                    branchItem.getMetaProductId(), Constant.PRODUCT_TYPE.TRAFFIC.name());

        if (null != metaProductTraffic) {

          OrdOrderItemMeta ordOrderItemMeta = new OrdOrderItemMeta();
          ordOrderItemMeta.setVisitTime(visitTime);
          ordOrderItemMeta.setDirection(metaProductTraffic.getDirection());

          PlaceFlight placeFlight =
              placeFlightService.queryPlaceFlight(metaProductTraffic.getGoFlight());

          if (null != placeFlight) {
            ordOrderItemMeta.setGoFlightCode(placeFlight.getFlightNo());
            if (StringUtils.isNotBlank(placeFlight.getStartTime())) {
              // 去的航班时间=(去玩的日期+起飞时间)
              String time = ordOrderItemMeta.getVisitTimeDay() + " " + placeFlight.getStartTime();
              ordOrderItemMeta.setGoFlightTime(DateUtil.getDateByStr(time, "yyyy-MM-dd HH:mm"));
            }
          }

          if (Constant.TRAFFIC_DIRECTION.ROUND.name().equals(metaProductTraffic.getDirection())
              && null != metaProductTraffic.getBackFlight()) { // 往返
            placeFlight = placeFlightService.queryPlaceFlight(metaProductTraffic.getBackFlight());
            if (null != placeFlight) {
              ordOrderItemMeta.setBackFlightCode(placeFlight.getFlightNo());
              if (StringUtils.isNotBlank(placeFlight.getStartTime())) {
                // 返回的航班时间=(去玩的日期+玩的天数)+起飞时间-1天
                Date temp =
                    DateUtil.dsDay_Date(
                        ordOrderItemMeta.getVisitTime(),
                        metaProductTraffic.getDays().intValue() - 1);
                String time =
                    DateUtil.getDateTime("yyyy-MM-dd", temp) + " " + placeFlight.getStartTime();
                ordOrderItemMeta.setBackFlightTime(DateUtil.getDateByStr(time, "yyyy-MM-dd HH:mm"));
              }
            }
          }

          ordOrderItemMateMap.put(branchItem.getMetaProductId(), ordOrderItemMeta);
        }
      }
    }
  }
  /**
   * 初始OrdOrderItemMeta相关信息
   *
   * @param ordOrderItemMateMap
   * @param branchItem
   */
  private void initOrdOrderItemMeta(
      Map<Long, OrdOrderItemMeta> ordOrderItemMateMap,
      ProdProductBranchItem branchItem,
      Date visitTime) {
    TimePrice timePrice =
        metaTimePriceDAO.getMetaTimePriceByIdAndDate(branchItem.getMetaBranchId(), visitTime);

    OrdOrderItemMeta ordOrderItemMeta = new OrdOrderItemMeta();
    ordOrderItemMeta.setSettlementPrice(timePrice.getSettlementPrice());
    ordOrderItemMateMap.put(branchItem.getMetaProductId(), ordOrderItemMeta);
  }