Commit 737cd7c7 by quan.tang

企业微信 获取 当前user

parent e00d7b76
......@@ -416,6 +416,8 @@ namespace Siger.WeComApi.Biz.service
try
{
var authCorpInfo = corpJson["auth_corp_info"].ToString();
_logger.Info($"authCorpInfo:{authCorpInfo}");
siger_wecom_company company = JsonConvert.DeserializeObject<siger_wecom_company>(authCorpInfo);
//赋值永久授权码permanent_code
var permanentCode = corpJson["permanent_code"].ToString();
......@@ -450,34 +452,46 @@ namespace Siger.WeComApi.Biz.service
}
//获取当前用户所属公司的永久授权码
string userCorpID = userInfoJson["corpid"].ToString();
//若当前属于西格数据
if (userCorpID == CorpID)
{
siger_wecom_company sigerInfo = _sigerWeComCompanyRepository.CheckSigerSelfWeComCompany(userCorpID);
ResponseWeComUser company = JsonConvert.DeserializeObject<ResponseWeComUser>(userInfoJson.ToString());
company.corpid = userCorpID;
company.corpname = sigerInfo.corp_name;
return company;
}
else
string corpid = userInfoJson["corpid"].ToString();
string userid = userInfoJson["userid"].ToString();
var company = _sigerWeComCompanyRepository.GetSigerWeComCompany("", corpid);
ResponseWeComUser companyinfo = new ResponseWeComUser();
companyinfo.corpid = corpid;
companyinfo.userid = userid;
if (companyinfo != null)
{
siger_wecom_company curCompany = _sigerWeComCompanyRepository.GetSigerWeComCompany("", userCorpID);
if (curCompany == null)
{
string errorMsg = string.Format("获取访客身份失败,errcode: {0},errmsg: {1}", "", "数据库中未找到当前授权公司");
throw new Exception(errorMsg);
}
//获取客户企业凭证
string accessToken = weComThirdHelper.GetCorpAccessToken(curCompany.corpid, curCompany.permanent_code);
//获取访客敏感信息
var userAllInfo = weComThirdHelper.GetUserAllInfo(accessToken, userInfoJson["userid"].ToString());
JObject userAllInfoJson = (JObject)JsonConvert.DeserializeObject(userAllInfo);
ResponseWeComUser company = JsonConvert.DeserializeObject<ResponseWeComUser>(userAllInfoJson.ToString());
company.corpid = userCorpID;
company.corpname = curCompany.corp_name;
return company;
companyinfo.corpname = company.corp_name;
}
return companyinfo;
////若当前属于西格数据
//if (userCorpID == CorpID)
//{
// siger_wecom_company sigerInfo = _sigerWeComCompanyRepository.CheckSigerSelfWeComCompany(userCorpID);
// ResponseWeComUser company = JsonConvert.DeserializeObject<ResponseWeComUser>(userInfoJson.ToString());
// company.corpid = userCorpID;
// company.corpname = sigerInfo.corp_name;
// return company;
//}
//else
//{
// siger_wecom_company curCompany = _sigerWeComCompanyRepository.GetSigerWeComCompany("", userCorpID);
// if (curCompany == null)
// {
// string errorMsg = string.Format("获取访客身份失败,errcode: {0},errmsg: {1}", "", "数据库中未找到当前授权公司");
// throw new Exception(errorMsg);
// }
// //获取客户企业凭证
// string accessToken = weComThirdHelper.GetCorpAccessToken(curCompany.corpid, curCompany.permanent_code);
// //获取访客敏感信息
// var userAllInfo = weComThirdHelper.GetUserAllInfo(accessToken, userInfoJson["userid"].ToString());
// JObject userAllInfoJson = (JObject)JsonConvert.DeserializeObject(userAllInfo);
// ResponseWeComUser company = JsonConvert.DeserializeObject<ResponseWeComUser>(userAllInfoJson.ToString());
// company.corpid = userCorpID;
// company.corpname = curCompany.corp_name;
// return company;
//}
}
......
......@@ -16,14 +16,15 @@ namespace Siger.ApiTPM.Utilities
//保存ticket与第三方应用凭证
public static string ticket { get; set; }
public static string suite_access_token { get; set; }
//企业微信后台开发者设置的token, corpID, EncodingAESKey
private readonly string Token = "VA7Ua2huaUKmjhaxakxCO2iYQYKCa6";
private readonly string CorpID = "ww99ade71da501313d";
private readonly string EncodingAESKey = "M1s6eo7BEBmxNw2Tj8TeQPKKT6zqKOyYRWkpuN8kmnn";
private readonly string ProviderSecret = "YfzQU3nKNSLAPM9-c4kHtP5hCTFG2p3xbJlFtsIlsxCPgs15079tYNL94Xb5Rf0s";
private static readonly string Token = "VA7Ua2huaUKmjhaxakxCO2iYQYKCa6";
private static readonly string CorpID = "ww99ade71da501313d";
private static readonly string EncodingAESKey = "M1s6eo7BEBmxNw2Tj8TeQPKKT6zqKOyYRWkpuN8kmnn";
private static readonly string ProviderSecret = "YfzQU3nKNSLAPM9-c4kHtP5hCTFG2p3xbJlFtsIlsxCPgs15079tYNL94Xb5Rf0s";
//企微应用关联的小程序信息
private readonly string SuiteID = "wwb172cebe81bae0af";
private readonly string SuiteSecret = "aHB2yPhKX8AsRp-c_8UBrhOju7ahxu8Rq3LLuRVrRo8";
private static readonly string SuiteID = "wwb172cebe81bae0af";
private static readonly string SuiteSecret = "aHB2yPhKX8AsRp-c_8UBrhOju7ahxu8Rq3LLuRVrRo8";
//基础地址
private static string baseUrl = "https://qyapi.weixin.qq.com/cgi-bin/";
......
......@@ -65,7 +65,7 @@ namespace Siger.WeComApi.Core.Domain.Entity
/// <summary>
/// 认证到期时间
/// </summary>
public DateTime verified_end_time { get; set; }
public int verified_end_time { get; set; }
/// <summary>
/// 企业规模
......
......@@ -43,6 +43,5 @@ namespace Siger.ApiTPM.Controllers
return new ResponseBase(1, 1, result);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment