コード例 #1
0
ファイル: PayRequestData.cs プロジェクト: sqddchen/zuqiu
        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
            }));
        }
コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #4
0
 public VipBLL()
 {
     vipDal = new VipDal();
 }
コード例 #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));
 }
コード例 #6
0
 /// <summary>
 /// 查询会员表
 /// </summary>
 /// <returns></returns>
 public static List <Vip> GetBooks()
 {
     return(VipDal.GetBooks());
 }
コード例 #7
0
 /// <summary>
 /// 清空积分
 /// </summary>
 /// <param name="phone"></param>
 /// <param name="jifen"></param>
 /// <returns></returns>
 public static bool ClearjifenByPhone(string phone)
 {
     return(VipDal.ClearjifenByPhone(phone));
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #10
0
 /// <summary>
 /// 根据电话号码查询会员
 /// </summary>
 /// <param name="Mobile"></param>
 /// <returns></returns>
 public static DataTable SetVipByMobile(string Mobile)
 {
     return(VipDal.SetVipByMobile(Mobile));
 }
コード例 #11
0
 /// <summary>
 /// 根据电话号码查询会员
 /// </summary>
 /// <param name="Mobile"></param>
 /// <returns></returns>
 public static bool SelectVipBymobilebool(string Mobile)
 {
     return(VipDal.SelectVipBymobilebool(Mobile));
 }
コード例 #12
0
 /// <summary>
 /// 添加会员
 /// </summary>
 /// <param name="vip"></param>
 /// <returns></returns>
 public static bool InsertVip(Vip vip)
 {
     return(VipDal.InsertVip(vip));
 }
コード例 #13
0
 /// <summary>
 /// 修改会员信息
 /// </summary>
 /// <param name="vip"></param>
 /// <returns></returns>
 public static bool UpdateVip(Vip vip)
 {
     return(VipDal.UpdateVip(vip));
 }
コード例 #14
0
 /// <summary>
 /// 删除会员
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static bool DeleteVip(int id)
 {
     return(VipDal.DeleteVip(id));
 }