using Mall.Model.Entity.Education;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mall.Repository.Education
{
  public  class RB_Education_MemberUseCouponRepository:BaseRepository<RB_Education_MemberUseCoupon>
    {
        /// 表名称
        /// </summary>
        public string TableName { get { return nameof(RB_Education_MemberUseCoupon); } }



        /// <summary>
        /// 会员优惠券
        /// </summary>
        /// <returns></returns>
        public List<RB_Education_MemberUseCoupon> GetList(RB_Education_MemberUseCoupon query)
        {
            StringBuilder builder = new StringBuilder();
            if (query != null)
            {
                if (query.TenantId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Education_MemberUseCoupon.TenantId)}={query.TenantId}");
                }
                if (query.TenantId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Education_MemberUseCoupon.MallBaseId)}={query.MallBaseId}");
                }
                
                if (query.UserId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Education_MemberUseCoupon.UserId)}={query.UserId}");
                }
                if (query.MemberCouponId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Education_MemberUseCoupon.MemberCouponId)}={query.MemberCouponId}");
                }
                if (query.OrderId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Education_MemberUseCoupon.OrderId)}={query.OrderId}");
                }

            }
            string sql = @$" select * FROM {TableName} AS a  where 1=1 and a.Status=0 {builder.ToString()} ";
            return Get<RB_Education_MemberUseCoupon>(sql).ToList();
        }
    }
}
