فهرست منبع

划拨创客机具后向对应创客机具数加减

DuGuYang 3 سال پیش
والد
کامیت
3ccfa42364
1فایلهای تغییر یافته به همراه15 افزوده شده و 2 حذف شده
  1. 15 2
      Areas/Admin/Controllers/MainServer/SysToolsController.cs

+ 15 - 2
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -3703,8 +3703,21 @@ namespace MySystem.Areas.Admin.Controllers
             }
             if (posInfo.BindingState == 0)
             {
-                posInfo.BuyUserId = tUserId.Id;
-                posInfo.UserId = tUserId.Id;
+                if (posInfo.UserId == 0 || posInfo.BuyUserId == posInfo.UserId)
+                {
+                    posInfo.BuyUserId = tUserId.Id;
+                    posInfo.UserId = tUserId.Id;
+                }
+                else
+                {
+                    posInfo.BuyUserId = tUserId.Id;
+                }
+                var fUserPos = db.UserMachineData.FirstOrDefault(m => m.IdBrand == fUserId.Id + "_" + posInfo.BrandId) ?? new UserMachineData();
+                var tUserPos = db.UserMachineData.FirstOrDefault(m => m.IdBrand == tUserId.Id + "_" + posInfo.BrandId) ?? new UserMachineData();
+                fUserPos.TotalMachineCount -= 1;
+                fUserPos.UnBindCount -= 1;
+                tUserPos.TotalMachineCount += 1;
+                tUserPos.UnBindCount += 1;
                 db.SaveChanges();
                 function.WriteLog(DateTime.Now.ToString() + ":请求参数," + query + ":" + SysUserName + "-" + SysRealName, "划拨创客机具");
             }