Example #1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            //验证Base64字符串的正则表达式
            Regex info = new Regex(@"[0-9|]");
            List <ValidationResult> errorList = new List <ValidationResult>();

            if (!SecureHelper.IsSafeSqlString(NickName))
            {
                errorList.Add(new ValidationResult("昵称中包含不安全的字符,请删除!", new string[] { "NickName" }));
            }
            if (BetType == "0")
            {
                errorList.Add(new ValidationResult("请选择房间类型!", new string[] { "BetType" }));
            }
            if (!info.IsMatch(Money))
            {
                errorList.Add(new ValidationResult("请输入有效的投注金额!", new string[] { "Money" }));
            }
            if (!info.IsMatch(BetTime))
            {
                errorList.Add(new ValidationResult("请输入有效的投注时间!", new string[] { "BetTime" }));
            }

            return(errorList);
        }
Example #2
0
        /// <summary>
        /// 获得订单列表搜索条件
        /// </summary>
        /// <param name="storeId">店铺id</param>
        /// <param name="osn">订单编号</param>
        /// <param name="uid">用户id</param>
        /// <param name="consignee">收货人</param>
        /// <param name="orderState">订单状态</param>
        /// <returns></returns>
        public string GetOrderListCondition(int storeId, string osn, int uid, string consignee, int orderState)
        {
            StringBuilder condition = new StringBuilder();

            if (storeId > 0)
            {
                condition.AppendFormat(" AND [storeid] = {0} ", storeId);
            }
            if (!string.IsNullOrWhiteSpace(osn) && SecureHelper.IsSafeSqlString(osn))
            {
                condition.AppendFormat(" AND [osn] like '{0}%' ", osn);
            }
            if (uid > 0)
            {
                condition.AppendFormat(" AND [uid] = {0} ", uid);
            }
            if (!string.IsNullOrWhiteSpace(consignee) && SecureHelper.IsSafeSqlString(consignee))
            {
                condition.AppendFormat(" AND [consignee] like '{0}%' ", consignee);
            }
            if (orderState > 0)
            {
                condition.AppendFormat(" AND [orderstate] = {0} ", orderState);
            }

            return(condition.Length > 0 ? condition.Remove(0, 4).ToString() : "");
        }
Example #3
0
        /// <summary>
        /// 后台获得店铺列表条件
        /// </summary>
        /// <param name="storeName">店铺名称</param>
        /// <param name="storeRid">店铺等级id</param>
        /// <param name="storeIid">店铺行业id</param>
        /// <param name="state">店铺状态</param>
        /// <returns></returns>
        public string AdminGetStoreListCondition(string storeName, int storeRid, int storeIid, int state)
        {
            StringBuilder condition = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(storeName) && SecureHelper.IsSafeSqlString(storeName))
            {
                condition.AppendFormat(" AND [name] like '{0}%' ", storeName);
            }

            if (storeRid > 0)
            {
                condition.AppendFormat(" AND [storerid] = {0} ", storeRid);
            }

            if (storeIid > 0)
            {
                condition.AppendFormat(" AND [storeiid] = {0} ", storeIid);
            }

            if (state > -1)
            {
                condition.AppendFormat(" AND [state]={0} ", (int)state);
            }

            return(condition.Length > 0 ? condition.Remove(0, 4).ToString() : "");
        }
Example #4
0
        /// <summary>
        /// 搜索
        /// </summary>
        public ActionResult AjaxSearch()
        {
            //搜索词
            string keyword = WebHelper.GetQueryString("keyword");

            if (keyword.Length == 0)
            {
                return(Content(""));
            }
            if (!SecureHelper.IsSafeSqlString(keyword))
            {
                return(Content(""));
            }

            //分类id
            int cateId = WebHelper.GetQueryInt("cateId");
            //品牌id
            int brandId = WebHelper.GetQueryInt("brandId");
            //筛选价格
            int filterPrice = WebHelper.GetQueryInt("filterPrice");
            //筛选属性
            string filterAttr = WebHelper.GetQueryString("filterAttr");
            //是否只显示有货
            int onlyStock = WebHelper.GetQueryInt("onlyStock");
            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //分类信息
            CategoryInfo categoryInfo = Categories.GetCategoryById(cateId);

            //分类价格范围列表
            string[] catePriceRangeList = StringHelper.SplitString(categoryInfo.PriceRange, "\r\n");
            //筛选属性处理
            List <int> attrValueIdList = new List <int>();

            string[] filterAttrValueIdList = StringHelper.SplitString(filterAttr, "-");
            foreach (string attrValueId in filterAttrValueIdList)
            {
                int temp = TypeHelper.StringToInt(attrValueId);
                if (temp > 0)
                {
                    attrValueIdList.Add(temp);
                }
            }

            //分页对象
            PageModel pageModel = new PageModel(20, page, Searches.GetSearchProductCount(keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock));
            //视图对象
            AjaxSearchModel model = new AjaxSearchModel()
            {
                PageModel   = pageModel,
                ProductList = Searches.SearchProducts(pageModel.PageSize, pageModel.PageNumber, keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock, sortColumn, sortDirection)
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        /// <summary>
        /// 商品咨询列表
        /// </summary>
        public ActionResult AjaxProductConsultList()
        {
            int    pid            = WebHelper.GetQueryInt("pid");
            int    consultTypeId  = WebHelper.GetQueryInt("consultTypeId");
            string consultMessage = WebHelper.GetQueryString("consultMessage");
            int    page           = WebHelper.GetQueryInt("page");

            if (!SecureHelper.IsSafeSqlString(consultMessage))
            {
                return(View(new AjaxProductConsultListModel()));
            }

            PageModel pageModel = new PageModel(10, page, ProductConsults.GetProductConsultCount(pid, consultTypeId, consultMessage));
            AjaxProductConsultListModel model = new AjaxProductConsultListModel()
            {
                Pid                    = pid,
                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 #6
0
        /// <summary>
        /// 品牌选择列表
        /// </summary>
        /// <param name="brandName">品牌名称</param>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <returns></returns>
        public ContentResult SelectList(string brandName, int pageNumber = 1, int pageSize = 24)
        {
            if (!SecureHelper.IsSafeSqlString(brandName))
            {
                brandName = "";
            }

            string    condition = AdminBrands.AdminGetBrandListCondition(brandName);
            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminBrands.AdminGetBrandCount(condition));

            DataTable brandSelectList = AdminBrands.AdminGetBrandSelectList(pageModel.PageSize, pageModel.PageNumber, condition);

            StringBuilder result = new StringBuilder("{");

            result.AppendFormat("\"totalPages\":\"{0}\",\"pageNumber\":\"{1}\",\"items\":[", pageModel.TotalPages, pageModel.PageNumber);
            foreach (DataRow row in brandSelectList.Rows)
            {
                result.AppendFormat("{0}\"id\":\"{1}\",\"name\":\"{2}\"{3},", "{", row["brandid"], row["name"].ToString().Trim(), "}");
            }

            if (brandSelectList.Rows.Count > 0)
            {
                result.Remove(result.Length - 1, 1);
            }

            result.Append("]}");
            return(Content(result.ToString()));
        }
Example #7
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(Url.Action("index", "home"), "你访问的商品不存在"));
            }

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

            PageModel pageModel           = new PageModel(10, page, ProductConsults.GetProductConsultCount(pid, consultTypeId, consultMessage));
            ProductConsultListModel model = new ProductConsultListModel()
            {
                ProductInfo            = productInfo,
                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.ShopConfig.VerifyPages)
            };

            return(View(model));
        }
Example #8
0
        /// <summary>
        /// 咨询商品
        /// </summary>
        public ActionResult ConsultProduct()
        {
            //不允许游客访问
            if (WorkContext.Uid < 1)
            {
                return(AjaxResult("nologin", "请先登录"));
            }

            //验证验证码
            if (CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.ShopConfig.VerifyPages))
            {
                string verifyCode = WebHelper.GetFormString("verifyCode");//验证码
                if (string.IsNullOrWhiteSpace(verifyCode))
                {
                    return(AjaxResult("emptyverifycode", "验证码不能为空"));;
                }
                else if (verifyCode.ToLower() != Sessions.GetValueString(WorkContext.Sid, "verifyCode"))
                {
                    return(AjaxResult("wrongverifycode", "验证码错误"));;
                }
            }

            int    pid            = WebHelper.GetFormInt("pid");
            int    consultTypeId  = WebHelper.GetFormInt("consultTypeId");
            string consultMessage = WebHelper.GetFormString("consultMessage");

            PartProductInfo partProductInfo = Products.GetPartProductById(pid);

            if (partProductInfo == null)
            {
                return(AjaxResult("noproduct", "请选择商品"));
            }

            if (consultTypeId < 1 || ProductConsults.GetProductConsultTypeById(consultTypeId) == null)
            {
                return(AjaxResult("noproductconsulttype", "请选择咨询类型"));
            }
            ;

            if (string.IsNullOrWhiteSpace(consultMessage))
            {
                return(AjaxResult("noconsultmessage", "请填写咨询内容"));
            }
            ;
            if (consultMessage.Length > 100)
            {
                return(AjaxResult("muchconsultmessage", "咨询内容内容太长"));
            }
            ;
            if (!SecureHelper.IsSafeSqlString(consultMessage))
            {
                return(AjaxResult("dangerconsultmessage", "咨询内中包含非法字符"));
            }
            ;

            ProductConsults.ConsultProduct(pid, consultTypeId, WorkContext.Uid, DateTime.Now, WebHelper.HtmlEncode(consultMessage), WorkContext.NickName, partProductInfo.Name, partProductInfo.ShowImg, WorkContext.IP);
            return(AjaxResult("success", Url.Action("product", new RouteValueDictionary {
                { "pid", pid }
            })));;
        }
Example #9
0
        /// <summary>
        /// 订单退款列表
        /// </summary>
        /// <param name="osn">订单编号</param>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <returns></returns>
        public ActionResult RefundList(string osn, int pageSize = 15, int pageNumber = 1)
        {
            if (!SecureHelper.IsSafeSqlString(osn))
            {
                osn = "";
            }

            string    condition = AdminOrderRefunds.GetOrderRefundListCondition(WorkContext.StoreId, osn);
            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminOrderRefunds.GetOrderRefundCount(condition));

            OrderRefundListModel model = new OrderRefundListModel()
            {
                OrderRefundList = AdminOrderRefunds.GetOrderRefundList(pageModel.PageSize, pageModel.PageNumber, condition),
                PageModel       = pageModel,
                OSN             = osn
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&OSN={3}",
                                                          Url.Action("refundlist"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize, osn));


            return(View(model));
        }
Example #10
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> errorList = new List <ValidationResult>();

            if (!SecureHelper.IsSafeSqlString(UserName))
            {
                errorList.Add(new ValidationResult("用户名中包含不安全的字符,请删除!", new string[] { "UserName" }));
            }

            return(errorList);
        }
Example #11
0
        public ActionResult KeyWordSearch()
        {
            //搜索词
            string keyword = WebHelper.GetQueryString("keyword");

            WorkContext.SearchWord = WebHelper.HtmlEncode(keyword);
            if (keyword.Length == 0)
            {
                return(PromptView(WorkContext.UrlReferrer, "请输入搜索词"));
            }
            if (!SecureHelper.IsSafeSqlString(keyword))
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, keyword);

            //获取当前搜索词匹配缓存结果
            ProductSearchKeyInfo keyInfo = BMACache.Get(keyword) as ProductSearchKeyInfo;

            if (keyInfo != null && string.IsNullOrEmpty(keyInfo.Name)) //无匹配
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            if (keyInfo == null) //未匹配过
            {
                keyInfo = Searches.GetProductSearchKey(keyword);
                if (keyInfo == null || string.IsNullOrEmpty(keyInfo.Name))
                {
                    keyInfo = new ProductSearchKeyInfo()
                    {
                        Name    = "",
                        keyType = -1,
                        ToId    = -1
                    };
                }
                BMACache.Insert(keyword, keyInfo);
            }

            //再次判断搜索词匹配结果
            if (keyInfo != null && string.IsNullOrEmpty(keyInfo.Name)) //无匹配
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            return(Redirect(Url.Action("categorysearch", new RouteValueDictionary {
                { "keyword", keyword }, { "searchKeyType", keyInfo.keyType }, { "searchKeyId", keyInfo.ToId }
            })));
        }
Example #12
0
        /// <summary>
        /// 商品评价列表
        /// </summary>
        public ActionResult ProductReviewList(string productName, string message, string rateStartTime, string rateEndTime, string sortColumn, string sortDirection, int pid = -1, int pageNumber = 1, int pageSize = 15)
        {
            if (!SecureHelper.IsSafeSqlString(message))
            {
                message = "";
            }
            if (!SecureHelper.IsSafeSqlString(rateStartTime))
            {
                rateStartTime = "";
            }
            if (!SecureHelper.IsSafeSqlString(rateEndTime))
            {
                rateEndTime = "";
            }
            if (!SecureHelper.IsSafeSqlString(sortColumn))
            {
                sortColumn = "";
            }
            if (!SecureHelper.IsSafeSqlString(sortDirection))
            {
                sortDirection = "";
            }

            string condition = AdminProductReviews.AdminGetProductReviewListCondition(WorkContext.StoreId, pid, message, rateStartTime, rateEndTime);
            string sort      = AdminProductReviews.AdminGetProductReviewListSort(sortColumn, sortDirection);

            PageModel pageModel          = new PageModel(pageSize, pageNumber, AdminProductReviews.AdminGetProductReviewCount(condition));
            ProductReviewListModel model = new ProductReviewListModel()
            {
                PageModel         = pageModel,
                SortColumn        = sortColumn,
                SortDirection     = sortDirection,
                ProductReviewList = AdminProductReviews.AdminGetProductReviewList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                Pid         = pid,
                ProductName = string.IsNullOrWhiteSpace(productName) ? "选择商品" : productName,
                Message     = message,
                StartTime   = rateStartTime,
                EndTime     = rateEndTime
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&message={5}&pid={6}&productName={7}&startTime={8}&endTime={9}",
                                                          Url.Action("productreviewlist"),
                                                          pageModel.PageNumber, pageModel.PageSize,
                                                          sortColumn, sortDirection,
                                                          message,
                                                          pid, productName,
                                                          rateStartTime, rateEndTime));
            return(View(model));
        }
Example #13
0
        /// <summary>
        /// 获得订单退款列表条件
        /// </summary>
        /// <param name="storeId">店铺id</param>
        /// <param name="osn">订单编号</param>
        /// <returns></returns>
        public string GetOrderRefundListCondition(int storeId, string osn)
        {
            StringBuilder condition = new StringBuilder();

            if (storeId > 0)
            {
                condition.AppendFormat(" AND [storeid] = {0} ", storeId);
            }
            if (!string.IsNullOrWhiteSpace(osn) && SecureHelper.IsSafeSqlString(osn))
            {
                condition.AppendFormat(" AND [osn] like '{0}%' ", osn);
            }

            return(condition.Length > 0 ? condition.Remove(0, 4).ToString() : "");
        }
Example #14
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 #15
0
        /// <summary>
        /// 构建关键词查询sql
        /// </summary>
        /// <param name="keywordList">分词后的关键词列表</param>
        /// <returns></returns>
        private string BuildKeywordSql(List <string> keywordList)
        {
            StringBuilder sql = new StringBuilder();

            foreach (string keyword in keywordList)
            {
                if (SecureHelper.IsSafeSqlString(keyword))
                {
                    sql.AppendFormat("'{0}',", keyword);
                }
            }
            if (sql.Length > 0)
            {
                sql.Remove(sql.Length - 1, 1);
            }
            return(sql.ToString());
        }
Example #16
0
        /// <summary>
        /// 店铺搜索
        /// </summary>
        public ActionResult Search()
        {
            //搜索词
            string keyword = WebHelper.GetQueryString("keyword");

            if (keyword.Length > 0 && !SecureHelper.IsSafeSqlString(keyword))
            {
                return(View("~/mobile/views/shared/prompt.cshtml", new PromptModel(WorkContext.UrlReferrer, "您搜索的商品不存在")));
            }

            //判断搜索词是否为店铺分类名称,如果是则重定向到店铺分类页面
            int storeCid = Stores.GetStoreCidByStoreIdAndName(WorkContext.StoreId, keyword);

            if (storeCid > 0)
            {
                return(Redirect(Url.Action("class", new RouteValueDictionary {
                    { "storeId", WorkContext.StoreId }, { "storeCid", storeCid }
                })));
            }

            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //分页对象
            PageModel pageModel = new PageModel(20, page, Searches.GetSearchStoreProductCount(keyword, WorkContext.StoreId, 0, 0, 0));
            //视图对象
            StoreSearchModel model = new StoreSearchModel()
            {
                Word          = keyword,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                PageModel     = pageModel,
                ProductList   = Searches.SearchStoreProducts(pageModel.PageSize, pageModel.PageNumber, keyword, WorkContext.StoreId, 0, 0, 0, sortColumn, sortDirection)
            };

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, keyword);

            return(View(model));
        }
Example #17
0
        /// <summary>
        /// 品牌列表
        /// </summary>
        /// <returns></returns>
        public ActionResult List()
        {
            string brandName = WebHelper.GetQueryString("brandName");
            int    page      = WebHelper.GetQueryInt("page");

            if (!SecureHelper.IsSafeSqlString(brandName))
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的品牌不存在"));
            }

            PageModel      pageModel = new PageModel(10, page, Brands.GetBrandCount(brandName));
            BrandListModel model     = new BrandListModel()
            {
                PageModel = pageModel,
                BrandName = brandName,
                BrandList = Brands.GetBrandList(pageModel.PageSize, pageModel.PageNumber, brandName)
            };

            return(View(model));
        }
Example #18
0
        /// <summary>
        /// 优惠劵类型列表
        /// </summary>
        /// <param name="couponTypeName">优惠劵类型名称</param>
        /// <param name="type">类型0代表正在发放,1代表正在使用,-1代表全部</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="pageSize">每页数</param>
        /// <returns></returns>
        public ActionResult CouponTypeList(string couponTypeName, int type = -1, int pageNumber = 1, int pageSize = 15)
        {
            if (!SecureHelper.IsSafeSqlString(couponTypeName))
            {
                couponTypeName = "";
            }

            string condition = AdminCoupons.AdminGetCouponTypeListCondition(WorkContext.StoreId, type, couponTypeName);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminCoupons.AdminGetCouponTypeCount(condition));

            CouponTypeListModel model = new CouponTypeListModel()
            {
                CouponTypeList = AdminCoupons.AdminGetCouponTypeList(pageModel.PageSize, pageModel.PageNumber, condition),
                PageModel      = pageModel,
                Type           = type,
                CouponTypeName = couponTypeName
            };

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

            itemList.Add(new SelectListItem()
            {
                Text = "全部", Value = "-1"
            });
            itemList.Add(new SelectListItem()
            {
                Text = "正在发放", Value = "0"
            });
            itemList.Add(new SelectListItem()
            {
                Text = "正在使用", Value = "1"
            });
            ViewData["typeList"] = itemList;

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&CouponTypeName={3}&type={4}",
                                                          Url.Action("coupontypelist"),
                                                          pageModel.PageNumber, pageModel.PageSize,
                                                          couponTypeName, type));
            return(View(model));
        }
Example #19
0
        /// <summary>
        /// 优惠劵列表
        /// </summary>
        /// <param name="sn">编号</param>
        /// <param name="couponTypeId">优惠劵类型id</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="pageSize">每页数</param>
        /// <returns></returns>
        public ActionResult CouponList(string sn, string accountName, int couponTypeId = -1, int pageNumber = 1, int pageSize = 15)
        {
            CouponTypeInfo couponTypeInfo = AdminCoupons.AdminGetCouponTypeById(couponTypeId);

            if (couponTypeInfo == null)
            {
                return(PromptView("优惠劵类型不存在"));
            }
            if (couponTypeInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("不能操作其它店铺的优惠劵类型"));
            }

            int uid = AdminUsers.GetUidByAccountName(accountName);

            if (!SecureHelper.IsSafeSqlString(sn))
            {
                sn = "";
            }

            string condition = AdminCoupons.AdminGetCouponListCondition(sn, uid, couponTypeId);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminCoupons.AdminGetCouponCount(condition));

            CouponListModel model = new CouponListModel()
            {
                CouponList   = AdminCoupons.AdminGetCouponList(pageModel.PageSize, pageModel.PageNumber, condition),
                PageModel    = pageModel,
                AccountName  = accountName,
                CouponTypeId = couponTypeId,
                SN           = sn
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&couponTypeId={3}&sn={4}&accountName={5}",
                                                          Url.Action("couponlist"),
                                                          pageModel.PageNumber, pageModel.PageSize,
                                                          couponTypeId, sn, accountName));
            return(View(model));
        }
Example #20
0
        /// <summary>
        /// 新闻列表
        /// </summary>
        public ActionResult List()
        {
            string newsTitle  = WebHelper.GetQueryString("newsTitle");
            int    newsTypeId = WebHelper.GetQueryInt("newsTypeId");
            int    page       = WebHelper.GetQueryInt("page");

            if (!SecureHelper.IsSafeSqlString(newsTitle))
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的新闻不存在"));
            }

            string        condition = News.GetNewsListCondition(newsTypeId, newsTitle);
            PageModel     pageModel = new PageModel(10, page, News.GetNewsCount(condition));
            NewsListModel model     = new NewsListModel()
            {
                PageModel    = pageModel,
                NewsList     = News.GetNewsList(pageModel.PageSize, pageModel.PageNumber, condition),
                NewsTitle    = newsTitle,
                NewsTypeId   = newsTypeId,
                NewsTypeList = News.GetNewsTypeList()
            };

            return(View(model));
        }
Example #21
0
        /// <summary>
        /// 找回密码
        /// </summary>
        public ActionResult FindPwd()
        {
            //get请求
            if (WebHelper.IsGet())
            {
                FindPwdModel model = new FindPwdModel();

                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);
            string verifyCode  = WebHelper.GetFormString("verifyCode");

            StringBuilder errorList = new StringBuilder("[");

            //账号验证
            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 ((!SecureHelper.IsSafeSqlString(accountName)))
            {
                errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名不存在", "}");
            }

            //验证码验证
            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", "验证码不正确", "}");
                }
            }

            //当以上验证都通过时
            PartUserInfo partUserInfo = null;

            if (ModelState.IsValid)
            {
                if (ValidateHelper.IsEmail(accountName))//验证邮箱
                {
                    partUserInfo = Users.GetPartUserByEmail(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "邮箱不存在", "}");
                    }
                }
                else if (ValidateHelper.IsMobile(accountName))//验证手机
                {
                    partUserInfo = Users.GetPartUserByMobile(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "手机号不存在", "}");
                    }
                }
                else//验证用户名
                {
                    partUserInfo = Users.GetPartUserByName(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名不存在", "}");
                    }
                }
            }

            if (errorList.Length == 1)
            {
                if (partUserInfo.Email.Length == 0 && partUserInfo.Mobile.Length == 0)
                {
                    return(AjaxResult("nocanfind", "由于您没有设置邮箱和手机,所以不能找回此账号的密码"));
                }

                return(AjaxResult("success", Url.Action("selectfindpwdtype", new RouteValueDictionary {
                    { "uid", partUserInfo.Uid }
                })));
            }
            else
            {
                return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true));
            }
        }
Example #22
0
        /// <summary>
        /// 登录
        /// </summary>
        public ActionResult Login()
        {
            string returnUrl = WebHelper.GetQueryString("returnUrl");

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

            if (WorkContext.MallConfig.LoginType == "")
            {
                return(PromptView(returnUrl, "商城目前已经关闭登陆功能!"));
            }
            if (WorkContext.Uid > 0)
            {
                return(PromptView(returnUrl, "您已经登录,无须重复登录!"));
            }
            if (WorkContext.MallConfig.LoginFailTimes != 0 && LoginFailLogs.GetLoginFailTimesByIp(WorkContext.IP) >= WorkContext.MallConfig.LoginFailTimes)
            {
                return(PromptView(returnUrl, "您已经输入错误" + WorkContext.MallConfig.LoginFailTimes + "次密码,请15分钟后再登陆!"));
            }

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

                model.ReturnUrl       = returnUrl;
                model.ShadowName      = WorkContext.MallConfig.ShadowName;
                model.IsRemember      = WorkContext.MallConfig.IsRemember == 1;
                model.IsVerifyCode    = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages);
                model.OAuthPluginList = Plugins.GetOAuthPluginList();

                return(View(model));
            }

            //ajax请求
            string accountName = WebHelper.GetFormString(WorkContext.MallConfig.ShadowName);
            string password    = WebHelper.GetFormString("password");
            string verifyCode  = WebHelper.GetFormString("verifyCode");
            int    isRemember  = WebHelper.GetFormInt("isRemember");

            StringBuilder errorList = new StringBuilder("[");

            //验证账户名
            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 ((!SecureHelper.IsSafeSqlString(accountName, false)))
            {
                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个字符", "}");
            }

            //验证验证码
            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", "验证码不正确", "}");
                }
            }

            //当以上验证全部通过时
            PartUserInfo partUserInfo = null;

            if (errorList.Length == 1)
            {
                if (BMAConfig.MallConfig.LoginType.Contains("2") && ValidateHelper.IsEmail(accountName))//邮箱登陆
                {
                    partUserInfo = Users.GetPartUserByEmail(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "邮箱不存在", "}");
                    }
                }
                else if (BMAConfig.MallConfig.LoginType.Contains("3") && ValidateHelper.IsMobile(accountName))//手机登陆
                {
                    partUserInfo = Users.GetPartUserByMobile(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "手机不存在", "}");
                    }
                }
                else if (BMAConfig.MallConfig.LoginType.Contains("1"))//用户名登陆
                {
                    partUserInfo = Users.GetPartUserByName(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名不存在", "}");
                    }
                }

                if (partUserInfo != null)
                {
                    if (Users.CreateUserPassword(password, partUserInfo.Salt) != partUserInfo.Password) //判断密码是否正确
                    {
                        LoginFailLogs.AddLoginFailTimes(WorkContext.IP, DateTime.Now);                  //增加登陆失败次数
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不正确", "}");
                    }
                    else if (partUserInfo.UserRid == 1)              //当用户等级是禁止访问等级时
                    {
                        if (partUserInfo.LiftBanTime > DateTime.Now) //达到解禁时间
                        {
                            UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits);
                            Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid);
                            partUserInfo.UserRid = userRankInfo.UserRid;
                        }
                        else
                        {
                            errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "您的账号当前被锁定,不能访问", "}");
                        }
                    }
                }
            }

            if (errorList.Length > 1)//验证失败时
            {
                return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true));
            }
            else//验证成功时
            {
                //删除登陆失败日志
                LoginFailLogs.DeleteLoginFailLogByIP(WorkContext.IP);
                //更新用户最后访问
                Users.UpdateUserLastVisit(partUserInfo.Uid, DateTime.Now, WorkContext.IP, WorkContext.RegionId);
                //更新购物车中用户id
                Carts.UpdateCartUidBySid(partUserInfo.Uid, WorkContext.Sid);
                //将用户信息写入cookie中
                MallUtils.SetUserCookie(partUserInfo, (WorkContext.MallConfig.IsRemember == 1 && isRemember == 1) ? 30 : -1);

                return(AjaxResult("success", "登录成功"));
            }
        }
Example #23
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 #24
0
        public ActionResult Login()
        {
            string returnUrl = WebHelper.GetQueryString("returnUrl");

            if (returnUrl.Length == 0)
            {
                returnUrl = "/";
            }

            if (WebHelper.IsGet())
            {
                //如果是Get请求,则展现登录框
                LoginModel model = new LoginModel();
                model.ReturnUrl    = returnUrl;
                model.ShadowName   = WorkContext.SiteConfig.ShadowName;
                model.IsRemember   = WorkContext.SiteConfig.IsRemember == 1;
                model.IsVerifyCode = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.SiteConfig.VerifyPages);
                return(View(model));
            }

            //ajax请求
            string accountName = WebHelper.GetFormString("accountName");
            string password    = WebHelper.GetFormString("password");
            string verifyCode  = WebHelper.GetFormString("verifyCode");
            int    isRemember  = WebHelper.GetFormInt("isRemember");

            StringBuilder errorList = new StringBuilder("[");

            //验证账户名
            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 ((!SecureHelper.IsSafeSqlString(accountName, false)))
            {
                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个字符", "}");
            }


            //验证验证码
            if (CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.SiteConfig.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", "验证码不正确", "}");
                }
            }

            //当以上验证全部通过时
            PartUserInfo partUserInfo = null;

            if (errorList.Length == 1)
            {
                if (BSConfig.SiteConfig.LoginType.Contains("2") && ValidateHelper.IsEmail(accountName))//邮箱登陆
                {
                    partUserInfo = Users.GetPartUserByEmail(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "邮箱不存在", "}");
                    }
                }
                else if (BSConfig.SiteConfig.LoginType.Contains("3") && ValidateHelper.IsMobile(accountName))//手机登陆
                {
                    partUserInfo = Users.GetPartUserByMobile(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "手机不存在", "}");
                    }
                }
                else if (BSConfig.SiteConfig.LoginType.Contains("1"))//用户名登陆
                {
                    partUserInfo = Users.GetPartUserByName(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名不存在", "}");
                    }
                }
                //判断密码是否正确
                if (partUserInfo != null && Users.CreateUserPassword(password, partUserInfo.Salt) != partUserInfo.Password)
                {
                    // LoginFailLogs.AddLoginFailTimes(WorkContext.IP, DateTime.Now);//增加登陆失败次数

                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不正确", "}");
                }
            }
            if (errorList.Length > 1)//验证失败时
            {
                return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true));
            }
            else//验证成功时
            {
                ////当用户等级是禁止访问等级时
                //if (partUserInfo.UserRid == 1)
                //    return AjaxResult("lockuser", "您的账号当前被锁定,不能访问");

                ////删除登陆失败日志
                //LoginFailLogs.DeleteLoginFailLogByIP(WorkContext.IP);
                ////更新用户最后访问
                //Users.UpdateUserLastVisit(partUserInfo.Uid, DateTime.Now, WorkContext.IP, WorkContext.RegionId);

                //将用户信息写入cookie中
                SiteUtils.SetUserCookie(partUserInfo, (WorkContext.SiteConfig.IsRemember == 1 && isRemember == 1) ? 30 : -1);
                AddLog(partUserInfo.UserName, "本地用户登录", "登录成功");
                return(AjaxResult("success", "登录成功"));
            }
        }
Example #25
0
        /// <summary>
        /// 发送更新邮箱确认邮件
        /// </summary>
        public ActionResult SendUpdateEmail()
        {
            string v = WebHelper.GetQueryString("v");
            //解密字符串
            string realV = ShopUtils.AESDecrypt(v);

            //数组第一项为uid,第二项为动作,第三项为验证时间,第四项为随机值
            string[] result = StringHelper.SplitString(realV);
            if (result.Length != 4)
            {
                return(AjaxResult("noauth", "您的权限不足"));
            }

            int      uid    = TypeHelper.StringToInt(result[0]);
            string   action = result[1];
            DateTime time   = TypeHelper.StringToDateTime(result[2]);

            //判断当前用户是否为验证用户
            if (uid != WorkContext.Uid)
            {
                return(AjaxResult("noauth", "您的权限不足"));
            }
            //判断验证时间是否过时
            if (DateTime.Now.AddMinutes(-30) > time)
            {
                return(AjaxResult("expired", "密钥已过期,请重新验证"));
            }

            string email      = WebHelper.GetFormString("email");
            string verifyCode = WebHelper.GetFormString("verifyCode");

            //检查验证码
            if (string.IsNullOrWhiteSpace(verifyCode))
            {
                return(AjaxResult("verifycode", "验证码不能为空"));
            }
            if (verifyCode.ToLower() != Sessions.GetValueString(WorkContext.Sid, "verifyCode"))
            {
                return(AjaxResult("verifycode", "验证码不正确"));
            }

            //检查邮箱
            if (string.IsNullOrWhiteSpace(email))
            {
                return(AjaxResult("email", "邮箱不能为空"));
            }
            if (!ValidateHelper.IsEmail(email))
            {
                return(AjaxResult("email", "邮箱格式不正确"));
            }
            if (!SecureHelper.IsSafeSqlString(email, false))
            {
                return(AjaxResult("email", "邮箱已经存在"));
            }
            int tempUid = Users.GetUidByEmail(email);

            if (tempUid > 0 && tempUid != WorkContext.Uid)
            {
                return(AjaxResult("email", "邮箱已经存在"));
            }


            string v2  = ShopUtils.AESEncrypt(string.Format("{0},{1},{2},{3}", WorkContext.Uid, email, DateTime.Now, Randoms.CreateRandomValue(6)));
            string url = string.Format("http://{0}{1}", Request.Url.Authority, Url.Action("updateemail", new RouteValueDictionary {
                { "v", v2 }
            }));

            //发送验证邮件
            Emails.SendSCUpdateEmail(email, WorkContext.UserName, url);
            return(AjaxResult("success", "邮件已经发送,请前往你的邮箱进行验证"));
        }
Example #26
0
        /// <summary>
        /// 搜索
        /// </summary>
        public ActionResult Search()
        {
            //搜索词
            string keyword = WebHelper.GetQueryString("keyword");

            WorkContext.SearchWord = WebHelper.HtmlEncode(keyword);
            if (keyword.Length == 0)
            {
                return(PromptView(WorkContext.UrlReferrer, "请输入搜索词"));
            }
            if (!SecureHelper.IsSafeSqlString(keyword))
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, keyword);

            //判断搜索词是否为分类名称,如果是则重定向到分类页面
            int cateId = Categories.GetCateIdByName(keyword);

            if (cateId > 0)
            {
                return(Redirect(Url.Action("category", new RouteValueDictionary {
                    { "cateId", cateId }
                })));
            }
            else
            {
                cateId = WebHelper.GetQueryInt("cateId");
            }

            //分类列表
            List <CategoryInfo> categoryList = null;
            //分类信息
            CategoryInfo categoryInfo = null;
            //品牌列表
            List <BrandInfo> brandList = null;

            //品牌id
            int brandId = Brands.GetBrandIdByName(keyword);

            if (brandId > 0)//当搜索词为品牌名称时
            {
                //获取品牌相关的分类
                categoryList = Brands.GetBrandCategoryList(brandId);

                //由于搜索结果的展示是以分类为基础的,所以当分类不存在时直接将搜索结果设为“搜索的商品不存在”
                if (categoryList.Count == 0)
                {
                    return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
                }

                if (cateId > 0)
                {
                    categoryInfo = Categories.GetCategoryById(cateId);
                }
                else
                {
                    //当没有进行分类的筛选时,将分类列表中的首项设为当前选中的分类
                    categoryInfo = categoryList[0];
                    cateId       = categoryInfo.CateId;
                }
                brandList = new List <BrandInfo>();
                brandList.Add(Brands.GetBrandById(brandId));
            }
            else//当搜索词为商品关键词时
            {
                //获取商品关键词相关的分类
                categoryList = Searches.GetCategoryListByKeyword(keyword);

                //由于搜索结果的展示是以分类为基础的,所以当分类不存在时直接将搜索结果设为“搜索的商品不存在”
                if (categoryList.Count == 0)
                {
                    return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
                }

                if (cateId > 0)
                {
                    categoryInfo = Categories.GetCategoryById(cateId);
                }
                else
                {
                    categoryInfo = categoryList[0];
                    cateId       = categoryInfo.CateId;
                }
                //根据商品关键词获取分类相关的品牌
                brandList = Searches.GetCategoryBrandListByKeyword(cateId, keyword);
                if (brandList.Count == 0)
                {
                    return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
                }
                brandId = WebHelper.GetQueryInt("brandId");
            }
            //最后再检查一遍分类是否存在
            if (categoryInfo == null)
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            //筛选价格
            int filterPrice = WebHelper.GetQueryInt("filterPrice");
            //筛选属性
            string filterAttr = WebHelper.GetQueryString("filterAttr");
            //是否只显示有货
            int onlyStock = WebHelper.GetQueryInt("onlyStock");
            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //分类筛选属性及其值列表
            List <KeyValuePair <AttributeInfo, List <AttributeValueInfo> > > cateAAndVList = Categories.GetCategoryFilterAAndVList(cateId);

            //分类价格范围列表
            string[] catePriceRangeList = StringHelper.SplitString(categoryInfo.PriceRange, "\r\n");

            //筛选属性处理
            List <int> attrValueIdList = new List <int>();

            string[] filterAttrValueIdList = StringHelper.SplitString(filterAttr, "-");
            if (filterAttrValueIdList.Length != cateAAndVList.Count)//当筛选属性和分类的筛选属性数目不对应时,重置筛选属性
            {
                if (cateAAndVList.Count == 0)
                {
                    filterAttr = "0";
                }
                else
                {
                    int           count = cateAAndVList.Count;
                    StringBuilder sb    = new StringBuilder();
                    for (int i = 0; i < count; i++)
                    {
                        sb.Append("0-");
                    }
                    filterAttr = sb.Remove(sb.Length - 1, 1).ToString();
                }
            }
            else
            {
                foreach (string attrValueId in filterAttrValueIdList)
                {
                    int temp = TypeHelper.StringToInt(attrValueId);
                    if (temp > 0)
                    {
                        attrValueIdList.Add(temp);
                    }
                }
            }


            //分页对象
            PageModel pageModel = new PageModel(20, page, Searches.GetSearchProductCount(keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock));
            //视图对象
            SearchModel model = new SearchModel()
            {
                Word               = keyword,
                CateId             = cateId,
                BrandId            = brandId,
                FilterPrice        = filterPrice,
                FilterAttr         = filterAttr,
                OnlyStock          = onlyStock,
                SortColumn         = sortColumn,
                SortDirection      = sortDirection,
                CategoryList       = categoryList,
                CategoryInfo       = categoryInfo,
                BrandList          = brandList,
                CatePriceRangeList = catePriceRangeList,
                AAndVList          = cateAAndVList,
                PageModel          = pageModel,
                ProductList        = Searches.SearchProducts(pageModel.PageSize, pageModel.PageNumber, keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock, sortColumn, sortDirection)
            };

            return(View(model));
        }
Example #27
0
        /// <summary>
        /// 商品咨询列表
        /// </summary>
        public ActionResult ProductConsultList(string accountName, string productName, string consultMessage, string consultStartTime, string consultEndTime, string sortColumn, string sortDirection, int pid = -1, int consultTypeId = -1, int pageNumber = 1, int pageSize = 15)
        {
            if (!SecureHelper.IsSafeSqlString(consultMessage))
            {
                consultMessage = "";
            }
            if (!SecureHelper.IsSafeSqlString(consultStartTime))
            {
                consultStartTime = "";
            }
            if (!SecureHelper.IsSafeSqlString(consultEndTime))
            {
                consultEndTime = "";
            }
            if (!SecureHelper.IsSafeSqlString(sortColumn))
            {
                sortColumn = "";
            }
            if (!SecureHelper.IsSafeSqlString(sortDirection))
            {
                sortDirection = "";
            }
            int uid = AdminUsers.GetUidByAccountName(accountName);

            string condition = AdminProductConsults.AdminGetProductConsultListCondition(consultTypeId, WorkContext.StoreId, pid, uid, consultMessage, consultStartTime, consultEndTime);
            string sort      = AdminProductConsults.AdminGetProductConsultListSort(sortColumn, sortDirection);

            PageModel pageModel           = new PageModel(pageSize, pageNumber, AdminProductConsults.AdminGetProductConsultCount(condition));
            ProductConsultListModel model = new ProductConsultListModel()
            {
                PageModel          = pageModel,
                SortColumn         = sortColumn,
                SortDirection      = sortDirection,
                ProductConsultList = AdminProductConsults.AdminGetProductConsultList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                AccountName        = accountName,
                Pid              = pid,
                ProductName      = string.IsNullOrWhiteSpace(productName) ? "选择商品" : productName,
                ConsultTypeId    = consultTypeId,
                ConsultMessage   = consultMessage,
                ConsultStartTime = consultStartTime,
                ConsultEndTime   = consultEndTime
            };

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

            productConsultTypeList.Add(new SelectListItem()
            {
                Text = "全部类型", Value = "0"
            });
            foreach (ProductConsultTypeInfo productConsultTypeInfo in AdminProductConsults.GetProductConsultTypeList())
            {
                productConsultTypeList.Add(new SelectListItem()
                {
                    Text = productConsultTypeInfo.Title, Value = productConsultTypeInfo.ConsultTypeId.ToString()
                });
            }
            ViewData["productConsultTypeList"] = productConsultTypeList;

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&consultMessage={5}&pid={6}&productName={7}&consultStartTime={8}&consultEndTime={9}&consultTypeId={10}&accountName={11}",
                                                          Url.Action("productconsultlist"),
                                                          pageModel.PageNumber, pageModel.PageSize,
                                                          sortColumn, sortDirection,
                                                          consultMessage,
                                                          pid, productName,
                                                          consultStartTime, consultEndTime,
                                                          consultTypeId, accountName));
            return(View(model));
        }
Example #28
0
        /// <summary>
        /// 登录
        /// </summary>
        public ActionResult Login()
        {
            string returnUrl = WebHelper.GetQueryString("returnUrl");

            if (returnUrl.Length == 0)
            {
                //returnUrl = WorkContext.SubPath + "/malladmin/home/default";  //默认去后台页面
                string subpath = Request.ApplicationPath;
                if (subpath.Equals("/"))
                {
                    subpath = "";
                }
                returnUrl = subpath + "/malladmin/home/default";  //默认去后台页面
            }
            if (WorkContext.MallConfig.LoginType == "")
            {
                return(PromptView(returnUrl, "系统目前已经关闭登录功能!"));
            }
            if (WorkContext.Uid > 0)
            {
                return(PromptView(returnUrl, "您已经登录,无须重复登录!"));
            }

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

                model.ReturnUrl    = returnUrl;
                model.ShadowName   = WorkContext.MallConfig.ShadowName;
                model.IsRemember   = WorkContext.MallConfig.IsRemember == 1;
                model.IsVerifyCode = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages);
                //model.OAuthPluginList = Plugins.GetOAuthPluginList();

                model.Random = Randoms.GetRandomInt(0, 5);

                return(View(model));
            }

            //ajax请求
            string accountName = WebHelper.GetFormString("shadowName");  //WebHelper.GetFormString(WorkContext.MallConfig.ShadowName);
            string password    = WebHelper.GetFormString("password");
            string verifyCode  = WebHelper.GetFormString("verifyCode");
            int    isRemember  = WebHelper.GetFormInt("isRemember");

            StringBuilder errorList = new StringBuilder("[");

            //验证账户名
            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 ((!SecureHelper.IsSafeSqlString(accountName, false)))
            {
                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个字符", "}");
            }

            //验证验证码
            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", "验证码不正确", "}");
                }
            }

            //当以上验证全部通过时 xpGrid_User PartUserInfo
            xpGrid_User partUserInfo = null;

            if (errorList.Length == 1)
            {
                //用户名登录
                if (!BMAConfig.MallConfig.LoginType.Contains("1"))
                {
                    errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "不能使用用户名登录", "}");
                }
                else
                {
                    partUserInfo = Users.GetUserByName(accountName);
                    if (partUserInfo == null)
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名不存在", "}");
                    }
                }
                if (partUserInfo != null)
                {
                    if (password != partUserInfo.Password)//判断密码是否正确
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不正确", "}");
                    }
                    else if (partUserInfo.deleted == 1)//当用户等级是禁止访问等级时
                    {
                        errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "您的账号当前被锁定,不能访问", "}");
                    }
                }
            }
            if (errorList.Length > 1)//验证失败时
            {
                return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true));
            }
            else//验证成功时
            {
                //将用户信息写入cookie中
                MallUtils.SetUserCookie(partUserInfo, (WorkContext.MallConfig.IsRemember == 1 && isRemember == 1) ? 30 : -1);


                //return Redirect(returnUrl); //登录成功,直接转向
                return(AjaxResult("success", returnUrl));
            }
        }
Example #29
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 #30
0
        /// <summary>
        /// 订单列表
        /// </summary>
        /// <param name="osn">订单编号</param>
        /// <param name="accountName">账户名</param>
        /// <param name="consignee">收货人</param>
        /// <param name="orderState">订单状态</param>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <returns></returns>
        public ActionResult OrderList(string osn, string accountName, string consignee, string sortColumn, string sortDirection, int orderState = 0, int pageSize = 15, int pageNumber = 1)
        {
            if (!SecureHelper.IsSafeSqlString(osn))
            {
                osn = "";
            }
            if (!SecureHelper.IsSafeSqlString(consignee))
            {
                consignee = "";
            }
            if (!SecureHelper.IsSafeSqlString(sortColumn))
            {
                sortColumn = "";
            }
            if (!SecureHelper.IsSafeSqlString(sortDirection))
            {
                sortDirection = "";
            }
            //获取用户id
            int uid = Users.GetUidByAccountName(accountName);

            string condition = AdminOrders.GetOrderListCondition(WorkContext.StoreId, osn, uid, consignee, orderState);
            string sort      = AdminOrders.GetOrderListSort(sortColumn, sortDirection);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminOrders.GetOrderCount(condition));

            OrderListModel model = new OrderListModel()
            {
                OrderList     = AdminOrders.GetOrderList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                PageModel     = pageModel,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                OSN           = osn,
                AccountName   = accountName,
                Consignee     = consignee,
                OrderState    = orderState
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&OSN={5}&AccountName={6}&Consignee={7}&OrderState={8}",
                                                          Url.Action("orderlist"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          sortColumn, sortDirection,
                                                          osn, accountName, consignee, orderState));

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

            itemList.Add(new SelectListItem()
            {
                Text = "全部", Value = "0"
            });
            itemList.Add(new SelectListItem()
            {
                Text = "已提交", Value = ((int)OrderState.Submitted).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "等待付款", Value = ((int)OrderState.WaitPaying).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "待确认", Value = ((int)OrderState.Confirming).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "已确认", Value = ((int)OrderState.Confirmed).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "备货中", Value = ((int)OrderState.PreProducting).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "已发货", Value = ((int)OrderState.Sended).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "已完成", Value = ((int)OrderState.Completed).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "已锁定", Value = ((int)OrderState.Locked).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "已取消", Value = ((int)OrderState.Cancelled).ToString()
            });
            itemList.Add(new SelectListItem()
            {
                Text = "已退货", Value = ((int)OrderState.Returned).ToString()
            });
            ViewData["orderStateList"] = itemList;

            return(View(model));
        }