| | |
| | | |
| | | using Admin.NET.Core; |
| | | using Admin.NET.Core.Service; |
| | | using Dm.util; |
| | | using Furion; |
| | | using Furion.DynamicApiController; |
| | | using Furion.FriendlyException; |
| | |
| | | |
| | | private readonly SysCacheService _sysCacheService; |
| | | private readonly SqlSugarRepository<FBS_ExRole> _fBS_ExRoleRep; |
| | | |
| | | private readonly SqlSugarRepository<FBS_CoutomerExRole> _fBS_CustomerExRoleRep; |
| | | private readonly SqlSugarRepository<FBS_EnterpriseType> _fBS_EnterpriseTypeRep; |
| | | private readonly SqlSugarRepository<FBS_Customer> _fBS_CustomerRep; |
| | | /// <summary> |
| | | /// 用户扩展 |
| | | /// </summary> |
| | | private readonly SqlSugarRepository<FBS_CusExtend> _fBS_CusExtendRep; |
| | | |
| | | private IMapper _mapper; |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public CustomerService(SysCacheService cacheService, CustomerManagerS managerS,SqlSugarRepository<FBS_Customer> repository |
| | | , SqlSugarRepository<FBS_EnterpriseType> fbsenrep,IMapper mapper,SqlSugarRepository<FBS_ExRole> exroles , SqlSugarRepository<FBS_CusExtend> cusrep) |
| | | , SqlSugarRepository<FBS_EnterpriseType> fbsenrep,IMapper mapper,SqlSugarRepository<FBS_ExRole> exroles , |
| | | SqlSugarRepository<FBS_CusExtend> cusrep, |
| | | SqlSugarRepository<FBS_CoutomerExRole> cexrrep) |
| | | { |
| | | _sysCacheService= cacheService; |
| | | _customerManager = managerS; |
| | |
| | | _fBS_ExRoleRep = exroles; |
| | | _fBS_CusExtendRep = cusrep; |
| | | _mapper = mapper; |
| | | _fBS_CustomerExRoleRep = cexrrep; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | dd.CreateTime = DateTime.Now; |
| | | dd.CreateUserId = 0; |
| | | dd.CreateUserName = dd.NickName; |
| | | dd.CoutomerExRols = new List<FBS_CoutomerExRole>() |
| | | if(dd.CoutomerExRols==null) |
| | | { |
| | | new List<FBS_CoutomerExRole>() |
| | | { |
| | | new FBS_CoutomerExRole |
| | | { |
| | | ExRoleId= ExRole?.Id??0 |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | dd.CoutomerExRols.add(new FBS_CoutomerExRole |
| | | { |
| | | ExRoleId = ExRole?.Id ?? 0 |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | throw Oops.Oh("用户不存在"); |
| | | } |
| | | |
| | | var rols= await _fBS_ExRoleRep.GetFirstAsync(x => x.Code == cusExtend.TransactionCode && x.Status == StatusEnum.Enable); |
| | | if(rols==null) |
| | | { |
| | | throw Oops.Oh("交易主体不存在"); |
| | | } |
| | | |
| | | if(user.CoutomerExRols?.Any(x=>x.ExRole.Code==cusExtend.TransactionCode&& x.HasFlsh==true)==true) |
| | | var ExRoles = await _fBS_CustomerExRoleRep.GetListAsync(x => x.CustomerId == id); |
| | | if (ExRoles != null) |
| | | { |
| | | throw Oops.Oh("用户已经注册了该主体"); |
| | | if (ExRoles?.Any(x => x.ExRoleId == rols.Id && x.HasFlsh == true) == true) |
| | | { |
| | | throw Oops.Oh("用户已经注册了该主体"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | //增加用户角色 |
| | | await _fBS_CustomerExRoleRep.InsertAsync(new FBS_CoutomerExRole |
| | | { |
| | | ExRoleId = rols.Id, |
| | | CustomerId = id |
| | | }); |
| | | |
| | | |
| | | var usdata = await _fBS_CusExtendRep.GetFirstAsync(x => x.CustomerId == id&&x.TransactionCode==cusExtend.TransactionCode); |
| | | |
| | | if (usdata!=null) |
| | | { |
| | | if (usdata.steps == CusExtendStep.Pass) |
| | | { |
| | | throw Oops.Oh("用户已经注册了该主体"); |
| | | |
| | | } |
| | | throw Oops.Oh("用户已经申请了该角色,请走修改流程"); |
| | | } |
| | | |
| | | var data= cusExtend.Adapt<FBS_CusExtend>(); |
| | | |
| | | data.steps = CusExtendStep.UNExamine; |