Explorar el Código

添加企业利润费用统计功能

在 `StatisticsController.cs` 文件中,添加了一个新的私有异步方法 `CorporateProfitFeeCount`,用于统计企业利润团组费用条数,并在获取 `groupItems` 后调用该方法获取费用统计信息,合并到 `groupItems` 中。

在 `CorporateProfitViews.cs` 文件中,添加了一个新的类 `CorporateProfitFeeCount`,用于表示企业利润团组费用条数统计,并为 `CorporateProfitItem` 类添加了一个新的属性 `FeeCountTipsLabel`,用于存储费用提示标签。同时,为 `CorporateProfitFeeCount` 类添加了一个计算属性 `FeeCountTipsLabel`,用于生成费用提示标签的字符串。
LEIYI hace 2 meses
padre
commit
5027155710

+ 174 - 1
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -7741,7 +7741,6 @@ WHERE
 
         #region 企业利润
 
-
         /// <summary>
         /// 企业利润 infos
         /// </summary>
@@ -8055,6 +8054,21 @@ WHERE
 
             var groupItems = await _sqlSugar.SqlQueryable<CorporateProfitInfo>(sql).ToArrayAsync();
 
+            if (groupItems.Any())
+            {
+                var groupIds = groupItems.Select(x => x.Id).ToArray();
+
+                var feeCountInfos = await CorporateProfitFeeCount(groupIds);
+                if (feeCountInfos.Any())
+                {
+                    foreach (var item in groupItems)
+                    {
+                        var tips = feeCountInfos.FirstOrDefault(x => x.Id == item.Id)?.FeeCountTipsLabel ?? "";
+                        if (!string.IsNullOrEmpty(tips)) item.FeeCountTipsLabel = tips;
+                    }
+                }
+            }
+
             var dailySql = string.Format(@"SELECT
   dfp.Id,
   dfp.CompanyId,
@@ -8101,6 +8115,165 @@ ORDER BY
             return view;
         }
 
+        /// <summary>
+        /// 企业利润 
+        /// 团组费用条数统计
+        /// </summary>
+        /// <param name="groupIds"></param>
+        /// <returns></returns>
+        private async Task<CorporateProfitFeeCount[]> CorporateProfitFeeCount(int[] groupIds)
+        {
+            if (!groupIds.Any()) return Array.Empty<CorporateProfitFeeCount>();
+
+            //含未审核SQL
+            string sql = string.Format(@"SELECT
+  ROW_NUMBER() OVER(
+    ORDER BY
+      di.VisitDate Asc
+  ) AS 'RowIndex',
+  di.Id,
+  di.TeamName,
+  di.VisitDate,
+  (
+    SELECT
+      Count(1)
+    FROM
+      OA2023DB.dbo.Fin_ForeignReceivables ffr
+    WHERE
+      ffr.IsDel = 0
+      AND ffr.Diid = di.Id
+  ) 'ReceivableTotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      OA2023DB.dbo.Fin_ProceedsReceived fpr
+    WHERE
+      fpr.IsDel = 0
+      AND fpr.DIId = di.Id
+  ) 'ReceivedTotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Fin_PaymentRefundAndOtherMoney prom
+      INNER JOIN Grp_CreditCardPayment ccp ON prom.Id = ccp.CId
+      AND prom.DiId = ccp.DIId
+    WHERE
+      prom.IsDel = 0
+      AND prom.PayType = 1
+      AND ccp.CTable = 285 
+      --AND ccp.IsAuditGM = 1
+      AND ccp.IsAuditGM != 2
+      AND prom.DiId = di.Id
+  ) AS 'RefundedTotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Grp_HotelReservations hr
+      INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
+    WHERE
+      hr.IsDel = 0
+      AND ccp.IsDel = 0
+      AND ccp.CTable = 76 -- AND (
+      --   ccp.IsAuditGM = 1
+      --   OR ccp.IsAuditGM = 3
+      -- )
+      AND ccp.IsAuditGM != 2
+      AND hr.DiId = di.Id
+  ) AS 'HotelTotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Grp_CarTouristGuideGroundReservations ctggr
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.IsDel = 0
+      AND ccp.CTable = 79
+      AND ctggr.Id = ccp.CId
+    WHERE
+      ctggr.IsDel = 0 -- AND (
+      --   ccp.IsAuditGM = 1
+      --   OR ccp.IsAuditGM = 3
+      -- )
+      AND ccp.IsAuditGM != 2
+      AND ctggr.DiId = di.Id
+  ) AS 'LocalGuideTotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Grp_AirTicketReservations atr
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 85
+      AND atr.Id = ccp.CId
+    WHERE
+      atr.IsDel = 0 -- AND ccp.IsAuditGM = 1
+      AND ccp.IsAuditGM != 2
+      AND atr.DIId = di.Id
+  ) AS 'AirTicketToal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Grp_VisaInfo vi
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 80
+      AND vi.Id = ccp.CId
+    WHERE
+      vi.IsDel = 0 -- AND ccp.IsAuditGM = 1
+      AND ccp.IsAuditGM != 2
+      AND vi.DIId = di.Id
+  ) AS 'VisaTotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Grp_InvitationOfficialActivities ioa
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 81
+      AND ioa.Id = ccp.CId
+    WHERE
+      ioa.IsDel = 0 -- AND ccp.IsAuditGM = 1
+      AND ccp.IsAuditGM != 2
+      AND ioa.DiId = di.Id
+  ) AS 'OATotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Grp_Customers ic
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 82
+      AND ic.Id = ccp.CId
+    WHERE
+      ic.IsDel = 0 -- AND ccp.IsAuditGM = 1
+      AND ccp.IsAuditGM != 2
+      AND ic.DiId = di.Id
+  ) AS 'InsureTotal',
+  (
+    SELECT
+      Count(1)
+    FROM
+      Grp_DecreasePayments dp
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 98
+      AND dp.Id = ccp.CId
+    WHERE
+      dp.IsDel = 0 -- AND ccp.IsAuditGM = 1
+      AND ccp.IsAuditGM != 2
+      AND dp.Diid = di.Id
+  ) AS 'OtherTotal'
+FROM
+  OA2023DB.dbo.Grp_DelegationInfo di
+  LEFT JOIN Sys_SetData ss ON di.TeamDid = ss.Id
+WHERE
+  di.IsDel = 0
+  AND di.IsBid = 0
+   AND di.Id IN({0})", string.Join(",", groupIds));
+
+            return await _sqlSugar.SqlQueryable<CorporateProfitFeeCount>(sql).ToArrayAsync();
+        }
 
         /// <summary>
         /// 团组利润item详情

+ 73 - 0
OASystem/OASystem.Domain/ViewModels/Statistics/CorporateProfitViews.cs

@@ -135,6 +135,74 @@ namespace OASystem.Domain.ViewModels.Statistics
                 return ReceivableAmount - CostTotal;
             }
         }
+        /// <summary>
+        /// 费用Tips Lable
+        /// </summary>
+        public string FeeCountTipsLabel { get; set; }
+    }
+
+    /// <summary>
+    /// 企业利润团组费用条数统计
+    /// </summary>
+    public class CorporateProfitFeeCount
+    {
+        public int RowIndex { get; set; }
+        public int Id { get; set; }
+        public string TeamName { get; set; }
+        public DateTime VisitDate { get; set; }
+        /// <summary>
+        /// 应收费用-Count
+        /// </summary>
+        public int ReceivableTotal { get; set; }
+        /// <summary>
+        /// 已收费用-Count
+        /// </summary>
+        public int ReceivedTotal { get; set; }
+        /// <summary>
+        /// 收款退还费用-Count
+        /// </summary>
+        public int RefundedTotal { get; set; }
+        /// <summary>
+        /// 酒店费用-Count
+        /// </summary>
+        public int HotelTotal { get; set; }
+        /// <summary>
+        /// 地接费用-Count
+        /// </summary>
+        public int LocalGuideTotal { get; set; }
+        /// <summary>
+        /// 机票费用-Count
+        /// </summary>
+        public int AirTicketToal { get; set; }
+        /// <summary>
+        /// 签证费用-Count
+        /// </summary>
+        public int VisaTotal { get; set; }
+        /// <summary>
+        /// 商邀费用-Count
+        /// </summary>
+        public int OATotal { get; set; }
+        /// <summary>
+        /// 保险费用-Count
+        /// </summary>
+        public int InsureTotal { get; set; }
+        /// <summary>
+        /// 其他费用-Count
+        /// </summary>
+        public int OtherTotal { get; set; }
+       
+        /// <summary>
+        /// 费用Tips Lable
+        /// </summary>
+        public string FeeCountTipsLabel
+        {
+            get
+            {
+                string tips = $"应收数据:{ReceivableTotal} 条\r\n已收数据:{ReceivedTotal} 条\r\n收款退还数据:{RefundedTotal} 条\r\n酒店数据:{HotelTotal} 条\r\n地接数据:{LocalGuideTotal} 条\r\n机票数据:{AirTicketToal} 条\r\n签证数据:{VisaTotal} 条\r\n商邀数据:{OATotal} 条\r\n保险退还数据:{InsureTotal} 条\r\n其他费用数据:{OtherTotal} 条\r\n";
+
+                return tips;
+            }
+        }
     }
 
     public class CorporateProfitItem
@@ -168,6 +236,11 @@ namespace OASystem.Domain.ViewModels.Statistics
         /// 应收利润合计/已收-成本
         /// </summary>
         public decimal ReceivableProfitTotal { get; set; }
+
+        /// <summary>
+        /// 费用Tips Lable
+        /// </summary>
+        public string FeeCountTipsLabel { get; set; }
     }
 
     public class CorporateProfitItemView