/*
 * 商户进件资料
 */

using System;
using System.Web;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MySystem.Models;
using Library;
using LitJson;
using MySystemLib;

namespace MySystem.Areas.Admin.Controllers
{
    [Area("Admin")]
    [Route("Admin/[controller]/[action]")]
    public class MerchantAddInfoController : BaseController
    {
        public MerchantAddInfoController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
        {
            OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
        }

        #region 商户进件资料列表

        /// <summary>
        /// 根据条件查询商户进件资料列表
        /// </summary>
        /// <returns></returns>
        public IActionResult Index(MerchantAddInfo data, string right)
        {
            ViewBag.RightInfo = RightInfo;
            ViewBag.right = right;

            return View();
        }

        #endregion

        #region 根据条件查询商户进件资料列表

        /// <summary>
        /// 商户进件资料列表
        /// </summary>
        /// <returns></returns>
        public JsonResult IndexData(MerchantAddInfo data, string ApplymentStateSelect, int page = 1, int limit = 30)
        {

            Dictionary<string, string> Fields = new Dictionary<string, string>();

            Fields.Add("CreateDate", "3"); //时间


            string condition = " and Status>-1";
            //申请单状态
            if (!string.IsNullOrEmpty(ApplymentStateSelect))
            {
                condition += " and ApplymentState=" + ApplymentStateSelect;
            }


            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("MerchantAddInfo", Fields, "Id desc", "0", page, limit, condition);
            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
            foreach (Dictionary<string, object> dic in diclist)
            {
                dic["StatusName"] = dic["Status"].ToString() == "1" ? "正常" : "关闭";
                //申请单状态
                string ApplymentState = dic["ApplymentState"].ToString();
                if (ApplymentState == "APPLYMENT_STATE_EDITTING") dic["ApplymentState"] = "编辑中";
                if (ApplymentState == "APPLYMENT_STATE_AUDITING") dic["ApplymentState"] = "审核中";
                if (ApplymentState == "APPLYMENT_STATE_REJECTED") dic["ApplymentState"] = "已驳回";
                if (ApplymentState == "APPLYMENT_STATE_TO_BE_CONFIRMED") dic["ApplymentState"] = "待账户验证";
                if (ApplymentState == "APPLYMENT_STATE_TO_BE_SIGNED") dic["ApplymentState"] = "待签约";
                if (ApplymentState == "APPLYMENT_STATE_SIGNING") dic["ApplymentState"] = "开通权限中";
                if (ApplymentState == "APPLYMENT_STATE_FINISHED") dic["ApplymentState"] = "已完成";
                if (ApplymentState == "APPLYMENT_STATE_CANCELED") dic["ApplymentState"] = "已作废";
                if (ApplymentState == "") dic["ApplymentState"] = "";

            }
            return Json(obj);
        }

        #endregion

        #region 增加商户进件资料

        /// <summary>
        /// 增加或修改商户进件资料信息
        /// </summary>
        /// <returns></returns>
        public IActionResult Add(string right)
        {
            ViewBag.RightInfo = RightInfo;
            ViewBag.right = right;


            return View();
        }

        #endregion

        #region 增加商户进件资料

        /// <summary>
        /// 增加或修改商户进件资料信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Add(MerchantAddInfo data)
        {
            Dictionary<string, object> Fields = new Dictionary<string, object>();

            Fields.Add("ContactName", data.ContactName); //管理员姓名
            Fields.Add("ContactIdNumber", data.ContactIdNumber); //管理员身份证件号码
            Fields.Add("OpenId", data.OpenId); //管理员微信openid
            Fields.Add("MobilePhone", data.MobilePhone); //联系手机
            Fields.Add("ContactEmail", data.ContactEmail); //联系邮箱
            Fields.Add("SubjectType", data.SubjectType); //主体类型
            Fields.Add("LicenseCopy", data.LicenseCopy); //营业执照照片
            Fields.Add("LicenseNumber", data.LicenseNumber); //统一社会信用代码
            Fields.Add("LegalPerson", data.LegalPerson); //个体户经营者/法人姓名
            Fields.Add("CertCopy", data.CertCopy); //登记证书照片
            Fields.Add("CertType", data.CertType); //登记证书类型
            Fields.Add("CertNumber", data.CertNumber); //证书号
            Fields.Add("CertMerchantName", data.CertMerchantName); //商户名称
            Fields.Add("CompanyAddress", data.CompanyAddress); //注册地址
            Fields.Add("CertLegalPerson", data.CertLegalPerson); //法人姓名
            Fields.Add("PeriodBegin", data.PeriodBegin); //有效期限开始日期
            Fields.Add("PeriodEnd", data.PeriodEnd); //有效期限结束日期
            Fields.Add("OrganizationCopy", data.OrganizationCopy); //组织机构代码证照片
            Fields.Add("OrganizationCode", data.OrganizationCode); //组织机构代码
            Fields.Add("OrgPeriodBegin", data.OrgPeriodBegin); //组织机构代码证有效期开始日期
            Fields.Add("OrgPeriodEnd", data.OrgPeriodEnd); //组织机构代码证有效期结束日期
            Fields.Add("CertificateLetterCopy", data.CertificateLetterCopy); //单位证明函照片
            Fields.Add("IdDocType", data.IdDocType); //证件类型
            Fields.Add("IdCardCopy", data.IdCardCopy); //身份证人像面照片
            Fields.Add("IdCardNational", data.IdCardNational); //身份证国徽面照片
            Fields.Add("IdCardName", data.IdCardName); //身份证姓名
            Fields.Add("IdCardNumber", data.IdCardNumber); //身份证号码
            Fields.Add("CardPeriodBegin", data.CardPeriodBegin); //身份证有效期开始时间
            Fields.Add("CardPeriodEnd", data.CardPeriodEnd); //身份证有效期结束时间
            Fields.Add("Owner", data.Owner); //经营者/法人是否为受益人
            Fields.Add("UboInfoIdType", data.UboInfoIdType); //最终受益人证件类型
            Fields.Add("UboInfoIdCardCopy", data.UboInfoIdCardCopy); //最终受益人身份证人像面照片
            Fields.Add("UboInfoIdCardNational", data.UboInfoIdCardNational); //身份证国徽面照片
            Fields.Add("UboInfoIdDocCopy", data.UboInfoIdDocCopy); //最终受益人证件照片
            Fields.Add("UboInfoName", data.UboInfoName); //受益人姓名
            Fields.Add("UboInfoIdNumber", data.UboInfoIdNumber); //最终受益人证件号码
            Fields.Add("UboInfoIdPeriodBegin", data.UboInfoIdPeriodBegin); //证件有效期开始时间
            Fields.Add("UboInfoIdPeriodEnd", data.UboInfoIdPeriodEnd); //证件有效期结束时间
            Fields.Add("MerchantShortname", data.MerchantShortname); //商户简称
            Fields.Add("ServicePhone", data.ServicePhone); //客服电话
            Fields.Add("SalesScenesType", data.SalesScenesType); //经营场景类型
            Fields.Add("BizStoreName", data.BizStoreName); //门店名称
            Fields.Add("BizAddressCode", data.BizAddressCode); //门店省市编码
            Fields.Add("BizStoreAddress", data.BizStoreAddress); //门店地址
            Fields.Add("StoreEntrancePic", data.StoreEntrancePic); //门店门头照片
            Fields.Add("IndoorPic", data.IndoorPic); //店内环境照片
            Fields.Add("BizSubAppid", data.BizSubAppid); //线下场所对应的商家APPID
            Fields.Add("MpAppid", data.MpAppid); //服务商公众号APPID
            Fields.Add("MpSubAppid", data.MpSubAppid); //商家公众号APPID
            Fields.Add("MpPics", data.MpPics); //公众号页面截图
            Fields.Add("MiniProgramAppid", data.MiniProgramAppid); //服务商小程序APPID
            Fields.Add("MiniProgramSubAppid", data.MiniProgramSubAppid); //商家小程序APPID
            Fields.Add("MiniProgramPics", data.MiniProgramPics); //小程序截图
            Fields.Add("AppAppid", data.AppAppid); //服务商应用APPID
            Fields.Add("AppSubAppid", data.AppSubAppid); //商家应用APPID
            Fields.Add("AppPics", data.AppPics); //APP截图
            Fields.Add("WebDomain", data.WebDomain); //互联网网站域名
            Fields.Add("WebAuthorisation", data.WebAuthorisation); //网站授权函
            Fields.Add("WebAppId", data.WebAppId); //互联网网站对应的商家APPID
            Fields.Add("SubCorpId", data.SubCorpId); //商家企业微信CorpID
            Fields.Add("WeworkPics", data.WeworkPics); //企业微信页面截图
            Fields.Add("SettlementId", data.SettlementId); //入驻结算规则ID
            Fields.Add("QualificationType", data.QualificationType); //所属行业
            Fields.Add("Qualifications", data.Qualifications); //特殊资质图片
            Fields.Add("ActivitiesId", data.ActivitiesId); //优惠费率活动ID
            Fields.Add("ActivitiesRate", data.ActivitiesRate); //优惠费率活动值
            Fields.Add("BankAccountType", data.BankAccountType); //账户类型
            Fields.Add("AccountName", data.AccountName); //开户名称
            Fields.Add("AccountBank", data.AccountBank); //开户银行
            Fields.Add("BankAddressCode", data.BankAddressCode); //开户银行省市编码
            Fields.Add("BankBranchId", data.BankBranchId); //开户银行联行号
            Fields.Add("BankName", data.BankName); //开户银行全称
            Fields.Add("AccountNumber", data.AccountNumber); //银行账号

            Fields.Add("SeoTitle", data.SeoTitle);
            Fields.Add("SeoKeyword", data.SeoKeyword);
            Fields.Add("SeoDescription", data.SeoDescription);
            int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("MerchantAddInfo", Fields, 0);
            AddSysLog(data.Id.ToString(), "MerchantAddInfo", "add");
            db.SaveChanges();

            return "success";
        }

        #endregion

        #region 修改商户进件资料

        /// <summary>
        /// 增加或修改商户进件资料信息
        /// </summary>
        /// <returns></returns>
        public IActionResult Edit(string right, int Id = 0)
        {
            ViewBag.RightInfo = RightInfo;
            ViewBag.right = right;
            ViewBag.Id = Id.ToString();


            MerchantAddInfo editData = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
            ViewBag.data = editData;
            return View();
        }

        #endregion

        #region 修改商户进件资料

        /// <summary>
        /// 增加或修改商户进件资料信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Edit(MerchantAddInfo data)
        {
            Dictionary<string, object> Fields = new Dictionary<string, object>();

            Fields.Add("ContactName", data.ContactName); //管理员姓名
            Fields.Add("ContactIdNumber", data.ContactIdNumber); //管理员身份证件号码
            Fields.Add("OpenId", data.OpenId); //管理员微信openid
            Fields.Add("MobilePhone", data.MobilePhone); //联系手机
            Fields.Add("ContactEmail", data.ContactEmail); //联系邮箱
            Fields.Add("SubjectType", data.SubjectType); //主体类型
            Fields.Add("LicenseCopy", data.LicenseCopy); //营业执照照片
            Fields.Add("LicenseNumber", data.LicenseNumber); //统一社会信用代码
            Fields.Add("LegalPerson", data.LegalPerson); //个体户经营者/法人姓名
            Fields.Add("CertCopy", data.CertCopy); //登记证书照片
            Fields.Add("CertType", data.CertType); //登记证书类型
            Fields.Add("CertNumber", data.CertNumber); //证书号
            Fields.Add("CertMerchantName", data.CertMerchantName); //商户名称
            Fields.Add("CompanyAddress", data.CompanyAddress); //注册地址
            Fields.Add("CertLegalPerson", data.CertLegalPerson); //法人姓名
            Fields.Add("PeriodBegin", data.PeriodBegin); //有效期限开始日期
            Fields.Add("PeriodEnd", data.PeriodEnd); //有效期限结束日期
            Fields.Add("OrganizationCopy", data.OrganizationCopy); //组织机构代码证照片
            Fields.Add("OrganizationCode", data.OrganizationCode); //组织机构代码
            Fields.Add("OrgPeriodBegin", data.OrgPeriodBegin); //组织机构代码证有效期开始日期
            Fields.Add("OrgPeriodEnd", data.OrgPeriodEnd); //组织机构代码证有效期结束日期
            Fields.Add("CertificateLetterCopy", data.CertificateLetterCopy); //单位证明函照片
            Fields.Add("IdDocType", data.IdDocType); //证件类型
            Fields.Add("IdCardCopy", data.IdCardCopy); //身份证人像面照片
            Fields.Add("IdCardNational", data.IdCardNational); //身份证国徽面照片
            Fields.Add("IdCardName", data.IdCardName); //身份证姓名
            Fields.Add("IdCardNumber", data.IdCardNumber); //身份证号码
            Fields.Add("CardPeriodBegin", data.CardPeriodBegin); //身份证有效期开始时间
            Fields.Add("CardPeriodEnd", data.CardPeriodEnd); //身份证有效期结束时间
            Fields.Add("Owner", data.Owner); //经营者/法人是否为受益人
            Fields.Add("UboInfoIdType", data.UboInfoIdType); //最终受益人证件类型
            Fields.Add("UboInfoIdCardCopy", data.UboInfoIdCardCopy); //最终受益人身份证人像面照片
            Fields.Add("UboInfoIdCardNational", data.UboInfoIdCardNational); //身份证国徽面照片
            Fields.Add("UboInfoIdDocCopy", data.UboInfoIdDocCopy); //最终受益人证件照片
            Fields.Add("UboInfoName", data.UboInfoName); //受益人姓名
            Fields.Add("UboInfoIdNumber", data.UboInfoIdNumber); //最终受益人证件号码
            Fields.Add("UboInfoIdPeriodBegin", data.UboInfoIdPeriodBegin); //证件有效期开始时间
            Fields.Add("UboInfoIdPeriodEnd", data.UboInfoIdPeriodEnd); //证件有效期结束时间
            Fields.Add("MerchantShortname", data.MerchantShortname); //商户简称
            Fields.Add("ServicePhone", data.ServicePhone); //客服电话
            Fields.Add("SalesScenesType", data.SalesScenesType); //经营场景类型
            Fields.Add("BizStoreName", data.BizStoreName); //门店名称
            Fields.Add("BizAddressCode", data.BizAddressCode); //门店省市编码
            Fields.Add("BizStoreAddress", data.BizStoreAddress); //门店地址
            Fields.Add("StoreEntrancePic", data.StoreEntrancePic); //门店门头照片
            Fields.Add("IndoorPic", data.IndoorPic); //店内环境照片
            Fields.Add("BizSubAppid", data.BizSubAppid); //线下场所对应的商家APPID
            Fields.Add("MpAppid", data.MpAppid); //服务商公众号APPID
            Fields.Add("MpSubAppid", data.MpSubAppid); //商家公众号APPID
            Fields.Add("MpPics", data.MpPics); //公众号页面截图
            Fields.Add("MiniProgramAppid", data.MiniProgramAppid); //服务商小程序APPID
            Fields.Add("MiniProgramSubAppid", data.MiniProgramSubAppid); //商家小程序APPID
            Fields.Add("MiniProgramPics", data.MiniProgramPics); //小程序截图
            Fields.Add("AppAppid", data.AppAppid); //服务商应用APPID
            Fields.Add("AppSubAppid", data.AppSubAppid); //商家应用APPID
            Fields.Add("AppPics", data.AppPics); //APP截图
            Fields.Add("WebDomain", data.WebDomain); //互联网网站域名
            Fields.Add("WebAuthorisation", data.WebAuthorisation); //网站授权函
            Fields.Add("WebAppId", data.WebAppId); //互联网网站对应的商家APPID
            Fields.Add("SubCorpId", data.SubCorpId); //商家企业微信CorpID
            Fields.Add("WeworkPics", data.WeworkPics); //企业微信页面截图
            Fields.Add("SettlementId", data.SettlementId); //入驻结算规则ID
            Fields.Add("QualificationType", data.QualificationType); //所属行业
            Fields.Add("Qualifications", data.Qualifications); //特殊资质图片
            Fields.Add("ActivitiesId", data.ActivitiesId); //优惠费率活动ID
            Fields.Add("ActivitiesRate", data.ActivitiesRate); //优惠费率活动值
            Fields.Add("BankAccountType", data.BankAccountType); //账户类型
            Fields.Add("AccountName", data.AccountName); //开户名称
            Fields.Add("AccountBank", data.AccountBank); //开户银行
            Fields.Add("BankAddressCode", data.BankAddressCode); //开户银行省市编码
            Fields.Add("BankBranchId", data.BankBranchId); //开户银行联行号
            Fields.Add("BankName", data.BankName); //开户银行全称
            Fields.Add("AccountNumber", data.AccountNumber); //银行账号

            Fields.Add("SeoTitle", data.SeoTitle);
            Fields.Add("SeoKeyword", data.SeoKeyword);
            Fields.Add("SeoDescription", data.SeoDescription);

            int Id = 0;
            string BusinessCode = "";
            MerchantAddInfo check = db.MerchantAddInfo.FirstOrDefault(m => m.Id == data.Id);
            if (check == null)
            {
                BusinessCode = "KXS" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(5);
                Fields.Add("BusinessCode", BusinessCode);
                Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("MerchantAddInfo", Fields, 0);
            }
            else
            {
                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MerchantAddInfo", Fields, data.Id);
                Id = data.Id;
                BusinessCode = check.BusinessCode;
            }
            AddSysLog(Id.ToString(), "MerchantAddInfo", "update");
            db.SaveChanges();

            MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
            MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
            string result = ""; //new WeChatFunction(_accessor.HttpContext).MerchantCreate(merchantadd, merchant);
            if (result.Contains("\"applyment_id\":"))
            {
                JsonData jsonObj = JsonMapper.ToObject(result);
                List<MerchantSign> signs = RedisDbconn.Instance.GetList<MerchantSign>("MerchantSignList", 1, 10000000);
                bool op = signs.Any(m => m.BusinessCode == BusinessCode);
                if (!op)
                {
                    RedisDbconn.Instance.AddList("WeChatSignList", new MerchantSign()
                    {
                        BusinessCode = BusinessCode,
                        MerchantAddInfoId = Id,
                        Status = ""
                    });
                }
                signs.Clear();
            }
            return "success";
        }

        #endregion

        #region 删除商户进件资料信息

        /// <summary>
        /// 删除商户进件资料信息
        /// </summary>
        /// <returns></returns>
        public string Delete(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "MerchantAddInfo", "del");
            foreach (string subid in idlist)
            {
                int id = int.Parse(subid);
                Dictionary<string, object> Fields = new Dictionary<string, object>();
                Fields.Add("Status", -1);
                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MerchantAddInfo", Fields, id);
            }
            db.SaveChanges();

            return "success";
        }

        #endregion

        #region 开启

        /// <summary>
        /// 开启
        /// </summary>
        /// <returns></returns>
        public string Open(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "MerchantAddInfo", "open");
            foreach (string subid in idlist)
            {
                int id = int.Parse(subid);
                Dictionary<string, object> Fields = new Dictionary<string, object>();
                Fields.Add("Status", 1);
                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MerchantAddInfo", Fields, id);
            }
            db.SaveChanges();
            return "success";
        }

        #endregion

        #region 关闭

        /// <summary>
        /// 关闭
        /// </summary>
        /// <returns></returns>
        public string Close(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "MerchantAddInfo", "close");
            foreach (string subid in idlist)
            {
                int id = int.Parse(subid);
                Dictionary<string, object> Fields = new Dictionary<string, object>();
                Fields.Add("Status", 0);
                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MerchantAddInfo", Fields, id);
            }
            db.SaveChanges();
            return "success";
        }

        #endregion

        #region 排序
        /// <summary>
        /// 排序
        /// </summary>
        /// <param name="Id"></param>
        public string Sort(int Id, int Sort)
        {
            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("MerchantAddInfo", Sort, Id);

            AddSysLog(Id.ToString(), "MerchantAddInfo", "sort");
            return "success";
        }
        #endregion

        #region 导入数据
        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="ExcelData"></param>
        public string Import(string ExcelData)
        {
            ExcelData = HttpUtility.UrlDecode(ExcelData);
            JsonData list = JsonMapper.ToObject(ExcelData);
            for (int i = 1; i < list.Count; i++)
            {
                JsonData dr = list[i];

                db.MerchantAddInfo.Add(new MerchantAddInfo()
                {
                    CreateDate = DateTime.Now,
                    UpdateDate = DateTime.Now,

                });
                db.SaveChanges();
            }
            AddSysLog("0", "MerchantAddInfo", "Import");
            return "success";
        }
        #endregion

        #region 导出Excel

        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <returns></returns>
        public JsonResult ExportExcel(MerchantAddInfo data, string ApplymentStateSelect)
        {
            Dictionary<string, string> Fields = new Dictionary<string, string>();
            Fields.Add("CreateDate", "3"); //时间


            string condition = " and Status>-1";
            //申请单状态
            if (!string.IsNullOrEmpty(ApplymentStateSelect))
            {
                condition += " and ApplymentState=" + ApplymentStateSelect;
            }


            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("MerchantAddInfo", Fields, "Id desc", "0", 1, 20000, condition, "", false);
            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
            foreach (Dictionary<string, object> dic in diclist)
            {
                dic["StatusName"] = dic["Status"].ToString() == "1" ? "正常" : "关闭";
                //申请单状态
                string ApplymentState = dic["ApplymentState"].ToString();
                if (ApplymentState == "APPLYMENT_STATE_EDITTING") dic["ApplymentState"] = "编辑中";
                if (ApplymentState == "APPLYMENT_STATE_AUDITING") dic["ApplymentState"] = "审核中";
                if (ApplymentState == "APPLYMENT_STATE_REJECTED") dic["ApplymentState"] = "已驳回";
                if (ApplymentState == "APPLYMENT_STATE_TO_BE_CONFIRMED") dic["ApplymentState"] = "待账户验证";
                if (ApplymentState == "APPLYMENT_STATE_TO_BE_SIGNED") dic["ApplymentState"] = "待签约";
                if (ApplymentState == "APPLYMENT_STATE_SIGNING") dic["ApplymentState"] = "开通权限中";
                if (ApplymentState == "APPLYMENT_STATE_FINISHED") dic["ApplymentState"] = "已完成";
                if (ApplymentState == "APPLYMENT_STATE_CANCELED") dic["ApplymentState"] = "已作废";
                if (ApplymentState == "") dic["ApplymentState"] = "";

            }

            Dictionary<string, object> result = new Dictionary<string, object>();
            result.Add("Status", "1");
            result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
            result.Add("Obj", diclist);
            Dictionary<string, object> ReturnFields = new Dictionary<string, object>();

            result.Add("Fields", ReturnFields);
            AddSysLog("0", "MerchantAddInfo", "ExportExcel");
            return Json(result);
        }

        #endregion

    }
}
