lifa 1 год назад
Родитель
Сommit
55bed5b911

+ 50 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Dto/ProjectCountPageOutput.cs

@@ -23,6 +23,15 @@ namespace ZhonTai.Admin.Services.DiTuiAPI.Dto
 {
     public class ProjectCountPageOutput
     {
+        public ProjectCountPageOutput()
+        {
+        }
+
+        public ProjectCountPageOutput(string settleDate)
+        {
+            SettleDate = settleDate;
+        }
+
         public ProjectCountPageOutput(long id, string settleDate,string salesman,List<SettleCount> settleCounts)
         {
             Id = id;
@@ -38,6 +47,13 @@ namespace ZhonTai.Admin.Services.DiTuiAPI.Dto
 
     public class SettleCount
     {
+        public SettleCount(string settleStandard, string settleNum)
+        {
+            SettleStandard = settleStandard;
+            SettleNum = settleNum;
+            Commission = "--";
+
+        }
         public SettleCount(string settleStandard,string settleNum,string commission)
         {
             SettleStandard = settleStandard;
@@ -59,4 +75,38 @@ namespace ZhonTai.Admin.Services.DiTuiAPI.Dto
         public string Commission { get; set; }
 
     }
+
+    public class SettleRecord
+    {
+        public SettleRecord(string settleStandard,string validCount,string count)
+        {
+            SettleStandard = settleStandard;
+            ValidCount = validCount;
+            Count = count;
+            Commission = "--";
+        }
+        public SettleCount RecordeToCount()
+        {
+            SettleCount sc = new SettleCount(this.SettleStandard, this.ValidCount + "/" + this.Count, this.Commission);
+            //sc.SettleNum = ;
+            //sc.SettleStandard = ;
+            //sc.Commission = this.Commission;
+            return sc;
+        }
+
+        public string SettleStandard { get; set; }
+        /// <summary>
+        /// 有效数
+        /// </summary>
+        public string ValidCount { get; set; }
+        /// <summary>
+        /// 总数
+        /// </summary>
+        public string Count { get; set; }
+        /// <summary>
+        /// 佣金
+        /// </summary>
+        public string Commission { get; set; } 
+    }
+
 }

+ 40 - 60
src/platform/ZhonTai.Admin/Services/DiTuiAPI/ProjectsService.cs

@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http.Metadata;
+using Microsoft.AspNetCore.Mvc;
 using Qiniu.Util;
 using System;
 using System.Collections.Generic;
@@ -30,11 +31,13 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         private ProjectLinkRepository _ProjectLinkRepository;
         private ProjectRepository _projectRepository;
         private ProjectPriceRepository _projectPriceRepository;
-        public ProjectsService(ProjectLinkRepository projectLinkRepository,ProjectRepository projectRepository,ProjectPriceRepository projectPriceRepository)
+        private ProjectStatRepository _projectStatRepository;
+        public ProjectsService(ProjectLinkRepository projectLinkRepository,ProjectRepository projectRepository,ProjectPriceRepository projectPriceRepository,ProjectStatRepository projectStatRepository)
         {
             _ProjectLinkRepository = projectLinkRepository;
             _projectRepository = projectRepository;
             _projectPriceRepository = projectPriceRepository;
+            _projectStatRepository = projectStatRepository;
         }
 
         /// <summary>
@@ -250,68 +253,45 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
                 ProjectId = 0;
             }
 
+            if(ProjectId == 0)
+            {
+                throw ResultOutput.Exception("项目 ID 不可为空");
+            }
 
-            //var list = _ProjectLinkRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
-            //    .WhereIf(ProjectId.HasValue && ProjectId.Value > 0, a => a.ProjectId == ProjectId)
-            //    .WhereIf(Salesman.NotNull(), a => a.Salesman.Contains(Salesman))
-            //    .WhereIf(SalesmanPhone.NotNull(), a => a.SalesmanPhone.Contains(SalesmanPhone))
-            //.Count(out var total)
-            //.Page(input.CurrentPage, input.PageSize)
-            //.ToList(m => new ProjectQrcodePageOutput()
-            //{
-            //    Id = m.Id,
-            //    Salesman = m.Salesman,
-            //    UseTime = m.UseTime,
-            //    QrcodeUrl = m.QrcodeUrl,
-            //    QueryUrl = m.QueryUrl
-            //});
+            var listStat = _projectStatRepository
+                .Select
+                .DisableGlobalFilter(FilterNames.Tenant)
+                .Where(a => a.ProjectId == ProjectId)
+                .WhereIf(Date.NotNull(), a => a.EffectDate.ToString().Contains(Date))
+                .GroupBy(a => a.EffectDate)
+                .Page(input.CurrentPage, input.PageSize)
+                .ToList(m => new { SettleDate = m.Key});
 
             List<ProjectCountPageOutput> list = new List<ProjectCountPageOutput>();
-            List<SettleCount> settleCounts = new List<SettleCount>();
-            settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            settleCounts.Add(new SettleCount("电商首购B级", "201/300单", "201元"));
-            settleCounts.Add(new SettleCount("电商首购C级", "202/300单", "202元"));
-            settleCounts.Add(new SettleCount("今日汇总", "603/900单", "603元"));
-
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            list.Add(new ProjectCountPageOutput((long)(ProjectId != 0 ? ProjectId : 416237348180038), "2023-05-02","", settleCounts));
-
-            List<SettleCount> settleCounts1 = new List<SettleCount>();
-            settleCounts1.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            settleCounts1.Add(new SettleCount("电商首购B级", "199/300单", "199元"));
-            settleCounts1.Add(new SettleCount("电商首购C级", "198/300单", "198元"));
-            settleCounts1.Add(new SettleCount("今日汇总", "597/900单", "597元"));
-
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            list.Add(new ProjectCountPageOutput((long)(ProjectId != 0 ? ProjectId : 416237348180038), "2023-05-01","", settleCounts1));
-
-            // 项目日统计数据
-            List<ProjectCountPageOutput> listDay = new List<ProjectCountPageOutput>();
-            List<SettleCount> settleCountsDay = new List<SettleCount>();
-            settleCountsDay.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            settleCountsDay.Add(new SettleCount("电商首购B级", "201/300单", "201元"));
-            settleCountsDay.Add(new SettleCount("电商首购C级", "202/300单", "202元"));
-            settleCountsDay.Add(new SettleCount("今日汇总", "603/900单", "603元"));
-
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            listDay.Add(new ProjectCountPageOutput((long)(ProjectId != 0 ? ProjectId : 416237348180038), !string.IsNullOrEmpty(Date)? Date :"2023-05-02", "中捷乐淘", settleCountsDay));
-
-            List<SettleCount> settleCountsDay1 = new List<SettleCount>();
-            settleCountsDay1.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            settleCountsDay1.Add(new SettleCount("电商首购B级", "199/300单", "199元"));
-            settleCountsDay1.Add(new SettleCount("电商首购C级", "198/300单", "198元"));
-            settleCountsDay1.Add(new SettleCount("今日汇总", "597/900单", "597元"));
-
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            //settleCounts.Add(new SettleCount("电商首购A级", "200/300单", "200元"));
-            listDay.Add(new ProjectCountPageOutput((long)(ProjectId != 0 ? ProjectId : 416237348180038), !string.IsNullOrEmpty(Date) ? Date : "2023-05-02", "suzhou柿集", settleCountsDay1));
-
-            if(!string.IsNullOrEmpty(Date))
+            foreach (var countDate in listStat)
             {
-                list = listDay;
+                //string.Format("{0:yyyy-MM-dd HH:mm:ss}", m.CreatedTime)
+                string countDateString = string.Format("{0:yyyy-MM-dd}", countDate.SettleDate);
+                //List<SettleCount> settleCounts = new List<SettleCount>();
+                var sr = _projectStatRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
+                    .Where(a => a.ProjectId == ProjectId)
+                    .Where(a => a.EffectDate.ToString().Contains(countDateString))
+                    .ToList(m => new SettleRecord(m.Name,m.ValidCount.ToString(),m.ValidCount.ToString()){});
+
+                List<SettleCount> sc = new List<SettleCount>();
+                long validCount = 0;
+                long Count = 0;
+                long commission = 0;
+                foreach(var item in sr)
+                {
+                    validCount += Convert.ToInt16(item.ValidCount);
+                    Count += Convert.ToInt16( item.Count);
+                    //commission += Convert.ToInt16(item.Commission);
+                    sc.Add(new SettleCount(item.SettleStandard, item.ValidCount + "/" + item.ValidCount));
+                }
+                sc.Add(new SettleCount("汇总", validCount + "/" + Count, "--"));
+
+                list.Add(new ProjectCountPageOutput((long)ProjectId, countDateString, "", sc));
             }
             
 

+ 15 - 0
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -5876,6 +5876,21 @@
             佣金
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.SettleRecord.ValidCount">
+            <summary>
+            有效数
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.SettleRecord.Count">
+            <summary>
+            总数
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.SettleRecord.Commission">
+            <summary>
+            佣金
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ProjectDescOutput.Id">
             <summary>
             ID