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

namespace Mall.Repository.Product
{
    /// <summary>
    /// 订单支付信息仓储层
    /// </summary>
    public class RB_Goods_Online_TradeRepository : BaseRepository<RB_Goods_Online_Trade>
    {

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="dmodel"></param>
        /// <returns></returns>
        public List<RB_Goods_Online_Trade_Extend> GetList(RB_Goods_Online_Trade_Extend dmodel)
        {
            string where = $" 1=1 ";
            if (dmodel.TenantId > 0)
            {
                where += $@" and {nameof(RB_Goods_Online_Trade.TenantId)}={dmodel.TenantId}";
            }
            if (dmodel.MallBaseId > 0)
            {
                where += $@" and {nameof(RB_Goods_Online_Trade.MallBaseId)}={dmodel.MallBaseId}";
            }
            if (dmodel.Type > 0)
            {
                where += $@" and {nameof(RB_Goods_Online_Trade.Type)}={dmodel.Type}";
            }
            if (dmodel.User_Id > 0)
            {
                where += $@" and {nameof(RB_Goods_Online_Trade.User_Id)}={dmodel.User_Id}";
            }            

            string sql = $@"SELECT * FROM RB_Goods_Online_Trade where {where} order by Id asc";
            return Get<RB_Goods_Online_Trade_Extend>(sql).ToList();
        }
    }
}
