using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Data;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using MySystem.PxcModels;
using System.Threading;
using Library;
using LitJson;
using System.Security.Cryptography;

namespace MySystem.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Error()
        {
            string isapi = Request.Headers["Api"].ToString();
            if (isapi != "1")
            {
                if (Response.StatusCode == 500)
                {
                    return Redirect("/public/errpage/pc/500.html");
                }
                else if (Response.StatusCode == 502)
                {
                    return Redirect("/public/errpage/pc/502.html");
                }
                else if (Response.StatusCode == 404)
                {
                    return Redirect("/public/errpage/pc/404.html");
                }
            }
            return View();
        }
      



        public string test()
        {
            List<string> poslist = new List<string>();
            poslist.Add("M00000000000034");
            string result = PublicImportDataService.Instance.PospFee(poslist, "LKB_0.63+3", "联客宝");

            if(result.Contains("\"content\""))
            {
                JsonData jsonObj = JsonMapper.ToObject(result);
                result += EncryptHelper.AesDecrypt(jsonObj["content"].ToString(), "6v8cr0uyhtwtawda");
            }

            // string result = PublicImportDataService.Instance.PospQueryServiceFee();
            // result += "\n\n";
            // result += PublicImportDataService.Instance.PospQueryFee();

            // {"deposit_change_time":"2023-12-26 21:51:04","agent_id":"V1703471325","deposit_list":[{"deposit_id":"LKB_000","deposit_name":"联客宝","supplement_info":"LKB_000"},{"deposit_id":"LKB_99","deposit_name":"联客宝","supplement_info":"LKB_99"},{"deposit_id":"LKB_199","deposit_name":"联客宝","supplement_info":"LKB_199"},{"deposit_id":"LKB_0.63+3","deposit_name":"联客宝","supplement_info":"LKB_0.63+3"},{"deposit_id":"LKB_0.6+0","deposit_name":"联客宝0.6+0","supplement_info":"LKB_0.6+0"},{"deposit_id":"LKB_0.63+0","deposit_name":"联客宝0.63+0","supplement_info":"LKB_0.63+0"},{"deposit_id":"LKB_299","deposit_name":"联客宝299押金","supplement_info":"LKB_299"}]}

            // {"plan_change_time":"2023-12-26 21:51:04","agent_id":"V1703471325","plan_list":[{"plan_id":"LKB_000","plan_name":"联客宝","supplement_info":"LKB_000"},{"plan_id":"LKB_99","plan_name":"联客宝","supplement_info":"LKB_99"},{"plan_id":"LKB_199","plan_name":"联客宝","supplement_info":"LKB_199"},{"plan_id":"LKB_0.63+3","plan_name":"联客宝","supplement_info":"LKB_0.63+3"},{"plan_id":"LKB_0.6+0","plan_name":"联客宝0.6+0","supplement_info":"LKB_0.6+0"},{"plan_id":"LKB_0.63+0","plan_name":"联客宝0.63+0","supplement_info":"LKB_0.63+0"},{"plan_id":"LKB_299","plan_name":"联客宝299押金","supplement_info":"LKB_299"}]}

            return result;
        }

        
    
    
    }
}