|
|
|
@ -16,6 +16,7 @@ public class CountDayOrderTask : ITask
|
|
|
|
|
{
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(CountDayOrderTask));
|
|
|
|
|
private volatile bool _stop;
|
|
|
|
|
private Timer _timer;
|
|
|
|
|
|
|
|
|
|
public ChargeOrderService _ChargeOrderService { get; set; }
|
|
|
|
|
|
|
|
|
@ -29,13 +30,14 @@ public class CountDayOrderTask : ITask
|
|
|
|
|
|
|
|
|
|
public int Interval()
|
|
|
|
|
{
|
|
|
|
|
return 1000 * 86400;
|
|
|
|
|
return 1000 * 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle()
|
|
|
|
|
{
|
|
|
|
|
// 统计每日运行
|
|
|
|
|
CountOrder();
|
|
|
|
|
return;
|
|
|
|
|
// CountOrder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -43,16 +45,50 @@ public class CountDayOrderTask : ITask
|
|
|
|
|
public bool Stoped()
|
|
|
|
|
{
|
|
|
|
|
return _stop;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
|
|
|
|
_stop = true;
|
|
|
|
|
_timer?.Change(Timeout.Infinite, Timeout.Infinite);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResetStop()
|
|
|
|
|
{
|
|
|
|
|
_stop = false;
|
|
|
|
|
ScheduleNextRun();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public CountDayOrderTask()
|
|
|
|
|
{
|
|
|
|
|
ScheduleNextRun();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ScheduleNextRun()
|
|
|
|
|
{
|
|
|
|
|
if (_stop)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DateTime now = DateTime.Now;
|
|
|
|
|
DateTime nextRun = new DateTime(now.Year, now.Month, now.Day, 19, 21, 0);
|
|
|
|
|
if (now > nextRun)
|
|
|
|
|
{
|
|
|
|
|
nextRun = nextRun.AddDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimeSpan timeToGo = nextRun - now;
|
|
|
|
|
_timer = new Timer(x =>
|
|
|
|
|
{
|
|
|
|
|
if (!_stop)
|
|
|
|
|
{
|
|
|
|
|
CountOrder();
|
|
|
|
|
ScheduleNextRun();
|
|
|
|
|
}
|
|
|
|
|
}, null, timeToGo, Timeout.InfiniteTimeSpan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CountOrder()
|
|
|
|
|