diff --git a/Myshipping.Core/MQ/RecCompanyUserChangeService.cs b/Myshipping.Core/MQ/RecCompanyUserChangeService.cs index a14462f..fc4cf3a 100644 --- a/Myshipping.Core/MQ/RecCompanyUserChangeService.cs +++ b/Myshipping.Core/MQ/RecCompanyUserChangeService.cs @@ -44,6 +44,7 @@ namespace Myshipping.Core.MQ _userService = _serviceScope.ServiceProvider.GetService(); _sysUserRep = _serviceScope.ServiceProvider.GetService>(); _sysTenantRep = _serviceScope.ServiceProvider.GetService>(); + } public override void Dispose() @@ -116,14 +117,16 @@ namespace Myshipping.Core.MQ tenant.Email = $"{tenant.Id}"; tenant.TenantType = TenantTypeEnum.COMMON; var newTenant = _sysTenantRep.InsertReturnEntity(tenant); - _tenantService.InitNewTenant(tenant); } - } else if (type == "UserJoin") //用户加入公司 { + + + + } else if (type == "UserLeave") //用户离职 { @@ -131,6 +134,55 @@ namespace Myshipping.Core.MQ } else if (type == "CompanyUserSync") //公司及员工数据同步 { + /////同步租户 + var comp = jobj.GetJObjectValue("company"); + var compid = comp.GetStringValue("CompId"); + var compname = comp.GetStringValue("CompName"); + var adminShowName = comp.GetStringValue("AdminShowName"); + + var findTenant = _sysTenantRep.FirstOrDefault(x => x.CompId == compid); //先根据关联ID查找 + + if (findTenant == null) + { + findTenant = _sysTenantRep.FirstOrDefault(x => x.Name == compname); //再根据公司全称查找 + } + + if (findTenant == null) //找不到,新建 + { + var tenant = new SysTenant(); + tenant.Id = YitIdHelper.NextId(); + tenant.Name = compname; + tenant.AdminName = adminShowName; + tenant.Email = $"{tenant.Id}"; + tenant.TenantType = TenantTypeEnum.COMMON; + findTenant = _sysTenantRep.InsertReturnEntity(tenant); + _tenantService.InitNewTenant(tenant); + } + ////同步用户 + var user = jobj.GetJArrayValue("users"); + ///租户id + var tenantid = findTenant.Id; + foreach (var item in user) + { + + + + + + + + } + + + + + + + + + + + } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 6e66eeb..52909c5 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -3880,6 +3880,11 @@ 租户类型 + + + 大简云公司ID + + 定时任务