public ActionResult Old_Index() { if (!Sys.CurrentUser.IsLogin || Sys.CurrentUser.IsStore) { return(RedirectToAction("Login", "Account")); } //获取公告列表 ViewBag.NoticeList = NoticeService.GetNewestNotice(3); //获取活动列表 ViewBag.ActivityList = CommodityPromotionService.GetNewestActivity(3); ViewBag.OrderList = OrderService.GetNewOrder(7); //todo: 模拟数据 string mode = Request["mode"]; ViewBag.accessCount = 0; ViewBag.WelcomeText = "欢迎光临"; ViewBag.CurUserName = Sys.CurrentUser.FullName; ViewBag.CurLoginName = Sys.CurrentUser.UserName; var categories = new List <string>(); var stores = new List <string>(); var hours = new TimeSpan[] { new TimeSpan(8, 0, 0), new TimeSpan(10, 0, 0), new TimeSpan(12, 0, 0), new TimeSpan(14, 0, 0), new TimeSpan(16, 0, 0), new TimeSpan(18, 0, 0), new TimeSpan(20, 0, 0) }; var list = new List <Pharos.Sys.Models.MenuModel>(); list = _menuBLL.GetHomeMenusByUID(Sys.CurrentUser.UID); ViewBag.Menus = list; ViewBag.categoryData = ReportBLL.QueryIndexSaleCategorys(ref categories).ToJson(); ViewBag.chart1Data = ReportBLL.QueryIndexSaleCategorys(ref categories).FirstOrDefault() == null ? new List <object>() : ReportBLL.QueryIndexSaleCategorys(ref categories).FirstOrDefault().data; ViewBag.categoryJSON = categories.ToJson(); ViewBag.hourData = ReportBLL.QueryIndexSaleHour(categories, hours).ToJson(); ViewBag.chart2Data = ReportBLL.QueryIndexSaleHour(categories, hours).FirstOrDefault() == null ? new List <object>() : ReportBLL.QueryIndexSaleHour(categories, hours).FirstOrDefault().data; ViewBag.hoursJSON = hours.Select(o => o.Hours.ToString("00") + ":" + o.Minutes.ToString("00")).ToJson(); ViewBag.storeData = ReportBLL.QueryIndexSaleStore(categories, ref stores).ToJson(); ViewBag.chart3Data = ReportBLL.QueryIndexSaleStore(categories, ref stores).FirstOrDefault() == null ? new List <object>() : ReportBLL.QueryIndexSaleStore(categories, ref stores).FirstOrDefault().data; ViewBag.storeJSON = stores.ToJson(); return(View()); }
public ActionResult GetRemind(string type) { List <RemindModel> rmList = new List <RemindModel>(); switch (type.ToLower()) { case "stockout": //缺货提醒 var datas = CommodityService.GetStockout().GroupBy(o => o.Key); foreach (var item in datas) { rmList.Add(new RemindModel(item.Key + "缺货提醒", item.Key + "以下商品缺货:<br/>" + string.Join(",", item.Select(o => o.Value)))); } break; case "activity": //活动提醒 Dictionary <short, string> promotionTypeDict = new Dictionary <short, string>(); //1:单品折扣、 2:捆绑促销、 3:组合促销、4:买赠促销、 5:满元促销 promotionTypeDict.Add(1, "单品折扣"); promotionTypeDict.Add(2, "捆绑促销"); promotionTypeDict.Add(3, "组合促销"); promotionTypeDict.Add(4, "买赠促销"); promotionTypeDict.Add(5, "满元促销"); var promotions = CommodityPromotionService.GetNewestActivity(10); foreach (var item in promotions) { var storeids = item.StoreId.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var stores = WarehouseService.FindList(o => storeids.Contains(o.StoreId)).Select(o => o.Title); rmList.Add( new RemindModel( string.Format( "{1}~{2} {0}", promotionTypeDict[item.PromotionType], (item.StartDate ?? new DateTime()).ToString("yyyy-MM-dd"), (item.EndDate ?? new DateTime()).ToString("yyyy-MM-dd")), item.Id)); } break; case "receive": //收货提醒 var orderDatas = OrderDistributionService.GetReceivedOrder(); foreach (var item in orderDatas) { rmList.Add(new RemindModel(string.Format("{0}有订单发货,请注意查收!", item.Store), string.Format("<br/>门店:{0}<br/>配送批次号:{1}<br/>订单编号:{2}<br/>", item.Store, item.DistributionBatch, item.IndentOrderId))); } break; case "expiration": //保质期到期提醒 var commodities = CommodityService.GetExpiresProduct(); foreach (var item in commodities) { rmList.Add(new RemindModel(string.Format("{0}已过期或将要过期", item.Key), string.Format("{0}将要过期<br/>过期时间:{1}", item.Key, item.Value.ExpirationDate))); } break; case "contract": //合同提醒 var contracts = ContractSerivce.GetContractRemind(); foreach (var item in contracts) { rmList.Add(new RemindModel(string.Format("<span style=\"width:120px;display:inline-block;\">{0}</span><span style=\"width:110px;display:inline-block;\">{1}</span><span style=\"width:110px;display:inline-block;\">{2}</span>", item.ContractSN, item.SupplierTitle, item.EndDate), string.Format("合同编号:{0}<br/>供应商:{1}<br/>结束日期:{2}", item.ContractSN, item.SupplierTitle, item.EndDate))); } break; } return(new JsonNetResult(rmList)); }
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())); }
public ActionResult Index() { #region 如未登录 或 非门店登录,则跳转到 门店登录页 if (!Sys.CurrentStoreUser.IsLogin) { Sys.CurrentStoreUser.Exit(); return(RedirectToAction("Login")); //Response.Redirect("/Store/Login"); } #endregion /* * 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; * } * * if (!s_cid.IsNullOrEmpty() && !s_sid.IsNullOrEmpty()) * { * Authorize authorize = new Authorize(); * csID 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") * { * //如未登录 或 非门店登录,则跳转到 门店登录页 * if (!Sys.CurrentUser.IsLogin || !Sys.CurrentUser.IsStore) * { * Sys.CurrentUser.Exit(); * * //ip、localhost门店登录 * if (csid2.message == "localhost" || csid2.message == "ip") * { * Response.Redirect("/store" + csid2.cid + "-" + csid2.sid); * return null; * } * * Response.Redirect("/Store/Login"); * return null; * } * else * { * 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]; * * string ss = sid.Split('~')[0]; * * if (cid.IsNullOrEmpty()) * { * cid = "0"; * } * if (sid.IsNullOrEmpty()) * { * sid = "0"; * } * * if (csid.cid.Trim() != cid || csid.sid.Trim() != sid) * { * Sys.CurrentUser.Exit(); * * //ip、localhost门店登录 * if (csid2.message == "localhost" || csid2.message == "ip") * { * Response.Redirect("/store" + csid2.cid + "-" + csid2.sid); * return null; * } * * Response.Redirect("/Store/Login"); * return null; * } * } * } * * } * } * else * { * Response.Redirect("/Account/noBusiness"); * return null; * } * //是否localhost、ip门店登录 * string isLocalhostIp = "0"; * if (csid2.message == "localhost" || csid2.message == "ip") * { * isLocalhostIp = "1"; * } */ ViewBag.isLocalhostIp = "1"; ViewBag.cid = Pharos.Utility.Config.GetAppSettings("CompanyId"); ViewBag.sid = Sys.SysCommonRules.CurrentStore; ViewBag.WelcomeText = "欢迎光临"; ViewBag.CurUserName = Sys.CurrentStoreUser.FullName; ViewBag.CurLoginName = Sys.CurrentStoreUser.UserName; ViewBag.comptitle = Sys.CurrentStoreUser.StoreName; //获取活动列表 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;//活动公告 //近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, Sys.CurrentStoreUser.StoreId); //新增会员数量 ViewBag.newSalesVolume = ReportBLL.GetSalesVolume(beginTime, endTime, Sys.CurrentStoreUser.StoreId); //新增销售量 var saleOrderList3Day = SaleOrdersService.GetIndexSaleOrder(beginTime, endTime, Sys.CurrentStoreUser.StoreId); //3天内的销售订单 ViewBag.newSaleOrderNumber = saleOrderList3Day.Count(); //新增客单量 decimal newSaleTotal = 0; newSaleTotal = saleOrderList3Day.Sum(o => o.TotalAmount); 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, Sys.CurrentStoreUser.StoreId); dayTitleList.Add(int.Parse(DateTime.Now.AddDays(0 - i).ToString("dd")) + "日"); saleTotalList.Add(saleOrderList.Sum(o => o.TotalAmount)); 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, Sys.CurrentStoreUser.StoreId); //近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.CurrentStoreUser.UID, 1); //var pids = new string[] { "1", "3", "15", "25", "68" }; //传秤门店固定菜单 list.Add(new Sys.Models.MenuModel() { Id = "165", Level = 0, Name = "商品传秤", ParentId = "0", Url = null, Value = "165", Children = new List <Sys.Models.MenuModel>() { new Sys.Models.MenuModel() { Id = "166", Level = 1, Name = "下发到电子秤", ParentId = "165", Url = "/Product/ProductWeight", Value = "166", Children = null }, new Sys.Models.MenuModel() { Id = "167", Level = 1, Name = "电子秤设备配置", ParentId = "165", Url = "/Product/ProductWeightSetting", Value = "167", Children = null } } }); ViewBag.Menus = list; var set = new Pharos.Sys.BLL.SysWebSettingBLL().GetWebSetting(); return(View(set)); }