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

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



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

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