Ejemplo n.º 1
0
        /// <summary>
        /// 发送找回密码短信
        /// </summary>
        public ActionResult SendFindPwdMobile()
        {
            int uid = WebHelper.GetQueryInt("uid");

            PartUserInfo partUserInfo = Users.GetPartUserById(uid);

            if (partUserInfo == null)
            {
                return(AjaxResult("nouser", "用户不存在"));
            }
            if (partUserInfo.Mobile.Length == 0)
            {
                return(AjaxResult("nocanfind", "由于您没有设置手机,所以不能通过手机找回此账号的密码"));
            }

            //发送找回密码短信
            string moibleCode = Randoms.CreateRandomValue(6);

            Sessions.SetItem(WorkContext.Sid, "findPwdMoibleCode", moibleCode);
            SMSes.SendFindPwdMobile(partUserInfo.Mobile, moibleCode);
            return(AjaxResult("success", "验证码已发送,请查收"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 完成订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="completeTime">完成时间</param>
        /// <param name="ip">ip</param>
        public static void CompleteOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, DateTime completeTime, string ip)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Completed);//将订单状态设为完成状态

            //订单商品列表
            List<OrderProductInfo> orderProductList = GetOrderProductList(orderInfo.Oid);

            //发放完成订单积分
            Credits.SendCompleteOrderCredits(ref partUserInfo, orderInfo, orderProductList, completeTime);

            //发放单品促销活动支付积分和优惠劵
            foreach (OrderProductInfo orderProductInfo in orderProductList)
            {
                if (orderProductInfo.Type == 0)
                {
                    if (orderProductInfo.PayCredits > 0)
                        Credits.SendSinglePromotionCredits(ref partUserInfo, orderInfo, orderProductInfo.PayCredits, completeTime);
                    if (orderProductInfo.CouponTypeId > 0)
                        Coupons.SendSinglePromotionCoupon(partUserInfo, orderProductInfo.CouponTypeId, orderInfo, ip);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 验证IMEI号是否匹配
        /// </summary>
        /// <returns></returns>
        public ActionResult ValidateIMEI()
        {
            NameValueCollection parmas = WorkContext.postparms;

            if (parmas.Keys.Count != 2)
            {
                return(APIResult("error", "缺少请求参数"));
            }
            string       account      = parmas["account"].Trim();
            string       imei         = parmas["imei"];
            PartUserInfo partUserInfo = Users.GetPartUserByMobile(account);

            if (partUserInfo.Uid <= 0)
            {
                return(APIResult("error", "账号不存在"));
            }
            if (partUserInfo.IMEI.ToLower() != imei.TrimEnd().ToLower())
            {
                return(APIResult("error", "账号已在其他手机登录"));
            }
            return(APIResult("success", "验证通过"));
        }
Ejemplo n.º 4
0
        public ActionResult Add(ArticleClassModel model)
        {
            ArticleClassInfo info = new ArticleClassInfo();
            //获取当前登录用户信息
            string       ck           = WebHelper.GetCookie("bs", "uname");
            PartUserInfo partUserInfo = Users.GetPartUserByName(ck);

            if (ModelState.IsValid)
            {
                info.ClassName            = model.ClassName;
                info.ParentArticleClassID = model.ParentArticleClassID;
                info.ClassType            = model.ClassType;
                info.Target       = model.Target;
                info.IsWeb        = model.IsWeb;
                info.IsNav        = model.IsNav;
                info.WebUrl       = model.WebUrl == null ? "" : model.WebUrl;
                info.IsAdmin      = model.IsAdmin;
                info.AdminUrl     = model.AdminUrl == null ? "" : model.AdminUrl;
                info.DisplayOrder = model.DisplayOrder;
                info.IsOpen       = model.IsOpen;
                info.ListView     = model.ListView;
                info.ContentView  = model.ContentView;
                info.Code         = model.Code;
                info.ImgUrl       = model.ImgUrl;
                info.Keyword      = model.Keyword == null ? "" : model.Keyword;
                info.Description  = model.Description == null ? "" : model.Description;
                info.IsClassBrand = model.IsClassBrand;
                info.Subhead      = model.Subhead;
                info.Auditor      = ck;
                info.IsShowNews   = model.IsShowNews;
                ArticleClass.Create(info);
                AddLog(info, "分类新加成功");
                //AddAdminOperateLog
                return(PromptView("分类新加成功"));
            }
            Loads();
            return(View(model));
        }
Ejemplo n.º 5
0
        private static IUserNOSQLStrategy _usernosql = BMAData.UserNOSQL;//用户非关系型数据库

        #region 辅助方法

        /// <summary>
        /// 从IDataReader创建PartUserInfo
        /// </summary>
        public static PartUserInfo BuildPartUserFromReader(IDataReader reader)
        {
            PartUserInfo partUserInfo = new PartUserInfo();

            partUserInfo.Uid          = TypeHelper.ObjectToInt(reader["uid"]);
            partUserInfo.UserName     = reader["username"].ToString();
            partUserInfo.Email        = reader["email"].ToString();
            partUserInfo.Mobile       = reader["mobile"].ToString();
            partUserInfo.Password     = reader["password"].ToString();
            partUserInfo.UserRid      = TypeHelper.ObjectToInt(reader["userrid"]);
            partUserInfo.StoreId      = TypeHelper.ObjectToInt(reader["storeid"]);
            partUserInfo.MallAGid     = TypeHelper.ObjectToInt(reader["mallagid"]);
            partUserInfo.NickName     = reader["nickname"].ToString();
            partUserInfo.Avatar       = reader["avatar"].ToString();
            partUserInfo.PayCredits   = TypeHelper.ObjectToInt(reader["paycredits"]);
            partUserInfo.RankCredits  = TypeHelper.ObjectToInt(reader["rankcredits"]);
            partUserInfo.VerifyEmail  = TypeHelper.ObjectToInt(reader["verifyemail"]);
            partUserInfo.VerifyMobile = TypeHelper.ObjectToInt(reader["verifymobile"]);
            partUserInfo.LiftBanTime  = TypeHelper.ObjectToDateTime(reader["liftbantime"]);
            partUserInfo.Salt         = reader["salt"].ToString();

            return(partUserInfo);
        }
Ejemplo n.º 6
0
        public void UpdatePartUser(PartUserInfo partUserInfo)
        {
            DbParameter[] parms =
            {
                GenerateInParam("@username",     SqlDbType.NChar,   20, partUserInfo.UserName),
                GenerateInParam("@email",        SqlDbType.Char,    50, partUserInfo.Email),
                GenerateInParam("@mobile",       SqlDbType.Char,    15, partUserInfo.Mobile),
                GenerateInParam("@nickname",     SqlDbType.NChar,   20, partUserInfo.NickName),
                //GenerateInParam("@userrankid",SqlDbType.TinyInt,1,partUserInfo.UserRankID),
                GenerateInParam("@admingroupid", SqlDbType.TinyInt,  1, partUserInfo.AdminGroupID),
                //GenerateInParam("@avatar",SqlDbType.Char,40,partUserInfo.Avatar),
                // GenerateInParam("@rankcredits",SqlDbType.Int,4,partUserInfo.RankCredits),
                //GenerateInParam("@verifyemail",SqlDbType.TinyInt,1,partUserInfo.VerifyEmail),
                //GenerateInParam("@verifymobile",SqlDbType.TinyInt,1,partUserInfo.VerifyMobile),
                GenerateInParam("@state",        SqlDbType.TinyInt,  1, partUserInfo.State),
                GenerateInParam("@userid",       SqlDbType.Int,      4, partUserInfo.UserID)
            };


            string commandText = string.Format("update {0}User SET UserName =@UserName,Email=@Email,Mobile=@Mobile,NickName=@NickName,AdminGroupID=@AdminGroupID,State=@State where UserID =@UserID ", RDBSHelper.RDBSTablePre);

            RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <returns></returns>
        public ActionResult SendMsg()
        {
            try
            {
                NameValueCollection parmas = WorkContext.postparms;

                string type    = parmas["type"];
                string vip     = parmas["roomid"];
                string account = parmas["account"];

                PartUserInfo user = Users.GetPartUserByMobile(account);

                string hxurl = "https://a1.easemob.com/1117170524115941/lk28/messages";
                MD_AccessTokenResult token = Lottery.GetAccessToken();


                string msg = "欢迎【" + user.NickName + "】 " + (type == "1"?"进入":"退出") + "房间...";
                //获取聊天室信息
                string ptdata = "{\"target_type\":\"chatrooms\",\"target\":[\"" + vip +
                                "\"], \"msg\":{\"type\":\"txt\",\"msg\":\"" + msg + "\"},\"from\":\"8002\"}";
                string chats = WebHelper.GetHXRequestData(hxurl, "post", token.SuccessResult.access_token, true, ptdata);
                if (chats.Contains("error"))
                {
                    Logs.Write("发送消息失败:" + chats);
                    return(APIResult("error", "发送失败"));
                }
                else
                {
                    return(APIResult("success", "发送成功"));
                }
            }
            catch (Exception ex)
            {
                Logs.Write("发送消息失败:" + ex.Message);
                return(APIResult("error", "发送失败", true));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 领取优惠劵
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="couponTypeInfo">优惠劵类型信息</param>
        /// <param name="pullTime">领取时间</param>
        /// <param name="pullIP">领取ip</param>
        /// <returns></returns>
        public static string PullCoupon(PartUserInfo partUserInfo, CouponTypeInfo couponTypeInfo, DateTime pullTime, string pullIP)
        {
            string couponSN = GenerateCouponSN();

            CouponInfo couponInfo = new CouponInfo();

            couponInfo.CouponSN     = couponSN;
            couponInfo.Uid          = partUserInfo.Uid;
            couponInfo.CouponTypeId = couponTypeInfo.CouponTypeId;
            couponInfo.Oid          = 0;
            couponInfo.UseTime      = new DateTime(1900, 1, 1);
            couponInfo.UseIP        = "";
            couponInfo.Money        = couponTypeInfo.Money;
            couponInfo.ActivateTime = pullTime;
            couponInfo.ActivateIP   = pullIP;
            couponInfo.CreateUid    = partUserInfo.Uid;
            couponInfo.CreateOid    = 0;
            couponInfo.CreateTime   = pullTime;
            couponInfo.CreateIP     = pullIP;

            CreateCoupon(couponInfo);

            return(couponSN);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 退货
        /// </summary>
        public ActionResult ReturnOrderProduct(int oid = -1)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }
            if (orderInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("不能操作其它店铺的订单"));
            }
            if (orderInfo.OrderState != (int)OrderState.Sended && orderInfo.OrderState != (int)OrderState.Completed)
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单当前不能退货"));
            }

            PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid);

            AdminOrders.ReturnOrder(ref partUserInfo, orderInfo, WorkContext.Uid, DateTime.Now);
            CreateOrderAction(oid, OrderActionType.Return, "订单已退货");
            AddStoreAdminLog("退货", "退货,订单ID为:" + oid);
            return(PromptView(Url.Action("orderinfo", new { oid = oid }), "退货成功"));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 更新用户头像
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateImg()
        {
            try
            {
                NameValueCollection parmas = WorkContext.postparms;
                PartUserInfo        user   = Users.GetPartUserById(WorkContext.Uid);

                user.Avatar = parmas["img"];

                bool udres = Users.UpdatePartUser(user);
                if (udres)
                {
                    return(AjaxResult("success", "更新成功"));
                }
                else
                {
                    return(AjaxResult("error", "更新失败"));
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult("error", "更新失败"));
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 发送找回密码邮件
        /// </summary>
        public ActionResult SendFindPwdEmail()
        {
            int uid = WebHelper.GetQueryInt("uid");

            PartUserInfo partUserInfo = Users.GetPartUserById(uid);

            if (partUserInfo == null)
            {
                return(AjaxResult("nouser", "用户不存在"));
            }
            if (partUserInfo.Email.Length == 0)
            {
                return(AjaxResult("nocanfind", "由于您没有设置邮箱,所以不能通过邮箱找回此账号的密码"));
            }

            //发送找回密码邮件
            string v   = MallUtils.AESEncrypt(string.Format("{0},{1},{2}", partUserInfo.Uid, DateTime.Now, Randoms.CreateRandomValue(6)));
            string url = string.Format("http://{0}{1}", Request.Url.Authority, Url.Action("resetpwd", new RouteValueDictionary {
                { "v", v }
            }));

            Emails.SendFindPwdEmail(partUserInfo.Email, partUserInfo.UserName, url);
            return(AjaxResult("success", "邮件已发送,请查收"));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 取消订单
        /// </summary>
        public ActionResult CancelOrder(int oid = -1)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }
            if (orderInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("不能操作其它店铺的订单"));
            }
            if (!(orderInfo.OrderState == (int)OrderState.WaitPaying || (orderInfo.OrderState == (int)OrderState.Confirming && orderInfo.PayMode == 0)))
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单当前不能取消"));
            }

            PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid);

            AdminOrders.CancelOrder(ref partUserInfo, orderInfo, WorkContext.Uid, DateTime.Now);
            CreateOrderAction(oid, OrderActionType.Cancel, "订单已取消");
            AddStoreAdminLog("取消订单", "取消订单,订单ID为:" + oid);
            return(PromptView(Url.Action("orderinfo", new { oid = oid }), "取消订单成功"));
        }
Ejemplo n.º 13
0
        public ActionResult OperateOrder(int oid = -1, int actionType = -1, string actionDes = "")
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

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

            if (actionDes.Length > 125)
            {
                OperateOrderModel model = new OperateOrderModel();
                model.Oid             = oid;
                model.OrderInfo       = orderInfo;
                model.OrderActionType = (OrderActionType)actionType;
                model.ActionDes       = actionDes;

                ModelState.AddModelError("actionDes", "最多只能输入125个字");
                return(View(model));
            }

            OrderActionType orderActionType = (OrderActionType)actionType;
            OrderState      orderState      = (OrderState)orderInfo.OrderState;

            if (orderActionType == OrderActionType.Confirm)//确认订单
            {
                if (orderState != OrderState.Confirming)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "买家还未付款,不能确认订单"));
                }

                AdminOrders.ConfirmOrder(orderInfo);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单已经确认" : actionDes);
            }
            else if (orderActionType == OrderActionType.PreProduct)//备货
            {
                if (orderState != OrderState.Confirmed)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单还未确认,不能备货"));
                }

                AdminOrders.PreProduct(orderInfo);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单正在备货" : actionDes);
            }
            else if (orderActionType == OrderActionType.Send)//发货
            {
                if (orderState != OrderState.PreProducting)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单还未备货,不能发货"));
                }

                string shipSN = WebHelper.GetFormString("shipSN").Trim();
                if (shipSN.Length < 1)
                {
                    OperateOrderModel model = new OperateOrderModel();
                    model.Oid             = oid;
                    model.OrderInfo       = orderInfo;
                    model.OrderActionType = orderActionType;
                    model.ActionDes       = actionDes;

                    ModelState.AddModelError("shipSN", "请填写配送单号");
                    return(View(model));
                }
                AdminOrders.SendOrder(oid, OrderState.Sended, shipSN, DateTime.Now);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单已经发货,发货方式为:" + orderInfo.ShipFriendName + ",单号为:" + shipSN : actionDes);
            }
            else if (orderActionType == OrderActionType.Lock)//锁定订单
            {
                if (!(orderState == OrderState.WaitPaying || (orderState == OrderState.Confirming && orderInfo.PayMode == 0)))
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单当前不能锁定"));
                }

                AdminOrders.LockOrder(orderInfo);
                CreateOrderAction(oid, orderActionType, "订单已锁定:" + actionDes);
            }
            else if (orderActionType == OrderActionType.Cancel)//取消订单
            {
                if (!(orderState == OrderState.WaitPaying || (orderState == OrderState.Confirming && orderInfo.PayMode == 0)))
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单当前不能取消"));
                }

                PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid);
                AdminOrders.CancelOrder(ref partUserInfo, orderInfo, WorkContext.Uid, DateTime.Now);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "订单已取消" : actionDes);
            }
            else
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "当前操作不存在"));
            }

            AddAdminOperateLog("操作订单", "操作订单,订单ID为:" + oid);
            return(PromptView(Url.Action("orderinfo", new { oid = oid }), "操作已完成"));
        }
Ejemplo n.º 14
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));
            }
        }
Ejemplo n.º 15
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", "登录成功"));
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 更新部分用户
 /// </summary>
 /// <returns></returns>
 public static void UpdatePartUser(PartUserInfo partUserInfo)
 {
     BrnMall.Data.Users.UpdatePartUser(partUserInfo);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 获得配送费用
 /// </summary>
 /// <param name="totalWeight">商品总重量</param>
 /// <param name="productAmount">商品合计</param>
 /// <param name="orderProductList">订单商品列表</param>
 /// <param name="buyTime">购买时间</param>
 /// <param name="provinceId">省id</param>
 /// <param name="cityId">市id</param>
 /// <param name="countyId">县或区id</param>
 /// <param name="partUserInfo">购买用户</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public decimal GetShipFee(int totalWeight, decimal productAmount, List <OrderProductInfo> orderProductList, DateTime buyTime, int provinceId, int cityId, int countyId, PartUserInfo partUserInfo)
 {
     foreach (ShipRuleInfo shipRuleInfo in PluginUtils.GetShipRuleList())
     {
         if (shipRuleInfo.RegionId == 0 || shipRuleInfo.RegionId == provinceId || shipRuleInfo.RegionId == cityId || shipRuleInfo.RegionId == countyId)
         {
             if (productAmount >= shipRuleInfo.FreeMoney)
             {
                 return(0M);
             }
             if (shipRuleInfo.Type == 0)
             {
                 if (totalWeight <= 1000)
                 {
                     return(shipRuleInfo.ExtCode1);
                 }
                 else
                 {
                     if (((totalWeight - shipRuleInfo.ExtCode1 * 1000) % (shipRuleInfo.ExtCode2 * 1000)) == 0)
                     {
                         return(shipRuleInfo.ExtCode1 + shipRuleInfo.ExtCode2 * ((totalWeight - shipRuleInfo.ExtCode1 * 1000) / (shipRuleInfo.ExtCode2 * 1000)));
                     }
                     else
                     {
                         return(shipRuleInfo.ExtCode1 + shipRuleInfo.ExtCode2 * (((totalWeight - shipRuleInfo.ExtCode1 * 1000) / (shipRuleInfo.ExtCode2 * 1000)) + 1));
                     }
                 }
             }
             else if (shipRuleInfo.Type == 1)
             {
                 decimal shipFee = 0M;
                 foreach (OrderProductInfo orderProductInfo in orderProductList)
                 {
                     shipFee += shipRuleInfo.ExtCode1 * orderProductInfo.RealCount;
                 }
                 return(shipFee);
             }
         }
     }
     return(0M);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 获得货到付款支付手续费
 /// </summary>
 /// <param name="productAmount">商品合计</param>
 /// <param name="buyTime">购买时间</param>
 /// <param name="provinceId">省id</param>
 /// <param name="cityId">市id</param>
 /// <param name="countyId">县或区id</param>
 /// <param name="partUserInfo">购买用户</param>
 /// <returns></returns>
 public decimal GetCODPayFee(decimal productAmount, DateTime buyTime, int provinceId, int cityId, int countyId, PartUserInfo partUserInfo)
 {
     foreach (ShipRuleInfo shipRuleInfo in PluginUtils.GetShipRuleList())
     {
         if (shipRuleInfo.RegionId == 0 || shipRuleInfo.RegionId == provinceId || shipRuleInfo.RegionId == cityId || shipRuleInfo.RegionId == countyId)
         {
             return(shipRuleInfo.CODPayFee);
         }
     }
     return(0M);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// 获得支付手续费
 /// </summary>
 /// <param name="productAmount">商品合计</param>
 /// <param name="buyTime">购买时间</param>
 /// <param name="partUserInfo">购买用户</param>
 /// <returns></returns>
 public decimal GetPayFee(decimal productAmount, DateTime buyTime, PartUserInfo partUserInfo)
 {
     return(0M);
 }
Ejemplo n.º 20
0
        private PartUserInfo partUserInfo     = null;                 //用户信息

        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            ip = WebHelper.GetIP();
            //当用户ip不在允许的后台访问ip列表时
            if (!string.IsNullOrEmpty(shopConfigInfo.AdminAllowAccessIP) && !ValidateHelper.InIPList(ip, shopConfigInfo.AdminAllowAccessIP))
            {
                filterContext.Result = HttpNotFound();
                return;
            }
            //当用户IP被禁止时
            if (BannedIPs.CheckIP(ip))
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //获得用户id
            int uid = ShopUtils.GetUidCookie();

            if (uid < 1)
            {
                uid = WebHelper.GetRequestInt("uid");
            }
            if (uid < 1)//当用户为游客时
            {
                //创建游客
                partUserInfo = Users.CreatePartGuest();
            }
            else//当用户为会员时
            {
                //获得保存在cookie中的密码
                string encryptPwd = ShopUtils.GetCookiePassword();
                if (string.IsNullOrWhiteSpace(encryptPwd))
                {
                    encryptPwd = WebHelper.GetRequestString("password");
                }
                //防止用户密码被篡改为危险字符
                if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd))
                {
                    //创建游客
                    partUserInfo = Users.CreatePartGuest();
                    ShopUtils.SetUidCookie(-1);
                    ShopUtils.SetCookiePassword("");
                }
                else
                {
                    partUserInfo = Users.GetPartUserByUidAndPwd(uid, ShopUtils.DecryptCookiePassword(encryptPwd));
                    if (partUserInfo == null)
                    {
                        partUserInfo = Users.CreatePartGuest();
                        ShopUtils.SetUidCookie(-1);
                        ShopUtils.SetCookiePassword("");
                    }
                }
            }

            //当用户等级是禁止访问等级时
            if (partUserInfo.UserRid == 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //如果当前用户没有登录
            if (partUserInfo.Uid < 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //如果当前用户不是管理员
            if (partUserInfo.AdminGid == 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 发放登陆积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="loginTime">登陆时间</param>
        public static void SendLoginCredits(ref PartUserInfo partUserInfo, DateTime loginTime)
        {
            if (_creditconfiginfo.LoginRankCredits > 0) //_creditconfiginfo.LoginPayCredits > 0 ||
            {
                DateTime slcTime = TypeHelper.StringToDateTime(WebHelper.UrlDecode(MallUtils.GetBMACookie("slctime")), loginTime.Date.AddDays(-2));
                if (loginTime.Date <= slcTime.Date)
                {
                    return;
                }


                //判断是否为禁用用户
                if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now)
                {
                    return;
                }

                if (!IsSendTodayLoginCredit(partUserInfo.Uid, DateTime.Now))
                {
                    MallUtils.SetBMACookie("slctime", WebHelper.UrlEncode(loginTime.ToString()));

                    //int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, loginTime.Date);
                    int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, loginTime.Date);
                    if (surplusRankCredits == 0) //surplusPayCredits == 0 &&
                    {
                        return;
                    }

                    //int payCredits = 0;
                    int rankCredits = 0;
                    //if (surplusPayCredits > 0)
                    //    payCredits = surplusPayCredits < _creditconfiginfo.LoginPayCredits ? surplusPayCredits : _creditconfiginfo.LoginPayCredits;
                    //else if (surplusPayCredits == -1)
                    //    payCredits = _creditconfiginfo.LoginPayCredits;
                    if (surplusRankCredits > 0)
                    {
                        rankCredits = surplusRankCredits < _creditconfiginfo.LoginRankCredits ? surplusRankCredits : _creditconfiginfo.LoginRankCredits;
                    }
                    else if (surplusRankCredits == -1)
                    {
                        rankCredits = _creditconfiginfo.LoginRankCredits;
                    }

                    //partUserInfo.PayCredits += payCredits;
                    partUserInfo.RankCredits += rankCredits;

                    int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
                    if (userRid != partUserInfo.UserRid)
                    {
                        partUserInfo.UserRid = userRid;
                    }
                    else
                    {
                        userRid = 0;
                    }

                    CreditLogInfo creditLogInfo = new CreditLogInfo();
                    creditLogInfo.Uid         = partUserInfo.Uid;
                    creditLogInfo.PayCredits  = 0;// payCredits;
                    creditLogInfo.RankCredits = rankCredits;
                    creditLogInfo.Action      = (int)CreditAction.Login;
                    creditLogInfo.ActionCode  = 0;
                    creditLogInfo.ActionTime  = loginTime;
                    creditLogInfo.ActionDes   = "登陆赠送积分";
                    creditLogInfo.Operator    = 0;

                    //发送积分,并更新用户等级
                    SendCredits(userRid, creditLogInfo);
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 发放登陆积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="loginTime">登陆时间</param>
        /// <param name="oldTime">上次发放登陆积分时间</param>
        /// <param name="newTime">本次发放登陆积分时间</param>
        public static void SendLoginCredits(ref PartUserInfo partUserInfo, DateTime loginTime, DateTime oldTime, out DateTime newTime)
        {
            newTime = oldTime;

            if (_creditconfiginfo.LoginPayCredits > 0 || _creditconfiginfo.LoginRankCredits > 0)
            {
                if (loginTime.Date <= oldTime.Date)
                {
                    return;
                }

                if (!IsSendTodayLoginCredit(partUserInfo.Uid, DateTime.Now))
                {
                    newTime = loginTime;

                    int surplusPayCredits  = GetDaySurplusPayCredits(partUserInfo.Uid, loginTime.Date);
                    int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, loginTime.Date);
                    if (surplusPayCredits == 0 && surplusRankCredits == 0)
                    {
                        return;
                    }

                    int payCredits  = 0;
                    int rankCredits = 0;
                    if (surplusPayCredits > 0)
                    {
                        payCredits = surplusPayCredits < _creditconfiginfo.LoginPayCredits ? surplusPayCredits : _creditconfiginfo.LoginPayCredits;
                    }
                    else if (surplusPayCredits == -1)
                    {
                        payCredits = _creditconfiginfo.LoginPayCredits;
                    }
                    if (surplusRankCredits > 0)
                    {
                        rankCredits = surplusRankCredits < _creditconfiginfo.LoginRankCredits ? surplusRankCredits : _creditconfiginfo.LoginRankCredits;
                    }
                    else if (surplusRankCredits == -1)
                    {
                        rankCredits = _creditconfiginfo.LoginRankCredits;
                    }

                    partUserInfo.PayCredits  += payCredits;
                    partUserInfo.RankCredits += rankCredits;

                    int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
                    if (userRid != partUserInfo.UserRid)
                    {
                        partUserInfo.UserRid = userRid;
                    }
                    else
                    {
                        userRid = 0;
                    }

                    CreditLogInfo creditLogInfo = new CreditLogInfo();
                    creditLogInfo.Uid         = partUserInfo.Uid;
                    creditLogInfo.PayCredits  = payCredits;
                    creditLogInfo.RankCredits = rankCredits;
                    creditLogInfo.Action      = (int)CreditAction.Login;
                    creditLogInfo.ActionCode  = 0;
                    creditLogInfo.ActionTime  = loginTime;
                    creditLogInfo.ActionDes   = "登陆赠送积分";
                    creditLogInfo.Operator    = 0;

                    SendCredits(userRid, creditLogInfo);
                }
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 验证手机号
        /// </summary>
        /// <param name="account"></param>
        /// <param name="paccount"></param>
        /// <returns></returns>
        public ActionResult Validate(string account, string paccount)
        {
            if (account == string.Empty)
            {
                return(AjaxResult("error", "请输入手机号!"));
            }
            else if (account.Length != 11)
            {
                return(AjaxResult("error", "请输入有效手机号!"));
            }
            else if (paccount == string.Empty || paccount.Trim().Length != 11)
            {
                return(AjaxResult("error", "访问的分享地址无效!"));
            }
            else if (paccount == account)
            {
                return(AjaxResult("error", "推广功能只能推荐好友注册呦!"));
            }
            else
            {
                //bool result = ValidateHelper.IsGZYDModbile(account);
                //if (!result)
                //{
                //    return AjaxResult("error", "主人!请使用您的广州移动号码申请《黑米壳通行证》有更多惊喜等着你哟!!");
                //}
                //else
                {
                    //验证手机号是否已经领过
                    DataTable dt = Users.ValidateUser(account);
                    if (dt.Rows.Count > 0)
                    {
                        //return AjaxResult("error", "您已经领取过,每个手机号只能领取一次奥!");
                        return(AjaxResult("error", "99"));
                    }


                    //发送短信验证码,将验证码记录到数据库
                    string code = Randoms.CreateRandomValue(6);

                    PartUserInfo puser = Users.GetPartUserByMobile(paccount);
                    if (puser == null)
                    {
                        return(AjaxResult("error", "访问的分享地址无效!"));
                    }
                    //记录数据库
                    bool addcode = Users.AddInviteInfo(paccount, account, code);
                    if (addcode)
                    {
                        //发送短信
                        try
                        {
                            bool smsres = SMSes.SendAliSMS(account, "register", code);
                            if (!smsres)
                            {
                                Users.DelInviteInfo(account);
                                return(AjaxResult("error", "短信验证码发送失败,请稍后再试"));
                            }
                            else
                            {
                                return(AjaxResult("success", "发送成功"));
                            }
                        }
                        catch (Exception ex)
                        {
                            Users.DelInviteInfo(account);
                            return(AjaxResult("error", "短信验证码发送失败,请稍后再试"));
                        }
                    }
                    else
                    {
                        return(AjaxResult("error", "发送失败"));
                    }
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 重置密码
        /// </summary>
        public ActionResult ResetPwd()
        {
            string v = WebHelper.GetQueryString("v");
            //解密字符串
            string realV;

            try
            {
                realV = MallUtils.AESDecrypt(v);
            }
            catch (Exception ex)
            {
                //如果v来自邮件,那么需要url解码
                realV = MallUtils.AESDecrypt(WebHelper.UrlDecode(v));
            }

            //数组第一项为uid,第二项为验证时间,第三项为随机值
            string[] result = StringHelper.SplitString(realV);
            if (result.Length != 3)
            {
                return(HttpNotFound());
            }

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

            PartUserInfo partUserInfo = Users.GetPartUserById(uid);

            if (partUserInfo == null)
            {
                return(PromptView("用户不存在"));
            }
            //判断验证时间是否过时
            if (DateTime.Now.AddMinutes(-30) > time)
            {
                return(PromptView("此链接已经失效,请重新验证"));
            }

            //get请求
            if (WebHelper.IsGet())
            {
                ResetPwdModel model = new ResetPwdModel();
                model.V = v;
                return(View(model));
            }

            //ajax请求
            string password   = WebHelper.GetFormString("password");
            string confirmPwd = WebHelper.GetFormString("confirmPwd");

            StringBuilder errorList = new StringBuilder("[");

            //验证
            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},", "{", "confirmPwd", "两次输入的密码不一样", "}");
            }

            if (errorList.Length == 1)
            {
                //生成用户新密码
                string p = Users.CreateUserPassword(password, partUserInfo.Salt);
                //设置用户新密码
                Users.UpdateUserPasswordByUid(uid, p);
                //清空当前用户信息
                WebHelper.DeleteCookie("bma");
                Sessions.RemoverSession(WorkContext.Sid);
                OnlineUsers.DeleteOnlineUserBySid(WorkContext.Sid);

                return(AjaxResult("success", Url.Action("login")));
            }
            else
            {
                return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true));
            }
        }
Ejemplo n.º 25
0
        public ActionResult AdminAdd(UsersModel model)
        {
            UserInfo userInfo = new UserInfo();

            if (ModelState.IsValid)
            {
                //验证用户名是否重复
                PartUserInfo info = Users.GetPartUserByName(model.UserName);
                if (info != null)
                {
                    return(PromptView("用户名不能重复"));
                }
                //model.Email = Request.Form.Get("Email").ToString();
                //Regex regex = new Regex(@"([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])");
                //bool a = regex.IsMatch(model.Email);
                //if (a == false)
                //{
                //    return PromptView("/admin/Users/AdminAdd", "请输入正确的邮箱格式!");
                //}
                //model.Mobile = Request.Form.Get("Mobile").ToString();
                //Regex regem = new Regex(@"1[34578]\d{9}");
                //bool b = regem.IsMatch(model.Mobile);
                //if (b == false)
                //{
                //    return PromptView("/admin/Users/AdminAdd", "请输入正确的手机号码!");
                //}
                //model.Password = Request.Form.Get("Password").ToString();
                //Regex regeb = new Regex(@"\d{6}");
                //bool c = regeb.IsMatch(model.Password);
                //if (c == false)
                //{
                //    return PromptView("/admin/Users/AdminAdd", "请至少输入6位数的密码!");
                //}
                string ck = WebHelper.GetCookie("bs", "uname");
                userInfo.UserID   = model.UserID;
                userInfo.UserName = model.UserName;
                //userInfo.Password,
                userInfo.Salt     = Users.GenerateUserSalt();
                userInfo.Password = Users.CreateUserPassword(model.Password, userInfo.Salt);
                if (Request.Form.Get("NickName").ToString().Equals(""))
                {
                    userInfo.NickName = ck;
                }
                else
                {
                    userInfo.NickName = model.NickName;
                }
                userInfo.Email        = model.Email;
                userInfo.Mobile       = model.Mobile;
                userInfo.AdminGroupID = model.AdminGroupID;
                userInfo.Avatar       = "";
                userInfo.RankCredits  = 0;
                userInfo.UserRankID   = 0;
                userInfo.VerifyEmail  = 0;
                userInfo.State        = 0;
                userInfo.Address      = "";
                userInfo.Birthday     = DateTime.Parse("1900-1-1");
                userInfo.Body         = "";
                userInfo.Gender       = 0;
                userInfo.IdCard       = "";
                userInfo.LastIP       = "";
                userInfo.LastTime     = DateTime.Now;
                userInfo.RegionId     = 0;
                userInfo.RegIP        = "";
                userInfo.RegTime      = DateTime.Now;
                Users.CreateUser(userInfo);

                //AddAdminOperateLog
                return(PromptView("管理员新加成功"));
            }
            List <UserRoleInfo> resultList = new List <UserRoleInfo>();

            resultList = UserRoles.GetUserRoleList().ToList();
            //Load();
            TempData["modelList"] = resultList;
            return(View(model));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 退货
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="operatorId">操作人id</param>
        /// <param name="returnTime">退货时间</param>
        public static void ReturnOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int operatorId, DateTime returnTime)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Returned); //将订单状态设为退货状态

            if (orderInfo.OrderState == (int)OrderState.Sended)   //用户收货时退货
            {
                if (orderInfo.CouponMoney > 0)                    //退回用户使用的优惠劵
                {
                    Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);
                }

                if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                {
                    Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, returnTime);
                }

                if (orderInfo.PaySN.Length > 0)//退回用户支付的金钱(此操作只是将退款记录保存到表'orderrefunds'中,实际退款还需要再次操作)
                {
                    OrderRefunds.ApplyRefund(new OrderRefundInfo
                    {
                        Oid           = orderInfo.Oid,
                        OSN           = orderInfo.OSN,
                        Uid           = orderInfo.Uid,
                        State         = 0,
                        ApplyTime     = returnTime,
                        PayMoney      = orderInfo.SurplusMoney,
                        RefundMoney   = orderInfo.SurplusMoney,
                        PaySN         = orderInfo.PaySN,
                        PaySystemName = orderInfo.PaySystemName,
                        PayFriendName = orderInfo.PayFriendName
                    });
                }
            }
            else if (orderInfo.OrderState == (int)OrderState.Completed) //订单完成后退货
            {
                if (orderInfo.CouponMoney > 0)                          //退回用户使用的优惠劵
                {
                    Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);
                }

                if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                {
                    Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, returnTime);
                }

                //应退金钱
                decimal returnMoney = orderInfo.SurplusMoney;

                //订单发放的积分
                DataTable sendCredits      = Credits.GetUserOrderSendCredits(orderInfo.Oid);
                int       payCreditAmount  = TypeHelper.ObjectToInt(sendCredits.Rows[0]["paycreditamount"]);
                int       rankCreditAmount = TypeHelper.ObjectToInt(sendCredits.Rows[0]["rankcreditamount"]);
                //判断用户当前积分是否足够退回,如果不足够就将差额核算成金钱并在应退金钱中减去
                if (partUserInfo.PayCredits < payCreditAmount)
                {
                    returnMoney     = returnMoney - Credits.PayCreditsToMoney(payCreditAmount - partUserInfo.PayCredits);
                    payCreditAmount = partUserInfo.PayCredits;
                }
                //收回订单发放的积分
                Credits.ReturnUserOrderSendCredits(ref partUserInfo, orderInfo, payCreditAmount, rankCreditAmount, operatorId, returnTime);

                StringBuilder couponIdList = new StringBuilder();
                //订单发放的优惠劵列表
                List <CouponInfo> couponList = Coupons.GetUserOrderSendCouponList(orderInfo.Oid);
                //判断优惠劵是否已经被使用,如果已经使用就在应退金钱中减去优惠劵金额
                foreach (CouponInfo couponInfo in couponList)
                {
                    if (couponInfo.Oid > 0)
                    {
                        returnMoney = returnMoney - couponInfo.Money;
                    }
                    else
                    {
                        couponIdList.AppendFormat("{0},", couponInfo.CouponId);
                    }
                }
                //收回订单发放的优惠劵
                if (couponIdList.Length > 0)
                {
                    Coupons.DeleteCouponById(couponIdList.Remove(couponIdList.Length - 1, 1).ToString());
                }

                if (returnMoney > 0)//退回用户支付的金钱(此操作只是将退款记录保存到表'orderrefunds'中,实际退款还需要再次操作)
                {
                    OrderRefunds.ApplyRefund(new OrderRefundInfo
                    {
                        Oid           = orderInfo.Oid,
                        OSN           = orderInfo.OSN,
                        Uid           = orderInfo.Uid,
                        State         = 0,
                        ApplyTime     = returnTime,
                        PayMoney      = orderInfo.SurplusMoney,
                        RefundMoney   = returnMoney,
                        PaySN         = orderInfo.PaySN,
                        PaySystemName = orderInfo.PaySystemName,
                        PayFriendName = orderInfo.PayFriendName
                    });
                }
            }

            Products.IncreaseProductStockNumber(GetOrderProductList(orderInfo.Oid));//增加商品库存数量
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 更新部分用户
 /// </summary>
 /// <returns></returns>
 public static void UpdatePartUser(PartUserInfo partUserInfo)
 {
     NStore.Data.Users.UpdatePartUser(partUserInfo);
 }
Ejemplo n.º 28
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", "登录成功"));
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="storeInfo">店铺信息</param>
        /// <param name="orderProductList">订单商品列表</param>
        /// <param name="singlePromotionList">单品促销活动列表</param>
        /// <param name="fullShipAddressInfo">配送地址</param>
        /// <param name="payMode">支付方式(0代表货到付款,1代表在线支付)</param>
        /// <param name="payCreditCount">支付积分数</param>
        /// <param name="couponList">优惠劵列表</param>
        /// <param name="fullCut">满减</param>
        /// <param name="buyerRemark">买家备注</param>
        /// <param name="bestTime">最佳配送时间</param>
        /// <param name="ip">ip地址</param>
        /// <returns>订单信息</returns>
        public static OrderInfo CreateOrder(PartUserInfo partUserInfo, StoreInfo storeInfo, List <OrderProductInfo> orderProductList, List <SinglePromotionInfo> singlePromotionList, FullShipAddressInfo fullShipAddressInfo, int payMode, ref int payCreditCount, List <CouponInfo> couponList, int fullCut, string buyerRemark, DateTime bestTime, string ip)
        {
            DateTime nowTime = DateTime.Now;

            OrderInfo orderInfo = new OrderInfo();

            orderInfo.OSN = GenerateOSN(storeInfo.StoreId, partUserInfo.Uid, fullShipAddressInfo.RegionId, nowTime);;
            orderInfo.Uid = partUserInfo.Uid;

            orderInfo.Weight        = Carts.SumOrderProductWeight(orderProductList);
            orderInfo.ProductAmount = Carts.SumOrderProductAmount(orderProductList);
            orderInfo.FullCut       = fullCut;
            orderInfo.ShipFee       = GetShipFee(fullShipAddressInfo.ProvinceId, fullShipAddressInfo.CityId, orderProductList);
            orderInfo.OrderAmount   = orderInfo.ProductAmount - orderInfo.FullCut + orderInfo.ShipFee;

            decimal payCreditMoney = Credits.PayCreditsToMoney(payCreditCount);

            if (orderInfo.OrderAmount >= payCreditMoney)
            {
                orderInfo.PayCreditCount = payCreditCount;
                orderInfo.PayCreditMoney = payCreditMoney;
                payCreditCount           = 0;
            }
            else
            {
                int orderPayCredits = Credits.MoneyToPayCredits(orderInfo.OrderAmount);
                orderInfo.PayCreditCount = orderPayCredits;
                orderInfo.PayCreditMoney = orderInfo.OrderAmount;
                payCreditCount           = payCreditCount - orderPayCredits;
            }

            orderInfo.CouponMoney = Coupons.SumCouponMoney(couponList);

            orderInfo.SurplusMoney = orderInfo.OrderAmount - orderInfo.PayCreditMoney - orderInfo.CouponMoney;
            if (orderInfo.SurplusMoney < 0)
            {
                orderInfo.SurplusMoney = 0;
            }

            orderInfo.OrderState = (orderInfo.SurplusMoney <= 0 || payMode == 0) ? (int)OrderState.Confirming : (int)OrderState.WaitPaying;

            orderInfo.IsReview      = 0;
            orderInfo.AddTime       = nowTime;
            orderInfo.StoreId       = storeInfo.StoreId;
            orderInfo.StoreName     = storeInfo.Name;
            orderInfo.PaySystemName = payMode == 0 ? "cod" : "";
            orderInfo.PayFriendName = payMode == 0 ? "货到付款" : "";
            orderInfo.PayMode       = payMode;

            orderInfo.RegionId  = fullShipAddressInfo.RegionId;
            orderInfo.Consignee = fullShipAddressInfo.Consignee;
            orderInfo.Mobile    = fullShipAddressInfo.Mobile;
            orderInfo.Phone     = fullShipAddressInfo.Phone;
            orderInfo.Email     = fullShipAddressInfo.Email;
            orderInfo.ZipCode   = fullShipAddressInfo.ZipCode;
            orderInfo.Address   = fullShipAddressInfo.Address;
            orderInfo.BestTime  = bestTime;

            orderInfo.BuyerRemark = buyerRemark;
            orderInfo.IP          = ip;

            try
            {
                //添加订单
                int oid = _iorderstrategy.CreateOrder(orderInfo, Carts.IsPersistOrderProduct, orderProductList);
                if (oid > 0)
                {
                    orderInfo.Oid = oid;

                    //减少商品库存数量
                    Products.DecreaseProductStockNumber(orderProductList);
                    //更新限购库存
                    if (singlePromotionList.Count > 0)
                    {
                        Promotions.UpdateSinglePromotionStock(singlePromotionList);
                    }
                    //使用支付积分
                    Credits.PayOrder(ref partUserInfo, orderInfo, orderInfo.PayCreditCount, nowTime);
                    //使用优惠劵
                    foreach (CouponInfo couponInfo in couponList)
                    {
                        if (couponInfo.Uid > 0)
                        {
                            Coupons.UseCoupon(couponInfo.CouponId, oid, nowTime, ip);
                        }
                        else
                        {
                            Coupons.ActivateAndUseCoupon(couponInfo.CouponId, partUserInfo.Uid, oid, nowTime, ip);
                        }
                    }

                    return(orderInfo);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(null);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 发放登陆积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="loginTime">登陆时间</param>
        public static void SendLoginCredits(ref PartUserInfo partUserInfo, DateTime loginTime)
        {
            DateTime newTime;

            SendLoginCredits(ref partUserInfo, loginTime, TypeHelper.StringToDateTime(WebHelper.UrlDecode(MallUtils.GetBMACookie("slctime")), loginTime.Date.AddDays(-2)), out newTime);
        }