/*
 * 激活奖励记录
 */

using System;
using System.Web;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Data;
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;

namespace MySystem.Areas.Admin.Controllers
{
    [Area("Admin")]
    [Route("Admin/[controller]/[action]")]
    public class ActiveRewardController : BaseController
    {
        public ActiveRewardController(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(ActiveReward data, string right, string BrandId)
        {
            ViewBag.RightInfo = RightInfo;
            ViewBag.right = right;
            ViewBag.BrandId = BrandId;

            return View();
        }

        #endregion

        #region 根据条件查询激活奖励记录列表

        /// <summary>
        /// 激活奖励记录列表
        /// </summary>
        /// <returns></returns>
        public JsonResult IndexData(ActiveReward data, string right, string BrandId, string MerchantNo, string MerchantName, string MakerCode, string RealName, string MerMakerCode, string MerRealName, string ParentMakerCode, string ParentRealName, string ParentParentMakerCode, string ParentParentRealName, string StoreNo, string StoreName, string SnTypeSelect, string ActTypeSelect, string ActDateData, int page = 1, int limit = 30)
        {

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

            Fields.Add("BrandId", "1");
            Fields.Add("KqMerNo", "1"); //快钱商户编号
            Fields.Add("KqSnNo", "1"); //快钱SN号
            Fields.Add("TopUserId", "0"); //顶级创客

            string condition = " and Status>-1";
            //商户编号
            if (!string.IsNullOrEmpty(MerchantNo))
            {
                condition += " and MerchantId in (select MerchantId from MerchantForCode where MakerCode='" + MerchantNo + "')";
            }
            //商户名称
            if (!string.IsNullOrEmpty(MerchantName))
            {
                condition += " and MerchantId in (select MerchantId from MerchantForName where RealName='" + MerchantName + "')";
            }
            //创客编号
            if (!string.IsNullOrEmpty(MakerCode))
            {
                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
            }
            //创客名称
            if (!string.IsNullOrEmpty(RealName))
            {
                condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
            }
            //商户创客编号
            if (!string.IsNullOrEmpty(MerMakerCode))
            {
                condition += " and MerUserId in (select UserId from UserForMakerCode where MakerCode='" + MerMakerCode + "')";
            }
            //商户创客名称
            if (!string.IsNullOrEmpty(MerRealName))
            {
                condition += " and MerUserId in (select UserId from UserForRealName where RealName='" + MerRealName + "')";
            }
            //上级创客编号
            if (!string.IsNullOrEmpty(ParentMakerCode))
            {
                condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
            }
            //上级创客名称
            if (!string.IsNullOrEmpty(ParentRealName))
            {
                condition += " and ParentUserId in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
            }
            //上上级创客编号
            if (!string.IsNullOrEmpty(ParentParentMakerCode))
            {
                condition += " and ParentParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentParentMakerCode + "')";
            }
            //上上级创客名称
            if (!string.IsNullOrEmpty(ParentParentRealName))
            {
                condition += " and ParentParentUserId in (select UserId from UserForRealName where RealName='" + ParentParentRealName + "')";
            }
            //仓库编号
            if (!string.IsNullOrEmpty(StoreNo))
            {
                condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
            }
            //仓库名称
            if (!string.IsNullOrEmpty(RealName))
            {
                condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreName + "')";
            }
            //机具类型
            if (!string.IsNullOrEmpty(SnTypeSelect))
            {
                condition += " and SnType=" + SnTypeSelect;
            }
            //激活类型
            if (!string.IsNullOrEmpty(ActTypeSelect))
            {
                condition += " and ActType=" + ActTypeSelect;
            }
            if (!string.IsNullOrEmpty(ActDateData))
            {
                string[] datelist = ActDateData.Split(new string[] { " - " }, StringSplitOptions.None);
                var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
                var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
                var check = db.ActiveReward.Any(m => m.ActDate >= start && m.BrandId == Convert.ToInt32(BrandId));
                var checks = db.ActiveReward.Any(m => m.ActDate <= end && m.BrandId == Convert.ToInt32(BrandId));
                if (check)
                {
                    var sId = db.ActiveReward.Where(m => m.ActDate >= start && m.BrandId == Convert.ToInt32(BrandId)).Min(m => m.Id);
                    condition += "  and Id >=" + sId;
                }
                if (checks)
                {
                    var eId = db.ActiveReward.Where(m => m.ActDate <= end && m.BrandId == Convert.ToInt32(BrandId)).Max(m => m.Id);
                    condition += " and Id <=" + eId;
                }
            }
            else
            {
                var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
                var check = db.ActiveReward.Any(m => m.ActDate >= start && m.BrandId == Convert.ToInt32(BrandId));
                if (check)
                {
                    var minId = db.ActiveReward.Where(m => m.ActDate >= start && m.BrandId == Convert.ToInt32(BrandId)).Min(m => m.Id);
                    var Info = function.ReadInstance("/WritePage/ActiveReward/ActiveReward" + BrandId + ".txt");
                    if (string.IsNullOrEmpty(Info))
                    {
                        function.WritePage("/WritePage/ActiveReward/", "ActiveReward" + BrandId + ".txt", minId.ToString());
                        condition += " and Id >=" + minId;
                    }
                    else if (minId != int.Parse(Info))
                    {
                        function.WritePage("/WritePage/ActiveReward/", "ActiveReward" + BrandId + ".txt", minId.ToString());
                        condition += " and Id >=" + minId;
                    }
                    else
                    {
                        condition += " and Id >=" + Convert.ToInt32(Info);
                    }
                }
                else
                {
                    condition += " and Id =0";
                }
            }

            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("ActiveReward", 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)
            {
                //商户
                int MerchantId = int.Parse(dic["MerchantId"].ToString());
                MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantInfo();
                dic["MerchantNo"] = "";
                dic["MerchantName"] = merchant.Name;
                //奖励创客
                int UserId = int.Parse(dic["UserId"].ToString());
                Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
                dic["MakerCode"] = user.MakerCode;
                dic["RealName"] = user.RealName;
                //顶级创客
                int TopUserId = int.Parse(dic["TopUserId"].ToString());
                Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
                dic["TopMakerCode"] = tuser.MakerCode;
                dic["TopRealName"] = tuser.RealName;
                //直属创客
                int MerUserId = int.Parse(dic["MerUserId"].ToString());
                Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
                dic["MerMakerCode"] = muser.MakerCode;
                dic["MerRealName"] = muser.RealName;
                //上级创客
                int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
                Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
                dic["ParentMakerCode"] = puser.MakerCode;
                dic["ParentRealName"] = puser.RealName;
                //上上级创客
                int ParentParentUserId = int.Parse(dic["ParentParentUserId"].ToString());
                Users ppuser = db.Users.FirstOrDefault(m => m.Id == ParentParentUserId) ?? new Users();
                dic["ParentParentMakerCode"] = ppuser.MakerCode;
                dic["ParentParentRealName"] = ppuser.RealName;
                //申请创客
                int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
                Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
                dic["SnApplyMakerCode"] = snuser.MakerCode;
                dic["SnApplyRealName"] = snuser.RealName;
                //SN仓库
                int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
                StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
                dic["StoreNo"] = store.StoreNo;
                dic["StoreName"] = store.StoreName;
                //机具类型
                int SnType = int.Parse(dic["SnType"].ToString());
                if (SnType == 0) dic["SnType"] = "兑换机具";
                if (SnType == 1) dic["SnType"] = "循环机具";
                //激活类型
                int ActType = int.Parse(dic["ActType"].ToString());
                if (ActType == 0) dic["ActType"] = "正常激活";
                if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
                if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
                if (ActType == 3) dic["ActType"] = "循环机划拨激活";
            }
            Dictionary<string, object> other = new Dictionary<string, object>();
            string RewardAmount = "0.00";//奖励金额
            DataTable dt = OtherMySqlConn.dtable("select sum(RewardAmount) from ActiveReward where BrandId='" + BrandId + "'" + condition);
            if (dt.Rows.Count > 0)
            {
                RewardAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
            }
            other.Add("RewardAmount", RewardAmount);
            obj.Add("other", other);
            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(ActiveReward data)
        {
            Dictionary<string, object> Fields = new Dictionary<string, object>();


            Fields.Add("SeoTitle", data.SeoTitle);
            Fields.Add("SeoKeyword", data.SeoKeyword);
            Fields.Add("SeoDescription", data.SeoDescription);
            int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("ActiveReward", Fields, 0);
            AddSysLog(data.Id.ToString(), "ActiveReward", "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;


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

        #endregion

        #region 修改激活奖励记录

        /// <summary>
        /// 增加或修改激活奖励记录信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Edit(ActiveReward data)
        {
            Dictionary<string, object> Fields = new Dictionary<string, object>();


            Fields.Add("SeoTitle", data.SeoTitle);
            Fields.Add("SeoKeyword", data.SeoKeyword);
            Fields.Add("SeoDescription", data.SeoDescription);
            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("ActiveReward", Fields, data.Id);
            AddSysLog(data.Id.ToString(), "ActiveReward", "update");
            db.SaveChanges();

            return "success";
        }

        #endregion

        #region 删除激活奖励记录信息

        /// <summary>
        /// 删除激活奖励记录信息
        /// </summary>
        /// <returns></returns>
        public string Delete(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "ActiveReward", "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("ActiveReward", 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, "ActiveReward", "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("ActiveReward", 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, "ActiveReward", "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("ActiveReward", 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("ActiveReward", Sort, Id);

            AddSysLog(Id.ToString(), "ActiveReward", "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.ActiveReward.Add(new ActiveReward()
                {
                    CreateDate = DateTime.Now,
                    UpdateDate = DateTime.Now,

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

        #region 导出Excel

        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <returns></returns>
        public JsonResult ExportExcel(ActiveReward data, string MerchantNo, string MerchantName, string MakerCode, string RealName, string MerMakerCode, string MerRealName, string ParentMakerCode, string ParentRealName, string ParentParentMakerCode, string ParentParentRealName, string StoreNo, string StoreName, string SnTypeSelect, string ActTypeSelect)
        {
            Dictionary<string, string> Fields = new Dictionary<string, string>();

            Fields.Add("BrandId", "1");
            Fields.Add("KqMerNo", "1"); //快钱商户编号
            Fields.Add("KqSnNo", "1"); //快钱SN号
            Fields.Add("ActDate", "3"); //激活时间
            Fields.Add("TopUserId", "0"); //顶级创客

            string condition = " and Status>-1";
            //商户编号
            if (!string.IsNullOrEmpty(MerchantNo))
            {
                condition += " and MerchantId in (select MerchantId from MerchantForCode where MakerCode='" + MerchantNo + "')";
            }
            //商户名称
            if (!string.IsNullOrEmpty(MerchantName))
            {
                condition += " and MerchantId in (select MerchantId from MerchantForName where RealName='" + MerchantName + "')";
            }
            //创客编号
            if (!string.IsNullOrEmpty(MakerCode))
            {
                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
            }
            //创客名称
            if (!string.IsNullOrEmpty(RealName))
            {
                condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
            }
            //商户创客编号
            if (!string.IsNullOrEmpty(MerMakerCode))
            {
                condition += " and MerUserId in (select UserId from UserForMakerCode where MakerCode='" + MerMakerCode + "')";
            }
            //商户创客名称
            if (!string.IsNullOrEmpty(MerRealName))
            {
                condition += " and MerUserId in (select UserId from UserForRealName where RealName='" + MerRealName + "')";
            }
            //上级创客编号
            if (!string.IsNullOrEmpty(ParentMakerCode))
            {
                condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
            }
            //上级创客名称
            if (!string.IsNullOrEmpty(ParentRealName))
            {
                condition += " and ParentUserId in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
            }
            //上上级创客编号
            if (!string.IsNullOrEmpty(ParentParentMakerCode))
            {
                condition += " and ParentParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentParentMakerCode + "')";
            }
            //上上级创客名称
            if (!string.IsNullOrEmpty(ParentParentRealName))
            {
                condition += " and ParentParentUserId in (select UserId from UserForRealName where RealName='" + ParentParentRealName + "')";
            }
            //仓库编号
            if (!string.IsNullOrEmpty(StoreNo))
            {
                condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
            }
            //仓库名称
            if (!string.IsNullOrEmpty(RealName))
            {
                condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreName + "')";
            }
            //机具类型
            if (!string.IsNullOrEmpty(SnTypeSelect))
            {
                condition += " and SnType=" + SnTypeSelect;
            }
            //激活类型
            if (!string.IsNullOrEmpty(ActTypeSelect))
            {
                condition += " and ActType=" + ActTypeSelect;
            }

            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("ActiveReward", Fields, "Id desc", "0", 1, 20000, condition, "MerchantId,ActDate,CreateDate,UserId,MerUserId,ParentUserId,ParentParentUserId,TopUserId,KqMerNo,KqSnNo,SnType,ActType,SnStoreId,SnApplyUserId,RewardAmount", false);
            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
            foreach (Dictionary<string, object> dic in diclist)
            {
                //商户
                int MerchantId = int.Parse(dic["MerchantId"].ToString());
                MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantInfo();
                dic["MerchantNo"] = "";
                dic["MerchantName"] = merchant.Name;
                //奖励创客
                int UserId = int.Parse(dic["UserId"].ToString());
                Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
                dic["MakerCode"] = user.MakerCode;
                dic["RealName"] = user.RealName;
                //顶级创客
                int TopUserId = int.Parse(dic["TopUserId"].ToString());
                Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
                dic["TopMakerCode"] = tuser.MakerCode;
                dic["TopRealName"] = tuser.RealName;
                //直属创客
                int MerUserId = int.Parse(dic["MerUserId"].ToString());
                Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
                dic["MerMakerCode"] = muser.MakerCode;
                dic["MerRealName"] = muser.RealName;
                //上级创客
                int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
                Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
                dic["ParentMakerCode"] = puser.MakerCode;
                dic["ParentRealName"] = puser.RealName;
                //上上级创客
                int ParentParentUserId = int.Parse(dic["ParentParentUserId"].ToString());
                Users ppuser = db.Users.FirstOrDefault(m => m.Id == ParentParentUserId) ?? new Users();
                dic["ParentParentMakerCode"] = ppuser.MakerCode;
                dic["ParentParentRealName"] = ppuser.RealName;
                //申请创客
                int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
                Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
                dic["SnApplyMakerCode"] = snuser.MakerCode;
                dic["SnApplyRealName"] = snuser.RealName;
                //SN仓库
                int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
                StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
                dic["StoreNo"] = store.StoreNo;
                dic["StoreName"] = store.StoreName;
                //机具类型
                int SnType = int.Parse(dic["SnType"].ToString());
                if (SnType == 0) dic["SnType"] = "兑换机具";
                if (SnType == 1) dic["SnType"] = "循环机具";
                //激活类型
                int ActType = int.Parse(dic["ActType"].ToString());
                if (ActType == 0) dic["ActType"] = "正常激活";
                if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
                if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
                if (ActType == 3) dic["ActType"] = "循环机划拨激活";
                dic.Remove("MerchantId");
                dic.Remove("UserId");
                dic.Remove("MerUserId");
                dic.Remove("ParentUserId");
                dic.Remove("ParentParentUserId");
                dic.Remove("SnApplyUserId");
                dic.Remove("SnStoreId");
            }

            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>();
            ReturnFields.Add("MerchantNo", "商户编号");
            ReturnFields.Add("MerchantName", "商户名称");
            ReturnFields.Add("ActDate", "激活日期");
            ReturnFields.Add("CreateDate", "奖励时间");
            ReturnFields.Add("MakerCode", "奖励创客编号");
            ReturnFields.Add("RealName", "奖励创客名称");
            ReturnFields.Add("MerMakerCode", "直属创客编号");
            ReturnFields.Add("MerRealName", "直属创客名称");
            ReturnFields.Add("ParentMakerCode", "上级创客编码");
            ReturnFields.Add("ParentRealName", "上级创客名称");
            ReturnFields.Add("ParentParentMakerCode", "上上级创客编码");
            ReturnFields.Add("ParentParentRealName", "上上级创客名称");
            ReturnFields.Add("TopMakerCode", "顶级创客编码");
            ReturnFields.Add("TopRealName", "顶级创客名称");
            ReturnFields.Add("KqMerNo", "快钱商户编号");
            ReturnFields.Add("KqSnNo", "快钱SN号");
            ReturnFields.Add("SnType", "机具类型");
            ReturnFields.Add("ActType", "激活类型");
            ReturnFields.Add("StoreNo", "SN仓库编号");
            ReturnFields.Add("StoreName", "SN仓库名称");
            ReturnFields.Add("SnApplyMakerCode", "机具申请创客编号");
            ReturnFields.Add("SnApplyRealName", "机具申请创客姓名");
            ReturnFields.Add("RewardAmount", "奖励金额(元)");

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

        #endregion

    }
}
