/// <summary>登録処理</summary> public async Task <AccountTransferImportResult> ImportAsync(AccountTransferImportSource source, CancellationToken token = default(CancellationToken)) { var importDataId = source.ImportDataId ?? 0; var data = await importDataProcessor.GetAsync(importDataId, token : token); var agency = (await paymentAgencyGetByIdsQueryProcessor.GetByIdsAsync(new[] { source.PaymentAgencyId }, token)).First(); var sources = data.Details.Select(x => serializer.UnpackSingleObject(x.RecordItem)).ToArray(); var items = sources.Select(x => new AccountTransferImportData { BillingIdList = x.Billings.Select(y => y.Id).ToArray(), CustomerIds = x.Billings.Select(y => y.CustomerId).ToArray(), ResultCode = x.TransferResultCode, DoUpdateAccountTransferLogId = !x.IgnoreInitialization, DueDate = x.NewDueAt, UpdateBy = source.LoginUserId, DueDateOffset = agency.DueDateOffset, CollectCategoryId = source.NewCollectCategoryId, }).ToArray(); var importResult = await billingAccountTransferProcessor.ImportAsync(items, token); return(new AccountTransferImportResult { ProcessResult = new ProcessResult { Result = true }, }); }
/// <summary>インポート処理 データ登録</summary> /// <param name="source"></param> /// <param name="token"></param> /// <returns></returns> public async Task <ImportDataResult> ImportAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken)) { var companyTask = companyProcessor.GetAsync(new CompanySearch { Id = source.CompanyId, }, token); var appConTask = applicationControlProcessor.GetAsync(source.CompanyId, token); await Task.WhenAll(companyTask, appConTask); var company = companyTask.Result.First(); var applicationControl = appConTask.Result; var importDataId = source.ImportDataId ?? 0; var importer = new BillingImporterBase(applicationControl) { CompanyId = source.CompanyId, CompanyCode = company.Code, LoginUserId = source.LoginUserId, ImporterSettingId = source.ImporterSettingId, Deserialize = bytes => serializer.UnpackSingleObject(bytes), LoadImportDataAsync = () => importDataProcessor.GetAsync(importDataId, objectType: 0, token: token), ImportInnerAsync = (companyId, loginUserId, settingId, items) => billingImporterProcessor.ImportAsync(new BillingImportItems { CompanyId = companyId, LoginUserId = loginUserId, ImporterSettingId = settingId, Items = items, }, token), }; var result = await importer.ImportAsync(); return(new ImportDataResult { SaveCount = importer.SaveCount, SaveAmount = importer.SaveAmount, }); }
/// <summary>登録処理</summary> /// <param name="source"></param> /// <param name="token"></param> /// <returns></returns> public async Task <ImportDataResult> ImportAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken)) { var companyTask = GetCompanyAsync(source.CompanyId, token); var appConTask = GetApplicationControlAsync(source.CompanyId, token); await Task.WhenAll(companyTask, appConTask); var company = companyTask.Result; var applicationControl = appConTask.Result; var importDataId = source.ImportDataId ?? 0; var importer = new PaymentScheduleImporterBase(applicationControl) { CompanyId = source.CompanyId, CompanyCode = company.Code, LoginUserId = source.LoginUserId, ImporterSettingId = source.ImporterSettingId, DoTargetNotMatchedData = source.DoTargetNotMatchedData, DoReplaceAmount = source.DoReplaceAmount, DoIgnoreSameCustomerGroup = source.DoIgnoreSameCustomerGroup, Deserialize = bytes => serializerScheduledPaymentImport.UnpackSingleObject(bytes), LoadImportDataAsync = () => importDataProcessor.GetAsync(importDataId, objectType: 0, token: token), SaveInnerAsync = async(companyId, loginUserId, settingId, items) => { var results = (await billingScheduledPaymentProcessor.ImportAsync(new BillingScheduledPaymentImportSource { }, token)).ToArray(); return(new ScheduledPaymentImportResult { ProcessResult = new ProcessResult { Result = true, }, ScheduledPaymentImport = results, }); }, }; var result = await importer.ImportAsync(); return(new ImportDataResult { SaveCount = importer.SaveCount, SaveAmount = importer.SaveAmount, }); }
public async Task <byte[]> GetAsync(AccountTransferImportSource source, CancellationToken token = default(CancellationToken)) { var importDataId = source.ImportDataId ?? 0; var importDataTask = importDataProcessor.GetAsync(importDataId, token: token); var companyTask = companyGetByIdsQueryProcessor.GetByIdsAsync(new[] { source.CompanyId }, token); await Task.WhenAll(importDataTask, companyTask); var importData = importDataTask.Result; var company = companyTask.Result.First(); var sources = importData.Details.Select(x => serializer.UnpackSingleObject(x.RecordItem)).ToArray(); var reportSource = sources.Select(x => new AccountTransferImportReport.ReportRow { Billing = x.Billings?.Single(b => b.Id == x.Billings.Min(y => y.Id)), TransferResultCode = x.TransferResultCode, TransferAmount = x.TransferAmount, TransferBankName = x.TransferBankName, TransferBranchName = x.TransferBranchName, TransferCustomerCode = x.TransferCustomerCode, TransferAccountName = x.TransferAccountName, }).ToArray(); if (!(reportSource?.Any() ?? false)) { return(null); } var report = new AccountTransferImportReport() { Name = $"口座振替結果データ一覧_{DateTime.Now:yyyyMMdd_HHmmss}" }; // 帳票生成 report.SetBasicPageSetting(company.Code, company.Name); report.SetData(reportSource); report.Run(); return(report.Convert()); }
/// <summary>正常な入金データの取得</summary> /// <param name="id"></param> /// <param name="token"></param> /// <returns></returns> public async Task <IEnumerable <ReceiptInput> > GetValidItemsAsync(long id, CancellationToken token = default(CancellationToken)) { var data = await importDataProcessor.GetAsync(id, objectType : 0, token : token); return(data.Details.Select(x => serializer.UnpackSingleObject(x.RecordItem)).ToArray()); }