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;

namespace Edu.Repository.Sell
{
    /// <summary>
    /// 订单阶梯价格仓储层
    /// </summary>
    public class RB_Order_StepPriceRepository : BaseRepository<RB_Order_StepPrice>
    {
        /// <summary>
        /// 获取订单阶梯价格列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Order_StepPrice_ViewModel> GetList(RB_Order_StepPrice_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat(@" 
SELECT *
FROM RB_Order_StepPrice
WHERE 1=1
");
            if (query != null)
            {
                if (query.OrderId>0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Order_StepPrice_ViewModel.OrderId), query.OrderId);
                }
                if (!string.IsNullOrEmpty(query.Q_OrderIds))
                {
                    builder.AppendFormat(" AND {0} IN ({1}) ", nameof(RB_Order_StepPrice_ViewModel.OrderId), query.Q_OrderIds);
                }
            }
            return Get<RB_Order_StepPrice_ViewModel>(builder.ToString()).ToList();
        }
    }
}
