Преглед на файлове

添加应收利润合计计算和属性

在 `StatisticsController.cs` 中,增加了计算和设置应收利润合计的代码,包括 `groupReceivableTotal` 和 `notGroupReceivableTotal` 的计算,并在 `WorkbookDesigner` 中设置了 `ReceivableProfitTotal` 和 `NotReceivableProfitTotal` 的数据源。

在 `CorporateProfitViews.cs` 中,添加了 `ReceivableProfitTotal` 属性,用于计算应收利润合计(已收金额减去成本),以及 `ReceivableAmount` 属性,用于表示应收金额。

更新客户资料导出和应收利润计算功能

在 MarketCustomerResourcesController.cs 文件中:
- 修改注释和文件名,增加保存路径和下载链接代码
- 增加客户资料表操作记录代码(注释掉的部分)
- 新增 NewClientDataAuthorityExcelDownload 方法

在 StatisticsController.cs 文件中:
- 增加团组和非团组应收利润合计计算
- 更新 Excel 模板数据源设置

在 CorporateProfitViews.cs 文件中:
- 增加应收利润合计和应收金额属性
- 更新注释
LEIYI преди 2 месеца
родител
ревизия
bc13d7c337

+ 59 - 2
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -564,7 +564,7 @@ namespace OASystem.API.Controllers
         }
 
         /// <summary>
-        /// 客户资料数据 excel 下载
+        /// 客户资料数据 全信息导出 excel 下载
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
@@ -596,7 +596,63 @@ namespace OASystem.API.Controllers
                 designer.Process();
 
                 //文件名
-                string fileName = $"公司客户资料{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
+                string fileName = $"公司客户资料(全信息导出){DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
+                designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "NewClientDataExcelDownload/" + fileName);
+                string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/NewClientDataExcelDownload/" + fileName;
+
+                #region 客户资料表操作记录
+                var respose = JsonView(true, "成功", url);
+                //var paramData = new
+                //{
+                //    APIName = @"MarketCustomerResources/NewClientDataExcelDownload",
+                //    RequestParam = dto,
+                //    ResposeParam = respose
+                //};
+                //await GeneralMethod.NewClientOperationRecord(dto.PortType, OperationEnum.Download, dto.OperationUserId, 0, JsonConvert.SerializeObject(paramData));
+                #endregion
+
+                return Ok(respose);
+            }
+
+            return Ok(JsonView(false));
+
+        }
+
+
+        /// <summary>
+        /// 客户资料数据 分权限导出 excel 下载
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ApiLog("Crm_NewClientData", OperationEnum.Download)]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> NewClientDataAuthorityExcelDownload(NewClientDataExcelDownloadDto dto)
+        {
+            #region 参数验证
+            if (dto.OperationUserId < 0) return Ok(JsonView(false, "请传入有效的OperationUserId参数!"));
+
+            if (dto.PortType < 0) return Ok(JsonView(false, "请传入有效的PortType参数!"));
+            if (dto.PageId < 0) return Ok(JsonView(false, "请传入有效的PageId参数!"));
+            #endregion
+
+            #region 页面操作权限验证
+            var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.OperationUserId, dto.PageId);
+
+            if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权!"));
+            #endregion
+
+            var dt = await _clientDataRepository.NewClientDataExcelDownload(dto);
+            if (dt != null)
+            {
+                string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/公司客户资料分权限导出模板.xlsx");
+                var designer = new WorkbookDesigner();
+                designer.Workbook = new Workbook(tempPath);
+                designer.SetDataSource("NCDDT", dt);
+                designer.Process();
+
+                //文件名
+                string fileName = $"公司客户资料(分权限导出){DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
                 designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "NewClientDataExcelDownload/" + fileName);
                 string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/NewClientDataExcelDownload/" + fileName;
 
@@ -619,6 +675,7 @@ namespace OASystem.API.Controllers
 
         }
 
+
         /// <summary>
         /// 客户资料数据 历史记录 Init
         /// </summary>

+ 6 - 0
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -8147,10 +8147,12 @@ ORDER BY
 
             //团组 收款、成本、利润 合计
             var groupCollectionTotal = groupItems.Where(x => groupTypeIds.Contains(x.TeamDid)).Sum(x => x.CollectionTotal);
+            var groupReceivableTotal = groupItems.Where(x => groupTypeIds.Contains(x.TeamDid)).Sum(x => x.ReceivableProfitTotal);
             var groupCostTotal = groupItems.Where(x => groupTypeIds.Contains(x.TeamDid)).Sum(x => x.CostTotal);
             var groupProfitTotal = groupItems.Where(x => groupTypeIds.Contains(x.TeamDid)).Sum(x => x.ProfitTotal);
             //非团组 收款、成本、利润 合计
             var notGroupCollectionTotal = groupItems.Where(x => !groupTypeIds.Contains(x.TeamDid)).Sum(x => x.CollectionTotal);
+            var notGroupReceivableTotal = groupItems.Where(x => !groupTypeIds.Contains(x.TeamDid)).Sum(x => x.ReceivableProfitTotal);
             var notGroupCostTotal = groupItems.Where(x => !groupTypeIds.Contains(x.TeamDid)).Sum(x => x.CostTotal);
             var notGroupProfitTotal = groupItems.Where(x => !groupTypeIds.Contains(x.TeamDid)).Sum(x => x.ProfitTotal);
             //会务数量
@@ -8181,6 +8183,10 @@ ORDER BY
                 designer.Workbook = new Workbook(tempPath);
                 designer.SetDataSource("ReceivablesTemp", datas);
 
+                //
+                designer.SetDataSource("ReceivableProfitTotal", groupReceivableTotal.ToString("#0.00"));
+                designer.SetDataSource("NotReceivableProfitTotal", notGroupReceivableTotal.ToString("#0.00"));
+
                 designer.SetDataSource("SumAccounts", groupCollectionTotal.ToString("#0.00"));
                 designer.SetDataSource("SumReceived", groupCostTotal.ToString("#0.00"));
                 designer.SetDataSource("SumBalance", groupProfitTotal.ToString("#0.00"));

+ 24 - 3
OASystem/OASystem.Domain/ViewModels/Statistics/CorporateProfitViews.cs

@@ -116,7 +116,7 @@ namespace OASystem.Domain.ViewModels.Statistics
             }
         }
         /// <summary>
-        /// 利润合计
+        /// 利润合计/已收-成本
         /// </summary>
         public decimal ProfitTotal
         {
@@ -125,6 +125,16 @@ namespace OASystem.Domain.ViewModels.Statistics
                 return CollectionTotal - CostTotal;
             }
         }
+        /// <summary>
+        /// 应收利润合计/已收-成本
+        /// </summary>
+        public decimal ReceivableProfitTotal
+        {
+            get
+            {
+                return ReceivableAmount - CostTotal;
+            }
+        }
     }
 
     public class CorporateProfitItem
@@ -136,17 +146,28 @@ namespace OASystem.Domain.ViewModels.Statistics
         public DateTime VisitDate { get; set; }
       
         /// <summary>
-        /// 收款合计
+        /// 收款合计(已收金额)
         /// </summary>
         public decimal CollectionTotal { get; set; }
+        
+        /// <summary>
+        /// 应收 
+        /// </summary>
+        public decimal ReceivableAmount { get; set; }
+
         /// <summary>
         /// 成本合计
         /// </summary>
         public decimal CostTotal { get; set; }
         /// <summary>
-        /// 利润合计
+        /// 利润合计/已收-成本
         /// </summary>
         public decimal ProfitTotal { get; set; }
+
+        /// <summary>
+        /// 应收利润合计/已收-成本
+        /// </summary>
+        public decimal ReceivableProfitTotal { get; set; }
     }
 
     public class CorporateProfitItemView