using MySystem.Models.Main2;
using Library;
using MySystem.Service.Main2;
using System.Collections.Generic;
using System;
using LitJson;
using MySystem.Areas.Api.Controllers;

namespace MySystem
{
    /// <summary>
    /// 我的工具类
    /// </summary>
    public class MySelfUtil
    {
        #region 到账记录列表
        /// <summary>
        /// 到账记录列表
        /// </summary>
        /// <returns></returns>
        public static List<Dictionary<string, object>> CardInComeRecordList(int MerchantId, string StartDate, string EndDate, string pageSize, string pageNum)
        {
            var merchantInfo = MerchantAddInfoService.Query(MerchantId);
            var SubjectType = 0;
            if (merchantInfo.SubjectType == "SUBJECT_TYPE_ENTERPRISE") SubjectType = 1; //企业公司
            if (merchantInfo.SubjectType == "SUBJECT_TYPE_INDIVIDUAL") SubjectType = 2; //个体工商户
            if (merchantInfo.SubjectType == "SUBJECT_TYPE_SMALL") SubjectType = 3; //小微
            JsonData Info = JsonMapper.ToObject(HaoDaHelper.Instance.CardInComeRecord(merchantInfo.OutMchtNo, StartDate, EndDate, merchantInfo.MchtNo, "", "", pageNum, pageSize));
            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
            if (Info["code"].ToString() == "0")
            {
                var list = Info["data"]["list"];
                for (int i = 0; i < list.Count; i++)
                {
                    Dictionary<string, object> curData = new Dictionary<string, object>();
                    var item = list[i];
                    if (item["settleAccountName"].ToString() != "四川省润观米科技有限公司")
                    {
                        curData.Add("TradeNo", item["id"].ToString()); //订单Id
                        curData.Add("SettleStatus", item["settleStatus"].ToString()); //结算状态(0: 入账成功、1: 入账失败、2: 结算超时、3: 入账受理成功、4: 已提交结算请求、5:已拆分批次、6: 初始化批次信息、7:正在提交结算请求)
                        curData.Add("MerchantName", merchantInfo.CertMerchantName); //商户名称
                        curData.Add("ClearTime", item["clearTime"].ToString()); //处理时间
                        curData.Add("RemitTime", item["remitTime"].ToString()); //到账时间
                        curData.Add("SettleDate", item["settleDate"].ToString().Substring(item["settleDate"].ToString().Length - 5, 5)); //结算日期
                        curData.Add("SettleAmount", (decimal.Parse(item["settleAmount"].ToString()) / 100).ToString("f2")); //结算金额
                        curData.Add("SubjectType", SubjectType); //进件类型(1 企业 2 个体 3 小微)
                        curData.Add("CardNo", item["cardNo"].ToString()); //结算卡号
                        curData.Add("TradeMchtName", item["tradeMchtName"].ToString()); //收单商户名称
                        curData.Add("BankName", item["bankName"].ToString()); //开户行名称
                        dataList.Add(curData);
                    }
                }
            }
            return dataList;
        }
        #endregion


    }
}