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.

84 lines
3.7 KiB
C#

using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Invoice.Entity;
using DS.WMS.Core.Invoice.Interface;
using DS.WMS.Core.TaskPlat.Dtos;
using MathNet.Numerics.Distributions;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.Invoice.Method
{
/// <summary>
/// 银行流水相关
/// </summary>
public class BankStatementService : IBankStatementService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISaasDbService saasService;
private readonly IUser user;
private readonly ISqlSugarClient db;
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public BankStatementService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
}
/// <summary>
/// 获取银行流水列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<DataResult<List<GetBankStatementOutPut>>> GetBankStatementList(PageRequest<GetBankStatementInput> request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var result = await tenantDb.Queryable<BankStatement>()
.Where(t => t.OrgId == user.OrgId)
.WhereIF(!string.IsNullOrWhiteSpace(request.OtherQueryCondition.AccountId), t => t.AccountId == request.OtherQueryCondition.AccountId)//银行账户
.WhereIF(!string.IsNullOrWhiteSpace(request.OtherQueryCondition.BusinessType), t => t.BusinessType.Contains(request.OtherQueryCondition.BusinessType))//交易类型
.WhereIF(!string.IsNullOrWhiteSpace(request.OtherQueryCondition.PayerAccountNumber), t => t.BusinessType.Contains(request.OtherQueryCondition.PayerAccountNumber))//付款方银行账户
.WhereIF(!string.IsNullOrWhiteSpace(request.OtherQueryCondition.PayerName), t => t.BusinessType.Contains(request.OtherQueryCondition.PayerName))//付款人名称
.WhereIF(request.OtherQueryCondition.StartDate != null, t => t.PayDataTime >= request.OtherQueryCondition.StartDate)
.WhereIF(request.OtherQueryCondition.EndDate != null, t => t.PayDataTime >= request.OtherQueryCondition.EndDate)
.Select(t => new GetBankStatementOutPut
{
Id = t.Id,
},true)
.ToQueryPageAsync(request.PageCondition);
return result;
}
/// <summary>
/// 获取银行账号列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<GetBankAccountListOutput>>> GetBankAccountList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable<BankStatement>()
.Where(t => t.OrgId == user.OrgId)
.GroupBy(it => new { it.BankName, it.AccountId }) //可以多字段
.Select(it => new GetBankAccountListOutput
{
BankName = it.BankName,
AccountId = it.AccountId
}).ToList();
return DataResult<List<GetBankAccountListOutput>>.Success(list);
}
}
}