using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Authorization;
using System.Web;
using MySystem.Models.Main1;
using MySystem.Service.Main1;
using LitJson;
using Library;

namespace MySystem.Areas.Api.Controllers.v1.Main1
{
    [Area("Api")]
    [Route("/v1/QrCodePlateMain/[controller]/[action]")]
    public class MerchantAmountSummayController : BaseController
    {
        public MerchantAmountSummayController(IHttpContextAccessor accessor) : base(accessor)
        {
        }


        #region 交易统计-直连商户交易统计
        [Authorize]
        public JsonResult DirectMerchantTradeSummaryList(string value)
        {
            value = PublicFunction.DesDecrypt(value); ;
            JsonData data = JsonMapper.ToObject(value);
            List<Dictionary<string, object>> dataList = DirectMerchantTradeSummaryListDo(value);
            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
        }
        private List<Dictionary<string, object>> DirectMerchantTradeSummaryListDo(string value)
        {
            JsonData data = JsonMapper.ToObject(value);
            string MerchantName = data["MerchantName"].ToString(); //商户名称
            string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
            string TradeDate = data["TradeDate"].ToString(); //交易日期
            int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
            int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
            string condition = "";
            List<RelationData> relationData = new List<RelationData>();
            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
            List<Dictionary<string, object>> source = MerchantAmountSummayService.List(relationData, condition, pageNum, pageSize);
            foreach (Dictionary<string, object> subdata in source)
            {
                Dictionary<string, object> curData = new Dictionary<string, object>();
                curData.Add("", subdata[""].ToString()); //
                curData.Add("TradeDate", ""); //交易日期
                curData.Add("MerchantName", ""); //商户名称
                curData.Add("TodayAmount", ""); //当日总收入
                curData.Add("TotalAmount", ""); //营收总金额
                curData.Add("InFactAmount", ""); //实收总金额
                curData.Add("ActAmount", ""); //活动交易额
                curData.Add("NonActAmount", ""); //非活动交易额
                curData.Add("WeChatInFactAmount", ""); //微信实收
                curData.Add("AliPayInFactAmount", ""); //支付宝实收
                curData.Add("OrderCount", ""); //订单总数

                dataList.Add(curData);
            }
            return dataList;
        }
        #endregion

    }
}
