using AutoMapper;
using OASystem.Domain;
using OASystem.Domain.Dtos.Groups;
using OASystem.Domain.Entities.Financial;
using OASystem.Domain.ViewModels.Financial;
using OASystem.Infrastructure.Repositories.Groups;
using OASystem.Infrastructure.Repositories.System;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OASystem.Infrastructure.Repositories.Financial
{
///
/// 财务 - 团组应收款项 仓库
/// 雷怡 2023.08.16 15:03
///
public class ForeignReceivablesRepository : BaseRepository
{
private readonly IMapper _mapper;
private readonly DelegationInfoRepository _delegationRep;
private readonly SetDataRepository _setDataRep;
public ForeignReceivablesRepository(SqlSugarClient sqlSugar, IMapper mapper, DelegationInfoRepository delegationRep, SetDataRepository setDataRep)
: base(sqlSugar)
{
_mapper = mapper;
_delegationRep = delegationRep;
_setDataRep = setDataRep;
}
///
/// 收款账单 数据源
///
///
public async Task GetDataSource()
{
Result result = new() { Code = -2 };
var groupNameData = await _delegationRep.GetGroupNameList(new GroupNameDto());
var currencyData = await _setDataRep.GetSetDataBySTId(_setDataRep,66); //币种
var remittanceMethodData = await _setDataRep.GetSetDataBySTId(_setDataRep, 14); //汇款方式
result.Code = 0;
result.Msg = "成功!";
result.Data = new {
GroupNameData= groupNameData.Data,
CurrencyData = currencyData.Data,
RemittanceMethodData = remittanceMethodData.Data
};
return result;
}
///
/// 根据diid查询团组应收款项
///
///
///
public async Task GetGroupReceivablesByDiid(int diid)
{
Result result = new() { Code = -2 };
string sql = string.Format(@"Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0}", diid);
var groupReceivedList = await _sqlSugar.SqlQueryable(sql).ToListAsync();
result.Code = 0;
result.Msg = "查询成功!";
result.Data = groupReceivedList;
return result;
}
///
/// 根据diid 数组 查询团组应收款项
///
///
///
public async Task GetGroupReceivablesByDiids(int[] diids)
{
Result result = new() { Code = -2 };
//string sql = string.Format(@"Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0}", diids);
var groupReceivedList = await _sqlSugar.Queryable()
.Where(pr => pr.IsDel == 0 && diids.Contains(pr.Diid)).ToListAsync();
result.Code = 0;
result.Msg = "查询成功!";
result.Data = groupReceivedList;
return result;
}
}
}