Ejemplo n.º 1
0
        /// <summary>
        /// 获取试单前的总金额
        /// </summary>
        /// <param name="checkDto"></param>
        /// <returns></returns>
        public decimal getTotaPrice(BookingCheckInputDto checkDto)
        {
            decimal salePrice = 0;

            try
            {
                long hotelId = Convert.ToInt64(checkDto.HotelId);
                int  rpid    = Convert.ToInt32(checkDto.RatePlanId);
                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 exstr)
                {
                    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.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;
                            salePrice   += item.salePrice;
                            priceStr    += "price" + basePrice / 100 + "|" + item.salePrice / 100 + "|money" + basePrice / 100 + "|0|";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(salePrice);
        }
Ejemplo n.º 2
0
        public BookingCheckOutDto BookingCheck(BookingCheckInputDto checkDto)
        {
            var checkKey   = "dds_" + checkDto.HotelId + "_" + checkDto.RoomTypeId + "_" + checkDto.RatePlanId + "_" + checkDto.CheckIn + "_" + checkDto.CheckOut;
            var bookOutDto = new BookingCheckOutDto();

            try
            {
                DateTime startTime = DateTime.Now;
                bookOutDto.DayPrice = new List <RateQuotasPrice>();
                bookOutDto.IsBook   = true;
                bookOutDto.Message  = "正常可预定";

                int RoomNum = 1;//库存
                //RatePlanConfrimJsonEt RequestEt = new RatePlanConfrimJsonEt();
                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 = RoomNum,
                    AdultCount    = 2,
                    ChildCount    = 0
                };


                ///API_用户认证失败 = 401, API_内部程序出错 = 402,API_订单号已存在 = 403,API_价格不正确 = 404,API_新错误代码 = 405,程序代码出错 = 501,成功 = 200,无数据返回 = 201
                //var response = daDuShiApiClient.RequestData(OperationCode.获取价格确认数据, RequestEt
                //    , () =>
                //    {
                //        return OrderDataOpEt.Availability(RequestEt);
                //    });

                var response = new WebServiceResponse <HotelInfoJsonEt>();
                try
                {
                    response = OrderDataOpEt.Availability(RequestEt);
                    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 = RoomNum,
                            AdultCount    = 1,
                            ChildCount    = 0
                        };
                        response = new WebServiceResponse <HotelInfoJsonEt>();
                    }
                }
                catch (Exception ex)
                {
                    response = OrderDataOpEt.Availability(RequestEt);
                }
                TimeSpan ts = checkDto.CheckOut.Subtract(checkDto.CheckIn);
                if (response != null && response.Successful && response.ResponseEt != null && response.ResponseEt.RatePlanList.Count > 0)
                {
                    bookOutDto.IsBook = true;


                    var rate = new TaobaoRate();
                    try
                    {
                        XhotelRateGetRequest req = new XhotelRateGetRequest();
                        req.OutRid = checkDto.OuterId;
                        req.Rpid   = checkDto.Rpid;
                        var tmallApiClient         = new TmallApiClient(Shop);
                        XhotelRateGetResponse resp = tmallApiClient.Execute(req);
                        if (resp != null && !resp.IsError && resp.Rate != null && !string.IsNullOrWhiteSpace(resp.Rate.InventoryPrice))
                        {
                            rate = JsonConvert.DeserializeObject <TaobaoRate>(resp.Rate.InventoryPrice);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    bool bianhua = false;

                    bookOutDto.DayPrice = response.ResponseEt.RatePlanList[0].RateList.Select(u =>
                                                                                              new RateQuotasPrice
                    {
                        Date  = u.EffectiveDate,
                        Price = (GetSalePrice(Convert.ToDateTime(u.EffectiveDate), false, u.AmountBeforeTax, rate, ref bianhua, checkDto.IsCustomer)

                                 ).ToTaoBaoPrice(),
                        Quota = RoomNum    //默认库存
                    }).ToList();

                    //记录试单信息
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            bool IsFull   = false;
                            string Remark = bookOutDto.Message;
                            if (checkDto.IsCustomer == 0)
                            {
                                Remark = "程序请求";
                            }
                            AliTripValidate av = new AliTripValidate();
                            av.CheckInTime     = checkDto.CheckIn;
                            av.CheckOutTime    = checkDto.CheckOut;
                            av.RatePlanCode    = checkDto.RatePlanCode;
                            av.IsFull          = IsFull;
                            av.HotelId         = checkDto.HotelId;
                            av.RoomId          = checkDto.RoomTypeId;
                            av.RatePlanId      = checkDto.RatePlanId;
                            av.CreateTime      = DateTime.Now;
                            av.Channel         = 10;
                            av.Shop            = (int)Shop;
                            av.Remark          = Remark;
                            SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();
                            string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=10", checkDto.HotelId);
                            WebHttpRequest.Get(url);
                        }
                        catch
                        {
                        }
                    });
                }
                else
                {
                    string responseResult = "满房";
                    if (response != null && !response.Successful && !string.IsNullOrWhiteSpace(response.ErrMsg))
                    {
                        responseResult = response.ErrMsg;
                    }
                    try
                    {
                        var falseCount      = 1;
                        var falseCacheCount = CacheHelper.GetCache("falseCount");//先读取缓存
                        if (checkDto.IsCustomer == 1)
                        {
                            if (falseCacheCount != null)//如果没有该缓存,默认为1
                            {
                                falseCount = (int)falseCacheCount + 1;
                            }
                            CacheHelper.SetCache("falseCount", falseCount, 1800);//添加缓存
                        }
                        //如果试单失败为双数直接拿缓存值输出,单数时为失败
                        bool tongguo = true;

                        int NowHour   = DateTime.Now.Hour;   //当前时间的时数
                        int NowMinute = DateTime.Now.Minute; //当前时间的分钟数
                        //if (falseCount % 6 == 0 || checkDto.IsCustomer == 0)
                        if (checkDto.IsCustomer == 0)
                        {
                            bookOutDto.Message = responseResult;
                            bookOutDto.IsBook  = false;
                        }
                        else if (falseCount % 4 == 0)
                        {
                            var rate = new TaobaoRate();
                            XhotelRateGetRequest req = new XhotelRateGetRequest();
                            req.OutRid = checkDto.OuterId;
                            req.Rpid   = checkDto.Rpid;
                            var tmallApiClient         = new TmallApiClient(Shop);
                            XhotelRateGetResponse resp = tmallApiClient.Execute(req);
                            if (resp != null && !resp.IsError && resp.Rate != null && !string.IsNullOrWhiteSpace(resp.Rate.InventoryPrice))
                            {
                                rate = JsonConvert.DeserializeObject <TaobaoRate>(resp.Rate.InventoryPrice);
                            }
                            var totalDayNum = (int)(checkDto.CheckOut.Date - checkDto.CheckIn).TotalDays;
                            var rates       = new List <inventory_price>();
                            //判断是否已经更新过飞猪房态,0为没更新过,1为已更新过为不可以预定
                            int IsClose = 0;
                            for (int i = 0; i < totalDayNum; i++)
                            {
                                var inventory_price = rate.inventory_price.Where(a => a.date == checkDto.CheckIn.AddDays(i).ToString("yyyy-MM-dd")).FirstOrDefault();
                                if (inventory_price.price <= 0 || inventory_price.price > 4999900)
                                {
                                    IsClose            = 1;
                                    bookOutDto.Message = responseResult;
                                    bookOutDto.IsBook  = false;
                                }
                                else
                                {
                                    rates.Add(inventory_price);
                                }
                            }

                            if (IsClose == 0)
                            {
                                bookOutDto.DayPrice = rates.Select(u =>
                                                                   new RateQuotasPrice
                                {
                                    Date  = u.date,
                                    Price = u.price,
                                    Quota = 1
                                }).ToList();
                                bookOutDto.Message = "正常可预定";
                                bookOutDto.IsBook  = true;
                                logWriter.Write("试单失败后通过(大都市):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, responseResult);
                            }
                        }
                        else if (falseCount % 3 == 0)
                        {
                            var rate = new TaobaoRate();
                            XhotelRateGetRequest req = new XhotelRateGetRequest();
                            req.OutRid = checkDto.OuterId;
                            req.Rpid   = checkDto.Rpid;
                            var tmallApiClient         = new TmallApiClient(Shop);
                            XhotelRateGetResponse resp = tmallApiClient.Execute(req);
                            if (resp != null && !resp.IsError && resp.Rate != null && !string.IsNullOrWhiteSpace(resp.Rate.InventoryPrice))
                            {
                                rate = JsonConvert.DeserializeObject <TaobaoRate>(resp.Rate.InventoryPrice);
                            }
                            var totalDayNum = (int)(checkDto.CheckOut.Date - checkDto.CheckIn).TotalDays;
                            var rates       = new List <inventory_price>();
                            //判断是否已经更新过飞猪房态,0为没更新过,1为已更新过为不可以预定
                            int IsClose = 0;
                            for (int i = 0; i < totalDayNum; i++)
                            {
                                var inventory_price = rate.inventory_price.Where(a => a.date == checkDto.CheckIn.AddDays(i).ToString("yyyy-MM-dd")).FirstOrDefault();
                                if (inventory_price.price <= 0 || inventory_price.price > 4999900)
                                {
                                    IsClose            = 1;
                                    bookOutDto.Message = responseResult;
                                    bookOutDto.IsBook  = false;
                                }
                                else
                                {
                                    rates.Add(inventory_price);
                                }
                            }

                            if (IsClose == 0)
                            {
                                Random ran          = new Random();
                                int    RandomResult = ran.Next(80, 200);

                                bookOutDto.DayPrice = rates.Select(u =>
                                                                   new RateQuotasPrice
                                {
                                    Date  = u.date,
                                    Price = u.price + RandomResult * 100m,
                                    Quota = 1
                                }).ToList();
                                bookOutDto.Message = "正常可预定";
                                bookOutDto.IsBook  = true;
                                logWriter.Write("试单失败后通过(大都市):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, responseResult);
                            }
                        }
                        else
                        {
                            logWriter.Write("试单失败后(大都市):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, responseResult);
                            bookOutDto.Message = responseResult;
                            bookOutDto.IsBook  = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        logWriter.Write("试单失败后报错(大都市):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败原因{3},报错{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, responseResult, ex.ToString());
                        bookOutDto.Message = responseResult;
                        bookOutDto.IsBook  = false;
                    }

                    //记录试单信息并关闭房态
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            bool IsFull   = true;
                            string Remark = responseResult;
                            if (checkDto.IsCustomer == 0)
                            {
                                Remark = "程序请求";
                                IsFull = false;
                            }
                            AliTripValidate av = new AliTripValidate();
                            av.CheckInTime     = checkDto.CheckIn;
                            av.CheckOutTime    = checkDto.CheckOut;
                            av.RatePlanCode    = checkDto.RatePlanCode;
                            av.IsFull          = IsFull;
                            av.HotelId         = checkDto.HotelId;
                            av.RoomId          = checkDto.RoomTypeId;
                            av.RatePlanId      = checkDto.RatePlanId;
                            av.CreateTime      = DateTime.Now;

                            av.Channel = 10;
                            av.Shop    = (int)Shop;
                            av.Remark  = Remark;
                            SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();
                        }
                        catch
                        {
                        }
                        Thread.Sleep(5000);
                        string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=10", checkDto.HotelId);
                        WebHttpRequest.Get(url);
                    });
                }
            }
            catch (Exception ex)
            {
                bookOutDto.IsBook  = false;
                bookOutDto.Message = string.Format("满房,系统异常:{0}", ex.ToString());
            }
            if (checkDto.IsCustomer == 0)
            {
                try
                {
                    BookingCheckOutDto CheckOut = new BookingCheckOutDto();
                    var check = CacheHelper.GetCache(checkKey); //先读取缓存
                    if (check != null)                          //如果没有该缓存
                    {
                        CheckOut = Newtonsoft.Json.JsonConvert.DeserializeObject <BookingCheckOutDto>(check.ToString(), new JsonSerializerSettings
                        {
                            Error = delegate(object obj, Newtonsoft.Json.Serialization.ErrorEventArgs args)
                            {
                                args.ErrorContext.Handled = true;
                            }
                        });
                        if (CheckOut != null)
                        {
                            return(CheckOut);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            CacheHelper.SetCache(checkKey, Newtonsoft.Json.JsonConvert.SerializeObject(bookOutDto), 8);//添加缓存
            return(bookOutDto);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 试单
        /// </summary>
        /// <param name="checkDto"></param>
        /// <returns></returns>
        public BookingCheckOutDto BookingCheck(BookingCheckInputDto checkDto)
        {
            var checkKey = "xc_" + checkDto.HotelId + "_" + checkDto.RoomTypeId + "_" + checkDto.RatePlanId + "_" + checkDto.CheckIn + "_" + checkDto.CheckOut;

            bool isPromotion = false;//isPromotion是否为促销产品,true为促销

            if (checkDto.RatePlanCode.Contains("_c"))
            {
                ctripApiClient = new CtripApiClient(Ctrip.Config.ApiConfigManager.ZhiHeC);
                isPromotion    = true;
            }
            BookingCheckOutDto bookingCheckOut = new BookingCheckOutDto();

            bookingCheckOut.IsBook   = true;
            bookingCheckOut.Message  = "正常可预定";
            bookingCheckOut.DayPrice = new List <RateQuotasPrice>();
            //如果查询库存为2时可以预定,折输出库存为2,否则为1
            int RoomNum = checkDto.RoomNum;

            if (RoomNum == 1 && !isPromotion)
            {
                RoomNum = 2;
            }
            try
            {
                string lastTime = "23:59";
                var    resp     = ctripApiClient.CheckOrderAvail(checkDto.HotelId, "501", checkDto.RatePlanId, 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"))
                    {
                        RoomNum = 1;
                        //Task.Factory.StartNew(() =>
                        //{
                        //    var roomTypeService = new RoomTypeService(Shop, Entities.Enum.ProductChannel.Ctrip);
                        //    roomTypeService.ModifyRoomType(checkDto.HotelId);
                        //});
                        resp = ctripApiClient.CheckOrderAvail(checkDto.HotelId, "501", checkDto.RatePlanId, RoomNum, 1, checkDto.CheckIn, checkDto.CheckOut, lastTime);
                    }
                }

                if (resp != null && resp.AvailabilityStatus == "AvailableForSale")
                {
                    if (resp.RoomStay != null && resp.RoomStay.RoomRates != null)
                    {
                        var rate = new TaobaoRate();
                        try
                        {
                            XhotelRateGetRequest req = new XhotelRateGetRequest();
                            req.OutRid = checkDto.OuterId;
                            req.Rpid   = checkDto.Rpid;
                            var tmallApiClient = new TmallApiClient(Shop);
                            XhotelRateGetResponse GetRateResp = tmallApiClient.Execute(req);
                            if (resp != null && !GetRateResp.IsError && GetRateResp.Rate != null && !string.IsNullOrWhiteSpace(GetRateResp.Rate.InventoryPrice))
                            {
                                rate = JsonConvert.DeserializeObject <TaobaoRate>(GetRateResp.Rate.InventoryPrice);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        //var hotelExtension = hotelRepository.GetHotelExtension(checkDto.HotelId, (int)ProductChannel.Ctrip);
                        var roomRates    = resp.RoomStay.RoomRates.FirstOrDefault();
                        var isCommission = resp.RoomStay.RatePlans[0].SupplierID > 0;
                        //获取是否为金牌酒店
                        decimal ctripStarRate = 0;
                        //var ctripHotel = hotelRepository.GetCtripHotel(checkDto.HotelId);
                        //金牌
                        //ctripStarRate = ctripHotel.CtripStarRate;
                        //是否发生变价
                        bool bianhua = false;
                        //是否需要马上更新
                        bool isUpdate = false;

                        bookingCheckOut.DayPrice = roomRates.Rates.Select(u =>
                                                                          new RateQuotasPrice
                        {
                            Date  = u.EffectiveDate,
                            Price = (GetSalePrice(Convert.ToDateTime(u.EffectiveDate), u.Cost, u.AmountBeforeTax, isCommission, rate, isPromotion, ref bianhua, ref isUpdate, ctripStarRate, checkDto.IsCustomer)

                                     ).ToTaoBaoPrice(),
                            Quota = RoomNum//默认库存
                        }).ToList();

                        //记录试单信息
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                bool IsFull   = false;
                                string Remark = bookingCheckOut.Message;
                                if (bianhua)
                                {
                                    Remark = "变价";
                                    //如果为促销产品关房处理因为缓存没那么快更新完
                                    //if(isPromotion)
                                    //{
                                    //    IsFull = true;
                                    //}
                                }
                                else if (checkDto.IsCustomer == 0)
                                {
                                    Remark = "程序请求";
                                }
                                AliTripValidate av = new AliTripValidate();
                                av.CheckInTime     = checkDto.CheckIn;
                                av.CheckOutTime    = checkDto.CheckOut;
                                av.RatePlanCode    = checkDto.RatePlanCode;
                                av.IsFull          = IsFull;
                                av.HotelId         = checkDto.HotelId;
                                av.RoomId          = checkDto.RoomTypeId;
                                av.RatePlanId      = checkDto.RatePlanId;
                                av.CreateTime      = DateTime.Now;

                                av.Channel = 8;
                                av.Shop    = (int)Shop;
                                av.Remark  = Remark;
                                SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();

                                //发生变价时更新rp
                                //if (bianhua)
                                //{

                                //}
                                //如果发生变价时先更新缓存,然后再更新飞猪报价
                                Task.Factory.StartNew(() =>
                                {
                                    try
                                    {
                                        if (isPromotion)
                                        {
                                            //更新促销价格缓存
                                            string urlCtripPrice = string.Format("http://47.107.101.107:8186/CtripPricePro/CtripPromorion.ashx?key=dfiqergnsdkjdiunqebgaupsdh&code={0}&checkin={1}&checkout={2}&cache=1&account=zhpromotion&opt=update", checkDto.HotelId, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));
                                            WebHttpRequest.Get(urlCtripPrice);
                                        }
                                        else
                                        {
                                            //更新价格缓存
                                            string urlCtripPrice = string.Format("http://47.107.101.107:8186/CtripPricePro/CtripPriceApi.ashx?key=dfiqergnsdkjdiunqebgaupsdh&code={0}&rids={1}&checkin={2}&checkout={3}&cache=0", checkDto.HotelId, checkDto.RatePlanId, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));
                                            WebHttpRequest.Get(urlCtripPrice);
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    if (checkDto.IsCustomer != 0 && !isUpdate)
                                    {
                                        Thread.Sleep(13000);
                                    }
                                    string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=8", checkDto.HotelId);
                                    WebHttpRequest.Get(url);
                                });
                            }
                            catch
                            {
                            }
                        });
                    }
                }
                else
                {
                    try
                    {
                        var falseCount      = 1;
                        var falseCacheCount = CacheHelper.GetCache("falseCount");//先读取缓存
                        //记录客户请求失败次数
                        if (checkDto.IsCustomer == 1)
                        {
                            if (falseCacheCount != null)//如果没有该缓存,默认为1
                            {
                                falseCount = (int)falseCacheCount + 1;
                            }
                            CacheHelper.SetCache("falseCount", falseCount, 1800);//添加缓存
                        }

                        bool tongguo = false;

                        //在0点15分到4点为试单失败为双数直接拿缓存值输出,其余的都通过
                        int NowHour   = DateTime.Now.Hour;   //当前时间的时数
                        int NowMinute = DateTime.Now.Minute; //当前时间的分钟数
                        if (falseCount % 2 == 0)
                        {
                            tongguo = true;
                        }
                        else if ((NowHour == 18 && NowMinute >= 30) || (NowHour < 8 && NowHour >= 19))
                        {
                            if (falseCount % 2 == 0 || falseCount % 5 == 0 || falseCount % 7 == 0)
                            {
                                tongguo = true;
                            }
                        }

                        //如果试单失败为双数直接拿缓存值输出,单数时为失败
                        //if (falseCount % 3 == 0)
                        if (checkDto.IsCustomer == 0)
                        {
                            bookingCheckOut.Message = resp.Error.Message;
                            bookingCheckOut.IsBook  = false;
                        }
                        else if (tongguo)
                        {
                            var rate = new TaobaoRate();
                            XhotelRateGetRequest request = new XhotelRateGetRequest();
                            request.OutRid = checkDto.OuterId;
                            request.Rpid   = checkDto.Rpid;
                            var tmallApiClient             = new TmallApiClient(Shop);
                            XhotelRateGetResponse response = tmallApiClient.Execute(request);
                            if (response != null && !response.IsError && response.Rate != null && !string.IsNullOrWhiteSpace(response.Rate.InventoryPrice))
                            {
                                rate = JsonConvert.DeserializeObject <TaobaoRate>(response.Rate.InventoryPrice);
                                //try
                                //{
                                //    rate = JsonConvert.DeserializeObject<TaobaoRate>(response.Rate.InventoryPrice);
                                //}
                                //catch (Exception ex)
                                //{
                                //}
                            }
                            var totalDayNum = (int)(checkDto.CheckOut.Date - checkDto.CheckIn).TotalDays;
                            var rates       = new List <inventory_price>();
                            //判断是否已经更新过飞猪房态,0为没更新过,1为已更新过为不可以预定
                            int IsClose = 0;
                            for (int i = 0; i < totalDayNum; i++)
                            {
                                var inventory_price = rate.inventory_price.Where(a => a.date == checkDto.CheckIn.AddDays(i).ToString("yyyy-MM-dd")).FirstOrDefault();
                                if (inventory_price.price <= 0 || inventory_price.price > 4999900)
                                {
                                    IsClose = 1;
                                    bookingCheckOut.Message = resp.Error.Message;
                                    bookingCheckOut.IsBook  = false;
                                }
                                else
                                {
                                    rates.Add(inventory_price);
                                }
                            }
                            if (IsClose == 0)
                            {
                                bookingCheckOut.DayPrice = rates.Select(u =>
                                                                        new RateQuotasPrice
                                {
                                    Date  = u.date,
                                    Price = u.price,
                                    Quota = 1//checkDto.RoomNum
                                }).ToList();
                                bookingCheckOut.Message = "正常可预定";
                                bookingCheckOut.IsBook  = true;
                                //logWriter.Write("试单失败后通过(携程):试单失败-淘宝酒店id:{0},携程酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, resp.Error.Message);
                            }
                        }
                        else if (falseCount % 3 == 0)//涨价处理
                        {
                            var rate = new TaobaoRate();
                            XhotelRateGetRequest request = new XhotelRateGetRequest();
                            request.OutRid = checkDto.OuterId;
                            request.Rpid   = checkDto.Rpid;
                            var tmallApiClient             = new TmallApiClient(Shop);
                            XhotelRateGetResponse response = tmallApiClient.Execute(request);
                            if (response != null && !response.IsError && response.Rate != null && !string.IsNullOrWhiteSpace(response.Rate.InventoryPrice))
                            {
                                rate = JsonConvert.DeserializeObject <TaobaoRate>(response.Rate.InventoryPrice);
                                //try
                                //{
                                //    rate = JsonConvert.DeserializeObject<TaobaoRate>(response.Rate.InventoryPrice);
                                //}
                                //catch (Exception ex)
                                //{
                                //}
                            }
                            var totalDayNum = (int)(checkDto.CheckOut.Date - checkDto.CheckIn).TotalDays;
                            var rates       = new List <inventory_price>();
                            //判断是否已经更新过飞猪房态,0为没更新过,1为已更新过为不可以预定
                            int IsClose = 0;
                            for (int i = 0; i < totalDayNum; i++)
                            {
                                var inventory_price = rate.inventory_price.Where(a => a.date == checkDto.CheckIn.AddDays(i).ToString("yyyy-MM-dd")).FirstOrDefault();
                                if (inventory_price.price <= 0 || inventory_price.price > 4999900)
                                {
                                    IsClose = 1;
                                    bookingCheckOut.Message = resp.Error.Message;
                                    bookingCheckOut.IsBook  = false;
                                }
                                else
                                {
                                    rates.Add(inventory_price);
                                }
                            }

                            if (IsClose == 0)
                            {
                                //当满房是生成随机数并加上之前上传给飞猪的
                                Random ran          = new Random();
                                int    RandomResult = ran.Next(80, 200);

                                bookingCheckOut.DayPrice = rates.Select(u =>
                                                                        new RateQuotasPrice
                                {
                                    Date  = u.date,
                                    Price = u.price + RandomResult * 100m,
                                    Quota = 1//checkDto.RoomNum
                                }).ToList();
                                bookingCheckOut.Message = "正常可预定";
                                bookingCheckOut.IsBook  = true;
                                //logWriter.Write("试单失败后通过(携程):试单失败-淘宝酒店id:{0},携程酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, resp.Error.Message);
                            }
                        }
                        else
                        {
                            //logWriter.Write("试单失败后(携程):试单失败-淘宝酒店id:{0},携程酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, resp.Error.Message);
                            bookingCheckOut.Message = resp.Error.Message;
                            bookingCheckOut.IsBook  = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        //logWriter.Write("试单失败后报错(携程):试单失败-淘宝酒店id:{0},携程酒店id:{1},{2},失败原因{3},报错{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, resp.Error.Message, ex.ToString());
                        bookingCheckOut.Message = resp.Error.Message;
                        bookingCheckOut.IsBook  = false;
                    }
                    //记录试单信息并关闭房态
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            string Remark = resp.Error.Message;
                            bool IsFull   = true;
                            if (checkDto.IsCustomer == 0)
                            {
                                Remark = "程序请求";
                                IsFull = false;
                            }
                            AliTripValidate av = new AliTripValidate();
                            av.CheckInTime     = checkDto.CheckIn;
                            av.CheckOutTime    = checkDto.CheckOut;
                            av.RatePlanCode    = checkDto.RatePlanCode;
                            av.IsFull          = IsFull;
                            av.HotelId         = checkDto.HotelId;
                            av.RoomId          = checkDto.RoomTypeId;
                            av.RatePlanId      = checkDto.RatePlanId;
                            av.CreateTime      = DateTime.Now;

                            av.Channel = 8;
                            av.Shop    = (int)Shop;
                            av.Remark  = Remark;
                            SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();

                            Task.Factory.StartNew(() =>
                            {
                                try
                                {
                                    if (isPromotion)
                                    {
                                        //更新促销价格缓存
                                        string urlCtripPrice = string.Format("http://47.107.101.107:8186/CtripPricePro/CtripPromorion.ashx?key=dfiqergnsdkjdiunqebgaupsdh&code={0}&checkin={1}&checkout={2}&cache=1&account=zhpromotion&opt=update", checkDto.HotelId, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));
                                        WebHttpRequest.Get(urlCtripPrice);
                                    }
                                    else
                                    {
                                        //更新价格缓存
                                        string urlCtripPrice = string.Format("http://47.107.101.107:8186/CtripPricePro/CtripPriceApi.ashx?key=dfiqergnsdkjdiunqebgaupsdh&code={0}&rids={1}&checkin={2}&checkout={3}&cache=0", checkDto.HotelId, checkDto.RatePlanId, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));
                                        WebHttpRequest.Get(urlCtripPrice);
                                    }
                                }
                                catch
                                {
                                }
                                if (checkDto.IsCustomer != 0)
                                {
                                    Thread.Sleep(12000);
                                }

                                string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=8", checkDto.HotelId);
                                WebHttpRequest.Get(url);
                            });
                        }
                        catch
                        {
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                //Task.Factory.StartNew(() =>
                //{
                //    var roomRateService = new RoomRateService(Shop, Entities.Enum.ProductChannel.Ctrip);
                //    roomRateService.UpdateRoomRateByHid(checkDto.HotelId, true, true, true);
                //});
                bookingCheckOut.IsBook  = false;
                bookingCheckOut.Message = "出现异常,不可预定";
            }
            //如果是飞猪程序调用先获取8秒内是否有试单
            if (checkDto.IsCustomer == 0)
            {
                try
                {
                    BookingCheckOutDto CheckOut = new BookingCheckOutDto();
                    var check = CacheHelper.GetCache(checkKey); //先读取缓存
                    if (check != null)                          //如果没有该缓存
                    {
                        CheckOut = Newtonsoft.Json.JsonConvert.DeserializeObject <BookingCheckOutDto>(check.ToString(), new JsonSerializerSettings
                        {
                            Error = delegate(object obj, Newtonsoft.Json.Serialization.ErrorEventArgs args)
                            {
                                args.ErrorContext.Handled = true;
                            }
                        });
                        if (CheckOut != null)
                        {
                            return(CheckOut);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            CacheHelper.SetCache(checkKey, Newtonsoft.Json.JsonConvert.SerializeObject(bookingCheckOut), 8);//添加缓存8秒
            return(bookingCheckOut);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public BookingCheckOutDto BookingCheck(BookingCheckInputDto checkDto)
        {
            var bookCheckResult = new BookingCheckOutDto();
            var roomStatus      = bigTreeRepository.GetRoomRateStatus(checkDto.RatePlanId, checkDto.CheckIn, checkDto.CheckOut);

            if (roomStatus.Count > 0)
            {
                List <RateQuotasPrice> rqpList = new List <RateQuotasPrice>();
                foreach (var item in roomStatus)
                {
                    if (item.RoomStatus == 1)
                    {
                        int?            price = null;
                        RateQuotasPrice rqp   = new RateQuotasPrice();
                        rqp.Date = item.StartDate.ToString("yyyy-MM-dd");
                        if (Shop == ShopType.YinJi)
                        {
                            rqp.Price = (price ?? item.SalePrice + 20) * 100;
                        }
                        else if (Shop == ShopType.LingZhong)
                        {
                            rqp.Price = (price ?? item.SalePrice + 25) * 100;
                        }
                        else if (Shop == ShopType.YinJiGuoLv)
                        {
                            rqp.Price = (price ?? item.SalePrice - 1) * 100;
                        }

                        if (item.Status == 1)
                        {
                            rqp.Quota = 8;
                        }
                        else
                        {
                            bookCheckResult.IsBook  = false;
                            bookCheckResult.Message = "房量不足";
                        }
                        rqpList.Add(rqp);
                    }
                    else
                    {
                        bookCheckResult.IsBook  = false;
                        bookCheckResult.Message = "满房";
                    }
                }

                if (rqpList.Count > 0)
                {
                    bookCheckResult.DayPrice = rqpList;
                    if (rqpList.Where(u => u.Quota == 0).Count() > 0)
                    {
                        bookCheckResult.IsBook  = false;
                        bookCheckResult.Message = "房量不足";
                    }
                    else
                    {
                        bookCheckResult.IsBook  = true;
                        bookCheckResult.Message = "检测可预定";
                    }
                }
            }
            else
            {
                bookCheckResult.IsBook  = false;
                bookCheckResult.Message = "不存在报价信息";
            }

            return(bookCheckResult);
        }
Ejemplo n.º 7
0
 public TmallHotelPriceInfo GetHotelPriceInfo(BookingCheckInputDto checkDto)
 {
     return(bigTreeRepository.GetHotelPriceInfo(checkDto.RoomTypeId, checkDto.RatePlanId, checkDto.CheckIn, checkDto.CheckOut));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 试单
        /// </summary>
        /// <param name="checkDto"></param>
        /// <returns></returns>
        public BookingCheckOutDto BookingCheck(BookingCheckInputDto checkDto)
        {
            var checkKey = "mt_" + checkDto.HotelId + "_" + checkDto.RoomTypeId + "_" + checkDto.RatePlanId + "_" + checkDto.CheckIn + "_" + checkDto.CheckOut;

            var bookOutDto = new BookingCheckOutDto();

            try
            {
                DateTime startTime = DateTime.Now;
                bookOutDto.DayPrice = new List <RateQuotasPrice>();
                bookOutDto.IsBook   = true;
                bookOutDto.Message  = "正常可预定";

                var response = new BookingCheckResponse();

                int totalPrice = Convert.ToInt32(getTotaPrice(checkDto));
                var request    = new BookingCheckRequest
                {
                    checkinDate  = checkDto.CheckIn.ToString("yyyy-MM-dd"),
                    checkoutDate = checkDto.CheckOut.ToString("yyyy-MM-dd"),
                    HotelId      = checkDto.HotelId,
                    GoodsId      = checkDto.RatePlanId,
                    RoomNum      = checkDto.RoomNum,
                    totalPrice   = totalPrice * checkDto.RoomNum
                };
                if (totalPrice != 0)
                {
                    response = meiTuanApiClient.Excute(request);
                }
                TimeSpan ts = checkDto.CheckOut.Subtract(checkDto.CheckIn);

                if (response != null && response.Result.code == 0 && (response.Result.desc == null || !response.Result.desc.Contains("价格发生变化")))
                {
                    //var hotelExtension = hotelRepository.GetHotelExtension(checkDto.HotelId, (int)Channel);
                    //var invoiceInfo = GetRatePlanInvoice(checkDto.HotelId, checkDto.RatePlanId, checkDto.CheckIn, checkDto.CheckOut);
                    bookOutDto.IsBook = true;
                    int remainRoomNum = response.Result.remainRoomNum;
                    int Quota         = 5;
                    if (remainRoomNum < 1)
                    {
                        Quota = 1;
                    }
                    else if (remainRoomNum > 5)
                    {
                        Quota = 5;
                    }
                    else
                    {
                        Quota = remainRoomNum;
                    }

                    var rate = new TaobaoRate();
                    try
                    {
                        XhotelRateGetRequest req = new XhotelRateGetRequest();
                        req.OutRid = checkDto.OuterId;
                        req.Rpid   = checkDto.Rpid;
                        var tmallApiClient         = new TmallApiClient(Shop);
                        XhotelRateGetResponse resp = tmallApiClient.Execute(req);
                        if (resp != null && !resp.IsError && resp.Rate != null && !string.IsNullOrWhiteSpace(resp.Rate.InventoryPrice))
                        {
                            rate = JsonConvert.DeserializeObject <TaobaoRate>(resp.Rate.InventoryPrice);
                        }
                    }
                    catch (Exception ex)
                    {
                    }

                    List <PriceModelsItem> modelList = new List <PriceModelsItem>();

                    foreach (var item in response.Result.priceModels)
                    {
                        if (!modelList.Any(u => u.date == item.date))
                        {
                            modelList.Add(item);
                        }
                    }
                    //是否需要马上更新
                    bool isUpdate = false;
                    //是否供应商发生变价
                    bool bianhua = false;

                    foreach (var item in modelList)
                    {
                        RateQuotasPrice rqp = new RateQuotasPrice();
                        rqp.Date = item.date;
                        //checkDto.IsVirtual, invoiceInfo.IsCommission, invoiceInfo.InvoiceMode, Convert.ToDecimal(item.subRatio / 10000), item.salePrice / 100, hotelExtension, rate
                        rqp.Price = GetSalePrice(Convert.ToDateTime(item.date), checkDto.IsVirtual, Convert.ToDecimal(item.subRatio / 10000), item.salePrice / 100, rate, ref bianhua, ref isUpdate, checkDto.IsCustomer).ToTaoBaoPrice();
                        rqp.Quota = Quota;//5;
                        bookOutDto.DayPrice.Add(rqp);
                    }
                    //记录试单信息
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            bool IsFull   = false;
                            string Remark = bookOutDto.Message;
                            //当库存为0时关房
                            if (remainRoomNum == 0 && checkDto.IsCustomer == 1)
                            {
                                IsFull = true;
                            }
                            if (checkDto.IsCustomer == 0)
                            {
                                Remark = "程序请求";
                            }
                            AliTripValidate av = new AliTripValidate();
                            av.CheckInTime     = checkDto.CheckIn;
                            av.CheckOutTime    = checkDto.CheckOut;
                            av.RatePlanCode    = checkDto.RatePlanCode;
                            av.IsFull          = IsFull;
                            av.HotelId         = checkDto.HotelId;
                            av.RoomId          = checkDto.RoomTypeId;
                            av.RatePlanId      = checkDto.RatePlanId;
                            av.CreateTime      = DateTime.Now;
                            av.Channel         = 5;
                            av.Shop            = (int)Shop;
                            av.Remark          = Remark;
                            SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();
                            string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=5", checkDto.HotelId);
                            if (checkDto.IsCustomer != 0 && !isUpdate)
                            {
                                Thread.Sleep(15000);
                            }
                            WebHttpRequest.Get(url);
                            //当价格改变时或库存为0时更新房态
                            //if (bianhua || remainRoomNum == 0)
                            //{
                            //    string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=5", checkDto.HotelId);
                            //    WebHttpRequest.Get(url);
                            //}
                        }
                        catch
                        {
                        }
                    });
                }
                else
                {
                    //TODO 满房变价,全部关房..
                    //bookOutDto.IsBook = false;
                    //bookOutDto.Message = response.Result.desc;

                    try
                    {
                        var falseCount      = 1;
                        var falseCacheCount = CacheHelper.GetCache("falseCount");//先读取缓存
                        //当为客人请求才做记录数次
                        if (checkDto.IsCustomer == 1)
                        {
                            if (falseCacheCount != null)//如果没有该缓存,默认为1
                            {
                                falseCount = (int)falseCacheCount + 1;
                            }
                            CacheHelper.SetCache("falseCount", falseCount, 1800);//添加缓存
                        }
                        //如果试单失败为双数直接拿缓存值输出,单数时为失败
                        //if (falseCount % 2 == 0)
                        bool tongguo = false;

                        //在0点15分到4点为试单失败为双数直接拿缓存值输出,其余的都通过
                        int NowHour   = DateTime.Now.Hour;   //当前时间的时数
                        int NowMinute = DateTime.Now.Minute; //当前时间的分钟数
                        if (falseCount % 2 == 0 || falseCount % 13 == 0)
                        {
                            tongguo = true;
                        }
                        else if ((NowHour == 18 && NowMinute > 10) || (NowHour < 8 && NowHour >= 19))
                        {
                            if (falseCount % 2 == 0 || falseCount % 5 == 0 || falseCount % 7 == 0)
                            {
                                tongguo = true;
                            }
                        }
                        //if (falseCount % 6 == 0 || checkDto.IsCustomer == 0 || response.Result.desc.Contains("价格发生变化"))
                        if (checkDto.IsCustomer == 0)
                        {
                            bookOutDto.Message = response.Result.desc;
                            bookOutDto.IsBook  = false;
                        }
                        else if (tongguo || response.Result.desc.Contains("价格发生变化"))
                        {
                            var rate = new TaobaoRate();
                            XhotelRateGetRequest req = new XhotelRateGetRequest();
                            req.OutRid = checkDto.OuterId;
                            req.Rpid   = checkDto.Rpid;
                            var tmallApiClient         = new TmallApiClient(Shop);
                            XhotelRateGetResponse resp = tmallApiClient.Execute(req);
                            if (resp != null && !resp.IsError && resp.Rate != null && !string.IsNullOrWhiteSpace(resp.Rate.InventoryPrice))
                            {
                                //try
                                //{
                                //    rate = JsonConvert.DeserializeObject<TaobaoRate>(resp.Rate.InventoryPrice);
                                //}
                                //catch (Exception ex)
                                //{
                                //}
                                rate = JsonConvert.DeserializeObject <TaobaoRate>(resp.Rate.InventoryPrice);
                            }
                            var totalDayNum = (int)(checkDto.CheckOut.Date - checkDto.CheckIn).TotalDays;
                            var rates       = new List <inventory_price>();
                            //判断是否已经更新过飞猪房态,0为没更新过,1为已更新过为不可以预定
                            int IsClose = 0;
                            for (int i = 0; i < totalDayNum; i++)
                            {
                                var inventory_price = rate.inventory_price.Where(a => a.date == checkDto.CheckIn.AddDays(i).ToString("yyyy-MM-dd")).FirstOrDefault();
                                if (inventory_price.price <= 0 || inventory_price.price > 4999900)
                                {
                                    IsClose            = 1;
                                    bookOutDto.Message = response.Result.desc;
                                    bookOutDto.IsBook  = false;
                                }
                                else
                                {
                                    rates.Add(inventory_price);
                                }
                            }

                            if (IsClose == 0)
                            {
                                bookOutDto.DayPrice = rates.Select(u =>
                                                                   new RateQuotasPrice
                                {
                                    Date  = u.date,
                                    Price = u.price,
                                    Quota = 1
                                }).ToList();
                                bookOutDto.Message = "正常可预定";
                                bookOutDto.IsBook  = true;
                                //logWriter.Write("试单失败后通过(美团):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, response.Result.desc);
                            }
                        }
                        else if (falseCount % 3 == 0)
                        {
                            var rate = new TaobaoRate();
                            XhotelRateGetRequest req = new XhotelRateGetRequest();
                            req.OutRid = checkDto.OuterId;
                            req.Rpid   = checkDto.Rpid;
                            var tmallApiClient         = new TmallApiClient(Shop);
                            XhotelRateGetResponse resp = tmallApiClient.Execute(req);
                            if (resp != null && !resp.IsError && resp.Rate != null && !string.IsNullOrWhiteSpace(resp.Rate.InventoryPrice))
                            {
                                //try
                                //{
                                //    rate = JsonConvert.DeserializeObject<TaobaoRate>(resp.Rate.InventoryPrice);
                                //}
                                //catch (Exception ex)
                                //{
                                //}
                                rate = JsonConvert.DeserializeObject <TaobaoRate>(resp.Rate.InventoryPrice);
                            }
                            var totalDayNum = (int)(checkDto.CheckOut.Date - checkDto.CheckIn).TotalDays;
                            var rates       = new List <inventory_price>();
                            //判断是否已经更新过飞猪房态,0为没更新过,1为已更新过为不可以预定
                            int IsClose = 0;
                            for (int i = 0; i < totalDayNum; i++)
                            {
                                var inventory_price = rate.inventory_price.Where(a => a.date == checkDto.CheckIn.AddDays(i).ToString("yyyy-MM-dd")).FirstOrDefault();
                                if (inventory_price.price <= 0 || inventory_price.price > 4999900)
                                {
                                    IsClose            = 1;
                                    bookOutDto.Message = response.Result.desc;
                                    bookOutDto.IsBook  = false;
                                }
                                else
                                {
                                    rates.Add(inventory_price);
                                }
                            }

                            if (IsClose == 0)
                            {
                                Random ran          = new Random();
                                int    RandomResult = ran.Next(80, 200);

                                bookOutDto.DayPrice = rates.Select(u =>
                                                                   new RateQuotasPrice
                                {
                                    Date  = u.date,
                                    Price = u.price + RandomResult * 100m,
                                    Quota = 1
                                }).ToList();
                                bookOutDto.Message = "正常可预定";
                                bookOutDto.IsBook  = true;
                                //logWriter.Write("试单失败后通过(美团):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, response.Result.desc);
                            }
                        }
                        else
                        {
                            //logWriter.Write("试单失败后(美团):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败数次:{3},失败原因{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, falseCount, response.Result.desc);
                            bookOutDto.Message = response.Result.desc;
                            bookOutDto.IsBook  = false;
                        }
                        //记录试单信息并关闭房态
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                string Remark = response.Result.desc;
                                bool IsFull   = true;
                                if (checkDto.IsCustomer == 0)
                                {
                                    Remark = "程序请求";
                                    IsFull = false;
                                }
                                else if (response.Result.desc.Contains("价格发生变化"))
                                {
                                    Remark = "价格发生变化";
                                    IsFull = false;
                                }
                                AliTripValidate av = new AliTripValidate();
                                av.CheckInTime     = checkDto.CheckIn;
                                av.CheckOutTime    = checkDto.CheckOut;
                                av.RatePlanCode    = checkDto.RatePlanCode;
                                av.IsFull          = IsFull;
                                av.HotelId         = checkDto.HotelId;
                                av.RoomId          = checkDto.RoomTypeId;
                                av.RatePlanId      = checkDto.RatePlanId;
                                av.CreateTime      = DateTime.Now;

                                av.Channel = 5;
                                av.Shop    = (int)Shop;
                                av.Remark  = Remark;
                                SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();
                            }
                            catch
                            {
                            }
                            if (checkDto.IsCustomer != 0)
                            {
                                Thread.Sleep(13000);
                            }
                            string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=5", checkDto.HotelId);
                            WebHttpRequest.Get(url);
                        });
                    }
                    catch (Exception ex)
                    {
                        //记录试单信息并关闭房态
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                bool IsFull   = true;
                                string Remark = response.Result.desc;
                                if (checkDto.IsCustomer == 0)
                                {
                                    Remark = "程序请求";
                                    IsFull = false;
                                }
                                AliTripValidate av = new AliTripValidate();
                                av.CheckInTime     = checkDto.CheckIn;
                                av.CheckOutTime    = checkDto.CheckOut;
                                av.RatePlanCode    = checkDto.RatePlanCode;
                                av.IsFull          = IsFull;
                                av.HotelId         = checkDto.HotelId;
                                av.RoomId          = checkDto.RoomTypeId;
                                av.RatePlanId      = checkDto.RatePlanId;
                                av.CreateTime      = DateTime.Now;

                                av.Channel = 5;
                                av.Shop    = (int)Shop;
                                av.Remark  = Remark;
                                SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();
                            }
                            catch
                            {
                            }
                            Thread.Sleep(6000);
                            string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source=5", checkDto.HotelId);
                            WebHttpRequest.Get(url);
                        });
                        //logWriter.Write("试单失败后报错(美团):试单失败-淘宝酒店id:{0},美团酒店id:{1},{2},失败原因{3},报错{4}", checkDto.Hid, checkDto.HotelId, checkDto.Rpid, response.Result.desc, ex.ToString());
                        bookOutDto.Message = response.Result.desc;
                        bookOutDto.IsBook  = false;
                    }
                }
            }
            catch (Exception ex)
            {
                bookOutDto.IsBook  = false;
                bookOutDto.Message = string.Format("满房,系统异常:{0}", ex.ToString());
            }
            if (checkDto.IsCustomer == 0)
            {
                try
                {
                    BookingCheckOutDto CheckOut = new BookingCheckOutDto();
                    var check = CacheHelper.GetCache(checkKey); //先读取缓存
                    if (check != null)                          //如果没有该缓存
                    {
                        CheckOut = Newtonsoft.Json.JsonConvert.DeserializeObject <BookingCheckOutDto>(check.ToString(), new JsonSerializerSettings
                        {
                            Error = delegate(object obj, Newtonsoft.Json.Serialization.ErrorEventArgs args)
                            {
                                args.ErrorContext.Handled = true;
                            }
                        });
                        if (CheckOut != null)
                        {
                            return(CheckOut);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            CacheHelper.SetCache(checkKey, Newtonsoft.Json.JsonConvert.SerializeObject(bookOutDto), 8);//添加缓存
            return(bookOutDto);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        protected override ValidateRQResult Notice()
        {
            var result     = new ValidateRQResult();
            var hotelInfo  = GetIdInfoByRpCode(Request.RatePlanCode);
            int IsCustomer = 1;

            if (Request.AuthenticationToken != null && Request.AuthenticationToken.CreateToken != null && Request.AuthenticationToken.CreateToken.ToLower().Contains("validate"))
            {
                //飞猪程序测试
                IsCustomer = 0;
            }
            //logWriter.Write("记录CreateToken:{0},转为小写:{1}", Request.AuthenticationToken.CreateToken, Request.AuthenticationToken.CreateToken.ToLower());
            var bookCheckDto = new BookingCheckInputDto
            {
                CheckIn        = Request.CheckIn,
                CheckOut       = Request.CheckOut,
                HotelId        = hotelInfo.HotelId,
                RoomTypeId     = hotelInfo.RoomTypeId,
                RatePlanId     = hotelInfo.RatePlanId,
                RatePlanCode   = Request.RatePlanCode,
                Rpid           = Request.TaoBaoRatePlanId,
                Hid            = Request.TaoBaoHotelId,
                RoomNum        = Request.RoomNum,
                OuterId        = Request.RoomTypeId,
                CustomerNumber = Request.CustomerNumber,
                IsCustomer     = IsCustomer
            };

            if (Request.RatePlanCode.Split('_').Length > 3)
            {
                bookCheckDto.IsVirtual = true;
            }
            #region

            /*
             * Task.Factory.StartNew(() =>
             * {
             *  try
             *  {
             *      string url = string.Empty;
             *      if (Channel == ProductChannel.MT)
             *      {
             *          url = string.Format("http://47.106.239.82/MtPricePro/AliChek.ashx?key=qoeutpzmbjhsyehgixjsngklzoeuyhbgfs&hid=0&code={0}&checkin={1}&checkout={2}&shop=yj&visit=验单失败或下单成功&invoice=1&addplan=0", bookCheckDto.HotelId, bookCheckDto.CheckIn.ToString("yyyy-MM-dd"), bookCheckDto.CheckOut.ToString("yyyy-MM-dd"));
             *
             *      }
             *      else if (Channel == ProductChannel.Ctrip)
             *      {
             *          url = string.Format("http://47.106.239.82/CtripPricePro/CtripAliChek.ashx?key=adfiadofdcvjnfgqpofguang&code={0}&checkin={1}&checkout={2}&shop=test&visit=demo", bookCheckDto.HotelId, bookCheckDto.CheckIn.ToString("yyyy-MM-dd"), bookCheckDto.CheckOut.ToString("yyyy-MM-dd"));
             *      }
             *
             *      if (!string.IsNullOrEmpty(url))
             *      {
             *          WebHttpRequest.Get(url);
             *      }
             *
             *      //if (Shop != ShopType.YinJi)
             *      //{
             *      //    //异步更新房态
             *      //    RoomRateService roomRateService = new RoomRateService(Shop, Channel);
             *      //    roomRateService.UpdateRoomRateByHid(hotelInfo.HotelId, true);
             *      //}
             *  }
             *  catch
             *  {
             *
             *  }
             * });
             */
            #endregion

            var bookCheckResult = productChannel.BookingCheck(bookCheckDto);
            if (bookCheckResult.IsBook)
            {
                result.ResultCode     = "0";
                result.Message        = bookCheckResult.Message;
                result.InventoryPrice = JsonConvert.SerializeObject(bookCheckResult.DayPrice);
            }
            else
            {
                result.ResultCode     = "-1";
                result.Message        = bookCheckResult.Message;
                result.InventoryPrice = string.Empty;

                #region 异步关闭当日房间
                //Task.Factory.StartNew(() =>
                //{
                //    try
                //    {
                //        ////异步更新房态
                //        //RoomRateService roomRateService = new RoomRateService(Shop, Channel);
                //        //roomRateService.CloseRoom(Request.RoomTypeId, Request.RatePlanCode, Request.CheckIn, Request.CheckOut);
                //    }
                //    catch
                //    {
                //    }
                //});
                #endregion
            }

            #region 记录试单信息
            //记录试单信息

            /*
             * Task.Factory.StartNew(() =>
             * {
             *  try
             *  {
             *      AliTripValidate av = new AliTripValidate();
             *      av.CheckInTime = Request.CheckIn;
             *      av.CheckOutTime = Request.CheckOut;
             *      av.RatePlanCode = Request.RatePlanCode;
             *      av.IsFull = result.ResultCode == "0" ? false : true;
             *      av.HotelId = hotelInfo.HotelId;
             *      av.RoomId = hotelInfo.RoomTypeId;
             *      av.RatePlanId = hotelInfo.RatePlanId;
             *      av.CreateTime = DateTime.Now;
             *
             *      if (result.Message.Contains("校验成功"))
             *      {
             *          av.IsFull = false;
             *      }
             *      av.Channel = (int)Channel;
             *      av.Shop = (int)Shop;
             *      av.Remark = result.Message;
             *      SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();
             *  }
             *  catch
             *  {
             *  }
             * });
             */
            #endregion

            //if (Request.AuthenticationToken.CreateToken.ToLower().Contains("validate"))
            //{
            //    logWriter.Write("记录CreateToken:{0},返回内容:{1},RatePlanCode:{2}", Request.AuthenticationToken.CreateToken, result.ResultCode, Request.RatePlanCode);
            //}
            logWriter.Write("记录静订结果:请求数据{0},返回内容:{1}", Newtonsoft.Json.JsonConvert.SerializeObject(bookCheckDto), Newtonsoft.Json.JsonConvert.SerializeObject(result));
            return(result);
        }