using AutoMapper;
using OASystem.Domain;
using OASystem.Domain.Entities.Financial;
using OASystem.Domain.ViewModels.Financial;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OASystem.Infrastructure.Repositories.Financial
{
    /// <summary>
    /// 财务 - 团组应收款项 仓库
    /// 雷怡 2023.08.16 15:03
    /// </summary>
    public class ForeignReceivablesRepository:BaseRepository<Fin_ForeignReceivables,Fin_ForeignReceivablesView>
    {
        private readonly IMapper _mapper;

        public ForeignReceivablesRepository(SqlSugarClient sqlSugar, IMapper mapper)
            :base(sqlSugar)
        {
            _mapper = mapper;
        }

        /// <summary>
        /// 根据diid查询团组已收收款项
        /// </summary>
        /// <param name="diid"></param>
        /// <returns></returns>
        public async Task<Result> GetGroupReceivablesByDiid(int diid)
        {
            Result result = new() { Code = -2 };

            string sql = string.Format(@"Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0}", diid);

            var groupReceivedList = await _sqlSugar.SqlQueryable<Fin_ProceedsReceivedView>(sql).ToListAsync();

            result.Code = 0;
            result.Msg = "查询成功!";
            result.Data = groupReceivedList;

            return result;

        }
    }
}