Exemple #1
0
        public void GETUSERINFOBYOPENID(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            string  _openid = CommonHelp.GetCookieString("openid");
            WX_User u       = new WX_UserB().GetEntity(d => d.Openid == _openid);

            if (u != null)
            {
                JH_Auth_User localuser = new JH_Auth_UserB().GetEntity(d => d.WXopenid == _openid && d.IsWX == 1);
                if (localuser != null)
                {
                    msg.Result = localuser;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 绑定手机、姓名、身份证、专卖许可证
        /// </summary>
        public void BINDTOMONOLICENSE(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            JH_Auth_User j = JsonConvert.DeserializeObject <JH_Auth_User>(P1);

            if (j == null)
            {
                msg.ErrorMsg = "绑定失败";
                return;
            }
            if (string.IsNullOrWhiteSpace(j.UserRealName.Trim()))
            {
                msg.ErrorMsg = "姓名不能为空";
                return;
            }
            if (string.IsNullOrWhiteSpace(j.mobphone.Trim()))
            {
                msg.ErrorMsg = "手机号不能为空";
                return;
            }
            if (string.IsNullOrWhiteSpace(j.IDCard.Trim()))
            {
                msg.ErrorMsg = "身份证号不能为空";
                return;
            }
            if (string.IsNullOrWhiteSpace(j.ToMonoLicense.Trim()))
            {
                msg.ErrorMsg = "专卖许可证号不能为空";
                return;
            }
            string  _openid = CommonHelp.GetCookieString("openid");
            WX_User u       = new WX_UserB().GetEntity(d => d.Openid == _openid);

            msg.Result = u;
            if (u != null)
            {
                JH_Auth_User localuser = new JH_Auth_UserB().GetEntity(d => d.mobphone == j.mobphone.Trim());
                if (localuser == null)
                {
                    new JH_Auth_UserB().ExsSql("update JH_Auth_User set WXopenid='', IsWX=0, IDCard='',ToMonoLicense='' where WXopenid='" + _openid + "'");//清除以前绑定的用户
                    //新用户,随机生成
                    localuser               = new JH_Auth_User();
                    localuser.UserName      = "******" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 16);
                    localuser.UserRealName  = j.UserRealName.Trim();
                    localuser.UserPass      = CommonHelp.GetMD5("a123456");
                    localuser.pccode        = EncrpytHelper.Encrypt(localuser.UserName + "@" + localuser.UserPass + "@" + DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                    localuser.ComId         = 10334;
                    localuser.Sex           = u.Sex;
                    localuser.mobphone      = j.mobphone.Trim();
                    localuser.BranchCode    = 0;
                    localuser.CRDate        = localuser.logindate = DateTime.Now;
                    localuser.CRUser        = "******";
                    localuser.IsUse         = "Y";
                    localuser.IsWX          = 1;
                    localuser.WXopenid      = _openid;
                    localuser.weixinCard    = j.weixinCard.Trim();
                    localuser.IDCard        = j.IDCard.Trim();
                    localuser.ToMonoLicense = j.ToMonoLicense.Trim();

                    new JH_Auth_UserB().Insert(localuser);
                    WXFWHelp.UpdateCookieAfterSignIn(localuser);
                    msg.Result = localuser;
                    //msg.ErrorMsg = "手机号不存在,请联系管理员";
                    return;
                }
                else
                {
                    //老用户
                    if (localuser.UserRealName == j.UserRealName.Trim())
                    {
                        new JH_Auth_UserB().ExsSql("update JH_Auth_User set WXopenid='', IsWX=0, IDCard='',ToMonoLicense='' where WXopenid='" + _openid + "'");//清除以前绑定的用户

                        localuser.WXopenid   = _openid;
                        localuser.IsWX       = 1;
                        localuser.weixinCard = j.weixinCard.Trim();
                        //localuser.pccode = EncrpytHelper.Encrypt(localuser.UserName + "@" + localuser.UserPass + "@" + DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                        localuser.logindate     = DateTime.Now;
                        localuser.IDCard        = j.IDCard.Trim();
                        localuser.ToMonoLicense = j.ToMonoLicense.Trim();

                        new JH_Auth_UserB().Update(localuser);//更新logindate,pccode不能更新
                        WXFWHelp.UpdateCookieAfterSignIn(localuser);
                        msg.Result = localuser;
                    }
                    else
                    {
                        msg.ErrorMsg = "姓名与手机号不匹配";
                        return;
                    }
                }
            }
            else
            {
                msg.ErrorMsg = "微信登录异常";
                return;
            }
        }