DuGuYang 3 år sedan
förälder
incheckning
926e90a71e

+ 1 - 0
Areas/Admin/Controllers/BsServer/BaseController.cs

@@ -29,6 +29,7 @@ namespace MySystem.Areas.Admin.Controllers
         public OpModels.WebCMSEntities opdb = new OpModels.WebCMSEntities();
 
         public string Host = Library.ConfigurationManager.AppSettings["Host"].ToString();
+        public string OpHost = Library.ConfigurationManager.AppSettings["OpHost"].ToString();
 
         public string ShareHost = "";
         public string SourceHost = OssHelper.Instance.SourceHost;

+ 350 - 104
Areas/Admin/Controllers/MainServer/StoreHouseController.cs

@@ -155,20 +155,25 @@ namespace MySystem.Areas.Admin.Controllers
                         userIds += item.Id + ",";
                     }
                     userIds += user.Id;//下线创客Id包含自己
-                    string ParentNav = function.CheckNull(user.ParentNav).Trim(',').Replace(",,", ",");
-                    string[] ParentNavList = ParentNav.Split(',');
-                    string OpId = ParentNavList[^1];//上线创客
-                    var storeHouse = db.StoreHouse.Where(m => m.OpId == int.Parse(OpId) && m.Sort == 0 && m.UserId != 0 && m.UserId != 1).ToList();//上线关联的分仓
-                    var storeHouses = db.StoreHouse.Where(m => m.OpId == 0 && userIds.TrimEnd(',').Contains(m.UserId.ToString()) && m.UserId != 0 && m.UserId != 1 && m.Status > 0).ToList();//下线未关联分仓
+                    // string ParentNav = function.CheckNull(user.ParentNav).Trim(',').Replace(",,", ",");
+                    // string[] ParentNavList = ParentNav.Split(',');
+                    // string OpId = ParentNavList[^1];//上线创客
                     string Id = "";
-                    foreach (var items in storeHouse)
+                    // var storeHouse = db.StoreHouse.Where(m => m.OpId == int.Parse(OpId) && m.Sort == 0 && m.UserId != 0 && m.UserId != 1 && m.Status == 1).ToList();//上线关联的分仓
+                    DataTable dt = OtherMySqlConn.dtable("SELECT Id FROM StoreHouse WHERE UserId IN(" + userIds.TrimEnd(',') + ") AND OPId not IN (" + userIds.TrimEnd(',') + ") AND `Status`=1 AND Sort=0 AND UserId>1");
+                    foreach (DataRow item in dt.Rows)
                     {
-                        Id += items.Id + ",";
-                    }
-                    foreach (var item1 in storeHouses)
-                    {
-                        Id += item1.Id + ",";
+                        Id += item["Id"].ToString() + ",";
                     }
+                    // var storeHouses = db.StoreHouse.Where(m => m.OpId == 0 && userIds.TrimEnd(',').Contains(m.UserId.ToString()) && m.UserId != 0 && m.UserId != 1 && m.Status > 0).ToList();//下线未关联分仓?
+                    // foreach (var items in storeHouse)
+                    // {
+                    //     Id += items.Id + ",";
+                    // }
+                    // foreach (var item1 in storeHouses)
+                    // {
+                    //     Id += item1.Id + ",";
+                    // }
                     condition += " and Id in (" + Id.TrimEnd(',') + ")";
 
                 }
@@ -464,6 +469,60 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 return "您输入的仓库负责人编号不存在,请重新输入正确的仓库负责人编号";
             }
+            var store = db.StoreHouse.Where(m => m.Sort == 0 && m.Status == 1 && m.UserId == user.UserId).ToList();
+            var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == user.UserId) ?? new UserAccount();
+            if (userAccount.Id > 0)
+            {
+                userAccount.StoreDeposit = data.Deposit;
+                db.SaveChanges();
+            }
+            RedisDbconn.Instance.AddList("ResetStoreReserveQueue", user.UserId.ToString());
+            decimal olddeposit = 0;//旧押金
+            decimal newdeposit = 0;//新押金
+            var sto = db.StoreHouse.FirstOrDefault(m => m.Id == data.Id);
+            newdeposit = data.Deposit;
+            olddeposit = sto.Deposit;
+            if (sto.OpId > 0)
+            {
+                var amount = opdb.UserAccount.FirstOrDefault(m => m.UserId == sto.OpId) ?? new OpModels.UserAccount();
+                if (newdeposit > olddeposit)
+                {
+                    var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                    {
+                        CreateDate = DateTime.Now,
+                        UserId = sto.OpId,
+                        SeoDescription = "分仓押金变更",
+                        OperateType = 1,
+                        UseAmount = newdeposit - olddeposit,
+                        BeforeAmount = amount.ValidAmount,
+                        AfterAmount = amount.ValidAmount + newdeposit - olddeposit,
+                    }).Entity;
+                    opdb.SaveChanges();
+                }
+                if (newdeposit < olddeposit)
+                {
+                    var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                    {
+                        CreateDate = DateTime.Now,
+                        UserId = sto.OpId,
+                        SeoDescription = "分仓押金变更",
+                        OperateType = 2,
+                        UseAmount = olddeposit - newdeposit,
+                        BeforeAmount = amount.ValidAmount,
+                        AfterAmount = amount.ValidAmount + newdeposit - olddeposit,
+                    }).Entity;
+                    opdb.SaveChanges();
+                }
+                amount.ValidAmount -= sto.Deposit;
+                amount.ValidAmount += data.Deposit;
+                opdb.SaveChanges();
+            }
+            foreach (var item in store)
+            {
+                var storeInfo = store.FirstOrDefault(m => m.Id == item.Id);
+                storeInfo.Deposit = data.Deposit;
+                db.SaveChanges();
+            }
             Fields.Add("ManageUserId", manage.UserId); //仓库管理员
             Fields.Add("ManagerEmail", data.ManagerEmail); //管理者邮箱
             Fields.Add("ManageMobile", data.ManageMobile);
@@ -1506,17 +1565,38 @@ namespace MySystem.Areas.Admin.Controllers
         /// 关联分仓
         /// </summary>
         /// <returns></returns>
-        public IActionResult BatchSetting(string right)
+        public IActionResult BatchSetting(string right, string StoreIds)
         {
+            string[] idlist = StoreIds.Split(new char[] { ',' });
+            var totalAmount = 0;
+            foreach (var item in idlist)
+            {
+                int StoreId = int.Parse(item);
+                var amount = 0;
+                var tamount = 0;
+                var storeInfo = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId);
+                var posCount = db.PosMachinesTwo.Count(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0 && m.OpId == 0);
+                var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == int.Parse(storeInfo.BrandId));
+                if (brandInfo.Name.Contains("电签"))
+                {
+                    amount = 100;
+                }
+                if (brandInfo.Name.Contains("大POS"))
+                {
+                    amount = 150;
+                }
+                tamount = amount * posCount;//扣减运营中心该品牌机具额度
+                totalAmount += tamount;//关联分仓打标记运营中心所需额度
+            }
             ViewBag.RightInfo = RightInfo;
             ViewBag.right = right;
+            ViewBag.totalAmount = "关联分仓机具需要额度:" + totalAmount;
 
             return View();
         }
 
         #endregion
 
-        //TODO:关联分仓和取消关联要添加额度变动记录
         #region 关联分仓
 
         /// <summary>
@@ -1524,72 +1604,161 @@ namespace MySystem.Areas.Admin.Controllers
         /// </summary>
         /// <returns></returns>
         [HttpPost]
-        public string BatchSetting(string Id, string MakerCode)
+        public string BatchSetting(string Id, string MakerCode, string IsOk = "1")
         {
             string[] idlist = Id.Split(new char[] { ',' });
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
             AddSysLog(Id, "StoreHouse", "StoreHouseBatchSetting");
             var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
             if (userForMakerCode.UserId > 0)
             {
                 var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.UserId == userForMakerCode.UserId) ?? new OpModels.SysAdmin();
+                Fields.Add("OpId", sysAdmin.UserId);
                 if (sysAdmin.Id > 0)
                 {
-                    DataTable dt = OtherMySqlConn.dtable("UPDATE StoreHouse SET OpId=" + sysAdmin.UserId + " WHERE Id IN (" + Id + ") AND StoreKind!=2 AND `Status` >0");
-                    // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouse", Fields, pos.Id);
-                    db.SaveChanges();
-                    foreach (var item in idlist)
+                    var amount = 0;
+                    var tamount = 0;
+                    decimal deposit = 0;
+                    var pCount = 0;
+                    var userIds = "";
+                    string error = "";
+                    foreach (var items in idlist)
                     {
-                        int StoreId = int.Parse(item);
-                        var amount = 0;
-                        var tamount = 0;
+                        int StoreId = int.Parse(items);
                         var storeInfo = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId && m.StoreKind != 2);
-                        var posCount = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0).Count();
-                        var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == int.Parse(storeInfo.BrandId));
-                        if (brandInfo.Name.Contains("电签"))
+                        if (storeInfo.OpId > 0)
                         {
-                            amount = 100;
+                            error += "以下操作失败" + storeInfo.StoreNo + ',' + "请先解除该分仓的关联" + '\n';
                         }
-                        if (brandInfo.Name.Contains("大POS"))
+                        else
                         {
-                            amount = 150;
+                            var pos = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0).ToList();
+                            var posCount = pos.Count();
+                            var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == int.Parse(storeInfo.BrandId));
+                            if (brandInfo.Name.Contains("电签"))
+                            {
+                                amount = 100;
+                            }
+                            if (brandInfo.Name.Contains("大POS"))
+                            {
+                                amount = 150;
+                            }
+                            if (!userIds.Contains(storeInfo.UserId + ","))
+                            {
+                                userIds += storeInfo.UserId + ",";
+                                deposit += storeInfo.Deposit;//增加分仓押金
+                            }
+                            else
+                            {
+                                deposit = storeInfo.Deposit;//增加分仓押金
+                            }
+                            tamount += amount * posCount;//扣减运营中心该品牌机具额度
+                            pCount += posCount;//添加总机具数
                         }
-                        tamount = amount * posCount;//扣减运营中心该品牌机具额度
-                        var userAmount = opdb.UserAccount.FirstOrDefault(m => m.Sort == sysAdmin.Id) ?? new OpModels.UserAccount();
-                        userAmount.ValidAmount -= tamount;//扣减关联分仓机具占用额度
-                        userAmount.ValidAmount += storeInfo.Deposit;//增加关联分仓押金
-                        // storeInfo.OpId = sysAdmin.UserId;
-                        db.SaveChanges();
-                        opdb.SaveChanges();
-                        var query = opdb.StoreForOperate.FirstOrDefault(m => m.OpId == sysAdmin.UserId && m.StoreId == StoreId && m.Sort == 0 && m.QueryCount == storeInfo.UserId && m.Status == 0);
-                        if (query == null)
+                    }
+                    if (!string.IsNullOrEmpty(error))
+                    {
+                        return "Warning|" + error;
+                    }
+                    var userAmount = opdb.UserAccount.FirstOrDefault(m => m.Sort == sysAdmin.Id) ?? new OpModels.UserAccount();
+                    if (userAmount.ValidAmount + deposit - tamount >= 0)
+                    {
+                        foreach (var item in idlist)
                         {
-                            var user = db.Users.FirstOrDefault(m => m.Id == storeInfo.UserId) ?? new Users();
-                            query = opdb.StoreForOperate.Add(new OpModels.StoreForOperate()
+                            int StoreId = int.Parse(item);
+                            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouse", Fields, StoreId);
+                            var storeInfo = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId && m.StoreKind != 2);
+                            if (storeInfo.OpId == 0)
                             {
-                                CreateDate = DateTime.Now, //创建时间
-                                CreateMan = SysUserName + "_" + SysRealName,
-                                QueryCount = storeInfo.UserId,//分仓所属人Id
-                                SeoTitle = user.MakerCode,
-                                SeoKeyword = storeInfo.StoreNo,
-                                SeoDescription = storeInfo.StoreName,
-                                OpId = sysAdmin.UserId,
-                                StoreId = StoreId,
-                            }).Entity;
-                            opdb.SaveChanges();
+                                var pos = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0).ToList();
+                                var posCount = pos.Count();
+                                if (IsOk == "1")
+                                {
+                                    foreach (var items in pos)
+                                    {
+                                        var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == items.Id) ?? new PosMachinesTwo();
+                                        posInfo.OpId = sysAdmin.UserId;
+                                        db.SaveChanges();
+                                    }
+                                    sysAdmin.TotalMachineCount += posCount;//添加总机具数
+                                    opdb.SaveChanges();
+                                }
+                                storeInfo.OpId = sysAdmin.UserId;
+                                db.SaveChanges();
+
+                                var query = opdb.StoreForOperate.FirstOrDefault(m => m.OpId == sysAdmin.UserId && m.StoreId == StoreId && m.Sort == 0 && m.QueryCount == storeInfo.UserId && m.Status == 0);
+                                if (query == null)
+                                {
+                                    var user = db.Users.FirstOrDefault(m => m.Id == storeInfo.UserId) ?? new Users();
+                                    query = opdb.StoreForOperate.Add(new OpModels.StoreForOperate()
+                                    {
+                                        CreateDate = DateTime.Now, //创建时间
+                                        CreateMan = SysUserName + "_" + SysRealName,
+                                        QueryCount = storeInfo.UserId,//分仓所属人Id
+                                        SeoTitle = user.MakerCode,
+                                        SeoKeyword = storeInfo.StoreNo,
+                                        SeoDescription = storeInfo.StoreName,
+                                        OpId = sysAdmin.UserId,
+                                        StoreId = StoreId,
+                                    }).Entity;
+                                    opdb.SaveChanges();
+                                }
+                                //添加分仓创建时间
+                                var users = db.Users.FirstOrDefault(m => m.Id == storeInfo.UserId) ?? new Users();
+                                if (users.Id > 0)
+                                {
+                                    DataTable dt = OtherMySqlConn.dtable("SELECT CreateDate FROM StoreHouse WHERE UserId=" + users.Id + " AND `Status`>0 ORDER BY CreateDate LIMIT 1");
+                                    if (dt.Rows.Count > 0)
+                                    {
+                                        users.CreateStoreDate = DateTime.Parse(dt.Rows[0][0].ToString());
+                                        db.SaveChanges();
+                                    }
+                                }
+                            }
                         }
-                        //添加分仓创建时间
-                        var users = db.Users.FirstOrDefault(m => m.Id == storeInfo.UserId) ?? new Users();
-                        if (users.Id > 0)
+                        if (IsOk == "1")
                         {
-                            if (string.IsNullOrEmpty(users.CreateStoreDate.ToString()))
+                            if (deposit > tamount)
                             {
-                                users.CreateStoreDate = DateTime.Now;
-                                db.SaveChanges();
+                                var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                                {
+                                    CreateDate = DateTime.Now,
+                                    UserId = sysAdmin.UserId,
+                                    SeoDescription = "关联分仓",
+                                    OperateType = 1,
+                                    UseAmount = deposit - tamount,
+                                    BeforeAmount = userAmount.ValidAmount,
+                                    AfterAmount = userAmount.ValidAmount + deposit - tamount,
+                                }).Entity;
                             }
+                            if (deposit < tamount)
+                            {
+                                var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                                {
+                                    CreateDate = DateTime.Now,
+                                    UserId = sysAdmin.UserId,
+                                    SeoDescription = "关联分仓",
+                                    OperateType = 2,
+                                    UseAmount = tamount - deposit,
+                                    BeforeAmount = userAmount.ValidAmount,
+                                    AfterAmount = userAmount.ValidAmount + deposit - tamount,
+                                }).Entity;
+                            }
+                            userAmount.ValidAmount -= tamount;//扣减关联分仓机具占用额度
+                            userAmount.ValidAmount += deposit;//增加关联分仓押金
+                            opdb.SaveChanges();
                         }
+                        sysAdmin.StoreCount += pCount;//添加关联分仓数
+                        opdb.SaveChanges();
+                    }
+                    else
+                    {
+                        return "运营中心额度不足";
                     }
-                    sysAdmin.StoreCount += idlist.Count();//添加关联分仓数
-                    opdb.SaveChanges();
+                }
+                else
+                {
+                    return "该创客未创建运营中心";
                 }
             }
             return "success";
@@ -1612,11 +1781,44 @@ namespace MySystem.Areas.Admin.Controllers
         /// 取消关联
         /// </summary>
         /// <returns></returns>
-        public IActionResult BatchCancle(string right)
+        public IActionResult BatchCancle(string right, string StoreIds)
         {
+            string[] idlist = StoreIds.Split(new char[] { ',' });
+            decimal totalAmount = 0;
+            decimal deposit = 0;
+            var userIds = "";
+            foreach (var item in idlist)
+            {
+                int StoreId = int.Parse(item);
+                var amount = 0;
+                var tamount = 0;
+                var storeInfo = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId);
+                var posCount = db.PosMachinesTwo.Count(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0 && m.OpId == storeInfo.OpId);
+                var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == int.Parse(storeInfo.BrandId));
+                if (brandInfo.Name.Contains("电签"))
+                {
+                    amount = 100;
+                }
+                if (brandInfo.Name.Contains("大POS"))
+                {
+                    amount = 150;
+                }
+                if (!userIds.Contains(storeInfo.UserId + ","))
+                {
+                    userIds += storeInfo.UserId + ",";
+                    deposit += storeInfo.Deposit;
+                }
+                else
+                {
+                    deposit = storeInfo.Deposit;
+                }
+                tamount = amount * posCount;//增加运营中心该品牌机具额度
+                totalAmount += tamount;//取消关联分仓打标记运营中心所需额度
+            }
+            // totalAmount -= deposit;
             ViewBag.RightInfo = RightInfo;
             ViewBag.right = right;
-
+            ViewBag.totalAmount = "取消关联机具获得额度:" + totalAmount;
             return View();
         }
 
@@ -1630,84 +1832,128 @@ namespace MySystem.Areas.Admin.Controllers
         /// </summary>
         /// <returns></returns>
         [HttpPost]
-        public string BatchCancle(string Id, string MakerCode)
+        public string BatchCancle(string Id, string MakerCode, string IsOk = "1")
         {
             string[] idlist = Id.Split(new char[] { ',' });
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
             AddSysLog(Id, "StoreHouse", "StoreHouseBatchCancle");
             var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
             if (userForMakerCode.UserId > 0)
             {
                 var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.UserId == userForMakerCode.UserId);
+                Fields.Add("OpId", 0);
                 if (sysAdmin.Id > 0)
                 {
+                    var amount = 0;
+                    var tamount = 0;
+                    decimal deposit = 0;
+                    var pCount = 0;
+                    var userIds = "";
                     string error = "";
                     foreach (var item in idlist)
                     {
                         int StoreId = int.Parse(item);
-                        var store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId && m.StoreKind != 2);
-                        if (store != null && store.OpId != sysAdmin.UserId)
+                        var store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId && m.StoreKind != 2 && m.OpId == sysAdmin.UserId);
+                        if (store == null)
                         {
                             error += "分仓" + store.StoreNo + "未在创客" + MakerCode + "的关联分仓中";
                         }
+                        else
+                        {
+                            var pos = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0 && m.OpId == sysAdmin.UserId).ToList();
+                            var posCount = pos.Count();
+                            var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == int.Parse(store.BrandId));
+                            if (brandInfo.Name.Contains("电签"))
+                            {
+                                amount = 100;
+                            }
+                            if (brandInfo.Name.Contains("大POS"))
+                            {
+                                amount = 150;
+                            }
+                            if (!userIds.Contains(store.UserId + ","))
+                            {
+                                userIds += store.UserId + ",";
+                                deposit += store.Deposit;//增加分仓押金
+                            }
+                            else
+                            {
+                                deposit = store.Deposit;//增加分仓押金
+                            }
+                            tamount += amount * posCount;//扣减运营中心该品牌机具额度
+                            pCount += posCount;//添加总机具数
+                        }
                     }
-
                     if (!string.IsNullOrEmpty(error))
                     {
                         return "Warning|" + error;
                     }
-
-                    DataTable dt = OtherMySqlConn.dtable("UPDATE StoreHouse SET OpId=0 WHERE Id IN (" + Id + ") AND OpId =" + sysAdmin.UserId + " AND StoreKind!=2 AND `Status` >0");
-                    // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouse", Fields, pos.Id);
-                    db.SaveChanges();
-                    foreach (var item in idlist)
+                    var userAmount = opdb.UserAccount.FirstOrDefault(m => m.Sort == sysAdmin.Id) ?? new OpModels.UserAccount();
+                    if (userAmount.ValidAmount - deposit + tamount >= 0)
                     {
-                        int StoreId = int.Parse(item);
-                        var store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId && m.StoreKind != 2);
-                        if (store != null && store.OpId != sysAdmin.UserId)
-                        {
-                            return "分仓" + store.StoreNo + "未在创客" + MakerCode + "的关联分仓中";
-                        }
-                        var amount = 0;
-                        var tamount = 0;
-                        var storeInfo = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId);
-                        var posCount = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0).Count();
-                        var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == int.Parse(storeInfo.BrandId));
-                        if (brandInfo.Name.Contains("电签"))
-                        {
-                            amount = 100;
-                        }
-                        if (brandInfo.Name.Contains("大POS"))
+                        foreach (var item in idlist)
                         {
-                            amount = 150;
+                            int StoreId = int.Parse(item);
+                            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouse", Fields, StoreId);
+                            var store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId && m.StoreKind != 2);
+                            var pos = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0 && m.OpId == sysAdmin.UserId).ToList();
+                            foreach (var items in pos)
+                            {
+                                var posInfo = pos.FirstOrDefault(m => m.Id == items.Id) ?? new PosMachinesTwo();
+                                posInfo.OpId = 0;
+                                db.SaveChanges();
+                            }
+                            var query = opdb.StoreForOperate.FirstOrDefault(m => m.Status == 0 && m.OpId == sysAdmin.UserId && m.StoreId == StoreId && m.Sort == 0 && m.QueryCount == store.UserId);
+                            if (query != null)
+                            {
+                                query.UpdateDate = DateTime.Now;
+                                query.UpdateMan = SysUserName + "_" + SysRealName;
+                                query.Status = -1;
+                                opdb.SaveChanges();
+                            }
                         }
-                        tamount = amount * posCount;//扣减运营中心该品牌机具额度
-                        var userAmount = opdb.UserAccount.FirstOrDefault(m => m.Sort == sysAdmin.Id) ?? new OpModels.UserAccount();
-                        userAmount.ValidAmount += tamount;//增加关联分仓机具占用额度
-                        userAmount.ValidAmount -= storeInfo.Deposit;//扣减关联分仓押金
-                        opdb.SaveChanges();
-                        var query = opdb.StoreForOperate.FirstOrDefault(m => m.Status == 0 && m.OpId == sysAdmin.UserId && m.StoreId == StoreId && m.Sort == 0 && m.QueryCount == store.UserId);
-                        if (query != null)
+                        userAmount.ValidAmount -= deposit;//扣减关联分仓押金
+                        userAmount.ValidAmount += tamount;//添加关联仓库机占用额度
+                        sysAdmin.StoreCount -= idlist.Count();//减少关联分仓数
+                        sysAdmin.TotalMachineCount -= pCount;//减少关联分仓机具数
+                        if (deposit > tamount)
                         {
-                            query.UpdateDate = DateTime.Now;
-                            query.UpdateMan = SysUserName + "_" + SysRealName;
-                            query.Status = -1;
-                            opdb.SaveChanges();
+                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                            {
+                                CreateDate = DateTime.Now,
+                                UserId = sysAdmin.UserId,
+                                SeoDescription = "取消关联分仓",
+                                OperateType = 2,
+                                UseAmount = deposit - tamount,
+                                BeforeAmount = userAmount.ValidAmount,
+                                AfterAmount = userAmount.ValidAmount - deposit + tamount,
+                            }).Entity;
                         }
-                        //取消分仓创建时间
-                        var users = db.Users.FirstOrDefault(m => m.Id == storeInfo.UserId) ?? new Users();
-                        if (users.Id > 0)
+                        if (deposit < tamount)
                         {
-                            if (string.IsNullOrEmpty(users.CreateStoreDate.ToString()))
+                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
                             {
-                                users.CreateStoreDate = null;
-                                db.SaveChanges();
-                            }
+                                CreateDate = DateTime.Now,
+                                UserId = sysAdmin.UserId,
+                                SeoDescription = "取消关联分仓",
+                                OperateType = 1,
+                                UseAmount = tamount - deposit,
+                                BeforeAmount = userAmount.ValidAmount,
+                                AfterAmount = userAmount.ValidAmount - deposit + tamount,
+                            }).Entity;
                         }
+                        opdb.SaveChanges();
+                    }
+                    else
+                    {
+                        return "运营中心额度不足";
                     }
-                    sysAdmin.StoreCount -= idlist.Count();//减少关联分仓数
-                    opdb.SaveChanges();
                 }
             }
+            else
+            {
+                return "该创客未创建运营中心";
+            }
             return "success";
         }
 

+ 1 - 1
Areas/Admin/Controllers/MainServer/StoreMachineApplyController.cs

@@ -653,7 +653,7 @@ namespace MySystem.Areas.Admin.Controllers
                 tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status > -1);
 
                 MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
-                PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
+                PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.BuyUserId == 0 && m.UserId == 0 && m.PreUserId == 0) ?? new PosMachinesTwo();
                 if (machine.Id > 0)
                 {
                     if (machine.BrandId != BrandId)

+ 4 - 3
Areas/Admin/Controllers/OperateServer/StoreMachineApplyOperateController.cs

@@ -192,6 +192,7 @@ namespace MySystem.Areas.Admin.Controllers
         #endregion
 
 
+
         #region 增加分仓机具申请记录
 
         /// <summary>
@@ -542,7 +543,6 @@ namespace MySystem.Areas.Admin.Controllers
             ViewBag.data = editData;
 
             SysAdmin sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.Status == 0 && m.UserId == editData.UserId) ?? new SysAdmin();
-            // Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
             ViewBag.OpCode = sysAdmin.OpCode;
             ViewBag.MakerCode = sysAdmin.MakerCode;
             ViewBag.MakerName = sysAdmin.MakerName;
@@ -552,7 +552,6 @@ namespace MySystem.Areas.Admin.Controllers
 
         #endregion
 
-        //TODO:总仓给运营中心机关联的分仓发货应操作哪些数据
         #region 审核发货
 
         [HttpPost]
@@ -759,7 +758,6 @@ namespace MySystem.Areas.Admin.Controllers
                 apply.SeoDescription = function.CheckString(SnNo) + ',';
 
                 fromstore = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId);
-                // tostore = db.StoreHouse.FirstOrDefault(m => m.Sort > 0 && m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status == 1);
 
                 Models.MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new Models.MachineForSnNo();
                 Models.PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.BuyUserId == 0 && m.UserId == 0) ?? new Models.PosMachinesTwo();
@@ -907,6 +905,7 @@ namespace MySystem.Areas.Admin.Controllers
                 if (sysAdmin.Id > 0)
                 {
                     sysAdmin.TotalMachineCount += item.Num;
+                    opdb.SaveChanges();
                 }
             }
             apply.SeoTitle = SysUserName + '-' + SysRealName;//添加操作人信息
@@ -922,6 +921,8 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
+
+
         //发货信息实体类
         private class SendInfo
         {

+ 844 - 0
Areas/Admin/Controllers/OperateServer/StoreMachineApplysOperateController.cs

@@ -0,0 +1,844 @@
+/*
+ * 运营中心机具申请记录
+ */
+
+using System;
+using System.Web;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using MySystem.Models;
+using Library;
+using LitJson;
+using MySystemLib;
+
+namespace MySystem.Areas.Admin.Controllers
+{
+    [Area("Admin")]
+    [Route("Admin/[controller]/[action]")]
+    public class StoreMachineApplysOperateController : BaseController
+    {
+        public StoreMachineApplysOperateController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
+        {
+            OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+        }
+
+
+        #region 运营中心关联分仓机具申请记录列表
+
+        /// <summary>
+        /// 根据条件查询运营中心机具申请记录列表
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Indexs1(StoreMachineApply data, string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            return View();
+        }
+
+        #endregion
+
+        #region 根据条件查询运营中心关联分仓机具申请记录列表
+
+        /// <summary>
+        /// 运营中心机具申请记录列表
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult Indexs1Data(StoreMachineApply data, string MakerCode, string OpCode, string CreateDateData, string StatusSelect, int page = 1, int limit = 30)
+        {
+
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+
+            Fields.Add("ApplyNo", "1"); //申请单号
+            Fields.Add("SendMode", "1"); //发货方式
+
+
+            string condition = " and Status>-1 and QueryCount>0";
+            if (!string.IsNullOrEmpty(CreateDateData))
+            {
+                string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
+            }
+            //创客编号
+            if (!string.IsNullOrEmpty(MakerCode))
+            {
+                var maker = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
+                var user = db.Users.FirstOrDefault(m => m.Id == maker.UserId) ?? new Users();
+                condition += " and UserId="+ user.Id;
+            }
+            //运营中心编号
+            if (!string.IsNullOrEmpty(OpCode))
+            {
+                condition += " and QueryCount in (select UserId from SysAdmin where OpCode='" + OpCode + "')";
+            }
+
+            if (!string.IsNullOrEmpty(StatusSelect))
+            {
+                condition += " and Status=" + StatusSelect + "";
+            }
+
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreMachineApply", Fields, "Id desc", "0", page, limit, condition);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            foreach (Dictionary<string, object> dic in diclist)
+            {
+                //品牌
+                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
+                int Status = int.Parse(dic["Status"].ToString());
+                if (Status == 0) dic["StatusName"] = "待配货";
+                if (Status == 1) dic["StatusName"] = "已发货";
+                if (Status == 2) dic["StatusName"] = "已驳回";
+                //创客
+                int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
+                var users = db.Users.FirstOrDefault(m => m.Id == UserId);
+                dic["MakerCode"] = users.MakerCode;
+                dic["RealName"] = users.RealName;
+
+                //运营中心
+                int OpId = int.Parse(function.CheckInt(dic["QueryCount"].ToString()));
+                var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.UserId == OpId && m.QueryCount == 1 && m.Status == 0) ?? new OpModels.SysAdmin();
+                // dic["OpCode"] = sysAdmin.OpCode;
+                dic.Remove("UserId");
+
+            }
+            return Json(obj);
+        }
+
+        #endregion
+
+
+        #region 增加分仓机具申请记录
+
+        /// <summary>
+        /// 增加或修改分仓机具申请记录信息
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Add(string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            return View();
+        }
+
+        #endregion
+
+        #region 增加分仓机具申请记录
+
+        /// <summary>
+        /// 增加或修改分仓机具申请记录信息
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public string Add(StoreMachineApply data)
+        {
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
+
+            Fields.Add("BrandId", data.BrandId); //品牌
+            Fields.Add("ApplyNo", data.ApplyNo); //申请单号
+            Fields.Add("ApplyNum", data.ApplyNum); //申请台数
+            Fields.Add("SendNum", data.SendNum); //发货台数
+            Fields.Add("UseAmount", data.UseAmount); //使用额度
+            Fields.Add("SendMode", data.SendMode); //发货方式
+            Fields.Add("ErpCode", data.ErpCode); //快递单号
+            Fields.Add("SendSn", data.SendSn); //发货SN数据
+            Fields.Add("UserId", data.UserId); //创客
+
+            Fields.Add("SeoTitle", data.SeoTitle);
+            Fields.Add("SeoKeyword", data.SeoKeyword);
+            Fields.Add("SeoDescription", data.SeoDescription);
+            int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("StoreMachineApply", Fields, 0);
+            AddSysLog(data.Id.ToString(), "StoreMachineApply", "add");
+            opdb.SaveChanges();
+
+            return "success";
+        }
+
+        #endregion
+
+        #region 修改分仓机具申请记录
+
+        /// <summary>
+        /// 增加或修改分仓机具申请记录信息
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Edit(string right, int Id = 0)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+            StoreMachineApply editData = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id) ?? new StoreMachineApply();
+            ViewBag.data = editData;
+
+            Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
+            ViewBag.MakerName = users.RealName;
+            ViewBag.UseAmount = editData.UseAmount;
+            JsonData SendSnList = new JsonData();
+            SendSnList = JsonMapper.ToObject(editData.SendSn);//申请数据
+            List<Dictionary<string, object>> KsProductList = new List<Dictionary<string, object>>();
+            for (int i = 0; i < SendSnList.Count; i++)
+            {
+                int BrandId = Convert.ToInt32(SendSnList[i]["BrandId"].ToString());
+                int Num = Convert.ToInt32(SendSnList[i]["ApplyNum"].ToString());
+                var products = db.KqProducts.Where(m => m.Id == BrandId).ToList();
+                foreach (var product in products)
+                {
+                    Dictionary<string, object> item = new Dictionary<string, object>();
+                    item.Add("BrandId", BrandId);  //商品Id
+                    item.Add("Name", product.Name);  //商品名称
+                    item.Add("Num", Num);  //商品数量
+                    KsProductList.Add(item);
+                }
+            }
+            ViewBag.KsProductList = KsProductList;
+
+            return View();
+        }
+
+        #endregion
+
+        #region 修改分仓机具申请记录
+
+        /// <summary>
+        /// 增加或修改分仓机具申请记录信息
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public string Edit(StoreMachineApply data)
+        {
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
+            Fields.Add("SendSn", data.SendSn); //发货SN数据
+            JsonData SendSnList = new JsonData();
+            SendSnList = JsonMapper.ToObject(data.SendSn);//申请数据
+            int ApplyNum = 0;
+            for (int i = 0; i < SendSnList.Count; i++)
+            {
+                int num = Convert.ToInt32(SendSnList[i]["ApplyNum"].ToString());
+                ApplyNum += num;
+            }
+            Fields.Add("BrandId", data.BrandId); //品牌
+            Fields.Add("ApplyNo", data.ApplyNo); //申请单号
+            Fields.Add("ApplyNum", ApplyNum); //申请台数
+            Fields.Add("SendNum", data.SendNum); //发货台数
+            Fields.Add("UseAmount", data.UseAmount); //使用额度
+            Fields.Add("SendMode", data.SendMode); //发货方式
+            Fields.Add("ErpCode", data.ErpCode); //快递单号
+            Fields.Add("UserId", data.UserId); //创客
+
+            Fields.Add("SeoTitle", SysUserName + '-' + SysRealName);
+            Fields.Add("SeoKeyword", data.SeoKeyword);
+            Fields.Add("SeoDescription", data.SeoDescription);
+            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, data.Id);
+            AddSysLog(data.Id.ToString(), "OpStoreMachineApply", "update");
+            db.SaveChanges();
+
+            return "success";
+        }
+
+        #endregion
+
+        #region 删除分仓机具申请记录信息
+
+        /// <summary>
+        /// 删除分仓机具申请记录信息
+        /// </summary>
+        /// <returns></returns>
+        public string Delete(string Id)
+        {
+            string[] idlist = Id.Split(new char[] { ',' });
+            AddSysLog(Id, "StoreMachineApply", "del");
+            foreach (string subid in idlist)
+            {
+                int id = int.Parse(subid);
+                Dictionary<string, object> Fields = new Dictionary<string, object>();
+                Fields.Add("Status", -1);
+                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, id);
+            }
+            db.SaveChanges();
+
+            return "success";
+        }
+
+        #endregion
+
+        #region 开启
+
+        /// <summary>
+        /// 开启
+        /// </summary>
+        /// <returns></returns>
+        public string Open(string Id)
+        {
+            string[] idlist = Id.Split(new char[] { ',' });
+            AddSysLog(Id, "StoreMachineApply", "open");
+            foreach (string subid in idlist)
+            {
+                int id = int.Parse(subid);
+                Dictionary<string, object> Fields = new Dictionary<string, object>();
+                Fields.Add("Status", 1);
+                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, id);
+            }
+            db.SaveChanges();
+            return "success";
+        }
+
+        #endregion
+
+        #region 关闭
+
+        /// <summary>
+        /// 关闭
+        /// </summary>
+        /// <returns></returns>
+        public string Close(string Id)
+        {
+            string[] idlist = Id.Split(new char[] { ',' });
+            AddSysLog(Id, "StoreMachineApply", "close");
+            foreach (string subid in idlist)
+            {
+                int id = int.Parse(subid);
+                Dictionary<string, object> Fields = new Dictionary<string, object>();
+                Fields.Add("Status", 2);
+                var query = db.StoreMachineApply.FirstOrDefault(m => m.Id == id);
+                var users = db.UserAccount.FirstOrDefault(m => m.Status == 0 && m.UserId == query.UserId) ?? new UserAccount();
+                if (users.Id > 0)
+                {
+                    users.ValidAmount += query.UseAmount;
+                    db.SaveChanges();
+                }
+                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, id);
+            }
+            db.SaveChanges();
+            return "success";
+        }
+
+        #endregion
+
+        #region 排序
+        /// <summary>
+        /// 排序
+        /// </summary>
+        /// <param name="Id"></param>
+        public string Sort(int Id, int Sort)
+        {
+            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("StoreMachineApply", Sort, Id);
+
+            AddSysLog(Id.ToString(), "StoreMachineApply", "sort");
+            return "success";
+        }
+        #endregion
+
+        #region 导入数据
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        public string Import(string ExcelData)
+        {
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+            for (int i = 1; i < list.Count; i++)
+            {
+                JsonData dr = list[i];
+
+                db.StoreMachineApply.Add(new StoreMachineApply()
+                {
+                    CreateDate = DateTime.Now,
+                    UpdateDate = DateTime.Now,
+
+                });
+                db.SaveChanges();
+            }
+            AddSysLog("0", "OpStoreMachineApply", "Import");
+            return "success";
+        }
+        #endregion
+
+        #region 导出Excel
+
+        /// <summary>
+        /// 导出Excel
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult ExportExcel(StoreMachineApply data, string BrandIdSelect, string UserIdRealName, string UserIdMakerCode)
+        {
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+            Fields.Add("CreateDate", "3"); //时间
+            Fields.Add("ApplyNo", "1"); //申请单号
+            Fields.Add("SendMode", "1"); //发货方式
+
+
+            string condition = " and Status>-1";
+            //品牌
+            if (!string.IsNullOrEmpty(BrandIdSelect))
+            {
+                condition += " and BrandId=" + BrandIdSelect;
+            }
+            //创客真实姓名
+            if (!string.IsNullOrEmpty(UserIdRealName))
+            {
+                condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
+            }
+            //创客编号
+            if (!string.IsNullOrEmpty(UserIdMakerCode))
+            {
+                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
+            }
+
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreMachineApply", Fields, "Id desc", "0", 1, 20000, condition, "BrandId,ApplyNo,ApplyNum,SendNum,UseAmount,SendMode,ErpCode,UserId", false);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            foreach (Dictionary<string, object> dic in diclist)
+            {
+                //品牌
+                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
+                dic["StatusName"] = dic["Status"].ToString() == "1" ? "正常" : "关闭";
+                //运营中心
+                int OpId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
+                var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.Id == OpId) ?? new OpModels.SysAdmin();
+                // Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+                dic["MakerName"] = sysAdmin.MakerName;
+                dic["MakerCode"] = sysAdmin.MakerCode;
+                dic["OpCode"] = sysAdmin.OpCode;
+                dic.Remove("OpId");
+
+            }
+
+            Dictionary<string, object> result = new Dictionary<string, object>();
+            result.Add("Status", "1");
+            result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
+            result.Add("Obj", diclist);
+            Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
+            ReturnFields.Add("BrandId", "品牌");
+            ReturnFields.Add("ApplyNo", "申请单号");
+            ReturnFields.Add("ApplyNum", "申请台数");
+            ReturnFields.Add("SendNum", "发货台数");
+            ReturnFields.Add("UseAmount", "使用额度");
+            ReturnFields.Add("SendMode", "发货方式");
+            ReturnFields.Add("ErpCode", "快递单号");
+            ReturnFields.Add("MakerName", "创客真实姓名");
+            ReturnFields.Add("MakerName", "创客编号");
+            ReturnFields.Add("OpCode", "运营中心编号");
+
+            result.Add("Fields", ReturnFields);
+            AddSysLog("0", "OpStoreMachineApply", "ExportExcel");
+            return Json(result);
+        }
+
+        #endregion
+
+
+        #region 运营中心关联分仓审核发货
+
+        public IActionResult AuditSend(string right, int Id = 0)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            var editData = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id) ?? new StoreMachineApply();
+            ViewBag.data = editData;
+
+            var users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
+            ViewBag.MakerName = users.RealName;
+
+            return View();
+        }
+
+        #endregion
+
+        #region 运营中心关联分仓审核发货
+
+        [HttpPost]
+        public string AuditSend(StoreMachineApply data, string ExcelData)
+        {
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
+            Fields.Add("ApplyNum", data.ApplyNum); //申请数
+            Fields.Add("SendNum", data.ApplyNum); //发货数
+            Fields.Add("ErpCode", data.ErpCode); //快递单号
+            Fields.Add("SendMode", data.SendMode); //发货方式
+            Fields.Add("SeoKeyword", data.SeoKeyword); //申请描述
+            Fields.Add("Status", 1);
+            AddSysLog(data.Id.ToString(), "StoreMachineApply", "AuditSend");
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+            List<SendInfo> sendInfos = new List<SendInfo>();
+            List<CheckSendInfo> checksendInfos = new List<CheckSendInfo>();
+            var apply = db.StoreMachineApply.FirstOrDefault(m => m.Id == data.Id) ?? new StoreMachineApply();
+            JsonData ApplyList = JsonMapper.ToObject(apply.SendSn);
+            decimal ApplyAmount = 0;
+            decimal Amount = 0;
+            for (int i = 0; i < ApplyList.Count; i++)
+            {
+                int num = Convert.ToInt32(ApplyList[i]["ApplyNum"].ToString());
+                int BrandIds = Convert.ToInt32(ApplyList[i]["BrandId"].ToString());
+                //自动匹配品牌
+                var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == BrandIds);
+                if (brandInfo.Name.Contains("电签"))
+                {
+                    ApplyAmount += num * 100;
+                }
+                if (brandInfo.Name.Contains("大POS"))
+                {
+                    ApplyAmount += num * 150;
+                }
+            }
+            Amount = apply.UseAmount - ApplyAmount;
+            StoreHouse tostore = new StoreHouse();
+            StoreHouse fromstore = new StoreHouse();
+
+            var BrandId = 0;
+            var FromStoreId = 0;
+            string error = "";
+            if (string.IsNullOrEmpty(ExcelData))
+            {
+                return "Warning|" + "请选择要导入的数据";
+            }
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+
+            //判断各品牌发货数量是否符合
+            if (list.Count - 1 > apply.ApplyNum)
+            {
+                return "Warning|" + "机具发货数量过多!";
+            }
+            if (list.Count - 1 < apply.ApplyNum)
+            {
+                return "Warning|" + "机具发货数量不足!";
+            }
+            for (int index = 1; index < list.Count; index++)
+            {
+                JsonData dr = list[index];
+                string itemJson = dr.ToJson();
+                string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                string Brand = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+                string BatchNo = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
+                string OutNote = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
+
+                BrandId = Convert.ToInt32(Brand);
+
+                if (BrandId == 1) FromStoreId = 7;
+                if (BrandId == 2) FromStoreId = 721;
+                if (BrandId == 3) FromStoreId = 697;
+                if (BrandId == 4) FromStoreId = 774;
+                if (BrandId == 5) FromStoreId = 775;
+                if (BrandId == 6) FromStoreId = 871;
+                if (BrandId == 7) FromStoreId = 1047;
+                if (BrandId == 8) FromStoreId = 4831;
+                if (BrandId == 9) FromStoreId = 4832;
+                CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandId);
+                if (items == null)
+                {
+                    CheckSendInfo rows = new CheckSendInfo()
+                    {
+                        BrandId = BrandId,
+                        Num = 1
+                    };
+                    checksendInfos.Add(rows);
+                }
+                else
+                {
+                    items.Num += 1;
+                }
+            }
+            for (int i = 0; i < ApplyList.Count; i++)
+            {
+                int num = Convert.ToInt32(ApplyList[i]["ApplyNum"].ToString());
+                int BrandIds = Convert.ToInt32(ApplyList[i]["BrandId"].ToString());
+                if (BrandIds == 1) FromStoreId = 7;
+                if (BrandIds == 2) FromStoreId = 721;
+                if (BrandIds == 3) FromStoreId = 697;
+                if (BrandIds == 4) FromStoreId = 774;
+                if (BrandIds == 5) FromStoreId = 775;
+                if (BrandIds == 6) FromStoreId = 871;
+                if (BrandIds == 7) FromStoreId = 1047;
+                if (BrandIds == 8) FromStoreId = 4831;
+                if (BrandIds == 9) FromStoreId = 4832;
+                var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == BrandIds);
+                CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandIds) ?? new CheckSendInfo();
+                if (items.Num > num)
+                {
+                    return "Warning|" + "该条发货记录的" + brandInfo.Name + "发货数量过多!";
+                }
+                if (items.Num < num)
+                {
+                    return "Warning|" + "该条发货记录的" + brandInfo.Name + "发货数量不足!";
+                }
+            }
+
+            List<string> PosSnList = new List<string>();
+            for (int index = 1; index < list.Count; index++)
+            {
+                JsonData dr = list[index];
+                string itemJson = dr.ToJson();
+                string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                string Brand = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+                BrandId = Convert.ToInt32(Brand);
+                MachineForSnNo posInfo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
+                var pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posInfo.SnId) ?? new PosMachinesTwo();
+                if (posInfo.SnId > 0)
+                {
+                    if (pos.Id > 0)
+                    {
+                        if (pos.BrandId != BrandId)
+                        {
+                            error += "以下操作失败" + SnNo + ',' + "该机具品牌填写错误" + '\n';
+                        }
+                    }
+
+                    if (BrandId == 1) FromStoreId = 7;
+                    if (BrandId == 2) FromStoreId = 721;
+                    if (BrandId == 3) FromStoreId = 697;
+                    if (BrandId == 4) FromStoreId = 774;
+                    if (BrandId == 5) FromStoreId = 775;
+                    if (BrandId == 6) FromStoreId = 871;
+                    if (BrandId == 7) FromStoreId = 1047;
+                    if (BrandId == 8) FromStoreId = 4831;
+                    if (BrandId == 9) FromStoreId = 4832;
+                    if (PosSnList.Contains(SnNo))
+                    {
+                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '\n';
+                    }
+                    PosSnList.Add(SnNo);
+                }
+                else
+                {
+                    error += "以下操作失败" + SnNo + ',' + "未找到该机具" + '\n';
+                }
+            }
+            if (!string.IsNullOrEmpty(error))
+            {
+                return "Warning|" + error;
+            }
+            Dictionary<string, int> storeData = new Dictionary<string, int>();
+            Dictionary<string, int> toStoreData = new Dictionary<string, int>();
+            for (int index = 1; index < list.Count; index++)
+            {
+                JsonData dr = list[index];
+                string itemJson = dr.ToJson();
+                string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                string Brand = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+                string BatchNo = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
+                string OutNote = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
+
+                BrandId = Convert.ToInt32(Brand);
+
+                if (BrandId == 1) FromStoreId = 7;
+                if (BrandId == 2) FromStoreId = 721;
+                if (BrandId == 3) FromStoreId = 697;
+                if (BrandId == 4) FromStoreId = 774;
+                if (BrandId == 5) FromStoreId = 775;
+                if (BrandId == 6) FromStoreId = 871;
+                if (BrandId == 7) FromStoreId = 1047;
+                if (BrandId == 8) FromStoreId = 4831;
+                if (BrandId == 9) FromStoreId = 4832;
+                tostore = db.StoreHouse.FirstOrDefault(m => m.Sort > 0 && m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status == 1);
+                SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
+                if (item == null)
+                {
+                    SendInfo row = new SendInfo()
+                    {
+                        FromStoreId = FromStoreId,
+                        ToStoreId = tostore.Id,
+                        BrandId = BrandId,
+                        Num = 1
+                    };
+                    sendInfos.Add(row);
+                }
+                else
+                {
+                    item.Num += 1;
+                }
+
+                apply.SeoDescription = function.CheckString(SnNo) + ',';
+
+                fromstore = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId);
+                // tostore = db.StoreHouse.FirstOrDefault(m => m.Sort > 0 && m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status == 1);
+
+                MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
+                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)
+                    {
+                        return machine.PosSn + "与表格里填写的品牌不一致";
+                    }
+                    else
+                    {
+                        StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
+                        {
+                            CreateDate = DateTime.Now,
+                            CreateMan = SysUserName,
+                            Sort = data.Id,//库存变动关联申请记录表
+                            StoreId = FromStoreId, //出货仓库
+                            BrandId = BrandId, //产品类型
+                            ProductName = RelationClass.GetKqProductBrandInfo(BrandId), //产品名称
+                            BizBatchNo = BatchNo, //业务批次号
+                            TransType = 1, //交易类型
+                            SnNo = SnNo, //SN编号
+                            StockOpDirect = 1, //库存操作方向
+                            SnStatus = 1, //SN状态
+                            DeviceVendor = machine.DeviceName, //设备厂商
+                            DeviceModel = machine.DeviceKind, //设备型号
+                            DeviceType = machine.DeviceType, //设备类型
+                            FromUserId = fromstore.UserId, //出货人
+                            FromDate = DateTime.Now, //出库时间
+                            FromRemark = OutNote, //出库备注
+                            ToUserId = tostore.UserId, //收货人
+                            ToStoreId = fromstore.Id, //退货收货仓库                        
+                            SourceStoreId = machine.SourceStoreId, //源仓库编号
+                            BrandType = machine.DeviceType, //品牌类型
+                        }).Entity;
+
+                        string ChangeNo = "CS";
+                        int StoreStockChangeId = stockchange.Id;
+                        string StoreStockChangeIdString = StoreStockChangeId.ToString();
+                        for (int j = 0; j < 18 - StoreStockChangeId.ToString().Length; j++)
+                        {
+                            StoreStockChangeIdString = "0" + StoreStockChangeIdString;
+                        }
+                        ChangeNo += StoreStockChangeIdString;
+                        stockchange.ChangeNo = ChangeNo; //交易流水编号
+                        machine.StoreId = tostore.Id;
+
+                        db.StoreChangeHistory.Add(new StoreChangeHistory()
+                        {
+                            CreateDate = DateTime.Now,
+                            UserId = fromstore.UserId, //创客
+                            BrandId = BrandId, //产品类型
+                            ChangeRecordNo = ChangeNo, //变更记录单号
+                            BizBatchNo = BatchNo, //业务批次号
+                            TransType = 1, //交易类型
+                            SnNo = SnNo, //SN编号
+                            SnType = machine.PosSnType, //SN机具类型
+                            StockOpDirect = 1, //库存操作方向
+                            DeviceVendor = machine.DeviceName, //设备厂商
+                            DeviceModel = machine.DeviceKind, //设备型号
+                            DeviceType = machine.DeviceType, //设备类型
+                            FromUserId = fromstore.UserId, //出货创客
+                            FromDate = DateTime.Now, //出库时间
+                            FromRemark = OutNote, //出库备注
+                            SourceStoreId = machine.SourceStoreId, //源仓库
+                            StoreId = fromstore.Id, //仓库
+                            ToUserId = tostore.UserId,//收货创客
+                        });
+
+                        //修改机具所属仓库
+                        machine.StoreId = tostore.Id;
+                        machine.UpdateDate = DateTime.Now;
+
+                        //添加机具所属运营中心
+                        machine.OpId = tostore.UserId;
+                        db.SaveChanges();
+                    }
+                }
+                else
+                {
+                    return "总仓无该机具";
+                }
+            }
+
+            foreach (var item in sendInfos)
+            {
+                //出货仓库数据调整
+                StoreHouse storeCH = db.StoreHouse.FirstOrDefault(m => m.Id == item.FromStoreId) ?? new StoreHouse();
+                StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
+                {
+                    CreateDate = DateTime.Now,
+                    StoreId = storeCH.Id, //仓库
+                    TransType = 1, //交易类型
+                    BrandId = BrandId, //产品类型
+                    OpStoreNum = item.Num, //操作库存数
+                    OpSymbol = "-", //操作符
+                    BeforeTotalNum = storeCH.TotalNum, //操作前总库存数
+                    AfterTotalNum = storeCH.TotalNum - item.Num, //操作后总库存数
+                    BeforeLaveNum = storeCH.LaveNum, //操作前剩余库存数
+                    AfterLaveNum = storeCH.LaveNum - item.Num, //操作后剩余库存数
+                    BeforeOutNum = storeCH.OutNum, //操作前出库数
+                    AfterOutNum = storeCH.OutNum + item.Num, //操作后出库数
+                }).Entity;
+                string ChangeNo1 = "CS";
+                int StoreStockChangeId1 = balance.Id;
+                string StoreStockChangeId1String = StoreStockChangeId1.ToString();
+                for (int i = 0; i < 18 - StoreStockChangeId1.ToString().Length; i++)
+                {
+                    StoreStockChangeId1String = "0" + StoreStockChangeId1String;
+                }
+                ChangeNo1 += StoreStockChangeId1String;
+                balance.TransRecordNo = ChangeNo1; //交易流水编号
+                storeCH.LaveNum -= item.Num;
+                storeCH.OutNum += item.Num;
+
+                //收货仓库数据调整
+                StoreHouse storeSH = db.StoreHouse.FirstOrDefault(m => m.Id == item.ToStoreId) ?? new StoreHouse();
+                balance = db.StoreBalance.Add(new StoreBalance()
+                {
+                    CreateDate = DateTime.Now,
+                    StoreId = storeSH.Id, //仓库
+                    TransType = 0, //交易类型
+                    BrandId = BrandId, //产品类型
+                    OpStoreNum = item.Num, //操作库存数
+                    OpSymbol = "+", //操作符
+                    BeforeTotalNum = storeSH.TotalNum, //操作前总库存数
+                    AfterTotalNum = storeSH.TotalNum + item.Num, //操作后总库存数
+                    BeforeLaveNum = storeSH.LaveNum, //操作前剩余库存数
+                    AfterLaveNum = storeSH.LaveNum + item.Num, //操作后剩余库存数
+                    BeforeOutNum = storeSH.OutNum, //操作前出库数
+                    AfterOutNum = storeSH.OutNum, //操作后出库数
+                }).Entity;
+                string ChangeNo2 = "CS";
+                int StoreStockChangeId2 = balance.Id;
+                string StoreStockChangeId2String = StoreStockChangeId2.ToString();
+                for (int i = 0; i < 18 - StoreStockChangeId2.ToString().Length; i++)
+                {
+                    StoreStockChangeId2String = "0" + StoreStockChangeId2String;
+                }
+                ChangeNo2 += StoreStockChangeId2String;
+                balance.TransRecordNo = ChangeNo2; //交易流水编号
+                storeSH.TotalNum += item.Num;
+                storeSH.LaveNum += item.Num;
+                
+            }
+            apply.SeoTitle = SysUserName + '-' + SysRealName;//添加操作人信息
+            apply.UseAmount = ApplyAmount;
+
+            db.SaveChanges();
+            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, data.Id);
+
+            string SendData = "{\"Kind\":\"2\",\"Data\":{\"UserId\":\"" + apply.UserId + "\",\"Amount\":\"" + Amount + "\",\"OperateType\":\"1\"}}";
+            RedisDbconn.Instance.AddList("StoreApplyQueue", SendData);
+            return "success";
+
+        }
+        #endregion
+
+
+        //发货信息实体类
+        private class SendInfo
+        {
+            public int FromStoreId { get; set; }
+            public int ToStoreId { get; set; }
+            public int BrandId { get; set; }
+            public int Num { get; set; }
+        }
+
+        //检查发货信息实体类
+        private class CheckSendInfo
+        {
+            public int BrandId { get; set; }
+            public int Num { get; set; }
+        }
+
+    }
+}

+ 21 - 1
Areas/Admin/Controllers/OperateServer/SysAdminOperateController.cs

@@ -98,6 +98,9 @@ namespace MySystem.Areas.Admin.Controllers
                 SysAdmin sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.Id == Id) ?? new SysAdmin();
                 dic["MakerCode"] = sysAdmin.MakerCode;
                 dic["MakerName"] = sysAdmin.MakerName;
+                
+                //登陆地址
+                dic["LoginUrl"] = OpHost + "/Admin/" + dbconn.Encrypt3DES(sysAdmin.Sort.ToString(), "kxs12345") + "/Login";
 
                 //实缴额度
                 UserAccount userAccount = opdb.UserAccount.FirstOrDefault(m => m.Sort == Id) ?? new UserAccount();
@@ -216,7 +219,7 @@ namespace MySystem.Areas.Admin.Controllers
                             Sort = edit.Id,//所属运营中心
                             CreateMan = SysUserName + "_" + SysRealName,
                             Details = "运营中心管理员,可以操作运营中心所有权限",
-                            RightInfo = ",1_1,1_1_1,1_1_1_edit,1_2,1_2_1,1_2_2,1_2_3,1_2_1_export,1_3,1_3_1,1_3_1_import,1_4,1_4_1,1_4_1_add,1_4_2,1_4_2_add,1_4_3,1_6,1_6_1,1_6_1_add,1_6_1_delete,1_6_1_edit,1_6_2,1_6_2_add,1_6_2_delete,1_6_2_edit,",
+                            RightInfo = ",1_1,1_1_1,1_1_1_edit,1_2,1_2_1,1_2_1_export,1_3,1_3_1,1_3_1_import,1_4,1_4_1,1_4_1_add,1_4_2,1_4_2_add,1_4_3,1_4_3_edit,1_4_3_base,1_4_3_audit,1_6,1_6_1,1_6_1_add,1_6_1_delete,1_6_1_edit,1_6_2,1_6_2_add,1_6_2_delete,1_6_2_edit,",
                             Name = "运营中心管理员",
 
                         }).Entity;
@@ -701,5 +704,22 @@ namespace MySystem.Areas.Admin.Controllers
 
         #endregion
 
+
+        #region 修改账户金额
+
+        [HttpPost]
+        public string LoginUrl(string Ids)
+        {
+            int Id = int.Parse(Ids);
+            var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.Id == Id) ?? new OpModels.SysAdmin();
+            if (sysAdmin.Id > 0)
+            {
+                return Host + "/Admin/" + dbconn.Encrypt3DES(sysAdmin.Sort.ToString(), "kxs12345") + "/Login";
+            }
+            return "success";
+        }
+        #endregion
+
+
     }
 }

+ 21 - 1
Areas/Admin/Views/MainServer/StoreHouse/BatchCancle.cshtml

@@ -1,7 +1,7 @@
 @{
     string RightInfo = ViewBag.RightInfo as string;
     string right = ViewBag.right as string;
-
+    string totalAmount = ViewBag.totalAmount as string;
 }
 <!DOCTYPE html>
 <html>
@@ -36,6 +36,11 @@
                                         <input class="layui-input" type="text" id="MakerCode" name="MakerCode"
                                             maxlength="50" lay-verify="required|" autocomplete="off"
                                             placeholder="请输入运营创客编号">
+                                        <div class="layui-inline layui-word-aux" style="color: #f00;" id="Reserve">
+                                        </div>
+                                        <div class="layui-input-inline">
+                                            @ViewBag.totalAmount
+                                        </div>
                                     </div>
                                 </div>
                             </div>
@@ -56,6 +61,21 @@
     <script src="/other/mybjq/kindeditor-min.js"></script>
     <script src="/other/mybjq/lang/zh_CN.js"></script>
     <script>
+        var st;
+        function GetReserve(obj) {
+            clearTimeout(st);
+            setTimeout(function () {
+                $.ajax({
+                    url: "/Admin/StoreHouse/GetReserve?r=" + Math.random(1),
+                    data: "MakerCode=" + $(obj).val(),
+                    dataType: "text",
+                    success: function (data) {
+                        $('#Reserve').text('当前可用额度:' + data);
+                    }
+                });
+            }, 1000);
+
+        }
 
 
         //编辑器

+ 13 - 7
Areas/Admin/Views/MainServer/StoreHouse/BatchSetting.cshtml

@@ -1,6 +1,7 @@
 @{
     string RightInfo = ViewBag.RightInfo as string;
     string right = ViewBag.right as string;
+    string totalAmount = ViewBag.totalAmount as string;
 
 }
 <!DOCTYPE html>
@@ -34,18 +35,22 @@
                                     <label class="layui-form-label">运营创客编号</label>
                                     <div class="layui-input-inline">
                                         <input class="layui-input" type="text" id="MakerCode" name="MakerCode"
-                                            maxlength="50" lay-verify="required|" autocomplete="off" onkeyup="GetReserve(this)"
-                                            placeholder="请输入运营创客编号">
-                                        <div class="layui-inline layui-word-aux" style="color: #f00;" id="Reserve"></div>
+                                            maxlength="50" lay-verify="required|" autocomplete="off"
+                                            onkeyup="GetReserve(this)" placeholder="请输入运营创客编号">
+                                        <div class="layui-inline layui-word-aux" style="color: #f00;" id="Reserve">
+                                        </div>
+                                        <div class="layui-input-inline">
+                                            @ViewBag.totalAmount
+                                        </div>
                                     </div>
                                 </div>
-                                <div class="layui-form-item">
+                                @* <div class="layui-form-item">
                                     <label class="layui-form-label">是否标记</label>
                                     <div class="layui-input-block">
                                         <input type="checkbox" id="IsOk" name="IsOk" value="1" lay-skin="switch"
                                             lay-filter="switchTest" title="开关">
                                     </div>
-                                </div>
+                                </div> *@
                             </div>
                         </div>
                     </div>
@@ -65,9 +70,9 @@
     <script src="/other/mybjq/lang/zh_CN.js"></script>
     <script>
         var st;
-        function GetReserve(obj){
+        function GetReserve(obj) {
             clearTimeout(st);
-            setTimeout(function(){
+            setTimeout(function () {
                 $.ajax({
                     url: "/Admin/StoreHouse/GetReserve?r=" + Math.random(1),
                     data: "MakerCode=" + $(obj).val(),
@@ -77,6 +82,7 @@
                     }
                 });
             }, 1000);
+
         }
 
 

+ 274 - 0
Areas/Admin/Views/OperateServer/StoreMachineApplysOperate/Add.cshtml

@@ -0,0 +1,274 @@
+@{
+    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>
+</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">
+                <ul class="layui-tab-title">
+                    <li class="layui-this" lay-id="1">基本信息</li><li lay-id="8">发货SN</li>
+                </ul>
+                <div class="layui-tab-content mt20">
+                    <div class="layui-tab-item layui-show">
+@{Dictionary<string, string> KqProductsDic = new MySystem.DictionaryClass().getKqProductsDic();}
+<div class="layui-form-item">
+<label class="layui-form-label">品牌</label>
+<div class="layui-input-inline">
+<select id="BrandId" name="BrandId" lay-search="">
+<option value="">请选择</option>
+@foreach (string key in KqProductsDic.Keys)
+{
+<option value="@key">@KqProductsDic[key]</option>
+}
+</select>
+</div>
+</div>
+<div class="layui-form-item">
+<label class="layui-form-label">申请单号</label>
+<div class="layui-input-inline">
+<input class="layui-input" type="text" id="ApplyNo" name="ApplyNo" maxlength="50" lay-verify="required|" autocomplete="off" placeholder="请输入申请单号">
+</div>
+</div>
+<div class="layui-form-item">
+<label class="layui-form-label">申请台数</label>
+<div class="layui-input-inline">
+<input class="layui-input" type="text" id="ApplyNum" name="ApplyNum" maxlength="20" lay-verify="" autocomplete="off" placeholder="请输入申请台数">
+</div>
+</div>
+<div class="layui-form-item">
+<label class="layui-form-label">发货台数</label>
+<div class="layui-input-inline">
+<input class="layui-input" type="text" id="SendNum" name="SendNum" maxlength="20" lay-verify="" autocomplete="off" placeholder="请输入发货台数">
+</div>
+</div>
+<div class="layui-form-item">
+<label class="layui-form-label">使用额度</label>
+<div class="layui-input-inline">
+<input class="layui-input" type="text" id="UseAmount" name="UseAmount" maxlength="20" lay-verify="" autocomplete="off" placeholder="请输入使用额度">
+</div>
+</div>
+<div class="layui-form-item">
+<label class="layui-form-label">发货方式</label>
+<div class="layui-input-inline">
+<input class="layui-input" type="text" id="SendMode" name="SendMode" maxlength="50" lay-verify="" autocomplete="off" placeholder="请输入发货方式">
+</div>
+</div>
+<div class="layui-form-item">
+<label class="layui-form-label">快递单号</label>
+<div class="layui-input-inline">
+<input class="layui-input" type="text" id="ErpCode" name="ErpCode" maxlength="50" lay-verify="" autocomplete="off" placeholder="请输入快递单号">
+</div>
+</div>
+@{Dictionary<string, string> UsersDic = new MySystem.DictionaryClass().getUsersDic();}
+<div class="layui-form-item">
+<label class="layui-form-label">创客</label>
+<div class="layui-input-inline">
+<select id="UserId" name="UserId" lay-search="">
+<option value="">请选择</option>
+@foreach (string key in UsersDic.Keys)
+{
+<option value="@key">@UsersDic[key]</option>
+}
+</select>
+</div>
+</div>
+
+</div>
+<div class="layui-tab-item">
+<div class="layui-form-item layui-form-text">
+<label class="layui-form-label">发货SN数据</label>
+<div class="layui-input-block">
+<textarea class="layui-textarea" id="SendSn" name="SendSn" maxlength="" lay-verify="" placeholder="请输入发货SN数据"></textarea>
+</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@(MySystem.OssHelper.Instance.OssStatus ? "-oss" : "").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 ids = "";
+        function getChildren(obj) {
+            $.each(obj, function (index, value) {
+                var id = obj[index].id;
+                ids += id + ",";
+                var children = obj[index].children;
+                if (children) {
+                    getChildren(children);
+                }
+            });
+        }
+
+        function AreasProvinceInit(tagId, areasVal, form) {
+            for (var i = 0; i < provs_data.length; i++) {
+                var sel = "";
+                if (areasVal.indexOf(provs_data[i].text) > -1) {
+                    sel = " selected=selected";
+                }
+                $("#" + tagId + "Province").append('<option value="' + provs_data[i].value + '"' + sel + '>' + provs_data[i].text + '</option>');
+            }
+            form.render();
+        }
+
+        function AreasProvinceSelected(tagId, areasVal, form, value) {
+            $("#" + tagId + "City").html('<option value="">市</option>');
+            var list = citys_data[value];
+            for (var i = 0; i < list.length; i++) {
+                var sel = "";
+                if (areasVal.indexOf(list[i].text) > -1) {
+                    sel = " selected=selected";
+                }
+                $("#" + tagId + "City").append('<option value="' + list[i].value + '"' + sel + '>' + list[i].text + '</option>');
+            }
+            $("#" + tagId + "Area").html('<option value="">县/区</option>');
+            form.render();
+            $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+        }
+
+        function AreasCitySelected(tagId, areasVal, form, value) {
+            $("#" + tagId + "Area").html('<option value="">县/区</option>');
+            var list = dists_data[value];
+            for (var i = 0; i < list.length; i++) {
+                var sel = "";
+                if (areasVal.indexOf(list[i].text) > -1) {
+                    sel = " selected=selected";
+                }
+                $("#" + tagId + "Area").append('<option value="' + list[i].value + '"' + sel + '>' + list[i].text + '</option>');
+            }
+            form.render();
+            $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+        }
+
+        function AreasAreaSelected(tagId, form) {
+            form.render();
+            $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+        }
+        function movePrev(obj, tagId) {
+            $(obj).parent().prev().insertAfter($(obj).parent());
+            checkPics(tagId);
+        }
+        function moveNext(obj, tagId) {
+            $(obj).parent().next().insertBefore($(obj).parent());
+            checkPics(tagId);
+        }
+        function deletePic(obj, tagId) {
+            $(obj).parent().remove();
+            checkPics(tagId);
+        }
+        function checkPics(tagId) {
+            var pics = "";
+            var texts = "";
+            $("#" + tagId + "Image div img").each(function (i) {
+                pics += $(this).attr("src").replace(osshost, '') + "|";
+            });
+            $("#" + tagId + "Image div input").each(function (i) {
+                texts += $(this).val() + "|";
+            });
+            if (pics == "") {
+                $("#" + tagId).val("");
+            } else {
+                pics = pics.substring(0, pics.length - 1);
+                texts = texts.substring(0, pics.length - 1);
+                $("#" + tagId).val(pics + "#cut#" + texts);
+            }
+        }
+        function checkBox(tagId) {
+            var text = "";
+            $("input[type=checkbox][name=" + tagId + "List]:checked").each(function (i) {
+                text += $(this).val() + ",";
+            });
+            $("#" + tagId).val(text);
+        }
+        function showBigPic(picpath) {
+            parent.layer.open({
+                type: 1,
+                title: false,
+                closeBtn: 0,
+                shadeClose: true,
+                area: ['auto', 'auto'],
+                content: '<img src="' + picpath + '" style="max-width:800px; max-height:800px;" />'
+            });
+        }
+
+        
+        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');
+            });
+    
+            //日期
+            
+
+            //上传文件
+            
+
+            //穿梭框
+            
+
+            //TreeView,比如权限管理
+            
+
+            //省市区
+            
+        })
+
+    </script>
+</body>
+</html>

+ 217 - 0
Areas/Admin/Views/OperateServer/StoreMachineApplysOperate/AuditSend.cshtml

@@ -0,0 +1,217 @@
+@using MySystem.Models;
+@{
+    StoreMachineApply editData = ViewBag.data as StoreMachineApply;
+}
+@{
+    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>
+</head>
+
+<body>
+
+    <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
+        <input type="hidden" name="Id" value="@editData.Id" />
+        <input type="hidden" name="ExcelData" id="ExcelData" value="" />
+
+        <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-input-inline">
+                                    <input class="layui-input" type="text" readonly id="MakerName" name="MakerName"
+                                        value="@ViewBag.MakerName" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div>
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">申请单号</label>
+                                <div class="layui-input-inline">
+                                    <input class="layui-input" type="text" readonly id="ApplyNo" name="ApplyNo"
+                                        value="@editData.ApplyNo" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div>
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">申请数量</label>
+                                <div class="layui-input-inline">
+                                    <input class="layui-input" type="text" readonly id="ApplyNum" name="ApplyNum"
+                                        value="@editData.ApplyNum" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div>
+                            @* <div class="layui-form-item">
+                                <label class="layui-form-label">发货数量</label>
+                                <div class="layui-input-inline">
+                                    <input class="layui-input" type="text" id="SendNum" name="SendNum"
+                                        value="@editData.SendNum" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div> *@
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">快递单号</label>
+                                <div class="layui-input-inline">
+                                    <input class="layui-input" type="text" id="ErpCode" name="ErpCode"
+                                        value="@editData.ErpCode" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div>
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">发货方式</label>
+                                <div class="layui-input-inline">
+                                    <input class="layui-input" type="text" id="SendMode" name="SendMode"
+                                        value="@editData.SendMode" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div>
+                            @* <div class="layui-form-item">
+                                <label class="layui-form-label">*审核结果</label>
+                                <div class="layui-input-inline">
+                                    <select id="Status" name="Status" lay-verify="required|" lay-search="">
+                                        <option value="">请选择</option>
+                                        <option value="0">待审核</option>
+                                        <option value="1">审核通过</option>
+                                        <option value="2">审核不通过</option>
+                                    </select>
+                                    <script>
+                                        $("#Status").val("@editData.Status");
+                                    </script>
+                                </div>
+                            </div> *@
+                            <div class="layui-form-item layui-form-text">
+                                <label class="layui-form-label">描述</label>
+                                <div class="layui-input-block">
+                                    <textarea class="layui-textarea" id="SeoKeyword" name="SeoKeyword" maxlength="max"
+                                        lay-verify="required|" placeholder="请输入申请描述"></textarea>
+                                </div>
+                            </div>
+                            <div class="layui-form-item"">
+                            <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">
+                                        <a href="/users/批量添加机具SN模版.xlsx">点击下载批量添加机具SN模版</a>
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="layui-form-item"">
+                            <label class=" layui-form-label">导入机具SN</label>
+                                <div class=" layui-input-block">
+                                    <div class="layui-upload">
+                                        <input type="file" id="ExcelFile" name="ExcelFile" value="">
+                                        <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@(MySystem.OssHelper.Instance.OssStatus ? "-oss" : "").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 ids = "";
+        function getChildren(obj) {
+            $.each(obj, function (index, value) {
+                var id = obj[index].id;
+                ids += id + ",";
+                var children = obj[index].children;
+                if (children) {
+                    getChildren(children);
+                }
+            });
+        }
+
+        var tree;
+        var element;
+        var upload;
+        var excel;
+        layui.config({
+            base: '/layuiadmin/' //静态资源所在路径
+        }).extend({
+            index: 'lib/index' //主入口模块
+        }).use(['index', 'form', 'upload', 'layedit', 'laydate', 'element', 'croppers', 'transfer', 'tree', 'util', 'excel'], 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');
+            });
+
+            //excel导入
+            excel = layui.excel;
+            $('#ExcelFile').change(function (e) {
+                var files = e.target.files;
+                excel.importExcel(files, {}, function (data) {
+                    $("#ExcelData").val(JSON.stringify(data[0].Sheet1));
+                });
+            });
+
+            //日期
+
+
+            //上传文件
+
+
+            //穿梭框
+
+
+            //TreeView,比如权限管理
+
+
+            //省市区
+
+        })
+
+    </script>
+</body>
+
+</html>

+ 257 - 0
Areas/Admin/Views/OperateServer/StoreMachineApplysOperate/Edit.cshtml

@@ -0,0 +1,257 @@
+@using MySystem.OpModels;
+@{
+    StoreMachineApply editData = ViewBag.data as StoreMachineApply;
+}
+@{
+    string RightInfo = ViewBag.RightInfo as string;
+    string right = ViewBag.right as string;
+    List<Dictionary<string, object>> KsProductList = ViewBag.KsProductList as List<Dictionary<string, object>>;
+
+}
+<!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">
+        <input type="hidden" name="Id" value="@editData.Id" />
+
+        <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">
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">创客名称</label>
+                                <div class="layui-input-inline">
+                                    <input class="layui-input" type="text" readonly id="MakerName" name="MakerName"
+                                        value="@ViewBag.MakerName" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                        <input class="layui-input" type="hidden" readonly id="UserId" name="UserId"
+                                        value="@ViewBag.UserId" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                        <input class="layui-input" type="hidden" readonly id="UseAmount" name="UseAmount"
+                                        value="@ViewBag.UseAmount" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div>
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">申请单号</label>
+                                <div class="layui-input-inline">
+                                    <input class="layui-input" type="text" readonly id="ApplyNo" name="ApplyNo"
+                                        value="@editData.ApplyNo" maxlength="32" lay-verify="required|"
+                                        autocomplete="off" placeholder="">
+                                </div>
+                            </div>
+                            <fieldset class="layui-elem-field layui-field-title">
+                                <legend>申请信息</legend>
+                            </fieldset>
+                            <input type="hidden" id="SendSn" name="SendSn" value="@editData.SendSn">
+                            @foreach (Dictionary<string, object> item in KsProductList)
+                            {
+                                <div class="layui-form-item">
+                                    <div class="layui-inline">
+                                        <label class="layui-form-label">@item["Name"]:</label>
+                                        <div class="layui-input-inline productlist">
+                                            <input type="hidden" name="BrandId" value="@item["BrandId"]">
+                                            <input class="layui-input" type="text" @(editData.Status == 1 ? "readonly" : "") name="ApplyNum" placeholder=""
+                                            autocomplete="off" value="@item["Num"]">
+                                        </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@(MySystem.OssHelper.Instance.OssStatus ? "-oss" : "").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 ids = "";
+            function getChildren(obj) {
+                $.each(obj, function (index, value) {
+                    var id = obj[index].id;
+                    ids += id + ",";
+                    var children = obj[index].children;
+                    if (children) {
+                        getChildren(children);
+                    }
+                });
+            }
+
+            function AreasProvinceInit(tagId, areasVal, form) {
+                for (var i = 0; i < provs_data.length; i++) {
+                    var sel = "";
+                    if (areasVal.indexOf(provs_data[i].text) > -1) {
+                        sel = " selected=selected";
+                    }
+                    $("#" + tagId + "Province").append('<option value="' + provs_data[i].value + '"' + sel + '>' + provs_data[i].text + '</option>');
+                }
+                form.render();
+            }
+
+            function AreasProvinceSelected(tagId, areasVal, form, value) {
+                $("#" + tagId + "City").html('<option value="">市</option>');
+                var list = citys_data[value];
+                for (var i = 0; i < list.length; i++) {
+                    var sel = "";
+                    if (areasVal.indexOf(list[i].text) > -1) {
+                        sel = " selected=selected";
+                    }
+                    $("#" + tagId + "City").append('<option value="' + list[i].value + '"' + sel + '>' + list[i].text + '</option>');
+                }
+                $("#" + tagId + "Area").html('<option value="">县/区</option>');
+                form.render();
+                $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+            }
+
+            function AreasCitySelected(tagId, areasVal, form, value) {
+                $("#" + tagId + "Area").html('<option value="">县/区</option>');
+                var list = dists_data[value];
+                for (var i = 0; i < list.length; i++) {
+                    var sel = "";
+                    if (areasVal.indexOf(list[i].text) > -1) {
+                        sel = " selected=selected";
+                    }
+                    $("#" + tagId + "Area").append('<option value="' + list[i].value + '"' + sel + '>' + list[i].text + '</option>');
+                }
+                form.render();
+                $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+            }
+
+            function AreasAreaSelected(tagId, form) {
+                form.render();
+                $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+            }
+            function movePrev(obj, tagId) {
+                $(obj).parent().prev().insertAfter($(obj).parent());
+                checkPics(tagId);
+            }
+            function moveNext(obj, tagId) {
+                $(obj).parent().next().insertBefore($(obj).parent());
+                checkPics(tagId);
+            }
+            function deletePic(obj, tagId) {
+                $(obj).parent().remove();
+                checkPics(tagId);
+            }
+            function checkPics(tagId) {
+                var pics = "";
+                var texts = "";
+                $("#" + tagId + "Image div img").each(function (i) {
+                    pics += $(this).attr("src").replace(osshost, '') + "|";
+                });
+                $("#" + tagId + "Image div input").each(function (i) {
+                    texts += $(this).val() + "|";
+                });
+                if (pics == "") {
+                    $("#" + tagId).val("");
+                } else {
+                    pics = pics.substring(0, pics.length - 1);
+                    texts = texts.substring(0, pics.length - 1);
+                    $("#" + tagId).val(pics + "#cut#" + texts);
+                }
+            }
+            function checkBox(tagId) {
+                var text = "";
+                $("input[type=checkbox][name=" + tagId + "List]:checked").each(function (i) {
+                    text += $(this).val() + ",";
+                });
+                $("#" + tagId).val(text);
+            }
+            function showBigPic(picpath) {
+                parent.layer.open({
+                    type: 1,
+                    title: false,
+                    closeBtn: 0,
+                    shadeClose: true,
+                    area: ['auto', 'auto'],
+                    content: '<img src="' + picpath + '" style="max-width:800px; max-height:800px;" />'
+                });
+            }
+
+            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');
+                });
+
+                //日期
+
+
+                //上传文件
+
+
+                //穿梭框
+
+
+                //TreeView,比如权限管理
+
+
+                //省市区
+
+
+            })
+
+        </script>
+</body>
+
+</html>

+ 173 - 0
Areas/Admin/Views/OperateServer/StoreMachineApplysOperate/Indexs1.cshtml

@@ -0,0 +1,173 @@
+@{
+    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">
+    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
+    <script src="/admin/js/jquery-1.10.1.min.js"></script>
+    <style>
+        .layui-input-inline {
+            width: 175px !important;
+        }
+
+        .layui-form-label {
+            width: 85px !important;
+        }
+
+        .layui-inline {
+            margin-right: 0px !important;
+        }
+
+        .w100 {
+            width: 100px !important;
+        }
+
+        .ml50 {
+            margin-left: 50px !important;
+        }
+    </style>
+</head>
+
+<body>
+    <div class="layui-fluid">
+        <div class="layui-card">
+            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
+                <div class="layui-form-item">
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创建时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="CreateDateData" id="CreateDate"
+                                placeholder="创建时间" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">申请单号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="ApplyNo" placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">发货方式</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="SendMode" placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创客编号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="MakerCode" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">运营中心编号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="OpCode" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">发货状态</label>
+                        <div class="layui-input-inline">
+                            <select id="StatusSelect" name="StatusSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="0">待配货</option>
+                                <option value="1">已发货</option>
+                                <option value="2">已驳回</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline ml50">
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
+                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
+                        </button>
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-searchall">
+                            <i class="layui-icon layui-icon-list layuiadmin-button-btn"></i>全部
+                        </button>
+                    </div>
+                </div>
+            </div>
+
+            <div class="layui-card-body">
+                <div style="padding-bottom: 10px;">
+                    @if (RightInfo.Contains("," + right + "_add,"))
+                    {
+                        <button class="layui-btn" data-type="add"><i
+                            class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_delete,"))
+                    {
+                        <button class="layui-btn" data-type="batchdel"><i
+                            class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                        <button class="layui-btn" data-type="Open">开启</button>
+                        <button class="layui-btn" data-type="Close">关闭</button>
+                        <button class="layui-btn" data-type="ExportExcel"><i
+                            class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
+
+                    }
+                </div>
+
+                <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
+                <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>
+                    }
+                    @if (RightInfo.Contains("," + right + "_audit,"))
+                    {
+                        @("{{# if(d.Status == 0 ) { }}")
+                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="audit"><i class="layui-icon layui-icon-edit"></i>审核发货</a>
+                        @("{{# } }}")
+                    }
+                    {{# if(d.Status == 0) { }}
+                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="Close"><i class="layui-icon layui-icon-edit"></i>驳回</a>
+                    {{# } }}
+                </script>
+            </div>
+        </div>
+    </div>
+    <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>
+                <div class="layui-form-mid layui-word-aux" id="excelTemp">
+                </div>
+            </div>
+            <div class="layui-form-item">
+                <label class="layui-form-label">excel文件</label>
+                <div class="layui-form-mid layui-word-aux">
+                    <div class="layui-upload">
+                        <input type="file" id="ExcelFile" name="ExcelFile" value="">
+                    </div>
+                    <div class="mt10" id="ExcelFileList">
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="layui-form-item ml10">
+            <div class="layui-input-block">
+                <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button>
+            </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script src="/layuiadmin/modules_operate/StoreMachineApplys1_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script>
+
+    </script>
+</body>
+
+</html>

+ 33 - 19
Areas/Admin/Views/OperateServer/SysAdminOperate/Index.cshtml

@@ -1,37 +1,44 @@
 @{
     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">
+    <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">
     <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
     <script src="/admin/js/jquery-1.10.1.min.js"></script>
     <style>
-        .layui-input-inline{
+        .layui-input-inline {
             width: 175px !important;
         }
-        .layui-form-label{
+
+        .layui-form-label {
             width: 85px !important;
         }
-        .layui-inline{
+
+        .layui-inline {
             margin-right: 0px !important;
         }
-        .w100{
+
+        .w100 {
             width: 100px !important;
         }
-        .ml50{
+
+        .ml50 {
             margin-left: 50px !important;
         }
     </style>
 </head>
+
 <body>
     <div class="layui-fluid">
         <div class="layui-card">
@@ -40,8 +47,7 @@
                     <div class="layui-inline">
                         <label class="layui-form-label">运营中心编号</label>
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="AdminName" placeholder=""
-                                autocomplete="off">
+                            <input class="layui-input" type="text" name="AdminName" placeholder="" autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline">
@@ -54,7 +60,7 @@
                         <label class="layui-form-label">创建时间</label>
                         <div class="layui-input-inline">
                             <input class="layui-input" type="text" readonly name="CreateDateData" id="CreateDateData"
-                            placeholder="" autocomplete="off">
+                                placeholder="" autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline ml50">
@@ -72,11 +78,13 @@
                 <div style="padding-bottom: 10px;">
                     @if (RightInfo.Contains("," + right + "_add,"))
                     {
-                    <button class="layui-btn" data-type="add"><i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新增</button>
+                        <button class="layui-btn" data-type="add"><i
+                            class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新增</button>
                     }
                     @if (RightInfo.Contains("," + right + "_delete,"))
                     {
-                    @* <button class="layui-btn" data-type="batchdel"><i class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除</button> *@
+                        @* <button class="layui-btn" data-type="batchdel"><i class="layui-icon layui-icon-delete
+                            layuiadmin-button-btn"></i>删除</button> *@
                     }
                     @if (RightInfo.Contains("," + right + "_edit,"))
                     {
@@ -84,7 +92,7 @@
                         <button class="layui-btn" data-type="Close">关闭</button>
                     }
                 </div>
-                
+
                 <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
                 <script type="text/html" id="imgTpl">
                     <img style="display: inline-block; width: 50%; height: 100%;" src={{ d.avatar }}>
@@ -92,19 +100,23 @@
                 <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 + "_delete,"))
                     {
-                    @* <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a> *@
+                        @* <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a> *@
                     }
                     @if (RightInfo.Contains("," + right + "_EditAmt,"))
                     {
-                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="EditAmt"><i class="layui-icon layui-icon-edit"></i>修改可用额度</a>
+                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="EditAmt"><i class="layui-icon layui-icon-edit"></i>修改可用额度</a>
                     }
                     @if (RightInfo.Contains("," + right + "_EditBalance,"))
                     {
-                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="EditBalance"><i class="layui-icon layui-icon-edit"></i>修改账户余额</a>
+                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="EditBalance"><i class="layui-icon layui-icon-edit"></i>修改账户余额</a>
+                    }
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-edit"></i>登陆地址</a>
                     }
                 </script>
             </div>
@@ -131,9 +143,11 @@
     </div>
 
     <script src="/layuiadmin/layui/layui.js"></script>
-    <script src="/layuiadmin/modules_operate/SysAdminOperate_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script
+        src="/layuiadmin/modules_operate/SysAdminOperate_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
     <script>
-        
+
     </script>
 </body>
+
 </html>

+ 1 - 0
Models/UserAccount.cs

@@ -42,5 +42,6 @@ namespace MySystem.Models
         public decimal ThisMonthPreAmount { get; set; }
         public decimal ValidPreAmount { get; set; }
         public decimal SmallStoreDeposit { get; set; }
+        public decimal StoreDeposit { get; set; }
     }
 }

+ 2 - 0
Models/WebCMSEntities.cs

@@ -15102,6 +15102,8 @@ namespace MySystem.Models
 
                 entity.Property(e => e.Status).HasColumnType("int(11)");
 
+                entity.Property(e => e.StoreDeposit).HasColumnType("decimal(18,2)");
+
                 entity.Property(e => e.TeamTotalOverProfit).HasColumnType("decimal(18,2)");
 
                 entity.Property(e => e.TeamTotalProfit).HasColumnType("decimal(18,2)");

+ 1 - 0
appsettings.json

@@ -14,6 +14,7 @@
     "ConnectionStrings": "",
     "WebServiceUrl": "",
     "DbSchemeUrl": "",
+    "OpHost": "http://operate.kexiaoshuang.com/",
     "Host": "http://test.bs.kexiaoshuang.com/",
     "OssHost": "http://oss.kexiaoshuang.com",
     "Database": "KxsMainServer",

+ 16 - 1
wwwroot/layuiadmin/modules_main/PosMachinesTwo_Admin.js

@@ -272,8 +272,23 @@ layui.config({
         }
     });
     form.on('submit(LAY-list-front-searchall)', function (data) {
+        var field = data.field;
+        field.ShowFlag = 1;
+        field.UserIdMakerCode = "";
+        field.UserIdRealName = "";
+        field.StoreIdCode = "";
+        field.StoreIdName = "";
+        field.PosSn = "";
+        field.BindingStateSelect = "";
+        field.ActivationStateSelect = "";
+        field.ActivationDateData = "";
+        field.BindingDateData = "";
+        field.BrandId = "";
+        field.IsStoreSelect = "";
+        field.OpCode = "";
+
         table.reload('LAY-list-manage', {
-            where: null,
+            where: field,
             page: {
                 curr: 1
             }

+ 76 - 59
wwwroot/layuiadmin/modules_main/StoreHouse_Admin.js

@@ -1,4 +1,5 @@
 var ExcelData, ExcelKind;
+var clickflag = 0;
 
 function ConfirmImport() {
     var index = layer.load(1, {
@@ -250,7 +251,7 @@ layui.config({
                 width: 130,
                 title: '关联运营中心',
                 sort: true
-            },{
+            }, {
                 field: 'StoreKind',
                 width: 130,
                 title: '仓库归属类型',
@@ -493,7 +494,7 @@ layui.config({
     form.on('submit(LAY-list-front-search)', function (data) {
         var field = data.field;
         field.ShowFlag = 1;
-        if (field.StoreNo == "" && field.StoreName == "" && field.UserIdMakerCode == "" && field.UserIdRealName == "" && field.ManageUserIdRealName == "" && field.ManageUserIdMobile == "" && field.ManageUserIdMakerCode == "" && field.ManagerEmail == "" && field.StoreStatusSelect == "" && field.CreateDateData == "" && field.MakerCode == "" && field.YZOpCode == "" && field.OpStatusSelect =="" && field.StoreKindSelect == "") {
+        if (field.StoreNo == "" && field.StoreName == "" && field.UserIdMakerCode == "" && field.UserIdRealName == "" && field.ManageUserIdRealName == "" && field.ManageUserIdMobile == "" && field.ManageUserIdMakerCode == "" && field.ManagerEmail == "" && field.StoreStatusSelect == "" && field.CreateDateData == "" && field.MakerCode == "" && field.YZOpCode == "" && field.OpStatusSelect == "" && field.StoreKindSelect == "") {
             layer.alert('请输入查询条件');
         }
         else {
@@ -509,6 +510,7 @@ layui.config({
     form.on('submit(LAY-list-front-searchall)', function (data) {
         var field = data.field;
         field.ShowFlag = 1;
+        console.log(field.ShowFlag)
         field.StoreNo = "";
         field.StoreName = "";
         field.ManagerEmail = "";
@@ -844,7 +846,7 @@ layui.config({
                 var perContent = layer.open({
                     type: 2,
                     title: '关联分仓',
-                    content: 'BatchSetting',
+                    content: 'BatchSetting?StoreIds=' + ids,
                     maxmin: true,
                     area: ['550px', '350px'],
                     btn: ['确定', '取消'],
@@ -864,35 +866,42 @@ layui.config({
                         }, 300);
                         //监听提交
                         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({});
-
-                            $.ajax({
-                                type: "POST",
-                                url: "/Admin/StoreHouse/BatchSetting?r=" + Math.random(1),
-                                data: userdata + "Id=" + ids,
-                                dataType: "text",
-                                success: function (data) {
-                                    layer.close(index);
-                                    if (data == "success") {
-                                        table.reload('LAY-list-manage');
-                                    }
-                                    else if (data.indexOf("Warning") == 0) {
-                                        var datalist = data.split('|');
-                                        layer.alert(datalist[1], { time: 20000 }, function () {
-                                            window.location.reload();
-                                        });
-                                    }
-                                    else {
-                                        layer.msg(data);
-                                    }
+                            if (clickflag == 0) {
+                                clickflag = 1;
+                                var field = data.field; //获取提交的字段
+                                var userdata = "";
+                                for (var prop in field) {
+                                    userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
                                 }
-                            });
+                                //提交 Ajax 成功后,静态更新表格中的数据
+                                //$.ajax({});
+                                $.ajax({
+                                    type: "POST",
+                                    url: "/Admin/StoreHouse/BatchSetting?r=" + Math.random(1),
+                                    data: userdata + "Id=" + ids,
+                                    dataType: "text",
+                                    success: function (data) {
+                                        clickflag = 0;
+                                        layer.close(index);
+                                        if (data == "success") {
+                                            layer.msg('关联成功', {
+                                                time: 1000
+                                            }, function () {
+                                                table.reload('LAY-list-manage'); //数据刷新
+                                            });
+                                        }
+                                        else if (data.indexOf("Warning") == 0) {
+                                            var datalist = data.split('|');
+                                            layer.alert(datalist[1], { time: 20000 }, function () {
+                                                window.location.reload();
+                                            });
+                                        }
+                                        else {
+                                            layer.msg(data);
+                                        }
+                                    }
+                                });
+                            }
                         });
                         submit.trigger('click');
                     }
@@ -914,7 +923,7 @@ layui.config({
                 var perContent = layer.open({
                     type: 2,
                     title: '取消关联',
-                    content: 'BatchSetting',
+                    content: 'BatchCancle?StoreIds=' + ids,
                     maxmin: true,
                     area: ['650px', '550px'],
                     btn: ['确定', '取消'],
@@ -934,35 +943,43 @@ layui.config({
                         }, 300);
                         //监听提交
                         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({});
+                            if (clickflag == 0) {
+                                clickflag = 1;
+                                var field = data.field; //获取提交的字段
+                                var userdata = "";
+                                for (var prop in field) {
+                                    userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                                }
+                                //提交 Ajax 成功后,静态更新表格中的数据
+                                //$.ajax({});
 
-                            $.ajax({
-                                type: "POST",
-                                url: "/Admin/StoreHouse/BatchCancle?r=" + Math.random(1),
-                                data: userdata + "Id=" + ids,
-                                dataType: "text",
-                                success: function (data) {
-                                    layer.close(index);
-                                    if (data == "success") {
-                                        table.reload('LAY-list-manage');
-                                    }
-                                    else if (data.indexOf("Warning") == 0) {
-                                        var datalist = data.split('|');
-                                        layer.alert(datalist[1], { time: 20000 }, function () {
-                                            window.location.reload();
-                                        });
+                                $.ajax({
+                                    type: "POST",
+                                    url: "/Admin/StoreHouse/BatchCancle?r=" + Math.random(1),
+                                    data: userdata + "Id=" + ids,
+                                    dataType: "text",
+                                    success: function (data) {
+                                        clickflag = 0;
+                                        layer.close(index);
+                                        if (data == "success") {
+                                            layer.msg('取消成功', {
+                                                time: 1000
+                                            }, function () {
+                                                table.reload('LAY-list-manage'); //数据刷新
+                                            });
+                                        }
+                                        else if (data.indexOf("Warning") == 0) {
+                                            var datalist = data.split('|');
+                                            layer.alert(datalist[1], { time: 20000 }, function () {
+                                                window.location.reload();
+                                            });
+                                        }
+                                        else {
+                                            layer.msg(data);
+                                        }
                                     }
-                                    else {
-                                        layer.msg(data);
-                                    }
-                                }
-                            });
+                                });
+                            }
                         });
                         submit.trigger('click');
                     }

+ 0 - 7
wwwroot/layuiadmin/modules_operate/StoreMachineApply_Admin.js

@@ -287,13 +287,6 @@ layui.config({
                                         layer.alert(datalist[1], { time: 20000 }, function () {
                                             window.location.reload();
                                         });
-                                    } else {
-                                        layer.close(index); //关闭弹层
-                                        layer.msg('审核完成', {
-                                            time: 1500
-                                        }, function () {
-                                            table.reload('LAY-list-manage'); //数据刷新
-                                        });
                                     }
                                 }
                             });

+ 519 - 0
wwwroot/layuiadmin/modules_operate/StoreMachineApplys1_Admin.js

@@ -0,0 +1,519 @@
+var ExcelData, ExcelKind;
+var clickflag = 0;
+function ConfirmImport() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/StoreMachineApplysOperate/Import?r=" + Math.random(1),
+        data: "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);
+            }
+        }
+    });
+}
+
+var excel;
+layui.config({
+    base: '/layuiadmin/' //静态资源所在路径
+}).extend({
+    myexcel: 'layui/lay/modules/excel',
+    index: 'lib/index' //主入口模块
+}).use(['index', 'table', 'excel', 'laydate'], function () {
+    var $ = layui.$
+        , form = layui.form
+        , table = layui.table;
+
+    //- 筛选条件-日期
+    var laydate = layui.laydate;
+    var layCreateDate = laydate.render({
+        elem: '#CreateDate',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layCreateDate.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layCreateDate.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#CreateDate').val(value);
+            }
+        }
+    });
+
+
+    //excel导入
+    excel = layui.excel;
+    $('#ExcelFile').change(function (e) {
+        var files = e.target.files;
+        excel.importExcel(files, {}, function (data) {
+            ExcelData = data[0].sheet1;
+        });
+    });
+
+    //监听单元格编辑
+    table.on('edit(LAY-list-manage)', function (obj) {
+        var value = obj.value //得到修改后的值
+            , data = obj.data //得到所在行所有键值
+            , field = obj.field; //得到字段
+        if (field == "Sort") {
+            $.ajax({
+                type: "POST",
+                url: "/Admin/StoreMachineApplysOperate/Sort?r=" + Math.random(1),
+                data: "Id=" + data.Id + "&Sort=" + value,
+                dataType: "text",
+                success: function (data) {
+                }
+            });
+        }
+    });
+
+    //列表数据
+    table.render({
+        elem: '#LAY-list-manage'
+        , url: '/Admin/StoreMachineApplysOperate/Indexs1Data' //模拟接口
+        , cols: [[
+            { type: 'checkbox', fixed: 'left' }
+            , { field: 'CreateDate', width: 150, title: '创建时间', sort: true }
+            , { field: 'StatusName', width: 150, title: '状态', sort: true }
+            , { field: 'ApplyNo', width: 150, title: '申请单号', sort: true }
+            , { field: 'ApplyNum', width: 150, title: '申请台数', sort: true }
+            , { field: 'SendNum', width: 150, title: '发货台数', sort: true }
+            , { field: 'UseAmount', width: 150, title: '使用额度', sort: true }
+            , { field: 'SendMode', width: 150, title: '发货方式', sort: true }
+            , { field: 'ErpCode', width: 150, title: '快递单号', sort: true }
+            , { field: 'RealName', width: 150, title: '创客姓名', sort: true }
+            , { field: 'MakerCode', width: 150, title: '创客编号', sort: true }
+            , { field: 'OpCode', width: 150, title: '运营中心编号', sort: true }
+            , { title: '操作', align: 'center', width: 500, fixed: 'right', toolbar: '#table-list-tools' }
+        ]]
+        , where: {
+
+        }
+        , page: true
+        , limit: 30
+        , height: 'full-220'
+        , text: '对不起,加载出现异常!'
+        , done: function (res, curr, count) {
+            $(".layui-none").text("无数据");
+        }
+    });
+
+    //监听工具条
+    table.on('tool(LAY-list-manage)', function (obj) {
+        var data = obj.data;
+        if (obj.event === 'del') {
+            var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreMachineApplysOperate/Delete?r=" + Math.random(1),
+                    data: "Id=" + data.Id,
+                    dataType: "text",
+                    success: function (data) {
+                        if (data == "success") {
+                            obj.del();
+                            layer.close(index);
+                        } else {
+                            parent.layer.msg(data);
+                        }
+                    }
+                });
+            });
+        } else if (obj.event === 'edit') {
+            var tr = $(obj.tr);
+            var perContent = layer.open({
+                type: 2
+                , title: '分仓机具申请记录-编辑'
+                , content: 'Edit?Id=' + data.Id + ''
+                , maxmin: true
+                , area: ['500px', '450px']
+                , btn: ['确定', '取消']
+                , yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index]
+                        , submitID = 'LAY-list-front-submit'
+                        , submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+                    var SendSn = '[';
+                    var ApplyNums = layero.find('iframe').contents().find('.productlist input[type=text][name=ApplyNum]');
+                    layero.find('iframe').contents().find('.productlist input[type=hidden][name=BrandId]').each(function (i) {
+                        var BrandId = $(this).val();
+                        var ApplyNum = ApplyNums.eq(i).val();
+                        SendSn += '{"ApplyNum":' + ApplyNum + ',"BrandId":' + BrandId + '}';
+                        if (i < ApplyNums.length - 1) {
+                            SendSn += ',';
+                        }
+                    });
+                    SendSn += ']';
+                    layero.find('iframe').contents().find('#SendSn').val(SendSn);
+
+                    //监听提交
+                    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({});
+
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/StoreMachineApplysOperate/Edit?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    layer.msg("修改成功", { time: 500 }, function () {
+                                        table.reload('LAY-list-manage'); //数据刷新
+                                    });
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+                , success: function (layero, index) {
+
+                }
+            });
+            // layer.full(perContent);
+        } else if (obj.event === 'Close') {
+            var index = layer.confirm('是否确定驳回?驳回后使用额度将返回该创客的可用额度', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreMachineApplysOperate/Close?r=" + Math.random(1),
+                    data: "Id=" + data.Id,
+                    dataType: "text",
+                    success: function (data) {
+                        layer.close(index); //关闭弹层
+                        if (data == "success") {
+                            layer.msg("已驳回", { time: 1500 }, function () {
+                                table.reload('LAY-list-manage'); //数据刷新
+                            });
+                        } else {
+                            parent.layer.msg(data);
+                        }
+                    }
+                });
+            });
+        } else if (obj.event === 'audit') {
+            var tr = $(obj.tr);
+            var perContent = layer.open({
+                type: 2,
+                title: '审核发货',
+                content: 'AuditSend?Id=' + data.Id + '',
+                maxmin: true,
+                area: ['450px', '680px'],
+                btn: ['确定发货', '取消'],
+                yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index],
+                        submitID = 'LAY-list-front-submit',
+                        submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        if(clickflag == 0) {
+                            clickflag = 1;
+                            var field = data.field; //获取提交的字段
+                            var userdata = "";
+                            for (var prop in field) {
+                                userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                            }
+                            //提交 Ajax 成功后,静态更新表格中的数据
+                            //$.ajax({});
+                            $.ajax({
+                                type: "POST",
+                                url: "/Admin/StoreMachineApplysOperate/AuditSend?r=" + Math.random(1),
+                                data: userdata,
+                                dataType: "text",
+                                success: function (data) {
+                                    clickflag = 0;
+                                    if (data == "success") {
+                                        layer.close(index); //关闭弹层
+                                        layer.msg('发货成功', {
+                                            time: 1500
+                                        }, function () {
+                                            table.reload('LAY-list-manage'); //数据刷新
+                                        });
+                                    } else if (data.indexOf("Warning") == 0) {
+                                        var datalist = data.split('|');
+                                        layer.alert(datalist[1], { time: 20000 }, function () {
+                                            window.location.reload();
+                                        });
+                                    } else {
+                                        layer.close(index); //关闭弹层
+                                        layer.msg('审核完成', {
+                                            time: 1500
+                                        }, function () {
+                                            table.reload('LAY-list-manage'); //数据刷新
+                                        });
+                                    }
+                                }
+                            });
+                        }
+                    });
+                    submit.trigger('click');
+                },
+                success: function (layero, index) {
+
+                }
+            });
+}
+    });
+
+
+//监听搜索
+form.on('submit(LAY-list-front-search)', function (data) {
+    var field = data.field;
+
+    //执行重载
+    table.reload('LAY-list-manage', {
+        where: field,
+        page: {
+            curr: 1
+        }
+    });
+});
+form.on('submit(LAY-list-front-searchall)', function (data) {
+    table.reload('LAY-list-manage', {
+        where: null,
+        page: {
+            curr: 1
+        }
+    });
+});
+
+//事件
+var active = {
+    batchdel: function () {
+        var checkStatus = table.checkStatus('LAY-list-manage')
+            , data = checkStatus.data; //得到选中的数据
+        if (data.length < 1) {
+            parent.layer.msg("请选择要删除的项");
+        } else {
+            var ids = "";
+            $.each(data, function (index, value) {
+                ids += data[index].Id + ",";
+            });
+            ids = ids.substring(0, ids.length - 1);
+            var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreMachineApplysOperate/Delete?r=" + Math.random(1),
+                    data: "Id=" + ids,
+                    dataType: "text",
+                    success: function (data) {
+                        layer.close(index);
+                        if (data == "success") {
+                            table.reload('LAY-list-manage');
+                        } else {
+                            layer.msg(data);
+                        }
+                    }
+                });
+            });
+        }
+    }
+    , add: function () {
+        var perContent = layer.open({
+            type: 2
+            , title: '分仓机具申请记录-添加'
+            , content: 'Add'
+            , maxmin: true
+            , area: ['500px', '450px']
+            , btn: ['确定', '取消']
+            , yes: function (index, layero) {
+                var iframeWindow = window['layui-layer-iframe' + index]
+                    , submitID = 'LAY-list-front-submit'
+                    , submit = layero.find('iframe').contents().find('#' + submitID);
+
+                setTimeout(function () {
+                    layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                        var errObj = $(this).find('.layui-form-danger');
+                        if (errObj.length > 0) {
+                            iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                            submit.click();
+                        }
+                    });
+                }, 300);
+
+
+
+
+
+
+                //监听提交
+                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({});
+
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/StoreMachineApplysOperate/Add?r=" + Math.random(1),
+                        data: userdata,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index); //关闭弹层
+                            if (data == "success") {
+                                table.reload('LAY-list-manage'); //数据刷新
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+
+                submit.trigger('click');
+            }
+        });
+        layer.full(perContent);
+    }
+    , ImportData: function () {
+        ExcelKind = 1;
+        layer.open({
+            type: 1,
+            title: '导入',
+            maxmin: false,
+            area: ['460px', '280px'],
+            content: $('#excelForm'),
+            cancel: function () {
+            }
+        });
+        $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
+    }
+    , ExportExcel: function () {
+        var userdata = '';
+        $(".layuiadmin-card-header-auto input").each(function (i) {
+            userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+        });
+        $(".layuiadmin-card-header-auto select").each(function (i) {
+            userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+        });
+        $.ajax({
+            type: "GET",
+            url: "/Admin/StoreMachineApplysOperate/ExportExcel?r=" + Math.random(1),
+            data: userdata,
+            dataType: "json",
+            success: function (data) {
+                data.Obj.unshift(data.Fields);
+                excel.exportExcel(data.Obj, data.Info, 'xlsx');
+            }
+        });
+    }
+    , Open: function () {
+        var checkStatus = table.checkStatus('LAY-list-manage')
+            , data = checkStatus.data; //得到选中的数据
+        if (data.length < 1) {
+            parent.layer.msg("请选择要开启的项");
+        } else {
+            var ids = "";
+            $.each(data, function (index, value) {
+                ids += data[index].Id + ",";
+            });
+            ids = ids.substring(0, ids.length - 1);
+            var index = layer.confirm('确定要开启吗?', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreMachineApplysOperate/Open?r=" + Math.random(1),
+                    data: "Id=" + ids,
+                    dataType: "text",
+                    success: function (data) {
+                        layer.close(index);
+                        if (data == "success") {
+                            table.reload('LAY-list-manage');
+                        } else {
+                            layer.msg(data);
+                        }
+                    }
+                });
+            });
+        }
+    }
+    , Close: function () {
+        var checkStatus = table.checkStatus('LAY-list-manage')
+            , data = checkStatus.data; //得到选中的数据
+        if (data.length < 1) {
+            parent.layer.msg("请选择要关闭的项");
+        } else {
+            var ids = "";
+            $.each(data, function (index, value) {
+                ids += data[index].Id + ",";
+            });
+            ids = ids.substring(0, ids.length - 1);
+            var index = layer.confirm('确定要关闭吗?', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreMachineApplysOperate/Close?r=" + Math.random(1),
+                    data: "Id=" + ids,
+                    dataType: "text",
+                    success: function (data) {
+                        layer.close(index);
+                        if (data == "success") {
+                            table.reload('LAY-list-manage');
+                        } else {
+                            layer.msg(data);
+                        }
+                    }
+                });
+            });
+        }
+    }
+};
+
+$('.layui-btn').on('click', function () {
+    var type = $(this).data('type');
+    active[type] ? active[type].call(this) : '';
+});
+});

+ 67 - 60
wwwroot/layuiadmin/modules_operate/SysAdminOperate_Admin.js

@@ -1,4 +1,5 @@
 var ExcelData;
+var clickflag = 0;
 
 function ConfirmImport() {
     $.ajax({
@@ -84,7 +85,7 @@ layui.config({
                 url: "/Admin/SysAdminOperate/Sort?r=" + Math.random(1),
                 data: "Id=" + data.Id + "&Sort=" + value,
                 dataType: "text",
-                success: function (data) {}
+                success: function (data) { }
             });
         }
     });
@@ -93,70 +94,74 @@ layui.config({
     table.render({
         elem: '#LAY-list-manage',
         url: '/Admin/SysAdminOperate/IndexData' //模拟接口
-            ,
+        ,
         cols: [
             [{
-                    type: 'checkbox',
-                    fixed: 'left'
-                }, {
-                    field: 'Id',
-                    fixed: 'left',
-                    title: 'ID',
-                    width: 80,
-                    sort: true,
-                    unresize: true
-                }, {
-                    field: 'OpCode',
-                    title: '运营中心编号',
-                    sort: true
-                }, {
-                    field: 'RealName',
-                    title: '名称',
-                    sort: true
-                }, {
-                    field: 'MakerCode',
-                    title: '所属创客编号',
-                    sort: true
-                }, {
-                    field: 'MakerName',
-                    title: '所属真实姓名',
-                    sort: true
-                }, {
-                    field: 'CreateDate',
-                    title: '创建时间',
-                    sort: true
-                }, {
-                    field: 'TotalAmt',
-                    title: '实缴额度',
-                    sort: true
-                }, {
-                    field: 'ValidAmount',
-                    title: '当前额度',
-                    sort: true
-                }, {
-                    field: 'WithdrawAmount',
-                    title: '已提现金额',
-                    sort: true
-                }, {
-                    field: 'WithdrawingAmount',
-                    title: '提现中金额',
-                    sort: true
-                }, {
-                    field: 'StoreCount',
-                    title: '分仓数量',
-                    sort: true
-                }
+                type: 'checkbox',
+                fixed: 'left'
+            }, {
+                field: 'Id',
+                fixed: 'left',
+                title: 'ID',
+                width: 80,
+                sort: true,
+                unresize: true
+            }, {
+                field: 'OpCode',
+                title: '运营中心编号',
+                sort: true
+            }, {
+                field: 'LoginUrl',
+                title: '登陆地址',
+                sort: true
+            }, {
+                field: 'RealName',
+                title: '名称',
+                sort: true
+            }, {
+                field: 'MakerCode',
+                title: '所属创客编号',
+                sort: true
+            }, {
+                field: 'MakerName',
+                title: '所属真实姓名',
+                sort: true
+            }, {
+                field: 'CreateDate',
+                title: '创建时间',
+                sort: true
+            }, {
+                field: 'TotalAmt',
+                title: '实缴额度',
+                sort: true
+            }, {
+                field: 'ValidAmount',
+                title: '当前额度',
+                sort: true
+            }, {
+                field: 'WithdrawAmount',
+                title: '已提现金额',
+                sort: true
+            }, {
+                field: 'WithdrawingAmount',
+                title: '提现中金额',
+                sort: true
+            }, {
+                field: 'StoreCount',
+                title: '分仓数量',
+                sort: true
+            }
                 // , { field: 'Role', title: '角色', sort: true }
                 // , { field: 'LastLoginDate', title: '最后登录时间', sort: true }
 
                 // , { field: 'Sort', fixed: 'right', title: '排序', width: 80, edit: 'text' }
                 , {
-                    title: '操作',
-                    align: 'center',
-                    width: 400,
-                    fixed: 'right',
-                    toolbar: '#table-list-tools'
-                }
+                title: '操作',
+                align: 'center',
+                width: 400,
+                fixed: 'right',
+                toolbar: '#table-list-tools'
+            }
             ]
         ],
         where: {
@@ -445,7 +450,9 @@ layui.config({
                             success: function (data) {
                                 layer.close(index); //关闭弹层
                                 if (data == "success") {
-                                    table.reload('LAY-list-manage'); //数据刷新
+                                    layer.msg("添加成功", { time: 1500 }, function () {
+                                        table.reload('LAY-list-manage'); //数据刷新
+                                    });
                                 } else {
                                     layer.msg(data);
                                 }
@@ -465,7 +472,7 @@ layui.config({
                 maxmin: false,
                 area: ['460px', '180px'],
                 content: $('#excelForm'),
-                cancel: function () {}
+                cancel: function () { }
             });
         },
         ExportExcel: function () {