Exemple #1
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>();
                }
            });
        }
Exemple #2
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);
        }