Parcourir la source

酒店自动审核Bug更改

LEIYI il y a 3 mois
Parent
commit
02adcbebb0

+ 33 - 12
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -4242,7 +4242,21 @@ Group by PriceType ", dto.diId);
                         dt.Columns.Add(GetString(worksheet.Cells[i, j].Value));
                     //剩下的写入datatable
                     else
-                        dr[j - 1] = GetString(worksheet.Cells[i, j].Value);
+                    {
+                        var cell = worksheet.Cells[i, j];
+
+                        if (j == 1 || j == 2)
+                        {
+                            if (cell.Value is double)
+                            {
+                                dr[j - 1] = EPPlusConvertToDateTime((double)cell.Value).ToString("MM/dd");
+                            }
+                        }
+                        else
+                        {
+                            dr[j - 1] = GetString(cell.Value);
+                        }
+                    }
                 }
             }
             return dt;
@@ -4250,7 +4264,6 @@ Group by PriceType ", dto.diId);
 
         private string GetString(object obj)
         {
-
             if (obj == null)
                 return "";
 
@@ -4258,6 +4271,15 @@ Group by PriceType ", dto.diId);
 
         }
 
+        public static DateTime EPPlusConvertToDateTime(double numericDate)
+        {
+            // Excel起始日期
+            DateTime startDate = new DateTime(1899, 12, 30);
+            // 将数字日期转换为时间间隔,并加上起始日期
+            TimeSpan duration = new TimeSpan((long)(numericDate * TimeSpan.TicksPerDay));
+            return startDate.Add(duration);
+        }
+
         private DataTable ExcelFileToDataTable(IFormFile file)
         {
             DataTable dtTest = null;
@@ -4641,8 +4663,11 @@ Group by PriceType ", dto.diId);
                     for (int j = 0; j < dt.Rows.Count; j++)//遍历行
                     {
                         DataRow dr = dt1.NewRow(); //获取每一行的数据
-                        dr["TradingDay"] = dt.Rows[j][0].ToString();
-                        dr["TallyDay"] = dt.Rows[j][1].ToString();
+                        var tradingDay = dt.Rows[j][0].ToString();
+
+                        dr["TradingDay"] = tradingDay;
+                        var tallyDay = dt.Rows[j][1].ToString();
+                        dr["TallyDay"] = tallyDay;
                         dr["TransactionDesc"] = dt.Rows[j][2].ToString();
                         dr["RMBMoney"] = dt.Rows[j][3].ToString();
                         dr["CardNo"] = dt.Rows[j][4].ToString();
@@ -4683,12 +4708,8 @@ Group by PriceType ", dto.diId);
 
                         if (item["TradingDay"] != null)
                         {
-                            var dtBool = DateTime.TryParse(item["TradingDay"].ToString(), out DateTime _ExcelDt);
-
-                            if (dtBool)
-                            {
-                                ExcelDt = _ExcelDt.ToString("MMdd");
-                            }
+                            
+                            ExcelDt = item["TradingDay"].ToString();
                             
                         }
 
@@ -4706,9 +4727,9 @@ Group by PriceType ", dto.diId);
                             {
                                 if (!string.IsNullOrWhiteSpace(Citem.ConsumptionDate))
                                 {
-                                    DBDt = DateTime.Parse(Citem.ConsumptionDate).ToString("MMdd");
+                                    DBDt = DateTime.Parse(Citem.ConsumptionDate).ToString("MM/dd");
 
-                                    if (DBDt == ExcelDt)
+                                    if (DBDt.Equals(ExcelDt))
                                     {
                                         item["TeamRemark"] = delegationInfos.Find(it => it.Id == Citem.DIId)?.TeamName;
                                         item["Handlers"] = users.Find(it => it.Id == Citem.CreateUserId)?.CnName;

+ 1 - 1
OASystem/OASystem.Domain/ViewModels/Groups/FeeAuditView.cs

@@ -18,7 +18,7 @@ namespace OASystem.Domain.ViewModels.Groups
     {
         #region OP 自动审核相关
 
-       
+        public DateTime CurrTime { get; set; }
 
         /// <summary>
         /// 自动审核 - 车费用

+ 18 - 5
OASystem/OASystem.Infrastructure/Repositories/Groups/FeeAuditRepository.cs

@@ -62,6 +62,19 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     if (index >= 0)
                     {
                         costContents[i].Date = costContents[index].Date;
+                        var dtBool = DateTime.TryParse(costContents[i].Date, out DateTime _dateTime);
+                        if (dtBool)
+                        {
+                            costContents[i].CurrTime = _dateTime;
+                        }
+                    }
+                }
+                else
+                {
+                    var dtBool = DateTime.TryParse(costContents[i].Date, out DateTime _dateTime);
+                    if (dtBool)
+                    {
+                        costContents[i].CurrTime = _dateTime;
                     }
                 }
             }
@@ -101,7 +114,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 DateTime checkIn = Convert.ToDateTime(hotelCostInfo.CheckInDate),
                          checkOut = Convert.ToDateTime(hotelCostInfo.CheckOutDate);
                 if (checkOut > checkIn) checkOut = checkOut.AddDays(-1); //房费计算,结束日期为前一天
-                var hotelCostInfos = costContents.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
+                var hotelCostInfos = costContents.Where(x =>  x.CurrTime >= checkIn && x.CurrTime <= checkOut).ToList();
                 if (hotelCostInfos.Count < 1) isAutoAudit = false;
 
                 decimal otherFee = hotelCostDetails.Where(x => x.PriceType != 1).Sum(x => x.Price * (x.Rate == 0.0000M ? 1.0000M : x.Rate));
@@ -116,19 +129,19 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     //1.判断费用是否 <= 成本费用
                     //1.1 判断单间费用
                     decimal singleRoomPrice = (hotelCostInfo.SingleRoomPrice + otherFee) * _rate;
-                    if (singleRoomPrice > 0) if (singleRoomPrice > hotelSingleRoomFee * _rate) isAutoAudit = false;
+                    if (singleRoomPrice > 0) if (singleRoomPrice > hotelSingleRoomFee * _teamRate) isAutoAudit = false;
 
                     //1.2 判断双人间费用
                     decimal doubleRoomPrice = (hotelCostInfo.DoubleRoomPrice + otherFee) * _rate;
-                    if (doubleRoomPrice > 0) if (doubleRoomPrice > hotelDoubleRoomFee * _rate) isAutoAudit = false;
+                    if (doubleRoomPrice > 0) if (doubleRoomPrice > hotelDoubleRoomFee * _teamRate) isAutoAudit = false;
 
                     //1.3 判断套房费用
                     decimal suiteRoomPrice = (hotelCostInfo.SuiteRoomPrice + otherFee) * _rate;
-                    if (suiteRoomPrice > 0) if (suiteRoomPrice > hotelSuiteFee * _rate) isAutoAudit = false;
+                    if (suiteRoomPrice > 0) if (suiteRoomPrice > hotelSuiteFee * _teamRate) isAutoAudit = false;
 
                     //1.4 判断其他房型费用
                     decimal otherRoomPrice = (hotelCostInfo.OtherRoomPrice + otherFee) * _rate;
-                    if (otherRoomPrice > 0) if (otherRoomPrice > hotelSuiteRoomFee * _rate) isAutoAudit = false;
+                    if (otherRoomPrice > 0) if (otherRoomPrice > hotelSuiteRoomFee * _teamRate) isAutoAudit = false;
                 }
 
                 //2.判断是否自动审核