示例#1
0
        /// <summary>
        /// 获取酒店价格
        /// </summary>
        /// <param name="rid"></param>
        /// <param name="rpid"></param>
        /// <param name="checkInTime"></param>
        /// <param name="checkOutTime"></param>
        /// <returns></returns>
        public TmallHotelPriceInfo GetHotelPriceInfo(string rid, string rpid, DateTime checkInTime, DateTime checkOutTime)
        {
            string sql = string.Format(@"
SELECT  h.hotelName, hr.rid RoomId,hr.roomName RoomName,rp.ratePlanName RatePlanName,hr.roomState RoomStatus,rp.roomBreakfast Breakfast,rp.ratePlanId RatePlanId,rp.status RatePlanStatus,rr.startDate AS CheckInTime,rr.salePrice AS BasePrice,rr.taobaoprice AS SalePrice, rr.roomstate  as Available,rp.paymentType PaymentType
                FROM dbo.hotelRooms hr INNER JOIN dbo.ratePlans rp ON rp.rid = hr.rId
                LEFT JOIN dbo.roomRates rr with(nolock) ON rr.ratePlanId=rp.ratePlanId
                left join hotels h with(nolock) on h.hId=hr.hId
                WHERE hr.rId='{0}' AND rp.ratePlanId='{1}' AND rr.startDate>='{2}' AND rr.startDate<'{3}'
                ", rid, rpid, checkInTime.ToString("yyyy-MM-dd"), checkOutTime.ToString("yyyy-MM-dd"));

            TmallHotelPriceInfo order = new TmallHotelPriceInfo();
            var result = sqlSugarClient.SqlQueryable <DetailOrderDto>(sql).ToList();

            if (result.Count > 0)
            {
                var roomInfo = result.FirstOrDefault();
                order.RoomName     = roomInfo.RoomName;
                order.RatePlanName = roomInfo.RatePlanName;
                order.PaymentType  = roomInfo.PaymentType;
                order.HotelName    = roomInfo.HotelName;
                if (roomInfo.RoomStatus == 0 || roomInfo.RatePlanStatus == 0)
                {
                    return(order);
                }

                string priceStr  = "";
                string datestr   = "";
                int    datePrice = 0;
                foreach (var item in result)
                {
                    if (item.Available == 0)
                    {
                        return(order);
                    }

                    datestr    = item.CheckInTime.ToString("yyyy-M-dd");
                    priceStr  += "price" + datestr + "|" + item.BasePrice + "|money" + datestr + "|0|";
                    datePrice += item.BasePrice;
                }
                order.PriceStr  = priceStr;
                order.DatePrice = datePrice;
            }
            return(order);
        }
示例#2
0
        public TmallHotelPriceInfo GetHotelPriceInfo(BookingCheckInputDto checkDto)
        {
            string hotelId = checkDto.HotelId;
            string rpid    = checkDto.RatePlanId;

            string  ratePlanId = checkDto.RatePlanId;
            string  lastTime   = "23:59";
            string  priceStr   = string.Empty;
            decimal totalPrice = 0;

            TmallHotelPriceInfo priceInfo = new TmallHotelPriceInfo();

            priceInfo.BreakFast = 99;
            #region 获取酒店名称
            try
            {
                string sql          = string.Format("select top 1 HotelName as HotelName from DaDuShi_Hotels(NOLOCK) where HotelCode = '{0}'", hotelId);
                var    getHotelInfo = SqlSugarContext.ResellbaseInstance.SqlQueryable <MeiTuanHotel>(sql).First();
                if (getHotelInfo != null && getHotelInfo.HotelName != null)
                {
                    priceInfo.HotelName = getHotelInfo.HotelName;
                }
                else
                {
                    priceInfo.HotelName = "酒店未获取";
                }
            }
            catch
            {
                priceInfo.HotelName = "酒店未获取";
            }
            #endregion

            var RequestEt = new RatePlanConfrimJsonEt
            {
                HotelCode     = checkDto.HotelId,
                RatePlanCode  = checkDto.RatePlanId,
                RoomTypeCode  = checkDto.RoomTypeId,
                CheckIn       = checkDto.CheckIn.ToString("yyyy-MM-dd"),
                CheckOut      = checkDto.CheckOut.ToString("yyyy-MM-dd"),
                NumberOfUnits = checkDto.RoomNum,
                AdultCount    = 2,
                ChildCount    = 0
            };
            //当失败时重新试单
            var response = new WebServiceResponse <HotelInfoJsonEt>();
            try
            {
                response = OrderDataOpEt.Availability(RequestEt);
            }
            catch (Exception exMt)
            {
                response = OrderDataOpEt.Availability(RequestEt);
            }
            #region 默认为2个人请求,当失败时为一个人请求
            if (response == null || !response.Successful || response.ResponseEt == null || response.ResponseEt.RatePlanList.Count == 0)
            {
                RequestEt = new RatePlanConfrimJsonEt
                {
                    HotelCode     = checkDto.HotelId,
                    RatePlanCode  = checkDto.RatePlanId,
                    RoomTypeCode  = checkDto.RoomTypeId,
                    CheckIn       = checkDto.CheckIn.ToString("yyyy-MM-dd"),
                    CheckOut      = checkDto.CheckOut.ToString("yyyy-MM-dd"),
                    NumberOfUnits = checkDto.RoomNum,
                    AdultCount    = 1,
                    ChildCount    = 0
                };
                //当失败时重新试单
                response = new WebServiceResponse <HotelInfoJsonEt>();
                try
                {
                    response = OrderDataOpEt.Availability(RequestEt);
                }
                catch (Exception exMt)
                {
                    response = OrderDataOpEt.Availability(RequestEt);
                }
            }
            #endregion

            if (response != null && response.Successful && response.ResponseEt != null && response.ResponseEt.RatePlanList.Count > 0)
            {
                foreach (var item in response.ResponseEt.RatePlanList[0].RateList)
                {
                    var basePrice = item.AmountBeforeTax;
                    priceStr   += "price" + basePrice + "|" + basePrice + "|money" + basePrice + "|0|";
                    totalPrice += basePrice;
                }
                priceInfo.DatePrice    = totalPrice;
                priceInfo.PriceStr     = priceStr;
                priceInfo.RoomName     = response.ResponseEt.RatePlanList[0].RoomTypeName;
                priceInfo.RatePlanName = response.ResponseEt.RatePlanList[0].RoomTypeName;
                priceInfo.PaymentType  = 1;
                priceInfo.BreakFast    = response.ResponseEt.RatePlanList[0].RateList.Min(s => s.Breakfast);
            }
            else
            {
                try
                {
                    //当不可预订时获取房型名称失败,重新到数据库获取
                    string sql          = string.Format("select top 1 RoomTypeName as HotelName from DaDuShi_RoomType WITH(NOLOCK) where HotelCode = '{0}' and RoomTypeCode='{1}'", hotelId, checkDto.RoomTypeId);
                    var    getHotelInfo = SqlSugarContext.ResellbaseInstance.SqlQueryable <MeiTuanHotel>(sql).First();
                    if (getHotelInfo != null && getHotelInfo.HotelName != null)
                    {
                        priceInfo.RoomName = getHotelInfo.HotelName;
                    }
                    else
                    {
                        priceInfo.RoomName = "获取房型失败";
                    }
                }
                catch
                {
                    priceInfo.RoomName = "获取房型失败";;
                }
            }

            return(priceInfo);
        }
示例#3
0
        /// <summary>
        /// 获取酒店基础信息
        /// </summary>
        /// <param name="checkDto"></param>
        /// <returns></returns>
        public TmallHotelPriceInfo GetHotelPriceInfo(BookingCheckInputDto checkDto)
        {
            TmallHotelPriceInfo priceInfo = new TmallHotelPriceInfo();

            if (checkDto.RatePlanCode.Contains("_c"))
            {
                ctripApiClient = new CtripApiClient(Ctrip.Config.ApiConfigManager.ZhiHeC);
            }
            try
            {
                string  ratePlanId = checkDto.RatePlanId;
                string  lastTime   = "23:59";
                string  priceStr   = string.Empty;
                decimal totalPrice = 0;

                var getHotelInfo = Task.Factory.StartNew(() => { return(ctripRepository.GetHotel(checkDto.HotelId)); });
                var hotel        = getHotelInfo.Result;
                if (hotel == null || hotel.HotelName == null || hotel.HotelName == "")
                {
                    priceInfo.HotelName = "获取酒店失败";
                }
                else
                {
                    priceInfo.HotelName = hotel.HotelName;
                }
                HotelAvailReponse resp = new HotelAvailReponse();
                //当失败时重新试单
                try
                {
                    resp = ctripApiClient.CheckOrderAvail(checkDto.HotelId, "501", ratePlanId, checkDto.RoomNum, 1, checkDto.CheckIn, checkDto.CheckOut, lastTime);
                }
                catch
                {
                    resp = ctripApiClient.CheckOrderAvail(checkDto.HotelId, "501", ratePlanId, checkDto.RoomNum, 1, checkDto.CheckIn, checkDto.CheckOut, lastTime);
                }
                if (resp != null && resp.AvailabilityStatus == "NoAvailability")
                {
                    if (resp.Error != null && resp.Error.Message.Contains("Invalid number of rooms"))
                    {
                        //Task.Factory.StartNew(() =>
                        //{
                        //    var roomTypeService = new RoomTypeService(Shop, Entities.Enum.ProductChannel.Ctrip);
                        //    roomTypeService.ModifyRoomType(checkDto.HotelId);
                        //});
                        try
                        {
                            resp = ctripApiClient.CheckOrderAvail(checkDto.HotelId, "501", ratePlanId, checkDto.RoomNum, 1, checkDto.CheckIn, checkDto.CheckOut, lastTime);
                        }
                        catch
                        {
                            resp = ctripApiClient.CheckOrderAvail(checkDto.HotelId, "501", ratePlanId, checkDto.RoomNum, 1, checkDto.CheckIn, checkDto.CheckOut, lastTime);
                        }
                    }
                }

                if (resp != null && resp.AvailabilityStatus == "AvailableForSale")
                {
                    if (resp.RoomStay != null && resp.RoomStay.RatePlans != null && resp.RoomStay.RoomRates != null)
                    {
                        var ratePlan  = resp.RoomStay.RatePlans.FirstOrDefault();
                        var roomRates = resp.RoomStay.RoomRates.FirstOrDefault();
                        // var roomType = resp.RoomStay.RoomTypes.FirstOrDefault();
                        if (roomRates != null || roomRates.Rates != null || roomRates.Rates.Count > 0)
                        {
                            string ExtensionName = string.Empty;
                            try
                            {
                                var ctripHotel = hotelRepository.GetCtripHotel(checkDto.HotelId);
                                //var hotelExtension = SqlSugarContext.LingZhongInstance.Queryable<AliTripHotelExtension>().Where(u => u.HotelId == checkDto.HotelId && u.Source == (int)ProductChannel.Ctrip).First();
                                if (ctripHotel != null && ctripHotel.CtripStarRate != null && ctripHotel.CtripStarRate >= 5)
                                {
                                    ExtensionName = "[金牌]";
                                }
                            }
                            catch
                            {
                            }
                            foreach (var item in roomRates.Rates)
                            {
                                var basePrice = item.AmountBeforeTax;
                                if (item.Cost > 0)
                                {
                                    basePrice = item.Cost;
                                }
                                //var basePrice = item.AmountBeforeTax;
                                priceStr   += "price" + basePrice + "|" + basePrice + "|money" + basePrice + "|0|";
                                totalPrice += basePrice;
                            }

                            string RatePlanName = ratePlan.RatePlanName;

                            int invoiceMode = ratePlan.InvoiceTargetType;
                            if (invoiceMode == 1)
                            {
                                RatePlanName = string.Format("{0}[携程开具发票]", RatePlanName);
                            }
                            else if (invoiceMode == 2)
                            {
                                RatePlanName = string.Format("{0}[酒店开具发票]", RatePlanName);
                            }

                            if (ratePlan.SupplierID > 0)
                            {
                                RatePlanName = string.Format("{0}[代理]", RatePlanName);
                            }

                            if (checkDto.RatePlanCode.Contains("_c"))
                            {
                                RatePlanName = string.Format("{0}[促销]", RatePlanName);
                            }


                            priceInfo.DatePrice    = totalPrice;
                            priceInfo.PriceStr     = priceStr;
                            priceInfo.RoomName     = ratePlan.RatePlanName;
                            priceInfo.PaymentType  = 1;
                            priceInfo.RatePlanName = RatePlanName + ExtensionName;



                            return(priceInfo);
                        }
                    }
                }
                else
                {
                    var getRoomInfo = Task.Factory.StartNew(() => { return(ctripRepository.GetRoomType(checkDto.HotelId, checkDto.RoomTypeId)); });

                    var roomInfo = getRoomInfo.Result;
                    if (roomInfo == null || roomInfo.RoomName == null || roomInfo.RoomName == "")
                    {
                        priceInfo.RoomName = "获取房型失败";
                    }
                    else
                    {
                        priceInfo.RoomName = roomInfo.RoomName;
                    }
                }
            }
            catch
            {
            }

            return(priceInfo);
        }
示例#4
0
        /// <summary>
        /// 获取酒店原始信息
        /// </summary>
        /// <param name="checkDto"></param>
        /// <returns></returns>
        public TmallHotelPriceInfo GetHotelPriceInfo(BookingCheckInputDto checkDto)
        {
            long hotelId = Convert.ToInt64(checkDto.HotelId);
            int  rpid    = Convert.ToInt32(checkDto.RatePlanId);
            TmallHotelPriceInfo priceInfo = new TmallHotelPriceInfo();
            var request = new HotelGoodsRequest
            {
                CheckinDate  = checkDto.CheckIn.ToString("yyyy-MM-dd"),
                CheckoutDate = checkDto.CheckOut.ToString("yyyy-MM-dd"),
                GoodsType    = 1,
                HotelIds     = new List <long> {
                    hotelId
                }
            };
            //当失败时重新试单
            var response = new HotelGoodsResponse();

            try
            {
                response = meiTuanApiClient.Excute(request);
            }
            catch (Exception exMt)
            {
                response = meiTuanApiClient.Excute(request);
            }
            if (response != null && response.Result != null && response.Result.hotelGoods != null && response.Result.hotelGoods.Count > 0)
            {
                var rplist    = response.Result.hotelGoods[0].goods;
                var currentRp = rplist.Where(u => u.hotelId == hotelId && u.goodsId == rpid).FirstOrDefault();
                if (currentRp != null)
                {
                    priceInfo.RoomName     = currentRp.roomInfoList[0].roomName;
                    priceInfo.RatePlanName = currentRp.goodsName;
                    int invoiceMode = currentRp.invoiceInfo.invoiceMode;
                    if (invoiceMode == 1)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[酒店开具发票]", priceInfo.RatePlanName);
                    }
                    else if (invoiceMode == 2)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[美团开具发票]", priceInfo.RatePlanName);
                    }
                    else if (invoiceMode == 3)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[第三方开具发票]", priceInfo.RatePlanName);
                    }

                    if (currentRp.thirdParty == 1)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[代理]", priceInfo.RatePlanName);
                    }

                    if (currentRp.goodsType == 2)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[钟点房]", priceInfo.RatePlanName);
                    }

                    //priceInfo.RatePlanName = string.Format("{0} [{1}早]", priceInfo.RatePlanName, );
                    string  priceStr    = string.Empty;
                    decimal sTotalPrice = 0;
                    decimal sBasePrice  = 0;

                    foreach (var item in currentRp.priceModels)
                    {
                        var     subPricedic = item.subPrice;
                        decimal basePrice   = item.salePrice - item.subPrice;
                        sBasePrice  += basePrice;
                        sTotalPrice += subPricedic;
                        priceStr    += "price" + basePrice / 100 + "|" + item.salePrice / 100 + "|money" + basePrice / 100 + "|0|";
                    }
                    priceInfo.DatePrice   = Convert.ToDecimal(sBasePrice / 100);
                    priceInfo.PriceStr    = priceStr;
                    priceInfo.PaymentType = 1;
                    priceInfo.STotalPrice = Convert.ToDecimal(sTotalPrice / 100);


                    var hotel = SqlSugarContext.ChannelInstance.Queryable <MeiTuanHotel>().Where(u => u.HotelId == hotelId).First();
                    if (hotel != null)
                    {
                        priceInfo.HotelName = hotel.HotelName;
                    }
                    else
                    {
                        try
                        {
                            string sql          = string.Format("select top 1 hotelId as HotelId,pointName as HotelName from Mt_hotels where hotelId = {0}", hotelId);
                            var    getHotelInfo = SqlSugarContext.HotelProductInstance.SqlQueryable <MeiTuanHotel>(sql).First();
                            if (getHotelInfo != null && getHotelInfo.HotelName != null)
                            {
                                priceInfo.HotelName = getHotelInfo.HotelName;
                            }
                            else
                            {
                                priceInfo.HotelName = "酒店未获取";
                            }
                        }
                        catch
                        {
                            priceInfo.HotelName = "酒店未获取";
                        }
                    }
                }
            }


            return(priceInfo);
        }