From 3ad8babb3a5929eadc18d3518563b6355a800681 Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期四, 07 八月 2025 12:59:24 +0800
Subject: [PATCH] no message

---
 Admin.NET/FZCZTB.Net.CustomerSYSTem/Service/FBS_CusExtend/FBS_CusExtendService.cs |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/Admin.NET/FZCZTB.Net.CustomerSYSTem/Service/FBS_CusExtend/FBS_CusExtendService.cs b/Admin.NET/FZCZTB.Net.CustomerSYSTem/Service/FBS_CusExtend/FBS_CusExtendService.cs
index d16d7a0..18d4555 100644
--- a/Admin.NET/FZCZTB.Net.CustomerSYSTem/Service/FBS_CusExtend/FBS_CusExtendService.cs
+++ b/Admin.NET/FZCZTB.Net.CustomerSYSTem/Service/FBS_CusExtend/FBS_CusExtendService.cs
@@ -226,9 +226,31 @@
     [ApiDescriptionSettings(Name = "Delete"), HttpPost]
     public async Task Delete(DeleteFBS_CusExtendInput input)
     {
-        var entity = await _fBS_CusExtendRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
-        //await _fBS_CusExtendRep.FakeDeleteAsync(entity);   //鍋囧垹闄�
-        await _fBS_CusExtendRep.DeleteAsync(entity);   //鐪熷垹闄�
+     await    _fBS_CusExtendRep.AsTenant().BeginTranAsync();
+        try
+        {
+            var entity = await _fBS_CusExtendRep.AsQueryable().Includes(x => x.TransactionRole).Where(x => x.Id == input.Id).FirstAsync() ?? throw Oops.Oh(ErrorCodeEnum.D1002);
+            if (entity != null)
+            {
+                var exrles = await _fBS_CoutomerExRoleRep.GetFirstAsync(x => x.CustomerId == entity.CustomerId && x.ExRoleId == entity.TransactionRole.Id);
+                if (exrles != null)
+                {
+                    await _fBS_CoutomerExRoleRep.DeleteAsync(exrles);
+                }
+
+                //await _fBS_CusExtendRep.FakeDeleteAsync(entity);   //鍋囧垹闄�
+
+                await _fBS_CusExtendRep.DeleteAsync(entity);   //鐪熷垹闄�
+            }
+
+          await   _fBS_CusExtendRep.AsTenant().CommitTranAsync();
+        }
+        catch (Exception)
+        {
+            await _fBS_CusExtendRep.AsTenant().RollbackTranAsync();
+            throw;
+        }
+    
     }
 
     /// <summary>

--
Gitblit v1.9.1