You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
using Autofac;
|
|
using HybirdFrameworkCore.Autofac;
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
using HybirdFrameworkCore.Job;
|
|
using log4net;
|
|
using Repository.Station;
|
|
|
|
namespace Service.Job;
|
|
|
|
[Scope]
|
|
public class CancelAmtOrderJob : AbstractCronJob
|
|
{
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(CancelAmtOrderJob));
|
|
|
|
public readonly AmtOrderInfoRepository
|
|
_amtOrderInfoRepository = AppInfo.Container.Resolve<AmtOrderInfoRepository>();
|
|
|
|
public readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
protected override Task Handle()
|
|
{
|
|
var time = DateTime.Now;
|
|
DateTime halfHourAgo = time.AddMinutes(-30);
|
|
|
|
// 查询最近半小时内的预约订单
|
|
var recentOrders = _amtOrderInfoRepository.QueryListByClause(u =>
|
|
u.CreatedTime > halfHourAgo && u.Status == 1 && u.EndTime < time && u.SwapOrderNo == null);
|
|
|
|
if (recentOrders != null)
|
|
{
|
|
foreach (var amtOrderInfo in recentOrders)
|
|
{
|
|
amtOrderInfo.Status = 2;
|
|
// _binInfoRepository.UpdateAsync(i => i.ChargerNo == amtOrderInfo.BinNos, i => i.AmtLock == 0);
|
|
_binInfoRepository.UpdateAsync(i => i.AmtLock == 0,i => i.No == amtOrderInfo.BinNos);
|
|
|
|
}
|
|
|
|
_amtOrderInfoRepository.Update(recentOrders);
|
|
}
|
|
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
protected override string Key()
|
|
{
|
|
return "CancelAmtOrderJob";
|
|
}
|
|
|
|
protected override string Cron()
|
|
{
|
|
return "0 * * * * ?";
|
|
}
|
|
} |