Просмотр исходного кода

创客机具驳回仓库
调拨填写机具和发货仓库不符错误提示
机具费率调整
分仓临额变动记录

DuGuYang 3 лет назад
Родитель
Сommit
2ac47aef48
22 измененных файлов с 2344 добавлено и 368 удалено
  1. 122 112
      AppStart/ExcelHelper.cs
  2. 712 0
      Areas/Admin/Controllers/MainServer/PosMachinesTwoChangeController.cs
  3. 8 0
      Areas/Admin/Controllers/MainServer/PosMachinesTwoController.cs
  4. 7 0
      Areas/Admin/Controllers/MainServer/StoreHouseAmountRecordController.cs
  5. 33 20
      Areas/Admin/Controllers/MainServer/StoreHouseController.cs
  6. 307 153
      Areas/Admin/Controllers/MainServer/SysToolsController.cs
  7. 5 0
      Areas/Admin/Controllers/MainServer/UserAccountRecordController.cs
  8. 203 0
      Areas/Admin/Views/MainServer/PosMachinesTwoChange/Add.cshtml
  9. 215 0
      Areas/Admin/Views/MainServer/PosMachinesTwoChange/Edit.cshtml
  10. 157 0
      Areas/Admin/Views/MainServer/PosMachinesTwoChange/Index.cshtml
  11. 3 3
      Areas/Admin/Views/MainServer/StoreHouse/Import.cshtml
  12. 4 0
      Areas/Admin/Views/MainServer/StoreHouse/Index.cshtml
  13. 13 0
      Areas/Admin/Views/MainServer/StoreHouseAmountRecord/Index.cshtml
  14. 4 4
      Areas/Admin/Views/MainServer/SysTools/ChangeBadPos.cshtml
  15. 1 0
      Areas/Admin/Views/MainServer/UserAccountRecord/Index.cshtml
  16. 0 8
      wwwroot/layuiadmin/modules_main/Loop_Admin.js
  17. 478 0
      wwwroot/layuiadmin/modules_main/PosMachinesTwoChange_Admin.js
  18. 1 0
      wwwroot/layuiadmin/modules_main/PosMachinesTwo_Admin.js
  19. 1 0
      wwwroot/layuiadmin/modules_main/StoreHouseAmountRecord_Admin.js
  20. 4 3
      wwwroot/layuiadmin/modules_main/StoreHouse_Admin.js
  21. 66 65
      wwwroot/layuiadmin/modules_main/UserAccountRecord_Admin.js
  22. BIN
      wwwroot/users/创客机具驳回仓库模版.xlsx

+ 122 - 112
AppStart/ExcelHelper.cs

@@ -274,148 +274,158 @@ namespace MySystem
 
                                         int BrandId = int.Parse(function.CheckInt(BrandIdString));
 
-                                        KqProducts kqProduct = db.KqProducts.FirstOrDefault(m => m.Id == BrandId) ?? new KqProducts();
-                                        if (kqProduct.Id > 0)
+                                        //调拨时若出货仓库与填写仓库不符,则该条出货失败
+                                        var posinfo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.BrandId == BrandId);
+                                        var storeinfo = db.StoreForCode.FirstOrDefault(m => m.Code == OutStoreNo && m.StoreId == posinfo.StoreId);
+                                        if (storeinfo != null)
                                         {
-                                            StoreForCode storefor = db.StoreForCode.FirstOrDefault(m => m.Code == OutStoreNo) ?? new StoreForCode();
-                                            StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == storefor.StoreId) ?? new StoreHouse();
-                                            if (store.LaveNum > 0)
+                                            KqProducts kqProduct = db.KqProducts.FirstOrDefault(m => m.Id == BrandId) ?? new KqProducts();
+                                            if (kqProduct.Id > 0)
                                             {
-                                                StoreForCode tostorefor = db.StoreForCode.FirstOrDefault(m => m.Code == StoreNo) ?? new StoreForCode();
-                                                StoreHouse tostore = db.StoreHouse.FirstOrDefault(m => m.Id == tostorefor.StoreId) ?? new StoreHouse();
-                                                if (tostore.Id > 0)
+                                                StoreForCode storefor = db.StoreForCode.FirstOrDefault(m => m.Code == OutStoreNo) ?? new StoreForCode();
+                                                StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == storefor.StoreId) ?? new StoreHouse();
+                                                if (store.LaveNum > 0)
                                                 {
-                                                    MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
-                                                    PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.StoreId != tostore.Id && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
-                                                    if (machine.Id > 0)
+                                                    StoreForCode tostorefor = db.StoreForCode.FirstOrDefault(m => m.Code == StoreNo) ?? new StoreForCode();
+                                                    StoreHouse tostore = db.StoreHouse.FirstOrDefault(m => m.Id == tostorefor.StoreId) ?? new StoreHouse();
+                                                    if (tostore.Id > 0)
                                                     {
-                                                        StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
-                                                        {
-                                                            CreateDate = DateTime.Now,
-                                                            CreateMan = Operator,
-                                                            StoreId = storefor.StoreId, //仓库
-                                                            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 = store.UserId, //出货人
-                                                            FromDate = DateTime.Now, //出库时间
-                                                            FromRemark = OutNote, //出库备注
-                                                            ToUserId = tostore.UserId, //收货人
-                                                            ToStoreId = tostorefor.StoreId, //退货收货仓库                        
-                                                            SourceStoreId = machine.SourceStoreId, //源仓库编号
-                                                            BrandType = machine.DeviceType, //品牌类型
-                                                        }).Entity;
-                                                        db.SaveChanges();
-                                                        string ChangeNo = "SC";
-                                                        int StoreStockChangeId = stockchange.Id;
-                                                        string StoreStockChangeIdString = StoreStockChangeId.ToString();
-                                                        for (int j = 0; j < 18 - StoreStockChangeId.ToString().Length; j++)
+                                                        MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
+                                                        PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.StoreId != tostore.Id && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
+                                                        if (machine.Id > 0)
                                                         {
-                                                            StoreStockChangeIdString = "0" + StoreStockChangeIdString;
-                                                        }
-                                                        ChangeNo += StoreStockChangeIdString;
-                                                        stockchange.ChangeNo = ChangeNo; //交易流水编号
-                                                        machine.StoreId = tostorefor.StoreId;
+                                                            StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
+                                                            {
+                                                                CreateDate = DateTime.Now,
+                                                                CreateMan = Operator,
+                                                                StoreId = storefor.StoreId, //仓库
+                                                                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 = store.UserId, //出货人
+                                                                FromDate = DateTime.Now, //出库时间
+                                                                FromRemark = OutNote, //出库备注
+                                                                ToUserId = tostore.UserId, //收货人
+                                                                ToStoreId = tostorefor.StoreId, //退货收货仓库                        
+                                                                SourceStoreId = machine.SourceStoreId, //源仓库编号
+                                                                BrandType = machine.DeviceType, //品牌类型
+                                                            }).Entity;
+                                                            db.SaveChanges();
+                                                            string ChangeNo = "SC";
+                                                            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 = tostorefor.StoreId;
 
-                                                        db.StoreChangeHistory.Add(new StoreChangeHistory()
-                                                        {
-                                                            CreateDate = DateTime.Now,
-                                                            CreateMan = Operator,
-                                                            UserId = store.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 = store.UserId, //出货创客
-                                                            FromDate = DateTime.Now, //出库时间
-                                                            FromRemark = OutNote, //出库备注
-                                                            SourceStoreId = machine.SourceStoreId, //源仓库
-                                                            StoreId = store.Id, //仓库
-                                                        });
+                                                            db.StoreChangeHistory.Add(new StoreChangeHistory()
+                                                            {
+                                                                CreateDate = DateTime.Now,
+                                                                CreateMan = Operator,
+                                                                UserId = store.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 = store.UserId, //出货创客
+                                                                FromDate = DateTime.Now, //出库时间
+                                                                FromRemark = OutNote, //出库备注
+                                                                SourceStoreId = machine.SourceStoreId, //源仓库
+                                                                StoreId = store.Id, //仓库
+                                                            });
 
-                                                        db.StoreChangeHistory.Add(new StoreChangeHistory()
-                                                        {
-                                                            CreateDate = DateTime.Now,
-                                                            CreateMan = Operator,
-                                                            UserId = tostore.UserId, //创客
-                                                            BrandId = BrandId, //产品类型
-                                                            ChangeRecordNo = ChangeNo, //变更记录单号
-                                                            BizBatchNo = BatchNo, //业务批次号
-                                                            TransType = 1, //交易类型
-                                                            SnNo = SnNo, //SN编号
-                                                            SnType = machine.PosSnType, //SN机具类型
-                                                            StockOpDirect = 0, //库存操作方向
-                                                            DeviceVendor = machine.DeviceName, //设备厂商
-                                                            DeviceModel = machine.DeviceKind, //设备型号
-                                                            DeviceType = machine.DeviceType, //设备类型
-                                                            ToUserId = tostore.UserId, //收货创客
-                                                            ToStoreId = tostore.Id, //创客退货收货仓库
-                                                            ToDate = DateTime.Now, //入库时间
-                                                            ToRemark = OutNote, //入库备注
-                                                            SourceStoreId = machine.SourceStoreId, //源仓库
-                                                            StoreId = tostore.Id, //仓库
-                                                        });
-                                                        db.SaveChanges();
+                                                            db.StoreChangeHistory.Add(new StoreChangeHistory()
+                                                            {
+                                                                CreateDate = DateTime.Now,
+                                                                CreateMan = Operator,
+                                                                UserId = tostore.UserId, //创客
+                                                                BrandId = BrandId, //产品类型
+                                                                ChangeRecordNo = ChangeNo, //变更记录单号
+                                                                BizBatchNo = BatchNo, //业务批次号
+                                                                TransType = 1, //交易类型
+                                                                SnNo = SnNo, //SN编号
+                                                                SnType = machine.PosSnType, //SN机具类型
+                                                                StockOpDirect = 0, //库存操作方向
+                                                                DeviceVendor = machine.DeviceName, //设备厂商
+                                                                DeviceModel = machine.DeviceKind, //设备型号
+                                                                DeviceType = machine.DeviceType, //设备类型
+                                                                ToUserId = tostore.UserId, //收货创客
+                                                                ToStoreId = tostore.Id, //创客退货收货仓库
+                                                                ToDate = DateTime.Now, //入库时间
+                                                                ToRemark = OutNote, //入库备注
+                                                                SourceStoreId = machine.SourceStoreId, //源仓库
+                                                                StoreId = tostore.Id, //仓库
+                                                            });
+                                                            db.SaveChanges();
 
-                                                        // RemoveClass.DeletePosMachineList("PosMachineTwoList:" + storefor.StoreId, machine.Id);
-                                                        // RedisDbconn.Instance.AddList("PosMachineTwoList:" + tostorefor.StoreId, machine);
+                                                            // RemoveClass.DeletePosMachineList("PosMachineTwoList:" + storefor.StoreId, machine.Id);
+                                                            // RedisDbconn.Instance.AddList("PosMachineTwoList:" + tostorefor.StoreId, machine);
 
-                                                        if (!storeData.ContainsKey(storefor.StoreId + "_" + BrandId))
-                                                        {
-                                                            storeData.Add(storefor.StoreId + "_" + BrandId, 1);
+                                                            if (!storeData.ContainsKey(storefor.StoreId + "_" + BrandId))
+                                                            {
+                                                                storeData.Add(storefor.StoreId + "_" + BrandId, 1);
+                                                            }
+                                                            else
+                                                            {
+                                                                storeData[storefor.StoreId + "_" + BrandId] += 1;
+                                                            }
+                                                            if (!toStoreData.ContainsKey(tostorefor.StoreId + "_" + BrandId))
+                                                            {
+                                                                toStoreData.Add(tostorefor.StoreId + "_" + BrandId, 1);
+                                                            }
+                                                            else
+                                                            {
+                                                                toStoreData[tostorefor.StoreId + "_" + BrandId] += 1;
+                                                            }
+                                                            SuccessCount += 1;
+                                                            RedisDbconn.Instance.Set("CheckImport:" + checkKey, SuccessCount + " / " + TotalCount);
                                                         }
                                                         else
                                                         {
-                                                            storeData[storefor.StoreId + "_" + BrandId] += 1;
-                                                        }
-                                                        if (!toStoreData.ContainsKey(tostorefor.StoreId + "_" + BrandId))
-                                                        {
-                                                            toStoreData.Add(tostorefor.StoreId + "_" + BrandId, 1);
+                                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "不是仓库机或不在填写的收货仓库中");
                                                         }
-                                                        else
+                                                        if (string.IsNullOrEmpty(tostore.ProductName))
                                                         {
-                                                            toStoreData[tostorefor.StoreId + "_" + BrandId] += 1;
+                                                            tostore.BrandId = BrandId.ToString();
+                                                            tostore.ProductName = kqProduct.Name;
                                                         }
-                                                        SuccessCount += 1;
-                                                        RedisDbconn.Instance.Set("CheckImport:" + checkKey, SuccessCount + " / " + TotalCount);
                                                     }
                                                     else
                                                     {
-                                                        RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "不是仓库机或不在填写的收货仓库中");
-                                                    }
-                                                    if (string.IsNullOrEmpty(tostore.ProductName))
-                                                    {
-                                                        tostore.BrandId = BrandId.ToString();
-                                                        tostore.ProductName = kqProduct.Name;
+                                                        RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "填写的收货仓库编号不正确");
                                                     }
                                                 }
                                                 else
                                                 {
-                                                    RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "填写的收货仓库编号不正确");
+                                                    RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "所在的仓库" + store.StoreName + "(" + store.StoreNo + ")库存不足");
                                                 }
+                                                db.SaveChanges();
                                             }
                                             else
                                             {
-                                                RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "所在的仓库" + store.StoreName + "(" + store.StoreNo + ")库存不足");
+                                                RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "的品牌填写有误");
                                             }
-                                            db.SaveChanges();
                                         }
                                         else
                                         {
-                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "的品牌填写有误");
+                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "机具" + SnNo + "出货仓库与填写仓库不符");
                                         }
                                     }
                                     DoCount += Size;

+ 712 - 0
Areas/Admin/Controllers/MainServer/PosMachinesTwoChangeController.cs

@@ -0,0 +1,712 @@
+/*
+ * 机具库
+ */
+
+using System;
+using System.Web;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Data;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using MySystem.Models;
+using Library;
+using LitJson;
+using MySystemLib;
+
+namespace MySystem.Areas.Admin.Controllers
+{
+    [Area("Admin")]
+    [Route("Admin/[controller]/[action]")]
+    public class PosMachinesTwoChangeController : BaseController
+    {
+        public PosMachinesTwoChangeController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
+        {
+            OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+        }
+
+        #region 机具库列表
+
+        /// <summary>
+        /// 根据条件查询机具库列表
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Index(PosMachinesTwo data, string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+            return View();
+        }
+
+        #endregion
+
+        #region 根据条件查询机具库列表
+
+        /// <summary>
+        /// 机具库列表
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult IndexData(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName, string BrandId, string ActivationDateData, string BindingDateData, int page = 1, int limit = 30)
+        {
+
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+
+            Fields.Add("PosSn", "1"); //SN编号
+            Fields.Add("BrandId", "0"); //品牌
+
+
+            string condition = " and Status>-1 AND BindingState = 1 AND DATE_SUB(CURDATE(), INTERVAL 180 DAY) >= date(BindingTime)";
+            //绑定状态
+            if (!string.IsNullOrEmpty(BindingStateSelect))
+            {
+                condition += " and BindingState=" + BindingStateSelect;
+            }
+            //激活状态
+            if (!string.IsNullOrEmpty(ActivationStateSelect))
+            {
+                condition += " and ActivationState=" + ActivationStateSelect;
+            }
+            //所属创客编号
+            if (!string.IsNullOrEmpty(UserIdMakerCode))
+            {
+                condition += " and BuyUserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
+            }
+            //所属创客真实姓名
+            if (!string.IsNullOrEmpty(UserIdRealName))
+            {
+                condition += " and BuyUserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
+            }
+            //所属仓库编号
+            if (!string.IsNullOrEmpty(StoreIdCode))
+            {
+                condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
+            }
+            //所属仓库名称
+            if (!string.IsNullOrEmpty(StoreIdName))
+            {
+                condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
+            }
+            //品牌
+            if (!string.IsNullOrEmpty(BrandId))
+            {
+                condition += " and BrandId =" + BrandId;
+            }
+
+            if (!string.IsNullOrEmpty(ActivationDateData))
+            {
+                string[] datelist = ActivationDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and ActivationTime>='" + start + " 00:00:00' and ActivationTime<='" + end + " 23:59:59'";
+            }
+
+            if (!string.IsNullOrEmpty(BindingDateData))
+            {
+                string[] datelist = BindingDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and BindingTime>='" + start + " 00:00:00' and BindingTime<='" + end + " 23:59:59'";
+            }
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", page, limit, condition);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            foreach (Dictionary<string, object> dic in diclist)
+            {
+                //绑定状态
+                int BindingState = int.Parse(dic["BindingState"].ToString());
+                if (BindingState == 0) dic["BindingState"] = "未绑定";
+                if (BindingState == 1) dic["BindingState"] = "已绑定";
+                //激活状态
+                int ActivationState = int.Parse(dic["ActivationState"].ToString());
+                if (ActivationState == 0) dic["ActivationState"] = "未激活";
+                if (ActivationState == 1) dic["ActivationState"] = "已激活";
+                //所属创客
+                int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
+                Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+                dic["UserIdMakerCode"] = userid_Users.MakerCode;
+                dic["UserIdRealName"] = userid_Users.RealName;
+                dic.Remove("UserId");
+                //所属仓库
+                int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
+                StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
+                dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
+                dic["StoreIdName"] = storeid_StoreHouse.StoreName;
+                dic.Remove("StoreId");
+                //产品类型
+                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
+                //参加活动
+                dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
+                //绑定商户
+                int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
+                PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
+                dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
+                dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
+                dic.Remove("BindMerchantId");
+                //机具类型
+                int PosSnType = int.Parse(dic["PosSnType"].ToString());
+                if (PosSnType == 0) dic["PosSnType"] = "购买机具";
+                if (PosSnType == 1) dic["PosSnType"] = "赠送机具";
+                //设备类型
+                string DeviceType = dic["DeviceType"].ToString();
+                if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
+                if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
+                if (DeviceType == "") dic["DeviceType"] = "";
+
+                //盟主信息
+                int LeaderUserId = int.Parse(function.CheckInt(dic["LeaderUserId"].ToString()));
+                if (LeaderUserId != 0)
+                {
+                    Users users = db.Users.FirstOrDefault(m => m.Id == LeaderUserId) ?? new Users();
+                    dic["UserInfo"] = users.MakerCode + "_" + users.RealName;
+                }
+
+                //是否为第一台机具
+                int IsFirst = int.Parse(dic["IsFirst"].ToString());
+                if (IsFirst == 0) dic["IsFirst"] = "否";
+                if (IsFirst == 1) dic["IsFirst"] = "是";
+
+                //循环开始时间
+                if (!string.IsNullOrEmpty(dic["RecycEndDate"].ToString()))
+                {
+                    var RecycStartDate = Convert.ToDateTime(dic["RecycEndDate"].ToString()).AddMonths(-3).ToString("yyyy-MM-dd HH:mm:ss");
+                    dic["RecycStartDate"] = RecycStartDate;
+                }
+
+
+            }
+            Dictionary<string, object> other = new Dictionary<string, object>();
+            int TotalCount = 0;//总机具数
+            string KysCount99 = "0.00";
+            string KssCount99 = "0.00";
+            string KssCoun198 = "0.00";
+            string KssCount298 = "0.00";
+            DataTable dt = OtherMySqlConn.dtable("select count(0) from PosMachinesTwo where 1=1" + condition);
+            if (dt.Rows.Count > 0)
+            {
+                TotalCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
+            }
+            // dt = OtherMySqlConn.dtable("select sum(TotalPrice) from Orders where PayStatus=1" + condition);
+            // if (dt.Rows.Count > 0)
+            // {
+            //     FailAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
+            // }
+            other.Add("TotalCount", TotalCount);
+            other.Add("KysCount99", 0);
+            other.Add("KssCount99", 0);
+            other.Add("KssCoun198", 0);
+            other.Add("KssCount298", 0);
+            obj.Add("other", other);
+            return Json(obj);
+        }
+
+        #endregion
+
+        #region 增加机具库
+
+        /// <summary>
+        /// 增加或修改机具库信息
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Add(string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            return View();
+        }
+
+        #endregion
+
+        #region 增加机具库
+
+        /// <summary>
+        /// 增加或修改机具库信息
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public string Add(PosMachinesTwo data)
+        {
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
+
+
+            Fields.Add("SeoTitle", data.SeoTitle);
+            Fields.Add("SeoKeyword", data.SeoKeyword);
+            Fields.Add("SeoDescription", data.SeoDescription);
+            int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("PosMachinesTwo", Fields, 0);
+            AddSysLog(data.Id.ToString(), "PosMachinesTwo", "add");
+            db.SaveChanges();
+
+            return "success";
+        }
+
+        #endregion
+
+        #region 修改机具库
+
+        /// <summary>
+        /// 增加或修改机具库信息
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Edit(string right, int Id = 0)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            PosMachinesTwo editData = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id) ?? new PosMachinesTwo();
+            ViewBag.data = editData;
+            return View();
+        }
+
+        #endregion
+
+        #region 修改机具库
+
+        /// <summary>
+        /// 增加或修改机具库信息
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public string Edit(PosMachinesTwo data)
+        {
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
+            Fields.Add("PosSnType", data.PosSnType);
+            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, data.Id);
+            AddSysLog(data.Id.ToString(), "PosMachinesTwo", "update");
+            db.SaveChanges();
+            RedisDbconn.Instance.Clear("PosMachinesTwo:" + data.Id);
+            return "success";
+        }
+
+        #endregion
+
+
+        #region 未使用机具归位总仓
+
+        /// <summary>
+        /// 未使用机具归位总仓
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Home(string right, int Id = 0)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            PosMachinesTwo editData = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id) ?? new PosMachinesTwo();
+            ViewBag.data = editData;
+            return View();
+        }
+
+        #endregion
+
+        #region 未使用机具归位总仓
+
+        /// <summary>
+        /// 未使用机具归位总仓
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public string Home(PosMachinesTwo data)
+        {
+            Dictionary<string, object> Fields = new Dictionary<string, object>();
+            Fields.Add("SeoTitle", "");
+            Fields.Add("SeoKeyword", "");
+            Fields.Add("PosSnType", 0);
+            new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, data.Id);
+            AddSysLog(data.Id.ToString(), "PosMachinesTwo", "home");
+            db.SaveChanges();
+            RedisDbconn.Instance.Clear("PosMachinesTwo:" + data.Id);
+            return "success";
+        }
+
+        #endregion
+
+
+        #region 删除机具库信息
+
+        /// <summary>
+        /// 删除机具库信息
+        /// </summary>
+        /// <returns></returns>
+        public string Delete(string Id)
+        {
+            string[] idlist = Id.Split(new char[] { ',' });
+            AddSysLog(Id, "PosMachinesTwo", "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("PosMachinesTwo", 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, "PosMachinesTwo", "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("PosMachinesTwo", 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, "PosMachinesTwo", "close");
+            foreach (string subid in idlist)
+            {
+                int id = int.Parse(subid);
+                Dictionary<string, object> Fields = new Dictionary<string, object>();
+                Fields.Add("Status", 0);
+                new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", 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("PosMachinesTwo", Sort, Id);
+
+            AddSysLog(Id.ToString(), "PosMachinesTwo", "sort");
+            return "success";
+        }
+        #endregion
+
+        #region 导入数据
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        public string Import(string ExcelData, int Kind = 0)
+        {
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+            if (Kind == 1)
+            {
+                string error = "";
+                List<string> PosSnList = new List<string>();
+                for (int i = 1; i < list.Count; i++)
+                {
+                    JsonData dr = list[i];
+                    string itemJson = dr.ToJson();
+                    string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                    string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+                    string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
+                    string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
+                    string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
+                    string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
+                    UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
+                    var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
+                    MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
+                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
+                    if (posInfo == null)
+                    {
+                        error += "以下操作失败" + PosSn + ',' + "未找到该品牌的机具" + '\n';
+                    }
+                    else if (PosSnList.Contains(PosSn))
+                    {
+                        error += "以下操作失败" + PosSn + ',' + "该机具号重复" + '\n';
+                    }
+                    else if (!string.IsNullOrEmpty(error))
+                    {
+                        return "Warning|" + error;
+                    }
+                    else
+                    {
+                        PosSnList.Add(PosSn);
+                    }
+
+                }
+                for (int i = 1; i < list.Count; i++)
+                {
+                    JsonData dr = list[i];
+                    string itemJson = dr.ToJson();
+                    string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                    string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+                    string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
+                    string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
+                    string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
+                    string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
+                    decimal amount = 0;
+                    UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
+                    var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
+                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new UserAccount();
+                    var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == Convert.ToInt32(BrandId)) ?? new KqProducts();
+                    if (brandInfo.Name.Contains("电签"))
+                    {
+                        amount = 200;
+                    }
+                    if (brandInfo.Name.Contains("大POS"))
+                    {
+                        amount = 300;
+                    }
+                    userAccount.ValidAmount += amount;
+                    string text = string.Format("导入机具驳回仓库,UserId: '" + user.Id + "',BeforeChangeAmount:'" + userAccount.ValidAmount + "',AfterChangeAmount:'" + userAccount.ValidAmount + amount + "',ChangeAmount:'" + amount + "',Time'" + DateTime.Now + "'");
+                    function.WriteLog(text, "机具驳回仓库");//机具驳回仓库日志
+                    db.SaveChanges();
+                    MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
+                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
+                    if (posInfo != null)
+                    {
+                        var storehouse = db.StoreHouse.FirstOrDefault(m => m.Id == posInfo.StoreId);
+                        StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
+                        {
+                            CreateDate = DateTime.Now,
+                            StoreId = storehouse.Id, //出货 仓库
+                            BrandId = Convert.ToInt32(BrandId), //产品类型
+                            ProductName = RelationClass.GetKqProductBrandInfo(Convert.ToInt32(BrandId)), //产品名称
+                            BizBatchNo = No, //业务批次号
+                            TransType = 1, //交易类型
+                            SnNo = PosSn, //SN编号
+                            StockOpDirect = 1, //库存操作方向
+                            SnStatus = 1, //SN状态
+                            DeviceVendor = posInfo.DeviceName, //设备厂商
+                            DeviceModel = posInfo.DeviceKind, //设备型号
+                            DeviceType = posInfo.DeviceType, //设备类型                    
+                            SourceStoreId = posInfo.SourceStoreId, //源仓库编号
+                            BrandType = posInfo.DeviceType, //品牌类型
+                        }).Entity;
+
+                        db.StoreChangeHistory.Add(new StoreChangeHistory()
+                        {
+                            CreateDate = DateTime.Now,
+                            UserId = user.Id, //创客
+                            BrandId = Convert.ToInt32(BrandId), //产品类型
+                            ChangeRecordNo = "JJBH" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), //变更记录单号
+                            SeoTitle = "机具驳回仓库",
+                            BizBatchNo = No, //业务批次号
+                            SnNo = PosSn, //SN编号
+                        });
+                        StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
+                        {
+                            CreateDate = DateTime.Now,
+                            StoreId = posInfo.StoreId, //仓库
+                            BrandId = Convert.ToInt32(BrandId), //产品类型
+                            OpStoreNum = 1, //操作库存数
+                            OpSymbol = "+", //操作符
+                            BeforeTotalNum = storehouse.TotalNum, //操作前总库存数
+                            AfterTotalNum = storehouse.TotalNum + 1, //操作后总库存数
+                            BeforeLaveNum = storehouse.LaveNum, //操作前剩余库存数
+                            AfterLaveNum = storehouse.LaveNum + 1, //操作后剩余库存数
+                            BeforeOutNum = storehouse.OutNum, //操作前出库数
+                            AfterOutNum = storehouse.OutNum - 1, //操作后出库数
+                        }).Entity;
+                    }
+                }
+                db.SaveChanges();
+            }
+            AddSysLog("0", "MachinesRejectStore", "Import");
+            return "success";
+        }
+        #endregion
+
+
+        #region
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        [HttpPost]
+        public string ImportPost(string ExcelPath)
+        {
+            string key = function.MD5_16(Guid.NewGuid().ToString());
+            RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#PosMachinesTwoChange#cut#" + key + "#cut#" + SysUserName);
+            return "success|" + key;
+        }
+        public string CheckImport(string key)
+        {
+            string result = RedisDbconn.Instance.Get<string>("CheckImport:" + key);
+            if (!string.IsNullOrEmpty(result))
+            {
+                string[] datalist = result.Split('|');
+                if (datalist[0] == "success")
+                {
+                    return result;
+                }
+                return datalist[0];
+            }
+            return "0";
+        }
+        #endregion
+
+
+        #region 导出Excel
+
+        /// <summary>
+        /// 导出Excel
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult ExportExcel(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName)
+        {
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+            Fields.Add("PosSn", "1"); //SN编号
+            Fields.Add("BrandId", "0"); //品牌
+
+            string condition = " and Status>-1";
+            //绑定状态
+            if (!string.IsNullOrEmpty(BindingStateSelect))
+            {
+                condition += " and BindingState=" + BindingStateSelect;
+            }
+            //激活状态
+            if (!string.IsNullOrEmpty(ActivationStateSelect))
+            {
+                condition += " and ActivationState=" + ActivationStateSelect;
+            }
+            //所属创客创客编号
+            if (!string.IsNullOrEmpty(UserIdMakerCode))
+            {
+                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
+            }
+            //所属创客真实姓名
+            if (!string.IsNullOrEmpty(UserIdRealName))
+            {
+                condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
+            }
+            //所属仓库编号
+            if (!string.IsNullOrEmpty(StoreIdCode))
+            {
+                condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
+            }
+            //所属仓库名称
+            if (!string.IsNullOrEmpty(StoreIdName))
+            {
+                condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
+            }
+
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", 1, 20000, condition, "BindingState,ActivationState,UserId,StoreId,PosSn,BrandId,ActivityList,BindMerchantId,PosSnType,DeviceType,BindingTime,ActivationTime,TransferTime", false);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            foreach (Dictionary<string, object> dic in diclist)
+            {
+                //绑定状态
+                int BindingState = int.Parse(dic["BindingState"].ToString());
+                if (BindingState == 0) dic["BindingState"] = "未绑定";
+                if (BindingState == 1) dic["BindingState"] = "已绑定";
+                //绑定时间
+                if (!string.IsNullOrEmpty(dic["BindingTime"].ToString()))
+                {
+                    DateTime BindingTime = Convert.ToDateTime(dic["BindingTime"].ToString());
+                }
+
+                //激活状态
+                int ActivationState = int.Parse(dic["ActivationState"].ToString());
+                if (ActivationState == 0) dic["ActivationState"] = "未激活";
+                if (ActivationState == 1) dic["ActivationState"] = "已激活";
+                //激活时间
+                if (!string.IsNullOrEmpty(dic["ActivationTime"].ToString()))
+                {
+                    DateTime ActivationTime = Convert.ToDateTime(dic["ActivationTime"].ToString());
+                }
+
+                //划拨时间
+                if (!string.IsNullOrEmpty(dic["TransferTime"].ToString()))
+                {
+                    DateTime TransferTime = Convert.ToDateTime(dic["TransferTime"].ToString());
+                }
+                //所属创客
+                int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
+                Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+                dic["UserIdMakerCode"] = userid_Users.MakerCode;
+                dic["UserIdRealName"] = userid_Users.RealName;
+                dic.Remove("UserId");
+                //所属仓库
+                int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
+                StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
+                dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
+                dic["StoreIdName"] = storeid_StoreHouse.StoreName;
+                dic.Remove("StoreId");
+                //产品类型
+                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
+                //参加活动
+                // dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
+                //绑定商户
+                int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
+                PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
+                dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
+                dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
+                dic.Remove("BindMerchantId");
+                //机具类型
+                int PosSnType = int.Parse(dic["PosSnType"].ToString());
+                if (PosSnType == 0) dic["PosSnType"] = "购买机具";
+                if (PosSnType == 1) dic["PosSnType"] = "赠送机具";
+                // //设备类型
+                // string DeviceType = dic["DeviceType"].ToString();
+                // if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
+                // if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
+                // if (DeviceType == "") dic["DeviceType"] = "";
+
+            }
+
+            Dictionary<string, object> result = new Dictionary<string, object>();
+            result.Add("Status", "1");
+            result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
+            result.Add("Obj", diclist);
+            Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
+            ReturnFields.Add("UserIdMakerCode", "创客编号");
+            ReturnFields.Add("UserIdRealName", "创客姓名");
+            ReturnFields.Add("StoreIdCode", "仓库编号");
+            ReturnFields.Add("StoreIdName", "仓库名称");
+            ReturnFields.Add("BrandId", "产品类型");
+            ReturnFields.Add("PosSn", "SN编号");
+            ReturnFields.Add("PosSnType", "SN类型");
+            // ReturnFields.Add("ActivityList", "参加活动");
+            ReturnFields.Add("BindMerchantIdMerchantNo", "绑定商户编号");
+            ReturnFields.Add("BindMerchantIdMerchantName", "绑定商户姓名");
+            ReturnFields.Add("DeviceType", "设备类型");
+            ReturnFields.Add("BindingState", "绑定状态");
+            ReturnFields.Add("BindingTime", "绑定时间");
+            ReturnFields.Add("ActivationState", "激活状态");
+            ReturnFields.Add("ActivationTime", "激活时间");
+            ReturnFields.Add("TransferTime", "划拨时间");
+
+            result.Add("Fields", ReturnFields);
+            AddSysLog("0", "PosMachinesTwo", "ExportExcel");
+            return Json(result);
+        }
+
+        #endregion
+
+    }
+}

+ 8 - 0
Areas/Admin/Controllers/MainServer/PosMachinesTwoController.cs

@@ -170,6 +170,14 @@ namespace MySystem.Areas.Admin.Controllers
                 if (IsFirst == 0) dic["IsFirst"] = "否";
                 if (IsFirst == 1) dic["IsFirst"] = "是";
 
+                //循环开始时间
+                if (!string.IsNullOrEmpty(dic["RecycEndDate"].ToString()))
+                {
+                    var RecycStartDate = Convert.ToDateTime(dic["RecycEndDate"].ToString()).AddMonths(-3).ToString("yyyy-MM-dd HH:mm:ss");
+                    dic["RecycStartDate"] = RecycStartDate;
+                }
+
+
             }
             Dictionary<string, object> other = new Dictionary<string, object>();
             int TotalCount = 0;//总机具数

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

@@ -98,6 +98,13 @@ namespace MySystem.Areas.Admin.Controllers
                 int AmountType = int.Parse(dic["AmountType"].ToString());
                 if (AmountType == 0) dic["AmountType"] = "固定额度";
                 if (AmountType == 1) dic["AmountType"] = "临时额度";
+                //变动类别
+                int ChangeType = int.Parse(dic["Sort"].ToString());
+                if (ChangeType == 1) dic["ChangeType"] = "购买临时额度";
+                if (ChangeType == 2) dic["ChangeType"] = "增减分仓临时额度";
+                if (ChangeType == 3) dic["ChangeType"] = "调低额度返回余额";
+                if (ChangeType == 4) dic["ChangeType"] = "仓库发货|预发机申请";
+                if (ChangeType == 5) dic["ChangeType"] = "后台仓库调拨";
                 //操作类别
                 int OperateType = int.Parse(dic["OperateType"].ToString());
                 if (OperateType == 1) dic["OperateType"] = "增加";

+ 33 - 20
Areas/Admin/Controllers/MainServer/StoreHouseController.cs

@@ -291,7 +291,7 @@ namespace MySystem.Areas.Admin.Controllers
                         account.FixedAmount = 20000;
                         account.ValidAmount = 20000;
                     }
-                    
+
                     RedisDbconn.Instance.Set("StoreForName:" + data.StoreName, Id);
                     AddSysLog(data.Id.ToString(), "StoreHouse", "add");
                     db.SaveChanges();
@@ -693,16 +693,21 @@ namespace MySystem.Areas.Admin.Controllers
                     }
                     var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
                     MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
-                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
+                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.BindingState == 0);
+                    var posInfos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.BindingState == 0 && m.StoreId == store.Id);
                     if (posInfo == null)
                     {
-                        error += "以下操作失败" + PosSn + ',' + "未找到该品牌的机具" + '\n';
+                        error += "以下操作失败" + PosSn + ',' + "未找到该品牌的未使用机具" + '\n';
+                    }
+                    if (posInfos != null)
+                    {
+                        error += "以下操作失败" + PosSn + ',' + "该机具已在仓库:" + StoreNo + '\n';
                     }
-                    else if (PosSnList.Contains(PosSn))
+                    if (PosSnList.Contains(PosSn))
                     {
                         error += "以下操作失败" + PosSn + ',' + "该机具号重复" + '\n';
                     }
-                    else if (!string.IsNullOrEmpty(error))
+                    if (!string.IsNullOrEmpty(error))
                     {
                         return "Warning|" + error;
                     }
@@ -724,6 +729,8 @@ namespace MySystem.Areas.Admin.Controllers
                     string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
                     decimal amount = 0;
                     UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
+                    StoreForCode storeForCode = db.StoreForCode.FirstOrDefault(m => m.Code == StoreNo);
+                    var store = db.StoreHouse.FirstOrDefault(m => m.Id == storeForCode.StoreId && m.UserId == userForMakerCode.UserId && m.BrandId == BrandId) ?? new StoreHouse();
                     var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
                     var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new UserAccount();
                     var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == Convert.ToInt32(BrandId)) ?? new KqProducts();
@@ -740,18 +747,14 @@ namespace MySystem.Areas.Admin.Controllers
                     function.WriteLog(text, "机具驳回仓库");//机具驳回仓库日志
                     db.SaveChanges();
                     MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
-                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
+                    var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.BindingState == 0);
                     if (posInfo != null)
                     {
-                        var storehouse = db.StoreHouse.FirstOrDefault(m => m.Id == posInfo.StoreId);
-                        storehouse.TotalNum += 1;
-                        storehouse.LaveNum += 1;
-                        storehouse.OutNum -= 1;
-                        db.SaveChanges();
+                        
                         StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
                         {
                             CreateDate = DateTime.Now,
-                            StoreId = storehouse.Id, //出货 仓库
+                            StoreId = store.Id, //出货 仓库
                             BrandId = Convert.ToInt32(BrandId), //产品类型
                             ProductName = RelationClass.GetKqProductBrandInfo(Convert.ToInt32(BrandId)), //产品名称
                             BizBatchNo = No, //业务批次号
@@ -765,6 +768,7 @@ namespace MySystem.Areas.Admin.Controllers
                             SourceStoreId = posInfo.SourceStoreId, //源仓库编号
                             BrandType = posInfo.DeviceType, //品牌类型
                         }).Entity;
+                        db.SaveChanges();
 
                         db.StoreChangeHistory.Add(new StoreChangeHistory()
                         {
@@ -776,23 +780,32 @@ namespace MySystem.Areas.Admin.Controllers
                             BizBatchNo = No, //业务批次号
                             SnNo = PosSn, //SN编号
                         });
+                        db.SaveChanges();
+
                         StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
                         {
                             CreateDate = DateTime.Now,
-                            StoreId = posInfo.StoreId, //仓库
+                            StoreId = store.Id, //仓库
                             BrandId = Convert.ToInt32(BrandId), //产品类型
                             OpStoreNum = 1, //操作库存数
                             OpSymbol = "+", //操作符
-                            BeforeTotalNum = storehouse.TotalNum, //操作前总库存数
-                            AfterTotalNum = storehouse.TotalNum + 1, //操作后总库存数
-                            BeforeLaveNum = storehouse.LaveNum, //操作前剩余库存数
-                            AfterLaveNum = storehouse.LaveNum + 1, //操作后剩余库存数
-                            BeforeOutNum = storehouse.OutNum, //操作前出库数
-                            AfterOutNum = storehouse.OutNum - 1, //操作后出库数
+                            BeforeTotalNum = store.TotalNum, //操作前总库存数
+                            AfterTotalNum = store.TotalNum + 1, //操作后总库存数
+                            BeforeLaveNum = store.LaveNum, //操作前剩余库存数
+                            AfterLaveNum = store.LaveNum + 1, //操作后剩余库存数
+                            BeforeOutNum = store.OutNum, //操作前出库数
+                            AfterOutNum = store.OutNum + 1, //操作后出库数
                         }).Entity;
+                        db.SaveChanges();
+                        
+                        posInfo.StoreId = store.Id;
+                        store.TotalNum += 1;
+                        store.LaveNum += 1;
+                        store.OutNum -= 1;
+                        db.SaveChanges();
+
                     }
                 }
-                db.SaveChanges();
             }
             AddSysLog("0", "MachinesRejectStore", "Import");
             return "success";

+ 307 - 153
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -1491,7 +1491,7 @@ namespace MySystem.Areas.Admin.Controllers
         }
 
         [HttpPost]
-        public string ChangeBadPosDo(string OldSn, string NewSn, string BackStoreNo, string OutStoreNo, string MakerCode = "", int IsSend = 0)
+        public string ChangeBadPosDo(string OldSn, string NewSn, int IsSend = 0)
         {
             if (string.IsNullOrEmpty(OldSn))
             {
@@ -1507,135 +1507,253 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 return "原机具SN数量和新机具SN数量不一致";
             }
-            WebCMSEntities db = new WebCMSEntities();
-            PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == OldSn);
-            StoreForCode storeForBack = db.StoreForCode.FirstOrDefault(m => m.Code == BackStoreNo) ?? new StoreForCode();
-            StoreForCode storeForOut = db.StoreForCode.FirstOrDefault(m => m.Code == OutStoreNo) ?? new StoreForCode();
-            StoreHouse BackStore = db.StoreHouse.FirstOrDefault(m => m.Id == storeForBack.StoreId) ?? new StoreHouse();
-            StoreHouse OutStore = db.StoreHouse.FirstOrDefault(m => m.Id == storeForOut.StoreId) ?? new StoreHouse();
-            string ChangeNo = "BPC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(3);
-            KqProducts oldPosBrand = new KqProducts();
-            KqProducts newPosBrand = new KqProducts();
-            MachineChange add = db.MachineChange.Add(new MachineChange()
-            {
-                CreateDate = DateTime.Now,
-                UpdateDate = DateTime.Now,
-                CreateMan = SysUserName + "-" + SysRealName,
-                ChangeNo = ChangeNo, //转换单号
-                UserId = 0, //创客
-                ChangeTime = DateTime.Now, //转换时间
-                BackStoreId = BackStore.Id, //退回仓库
-                BackStoreName = BackStore.StoreName, //退回仓库名称
-                Remark = "坏机换新", //订单备注
-                BackStoreUserId = BackStore.UserId, //退回仓库归属人
-                OutProductType = int.Parse(OutStore.BrandId), //出库产品类型
-                OutProductName = OutStore.ProductName, //出库产品名称
-                OutStoreId = OutStore.Id, //出库仓库
-                OutStoreName = OutStore.StoreName, //出库仓库名称
-                OutStoreAreas = OutStore.Areas, //出库仓库所在地区
-                OutStoreAddress = OutStore.Address, //出库仓库地址
-                OutStoreManager = "", //出库仓库联系人
-                OutStoreManagerMobile = OutStore.ManageMobile, //出库仓库联系人手机号
-            }).Entity;
-            db.SaveChanges();
-            int BackProductType = 0;
-            string BackProductName = "";
-            string ChangeDeviceName = "";
-            string ChangeSnExpand = "";
+            decimal amount = 0;
             for (int i = 0; i < OldSnList.Length; i++)
             {
                 string OldSnNum = OldSnList[i];
                 string NewSnNum = NewSnList[i];
                 MachineForSnNo oldForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == OldSnNum) ?? new MachineForSnNo();
                 MachineForSnNo newForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == NewSnNum) ?? new MachineForSnNo();
-                PosMachinesTwo oldpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == oldForSnNo.SnId);
+                PosMachinesTwo oldpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == oldForSnNo.SnId && m.BindingState == 0);
+                oldpos.Status = -1;
+                var oldStore = db.StoreHouse.FirstOrDefault(m => m.Id == oldpos.StoreId);
                 if (oldpos == null)
                 {
-                    return "原机具SN不正确";
+                    return "原机具SN不正确或者不符合换机条件";
                 }
-                PosMachinesTwo newpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == newForSnNo.SnId);
+                PosMachinesTwo newpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == newForSnNo.SnId && m.BuyUserId == 0 && m.UserId == 0 && m.BindingState == 0);
                 if (newpos == null)
                 {
-                    return "新机具SN不正确";
+                    return "新机具SN不正确或者不为仓库机";
                 }
-                oldPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == oldpos.BrandId) ?? new KqProducts();
-                newPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == newpos.BrandId) ?? new KqProducts();
-                Users user = new Users();
-                if (!string.IsNullOrEmpty(MakerCode))
+                if (oldpos.BrandId != newpos.BrandId)
                 {
-                    UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
-                    user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
+                    return "新机具和旧机具品牌不相同";
+                }
+
+                var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == newpos.BrandId) ?? new KqProducts();
+                if (brandInfo.Name.Contains("大POS"))
+                {
+                    amount = 300;
+                }
+                if (brandInfo.Name.Contains("电签"))
+                {
+                    amount = 200;
+                }
+                var storehouse = db.StoreHouse.FirstOrDefault(m => m.Id == newpos.StoreId) ?? new StoreHouse();
+                storehouse.LaveNum -= 1;
+                var userAcount = db.UserAccount.FirstOrDefault(m => m.Id == storehouse.UserId) ?? new UserAccount();
+                if (oldpos.StoreId != newpos.StoreId)
+                {
+                    userAcount.ValidAmount += amount;
+                    newpos.StoreId = oldpos.StoreId;
+                    newpos.BuyUserId = oldpos.BuyUserId;
+                    newpos.UserId = oldpos.UserId;
+                    newpos.LeaderUserId = oldpos.LeaderUserId;
+                    newpos.PreUserId = oldpos.PreUserId;
+                    newpos.IsFirst = oldpos.IsFirst;
                 }
                 else
                 {
-                    user = db.Users.FirstOrDefault(m => m.Id == oldpos.UserId) ?? new Users();
+                    newpos.BuyUserId = oldpos.BuyUserId;
+                    newpos.UserId = oldpos.UserId;
+                    newpos.LeaderUserId = oldpos.LeaderUserId;
+                    newpos.PreUserId = oldpos.PreUserId;
+                    newpos.IsFirst = oldpos.IsFirst;
                 }
-                newpos.BuyUserId = oldpos.BuyUserId;
-                newpos.UserId = oldpos.UserId;
-                newpos.RecycEndDate = oldpos.RecycEndDate;
-                newpos.ScanQrTrade = oldpos.ScanQrTrade;
-                newpos.DebitCardTrade = oldpos.DebitCardTrade;
-                newpos.CreditTrade = oldpos.CreditTrade;
-                newpos.PosSnType = oldpos.PosSnType;
-                newpos.TransferTime = oldpos.TransferTime;
-                newpos.IsPurchase = oldpos.IsPurchase;
-                newpos.BindingState = oldpos.BindingState;
-                newpos.ActivationState = oldpos.ActivationState;
-                newpos.BindingTime = oldpos.BindingTime;
-                newpos.ActivationTime = oldpos.ActivationTime;
-                newpos.IsFirst = oldpos.IsFirst;
-                newpos.SeoKeyword = oldpos.SeoKeyword;
-                newpos.PrizeParams = oldpos.PrizeParams;
-                newpos.LeaderUserId = oldpos.LeaderUserId;
-                newpos.IsFirst = oldpos.IsFirst;
-                oldpos.Status = -1;
-                db.MachineChangeDetail.Add(new MachineChangeDetail()
+                db.SaveChanges();
+
+                var oldPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == oldpos.BrandId) ?? new KqProducts();
+                var newPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == newpos.BrandId) ?? new KqProducts();
+                var UserId = 0;
+                if (oldpos.BuyUserId == 0)
+                {
+                    UserId = oldStore.UserId;
+                }
+                else
+                {
+                    UserId = oldpos.BuyUserId;
+                }
+                BrokenMachineChange add = db.BrokenMachineChange.Add(new BrokenMachineChange()
                 {
                     CreateDate = DateTime.Now,
                     CreateMan = SysUserName + "-" + SysRealName,
-                    ChangeNo = ChangeNo, //订单号
-                    ChangeId = add.Id, //订单Id
-                    BackProductType = oldpos.BrandId, //退回产品类型
-                    BackProductName = oldPosBrand.Name, //退回产品名称
-                    UserId = 0, //创客
-                    BackSnNo = oldpos.PosSn, //设备SN编号
-                    OutProductType = newpos.BrandId, //出库产品类型
-                    OutProductName = newPosBrand.Name, //出库产品名称
-                    OutSnNo = newpos.PosSn, //出库设备SN编号
-                    OutSnType = newpos.PosSnType, //出库SN机具类型
-                    Remark = "坏机换新", //备注
-                    BackSnType = oldpos.PosSnType, //退回SN机具类型
-                });
+                    ChangeNo = "BPC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(3), //转换单号
+                    UserId = UserId, //创客
+                }).Entity;
                 db.SaveChanges();
-                BackProductType = oldpos.BrandId;
-                BackProductName = newPosBrand.Name;
-                ChangeDeviceName = oldpos.DeviceName;
-                ChangeSnExpand += oldpos.PosSn + "\n";
-                PublicFunction.SycnMachineCount(oldpos.BuyUserId, oldpos.BrandId);
-            }
-            add.BackProductType = BackProductType; //退回产品类型
-            add.BackProductName = BackProductName; //退回产品名称
-            add.ChangeDeviceName = ChangeDeviceName; //转换机具名称
-            add.ChangeDeviceNum = OldSnList.Length; //转换机具数量
-            add.ChangeSnExpand = ChangeSnExpand; //机具SN
-            BackStore.LaveNum += OldSnList.Length; //退回仓库库存
-            OutStore.LaveNum -= OldSnList.Length; //出货仓库库存
-            db.SaveChanges();
-            db.Dispose();
-            if (IsSend == 1)
-            {
-                RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                BrokenMachineChangeDetail adds = db.BrokenMachineChangeDetail.Add(new BrokenMachineChangeDetail()
                 {
-                    UserId = pos.BuyUserId, //接收创客
-                    MsgType = 2,
-                    Title = "坏机换新成功通知", //标题
-                    Summary = "您的 " + oldPosBrand.Name + " SN:" + OldSn + "已经成功为您换为" + newPosBrand.Name + "SN:" + NewSn + "。",
                     CreateDate = DateTime.Now,
+                    CreateMan = SysUserName + "-" + SysRealName,
+                    OutSnNo = OldSnNum,
+                    BackSnNo = NewSnNum,
+                    ChangeNo = add.ChangeNo, //转换单号
+                    ChangeId = add.Id, //转换记录Id
+                    UserId = add.UserId, //创客
+                }).Entity;
+                db.SaveChanges();
+                if (IsSend == 1)
+                {
+                    RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                    {
+                        UserId = UserId, //接收创客
+                        MsgType = 2,
+                        Title = "坏机换新成功通知", //标题
+                        Summary = "您的坏机 " + oldPosBrand.Name + " SN:" + OldSn + "已经成功为您换为" + newPosBrand.Name + "SN:" + NewSn + "。",
+                        CreateDate = DateTime.Now,
 
-                }));
+                    }));
+                }
             }
             return "success";
         }
+
+        // public string ChangeBadPosDo(string OldSn, string NewSn, string BackStoreNo, string OutStoreNo, string MakerCode = "", int IsSend = 0)
+        // {
+        //     if (string.IsNullOrEmpty(OldSn))
+        //     {
+        //         return "请输入原机具SN";
+        //     }
+        //     if (string.IsNullOrEmpty(NewSn))
+        //     {
+        //         return "请输入新机具SN";
+        //     }
+        //     string[] OldSnList = OldSn.Split('\n');
+        //     string[] NewSnList = NewSn.Split('\n');
+        //     if (OldSnList.Length != NewSnList.Length)
+        //     {
+        //         return "原机具SN数量和新机具SN数量不一致";
+        //     }
+        //     WebCMSEntities db = new WebCMSEntities();
+        //     PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == OldSn);
+        //     StoreForCode storeForBack = db.StoreForCode.FirstOrDefault(m => m.Code == BackStoreNo) ?? new StoreForCode();
+        //     StoreForCode storeForOut = db.StoreForCode.FirstOrDefault(m => m.Code == OutStoreNo) ?? new StoreForCode();
+        //     StoreHouse BackStore = db.StoreHouse.FirstOrDefault(m => m.Id == storeForBack.StoreId) ?? new StoreHouse();
+        //     StoreHouse OutStore = db.StoreHouse.FirstOrDefault(m => m.Id == storeForOut.StoreId) ?? new StoreHouse();
+        //     string ChangeNo = "BPC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(3);
+        //     KqProducts oldPosBrand = new KqProducts();
+        //     KqProducts newPosBrand = new KqProducts();
+        //     MachineChange add = db.MachineChange.Add(new MachineChange()
+        //     {
+        //         CreateDate = DateTime.Now,
+        //         UpdateDate = DateTime.Now,
+        //         CreateMan = SysUserName + "-" + SysRealName,
+        //         ChangeNo = ChangeNo, //转换单号
+        //         UserId = 0, //创客
+        //         ChangeTime = DateTime.Now, //转换时间
+        //         BackStoreId = BackStore.Id, //退回仓库
+        //         BackStoreName = BackStore.StoreName, //退回仓库名称
+        //         Remark = "坏机换新", //订单备注
+        //         BackStoreUserId = BackStore.UserId, //退回仓库归属人
+        //         OutProductType = int.Parse(OutStore.BrandId), //出库产品类型
+        //         OutProductName = OutStore.ProductName, //出库产品名称
+        //         OutStoreId = OutStore.Id, //出库仓库
+        //         OutStoreName = OutStore.StoreName, //出库仓库名称
+        //         OutStoreAreas = OutStore.Areas, //出库仓库所在地区
+        //         OutStoreAddress = OutStore.Address, //出库仓库地址
+        //         OutStoreManager = "", //出库仓库联系人
+        //         OutStoreManagerMobile = OutStore.ManageMobile, //出库仓库联系人手机号
+        //     }).Entity;
+        //     db.SaveChanges();
+        //     int BackProductType = 0;
+        //     string BackProductName = "";
+        //     string ChangeDeviceName = "";
+        //     string ChangeSnExpand = "";
+        //     for (int i = 0; i < OldSnList.Length; i++)
+        //     {
+        //         string OldSnNum = OldSnList[i];
+        //         string NewSnNum = NewSnList[i];
+        //         MachineForSnNo oldForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == OldSnNum) ?? new MachineForSnNo();
+        //         MachineForSnNo newForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == NewSnNum) ?? new MachineForSnNo();
+        //         PosMachinesTwo oldpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == oldForSnNo.SnId);
+        //         if (oldpos == null)
+        //         {
+        //             return "原机具SN不正确";
+        //         }
+        //         PosMachinesTwo newpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == newForSnNo.SnId);
+        //         if (newpos == null)
+        //         {
+        //             return "新机具SN不正确";
+        //         }
+        //         oldPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == oldpos.BrandId) ?? new KqProducts();
+        //         newPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == newpos.BrandId) ?? new KqProducts();
+        //         Users user = new Users();
+        //         if (!string.IsNullOrEmpty(MakerCode))
+        //         {
+        //             UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
+        //             user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
+        //         }
+        //         else
+        //         {
+        //             user = db.Users.FirstOrDefault(m => m.Id == oldpos.UserId) ?? new Users();
+        //         }
+        //         newpos.BuyUserId = oldpos.BuyUserId;
+        //         newpos.UserId = oldpos.UserId;
+        //         newpos.RecycEndDate = oldpos.RecycEndDate;
+        //         newpos.ScanQrTrade = oldpos.ScanQrTrade;
+        //         newpos.DebitCardTrade = oldpos.DebitCardTrade;
+        //         newpos.CreditTrade = oldpos.CreditTrade;
+        //         newpos.PosSnType = oldpos.PosSnType;
+        //         newpos.TransferTime = oldpos.TransferTime;
+        //         newpos.IsPurchase = oldpos.IsPurchase;
+        //         newpos.BindingState = oldpos.BindingState;
+        //         newpos.ActivationState = oldpos.ActivationState;
+        //         newpos.BindingTime = oldpos.BindingTime;
+        //         newpos.ActivationTime = oldpos.ActivationTime;
+        //         newpos.IsFirst = oldpos.IsFirst;
+        //         newpos.SeoKeyword = oldpos.SeoKeyword;
+        //         newpos.PrizeParams = oldpos.PrizeParams;
+        //         newpos.LeaderUserId = oldpos.LeaderUserId;
+        //         newpos.IsFirst = oldpos.IsFirst;
+        //         oldpos.Status = -1;
+        //         db.MachineChangeDetail.Add(new MachineChangeDetail()
+        //         {
+        //             CreateDate = DateTime.Now,
+        //             CreateMan = SysUserName + "-" + SysRealName,
+        //             ChangeNo = ChangeNo, //订单号
+        //             ChangeId = add.Id, //订单Id
+        //             BackProductType = oldpos.BrandId, //退回产品类型
+        //             BackProductName = oldPosBrand.Name, //退回产品名称
+        //             UserId = 0, //创客
+        //             BackSnNo = oldpos.PosSn, //设备SN编号
+        //             OutProductType = newpos.BrandId, //出库产品类型
+        //             OutProductName = newPosBrand.Name, //出库产品名称
+        //             OutSnNo = newpos.PosSn, //出库设备SN编号
+        //             OutSnType = newpos.PosSnType, //出库SN机具类型
+        //             Remark = "坏机换新", //备注
+        //             BackSnType = oldpos.PosSnType, //退回SN机具类型
+        //         });
+        //         db.SaveChanges();
+        //         BackProductType = oldpos.BrandId;
+        //         BackProductName = newPosBrand.Name;
+        //         ChangeDeviceName = oldpos.DeviceName;
+        //         ChangeSnExpand += oldpos.PosSn + "\n";
+        //         PublicFunction.SycnMachineCount(oldpos.BuyUserId, oldpos.BrandId);
+        //     }
+        //     add.BackProductType = BackProductType; //退回产品类型
+        //     add.BackProductName = BackProductName; //退回产品名称
+        //     add.ChangeDeviceName = ChangeDeviceName; //转换机具名称
+        //     add.ChangeDeviceNum = OldSnList.Length; //转换机具数量
+        //     add.ChangeSnExpand = ChangeSnExpand; //机具SN
+        //     BackStore.LaveNum += OldSnList.Length; //退回仓库库存
+        //     OutStore.LaveNum -= OldSnList.Length; //出货仓库库存
+        //     db.SaveChanges();
+        //     db.Dispose();
+        //     if (IsSend == 1)
+        //     {
+        //         RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+        //         {
+        //             UserId = pos.BuyUserId, //接收创客
+        //             MsgType = 2,
+        //             Title = "坏机换新成功通知", //标题
+        //             Summary = "您的 " + oldPosBrand.Name + " SN:" + OldSn + "已经成功为您换为" + newPosBrand.Name + "SN:" + NewSn + "。",
+        //             CreateDate = DateTime.Now,
+
+        //         }));
+        //     }
+        //     return "success";
+        // }
         #endregion
 
 
@@ -1853,46 +1971,47 @@ namespace MySystem.Areas.Admin.Controllers
             ViewBag.SwapSnExpand = SwapSnExpand;
             ViewBag.SnNos = SnNos;
 
-            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
-            var machineApplie = db.MachineApply.Where(m => m.Status > -1).ToList();
+            // List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+            // var machineApplie = db.MachineApply.Where(m => m.Status > -1).ToList();
 
-            if (!string.IsNullOrEmpty(SwapSnExpand))
-            {
-                machineApplie = db.MachineApply.Where(m => m.Status > -1 && m.SwapSnExpand.Contains(SwapSnExpand)).ToList();
-                foreach (var item in machineApplie)
-                {
-                    var orders = db.Orders.FirstOrDefault(m => m.Sort == item.Id && m.Id == item.QueryCount);
-                    Dictionary<string, object> data = new Dictionary<string, object>();
-                    data["ApplyNo"] = item.ApplyNo.ToString();
-                    data["OrderNo"] = orders.OrderNo.ToString();
-                    data["MakerCode"] = item.ApplyNo.ToString();
-                    data["RealName"] = item.ApplyNo.ToString();
-                    data["ComeSn"] = item.ApplyNo.ToString();
-                    data["SendSn"] = item.ApplyNo.ToString();
-                    data["CreateDate"] = item.ApplyNo.ToString();
-                    data["Status"] = item.ApplyNo.ToString();
-                    dataList.Add(data);
-                }
-            }
-            if (!string.IsNullOrEmpty(SnNos))
-            {
-                machineApplie = db.MachineApply.Where(m => m.Status > -1 && m.SwapSnExpand.Contains(SnNos)).ToList();
-                foreach (var item in machineApplie)
-                {
-                    var orders = db.Orders.FirstOrDefault(m => m.Sort == item.Id && m.Id == item.QueryCount);
-                    Dictionary<string, object> data = new Dictionary<string, object>();
-                    data["ApplyNo"] = item.ApplyNo.ToString();
-                    data["OrderNo"] = orders.OrderNo.ToString();
-                    data["MakerCode"] = item.ApplyNo.ToString();
-                    data["RealName"] = item.ApplyNo.ToString();
-                    data["ComeSn"] = item.ApplyNo.ToString();
-                    data["SendSn"] = item.ApplyNo.ToString();
-                    data["CreateDate"] = item.ApplyNo.ToString();
-                    data["Status"] = item.ApplyNo.ToString();
-                    dataList.Add(data);
-                }
-            }
-            return View(dataList);
+            // if (!string.IsNullOrEmpty(SwapSnExpand))
+            // {
+            //     machineApplie = db.MachineApply.Where(m => m.Status > -1 && m.SwapSnExpand.Contains(SwapSnExpand)).ToList();
+            //     foreach (var item in machineApplie)
+            //     {
+            //         var orders = db.Orders.FirstOrDefault(m => m.Sort == item.Id && m.Id == item.QueryCount);
+            //         Dictionary<string, object> data = new Dictionary<string, object>();
+            //         data["ApplyNo"] = item.ApplyNo.ToString();
+            //         data["OrderNo"] = orders.OrderNo.ToString();
+            //         data["MakerCode"] = item.ApplyNo.ToString();
+            //         data["RealName"] = item.ApplyNo.ToString();
+            //         data["ComeSn"] = item.ApplyNo.ToString();
+            //         data["SendSn"] = item.ApplyNo.ToString();
+            //         data["CreateDate"] = item.ApplyNo.ToString();
+            //         data["Status"] = item.ApplyNo.ToString();
+            //         dataList.Add(data);
+            //     }
+            // }
+            // if (!string.IsNullOrEmpty(SnNos))
+            // {
+            //     machineApplie = db.MachineApply.Where(m => m.Status > -1 && m.SwapSnExpand.Contains(SnNos)).ToList();
+            //     foreach (var item in machineApplie)
+            //     {
+            //         var orders = db.Orders.FirstOrDefault(m => m.Sort == item.Id && m.Id == item.QueryCount);
+            //         Dictionary<string, object> data = new Dictionary<string, object>();
+            //         data["ApplyNo"] = item.ApplyNo.ToString();
+            //         data["OrderNo"] = orders.OrderNo.ToString();
+            //         data["MakerCode"] = item.ApplyNo.ToString();
+            //         data["RealName"] = item.ApplyNo.ToString();
+            //         data["ComeSn"] = item.ApplyNo.ToString();
+            //         data["SendSn"] = item.ApplyNo.ToString();
+            //         data["CreateDate"] = item.ApplyNo.ToString();
+            //         data["Status"] = item.ApplyNo.ToString();
+            //         dataList.Add(data);
+            //     }
+            // }
+            // return View(dataList);
+            return View();
         }
 
         #endregion
@@ -1904,8 +2023,7 @@ namespace MySystem.Areas.Admin.Controllers
         /// </summary>
         /// <returns></returns>
 
-        [HttpPost]
-        public JsonResult LoopData(string SwapSnExpand, string SnNos, int page = 1, int limit = 30)
+        public IActionResult LoopData(string SwapSnExpand, string SnNos, int page = 1, int limit = 30)
         {
             Dictionary<string, string> Fields = new Dictionary<string, string>();
             Fields.Add("SwapSnExpand", "1"); //申请机具SN
@@ -1954,20 +2072,56 @@ namespace MySystem.Areas.Admin.Controllers
                 machineApplie = db.MachineApply.Where(m => m.Status > -1).ToList();
                 foreach (var item in machineApplie)
                 {
-                    var orders = db.Orders.FirstOrDefault(m => m.Sort == item.Id && m.Id == item.QueryCount);
+                    var orders = db.Orders.FirstOrDefault(m => m.Sort == item.Id && m.Id == item.QueryCount) ?? new Orders();
+                    var user = db.Users.FirstOrDefault(m => m.Id == item.UserId) ?? new Users();
                     Dictionary<string, object> data = new Dictionary<string, object>();
                     data["ApplyNo"] = item.ApplyNo.ToString();
-                    data["OrderNo"] = orders.OrderNo.ToString();
-                    data["MakerCode"] = item.ApplyNo.ToString();
-                    data["RealName"] = item.ApplyNo.ToString();
-                    data["ComeSn"] = item.ApplyNo.ToString();
-                    data["SendSn"] = item.ApplyNo.ToString();
-                    data["CreateDate"] = item.ApplyNo.ToString();
-                    data["Status"] = item.ApplyNo.ToString();
+                    if (!string.IsNullOrEmpty(orders.OrderNo))
+                    {
+                        data["OrderNo"] = orders.OrderNo.ToString();
+                    }
+                    if (string.IsNullOrEmpty(orders.OrderNo))
+                    {
+                        data["OrderNo"] = "";
+                    }
+                    if (!string.IsNullOrEmpty(orders.SnNos))
+                    {
+                        data["SendSn"] = orders.SnNos.ToString();
+                    }
+                    if (string.IsNullOrEmpty(orders.SnNos))
+                    {
+                        data["SendSn"] = "";
+                    }
+                    if (!string.IsNullOrEmpty(user.MakerCode))
+                    {
+                        data["MakerCode"] = user.MakerCode.ToString();
+                    }
+                    if (string.IsNullOrEmpty(user.MakerCode))
+                    {
+                        data["MakerCode"] = "";
+                    }
+                    if (!string.IsNullOrEmpty(user.RealName))
+                    {
+                        data["RealName"] = user.RealName.ToString();
+                    }
+                    if (string.IsNullOrEmpty(user.RealName))
+                    {
+                        data["RealName"] = "";
+                    }
+                    data["ComeSn"] = item.SwapSnExpand.ToString();
+                    data["CreateDate"] = item.CreateDate.ToString();
+                    if (item.ApplyNo.ToString() == "0")
+                    {
+                        data["Status"] = "待处理";
+                    }
+                    if (item.ApplyNo.ToString() == "1")
+                    {
+                        data["Status"] = "成功";
+                    }
                     dataList.Add(data);
                 }
             }
-
+            dataList = dataList.Skip((page - 1) * limit).Take(limit).ToList();//分页的重点
             return Json(dataList);
         }
 

+ 5 - 0
Areas/Admin/Controllers/MainServer/UserAccountRecordController.cs

@@ -124,6 +124,11 @@ namespace MySystem.Areas.Admin.Controllers
                 dic["ProductTypeName"] = RelationClass.GetKqProductBrandInfo(ProductType);
                 int ChangeType = int.Parse(dic["ChangeType"].ToString());
                 dic["ChangeTypeName"] = RelationClassForConst.GetChangeTypeInfo(ChangeType);
+                
+                //获得盟主5元奖励的机具Sn
+                int SnId = int.Parse(dic["QueryCount"].ToString());
+                PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnId) ?? new PosMachinesTwo();
+                dic["PosSn"] = pos.PosSn;
             }
             Dictionary<string, object> other = new Dictionary<string, object>();
             

+ 203 - 0
Areas/Admin/Views/MainServer/PosMachinesTwoChange/Add.cshtml

@@ -0,0 +1,203 @@
+@{
+    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>
+                </ul>
+                <div class="layui-tab-content mt20">
+                    <div class="layui-tab-item layui-show">
+
+</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>

+ 215 - 0
Areas/Admin/Views/MainServer/PosMachinesTwoChange/Edit.cshtml

@@ -0,0 +1,215 @@
+@using MySystem.Models;
+@{PosMachinesTwo editData = ViewBag.data as PosMachinesTwo;}
+@{
+    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" />
+        
+        <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>
+                </ul>
+                <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">
+                                <select id="PosSnType" name="PosSnType" lay-search="">
+                                    <option value=""></option>
+                                    <option value="0">购买机</option>
+                                    <option value="1">赠送机</option>
+                                </select>
+                                <script>$("#PosSnType").val("@editData.PosSnType");</script>
+                            </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>

+ 157 - 0
Areas/Admin/Views/MainServer/PosMachinesTwoChange/Index.cshtml

@@ -0,0 +1,157 @@
+@{
+    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" name="UserIdMakerCode" 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="UserIdRealName" 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="StoreIdCode" 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="StoreIdName" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">SN编号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="PosSn" placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">绑定状态</label>
+                        <div class="layui-input-inline">
+                            <select id="BindingStateSelect" name="BindingStateSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="0">未绑定</option>
+                                <option value="1">已绑定</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">激活状态</label>
+                        <div class="layui-input-inline">
+                            <select id="ActivationStateSelect" name="ActivationStateSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="0">未激活</option>
+                                <option value="1">已激活</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">激活时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="ActivationDateData" id="ActivationTime"
+                                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" readonly name="BindingDateData" id="BindingTime"
+                                placeholder="绑定时间" autocomplete="off">
+                        </div>
+                    </div>
+                    @{Dictionary<string, string> ProfitObjectsActivesDic = new MySystem.DictionaryClass().getKqProductBrandDic();}
+                    <div class="layui-inline">
+                        <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 ProfitObjectsActivesDic.Keys)
+                                {
+                                <option value="@key">@ProfitObjectsActivesDic[key]</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>
+                        @if (RightInfo.Contains("," + right + "_export,"))
+                        {
+                        <button class="layui-btn" data-type="ExportExcel"><i class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
+                        }
+                    </div>
+                </div>
+            </div>
+
+            <div class="layui-card-body">
+                <blockquote class="layui-elem-quote layui-text">
+                    总机具(台):<span style="color: #f00;" id="TotalCount">0</span>
+                </blockquote>
+                <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 + "_Home,"))
+                    {
+                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="home"><i class="layui-icon layui-icon-edit"></i>一键归位</a>
+                    }
+                </script>
+            </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script src="/layuiadmin/modules_main/PosMachinesTwoChange_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script>
+        
+    </script>
+</body>
+</html>

+ 3 - 3
Areas/Admin/Views/MainServer/StoreHouse/Import.cshtml

@@ -49,10 +49,10 @@
                                 {
                                 <a href="/users/客小爽仓库发货至创客模版.xlsx">点击下载仓库发货至创客模版</a>
                                 }
-                                @if(ExcelKind == "4")
+                                @* @if(ExcelKind == "4")
                                 {
-                                <a href="/users/客小爽机具驳回仓库模版.xlsx">点击下载机具驳回仓库模版</a>
-                                }
+                                <a href="/users/客机具驳回仓库.xlsx">点击下载创客机具驳回仓库模版</a>
+                                } *@
                             </div>
                         </div>
                         <div class="layui-form-item">

+ 4 - 0
Areas/Admin/Views/MainServer/StoreHouse/Index.cshtml

@@ -154,6 +154,10 @@
                             class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>仓库发货至创客</button>
                         @* <button class="layui-btn" data-type="ImportBack"><i class="layui-icon layui-icon-upload
                             layuiadmin-button-btn"></i>机具回仓库</button> *@
+
+                    }
+                    @if (RightInfo.Contains("," + right + "_import4,") || RightInfo.Contains("," + right + "_import,"))
+                    {
                         <button class="layui-btn" data-type="ImportRejectStore"><i
                             class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>机具驳回仓库</button>
 

+ 13 - 0
Areas/Admin/Views/MainServer/StoreHouseAmountRecord/Index.cshtml

@@ -73,6 +73,19 @@
                             </select>
                         </div>
                     </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">变动类别</label>
+                        <div class="layui-input-inline">
+                            <select id="AmountTypeSelect" name="AmountTypeSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="0">购买临时额度</option>
+                                <option value="1">增减分仓临时额度</option>
+                                <option value="1">调低额度返回余额</option>
+                                <option value="1">仓库发货,预发机申请</option>
+                                <option value="1">后台仓库调拨</option>
+                            </select>
+                        </div>
+                    </div>
                     <div class="layui-inline">
                         <label class="layui-form-label">操作类别</label>
                         <div class="layui-input-inline">

+ 4 - 4
Areas/Admin/Views/MainServer/SysTools/ChangeBadPos.cshtml

@@ -34,16 +34,16 @@
                                     <label class="layui-form-label">原机具SN</label>
                                     <div class="layui-input-block">
                                         <textarea class="layui-textarea" lay-verify="required|" name="OldSn" id="OldSn"
-                                            placeholder="请输入原机具SN,多个SN用回车隔开"></textarea>
+                                            placeholder="请输入原机具SN"></textarea>
                                     </div>
                                 </div>
                                 <div class="layui-form-item">
                                     <label class="layui-form-label">新机具SN</label>
                                     <div class="layui-input-block">
                                         <textarea class="layui-textarea" lay-verify="required|" name="NewSn" id="NewSn"
-                                            placeholder="请输入新机具SN,多个SN用回车隔开"></textarea>
+                                            placeholder="请输入新机具SN"></textarea>
                                     </div>
-                                </div>
+                                @* </div>
                                 <div class="layui-form-item">
                                     <label class="layui-form-label">退回仓库编号</label>
                                     <div class="layui-input-inline">
@@ -66,7 +66,7 @@
                                         <input class="layui-input" type="text" id="MakerCode" name="MakerCode" maxlength="50"
                                             autocomplete="off" placeholder="请输入创客编号">
                                     </div>
-                                </div>
+                                </div> *@
                                 <div class="layui-form-item">
                                     <label class="layui-form-label">是否推送消息</label>
                                     <div class="layui-input-block">

+ 1 - 0
Areas/Admin/Views/MainServer/UserAccountRecord/Index.cshtml

@@ -109,6 +109,7 @@
                                 <option value="60">流量卡分佣</option>
                                 <option value="111">分润补贴</option>
                                 <option value="112">直推奖励</option>
+                                <option value="116">大盟主奖励</option>
                             </select>
                         </div>
                     </div>

+ 0 - 8
wwwroot/layuiadmin/modules_main/Loop_Admin.js

@@ -1,11 +1,3 @@
-/*
- * @Author: DuGuYang 2731498193@qq.com
- * @Date: 2022-09-19 11:13:43
- * @LastEditors: DuGuYang 2731498193@qq.com
- * @LastEditTime: 2022-09-22 15:26:37
- * @FilePath: /admin-server/wwwroot/layuiadmin/modules_main/SysTools_Admin.js
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
 var ExcelData, ExcelKind;
 
 function ConfirmImport() {

+ 478 - 0
wwwroot/layuiadmin/modules_main/PosMachinesTwoChange_Admin.js

@@ -0,0 +1,478 @@
+var ExcelData, ExcelKind;
+function ConfirmImport() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/PosMachinesTwoChange/Import?r=" + Math.random(1),
+        data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            } else if (data.indexOf("warning") == 0) {
+                var datalist = data.split('|');
+                layer.alert(datalist[0], { time: 20000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
+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: '#ActivationTime',
+        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) {
+                $('#ActivationTime').val(value);
+            }
+        }
+    });
+
+    //- 筛选条件-日期
+    var laydates = layui.laydate;
+    var layCreateDate = laydates.render({
+        elem: '#BindingTime',
+        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) {
+                $('#BindingTime').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/PosMachinesTwo/Sort?r=" + Math.random(1),
+                data: "Id=" + data.Id + "&Sort=" + value,
+                dataType: "text",
+                success: function (data) {
+                }
+            });
+        }
+    });
+    
+    //列表数据
+    table.render({
+        elem: '#LAY-list-manage'
+        , url: '/Admin/PosMachinesTwoChange/IndexData' //模拟接口
+        , cols: [[
+            { type: 'checkbox', fixed: 'left' }
+            ,{field:'PosSn', width: 200, title:'SN编号', sort: true}
+            ,{field:'BrandId', width: 200, title:'产品类型', sort: true}
+            ,{field:'StoreIdCode', width: 200, title:'所在仓库编号', sort: true}
+            ,{field:'StoreIdName', width: 200, title:'所在仓库名称', sort: true}
+            ,{field:'UserIdMakerCode', width: 200, title:'创客编号', sort: true}
+            ,{field:'UserIdRealName', width: 200, title:'创客姓名', sort: true}
+            ,{field:'BindMerchantIdMerchantNo', width: 200, title:'绑定商户编号', sort: true}
+            ,{field:'BindMerchantIdMerchantName', width: 200, title:'绑定商户姓名', sort: true}
+            ,{field:'PosSnType', width: 200, title:'机具类型', sort: true}
+            ,{field:'DeviceType', width: 200, title:'设备类型', sort: true}
+            ,{field:'BindingState', width: 200, title:'绑定状态', sort: true}
+            ,{ field: 'ActivationState', width: 200, title: '激活状态', sort: true }
+            ,{ field: 'ActivationTime', width: 200, title: '激活时间', sort: true }
+            ,{ field: 'BindingTime', width: 200, title: '绑定时间', sort: true }
+            ,{ field: 'TransferTime', width: 200, title: '划拨时间', sort: true }
+            ,{ field: 'RecycStartDate', width: 200, title: '循环开始时间', sort: true }
+            ,{ field: 'RecycEndDate', width: 200, title: '循环截止时间', sort: true }
+            ,{ field: 'UserInfo', width: 200, title: '大盟主券标记', sort: true }
+            ,{ field: 'IsFirst', width: 200, title: '是否第一台机具', sort: true }
+            ,{ field: 'SeoKeyword', width: 200, title: '押金金额', sort: true }
+            ,{ title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#table-list-tools' }
+        ]]
+        , where: {
+            
+        }
+        , page: true
+        , limit: 30
+        , height: 'full-' + String($('.layui-card-header').height() + 130)
+        , text: '对不起,加载出现异常!'
+        , done: function (res, curr, count) {
+            $("#TotalCount").text(res.other.TotalCount);
+            $("#KysCount99").text(res.other.KysCount99);
+            $("#KssCount99").text(res.other.KssCount99);
+            $("#KssCoun198").text(res.other.KssCoun198);
+            $("#KssCount298").text(res.other.KssCount298);
+            $(".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/PosMachinesTwo/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);
+
+                    
+                    
+                    
+                    
+
+                    //监听提交
+                    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/PosMachinesTwo/Edit?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');
+                }
+                , success: function (layero, index) {
+
+                }
+            });
+            layer.full(perContent);
+        }
+    });
+
+
+    //监听搜索
+    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/PosMachinesTwo/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/PosMachinesTwo/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);
+        }
+        , RejectStore: function () {
+            ExcelKind = 1;
+            layer.open({
+                type: 1,
+                title: '机具驳回仓库导入',
+                maxmin: false,
+                area: ['460px', '280px'],
+                content: $('#excelForm'),
+                cancel: function () {
+                }
+            });
+            $("#excelTemp").html('<a href="/users/机具驳回仓库模版.xlsx">点击下载机具驳回仓库模版</a>');
+        }
+        , 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()) + '&';
+            });
+            var index = layer.load(1, {
+                shade: [0.5, '#000']
+            });
+            $.ajax({
+                type: "GET",
+                url: "/Admin/PosMachinesTwo/ExportExcel?r=" + Math.random(1),
+                data: userdata,
+                dataType: "json",
+                success: function (data) {
+                    data.Obj.unshift(data.Fields);
+                    excel.exportExcel(data.Obj, data.Info, 'xlsx');
+                    layer.close(index);
+                }
+            });
+        }
+        , 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/PosMachinesTwo/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/PosMachinesTwo/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) : '';
+    });
+});

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

@@ -141,6 +141,7 @@ layui.config({
             ,{ field: 'ActivationTime', width: 200, title: '激活时间', sort: true }
             ,{ field: 'BindingTime', width: 200, title: '绑定时间', sort: true }
             ,{ field: 'TransferTime', width: 200, title: '划拨时间', sort: true }
+            ,{ field: 'RecycStartDate', width: 200, title: '循环开始时间', sort: true }
             ,{ field: 'RecycEndDate', width: 200, title: '循环截止时间', sort: true }
             ,{ field: 'UserInfo', width: 200, title: '大盟主券标记', sort: true }
             ,{ field: 'IsFirst', width: 200, title: '是否第一台机具', sort: true }

+ 1 - 0
wwwroot/layuiadmin/modules_main/StoreHouseAmountRecord_Admin.js

@@ -100,6 +100,7 @@ layui.config({
             , { field: 'BeforeAmount', width: 200, title: '使用前剩余额度', sort: true }
             , { field: 'AfterAmount', width: 200, title: '使用后剩余额度', sort: true }
             , { field: 'AmountType', width: 200, title: '额度类别', sort: true }
+            , { field: 'ChangeType', width: 200, title: '变动类别', sort: true }
             , { field: 'OperateType', width: 200, title: '操作类别', sort: true }
 
             , { field: 'Sort', fixed: 'right', title: '排序', width: 80, edit: 'text' }

+ 4 - 3
wwwroot/layuiadmin/modules_main/StoreHouse_Admin.js

@@ -27,7 +27,7 @@ function ConfirmImport() {
 function ConfirmRejectImport() {
     $.ajax({
         type: "POST",
-        url: "/Admin/Users/RejectStore?r=" + Math.random(1),
+        url: "/Admin/StoreHouse/RejectStore?r=" + Math.random(1),
         data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
         dataType: "text",
         success: function (data) {
@@ -158,7 +158,7 @@ layui.config({
             [{
                 type: 'checkbox',
                 fixed: 'left'
-            },{
+            }, {
                 field: 'StoreNo',
                 width: 110,
                 title: '仓库编号',
@@ -773,11 +773,12 @@ layui.config({
                 title: '导入',
                 maxmin: false,
                 area: ['650px', '350px'],
+                // btn: ['确定', '取消'],
                 content: $('#excelForm'),
                 cancel: function () {
                 }
             });
-            $("#excelTemp").html('<a href="/users/机具驳回仓库模版.xlsx">点击下载机具驳回仓库模版</a>');
+            $("#excelTemp").html('<a href="/users/创客机具驳回仓库模版.xlsx">点击下载创客机具驳回仓库模版</a>');
         },
         ExportExcel: function () {
             var userdata = '';

+ 66 - 65
wwwroot/layuiadmin/modules_main/UserAccountRecord_Admin.js

@@ -31,49 +31,49 @@ layui.config({
     //- 筛选条件-日期
     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);
-}
-}
-});
+        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;        
+    excel = layui.excel;
     $('#ExcelFile').change(function (e) {
         var files = e.target.files;
-        excel.importExcel(files, { }, function (data) {
+        excel.importExcel(files, {}, function (data) {
             ExcelData = data[0].sheet1;
         });
     });
 
     //监听单元格编辑
-    table.on('edit(LAY-list-manage)', function(obj){
+    table.on('edit(LAY-list-manage)', function (obj) {
         var value = obj.value //得到修改后的值
-        ,data = obj.data //得到所在行所有键值
-        ,field = obj.field; //得到字段
-        if(field == "Sort"){
+            , data = obj.data //得到所在行所有键值
+            , field = obj.field; //得到字段
+        if (field == "Sort") {
             $.ajax({
                 type: "POST",
                 url: "/Admin/UserAccountRecord/Sort?r=" + Math.random(1),
@@ -84,29 +84,30 @@ $('#CreateDate').val(value);
             });
         }
     });
-    
+
     //列表数据
     table.render({
         elem: '#LAY-list-manage'
         , url: '/Admin/UserAccountRecord/IndexData' //模拟接口
         , cols: [[
             { type: 'checkbox', fixed: 'left' }
-            ,{field:'MakerCode', width: 105, title:'创客编号', sort: true}
-            ,{field:'RealName', width: 105, title:'创客姓名', sort: true}
+            , { field: 'MakerCode', width: 105, title: '创客编号', sort: true }
+            , { field: 'RealName', width: 105, title: '创客姓名', sort: true }
             // ,{field:'TopMakerCode', width: 200, title:'顶级创客编号', sort: true}
             // ,{field:'TopRealName', width: 200, title:'顶级创客名称', sort: true}
-            ,{field:'ProductTypeName', width: 105, title:'产品类型', sort: true}
+            , { field: 'ProductTypeName', width: 105, title: '产品类型', sort: true }
             // ,{field:'TransRecordNo', width: 200, title:'交易流水编号', sort: true}
-            ,{field:'ChangeTypeName', width: 110, title:'交易类型', sort: true}
-            ,{field:'ChangeAmount', width: 110, title:'交易金额', sort: true}
-            ,{field:'Remark', width: 100, title:'备注', sort: true}
-            ,{field:'BeforeTotalAmount', width: 130, title:'交易前总金额', sort: true}
-            ,{field:'AfterTotalAmount', width: 130, title:'交易后总金额', sort: true}
-            ,{field:'BeforeFreezeAmount', width: 150, title:'交易前冻结金额', sort: true}
-            ,{field:'AfterFreezeAmount', width: 150, title:'交易后冻结金额', sort: true}
-            ,{field:'BeforeBalanceAmount', width: 120, title:'交易前余额', sort: true}
-            ,{field:'AfterBalanceAmount', width: 120, title:'交易后余额', sort: true}
-            ,{field:'CreateDate', width: 110, title:'交易时间', sort: true}
+            , { field: 'ChangeTypeName', width: 110, title: '交易类型', sort: true }
+            , { field: 'ChangeAmount', width: 110, title: '交易金额', sort: true }
+            , { field: 'Remark', width: 100, title: '备注', sort: true }
+            , { field: 'BeforeTotalAmount', width: 130, title: '交易前总金额', sort: true }
+            , { field: 'AfterTotalAmount', width: 130, title: '交易后总金额', sort: true }
+            , { field: 'BeforeFreezeAmount', width: 150, title: '交易前冻结金额', sort: true }
+            , { field: 'AfterFreezeAmount', width: 150, title: '交易后冻结金额', sort: true }
+            , { field: 'BeforeBalanceAmount', width: 120, title: '交易前余额', sort: true }
+            , { field: 'AfterBalanceAmount', width: 120, title: '交易后余额', sort: true }
+            , { field: 'CreateDate', width: 110, title: '交易时间', sort: true }
+            , { field: 'PosSn', width: 110, title: '机具Sn', sort: true }
         ]]
         , where: {
             UserId: UserId
@@ -147,7 +148,7 @@ $('#CreateDate').val(value);
                     data: "Id=" + data.Id,
                     dataType: "text",
                     success: function (data) {
-                        if (data == "success") {                            
+                        if (data == "success") {
                             obj.del();
                             layer.close(index);
                         } else {
@@ -170,20 +171,20 @@ $('#CreateDate').val(value);
                         , submitID = 'LAY-list-front-submit'
                         , submit = layero.find('iframe').contents().find('#' + submitID);
 
-                    setTimeout(function () { 
+                    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) {
@@ -194,7 +195,7 @@ $('#CreateDate').val(value);
                         }
                         //提交 Ajax 成功后,静态更新表格中的数据
                         //$.ajax({});
-                        
+
                         $.ajax({
                             type: "POST",
                             url: "/Admin/UserAccountRecord/Edit?r=" + Math.random(1),
@@ -283,20 +284,20 @@ $('#CreateDate').val(value);
                         , submitID = 'LAY-list-front-submit'
                         , submit = layero.find('iframe').contents().find('#' + submitID);
 
-                    setTimeout(function () { 
+                    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) {
@@ -307,7 +308,7 @@ $('#CreateDate').val(value);
                         }
                         //提交 Ajax 成功后,静态更新表格中的数据
                         //$.ajax({});
-                        
+
                         $.ajax({
                             type: "POST",
                             url: "/Admin/UserAccountRecord/Add?r=" + Math.random(1),
@@ -362,9 +363,9 @@ $('#CreateDate').val(value);
         , Open: function () {
             var checkStatus = table.checkStatus('LAY-list-manage')
                 , data = checkStatus.data; //得到选中的数据
-            if(data.length < 1){
+            if (data.length < 1) {
                 parent.layer.msg("请选择要开启的项");
-            }else{
+            } else {
                 var ids = "";
                 $.each(data, function (index, value) {
                     ids += data[index].Id + ",";
@@ -391,9 +392,9 @@ $('#CreateDate').val(value);
         , Close: function () {
             var checkStatus = table.checkStatus('LAY-list-manage')
                 , data = checkStatus.data; //得到选中的数据
-            if(data.length < 1){
+            if (data.length < 1) {
                 parent.layer.msg("请选择要关闭的项");
-            }else{
+            } else {
                 var ids = "";
                 $.each(data, function (index, value) {
                     ids += data[index].Id + ",";

BIN
wwwroot/users/创客机具驳回仓库模版.xlsx