Пример #1
0
  public List<HtlB2bIncrease> queryIncreasePrice(
      List<Long> hotelIdParams, List<Long> priceTypeIdParams, Date inDate, Date outDate) {
    StringBuilder sql =
        new StringBuilder(
            " select p.hotel_id,p.room_type_id,p.child_room_type_id,p.base_price,(p.sale_price - p.base_price) as COMMISSION,p.able_sale_date, ");
    sql.append(" i.INCREASE_RATE,p.currency ");
    sql.append(" from hwtemp_htl_price p, b2b_increase i ");
    sql.append(" where p.hotel_id = i.hotel_id ");
    sql.append(" and i.flag =1 ");
    sql.append(" and p.pay_method = 'pre_pay' ");
    sql.append(" and p.able_sale_date >=trunc(?) ");
    sql.append(" and p.able_sale_date <trunc(?) "); // 离店日期 应该只有小于不能等于
    sql.append(" and p.child_room_type_id in ( ");
    for (Long priceTypeIdParam : priceTypeIdParams) {
      sql.append(priceTypeIdParam).append(",");
    }
    sql.setCharAt(sql.length() - 1, ')');
    sql.append(" and p.hotel_id in ( ");
    for (Long hotelIdParam : hotelIdParams) {
      sql.append(hotelIdParam).append(",");
    }
    sql.setCharAt(sql.length() - 1, ')');
    // 这里封装对象
    List<Object[]> objects =
        super.queryByNativeSQL(sql.toString(), new Object[] {inDate, outDate}, null);
    List<HtlB2bIncrease> htlB2bIncreases = new ArrayList<HtlB2bIncrease>();

    for (Object[] obj : objects) {
      HtlB2bIncrease htlB2bIncrease = new HtlB2bIncrease();
      htlB2bIncrease.setHotelId(((BigDecimal) obj[0]).longValue()); // BigDeimal类型 需要转换
      htlB2bIncrease.setRoomTypeId(((BigDecimal) obj[1]).longValue());
      htlB2bIncrease.setPriceTypeId(((BigDecimal) obj[2]).longValue());
      htlB2bIncrease.setBasePrice(((BigDecimal) obj[3]).doubleValue());
      htlB2bIncrease.setCommission(((BigDecimal) obj[4]).doubleValue());
      htlB2bIncrease.setAbleSaleDate((Date) (obj[5]));
      double increaseRate = Double.valueOf(String.valueOf(obj[6]));
      if (increaseRate > 1) { // 设置加幅的是固定金额
        htlB2bIncrease.setIncreasePrice(
            htlB2bIncrease.getBasePrice()
                + increaseRate / CurrencyBean.getRateToRMB(String.valueOf(obj[7])));
        htlB2bIncrease.setCurrency(String.valueOf(obj[7]));
      } else { // 设置加幅的是比例
        htlB2bIncrease.setIncreasePrice(
            htlB2bIncrease.getBasePrice() + htlB2bIncrease.getCommission() * increaseRate);
        htlB2bIncrease.setCurrency(String.valueOf(obj[7]));
      }
      htlB2bIncreases.add(htlB2bIncrease);
    }

    return htlB2bIncreases;
  }
Пример #2
0
  /**
   * 提供给订单校验的接口 需要更改priceList里面的价格和orderitems的价格
   *
   * @param order
   * @return
   */
  public OrOrder modifyOrderIncreasePrice(OrOrder order) {
    long hotelId = order.getHotelId();
    long priceTypeId = order.getChildRoomTypeId();
    Date inDate = order.getCheckinDate();
    Date outDate = order.getCheckoutDate();
    List<Long> hotelIdParams = new ArrayList<Long>();
    hotelIdParams.add(hotelId);
    List<Long> priceTypeIdParams = new ArrayList<Long>();
    priceTypeIdParams.add(priceTypeId);
    List<HtlB2bIncrease> htlB2bIncreases =
        htlB2bDao.queryIncreasePrice(hotelIdParams, priceTypeIdParams, inDate, outDate);
    double sum = 0;
    for (HtlB2bIncrease htlB2bIncrease : htlB2bIncreases) {
      // priceList
      for (OrPriceDetail priceDetail : order.getPriceList()) {
        if (priceDetail.getNight().getTime() == htlB2bIncrease.getAbleSaleDate().getTime()) {
          priceDetail.setBasePrice(htlB2bIncrease.getBasePrice());
          priceDetail.setSalePrice(htlB2bIncrease.getIncreasePrice());
        }
      }
      // orderitems
      for (OrOrderItem orderItem : order.getOrderItems()) {
        if (orderItem.getNight().getTime() == htlB2bIncrease.getAbleSaleDate().getTime()) {
          orderItem.setSalePrice(htlB2bIncrease.getIncreasePrice());
          orderItem.setAgentReadComissionPrice(htlB2bIncrease.getIncreasePrice()); // 设置佣金价
          orderItem.setAgentReadComissionRate(0); // 返佣率设置为0
          orderItem.setAgentReadComission(0); // 佣金额设置为0
        }
      }

      sum += htlB2bIncrease.getIncreasePrice();
    }
    sum = sum * order.getRoomQuantity(); // 注意还需要乘房间数量
    order.setSum(Math.ceil(sum)); // 设置原币种
    if (order.getRateId() == 0) {
      double sumRmb = sum * CurrencyBean.getRateToRMB(order.getPaymentCurrency()); // 设置RMB币种
    }
    double sumRmb = sum * order.getRateId();
    order.setSumRmb(Math.ceil(sumRmb)); // 逢一进十
    return order;
  }
  public static void finishFillCommodity(
      HotelQuotationDTO curComm,
      RoomTypeDTO curRoom,
      HotelInfoDTO curHotel,
      HtlQuotationQueryDTO queryDTO,
      AbstractHotelQueryHandler handler) {

    if (null == curRoom) return;
    /** 1. 判断商品能否预订(每天的情况) 2. 确定商品的直联方式,商品的直联方式暂时取首日的直联方式,完全可以满足当前和未来很长时间的业务需要 3. 商品能否预订 */
    boolean canbook = false;
    boolean isRoomful = false;
    boolean canBookBed[] = {true, true, true};
    StringBuilder cantbookReason = new StringBuilder("");
    String notSatisfyClauseReason = "";
    for (SaleItemDTO curInfo : curComm.getSaleInfoList()) {

      if (curInfo.isRoomful()) {
        isRoomful = true;
      }

      //			if (0 == DateUtil.getDay(curInfo.getAbleDate(), queryDTO.getCheckInDate())) {// 入住首日
      curComm.setHdltype(curInfo.getHdltype());
      //			}

      int nBedType = Integer.parseInt(curInfo.getBedtype()) - 1;

      if (!canBookBed[nBedType]) {
        continue;
      }

      setCanbookPerDay(curInfo, queryDTO); // 每一天能否预订

      if (!curInfo.isBookEnAble()) {
        canBookBed[nBedType] = false;
        String reason = curInfo.getReasonOfDisableBook();
        cantbookReason.append(reason).append(",");
        if (NotBookReason.NotSatisfyClause.equals(reason)) {
          notSatisfyClauseReason = curInfo.getNotsatisfyClauseOfReason();
        }
      }
    }
    StringBuilder bedTypes = new StringBuilder("");
    String bedAll = curComm.getBedAll();
    for (int i = 0; i < canBookBed.length; i++) {
      if (canBookBed[i] && 0 <= bedAll.indexOf("" + (i + 1))) {
        canbook = true;
        bedTypes.append(i + 1).append(",");
      }
    }
    curComm.setCanBook(canbook);
    curComm.setRoomFull(isRoomful);
    if (canbook) {
      bedTypes.deleteCharAt(bedTypes.length() - 1);
      curComm.setBedtype(bedTypes.toString());
    } else {
      curComm.setBedtype(bedAll);
      curComm.setCantbookReason(
          getCantBookReasonByCommodity(cantbookReason.toString(), notSatisfyClauseReason));
    }

    /** 商品是否显示 */
    showCommodity(curComm, curHotel, queryDTO.getFromChannel());

    // 更新该商品所属房型的能否预订属性
    if (!curRoom.isCanbook() && curComm.isCanBook()) {
      curRoom.setCanbook(true);
    }

    // 更新该商品所属房型的最低价和最高价
    double rate = CurrencyBean.getRateToRMB(curComm.getCurrency());
    double minPriceCom = Math.ceil(curComm.getMinPirceRoomType() * rate * 10) / 10;
    double maxPriceCom = Math.ceil(curComm.getMaxPriceRoomType() * rate * 10) / 10;
    if (!curComm.isShow()) { // 如果外网不显示该商品,则该商品就不参与最低价和最高价的计算,与外网一致
      minPriceCom = 0;
      maxPriceCom = 0;
    }

    if (0.1 < minPriceCom) {
      double minPrice = curRoom.getMinPrice();
      if (0.1 < minPrice) {
        if (minPrice > minPriceCom) {
          curRoom.setMinPrice(minPriceCom);
          curRoom.setQuotationId(curComm.getQuotationId());
        }
      } else {
        curRoom.setMinPrice(minPriceCom);
        curRoom.setQuotationId(curComm.getQuotationId());
      }
    }

    if (0.1 < maxPriceCom) {
      double maxPrice = curRoom.getMaxPrice();
      if (0.1 < maxPrice) {
        if (maxPrice < maxPriceCom) {
          curRoom.setMaxPrice(maxPriceCom);
        }
      } else {
        curRoom.setMaxPrice(maxPriceCom);
      }
    }

    // 更新该商品所属房型的是否含早信息
    if (curComm.getBreakfastnumber() > 0 || curComm.getBreakfastnumber() == -1) {
      curRoom.setHasBreakfast(true);
    }

    // 回调结束处理该商品信息
    CommoditySummaryDTO curComSummary = new CommoditySummaryDTO();
    curComSummary.setMinPirceRoomType(minPriceCom);
    curComSummary.setMaxPriceRoomType(maxPriceCom);
    curComSummary.setHdltype(curComm.getHdltype());
    curComSummary.setShow(curComm.isShow());
    curComSummary.setCanBook(curComm.isCanBook());
    curComSummary.setCantbookReason(curComm.getCantbookReason());
    if (!curComSummary.isRoomful()) {
      curComSummary.setRoomful(curComm.isRoomFull());
    }
    curComSummary.setBedType(curComm.getBedtype());
    //		curComSummary.setBandInfo(curComm.isFreeNet() ? "免费" : (curRoom.isHasNet() ? "收费" : "无"));//
    // 是否含宽带
    curComSummary.setBandInfo(
        curRoom.isHasNet() ? (curComm.isFreeNet() ? "免费" : "收费") : "无"); // 是否含宽带
    curRoom.setHdltype(
        HotelHandlerUtil.hdlTypeTransformation(curRoom.getHdltype(), curComSummary.getHdltype()));
    handler.endHandleQuotation(curComSummary);
  }