Пример #1
0
        /// <summary>
        /// 城市
        /// </summary>
        /// <param name="code"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Sys_AreaInfoModel AddCityCode(string code, string name)
        {
            var city      = new Sys_AreaInfoModel();
            var oldList   = new Sys_AreaInfoAccess2().Query().Where(x => x.type == 3).ToList();
            var modellist = new List <Sys_AreaMatchModel>();
            var matchDb   = new Sys_AreaMatchAccess();
            var cityMatch = matchDb.Query().Where(x => x.OutType == 2 && x.OutCityCode == code).FirstOrDefault();

            if (cityMatch == null || cityMatch.Id <= 0)
            {
                city      = oldList.FirstOrDefault(x => x.name == name);
                cityMatch = new Sys_AreaMatchModel
                {
                    OutCityCode = code,
                    OutCityName = name,
                    OutType     = 2,
                    HbId        = city?.id ?? 0
                };
                matchDb.Add(cityMatch);
            }
            else
            {
                city = oldList.FirstOrDefault(x => x.id == cityMatch.HbId);
            }
            return(city);
        }
Пример #2
0
        //库存 baoku/hotel/getRoomInventoryList、

        #region 城市匹配


        /// <summary>
        /// 获取城市列表
        /// </summary>
        /// <returns></returns>

        public static DataResult GetCityList()
        {
            var result = new DataResult();
            var url    = AtourSignUtil.AtourAuth_URL + "city/getCityList";
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("appId", AtourSignUtil.AtourAuth_APPID);
            var sign     = AtourSignUtil.GetSignUtil(dic);
            var citylist = ApiHelper.HttpGet(url + "?appId=" + AtourSignUtil.AtourAuth_APPID + "&sign=" + sign);

            if (string.IsNullOrWhiteSpace(citylist))
            {
                result = new DataResult {
                    Code = DataResultType.Fail, Message = "系统异常"
                };
            }

            var oldList   = new Sys_AreaInfoAccess2().Query().Where(x => x.type == 3).ToList();
            var modellist = new List <Sys_AreaMatchModel>();
            var data      = citylist.ToObject <AtourCityResponse>();

            data?.result?.ForEach(n =>
            {
                var old   = oldList.FirstOrDefault(x => x.name == n.cityName.Replace("市", ""));
                var model = new Sys_AreaMatchModel
                {
                    OutProvId   = 0,
                    OutProvName = n.provinceName,
                    OutCityId   = n.cityId,
                    OutCityName = n.cityName,
                    HbId        = old?.id ?? 0,
                    OutType     = 1
                };
                var db = new Sys_AreaMatchAccess();
                var m  = db.Query().Where(x => x.OutType == 1 && x.OutCityId == n.cityId).FirstOrDefault();
                if (m == null || m.Id <= 0)
                {
                    db.Add(model);
                    result.Data += $"{old?.id}:{n.cityName};";
                }
                else
                {
                }
            });

            return(result);
        }
Пример #3
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);
        }