Пример #1
0
        /// <summary>
        /// 获取酒店最低价格
        /// </summary>
        /// <param name="hotelIds"></param>
        public static OTA_HotelRatePlanReturnEntity GetHotelRoomPrice(List<int> hotelIds, bool availRatesOnlyInd, DateTime startDt, DateTime endDt)
        {
            OTA_HotelRatePlanCallEntity callEntity = new OTA_HotelRatePlanCallEntity();
            List<HotelRatePlanRQ> ratePlans = new List<HotelRatePlanRQ>();
            var items = from it in hotelIds
                        let ratePlan = new HotelRatePlanRQ() { AvailRatesOnlyInd = availRatesOnlyInd, StartDate = startDt, EndDate = endDt, HotelCode = it }
                        select ratePlan;

            callEntity.HotelRatePlanList = items.ToList();
            var rep = hotelOTAService.OTA_HotelRatePlan(callEntity);
            return rep;
        }
Пример #2
0
        public static bool HotelRealTimeRoomRatePlanInfo(int hotelID, int roomTypeCode)
        {
            OTA_HotelRatePlanCallEntity callEntity = new OTA_HotelRatePlanCallEntity();
            var ratePlansRQ = new HotelRatePlanRQ();
            ratePlansRQ.AvailRatesOnlyInd = true;
            ratePlansRQ.HotelCode = hotelID;
            ratePlansRQ.StartDate = DateTime.Now.Date;
            callEntity.HotelRatePlanList = new List<HotelRatePlanRQ>() { ratePlansRQ };
            var rep = hotelOTAService.OTA_HotelRatePlan(callEntity);

            return true;
        }
Пример #3
0
        /// <summary>
        /// 根据查询条件查询可用的Rate Plan,包括房价、可卖渠道。通常用于双方系统保持一致性
        /// 参数Start,End,HotelCode为必填;参数AvailRatesOnlyInd为空时值为false
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public OTA_HotelRatePlanReturnEntity OTA_HotelRatePlan(OTA_HotelRatePlanCallEntity req)
        {
            var rep = new OTA_HotelRatePlanReturnEntity();
            try
            {
                StringBuilder reqXml = new StringBuilder("<ns:OTA_HotelRatePlanRQ TimeStamp=\"2013-06-01T00:00:00.000+08:00\" Version=\"1.0\">");
                reqXml.Append("<ns:RatePlans>");
                foreach (var item in req.HotelRatePlanList)
                {
                    reqXml.Append("<ns:RatePlan>");
                    reqXml.AppendFormat("<ns:DateRange Start=\"{0}\" End=\"{1}\"/>", item.StartDate.ToString("yyyy-MM-dd"), item.EndDate.ToString("yyyy-MM-dd"));
                    reqXml.Append("<ns:RatePlanCandidates>");
                    reqXml.AppendFormat("<ns:RatePlanCandidate AvailRatesOnlyInd=\"{0}\" >", item.AvailRatesOnlyInd.ToString().ToLower());
                    reqXml.Append("<ns:HotelRefs>");
                    reqXml.AppendFormat("<ns:HotelRef HotelCode=\"{0}\"/>", item.HotelCode);
                    reqXml.Append("</ns:HotelRefs>");
                    reqXml.Append("</ns:RatePlanCandidate>");
                    reqXml.Append("</ns:RatePlanCandidates>");
                    reqXml.Append("<ns:TPA_Extensions RestrictedDisplayIndicator=\"false\"/>");
                    reqXml.Append("</ns:RatePlan>");
                }
                reqXml.Append("</ns:RatePlans>");
                reqXml.Append("</ns:OTA_HotelRatePlanRQ>");

                req.RequestContent = reqXml.ToString();
                string repXml = HotelApiCall(req);
                //LogHelper.Debug(repXml);
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(repXml);
                GetHeaderResult(xmlDoc, rep);
                var hotelRatePlanNodes = xmlDoc.SelectNodes("Response/HotelResponse/OTA_HotelRatePlanRS/RatePlans");
                List<HotelRatePlan> hotelRatePlanList = new List<HotelRatePlan>();

                HotelRatePlan ratePlan = null;

                foreach (XmlNode hp in hotelRatePlanNodes)
                {
                    ratePlan = new HotelRatePlan();
                    ratePlan.HotelCode = ((XmlElement)hp).GetAttribute("HotelCode").Trim().ToInt32();
                    var roomRatePlanNodes = hp.SelectNodes("RatePlan");
                    List<RoomRatePlan> roomRatePlanList = new List<RoomRatePlan>();
                    RoomRatePlan roomRatePlan = null;
                    foreach (XmlNode rp in roomRatePlanNodes)
                    {
                        roomRatePlan = new RoomRatePlan();

                        XmlNode desNode = rp.SelectSingleNode("Description/Text");
                        if (desNode != null)
                        {
                            roomRatePlan.Description = desNode.InnerText.Trim();
                        }
                        roomRatePlan.MarketCode = ((XmlElement)rp).GetAttribute("MarketCode").Trim().ToInt32();
                        roomRatePlan.RatePlanCategory = ((XmlElement)rp).GetAttribute("RatePlanCategory").Trim().ToInt32();
                        roomRatePlan.HotelRoomCode = ((XmlElement)rp).GetAttribute("RatePlanCode").Trim().ToInt32();
                        
                        var SellableProductNodes = rp.SelectNodes("SellableProducts/SellableProduct");
                        List<string> sellableProductList = new List<string>();
                        if (SellableProductNodes != null)
                        {
                            foreach (XmlNode n in SellableProductNodes)
                            {
                                sellableProductList.Add(((XmlElement)n).GetAttribute("InvCode").Trim());
                            }
                        }
                        roomRatePlan.SellableProductList = sellableProductList;

                        List<RoomRate> roomRateList = new List<RoomRate>();
                        var roomRateNodes = rp.SelectNodes("Rates/Rate");
                        RoomRate roomRate = null;
                        foreach (XmlNode rn in roomRateNodes)
                        {
                            roomRate = new RoomRate();
                            roomRate.StartTime = ((XmlElement)rn).GetAttribute("Start").Trim().ToDateTime();
                            roomRate.EndTime = ((XmlElement)rn).GetAttribute("End").Trim().ToDateTime();
                            roomRate.Status = ((XmlElement)rn).GetAttribute("Status").Trim();
                            roomRate.IsInstantConfirm = ((XmlElement)rn).GetAttribute("IsInstantConfirm").Trim()=="false"?0:1;

                            XmlElement baseByGuestAmtNode = (XmlElement)rn.SelectSingleNode("BaseByGuestAmts/BaseByGuestAmt");
                            roomRate.AmountBeforeTax = baseByGuestAmtNode.GetAttribute("AmountBeforeTax").Trim().ToDecimal();
                            roomRate.CurrencyCode = baseByGuestAmtNode.GetAttribute("CurrencyCode").Trim();
                            roomRate.NumberOfGuests = baseByGuestAmtNode.GetAttribute("NumberOfGuests").Trim().ToInt32();
                            string listprice = baseByGuestAmtNode.GetAttribute("ListPrice").Trim();

                            if (!string.IsNullOrEmpty(listprice))
                            {
                                roomRate.ListPrice = listprice.ToDecimal();
                            }

                            XmlNode CancelPenaltyNode = rn.SelectSingleNode("CancelPolicies/CancelPenalty");

                            if(CancelPenaltyNode!=null)
                            {
                                roomRate.CancelPenaltyStartTime = ((XmlElement)CancelPenaltyNode).GetAttribute("Start").Trim().ToDateTime();
                                roomRate.CancelPenaltyEndTime = ((XmlElement)CancelPenaltyNode).GetAttribute("End").Trim().ToDateTime();

                                XmlNode AmountPercentNode = CancelPenaltyNode.SelectSingleNode("AmountPercent");
                                roomRate.CancelAmount = ((XmlElement)AmountPercentNode).GetAttribute("Amount").Trim().ToDecimal();
                                roomRate.CancelCurrencyCode = ((XmlElement)AmountPercentNode).GetAttribute("CurrencyCode").Trim();

                                XmlElement GuaranteePolicyEle = (XmlElement)rn.SelectSingleNode("GuaranteePolicies/GuaranteePolicy");
                                if(GuaranteePolicyEle!=null)
                                {
                                    
                                    roomRate.GuaranteeCode = GuaranteePolicyEle.GetAttribute("GuaranteeCode").Trim();
                                    roomRate.HoldTime = GuaranteePolicyEle.GetAttribute("HoldTime").Trim();
                                }
                                
                            }
                            else
                            {
                                roomRate.CancelPenaltyStartTime = DateTime.Parse("1900-1-1");
                                roomRate.CancelPenaltyEndTime = DateTime.Parse("1900-1-1");
                                roomRate.CancelAmount = 0;
                                roomRate.CancelCurrencyCode = "";
                                roomRate.GuaranteeCode = "";
                                roomRate.HoldTime = "1900-1-1";
                            }

                            
                            XmlElement MealsIncludedEle = (XmlElement)rn.SelectSingleNode("MealsIncluded");
                            roomRate.Breakfast = MealsIncludedEle.GetAttribute("Breakfast").Trim();
                            roomRate.NumberOfBreakfast = MealsIncludedEle.GetAttribute("NumberOfBreakfast").Trim().ToInt32();


                            List<Pertain> pertainList = new List<Pertain>();
                            var feeNodes = rn.SelectNodes("Fees/Fee");
                            Pertain pertain = null;
                            foreach (XmlNode fn in feeNodes)
                            {
                                pertain = new Pertain();
                                pertain.Amount = ((XmlElement)fn).GetAttribute("Amount").Trim().ToDecimal();
                                pertain.ChargeUnit = ((XmlElement)fn).GetAttribute("ChargeUnit").Trim();
                                pertain.CurrencyCode = ((XmlElement)fn).GetAttribute("CurrencyCode").Trim();
                                pertain.Code = ((XmlElement)fn).GetAttribute("Code").Trim();
                                pertain.Description = fn.SelectSingleNode("Description/Text").InnerText.Trim();
                                pertainList.Add(pertain);
                            }

                            roomRate.PertainList = pertainList;

                            XmlNode RebatePromotionNode = rn.SelectSingleNode("TPA_Extensions/RebatePromotion");
                            if (RebatePromotionNode != null)
                            {
                                roomRate.StartPeriod = ((XmlElement)RebatePromotionNode).GetAttribute("StartPeriod").Trim().ToDateTime();
                                roomRate.EndPeriod = ((XmlElement)RebatePromotionNode).GetAttribute("EndPeriod").Trim().ToDateTime();
                                roomRate.BackCurrencyCode = ((XmlElement)RebatePromotionNode).GetAttribute("CurrencyCode").Trim();
                                roomRate.BackCode = ((XmlElement)RebatePromotionNode).GetAttribute("Code").Trim();
                                roomRate.ProgramName = ((XmlElement)RebatePromotionNode).GetAttribute("ProgramName").Trim();
                                roomRate.BackAmount = ((XmlElement)RebatePromotionNode).GetAttribute("Amount").Trim().ToDecimal();
                                roomRate.BackDescription = RebatePromotionNode.SelectSingleNode("Description/Text").InnerText.Trim();
                                roomRate.RoomCode = roomRatePlan.HotelRoomCode;
                            }
                            else
                            {
                                roomRate.StartPeriod = DateTime.Parse("1900-1-1");
                                roomRate.EndPeriod = DateTime.Parse("1900-1-1");
                                roomRate.BackCurrencyCode = "";
                                roomRate.BackCode = "";
                                roomRate.ProgramName = "";
                                roomRate.BackAmount = 0;
                                roomRate.BackDescription = "";
                                roomRate.RoomCode = 0;

                            }
                            roomRateList.Add(roomRate);

                        }
                        roomRatePlan.RoomRateList = roomRateList;
                        roomRatePlanList.Add(roomRatePlan);
                    }
                    ratePlan.RoomRatePlanList = roomRatePlanList;
                    hotelRatePlanList.Add(ratePlan);
                }
                rep.HotelRatePlanList = hotelRatePlanList;
            }
            catch
            {
                throw;
            }
            return rep;
        }