DuGuYang пре 2 година
родитељ
комит
ca35925252

+ 1 - 1
AppStart/Helper/ImportHelper/BatchEditUserAmountService.cs

@@ -360,7 +360,7 @@ namespace MySystem
                     }
                     else
                     {
-                        Thread.Sleep(50000);
+                        Thread.Sleep(5000);
                     }
                 }
                 catch (Exception ex)

+ 127 - 0
AppStart/Helper/ImportHelper/PreWithdrawalResultsService.cs

@@ -0,0 +1,127 @@
+using System;
+using System.Threading;
+using System.Linq;
+using System.Data;
+using Library;
+using MySystem.Models;
+using System.Collections.Generic;
+
+/// <summary>
+/// 小分仓临时额度提现结果导入
+/// </summary>
+namespace MySystem
+{
+    public class PreWithdrawalResultsService
+    {
+        public readonly static PreWithdrawalResultsService Instance = new PreWithdrawalResultsService();
+        private PreWithdrawalResultsService()
+        {
+        }
+
+        public void Start()//启动
+        {
+            Thread thread = new Thread(ImportPostDo);
+            thread.IsBackground = true;
+            thread.Start();
+        }
+
+        public void ImportPostDo()
+        {
+            while (true)
+            {
+                try
+                {
+                    string data = RedisDbconn.Instance.RPop<string>("PreWithdrawalResultsQueue");
+                    if (!string.IsNullOrEmpty(data))
+                    {
+                        string[] dataList = data.Split("#cut#");
+                        string _ExcelPath = dataList[0];
+                        string _Kind = dataList[1];
+                        string checkKey = dataList[2];
+                        string Operator = dataList[3]; // 操作人
+                        int SuccessCount = 0;
+                        int DoCount = 0;
+                        string FullExcelPath = function.getPath(_ExcelPath);
+                        FullExcelPath = FullExcelPath.Replace("//", "/");
+                        DataTable list = new PublicFunction().ExcelToDataTable(FullExcelPath);
+                        int TotalCount = list.Rows.Count;
+                        while (DoCount < list.Rows.Count)
+                        {
+                            WebCMSEntities db = new WebCMSEntities();
+                            //导入结算金额
+                            if (_Kind == "1")
+                            {
+                                var tran = db.Database.BeginTransaction();
+                                try
+                                {
+                                    int Size = 100;
+                                    if (list.Rows.Count - DoCount < 100)
+                                    {
+                                        Size = list.Rows.Count - DoCount;
+                                    }
+                                    Dictionary<string, int> storeData = new Dictionary<string, int>();
+                                    for (int i = DoCount; i < DoCount + Size; i++)
+                                    {
+                                        DataRow dr = list.Rows[i];
+                                        string Id = dr["A"].ToString();
+                                        string IsOk = dr["L"].ToString();
+                                        var id = int.Parse(Id);
+                                        var Info = db.PreAmountRecord.FirstOrDefault(m => m.Id == id) ?? new PreAmountRecord();
+                                        if (Info.Id > 0)
+                                        {
+                                            if (IsOk == "是") Info.Status = 1;
+                                            if (IsOk == "否")
+                                            {
+                                                Info.Status = -1;
+                                                var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == Info.UserId) ?? new UserAccount();
+                                                if (userAccount.Id > 0)
+                                                {
+                                                    userAccount.PreTempAmount += Info.UseAmount;//退还卡充值临额
+                                                    userAccount.ValidPreAmount += Info.UseAmount;//退还可用额度
+                                                }
+                                            }
+                                        }
+                                        else
+                                        {
+                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到记录为Id" + Id + "相关信息");
+                                        }
+                                    }
+                                    DoCount += Size;
+                                    db.SaveChanges();
+                                    tran.Commit();
+                                    if (DoCount >= list.Rows.Count)
+                                    {
+                                        RedisDbconn.Instance.Set("PreWithdrawalResultsCheckImport:" + checkKey, "success|" + SuccessCount);
+                                        RedisDbconn.Instance.SetExpire("PreWithdrawalResultsCheckImport:" + checkKey, 60000);
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                    DoCount = list.Rows.Count;
+                                    function.WriteLog(ex.ToString(), "导入结算金额");
+                                    tran.Rollback();
+                                    ErrorMsg msg = new ErrorMsg()
+                                    {
+                                        Time = DateTime.Now,
+                                        ErrorContent = ex.ToString(),
+                                    };
+                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入结算金额Excel文件异常");
+                                }
+                                tran.Dispose();
+                            }
+
+                        }
+                    }
+                    else
+                    {
+                        Thread.Sleep(50000);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "后台导入Excel文件队列异常");
+                }
+            }
+        }
+    }
+}

+ 127 - 0
AppStart/Helper/ImportHelper/StoreHouseWithdrawalResultsService.cs

@@ -0,0 +1,127 @@
+using System;
+using System.Threading;
+using System.Linq;
+using System.Data;
+using Library;
+using MySystem.Models;
+using System.Collections.Generic;
+
+/// <summary>
+/// 分仓临时额度提现结果导入
+/// </summary>
+namespace MySystem
+{
+    public class StoreHouseWithdrawalResultsService
+    {
+        public readonly static StoreHouseWithdrawalResultsService Instance = new StoreHouseWithdrawalResultsService();
+        private StoreHouseWithdrawalResultsService()
+        {
+        }
+
+        public void Start()//启动
+        {
+            Thread thread = new Thread(ImportPostDo);
+            thread.IsBackground = true;
+            thread.Start();
+        }
+
+        public void ImportPostDo()
+        {
+            while (true)
+            {
+                try
+                {
+                    string data = RedisDbconn.Instance.RPop<string>("StoreHouseWithdrawalResultsQueue");
+                    if (!string.IsNullOrEmpty(data))
+                    {
+                        string[] dataList = data.Split("#cut#");
+                        string _ExcelPath = dataList[0];
+                        string _Kind = dataList[1];
+                        string checkKey = dataList[2];
+                        string Operator = dataList[3]; // 操作人
+                        int SuccessCount = 0;
+                        int DoCount = 0;
+                        string FullExcelPath = function.getPath(_ExcelPath);
+                        FullExcelPath = FullExcelPath.Replace("//", "/");
+                        DataTable list = new PublicFunction().ExcelToDataTable(FullExcelPath);
+                        int TotalCount = list.Rows.Count;
+                        while (DoCount < list.Rows.Count)
+                        {
+                            WebCMSEntities db = new WebCMSEntities();
+                            //导入结果
+                            if (_Kind == "1")
+                            {
+                                var tran = db.Database.BeginTransaction();
+                                try
+                                {
+                                    int Size = 100;
+                                    if (list.Rows.Count - DoCount < 100)
+                                    {
+                                        Size = list.Rows.Count - DoCount;
+                                    }
+                                    Dictionary<string, int> storeData = new Dictionary<string, int>();
+                                    for (int i = DoCount; i < DoCount + Size; i++)
+                                    {
+                                        DataRow dr = list.Rows[i];
+                                        string Id = dr["A"].ToString();
+                                        string IsOk = dr["L"].ToString();
+                                        var id = int.Parse(Id);
+                                        var Info = db.StoreHouseAmountRecord.FirstOrDefault(m => m.Id == id) ?? new StoreHouseAmountRecord();
+                                        if (Info.Id > 0)
+                                        {
+                                            if (IsOk == "是") Info.Status = 1;
+                                            if (IsOk == "否")
+                                            {
+                                                Info.Status = -1;
+                                                var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == Info.UserId) ?? new UserAccount();
+                                                if (userAccount.Id > 0)
+                                                {
+                                                    userAccount.TempAmount += Info.UseAmount;//退还卡充值临额
+                                                    userAccount.ValidAmount += Info.UseAmount;//退还可用额度
+                                                }
+                                            }
+                                        }
+                                        else
+                                        {
+                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到记录为Id" + Id + "相关信息");
+                                        }
+                                    }
+                                    DoCount += Size;
+                                    db.SaveChanges();
+                                    tran.Commit();
+                                    if (DoCount >= list.Rows.Count)
+                                    {
+                                        RedisDbconn.Instance.Set("StoreHouseWithdrawalResultsCheckImport:" + checkKey, "success|" + SuccessCount);
+                                        RedisDbconn.Instance.SetExpire("StoreHouseWithdrawalResultsCheckImport:" + checkKey, 60000);
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                    DoCount = list.Rows.Count;
+                                    function.WriteLog(ex.ToString(), "分仓临时额度提现结果导入");
+                                    tran.Rollback();
+                                    ErrorMsg msg = new ErrorMsg()
+                                    {
+                                        Time = DateTime.Now,
+                                        ErrorContent = ex.ToString(),
+                                    };
+                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "分仓临时额度提现结果导入Excel文件异常");
+                                }
+                                tran.Dispose();
+                            }
+
+                        }
+                    }
+                    else
+                    {
+                        Thread.Sleep(50000);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "后台导入Excel文件队列异常");
+                }
+            }
+        }
+    }
+}

+ 0 - 373
AppStart/Helper/ImportHelper/WithdrawalResultsService.cs

@@ -1,373 +0,0 @@
-using System;
-using System.Threading;
-using System.Linq;
-using System.Data;
-using Library;
-using MySystem.Models;
-using System.Collections.Generic;
-
-/// <summary>
-/// 提现结果导入
-/// </summary>
-namespace MySystem
-{
-    public class WithdrawalResultsService
-    {
-        public readonly static WithdrawalResultsService Instance = new WithdrawalResultsService();
-        private WithdrawalResultsService()
-        {
-        }
-
-        public void Start()//启动
-        {
-            Thread thread = new Thread(ImportPostDo);
-            thread.IsBackground = true;
-            thread.Start();
-        }
-
-        public void ImportPostDo()
-        {
-            while (true)
-            {
-                try
-                {
-                    string data = RedisDbconn.Instance.RPop<string>("WithdrawalResultsQueue");
-                    if (!string.IsNullOrEmpty(data))
-                    {
-                        string[] dataList = data.Split("#cut#");
-                        string _ExcelPath = dataList[0];
-                        string _Kind = dataList[1];
-                        string checkKey = dataList[2];
-                        string Operator = dataList[3]; // 操作人
-                        int SuccessCount = 0;
-                        int DoCount = 0;
-                        string FullExcelPath = function.getPath(_ExcelPath);
-                        FullExcelPath = FullExcelPath.Replace("//", "/");
-                        DataTable list = new PublicFunction().ExcelToDataTable(FullExcelPath);
-                        int TotalCount = list.Rows.Count;
-                        while (DoCount < list.Rows.Count)
-                        {
-                            WebCMSEntities db = new WebCMSEntities();
-                            //导入结算金额
-                            if (_Kind == "1")
-                            {
-                                var tran = db.Database.BeginTransaction();
-                                try
-                                {
-                                    int Size = 100;
-                                    if (list.Rows.Count - DoCount < 100)
-                                    {
-                                        Size = list.Rows.Count - DoCount;
-                                    }
-                                    Dictionary<string, int> storeData = new Dictionary<string, int>();
-                                    for (int i = DoCount; i < DoCount + Size; i++)
-                                    {
-                                        DataRow dr = list.Rows[i];
-                                        string MakerCode = dr[0].ToString(); //创客编号
-                                        string SettleAmount = dr[2].ToString(); //提现结算金额(元)
-                                        UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
-                                        if (UserCode.UserId > 0)
-                                        {
-                                            var user = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId) ?? new Users();
-                                            if (user.Id > 0)
-                                            {
-                                                user.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
-                                            }
-                                            else
-                                            {
-                                                RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "创客信息");
-                                            }
-                                        }
-                                        else
-                                        {
-                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "编号关联信息");
-                                        }
-                                    }
-                                    DoCount += Size;
-                                    db.SaveChanges();
-                                    tran.Commit();
-                                    if (DoCount >= list.Rows.Count)
-                                    {
-                                        RedisDbconn.Instance.Set("BatchEditUserAmountCheckImport:" + checkKey, "success|" + SuccessCount);
-                                        RedisDbconn.Instance.SetExpire("BatchEditUserAmountCheckImport:" + checkKey, 60000);
-                                    }
-                                }
-                                catch (Exception ex)
-                                {
-                                    DoCount = list.Rows.Count;
-                                    function.WriteLog(ex.ToString(), "导入结算金额");
-                                    tran.Rollback();
-                                    ErrorMsg msg = new ErrorMsg()
-                                    {
-                                        Time = DateTime.Now,
-                                        ErrorContent = ex.ToString(),
-                                    };
-                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入结算金额Excel文件异常");
-                                }
-                                tran.Dispose();
-                            }
-                            //导入冻结金额
-                            if (_Kind == "2")
-                            {
-                                var tran = db.Database.BeginTransaction();
-                                try
-                                {
-                                    int Size = 100;
-                                    if (list.Rows.Count - DoCount < 100)
-                                    {
-                                        Size = list.Rows.Count - DoCount;
-                                    }
-                                    Dictionary<string, int> storeData = new Dictionary<string, int>();
-                                    for (int i = DoCount; i < DoCount + Size; i++)
-                                    {
-                                        DataRow dr = list.Rows[i];
-                                        string MakerCode = dr[0].ToString(); //创客编号
-                                        string CashFreezeAmt = dr[2].ToString(); //提现结算金额(元)
-                                        UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
-                                        if (UserCode.UserId > 0)
-                                        {
-                                            var user = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId) ?? new Users();
-                                            if (user.Id > 0)
-                                            {
-                                                user.CashFreezeAmt = decimal.Parse(function.CheckInt(CashFreezeAmt));
-                                            }
-                                            else
-                                            {
-                                                RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "创客信息");
-                                            }
-                                        }
-                                        else
-                                        {
-                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "编号关联信息");
-                                        }
-                                    }
-                                    DoCount += Size;
-                                    db.SaveChanges();
-                                    tran.Commit();
-                                    if (DoCount >= list.Rows.Count)
-                                    {
-                                        RedisDbconn.Instance.Set("BatchEditUserAmountCheckImport:" + checkKey, "success|" + SuccessCount);
-                                        RedisDbconn.Instance.SetExpire("BatchEditUserAmountCheckImport:" + checkKey, 60000);
-                                    }
-                                }
-                                catch (Exception ex)
-                                {
-                                    DoCount = list.Rows.Count;
-                                    function.WriteLog(ex.ToString(), "导入冻结金额");
-                                    tran.Rollback();
-                                    ErrorMsg msg = new ErrorMsg()
-                                    {
-                                        Time = DateTime.Now,
-                                        ErrorContent = ex.ToString(),
-                                    };
-                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入冻结金额Excel文件异常");
-                                }
-                                tran.Dispose();
-                            }
-                            //导入风控数据
-                            if (_Kind == "3")
-                            {
-                                var tran = db.Database.BeginTransaction();
-                                try
-                                {
-                                    int Size = 100;
-                                    if (list.Rows.Count - DoCount < 100)
-                                    {
-                                        Size = list.Rows.Count - DoCount;
-                                    }
-                                    Dictionary<string, int> storeData = new Dictionary<string, int>();
-                                    for (int i = DoCount; i < DoCount + Size; i++)
-                                    {
-                                        DataRow dr = list.Rows[i];
-                                        string MakerCode = dr[0].ToString(); //创客编号
-                                        string RiskFlag = dr[2].ToString(); //风控标记(0 否 1 是)
-                                        string RiskNote = dr[3].ToString(); //风控备注
-                                        UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
-                                        if (UserCode.UserId > 0)
-                                        {
-                                            var user = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId) ?? new Users();
-                                            if (user.Id > 0)
-                                            {
-                                                user.RiskFlag = ulong.Parse(function.CheckInt(RiskFlag));
-                                                user.RiskRemark = RiskNote;
-                                            }
-                                            else
-                                            {
-                                                RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "创客信息");
-                                            }
-                                        }
-                                        else
-                                        {
-                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "编号关联信息");
-                                        }
-                                    }
-                                    DoCount += Size;
-                                    db.SaveChanges();
-                                    tran.Commit();
-                                    if (DoCount >= list.Rows.Count)
-                                    {
-                                        RedisDbconn.Instance.Set("BatchEditUserAmountCheckImport:" + checkKey, "success|" + SuccessCount);
-                                        RedisDbconn.Instance.SetExpire("BatchEditUserAmountCheckImport:" + checkKey, 60000);
-                                    }
-                                }
-                                catch (Exception ex)
-                                {
-                                    DoCount = list.Rows.Count;
-                                    function.WriteLog(ex.ToString(), "导入风控数据");
-                                    tran.Rollback();
-                                    ErrorMsg msg = new ErrorMsg()
-                                    {
-                                        Time = DateTime.Now,
-                                        ErrorContent = ex.ToString(),
-                                    };
-                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入风控数据Excel文件异常");
-                                }
-                                tran.Dispose();
-                            }
-                            //批量修改账户金额
-                            if (_Kind == "4")
-                            {
-                                var tran = db.Database.BeginTransaction();
-                                try
-                                {
-                                    int Size = 100;
-                                    if (list.Rows.Count - DoCount < 100)
-                                    {
-                                        Size = list.Rows.Count - DoCount;
-                                    }
-                                    Dictionary<string, int> storeData = new Dictionary<string, int>();
-                                    for (int i = DoCount; i < DoCount + Size; i++)
-                                    {
-                                        DataRow dr = list.Rows[i];
-                                        string MakerCode = dr[0].ToString(); //创客编号
-                                        string RealName = dr[1].ToString(); //创客姓名
-                                        string OperationAmt = dr[2].ToString();//操作金额
-                                        string OperationType = dr[3].ToString();//操作类型(1-冻结 2-解冻 3-扣减 4-增加)
-                                        UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
-                                        if (UserCode.UserId > 0)
-                                        {
-                                            var user = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId && m.RealName == RealName) ?? new Users();
-                                            if (user.Id > 0)
-                                            {
-                                                UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == user.Id) ?? new UserAccount();
-                                                if (account.Id > 0)
-                                                {
-                                                    decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
-                                                    decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
-                                                    decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
-                                                    int ChangeType = 0;
-                                                    if (OperationType == "1" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
-                                                    {
-                                                        account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
-                                                        account.FreezeAmount += Convert.ToDecimal(OperationAmt);
-                                                        ChangeType = 61;
-                                                    }
-                                                    else if (OperationType == "1" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
-                                                    {
-                                                        RedisDbconn.Instance.AddList("ErrList" + checkKey, "以下操作失败" + user.MakerCode + ',' + user.RealName + "冻结金额大于余额");
-                                                    }
-                                                    else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) <= account.FreezeAmount)
-                                                    {
-                                                        account.BalanceAmount += Convert.ToDecimal(OperationAmt);
-                                                        account.FreezeAmount -= Convert.ToDecimal(OperationAmt);
-                                                        ChangeType = 62;
-                                                    }
-                                                    else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) > account.FreezeAmount)
-                                                    {
-                                                        RedisDbconn.Instance.AddList("ErrList" + checkKey, "以下操作失败" + user.MakerCode + ',' + user.RealName + "解冻金额大于冻结金额");
-                                                    }
-                                                    else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
-                                                    {
-                                                        account.TotalAmount -= Convert.ToDecimal(OperationAmt);
-                                                        account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
-                                                        ChangeType = 63;
-                                                    }
-                                                    else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
-                                                    {
-                                                        RedisDbconn.Instance.AddList("ErrList" + checkKey, "以下操作失败" + user.MakerCode + ',' + user.RealName + "扣减金额大于余额");
-                                                    }
-                                                    else if (OperationType == "4")
-                                                    {
-                                                        account.TotalAmount += Convert.ToDecimal(OperationAmt);
-                                                        account.BalanceAmount += Convert.ToDecimal(OperationAmt);
-                                                        ChangeType = 64;
-                                                    }
-                                                    decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
-                                                    decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
-                                                    decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
-                                                    UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
-                                                    {
-                                                        CreateDate = DateTime.Now,
-                                                        UpdateDate = DateTime.Now,
-                                                        UserId = user.Id, //创客
-                                                        ChangeType = ChangeType, //变动类型
-                                                        ChangeAmount = Convert.ToDecimal(OperationAmt), //变更金额
-                                                        BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
-                                                        AfterTotalAmount = AfterTotalAmount, //变更后总金额
-                                                        BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
-                                                        AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
-                                                        BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
-                                                        AfterBalanceAmount = AfterBalanceAmount, //变更后余额
-                                                        Remark = dr[4].ToString(),
-                                                    }).Entity;
-                                                    db.SaveChanges();
-                                                    function.WriteLog(DateTime.Now.ToString() + "\n" + user.Id.ToString(), "批量修改账户金额");
-                                                }
-                                                else
-                                                {
-                                                    account = db.UserAccount.Add(new UserAccount()
-                                                    {
-                                                        Id = user.Id,
-                                                        UserId = user.Id,
-                                                    }).Entity;
-                                                    db.SaveChanges();
-                                                }
-                                            }
-                                            else
-                                            {
-                                                RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "创客信息");
-                                            }
-                                        }
-                                        else
-                                        {
-                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "未找到" + MakerCode + "编号关联信息");
-                                        }
-                                    }
-                                    DoCount += Size;
-                                    db.SaveChanges();
-                                    tran.Commit();
-                                    if (DoCount >= list.Rows.Count)
-                                    {
-                                        RedisDbconn.Instance.Set("BatchEditUserAmountCheckImport:" + checkKey, "success|" + SuccessCount);
-                                        RedisDbconn.Instance.SetExpire("BatchEditUserAmountCheckImport:" + checkKey, 60000);
-                                    }
-                                }
-                                catch (Exception ex)
-                                {
-                                    DoCount = list.Rows.Count;
-                                    function.WriteLog(ex.ToString(), "批量修改账户金额");
-                                    tran.Rollback();
-                                    ErrorMsg msg = new ErrorMsg()
-                                    {
-                                        Time = DateTime.Now,
-                                        ErrorContent = ex.ToString(),
-                                    };
-                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "批量修改账户金额Excel文件异常");
-                                }
-                                tran.Dispose();
-                            }
-                        }
-                    }
-                    else
-                    {
-                        Thread.Sleep(50000);
-                    }
-                }
-                catch (Exception ex)
-                {
-                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "后台导入Excel文件队列异常");
-                }
-            }
-        }
-    }
-}

+ 69 - 2
Areas/Admin/Controllers/MainServer/PreAmountRecordController.cs

@@ -418,8 +418,8 @@ namespace MySystem.Areas.Admin.Controllers
             }
             else
             {
-                var Info = db.StoreHouseAmountRecord.Where(m => IdList.Contains(m.Id) && m.Status == 2).ToList();//成功
-                var Infos = db.StoreHouseAmountRecord.Where(m => IdLists.Contains(m.Id) && m.Status == 2).ToList();//失败
+                var Info = db.PreAmountRecord.Where(m => IdList.Contains(m.Id) && m.Status == 2).ToList();//成功
+                var Infos = db.PreAmountRecord.Where(m => IdLists.Contains(m.Id) && m.Status == 2).ToList();//失败
                 foreach (var item in Info)
                 {
                     item.Status = 1;//设置为成功
@@ -442,5 +442,72 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
+
+        #region 通过队列导入数据
+
+        public IActionResult ImportByQueue(string right, string ExcelKind)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+            ViewBag.ExcelKind = ExcelKind;
+            return View();
+        }
+        /// <summary>
+        /// 通过队列导入数据
+        /// </summary>
+        /// <param name="ExcelPath"></param>
+        [HttpPost]
+        public string ImportByQueuePost(string ExcelPath, int Kind = 0)
+        {
+            string key = function.MD5_16(Guid.NewGuid().ToString());
+            RedisDbconn.Instance.AddList("PreWithdrawalResultsQueue", ExcelPath + "#cut#" + Kind + "#cut#" + key + "#cut#" + SysUserName);
+            return "success|" + key;
+        }
+        public string CheckImport(string key)
+        {
+            string result = RedisDbconn.Instance.Get<string>("PreWithdrawalResultsCheckImport:" + key);
+            if (!string.IsNullOrEmpty(result))
+            {
+                string[] datalist = result.Split('|');
+                if (datalist[0] == "success")
+                {
+                    return result;
+                }
+                return datalist[0];
+            }
+            return "0";
+        }
+        public Dictionary<string, object> CheckImportV2(string key)
+        {
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string result = RedisDbconn.Instance.Get<string>("PreWithdrawalResultsCheckImport:" + key);
+            if (!string.IsNullOrEmpty(result))
+            {
+                string[] datalist = result.Split('|');
+                if (datalist[0] == "success")
+                {
+                    List<string> errList = RedisDbconn.Instance.GetList<string>("ErrList" + key);
+                    if (errList.Count > 0)
+                    {
+                        Obj.Add("status", 2);
+                        Obj.Add("errList", errList);
+                    }
+                    else
+                    {
+                        Obj.Add("status", 1);
+                        Obj.Add("data", result);
+                    }
+                    return Obj;
+                }
+                Obj.Add("status", 0);
+                Obj.Add("data", datalist[0]);
+                return Obj;
+            }
+            Obj.Add("status", -1);
+            Obj.Add("data", "执行中...");
+            return Obj;
+        }
+        #endregion
+
     }
 }

+ 67 - 0
Areas/Admin/Controllers/MainServer/StoreHouseAmountRecordController.cs

@@ -788,5 +788,72 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
+
+        #region 通过队列导入数据
+
+        public IActionResult ImportByQueue(string right, string ExcelKind)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+            ViewBag.ExcelKind = ExcelKind;
+            return View();
+        }
+        /// <summary>
+        /// 通过队列导入数据
+        /// </summary>
+        /// <param name="ExcelPath"></param>
+        [HttpPost]
+        public string ImportByQueuePost(string ExcelPath, int Kind = 0)
+        {
+            string key = function.MD5_16(Guid.NewGuid().ToString());
+            RedisDbconn.Instance.AddList("StoreHouseWithdrawalResultsQueue", ExcelPath + "#cut#" + Kind + "#cut#" + key + "#cut#" + SysUserName);
+            return "success|" + key;
+        }
+        public string CheckImport(string key)
+        {
+            string result = RedisDbconn.Instance.Get<string>("StoreHouseWithdrawalResultsCheckImport:" + key);
+            if (!string.IsNullOrEmpty(result))
+            {
+                string[] datalist = result.Split('|');
+                if (datalist[0] == "success")
+                {
+                    return result;
+                }
+                return datalist[0];
+            }
+            return "0";
+        }
+        public Dictionary<string, object> CheckImportV2(string key)
+        {
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string result = RedisDbconn.Instance.Get<string>("StoreHouseWithdrawalResultsCheckImport:" + key);
+            if (!string.IsNullOrEmpty(result))
+            {
+                string[] datalist = result.Split('|');
+                if (datalist[0] == "success")
+                {
+                    List<string> errList = RedisDbconn.Instance.GetList<string>("ErrList" + key);
+                    if (errList.Count > 0)
+                    {
+                        Obj.Add("status", 2);
+                        Obj.Add("errList", errList);
+                    }
+                    else
+                    {
+                        Obj.Add("status", 1);
+                        Obj.Add("data", result);
+                    }
+                    return Obj;
+                }
+                Obj.Add("status", 0);
+                Obj.Add("data", datalist[0]);
+                return Obj;
+            }
+            Obj.Add("status", -1);
+            Obj.Add("data", "执行中...");
+            return Obj;
+        }
+        #endregion
+
     }
 }

+ 2 - 1
Areas/Admin/Views/MainServer/PreAmountRecord/Indexs.cshtml

@@ -140,7 +140,8 @@
         </div>
         <div class="layui-form-item ml10">
             <div class="layui-input-block">
-                <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button>
+                @* <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button> *@
+                <button type="button" class="layui-btn" onclick="ConfirmImportByQueue()">立即导入</button>
             </div>
         </div>
     </div>

+ 2 - 1
Areas/Admin/Views/MainServer/StoreHouseAmountRecord/Indexs.cshtml

@@ -140,7 +140,8 @@
         </div>
         <div class="layui-form-item ml10">
             <div class="layui-input-block">
-                <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button>
+                @* <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button> *@
+                <button type="button" class="layui-btn" onclick="ConfirmImportByQueue()">立即导入</button>
             </div>
         </div>
     </div>

+ 57 - 1
wwwroot/layuiadmin/modules_main/PreCardAmountRecord_Admin.js

@@ -22,6 +22,62 @@ function ConfirmImport() {
     });
 }
 
+function ConfirmImportByQueue() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/PreAmountRecord/ImportByQueuePost?r=" + Math.random(1),
+        data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            } else if (data.indexOf("warning") == 0) {
+                var datalist = data.split('|');
+                layer.alert(datalist[0], { time: 20000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
+function CheckImport(table, key, loadindex, index) {
+    $.ajax({
+        url: "/Admin/PreAmountRecord/CheckImportV2?r=" + Math.random(1),
+        data: "key=" + key,
+        dataType: "json",
+        success: function (data) {
+            if (data.status == 1) {
+                layer.msg("成功操作" + data.data + "条", {
+                    time: 2000
+                }, function () {
+                    layer.close(index); //关闭弹层
+                    layer.close(loadindex);
+                    table.reload('LAY-list-manage'); //数据刷新
+                });
+            } else if (data.status == 2) {
+                layer.close(index); //关闭弹层
+                layer.close(loadindex);
+                var content = '';
+                for (var i = 0; i < data.errList.length; i++) {
+                    content += data.errList[i] + '<br/>'
+                }
+                layer.alert(content);
+            } else {
+                layer.msg(data.data, {
+                    time: 1000
+                }, function () {
+                    CheckImport(table, key, loadindex, index);
+                });
+            }
+        }
+    });
+}
+
 var excel;
 layui.config({
     base: '/layuiadmin/' //静态资源所在路径
@@ -69,7 +125,7 @@ layui.config({
     $('#ExcelFile').change(function (e) {
         var files = e.target.files;
         excel.importExcel(files, {}, function (data) {
-            ExcelData = data[0].sheet1;
+            ExcelData = data[0].Sheet1;
         });
     });
 

+ 56 - 0
wwwroot/layuiadmin/modules_main/StoreHouseCardAmountRecord_Admin.js

@@ -22,6 +22,62 @@ function ConfirmImport() {
     });
 }
 
+function ConfirmImportByQueue() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/StoreHouseAmountRecord/ImportByQueuePost?r=" + Math.random(1),
+        data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            } else if (data.indexOf("warning") == 0) {
+                var datalist = data.split('|');
+                layer.alert(datalist[0], { time: 20000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
+function CheckImport(table, key, loadindex, index) {
+    $.ajax({
+        url: "/Admin/StoreHouseAmountRecord/CheckImportV2?r=" + Math.random(1),
+        data: "key=" + key,
+        dataType: "json",
+        success: function (data) {
+            if (data.status == 1) {
+                layer.msg("成功操作" + data.data + "条", {
+                    time: 2000
+                }, function () {
+                    layer.close(index); //关闭弹层
+                    layer.close(loadindex);
+                    table.reload('LAY-list-manage'); //数据刷新
+                });
+            } else if (data.status == 2) {
+                layer.close(index); //关闭弹层
+                layer.close(loadindex);
+                var content = '';
+                for (var i = 0; i < data.errList.length; i++) {
+                    content += data.errList[i] + '<br/>'
+                }
+                layer.alert(content);
+            } else {
+                layer.msg(data.data, {
+                    time: 1000
+                }, function () {
+                    CheckImport(table, key, loadindex, index);
+                });
+            }
+        }
+    });
+}
+
 var excel;
 layui.config({
     base: '/layuiadmin/' //静态资源所在路径