private void SetPriceDetail(AirMatrixFlightMeta.Price price, AirMaterial currentFlight) { price.TotalPrice = GetTotalPrice(currentFlight); price.BaseFare = currentFlight.AdultBaseFare + currentFlight.AdultMarkup; }
private void SetLowerPrice(AirMaterial currentFlight, AirMatrixFlightMeta currentMatrix) { int currentStops = 0; MatrixStopType stopType = MatrixStopType.All; //�жϸ�Flight�ж���Stop currentStops = GetFlightStops(currentFlight); stopType = GetMatrixStopType(currentStops); switch (currentStops) { case 0: SetLowerPriceDetail(currentMatrix.ZeroStopPrice, currentFlight); break; case 1: SetLowerPriceDetail(currentMatrix.OneStopPrice, currentFlight); break; default: SetLowerPriceDetail(currentMatrix.MoreThanTwoStopPrice, currentFlight); break; } currentMatrix.AddFlight(currentFlight, stopType); AirMatrixFlightsByStop.AddFlight(currentFlight, stopType); }
private void SetLowerPriceDetail(AirMatrixFlightMeta.Price price, AirMaterial currentFlight) { if (price.BaseFare == 0) { price.TotalPrice = GetTotalPrice(currentFlight); price.BaseFare = currentFlight.AdultBaseFare + currentFlight.AdultMarkup; } else if (IsCurrentPriceLower(price, currentFlight)) { price.TotalPrice = GetTotalPrice(currentFlight); price.BaseFare = currentFlight.AdultBaseFare + currentFlight.AdultMarkup; } }
private void SetAirLine(AirMaterial currentFlight, AirMatrixFlightMeta currentMatrix) { if (flightInfohider.IsNeedToHide(currentFlight)) { Airline airLine = new Airline(); airLine.Code = flightInfohider.ReplaceFlightCode(currentFlight); airLine.Name = flightInfohider.ReplaceFlightName(currentFlight); airLine.LogoUrl = LOGO_DEFAULT; currentMatrix.AirLine = airLine; } else { currentMatrix.AirLine = ((AirProfile)currentFlight.Profile).Airlines[0]; } }
private void SetLowerFarePrice(AirMaterial currentFlight, AirMatrixFlightMeta currentMatrix) { if (currentMatrix.LowFareSelectPrice.BaseFare == 0 || (currentFlight.AdultBaseFare + currentFlight.AdultMarkup) < currentMatrix.LowFareSelectPrice.BaseFare) { SetPriceDetail(currentMatrix.LowFareSelectPrice, currentFlight); } }
private bool IsCurrentPriceLower(AirMatrixFlightMeta.Price price, AirMaterial currentFlight) { decimal currentTotalPrice = 0; currentTotalPrice = GetTotalPrice(currentFlight); if (currentTotalPrice == price.TotalPrice) { return currentFlight.AdultBaseFare < price.BaseFare; } return GetTotalPrice(currentFlight) < price.TotalPrice; }
private bool IsAirLineExist(AirMaterial currentFlight, List<AirMatrixFlightMeta> matrixList,ref AirMatrixFlightMeta currentMatrix) { string currentAirLineCode = string.Empty; if (flightInfohider.IsNeedToHide(currentFlight)) { currentAirLineCode = flightInfohider.ReplaceFlightCode(currentFlight); } else { currentAirLineCode = ((AirProfile)(currentFlight.Profile)).Airlines[0].Code; } for (int matrixIndex = 0; matrixIndex < matrixList.Count; matrixIndex++) { if (matrixList[matrixIndex].AirLine.Code == currentAirLineCode) { currentMatrix = matrixList[matrixIndex]; return true; } } return false; }
private int CompareMatrixPrice(AirMatrixFlightMeta matrixFrom, AirMatrixFlightMeta matrixTo) { int compareResult = 0; //if (matrixFrom.ZeroStopPrice.TotalPrice != matrixTo.ZeroStopPrice.TotalPrice && matrixFrom.ZeroStopPrice.TotalPrice != 0) //{ // compareResult = matrixFrom.ZeroStopPrice.TotalPrice.CompareTo(matrixTo.ZeroStopPrice.TotalPrice); //} //else if (matrixFrom.ZeroStopPrice.BaseFare != matrixTo.ZeroStopPrice.BaseFare) //{ // compareResult = matrixFrom.ZeroStopPrice.BaseFare.CompareTo(matrixTo.ZeroStopPrice.BaseFare); //} //else //{ // if (matrixFrom.OneStopPrice.TotalPrice != matrixTo.OneStopPrice.TotalPrice && matrixFrom.OneStopPrice.TotalPrice != 0) // { // compareResult = matrixFrom.OneStopPrice.TotalPrice.CompareTo(matrixTo.OneStopPrice.TotalPrice); // } // else if (matrixFrom.OneStopPrice.BaseFare != matrixTo.OneStopPrice.BaseFare) // { // compareResult = matrixFrom.OneStopPrice.BaseFare.CompareTo(matrixTo.OneStopPrice.BaseFare); // } // else // { // if (matrixFrom.MoreThanTwoStopPrice.TotalPrice != matrixTo.MoreThanTwoStopPrice.TotalPrice && matrixFrom.MoreThanTwoStopPrice.TotalPrice != 0) // { // compareResult = matrixFrom.MoreThanTwoStopPrice.TotalPrice.CompareTo(matrixTo.MoreThanTwoStopPrice.TotalPrice); // } // else if (matrixFrom.OneStopPrice.BaseFare != matrixTo.OneStopPrice.BaseFare) // { // compareResult = matrixFrom.MoreThanTwoStopPrice.BaseFare.CompareTo(matrixTo.MoreThanTwoStopPrice.BaseFare); // } // else // { // } // } //} compareResult = matrixFrom.LowestPrice.ComparedPrice.CompareTo(matrixTo.LowestPrice.ComparedPrice); if (compareResult == 0) { compareResult = matrixFrom.LowFareSelectPrice.ComparedPrice.CompareTo(matrixTo.LowFareSelectPrice.ComparedPrice); } return compareResult; }
private List<AirMatrixFlightMeta> AddSelectLowFareToList(List<AirMatrixFlightMeta> matrixList, List<Component> flightList) { AirMatrixFlightMeta currentMatrix; AirMaterial currentFlight; int selectFlightCount = 0; //����ͼ۸����� matrixList = GetSortedByPriceMatrixList(matrixList); if (matrixList.Count > MAX_MATRIX_COUNT) { matrixList.RemoveRange(MAX_MATRIX_COUNT, matrixList.Count - MAX_MATRIX_COUNT); } for (int flightIndex = 0; flightIndex < flightList.Count; flightIndex++) { currentFlight = (AirMaterial)flightList[flightIndex]; currentMatrix = new AirMatrixFlightMeta(); if (IsAirLineExist(currentFlight, matrixList,ref currentMatrix)) { SetLowerFarePrice(currentFlight, currentMatrix); } else { SetAirLine(currentFlight, currentMatrix); SetLowerFarePrice(currentFlight,currentMatrix); if (matrixList.Count >= MAX_MATRIX_COUNT) { matrixList.RemoveAt(MAX_MATRIX_COUNT - 1 - selectFlightCount); } matrixList.Add(currentMatrix); selectFlightCount++; if (selectFlightCount == MAX_SelectFlightCount) { break; } } } //����ͼ۸����� matrixList = GetSortedByPriceMatrixList(matrixList); matrixList = GetFilteredMatrixList(matrixList); return matrixList; }
public List<AirMatrixFlightMeta> EditFlightsToAirMatrixStyle(List<Component> flightList) { AirMaterial currentFlight = null; AirMatrixFlightMeta currentMatrix = null; string currentAirLineCode = string.Empty; string preAirLineCode = string.Empty; List<Component> sortedByAirLineFlightList = null; List<AirMatrixFlightMeta> matrixList = new List<AirMatrixFlightMeta>(); //��flightList��AirLine���� sortedByAirLineFlightList = GetSortedByAirLineFlightList(flightList); //flightList.Sort( //currentFlight.co for (int flightIndex = 0; flightIndex < sortedByAirLineFlightList.Count; flightIndex++) { currentFlight = (AirMaterial)sortedByAirLineFlightList[flightIndex]; if (IsFirstFligt(flightIndex)) { currentMatrix = new AirMatrixFlightMeta(); SetAirLine(currentFlight, currentMatrix); SetFirstPrice(currentFlight, currentMatrix); } else { if (flightInfohider.IsNeedToHide(currentFlight)) { currentAirLineCode = flightInfohider.ReplaceFlightCode(currentFlight); } else { currentAirLineCode = ((AirProfile)(currentFlight.Profile)).Airlines[0].Code; } preAirLineCode = currentMatrix.AirLine.Code; if (IsAirLineChanged(currentAirLineCode, preAirLineCode)) { matrixList.Add(currentMatrix); currentMatrix = new AirMatrixFlightMeta(); SetAirLine(currentFlight, currentMatrix); SetFirstPrice(currentFlight, currentMatrix); } else { SetLowerPrice(currentFlight, currentMatrix); } } if (flightIndex == flightList.Count - 1) { matrixList.Add(currentMatrix); } } return matrixList; }