public IHttpActionResult GetWechatStatus() { var response = new ResponseObject <WechatAccountModel>(); var message = "当前用户未绑定"; AccountUser account = null; try { var request = HttpContext.Current.Request; var authToken = request.Headers["Authorization"].Replace("Bear ", ""); var openId = _wechatLoginEventService.GetOpenIdWithToken(authToken); if (string.IsNullOrEmpty(openId)) { throw new Exception("当前token无效"); } account = _accountService.GetAccountByOpenId(openId); if (account != null) { response.Data = new WechatAccountModel() { UserName = account.UserName, NickName = account.WechatNickName, AvatarUrl = account.AvatarUrl, Government = account.Government.Name }; message = "用户已绑定。"; } response.Message = message; response.Code = "200"; //_logger.Information("获取微信状态成功!", account); } catch (Exception ex) { response.Message = ex.Message; response.Code = "401"; //_logger.Error(string.Format("获取微信状态失败,错误原因:{0}", ex.GetOriginalException().Message), finder); } return(Ok(response)); }