Browse Source

项目价格设置

zmq 1 year ago
parent
commit
e9acf4aac8

+ 5 - 1
src/platform/ZhonTai.Admin/Core/Db/DbHelper.cs

@@ -198,10 +198,14 @@ public class DbHelper
                     if (e.Value == null || (long)e.Value == default || (long?)e.Value == default)
                     {                        
                         e.Value = user.TenantId;
-                    }
+                    }                  
                     if (e.Value != null && (long)e.Value == -1) {
                         e.Value = "";
                     }
+                    if (e.Value != null && (long)e.Value!=-1)
+                    {
+                        e.Value = e.Value;
+                    }
                     break;
 
             }

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

@@ -29,7 +29,7 @@ namespace ZhonTai.Admin.Domain.Project
         /// <summary>
         /// 抽成比例
         /// </summary>
-        public decimal DrawRatio { get; set; }
+        public decimal? DrawRatio { get; set; }
         /// <summary>
         /// 抽成金额
         /// </summary>

+ 2 - 2
src/platform/ZhonTai.Admin/Domain/Project/ProjectPriceEntity.cs

@@ -33,10 +33,10 @@ namespace ZhonTai.Admin.Domain.Project
         /// <summary>
         /// 抽成比例
         /// </summary>
-        public decimal DrawRatio { get; set; }
+        public decimal? DrawRatio { get; set; }
         /// <summary>
         /// 抽成金额
         /// </summary>
-        public decimal DrawPrice { get; set; }
+        public decimal? DrawPrice { get; set; }
     }
 }

+ 8 - 0
src/platform/ZhonTai.Admin/Services/Project/Dto/PriceGetPageOutput.cs

@@ -21,9 +21,17 @@ namespace ZhonTai.Admin.Services.Project.Dto
         /// </summary>
         public string Name { get; set; }
         /// <summary>
+        /// 项目名称
+        /// </summary>
+        public int Status { get; set; }        
+        /// <summary>
         /// 项目价格列表
         /// </summary>
         public List<PriceGetPageOutput_Price> Prices { get; set; }
+        /// <summary>
+        /// 预价格列表
+        /// </summary>
+        public List<PriceGetPageOutput_Price> PrePrices { get; set; }
     }
     public class PriceGetPageOutput_Price {
         /// <summary>

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

@@ -10,8 +10,8 @@ namespace ZhonTai.Admin.Services.Project.Dto
     {
         public long Id { get; set; }
         public int DrawPriceWay { get; set; }
-        public decimal DrawRatio { get; set; }
-        public decimal DrawPrice { get; set; }
+        public decimal? DrawRatio { get; set; }
+        public decimal? DrawPrice { get; set; }
         public DateTime? EffectDate { get; set; }
         
     }

+ 3 - 2
src/platform/ZhonTai.Admin/Services/Project/Dto/TenantDrawSetInput.cs

@@ -11,11 +11,12 @@ namespace ZhonTai.Admin.Services.Project.Dto
     {
         [Required]
         public long TenatntId { get; set; }
+        [Required]
         public long ProjectPriceId { get; set; }
         public long ProjectId { get; set; }
         public int DrawPriceWay { get; set; }
-        public decimal DrawRatio { get; set; }
-        public decimal DrawPrice { get; set; }
+        public decimal? DrawRatio { get; set; }
+        public decimal? DrawPrice { get; set; }
         public DateTime? EffectDate { get; set; }
         
     }

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

@@ -19,7 +19,7 @@ namespace ZhonTai.Admin.Services.Project.Dto
         public string Name { get; set; }
         public decimal Price { get; set; }
         public int DrawPriceWay { get; set; }
-        public decimal DrawRatio { get; set; }
-        public decimal DrawPrice { get; set; }
+        public decimal? DrawRatio { get; set; }
+        public decimal? DrawPrice { get; set; }
     }
 }

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

@@ -6,7 +6,8 @@ using System.Threading.Tasks;
 
 namespace ZhonTai.Admin.Services.Project
 {
-    internal class IProjectPriceService
+    public interface IProjectPriceService
     {
+        Task ExecuteTaskCompanyDraw();
     }
 }

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

@@ -7,6 +7,6 @@ using System.Threading.Tasks;
 namespace ZhonTai.Admin.Services.Project
 {
     public interface IProjectService
-    {
+    {        
     }
 }

+ 271 - 62
src/platform/ZhonTai.Admin/Services/Project/ProjectPriceService.cs

@@ -1,9 +1,13 @@
-using Microsoft.AspNetCore.Mvc;
+using FreeScheduler;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
 using NPOI.SS.Formula.Functions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using ZhonTai.Admin.Core.Consts;
 using ZhonTai.Admin.Core.Dto;
@@ -22,7 +26,7 @@ namespace ZhonTai.Admin.Services.Project
     /// </summary>
     [Order(10)]
     [DynamicApi(Area = AdminConsts.AreaName)]
-    public partial class ProjectPriceService : BaseService, IProjectService, IDynamicApi
+    public partial class ProjectPriceService : BaseService, IProjectPriceService, IDynamicApi
     {
         private readonly IProjectRepository _projectRepository;
         private readonly IProjectPriceRepository _projectPriceRepository;
@@ -49,8 +53,9 @@ namespace ZhonTai.Admin.Services.Project
             await ProjectPriceInitAsync();
 
             var list = await _projectConfigRepository.Select
-                .Where(m => m.ProjectId == 0 && m.ProjectPriceId == 0 && m.Status == 1)
-                .OrderByDescending(m=>m.EffectDate)
+                .DisableGlobalFilter(FilterNames.Tenant)
+                .Where(m => m.ProjectId == 0 && m.ProjectPriceId == 0 && m.DrawType == 1 && m.Status == 1)
+                .OrderByDescending(m => m.EffectDate)
             .ToListAsync(a => new
             {
                 a.Id,
@@ -62,14 +67,14 @@ namespace ZhonTai.Admin.Services.Project
             {
                 DateTime dtnow = DateTime.Today;
                 var next = list[0];
-                var current = list[1];                
-                output.CurrentRatio = current.DrawRatio;
+                var current = list[1];
+                output.CurrentRatio = current.DrawRatio.Value;
                 output.NextRatio = next.DrawRatio;
                 output.NextEffectDate = next.EffectDate;
             }
             else
             {
-                output.CurrentRatio = list[0].DrawRatio;                
+                output.CurrentRatio = list[0].DrawRatio.Value;
             }
             return output;
         }
@@ -84,8 +89,9 @@ namespace ZhonTai.Admin.Services.Project
 
             CheckDrawRatioEffect(input.EffectDate);
 
-            //删除旧的未生效记录
-            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)
+            var dtDay = 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 > dtDay)
             .ToListAsync(m => m.Id);
             if (listDeleteId.Count > 0)
             {
@@ -115,7 +121,7 @@ namespace ZhonTai.Admin.Services.Project
         [HttpPost]
         public async Task<PageOutput<GetProjectPricePageOutput>> GetProjectPageAsync(PageInput<GetProjectPricePageInput> input)
         {
-            var list = await _projectRepository.Select
+            var list = await _projectRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
             .Count(out var total)
             .OrderByDescending(true, a => a.Id)
             .Page(input.CurrentPage, input.PageSize)
@@ -124,7 +130,8 @@ namespace ZhonTai.Admin.Services.Project
                 Id = a.Id,
                 Name = a.Name,
                 Logo = a.Logo,
-                Prices = _projectPriceRepository.Select.Where(m => m.ProjectId == a.Id).ToList<PriceGetPageOutput_Price>()
+                Status = a.Status,
+                Prices = _projectPriceRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == a.Id).ToList<PriceGetPageOutput_Price>(),
             });
 
             var data = new PageOutput<GetProjectPricePageOutput>()
@@ -144,7 +151,14 @@ namespace ZhonTai.Admin.Services.Project
         public async Task<long> SetProjectPriceAsync(ProjectPriceSetInput input)
         {
             //验证项目价格信息是否存在
-            var price = await _projectPriceRepository.GetAsync(input.Id);
+            var price = await _projectPriceRepository.Select.DisableGlobalFilter(FilterNames.Tenant).From<ProjectEntity>().LeftJoin((pp, p) => pp.ProjectId == p.Id)
+                .Where((pp, p) => pp.Id == input.Id).ToOneAsync((pp, p) => new
+                {
+                    pp.Id,
+                    pp.ProjectId,
+                    pp.Price,
+                    p.Status
+                });
             if (!(price?.Id > 0))
             {
                 throw ResultOutput.Exception("信息不存在,请刷新后重试!");
@@ -153,12 +167,12 @@ namespace ZhonTai.Admin.Services.Project
             {
                 throw ResultOutput.Exception("无效的设价方式!");
             }
-            decimal amount = input.DrawPrice;
+            decimal? amount = input.DrawPrice;
             if (input.DrawPriceWay == 1)
             {
                 CheckDrawRatio(input.DrawRatio);
 
-                amount = GetDrawAmount(price.Price, input.DrawRatio);
+                amount = GetDrawAmount(price.Price, input.DrawRatio.Value);
             }
             else if (input.DrawPriceWay == 2)
             {
@@ -168,28 +182,59 @@ namespace ZhonTai.Admin.Services.Project
                     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 == 2)
-           .ToListAsync(m => m.Id);
-            if (listDeleteId.Count > 0)
-            {
-                await _projectConfigRepository.SoftDeleteAsync(m => listDeleteId.Contains(m.Id));
+            if (price.Status != 1) {
+                CheckDrawRatioEffect(input.EffectDate);
             }
 
-            //新增
-            var effectDate = input.EffectDate.HasValue ? input.EffectDate : DateTime.Today.AddDays(1);
-            await _projectConfigRepository.InsertAsync(new ProjectConfigEntity()
+            //项目没有上架可以直接启用设价信息
+            if (price.Status == 1)
             {
-                ProjectId = price.ProjectId,
-                ProjectPriceId = price.Id,
-                Status = 1,
-                DrawWay = input.DrawPriceWay,
-                DrawRatio = input.DrawRatio,
-                DrawAmount = amount,
-                EffectDate = effectDate,
-                DrawType = 2,
-                TenantId = 0
-            });
+                await _projectPriceRepository.UpdateDiy.SetDto(new
+                {
+                    DrawPriceWay = input.DrawPriceWay,
+                    DrawRatio = input.DrawRatio,
+                    DrawPrice = amount,
+                }).Where(m => m.Id == price.Id).DisableGlobalFilter(FilterNames.Tenant).ExecuteAffrowsAsync();
+
+                //新增记录
+                await _projectConfigRepository.InsertAsync(new ProjectConfigEntity()
+                {
+                    ProjectId = price.ProjectId,
+                    ProjectPriceId = price.Id,
+                    Status = 1,
+                    DrawWay = input.DrawPriceWay,
+                    DrawRatio = input.DrawRatio,
+                    DrawAmount = amount,
+                    DrawType = 2,
+                    TenantId = 0,
+                    IsDeleted = true
+                });
+            }
+            else
+            {
+                //覆盖已经存在未生效的
+                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
@@ -224,7 +269,15 @@ namespace ZhonTai.Admin.Services.Project
             {
                 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>()
+                prices = _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == projectId && m.TenantId == a.TenantId && m.Status == 1 && m.DrawType == 3).ToList<TenantPriceGetPageOutput_Price>(m =>new TenantPriceGetPageOutput_Price
+                { 
+                    ProjectId=m.ProjectId,
+                    ProjectPriceId=m.ProjectPriceId,
+                    DrawPriceWay=m.DrawWay,
+                    DrawRatio=m.DrawRatio,
+                    DrawPrice=m.DrawAmount
+                    
+                })
             });
             //项目信息同平台信息合并
             foreach (var item in list)
@@ -282,26 +335,35 @@ namespace ZhonTai.Admin.Services.Project
                 throw ResultOutput.Exception("无效的设价方式!");
             }
             //验证平台是否存在
-            var tenant = await _tenantRepository.GetAsync(input.TenatntId);
+            var tenant = await _tenantRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
+                .Where(m => m.Id == input.TenatntId).ToOneAsync();
             if (!(tenant?.Id > 0))
             {
                 throw ResultOutput.Exception("平台不存在,请刷新后重试!");
             }
 
             //验证项目价格信息是否存在
-            var price = await _projectPriceRepository.GetAsync(input.ProjectPriceId);
+            var price = await _projectPriceRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
+                .From<ProjectEntity>().LeftJoin((pp, p) => pp.ProjectId == p.Id)
+                .Where((pp, p) => pp.Id == input.ProjectPriceId).ToOneAsync((pp, p) => new
+                {
+                    pp.Id,
+                    pp.Price,
+                    pp.ProjectId,
+                    p.Status
+                });
             if (!(price?.Id > 0))
             {
                 throw ResultOutput.Exception("项目信息不存在,请刷新后重试!");
             }
-           
+
             var amount = input.DrawPrice;
             if (input.DrawPriceWay == 1)
             {
                 //抽成比例
                 CheckDrawRatio(input.DrawRatio);
 
-                amount = GetDrawAmount(price.Price, input.DrawRatio);
+                amount = GetDrawAmount(price.Price, input.DrawRatio.Value);
 
             }
             else if (input.DrawPriceWay == 2)
@@ -310,35 +372,173 @@ namespace ZhonTai.Admin.Services.Project
                 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)
+            //生效时间验证
+            if (price.Status != 1)
             {
-                await _projectConfigRepository.SoftDeleteAsync(m => listDeleteId.Contains(m.Id));
+                CheckDrawRatioEffect(input.EffectDate);
+            }
+            //待上线项目直接生效
+            if (price.Status == 1)
+            {
+                await _projectConfigRepository.UpdateDiy.DisableGlobalFilter(FilterNames.Tenant)
+                    .SetDto(new {
+                        IsDeleted = true
+                    })
+                    .Where(m => m.ProjectId == price.ProjectId && m.ProjectPriceId == price.Id && m.TenantId == input.TenatntId && m.Status == 1 && m.DrawType == 3)
+                    .ExecuteAffrowsAsync();
+                //新增
+                var effectDate = DateTime.Today;
+                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
+                });
+            }
+            else
+            {
+                //覆盖已经存在未生效的
+                var listDeleteId = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
+                    .Where(m => m.ProjectId == price.ProjectId && m.ProjectPriceId == price.Id && m.Status == 1 &&m.TenantId==input.TenatntId&& 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;
+                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;
+        }
+        #endregion
 
-            //新增
-            var effectDate = input.EffectDate.HasValue ? input.EffectDate : DateTime.Today.AddDays(1);
-            await _projectConfigRepository.InsertAsync(new ProjectConfigEntity()
+        #region 定时任务 每天凌晨执行一次
+        /// <summary>
+        /// 执行公司抽成任务
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [AllowAnonymous]
+        public async Task ExecuteTaskCompanyDraw()
+        {
+            var dtDay = DateTime.Today;
+            var list = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.DrawType == 1 && m.Status == 1 && m.EffectDate == dtDay).ToListAsync();
+            if (list != null && list.Count == 1)
             {
-                ProjectId = price.ProjectId,
-                ProjectPriceId = price.Id,
-                Status = 1,
-                DrawWay = input.DrawPriceWay,
-                DrawRatio = input.DrawRatio,
-                DrawAmount = amount,
-                EffectDate = effectDate,
-                DrawType = 3,
-                TenantId = input.TenatntId
-            });
+                //之前的数据失效
+                var result = await _projectConfigRepository.UpdateDiy
+                    .DisableGlobalFilter(FilterNames.Tenant)
+                    .SetDto(new { Status = 2 })
+                    .Where(m => m.ProjectId == 0 && m.ProjectPriceId == 0 && m.TenantId == 0 && m.DrawType == 1 && m.Status == 1 && m.EffectDate < dtDay)
+                    .ExecuteAffrowsAsync();
+                if (result > 0)
+                {
+                    throw ResultOutput.Exception($"成功执行{result}条数据");
+                }
+                else
+                {
+                    throw ResultOutput.Exception("执行失败");
+                }
+            }
+            else
+            {
+                throw ResultOutput.Exception("无需执行数据");
+            }
+        }
+        /// <summary>
+        /// 执行抽成项目任务
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [AllowAnonymous]
+        public async Task ExecuteTaskProjectDraw()
+        {
+            var list = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.DrawType == 2 && m.Status == 1 && m.EffectDate == DateTime.Today).ToListAsync();
+            if (list != null)
+            {
+                //数据挪项目中
+                foreach (var item in list)
+                {
+                    await _projectPriceRepository.UpdateDiy.SetDto(new ProjectPriceEntity
+                    {
+                    }).Where(m => m.Id == item.ProjectPriceId && m.ProjectId == item.ProjectId)
+                    .DisableGlobalFilter(FilterNames.Tenant)
+                    .ExecuteAffrowsAsync();
+                }
 
+                //之前的数据失效
+                var result = await _projectConfigRepository.UpdateDiy
+                    .DisableGlobalFilter(FilterNames.Tenant)
+                    .SetDto(new { Status = 2 })
+                    .Where(m => m.DrawType == 2 && m.Status == 1 && m.EffectDate < DateTime.Today)
+                    .ExecuteAffrowsAsync();
+                if (result > 0)
+                {
+                    throw ResultOutput.Exception($"成功执行{result}条数据");
+                }
+                else
+                {
+                    throw ResultOutput.Exception("执行失败");
+                }
+            }
+            else
+            {
+                throw ResultOutput.Exception("无需执行数据");
+            }
+        }
 
-            return 1;
+        /// <summary>
+        /// 执行抽成平台任务
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [AllowAnonymous]
+        public async Task ExecuteTasDrawTenant()
+        {
+            var list = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.DrawType == 3 && m.Status == 1 && m.EffectDate == DateTime.Today).ToListAsync();
+            if (list != null)
+            {                
+                //之前的数据失效
+                var result = await _projectConfigRepository.UpdateDiy
+                    .DisableGlobalFilter(FilterNames.Tenant)
+                    .SetDto(new { Status = 2 })
+                    .Where(m => m.DrawType == 3 && m.Status == 1 && m.EffectDate < DateTime.Today)
+                    .ExecuteAffrowsAsync();
+                if (result > 0)
+                {
+                    throw ResultOutput.Exception($"成功执行{result}条数据");
+                }
+                else
+                {
+                    throw ResultOutput.Exception("执行失败");
+                }
+            }
+            else
+            {
+                throw ResultOutput.Exception("无需执行数据");
+            }
         }
         #endregion
 
@@ -348,8 +548,12 @@ namespace ZhonTai.Admin.Services.Project
         /// 校验抽成比例
         /// </summary>
         /// <param name="drawRatio"></param>
-        private void CheckDrawRatio(decimal drawRatio)
+        private void CheckDrawRatio(decimal? drawRatio)
         {
+            if (!drawRatio.HasValue)
+            {
+                throw ResultOutput.Exception("抽成比例有效范围在0-100");
+            }
             //抽成比例
             if (drawRatio < 0 || drawRatio > 100)
             {
@@ -360,8 +564,11 @@ namespace ZhonTai.Admin.Services.Project
         /// 校验抽成比例生效时间
         /// </summary>
         /// <param name="effectDate"></param>
-        private void CheckDrawRatioEffect(DateTime effectDate)
+        private void CheckDrawRatioEffect(DateTime? effectDate)
         {
+            if (!effectDate.HasValue) {
+                throw ResultOutput.Exception("请设置生效时间");
+            }
             //生效时间
             if (effectDate <= DateTime.Today)
             {
@@ -391,7 +598,9 @@ namespace ZhonTai.Admin.Services.Project
                     ProjectPriceId = 0,
                     DrawRatio = 5,
                     EffectDate = DateTime.Today,
-                    Status = 1
+                    TenantId = -1,
+                    Status = 1,
+                    DrawWay = 1
                 });
             }
         }

+ 2 - 9
src/platform/ZhonTai.Admin/Services/Project/ProjectService.cs

@@ -133,13 +133,7 @@ namespace ZhonTai.Admin.Services.Project
             ProjectEntity entity = Mapper.Map<ProjectEntity>(input);
             entity.Status = 1;
             ProjectEntity project = await _projectRepository.InsertAsync(entity);
-            long projectId = project.Id;
-
-            //公司默认抽成金额
-            decimal ratio = 5;
-            var companyRatio = await _dictRepository.Select.Where(m => m.Code == "CompanyProjectDrawRatio").FirstAsync();
-            if (companyRatio != null)
-                ratio = decimal.Parse(companyRatio.Value);
+            long projectId = project.Id;                        
 
 
             //添加项目价格            
@@ -148,8 +142,7 @@ namespace ZhonTai.Admin.Services.Project
                 ProjectId = projectId,
                 Name = m.Name,
                 Price = m.Price,
-                DrawPriceWay=0,
-                DrawPrice=UtilConvertExtension.ToDecimalCutWithN(m.Price * ratio * 0.01m,0m,1)
+                DrawPriceWay=0                
             }).ToList();
 
             await _projectPriceRepository.InsertAsync(prices);

+ 1 - 1
src/platform/ZhonTai.Admin/Services/ProjectStat/ProjectStatService.cs

@@ -262,7 +262,7 @@ namespace ZhonTai.Admin.Services.ProjectStat
                                 if (drawcompany != null)
                                 {
                                     drawway = 1;
-                                    ratio = drawcompany.DrawRatio;
+                                    ratio = drawcompany.DrawRatio.Value;
                                 }
                             }
                         }