Ejemplo n.º 1
0
        public static IList <StoreLocationInfo> GetStoreLocationInfoByOpenId(string openId, string longitude, string Latitude)
        {
            IList <StoreLocationInfo> list = (IList <StoreLocationInfo>)HiCache.Get($"DataCache-UserStoreInfo_{openId}");

            if (list == null)
            {
                IList <double>            list2                = new List <double>();
                string                    fromLatLng           = Latitude + "," + longitude;
                IList <string>            list3                = new List <string>();
                IList <StoreLocationInfo> allStoreLocationInfo = DepotHelper.GetAllStoreLocationInfo();
                if (allStoreLocationInfo != null && allStoreLocationInfo.Count > 0)
                {
                    list3 = (from s1 in allStoreLocationInfo
                             select s1.LatLng).ToList();
                    MapHelper.GetLatLngDistancesFromAPI(fromLatLng, list3, ref list2);
                    for (int i = 0; i < allStoreLocationInfo.Count; i++)
                    {
                        allStoreLocationInfo[i].Distances = list2[i];
                    }
                    list = (from s in allStoreLocationInfo
                            orderby s.Distances
                            select s).ToList();
                    HiCache.Insert($"DataCache-UserStoreInfo_{openId}", list, 180);
                }
            }
            return(list);
        }
Ejemplo n.º 2
0
        public static string CookieUserCoordinate(string latLng)
        {
            string text     = "";
            string province = "";
            string text2    = "";
            string country  = "";
            string text3    = "";

            DepotHelper.GetAddressByLatLng(latLng, ref text, ref province, ref text2, ref country, ref text3);
            int regionIdByRegionName = RegionHelper.GetRegionIdByRegionName(text2, 2);
            int regionId             = RegionHelper.GetRegionId(text3, country, text2, province);

            if (regionId == 0)
            {
                regionId = RegionHelper.GetRegionChildList(regionIdByRegionName, false)[0].RegionId;
            }
            string   fullPath = RegionHelper.GetFullPath(regionId, true);
            string   userCoordinateCookieName = DepotHelper.UserCoordinateCookieName;
            DateTime now = DateTime.Now;

            WebHelper.SetCookie(userCoordinateCookieName, "Coordinate", latLng, now.AddMinutes(10.0));
            string userCoordinateCookieName2 = DepotHelper.UserCoordinateCookieName;

            now = DateTime.Now;
            WebHelper.SetCookie(userCoordinateCookieName2, "NewCoordinate", latLng, now.AddMinutes(10.0));
            string text4 = HttpUtility.UrlEncode(string.IsNullOrWhiteSpace(text) ? text3 : text);
            string userCoordinateCookieName3 = DepotHelper.UserCoordinateCookieName;
            string value = text4;

            now = DateTime.Now;
            WebHelper.SetCookie(userCoordinateCookieName3, "Address", value, now.AddMinutes(10.0));
            string userCoordinateCookieName4 = DepotHelper.UserCoordinateCookieName;
            string value2 = HttpUtility.UrlEncode(text2);

            now = DateTime.Now;
            WebHelper.SetCookie(userCoordinateCookieName4, "CityName", value2, now.AddMinutes(10.0));
            string userCoordinateCookieName5 = DepotHelper.UserCoordinateCookieName;
            string value3 = regionIdByRegionName.ToString();

            now = DateTime.Now;
            WebHelper.SetCookie(userCoordinateCookieName5, "CityRegionId", value3, now.AddMinutes(10.0));
            string userCoordinateCookieName6 = DepotHelper.UserCoordinateCookieName;
            string value4 = regionId.ToString();

            now = DateTime.Now;
            WebHelper.SetCookie(userCoordinateCookieName6, "RegionId", value4, now.AddMinutes(10.0));
            string userCoordinateCookieName7 = DepotHelper.UserCoordinateCookieName;
            string value5 = fullPath;

            now = DateTime.Now;
            WebHelper.SetCookie(userCoordinateCookieName7, "FullRegionPath", value5, now.AddMinutes(10.0));
            return(text4);
        }
Ejemplo n.º 3
0
        public static void GetRegionIdFromLonLan(string latLng, out int regionId, out int areaId)
        {
            string text     = "";
            string province = "";
            string text2    = "";
            string country  = "";
            string street   = "";

            DepotHelper.GetAddressByLatLng(latLng, ref text, ref province, ref text2, ref country, ref street);
            regionId = RegionHelper.GetRegionIdByRegionName(text2, 2);
            areaId   = RegionHelper.GetRegionId(street, country, text2, province);
            if (areaId == 0)
            {
                areaId = RegionHelper.GetRegionChildList(regionId, false)[0].RegionId;
            }
        }
Ejemplo n.º 4
0
        public static StoresInfo GetNearDeliveStores(string latLng, bool isApp = false)
        {
            StoresInfo storesInfo = new StoresInfo();
            string     text       = "";
            string     province   = "";
            string     text2      = "";
            string     country    = "";
            string     text3      = "";

            DepotHelper.GetAddressByLatLng(latLng, ref text, ref province, ref text2, ref country, ref text3);
            int regionIdByRegionName = RegionHelper.GetRegionIdByRegionName(text2, 2);
            int regionId             = RegionHelper.GetRegionId(text3, country, text2, province);

            if (regionId == 0)
            {
                IList <RegionInfo> regionChildList = RegionHelper.GetRegionChildList(regionIdByRegionName, false);
                if (regionChildList != null && regionChildList.Count > 0)
                {
                    regionId = regionChildList[0].RegionId;
                }
            }
            string             fullPath         = RegionHelper.GetFullPath(regionId, true);
            string             fullPath2        = RegionHelper.GetFullPath(regionId, true);
            IList <StoresInfo> nearDeliveStores = new StoresDao().GetNearDeliveStores(regionIdByRegionName, fullPath);

            storesInfo = DepotHelper.GetBestNearStoreInfo(latLng, nearDeliveStores);
            if (storesInfo == null || storesInfo.StoreId <= 0)
            {
                nearDeliveStores = new StoresDao().GetNearOtherStores(regionIdByRegionName);
                storesInfo       = DepotHelper.GetBestNearStoreInfo(latLng, nearDeliveStores);
            }
            if (!isApp)
            {
                string   userCoordinateTimeCookieName = DepotHelper.UserCoordinateTimeCookieName;
                DateTime now   = DateTime.Now;
                string   value = now.ToString();
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateTimeCookieName, value, now.AddMinutes(1.0), null, true);
                string userCoordinateCookieName = DepotHelper.UserCoordinateCookieName;
                string value2 = HttpUtility.UrlEncode(string.IsNullOrWhiteSpace(text) ? text3 : text);
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName, "Address", value2, now.AddMinutes(10.0));
                string userCoordinateCookieName2 = DepotHelper.UserCoordinateCookieName;
                string value3 = HttpUtility.UrlEncode(text2);
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName2, "CityName", value3, now.AddMinutes(10.0));
                string userCoordinateCookieName3 = DepotHelper.UserCoordinateCookieName;
                string value4 = regionIdByRegionName.ToString();
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName3, "CityRegionId", value4, now.AddMinutes(10.0));
                string userCoordinateCookieName4 = DepotHelper.UserCoordinateCookieName;
                string value5 = regionId.ToString();
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName4, "RegionId", value5, now.AddMinutes(10.0));
                string userCoordinateCookieName5 = DepotHelper.UserCoordinateCookieName;
                string value6 = storesInfo.StoreId.ToString();
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName5, "StoreId", value6, now.AddMinutes(10.0));
                string userCoordinateCookieName6 = DepotHelper.UserCoordinateCookieName;
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName6, "Coordinate", latLng, now.AddMinutes(10.0));
                string userCoordinateCookieName7 = DepotHelper.UserCoordinateCookieName;
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName7, "NewCoordinate", latLng, now.AddMinutes(10.0));
                string userCoordinateCookieName8 = DepotHelper.UserCoordinateCookieName;
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName8, "StoreType", "1", now.AddMinutes(10.0));
                string userCoordinateCookieName9 = DepotHelper.UserCoordinateCookieName;
                string value7 = fullPath2;
                now = DateTime.Now;
                WebHelper.SetCookie(userCoordinateCookieName9, "FullRegionPath", value7, now.AddMinutes(10.0));
            }
            return(storesInfo);
        }