Example #1
0
        /// <summary>
        /// 获取cookie
        /// </summary>
        /// <param name="cID"></param>
        /// <param name="u"></param>
        public UserLogin setUserLogin(int cID, UserLogin user)
        {
            if (Cookies.IsExist("remuc"))
            {
                //cookie的CID
                string cid = Cookies.Get("remuc", "_cid");
                if (cid.IsNullOrEmpty())
                {
                    cid = "0";
                }

                //输入的域名存在商户
                if (cID > 0)
                {
                    //API的CID等于cookie的CID
                    if (cid == cID.ToString())
                    {
                        user.CID        = Convert.ToInt32(cid);
                        user.UserName   = Cookies.Get("remuc", "_uname");
                        user.UserPwd    = Cookies.Get("remuc", "_pwd");
                        user.RememberMe = true;
                    }
                }
                //localhost访问、ip访问、保留二级域名访问
                else
                {
                    user.CID        = Convert.ToInt32(cid);
                    user.UserName   = Cookies.Get("remuc", "_uname");
                    user.UserPwd    = Cookies.Get("remuc", "_pwd");
                    user.RememberMe = true;
                }
            }
            return(user);
        }
Example #2
0
        public ActionResult Login()
        {
            //if (CurrentUser.IsLogin)
            //{
            //    //已登录,则直接进入主界面
            //    return Redirect(Url.Action("Index", "Home"));
            //}
            //1为单商户版本,其他值为多商户版本
            string ver = Pharos.Utility.Config.GetAppSettings("ver");

            //单商户版本
            if (ver == "1")
            {
                var user = new UserLogin();
                if (Cookies.IsExist("remuc"))
                {
                    user.UserName   = Cookies.Get("remuc", "_uname");
                    user.UserPwd    = Cookies.Get("remuc", "_pwd");
                    user.RememberMe = true;
                }
                return(View(user));
            }
            //多商户版本
            else
            {
                return(Logins());
            }
        }
        public ActionResult Login()
        {
            var user = new UserLogin();

            if (Cookies.IsExist("remuc"))
            {
                user.UserName   = Cookies.Get("remuc", "_uname");
                user.UserPwd    = Cookies.Get("remuc", "_pwd");
                user.RememberMe = true;
            }
            return(View(user));
        }
Example #4
0
        public ActionResult Login()
        {
            //if (CurrentUser.IsLogin)
            //{
            //    //已登录,则直接进入主界面
            //    return Redirect(Url.Action("Index", "Home"));
            //}
            var user = new UserLogin();

            if (Cookies.IsExist("remuc"))
            {
                user.UserName   = Cookies.Get("remuc", "_uname");
                user.UserPwd    = Cookies.Get("remuc", "_pwd");
                user.RememberMe = true;
            }
            return(View(user));
        }
Example #5
0
        public ActionResult Index()
        {
            //if (!Sys.CurrentUser.IsLogin || Sys.CurrentUser.IsStore)
            //{
            //    return RedirectToAction("Login", "Account");
            //}

            #region sync
            //ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
            //ChannelFactory<Sync.IService1> myFactory = new ChannelFactory<Sync.IService1>("endpointConfig");
            //Sync.IService1 client = myFactory.CreateChannel();
            //ServiceReference2.AccountClient client = new ServiceReference2.AccountClient();
            //using (TransactionScope tran = new TransactionScope())
            //{
            //    var pv = client.GetPublish(CommonService.CompanyId, 1);
            //    if (pv != null)
            //    {
            //        var menus = new List<Sys.Entity.SysMenus>();
            //if (pv.ProductMenusk__BackingField != null)
            //{
            //    Pharos.Logic.BLL.SysMenuBLL menuBll = new SysMenuBLL();
            //    menus = pv.ProductMenusk__BackingField.Select(o => new Sys.Entity.SysMenus()
            //    {
            //        CompanyId = CommonService.CompanyId,
            //        MenuId = o.MenuIdk__BackingField,
            //        PMenuId = o.PMenuIdk__BackingField,
            //        SortOrder = o.SortOrderk__BackingField,
            //        Status = o.Statusk__BackingField,
            //        Title = o.Titlek__BackingField,
            //        Type = 0,
            //        URL = o.Urlk__BackingField
            //    }).ToList();
            //    menuBll.SyncMenu(menus);
            //}
            //if (pv.ProductLimitsk__BackingField != null)
            //{
            //    Pharos.Logic.BLL.SysLimitsBLL limitBll = new SysLimitsBLL();
            //    var limits = menus.Select(o => new Sys.Entity.SysLimits()
            //    {
            //        CompanyId = o.CompanyId,
            //        LimitId = o.MenuId,
            //        PLimitId = 0,
            //        Depth = 1,
            //        Status = Convert.ToInt16(o.Status),
            //        Title = o.Title
            //    }).ToList();

            //    limits.AddRange(pv.ProductLimitsk__BackingField.Select(o => new Sys.Entity.SysLimits()
            //    {
            //        CompanyId = CommonService.CompanyId,
            //        LimitId = o.LimitIdk__BackingField.GetValueOrDefault(),
            //        PLimitId = o.MenuIdk__BackingField.GetValueOrDefault(),
            //        Depth = 2,
            //        Status = Convert.ToInt16(o.Statusk__BackingField.GetValueOrDefault()),
            //        Title = o.Titlek__BackingField
            //    }));

            //    limitBll.SyncLimit(limits);
            //}
            //    }
            //    tran.Complete();
            //}
            //client.Close();
            #endregion

            #region 验证
            //1为单商户版本,其他值为多商户版本
            string ver = Pharos.Utility.Config.GetAppSettings("ver");
            //单商户版本
            if (ver == "1")
            {
                if (!Sys.CurrentUser.IsLogin || Sys.CurrentUser.IsStore)
                {
                    Response.Redirect("/Account/Login");
                }
            }
            //多商户版本
            else
            {
                //二级域名
                string d = "";

                //二级域名
                string dom = "";
                if (!RouteData.Values["dom"].IsNullOrEmpty())
                {
                    dom = RouteData.Values["dom"].ToString();
                }
                //一级域名
                string d1 = "";
                if (!RouteData.Values["d1"].IsNullOrEmpty())
                {
                    d1 = RouteData.Values["d1"].ToString();
                }
                //顶级域名
                string d0 = "";
                if (!RouteData.Values["d0"].IsNullOrEmpty())
                {
                    d0 = RouteData.Values["d0"].ToString();
                }

                if (!d0.IsNullOrEmpty())
                {
                    if (!dom.IsNullOrEmpty())
                    {
                        d = dom;
                    }
                }

                //输入保留二级域名:store
                if (!RouteData.Values["cid"].IsNullOrEmpty())
                {
                    d = "store";
                }

                //localhost访问、ip访问
                if ((dom.ToLower().Trim() == "localhost") || (dom.IsNullOrEmpty() && d1.IsNullOrEmpty() && d0.IsNullOrEmpty()))
                {
                    if (!Sys.CurrentUser.IsLogin || Sys.CurrentUser.IsStore)
                    {
                        Response.Redirect("/Account/Login");
                        return(null);
                    }
                }
                //域名访问
                else
                {
                    //API的CID
                    int cID = Authorize.getCID(d);

                    //输入保留二级域名:store
                    if (d.ToLower().Trim().Contains("store") && cID == -1)
                    {
                        //门店
                        Response.Redirect("/Store/Index");
                        return(null);
                    }
                    //请求API发生错误
                    else if (cID == -2)
                    {
                        Response.Redirect("/Account/error");
                        return(null);
                    }
                    //输入的二级域名是空
                    else if (cID == -1)
                    {
                        Response.Redirect("/Account/noBusiness");
                        return(null);
                    }
                    //输入的域名不存在商户
                    else if (cID == 0)
                    {
                        Response.Redirect("/Account/noBusiness");
                        return(null);
                    }
                    //输入的域名是保留二级域名
                    else if (cID == -3)
                    {
                        //在crm里面
                        if (d.ToLower() == "erp")
                        {
                            if (!Sys.CurrentUser.IsLogin || Sys.CurrentUser.IsStore)
                            {
                                Response.Redirect("/Account/Login");
                                return(null);
                            }
                        }
                        //不在crm里面
                        else
                        {
                            Response.Redirect("/Account/noBusiness");
                            return(null);
                        }
                    }
                    //输入的域名存在商户
                    else if (cID > 0)
                    {
                        var obj = UserInfoService.Find(o => o.CompanyId == cID);
                        //CID在目前项目不存在
                        if (obj == null)
                        {
                            Response.Redirect("/Account/noUser?cid=" + cID);
                            return(null);
                        }
                        else
                        {
                            if (!Sys.CurrentUser.IsLogin || Sys.CurrentUser.IsStore)
                            {
                                Response.Redirect("/Account/Login");
                                return(null);
                            }
                            else
                            {
                                if (Cookies.IsExist("remuc"))
                                {
                                    //cookie的CID
                                    string cid = Cookies.Get("remuc", "_cid");
                                    if (cid.IsNullOrEmpty())
                                    {
                                        cid = "0";
                                    }

                                    if (cID != Convert.ToInt32(cid))
                                    {
                                        Response.Redirect("/Account/Login");
                                        return(null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            //获取活动列表
            var activityList = CommodityPromotionService.GetNewestActivity(3);
            //获取公告列表
            var noticeList = NoticeService.GetNewestNotice(3);
            //采购订单列表
            ViewBag.OrderList = OrderService.GetNewOrder(3);

            List <ActivityNoticeModel> activityNoticeList = new List <ActivityNoticeModel>();
            if (activityList != null)
            {
                foreach (var activity in activityList)
                {
                    activityNoticeList.Add(new ActivityNoticeModel(activity.Id, Enum.GetName(typeof(PromotionType), activity.PromotionType),
                                                                   DateTime.Parse(activity.StartDate.ToString()).ToString("yyyy-MM-dd") + "至" + DateTime.Parse(activity.EndDate.ToString()).ToString("yyyy-MM-dd"),
                                                                   Enum.GetName(typeof(SaleState), activity.State), activity.CreateDT, 1));
                }
            }
            if (noticeList != null)
            {
                foreach (var notice in noticeList)
                {
                    activityNoticeList.Add(new ActivityNoticeModel(notice.Id.ToString(), notice.Theme, notice.BeginDate.ToString("yyyy-MM-dd") + "至" + notice.ExpirationDate.ToString("yyyy-MM-dd"),
                                                                   notice.State == 1 ? "已发布":"未发布", notice.CreateDT, 2));
                }
            }
            activityNoticeList = activityNoticeList.OrderByDescending(o => o.CreateDT).Take(3).ToList();
            if (activityNoticeList == null)
            {
                activityNoticeList = new List <ActivityNoticeModel>();
            }
            ViewBag.activityNoticeList = activityNoticeList;//活动公告


            //todo: 模拟数据
            string mode = Request["mode"];
            ViewBag.accessCount = 0;

            ViewBag.WelcomeText  = "欢迎光临";
            ViewBag.CurUserName  = Sys.CurrentUser.FullName;
            ViewBag.CurLoginName = Sys.CurrentUser.UserName;

            //近3天数据
            var beginTime = DateTime.Parse(DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd"));
            var endTime   = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));
            ViewBag.newMemberNumber = MembersService.GetNewMemberNumber(beginTime, endTime); //新增会员数量
            ViewBag.newSalesVolume  = ReportBLL.GetSalesVolume(beginTime, endTime);          //新增销售量
            var saleOrderList3Day = SaleOrdersService.GetIndexSaleOrder(beginTime, endTime); //3天内的销售订单
            ViewBag.newSaleOrderNumber = saleOrderList3Day.Count();                          //新增客单量
            decimal newSaleTotal = 0;
            newSaleTotal         = saleOrderList3Day.Sum(o => o.Receive);
            ViewBag.newSaleTotal = newSaleTotal;//新增销售额

            //近7天数据
            var dayTitleList          = new List <string>();
            var saleTotalList         = new List <decimal>();
            var saleOederNumberList   = new List <int>();
            var hotProductNameList    = new List <string>();
            var hotProductSaleNumList = new List <int>();
            for (int i = 6; i >= 0; i--)
            {
                var time1         = DateTime.Parse(DateTime.Now.AddDays(0 - i).ToString("yyyy-MM-dd"));
                var time2         = DateTime.Parse(DateTime.Now.AddDays(0 - i + 1).ToString("yyyy-MM-dd"));
                var saleOrderList = SaleOrdersService.GetIndexSaleOrder(time1, time2);

                dayTitleList.Add(int.Parse(DateTime.Now.AddDays(0 - i).ToString("dd")) + "日");
                saleTotalList.Add(saleOrderList.Sum(o => o.Receive));
                saleOederNumberList.Add(saleOrderList.Count());
            }

            var hotProductBeginTime = DateTime.Parse(DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd"));
            var hotProductEndTime   = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));

            ReportBLL.GetHotProduct(hotProductBeginTime, hotProductEndTime, out hotProductNameList, out hotProductSaleNumList);

            //近7天热销商品
            ViewBag.hotProductNameList        = hotProductNameList.ToJson();
            ViewBag.hotProductSaleNumList     = hotProductSaleNumList.ToJson();
            ViewBag.hotProductNameListNotJson = hotProductNameList;

            ViewBag.dayTitleList        = dayTitleList.ToJson();
            ViewBag.saleTotalList       = saleTotalList.ToJson();       //近7天销售额
            ViewBag.saleOederNumberList = saleOederNumberList.ToJson(); //近7天客单量

            var list = new List <Pharos.Sys.Models.MenuModel>();
            list          = _menuBLL.GetHomeMenusByUID(Sys.CurrentUser.UID);
            ViewBag.Menus = list;
            var set = new Pharos.Sys.BLL.SysWebSettingBLL().GetWebSetting();
            //var comp = Authorize.GetCompanyByConnect(null);
            ViewBag.comptitle = set == null ? "ERP管理平台" : set.SysName;
            return(View(set ?? new Sys.Entity.SysWebSetting()));
        }
Example #6
0
        public ActionResult Login(string id)
        {
            /*var user = new UserLogin();
             * csID csid2 = ipLocalhost();
             *
             * //url中cid
             * string s_cid = "";
             *
             * if (!RouteData.Values["cid"].IsNullOrEmpty())
             * {
             *  s_cid = RouteData.Values["cid"].ToString();
             * }
             * //url中sid
             * string s_sid = "";
             *
             * if (!RouteData.Values["sid"].IsNullOrEmpty())
             * {
             *  s_sid = RouteData.Values["sid"].ToString();
             * }
             *
             * if (csid2.message == "禁止访问")
             * {
             *  Response.Redirect("/Account/noBusiness");
             *  return null;
             * }
             *
             * csID csid = new csID();
             * if (!s_cid.IsNullOrEmpty() && !s_sid.IsNullOrEmpty())
             * {
             *  Authorize authorize = new Authorize();
             *  csid = authorize.getCidSid(s_cid, s_sid);
             *  if (csid.message == "格式错误")
             *  {
             *      Response.Redirect("/Account/noBusiness");
             *      return null;
             *  }
             *  else if (csid.message == "域名的store后面必须是数字")
             *  {
             *      Response.Redirect("/Account/noBusiness");
             *      return null;
             *  }
             *  else if (csid.message == "success")
             *  {
             *      user.CID = Convert.ToInt32(csid.cid);
             *      if (Cookies.IsExist("remuc"))
             *      {
             *          //cookie的CID
             *          string cid = Cookies.Get("remuc", "_cid").Trim();
             *          //cookie的门店ID
             *          string sid = Server.UrlDecode(Cookies.Get("remuc", "_storeId"));
             *          sid = sid.Split('~')[0];
             *
             *          if (cid.IsNullOrEmpty())
             *          {
             *              cid = "0";
             *          }
             *          if (sid.IsNullOrEmpty())
             *          {
             *              sid = "0";
             *          }
             *
             *          if (csid.cid.Trim() == cid || csid.sid.Trim() == sid)
             *          {
             *              user.UserName = Cookies.Get("remuc", "_uname");
             *              user.UserPwd = Cookies.Get("remuc", "_pwd");
             *              user.StoreId = Server.UrlDecode(Cookies.Get("remuc", "_storeId"));
             *              user.RememberMe = true;
             *          }
             *      }
             *  }
             * }
             * else
             * {
             *  Response.Redirect("/Account/noBusiness");
             *  return null;
             * }
             *
             *
             * List<SelectListItem> list = ListToSelect(WarehouseService.GetAdminList(Convert.ToInt32(csid.cid), csid.sid).Select(o => new SelectListItem() { Text = o.Title, Value = o.StoreId + "~" + o.Title, Selected = o.StoreId == csid.sid })).ToList();
             * if (list.Count == 0)
             * {
             *  Response.Redirect("/Account/error?msg=" + Pharos.Utility.DESEncrypt.Encrypt("无效门店,请联系管理员检查该门店是否存在或开放!"));
             *  return null;
             * }
             *
             *
             * ViewBag.stores = list;
             * return View(user);
             */

            var user = new UserLogin();

            user.CID       = Pharos.Utility.Config.GetAppSettings("CompanyId").ToType <int>();
            user.StoreId   = Sys.SysCommonRules.CurrentStore;
            ViewBag.stores = ListToSelect(WarehouseService.GetAdminList().Select(o => new SelectListItem()
            {
                Text = o.Title, Value = o.StoreId + "~" + o.Title, Selected = o.StoreId == user.StoreId
            }));
            if (Cookies.IsExist("storeremuc"))
            {
                user.UserName   = Cookies.Get("storeremuc", "_uname");
                user.StoreId    = Server.UrlDecode(Cookies.Get("storeremuc", "_storeId"));
                user.RememberMe = true;
            }
            return(View(user));
        }