Commit 0c072646 authored by 吴春's avatar 吴春

提交代码

parent c08e34a3
...@@ -127,20 +127,20 @@ namespace Mall.Common ...@@ -127,20 +127,20 @@ namespace Mall.Common
/// </summary> /// </summary>
public int EmpId { get; set; } public int EmpId { get; set; }
public string erptoken { get; set; } //public string erptoken { get; set; }
/// <summary> ///// <summary>
/// erp用户id ///// erp用户id
/// </summary> ///// </summary>
public int ERPEmpId { get; set; } //public int ERPEmpId { get; set; }
/// <summary> ///// <summary>
/// erp公司id ///// erp公司id
/// </summary> ///// </summary>
public int ERPBranchId { get; set; } //public int ERPBranchId { get; set; }
/// <summary> ///// <summary>
/// erp集团id ///// erp集团id
/// </summary> ///// </summary>
public int ERPGroupId { get; set; } //public int ERPGroupId { get; set; }
} }
} }
...@@ -77,7 +77,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -77,7 +77,7 @@ namespace Mall.WebApi.Controllers.User
private ProductModule productModule = new ProductModule(); private ProductModule productModule = new ProductModule();
private Module.Property.AuthorizeModule authorizeModule = new Module.Property.AuthorizeModule(); //private Module.Property.AuthorizeModule authorizeModule = new Module.Property.AuthorizeModule();
#region 商户信息 #region 商户信息
[AllowAnonymous] [AllowAnonymous]
...@@ -115,63 +115,63 @@ namespace Mall.WebApi.Controllers.User ...@@ -115,63 +115,63 @@ namespace Mall.WebApi.Controllers.User
#region add by:W 2020-07-06 erp授权信息 #region add by:W 2020-07-06 erp授权信息
var erpUserInfo = new Mall.Model.Entity.Property.RB_Employee(); //var erpUserInfo = new Mall.Model.Entity.Property.RB_Employee();
string erptoken = ""; //string erptoken = "";
if (model.EmpId > 0) //if (model.EmpId > 0)
{
//判断当前登录人是否有erp账号信息
var authorizeModel = authorizeModule.GetAuthorizeList(new Model.Extend.Property.RB_ERP_Authorize_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId, MallUserId = model.EmpId, Type = 1 }).FirstOrDefault();
if (authorizeModel != null && authorizeModel.Status == 2)
{
//先查询是否存在是否是登陆手机号登陆
erpUserInfo = authorizeModule.GetByLoginMobileAndPwd(authorizeModel.Account, authorizeModel.Password, authorizeModel.ERPGroupId);
if (erpUserInfo == null)
{
//再查询是否存在是否是账号登陆
erpUserInfo = authorizeModule.GetNewByAccountAndPwd(authorizeModel.Account, authorizeModel.Password, authorizeModel.ERPGroupId);
}
if (erpUserInfo != null && !string.IsNullOrWhiteSpace(erpUserInfo.EmLoginMobile) && erpUserInfo.IsLeave == 0)
{
TokenUserInfo erpUserInfoToken = new TokenUserInfo { uid = erpUserInfo.EmployeeId.ToString(), requestFrom = Common.Enum.ApiRequestFromEnum.ERP };
#region JWT
IDateTimeProvider erpprovider = new UtcDateTimeProvider();
var erpnow = erpprovider.GetNow().AddMinutes(-1);
var erpunixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); // or use JwtValidator.UnixEpoch
var erpsecondsSinceEpoch = Math.Round((erpnow - erpunixEpoch).TotalSeconds);
var erppayload = new Dictionary<string, object>
{
{"iat",erpsecondsSinceEpoch },
{"exp",erpsecondsSinceEpoch+Config.JwtExpirTime},
{"userInfo",erpUserInfoToken }
};
IJwtAlgorithm erpalgorithm = new HMACSHA256Algorithm();
IJsonSerializer erpserializer = new JsonNetSerializer();
IBase64UrlEncoder erpurlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder erpencoder = new JwtEncoder(erpalgorithm, erpserializer, erpurlEncoder);
string erpsecret = Config.JwtSecretKey;
erptoken = erpencoder.Encode(erppayload, erpsecret);
#endregion
//ERPUserInfo erpObj = new ERPUserInfo
//{ //{
// //判断当前登录人是否有erp账号信息
// var authorizeModel = authorizeModule.GetAuthorizeList(new Model.Extend.Property.RB_ERP_Authorize_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId, MallUserId = model.EmpId, Type = 1 }).FirstOrDefault();
// if (authorizeModel != null && authorizeModel.Status == 2)
// {
// //先查询是否存在是否是登陆手机号登陆
// erpUserInfo = authorizeModule.GetByLoginMobileAndPwd(authorizeModel.Account, authorizeModel.Password, authorizeModel.ERPGroupId);
// if (erpUserInfo == null)
// {
// //再查询是否存在是否是账号登陆
// erpUserInfo = authorizeModule.GetNewByAccountAndPwd(authorizeModel.Account, authorizeModel.Password, authorizeModel.ERPGroupId);
// }
// Domain = authorizeModel.DomainName, // if (erpUserInfo != null && !string.IsNullOrWhiteSpace(erpUserInfo.EmLoginMobile) && erpUserInfo.IsLeave == 0)
// emName = erpUserInfo.EmName, // {
// EmployeeId = erpUserInfo.EmployeeId, // TokenUserInfo erpUserInfoToken = new TokenUserInfo { uid = erpUserInfo.EmployeeId.ToString(), requestFrom = Common.Enum.ApiRequestFromEnum.ERP };
// RB_Group_id = erpUserInfo.RB_Group_id, // #region JWT
// RB_Branch_id = erpUserInfo.RB_Branch_id, // IDateTimeProvider erpprovider = new UtcDateTimeProvider();
// RB_Post_Id = erpUserInfo.RB_Post_Id, // var erpnow = erpprovider.GetNow().AddMinutes(-1);
// RB_Department_Id = erpUserInfo.RB_Department_Id, // var erpunixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); // or use JwtValidator.UnixEpoch
// token = erptoken, // var erpsecondsSinceEpoch = Math.Round((erpnow - erpunixEpoch).TotalSeconds);
// SecretKey = erpUserInfo.SecretKey, // var erppayload = new Dictionary<string, object>
// //ImAccount = imAccount?.AccID ?? model.EmLoginMobile, //model.EmLoginMobile, // {
// //ImToken = IMService.DefaultPassword(), // {"iat",erpsecondsSinceEpoch },
//}; // {"exp",erpsecondsSinceEpoch+Config.JwtExpirTime},
//UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.ERP_Login_Info_+ erpUserInfo.EmployeeId, erpObj, Config.JwtExpirTime); // {"userInfo",erpUserInfoToken }
} // };
} // IJwtAlgorithm erpalgorithm = new HMACSHA256Algorithm();
// IJsonSerializer erpserializer = new JsonNetSerializer();
// IBase64UrlEncoder erpurlEncoder = new JwtBase64UrlEncoder();
// IJwtEncoder erpencoder = new JwtEncoder(erpalgorithm, erpserializer, erpurlEncoder);
// string erpsecret = Config.JwtSecretKey;
// erptoken = erpencoder.Encode(erppayload, erpsecret);
// #endregion
// //ERPUserInfo erpObj = new ERPUserInfo
// //{
// // Domain = authorizeModel.DomainName,
// // emName = erpUserInfo.EmName,
// // EmployeeId = erpUserInfo.EmployeeId,
// // RB_Group_id = erpUserInfo.RB_Group_id,
// // RB_Branch_id = erpUserInfo.RB_Branch_id,
// // RB_Post_Id = erpUserInfo.RB_Post_Id,
// // RB_Department_Id = erpUserInfo.RB_Department_Id,
// // token = erptoken,
// // SecretKey = erpUserInfo.SecretKey,
// // //ImAccount = imAccount?.AccID ?? model.EmLoginMobile, //model.EmLoginMobile,
// // //ImToken = IMService.DefaultPassword(),
// //};
// //UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.ERP_Login_Info_+ erpUserInfo.EmployeeId, erpObj, Config.JwtExpirTime);
// }
// }
} //}
#endregion #endregion
...@@ -210,10 +210,10 @@ namespace Mall.WebApi.Controllers.User ...@@ -210,10 +210,10 @@ namespace Mall.WebApi.Controllers.User
SecretKey = "", SecretKey = "",
MallBaseId = 0, MallBaseId = 0,
EmpId = model.EmpId, EmpId = model.EmpId,
erptoken = erptoken, //erptoken = erptoken,
ERPEmpId = erpUserInfo.EmployeeId, //ERPEmpId = erpUserInfo.EmployeeId,
ERPBranchId = erpUserInfo.RB_Branch_id, //ERPBranchId = erpUserInfo.RB_Branch_id,
ERPGroupId = erpUserInfo.RB_Group_id //ERPGroupId = erpUserInfo.RB_Group_id
}; };
UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + model.TenantId, obj, Config.JwtExpirTime); UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + model.TenantId, obj, Config.JwtExpirTime);
return ApiResult.Success("", obj); return ApiResult.Success("", obj);
......
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