Example #1
0
 /// <summary>
 /// 判断用户是否已经登录(解决Session超时问题)
 /// </summary>
 public bool IsUserLogin()
 {
     //如果Session为Null
     if (HttpContext.Current.Session[HotoKeys.SESSION_USER_INFO] != null)
     {
         return(true);
     }
     else
     {
         //检查Cookies
         string username = HotoUtils.GetCookie(HotoKeys.COOKIE_USER_NAME_REMEMBER, "DTcms"); //解密用户名
         string password = HotoUtils.GetCookie(HotoKeys.COOKIE_USER_PWD_REMEMBER, "DTcms");
         if (username != "" && password != "")
         {
             Hoto.BLL.users   bll   = new Hoto.BLL.users();
             Hoto.Model.users model = bll.GetModel(username, password, 0);
             if (model != null)
             {
                 HttpContext.Current.Session[HotoKeys.SESSION_USER_INFO] = model;
                 return(true);
             }
         }
     }
     return(false);
 }
Example #2
0
        /// <summary>
        /// 返回购物车商品总数
        /// </summary>
        /// <returns>Int</returns>
        protected int get_cart_quantity()
        {
            int group_id = 0;

            Hoto.Model.users userModel = GetUserInfo();
            if (userModel != null)
            {
                group_id = userModel.group_id;
            }
            Hoto.Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);
            return(cartModel.total_quantity);
        }
Example #3
0
 /// <summary>
 /// 取得用户信息
 /// </summary>
 public Hoto.Model.users GetUserInfo()
 {
     if (IsUserLogin())
     {
         Hoto.Model.users model = HttpContext.Current.Session[HotoKeys.SESSION_USER_INFO] as Hoto.Model.users;
         if (model != null)
         {
             //为了能查询到最新的用户信息,必须查询最新的用户资料
             model = new Hoto.BLL.users().GetModel(model.id);
             return(model);
         }
     }
     return(null);
 }
Example #4
0
 /// <summary>
 /// 将在Init事件执行
 /// </summary>
 protected void shopping_Init(object sender, EventArgs e)
 {
     int group_id = 0;
     userModel = GetUserInfo();
     if (userModel != null)
     {
         group_id = userModel.group_id;
     }
     if (action == "confirm" && userModel == null)
     {
         //自动跳转URL
         HttpContext.Current.Response.Redirect(linkurl("login"));
     }
     cartModel = Web.UI.ShopCart.GetTotal(group_id);
 }
Example #5
0
        /// <summary>
        /// 将在Init事件执行
        /// </summary>
        protected void shopping_Init(object sender, EventArgs e)
        {
            int group_id = 0;

            userModel = GetUserInfo();
            if (userModel != null)
            {
                group_id = userModel.group_id;
            }
            if (action == "confirm" && userModel == null)
            {
                //自动跳转URL
                HttpContext.Current.Response.Redirect(linkurl("login"));
            }
            cartModel = Web.UI.ShopCart.GetTotal(group_id);
        }
Example #6
0
 /// <summary>
 /// OnInit事件,检查用户是否登录
 /// </summary>
 void UserPage_Init(object sender, EventArgs e)
 {
     if (!IsUserLogin())
     {
         //跳转URL
         HttpContext.Current.Response.Redirect(linkurl("login"));
         return;
     }
     //获得登录用户信息
     userModel = GetUserInfo();
     groupModel = new Hoto.BLL.user_groups().GetModel(userModel.group_id);
     if (groupModel == null)
     {
         groupModel = new Hoto.Model.user_groups();
     }
     InitPage();
 }
Example #7
0
        /// <summary>
        /// 返回购物车列表
        /// </summary>
        /// <returns>IList</returns>
        protected IList <Hoto.Model.cart_items> get_cart_list()
        {
            int group_id = 0;

            Hoto.Model.users userModel = GetUserInfo();
            if (userModel != null)
            {
                group_id = userModel.group_id;
            }
            IList <Hoto.Model.cart_items> ls = Web.UI.ShopCart.GetList(group_id);

            if (ls == null)
            {
                ls = new List <Hoto.Model.cart_items>();
            }
            return(ls);
        }
Example #8
0
 /// <summary>
 /// OnInit事件,检查用户是否登录
 /// </summary>
 void UserPage_Init(object sender, EventArgs e)
 {
     if (!IsUserLogin())
     {
         //跳转URL
         HttpContext.Current.Response.Redirect(linkurl("login"));
         return;
     }
     //获得登录用户信息
     userModel  = GetUserInfo();
     groupModel = new Hoto.BLL.user_groups().GetModel(userModel.group_id);
     if (groupModel == null)
     {
         groupModel = new Hoto.Model.user_groups();
     }
     InitPage();
 }
Example #9
0
        /// <summary>
        /// OnInit事件,检查用户是否已经登录
        /// </summary>
        void UserPage_Init(object sender, EventArgs e)
        {
            turl = linkurl("usercenter", "index");
            if (HttpContext.Current.Request.Url != null && HttpContext.Current.Request.UrlReferrer != null)
            {
                if (HttpContext.Current.Request.Url.ToString().ToLower() != HttpContext.Current.Request.UrlReferrer.ToString().ToLower())
                {
                    turl = HttpContext.Current.Request.UrlReferrer.ToString();
                }
            }
            HotoUtils.WriteCookie(HotoKeys.COOKIE_URL_REFERRER, turl); //记住上一页面

            Hoto.Model.users model = GetUserInfo();
            if (model != null)
            {
                //写入登录日志
                //new Hoto.BLL.user_login_log().Add(model.id, model.user_name, "自动登录", HotoRequest.GetIP());
                //自动登录,跳转URL
                HttpContext.Current.Response.Redirect(turl);
            }
        }
Example #10
0
 /// <summary>
 /// 返回对应商品的会员价格
 /// </summary>
 /// <param name="goods_id">商品ID</param>
 /// <returns>Decimal</returns>
 protected decimal get_user_goods_price(int goods_id)
 {
     Hoto.Model.users userModel = GetUserInfo();
     if (userModel == null)
     {
         return(-1);
     }
     Hoto.Model.article_goods model = new Hoto.BLL.article().GetGoodsModel(goods_id);
     if (model != null)
     {
         if (model.goods_group_prices != null)
         {
             Hoto.Model.goods_group_price priceModel = model.goods_group_prices.Find(p => p.group_id == userModel.group_id);
             if (priceModel != null)
             {
                 return(priceModel.price);
             }
         }
         return(model.sell_price);
     }
     return(-1);
 }
Example #11
0
        /// <summary>
        /// 返回支付费用金额
        /// </summary>
        /// <param name="payment_id">支付ID</param>
        /// <returns>decimal</returns>
        protected decimal get_payment_poundage_amount(int payment_id)
        {
            int group_id = 0;

            Hoto.Model.users userModel = GetUserInfo();
            if (userModel != null)
            {
                group_id = userModel.group_id;
            }
            Hoto.Model.payment payModel = new Hoto.BLL.payment().GetModel(payment_id);
            if (payModel == null)
            {
                return(0);
            }
            decimal poundage_amount = payModel.poundage_amount;

            if (payModel.poundage_type == 1)
            {
                poundage_amount = (poundage_amount * Web.UI.ShopCart.GetTotal(group_id).real_amount) / 100;
            }
            return(poundage_amount);
        }
Example #12
0
        /// <summary>
        /// 将在Init事件执行
        /// </summary>
        protected void payment_Init(object sender, EventArgs e)
        {
            //取得处事类型
            action = HotoRequest.GetString("action");
            order_type = HotoRequest.GetString("order_type");
            order_no = HotoRequest.GetString("order_no");

            switch (action)
            {
                case "confirm":
                    if (string.IsNullOrEmpty(action) || string.IsNullOrEmpty(order_type) || string.IsNullOrEmpty(order_no))
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,URL传输参数有误!"));
                        return;
                    }
                    //检查用户是否登录
                    userModel = new Web.UI.BasePage().GetUserInfo();
                    if (userModel == null)
                    {
                        //用户未登录
                        HttpContext.Current.Response.Redirect(linkurl("payment", "login"));
                        return;
                    }
                    //检查订单的类型(充值或购物)
                    if (order_type == HotoEnums.AmountTypeEnum.Recharge.ToString()) //充值
                    {
                        amountModel = new Hoto.BLL.amount_log().GetModel(order_no);
                        if (amountModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }
                        //检查订单号是否已支付
                        if (amountModel.status == 1)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, amountModel.order_no));
                            return;
                        }
                        //检查支付方式
                        payModel = new Hoto.BLL.payment().GetModel(amountModel.payment_id);
                        if (payModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,支付方式不存在或已删除!"));
                            return;
                        }
                        //检查是否线上支付
                        if (payModel.type == 2)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,账户充值不允许线下支付!"));
                            return;
                        }
                        order_amount = amountModel.value; //订单金额
                    }
                    else if (order_type == HotoEnums.AmountTypeEnum.BuyGoods.ToString()) //购物
                    {
                        //检查订单是否存在
                        orderModel = new Hoto.BLL.orders().GetModel(order_no);
                        if (orderModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }
                        //检查是否已支付过
                        if (orderModel.payment_status == 2)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                            return;
                        }
                        //检查支付方式
                        payModel = new Hoto.BLL.payment().GetModel(orderModel.payment_id);
                        if (payModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,支付方式不存在或已删除!"));
                            return;
                        }
                        //检查是否线下付款
                        if (payModel.type == 2)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                            return;
                        }
                        //检查是否积分换购,直接跳转成功页面
                        if (orderModel.order_amount == 0)
                        {
                            //修改订单状态
                            bool result = new Hoto.BLL.orders().UpdateField(orderModel.order_no, "payment_status=2,payment_time='" + DateTime.Now + "'");
                            if (!result)
                            {
                                HttpContext.Current.Response.Redirect(linkurl("payment", "error"));
                                return;
                            }
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                            return;
                        }
                        order_amount = orderModel.order_amount; //订单金额
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,找不到您要提交的订单类型!"));
                        return;
                    }
                    break;
                case "succeed":
                    //检查订单的类型(充值或购物)
                    if (order_type == HotoEnums.AmountTypeEnum.Recharge.ToString()) //充值
                    {
                        amountModel = new Hoto.BLL.amount_log().GetModel(order_no);
                        if (amountModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }

                    }
                    else if (order_type == HotoEnums.AmountTypeEnum.BuyGoods.ToString()) //购物
                    {
                        orderModel = new Hoto.BLL.orders().GetModel(order_no);
                        if (orderModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,找不到您要提交的订单类型!"));
                        return;
                    }
                    break;
            }
        }
Example #13
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hoto.Model.users model)
 {
     return(dal.Update(model));
 }
Example #14
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hoto.Model.users model)
 {
     return(dal.Add(model));
 }
Example #15
0
        /// <summary>
        /// 将在Init事件执行
        /// </summary>
        protected void payment_Init(object sender, EventArgs e)
        {
            //取得处事类型
            action     = HotoRequest.GetString("action");
            order_type = HotoRequest.GetString("order_type");
            order_no   = HotoRequest.GetString("order_no");

            switch (action)
            {
            case "confirm":
                if (string.IsNullOrEmpty(action) || string.IsNullOrEmpty(order_type) || string.IsNullOrEmpty(order_no))
                {
                    HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,URL传输参数有误!"));
                    return;
                }
                //检查用户是否登录
                userModel = new Web.UI.BasePage().GetUserInfo();
                if (userModel == null)
                {
                    //用户未登录
                    HttpContext.Current.Response.Redirect(linkurl("payment", "login"));
                    return;
                }
                //检查订单的类型(充值或购物)
                if (order_type == HotoEnums.AmountTypeEnum.Recharge.ToString())     //充值
                {
                    amountModel = new Hoto.BLL.amount_log().GetModel(order_no);
                    if (amountModel == null)
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                        return;
                    }
                    //检查订单号是否已支付
                    if (amountModel.status == 1)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, amountModel.order_no));
                        return;
                    }
                    //检查支付方式
                    payModel = new Hoto.BLL.payment().GetModel(amountModel.payment_id);
                    if (payModel == null)
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,支付方式不存在或已删除!"));
                        return;
                    }
                    //检查是否线上支付
                    if (payModel.type == 2)
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,账户充值不允许线下支付!"));
                        return;
                    }
                    order_amount = amountModel.value;                                //订单金额
                }
                else if (order_type == HotoEnums.AmountTypeEnum.BuyGoods.ToString()) //购物
                {
                    //检查订单是否存在
                    orderModel = new Hoto.BLL.orders().GetModel(order_no);
                    if (orderModel == null)
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                        return;
                    }
                    //检查是否已支付过
                    if (orderModel.payment_status == 2)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                        return;
                    }
                    //检查支付方式
                    payModel = new Hoto.BLL.payment().GetModel(orderModel.payment_id);
                    if (payModel == null)
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,支付方式不存在或已删除!"));
                        return;
                    }
                    //检查是否线下付款
                    if (payModel.type == 2)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                        return;
                    }
                    //检查是否积分换购,直接跳转成功页面
                    if (orderModel.order_amount == 0)
                    {
                        //修改订单状态
                        bool result = new Hoto.BLL.orders().UpdateField(orderModel.order_no, "payment_status=2,payment_time='" + DateTime.Now + "'");
                        if (!result)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment", "error"));
                            return;
                        }
                        HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                        return;
                    }
                    order_amount = orderModel.order_amount;     //订单金额
                }
                else
                {
                    HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,找不到您要提交的订单类型!"));
                    return;
                }
                break;

            case "succeed":
                //检查订单的类型(充值或购物)
                if (order_type == HotoEnums.AmountTypeEnum.Recharge.ToString())     //充值
                {
                    amountModel = new Hoto.BLL.amount_log().GetModel(order_no);
                    if (amountModel == null)
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                        return;
                    }
                }
                else if (order_type == HotoEnums.AmountTypeEnum.BuyGoods.ToString())     //购物
                {
                    orderModel = new Hoto.BLL.orders().GetModel(order_no);
                    if (orderModel == null)
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,订单号不存在或已删除!"));
                        return;
                    }
                }
                else
                {
                    HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,找不到您要提交的订单类型!"));
                    return;
                }
                break;
            }
        }