Kaynağa Gözat

增强费用审核逻辑和代码可读性

在 `FeeAuditRepository.cs` 文件中进行了多项修改:
- 引入 `guestCount` 变量以优化其他费用计算。
- 在计算其他费用时考虑 `guestCount`,确保费用合理分摊。
- 增加费用判断的条件,确保仅在价格大于零时进行比较。
- 更新 SQL 更新命令格式,提高代码可读性。
Lyyyi 1 ay önce
ebeveyn
işleme
912333168b

+ 35 - 15
OASystem/OASystem.Infrastructure/Repositories/Groups/FeeAuditRepository.cs

@@ -116,7 +116,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     return _view;
                 }
 
-
                 //获取C表汇率
                 decimal _rate = 1.0000M;
                 var roomFeeInfo = hotelCostDetails.Where(x => x.PriceType == 1).First();
@@ -130,12 +129,21 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 bool isAutoAudit = true; //是否自动审核
                 DateTime checkIn = Convert.ToDateTime(hotelCostInfo.CheckInDate),
                          checkOut = Convert.ToDateTime(hotelCostInfo.CheckOutDate);
+
                 if (checkOut > checkIn) checkOut = checkOut.AddDays(-1); //房费计算,结束日期为前一天
                 var hotelCostInfos = costContents.Where(x => x.CurrTime >= checkIn && x.CurrTime <= checkOut).ToList();
                 if (hotelCostInfos.Count < 1) isAutoAudit = false;
 
+                #region 其他费用(早餐、地税、城市税) 按照个人计算 2025-07-01 14:07:25
                 decimal otherFee = hotelCostDetails.Where(x => x.PriceType != 1).Sum(x => x.Price * (x.Rate == 0.0000M ? 1.0000M : x.Rate));
-                if (otherFee > 0) { otherFee /= (checkOut - checkIn).Days; }
+
+                int guestCount = 0;
+                if (hotelCostInfo.GuestName.Contains(',')) guestCount = hotelCostInfo.GuestName.Split(",").Length;
+                else guestCount = 1;
+
+                if (otherFee > 0) otherFee /= guestCount;
+                #endregion
+
                 var hotelCostInfosGroup = hotelCostInfos.GroupBy(x => x.Date);
                 foreach (var item in hotelCostInfosGroup)
                 {
@@ -145,31 +153,43 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     var hotelSuiteRoomFee = item.Sum(x => x.HotelSuiteRoomFee) * _teamRate;   //成本其他房型间费用
                     //1.判断费用是否 <= 成本费用
                     //1.1 判断单间费用
-                    decimal singleRoomPrice = (hotelCostInfo.SingleRoomPrice + otherFee) * _rate; //酒店录入费用
-                    if (singleRoomPrice > 0) if (singleRoomPrice > hotelSingleRoomFee) isAutoAudit = false;
+                    if (hotelCostInfo.SingleRoomPrice > 0)
+                    {
+                        decimal singleRoomPrice = (hotelCostInfo.SingleRoomPrice + otherFee) * _rate; //酒店录入费用
+                        if (singleRoomPrice > hotelSingleRoomFee) isAutoAudit = false;
+                    }
 
                     //1.2 判断双人间费用
-                    decimal doubleRoomPrice = (hotelCostInfo.DoubleRoomPrice + otherFee) * _rate;//酒店录入费用
-                    if (doubleRoomPrice > 0) if (doubleRoomPrice > hotelDoubleRoomFee) isAutoAudit = false;
+                    if (hotelCostInfo.DoubleRoomPrice > 0)
+                    {
+                        decimal doubleRoomPrice = (hotelCostInfo.DoubleRoomPrice + otherFee) * _rate;//酒店录入费用
+                        if (doubleRoomPrice > hotelDoubleRoomFee) isAutoAudit = false;
+                    }
 
                     //1.3 判断套房费用
-                    decimal suiteRoomPrice = (hotelCostInfo.SuiteRoomPrice + otherFee) * _rate;//酒店录入费用
-                    if (suiteRoomPrice > 0) if (suiteRoomPrice > hotelSuiteFee) isAutoAudit = false;
+                    if (hotelCostInfo.SuiteRoomPrice > 0)
+                    {
+                        decimal suiteRoomPrice = (hotelCostInfo.SuiteRoomPrice + otherFee) * _rate;//酒店录入费用
+                        if (suiteRoomPrice > hotelSuiteFee) isAutoAudit = false;
+                    }
 
                     //1.4 判断其他房型费用
-                    decimal otherRoomPrice = (hotelCostInfo.OtherRoomPrice + otherFee) * _rate;//酒店录入费用
-                    if (otherRoomPrice > 0) if (otherRoomPrice > hotelSuiteRoomFee) isAutoAudit = false;
+                    if (hotelCostInfo.OtherRoomPrice > 0)
+                    {
+                        decimal otherRoomPrice = (hotelCostInfo.OtherRoomPrice + otherFee) * _rate;//酒店录入费用
+                        if (otherRoomPrice > hotelSuiteRoomFee) isAutoAudit = false;
+                    }
                 }
 
                 //2.判断是否自动审核
                 if (isAutoAudit)
                 {
                     var ccpUpdate = _sqlSugar.Updateable<Grp_CreditCardPayment>()
-                                       .SetColumns(it => it.IsAuditGM == 3)
-                                       .SetColumns(it => it.AuditGMOperate == 4)
-                                       .SetColumns(it => it.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
-                                       .Where(s => s.DIId == diId && s.CTable == 76 && s.CId == dataId)
-                                       .ExecuteCommand();
+                        .SetColumns(it => it.IsAuditGM == 3)
+                        .SetColumns(it => it.AuditGMOperate == 4)
+                        .SetColumns(it => it.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                        .Where(s => s.DIId == diId && s.CTable == 76 && s.CId == dataId)
+                        .ExecuteCommand();
                     if (ccpUpdate > 0)
                     {
                         _view.Code = 200;