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 | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 110 insertions(+), 4 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 a2c2813..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 @@ -18,6 +18,8 @@ using Admin.NET.Core; using FZCZTB.NET.MD.CutomerMd.Extend; using cylsg.utility; +using FZCZTB.NET.MD.CutomerMd; +using Furion.Logging.Extensions; namespace FZCZTB.Net.CustomerSYSTem; /// <summary> @@ -27,19 +29,23 @@ public class FBS_CusExtendService : IDynamicApiController, ITransient { private readonly SqlSugarRepository<FBS_CusExtend> _fBS_CusExtendRep; + private readonly SqlSugarRepository<FBS_CoutomerExRole> _fBS_CoutomerExRoleRep; private readonly ISqlSugarClient _sqlSugarClient; private readonly SysDictTypeService _sysDictTypeService; private readonly FBS_EnterpriseTypeService _EnterpriseTypeService; + public FBS_CusExtendService(SqlSugarRepository<FBS_CusExtend> fBS_CusExtendRep, ISqlSugarClient sqlSugarClient, SysDictTypeService sysDictTypeService, - FBS_EnterpriseTypeService fBS_EnterpriseTypeService ) + FBS_EnterpriseTypeService fBS_EnterpriseTypeService, + SqlSugarRepository<FBS_CoutomerExRole> cerRep) { _fBS_CusExtendRep = fBS_CusExtendRep; _sqlSugarClient = sqlSugarClient; _sysDictTypeService = sysDictTypeService; _EnterpriseTypeService = fBS_EnterpriseTypeService; + _fBS_CoutomerExRoleRep = cerRep; } /// <summary> /// @@ -55,6 +61,7 @@ StepsTypeItems = CommonHelper.GetEnumItemsWithAttributes<CusExtendStep>() }; } + /// <summary> /// 鍒嗛〉鏌ヨ浼佷笟璧勬枡 馃敄 /// </summary> @@ -92,6 +99,83 @@ .WhereIF(input.steps != null, u => u.steps == input.steps) .Select<FBS_CusExtendOutput>(); return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); + } + /// <summary> + /// 鏇存敼瀹℃牳鐘舵�� + /// </summary> + /// <param name="id">瑕佹洿鏀圭殑鐢ㄦ埛瑙掕壊璧勬枡Id</param> + /// <param name="step">瑕佹洿鏀圭殑鐘舵��</param> + /// <returns></returns> + [HttpGet] + public async Task<bool > ChangeSteps (long id, CusExtendStep step) + { + + var data=await _fBS_CusExtendRep.AsQueryable().Includes(x=>x.TransactionRole).Where(x=>x.Id==id).FirstAsync(); + if (data == null) + { + throw Oops.Oh("鏁版嵁涓嶅瓨鍦�"); + }; + if(data.steps== step) + { + return true; + } + try + { + await _fBS_CusExtendRep.AsTenant().BeginTranAsync(); + if (step == CusExtendStep.Pass) + { + //鏄鏍搁�氳繃 + + if (data.TransactionRole == null) + { + throw Oops.Oh("鐢ㄦ埛鍏宠仈瑙掕壊澶辫触锛岀敤鎴锋病鏈夌敵璇疯瑙掕壊锛岃閲嶆柊鐢宠瑙掕壊"); + } + + var exrles = await _fBS_CoutomerExRoleRep.GetFirstAsync(x => x.CustomerId == data.CustomerId && x.ExRoleId == data.TransactionRole.Id); + if (exrles == null) + throw Oops.Oh("鐢ㄦ埛鍏宠仈瑙掕壊澶辫触锛岀敤鎴锋病鏈夌敵璇疯瑙掕壊锛岃閲嶆柊鐢宠瑙掕壊"); + + exrles.HasFlsh = true; + await _fBS_CoutomerExRoleRep.UpdateAsync(exrles); + + + + + + } + else + if(data.steps== CusExtendStep.Pass) + { + //鏇存敼涓烘湭閫氳繃 + + if (data.TransactionRole == null) + { + throw Oops.Oh("鐢ㄦ埛鍏宠仈瑙掕壊澶辫触锛岀敤鎴锋病鏈夌敵璇疯瑙掕壊锛岃閲嶆柊鐢宠瑙掕壊"); + } + var exrles = await _fBS_CoutomerExRoleRep.GetFirstAsync(x => x.CustomerId == data.CustomerId && x.ExRoleId == data.TransactionRole.Id); + if (exrles == null) + throw Oops.Oh("鐢ㄦ埛鍏宠仈瑙掕壊澶辫触锛岀敤鎴锋病鏈夌敵璇疯瑙掕壊锛岃閲嶆柊鐢宠瑙掕壊"); + + exrles.HasFlsh = false; + await _fBS_CoutomerExRoleRep.UpdateAsync(exrles); + + + + + } + data.steps = step; + await _fBS_CusExtendRep.AsUpdateable(data).ExecuteCommandAsync(); + await _fBS_CusExtendRep.AsTenant().CommitTranAsync(); + return true; + + } + catch (Exception e) + { + await _fBS_CusExtendRep.AsTenant().RollbackTranAsync(); + e.Message.LogError(); + throw Oops.Oh("鏇存敼瀹℃牳鐘舵�佸け璐�"); ; + } + } /// <summary> @@ -142,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