using OASystem.Infrastructure.Repositories.Groups;

namespace OASystem.API.OAMethodLib.Quartz.Business
{
    public class TeamCurrency
    {

        private readonly static TeamRateRepository _grpCurrencyRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();

        /// <summary>
        /// 团组币种信息
        /// 每天 凌晨零点更新
        /// </summary>
        public static async void PostTeamCurrencyUpdate()
        {
            string grpCurrencyName = "GroupTeamCurrencyData";

            var _currData = await _grpCurrencyRep.PostGroupTeamRateHot();
            if (_currData != null)
            {
              var s = await RedisRepository.RedisFactory.CreateRedisRepository().KeyDeleteAsync(grpCurrencyName);
                if (s)
                {
                    TimeSpan ts = DateTime.Now.AddHours(25).TimeOfDay;
                    await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync(grpCurrencyName,JsonConvert.SerializeObject(_currData), ts);
                }
            }
        }
    }
}
