Selaa lähdekoodia

项目价格相关接口修复

lifa 1 vuosi sitten
vanhempi
commit
7a5947ce4a

+ 3 - 1
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Dto/ProjectSpecOutput.cs

@@ -27,11 +27,13 @@ namespace ZhonTai.Admin.Services.DiTuiAPI.Dto
     }
     public class ProjectPrice
     {
-        public ProjectPrice(string title,string price)
+        public ProjectPrice(long id, string title,string price)
         {
+            Id = id;
             Title = title;
             Price = price;
         }
+        public long Id { get; set; }
         public string Title { get; set; }
         public string Price { get; set; }
     }

+ 109 - 29
src/platform/ZhonTai.Admin/Services/DiTuiAPI/ProjectsService.cs

@@ -16,6 +16,7 @@ using ZhonTai.Admin.Repositories.Project;
 using ZhonTai.Admin.Repositories.ProjectLink;
 using ZhonTai.Admin.Services.DiTuiAPI.Dto;
 using ZhonTai.Admin.Services.Notice.Dto;
+using ZhonTai.Admin.Services.Project;
 using ZhonTai.Admin.Services.ProjectLink.Dto;
 using ZhonTai.DynamicApi;
 using ZhonTai.DynamicApi.Attributes;
@@ -71,17 +72,18 @@ 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)
+                //.GroupBy(m => m.ProjectId)
                 .ToListAsync(
                     m => new
                     {
-                        ProjectId = m.Value.ProjectId,
-                        ProjectPriceId = m.Value.ProjectPriceId,
-                        DrawAmount = m.Value.DrawAmount,
-                        EffectDate = m.Value.EffectDate,
+                        ProjectId = m.ProjectId,
+                        ProjectPriceId = m.ProjectPriceId,
+                        DrawAmount = m.DrawAmount,
+                        EffectDate = m.EffectDate,
                     }); 
 
 
@@ -93,24 +95,41 @@ 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 projectItem in listProject)
                 {
-                    foreach(var priceItem in priceList)
-                    {
-                        foreach (var projectItem in listProject)
+                    var maxPrice = await _projectPriceRepository
+                        .Select
+                        .DisableGlobalFilter(FilterNames.Tenant)
+                        .Where(m => m.ProjectId == projectItem.Id)
+                        .OrderByDescending(m => m.Price)
+                        .FirstAsync(m => new
                         {
-                            if(priceItem.ProjectId == projectItem.Id)
-                            {
-                                projectItem.Price = (Convert.ToDecimal(projectItem.Price) - priceItem.DrawAmount).ToString();
-                            }
-                        }
+                            ProjectPriceId = m.Id,
+                            ProjectPrice = m.Price
+                        });
+                    var priceConfig = await _projectConfigRepository
+                        .Select
+                        .DisableGlobalFilter(FilterNames.Tenant)
+                        .Where(m => m.ProjectPriceId == maxPrice.ProjectPriceId)
+                        .FirstAsync(m => new
+                        {
+                            DrawAmount = m.DrawAmount
+                        }) ;
+                    if(priceConfig is null)
+                    {
+                        // 未单独设置佣金抽成 默认抽取 5% 取 一位小数
+                        projectItem.Price = (Convert.ToDecimal(projectItem.Price) - ProjectPriceService.GetDrawAmount(Convert.ToDecimal( projectItem.Price),Convert.ToDecimal(5.00))).ToString();
+                    }
+                    else
+                    {
+                        projectItem.Price = (maxPrice.ProjectPrice - priceConfig.DrawAmount).ToString();
                     }
                 }
-                foreach(var proItem in listProject)
+                foreach (var proItem in listProject)
                 {
                     proItem.Price = proItem.Price + "元";
                 }
@@ -139,19 +158,37 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
             
             var result = await _projectRepository.Select.DisableGlobalFilter()
                 .Where(a => a.Id == id)
-                .FirstAsync(a => new ProjectDescOutput(a.Id,a.Logo,a.Name,a.MaxPrice.ToString(),a.SettleDay.ToString(),a.Tips));
-            return result;
+                .FirstAsync(a => new ProjectDescOutput(a.Id,a.Logo,a.Name,"",a.SettleDay.ToString(),a.Tips));
+
+            var maxPrice = await _projectPriceRepository
+                        .Select
+                        .DisableGlobalFilter(FilterNames.Tenant)
+                        .Where(m => m.ProjectId == id)
+                        .OrderByDescending(m => m.Price)
+                        .FirstAsync(m => new
+                        {
+                            ProjectPriceId = m.Id,
+                            ProjectPrice = m.Price
+                        });
 
-            //ProjectDescOutput projectDescOutput = new ProjectDescOutput();
-            //var doubleUser = await _ProjectLinkRepository.Select.Where(a => a.SalesmanPhone == input.SalesmanPhone && a.ProjectId == input.ProjectId)
-            //    .FirstAsync(a => new { a.Salesman, a.SalesmanPhone, a.Id });
-            //projectDescOutput.Id = result.Id;
-            //projectDescOutput.Logo = result.Logo;
-            //projectDescOutput.Name = "快手极速版";
-            //projectDescOutput.Price = "25";
-            //projectDescOutput.SettleDay = "T+1结算";
-            //projectDescOutput.Description = "快手极速版APP的新用户,全国可做不限推广方式,实时进件数据,不测次播,官方直推版。";
-            //return projectDescOutput;
+            var priceConfig = await _projectConfigRepository
+                .Select
+                .DisableGlobalFilter(FilterNames.Tenant)
+                .Where(m => m.ProjectPriceId == maxPrice.ProjectPriceId)
+                .FirstAsync(m => new
+                {
+                    DrawAmount = m.DrawAmount
+                });
+            if (priceConfig is null)
+            {
+                // 未单独设置佣金抽成 默认抽取 5% 取 一位小数
+                result.Price = (Convert.ToDecimal(maxPrice.ProjectPrice) - ProjectPriceService.GetDrawAmount(Convert.ToDecimal(maxPrice.ProjectPrice), Convert.ToDecimal(5.00))).ToString();
+            }
+            else
+            {
+                result.Price = (maxPrice.ProjectPrice - priceConfig.DrawAmount).ToString();
+            }
+            return result;
         }
 
         /// <summary>
@@ -175,10 +212,53 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
             result.Prices = await _projectPriceRepository.Select.DisableGlobalFilter()
                 .Where(a => a.ProjectId == id)
                 .ToListAsync(a => new ProjectPrice(
+                        a.Id,
                         a.Name,
                         a.Price.ToString()
                     ));
 
+            var priceList = await _projectConfigRepository.Select
+                .Where(m => m.EffectDate < DateTime.Now)
+                .Where(m => m.ProjectId == id)
+                .OrderByDescending(m => m.DrawAmount)
+                .ToListAsync(
+                    m => new
+                    {
+                        ProjectId = m.ProjectId,
+                        ProjectPriceId = m.ProjectPriceId,
+                        DrawAmount = m.DrawAmount,
+                        EffectDate = m.EffectDate,
+                    });
+            if(priceList.Count() == 0)
+            {
+                foreach (var priceItem in result.Prices)
+                {
+                    priceItem.Price = (Convert.ToDecimal(priceItem.Price) - ProjectPriceService.GetDrawAmount(Convert.ToDecimal(priceItem.Price), Convert.ToDecimal(5.00))).ToString();                  
+                }
+            }
+            else
+            {
+                foreach (var item in priceList)
+                {
+                    foreach (var priceItem in result.Prices)
+                    {
+                        if (item.ProjectPriceId == priceItem.Id)
+                        {
+                            priceItem.Price = (Convert.ToDecimal(priceItem.Price) - item.DrawAmount).ToString();
+                        }
+                        else
+                        {
+                            priceItem.Price = (Convert.ToDecimal(priceItem.Price) - ProjectPriceService.GetDrawAmount(Convert.ToDecimal(priceItem.Price), Convert.ToDecimal(5.00))).ToString();
+                        }
+                    }
+
+                }
+            }
+
+            
+
+
+
             return result;
 
 

+ 1 - 2
src/platform/ZhonTai.Admin/Services/Project/ProjectPriceService.cs

@@ -370,8 +370,7 @@ namespace ZhonTai.Admin.Services.Project
         /// <summary>
         /// 抽成金额
         /// </summary>
-
-        private decimal GetDrawAmount(decimal price, decimal ratio)
+        public static decimal GetDrawAmount(decimal price, decimal ratio)
         {
             var amount = UtilConvertExtension.ToDecimalCutWithN(price * ratio * 0.01m, 0, 1);
             return amount;

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

@@ -3354,6 +3354,21 @@
             结算时间
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Domain.Project.ProjectStatEntity.CompanyCommission">
+            <summary>
+            公司佣金
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Domain.Project.ProjectStatEntity.TenantCommission">
+            <summary>
+            平台佣金
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Domain.Project.ProjectStatEntity.TenantyRatio">
+            <summary>
+            平台比率
+            </summary>
+        </member>
         <member name="T:ZhonTai.Admin.Domain.RoleOrgEntity">
             <summary>
             角色部门
@@ -8206,6 +8221,14 @@
             <param name="EffecDate">状态 2上架 3下架 4暂停</param>
              <returns></returns>    
         </member>
+        <member name="M:ZhonTai.Admin.Services.ProjectStat.ProjectStatService.GetCommission(System.Decimal,System.Decimal,System.Int32)">
+            <summary>
+            获取佣金
+            </summary>
+            <param name="price">项目价格</param>
+            <param name="ratio">公司抽成比率,抽成方式是2,则抽成金额</param>
+            <param name="drawType">抽成方式1比率 2佣金</param>
+        </member>
         <member name="P:ZhonTai.Admin.Services.Project.Dto.CompanyDrawInput.DrawRatio">
             <summary>
             抽成比例