Esempio n. 1
0
        static MpConfigModel GetMpConfigModel()
        {
            var _vipDal  = new VipDal();
            var mpconfig = _vipDal.GetAll <MPConfig>().FirstOrDefault();

            return(mpconfig == null ? null : Newtonsoft.Json.JsonConvert.DeserializeObject <MpConfigModel>(mpconfig.ConfigValue, new Newtonsoft.Json.JsonSerializerSettings
            {
                MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore
            }));
        }
Esempio n. 2
0
        //public WebAuthorizeAttribute(OAuthScope oauthScope = OAuthScope.snsapi_userinfo)
        //{
        //    _oauthScope = oauthScope;
        //}

        //public override void OnActionExecuting(ActionExecutingContext filterContext)
        //{

        //    try
        //    {
        //        var httpContext = filterContext.HttpContext;
        //        var authData = GetAuthData(httpContext);
        //        if (string.IsNullOrEmpty(authData))
        //        {
        //            DoOAuth(filterContext);
        //            return;
        //        }

        //        authData = EncryptHelper.DESDecrypt(authData, _authKey);
        //        if (string.IsNullOrEmpty(authData))
        //        {
        //            DoOAuth(filterContext);
        //            return;
        //        }

        //        var userInfo = authData.ToObject<CurrentVipModel>();//JsonHelper.Deseriailize<UserModel>(authData);
        //        if (userInfo == null || userInfo.VipId <= 0 || string.IsNullOrEmpty(userInfo.OpenId))
        //        {
        //            DoOAuth(filterContext);
        //            return;
        //        }
        //        //if (filterContext.HttpContext.Session["_IsValidUser"] == null)
        //        //{
        //        var vip = new DataAccess.VipDal().Get<Vip>(userInfo.VipId);
        //        if (vip == null)
        //        {
        //            DoOAuth(filterContext);
        //            return;
        //        }
        //        //else
        //        //{
        //        //    filterContext.HttpContext.Session["_IsValidUser"] = true;
        //        //}
        //        //}

        //        httpContext.Items["CurrentVip"] = userInfo;

        //    }
        //    catch(Exception ex)
        //    {
        //        Senparc.Weixin.WeixinTrace.SendCustomLog(this.GetType().Name, ex.Message);

        //        filterContext.HttpContext.Response.Cookies.Clear();
        //        DoOAuth(filterContext);
        //    }
        //}

        //private void DoOAuth(ActionExecutingContext filterContext)
        //{
        //    //没有登录就做OAuth验证
        //    var callbackUrl = Senparc.Weixin.HttpUtility.UrlUtility.GenerateOAuthCallbackUrl(filterContext.HttpContext, _oauthCallbackUrl);
        //    var state = string.Format("{0}|{1}", "FromSenparc", DateTime.Now.Ticks);
        //    filterContext.HttpContext.Session["state"] = state;
        //    var url = OAuthApi.GetAuthorizeUrl(_appId, callbackUrl, state, _oauthScope);
        //    filterContext.Result = new RedirectResult(url);
        //}

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                var httpContext = filterContext.HttpContext;
                var authData    = GetAuthData(httpContext);
                if (string.IsNullOrEmpty(authData))
                {
                    RedirectLogin(filterContext);
                }

                authData = EncryptHelper.DESDecrypt(authData, _authKey);
                if (string.IsNullOrEmpty(authData))
                {
                    RedirectLogin(filterContext);
                }

                var userInfo = authData.ToObject <CurrentVipModel>();//JsonHelper.Deseriailize<UserModel>(authData);
                if (userInfo == null || userInfo.VipId <= 0)
                {
                    RedirectLogin(filterContext);
                }

                var dal = new VipDal();
                var vip = dal.Get <Vip>(userInfo.VipId);
                if (vip == null || Framework.Security.EncryptHelper.Md5(vip.Password) != userInfo.pwd)
                {
                    throw new ArgumentException("vip 不存在");
                }


                httpContext.Items["CurrentVip"] = userInfo;
            }
            catch (Exception ex)
            {
                var cookie = filterContext.HttpContext.Request.Cookies["webAuthData"];
                if (cookie != null)
                {
                    cookie.Expires = DateTime.Now.AddDays(-30);
                    filterContext.HttpContext.Response.SetCookie(cookie);
                }
                RedirectLogin(filterContext);
            }
        }
Esempio n. 3
0
        private void DoRun()
        {
            while (true)
            {
                try
                {
                    VipDal _dal = new VipDal();

                    var jobLog = new JobLog
                    {
                        JobName   = "续费通知",
                        StartTime = DateTime.Now,
                        EndTime   = DateTime.Now,
                        Result    = ""
                    };

                    var vips = _dal.GetExpiredVips();

                    foreach (var v in vips)
                    {
                        v.FeeStatus = (int)PayStatus.待支付;
                    }

                    _dal.Update(vips);

                    jobLog.EndTime = DateTime.Now;
                    jobLog.Result  = "成功";
                    _dal.Insert(jobLog);
                }
                catch (Exception ex)
                {
                    Senparc.Weixin.WeixinTrace.SendCustomLog("AutoPayNotifyJob", ex.Message);
                }


                Thread.Sleep(1000 * 60 * 10);
            }
        }
Esempio n. 4
0
 public VipBLL()
 {
     vipDal = new VipDal();
 }
Esempio n. 5
0
 /// <summary>
 /// 模糊查询或者电话或者姓名
 /// </summary>
 /// <param name="name"></param>
 /// <param name="phone"></param>
 /// <returns></returns>
 public static DataTable SelectVIPLikeNameOrPhone(string name, string phone)
 {
     return(VipDal.SelectVIPLikeNameOrPhone(name, phone));
 }
Esempio n. 6
0
 /// <summary>
 /// 查询会员表
 /// </summary>
 /// <returns></returns>
 public static List <Vip> GetBooks()
 {
     return(VipDal.GetBooks());
 }
Esempio n. 7
0
 /// <summary>
 /// 清空积分
 /// </summary>
 /// <param name="phone"></param>
 /// <param name="jifen"></param>
 /// <returns></returns>
 public static bool ClearjifenByPhone(string phone)
 {
     return(VipDal.ClearjifenByPhone(phone));
 }
Esempio n. 8
0
 /// <summary>
 /// 减去积分
 /// </summary>
 /// <param name="phone"></param>
 /// <param name="jifen"></param>
 /// <returns></returns>
 public static bool DecreasejifenByPhone(string phone, int jifen)
 {
     return(VipDal.DecreasejifenByPhone(phone, jifen));
 }
Esempio n. 9
0
 /// <summary>
 /// 添加积分
 /// </summary>
 /// <param name="phone"></param>
 /// <param name="jifen"></param>
 /// <returns></returns>
 public static bool UpdatejifenByPhone(string phone, int jifen)
 {
     return(VipDal.UpdatejifenByPhone(phone, jifen));
 }
Esempio n. 10
0
 /// <summary>
 /// 根据电话号码查询会员
 /// </summary>
 /// <param name="Mobile"></param>
 /// <returns></returns>
 public static DataTable SetVipByMobile(string Mobile)
 {
     return(VipDal.SetVipByMobile(Mobile));
 }
Esempio n. 11
0
 /// <summary>
 /// 根据电话号码查询会员
 /// </summary>
 /// <param name="Mobile"></param>
 /// <returns></returns>
 public static bool SelectVipBymobilebool(string Mobile)
 {
     return(VipDal.SelectVipBymobilebool(Mobile));
 }
Esempio n. 12
0
 /// <summary>
 /// 添加会员
 /// </summary>
 /// <param name="vip"></param>
 /// <returns></returns>
 public static bool InsertVip(Vip vip)
 {
     return(VipDal.InsertVip(vip));
 }
Esempio n. 13
0
 /// <summary>
 /// 修改会员信息
 /// </summary>
 /// <param name="vip"></param>
 /// <returns></returns>
 public static bool UpdateVip(Vip vip)
 {
     return(VipDal.UpdateVip(vip));
 }
Esempio n. 14
0
 /// <summary>
 /// 删除会员
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static bool DeleteVip(int id)
 {
     return(VipDal.DeleteVip(id));
 }