Browse Source

Merge branch 'DuGuYang' into feature-dgy-后台优化

DuGuYang 3 years ago
parent
commit
6988600f6f

+ 10 - 0
AppStart/ExcelHelper.cs

@@ -778,6 +778,7 @@ namespace MySystem
                                     {
                                         Size = list.Rows.Count - DoCount;
                                     }
+                                    List<string> opData = new List<string>();
                                     for (int i = DoCount; i < DoCount + Size; i++)
                                     {
                                         DataRow dr = list.Rows[i];
@@ -821,6 +822,10 @@ namespace MySystem
                                                     if (machine.Id > 0)
                                                     {
                                                         function.WriteLog(DateTime.Now.ToString() + "\n" + Newtonsoft.Json.JsonConvert.SerializeObject(machine), "机具回仓库日志");
+                                                        if(!opData.Contains(machine.BuyUserId + ":" + machine.BrandId))
+                                                        {
+                                                            opData.Add(machine.BuyUserId + ":" + machine.BrandId);
+                                                        }
                                                         machine.StoreId = tostorefor.StoreId;
                                                         machine.BuyUserId = 0;
                                                         machine.UserId = 0;
@@ -955,6 +960,11 @@ namespace MySystem
                                         db.SaveChanges();
                                     }
                                     db.SaveChanges();
+                                    foreach(string sub in opData)
+                                    {
+                                        string[] datalist = sub.Split(":");
+                                        PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
+                                    }
                                     tran.Commit();
                                     RedisDbconn.Instance.Set("CheckImport:" + checkKey, "success|" + SuccessCount);
                                     RedisDbconn.Instance.SetExpire("CheckImport:" + checkKey, 60000);

+ 42 - 13
AppStart/PublicFunction.cs

@@ -419,22 +419,39 @@ namespace MySystem
 
         public static void SycnMachineCount(int Id = 0, int BrandId = 0)
         {
-            WebCMSEntities dbnew = new WebCMSEntities();
-            string IdBrand = Id + "_" + BrandId;
-            UserMachineData machineData = dbnew.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
-            if (machineData == null)
+            RedisDbconn.Instance.AddList("SycnUserMachineCountQueue", "{\"UserId\":\"" + Id + "\",\"BrandId\":\"" + BrandId + "\"}");
+        }
+
+        #endregion
+
+        #region 统计机具绑定数据
+
+        public static void StatUserMachineData(int UserId, int BrandId, int Count)
+        {
+            using (WebCMSEntities db = new WebCMSEntities())
             {
-                machineData = dbnew.UserMachineData.Add(new UserMachineData()
+                string IdBrand = UserId + "_" + BrandId;
+                UserMachineData MachineData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
+                if (MachineData == null)
                 {
-                    IdBrand = IdBrand
-                }).Entity;
-                dbnew.SaveChanges();
+                    MachineData = db.UserMachineData.Add(new UserMachineData()
+                    {
+                        IdBrand = IdBrand,
+                    }).Entity;
+                    db.SaveChanges();
+                }
+                if(Count < 0)
+                {
+                    MachineData.TotalMachineCount -= Math.Abs(Count);
+                    MachineData.UnBindCount -= Math.Abs(Count);
+                }
+                else
+                {
+                    MachineData.TotalMachineCount += Count;
+                    MachineData.UnBindCount += Count;
+                }
+                db.SaveChanges();
             }
-            machineData.BindCount = dbnew.PosMachinesTwo.Count(m => m.Status > -1 && m.BuyUserId == Id && m.BrandId == BrandId && m.BindingState == 1);
-            machineData.UnBindCount = dbnew.PosMachinesTwo.Count(m => m.Status > -1 && m.BuyUserId == Id && m.BrandId == BrandId && m.BindingState == 0);
-            machineData.TotalMachineCount = machineData.BindCount + machineData.UnBindCount;
-            dbnew.SaveChanges();
-            dbnew.Dispose();
         }
 
         #endregion
@@ -448,6 +465,17 @@ namespace MySystem
             {
                 prepos.Status = -1;
                 prepos.ApplyFlag = 0;
+                SmallStoreHouse sstore = db.SmallStoreHouse.FirstOrDefault(m => m.UserId == prepos.ToUserId);
+                if(sstore != null)
+                {
+                    sstore.LaveNum += 1;
+                    sstore.TotalNum -= 1;
+                }
+                StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.UserId == prepos.FromStoreId);
+                if(store != null)
+                {
+                    store.LaveNum += 1;
+                }
                 // db.SaveChanges();
             }
             MachineApply apply = db.MachineApply.FirstOrDefault(m => m.SwapSnExpand.Contains(PosSn));
@@ -456,6 +484,7 @@ namespace MySystem
                 apply.SwapSnExpand = apply.SwapSnExpand.Replace(PosSn, PosSn.Substring(0, 3) + "d" + PosSn.Substring(4));
                 // db.SaveChanges();
             }
+
         }
 
         #endregion

+ 58 - 0
AppStart/SycnUserMachineCountHelper.cs

@@ -0,0 +1,58 @@
+using System;
+using System.Linq;
+using System.Threading;
+using MySystem.Models;
+using LitJson;
+
+
+namespace MySystem
+{
+    public class SycnUserMachineCountHelper
+    {
+        public readonly static SycnUserMachineCountHelper Instance = new SycnUserMachineCountHelper();
+        private SycnUserMachineCountHelper()
+        {
+        }
+
+        public void Start()//启动
+        {
+            Thread thread = new Thread(StartDo);
+            thread.IsBackground = true;
+            thread.Start();
+        }
+
+        public void StartDo()
+        {
+            while (true)
+            {
+                string data = RedisDbconn.Instance.RPop<string>("SycnUserMachineCountQueue");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    JsonData json = JsonMapper.ToObject(data);
+                    int UserId = int.Parse(json["UserId"].ToString());
+                    int BrandId = int.Parse(json["BrandId"].ToString());
+                    WebCMSEntities dbnew = new WebCMSEntities();
+                    string IdBrand = UserId + "_" + BrandId;
+                    UserMachineData machineData = dbnew.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
+                    if (machineData == null)
+                    {
+                        machineData = dbnew.UserMachineData.Add(new UserMachineData()
+                        {
+                            IdBrand = IdBrand
+                        }).Entity;
+                        dbnew.SaveChanges();
+                    }
+                    machineData.BindCount = dbnew.PosMachinesTwo.Count(m => m.Status > -1 && m.BuyUserId == UserId && m.BrandId == BrandId && m.BindingState == 1);
+                    machineData.UnBindCount = dbnew.PosMachinesTwo.Count(m => m.Status > -1 && m.BuyUserId == UserId && m.BrandId == BrandId && m.BindingState == 0);
+                    machineData.TotalMachineCount = machineData.BindCount + machineData.UnBindCount;
+                    dbnew.SaveChanges();
+                    dbnew.Dispose();
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+    }
+}

+ 48 - 48
Areas/Admin/Controllers/HomeController.cs

@@ -149,60 +149,60 @@ namespace MySystem.Areas.Admin.Controllers
         [HttpPost]
         public string Login(string UserName, string Pwd, string CheckCode)
         {
-            // string result = "";
-            // if (function.GetCookie(_accessor.HttpContext, "checkcode") != CheckCode)
-            // {
-            //     result = "验证码错误!!";
-            // }
-            // else
-            // {
-            //     Pwd = function.MD5_32(Pwd);
-            //     var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
-            //     if (user != null)
-            //     {
-            //         user.LastLoginDate = DateTime.Now;
-            //         db.SaveChanges();
-            //         function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
-            //         function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
-            //         function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
-            //         int RoleId = int.Parse(function.CheckInt(user.Role));
-            //         BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
-            //         string RightInfo = function.CheckNull(Role.RightInfo);
-            //         function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
-            //         string UserId = user.Id.ToString();
-            //         function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
-            //         function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
-            //         result = "success";
-            //     }
-            //     else
-            //     {
-            //         result = "用户名或密码错误";
-            //     }
-            // }
-
             string result = "";
-            Pwd = function.MD5_32(Pwd);
-            var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
-            if (user != null)
+            if (function.GetCookie(_accessor.HttpContext, "checkcode") != CheckCode)
             {
-                user.LastLoginDate = DateTime.Now;
-                db.SaveChanges();
-                function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
-                function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
-                function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
-                int RoleId = int.Parse(function.CheckInt(user.Role));
-                BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
-                string RightInfo = function.CheckNull(Role.RightInfo);
-                function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
-                string UserId = user.Id.ToString();
-                function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
-                function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
-                result = "success";
+                result = "验证码错误!!";
             }
             else
             {
-                result = "用户名或密码错误";
+                Pwd = function.MD5_32(Pwd);
+                var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
+                if (user != null)
+                {
+                    user.LastLoginDate = DateTime.Now;
+                    db.SaveChanges();
+                    function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
+                    function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
+                    function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
+                    int RoleId = int.Parse(function.CheckInt(user.Role));
+                    BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
+                    string RightInfo = function.CheckNull(Role.RightInfo);
+                    function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
+                    string UserId = user.Id.ToString();
+                    function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
+                    function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
+                    result = "success";
+                }
+                else
+                {
+                    result = "用户名或密码错误";
+                }
             }
+
+            // string result = "";
+            // Pwd = function.MD5_32(Pwd);
+            // var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
+            // if (user != null)
+            // {
+            //     user.LastLoginDate = DateTime.Now;
+            //     db.SaveChanges();
+            //     function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
+            //     function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
+            //     function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
+            //     int RoleId = int.Parse(function.CheckInt(user.Role));
+            //     BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
+            //     string RightInfo = function.CheckNull(Role.RightInfo);
+            //     function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
+            //     string UserId = user.Id.ToString();
+            //     function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
+            //     function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
+            //     result = "success";
+            // }
+            // else
+            // {
+            //     result = "用户名或密码错误";
+            // }
             return result;
         }
         #endregion

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

@@ -85,7 +85,7 @@ namespace MySystem.Areas.Admin.Controllers
             //机具号
             if (!string.IsNullOrEmpty(PosSn))
             {
-                condition += " and KqSnNo=" + PosSn;
+                condition += " and KqSnNo='" + PosSn + "'";
             }
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", page, limit, condition);
             List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;

+ 16 - 0
Areas/Admin/Controllers/MainServer/StoreHouseController.cs

@@ -919,6 +919,7 @@ namespace MySystem.Areas.Admin.Controllers
                 string error = "";
                 decimal amount = 0;
                 List<string> PosSnList = new List<string>();
+                List<string> opData = new List<string>();
                 for (int i = 1; i < list.Count; i++)
                 {
                     JsonData dr = list[i];
@@ -1045,6 +1046,11 @@ namespace MySystem.Areas.Admin.Controllers
                                     AfterOutNum = toStore.OutNum, //操作后出库数
                                 }).Entity;
                                 db.SaveChanges();
+                                
+                                if(!opData.Contains(posInfo.BuyUserId + ":" + posInfo.BrandId))
+                                {
+                                    opData.Add(posInfo.BuyUserId + ":" + posInfo.BrandId);
+                                }
 
                                 posInfo.StoreId = toStore.Id;
                                 posInfo.BuyUserId = 0;
@@ -1135,6 +1141,11 @@ namespace MySystem.Areas.Admin.Controllers
                                 }).Entity;
                                 db.SaveChanges();
 
+                                if(!opData.Contains(posInfo.BuyUserId + ":" + posInfo.BrandId))
+                                {
+                                    opData.Add(posInfo.BuyUserId + ":" + posInfo.BrandId);
+                                }
+
                                 posInfo.StoreId = toStore.Id;
                                 posInfo.BuyUserId = 0;
                                 posInfo.UserId = 0;
@@ -1174,6 +1185,11 @@ namespace MySystem.Areas.Admin.Controllers
                 {
                     return "Warning|" + error;
                 }
+                foreach(string sub in opData)
+                {
+                    string[] datalist = sub.Split(":");
+                    PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
+                }
             }
             AddSysLog("0", "MachinesRejectStore", "Import");
             return "success";

+ 10 - 2
Areas/Admin/Controllers/MainServer/StoreMachineApplyController.cs

@@ -103,7 +103,7 @@ namespace MySystem.Areas.Admin.Controllers
                 dic.Remove("UserId");
 
                 int OpId = int.Parse(function.CheckInt(dic["QueryCount"].ToString()));
-                var opInfo = opdb.SysAdmin.FirstOrDefault( m => m.UserId == OpId && m.QueryCount == 1 && m.Status > -1) ?? new OpModels.SysAdmin();
+                var opInfo = opdb.SysAdmin.FirstOrDefault(m => m.UserId == OpId && m.QueryCount == 1 && m.Status > -1) ?? new OpModels.SysAdmin();
                 dic["OpCode"] = opInfo.OpCode;
 
             }
@@ -527,6 +527,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandId);
                 if (items == null)
                 {
@@ -555,6 +557,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandIds == 7) FromStoreId = 1047;
                 if (BrandIds == 8) FromStoreId = 4831;
                 if (BrandIds == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == BrandIds);
                 CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandIds) ?? new CheckSendInfo();
                 if (items.Num > num)
@@ -596,6 +600,8 @@ namespace MySystem.Areas.Admin.Controllers
                     if (BrandId == 7) FromStoreId = 1047;
                     if (BrandId == 8) FromStoreId = 4831;
                     if (BrandId == 9) FromStoreId = 4832;
+                    if (BrandId == 10) FromStoreId = 5512;
+                    if (BrandId == 11) FromStoreId = 5513;
                     if (PosSnList.Contains(SnNo))
                     {
                         error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '\n';
@@ -633,6 +639,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status > -1 && m.Sort == 0);
                 SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
                 if (item == null)
@@ -817,7 +825,7 @@ namespace MySystem.Areas.Admin.Controllers
             public int Num { get; set; }
         }
 
-         //检查发货信息实体类
+        //检查发货信息实体类
         private class CheckSendInfo
         {
             public int BrandId { get; set; }

+ 47 - 9
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -997,7 +997,7 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 Users posUsers = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
                 decimal Deposits = decimal.Parse(function.CheckNum(pos.SeoKeyword));
-                if (pos.BrandId != 2 && pos.BrandId != 7)
+                if (pos.BrandId != 2 && pos.BrandId != 7 && pos.BrandId != 10 && pos.BrandId != 11)
                 {
                     Deposits = Deposits / 100;
                 }
@@ -1090,7 +1090,7 @@ namespace MySystem.Areas.Admin.Controllers
             }
             string tradeAmount = pos.CreditTrade.ToString();
             decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
-            if (pos.BrandId != 2 && pos.BrandId != 7)
+            if (pos.BrandId != 2 && pos.BrandId != 7 && pos.BrandId != 10 && pos.BrandId != 11)
             {
                 Deposit = Deposit / 100;
             }
@@ -1419,6 +1419,10 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 return "请输入新机具SN";
             }
+            if (string.IsNullOrEmpty(MerNo))
+            {
+                return "请输入商户编号";
+            }
             string[] OldSnList = OldSn.Split('\n');
             string[] NewSnList = NewSn.Split('\n');
             if (OldSnList.Length != NewSnList.Length)
@@ -1482,15 +1486,12 @@ namespace MySystem.Areas.Admin.Controllers
                 }
                 oldPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == oldpos.BrandId) ?? new KqProducts();
                 newPosBrand = db.KqProducts.FirstOrDefault(m => m.Id == newpos.BrandId) ?? new KqProducts();
-                PosMerchantInfo merchant = new PosMerchantInfo();
-                if (!string.IsNullOrEmpty(MerNo))
-                {
-                    merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PosMerchantInfo();
-                }
-                else
+                PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo);
+                if (merchant == null)
                 {
-                    merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == oldpos.BindMerchantId) ?? new PosMerchantInfo();
+                    CustomerSqlConn.op("insert into PosMerchantInfo select * from PosMerchantInfoBak where KqMerNo='" + MerNo + "'", MysqlConn.connstr);
                 }
+                merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PosMerchantInfo();
                 newpos.BindMerchantId = merchant.Id;
                 newpos.BuyUserId = oldpos.BuyUserId;
                 newpos.UserId = oldpos.UserId;
@@ -1601,6 +1602,7 @@ namespace MySystem.Areas.Admin.Controllers
             string[] OldSnList;
             string[] NewSnList;
             decimal amount = 0;
+            List<string> opData = new List<string>();
             //创客坏机换新
             if (ChangeType == "0")
             {
@@ -1715,6 +1717,11 @@ namespace MySystem.Areas.Admin.Controllers
                     newpos.UserId = oldpos.UserId;
                     newpos.PreUserId = oldpos.PreUserId;
 
+                    if(!opData.Contains(oldpos.BuyUserId + ":" + oldpos.BrandId))
+                    {
+                        opData.Add(oldpos.BuyUserId + ":" + oldpos.BrandId);
+                    }
+
                     oldpos.StoreId = storeBack.Id;
                     oldpos.QueryCount = 0;
                     oldpos.UpdateDate = null;
@@ -1904,6 +1911,11 @@ namespace MySystem.Areas.Admin.Controllers
                     newpos.IsFirst = oldpos.IsFirst;
                     newpos.TransferTime = oldpos.TransferTime;
 
+                    if(!opData.Contains(oldpos.BuyUserId + ":" + oldpos.BrandId))
+                    {
+                        opData.Add(oldpos.BuyUserId + ":" + oldpos.BrandId);
+                    }
+
                     oldpos.StoreId = storeBack.Id;
                     oldpos.QueryCount = 0;
                     oldpos.UpdateDate = null;
@@ -2097,6 +2109,11 @@ namespace MySystem.Areas.Admin.Controllers
             //         }));
             //     }
             // }
+            foreach(string sub in opData)
+            {
+                string[] datalist = sub.Split(":");
+                PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
+            }
             return "success";
         }
         #endregion
@@ -4078,6 +4095,7 @@ namespace MySystem.Areas.Admin.Controllers
             string[] OldSnList;
             OldSnList = OldSn.Replace("\r", "").Split('\n');
             string error = "";
+            List<string> opData = new List<string>();
             for (int i = 0; i < OldSnList.Length; i++)
             {
                 string OldSnNum = OldSnList[i];
@@ -4088,6 +4106,10 @@ namespace MySystem.Areas.Admin.Controllers
                 {
                     error += "以下操作失败" + OldSnNum + ',' + "该机具不在坏机仓或不存在" + '\n';
                 }
+                if(!opData.Contains(oldpos.BuyUserId + ":" + oldpos.BrandId))
+                {
+                    opData.Add(oldpos.BuyUserId + ":" + oldpos.BrandId);
+                }
                 oldpos.Status = 1;
                 oldpos.QueryCount = 0;
                 oldpos.UpdateDate = null;
@@ -4135,6 +4157,11 @@ namespace MySystem.Areas.Admin.Controllers
                 return "Warning|" + error;
             }
             db.SaveChanges();
+            foreach(string sub in opData)
+            {
+                string[] datalist = sub.Split(":");
+                PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
+            }
             return "success";
         }
         #endregion
@@ -4249,6 +4276,7 @@ namespace MySystem.Areas.Admin.Controllers
             var endTime = time.AddDays(20 - time.Day).AddDays(-60);
             StoreForCode storeForBack = new StoreForCode();
             StoreHouse BackStore = new StoreHouse();
+            List<string> opData = new List<string>();
             foreach (var item in PosSnList)
             {
                 MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == item) ?? new MachineForSnNo();
@@ -4390,6 +4418,11 @@ namespace MySystem.Areas.Admin.Controllers
                     var userMachineDatas = db.UserMachineData.FirstOrDefault(m => m.IdBrand == fInfo) ?? new UserMachineData();
                     userMachineDatas.TotalMachineCount -= 1;
                     userMachineDatas.UnBindCount -= 1;
+                    
+                    if(!opData.Contains(pos.BuyUserId + ":" + pos.BrandId))
+                    {
+                        opData.Add(pos.BuyUserId + ":" + pos.BrandId);
+                    }
 
                     pos.StoreId = BackStore.Id;//变更机具所属仓库,重置为仓库机
                     pos.Status = 1;
@@ -4471,6 +4504,11 @@ namespace MySystem.Areas.Admin.Controllers
                 }
             }
             db.SaveChanges();
+            foreach(string sub in opData)
+            {
+                string[] datalist = sub.Split(":");
+                PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
+            }
             return "success";
         }
         #endregion

+ 5 - 6
Areas/Admin/Controllers/MainServer/UserCashRecordController.cs

@@ -1261,13 +1261,12 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 int id = int.Parse(subid);
                 var userCashRecord = db.UserCashRecord.FirstOrDefault(m => m.Id == id) ?? new UserCashRecord();
-                var userAccountRecord = db.UserAccountRecord.Where(m => m.Version == id).ToList();
-                foreach (var item in userAccountRecord)
-                {
-                    int recordId = item.Id;
-                    new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Delete("UserAccountRecord", recordId);
-                }
+                DataTable dt = OtherMySqlConn.dtable("DELETE FROM UserAccountRecord WHERE Version=" + userCashRecord.Id + "");
                 userCashRecord.Status = 0;
+                userCashRecord.QueryCount = 0;
+                var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == userCashRecord.UserId) ?? new UserAccount();
+                userAccount.WithdrawAmount -= userCashRecord.TradeAmount;
+                userAccount.FreezeAmount += userCashRecord.TradeAmount;
                 db.SaveChanges();
             }
 

+ 16 - 0
Areas/Admin/Controllers/OperateServer/StoreHouseOperateController.cs

@@ -644,6 +644,7 @@ namespace MySystem.Areas.Admin.Controllers
                 string error = "";
                 decimal amount = 0;
                 List<string> PosSnList = new List<string>();
+                List<string> opData = new List<string>();
                 for (int i = 1; i < list.Count; i++)
                 {
                     JsonData dr = list[i];
@@ -770,6 +771,11 @@ namespace MySystem.Areas.Admin.Controllers
                                 }).Entity;
                                 db.SaveChanges();
 
+                                if(!opData.Contains(posInfo.BuyUserId + ":" + posInfo.BrandId))
+                                {
+                                    opData.Add(posInfo.BuyUserId + ":" + posInfo.BrandId);
+                                }
+
                                 posInfo.StoreId = toStore.Id;
                                 posInfo.BuyUserId = 0;
                                 posInfo.UserId = 0;
@@ -858,6 +864,11 @@ namespace MySystem.Areas.Admin.Controllers
                                 }).Entity;
                                 db.SaveChanges();
 
+                                if(!opData.Contains(posInfo.BuyUserId + ":" + posInfo.BrandId))
+                                {
+                                    opData.Add(posInfo.BuyUserId + ":" + posInfo.BrandId);
+                                }
+
                                 posInfo.StoreId = toStore.Id;
                                 posInfo.BuyUserId = 0;
                                 posInfo.UserId = 0;
@@ -897,6 +908,11 @@ namespace MySystem.Areas.Admin.Controllers
                 {
                     return "Warning|" + error;
                 }
+                foreach(string sub in opData)
+                {
+                    string[] datalist = sub.Split(":");
+                    PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
+                }
             }
             AddSysLog("0", "MachinesRejectStore", "Import");
             return "success";

+ 8 - 0
Areas/Admin/Controllers/OperateServer/StoreMachineApplyOperateController.cs

@@ -642,6 +642,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandId);
                 if (items == null)
                 {
@@ -670,6 +672,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandIds == 7) FromStoreId = 1047;
                 if (BrandIds == 8) FromStoreId = 4831;
                 if (BrandIds == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == BrandIds);
                 CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandIds) ?? new CheckSendInfo();
                 if (items.Num > num)
@@ -699,6 +703,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 Models.MachineForSnNo posInfo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new Models.MachineForSnNo();
                 var pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posInfo.SnId && m.StoreId == FromStoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0) ?? new Models.PosMachinesTwo();
                 if (posInfo.SnId > 0)
@@ -760,6 +766,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 tostore = db.StoreHouse.FirstOrDefault(m => m.Sort > 0 && m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status == 1);
                 SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
                 if (item == null)

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

@@ -537,6 +537,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandId);
                 if (items == null)
                 {
@@ -565,6 +567,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandIds == 7) FromStoreId = 1047;
                 if (BrandIds == 8) FromStoreId = 4831;
                 if (BrandIds == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == BrandIds);
                 CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandIds) ?? new CheckSendInfo();
                 if (items.Num > num)
@@ -594,6 +598,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 MachineForSnNo posInfo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
                 var pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posInfo.SnId && m.StoreId == FromStoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0) ?? new PosMachinesTwo();
                 if (posInfo.SnId > 0)
@@ -642,6 +648,8 @@ namespace MySystem.Areas.Admin.Controllers
                 if (BrandId == 7) FromStoreId = 1047;
                 if (BrandId == 8) FromStoreId = 4831;
                 if (BrandId == 9) FromStoreId = 4832;
+                if (BrandId == 10) FromStoreId = 5512;
+                if (BrandId == 11) FromStoreId = 5513;
                 tostore = db.StoreHouse.FirstOrDefault(m => m.Sort > 0 && m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status == 1);
                 SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
                 if (item == null)

+ 2 - 2
Areas/Admin/Views/Home/Login.cshtml

@@ -26,11 +26,11 @@
                     <label for="password">密码 / Password</label>
                     <input class="form-input" type="password" name="Pwd" id="Pwd" onKeyUp="if(event.keyCode==13){$('#CheckCode').focus();}" placeholder="请填写密码">
                 </div>
-                @* <div class="form-group pb10">
+                <div class="form-group pb10">
                     <label for="password">验证码 / Verification</label>
                     <input class="form-input" type="text" name="CheckCode" id="CheckCode" onkeyup="if(event.keyCode==13){syslogin();}" placeholder="请填写验证码" style="width: 70%; display: inline-block; margin-right: 2%">
                     <img src="/Api/PublicMethod/CheckCode" onclick="$(this).attr('src','/Api/PublicMethod/CheckCode?r='+Math.random())" style="width: 26%; height:38px;" />
-                </div> *@
+                </div>
                 @*<div class="form-group pb10 cf">
                         <label class="remembermetext fl" for="rememberme">
                             <input type="checkbox" checked name="rememberme">&nbsp;记住我的登录

+ 1 - 1
Startup.cs

@@ -140,7 +140,7 @@ namespace MySystem
             SycnHelpProfitService.Instance.Start();
             ExcelHelper.Instance.Start();
             OpExcelHelper.Instance.Start();
-            TestHelper.Instance.Start();
+            SycnUserMachineCountHelper.Instance.Start(); //重置创客机具数量
         }