6 changed files with 93 additions and 56 deletions
@ -0,0 +1,59 @@ |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading.Tasks; |
|||
using Coravel.Invocable; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using SettleAccount.Domain.BQ; |
|||
using Win.Sfs.SettleAccount.EntityFrameworkCore; |
|||
using Win.Sfs.SettleAccount.Options; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|||
{ |
|||
public class InvoiceSyncQadInvocable : IInvocable |
|||
{ |
|||
private readonly ILogger<InvoiceSyncQadInvocable> _logger; |
|||
private readonly GlobalConfigOptions _globalConfigOptions; |
|||
private readonly ISettleAccountDbContext _settleAccountDbContext; |
|||
/// <summary>
|
|||
/// 数据中心数据上下文
|
|||
/// </summary>
|
|||
private readonly ExChangeCenterDbContext _exChangeCenterDbContext; |
|||
|
|||
public InvoiceSyncQadInvocable( |
|||
ILogger<InvoiceSyncQadInvocable> logger, |
|||
IOptions<GlobalConfigOptions> options, |
|||
ISettleAccountDbContext settleAccountDbContext, |
|||
ExChangeCenterDbContext exChangeCenterDbContext) |
|||
{ |
|||
_logger = logger; |
|||
_globalConfigOptions = options.Value; |
|||
_settleAccountDbContext = settleAccountDbContext; |
|||
_exChangeCenterDbContext = exChangeCenterDbContext; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 执行
|
|||
/// </summary>
|
|||
public async Task Invoke() |
|||
{ |
|||
await Task.CompletedTask.ConfigureAwait(false); |
|||
|
|||
if (!_globalConfigOptions.IsSyncInvoiceQadState) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var invoiceSyncQads = _settleAccountDbContext.Set<InvoiceSyncQad>().Where(t => t.TaskState == 0 || t.TaskState == 1).OrderBy(t => t.CreationTime).Take(1000).ToList(); |
|||
|
|||
if (!invoiceSyncQads.Any()) |
|||
{ |
|||
_globalConfigOptions.IsSyncInvoiceQadState = false; |
|||
return; |
|||
} |
|||
|
|||
var taskIDs = invoiceSyncQads.Select(t => t.TaskID); |
|||
var TeaTaskSubs = _exChangeCenterDbContext.TEA_TASK_SUB.Where(t => taskIDs.Contains(t.TaskID)).ToList(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
namespace Win.Sfs.SettleAccount.Options |
|||
{ |
|||
/// <summary>
|
|||
/// 全局配置选项
|
|||
/// </summary>
|
|||
public class GlobalConfigOptions |
|||
{ |
|||
/// <summary>
|
|||
/// 是否同步发票Qad状态
|
|||
/// </summary>
|
|||
public bool IsSyncInvoiceQadState { get; set; } |
|||
} |
|||
} |
@ -1,9 +0,0 @@ |
|||
namespace Win.Sfs.SettleAccount.Options |
|||
{ |
|||
/// <summary>
|
|||
/// 发运配置选项
|
|||
/// </summary>
|
|||
public class SeConfigOptions |
|||
{ |
|||
} |
|||
} |
Loading…
Reference in new issue