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

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



        /// <summary>
        /// 会员卡包
        /// </summary>
        /// <returns></returns>
        public List<RB_Reserve_MemberCardBag_Extend> GetList(RB_Reserve_MemberCardBag_Extend query)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append($"   and a.`Status`=0 ");
            if (query != null)
            {
                if (query.TenantId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Reserve_MemberCardBag_Extend.TenantId)}={query.TenantId}");
                }
                if (query.TenantId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Reserve_MemberCardBag_Extend.MallBaseId)}={query.MallBaseId}");
                }
               
                if (query.UserId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Reserve_MemberCardBag_Extend.UserId)}={query.UserId}");
                }
                if (query.CouponId > 0)
                {
                    builder.Append($" AND a.{nameof(RB_Reserve_MemberCardBag_Extend.CouponId)}={query.CouponId}");
                }
                if (!string.IsNullOrEmpty(query.CouponIds))
                {
                    builder.Append($" AND a.{nameof(RB_Reserve_MemberCardBag_Extend.CouponId)} in ({query.CouponIds})");
                }
                if (!string.IsNullOrEmpty(query.Ids))
                {
                    builder.Append($" AND a.{nameof(RB_Reserve_MemberCardBag_Extend.Id)} in ({query.Ids})");
                }
                if (query.UseState >= 0)
                {
                    builder.Append($" AND a.{nameof(RB_Reserve_MemberCardBag_Extend.UseState)}={query.UseState}");
                }
            }
            string sql = @$" select * FROM {TableName} AS a  where 1=1 {builder.ToString()} ";
            return Get<RB_Reserve_MemberCardBag_Extend>(sql).ToList();
        }

    }
}
