/*
 * 创客库存变动记录
 */

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;
using MySystemLib;

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

            return View();
        }

        #endregion

        #region 根据条件查询创客库存变动记录列表

        /// <summary>
        /// 创客库存变动记录列表
        /// </summary>
        /// <returns></returns>
        public JsonResult IndexData(UserStoreChange data, string UserIdMakerCode, string UserIdRealName, string BindMerchantIdMerchantNo, string BindMerchantIdMerchantName, string BrandIdSelect, string TransTypeSelect, string StockOpDirectSelect, string SnStatusSelect, string BindStatusSelect, string ActiveStatusSelect, string BrandTypeSelect, string CreateDateData, int page = 1, int limit = 30)
        {

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

            Fields.Add("SnNo", "1"); //SN编号


            string condition = " and Status>-1";
            //创客编号
            if (!string.IsNullOrEmpty(UserIdMakerCode))
            {
                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
            }
            //创客真实姓名
            if (!string.IsNullOrEmpty(UserIdRealName))
            {
                condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
            }
            //产品类型
            if (!string.IsNullOrEmpty(BrandIdSelect))
            {
                condition += " and BrandId=" + BrandIdSelect;
            }
            //交易类型
            if (!string.IsNullOrEmpty(TransTypeSelect))
            {
                condition += " and TransType=" + TransTypeSelect;
            }
            //库存操作方向
            if (!string.IsNullOrEmpty(StockOpDirectSelect))
            {
                condition += " and StockOpDirect=" + StockOpDirectSelect;
            }
            //SN状态
            if (!string.IsNullOrEmpty(SnStatusSelect))
            {
                condition += " and SnStatus=" + SnStatusSelect;
            }
            //绑定状态
            if (!string.IsNullOrEmpty(BindStatusSelect))
            {
                condition += " and BindStatus=" + BindStatusSelect;
            }
            //激活状态
            if (!string.IsNullOrEmpty(ActiveStatusSelect))
            {
                condition += " and ActiveStatus=" + ActiveStatusSelect;
            }
            //绑定商户商户编号
            if (!string.IsNullOrEmpty(BindMerchantIdMerchantNo))
            {
                condition += " and BindMerchantId in (select MerchantId from MerchantForCode where Code='" + BindMerchantIdMerchantNo + "')";
            }
            //绑定商户商户姓名
            if (!string.IsNullOrEmpty(BindMerchantIdMerchantName))
            {
                condition += " and BindMerchantId in (select MerchantId from MerchantForName where Name='" + BindMerchantIdMerchantName + "')";
            }
            //品牌类型
            if (!string.IsNullOrEmpty(BrandTypeSelect))
            {
                condition += " and BrandType=" + BrandTypeSelect;
            }
            //变动时间
            if (!string.IsNullOrEmpty(CreateDateData))
            {
                string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
                string start = datelist[0];
                string end = datelist[1];
                condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
            }

            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserStoreChange", 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 UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
                Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
                dic["UserIdMakerCode"] = userid_Users.MakerCode;
                dic["UserIdRealName"] = userid_Users.RealName;
                dic.Remove("UserId");
                //产品类型
                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
                //交易类型
                int TransType = int.Parse(dic["TransType"].ToString());
                if (TransType == 10) dic["TransType"] = "领取";
                if (TransType == 11) dic["TransType"] = "划拨";
                if (TransType == 13) dic["TransType"] = "退货";
                if (TransType == 0) dic["TransType"] = "";
                //SN机具类型
                int SnType = int.Parse(dic["SnType"].ToString());
                if (SnType == 0) dic["SnType"] = "兑换机具";
                if (SnType == 1) dic["SnType"] = "循环机具";
                //库存操作方向
                int StockOpDirect = int.Parse(dic["StockOpDirect"].ToString());
                if (StockOpDirect == 0) dic["StockOpDirect"] = "入库";
                if (StockOpDirect == 1) dic["StockOpDirect"] = "出库";
                //收货创客
                int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
                Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
                dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
                dic["ToUserIdRealName"] = touserid_Users.RealName;
                dic.Remove("ToUserId");
                //创客退货收货仓库
                int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
                StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
                dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
                dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
                dic.Remove("ToStoreId");
                //源仓库
                int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
                StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
                dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
                dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
                dic.Remove("SourceStoreId");
                //SN状态
                int SnStatus = int.Parse(dic["SnStatus"].ToString());
                if (SnStatus == 0) dic["SnStatus"] = "未拨出";
                if (SnStatus == 1) dic["SnStatus"] = "已拨出";
                //绑定状态
                int BindStatus = int.Parse(dic["BindStatus"].ToString());
                if (BindStatus == 0) dic["BindStatus"] = "未绑定";
                if (BindStatus == 1) dic["BindStatus"] = "已绑定";
                //绑定商户
                int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
                MerchantInfo bindmerchantid_MerchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new MerchantInfo();
                dic["BindMerchantIdMerchantNo"] = "";
                dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.Name;
                dic.Remove("BindMerchantId");
                //激活状态
                int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
                if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
                if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
                //激活奖励创客
                int ActRewardUserId = int.Parse(function.CheckInt(dic["ActRewardUserId"].ToString()));
                Users actrewarduserid_Users = db.Users.FirstOrDefault(m => m.Id == ActRewardUserId) ?? new Users();
                dic["ActRewardUserIdMakerCode"] = actrewarduserid_Users.MakerCode;
                dic["ActRewardUserIdRealName"] = actrewarduserid_Users.RealName;
                dic.Remove("ActRewardUserId");
                //出货创客
                int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
                Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
                dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
                dic["FromUserIdRealName"] = fromuserid_Users.RealName;
                dic.Remove("FromUserId");

            }
            Dictionary<string, object> other = new Dictionary<string, object>();
            int NotPutNotBindCount = 0;//未拨出未绑定
            int NotPutBindCount = 0;//未拨出已绑定
            int PutNotBindCount = 0;//已拨出未绑定
            int PutBindCount = 0;//已拨出已绑定

            DataTable dt = OtherMySqlConn.dtable("select count(0) from UserStoreChange where SnStatus=0 and BindStatus=0" + condition);
            if (dt.Rows.Count > 0)
            {
                NotPutNotBindCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
            }
            dt = OtherMySqlConn.dtable("select count(0) from UserStoreChange where SnStatus=0 and BindStatus=1" + condition);
            if (dt.Rows.Count > 0)
            {
                NotPutBindCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
            }
            dt = OtherMySqlConn.dtable("select count(0) from UserStoreChange where SnStatus=1 and BindStatus=0" + condition);
            if (dt.Rows.Count > 0)
            {
                PutNotBindCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
            }
            dt = OtherMySqlConn.dtable("select count(0) from UserStoreChange where SnStatus=1 and BindStatus=1" + condition);
            if (dt.Rows.Count > 0)
            {
                PutBindCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
            }
            other.Add("NotPutNotBindCount", NotPutNotBindCount);
            other.Add("NotPutBindCount", NotPutBindCount);
            other.Add("PutNotBindCount", PutNotBindCount);
            other.Add("PutBindCount", PutBindCount);
            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(UserStoreChange 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("UserStoreChange", Fields, 0);
            AddSysLog(data.Id.ToString(), "UserStoreChange", "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;


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

        #endregion

        #region 修改创客库存变动记录

        /// <summary>
        /// 增加或修改创客库存变动记录信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Edit(UserStoreChange 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("UserStoreChange", Fields, data.Id);
            AddSysLog(data.Id.ToString(), "UserStoreChange", "update");
            db.SaveChanges();

            return "success";
        }

        #endregion

        #region 删除创客库存变动记录信息

        /// <summary>
        /// 删除创客库存变动记录信息
        /// </summary>
        /// <returns></returns>
        public string Delete(string Id)
        {
            string[] idlist = Id.Split(new char[] { ',' });
            AddSysLog(Id, "UserStoreChange", "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("UserStoreChange", 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, "UserStoreChange", "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("UserStoreChange", 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, "UserStoreChange", "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("UserStoreChange", 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("UserStoreChange", Sort, Id);

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

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

        #region 导出Excel

        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <returns></returns>
        public JsonResult ExportExcel(UserStoreChange data, string UserIdMakerCode, string UserIdRealName, string BindMerchantIdMerchantNo, string BindMerchantIdMerchantName, string BrandIdSelect, string TransTypeSelect, string StockOpDirectSelect, string SnStatusSelect, string BindStatusSelect, string ActiveStatusSelect, string BrandTypeSelect)
        {
            Dictionary<string, string> Fields = new Dictionary<string, string>();
            Fields.Add("CreateDate", "3"); //时间
            Fields.Add("SnNo", "1"); //SN编号


            string condition = " and Status>-1";
            //创客编号
            if (!string.IsNullOrEmpty(UserIdMakerCode))
            {
                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
            }
            //创客真实姓名
            if (!string.IsNullOrEmpty(UserIdRealName))
            {
                condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
            }
            //产品类型
            if (!string.IsNullOrEmpty(BrandIdSelect))
            {
                condition += " and BrandId=" + BrandIdSelect;
            }
            //交易类型
            if (!string.IsNullOrEmpty(TransTypeSelect))
            {
                condition += " and TransType=" + TransTypeSelect;
            }
            //库存操作方向
            if (!string.IsNullOrEmpty(StockOpDirectSelect))
            {
                condition += " and StockOpDirect=" + StockOpDirectSelect;
            }
            //SN状态
            if (!string.IsNullOrEmpty(SnStatusSelect))
            {
                condition += " and SnStatus=" + SnStatusSelect;
            }
            //绑定状态
            if (!string.IsNullOrEmpty(BindStatusSelect))
            {
                condition += " and BindStatus=" + BindStatusSelect;
            }
            //激活状态
            if (!string.IsNullOrEmpty(ActiveStatusSelect))
            {
                condition += " and ActiveStatus=" + ActiveStatusSelect;
            }
            //绑定商户商户编号
            if (!string.IsNullOrEmpty(BindMerchantIdMerchantNo))
            {
                condition += " and BindMerchantId in (select MerchantId from MerchantForCode where Code='" + BindMerchantIdMerchantNo + "')";
            }
            //绑定商户商户姓名
            if (!string.IsNullOrEmpty(BindMerchantIdMerchantName))
            {
                condition += " and BindMerchantId in (select MerchantId from MerchantForName where Name='" + BindMerchantIdMerchantName + "')";
            }
            //品牌类型
            if (!string.IsNullOrEmpty(BrandTypeSelect))
            {
                condition += " and BrandType=" + BrandTypeSelect;
            }


            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserStoreChange", Fields, "Id desc", "0", 1, 20000, condition, "UserId,BrandId,TransType,SnNo,SnType,StockOpDirect,ToUserId,ToStoreId,SourceStoreId,SnStatus,BindStatus,BindMerchantId,ActiveStatus,ActRewardUserId,FromUserId,CreateDate", false);
            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
            foreach (Dictionary<string, object> dic in diclist)
            {
                //创客
                int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
                Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
                dic["UserIdMakerCode"] = userid_Users.MakerCode;
                dic["UserIdRealName"] = userid_Users.RealName;
                dic.Remove("UserId");
                //产品类型
                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
                //交易类型
                int TransType = int.Parse(dic["TransType"].ToString());
                if (TransType == 10) dic["TransType"] = "领取";
                if (TransType == 11) dic["TransType"] = "划拨";
                if (TransType == 13) dic["TransType"] = "退货";
                if (TransType == 0) dic["TransType"] = "";
                //SN机具类型
                int SnType = int.Parse(dic["SnType"].ToString());
                if (SnType == 0) dic["SnType"] = "兑换机具";
                if (SnType == 1) dic["SnType"] = "循环机具";
                //库存操作方向
                int StockOpDirect = int.Parse(dic["StockOpDirect"].ToString());
                if (StockOpDirect == 0) dic["StockOpDirect"] = "入库";
                if (StockOpDirect == 1) dic["StockOpDirect"] = "出库";
                //收货创客
                int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
                Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
                dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
                dic["ToUserIdRealName"] = touserid_Users.RealName;
                dic.Remove("ToUserId");
                //创客退货收货仓库
                int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
                StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
                dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
                dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
                dic.Remove("ToStoreId");
                //源仓库
                int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
                StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
                dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
                dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
                dic.Remove("SourceStoreId");
                //SN状态
                int SnStatus = int.Parse(dic["SnStatus"].ToString());
                if (SnStatus == 0) dic["SnStatus"] = "未拨出";
                if (SnStatus == 1) dic["SnStatus"] = "已拨出";
                //绑定状态
                int BindStatus = int.Parse(dic["BindStatus"].ToString());
                if (BindStatus == 0) dic["BindStatus"] = "未绑定";
                if (BindStatus == 1) dic["BindStatus"] = "已绑定";
                //绑定商户
                int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
                MerchantInfo bindmerchantid_MerchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new MerchantInfo();
                dic["BindMerchantIdMerchantNo"] = "";
                dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.Name;
                dic.Remove("BindMerchantId");
                //激活状态
                int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
                if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
                if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
                //激活奖励创客
                int ActRewardUserId = int.Parse(function.CheckInt(dic["ActRewardUserId"].ToString()));
                Users actrewarduserid_Users = db.Users.FirstOrDefault(m => m.Id == ActRewardUserId) ?? new Users();
                dic["ActRewardUserIdMakerCode"] = actrewarduserid_Users.MakerCode;
                dic["ActRewardUserIdRealName"] = actrewarduserid_Users.RealName;
                dic.Remove("ActRewardUserId");
                //出货创客
                int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
                Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
                dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
                dic["FromUserIdRealName"] = fromuserid_Users.RealName;
                dic.Remove("FromUserId");

            }

            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("UserIdMakerCode", "创客编号");
            ReturnFields.Add("UserIdRealName", "创客真实姓名");
            ReturnFields.Add("BrandId", "产品类型");
            ReturnFields.Add("TransType", "交易类型");
            ReturnFields.Add("SnNo", "SN编号");
            ReturnFields.Add("SnType", "SN机具类型");
            ReturnFields.Add("StockOpDirect", "库存操作方向");
            ReturnFields.Add("ToUserIdMakerCode", "收货创客编号");
            ReturnFields.Add("ToUserIdRealName", "收货创客真实姓名");
            ReturnFields.Add("ToStoreIdStoreNo", "创客退货收货仓库编号");
            ReturnFields.Add("ToStoreIdStoreName", "创客退货收货仓库名称");
            ReturnFields.Add("SourceStoreIdStoreNo", "源仓库编号");
            ReturnFields.Add("SourceStoreIdStoreName", "源仓库名称");
            ReturnFields.Add("SnStatus", "SN状态");
            ReturnFields.Add("BindStatus", "绑定状态");
            ReturnFields.Add("BindMerchantIdMerchantNo", "绑定商户编号");
            ReturnFields.Add("BindMerchantIdMerchantName", "绑定商户姓名");
            ReturnFields.Add("ActiveStatus", "激活状态");
            ReturnFields.Add("ActRewardUserIdMakerCode", "激活奖励创客编号");
            ReturnFields.Add("ActRewardUserIdRealName", "激活奖励创客真实姓名");
            ReturnFields.Add("FromUserIdMakerCode", "出货创客编号");
            ReturnFields.Add("FromUserIdRealName", "出货创客真实姓名");
            ReturnFields.Add("CreateDate", "变动时间");

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

        #endregion

    }
}
