浏览代码

项目设价

zmq 2 年之前
父节点
当前提交
cd604ddcbd

+ 9 - 1
src/platform/ZhonTai.Admin/Domain/Project/ProjectConfigEntity.cs

@@ -23,6 +23,10 @@ namespace ZhonTai.Admin.Domain.Project
         /// </summary>
         /// </summary>
         public long ProjectPriceId { get; set; }
         public long ProjectPriceId { get; set; }
         /// <summary>
         /// <summary>
+        /// 抽成方式 1抽成比例 2抽成金额
+        /// </summary>
+        public int DrawWay { get; set; }
+        /// <summary>
         /// 抽成比例
         /// 抽成比例
         /// </summary>
         /// </summary>
         public decimal DrawRatio { get; set; }
         public decimal DrawRatio { get; set; }
@@ -33,10 +37,14 @@ namespace ZhonTai.Admin.Domain.Project
         /// <summary>
         /// <summary>
         /// 生效时间
         /// 生效时间
         /// </summary>        
         /// </summary>        
-        public DateTime EffectDate { get; set; }
+        public DateTime? EffectDate { get; set; }
         /// <summary>
         /// <summary>
         /// 状态 1正常 2失效
         /// 状态 1正常 2失效
         /// </summary>
         /// </summary>
         public int Status { get; set; }
         public int Status { get; set; }
+        /// <summary>
+        /// 1公司抽成 2项目抽成 3租户抽成
+        /// </summary>
+        public int DrawType { get; set; }
     }
     }
 }
 }

+ 0 - 14
src/platform/ZhonTai.Admin/Domain/ProjectAndTenant/IProjectAndTenantRepository.cs

@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZhonTai.Admin.Core.Repositories;
-using ZhonTai.Admin.Domain.TenantPkg;
-
-namespace ZhonTai.Admin.Domain.ProjectAndTenant
-{    
-    public interface IProjectAndTenantRepository : IRepositoryBase<ProjectAndTenantEntity>
-    {
-    }
-}

+ 0 - 33
src/platform/ZhonTai.Admin/Domain/ProjectAndTenant/ProjectAndTenantEntity.cs

@@ -1,33 +0,0 @@
-using FreeSql.DataAnnotations;
-using NPOI.SS.Formula.PTG;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZhonTai.Admin.Core.Entities;
-
-namespace ZhonTai.Admin.Domain.ProjectAndTenant
-{
-
-    /// <summary>
-    /// 平台项目价格
-    /// </summary>
-    [Table(Name = "ditui_tenant_project_price")]
-    [Index("idx_{tablename}_01", nameof(TenantId) + "," + nameof(ProjectId), true)]
-    public partial class ProjectAndTenantEntity : EntityTenant {
-        public long ProjectId { get; set; }
-        public long ProjectPriceId { get; set; }
-        public int DrawPriceWay { get; set; }
-        public decimal DrawRatio { get; set; }
-        public decimal DrawPrice { get; set; }
-        /// <summary>
-        /// 生效时间
-        /// </summary>
-        public DateTime EffectDate { get; set; }
-        /// <summary>
-        /// 1整体抽成 2项目抽成 3租户抽成
-        /// </summary>
-        public int SetType { get; set; }
-    }    
-}

+ 0 - 19
src/platform/ZhonTai.Admin/Repositories/ProjectAndTenant/ProjectAndTenantRepository.cs

@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZhonTai.Admin.Core.Db.Transaction;
-using ZhonTai.Admin.Domain.ProjectAndTenant;
-using ZhonTai.Admin.Domain.ProjectLink;
-
-namespace ZhonTai.Admin.Repositories.ProjectAndTenant
-{    
-    public class ProjectAndTenantRepository : AdminRepositoryBase<ProjectAndTenantEntity>, IProjectAndTenantRepository
-    {
-        public ProjectAndTenantRepository(UnitOfWorkManagerCloud muowm) : base(muowm)
-        {
-
-        }
-    }
-}

+ 2 - 0
src/platform/ZhonTai.Admin/Services/Project/Dto/PriceSetInput.cs

@@ -12,5 +12,7 @@ namespace ZhonTai.Admin.Services.Project.Dto
         public int DrawPriceWay { get; set; }
         public int DrawPriceWay { get; set; }
         public decimal DrawRatio { get; set; }
         public decimal DrawRatio { get; set; }
         public decimal DrawPrice { get; set; }
         public decimal DrawPrice { get; set; }
+        public DateTime? EffectDate { get; set; }
+        
     }
     }
 }
 }

+ 1 - 1
src/platform/ZhonTai.Admin/Services/Project/Dto/ProjectDrawOutput.cs

@@ -19,6 +19,6 @@ namespace ZhonTai.Admin.Services.Project.Dto
         /// <summary>
         /// <summary>
         /// 下次抽成比例生效时间
         /// 下次抽成比例生效时间
         /// </summary>
         /// </summary>
-        public DateTime NextEffectDate { get; set; }
+        public DateTime? NextEffectDate { get; set; }
     }
     }
 }
 }

+ 6 - 4
src/platform/ZhonTai.Admin/Services/ProjectAndTenant/Dto/ProjectAndTenantSetInput.cs → src/platform/ZhonTai.Admin/Services/Project/Dto/TenantDrawSetInput.cs

@@ -5,16 +5,18 @@ using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace ZhonTai.Admin.Services.ProjectAndTenant.Dto
+namespace ZhonTai.Admin.Services.Project.Dto
 {
 {
-    public class ProjectAndTenantSetInput
+    public class TenantDrawSetInput
     {
     {
         [Required]
         [Required]
         public long TenatntId { get; set; }
         public long TenatntId { get; set; }
-        public long ProjectPriceId { get; set; }        
-        public long Id { get; set; }
+        public long ProjectPriceId { get; set; }
+        public long ProjectId { get; set; }
         public int DrawPriceWay { get; set; }
         public int DrawPriceWay { get; set; }
         public decimal DrawRatio { get; set; }
         public decimal DrawRatio { get; set; }
         public decimal DrawPrice { get; set; }
         public decimal DrawPrice { get; set; }
+        public DateTime? EffectDate { get; set; }
+        
     }
     }
 }
 }

+ 2 - 3
src/platform/ZhonTai.Admin/Services/ProjectAndTenant/Dto/ProjectAndTenantGetPageInput.cs → src/platform/ZhonTai.Admin/Services/Project/Dto/TenantPriceGetPageInput.cs

@@ -5,11 +5,10 @@ using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace ZhonTai.Admin.Services.ProjectAndTenant.Dto
+namespace ZhonTai.Admin.Services.Project.Dto
 {
 {
-    public class ProjectAndTenantGetPageInput
+    public class TenantPriceGetPageInput
     {
     {
-
         [Required]
         [Required]
         public long ProjectId { get; set; }
         public long ProjectId { get; set; }
     }
     }

+ 8 - 9
src/platform/ZhonTai.Admin/Services/ProjectAndTenant/Dto/ProjectAndTenatntGetPageOutput.cs → src/platform/ZhonTai.Admin/Services/Project/Dto/TenantPriceGetPageOutput.cs

@@ -3,24 +3,23 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using ZhonTai.Admin.Services.Project.Dto;
 
 
-namespace ZhonTai.Admin.Services.ProjectAndTenant.Dto
+namespace ZhonTai.Admin.Services.Project.Dto
 {
 {
-    public class ProjectAndTenatntGetPageOutput
+    public class TenantPriceGetPageOutput
     {
     {
-        public long Id { get; set; }        
+        public long Id { get; set; }
         public string Name { get; set; }
         public string Name { get; set; }
-        public List<ProjectAndTenatntGetPageOutput_Price> prices { get; set; }
+        public List<TenantPriceGetPageOutput_Price> prices { get; set; }
     }
     }
-    public class ProjectAndTenatntGetPageOutput_Price
+    public class TenantPriceGetPageOutput_Price
     {
     {
-        public long Id { get; set; }
+        public long ProjectId { get; set; }        
         public long ProjectPriceId { get; set; }
         public long ProjectPriceId { get; set; }
         public string Name { get; set; }
         public string Name { get; set; }
-        public decimal Price { get; set; }        
+        public decimal Price { get; set; }
         public int DrawPriceWay { get; set; }
         public int DrawPriceWay { get; set; }
         public decimal DrawRatio { get; set; }
         public decimal DrawRatio { get; set; }
         public decimal DrawPrice { get; set; }
         public decimal DrawPrice { get; set; }
     }
     }
-}
+}

+ 196 - 24
src/platform/ZhonTai.Admin/Services/Project/ProjectPriceService.cs

@@ -7,7 +7,9 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using ZhonTai.Admin.Core.Consts;
 using ZhonTai.Admin.Core.Consts;
 using ZhonTai.Admin.Core.Dto;
 using ZhonTai.Admin.Core.Dto;
+using ZhonTai.Admin.Domain.Org;
 using ZhonTai.Admin.Domain.Project;
 using ZhonTai.Admin.Domain.Project;
+using ZhonTai.Admin.Domain.Tenant;
 using ZhonTai.Admin.Services.Project.Dto;
 using ZhonTai.Admin.Services.Project.Dto;
 using ZhonTai.Common.Extensions;
 using ZhonTai.Common.Extensions;
 using ZhonTai.DynamicApi;
 using ZhonTai.DynamicApi;
@@ -25,12 +27,16 @@ namespace ZhonTai.Admin.Services.Project
         private readonly IProjectRepository _projectRepository;
         private readonly IProjectRepository _projectRepository;
         private readonly IProjectPriceRepository _projectPriceRepository;
         private readonly IProjectPriceRepository _projectPriceRepository;
         private readonly IProjectConfigRepository _projectConfigRepository;
         private readonly IProjectConfigRepository _projectConfigRepository;
+        private readonly IOrgRepository _orgRepository;
+        private readonly ITenantRepository _tenantRepository;
 
 
-        public ProjectPriceService(IProjectRepository projectRepository, IProjectPriceRepository projectPriceRepository, IProjectConfigRepository projectConfigRepository)
+        public ProjectPriceService(IProjectRepository projectRepository, IProjectPriceRepository projectPriceRepository, IProjectConfigRepository projectConfigRepository, IOrgRepository orgRepository, ITenantRepository tenantRepository)
         {
         {
             _projectRepository = projectRepository;
             _projectRepository = projectRepository;
             _projectPriceRepository = projectPriceRepository;
             _projectPriceRepository = projectPriceRepository;
             _projectConfigRepository = projectConfigRepository;
             _projectConfigRepository = projectConfigRepository;
+            _orgRepository = orgRepository;
+            _tenantRepository = tenantRepository;
         }
         }
         #region 公司默认抽成比例
         #region 公司默认抽成比例
         /// <summary>
         /// <summary>
@@ -78,7 +84,7 @@ namespace ZhonTai.Admin.Services.Project
             CheckDrawRatioEffect(input.EffectDate);
             CheckDrawRatioEffect(input.EffectDate);
 
 
             //删除旧的未生效记录
             //删除旧的未生效记录
-            var listDeleteId = await _projectConfigRepository.Select.Where(m => m.ProjectId == 0 && m.ProjectPriceId == 0 && m.Status == 1 && m.EffectDate > DateTime.Today)
+            var listDeleteId = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.DrawType == 1 && m.ProjectId == 0 && m.ProjectPriceId == 0 && m.Status == 1 && m.EffectDate > DateTime.Today)
             .ToListAsync(m => m.Id);
             .ToListAsync(m => m.Id);
             if (listDeleteId.Count > 0)
             if (listDeleteId.Count > 0)
             {
             {
@@ -91,12 +97,15 @@ namespace ZhonTai.Admin.Services.Project
                 ProjectPriceId = 0,
                 ProjectPriceId = 0,
                 DrawRatio = input.DrawRatio,
                 DrawRatio = input.DrawRatio,
                 EffectDate = input.EffectDate,
                 EffectDate = input.EffectDate,
-                Status = 1
+                Status = 1,
+                DrawType = 1,
+                DrawWay = 1,
+                TenantId = 0
             });
             });
         }
         }
         #endregion
         #endregion
 
 
-        #region 项目抽成比例
+        #region 公司设置项目抽成比例
         /// <summary>
         /// <summary>
         /// 查询项目分页
         /// 查询项目分页
         /// </summary>
         /// </summary>
@@ -139,21 +148,16 @@ namespace ZhonTai.Admin.Services.Project
             {
             {
                 throw ResultOutput.Exception("信息不存在,请刷新后重试!");
                 throw ResultOutput.Exception("信息不存在,请刷新后重试!");
             }
             }
+            if (!new int[] { 1, 2 }.Contains(input.DrawPriceWay))
+            {
+                throw ResultOutput.Exception("无效的设价方式!");
+            }
+            decimal amount = input.DrawPrice;
             if (input.DrawPriceWay == 1)
             if (input.DrawPriceWay == 1)
             {
             {
-                //抽成比例
-                if (input.DrawRatio < 0 || input.DrawRatio > 100)
-                {
-                    throw ResultOutput.Exception("抽成比例有效范围在0-100");
-                }
-                var amount = UtilConvertExtension.ToDecimalCutWithN(price.Price * input.DrawRatio * 0.01m, 0, 1);
-                await _projectPriceRepository.UpdateDiy.SetSource(new ProjectPriceEntity()
-                {
-                    DrawPriceWay = input.DrawPriceWay,
-                    DrawRatio = input.DrawRatio,
-                    DrawPrice = amount,
-                    Id = price.Id
-                }).UpdateColumns(a => new { a.DrawPriceWay, a.DrawRatio, a.DrawPrice, a.ModifiedTime }).ExecuteAffrowsAsync();
+                CheckDrawRatio(input.DrawRatio);
+
+                amount = GetDrawAmount(price.Price, input.DrawRatio);
             }
             }
             else if (input.DrawPriceWay == 2)
             else if (input.DrawPriceWay == 2)
             {
             {
@@ -162,18 +166,177 @@ namespace ZhonTai.Admin.Services.Project
                 {
                 {
                     throw ResultOutput.Exception("设置有效的抽成金额");
                     throw ResultOutput.Exception("设置有效的抽成金额");
                 }
                 }
-                await _projectPriceRepository.UpdateDiy.SetSource(new ProjectPriceEntity()
+            }
+            //覆盖已经存在未生效的
+            var listDeleteId = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == price.ProjectId && m.ProjectPriceId == price.Id && m.Status == 1 && m.EffectDate > DateTime.Today && m.DrawType == 2)
+           .ToListAsync(m => m.Id);
+            if (listDeleteId.Count > 0)
+            {
+                await _projectConfigRepository.SoftDeleteAsync(m => listDeleteId.Contains(m.Id));
+            }
+
+            //新增
+            var effectDate = input.EffectDate.HasValue ? input.EffectDate : DateTime.Today.AddDays(1);
+            await _projectConfigRepository.InsertAsync(new ProjectConfigEntity()
+            {
+                ProjectId = price.ProjectId,
+                ProjectPriceId = price.Id,
+                Status = 1,
+                DrawWay = input.DrawPriceWay,
+                DrawRatio = input.DrawRatio,
+                DrawAmount = amount,
+                EffectDate = effectDate,
+                DrawType = 2,
+                TenantId = 0
+            });
+            return 1;
+        }
+        #endregion
+
+        #region 公司设置平台抽成比例
+        /// <summary>
+        /// 查询平台单独设价分页
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<PageOutput<TenantPriceGetPageOutput>> GetTenantDrawPageAsync(PageInput<TenantPriceGetPageInput> input)
+        {
+            var projectId = input?.Filter?.ProjectId;
+            if (!projectId.HasValue)
+            {
+                projectId = 0;
+            }
+            //项目价格信息
+            var projectprice = _projectPriceRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == projectId).ToList(m => new
+            {
+                m.Id,
+                m.Name,
+                m.Price
+            });
+            //平台信息
+            var list = await _orgRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
+            .Count(out var total)
+            .OrderByDescending(true, a => a.Id)
+            .Page(input.CurrentPage, input.PageSize)
+            .ToListAsync(a => new TenantPriceGetPageOutput()
+            {
+                Id = a.TenantId.Value,
+                Name = a.Name,
+                prices = _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == projectId && m.TenantId == a.TenantId && m.Status == 1 & m.DrawType == 3).ToList<TenantPriceGetPageOutput_Price>()
+            });
+            //项目信息同平台信息合并
+            foreach (var item in list)
+            {
+                List<TenantPriceGetPageOutput_Price> prices = new List<TenantPriceGetPageOutput_Price>();
+                foreach (var it in projectprice)
                 {
                 {
-                    DrawPriceWay = input.DrawPriceWay,
-                    DrawRatio = 0,
-                    DrawPrice = input.DrawPrice,
-                    Id = price.Id
-                }).UpdateColumns(a => new { a.DrawPriceWay, a.DrawRatio, a.DrawPrice, a.ModifiedTime }).ExecuteAffrowsAsync(); ;
+                    var tprice = item.prices.Where(m => m.ProjectPriceId == it.Id).FirstOrDefault();
+                    if (tprice != null)
+                    {
+                        prices.Add(new TenantPriceGetPageOutput_Price()
+                        {
+                            ProjectId = tprice.ProjectId,
+                            ProjectPriceId = tprice.ProjectPriceId,
+                            Name = it.Name,
+                            Price = it.Price,
+                            DrawPriceWay = tprice.DrawPriceWay,
+                            DrawRatio = tprice.DrawRatio,
+                            DrawPrice = tprice.DrawPrice
+                        });
+                    }
+                    else
+                    {
+                        prices.Add(new TenantPriceGetPageOutput_Price()
+                        {
+                            ProjectId = projectId.Value,
+                            ProjectPriceId = it.Id,
+                            Name = it.Name,
+                            Price = it.Price,
+                            DrawPriceWay = 0
+                        });
+                    }
+                }
+                item.prices = prices;
             }
             }
-            else
+
+            var data = new PageOutput<TenantPriceGetPageOutput>()
+            {
+                List = Mapper.Map<List<TenantPriceGetPageOutput>>(list),
+                Total = total
+            };
+
+            return data;
+        }
+        /// <summary>
+        /// 平台项目设置价格
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<long> SetTenantDrawAsync(TenantDrawSetInput input)
+        {
+            if (!new[] { 1, 2 }.Contains(input.DrawPriceWay))
             {
             {
                 throw ResultOutput.Exception("无效的设价方式!");
                 throw ResultOutput.Exception("无效的设价方式!");
             }
             }
+            //验证平台是否存在
+            var tenant = await _tenantRepository.GetAsync(input.TenatntId);
+            if (!(tenant?.Id > 0))
+            {
+                throw ResultOutput.Exception("平台不存在,请刷新后重试!");
+            }
+
+            //验证项目价格信息是否存在
+            var price = await _projectPriceRepository.GetAsync(input.ProjectPriceId);
+            if (!(price?.Id > 0))
+            {
+                throw ResultOutput.Exception("项目信息不存在,请刷新后重试!");
+            }
+           
+            var amount = input.DrawPrice;
+            if (input.DrawPriceWay == 1)
+            {
+                //抽成比例
+                CheckDrawRatio(input.DrawRatio);
+
+                amount = GetDrawAmount(price.Price, input.DrawRatio);
+
+            }
+            else if (input.DrawPriceWay == 2)
+            {
+                //抽成金额
+                if (input.DrawPrice > price.Price || input.DrawPrice < 0)
+                {
+                    throw ResultOutput.Exception("设置有效的抽成金额");
+                }               
+
+            }
+
+            //覆盖已经存在未生效的
+            var listDeleteId = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == price.ProjectId && m.ProjectPriceId == price.Id && m.Status == 1 && m.EffectDate > DateTime.Today && m.DrawType == 3)
+           .ToListAsync(m => m.Id);
+            if (listDeleteId.Count > 0)
+            {
+                await _projectConfigRepository.SoftDeleteAsync(m => listDeleteId.Contains(m.Id));
+            }
+
+            //新增
+            var effectDate = input.EffectDate.HasValue ? input.EffectDate : DateTime.Today.AddDays(1);
+            await _projectConfigRepository.InsertAsync(new ProjectConfigEntity()
+            {
+                ProjectId = price.ProjectId,
+                ProjectPriceId = price.Id,
+                Status = 1,
+                DrawWay = input.DrawPriceWay,
+                DrawRatio = input.DrawRatio,
+                DrawAmount = amount,
+                EffectDate = effectDate,
+                DrawType = 3,
+                TenantId = input.TenatntId
+            });
+
+
             return 1;
             return 1;
         }
         }
         #endregion
         #endregion
@@ -205,6 +368,15 @@ namespace ZhonTai.Admin.Services.Project
             }
             }
         }
         }
         /// <summary>
         /// <summary>
+        /// 抽成金额
+        /// </summary>
+
+        private decimal GetDrawAmount(decimal price, decimal ratio)
+        {
+            var amount = UtilConvertExtension.ToDecimalCutWithN(price * ratio * 0.01m, 0, 1);
+            return amount;
+        }
+        /// <summary>
         /// 初始化公司抽成信息
         /// 初始化公司抽成信息
         /// </summary>        
         /// </summary>        
         /// <returns></returns>
         /// <returns></returns>

+ 0 - 12
src/platform/ZhonTai.Admin/Services/ProjectAndTenant/IProjectAndTenantService.cs

@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ZhonTai.Admin.Services.ProjectAndTenant
-{
-    internal class IProjectAndTenantService
-    {
-    }
-}

+ 0 - 252
src/platform/ZhonTai.Admin/Services/ProjectAndTenant/ProjectAndTenantService.cs

@@ -1,252 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using NPOI.SS.Formula.PTG;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZhonTai.Admin.Core.Consts;
-using ZhonTai.Admin.Core.Dto;
-using ZhonTai.Admin.Domain.Project;
-using ZhonTai.Admin.Services.Project.Dto;
-using ZhonTai.Admin.Services.Project;
-using ZhonTai.Common.Extensions;
-using ZhonTai.DynamicApi.Attributes;
-using ZhonTai.DynamicApi;
-using ZhonTai.Admin.Domain.ProjectAndTenant;
-using ZhonTai.Admin.Domain.Org;
-using ZhonTai.Admin.Services.ProjectAndTenant.Dto;
-using NPOI.SS.Formula.Functions;
-
-namespace ZhonTai.Admin.Services.ProjectAndTenant
-{
-    /// <summary>
-    /// 平台项目价格设置服务
-    /// </summary>
-    [Order(10)]
-    [DynamicApi(Area = AdminConsts.AreaName)]
-    public partial class ProjectAndTenantService : BaseService, IProjectService, IDynamicApi
-    {
-        private readonly IProjectPriceRepository _projectPriceRepository;
-        private readonly IProjectAndTenantRepository _projectAndTenantRepository;
-        private readonly IOrgRepository _orgRepository;
-
-        public ProjectAndTenantService(IProjectPriceRepository projectPriceRepository, IProjectAndTenantRepository projectAndTenantRepository, IOrgRepository orgRepository)
-        {
-            _projectPriceRepository = projectPriceRepository;
-            _projectAndTenantRepository = projectAndTenantRepository;
-            _orgRepository = orgRepository;
-        }
-
-        /// <summary>
-        /// 查询分页
-        /// </summary>
-        /// <param name="input"></param>
-        /// <returns></returns>
-        [HttpPost]
-        public async Task<PageOutput<ProjectAndTenatntGetPageOutput>> GetPageAsync(PageInput<ProjectAndTenantGetPageInput> input)
-        {
-            var projectId = input?.Filter?.ProjectId;
-            if (!projectId.HasValue)
-            {
-                projectId = 0;
-            }
-            var projectprice = _projectPriceRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == projectId).ToList(m => new
-            {
-                m.Id,
-                m.Name,
-                m.Price
-            });
-            var list = await _orgRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
-            .Count(out var total)
-            .OrderByDescending(true, a => a.Id)
-            .Page(input.CurrentPage, input.PageSize)
-            .ToListAsync(a => new ProjectAndTenatntGetPageOutput()
-            {
-                Id = a.TenantId.Value,
-                Name = a.Name,
-                prices = _projectAndTenantRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == projectId && m.TenantId == a.TenantId).ToList<ProjectAndTenatntGetPageOutput_Price>()
-            });
-
-            foreach (var item in list)
-            {
-                List<ProjectAndTenatntGetPageOutput_Price> prices = new List<ProjectAndTenatntGetPageOutput_Price>();
-                foreach (var it in projectprice)
-                {
-                    var tprice = item.prices.Where(m => m.ProjectPriceId == it.Id).FirstOrDefault();
-                    if (tprice != null)
-                    {
-                        prices.Add(new ProjectAndTenatntGetPageOutput_Price()
-                        {
-                            Id = tprice.Id,
-                            Name = it.Name,
-                            Price = it.Price,
-                            ProjectPriceId = tprice.ProjectPriceId,
-                            DrawPriceWay = tprice.DrawPriceWay,
-                            DrawRatio = tprice.DrawRatio,
-                            DrawPrice = tprice.DrawPrice
-                        });
-                    }
-                    else
-                    {
-                        prices.Add(new ProjectAndTenatntGetPageOutput_Price()
-                        {
-                            Id = 0,
-                            Name = it.Name,
-                            Price = it.Price,
-                            ProjectPriceId = it.Id,
-                            DrawPriceWay = 0
-                        });
-                    }
-                }
-                item.prices = prices;
-            }
-
-            var data = new PageOutput<ProjectAndTenatntGetPageOutput>()
-            {
-                List = Mapper.Map<List<ProjectAndTenatntGetPageOutput>>(list),
-                Total = total
-            };
-
-            return data;
-        }
-        /// <summary>
-        /// 平台项目设置价格
-        /// </summary>
-        /// <param name="input"></param>
-        /// <returns></returns>
-        [HttpPost]
-        public async Task<long> SetPriceAsync(ProjectAndTenantSetInput input)
-        {
-            ProjectAndTenantEntity tprice = new ProjectAndTenantEntity();
-            if (input.Id > 0)
-            {
-                tprice = await _projectAndTenantRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.Id == input.Id).ToOneAsync();
-                if (tprice == null)
-                {
-                    throw ResultOutput.Exception("信息不存在,请刷新后重试!");
-                }
-            }
-            else {
-                tprice = await _projectAndTenantRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.TenantId == input.TenatntId && m.ProjectPriceId == input.ProjectPriceId).FirstAsync();                
-            }
-            //验证项目价格信息是否存在
-            var price = await _projectPriceRepository.GetAsync(input.ProjectPriceId);
-            if (!(price?.Id > 0))
-            {
-                throw ResultOutput.Exception("项目信息不存在,请刷新后重试!");
-            }
-
-            if (input.DrawPriceWay == 1)
-            {
-                //抽成比例
-                if (input.DrawRatio < 0 || input.DrawRatio > 100)
-                {
-                    throw ResultOutput.Exception("抽成比例有效范围在0-100");
-                }
-                var amount = UtilConvertExtension.ToDecimalCutWithN(price.Price * input.DrawRatio * 0.01m, 0, 1);
-                if (tprice != null)
-                {
-                    await _projectAndTenantRepository.UpdateDiy.DisableGlobalFilter(FilterNames.Tenant).SetSource(new ProjectAndTenantEntity()
-                    {
-                        DrawPriceWay = input.DrawPriceWay,
-                        DrawRatio = input.DrawRatio,
-                        DrawPrice = amount,
-                        Id = tprice.Id                       
-                    }).UpdateColumns(a => new { a.DrawPriceWay, a.DrawRatio, a.DrawPrice, a.ModifiedTime }).ExecuteAffrowsAsync();
-                }
-                else
-                {
-                    await _projectAndTenantRepository.InsertAsync(new ProjectAndTenantEntity()
-                    {
-                        DrawPriceWay = input.DrawPriceWay,
-                        DrawRatio = input.DrawRatio,
-                        DrawPrice = amount,
-                        TenantId = input.TenatntId,
-                        ProjectId = price.ProjectId,
-                        ProjectPriceId = price.Id
-                    });
-                }
-
-            }
-            else if (input.DrawPriceWay == 2)
-            {
-                if (tprice != null)
-                {
-                    //抽成金额
-                    if (input.DrawPrice > price.Price || input.DrawPrice < 0)
-                    {
-                        throw ResultOutput.Exception("设置有效的抽成金额");
-                    }
-                    await _projectAndTenantRepository.UpdateDiy.DisableGlobalFilter(FilterNames.Tenant).SetSource(new ProjectAndTenantEntity()
-                    {
-                        DrawPriceWay = input.DrawPriceWay,
-                        DrawRatio = 0,
-                        DrawPrice = input.DrawPrice,
-                        Id = tprice.Id                        
-                    }).UpdateColumns(a => new { a.DrawPriceWay, a.DrawRatio, a.DrawPrice, a.ModifiedTime }).ExecuteAffrowsAsync();
-                }
-                else
-                {
-                    await _projectAndTenantRepository.InsertAsync(new ProjectAndTenantEntity()
-                    {
-                        DrawPriceWay = input.DrawPriceWay,
-                        DrawRatio = 0,
-                        DrawPrice = input.DrawPrice,
-                        TenantId = input.TenatntId,
-                        ProjectId = price.ProjectId,
-                        ProjectPriceId = price.Id
-                    });
-                }
-            }
-            else
-            {
-                throw ResultOutput.Exception("无效的设价方式!");
-            }
-            return 1;
-        }
-        /// <summary>
-        /// 初始化抽成信息
-        /// </summary>        
-        /// <returns></returns>
-        public async Task<long> SetPriceInitAsync()
-        {
-            ProjectAndTenantEntity tprice = new ProjectAndTenantEntity();
-            var count= await _projectAndTenantRepository.Select.Where(m => m.SetType == 1).CountAsync();
-            if (count<=0)
-            {
-                await _projectAndTenantRepository.InsertAsync(new ProjectAndTenantEntity()
-                {
-                    ProjectId = 0,
-                    ProjectPriceId = 0,
-                    SetType = 1,
-                    EffectDate = DateTime.Now,
-                    TenantId = 0,
-                });
-            }           
-            return 1;
-        }
-        /// <summary>
-        /// 整体抽成更新
-        /// </summary>        
-        /// <returns></returns>
-        public async Task<long> SetPriceUpdateToGlobalAsync()
-        {
-            ProjectAndTenantEntity tprice = new ProjectAndTenantEntity();
-            var project = await _projectAndTenantRepository.Select.Where(m => m.SetType == 1).ToOneAsync();
-            //if (count > 0)
-            //{
-            //    await _projectAndTenantRepository.UpdateAsync(new ProjectAndTenantEntity()
-            //    {
-            //        ProjectId = 0,
-            //        ProjectPriceId = 0,
-            //        SetType = 1,
-            //        EffectDate = DateTime.Now,
-            //        TenantId = -1,
-            //    });
-            //}
-         
-            return 1;
-        }
-    }
-}

+ 29 - 46
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -2984,21 +2984,6 @@
             邀请码
             邀请码
             </summary>
             </summary>
         </member>
         </member>
-        <member name="T:ZhonTai.Admin.Domain.ProjectAndTenant.ProjectAndTenantEntity">
-            <summary>
-            平台项目价格
-            </summary>
-        </member>
-        <member name="P:ZhonTai.Admin.Domain.ProjectAndTenant.ProjectAndTenantEntity.EffectDate">
-            <summary>
-            生效时间
-            </summary>
-        </member>
-        <member name="P:ZhonTai.Admin.Domain.ProjectAndTenant.ProjectAndTenantEntity.SetType">
-            <summary>
-            1整体抽成 2项目抽成 3租户抽成
-            </summary>
-        </member>
         <member name="T:ZhonTai.Admin.Domain.ProjectLink.ProjectLinkEntity">
         <member name="T:ZhonTai.Admin.Domain.ProjectLink.ProjectLinkEntity">
             <summary>
             <summary>
             推广码
             推广码
@@ -3094,6 +3079,11 @@
             项目价格Id
             项目价格Id
             </summary>
             </summary>
         </member>
         </member>
+        <member name="P:ZhonTai.Admin.Domain.Project.ProjectConfigEntity.DrawWay">
+            <summary>
+            抽成方式 1抽成比例 2抽成金额
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Domain.Project.ProjectConfigEntity.DrawRatio">
         <member name="P:ZhonTai.Admin.Domain.Project.ProjectConfigEntity.DrawRatio">
             <summary>
             <summary>
             抽成比例
             抽成比例
@@ -3114,6 +3104,11 @@
             状态 1正常 2失效
             状态 1正常 2失效
             </summary>
             </summary>
         </member>
         </member>
+        <member name="P:ZhonTai.Admin.Domain.Project.ProjectConfigEntity.DrawType">
+            <summary>
+            1公司抽成 2项目抽成 3租户抽成
+            </summary>
+        </member>
         <member name="T:ZhonTai.Admin.Domain.Project.ProjectEntity">
         <member name="T:ZhonTai.Admin.Domain.Project.ProjectEntity">
             <summary>
             <summary>
             拉新项目
             拉新项目
@@ -7593,37 +7588,6 @@
             映射配置
             映射配置
             </summary>
             </summary>
         </member>
         </member>
-        <member name="T:ZhonTai.Admin.Services.ProjectAndTenant.ProjectAndTenantService">
-            <summary>
-            平台项目价格设置服务
-            </summary>
-        </member>
-        <member name="M:ZhonTai.Admin.Services.ProjectAndTenant.ProjectAndTenantService.GetPageAsync(ZhonTai.Admin.Core.Dto.PageInput{ZhonTai.Admin.Services.ProjectAndTenant.Dto.ProjectAndTenantGetPageInput})">
-            <summary>
-            查询分页
-            </summary>
-            <param name="input"></param>
-            <returns></returns>
-        </member>
-        <member name="M:ZhonTai.Admin.Services.ProjectAndTenant.ProjectAndTenantService.SetPriceAsync(ZhonTai.Admin.Services.ProjectAndTenant.Dto.ProjectAndTenantSetInput)">
-            <summary>
-            平台项目设置价格
-            </summary>
-            <param name="input"></param>
-            <returns></returns>
-        </member>
-        <member name="M:ZhonTai.Admin.Services.ProjectAndTenant.ProjectAndTenantService.SetPriceInitAsync">
-            <summary>
-            初始化抽成信息
-            </summary>        
-            <returns></returns>
-        </member>
-        <member name="M:ZhonTai.Admin.Services.ProjectAndTenant.ProjectAndTenantService.SetPriceUpdateToGlobalAsync">
-            <summary>
-            整体抽成更新
-            </summary>        
-            <returns></returns>
-        </member>
         <member name="P:ZhonTai.Admin.Services.ProjectLink.Dto.ProjectLinkGetPageDto.ProjectId">
         <member name="P:ZhonTai.Admin.Services.ProjectLink.Dto.ProjectLinkGetPageDto.ProjectId">
             <summary>
             <summary>
             项目Id
             项目Id
@@ -8004,6 +7968,20 @@
             <param name="input"></param>
             <param name="input"></param>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
+        <member name="M:ZhonTai.Admin.Services.Project.ProjectPriceService.GetTenantDrawPageAsync(ZhonTai.Admin.Core.Dto.PageInput{ZhonTai.Admin.Services.Project.Dto.TenantPriceGetPageInput})">
+            <summary>
+            查询平台单独设价分页
+            </summary>
+            <param name="input"></param>
+            <returns></returns>
+        </member>
+        <member name="M:ZhonTai.Admin.Services.Project.ProjectPriceService.SetTenantDrawAsync(ZhonTai.Admin.Services.Project.Dto.TenantDrawSetInput)">
+            <summary>
+            平台项目设置价格
+            </summary>
+            <param name="input"></param>
+            <returns></returns>
+        </member>
         <member name="M:ZhonTai.Admin.Services.Project.ProjectPriceService.CheckDrawRatio(System.Decimal)">
         <member name="M:ZhonTai.Admin.Services.Project.ProjectPriceService.CheckDrawRatio(System.Decimal)">
             <summary>
             <summary>
             校验抽成比例
             校验抽成比例
@@ -8016,6 +7994,11 @@
             </summary>
             </summary>
             <param name="effectDate"></param>
             <param name="effectDate"></param>
         </member>
         </member>
+        <member name="M:ZhonTai.Admin.Services.Project.ProjectPriceService.GetDrawAmount(System.Decimal,System.Decimal)">
+            <summary>
+            抽成金额
+            </summary>
+        </member>
         <member name="M:ZhonTai.Admin.Services.Project.ProjectPriceService.ProjectPriceInitAsync">
         <member name="M:ZhonTai.Admin.Services.Project.ProjectPriceService.ProjectPriceInitAsync">
             <summary>
             <summary>
             初始化公司抽成信息
             初始化公司抽成信息