Beispiel #1
0
        public void ChangePosition(HttpContext context)
        {
            string text = context.Request["fromLatLng"];
            string str  = context.Request["address"];

            context.Response.ContentType = "text/json";
            if (string.IsNullOrEmpty(text))
            {
                context.Response.Write("{\"Status\":\"noLatLng\",\"Message\":\"定位失败!\"}");
            }
            else
            {
                try
                {
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                    if (!masterSettings.OpenMultStore)
                    {
                        context.Response.Write("{\"Status\":\"platform\",\"Message\":\"进入平台页面!\"}");
                    }
                    else
                    {
                        string store_PositionRouteTo = masterSettings.Store_PositionRouteTo;
                        text = text.Trim().Replace(" ", "");
                        MemberInfo user = HiContext.Current.User;
                        DateTime   now;
                        if (store_PositionRouteTo.Equals("NearestStore"))
                        {
                            if (user != null && user.StoreId > 0 && masterSettings.Store_IsMemberVisitBelongStore)
                            {
                                DepotHelper.CookieUserCoordinate(text);
                                string userCoordinateCookieName = DepotHandler.UserCoordinateCookieName;
                                string value = HttpUtility.UrlEncode(str);
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateCookieName, "Address", value, now.AddDays(10.0));
                                string userCoordinateTimeCookieName = DepotHandler.UserCoordinateTimeCookieName;
                                now = DateTime.Now;
                                string value2 = now.ToString();
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateTimeCookieName, value2, now.AddMinutes(10.0), null, true);
                                context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + user.StoreId + "\"}");
                            }
                            else
                            {
                                StoresInfo nearDeliveStores          = DepotHelper.GetNearDeliveStores(text, false);
                                string     userCoordinateCookieName2 = DepotHandler.UserCoordinateCookieName;
                                string     value3 = HttpUtility.UrlEncode(str);
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateCookieName2, "Address", value3, now.AddDays(10.0));
                                if (nearDeliveStores == null || nearDeliveStores.StoreId <= 0)
                                {
                                    string store_PositionNoMatchTo = masterSettings.Store_PositionNoMatchTo;
                                    if (store_PositionNoMatchTo == "Platform")
                                    {
                                        context.Response.Write("{\"Status\":\"noStoreToPlatform\",\"Message\":\"进入平台页面!\"}");
                                    }
                                    else
                                    {
                                        context.Response.Write("{\"Status\":\"nothing\",\"Message\":\"进入无平台提示页面!\"}");
                                    }
                                }
                                else
                                {
                                    now = DateTime.Now;
                                    WebHelper.SetCookie("UserCoordinateCookie", "StoreType", "2", now.AddDays(10.0));
                                    string userCoordinateTimeCookieName2 = DepotHandler.UserCoordinateTimeCookieName;
                                    now = DateTime.Now;
                                    string value4 = now.ToString();
                                    now = DateTime.Now;
                                    WebHelper.SetCookie(userCoordinateTimeCookieName2, value4, now.AddMinutes(10.0), null, true);
                                    context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + nearDeliveStores.StoreId + "\"}");
                                }
                            }
                        }
                        else if (store_PositionRouteTo.Equals("StoreList"))
                        {
                            string str2 = DepotHelper.CookieUserCoordinate(text);
                            string userCoordinateCookieName3 = DepotHandler.UserCoordinateCookieName;
                            string value5 = HttpUtility.UrlEncode(str);
                            now = DateTime.Now;
                            WebHelper.SetCookie(userCoordinateCookieName3, "Address", value5, now.AddDays(10.0));
                            string userCoordinateTimeCookieName3 = DepotHandler.UserCoordinateTimeCookieName;
                            now = DateTime.Now;
                            string value6 = now.ToString();
                            now = DateTime.Now;
                            WebHelper.SetCookie(userCoordinateTimeCookieName3, value6, now.AddMinutes(10.0), null, true);
                            context.Response.Write("{\"Status\":\"storeList\",\"Addr\":\"" + str2 + "\",\"Message\":\"进入多门店首页!\"}");
                        }
                        else if (store_PositionRouteTo.Equals("Platform"))
                        {
                            DepotHelper.CookieUserCoordinate(text);
                            if (user != null && user.StoreId > 0 && masterSettings.Store_IsMemberVisitBelongStore)
                            {
                                string userCoordinateCookieName4 = DepotHandler.UserCoordinateCookieName;
                                string value7 = HttpUtility.UrlEncode(str);
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateCookieName4, "Address", value7, now.AddDays(10.0));
                                string userCoordinateTimeCookieName4 = DepotHandler.UserCoordinateTimeCookieName;
                                now = DateTime.Now;
                                string value8 = now.ToString();
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateTimeCookieName4, value8, now.AddMinutes(10.0), null, true);
                                context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + user.StoreId + "\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"Status\":\"platform\",\"Message\":\"进入平台页面!\"}");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    context.Response.Write("{\"Status\":\"error\",\"Message\":\"" + ex.Message + "\"}");
                }
            }
        }
Beispiel #2
0
        public void SerachNearStore(HttpContext context)
        {
            string text  = Globals.UrlDecode(context.Request["fromLatLng"].ToNullString());
            string text2 = context.Request["changeStore"].ToNullString();
            int    num   = context.Request["storeSource"].ToInt(0);
            int    num2  = context.Request["storeId"].ToInt(0);

            context.Response.ContentType = "text/json";
            if (string.IsNullOrEmpty(text))
            {
                context.Response.Write("{\"Status\":\"noLatLng\",\"Message\":\"定位失败!\"}");
            }
            else
            {
                try
                {
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                    if (!masterSettings.OpenMultStore)
                    {
                        context.Response.Write("{\"Status\":\"platform\",\"Message\":\"进入平台页面!\"}");
                    }
                    else
                    {
                        DateTime now;
                        if ((num == 2 || num == 3 || num == 4) && num2 > 0)
                        {
                            string value = num2.ToString();
                            now = DateTime.Now;
                            WebHelper.SetCookie("UserCoordinateCookie", "StoreId", value, now.AddDays(10.0));
                            now = DateTime.Now;
                            WebHelper.SetCookie("UserCoordinateCookie", "StoreType", "2", now.AddDays(10.0));
                            string userCoordinateTimeCookieName = DepotHandler.UserCoordinateTimeCookieName;
                            now = DateTime.Now;
                            string value2 = now.ToString();
                            now = DateTime.Now;
                            WebHelper.SetCookie(userCoordinateTimeCookieName, value2, now.AddMinutes(10.0), null, true);
                        }
                        string store_PositionRouteTo = masterSettings.Store_PositionRouteTo;
                        text = text.Trim().Replace(" ", "");
                        MemberInfo user    = HiContext.Current.User;
                        int        num3    = WebHelper.GetCookie(DepotHandler.UserCoordinateCookieName, "StoreType").ToInt(0);
                        int        num4    = WebHelper.GetCookie(DepotHandler.UserCoordinateCookieName, "StoreId").ToInt(0);
                        string     cookie  = WebHelper.GetCookie(DepotHandler.UserCoordinateTimeCookieName);
                        string     cookie2 = WebHelper.GetCookie(DepotHandler.UserCoordinateCookieName, "Coordinate");
                        if (num4 > 0)
                        {
                            StoresInfo storeById = StoresHelper.GetStoreById(num4);
                            if (storeById == null || storeById.State == 0)
                            {
                                num4 = 0;
                            }
                        }
                        if (num2 > 0)
                        {
                            StoresInfo storeById2 = StoresHelper.GetStoreById(num2);
                            if (storeById2 == null || storeById2.State == 0)
                            {
                                num2 = 0;
                            }
                        }
                        if (num == 4 && num2 > 0)
                        {
                            DepotHelper.CookieUserCoordinate(text);
                            context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + num2 + "\"}");
                        }
                        else if (num3 == 2 && num4 > 0 && num > 1 && !string.IsNullOrEmpty(cookie))
                        {
                            context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + num4 + "\"}");
                        }
                        else if (store_PositionRouteTo.Equals("NearestStore"))
                        {
                            if (!string.IsNullOrEmpty(cookie) && num3 == 2 && num4 > 0)
                            {
                                context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + num4 + "\"}");
                            }
                            else if (!string.IsNullOrEmpty(text2) && text2.Equals("0") && num4 > 0)
                            {
                                string userCoordinateTimeCookieName2 = DepotHandler.UserCoordinateTimeCookieName;
                                now = DateTime.Now;
                                string value3 = now.ToString();
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateTimeCookieName2, value3, now.AddMinutes(10.0), null, true);
                                string userCoordinateCookieName = DepotHandler.UserCoordinateCookieName;
                                string value4 = text;
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateCookieName, "NewCoordinate", value4, now.AddMinutes(10.0));
                                context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + num4 + "\"}");
                            }
                            else if (user != null && user.StoreId > 0 && masterSettings.Store_IsMemberVisitBelongStore)
                            {
                                DepotHelper.CookieUserCoordinate(text);
                                context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + user.StoreId + "\"}");
                            }
                            else if (!string.IsNullOrEmpty(cookie) && !string.IsNullOrEmpty(cookie2) && num4 > 0)
                            {
                                context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + num4 + "\"}");
                            }
                            else if (string.IsNullOrEmpty(cookie) && !string.IsNullOrEmpty(cookie2) && num4 > 0 && string.IsNullOrEmpty(text2))
                            {
                                string[]     array    = cookie2.Split(',');
                                PositionInfo degree   = new PositionInfo(array[0].ToDouble(0), array[1].ToDouble(0));
                                string[]     array2   = text.Split(',');
                                PositionInfo degree2  = new PositionInfo(array2[0].ToDouble(0), array2[1].ToDouble(0));
                                double       distance = MapHelper.GetDistance(degree, degree2);
                                if (distance > 500.0)
                                {
                                    string text3 = "";
                                    string text4 = "";
                                    string text5 = "";
                                    string text6 = "";
                                    string text7 = "";
                                    DepotHelper.GetAddressByLatLng(text, ref text3, ref text4, ref text5, ref text6, ref text7);
                                    string text8 = HttpUtility.UrlEncode(string.IsNullOrWhiteSpace(text3) ? text7 : text3);
                                    context.Response.Write("{\"Status\":\"tipChange\",\"Message\":\"提示切换!\",\"Addr\":\"" + text8 + "\",\"fromLatLng\":\"" + text + "\"}");
                                }
                                else
                                {
                                    string userCoordinateTimeCookieName3 = DepotHandler.UserCoordinateTimeCookieName;
                                    now = DateTime.Now;
                                    string value5 = now.ToString();
                                    now = DateTime.Now;
                                    WebHelper.SetCookie(userCoordinateTimeCookieName3, value5, now.AddMinutes(10.0), null, true);
                                    string userCoordinateCookieName2 = DepotHandler.UserCoordinateCookieName;
                                    string value6 = text;
                                    now = DateTime.Now;
                                    WebHelper.SetCookie(userCoordinateCookieName2, "NewCoordinate", value6, now.AddMinutes(10.0));
                                    context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + num4 + "\"}");
                                }
                            }
                            else
                            {
                                StoresInfo nearDeliveStores = DepotHelper.GetNearDeliveStores(text, false);
                                if (nearDeliveStores == null || nearDeliveStores.StoreId <= 0)
                                {
                                    string store_PositionNoMatchTo = masterSettings.Store_PositionNoMatchTo;
                                    if (store_PositionNoMatchTo == "Platform")
                                    {
                                        context.Response.Write("{\"Status\":\"noStoreToPlatform\",\"Message\":\"进入平台页面!\"}");
                                    }
                                    else
                                    {
                                        context.Response.Write("{\"Status\":\"nothing\",\"Message\":\"进入无平台提示页面!\"}");
                                    }
                                }
                                else
                                {
                                    context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + nearDeliveStores.StoreId + "\"}");
                                }
                            }
                        }
                        else if (store_PositionRouteTo.Equals("StoreList"))
                        {
                            if (!string.IsNullOrEmpty(text2) && text2.Equals("0"))
                            {
                                string userCoordinateTimeCookieName4 = DepotHandler.UserCoordinateTimeCookieName;
                                now = DateTime.Now;
                                string value7 = now.ToString();
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateTimeCookieName4, value7, now.AddMinutes(10.0), null, true);
                                string userCoordinateCookieName3 = DepotHandler.UserCoordinateCookieName;
                                string value8 = text;
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateCookieName3, "NewCoordinate", value8, now.AddMinutes(10.0));
                                context.Response.Write("{\"Status\":\"storeList\",\"Addr\":\"" + WebHelper.GetCookie(DepotHandler.UserCoordinateCookieName, "Address") + "\",\"Message\":\"进入多门店首页!\"}");
                            }
                            else if (!string.IsNullOrEmpty(text2) && text2.Equals("1"))
                            {
                                string userCoordinateTimeCookieName5 = DepotHandler.UserCoordinateTimeCookieName;
                                now = DateTime.Now;
                                string value9 = now.ToString();
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateTimeCookieName5, value9, now.AddMinutes(10.0), null, true);
                                string str = DepotHelper.CookieUserCoordinate(text);
                                context.Response.Write("{\"Status\":\"storeList\",\"Addr\":\"" + str + "\",\"Message\":\"进入多门店首页!\"}");
                            }
                            else if (string.IsNullOrEmpty(cookie) && !string.IsNullOrEmpty(cookie2) && string.IsNullOrEmpty(text2))
                            {
                                string[]     array3    = cookie2.Split(',');
                                PositionInfo degree3   = new PositionInfo(array3[0].ToDouble(0), array3[1].ToDouble(0));
                                string[]     array4    = text.Split(',');
                                PositionInfo degree4   = new PositionInfo(array4[0].ToDouble(0), array4[1].ToDouble(0));
                                double       distance2 = MapHelper.GetDistance(degree3, degree4);
                                if (distance2 > 500.0)
                                {
                                    string text9  = "";
                                    string text10 = "";
                                    string text11 = "";
                                    string text12 = "";
                                    string text13 = "";
                                    DepotHelper.GetAddressByLatLng(text, ref text9, ref text10, ref text11, ref text12, ref text13);
                                    string text14 = HttpUtility.UrlEncode(string.IsNullOrWhiteSpace(text9) ? text13 : text9);
                                    context.Response.Write("{\"Status\":\"tipChange\",\"Message\":\"提示切换!\",\"Addr\":\"" + text14 + "\",\"fromLatLng\":\"" + text + "\"}");
                                }
                                else
                                {
                                    string userCoordinateTimeCookieName6 = DepotHandler.UserCoordinateTimeCookieName;
                                    now = DateTime.Now;
                                    string value10 = now.ToString();
                                    now = DateTime.Now;
                                    WebHelper.SetCookie(userCoordinateTimeCookieName6, value10, now.AddMinutes(10.0), null, true);
                                    string userCoordinateCookieName4 = DepotHandler.UserCoordinateCookieName;
                                    string value11 = text;
                                    now = DateTime.Now;
                                    WebHelper.SetCookie(userCoordinateCookieName4, "NewCoordinate", value11, now.AddDays(10.0));
                                    context.Response.Write("{\"Status\":\"storeList\",\"Addr\":\"" + WebHelper.GetCookie(DepotHandler.UserCoordinateCookieName, "Address") + "\",\"Message\":\"进入多门店首页!\"}");
                                }
                            }
                            else if (string.IsNullOrEmpty(cookie2))
                            {
                                string userCoordinateTimeCookieName7 = DepotHandler.UserCoordinateTimeCookieName;
                                now = DateTime.Now;
                                string value12 = now.ToString();
                                now = DateTime.Now;
                                WebHelper.SetCookie(userCoordinateTimeCookieName7, value12, now.AddMinutes(10.0), null, true);
                                string str2 = DepotHelper.CookieUserCoordinate(text);
                                context.Response.Write("{\"Status\":\"storeList\",\"Addr\":\"" + str2 + "\",\"Message\":\"进入多门店首页!\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"Status\":\"storeList\",\"Addr\":\"" + WebHelper.GetCookie(DepotHandler.UserCoordinateCookieName, "Address") + "\",\"Message\":\"进入多门店首页!\"}");
                            }
                        }
                        else if (store_PositionRouteTo.Equals("Platform"))
                        {
                            if (string.IsNullOrEmpty(cookie2) || string.IsNullOrEmpty(cookie))
                            {
                                DepotHelper.CookieUserCoordinate(text);
                            }
                            if (user != null && user.StoreId > 0 && masterSettings.Store_IsMemberVisitBelongStore)
                            {
                                context.Response.Write("{\"Status\":\"goToStore\",\"Message\":\"进入门店首页!\",\"StoreId\":\"" + user.StoreId + "\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"Status\":\"platform\",\"Addr\":\"" + WebHelper.GetCookie(DepotHandler.UserCoordinateCookieName, "Address") + "\",\"Message\":\"进入平台页面!\"}");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    context.Response.Write("{\"Status\":\"error\",\"Message\":\"" + ex.Message + "\"}");
                }
            }
        }