コード例 #1
0
        //房价 baoku/hotel/getRoomRateList
        /// <summary>
        /// 酒店价格
        /// </summary>
        /// <param name="maxId">外部酒店ID</param>
        /// <param name="start">起始日期</param>
        /// <param name="top">几天</param>
        /// <returns></returns>
        public static DataResult GetRoomRate(int id, DateTime start, int top)
        {
            var result = new DataResult();
            var url    = AtourSignUtil.AtourAuth_URL + "baoku/hotel/getRoomRateList";

            var hDb       = new H_HotelInfoAccess();
            var hotelList = hDb.Query().Where(h => h.HIOutId == id && h.HIOutType == 1)?.ToList();

            if (hotelList == null || hotelList.Count == 0)
            {
                result.Message = "未查询到酒店";
                return(result);
            }


            //hotelId 是店ID
            //roomTypeId  是0房间类型ID(取接口4中的对应字段即可)
            //roomRateTypeId 否0旧版本价格类型ID(18; 协议价格 28:"【中介预付】ota-npp;29: "【中介现付】ota - npc",41,:"【中介预付】卖价"等,可兼容)
            //mebId 否12345会员ID;HRS渠道可以不传(不传则输出该渠道下所有房价数据),其它渠道必传;
            //start 是"2018-08-10"开始日期,格式: yyyy - MM - dd
            //end 是"2018-08-11"结束日期,格式:yyyy - MM - dd
            hotelList.ForEach(x =>
            {
                var d           = SetRoomRate(x, start, top);
                result.Message += d.Message;
            });

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 酒店详情
        /// </summary>
        /// <param name="maxId"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public static DataResult GetHotelDetail(int maxId, int top)
        {
            var result = new DataResult();

            var hDb       = new H_HotelInfoAccess();
            var hotelList = hDb.Query().Where(h => h.Id >= maxId && h.HIOutType == 1).Top(top)?.ToList();

            if (hotelList == null || hotelList.Count == 0)
            {
                return(result);
            }

            hotelList.ForEach(x =>
            {
                var dic = new Dictionary <string, string>();
                dic.Add("appId", AtourSignUtil.AtourAuth_APPID);
                dic.Add("hotelId", x.HIOutId.ToString());
                var sign  = AtourSignUtil.GetSignUtil(dic);
                var url   = AtourSignUtil.AtourAuth_URL + "baoku/hotel/getHotel";
                url      += "?appId=" + AtourSignUtil.AtourAuth_APPID + "&hotelId=" + x.HIOutId + "&sign=" + sign;
                var rtn   = ApiHelper.HttpGet(url)?.ToObject <AtourHotelDetailResponse>();
                var hotel = rtn?.result;
                if (hotel?.hotelId > 0)
                {
                    hDb.Update().Set(h =>
                                     h.HIName == hotel.name &&
                                     h.HIUpdateName == "亚朵数据更新" &&
                                     h.HIUpdateTime == DateTime.Now
                                     ).Where(h => h.Id == x.Id).Execute();
                    logDb.AddLog(x.Id, $"亚朵更新酒店:{hotel.hotelId}:{hotel.name}", ResourceLogType.HotelUpdate);

                    //更新图片
                    PidInit(hotel, x.Id);

                    //会员 暂时未开发
                }
                else
                {
                    result.Message = rtn?.msg ?? "系统异常";
                }
            });

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// 酒店新增
        /// </summary>
        private static void HotelInsert(List <XiWanHotelInfo> list)
        {
            var xwList = new List <XiWanHotelInfo>();

            list?.ForEach(x =>
            {
                xwList.Add(x);
                if (xwList.Count == 10)
                {
                    var wxIds  = xwList.Select(a => a.HotelId).ToList();
                    var hDb    = new H_HotelInfoAccess();
                    var dbList = hDb.Query().Where(h => h.HIOutId.In(wxIds) && h.HIOutType == 2)?.ToList()?.Select(h => h.HIOutId)?.ToList();
                    wxIds      = wxIds.Where(a => !dbList.Contains(a))?.ToList();

                    var addList = new List <H_HotelInfoModel>();
                    wxIds?.ForEach(a =>
                    {
                        var hotel = xwList.FirstOrDefault(xx => xx.HotelId == a);
                        var model = new H_HotelInfoModel()
                        {
                            HIIsValid = 1,
                            HIOutId   = hotel.HotelId,
                            HIOutType = 2,
                            HIName    = hotel.HotelName,
                            HIAddName = "喜玩新增",
                        };
                        var id = (int)hDb.Add(model);
                        //增量同步
                        //OpenApi.SysInfo(id);
                        OpenApi.HotelOffline(id, 1);
                        logDb.AddLog(id, $"喜玩新增酒店:{hotel.HotelId}:{hotel.HotelName}", ResourceLogType.HotelAdd);
                    });
                    //if (addList != null && addList.Count > 0)
                    //{
                    //    hDb.AddBatch(addList);
                    //}
                    xwList = new List <XiWanHotelInfo>();
                }
            });
        }
コード例 #4
0
        /// <summary>
        /// 获取酒店列表
        /// </summary>
        /// <returns></returns>
        public static DataResult GetHotelList(int maxId, int top)
        {
            var result = new DataResult()
            {
                Data = $"{maxId + top};"
            };

            var citylist = new Sys_AreaMatchAccess().Query().Where(x => x.OutType == 1 && x.HbId > maxId).ToList();

            if (citylist == null || !citylist.Any())
            {
                result.Message = $"{maxId}未查询到数据";
                result.Data    = $"{maxId + top}";
                return(result);
            }
            var log = string.Empty;

            foreach (var item in citylist)
            {
                result.Data += $"[{item.OutCityId}]:";
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("appId", AtourSignUtil.AtourAuth_APPID);
                dic.Add("cityId", item.OutCityId.ToString());
                var sign = AtourSignUtil.GetSignUtil(dic);
                var url  = AtourSignUtil.AtourAuth_URL + "baoku/hotel/getHotelList";
                url += "?appId=" + AtourSignUtil.AtourAuth_APPID + "&cityId=" + item.OutCityId.ToString() + "&sign=" + sign;
                var hotellst = ApiHelper.HttpGet(url);
                if (!string.IsNullOrWhiteSpace(hotellst))
                {
                    var baseCity = new Sys_AreaInfoAccess2().Query().FirstOrDefault(x => x.id == item.HbId);
                    var baseProv = new Sys_AreaInfoAccess2().Query().FirstOrDefault(x => x.id == baseCity.pid);
                    var data     = hotellst.ToObject <AtourHotelResponse>();
                    result.Data += $"{baseCity.name}酒店数量:{data?.result?.Count};";
                    data?.result?.ForEach(x =>
                    {
                        var hDb   = new H_HotelInfoAccess();
                        var model = hDb.Query().Where(h => h.HIOutId == x.hotelId && h.HIOutType == 1).FirstOrDefault();
                        int id    = model?.Id ?? 0;
                        if (model == null || id <= 0)
                        {
                            model = new H_HotelInfoModel()
                            {
                                HIOutId             = x.hotelId,
                                HIOutType           = 1,
                                HIName              = x.name ?? String.Empty,
                                HIAddress           = x.address ?? String.Empty,
                                HILinkPhone         = x.tel ?? string.Empty,
                                HICity              = baseCity.name,
                                HICityId            = baseCity.id,
                                HIProvince          = baseProv.name,
                                HIProvinceId        = baseCity.pid,
                                HIAddName           = "",
                                HIAddTime           = DateTime.Now,
                                HICheckIn           = string.Empty,
                                HICheckOut          = string.Empty,
                                HIChildRemark       = string.Empty,
                                HICounty            = string.Empty,
                                HICountyId          = 0,
                                HIFacilities        = string.Empty,
                                HIHotelIntroduction = string.Empty,
                                HIIsValid           = 1,
                                HIPetRemark         = string.Empty,
                                HIShoppingArea      = string.Empty,
                                HIShoppingAreaId    = 0,
                                HIUpdateName        = string.Empty,
                                HIUpdateTime        = DateTime.Now,
                                HIGdLonLat          = $"{x.longitude},{x.latitude}"
                            };
                            id = (int)(hDb.Add(model));
                            //OpenApi.SysInfo(id);
                            OpenApi.HotelOffline(id, 1);
                            logDb.AddLog(id, $"亚朵新增酒店:{x.hotelId}:{x.name}", ResourceLogType.HotelAdd);
                        }
                        else
                        { //更新
                          //hDb.Update().Where(h=>h.Id==id)
                          //.Set(h=>h.);
                        }
                        if (id > 0)
                        {
                            PidInit(x, id);
                        }
                    });
                }
                else
                {
                    result.Data += $"无数据;";
                }
            }

            return(result);
        }
コード例 #5
0
        //房型 baoku/hotel/getRoomTypeList
        /// <summary>
        /// 酒店房型
        /// </summary>
        /// <param name="maxId"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public static DataResult GetRoomType(int id, int top)
        {
            var result = new DataResult();

            result.Data = string.Empty;
            var hDb       = new H_HotelInfoAccess();
            var hotelList = hDb.Query().Where(h => h.Id >= id && h.HIOutType == 1).Top(top)?.ToList();

            if (hotelList == null || hotelList.Count == 0)
            {
                result.Message = "未查询到酒店";
                return(result);
            }
            var indexCount = 0;

            hotelList.ForEach(x =>
            {
                var dic = new Dictionary <string, string>();
                dic.Add("appId", AtourSignUtil.AtourAuth_APPID);
                dic.Add("hotelId", x.HIOutId.ToString());

                var sign = AtourSignUtil.GetSignUtil(dic);
                var url  = AtourSignUtil.AtourAuth_URL + "baoku/hotel/getRoomTypeList";
                url     += "?appId=" + AtourSignUtil.AtourAuth_APPID + "&hotelId=" + x.HIOutId + "&sign=" + sign;
                var rtn  = ApiHelper.HttpGet(url)?.ToObject <YdRoomTypeResponse>();
                var list = rtn?.result;
                if (list?.Count > 0)
                {
                    if (x.HIIsValid == 0)
                    {
                        hDb.Update().Where(h => h.Id == x.Id)
                        .Set(h => h.HIIsValid == 1 && h.HIUpdateName == "亚朵更新有效" && h.HIUpdateTime == DateTime.Now)
                        .Execute();
                        OpenApi.HotelOffline(x.Id, 1);
                        logDb.AddLog(x.Id, $"亚朵更新有效:{x.HIOutId}:{x.HIName}", ResourceLogType.HotelUpdate);
                    }

                    var listId     = list.Select(l => l.roomTypeId).ToList();
                    var db         = new H_HotelRoomAccess();
                    var room       = db.Query().Where(r => r.HIId == x.Id).ToList();
                    var updateList = room?.Where(r => listId.Contains(r.HROutId) && r.HROutType == 1)?.ToList();
                    result.Data   += $"[{indexCount++}]{x.HIName}新增房型{list.Count()}个;";
                    list.ForEach(l =>
                    {
                        var baseRoom = room?.Where(r => r.HROutId == l.roomTypeId && r.HIId == x.Id && r.HROutType == 1)?.FirstOrDefault();
                        if (baseRoom == null || baseRoom.Id <= 0)
                        {
                            var roomId = db.Add(new H_HotelRoomModel
                            {
                                Id            = 0,
                                HIId          = x.Id,
                                HROutType     = 1,
                                HROutId       = l.roomTypeId,
                                HRName        = l.roomTypeName ?? string.Empty,
                                HRRoomSIze    = string.Empty,
                                HRAddName     = "亚朵新增",
                                HRAddTime     = DateTime.Now,
                                HRBedType     = GetBedType(l.bedRemark, l.roomTypeName ?? string.Empty),
                                HRBedSize     = GetBedSize(l.bedRemark, l.roomTypeName ?? string.Empty),
                                HRFloor       = string.Empty,
                                HRIsValid     = 1,
                                HRPersonCount = 0,
                                HRUpdateName  = string.Empty,
                                HRUpdateTime  = DateTime.Now,
                                HRWindowsType = 0
                            });
                            logDb.AddLog(x.Id, $"亚朵新增房型:{x.HIOutId}:{x.HIName};{l.roomTypeId}", ResourceLogType.RoomAdd);
                        }
                        else
                        {
                            if (baseRoom.HRBedType == 0)
                            {
                                db.Update().Set(rr => rr.HRBedType == GetBedType(l.bedRemark, l.roomTypeName ?? string.Empty))
                                .Set(rr => rr.HRBedSize == GetBedSize(l.bedRemark, l.roomTypeName ?? string.Empty))
                                .Set(rr => rr.HRUpdateTime == DateTime.Now)
                                .Where(rr => rr.Id == baseRoom.Id).Execute();
                                logDb.AddLog(x.Id, $"亚朵更新房型床型:{x.HIOutId}:{x.HIName};{l.roomTypeId}", ResourceLogType.RoomUpdate);
                            }
                        }
                        //是否要修改
                    });
                    OpenApi.AddRoomInfo(x.Id);
                }
                else
                {
                    //房型数量为0  酒店无效
                    hDb.Update().Where(h => h.Id == x.Id)
                    .Set(h => h.HIIsValid == 0 && h.HIUpdateName == "亚朵无房型更新" && h.HIUpdateTime == DateTime.Now)
                    .Execute();
                    OpenApi.HotelOffline(x.Id, 0);
                    result.Message = rtn?.msg ?? "系统异常";
                    logDb.AddLog(x.Id, $"亚朵无房型更新:{x.HIOutId}:{x.HIName}", ResourceLogType.HotelDelete);
                }
                //查询最近三天的价格和库存
                var rrRtn    = GetRoomRate(x.HIOutId, DateTime.Now, 7);
                result.Data += rrRtn.Message?.ToString() ?? string.Empty;
            });

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// 喜玩价格
        /// </summary>
        /// <returns></returns>
        public static DataResult Xw_HotelPrice(long id = 0)
        {
            var rtn = new DataResult();

            var roomDb = new H_HotelRoomAccess();
            var hDb    = new H_HotelInfoAccess();
            var query  = hDb?.Query().Where(h => h.HIOutType == 2);

            if (id > 0)
            {
                query?.Where(x => x.Id == id);
            }
            var hotelList = query.ToList();

            hotelList?.ForEach(x =>
            {
                var hotel = GetHotelPrice(x.HIOutId);
                if (hotel != null && hotel.HotelId > 0)
                {
                    var c        = hotel?.Rooms?.Count() ?? 0;
                    rtn.Message += $"{c}个;";
                    if (c == 0)
                    {//房型数量为0  酒店无效
                        hDb.Update().Where(h => h.Id == x.Id)
                        .Set(h => h.HIIsValid == 0 && h.HIUpdateName == "喜玩无房型更新" && h.HIUpdateTime == DateTime.Now)
                        .Execute();
                        OpenApi.HotelOffline(x.Id, 0);
                        logDb.AddLog(x.Id, $"喜玩无房型更新:{hotel.HotelId}:{hotel.HotelName}", ResourceLogType.HotelDelete);

                        rtn.Message += $"[无效]";
                    }
                    else
                    {
                        if (x.HIIsValid == 0)
                        {
                            hDb.Update().Where(h => h.Id == x.Id)
                            .Set(h => h.HIIsValid == 1 && h.HIUpdateName == "喜玩更新酒店有效" && h.HIUpdateTime == DateTime.Now)
                            .Execute();
                            OpenApi.HotelOffline(x.Id, 1);
                            logDb.AddLog(x.Id, $"喜玩更新酒店有效:{hotel.HotelId}:{hotel.HotelName}", ResourceLogType.HotelUpdate);

                            rtn.Message += $"[有效]";
                        }
                        hotel?.Rooms?.ForEach(r =>
                        {
                            var oldRoom = roomDb.Query().Where(rd => rd.HIId == x.Id && rd.HROutId == r.RoomTypeId.ToInt()).FirstOrDefault();
                            if (oldRoom == null || oldRoom.Id <= 0)
                            {
                                oldRoom = new H_HotelRoomModel
                                {
                                    HROutId       = r.RoomTypeId.ToInt(),
                                    HIId          = x.Id,
                                    Id            = 0,
                                    HRAddName     = "喜玩新增",
                                    HRAddTime     = DateTime.Now,
                                    HRBedType     = GetBedType(r.RoomName, r.BedType),//需要转化
                                    HRBedSize     = GetBedSize(r.RoomName, r.BedType),
                                    HRFloor       = string.Empty,
                                    HRIsValid     = 1,
                                    HRName        = r.RoomName ?? String.Empty,
                                    HROutType     = 2,
                                    HRPersonCount = 0,
                                    HRRoomSIze    = r.Description ?? string.Empty,
                                    HRUpdateName  = string.Empty,
                                    HRUpdateTime  = new DateTime(2000, 1, 1),
                                    HRWindowsType = 0//需要转化
                                };
                                oldRoom.Id = (int)roomDb.Add(oldRoom);
                                logDb.AddLog(x.Id, $"喜玩新增房型:{hotel.HotelId}:{hotel.HotelName}:{r.RoomTypeId}", ResourceLogType.RoomAdd);
                            }
                            else
                            {//修改暂时不弄
                                if (oldRoom.HRBedType == 0)
                                {
                                    roomDb.Update().Set(rr => rr.HRBedType == GetBedType(r.RoomName, r.BedType))
                                    .Set(rr => rr.HRBedSize == GetBedSize(r.RoomName, r.BedType))
                                    .Where(rr => rr.Id == oldRoom.Id).Execute();
                                    logDb.AddLog(x.Id, $"喜玩更新房型床型:{hotel.HotelId}:{hotel.HotelName}:{r.RoomTypeId}", ResourceLogType.RoomUpdate);
                                }
                            }

                            if (oldRoom.Id > 0)
                            {
                                var rrDb = new H_HotelRoomRuleAccess();
                                //价格策略
                                var oldRule = rrDb.Query().Where(rr => rr.HRId == oldRoom.Id && rr.HRROutCode == r.RoomId && rr.HRROutType == 2).FirstOrDefault();
                                if (oldRule == null || oldRule.Id <= 0)
                                {
                                    oldRule = new H_HotelRoomRuleModel
                                    {
                                        Id                   = 0,
                                        HRROutCode           = r.RoomId,
                                        HRRXwProductSerial   = r.ProductSerial,
                                        HIId                 = x.Id,
                                        HRId                 = oldRoom.Id,
                                        HRRAddName           = "喜玩新增",
                                        HRRAddTime           = DateTime.Now,
                                        HRRBreakfastRule     = 0,
                                        HRRBreakfastRuleName = string.Empty,
                                        HRRCancelRule        = 0,
                                        HRRCancelRuleName    = string.Empty,
                                        HRRIsValid           = 1,
                                        HRRName              = r.RoomName ?? String.Empty,
                                        HRROutId             = 0,
                                        HRROutType           = 2,
                                        HRRSourceId          = 10103,
                                        HRRSourceName        = "代理",
                                        HRRSupplierId        = 2,
                                        HRRSupplierName      = "喜玩",
                                        HRRUpdateName        = string.Empty,
                                        HRRUpdateTime        = new DateTime(2000, 1, 1),
                                    };
                                    oldRule.Id = (int)rrDb.Add(oldRule);
                                    logDb.AddLog(x.Id, $"喜玩新增策略:{hotel.HotelId}:{hotel.HotelName}:{r.RoomId}", ResourceLogType.RuleAdd);
                                }
                                else
                                {
                                    var sql = rrDb.Update().Where(rr => rr.Id == oldRule.Id);
                                    sql.Set(rr => rr.HRRXwProductSerial == r.ProductSerial &&
                                            rr.HRRUpdateName == "喜玩更新" && rr.HRRIsValid == 1 &&
                                            rr.HRRUpdateTime == DateTime.Now
                                            ).Execute();
                                    logDb.AddLog(x.Id, $"喜玩更新策略:{hotel.HotelId}:{hotel.HotelName}:{r.RoomId}", ResourceLogType.RuleUpdate);
                                }
                                if (oldRule.Id > 0)
                                {
                                    var pDb = new H_HoteRulePriceAccess();
                                    r.Rates?.ForEach(p =>
                                    {
                                        var dateInit = ConvertHelper.ToInt32(p.Date.ToString("yyyyMMdd"), 0);
                                        var price    = pDb.Query().Where(pr => pr.HRRId == oldRule.Id && pr.HRPDateInt == dateInit).FirstOrDefault();
                                        if (price == null || price.Id <= 0)
                                        {//新增价格和库存
                                            price = new H_HoteRulePriceModel
                                            {
                                                Id               = 0,
                                                HIId             = x.Id,
                                                HRId             = oldRoom.Id,
                                                HRPAddName       = "喜玩新增",
                                                HRPAddTime       = DateTime.Now,
                                                HRPContractPrice = p.Price,
                                                HRPDate          = p.Date,
                                                HRPCount         = p.AvailableNum == 0 && p.Status ? 5 : p.AvailableNum,
                                                HRPDateInt       = dateInit,
                                                HRPIsValid       = 1,
                                                HRPRetainCount   = 0,
                                                HRPSellPrice     = p.Price,
                                                HRPStatus        = 1,
                                                HRPUpdateName    = string.Empty,
                                                HRPUpdateTime    = new DateTime(2000, 1, 1),
                                                HRRId            = oldRule.Id
                                            };
                                            price.Id = (int)pDb.Add(price);
                                            logDb.AddLog(x.Id, $"喜玩新增价格:{hotel.HotelId}:{hotel.HotelName}:{r.RoomId}:{p.Price}:{price.HRPCount}:{price.HRPDateInt}", ResourceLogType.PriceAdd);
                                        }
                                        else
                                        {
                                            var sql = pDb.Update().Where(pr => pr.Id == price.Id);
                                            sql.Set(pr => pr.HRPCount == (p.AvailableNum == 0 && p.Status ? 5 : p.AvailableNum));
                                            sql.Set(pr => pr.HRPContractPrice == p.Price &&
                                                    pr.HRPIsValid == (p.Status ? 1 : 0) &&
                                                    pr.HRPSellPrice == p.Price &&
                                                    pr.HRPUpdateName == "喜玩更新" &&
                                                    pr.HRPUpdateTime == DateTime.Now
                                                    ).Execute();
                                            logDb.AddLog(x.Id, $"喜玩更新价格:{hotel.HotelId}:{hotel.HotelName}:{r.RoomId}:{p.Price}:{price.HRPCount}:{price.HRPDateInt}", ResourceLogType.PriceUpdate);
                                        }
                                        OpenApi.AddRuleInfo(x.Id, oldRoom.Id, p.BreakfastNum, price.Id, p.Status ? 1 : 0);
                                        OpenApi.SysInfo(x.Id);
                                    });
                                }
                            }
                        });

                        var outRoomIds = hotel?.Rooms?.Select(r => r.RoomTypeId.ToInt()).ToList() ?? new List <int>(); //接口返回的房型Id
                        var dbRooms    = roomDb.Query().Where(rd => rd.HIId == x.Id).ToList();
                        var errDbRooms = dbRooms?.Where(rd => !outRoomIds.Contains(rd.HROutId))?.ToList();
                        if (errDbRooms != null && errDbRooms.Any())
                        {
                            LogHelper.Info("待无效房型id:" + JsonHelper.ToJson(errDbRooms) + "|| 更新时间:" + DateTime.Now.ToString(), "喜玩更新无效房型");
                        }
                        errDbRooms?.ForEach(err =>
                        {
                            //更新房型无效
                            roomDb.Update().Set(rr => rr.HRIsValid == 0)
                            .Where(rr => rr.Id == err.Id).Execute();

                            var pDb = new H_HoteRulePriceAccess();
                            //查询价格Id
                            var errDbPrice = pDb.Query().Where(pr => pr.HRId == err.Id).ToList();
                            //更新库存为0
                            var sql = pDb.Update().Where(pr => pr.HRId == err.Id);
                            sql.Set(pr => pr.HRPCount == 0 &&
                                    pr.HRPIsValid == 0 &&
                                    pr.HRPUpdateName == "喜玩更新" &&
                                    pr.HRPUpdateTime == DateTime.Now
                                    ).Execute();

                            //同步价格策略
                            errDbPrice.ForEach(pr =>
                            {
                                OpenApi.AddRuleInfo(x.Id, err.Id, 0, pr.Id, 0);
                            });
                            logDb.AddLog(x.Id, $"喜玩更新房型无效:{hotel.HotelId}:{hotel.HotelName}:{err.HROutId}", ResourceLogType.RoomDelete);
                        });

                        //同步房型
                        OpenApi.AddRoomInfo(x.Id);
                    }
                }
                else
                {//查询不到酒店信息无效
                    hDb.Update().Where(h => h.Id == x.Id)
                    .Set(h => h.HIIsValid == 0 && h.HIUpdateName == "喜玩酒店无信息更新" && h.HIUpdateTime == DateTime.Now)
                    .Execute();
                    OpenApi.HotelOffline(x.Id, 0);
                    logDb.AddLog(x.Id, $"喜玩酒店无信息更新:{hotel.HotelId}:{hotel.HotelName}:{x.HIOutId}", ResourceLogType.HotelDelete);
                    rtn.Message += $"[无效]";
                }
            });
            return(rtn);
        }
コード例 #7
0
        /// <summary>
        /// 酒店详情
        /// </summary>
        /// <param name="maxId"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public static DataResult GetHotelDetail(int maxId, int top)
        {
            var result = new DataResult();

            var hDb       = new H_HotelInfoAccess();
            var hotelList = hDb.Query().Where(h => h.Id >= maxId && h.HIOutType == 2).Top(top).OrderBy(h => h.HIOutId)?.ToList();

            if (hotelList == null || hotelList.Count == 0)
            {
                result.Message = "无数据";
                return(result);
            }
            var provList = new Sys_AreaInfoAccess2().Query().Where(x => x.type == 2).ToList();
            var msgList  = new List <string>();

            Parallel.ForEach(hotelList, new ParallelOptions()
            {
                MaxDegreeOfParallelism = 3
            }, (x, loopstate) =>
            {
                try
                {
                    var request = new XiWanHotelDetailRequest {
                        HotelId = x.HIOutId
                    };
                    var rtn   = XiWanAPI.XiWanPost <XiWanHotelDetail, XiWanHotelDetailRequest>(request, HotelDetailUrl);
                    var hotel = rtn?.Result;
                    if (hotel?.HotelId > 0)
                    {
                        var city = AddCityCode(hotel.CityCode, hotel.CityName) ?? new Sys_AreaInfoModel();
                        var prov = new Sys_AreaInfoModel();
                        if (city.pid > 0)
                        {
                            prov = provList.FirstOrDefault(p => p.id == city.pid) ?? new Sys_AreaInfoModel();
                        }
                        hDb.Update().Set(h =>
                                         h.HIGdLonLat == hotel.Position &&
                                         h.HIName == hotel.HotelName &&
                                         h.HIHotelIntroduction == hotel.Intro &&
                                         h.HIAddress == hotel.Address &&
                                         h.HILinkPhone == hotel.Tel &&
                                         h.HICityId == city.id &&
                                         h.HICity == (city.name ?? string.Empty) &&
                                         h.HIProvinceId == prov.id &&
                                         h.HIProvince == (prov.name ?? string.Empty) &&
                                         h.HIUpdateName == "喜玩详情接口更新" &&
                                         h.HIUpdateTime == DateTime.Now
                                         ).Where(h => h.Id == x.Id).Execute();
                        //会员 暂时未开发
                        logDb.AddLog(x.Id, $"喜玩详情接口更新:{hotel.HotelId}:{hotel.HotelName}", ResourceLogType.HotelUpdate);
                    }
                    else
                    {
                        msgList.Add(rtn?.Msg ?? "系统异常");
                    }

                    //房型等
                    var d1 = Xw_HotelPrice(x.Id);
                    msgList.Add($"||{x.Id}:{d1.Message}");
                    Thread.Sleep(10);
                }
                catch (Exception ex)
                {
                    var log = $"{ex.Message}--{x.Id}---{ex.ToString()}";
                    LogHelper.Error(log);
                }
            });
            result.Data = msgList;
            return(result);
        }