using Hotline.Share.Dtos.Settings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Domain.Dependency;

namespace Hotline.Settings.TimeLimitDomain.ExpireTimeSupplier;
public class HourSupplier : IExpireTimeSupplier, IScopeDependency
{
    public async Task<TimeResult> CalcEndTimeAsync(DateTime beginTime, TimeConfig timeConfig)
    {
        return new TimeResult
        {
            EndTime =
            beginTime.AddHours(timeConfig.Count),
            RuleStr = timeConfig.Count + "个小时",
            NearlyExpiredTime = beginTime.AddHours(timeConfig.Count * ((double)timeConfig.Percentage / 100)),
            NearlyExpiredTimeOne = beginTime.AddHours(timeConfig.Count * ((double)timeConfig.PercentageOne / 100))
        };
    }

    public async Task<TimeResult> CalcEndTimeNewAsync(DateTime beginTime, DateTime startTime, TimeConfig timeConfig)
    {
        return new TimeResult
        {
            EndTime =
            beginTime.AddHours(timeConfig.Count),
            RuleStr = timeConfig.Count + "个小时",
            NearlyExpiredTime = beginTime.AddHours(timeConfig.Count * ((double)timeConfig.Percentage / 100)),
            NearlyExpiredTimeOne = beginTime.AddHours(timeConfig.Count * ((double)timeConfig.PercentageOne / 100))
        };
    }
}
