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 MerchantInfoController : BaseController
    {
        public MerchantInfoController(IHttpContextAccessor accessor) : base(accessor)
        {
        }

        #region 商户激活-直连达标商户列表
        [Authorize]
        public JsonResult DirectQualifiedMerchants(string value)
        {
            value = PublicFunction.DesDecrypt(value); ;
            JsonData data = JsonMapper.ToObject(value);
            List<Dictionary<string, object>> dataList = DirectQualifiedMerchantsDo(value);
            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
        }
        private List<Dictionary<string, object>> DirectQualifiedMerchantsDo(string value)
        {
            JsonData data = JsonMapper.ToObject(value);
            string MerchantName = data["MerchantName"].ToString(); //商户名称
            string MctNo = data["MctNo"].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 = MerchantInfoService.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("MerchantName", ""); //商户名称
                curData.Add("MctNo", ""); //商户号
                curData.Add("UpdateDate", ""); //激活时间
                curData.Add("PayMode", ""); //支付方式(1 支付宝 2 微信)
                curData.Add("Status", ""); //达标状态(-1 未参与 0 考核中 1 已通过 2 未通过 101 待领取 100 已领取 99 发放中)
                curData.Add("Months", ""); //达标月数

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


    }
}
