コード例 #1
0
        /// <summary>
        /// 20200629 用户授权 通过解密获取unionid  再查询是否是泰便利注册用户
        /// </summary>

        public UserInfoResModel EasyDecryptByDE(WeChatCodeDEModel codeModel, string appId, string appSecret)
        {
            UserInfoResModel resModel = new UserInfoResModel();
            BaseViewModel    model    = new BaseViewModel();

            Dtol.Easydtol.UserInfo user = new Dtol.Easydtol.UserInfo();

            if (codeModel.code == null || codeModel.code == "")
            {
                model.ResponseCode = 9;
                model.Message      = "参数为空";
            }

            WeChatInfoModel oiask = JsonConvert.DeserializeObject <WeChatInfoModel>(GetOpenIdAndSessionKeyString(codeModel.code, appId, appSecret));

            if (!string.IsNullOrEmpty(oiask.session_key))
            {
                WechatUserInfoResModel res = new WechatUserInfoResModel();

                res = Decrypt(codeModel.encryptedData, codeModel.iv, oiask.session_key);
                if (!string.IsNullOrEmpty(res.unionId))
                {
                    V_OpenidUnionid v_Openid = new V_OpenidUnionid();
                    v_Openid.openid  = oiask.openid;
                    v_Openid.unionid = res.unionId;
                    v_OpenidUnionidRepository.Add(v_Openid);
                    v_OpenidUnionidRepository.SaveChanges();

                    user = GetEasyUser(res.unionId);

                    if (!String.IsNullOrEmpty(user.ID))
                    {
                        model.ResponseCode = 5;
                        model.Message      = "unionid不为空,已注册泰便利";
                    }
                    else
                    {
                        model.ResponseCode = 6;
                        model.Message      = "unionid不为空,未注册泰便利";
                    }
                }
                else
                {
                    model.ResponseCode = 7;
                    model.Message      = "授权未获取unionid";
                }
            }
            else
            {
                model.ResponseCode = 8;
                model.Message      = "授权未获取session_key";
            }
            resModel.baseView = model;
            resModel.userInfo = user;

            return(resModel);
        }
コード例 #2
0
 public virtual void Update(V_OpenidUnionid obj)
 {
     DbSet.Update(obj);
 }
コード例 #3
0
 public void RemoveNew(V_OpenidUnionid obj)
 {
     DbSet.Remove(obj);
 }
コード例 #4
0
 public virtual void Add(V_OpenidUnionid obj)
 {
     DbSet.Add(obj);
 }