Esempio n. 1
0
        /// <summary>
        /// 新增时候,优惠券立即发放(后台不需要做,在微信用户进去优惠券时候再取数据)
        /// </summary>
        /// <param name="userType"></param>
        private void AddPersonYqh(int userType)
        {
            BLL.wx_ucard_users userBll = new wx_ucard_users();
            IList<Model.wx_ucard_users> userlist = new List<Model.wx_ucard_users>();
            if (userType == 0)
            { //全部人员
                userlist = userBll.GetModelList("sid=" + sid);
            }
            else if (userType > 0 && userType < 1000)
            { //按照等级来取人员
                BLL.wx_ucard_udegree degreeBll = new wx_ucard_udegree();
                IList<Model.wx_ucard_udegree> degreelist = degreeBll.GetModelList("degreeNum=" + userType+" and sid="+sid);
                if (degreelist == null || degreelist.Count <= 0)
                {
                    return;
                }
                Model.wx_ucard_udegree degree = degreelist[0];
                userlist = userBll.GetModelList("ttScore<=" + degree.score_max + "  and ttScore>=" + degree.score_min+" and sid="+sid);
            }
            else if (userType > 1000 && userType < 2000)
            { 
                //按照开卡和消费情况来取人员

            
            }
            else if (userType > 2000)
            {
                //按照消费情况来取人员
                BLL.wx_ucard_users_consumeinfo cBll = new wx_ucard_users_consumeinfo();
                IList<Model.wx_ucard_users_consumeinfo> conlist = new List<Model.wx_ucard_users_consumeinfo>();
                if (userType == 2001)
                {  //单次消费超过x元
                    float dcje = MyCommFun.Str2Float(txtdcje.Text);
                    userlist = userBll.GetModelList("sid=" + sid + " and id in (select distinct uid from  wx_ucard_users_consumeinfo where sId=" + sid + " and consumeMoney>=" + dcje + ")");
                }
                else if (userType == 2002)
                {
                    //累计消费超过x元
                    float ljje = MyCommFun.Str2Float(txtljje.Text);
                    userlist = userBll.GetModelList("sid=" + sid + " and id in (select uid from wx_ucard_users_consumeinfo   group by uid having sum(consumeMoney)>" + ljje + ")");
                }
            }

        }
Esempio n. 2
0
        public string appsecret = ""; //公众微信平台下可以找到

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //获取从wxProcess.aspx传递过来的跳转地址reurl
                string              reurl   = HttpContext.Current.Session["session_reurl"].ToString();
                int                 wid     = int.Parse(HttpContext.Current.Session["session_wid"].ToString());
                BLL.wx_userweixin   wx      = new BLL.wx_userweixin();
                Model.wx_userweixin wxModel = wx.GetModel(wid);
                appid     = wxModel.AppId;
                appsecret = wxModel.AppSecret;
                string code = "";
                if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
                {
                    //获取微信回传的code
                    code = Request.QueryString["code"].ToString();
                    OAuth_Token Model           = Get_token(code);                      //获取token
                    OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                    if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                    {
                        //绑定数据
                        wx_ucard_users       userBLL   = new wx_ucard_users();
                        Model.wx_ucard_users userModel = new XCWeiXin.Model.wx_ucard_users();
                        bool Isuser = userBLL.getUserExists(OAuthUser_Model.openid);
                        if (Isuser)
                        {
                            userModel = userBLL.GetModel(OAuthUser_Model.openid);
                        }
                        userModel.wid       = wid;
                        userModel.openid    = OAuthUser_Model.openid;
                        userModel.wxName    = OAuthUser_Model.nickname;
                        userModel.sex       = OAuthUser_Model.sex;
                        userModel.language  = OAuthUser_Model.language;
                        userModel.province  = OAuthUser_Model.province;
                        userModel.city      = OAuthUser_Model.city;
                        userModel.country   = OAuthUser_Model.country;
                        userModel.headimgul = OAuthUser_Model.headimgurl;
                        userModel.subscribe = OAuthUser_Model.subscribe;
                        //   userModel.subscribe_time =DateTime.Parse(OAuthUser_Model.subscribe_time.Trim());
                        userModel.groupid = OAuthUser_Model.groupid;


                        if (!Isuser)//没有记录,添加
                        {
                            HttpCookie cookie = new HttpCookie("xcopenid");
                            cookie.Value   = OAuthUser_Model.openid;
                            cookie.Expires = DateTime.Now.AddDays(3650);
                            HttpContext.Current.Response.Cookies.Add(cookie);

                            userBLL.Add(userModel);
                        }
                        else//有记录更新
                        {
                            HttpCookie cookie = new HttpCookie("xcopenid");
                            cookie.Value   = OAuthUser_Model.openid;
                            cookie.Expires = DateTime.Now.AddDays(3650);
                            HttpContext.Current.Response.Cookies.Add(cookie);

                            ;                            userBLL.Update(userModel);
                        }
                        Response.Redirect("" + reurl + "&openid=" + OAuthUser_Model.openid + "");
                        //   Response.Redirect(reurl);
                    }
                    else  //未获得openid,回到wxProcess.aspx,访问弹出微信授权页面,提示用户授权
                    {
                        Response.Redirect("wxProcess.aspx?auth=1");
                    }
                }
            }
        }
Esempio n. 3
0
        public int init()
        {
            BLL.wx_userweixin   wx      = new BLL.wx_userweixin();
            Model.wx_userweixin wxModel = wx.GetModel(wid);
            appid     = wxModel.AppId;
            appsecret = wxModel.AppSecret;
            string code = "";

            if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
            {
                //获取微信回传的code
                code = Request.QueryString["code"].ToString();
                OAuth_Token Model           = Get_token(code);                      //获取token
                OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                {
                    //绑定数据
                    wx_ucard_users       userBLL   = new wx_ucard_users();
                    Model.wx_ucard_users userModel = new XCWeiXin.Model.wx_ucard_users();
                    bool Isuser = userBLL.getUserExists(OAuthUser_Model.openid);
                    if (Isuser)
                    {
                        userModel = userBLL.GetModel(OAuthUser_Model.openid);
                    }
                    userModel.wid       = wid;
                    userModel.openid    = OAuthUser_Model.openid;
                    userModel.wxName    = OAuthUser_Model.nickname;
                    userModel.sex       = OAuthUser_Model.sex;
                    userModel.language  = OAuthUser_Model.language;
                    userModel.province  = OAuthUser_Model.province;
                    userModel.city      = OAuthUser_Model.city;
                    userModel.country   = OAuthUser_Model.country;
                    userModel.headimgul = OAuthUser_Model.headimgurl;
                    userModel.subscribe = OAuthUser_Model.subscribe;
                    //   userModel.subscribe_time =DateTime.Parse(OAuthUser_Model.subscribe_time.Trim());
                    userModel.groupid = OAuthUser_Model.groupid;

                    openid = OAuthUser_Model.openid;
                    if (!Isuser)//没有记录,添加
                    {
                        HttpCookie cookie = new HttpCookie("xcopenid" + wid + "");
                        cookie.Value   = OAuthUser_Model.openid;
                        cookie.Expires = DateTime.Now.AddDays(3650);
                        HttpContext.Current.Response.Cookies.Add(cookie);

                        userBLL.Add(userModel);
                        return(0);
                    }
                    else//有记录更新
                    {
                        HttpCookie cookie = new HttpCookie("xcopenid" + wid + "");
                        cookie.Value   = OAuthUser_Model.openid;
                        cookie.Expires = DateTime.Now.AddDays(3650);
                        HttpContext.Current.Response.Cookies.Add(cookie);

                        userBLL.Update(userModel);
                        return(0);
                    }

                    //  Response.Redirect("" + reurl + "&openid=" + OAuthUser_Model.openid + "");
                    //   Response.Redirect(reurl);
                }
                else      //未获得openid,回到wxProcess.aspx,访问弹出微信授权页面,提示用户授权
                {
                    return(1);
                }
            }
            else       //取code失败
            {
                return(2);
            }
        }