using APT.BaseData.Domain.Entities.OP;
using APT.Infrastructure.Core;
using APT.Utility;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;

namespace CMS.OP.WebApi.Controllers.Api
{
    [Route("api/OP/OPRechargeCard")]
    public partial class RechargeCardController : AuthorizeApiController<T_OP_RECHARGE_CARD>
    {
        /// <summary>
        /// 排序分页查询数据
        /// </summary>
        /// <param name="pageFilter">分页过滤实体</param>
        /// <returns></returns>
        [HttpPost, Route("OrderPagedNoSelect")]
        public PagedActionResult<T_OP_RECHARGE_CARD> OrderPagedNoSelect([FromBody] KeywordPageFilter pageFilter)
        {
            return SafeGetPagedData<T_OP_RECHARGE_CARD>((result) =>
            {
                var filter = new BaseFilter(pageFilter.OrgId)
                {
                    SelectField = new string[] { "RECHARGE_CARD_ID" }
                };
                var member = GetEntities<T_OP_MEMBER>(x => x.RECHARGE_CARD_ID != null, filter);
                var card = GetOrderPageEntities<T_OP_RECHARGE_CARD>(x => !member.Select(y => y.RECHARGE_CARD_ID).Contains(x.ID), pageFilter);
                result.Data = card.Data;
                result.TotalCount = card.TotalCount;
            });
        }
    }
}
