You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
8.2 KiB
C#
159 lines
8.2 KiB
C#
using DS.WMS.Core.Code.Entity;
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
using DS.WMS.Core.Fee.Entity;
|
|
using DS.WMS.Core.Invoice.Entity;
|
|
using DS.WMS.Core.QuarztJobs.Dtos;
|
|
using DS.WMS.Core.QuarztJobs.Interface;
|
|
using DS.WMS.Core.QuarztJobs.Other;
|
|
using DS.WMS.Core.Sys.Entity;
|
|
using Masuit.Tools;
|
|
using Microsoft.AspNet.SignalR.Infrastructure;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DS.WMS.Core.QuarztJobs.Method
|
|
{
|
|
/// <summary>
|
|
/// 银行流水
|
|
/// </summary>
|
|
public class BankStatementService : IBankStatementService
|
|
{
|
|
private static readonly HttpClient _httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };
|
|
ISqlSugarClient? db;
|
|
public BankStatementService(IServiceProvider serviceProvider)
|
|
{
|
|
db = serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
}
|
|
|
|
public async Task GetBankStatement()
|
|
{
|
|
|
|
//获取组织机构请求授权列表
|
|
if (db == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//查询所有租户的数据库连接
|
|
var dbLinkList = await db.Queryable<Module.SqlSugar.SysTenantLink>().ClearFilter().ToListAsync();
|
|
|
|
//遍历每个租户
|
|
foreach (var item in dbLinkList)
|
|
{
|
|
try
|
|
{
|
|
SqlSugarClient? tenantDb = null;
|
|
|
|
tenantDb = new SqlSugarClient(new ConnectionConfig
|
|
{
|
|
ConfigId = item.Id,
|
|
ConnectionString = item.Connection,
|
|
DbType = item.DbType,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
|
|
//查询当前租户的配置
|
|
var orgauthlist = tenantDb.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.Deleted == false && t.AccountType == "BankStatement").ToList();
|
|
|
|
|
|
//遍历授权数据集
|
|
foreach (var orgauth in orgauthlist)
|
|
{
|
|
//组织请求远程接口api数据
|
|
GetBankStatementPost model = new GetBankStatementPost();
|
|
model.AccountName = orgauth.AppKey; // "青岛东胜伟业软件有限公司";
|
|
model.AccountKey = orgauth.AppSecret;// "bbb4ce881f31c954e4d18018b41126d4";
|
|
model.BeginDate = DateTime.Now.AddDays(-1).ToString("yyyyMMdd"); //往前查24小时的银行流水数据
|
|
model.EndDate = DateTime.Now.ToString("yyyyMMdd");
|
|
|
|
var result = await HttpHellp.PostAsync("http://47.104.90.170:9876/sync", JsonConvert.SerializeObject(model));
|
|
List<BankStatement> datalist = new List<BankStatement>();
|
|
//处理返回结果
|
|
var info = JsonConvert.DeserializeObject<GetBankStatementPostOutput>(result);
|
|
|
|
if (info != null && info.result != null)
|
|
{
|
|
var listdt = info.result.Select(t => t.RecordID).ToList();
|
|
var ininviceinfo = tenantDb.Queryable<BankStatement>().Where(x => listdt.Contains(x.RecordID)).ToList();
|
|
|
|
foreach (var itemdata in info.result)
|
|
{
|
|
//数据库中银行流水为空,则添加银行流水数据数据
|
|
if (ininviceinfo.Where(t => t.RecordID == itemdata.RecordID).Count() == 0)
|
|
{
|
|
BankStatement bs = new BankStatement();
|
|
bs.Id = SnowFlakeSingle.Instance.NextId();
|
|
bs.OrgId = orgauth.ApiOrgId;
|
|
bs.Custom = itemdata.Custom;
|
|
bs.BankName = itemdata.BankName;
|
|
bs.AccountName = itemdata.AccountName;
|
|
bs.AccountId = itemdata.AccountId;
|
|
bs.TransactionType = itemdata.TransactionType;
|
|
bs.BusinessType = itemdata.BusinessType;
|
|
bs.AccountHoldingBankNumberOfPayer = itemdata.AccountHoldingBankNumberOfPayer;
|
|
bs.PayerAccountBank = itemdata.PayerAccountBank;
|
|
bs.PayerAccountNumber = itemdata.PayerAccountNumber;
|
|
bs.PayerName = itemdata.PayerName;
|
|
bs.AccountHoldingBankNumberOfPayee = itemdata.AccountHoldingBankNumberOfPayee;
|
|
bs.PayeeAccountBank = itemdata.PayeeAccountBank;
|
|
bs.PayeeAccountNumber = itemdata.PayeeAccountNumber;
|
|
bs.PayeeName = itemdata.PayeeName;
|
|
bs.TransactionDate = itemdata.TransactionDate;
|
|
bs.TransactionTime = itemdata.TransactionTime;
|
|
bs.TradeCurrency = itemdata.TradeCurrency;
|
|
bs.TradeAmount = itemdata.TradeAmount;
|
|
bs.AfterTransactionBalance = itemdata.AfterTransactionBalance;
|
|
bs.ValueDate = itemdata.ValueDate;
|
|
bs.ExchangeRate = itemdata.ExchangeRate;
|
|
bs.TransactionReferenceNumber = itemdata.TransactionReferenceNumber;
|
|
bs.OnlineBankingTransactionRef = itemdata.OnlineBankingTransactionRef;
|
|
bs.CustomerTransactionRef = itemdata.CustomerTransactionRef;
|
|
bs.VoucherType = itemdata.VoucherType;
|
|
bs.VoucherNumber = itemdata.VoucherNumber;
|
|
bs.RecordID = itemdata.RecordID;
|
|
bs.Reference = itemdata.Reference;
|
|
bs.Purpose = itemdata.Purpose;
|
|
bs.Remark = itemdata.Remark;
|
|
bs.Remarks = itemdata.Remarks;
|
|
bs.Reserve1 = itemdata.Reserve1;
|
|
bs.Reserve2 = itemdata.Reserve2;
|
|
bs.Reserve3 = itemdata.Reserve3;
|
|
bs.OpeningBankNumberOfNominalPayer = itemdata.OpeningBankNumberOfNominalPayer;
|
|
bs.OpeningBankNameOfNominalPayer = itemdata.OpeningBankNameOfNominalPayer;
|
|
bs.AccountNumberOfNominalPayer = itemdata.AccountNumberOfNominalPayer;
|
|
bs.NameOfNominalPayer = itemdata.NameOfNominalPayer;
|
|
bs.OpeningBankNumberOfNominalPayee = itemdata.OpeningBankNumberOfNominalPayee;
|
|
bs.OpeningBankNameOfNominalPayee = itemdata.OpeningBankNameOfNominalPayee;
|
|
bs.AccountNumberOfNominalPayee = itemdata.AccountNumberOfNominalPayee;
|
|
bs.NameOfNominalPayee = itemdata.NameOfNominalPayee;
|
|
bs.FilePaths = itemdata.FilePaths;
|
|
bs.DataCreateTime = itemdata.CreateTime;
|
|
bs.PayDateTime = DateTime.ParseExact(($"{itemdata.TransactionDate} {itemdata.TransactionTime}"), "yyyyMMdd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); ; //交易时间
|
|
bs.CreateTime = DateTime.Now;
|
|
datalist.Add(bs);
|
|
}
|
|
}
|
|
await tenantDb.Insertable(datalist).ExecuteCommandAsync();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|