From 876292b5a092977ac84c1c1699d9f3e45b9be67d Mon Sep 17 00:00:00 2001
From: liaoxujun@qq.com <liaoxujun@qq.com>
Date: 星期四, 07 九月 2023 15:29:12 +0800
Subject: [PATCH] 增加是否具有标书编辑功能权限字段,和创建权限订单逻辑

---
 DocumentServiceApi.InitQMessage/MessageReceive.cs |   66 ++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/DocumentServiceApi.InitQMessage/MessageReceive.cs b/DocumentServiceApi.InitQMessage/MessageReceive.cs
index 39221e6..c5d8895 100644
--- a/DocumentServiceApi.InitQMessage/MessageReceive.cs
+++ b/DocumentServiceApi.InitQMessage/MessageReceive.cs
@@ -1,9 +1,11 @@
-锘縰sing DocumentServiceAPI.Model.Oder;
+锘縰sing 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;
@@ -53,6 +55,8 @@
                 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)
@@ -64,7 +68,7 @@
                     CreatBy = "娑堟伅闃熷垪 InitTenantOder",
                     CreatTime = DateTime.Now,
                     Description = obj.Description,
-                    Name = obj.ITCode,
+                    Name =obj.TenantName ,
                     PsW = obj.ITCode.Substring(obj.ITCode.Length - 4),
 
 
@@ -76,17 +80,61 @@
                     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();
@@ -102,11 +150,17 @@
             }
             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
@@ -148,6 +202,14 @@
                         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();
                 

--
Gitblit v1.9.1