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
{
///
/// 银行流水相关
///
public class BankStatementService : IBankStatementService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISaasDbService saasService;
private readonly IUser user;
private readonly ISqlSugarClient db;
///
/// 初始化
///
///
public BankStatementService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
saasService = _serviceProvider.GetRequiredService();
db = _serviceProvider.GetRequiredService();
user = _serviceProvider.GetRequiredService();
}
///
/// 获取银行流水列表
///
///
///
///
public async Task>> GetBankStatementList(PageRequest request)
{
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var result = await tenantDb.Queryable()
.Where(whereList)
.Where(t => t.OrgId == user.OrgId)
//.WhereIF(!string.IsNullOrWhiteSpace(request.OtherQueryCondition.AccountId), t => t.AccountId == request.OtherQueryCondition.AccountId)//银行账户
//.WhereIF(!string.IsNullOrWhiteSpace(request.OtherQueryCondition.TransactionType), t => t.TransactionType.Contains(request.OtherQueryCondition.TransactionType))//交易类型
//.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;
}
///
/// 获取银行账号列表
///
///
///
public async Task>> GetBankAccountList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable()
.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>.Success(list);
}
}
}