| | |
| | | using DocumentServiceAPI.Model.Oder; |
| | | using DocumentServiceAPI.Model.cyDocumentModel; |
| | | using DocumentServiceAPI.Model.Oder; |
| | | using DocumentServiceAPI.Model.Permissions; |
| | | using DocumentServiceAPI.Model.UserInfoModel; |
| | | using Furion; |
| | | using Furion.JsonSerialization; |
| | | using Furion.Logging.Extensions; |
| | | using Furion.Schedule; |
| | | using InitQ.Abstractions; |
| | | using InitQ.Attributes; |
| | | using Microsoft.Extensions.Options; |
| | |
| | | PayTime = obj.PayTime, |
| | | ZcUserID = obj.ZcUserID, |
| | | ITCode = obj.ITCode, |
| | | HasDocumentPermission=obj.HasDocumentPermission |
| | | |
| | | }; |
| | | TenantInfo? Tinfo = await _db.Queryable<TenantInfo>().Where(x=>x.ZcUserID==obj.ZcUserID).SingleAsync(); |
| | | if(Tinfo==null) |
| | |
| | | CreatBy = "消息队列 InitTenantOder", |
| | | CreatTime = DateTime.Now, |
| | | Description = obj.Description, |
| | | Name = obj.ITCode, |
| | | Name =obj.TenantName , |
| | | PsW = obj.ITCode.Substring(obj.ITCode.Length - 4), |
| | | |
| | | |
| | |
| | | Description = obj.Description, |
| | | EmployeeMaxCount = obj.EmployeeCount ?? 0, |
| | | UnitMaxCount = obj.UnitCount ?? 0, |
| | | |
| | | HasDocumentPermission=obj.HasDocumentPermission, |
| | | OverTime = DateTime.Now.AddMonths(obj.MonthCount ?? 0), |
| | | |
| | | |
| | | |
| | | }; |
| | | |
| | | //新建租户员工 |
| | | Document_EmployeeInfo employeeInfo = new Document_EmployeeInfo() |
| | | { |
| | | EmployeeName = "集团账号", |
| | | UserName = Tinfo.ItCode, |
| | | AdviseFlag = 2, |
| | | UserId = 0, |
| | | IsWork = 1, |
| | | UserPassWord = Tinfo.ItCode.Substring(Tinfo.ItCode.Length - 6), |
| | | Job = "集团用户", |
| | | IsLogin = true, |
| | | LastUpdateName = "消息队列 InitTenantOder", |
| | | LastUpdateTime = DateTime.Now, |
| | | }; |
| | | EmployeeAtTenant employeeAtTenant = new EmployeeAtTenant() |
| | | { |
| | | CreatBy = "消息队列 InitTenantOder", |
| | | CreatTime = DateTime.Now, |
| | | |
| | | }; |
| | | |
| | | Document_TenderUnit tenderUnit = new Document_TenderUnit() |
| | | { |
| | | UnitName = obj.TenantName ?? "集团公司", |
| | | AdviseFlag = 2, |
| | | UserId = 0, |
| | | CreatTime = DateTime.Now.ToString("yyyy MM dd"), |
| | | LastUpdateName = "消息队列 InitTenantOder", |
| | | LastUpdateTime = DateTime.Now, |
| | | IsDeled = false, |
| | | IsEn = true, |
| | | |
| | | |
| | | }; |
| | | |
| | | try |
| | | { |
| | | await _db.AsTenant().BeginTranAsync(); |
| | | |
| | | var id= await _db.Insertable(Tinfo).ExecuteReturnIdentityAsync(); |
| | | var eid = await _db.Insertable(employeeInfo).ExecuteReturnIdentityAsync(); |
| | | permissions.TenantId = id; |
| | | employeeAtTenant.TenantID = id; |
| | | employeeAtTenant.EmployeeID = eid; |
| | | tenderUnit.TenantId = id; |
| | | await _db.Insertable(tenderUnit).ExecuteCommandAsync(); |
| | | await _db.Insertable(employeeAtTenant).ExecuteCommandAsync(); |
| | | await _db.Insertable(permissions).ExecuteCommandAsync (); |
| | | await _db.Insertable(oder).ExecuteCommandAsync(); |
| | | await _db.AsTenant().CommitTranAsync(); |
| | |
| | | } |
| | | else |
| | | { |
| | | var Employee = await _db.Queryable<EmployeeAtTenant,Document_EmployeeInfo>((EAT, E) => new JoinQueryInfos( |
| | | |
| | | JoinType.Left, EAT.EmployeeID == E.EmployeeId |
| | | )).Where((EAT, E) => EAT.TenantID==Tinfo.Id).Select((EAT,E)=>E).FirstAsync(); |
| | | |
| | | Tinfo.ItCode = obj.ITCode; |
| | | Tinfo.UpdataBy = "消息队列 InitTenantOder"; |
| | | Tinfo.UpdataTime = DateTime.Now; |
| | | Tinfo.IsDel = false; |
| | | Tinfo.IsEn = true; |
| | | |
| | | var tp= await _db.Queryable<TenantPermissions>().Where(x=>x.TenantId==Tinfo.Id).FirstAsync(); |
| | | |
| | | try |
| | |
| | | await _db.Updateable(tp).ExecuteCommandAsync(); |
| | | |
| | | } |
| | | if (obj.ITCode != Employee.UserName) |
| | | { |
| | | //如果发现用户名已经更改,则该集团员工用户名跟随更改 |
| | | Employee.UserName = obj.ITCode; |
| | | Employee.LastUpdateName= "消息队列 InitTenantOder"; |
| | | Employee.LastUpdateTime = DateTime.Now; |
| | | await _db.Updateable(Employee).ExecuteCommandAsync(); |
| | | } |
| | | await _db.Insertable(oder).ExecuteCommandAsync(); |
| | | await _db.AsTenant().CommitTranAsync(); |
| | | |