public static bool WXGetUserByToken(string token, out UserInfo user) { TokenRedisDal tokenDal = new TokenRedisDal(); CustomerDbDal customerDb = new CustomerDbDal(); user = null; var openIdTemp = tokenDal.WXGetUserByToken(token); if (string.IsNullOrEmpty(openIdTemp)) { return(false); } else { var openId = openIdTemp.Split(';')[0]; user = customerDb.WxGetUserInfo(openId); return(true); } }
private void AddWxUserInfo(LoginInfo info, string openId) { PlatformOrdersrv platsrv = new PlatformOrdersrv(); CustomerDbDal customerDb = new CustomerDbDal(); var userinfo = customerDb.WxGetUserInfo(openId); if (userinfo == null) { var adzone = platsrv.CreatePid(); var user = new UserInfo() { adzoneid = adzone.Data.Model, //登陆成功保存下用户信息 avatarUrl = info.UserInfo.avatarUrl, city = info.UserInfo.city, country = info.UserInfo.country, createtime = DateTime.Now, gender = info.UserInfo.gender, language = info.UserInfo.language, nickName = info.UserInfo.nickName, province = info.UserInfo.province, openid = openId }; //保存/更新登陆信息 _customerDbDal.AddUserInfo(user); } else { if (string.IsNullOrEmpty(userinfo.adzoneid)) { var adzone = platsrv.CreatePid(); userinfo.adzoneid = adzone.Data.Model; } _customerDbDal.AddUserInfo(userinfo); } }