소스 검색

优化团组模块操作人处理逻辑

在 `GroupsController.cs` 中添加了处理团组模块实际操作人的逻辑,改进了 `Rank` 的解析,移除了不必要的变量。
在 `GeneralMethod.cs` 中新增 `GetGroupModuleOperators` 方法,并定义了相关类以支持操作人信息的存储。
在 `DelegationInfoView.cs` 中新增 `OperatorLabel` 属性以存储操作人列表。
在 `TourClientListRepository.cs` 中优化了代码格式,简化了 LINQ 查询,提升了代码可读性。
Lyyyi 1 개월 전
부모
커밋
261f4ef621

+ 26 - 2
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -854,7 +854,6 @@ namespace OASystem.API.Controllers
                     if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
                 }
 
-
                 string sqlWhere1 = string.Empty;
                 if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
                 {
@@ -883,6 +882,31 @@ namespace OASystem.API.Controllers
                 RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
                 var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
 
+                //处理 团组模块实际操作人
+                _DelegationList.ForEach(async x => { 
+                
+                    var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
+                    var operatorNames = new StringBuilder();
+                    operatorNames.AppendLine("各模块实际操作人:");
+                    if (operators.Any())
+                    {
+                        operators.ForEach(y => {
+
+                            string label = string.Empty;
+                            if (y.OperationUsers.Any())
+                            {
+                                var users = y.OperationUsers.Select(x => x.UserName).ToList();
+                                label = string.Join('、', users);
+                            }
+                            else label = "暂未指定";
+
+                            operatorNames.AppendLine($"{y.CTableName}:{label}");
+                        });
+                    }
+
+                    x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
+                });
+
                 var _view = new
                 {
                     PageFuncAuth = pageFunAuthView,
@@ -4653,7 +4677,7 @@ FROM
                         {
                             #region 处理客人姓名
 
-                            string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
+                            string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
                             item.ClientName = clientNames;
 
                             #endregion

+ 129 - 0
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -1069,6 +1069,135 @@ namespace OASystem.API.OAMethodLib
 
         #endregion
 
+
+        #region 根据团ID获取各板块操作人
+
+        /// <summary>
+        /// 获取 团组模块操作人
+        /// </summary>
+        /// <param name="groupId"></param>
+        /// <returns></returns>
+        public static List<GroupOperationUserView> GetGroupModuleOperators(int groupId)
+        { 
+            var modoule = new GroupOperationUserView();
+            var view = modoule.GetOperationUsersInit();
+            if(groupId < 1) return view;
+            var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>()
+                .Where(it => it.IsDel == 0 && it.Id == groupId)
+                .First();
+            if (groupInfo == null) return view;
+
+            //获取团组下的操作人
+            //车/导游地接
+            var opUers = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
+                .InnerJoin<Grp_CreditCardPayment>((x,y) => x.Id == y.CId && y.CTable == 79)
+                .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
+                .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
+                .Select((x, y, u) => new GroupOperationUserInfo
+                {
+                    UserId = u.Id,
+                    UserName = u.CnName
+                }).Distinct().ToList();
+            view.Where(it => it.CTableId == 79).FirstOrDefault().OperationUsers = opUers;
+
+            //签证 
+            var visaUsers = _sqlSugar.Queryable<Grp_VisaInfo>()
+                .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 80)
+                .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
+                .Where((x, y, u) => x.DIId == groupId && x.IsDel == 0)
+                .Select((x, y, u) => new GroupOperationUserInfo
+                {
+                    UserId = u.Id,
+                    UserName = u.CnName
+                }).Distinct().ToList();
+            view.Where(it => it.CTableId == 80).FirstOrDefault().OperationUsers = visaUsers;
+
+            //保险 
+            var insUsers = _sqlSugar.Queryable<Grp_Customers>()
+                .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 82)
+                .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
+                .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
+                .Select((x, y, u) => new GroupOperationUserInfo
+                {
+                    UserId = u.Id,
+                    UserName = u.CnName
+                }).Distinct().ToList();
+            view.Where(it => it.CTableId == 82).FirstOrDefault().OperationUsers = insUsers;
+
+            //邀请/公务活动 
+            var ioaUsers = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>()
+                .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 81)
+                .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
+                .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
+                .Select((x, y, u) => new GroupOperationUserInfo
+                {
+                    UserId = u.Id,
+                    UserName = u.CnName
+                }).Distinct().ToList();
+            if (!ioaUsers.Any())
+            {
+                ioaUsers = _sqlSugar.Queryable<Res_OfficialActivities>()
+                    .LeftJoin<Sys_Users>((x, y) => x.CreateUserId == y.Id)
+                    .Where((x, y) => x.DiId == groupId && x.IsDel == 0)
+                    .Select((x, y) => new GroupOperationUserInfo
+                    {
+                        UserId = y.Id,
+                        UserName = y.CnName
+                    }).Distinct().ToList();
+            }
+            view.Where(it => it.CTableId == 81).FirstOrDefault().OperationUsers = ioaUsers;
+
+            //其他款项 98
+            var otherUsers = _sqlSugar.Queryable<Grp_DecreasePayments>()
+                .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 98)
+                .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
+                .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
+                .Select((x, y, u) => new GroupOperationUserInfo
+                {
+                    UserId = u.Id,
+                    UserName = u.CnName
+                }).Distinct().ToList();
+            view.Where(it => it.CTableId == 98).FirstOrDefault().OperationUsers = otherUsers;
+
+            return view;
+        }
+
+        public class GroupOperationUserView
+        {
+            public int CTableId { get; set; }
+            public string CTableName { get; set; }
+            public List<GroupOperationUserInfo> OperationUsers { get; set; }
+
+            public GroupOperationUserView() { }
+
+            /// <summary>
+            /// 默认模块List
+            /// </summary>
+            /// <returns></returns>
+            public List<GroupOperationUserView> GetOperationUsersInit()
+            {
+                var modules = new List<GroupOperationUserView>() {
+                    new(){ CTableId = 76,CTableName = "酒店预订",
+                        OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 226,UserName = "宋夏雨" } } },
+                    new(){ CTableId = 79,CTableName = "车/导游地接" },
+                    new(){ CTableId = 80,CTableName = "签证" },
+                    new(){ CTableId = 82,CTableName = "团组客户保险" },
+                    new(){ CTableId = 81,CTableName = "邀请/公务活动" },
+                    new(){ CTableId = 85,CTableName = "机票预订",
+                        OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 269, UserName = "汪燕平" } }  },
+                    new(){ CTableId = 98,CTableName = "其他款项" },
+                };
+
+                return modules;
+            }
+        }
+        public class GroupOperationUserInfo
+        {
+            public int UserId { get; set; }
+            public string UserName { get; set; }
+        }
+        #endregion
+
         #endregion
 
         #region 团组汇率

+ 6 - 0
OASystem/OASystem.Domain/ViewModels/Groups/DelegationInfoView.cs

@@ -527,6 +527,12 @@ namespace OASystem.Domain.ViewModels.Groups
         public string GroupFirst { get; set; }
 
         public string CreateUserName { get; set; }
+
+        /// <summary>
+        /// 操作人列表
+        /// </summary>
+        public string OperatorLabel { get; set; }
+
     }
 
     

+ 41 - 45
OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs

@@ -120,7 +120,6 @@ WHERE
                     EncryptionProcessor.DecryptProperties(item);
                 }
 
-
                 _result.Code = 0;
                 _result.Data = data;
             }
@@ -632,9 +631,12 @@ WHERE
                 int companyId = -1;
                 int clientId = -1;
                 string clientName = string.Format(@"{0}{1}", item.LastName, item.FirstName);
-                Crm_DeleClient _DeleClientInfo = _DeleClients.Where(it => it.LastName.Equals(item.LastName) &&
-                                                                          it.FirstName.Equals(item.FirstName) &&
-                                                                          it.Phone.Equals(item.Phone)).FirstOrDefault();
+                var _DeleClientInfo = _DeleClients
+                    .Where(it => it.LastName.Equals(item.LastName) &&
+                                 it.FirstName.Equals(item.FirstName) &&
+                                 it.Phone.Equals(item.Phone))
+                    .FirstOrDefault();
+
                 if (_DeleClientInfo == null) //添加
                 {
                     if (!string.IsNullOrEmpty(item.CompanyFullName))
@@ -739,26 +741,29 @@ WHERE
                         Phone = item.Phone
                     };
                     //string temp_birthDay = "";
-                    DateTime tempDt_Birthday;
-                    bool b_birth = DateTime.TryParse(item.BirthDay, out tempDt_Birthday);
+
+                    bool b_birth = DateTime.TryParse(item.BirthDay, out DateTime tempDt_Birthday);
                     _DeleClient.BirthDay = b_birth ? tempDt_Birthday : null;
 
-                    var clientEdit = await _sqlSugar.Updateable(_DeleClient).UpdateColumns(it =>
-                                                                                 new
-                                                                                 {
-                                                                                     it.CrmCompanyId,
-                                                                                     it.LastName,
-                                                                                     it.FirstName,
-                                                                                     it.Sex,
-                                                                                     it.Phone,
-                                                                                     it.BirthDay
-                                                                                 }
-                                                                             )
-                                                                            .Where(it => it.Id == clientId)
-                                                                            .ExecuteCommandAsync();
+                    var clientEdit = await _sqlSugar
+                        .Updateable(_DeleClient)
+                        .UpdateColumns(it =>
+                                new
+                                {
+                                    it.CrmCompanyId,
+                                    it.LastName,
+                                    it.FirstName,
+                                    it.Sex,
+                                    it.Phone,
+                                    it.BirthDay
+                                }
+                            )
+                        .Where(it => it.Id == clientId)
+                        .ExecuteCommandAsync();
+
                     if (clientEdit < 0)
                     {
-                        _Msg += string.Format("{0} 基本信息修改失败,!请前往客户信息修改!\r\n", clientName);
+                        _Msg += string.Format("{0} 基本信息修改失败,请前往客户信息修改!\r\n", clientName);
                     }
                 }
 
@@ -786,7 +791,6 @@ WHERE
                     var UpdateTrue = _sqlSugar.Updateable(QuerFirstClient).UpdateColumns(x => new { x.IsDel,x.DeleteUserId,x.DeleteTime}).ExecuteCommand() > 0;
                 }
 
-
                 var tourClientAdd = await _sqlSugar.Insertable(_TourClientList).ExecuteReturnIdentityAsync();
                 if (tourClientAdd < 0)
                 {
@@ -1052,29 +1056,24 @@ WHERE
             }
             catch (Exception ex)
             {
-
                 _sqlSugar.RollbackTran();
                 _result.Msg = "程序异常 -- " + ex.Message;
             }
 
-
             return _result;
         }
 
-
         /// <summary>
         /// Del
         /// </summary>
-        /// <param name="portId"></param>
         /// <param name="id"></param>
+        /// <param name="userId"></param>
         /// <returns></returns>
         public async Task<Result> _Del(int id, int userId)
         {
-
             if (id > 0) 
             {
-
-                Grp_TourClientList _TourClientList = new Grp_TourClientList()
+                var _tourClientList = new Grp_TourClientList()
                 {
                     Id = id,
                     IsDel = 1,
@@ -1082,16 +1081,18 @@ WHERE
                     DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                 };
 
-                var certEdit = await _sqlSugar.Updateable(_TourClientList).UpdateColumns(it =>
-                                                                                new
-                                                                                {
-                                                                                    it.IsDel,
-                                                                                    it.DeleteUserId,
-                                                                                    it.DeleteTime,
-                                                                                }
-                    )
-                                                                           .Where(it => it.Id == id)
-                                                                           .ExecuteCommandAsync();
+                var certEdit = await _sqlSugar
+                    .Updateable(_tourClientList)
+                    .UpdateColumns(it =>
+                        new
+                        {
+                            it.IsDel,
+                            it.DeleteUserId,
+                            it.DeleteTime,
+                        })
+                    .Where(it => it.Id == id)
+                    .ExecuteCommandAsync();
+
                 if (certEdit < 0)
                 {
                     _result.Msg = string.Format(@"接团客户名单删除修改!");
@@ -1099,10 +1100,7 @@ WHERE
                 }
                 _result.Code = 0;
             }
-            else
-            {
-                _result.Msg = string.Format(@"请传入有效的Id参数");
-            }
+            else _result.Msg = string.Format(@"请传入有效的Id参数");
 
             return _result;
         }
@@ -1112,14 +1110,12 @@ WHERE
         /// </summary>
         /// <param name="ids"></param>
         /// <returns></returns>
-        public string _ResolveCustomerName(string ids)
+        public string ResolveCustomerName(string ids)
         {
             string clientStr = "";
             if (string.IsNullOrEmpty(ids)) return clientStr;
             var intList = new List<int>();
 
-
-
             //if (ids.Contains(","))
             //{
             //    string[] numbers = ids.Split(',');