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.Main;
using LitJson;
using Library;
using System.Data;
using MySystem.Service.Main;

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

        #region 工作台-主界面统计数据
        // [Authorize]
        public JsonResult IndexStat(string value)
        {
            value = DesDecrypt(value);
            value = value.Replace("null", "\"\"");
            JsonData data = JsonMapper.ToObject(value);
            Dictionary<string, object> Obj = IndexStatDo(value);
            return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
        }
        public Dictionary<string, object> IndexStatDo(string value)
        {
            JsonData data = JsonMapper.ToObject(value);
            string TimeType = data["TimeType"].ToString(); //时间范围
            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
            var Info = WorkSpaceUtil.IndexStat(TimeType, MerchantId);
            return Info;
        }
        #endregion


        #region 工作台-商户活动参数
        // [Authorize]
        public JsonResult Detail(string value)
        {
            value = DesDecrypt(value);
            value = value.Replace("null", "\"\"");
            JsonData data = JsonMapper.ToObject(value);
            Dictionary<string, object> Obj = DetailDo(value);
            return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
        }
        public Dictionary<string, object> DetailDo(string value)
        {
            JsonData data = JsonMapper.ToObject(value);
            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
            var Info = WorkSpaceUtil.Detail(MerchantId);
            return Info;
        }
        #endregion

    }
}
