Sfoglia il codice sorgente

我的项目接口 项目价格修正

lifa 1 anno fa
parent
commit
d1c55802a4

+ 44 - 20
src/platform/ZhonTai.Admin/Services/DiTuiAPI/ProjectsService.cs

@@ -8,6 +8,7 @@ using System.Linq.Expressions;
 using System.Text;
 using System.Threading.Tasks;
 using ZhonTai.Admin.Core.Attributes;
+using ZhonTai.Admin.Core.Configs;
 using ZhonTai.Admin.Core.Consts;
 using ZhonTai.Admin.Core.Dto;
 using ZhonTai.Admin.Domain.User;
@@ -32,12 +33,20 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         private ProjectRepository _projectRepository;
         private ProjectPriceRepository _projectPriceRepository;
         private ProjectStatRepository _projectStatRepository;
-        public ProjectsService(ProjectLinkRepository projectLinkRepository,ProjectRepository projectRepository,ProjectPriceRepository projectPriceRepository,ProjectStatRepository projectStatRepository)
+        private ProjectConfigRepository _projectConfigRepository;
+
+        public ProjectsService(
+            ProjectLinkRepository projectLinkRepository,
+            ProjectRepository projectRepository,
+            ProjectPriceRepository projectPriceRepository,
+            ProjectStatRepository projectStatRepository,
+            ProjectConfigRepository projectConfigRepository)
         {
             _ProjectLinkRepository = projectLinkRepository;
             _projectRepository = projectRepository;
             _projectPriceRepository = projectPriceRepository;
             _projectStatRepository = projectStatRepository;
+            _projectConfigRepository = projectConfigRepository;
         }
 
         /// <summary>
@@ -62,6 +71,19 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
                     UseCount = m.Sum(m.Value.IsUse == 1 ? 1 : 0),
                     ProjectName = ""
                 });
+            var priceList = await _projectConfigRepository.Select
+                .Where(m=> m.EffectDate < DateTime.Now)
+                .OrderByDescending(m => m.DrawAmount)
+                .GroupBy(m => m.ProjectId)
+                .ToListAsync(
+                    m => new
+                    {
+                        ProjectId = m.Value.ProjectId,
+                        ProjectPriceId = m.Value.ProjectPriceId,
+                        DrawAmount = m.Value.DrawAmount,
+                        EffectDate = m.Value.EffectDate,
+                    }); 
+
 
             var listProjectId = linkList.Select(m => m.ProjectId).Distinct().ToList();
 
@@ -71,30 +93,32 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
                     m.Id,
                     m.Name,
                     m.Logo,
-                    m.MaxPrice.ToString() + "元",
+                    m.MaxPrice.ToString(),
                     "T+" + m.SettleDay.ToString() + "结算"
                 ));
+
+                if(priceList.Count() >0)
+                {
+                    foreach(var priceItem in priceList)
+                    {
+                        foreach (var projectItem in listProject)
+                        {
+                            if(priceItem.ProjectId == projectItem.Id)
+                            {
+                                projectItem.Price = (Convert.ToDecimal(projectItem.Price) - priceItem.DrawAmount).ToString();
+                            }
+                        }
+                    }
+                }
+                foreach(var proItem in listProject)
+                {
+                    proItem.Price = proItem.Price + "元";
+                }
+
+
                 myProjectOutput.MyProjects = listProject;
             }
             return myProjectOutput;
-
-            //List<MyProject> myProjects = new List<MyProject>();
-            //myProjects.Add(new MyProject(
-            //        414497860591685,
-            //         "快手极速版",
-            //        "https://test-dt.zhongjie51.com/assetsImg/ks_logo.png",
-            //        "25元",
-            //        "T+1结算"
-            //    ));
-            //myProjects.Add(new MyProject(
-            //        414497860591687,
-            //         "点淘拉新",
-            //        "https://test-dt.zhongjie51.com/assetsImg/dt_logo.png",
-            //        "30元",
-            //        "T+3结算"
-            //    ));
-            //myProjectOutput.MyProjects = myProjects;
-            //return myProjectOutput;
         }
 
         /// <summary>