using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.Entity.Sell;
using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Sell;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;

namespace Edu.Repository.Sell
{
    /// <summary>
    /// 销售提成规则仓储层
    /// </summary>
    public class RB_Sell_StudyAbroad_RuleRepository : BaseRepository<RB_Sell_StudyAbroad_Rule>
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="demodel"></param>
        /// <returns></returns>
        public List<RB_Sell_StudyAbroad_Rule_ViewModel> GetList(RB_Sell_StudyAbroad_Rule_ViewModel demodel)
        {
            string where = $@" 1=1";
            
            if (demodel.Group_Id > 0)
            {
                where += $@" and r.{nameof(RB_Sell_StudyAbroad_Rule_ViewModel.Group_Id)} ={demodel.Group_Id}";
            }
            if (demodel.OrderType > 0)
            {
                where += $@" and r.{nameof(RB_Sell_StudyAbroad_Rule_ViewModel.OrderType)} ={demodel.OrderType}";
            }
            if (demodel.CommissionType > 0)
            {
                where += $@" and r.{nameof(RB_Sell_StudyAbroad_Rule_ViewModel.CommissionType)} ={demodel.CommissionType}";
            }

            string sql = $@" select r.* from RB_Sell_StudyAbroad_Rule r where {where} order by r.Id desc";
            return Get<RB_Sell_StudyAbroad_Rule_ViewModel>(sql).ToList();
        }

    }
}
