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

namespace OASystem.Infrastructure.Repositories.Financial
{
    /// <summary>
    /// 财务 - 其他款项
    /// </summary>
    public class OtherPriceRepository:BaseRepository<Fin_OtherPrice,Fin_OtherPriceView>
    {
        private readonly IMapper _mapper;

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

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

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

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

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

            return result;

        }
    }
}