Przeglądaj źródła

优化客户姓名处理及删除操作逻辑

在 `FinancialController.cs` 中,添加客户姓名解密处理,确保姓名安全性。
在 `GroupsController.cs` 中,简化删除操作的返回逻辑,减少嵌套层级并提供详细错误信息。
修复 `DecreasePaymentsRepository.cs` 中构造函数格式,提升代码可读性。
Lyyyi 1 dzień temu
rodzic
commit
09707c78ba

+ 10 - 4
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -6623,13 +6623,16 @@ Group by PriceType ", dto.diId);
                                         SimplClientInfo tempInfo = arr.FirstOrDefault(s => s.Id == tempId);
                                         if (tempInfo != null)
                                         {
+                                            string lastName = AesEncryptionHelper.Decrypt(tempInfo.LastName),
+                                                firstName = AesEncryptionHelper.Decrypt(tempInfo.FirstName);
+
                                             if (count > 1)
                                             {
-                                                clientName = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
+                                                clientName = string.Format(@"{0}{1}等{2}人", lastName, firstName, count);
                                             }
                                             else
                                             {
-                                                clientName = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
+                                                clientName = string.Format(@"{0}{1}", lastName, firstName);
                                             }
                                         }
                                     }
@@ -6664,13 +6667,16 @@ Group by PriceType ", dto.diId);
                                         SimplClientInfo tempInfo = bx_arr.FirstOrDefault(s => s.Id == tempId);
                                         if (tempInfo != null)
                                         {
+                                            string lastName = AesEncryptionHelper.Decrypt(tempInfo.LastName),
+                                                firstName = AesEncryptionHelper.Decrypt(tempInfo.FirstName);
+
                                             if (count > 1)
                                             {
-                                                bx_clientName = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
+                                                bx_clientName = string.Format(@"{0}{1}等{2}人", lastName, firstName, count);
                                             }
                                             else
                                             {
-                                                bx_clientName = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
+                                                bx_clientName = string.Format(@"{0}{1}", lastName, firstName);
                                             }
                                         }
                                     }

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

@@ -5214,12 +5214,8 @@ FROM
             if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
 
             var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
-            if (res.Code == 0)
-            {
-                return Ok(JsonView(true, "删除成功!"));
-
-            }
-            return Ok(JsonView(false, "删除失败!"));
+            if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
+            return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
         }
 
         /// <summary>

+ 130 - 130
OASystem/OASystem.Infrastructure/Repositories/Groups/DecreasePaymentsRepository.cs

@@ -26,7 +26,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         private readonly IMapper _mapper;
         private readonly TeamRateRepository _teamRateRep;
         private readonly SetDataRepository _setDataRepository;
-        public DecreasePaymentsRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep, SetDataRepository setDataRepository )
+        public DecreasePaymentsRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep, SetDataRepository setDataRepository)
             : base(sqlSugar)
         {
             this._mapper = mapper;
@@ -54,13 +54,13 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                               Left Join Sys_Users as su On gdp.CreateUserId = su.Id
                                               Where gdp.DiId = {0} And ccp.CTable = 98 {2} And ccp.IsDel = 0 And gdp.IsDel = 0 And gdp.CreateUserId in ({1}) ", dto.DiId, dto.UserId, sqlWhere);
             List<DecreasePaymentsView> _DecreasePayments = await _sqlSugar.SqlQueryable<DecreasePaymentsView>(sql).ToListAsync();
-            
+
             return new JsonView() { Code = 200, Msg = MsgTips.Succeed, Data = _DecreasePayments };
         }
 
         public async Task<JsonView> DecreasePaymentsSelect(DecreasePaymentsDto dto)
         {
-            
+
             #region 团组下拉框
 
             List<Grp_GroupsTaskAssignment> grp_GroupsTaskAssignment = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == dto.CTId).ToList();
@@ -148,7 +148,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 supplier = _supplier,
                 supplierArea = _supplierArea
             };
-            return  new JsonView() { Code = 200, Msg = MsgTips.Succeed, Data = data };
+            return new JsonView() { Code = 200, Msg = MsgTips.Succeed, Data = data };
 
         }
 
@@ -175,122 +175,122 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 //}
                 //else//不存在,可添加
                 //{
-                    id = await AddAsyncReturnId(grp_Decrease);
-                    if (id < 1)
-                    {
-                        RollbackTran();
-                        return new JsonView() { Code = 400, Msg = "添加失败!" };
-                    }
-
-                    //进行C表添加
-                    Grp_CreditCardPayment C = new Grp_CreditCardPayment();
-                    C.PayDId = dto.PayDId;
-                    C.ConsumptionPatterns = "";
-                    C.ConsumptionDate = "";
-                    C.CTDId = 0;
-                    C.BankNo = "";
-                    C.CardholderName = "";
-                    C.PayMoney = grp_Decrease.FeeTotal;
-                    C.PaymentCurrency = grp_Decrease.Currency;
-                    //当天汇率
-                    //if (!string.IsNullOrEmpty(hfRate.Value))
-                    //    C.DayRate = hfRate.Value;
-                    //else
-                    //C.DayRate = "";
-                    C.CompanyBankNo = "";
-                    C.OtherBankName = dto.OtherBankName;
-                    C.OtherSideNo = dto.OtherSideNo;
-                    C.OtherSideName = dto.OtherSideName;
-                    C.Remark = "";
-                    C.CreateUserId = grp_Decrease.CreateUserId;
-                    C.MFOperator = 0;
-                    C.MFOperatorDate = "";
-                    C.IsAuditDM = 0;
-                    C.AuditDMOperate = 0;
-                    C.AuditDMDate = "";
-                    C.IsAuditMF = 0;
-                    C.AuditMFOperate = 0;
-                    C.AuditMFDate = "";
-                    C.IsAuditGM = 0;
-                    C.AuditGMOperate = 21;
-                    C.AuditGMDate = "";
-
-                    //2025-04-07 第四次更改 PayDId == 72(刷卡) IsPay == 1
-                    if (C.PayDId == 72) C.IsPay = 1;
-
-                    C.DIId = grp_Decrease.DiId;
-                    C.CId = id;
-                    C.CTable = 98;
-                    C.PayPercentage = 100;
-                    C.PayThenMoney = 0;
-                    C.PayPercentageOld = 0;
-                    C.PayThenMoneyOld = 0;
-                    C.UpdateDate = "";
-                    C.Payee = dto.SupplierName;
-                    C.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
-                    C.ExceedBudget = 0;
-                    //C.RMBPrice = 0.00f;
+                id = await AddAsyncReturnId(grp_Decrease);
+                if (id < 1)
+                {
+                    RollbackTran();
+                    return new JsonView() { Code = 400, Msg = "添加失败!" };
+                }
 
-                    //设置该团组的汇率
-                    var teamRate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
-                    //Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == grp_Decrease.DiId && a.IsDel == 0 && a.CTable == 98);
-                    if (teamRate != null)
+                //进行C表添加
+                Grp_CreditCardPayment C = new Grp_CreditCardPayment();
+                C.PayDId = dto.PayDId;
+                C.ConsumptionPatterns = "";
+                C.ConsumptionDate = "";
+                C.CTDId = 0;
+                C.BankNo = "";
+                C.CardholderName = "";
+                C.PayMoney = grp_Decrease.FeeTotal;
+                C.PaymentCurrency = grp_Decrease.Currency;
+                //当天汇率
+                //if (!string.IsNullOrEmpty(hfRate.Value))
+                //    C.DayRate = hfRate.Value;
+                //else
+                //C.DayRate = "";
+                C.CompanyBankNo = "";
+                C.OtherBankName = dto.OtherBankName;
+                C.OtherSideNo = dto.OtherSideNo;
+                C.OtherSideName = dto.OtherSideName;
+                C.Remark = "";
+                C.CreateUserId = grp_Decrease.CreateUserId;
+                C.MFOperator = 0;
+                C.MFOperatorDate = "";
+                C.IsAuditDM = 0;
+                C.AuditDMOperate = 0;
+                C.AuditDMDate = "";
+                C.IsAuditMF = 0;
+                C.AuditMFOperate = 0;
+                C.AuditMFDate = "";
+                C.IsAuditGM = 0;
+                C.AuditGMOperate = 21;
+                C.AuditGMDate = "";
+
+                //2025-04-07 第四次更改 PayDId == 72(刷卡) IsPay == 1
+                if (C.PayDId == 72) C.IsPay = 1;
+
+                C.DIId = grp_Decrease.DiId;
+                C.CId = id;
+                C.CTable = 98;
+                C.PayPercentage = 100;
+                C.PayThenMoney = 0;
+                C.PayPercentageOld = 0;
+                C.PayThenMoneyOld = 0;
+                C.UpdateDate = "";
+                C.Payee = dto.SupplierName;
+                C.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
+                C.ExceedBudget = 0;
+                //C.RMBPrice = 0.00f;
+
+                //设置该团组的汇率
+                var teamRate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
+                //Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == grp_Decrease.DiId && a.IsDel == 0 && a.CTable == 98);
+                if (teamRate != null)
+                {
+                    if (teamRate.CurrencyCode.Equals("CNY"))
                     {
-                        if (teamRate.CurrencyCode.Equals("CNY"))
-                        {
-                            C.DayRate = 1.0000M;
-                            C.RMBPrice = C.PayMoney;
-                        }
-                        else
-                        {
-                            C.DayRate = teamRate.Rate;
-                            C.RMBPrice = C.PayMoney * C.DayRate;
-                        }
+                        C.DayRate = 1.0000M;
+                        C.RMBPrice = C.PayMoney;
                     }
                     else
                     {
-                        RollbackTran();
-                        return new JsonView() { Code = 400, Msg = $"添加失败!团组汇率未设置{_sqlSugar.Queryable<Sys_SetData>().First(it => it.IsDel == 0 && it.Id == grp_Decrease.Currency)?.Name ?? ""}该币种汇率!" };
+                        C.DayRate = teamRate.Rate;
+                        C.RMBPrice = C.PayMoney * C.DayRate;
                     }
-                    int cId = await _sqlSugar.Insertable(C).ExecuteReturnIdentityAsync();
-                    if (cId > 1)
-                    {
-
-                        #region 策划部内容同步添加至资料库
-                        //var userInfo = _sqlSugar.Queryable<Sys_Users>()
-                        //    .LeftJoin<Sys_Department>((u,d)=> d.IsDel == 0 && u.DepId == d.Id )
-                        //    .Where((u, d) => u.Id == dto.CreateUserId && d.DepName == "策划部" && u.IsDel == 0)
-                        //    .First();
-
-                        //if (userInfo != null)
-                        //{
-                        //    Res_MediaSuppliers mediaSuppliersData = new Res_MediaSuppliers
-                        //    {
-                        //        CreateTime = DateTime.Now,
-                        //        CreateUserId = dto.CreateUserId,
-                        //        UnitName = dto.SupplierName,
-                        //        TypeId = dto.SupplierTypeId,
-                        //        UnitAddress = dto.SupplierAddress,
-                        //        Contact = dto.SupplierContact,
-                        //        Tel = dto.SupplierContactNumber,
-                        //        Email = dto.SupplierEmail,
-                        //        Privince = dto.SupplierArea == 1 ? "国内" :"国外",
-                        //    };
-
-                        //    EncryptionProcessor.EncryptProperties(mediaSuppliersData);
-                        //    _sqlSugar.Insertable(mediaSuppliersData).ExecuteCommand();
-                        //}
-
-                        #endregion
+                }
+                else
+                {
+                    RollbackTran();
+                    return new JsonView() { Code = 400, Msg = $"添加失败!团组汇率未设置{_sqlSugar.Queryable<Sys_SetData>().First(it => it.IsDel == 0 && it.Id == grp_Decrease.Currency)?.Name ?? ""}该币种汇率!" };
+                }
+                int cId = await _sqlSugar.Insertable(C).ExecuteReturnIdentityAsync();
+                if (cId > 1)
+                {
 
-                        CommitTran();
-                        var data = new { ccpId = cId, sign = 1,dataId = id };
-                        return new JsonView() { Code = 200, Msg = "添加成功!", Data = data };
-                    }
+                    #region 策划部内容同步添加至资料库
+                    //var userInfo = _sqlSugar.Queryable<Sys_Users>()
+                    //    .LeftJoin<Sys_Department>((u,d)=> d.IsDel == 0 && u.DepId == d.Id )
+                    //    .Where((u, d) => u.Id == dto.CreateUserId && d.DepName == "策划部" && u.IsDel == 0)
+                    //    .First();
+
+                    //if (userInfo != null)
+                    //{
+                    //    Res_MediaSuppliers mediaSuppliersData = new Res_MediaSuppliers
+                    //    {
+                    //        CreateTime = DateTime.Now,
+                    //        CreateUserId = dto.CreateUserId,
+                    //        UnitName = dto.SupplierName,
+                    //        TypeId = dto.SupplierTypeId,
+                    //        UnitAddress = dto.SupplierAddress,
+                    //        Contact = dto.SupplierContact,
+                    //        Tel = dto.SupplierContactNumber,
+                    //        Email = dto.SupplierEmail,
+                    //        Privince = dto.SupplierArea == 1 ? "国内" :"国外",
+                    //    };
+
+                    //    EncryptionProcessor.EncryptProperties(mediaSuppliersData);
+                    //    _sqlSugar.Insertable(mediaSuppliersData).ExecuteCommand();
+                    //}
+
+                    #endregion
+
+                    CommitTran();
+                    var data = new { ccpId = cId, sign = 1, dataId = id };
+                    return new JsonView() { Code = 200, Msg = "添加成功!", Data = data };
+                }
 
-                    RollbackTran();
-                    return new JsonView() { Code = 400, Msg = "添加失败!" };
-               // }
+                RollbackTran();
+                return new JsonView() { Code = 400, Msg = "添加失败!" };
+                // }
             }
             else if (dto.Status == 2)
             {
@@ -381,7 +381,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }
             }
             RollbackTran();
-            return new JsonView() { Code = 400, Msg = MsgTips.Fail }; 
+            return new JsonView() { Code = 400, Msg = MsgTips.Fail };
         }
 
         public async Task<Result> PostGroupNameAndEasy(DecreasePaymentsDto dto)
@@ -501,11 +501,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// <param name="dto"></param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        public async Task<Result>  _Del(int id, int userId)
+        public async Task<Result> _Del(int id, int userId)
         {
             Result result = new Result() { Code = -2, Msg = "删除失败!" };
 
-            var ccpInfo =await _sqlSugar.Queryable<Grp_CreditCardPayment>()
+            var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
                 .FirstAsync(x => x.CId == id && x.CTable == 98 && x.IsDel == 0);
             if (ccpInfo == null) return new Result(-2, "数据不存在,不可删除!");
 
@@ -520,24 +520,24 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _sqlSugar.BeginTran();
 
             var del = await _sqlSugar.Updateable<Grp_DecreasePayments>()
-                                     .SetColumns(it => new Grp_DecreasePayments()
-                                     {
-                                         IsDel = 1,
-                                         DeleteUserId = userId,
-                                         DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
-                                     }).Where(it => it.Id == id)
-                                     .ExecuteCommandAsync();
+                .SetColumns(it => new Grp_DecreasePayments()
+                {
+                    IsDel = 1,
+                    DeleteUserId = userId,
+                    DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                }).Where(it => it.Id == id)
+                .ExecuteCommandAsync();
             if (del > 0)
             {
                 var del1 = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
-                                          .SetColumns(a => new Grp_CreditCardPayment()
-                                          {
-                                              IsDel = 1,
-                                              DeleteUserId = userId,
-                                              DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
-                                          })
-                                          .Where(a => a.CId == id && a.CTable == 98)
-                                          .ExecuteCommandAsync();
+                    .SetColumns(a => new Grp_CreditCardPayment()
+                    {
+                        IsDel = 1,
+                        DeleteUserId = userId,
+                        DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                    })
+                    .Where(a => a.CId == id && a.CTable == 98)
+                    .ExecuteCommandAsync();
                 if (del1 > 0)
                 {
                     _sqlSugar.CommitTran();