移动系统liao
9 天以前 65383b35f3b0420ab1d334ef354d4706d54f93f8
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>
@@ -93,6 +100,83 @@
            .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>
    /// 获取企业资料详情 ℹ️