|  | @@ -131,7 +131,16 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |                  Name = a.Name,
 | 
	
		
			
				|  |  |                  Logo = a.Logo,
 | 
	
		
			
				|  |  |                  Status = a.Status,
 | 
	
		
			
				|  |  | -                Prices = _projectPriceRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == a.Id).ToList<PriceGetPageOutput_Price>(),
 | 
	
		
			
				|  |  | +                Prices = _projectPriceRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == a.Id).ToList<PriceGetPageOutput_Price>(
 | 
	
		
			
				|  |  | +                    b=>new PriceGetPageOutput_Price() { 
 | 
	
		
			
				|  |  | +                        Id=b.Id,
 | 
	
		
			
				|  |  | +                        Name=b.Name,
 | 
	
		
			
				|  |  | +                        Price=b.Price,
 | 
	
		
			
				|  |  | +                        DrawPriceWay=b.DrawPriceWay,
 | 
	
		
			
				|  |  | +                        DrawRatio=b.DrawRatio,
 | 
	
		
			
				|  |  | +                        DrawPrice=b.DrawPrice,
 | 
	
		
			
				|  |  | +                        IsExistNextInfo = _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m=>m.DrawType==2&&m.ProjectPriceId==b.Id&&m.Status==1).Count()
 | 
	
		
			
				|  |  | +                    })
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var data = new PageOutput<GetProjectPricePageOutput>()
 | 
	
	
		
			
				|  | @@ -182,7 +191,8 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |                      throw ResultOutput.Exception("设置有效的抽成金额");
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if (price.Status != 1) {
 | 
	
		
			
				|  |  | +            if (price.Status != 1)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  |                  CheckDrawRatioEffect(input.EffectDate);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -269,23 +279,25 @@ 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>(m =>new TenantPriceGetPageOutput_Price
 | 
	
		
			
				|  |  | -                { 
 | 
	
		
			
				|  |  | -                    ProjectId=m.ProjectId,
 | 
	
		
			
				|  |  | -                    ProjectPriceId=m.ProjectPriceId,
 | 
	
		
			
				|  |  | -                    DrawPriceWay=m.DrawWay,
 | 
	
		
			
				|  |  | -                    DrawRatio=m.DrawRatio,
 | 
	
		
			
				|  |  | -                    DrawPrice=m.DrawAmount
 | 
	
		
			
				|  |  | -                    
 | 
	
		
			
				|  |  | +                prices = _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == projectId && m.TenantId == a.TenantId && m.Status == 1 && m.DrawType == 3).ToList(m => new TenantPriceGetPageOutput_Price
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    ProjectId = m.ProjectId,
 | 
	
		
			
				|  |  | +                    ProjectPriceId = m.ProjectPriceId,
 | 
	
		
			
				|  |  | +                    DrawPriceWay = m.DrawWay,
 | 
	
		
			
				|  |  | +                    DrawRatio = m.DrawRatio,
 | 
	
		
			
				|  |  | +                    DrawPrice = m.DrawAmount,
 | 
	
		
			
				|  |  | +                    EffectDate=m.EffectDate
 | 
	
		
			
				|  |  |                  })
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |              //项目信息同平台信息合并
 | 
	
		
			
				|  |  | +            var dtToday = DateTime.Today;
 | 
	
		
			
				|  |  |              foreach (var item in list)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  List<TenantPriceGetPageOutput_Price> prices = new List<TenantPriceGetPageOutput_Price>();
 | 
	
		
			
				|  |  |                  foreach (var it in projectprice)
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    var tprice = item.prices.Where(m => m.ProjectPriceId == it.Id).FirstOrDefault();
 | 
	
		
			
				|  |  | +                    var listItem=item.prices.Where(m => m.ProjectPriceId == it.Id).ToList();
 | 
	
		
			
				|  |  | +                    var tprice = listItem.Where(m=>m.EffectDate<= dtToday).FirstOrDefault();
 | 
	
		
			
				|  |  |                      if (tprice != null)
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  |                          prices.Add(new TenantPriceGetPageOutput_Price()
 | 
	
	
		
			
				|  | @@ -296,7 +308,8 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |                              Price = it.Price,
 | 
	
		
			
				|  |  |                              DrawPriceWay = tprice.DrawPriceWay,
 | 
	
		
			
				|  |  |                              DrawRatio = tprice.DrawRatio,
 | 
	
		
			
				|  |  | -                            DrawPrice = tprice.DrawPrice
 | 
	
		
			
				|  |  | +                            DrawPrice = tprice.DrawPrice,
 | 
	
		
			
				|  |  | +                            IsExistNextInfo= listItem.Count>1?1:0
 | 
	
		
			
				|  |  |                          });
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      else
 | 
	
	
		
			
				|  | @@ -307,7 +320,8 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |                              ProjectPriceId = it.Id,
 | 
	
		
			
				|  |  |                              Name = it.Name,
 | 
	
		
			
				|  |  |                              Price = it.Price,
 | 
	
		
			
				|  |  | -                            DrawPriceWay = 0
 | 
	
		
			
				|  |  | +                            DrawPriceWay = 0,
 | 
	
		
			
				|  |  | +                            IsExistNextInfo=listItem.Count>0?1:0
 | 
	
		
			
				|  |  |                          });
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
	
		
			
				|  | @@ -384,7 +398,8 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |              if (price.Status == 1)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  await _projectConfigRepository.UpdateDiy.DisableGlobalFilter(FilterNames.Tenant)
 | 
	
		
			
				|  |  | -                    .SetDto(new {
 | 
	
		
			
				|  |  | +                    .SetDto(new
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  |                          IsDeleted = true
 | 
	
		
			
				|  |  |                      })
 | 
	
		
			
				|  |  |                      .Where(m => m.ProjectId == price.ProjectId && m.ProjectPriceId == price.Id && m.TenantId == input.TenatntId && m.Status == 1 && m.DrawType == 3)
 | 
	
	
		
			
				|  | @@ -408,7 +423,7 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  //覆盖已经存在未生效的
 | 
	
		
			
				|  |  |                  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)
 | 
	
		
			
				|  |  | +                    .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)
 | 
	
		
			
				|  |  |                  {
 | 
	
	
		
			
				|  | @@ -432,6 +447,49 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return 1;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// 下次生效信息
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <param name="input"></param>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        [HttpPost]
 | 
	
		
			
				|  |  | +        public async Task<DrawInfoOutput> GetDrawInfoAsync(DrawInfoInput input)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            if (!new[] { 2, 3 }.Contains(input.DrawType))
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                throw ResultOutput.Exception("无效的抽成类型!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            DrawInfoOutput result   =new DrawInfoOutput();
 | 
	
		
			
				|  |  | +            //项目抽成信息
 | 
	
		
			
				|  |  | +            if (input.DrawType == 2)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                result = await _projectConfigRepository.Select
 | 
	
		
			
				|  |  | +                    .DisableGlobalFilter(FilterNames.Tenant)
 | 
	
		
			
				|  |  | +                    .Where(m => m.DrawType == 2 && m.ProjectPriceId == input.ProjectPriceId && m.EffectDate > DateTime.Today)
 | 
	
		
			
				|  |  | +                    .OrderBy(m => m.EffectDate)
 | 
	
		
			
				|  |  | +                    .ToOneAsync(m=>new DrawInfoOutput{ 
 | 
	
		
			
				|  |  | +                        DrawWay= m.DrawWay,
 | 
	
		
			
				|  |  | +                        DrawRatio= m.DrawRatio,
 | 
	
		
			
				|  |  | +                        DrawAmount= m.DrawAmount,
 | 
	
		
			
				|  |  | +                        EffectDate= m.EffectDate
 | 
	
		
			
				|  |  | +                    });                
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                result = await _projectConfigRepository.Select
 | 
	
		
			
				|  |  | +                   .DisableGlobalFilter(FilterNames.Tenant)
 | 
	
		
			
				|  |  | +                   .Where(m => m.DrawType == 3 && m.ProjectPriceId == input.ProjectPriceId &&m.TenantId==input.TenantId && m.EffectDate > DateTime.Today)
 | 
	
		
			
				|  |  | +                   .OrderBy(m => m.EffectDate)
 | 
	
		
			
				|  |  | +                   .ToOneAsync(m => new DrawInfoOutput
 | 
	
		
			
				|  |  | +                   {
 | 
	
		
			
				|  |  | +                       DrawWay = m.DrawWay,
 | 
	
		
			
				|  |  | +                       DrawRatio = m.DrawRatio,
 | 
	
		
			
				|  |  | +                       DrawAmount = m.DrawAmount,
 | 
	
		
			
				|  |  | +                       EffectDate = m.EffectDate
 | 
	
		
			
				|  |  | +                   });                
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          #endregion
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          #region 定时任务 每天凌晨执行一次
 | 
	
	
		
			
				|  | @@ -475,14 +533,18 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |          [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();
 | 
	
		
			
				|  |  | +            var dtToday = DateTime.Today;
 | 
	
		
			
				|  |  | +            var list = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.DrawType == 2 && m.Status == 1 && m.EffectDate ==dtToday ).ToListAsync();
 | 
	
		
			
				|  |  |              if (list != null)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  //数据挪项目中
 | 
	
		
			
				|  |  |                  foreach (var item in list)
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    await _projectPriceRepository.UpdateDiy.SetDto(new ProjectPriceEntity
 | 
	
		
			
				|  |  | +                    await _projectPriceRepository.UpdateDiy.SetDto(new
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  | +                        DrawPriceWay=item.DrawWay,
 | 
	
		
			
				|  |  | +                        DrawRatio=item.DrawRatio,
 | 
	
		
			
				|  |  | +                        DrawPrice=item.DrawAmount
 | 
	
		
			
				|  |  |                      }).Where(m => m.Id == item.ProjectPriceId && m.ProjectId == item.ProjectId)
 | 
	
		
			
				|  |  |                      .DisableGlobalFilter(FilterNames.Tenant)
 | 
	
		
			
				|  |  |                      .ExecuteAffrowsAsync();
 | 
	
	
		
			
				|  | @@ -492,7 +554,7 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |                  var result = await _projectConfigRepository.UpdateDiy
 | 
	
		
			
				|  |  |                      .DisableGlobalFilter(FilterNames.Tenant)
 | 
	
		
			
				|  |  |                      .SetDto(new { Status = 2 })
 | 
	
		
			
				|  |  | -                    .Where(m => m.DrawType == 2 && m.Status == 1 && m.EffectDate < DateTime.Today)
 | 
	
		
			
				|  |  | +                    .Where(m => m.DrawType == 2 && m.Status == 1 && m.EffectDate < dtToday)
 | 
	
		
			
				|  |  |                      .ExecuteAffrowsAsync();
 | 
	
		
			
				|  |  |                  if (result > 0)
 | 
	
		
			
				|  |  |                  {
 | 
	
	
		
			
				|  | @@ -517,14 +579,15 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |          [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();
 | 
	
		
			
				|  |  | +            var dtToday = DateTime.Today;
 | 
	
		
			
				|  |  | +            var list = await _projectConfigRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.DrawType == 3 && m.Status == 1 && m.EffectDate == dtToday).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)
 | 
	
		
			
				|  |  | +                    .Where(m => m.DrawType == 3 && m.Status == 1 && m.EffectDate < dtToday)
 | 
	
		
			
				|  |  |                      .ExecuteAffrowsAsync();
 | 
	
		
			
				|  |  |                  if (result > 0)
 | 
	
		
			
				|  |  |                  {
 | 
	
	
		
			
				|  | @@ -566,7 +629,8 @@ namespace ZhonTai.Admin.Services.Project
 | 
	
		
			
				|  |  |          /// <param name="effectDate"></param>
 | 
	
		
			
				|  |  |          private void CheckDrawRatioEffect(DateTime? effectDate)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            if (!effectDate.HasValue) {
 | 
	
		
			
				|  |  | +            if (!effectDate.HasValue)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  |                  throw ResultOutput.Exception("请设置生效时间");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              //生效时间
 |