Example #1
0
        private void LoadStore(int regionId)
        {
            List <SelectListItem> storeIndustryList = new List <SelectListItem>();

            storeIndustryList.Add(new SelectListItem()
            {
                Text = "选择店铺行业", Value = "-1"
            });
            foreach (StoreIndustryInfo storeIndustryInfo in AdminStoreIndustries.GetStoreIndustryList())
            {
                storeIndustryList.Add(new SelectListItem()
                {
                    Text = storeIndustryInfo.Title, Value = storeIndustryInfo.StoreIid.ToString()
                });
            }
            ViewData["storeIndustryList"] = storeIndustryList;

            List <SelectListItem> themeList = new List <SelectListItem>();
            DirectoryInfo         dir       = new DirectoryInfo(IOHelper.GetMapPath("/themes"));

            foreach (DirectoryInfo themeDir in dir.GetDirectories())
            {
                themeList.Add(new SelectListItem()
                {
                    Text = themeDir.Name, Value = themeDir.Name
                });
            }
            ViewData["themeList"] = themeList;

            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo != null)
            {
                ViewData["provinceId"] = regionInfo.ProvinceId;
                ViewData["cityId"]     = regionInfo.CityId;
                ViewData["countyId"]   = regionInfo.RegionId;
            }
            else
            {
                ViewData["provinceId"] = -1;
                ViewData["cityId"]     = -1;
                ViewData["countyId"]   = -1;
            }

            string allowImgType = string.Empty;

            string[] imgTypeList = StringHelper.SplitString(BMAConfig.MallConfig.UploadImgType, ",");
            foreach (string imgType in imgTypeList)
            {
                allowImgType += string.Format("{0},", imgType.ToLower());
            }
            allowImgType = allowImgType.Replace(".", "");
            allowImgType = allowImgType.TrimEnd(',');

            string[] sizeList = StringHelper.SplitString(WorkContext.MallConfig.StoreLogoThumbSize);

            ViewData["size"]         = sizeList[sizeList.Length / 2];
            ViewData["allowImgType"] = allowImgType;
            ViewData["maxImgSize"]   = BMAConfig.MallConfig.UploadImgSize;
        }
Example #2
0
        private void Load(int regionId)
        {
            List <SelectListItem> adminGroupList = new List <SelectListItem>();

            adminGroupList.Add(new SelectListItem()
            {
                Text = "选择管理员组", Value = "0"
            });
            foreach (AdminGroupInfo info in AdminGroups.GetAdminGroupList())
            {
                adminGroupList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.AdminGid.ToString()
                });
            }
            ViewData["adminGroupList"] = adminGroupList;

            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo != null)
            {
                ViewData["provinceId"] = regionInfo.ProvinceId;
                ViewData["cityId"]     = regionInfo.CityId;
                ViewData["countyId"]   = regionInfo.RegionId;
            }
            else
            {
                ViewData["provinceId"] = -1;
                ViewData["cityId"]     = -1;
                ViewData["countyId"]   = -1;
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
        }
Example #3
0
        /// <summary>
        /// 用户信息
        /// </summary>
        public ActionResult UserInfo()
        {
            UserInfoModel model = new UserInfoModel();

            model.UserInfo       = Users.GetUserById(WorkContext.Uid);
            model.UserRankInfo   = WorkContext.UserRankInfo;
            model.AdminGroupInfo = WorkContext.AdminGroupInfo;

            RegionInfo regionInfo = Regions.GetRegionById(model.UserInfo.RegionId);

            if (regionInfo != null)
            {
                ViewData["provinceId"] = regionInfo.ProvinceId;
                ViewData["cityId"]     = regionInfo.CityId;
                ViewData["countyId"]   = regionInfo.RegionId;
            }
            else
            {
                ViewData["provinceId"] = -1;
                ViewData["cityId"]     = -1;
                ViewData["countyId"]   = -1;
            }

            return(View(model));
        }
Example #4
0
        /// <summary>
        /// 订单信息
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <returns></returns>
        public ActionResult OrderInfo(int oid = -1)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }
            if (orderInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("不能操作其它店铺的订单"));
            }

            OrderInfoModel model = new OrderInfoModel();

            model.OrderInfo        = orderInfo;
            model.RegionInfo       = Regions.GetRegionById(orderInfo.RegionId);
            model.UserInfo         = Users.GetUserById(orderInfo.Uid);
            model.UserRankInfo     = AdminUserRanks.GetUserRankById(model.UserInfo.UserRid);
            model.OrderProductList = AdminOrders.GetOrderProductList(oid);
            model.OrderActionList  = OrderActions.GetOrderActionList(oid);

            string[] sizeList = StringHelper.SplitString(WorkContext.MallConfig.ProductShowThumbSize);

            ViewData["size"]    = sizeList[sizeList.Length / 2];
            ViewData["referer"] = MallUtils.GetStoreAdminRefererCookie();
            return(View(model));
        }
Example #5
0
        /// <summary>
        /// 订单信息
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <returns></returns>
        public ActionResult OrderInfo(int oid = -1)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }
            if (orderInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("不能操作其它店铺的订单"));
            }

            OrderInfoModel model = new OrderInfoModel();

            model.OrderInfo        = orderInfo;
            model.RegionInfo       = Regions.GetRegionById(orderInfo.RegionId);
            model.UserInfo         = Users.GetUserById(orderInfo.Uid);
            model.UserRankInfo     = AdminUserRanks.GetUserRankById(model.UserInfo.UserRid);
            model.OrderProductList = AdminOrders.GetOrderProductList(oid);
            model.OrderActionList  = OrderActions.GetOrderActionList(oid);

            ViewData["referer"] = MallUtils.GetStoreAdminRefererCookie();
            return(View(model));
        }
Example #6
0
        private void LoadStoreShipFee(int regionId)
        {
            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo != null)
            {
                if (regionInfo.Layer == 1)
                {
                    ViewData["provinceId"] = regionInfo.ProvinceId;
                    ViewData["cityId"]     = 0;
                }
                else
                {
                    RegionInfo parentRegionInfo = Regions.GetRegionById(regionInfo.ParentId);
                    ViewData["provinceId"] = parentRegionInfo.ProvinceId;
                    ViewData["cityId"]     = regionInfo.RegionId;
                }
            }
            else
            {
                ViewData["provinceId"] = 0;
                ViewData["cityId"]     = 0;
            }

            ViewData["referer"] = MallUtils.GetStoreAdminRefererCookie();
        }
Example #7
0
        public ActionResult EditShipRule(string shipRuleName = "")
        {
            ShipRuleInfo shipRuleInfo = PluginUtils.GetShipRuleList().Find(x => x.Name == shipRuleName);

            if (shipRuleInfo == null)
            {
                return(PromptView(Url.Action("config", "plugin", new { configController = "AdminSTO", configAction = "ShipRuleList" }), "配送规则不存在"));
            }

            ShipRuleModel model = new ShipRuleModel();

            model.Name = shipRuleInfo.Name;

            RegionInfo regionInfo = Regions.GetRegionById(shipRuleInfo.RegionId);

            if (regionInfo == null)
            {
                model.ProvinceId = -1;
                model.CityId     = -1;
                model.CountyId   = -1;
            }
            else
            {
                if (regionInfo.Layer == 1)
                {
                    model.ProvinceId = regionInfo.ProvinceId;
                    model.CityId     = -1;
                    model.CountyId   = -1;
                }
                else if (regionInfo.Layer == 2)
                {
                    model.ProvinceId = regionInfo.ProvinceId;
                    model.CityId     = regionInfo.CityId;
                    model.CountyId   = -1;
                }
                else if (regionInfo.Layer == 3)
                {
                    model.ProvinceId = regionInfo.ProvinceId;
                    model.CityId     = regionInfo.CityId;
                    model.CountyId   = regionInfo.RegionId;
                }
            }

            model.Type      = shipRuleInfo.Type;
            model.ExtCode1  = shipRuleInfo.ExtCode1;
            model.ExtCode2  = shipRuleInfo.ExtCode2;
            model.FreeMoney = shipRuleInfo.FreeMoney;
            model.CODPayFee = shipRuleInfo.CODPayFee;

            Load(model.ProvinceId, model.CityId, model.CountyId);

            return(View("~/plugins/BrnShop.ShipPlugin.STO/views/adminsto/editshiprule.cshtml", model));
        }
Example #8
0
        private void Load(int regionId)
        {
            List <SelectListItem> userRankList = new List <SelectListItem>();

            userRankList.Add(new SelectListItem()
            {
                Text = "选择会员等级", Value = "0"
            });
            foreach (UserRankInfo info in AdminUserRanks.GetUserRankList())
            {
                userRankList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.UserRid.ToString()
                });
            }
            ViewData["userRankList"] = userRankList;


            List <SelectListItem> mallAdminGroupList = new List <SelectListItem>();

            mallAdminGroupList.Add(new SelectListItem()
            {
                Text = "选择管理员组", Value = "0"
            });
            foreach (MallAdminGroupInfo info in MallAdminGroups.GetMallAdminGroupList())
            {
                mallAdminGroupList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.MallAGid.ToString()
                });
            }
            ViewData["mallAdminGroupList"] = mallAdminGroupList;

            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo != null)
            {
                ViewData["provinceId"] = regionInfo.ProvinceId;
                ViewData["cityId"]     = regionInfo.CityId;
                ViewData["countyId"]   = regionInfo.RegionId;
            }
            else
            {
                ViewData["provinceId"] = -1;
                ViewData["cityId"]     = -1;
                ViewData["countyId"]   = -1;
            }

            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
        }
Example #9
0
        /// <summary>
        /// 商品咨询列表
        /// </summary>
        public ActionResult ProductConsultList()
        {
            int    pid            = WebHelper.GetQueryInt("pid");
            int    consultTypeId  = WebHelper.GetQueryInt("consultTypeId");
            string consultMessage = WebHelper.GetQueryString("consultMessage");
            int    page           = WebHelper.GetQueryInt("page");

            //判断商品是否存在
            PartProductInfo productInfo = Products.GetPartProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            if (!SecureHelper.IsSafeSqlString(consultMessage))
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的内容不存在"));
            }

            //店铺信息
            StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId);

            if (storeInfo.State != (int)StoreState.Open)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            PageModel pageModel           = new PageModel(10, page, ProductConsults.GetProductConsultCount(pid, consultTypeId, consultMessage));
            ProductConsultListModel model = new ProductConsultListModel()
            {
                ProductInfo            = productInfo,
                CategoryInfo           = Categories.GetCategoryById(productInfo.CateId),
                BrandInfo              = Brands.GetBrandById(productInfo.BrandId),
                StoreInfo              = storeInfo,
                StoreKeeperInfo        = Stores.GetStoreKeeperById(storeInfo.StoreId),
                StoreRegion            = Regions.GetRegionById(storeInfo.RegionId),
                StoreRankInfo          = StoreRanks.GetStoreRankById(storeInfo.StoreRid),
                ConsultTypeId          = consultTypeId,
                ConsultMessage         = consultMessage,
                PageModel              = pageModel,
                ProductConsultList     = ProductConsults.GetProductConsultList(pageModel.PageSize, pageModel.PageNumber, pid, consultTypeId, consultMessage),
                ProductConsultTypeList = ProductConsults.GetProductConsultTypeList(),
                IsVerifyCode           = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages)
            };

            return(View(model));
        }
Example #10
0
        private void LoadStore(int regionId)
        {
            List <SelectListItem> storeIndustryList = new List <SelectListItem>();

            storeIndustryList.Add(new SelectListItem()
            {
                Text = "选择店铺行业", Value = "-1"
            });
            foreach (StoreIndustryInfo storeIndustryInfo in AdminStoreIndustries.GetStoreIndustryList())
            {
                storeIndustryList.Add(new SelectListItem()
                {
                    Text = storeIndustryInfo.Title, Value = storeIndustryInfo.StoreIid.ToString()
                });
            }
            ViewData["storeIndustryList"] = storeIndustryList;

            List <SelectListItem> themeList = new List <SelectListItem>();
            DirectoryInfo         dir       = new DirectoryInfo(IOHelper.GetMapPath("/themes"));

            foreach (DirectoryInfo themeDir in dir.GetDirectories())
            {
                themeList.Add(new SelectListItem()
                {
                    Text = themeDir.Name, Value = themeDir.Name
                });
            }
            ViewData["themeList"] = themeList;

            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo != null)
            {
                ViewData["provinceId"] = regionInfo.ProvinceId;
                ViewData["cityId"]     = regionInfo.CityId;
                ViewData["countyId"]   = regionInfo.RegionId;
            }
            else
            {
                ViewData["provinceId"] = -1;
                ViewData["cityId"]     = -1;
                ViewData["countyId"]   = -1;
            }

            ViewData["allowImgType"] = BMAConfig.UploadConfig.UploadImgType.Replace(".", "");
            ViewData["maxImgSize"]   = BMAConfig.UploadConfig.UploadImgSize;
        }
Example #11
0
        /// <summary>
        /// 套装
        /// </summary>
        public ActionResult Suit()
        {
            //套装id
            int pmId = GetRouteInt("pmId");

            if (pmId == 0)
            {
                pmId = WebHelper.GetQueryInt("pmId");
            }

            //判断套装是否存在或过期
            SuitPromotionInfo suitPromotionInfo = Promotions.GetSuitPromotionByPmIdAndTime(pmId, DateTime.Now);

            if (suitPromotionInfo == null)
            {
                return(PromptView("/", "你访问的套装不存在或过期"));
            }

            //店铺信息
            StoreInfo storeInfo = Stores.GetStoreById(suitPromotionInfo.StoreId);

            if (storeInfo.State != (int)StoreState.Open)
            {
                return(PromptView("/", "你访问的套装不存在"));
            }

            //扩展套装商品列表
            List <ExtSuitProductInfo> extSuitProductList = Promotions.GetExtSuitProductList(pmId);

            SuitModel model = new SuitModel();

            model.SuitPromotionInfo = suitPromotionInfo;
            model.SuitProductList   = extSuitProductList;
            model.StoreInfo         = storeInfo;
            model.StoreKeeperInfo   = Stores.GetStoreKeeperById(storeInfo.StoreId);
            model.StoreRegion       = Regions.GetRegionById(storeInfo.RegionId);
            model.StoreRankInfo     = StoreRanks.GetStoreRankById(storeInfo.StoreRid);

            foreach (ExtSuitProductInfo extSuitProductInfo in extSuitProductList)
            {
                model.SuitDiscount  += extSuitProductInfo.Number * extSuitProductInfo.Discount;
                model.ProductAmount += extSuitProductInfo.Number * extSuitProductInfo.ShopPrice;
            }
            model.SuitAmount = model.ProductAmount - model.SuitDiscount;

            return(View(model));
        }
Example #12
0
        /// <summary>
        /// 订单售后服务信息
        /// </summary>
        /// <param name="asId">售后服务id</param>
        /// <returns></returns>
        public ActionResult OrderAfterServiceInfo(int asId)
        {
            OrderAfterServiceInfo orderAfterServiceInfo = AdminOrderAfterServices.GetOrderAfterServiceByASId(asId);

            if (orderAfterServiceInfo == null || orderAfterServiceInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("订单售后服务不存在"));
            }

            OrderAfterServiceModel model = new OrderAfterServiceModel();

            model.OrderAfterServiceInfo = orderAfterServiceInfo;
            model.RegionInfo            = Regions.GetRegionById(orderAfterServiceInfo.RegionId);

            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return(View(model));
        }
Example #13
0
        /// <summary>
        /// 订单信息
        /// </summary>
        public ActionResult OrderInfo()
        {
            int       oid       = WebHelper.GetQueryInt("oid");
            OrderInfo orderInfo = Orders.GetOrderByOid(oid);

            if (orderInfo == null || orderInfo.Uid != WorkContext.Uid)
            {
                return(PromptView("订单不存在"));
            }

            OrderInfoModel model = new OrderInfoModel();

            model.OrderInfo        = orderInfo;
            model.RegionInfo       = Regions.GetRegionById(orderInfo.RegionId);
            model.OrderProductList = AdminOrders.GetOrderProductList(oid);

            return(View(model));
        }
Example #14
0
        /// <summary>
        /// 打印订单
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <returns></returns>
        public ActionResult PrintOrder(int oid)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }

            PrintOrderModel model = new PrintOrderModel()
            {
                OrderInfo        = orderInfo,
                RegionInfo       = Regions.GetRegionById(orderInfo.RegionId),
                OrderProductList = AdminOrders.GetOrderProductList(oid),
            };

            return(View(model));
        }
Example #15
0
        /// <summary>
        /// 商品评价列表
        /// </summary>
        public ActionResult ProductReviewList()
        {
            int pid        = WebHelper.GetQueryInt("pid");
            int reviewType = WebHelper.GetQueryInt("reviewType");
            int page       = WebHelper.GetQueryInt("page");

            //判断商品是否存在
            PartProductInfo productInfo = Products.GetPartProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //店铺信息
            StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId);

            if (storeInfo.State != (int)StoreState.Open)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            if (reviewType < 0 || reviewType > 3)
            {
                reviewType = 0;
            }

            PageModel pageModel          = new PageModel(10, page, ProductReviews.GetProductReviewCount(pid, reviewType));
            ProductReviewListModel model = new ProductReviewListModel()
            {
                ProductInfo       = productInfo,
                CategoryInfo      = Categories.GetCategoryById(productInfo.CateId),
                BrandInfo         = Brands.GetBrandById(productInfo.BrandId),
                StoreInfo         = storeInfo,
                StoreKeeperInfo   = Stores.GetStoreKeeperById(storeInfo.StoreId),
                StoreRegion       = Regions.GetRegionById(storeInfo.RegionId),
                StoreRankInfo     = StoreRanks.GetStoreRankById(storeInfo.StoreRid),
                ReviewType        = reviewType,
                PageModel         = pageModel,
                ProductReviewList = ProductReviews.GetProductReviewList(pid, reviewType, pageModel.PageSize, pageModel.PageNumber)
            };

            return(View(model));
        }
Example #16
0
        /// <summary>
        /// 打印订单
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <returns></returns>
        public ActionResult PrintOrder(int oid)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }

            PrintOrderModel model = new PrintOrderModel()
            {
                OrderInfo        = orderInfo,
                RegionInfo       = Regions.GetRegionById(orderInfo.RegionId),
                OrderProductList = AdminOrders.GetOrderProductList(oid),
                AdminRealName    = AdminUsers.GetUserDetailById(WorkContext.Uid).RealName
            };

            return(View(model));
        }
Example #17
0
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);
            this.ValidateRequest = false;

            WorkContext.IP = WebHelper.GetIP();
            if (WebHelper.GetQueryString("ip") == WorkContext.IP)
            {
                WorkContext.RegionInfo = Regions.GetRegionById(WebHelper.GetQueryInt("regionid"));
            }
            else
            {
                WorkContext.RegionInfo = IPSearch.SearchRegion(WorkContext.IP);
            }
            if (WorkContext.RegionInfo == null)
            {
                WorkContext.RegionInfo = new RegionInfo()
                {
                    RegionId = -1, Name = "未知区域"
                };
            }
            WorkContext.RegionId = WorkContext.RegionInfo.RegionId;

            WorkContext.Url = WebHelper.GetUrl();

            WorkContext.AppType    = WebHelper.GetQueryInt("appType");
            WorkContext.AppVersion = WebHelper.GetQueryString("appVersion");
            WorkContext.AppOS      = WebHelper.GetQueryString("appOS");

            //获得用户唯一标示符sid
            WorkContext.Sid = WebHelper.GetQueryString("sid");

            if (WorkContext.Sid.Length == 0)
            {
                //生成sid
                WorkContext.Sid = Sessions.GenerateSid();
            }

            PartUserInfo partUserInfo;

            //获得用户id
            int uid = WebHelper.GetQueryInt("uid");

            if (uid < 1)//当用户为游客时
            {
                //创建游客
                partUserInfo = Users.CreatePartGuest();
            }
            else//当用户为会员时
            {
                string encryptPwd = WebHelper.GetQueryString("encryptPwd");
                //防止用户密码被篡改为危险字符
                if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd))
                {
                    //创建游客
                    partUserInfo = Users.CreatePartGuest();
                    encryptPwd   = string.Empty;
                }
                else
                {
                    partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd));
                    if (partUserInfo != null)
                    {
                        //发放登陆积分
                        Credits.SendLoginCredits(ref partUserInfo, DateTime.Now, TypeHelper.StringToDateTime(WebHelper.GetQueryString("slctime")), out WorkContext.SLCTime);
                    }
                    else//当会员的账号或密码不正确时,将用户置为游客
                    {
                        partUserInfo = Users.CreatePartGuest();
                        encryptPwd   = string.Empty;
                    }
                }
                WorkContext.EncryptPwd = encryptPwd;
            }

            //设置用户等级
            if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now)
            {
                UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits);
                Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid);
                partUserInfo.UserRid = userRankInfo.UserRid;
            }

            WorkContext.PartUserInfo = partUserInfo;

            WorkContext.Uid             = partUserInfo.Uid;
            WorkContext.UserName        = partUserInfo.UserName;
            WorkContext.UserEmail       = partUserInfo.Email;
            WorkContext.UserMobile      = partUserInfo.Mobile;
            WorkContext.Password        = partUserInfo.Password;
            WorkContext.NickName        = partUserInfo.NickName;
            WorkContext.Avatar          = partUserInfo.Avatar;
            WorkContext.PayCreditName   = Credits.PayCreditName;
            WorkContext.PayCreditCount  = partUserInfo.PayCredits;
            WorkContext.RankCreditName  = Credits.RankCreditName;
            WorkContext.RankCreditCount = partUserInfo.RankCredits;

            WorkContext.UserRid      = partUserInfo.UserRid;
            WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid);
            WorkContext.UserRTitle   = WorkContext.UserRankInfo.Title;
            //设置用户商城管理员组
            WorkContext.MallAGid           = partUserInfo.MallAGid;
            WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid);
            WorkContext.MallAGTitle        = WorkContext.MallAdminGroupInfo.Title;

            //设置当前控制器类名
            WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower();
            //设置当前动作方法名
            WorkContext.Action  = RouteData.Values["action"].ToString().ToLower();
            WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action);

            WorkContext.ImageCDN  = WorkContext.MallConfig.ImageCDN;
            WorkContext.CSSCDN    = WorkContext.MallConfig.CSSCDN;
            WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN;

            //在线总人数
            WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount();
            //在线游客数
            WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount();
            //在线会员数
            WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount;
            //购物车中商品数量
            WorkContext.CartProductCount = WebHelper.GetQueryInt("cartProductCount");
        }
Example #18
0
        /// <summary>
        /// 注册
        /// </summary>
        public ActionResult Register()
        {
            string returnUrl = WebHelper.GetQueryString("returnUrl");

            if (returnUrl.Length == 0)
            {
                returnUrl = Url.Action("index", "home");
            }

            if (WorkContext.MallConfig.RegType.Length == 0)
            {
                return(PromptView(returnUrl, "商城目前已经关闭注册功能!"));
            }
            if (WorkContext.Uid > 0)
            {
                return(PromptView(returnUrl, "你已经是本商城的注册用户,无需再注册!"));
            }
            if (WorkContext.MallConfig.RegTimeSpan > 0)
            {
                DateTime registerTime = Users.GetRegisterTimeByRegisterIP(WorkContext.IP);
                if ((DateTime.Now - registerTime).Minutes <= WorkContext.MallConfig.RegTimeSpan)
                {
                    return(PromptView(returnUrl, "你注册太频繁,请间隔一定时间后再注册!"));
                }
            }

            //get请求
            if (WebHelper.IsGet())
            {
                RegisterModel model = new RegisterModel();

                model.ReturnUrl    = returnUrl;
                model.ShadowName   = WorkContext.MallConfig.ShadowName;
                model.IsVerifyCode = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages);

                return(View(model));
            }

            //ajax请求
            string accountName = WebHelper.GetFormString(WorkContext.MallConfig.ShadowName).Trim().ToLower();
            string password    = WebHelper.GetFormString("password");
            string confirmPwd  = WebHelper.GetFormString("confirmPwd");
            string verifyCode  = WebHelper.GetFormString("verifyCode");

            StringBuilder errorList = new StringBuilder("[");

            #region 验证

            //账号验证
            if (string.IsNullOrWhiteSpace(accountName))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名不能为空", "}");
            }
            else if (accountName.Length < 4 || accountName.Length > 50)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名必须大于3且不大于50个字符", "}");
            }
            else if (accountName.Contains(" "))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含空格", "}");
            }
            else if (accountName.Contains(":"))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含冒号", "}");
            }
            else if (accountName.Contains("<"))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含'<'符号", "}");
            }
            else if (accountName.Contains(">"))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含'>'符号", "}");
            }
            else if ((!SecureHelper.IsSafeSqlString(accountName, false)))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名不符合系统要求", "}");
            }
            else if (CommonHelper.IsInArray(accountName, WorkContext.MallConfig.ReservedName, "\n"))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "此账户名不允许被注册", "}");
            }
            else if (FilterWords.IsContainWords(accountName))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名包含禁止单词", "}");
            }

            //密码验证
            if (string.IsNullOrWhiteSpace(password))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不能为空", "}");
            }
            else if (password.Length < 4 || password.Length > 32)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码必须大于3且不大于32个字符", "}");
            }
            else if (password != confirmPwd)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "两次输入的密码不一样", "}");
            }

            //验证码验证
            if (CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages))
            {
                if (string.IsNullOrWhiteSpace(verifyCode))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "verifyCode", "验证码不能为空", "}");
                }
                else if (verifyCode.ToLower() != Sessions.GetValueString(WorkContext.Sid, "verifyCode"))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "verifyCode", "验证码不正确", "}");
                }
            }

            //其它验证
            int gender = WebHelper.GetFormInt("gender");
            if (gender < 0 || gender > 2)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "gender", "请选择正确的性别", "}");
            }

            string nickName = WebHelper.GetFormString("nickName");
            if (nickName.Length > 10)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "nickName", "昵称的长度不能大于10", "}");
            }
            else if (FilterWords.IsContainWords(nickName))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "nickName", "昵称中包含禁止单词", "}");
            }

            if (WebHelper.GetFormString("realName").Length > 5)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "realName", "真实姓名的长度不能大于5", "}");
            }

            string bday = WebHelper.GetFormString("bday");
            if (bday.Length == 0)
            {
                string bdayY = WebHelper.GetFormString("bdayY");
                string bdayM = WebHelper.GetFormString("bdayM");
                string bdayD = WebHelper.GetFormString("bdayD");
                bday = string.Format("{0}-{1}-{2}", bdayY, bdayM, bdayD);
            }
            if (bday.Length > 0 && bday != "--" && !ValidateHelper.IsDate(bday))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "bday", "请选择正确的日期", "}");
            }

            string idCard = WebHelper.GetFormString("idCard");
            if (idCard.Length > 0 && !ValidateHelper.IsIdCard(idCard))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "idCard", "请输入正确的身份证号", "}");
            }

            int regionId = WebHelper.GetFormInt("regionId");
            if (regionId > 0)
            {
                if (Regions.GetRegionById(regionId) == null)
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "regionId", "请选择正确的地址", "}");
                }
                if (WebHelper.GetFormString("address").Length > 75)
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "address", "详细地址的长度不能大于75", "}");
                }
            }

            if (WebHelper.GetFormString("bio").Length > 150)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "bio", "简介的长度不能大于150", "}");
            }

            //当以上验证都通过时
            UserInfo userInfo = null;
            if (errorList.Length == 1)
            {
                if (WorkContext.MallConfig.RegType.Contains("2") && ValidateHelper.IsEmail(accountName))//验证邮箱
                {
                    string emailProvider = CommonHelper.GetEmailProvider(accountName);
                    if (WorkContext.MallConfig.AllowEmailProvider.Length != 0 && (!CommonHelper.IsInArray(emailProvider, WorkContext.MallConfig.AllowEmailProvider, "\n")))
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "不能使用'" + emailProvider + "'类型的邮箱", "}");
                    }
                    else if (CommonHelper.IsInArray(emailProvider, WorkContext.MallConfig.BanEmailProvider, "\n"))
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "不能使用'" + emailProvider + "'类型的邮箱", "}");
                    }
                    else if (Users.IsExistEmail(accountName))
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "邮箱已经存在", "}");
                    }
                    else
                    {
                        userInfo          = new UserInfo();
                        userInfo.UserName = string.Empty;
                        userInfo.Email    = accountName;
                        userInfo.Mobile   = string.Empty;
                    }
                }
                else if (WorkContext.MallConfig.RegType.Contains("3") && ValidateHelper.IsMobile(accountName))//验证手机
                {
                    if (Users.IsExistMobile(accountName))
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "手机号已经存在", "}");
                    }
                    else
                    {
                        userInfo          = new UserInfo();
                        userInfo.UserName = string.Empty;
                        userInfo.Email    = string.Empty;
                        userInfo.Mobile   = accountName;
                    }
                }
                else if (WorkContext.MallConfig.RegType.Contains("1"))//验证用户名
                {
                    if (accountName.Length > 20)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名长度不能超过20个字符", "}");
                    }
                    else if (BrnMall.Services.Users.IsExistUserName(accountName))
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名已经存在", "}");
                    }
                    else
                    {
                        userInfo          = new UserInfo();
                        userInfo.UserName = accountName;
                        userInfo.Email    = string.Empty;
                        userInfo.Mobile   = string.Empty;
                    }
                }
            }

            #endregion

            if (errorList.Length > 1)//验证失败
            {
                return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true));
            }
            else//验证成功
            {
                #region 绑定用户信息

                userInfo.Salt     = Randoms.CreateRandomValue(6);
                userInfo.Password = Users.CreateUserPassword(password, userInfo.Salt);
                userInfo.UserRid  = UserRanks.GetLowestUserRank().UserRid;
                userInfo.StoreId  = 0;
                userInfo.MallAGid = 1;//非管理员组
                if (nickName.Length > 0)
                {
                    userInfo.NickName = WebHelper.HtmlEncode(nickName);
                }
                else
                {
                    userInfo.NickName = "bma" + Randoms.CreateRandomValue(7);
                }
                userInfo.Avatar       = "";
                userInfo.PayCredits   = 0;
                userInfo.RankCredits  = 0;
                userInfo.VerifyEmail  = 0;
                userInfo.VerifyMobile = 0;

                userInfo.LastVisitIP   = WorkContext.IP;
                userInfo.LastVisitRgId = WorkContext.RegionId;
                userInfo.LastVisitTime = DateTime.Now;
                userInfo.RegisterIP    = WorkContext.IP;
                userInfo.RegisterRgId  = WorkContext.RegionId;
                userInfo.RegisterTime  = DateTime.Now;

                userInfo.Gender   = WebHelper.GetFormInt("gender");
                userInfo.RealName = WebHelper.HtmlEncode(WebHelper.GetFormString("realName"));
                userInfo.Bday     = bday.Length > 0 ? TypeHelper.StringToDateTime(bday) : new DateTime(1900, 1, 1);
                userInfo.IdCard   = WebHelper.GetFormString("idCard");
                userInfo.RegionId = WebHelper.GetFormInt("regionId");
                userInfo.Address  = WebHelper.HtmlEncode(WebHelper.GetFormString("address"));
                userInfo.Bio      = WebHelper.HtmlEncode(WebHelper.GetFormString("bio"));

                #endregion

                //创建用户
                userInfo.Uid = Users.CreateUser(userInfo);

                //添加用户失败
                if (userInfo.Uid < 1)
                {
                    return(AjaxResult("exception", "创建用户失败,请联系管理员"));
                }

                //发放注册积分
                Credits.SendRegisterCredits(ref userInfo, DateTime.Now);
                //更新购物车中用户id
                Carts.UpdateCartUidBySid(userInfo.Uid, WorkContext.Sid);
                //将用户信息写入cookie
                MallUtils.SetUserCookie(userInfo, 0);

                //发送注册欢迎信息
                if (WorkContext.MallConfig.IsWebcomeMsg == 1)
                {
                    if (userInfo.Email.Length > 0)
                    {
                        Emails.SendWebcomeEmail(userInfo.Email);
                    }
                    if (userInfo.Mobile.Length > 0)
                    {
                        SMSes.SendWebcomeSMS(userInfo.Mobile);
                    }
                }

                //同步上下文
                WorkContext.Uid        = userInfo.Uid;
                WorkContext.UserName   = userInfo.UserName;
                WorkContext.UserEmail  = userInfo.Email;
                WorkContext.UserMobile = userInfo.Mobile;
                WorkContext.NickName   = userInfo.NickName;

                return(AjaxResult("success", "注册成功"));
            }
        }
Example #19
0
        public ActionResult AddShipRule(ShipRuleModel model)
        {
            if (ModelState.IsValid)
            {
                ShipRuleInfo shipRuleInfo = new ShipRuleInfo();
                shipRuleInfo.Name     = model.Name;
                shipRuleInfo.Type     = model.Type;
                shipRuleInfo.ExtCode1 = model.ExtCode1;
                if (model.Type == 0)
                {
                    shipRuleInfo.ExtCode2 = model.ExtCode2;
                }
                shipRuleInfo.FreeMoney = model.FreeMoney;
                shipRuleInfo.CODPayFee = model.CODPayFee;

                int regionId = 0;
                if (model.ProvinceId > 0)
                {
                    regionId = model.ProvinceId;
                }
                if (model.CityId > 0)
                {
                    regionId = model.CityId;
                }
                if (model.CountyId > 0)
                {
                    regionId = model.CountyId;
                }
                RegionInfo regionInfo = Regions.GetRegionById(regionId);
                if (regionInfo == null)
                {
                    shipRuleInfo.RegionId    = 0;
                    shipRuleInfo.RegionTitle = "全国";
                }
                else
                {
                    if (regionInfo.Layer == 1)
                    {
                        shipRuleInfo.RegionId    = regionId;
                        shipRuleInfo.RegionTitle = regionInfo.Name;
                    }
                    else if (regionInfo.Layer == 2)
                    {
                        shipRuleInfo.RegionId    = regionId;
                        shipRuleInfo.RegionTitle = regionInfo.ProvinceName + regionInfo.Name;
                    }
                    else if (regionInfo.Layer == 3)
                    {
                        shipRuleInfo.RegionId    = regionId;
                        shipRuleInfo.RegionTitle = regionInfo.ProvinceName + regionInfo.CityName + regionInfo.Name;
                    }
                }

                List <ShipRuleInfo> shipRuleList = PluginUtils.GetShipRuleList();
                shipRuleList.Add(shipRuleInfo);
                PluginUtils.SaveShipRuleList(shipRuleList);

                AddAdminOperateLog("添加申通快递配送规则");
                return(PromptView(Url.Action("config", "plugin", new { configController = "AdminSTO", configAction = "ShipRuleList" }), "配送规则添加成功"));
            }

            return(PromptView(Url.Action("config", "plugin", new { configController = "AdminSTO", configAction = "AddShipRule" }), "内容有误,请重写填写"));
        }
Example #20
0
        /// <summary>
        /// 编辑用户信息
        /// </summary>
        public ActionResult EditUser()
        {
            string userName = WebHelper.GetFormString("userName");
            string nickName = WebHelper.GetFormString("nickName");
            string avatar   = WebHelper.GetFormString("avatar");
            string realName = WebHelper.GetFormString("realName");
            int    gender   = WebHelper.GetFormInt("gender");
            string idCard   = WebHelper.GetFormString("idCard");
            string bday     = WebHelper.GetFormString("bday");
            int    regionId = WebHelper.GetFormInt("regionId");
            string address  = WebHelper.GetFormString("address");
            string bio      = WebHelper.GetFormString("bio");

            StringBuilder errorList = new StringBuilder("[");

            //验证用户名
            if (WorkContext.UserName.Length == 0 && userName.Length > 0)
            {
                if (userName.Length < 4 || userName.Length > 10)
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名必须大于3且不大于10个字符", "}");
                }
                else if (userName.Contains(" "))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名中不允许包含空格", "}");
                }
                else if (userName.Contains(":"))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名中不允许包含冒号", "}");
                }
                else if (userName.Contains("<"))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名中不允许包含'<'符号", "}");
                }
                else if (userName.Contains(">"))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名中不允许包含'>'符号", "}");
                }
                else if ((!SecureHelper.IsSafeSqlString(userName)))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名不符合系统要求", "}");
                }
                else if (CommonHelper.IsInArray(userName, WorkContext.ShopConfig.ReservedName, "\n"))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名已经存在", "}");
                }
                else if (FilterWords.IsContainWords(userName))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名包含禁止单词", "}");
                }
                else if (Users.IsExistUserName(userName))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "userName", "用户名已经存在", "}");
                }
            }
            else
            {
                userName = WorkContext.UserName;
            }

            //验证昵称
            if (nickName.Length > 10)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "nickName", "昵称的长度不能大于10", "}");
            }
            else if (FilterWords.IsContainWords(nickName))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "nickName", "昵称中包含禁止单词", "}");
            }

            //验证真实姓名
            if (realName.Length > 5)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "realName", "真实姓名的长度不能大于5", "}");
            }

            //验证性别
            if (gender < 0 || gender > 2)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "gender", "请选择正确的性别", "}");
            }

            //验证身份证号
            if (idCard.Length > 0 && !ValidateHelper.IsIdCard(idCard))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "idCard", "请输入正确的身份证号", "}");
            }

            //验证出生日期
            if (bday.Length == 0)
            {
                string bdayY = WebHelper.GetFormString("bdayY");
                string bdayM = WebHelper.GetFormString("bdayM");
                string bdayD = WebHelper.GetFormString("bdayD");
                bday = string.Format("{0}-{1}-{2}", bdayY, bdayM, bdayD);
            }
            if (bday.Length > 0 && bday != "--" && !ValidateHelper.IsDate(bday))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "bday", "请选择正确的日期", "}");
            }

            //验证区域
            if (regionId > 0)
            {
                RegionInfo regionInfo = Regions.GetRegionById(regionId);
                if (regionInfo == null || regionInfo.Layer != 3)
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "regionId", "请选择正确的地址", "}");
                }
            }

            //验证详细地址
            if (address.Length > 75)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "address", "详细地址的长度不能大于75", "}");
            }

            //验证简介
            if (bio.Length > 150)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "bio", "简介的长度不能大于150", "}");
            }

            if (errorList.Length == 1)
            {
                if (bday.Length == 0 || bday == "--")
                {
                    bday = "1900-1-1";
                }

                if (regionId < 1)
                {
                    regionId = 0;
                }

                Users.UpdateUser(WorkContext.Uid, userName, WebHelper.HtmlEncode(nickName), WebHelper.HtmlEncode(avatar), gender, WebHelper.HtmlEncode(realName), TypeHelper.StringToDateTime(bday), idCard, regionId, WebHelper.HtmlEncode(address), WebHelper.HtmlEncode(bio));
                if (userName.Length > 0 && nickName.Length > 0 && avatar.Length > 0 && realName.Length > 0 && bday != "1900-1-1" && idCard.Length > 0 && regionId > 0 && address.Length > 0)
                {
                    //Credits.SendCompleteUserInfoCredits(ref WorkContext.PartUserInfo, DateTime.Now);
                }
                return(AjaxResult("success", "信息更新成功"));
            }
            else
            {
                return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true));
            }
        }
Example #21
0
        /// <summary>
        /// 商品
        /// </summary>
        public ActionResult Product()
        {
            //商品id
            int pid = GetRouteInt("pid");

            if (pid == 0)
            {
                pid = WebHelper.GetQueryInt("pid");
            }

            //判断商品是否存在
            ProductInfo productInfo = Products.GetProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //店铺信息
            StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId);

            if (storeInfo.State != (int)StoreState.Open)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //商品存在时
            ProductModel model = new ProductModel();

            //商品id
            model.Pid = pid;
            //商品信息
            model.ProductInfo = productInfo;
            //商品分类
            model.CategoryInfo = Categories.GetCategoryById(productInfo.CateId);
            //商品品牌
            model.BrandInfo = Brands.GetBrandById(productInfo.BrandId);
            //店铺信息
            model.StoreInfo = storeInfo;
            //店长信息
            model.StoreKeeperInfo = Stores.GetStoreKeeperById(storeInfo.StoreId);
            //店铺区域
            model.StoreRegion = Regions.GetRegionById(storeInfo.RegionId);
            //店铺等级信息
            model.StoreRankInfo = StoreRanks.GetStoreRankById(storeInfo.StoreRid);
            //商品图片列表
            model.ProductImageList = Products.GetProductImageList(pid);
            //扩展商品属性列表
            model.ExtProductAttributeList = Products.GetExtProductAttributeList(pid);
            //商品SKU列表
            model.ProductSKUList = Products.GetProductSKUListBySKUGid(productInfo.SKUGid);
            //商品库存数量
            model.StockNumber = Products.GetProductStockNumberByPid(pid);


            //单品促销
            model.SinglePromotionInfo = Promotions.GetSinglePromotionByPidAndTime(pid, DateTime.Now);
            //买送促销活动列表
            model.BuySendPromotionList = Promotions.GetBuySendPromotionList(productInfo.StoreId, pid, DateTime.Now);
            //赠品促销活动
            model.GiftPromotionInfo = Promotions.GetGiftPromotionByPidAndTime(pid, DateTime.Now);
            //赠品列表
            if (model.GiftPromotionInfo != null)
            {
                model.ExtGiftList = Promotions.GetExtGiftList(model.GiftPromotionInfo.PmId);
            }
            //套装商品列表
            model.SuitProductList = Promotions.GetProductAllSuitPromotion(pid, DateTime.Now);
            //满赠促销活动
            model.FullSendPromotionInfo = Promotions.GetFullSendPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now);
            //满减促销活动
            model.FullCutPromotionInfo = Promotions.GetFullCutPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now);

            //广告语
            model.Slogan = model.SinglePromotionInfo == null ? "" : model.SinglePromotionInfo.Slogan;
            //商品促销信息
            model.PromotionMsg = Promotions.GeneratePromotionMsg(model.SinglePromotionInfo, model.BuySendPromotionList, model.FullSendPromotionInfo, model.FullCutPromotionInfo);
            //商品折扣价格
            model.DiscountPrice = Promotions.ComputeDiscountPrice(model.ProductInfo.ShopPrice, model.SinglePromotionInfo);

            //关联商品列表
            model.RelateProductList = Products.GetRelateProductList(pid);

            //用户浏览历史
            model.UserBrowseHistory = BrowseHistories.GetUserBrowseHistory(WorkContext.Uid, pid);

            //商品咨询类型列表
            model.ProductConsultTypeList = ProductConsults.GetProductConsultTypeList();

            //更新浏览历史
            if (WorkContext.Uid > 0)
            {
                Asyn.UpdateBrowseHistory(WorkContext.Uid, pid);
            }
            //更新商品统计
            Asyn.UpdateProductStat(pid, WorkContext.RegionId);

            return(View(model));
        }
Example #22
0
        /// <summary>
        /// 验证配送地址
        /// </summary>
        private string VerifyShipAddress(int regionId, string alias, string consignee, string mobile, string phone, string email, string zipcode, string address)
        {
            StringBuilder errorList = new StringBuilder("[");

            //检查区域
            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo == null || regionInfo.Layer != 3)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "regionId", "请选择有效的区域", "}");
            }

            //检查地址别名
            if (alias.Length > 25)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "alias", "最多只能输入25个字", "}");
            }

            //检查收货人
            if (string.IsNullOrWhiteSpace(consignee))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "consignee", "收货人不能为空", "}");
            }
            else if (consignee.Length > 10)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "consignee", "最多只能输入10个字", "}");
            }

            //检查手机号和固话号
            if (string.IsNullOrWhiteSpace(mobile) && string.IsNullOrWhiteSpace(phone))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "mobile", "手机号和固话号必填一项", "}");
            }
            else
            {
                if (!ValidateHelper.IsMobile(mobile))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "mobile", "手机号格式不正确", "}");
                }
                if (!ValidateHelper.IsPhone(phone))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "phone", "固话号格式不正确", "}");
                }
            }

            //检查邮箱
            if (!ValidateHelper.IsEmail(email))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "email", "邮箱格式不正确", "}");
            }

            //检查邮编
            if (!ValidateHelper.IsZipCode(zipcode))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "zipcode", "邮编格式不正确", "}");
            }

            //检查详细地址
            if (string.IsNullOrWhiteSpace(address))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "address", "详细地址不能为空", "}");
            }
            else if (address.Length > 75)
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "address", "最多只能输入75个字", "}");
            }

            if (errorList.Length > 1)
            {
                return(errorList.Remove(errorList.Length - 1, 1).Append("]").ToString());
            }
            else
            {
                return("");
            }
        }
Example #23
0
        /// <summary>
        /// 根据ip地址确定所在区域
        /// </summary>
        /// <param name="ip">ip地址</param>
        /// <returns></returns>
        public RegionInfo Seek(string ip)
        {
            IPLocation ipLocation = SearchLocation(ip);

            if (ipLocation == null || ipLocation.Country.Length == 0)
            {
                return(null);
            }

            string country = ipLocation.Country;

            int startIndex = country.IndexOf("省");
            int endIndex   = country.IndexOf("市");

            if (startIndex > 0 && endIndex > 0 && endIndex > startIndex)
            {
                RegionInfo regionInfo = Regions.GetRegionByNameAndLayer(country.Substring(startIndex + 1, endIndex - startIndex), 2);
                if (regionInfo != null)
                {
                    return(regionInfo);
                }
            }

            if (country.StartsWith("北京"))
            {
                return(Regions.GetRegionById(35));
            }
            else if (country.StartsWith("天津"))
            {
                return(Regions.GetRegionById(36));
            }
            else if (country.StartsWith("上海"))
            {
                return(Regions.GetRegionById(107));
            }
            else if (country.StartsWith("重庆"))
            {
                return(Regions.GetRegionById(269));
            }
            else if (country.StartsWith("四川省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(23));
                }
                else if (country.StartsWith("四川省阿坝州"))
                {
                    return(Regions.GetRegionById(288));
                }
                else if (country.StartsWith("四川省甘孜州"))
                {
                    return(Regions.GetRegionById(289));
                }
                else if (country.StartsWith("四川省凉山州"))
                {
                    return(Regions.GetRegionById(290));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("湖南省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(18));
                }
                else if (country.StartsWith("湖南省湘西州"))
                {
                    return(Regions.GetRegionById(230));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("湖北省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(17));
                }
                else if (country.StartsWith("湖北省神农架林区"))
                {
                    return(Regions.GetRegionById(1997));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("广西"))
            {
                if (country.Length == 2)
                {
                    return(Regions.GetRegionById(20));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(2, country.IndexOf('市') - 2), 2));
                }
            }
            else if (country.StartsWith("云南省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(25));
                }
                else if (country.StartsWith("云南省楚雄州"))
                {
                    return(Regions.GetRegionById(308));
                }
                else if (country.StartsWith("云南省红河州"))
                {
                    return(Regions.GetRegionById(309));
                }
                else if (country.StartsWith("云南省文山州"))
                {
                    return(Regions.GetRegionById(310));
                }
                else if (country.StartsWith("云南省西双版纳州"))
                {
                    return(Regions.GetRegionById(311));
                }
                else if (country.StartsWith("云南省大理州"))
                {
                    return(Regions.GetRegionById(312));
                }
                else if (country.StartsWith("云南省德宏州"))
                {
                    return(Regions.GetRegionById(313));
                }
                else if (country.StartsWith("云南省怒江州"))
                {
                    return(Regions.GetRegionById(314));
                }
                else if (country.StartsWith("云南省迪庆州"))
                {
                    return(Regions.GetRegionById(315));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("黑龙江省"))
            {
                if (country.Length == 4)
                {
                    return(Regions.GetRegionById(8));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(4, country.IndexOf('市') - 4), 2));
                }
                else if (country.Contains("地区"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(4, country.IndexOf("地区") - 3), 2));
                }
            }
            else if (country.StartsWith("吉林省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(7));
                }
                else if (country.StartsWith("吉林省延边州"))
                {
                    return(Regions.GetRegionById(93));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("内蒙古"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(5));
                }
                else if (country.Contains("盟"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('盟') - 3), 2));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("贵州省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(24));
                }
                else if (country.StartsWith("贵州省黔西南"))
                {
                    return(Regions.GetRegionById(296));
                }
                else if (country.StartsWith("贵州省黔东南"))
                {
                    return(Regions.GetRegionById(298));
                }
                else if (country.StartsWith("贵州省黔南州"))
                {
                    return(Regions.GetRegionById(299));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("甘肃省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(28));
                }
                else if (country.StartsWith("甘肃省临夏州"))
                {
                    return(Regions.GetRegionById(345));
                }
                else if (country.StartsWith("甘肃省甘南"))
                {
                    return(Regions.GetRegionById(346));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("新疆"))
            {
                if (country.Length == 2)
                {
                    return(Regions.GetRegionById(31));
                }
                else if (country.StartsWith("新疆阿勒泰"))
                {
                    return(Regions.GetRegionById(373));
                }
                else if (country.StartsWith("新疆昌吉州"))
                {
                    return(Regions.GetRegionById(364));
                }
                else if (country.StartsWith("新疆博尔塔拉州"))
                {
                    return(Regions.GetRegionById(365));
                }
                else if (country.StartsWith("新疆巴音郭楞州"))
                {
                    return(Regions.GetRegionById(366));
                }
                else if (country.StartsWith("新疆克孜勒苏柯尔州"))
                {
                    return(Regions.GetRegionById(368));
                }
                else if (country.StartsWith("新疆伊犁州"))
                {
                    return(Regions.GetRegionById(371));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(2, country.IndexOf('市') - 2), 2));
                }
                else if (country.Contains("地区"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(2, country.IndexOf("地区") - 1), 2));
                }
            }
            else if (country.StartsWith("青海省"))
            {
                if (country.Length == 3)
                {
                    return(Regions.GetRegionById(29));
                }
                else if (country.StartsWith("青海省海北州"))
                {
                    return(Regions.GetRegionById(349));
                }
                else if (country.StartsWith("青海省黄南州"))
                {
                    return(Regions.GetRegionById(350));
                }
                else if (country.StartsWith("青海省海南州"))
                {
                    return(Regions.GetRegionById(351));
                }
                else if (country.StartsWith("青海省果洛州"))
                {
                    return(Regions.GetRegionById(352));
                }
                else if (country.StartsWith("青海省玉树州"))
                {
                    return(Regions.GetRegionById(353));
                }
                else if (country.StartsWith("青海省海西州"))
                {
                    return(Regions.GetRegionById(354));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(3, country.IndexOf('市') - 3), 2));
                }
            }
            else if (country.StartsWith("西藏"))
            {
                if (country.Length == 2)
                {
                    return(Regions.GetRegionById(26));
                }
                else if (country.Contains("市"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(2, country.IndexOf('市') - 2), 2));
                }
                else if (country.Contains("地区"))
                {
                    return(Regions.GetRegionByNameAndLayer(country.Substring(2, country.IndexOf("地区") - 1), 2));
                }
            }
            else if (country.StartsWith("香港"))
            {
                return(Regions.GetRegionById(3241));
            }
            else if (country.StartsWith("澳门"))
            {
                return(Regions.GetRegionById(3242));
            }
            else if (country.StartsWith("台湾"))
            {
                return(Regions.GetRegionById(3240));
            }
            return(null);
        }