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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Sell
{
///
/// 教务奖励仓储层
///
public class RB_Teaching_BonusRepository : BaseRepository
{
///
/// 获取列表
///
///
///
public List GetList(RB_Teaching_Bonus_ViewModel demodel)
{
string where = $@" 1=1";
if (demodel.Group_Id > 0)
{
where += $@" and {nameof(RB_Teaching_Bonus.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.School_Id > 0)
{
where += $@" and {nameof(RB_Teaching_Bonus.School_Id)} ={demodel.School_Id}";
}
if (!string.IsNullOrEmpty(demodel.Month))
{
where += $@" and {nameof(RB_Teaching_Bonus.Month)} ='{demodel.Month}'";
}
if (demodel.TeacherId > 0)
{
where += $@" and FIND_IN_SET('{demodel.TeacherId}',{nameof(RB_Teaching_Bonus.TeacherIds)})";
}
if (demodel.State > 0)
{
where += $@" and {nameof(RB_Teaching_Bonus.State)} ={(int)demodel.State}";
}
string sql = $@" select * from RB_Teaching_Bonus where {where} order by Id desc";
return Get(sql).ToList();
}
///
/// 获取分页列表
///
///
///
///
///
///
public List GetPageList(int pageIndex,int pageSize,out long count,RB_Teaching_Bonus_ViewModel demodel)
{
string where = $@" 1=1";
if (demodel.Group_Id > 0)
{
where += $@" and {nameof(RB_Teaching_Bonus.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.School_Id > 0)
{
where += $@" and {nameof(RB_Teaching_Bonus.School_Id)} ={demodel.School_Id}";
}
if (!string.IsNullOrEmpty(demodel.Month))
{
where += $@" and {nameof(RB_Teaching_Bonus.Month)} ='{demodel.Month}'";
}
if (demodel.TeacherId > 0)
{
where += $@" and FIND_IN_SET('{demodel.TeacherId}',{nameof(RB_Teaching_Bonus.TeacherIds)})";
}
if (demodel.State > 0)
{
where += $@" and {nameof(RB_Teaching_Bonus.State)} ={(int)demodel.State}";
}
string sql = $@" select * from RB_Teaching_Bonus where {where} order by Id desc";
return GetPage(pageIndex, pageSize, out count, sql).ToList();
}
///
/// 获取教师最近几月的走势图
///
///
///
///
///
public List GetTeachingBonusLastlyChart(int id, int group_Id, string monthStr)
{
string sql = $@"select b.`Month`,SUM(bd.Money) AS Money
from RB_Teaching_BonusDetail bd
INNER JOIN rb_teaching_bonus b on bd.BonusId = b.Id
where bd.`Status`=0 AND bd.Group_Id ={group_Id} AND b.State=2 AND bd.TeacherId ={id} AND b.`Month` in ({monthStr})
GROUP BY b.`Month` ORDER BY b.`Month` DESC";
return Get(sql).ToList();
}
}
}