DuGuYang 3 лет назад
Родитель
Сommit
23baa9e660

+ 66 - 6
AppStart/ExcelHelper.cs

@@ -559,7 +559,7 @@ namespace MySystem
                                                     PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
                                                     if (machine.Id > 0)
                                                     {
-                                                        if(machine.BrandId == BrandId)
+                                                        if (machine.BrandId == BrandId)
                                                         {
                                                             StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
                                                             {
@@ -671,7 +671,7 @@ namespace MySystem
                                                             db.SaveChanges();
 
                                                             RemoveClass.DeletePosMachineList("PosMachineTwoList:" + storefor.StoreId, machine.Id);
-                                                            
+
                                                             if (!storeData.ContainsKey(storefor.StoreId + "_" + BrandId))
                                                             {
                                                                 storeData.Add(storefor.StoreId + "_" + BrandId, 1);
@@ -822,7 +822,7 @@ namespace MySystem
                                                     if (machine.Id > 0)
                                                     {
                                                         function.WriteLog(DateTime.Now.ToString() + "\n" + Newtonsoft.Json.JsonConvert.SerializeObject(machine), "机具回仓库日志");
-                                                        if(!opData.Contains(machine.BuyUserId + ":" + machine.BrandId))
+                                                        if (!opData.Contains(machine.BuyUserId + ":" + machine.BrandId))
                                                         {
                                                             opData.Add(machine.BuyUserId + ":" + machine.BrandId);
                                                         }
@@ -960,7 +960,7 @@ namespace MySystem
                                         db.SaveChanges();
                                     }
                                     db.SaveChanges();
-                                    foreach(string sub in opData)
+                                    foreach (string sub in opData)
                                     {
                                         string[] datalist = sub.Split(":");
                                         PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
@@ -1151,7 +1151,7 @@ namespace MySystem
                                                 {
                                                     UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == edit.UserId);
                                                     if (account != null)
-                                                    {                                                        
+                                                    {
                                                         account.QueryCount = 1;
                                                         decimal TradeAmount = edit.TradeAmount;
                                                         decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
@@ -1217,7 +1217,7 @@ namespace MySystem
                                                     if (account != null)
                                                     {
                                                         decimal TradeAmount = edit.TradeAmount;
-                                                        if(account.FreezeAmount < TradeAmount)
+                                                        if (account.FreezeAmount < TradeAmount)
                                                         {
                                                             RedisDbconn.Instance.AddList("ErrList" + checkKey, "提现记录单号为" + CashOrderNo + "的创客冻结金额异常");
                                                         }
@@ -1391,6 +1391,66 @@ namespace MySystem
                                 }
                             }
                         }
+                        else if (_Kind == "ImportJKCreateData")
+                        {
+                            var brandInfo = db.KqProducts.ToList();
+                            using (var tran = db.Database.BeginTransaction())
+                            {
+                                try
+                                {
+                                    int Size = 100;
+                                    if (list.Rows.Count - DoCount < 100)
+                                    {
+                                        Size = list.Rows.Count - DoCount;
+                                    }
+                                    for (int i = DoCount; i < DoCount + Size; i++)
+                                    {
+                                        DataRow dr = list.Rows[i];
+                                        string PosSn = dr[0].ToString(); // 提现单号
+                                        string CreateDate = dr[1].ToString(); // 备注
+                                        var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
+                                        if (pos.Id > 0)
+                                        {
+                                            var brandName = brandInfo.FirstOrDefault(m => m.Id == pos.BrandId);
+                                            if (brandName.Name.StartsWith("金控"))
+                                            {
+                                                pos.CreateDate = DateTime.Parse(CreateDate);
+                                                SuccessCount += 1;
+                                                RedisDbconn.Instance.Set("CheckImport:" + checkKey, SuccessCount + " / " + TotalCount);
+                                            }
+                                            else
+                                            {
+                                                RedisDbconn.Instance.AddList("ErrList" + checkKey, "以下操作失败" + PosSn + ',' + "该机具号品牌不符合修改规则");
+                                            }
+                                        }
+                                        else
+                                        {
+                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "以下操作失败" + PosSn + ',' + "该机具号不存在");
+                                        }
+                                    }
+                                    DoCount += Size;
+                                    db.SaveChanges();
+                                    tran.Commit();
+                                    if (DoCount >= list.Rows.Count)
+                                    {
+                                        RedisDbconn.Instance.Set("CheckImport:" + checkKey, "success|" + SuccessCount);
+                                        RedisDbconn.Instance.SetExpire("CheckImport:" + checkKey, 60000);
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                    DoCount = list.Rows.Count;
+                                    tran.Rollback();
+                                    ErrorMsg msg = new ErrorMsg()
+                                    {
+                                        Time = DateTime.Now,
+                                        ErrorContent = ex.ToString(),
+                                    };
+                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入Excel文件异常(金控导入修改入库时间)");
+                                }
+                            }
+                        }
+
                         db.Dispose();
                     }
                 }

+ 275 - 133
Areas/Admin/Controllers/MainServer/PosMachinesTwoController.cs

@@ -463,134 +463,134 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
-        #region 导入数据
-        /// <summary>
-        /// 导入数据
-        /// </summary>
-        /// <param name="ExcelData"></param>
-        public string Import(string ExcelData, int Kind = 0)
-        {
-            ExcelData = HttpUtility.UrlDecode(ExcelData);
-            JsonData list = JsonMapper.ToObject(ExcelData);
-            if (Kind == 1)
-            {
-                string error = "";
-                List<string> PosSnList = new List<string>();
-                for (int i = 1; i < list.Count; i++)
-                {
-                    JsonData dr = list[i];
-                    string itemJson = dr.ToJson();
-                    string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
-                    string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
-                    string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
-                    string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
-                    string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
-                    string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
-                    UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
-                    var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
-                    MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
-                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
-                    if (posInfo == null)
-                    {
-                        error += "以下操作失败" + PosSn + ',' + "未找到该品牌的机具" + '\n';
-                    }
-                    else if (PosSnList.Contains(PosSn))
-                    {
-                        error += "以下操作失败" + PosSn + ',' + "该机具号重复" + '\n';
-                    }
-                    else if (!string.IsNullOrEmpty(error))
-                    {
-                        return "Warning|" + error;
-                    }
-                    else
-                    {
-                        PosSnList.Add(PosSn);
-                    }
-
-                }
-                for (int i = 1; i < list.Count; i++)
-                {
-                    JsonData dr = list[i];
-                    string itemJson = dr.ToJson();
-                    string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
-                    string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
-                    string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
-                    string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
-                    string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
-                    string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
-                    decimal amount = 0;
-                    UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
-                    var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
-                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new UserAccount();
-                    var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == Convert.ToInt32(BrandId)) ?? new KqProducts();
-                    if (brandInfo.Name.Contains("电签"))
-                    {
-                        amount = 200;
-                    }
-                    if (brandInfo.Name.Contains("大POS"))
-                    {
-                        amount = 300;
-                    }
-                    userAccount.ValidAmount += amount;
-                    string text = string.Format("导入机具驳回仓库,UserId: '" + user.Id + "',BeforeChangeAmount:'" + userAccount.ValidAmount + "',AfterChangeAmount:'" + userAccount.ValidAmount + amount + "',ChangeAmount:'" + amount + "',Time'" + DateTime.Now + "'");
-                    function.WriteLog(text, "机具驳回仓库");//机具驳回仓库日志
-                    db.SaveChanges();
-                    MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
-                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
-                    if (posInfo != null)
-                    {
-                        var storehouse = db.StoreHouse.FirstOrDefault(m => m.Id == posInfo.StoreId);
-                        StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
-                        {
-                            CreateDate = DateTime.Now,
-                            CreateMan = SysUserName,
-                            StoreId = storehouse.Id, //出货 仓库
-                            BrandId = Convert.ToInt32(BrandId), //产品类型
-                            ProductName = RelationClass.GetKqProductBrandInfo(Convert.ToInt32(BrandId)), //产品名称
-                            BizBatchNo = No, //业务批次号
-                            TransType = 1, //交易类型
-                            SnNo = PosSn, //SN编号
-                            StockOpDirect = 1, //库存操作方向
-                            SnStatus = 1, //SN状态
-                            DeviceVendor = posInfo.DeviceName, //设备厂商
-                            DeviceModel = posInfo.DeviceKind, //设备型号
-                            DeviceType = posInfo.DeviceType, //设备类型                    
-                            SourceStoreId = posInfo.SourceStoreId, //源仓库编号
-                            BrandType = posInfo.DeviceType, //品牌类型
-                        }).Entity;
-
-                        db.StoreChangeHistory.Add(new StoreChangeHistory()
-                        {
-                            CreateDate = DateTime.Now,
-                            UserId = user.Id, //创客
-                            BrandId = Convert.ToInt32(BrandId), //产品类型
-                            ChangeRecordNo = "JJBH" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), //变更记录单号
-                            SeoTitle = "机具驳回仓库",
-                            BizBatchNo = No, //业务批次号
-                            SnNo = PosSn, //SN编号
-                        });
-                        StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
-                        {
-                            CreateDate = DateTime.Now,
-                            StoreId = posInfo.StoreId, //仓库
-                            BrandId = Convert.ToInt32(BrandId), //产品类型
-                            OpStoreNum = 1, //操作库存数
-                            OpSymbol = "+", //操作符
-                            BeforeTotalNum = storehouse.TotalNum, //操作前总库存数
-                            AfterTotalNum = storehouse.TotalNum + 1, //操作后总库存数
-                            BeforeLaveNum = storehouse.LaveNum, //操作前剩余库存数
-                            AfterLaveNum = storehouse.LaveNum + 1, //操作后剩余库存数
-                            BeforeOutNum = storehouse.OutNum, //操作前出库数
-                            AfterOutNum = storehouse.OutNum - 1, //操作后出库数
-                        }).Entity;
-                    }
-                }
-                db.SaveChanges();
-            }
-            AddSysLog("0", "MachinesRejectStore", "Import");
-            return "success";
-        }
-        #endregion
+        // #region 导入数据
+        // /// <summary>
+        // /// 导入数据
+        // /// </summary>
+        // /// <param name="ExcelData"></param>
+        // public string Import(string ExcelData, int Kind = 0)
+        // {
+        //     ExcelData = HttpUtility.UrlDecode(ExcelData);
+        //     JsonData list = JsonMapper.ToObject(ExcelData);
+        //     if (Kind == 1)
+        //     {
+        //         string error = "";
+        //         List<string> PosSnList = new List<string>();
+        //         for (int i = 1; i < list.Count; i++)
+        //         {
+        //             JsonData dr = list[i];
+        //             string itemJson = dr.ToJson();
+        //             string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+        //             string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+        //             string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
+        //             string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
+        //             string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
+        //             string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
+        //             UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
+        //             var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
+        //             MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
+        //             var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
+        //             if (posInfo == null)
+        //             {
+        //                 error += "以下操作失败" + PosSn + ',' + "未找到该品牌的机具" + '\n';
+        //             }
+        //             else if (PosSnList.Contains(PosSn))
+        //             {
+        //                 error += "以下操作失败" + PosSn + ',' + "该机具号重复" + '\n';
+        //             }
+        //             else if (!string.IsNullOrEmpty(error))
+        //             {
+        //                 return "Warning|" + error;
+        //             }
+        //             else
+        //             {
+        //                 PosSnList.Add(PosSn);
+        //             }
+
+        //         }
+        //         for (int i = 1; i < list.Count; i++)
+        //         {
+        //             JsonData dr = list[i];
+        //             string itemJson = dr.ToJson();
+        //             string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+        //             string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+        //             string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
+        //             string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
+        //             string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
+        //             string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
+        //             decimal amount = 0;
+        //             UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
+        //             var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
+        //             var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new UserAccount();
+        //             var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == Convert.ToInt32(BrandId)) ?? new KqProducts();
+        //             if (brandInfo.Name.Contains("电签"))
+        //             {
+        //                 amount = 200;
+        //             }
+        //             if (brandInfo.Name.Contains("大POS"))
+        //             {
+        //                 amount = 300;
+        //             }
+        //             userAccount.ValidAmount += amount;
+        //             string text = string.Format("导入机具驳回仓库,UserId: '" + user.Id + "',BeforeChangeAmount:'" + userAccount.ValidAmount + "',AfterChangeAmount:'" + userAccount.ValidAmount + amount + "',ChangeAmount:'" + amount + "',Time'" + DateTime.Now + "'");
+        //             function.WriteLog(text, "机具驳回仓库");//机具驳回仓库日志
+        //             db.SaveChanges();
+        //             MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
+        //             var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
+        //             if (posInfo != null)
+        //             {
+        //                 var storehouse = db.StoreHouse.FirstOrDefault(m => m.Id == posInfo.StoreId);
+        //                 StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
+        //                 {
+        //                     CreateDate = DateTime.Now,
+        //                     CreateMan = SysUserName,
+        //                     StoreId = storehouse.Id, //出货 仓库
+        //                     BrandId = Convert.ToInt32(BrandId), //产品类型
+        //                     ProductName = RelationClass.GetKqProductBrandInfo(Convert.ToInt32(BrandId)), //产品名称
+        //                     BizBatchNo = No, //业务批次号
+        //                     TransType = 1, //交易类型
+        //                     SnNo = PosSn, //SN编号
+        //                     StockOpDirect = 1, //库存操作方向
+        //                     SnStatus = 1, //SN状态
+        //                     DeviceVendor = posInfo.DeviceName, //设备厂商
+        //                     DeviceModel = posInfo.DeviceKind, //设备型号
+        //                     DeviceType = posInfo.DeviceType, //设备类型                    
+        //                     SourceStoreId = posInfo.SourceStoreId, //源仓库编号
+        //                     BrandType = posInfo.DeviceType, //品牌类型
+        //                 }).Entity;
+
+        //                 db.StoreChangeHistory.Add(new StoreChangeHistory()
+        //                 {
+        //                     CreateDate = DateTime.Now,
+        //                     UserId = user.Id, //创客
+        //                     BrandId = Convert.ToInt32(BrandId), //产品类型
+        //                     ChangeRecordNo = "JJBH" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), //变更记录单号
+        //                     SeoTitle = "机具驳回仓库",
+        //                     BizBatchNo = No, //业务批次号
+        //                     SnNo = PosSn, //SN编号
+        //                 });
+        //                 StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
+        //                 {
+        //                     CreateDate = DateTime.Now,
+        //                     StoreId = posInfo.StoreId, //仓库
+        //                     BrandId = Convert.ToInt32(BrandId), //产品类型
+        //                     OpStoreNum = 1, //操作库存数
+        //                     OpSymbol = "+", //操作符
+        //                     BeforeTotalNum = storehouse.TotalNum, //操作前总库存数
+        //                     AfterTotalNum = storehouse.TotalNum + 1, //操作后总库存数
+        //                     BeforeLaveNum = storehouse.LaveNum, //操作前剩余库存数
+        //                     AfterLaveNum = storehouse.LaveNum + 1, //操作后剩余库存数
+        //                     BeforeOutNum = storehouse.OutNum, //操作前出库数
+        //                     AfterOutNum = storehouse.OutNum - 1, //操作后出库数
+        //                 }).Entity;
+        //             }
+        //         }
+        //         db.SaveChanges();
+        //     }
+        //     AddSysLog("0", "MachinesRejectStore", "Import");
+        //     return "success";
+        // }
+        // #endregion
 
 
         #region 导入金控入库时间数据
@@ -611,7 +611,7 @@ namespace MySystem.Areas.Admin.Controllers
                 string itemJson = dr.ToJson();
                 string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
                 string CreateDate = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
-                var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn && m.Status > -1) ?? new PosMachinesTwo();
+                var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
                 if (pos.Id > 0)
                 {
                     var brandName = brandInfo.FirstOrDefault(m => m.Id == pos.BrandId);
@@ -645,6 +645,71 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
+       #region 导入数据
+
+        public IActionResult Import(string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+            return View();
+        }
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        [HttpPost]
+        public string ImportPost(string ExcelPath)
+        {
+            string key = function.MD5_16(Guid.NewGuid().ToString());
+            RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#ImportJKCreateData#cut#" + key + "#cut#" + SysUserName);
+            return "success|" + key;
+        }
+        public string CheckImport(string key)
+        {
+            string result = RedisDbconn.Instance.Get<string>("CheckImport:" + 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>("CheckImport:" + 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
+
 
 
         #region 导出Excel
@@ -653,13 +718,21 @@ namespace MySystem.Areas.Admin.Controllers
         /// 导出Excel
         /// </summary>
         /// <returns></returns>
-        public JsonResult ExportExcel(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName)
+        public JsonResult ExportExcel(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName, string BrandId, string ActivationDateData, string BindingDateData, string IsStoreSelect, string OpCode)
         {
             Dictionary<string, string> Fields = new Dictionary<string, string>();
             Fields.Add("PosSn", "1"); //SN编号
             Fields.Add("BrandId", "0"); //品牌
 
             string condition = " and Status>-1";
+            //是否仓库机
+            if (!string.IsNullOrEmpty(IsStoreSelect))
+            {
+                if (int.Parse(IsStoreSelect) > 0)
+                {
+                    condition += " and UserId=0 and BuyUserId=0";
+                }
+            }
             //绑定状态
             if (!string.IsNullOrEmpty(BindingStateSelect))
             {
@@ -673,12 +746,12 @@ namespace MySystem.Areas.Admin.Controllers
             //所属创客编号
             if (!string.IsNullOrEmpty(UserIdMakerCode))
             {
-                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
+                condition += " and BuyUserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
             }
             //所属创客真实姓名
             if (!string.IsNullOrEmpty(UserIdRealName))
             {
-                condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
+                condition += " and BuyUserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
             }
             //所属仓库编号
             if (!string.IsNullOrEmpty(StoreIdCode))
@@ -690,9 +763,69 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
             }
+            //运营中心编号
+            if (!string.IsNullOrEmpty(OpCode))
+            {
+                var sysUser = opdb.SysAdmin.FirstOrDefault(m => m.OpCode == OpCode) ?? new OpModels.SysAdmin();
+                if (sysUser.Id > 0)
+                {
+                    condition += " and OpId=" + sysUser.UserId;
+                }
+            }
+            //品牌
+            if (!string.IsNullOrEmpty(BrandId))
+            {
+                condition += " and BrandId =" + BrandId;
+            }
+
+            if (!string.IsNullOrEmpty(ActivationDateData))
+            {
+                string[] datelist = ActivationDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and ActivationTime>='" + start + " 00:00:00' and ActivationTime<='" + end + " 23:59:59'";
+            }
 
+            if (!string.IsNullOrEmpty(BindingDateData))
+            {
+                string[] datelist = BindingDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and BindingTime>='" + start + " 00:00:00' and BindingTime<='" + end + " 23:59:59'";
+            }
+            // //绑定状态
+            // if (!string.IsNullOrEmpty(BindingStateSelect))
+            // {
+            //     condition += " and BindingState=" + BindingStateSelect;
+            // }
+            // //激活状态
+            // if (!string.IsNullOrEmpty(ActivationStateSelect))
+            // {
+            //     condition += " and ActivationState=" + ActivationStateSelect;
+            // }
+            // //所属创客编号
+            // 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(StoreIdCode))
+            // {
+            //     condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
+            // }
+            // //所属仓库名称
+            // if (!string.IsNullOrEmpty(StoreIdName))
+            // {
+            //     condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
+            // }
 
-            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", 1, 20000, condition, "BindingState,ActivationState,UserId,StoreId,PosSn,BrandId,ActivityList,BindMerchantId,PosSnType,DeviceType,BindingTime,ActivationTime,TransferTime", false);
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", 1, 20000, condition, "BindingState,ActivationState,UserId,StoreId,PosSn,BrandId,ActivityList,BindMerchantId,PosSnType,DeviceType,BindingTime,ActivationTime,TransferTime,OpId", false);
             List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
             foreach (Dictionary<string, object> dic in diclist)
             {
@@ -747,6 +880,14 @@ namespace MySystem.Areas.Admin.Controllers
                 int PosSnType = int.Parse(dic["PosSnType"].ToString());
                 if (PosSnType == 0) dic["PosSnType"] = "兑换机具";
                 if (PosSnType == 1) dic["PosSnType"] = "循环机具";
+                //所属运营中心
+                int OpId = int.Parse(dic["OpId"].ToString());
+                if (OpId != 0)
+                {
+                    var sys = opdb.SysAdmin.FirstOrDefault(m => m.QueryCount > 0 && m.UserId == OpId) ?? new OpModels.SysAdmin();
+                    dic["OpCode"] = sys.OpCode;
+                }
+
                 // //设备类型
                 // string DeviceType = dic["DeviceType"].ToString();
                 // if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
@@ -776,6 +917,7 @@ namespace MySystem.Areas.Admin.Controllers
             ReturnFields.Add("ActivationState", "激活状态");
             ReturnFields.Add("ActivationTime", "激活时间");
             ReturnFields.Add("TransferTime", "划拨时间");
+            ReturnFields.Add("OpCode", "所属运营中心");
 
             result.Add("Fields", ReturnFields);
             AddSysLog("0", "PosMachinesTwo", "ExportExcel");

+ 134 - 0
Areas/Admin/Views/MainServer/PosMachinesTwo/Import.cshtml

@@ -0,0 +1,134 @@
+@{
+    string RightInfo = ViewBag.RightInfo as string;
+    string right = ViewBag.right as string;
+
+}
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <title>导入数据</title>
+    <meta name="renderer" content="webkit">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
+    <script src="/admin/js/jquery-1.10.1.min.js"></script>
+    <script src="/admin/js/LAreaData2.js"></script>
+    <style>
+        .layui-form-label {
+            width: 135px !important;
+        }
+
+        .layui-form-item .layui-input-block {
+            margin-left: 165px !important;
+        }
+    </style>
+</head>
+
+<body>
+
+    <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
+
+        <div class="layui-card">
+            <div class="layui-card-body">
+                <div class="layui-tab" lay-filter="mytabbar">
+                    <div class="layui-tab-content mt20">
+                        <div class="layui-tab-item layui-show">
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">模板下载</label>
+                                <div class="layui-form-mid layui-word-aux" id="excelTemp">
+                                    <a href="/users/金控入库时间修改模板.xlsx">点击下载金控入库时间修改模板文件</a>
+                                </div>
+                            </div>
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">excel文件</label>
+                                <div class="layui-input-block">
+                                    <div class="layui-upload">
+                                        <input type="hidden" id="ExcelPath" name="ExcelPath" value="">
+                                        <button class="layui-btn" type="button" id="ExcelPathBtn">选择</button>
+                                        <div class="layui-inline layui-word-aux"></div>
+                                    </div>
+                                    <div class="mt10" id="ExcelPathFile">
+                                    </div>
+                                </div>
+                            </div>
+
+                        </div>
+
+                    </div>
+                </div>
+                <div class="layui-form-item layui-hide">
+                    <input type="button" lay-submit lay-filter="LAY-list-front-submit" id="LAY-list-front-submit"
+                        value="确认">
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script src="/other/oss/upload-min.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script src="/other/mybjq/kindeditor-min.js"></script>
+    <script src="/other/mybjq/lang/zh_CN.js"></script>
+    <script>
+
+
+        //编辑器
+        KindEditor.ready(function (K) {
+
+        });
+
+
+        var tree;
+        var element;
+        var upload;
+        layui.config({
+            base: '/layuiadmin/' //静态资源所在路径
+        }).extend({
+            index: 'lib/index' //主入口模块
+        }).use(['index', 'form', 'upload', 'layedit', 'laydate', 'element', 'croppers', 'transfer', 'tree', 'util'], function () {
+            var $ = layui.$
+                , form = layui.form
+                , layer = layui.layer
+                , layedit = layui.layedit
+                , laydate = layui.laydate
+                , croppers = layui.croppers
+                , transfer = layui.transfer
+                , util = layui.util;
+            tree = layui.tree;
+            element = layui.element;
+            upload = layui.upload;
+
+            //Hash地址的定位
+            var layid = location.hash.replace(/^#test=/, '');
+            element.tabChange('test', layid);
+            element.on('tab(test)', function (elem) {
+                location.hash = 'test=' + $(this).attr('lay-id');
+            });
+
+            //日期
+
+
+            //上传文件
+            WebUploadJs('ExcelPathBtn', '@(Library.ConfigurationManager.AppSettings["Database"].ToString())/upload/v2', { width: 0, height: 0, quality: 0 }, { max_file_size: 1048576 }, function (filename) {
+                var fName = (filename.substring(filename.lastIndexOf("/"))).split("/");
+                $('#ExcelPathFile').html(fName);
+                $('#ExcelPath').val(filename);
+            });
+
+            //穿梭框
+
+
+
+            //TreeView,比如权限管理
+
+
+            //省市区
+
+        });
+
+    </script>
+</body>
+
+</html>

+ 10 - 5
Areas/Admin/Views/MainServer/PosMachinesTwo/Index.cshtml

@@ -152,10 +152,15 @@
                             <button class="layui-btn" data-type="ExportExcel"><i
                                 class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
                         }
-                        @if (RightInfo.Contains("," + right + "_import,"))
+                        @* @if (RightInfo.Contains("," + right + "_import,"))
                         {
                             <button class="layui-btn" data-type="ImportCreateData"><i
                                 class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导入金控入库时间</button>
+                        } *@
+                        @if (RightInfo.Contains("," + right + "_import,"))
+                        {
+                            <button class="layui-btn" data-type="ImportData"><i
+                                class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导入金控入库时间</button>
                         }
                     </div>
                 </div>
@@ -169,17 +174,17 @@
                 <script type="text/html" id="table-list-tools">
                     @if (RightInfo.Contains("," + right + "_edit,"))
                     {
-                                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
+                                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                     }
                     @if (RightInfo.Contains("," + right + "_Home,"))
                     {
-                                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="home"><i class="layui-icon layui-icon-edit"></i>一键归位</a>
+                                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="home"><i class="layui-icon layui-icon-edit"></i>一键归位</a>
                     }
                 </script>
             </div>
         </div>
     </div>
-    <div id="excelForm" style="display:none; padding:20px;">
+    @* <div id="excelForm" style="display:none; padding:20px;">
         <div class="layui-tab-item layui-show">
             <div class="layui-form-item">
                 <label class="layui-form-label">模板下载</label>
@@ -202,7 +207,7 @@
                 <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button>
             </div>
         </div>
-    </div>
+    </div> *@
 
     <script src="/layuiadmin/layui/layui.js"></script>
     <script src="/layuiadmin/modules_main/PosMachinesTwo_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>

+ 69 - 15
wwwroot/layuiadmin/modules_main/PosMachinesTwo_Admin.js

@@ -12,7 +12,7 @@ function ConfirmImport() {
                 });
             } else if (data.indexOf("Warning") == 0) {
                 var datalist = data.split('|');
-                layer.alert(datalist[0], { time: 20000 }, function () {
+                layer.alert(datalist[1], { time: 20000 }, function () {
                     window.location.reload();
                 });
             } else {
@@ -22,6 +22,27 @@ function ConfirmImport() {
     });
 }
 
+function CheckImport(table, key, loadindex, index) { 
+    $.ajax({
+        url: "/Admin/PosMachinesTwo/CheckImport?r=" + Math.random(1),
+        data: "key=" + key,
+        dataType: "text",
+        success: function (data) {
+            if (data.indexOf('success') == 0) {
+                layer.msg("成功操作" + data.split('|')[1] + "台机具", { time: 2000 }, function () {
+                    layer.close(index); //关闭弹层
+                    layer.close(loadindex);
+                    table.reload('LAY-list-manage'); //数据刷新
+                });
+            } else {
+                layer.msg(data, { time: 1000 }, function () {
+                    CheckImport(table, key, loadindex, index);
+                });
+            }
+        }
+    });
+}
+
 var excel;
 layui.config({
     base: '/layuiadmin/' //静态资源所在路径
@@ -386,31 +407,64 @@ layui.config({
             });
             layer.full(perContent);
         }
-        , RejectStore: function () {
-            ExcelKind = 1;
-            layer.open({
-                type: 1,
-                title: '机具驳回仓库导入',
-                maxmin: false,
-                area: ['460px', '280px'],
-                content: $('#excelForm'),
-                cancel: function () {
+        , ImportData: function () {
+            var perContent = layer.open({
+                type: 2
+                , title: '金控入库时间导入'
+                , content: 'Import'
+                , maxmin: true
+                , area: ['650px', '350px']
+                , btn: ['确定', '取消']
+                , yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index]
+                        , submitID = 'LAY-list-front-submit'
+                        , submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+                        var loadindex = layer.load(1, {
+                            shade: [0.5, '#000']
+                        });
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/PosMachinesTwo/ImportPost?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                if (data.indexOf("success") == 0) {
+                                    var datalist = data.split('|');
+                                    var key = datalist[1];
+                                    CheckImport(table, key, loadindex, index);
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
                 }
             });
-            $("#excelTemp").html('<a href="/users/机具驳回仓库模版.xlsx">点击下载机具驳回仓库模版</a>');
-        }
-        , ImportData: function () {
+        },RejectStore: function () {
             ExcelKind = 1;
             layer.open({
                 type: 1,
-                title: '导入',
+                title: '机具驳回仓库导入',
                 maxmin: false,
                 area: ['460px', '280px'],
                 content: $('#excelForm'),
                 cancel: function () {
                 }
             });
-            $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
+            $("#excelTemp").html('<a href="/users/机具驳回仓库模版.xlsx">点击下载机具驳回仓库模版</a>');
         }
         , ImportCreateData: function () {
             layer.open({