using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;

namespace Mall.Repository.Product
{
    public class RB_Invoice_RecordDetailRepository:BaseRepository<RB_Invoice_RecordDetail>
    {
        /// <summary>
        /// 表名称
        /// </summary>
        public string TableName { get { return nameof(RB_Invoice_RecordDetail); } }
        /// <summary>
        /// 
        /// 获取列表
        /// </summary>
        /// <param name="dmodel"></param>
        /// <returns></returns>
        public List<RB_Invoice_RecordDetail_Extend> GetList(RB_Invoice_RecordDetail_Extend dmodel)
        {
            string where = $" where 1=1  ";
            if (dmodel.TenantId > 0)
            {
                where += $@" and {nameof(RB_Invoice_RecordDetail_Extend.TenantId)}={dmodel.TenantId}";
            }
            if (dmodel.MallBaseId > 0)
            {
                where += $@" and {nameof(RB_Invoice_RecordDetail_Extend.MallBaseId)}={dmodel.MallBaseId}";
            }
            if (dmodel.Type > 0)
            {
                where += $@" and {nameof(RB_Invoice_RecordDetail_Extend.Type)}={dmodel.Type}";
            }
            if (!string.IsNullOrWhiteSpace(dmodel.OrderDetailIds))
            {
                where += $@" and {nameof(RB_Invoice_RecordDetail_Extend.OrderDetailId)} in ({dmodel.OrderDetailIds})";
            }
            string sql = $@"SELECT * FROM {TableName}  {where} order by Id asc";
            return Get<RB_Invoice_RecordDetail_Extend>(sql).ToList();
        }

    }
}
