From 45c6d6e44e9e8428718fc635d71e0869556da2c3 Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期一, 20 五月 2024 15:36:53 +0800
Subject: [PATCH] no message

---
 CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs |   80 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs b/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs
index ae8e340..1e7836d 100644
--- a/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs
+++ b/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs
@@ -32,6 +32,7 @@
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.CodeAnalysis.Operations;
+using NPOI.SS.Formula.Functions;
 using SqlSugar;
 using ZstdSharp.Unsafe;
 
@@ -437,6 +438,7 @@
 
                 }
 
+                
                 await _coreCmsDistributionServices.InsertAsync(model);
 
                 _unitOfWork.CommitTran();
@@ -738,11 +740,76 @@
                 jm.msg = GlobalConstVars.DataisNo;
                 return jm;
             }
+            try
+            {
+                _unitOfWork.BeginTran();
+                
+                    //濡傛灉鏄彇娑堝鏍�
 
-            var bl = await _coreCmsDistributionServices.DeleteByIdAsync(entity.id);
-            jm.code = bl ? 0 : 1;
-            jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
-            return jm;
+                    var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries();
+                    var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey);
+                var group = await _userGradeServices.GetUserGradeByValueKey(kc);
+                var defgroup = await _userGradeServices.GetDefaultUserGrade();
+                    if (defgroup != null)
+                    {
+                        var olduser = await _userServices.QueryByIdAsync(model.userId);
+                        if (olduser != null)
+                        {//澶勭悊鐢ㄦ埛绛夌骇
+                            if (olduser.grade == group.id)
+                            {
+                                if (defgroup != null)
+                                {
+                                    olduser.grade = defgroup.id;
+                                }
+                                else
+                                {
+
+                                    olduser.grade = 0;
+                                }
+
+                                olduser.updataTime = DateTime.Now;
+                                await _userServices.UpdateAsync(olduser);
+
+                            }
+                        }
+                        var store = await _coreCmsStoreServices.QueryByClauseAsync(x => x.userID == model.userId);
+                        //澶勭悊搴楅摵  鍙栨秷宸叉湁搴楅摵鐨勪娇鑳�
+                       if(store != null )
+                           
+                        {
+
+
+                        // var clerk= await _unitOfWork.GetDbClient().Queryable<CoreCmsClerk>().Where(x => x.storeId == store.id).ToListAsync();
+                        //鍒犻櫎搴楅摵鍛樺伐
+                         await _unitOfWork.GetDbClient().Deleteable<CoreCmsClerk>().Where(x=>x.storeId==store.id).ExecuteCommandAsync();
+                        //鍒犻櫎搴楅摵
+                        await _coreCmsStoreServices.DeleteByIdAsync(store.id);
+                       
+                      
+
+                    }
+
+
+                    }
+                var  bl = await _coreCmsDistributionServices.DeleteByIdAsync(entity.id);
+
+                _unitOfWork.CommitTran();
+                jm.code = bl ? 0 : 1;
+                    jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
+
+                    return jm;
+
+            }
+            catch (Exception)
+            {
+
+                _unitOfWork.RollbackTran();
+                jm.code = 1;
+                jm.msg = GlobalConstVars.DeleteFailure;
+
+                return jm;
+            }
+        
 
         }
 
@@ -817,5 +884,10 @@
         }
 
         #endregion
+
+
+
+
+      
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1