using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.PTG;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhonTai.Admin.Core.Attributes;
using ZhonTai.Admin.Core.Consts;
using ZhonTai.Admin.Core.Dto;
using ZhonTai.Admin.Services.DiTuiAPI.Dto;
using ZhonTai.DynamicApi;
using ZhonTai.DynamicApi.Attributes;


#region <<版本注释>>
/* ---------------------------
* 版权所有 (c) 2023 Frank 保留所有权利。
* CLR版本:4.0.30319.42000
* 机器名称:FRANK-WIN
* 命名空间:ZhonTai.Admin.Services.DiTuiAPI
* 唯一标识:89d883e6-5d83-4a7d-beb9-c96342ee6822
* 
* 创建者:Frank
* 电子邮箱: cfrank227@gmail.com
* 创建时间:2023/5/19 10:19:34
--------------------------*/
#endregion <<版本注释>>

namespace ZhonTai.Admin.Services.DiTuiAPI
{
    /// <summary>
    /// 报表
    /// </summary>
    [DynamicApi(Area = AdminConsts.DiTuiName)]
    public class ReportFormService : BaseService, IReportFormService, IDynamicApi
    {
        /// <summary>
        /// 个人余额统计
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        [NoOprationLog]
        public async Task<PersonProfitSumOutput> PersonProfitSumAsync()
        {
            PersonProfitSumOutput personProfitSumOutput = new PersonProfitSumOutput();
            personProfitSumOutput.month_profit = 123.4.ToString();
            personProfitSumOutput.total_profit = 456.7.ToString();

            return personProfitSumOutput;

        }

        //,string startDate, string endDate
        /// <summary>
        /// 结算报表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [NoOprationLog]
        public async Task<List<PersonReportFormOutput>> PersonReportFormAsync(PersonReportFormInput input)
        {

            List<PersonReportFormOutput> personReportFormOutputs = new List<PersonReportFormOutput>();
            personReportFormOutputs.Add(new PersonReportFormOutput(1234, "汇总", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "1280.0", "1280", "1500"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1234, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1235, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1236, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1237, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1238, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1239, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1120, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1121, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(2213, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));
            personReportFormOutputs.Add(new PersonReportFormOutput(1123, "京东", "https://test-dt.zhongjie51.com/assetsImg/jd_logo.png", "128.0","128","150"));

            var data = new PageOutput<PersonReportFormOutput>()
            {
                List = personReportFormOutputs,
                Total = personReportFormOutputs.Count()
        };

            return personReportFormOutputs;
        }

        /// <summary>
        /// 每日统计
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [NoOprationLog]
        public async Task<PageOutput<DailyCountOutput>> DailyCountAsync(PageInput<DailyCountInput> input)
        {
            List<DailyCountOutput> list = new List<DailyCountOutput>();
            list.Add(new DailyCountOutput("2023-5-18","123.4","123"));
            list.Add(new DailyCountOutput("2023-5-17","12.3","12"));
            list.Add(new DailyCountOutput("2023-5-16","1","1"));
            list.Add(new DailyCountOutput("2023-5-15","1234.5","1234"));
            list.Add(new DailyCountOutput("2023-5-14","123.4","123"));
            list.Add(new DailyCountOutput("2023-5-13","123.4","123"));
            list.Add(new DailyCountOutput("2023-5-12","123.4","123"));
            list.Add(new DailyCountOutput("2023-5-11","123.4","123"));
            list.Add(new DailyCountOutput("2023-5-10","123.4","123"));

            var data = new PageOutput<DailyCountOutput>()
            {
                List = list,
                Total = list.Count()
            };

            return data;
        }

        /// <summary>
        /// 项目结算详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [NoOprationLog]
        public async Task<QrcodeSettleOutput> QrcodeSettleAsync(QrcodeSettleInput input)
        {
            QrcodeSettleOutput qrcodeSettleOutput = new QrcodeSettleOutput();
            List<ProjectPriceStandard> priceList = new List<ProjectPriceStandard>();
            priceList.Add(new ProjectPriceStandard(123,"新用户","75","28","208"));
            priceList.Add(new ProjectPriceStandard(122,"回流用户","30","22","200"));
            qrcodeSettleOutput.Total = "80";
            qrcodeSettleOutput.Valid = "38";
            qrcodeSettleOutput.Profit = "580";
            qrcodeSettleOutput.StandardPrice = priceList;

            return qrcodeSettleOutput;
        }
        /// <summary>
        /// 项目结算-推广码列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [NoOprationLog]
        public async Task<PageOutput<QrcodeSettleListOutput>> QrcodeSettleListAsync(PageInput<QrcodeSettleListInput> input)
        {
            List<QrcodeSettleListOutput> list = new List<QrcodeSettleListOutput>();

            QrcodeSettleListOutput QrcodeSettleListOutput = new QrcodeSettleListOutput();
            List<ProjectPriceStandard> priceList = new List<ProjectPriceStandard>();
            priceList.Add(new ProjectPriceStandard(123, "新用户", "75", "28", "208"));
            priceList.Add(new ProjectPriceStandard(122, "回流用户", "30", "22", "200"));
            priceList.Add(new ProjectPriceStandard(121, "统计", "105", "50", "408"));
            QrcodeSettleListOutput.Salesman = "DS-地瓜";
            QrcodeSettleListOutput.ApplyTime = "2023-05-03";
            QrcodeSettleListOutput.Id = 123;
            QrcodeSettleListOutput.StandardPrice = priceList;

            list.Add(QrcodeSettleListOutput);

            QrcodeSettleListOutput QrcodeSettleListOutput1 = new QrcodeSettleListOutput();
            List<ProjectPriceStandard> priceList1 = new List<ProjectPriceStandard>();
            priceList1.Add(new ProjectPriceStandard(123, "新用户", "75", "28", "208"));
            priceList1.Add(new ProjectPriceStandard(122, "回流用户", "30", "22", "200"));
            priceList1.Add(new ProjectPriceStandard(1, "统计", "105", "50", "501"));
            QrcodeSettleListOutput1.Salesman = "DS-土豆";
            QrcodeSettleListOutput1.ApplyTime = "2023-05-03";
            QrcodeSettleListOutput1.Id = 124;
            QrcodeSettleListOutput1.StandardPrice = priceList1;

            list.Add(QrcodeSettleListOutput1);

            QrcodeSettleListOutput QrcodeSettleListOutput2 = new QrcodeSettleListOutput();
            List<ProjectPriceStandard> priceList2 = new List<ProjectPriceStandard>();
            priceList2.Add(new ProjectPriceStandard(123, "新用户", "75", "28", "208"));
            priceList2.Add(new ProjectPriceStandard(122, "回流用户", "30", "22", "200"));
            priceList2.Add(new ProjectPriceStandard(122, "统计", "105", "50", "502"));
            QrcodeSettleListOutput2.Salesman = "DS-山药";
            QrcodeSettleListOutput2.ApplyTime = "2023-05-03";
            QrcodeSettleListOutput2.Id = 125;
            QrcodeSettleListOutput2.StandardPrice = priceList2;

            list.Add(QrcodeSettleListOutput2);

            var data = new PageOutput<QrcodeSettleListOutput>()
            {
                List = list,
                Total = list.Count()
            };


            return data;
        }

        // TODO  项目结算详情页的 推广码列表

        /// <summary>
        /// 项目推广码
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        //[HttpGet]
        //public async Task<PageOutput<ProjectQrcodePageOutput>> ProjectQrcodePageAsync(PageInput<ProjectQrcodePageInput> input)
        //{
        //    var keyWrods = input.Filter?.Keywords;

        //    string Salesman = null;
        //    string SalesmanPhone = null;
        //    //var Salesman = input.Filter?.Salesman;
        //    //var Salesman = input.Filter?.Salesman;
        //    //var SalesmanPhone = input.Filter?.SalesmanPhone;
        //    //var SalesmanPhone = input.Filter?.SalesmanPhone;
        //    //var SalesmanPhone = input.Filter?.SalesmanPhone;

        //    var ProjectId = input.Filter?.ProjectId;

        //    var list = _ProjectLinkRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
        //        .WhereIf(ProjectId.HasValue && ProjectId.Value > 0, a => a.ProjectId == ProjectId)
        //        .WhereIf(Salesman.NotNull(), a => a.Salesman.Contains(Salesman))
        //        .WhereIf(SalesmanPhone.NotNull(), a => a.SalesmanPhone.Contains(SalesmanPhone))
        //    .Count(out var total)
        //    .Page(input.CurrentPage, input.PageSize)
        //    .ToList(m => new ProjectQrcodePageOutput()
        //    {
        //        Id = m.Id,
        //        Salesman = m.Salesman,
        //        UseTime = m.UseTime,
        //        QrcodeUrl = m.QrcodeUrl,
        //        QueryUrl = m.QueryUrl
        //    });

        //    var data = new PageOutput<ProjectQrcodePageOutput>()
        //    {
        //        List = list,
        //        Total = total
        //    };

        //    return data;
        //}


    }
}
