|
|
|
@ -0,0 +1,141 @@
|
|
|
|
|
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 orgauthlist = db.Queryable<SysOrgAuth>().ClearFilter().Where(t => t.Deleted == false && t.Type == "BankStatement").ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历授权数据集
|
|
|
|
|
foreach (var item in orgauthlist)
|
|
|
|
|
{
|
|
|
|
|
//组织请求远程接口api数据
|
|
|
|
|
|
|
|
|
|
GetBankStatementPost model = new GetBankStatementPost();
|
|
|
|
|
model.AccountName = item.Key; // "青岛东胜伟业软件有限公司";
|
|
|
|
|
model.AccountKey = item.Secret;// "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 dbLink = await db.Queryable<Module.SqlSugar.SysTenantLink>().ClearFilter().Where(t => t.TenantId == item.TenantId).FirstAsync();
|
|
|
|
|
SqlSugarClient? tenantDb = null;
|
|
|
|
|
//查询租户数据库中是否有当前数据
|
|
|
|
|
tenantDb = new SqlSugarClient(new ConnectionConfig
|
|
|
|
|
{
|
|
|
|
|
ConfigId = dbLink.Id,
|
|
|
|
|
ConnectionString = dbLink.Connection,
|
|
|
|
|
DbType = dbLink.DbType,
|
|
|
|
|
IsAutoCloseConnection = true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var listdt = info.result.Select(t => t.TransactionReferenceNumber).ToList();
|
|
|
|
|
var ininviceinfo = tenantDb.Queryable<BankStatement>().Where(x =>listdt .Contains(x.TransactionReferenceNumber)).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var itemdata in info.result)
|
|
|
|
|
{
|
|
|
|
|
//数据库中银行流水为空,则添加银行流水数据数据
|
|
|
|
|
if (ininviceinfo.Where(t => t.TransactionReferenceNumber == itemdata.TransactionReferenceNumber).Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
BankStatement bs = new BankStatement();
|
|
|
|
|
bs.Id = SnowFlakeSingle.Instance.NextId();
|
|
|
|
|
bs.OrgId = item.OrgId;
|
|
|
|
|
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.CreateTime = DateTime.Now;
|
|
|
|
|
//await tenantDb.Insertable(bs).ExecuteCommandAsync();
|
|
|
|
|
datalist.Add(bs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await tenantDb.Insertable(datalist).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|