| | |
| | | public async Task<OpenEnterpriseWalletCommandResult> Handle(OpenEnterpriseWalletCommand request, CancellationToken cancellationToken) |
| | | { |
| | | var logier = JwtUtils.GetCurrentLogier(); |
| | | if (logier.Type == EnumUserType.Enterprise) |
| | | { |
| | | request.EnterpriseId = logier.EnterpriseId; |
| | | } |
| | | if (request.EnterpriseId == null) throw Oops.Oh(EnumErrorCodeType.s400, "请填写企业Id"); |
| | | var enterprise = await repEnterprise.AsQueryable().AsNoTracking() |
| | | .Where(it => it.Id == logier.EnterpriseId) |
| | | .Where(it => it.Id == request.EnterpriseId) |
| | | .FirstOrDefaultAsync(); |
| | | if (enterprise == null) throw Oops.Oh(EnumErrorCodeType.s404, "企业"); |
| | | if (!enterprise.IsReal) throw Oops.Oh(EnumErrorCodeType.s510, "请先实名"); |
| | | var entity = await rep.AsQueryable() |
| | | .Where(it => it.EnterpriseId == logier.EnterpriseId && it.Access == request.Access) |
| | | .Where(it => it.EnterpriseId == request.EnterpriseId && it.Access == request.Access) |
| | | .FirstOrDefaultAsync(); |
| | | if (entity == null) |
| | | { |
| | | entity = new EnterpriseWallet(); |
| | | entity.EnterpriseId = logier.EnterpriseId!.Value; |
| | | entity.EnterpriseId = request.EnterpriseId!.Value; |
| | | entity.Access = EnumEnterpriseWalletAccess.Alipay; |
| | | entity.Account = request.Account; |
| | | entity.MerchantId = request.MerchantId; |
| | | entity.PersonalProductCode = "FUND_SAFT_SIGN_WITHHOLDING_P"; |
| | | entity.SignScene = "INDUSTRY|SATF_ACC"; |
| | | entity.ThirdPartyType = "PARTNER"; |
| | |
| | | else |
| | | { |
| | | if (entity.SignStatus == EnumEnterpriseWalletSignStatus.Normal) throw Oops.Oh(EnumErrorCodeType.s510, "已签约"); |
| | | entity.Account = request.Account; |
| | | entity.MerchantId = request.MerchantId; |
| | | entity.SignStatus = EnumEnterpriseWalletSignStatus.Apply; |
| | | await rep.UpdateAsync(entity); |
| | | } |
| | |
| | | public async Task<Guid> Handle(CloseEnterpriseWalletCommand request, CancellationToken cancellationToken) |
| | | { |
| | | var logier = JwtUtils.GetCurrentLogier(); |
| | | if (logier.Type == EnumUserType.Enterprise) |
| | | { |
| | | request.EnterpriseId = logier.EnterpriseId; |
| | | } |
| | | if (request.EnterpriseId == null) throw Oops.Oh(EnumErrorCodeType.s400, "请填写企业Id"); |
| | | var entity = await rep.AsQueryable() |
| | | .Where(it => it.EnterpriseId == logier.EnterpriseId && it.Access == request.Access) |
| | | .Where(it => it.EnterpriseId == request.EnterpriseId && it.Access == request.Access) |
| | | .FirstOrDefaultAsync(); |
| | | if (entity == null) throw Oops.Oh(EnumErrorCodeType.s404, "企业钱包"); |
| | | if (entity.SignStatus != EnumEnterpriseWalletSignStatus.Normal) throw Oops.Oh(EnumErrorCodeType.s510, "未签约"); |
| | |
| | | public async Task<RechargeEnterpriseWalletCommandResult> Handle(RechargeEnterpriseWalletCommand request, CancellationToken cancellationToken) |
| | | { |
| | | var logier = JwtUtils.GetCurrentLogier(); |
| | | if (logier.Type == EnumUserType.Enterprise) |
| | | { |
| | | request.EnterpriseId = logier.EnterpriseId; |
| | | } |
| | | if (request.EnterpriseId == null) throw Oops.Oh(EnumErrorCodeType.s400, "请填写企业Id"); |
| | | var entity = await rep.AsQueryable() |
| | | .Where(it => it.EnterpriseId == logier.EnterpriseId && it.Access == request.Access) |
| | | .Where(it => it.EnterpriseId == request.EnterpriseId && it.Access == request.Access) |
| | | .FirstOrDefaultAsync(); |
| | | if (entity == null) throw Oops.Oh(EnumErrorCodeType.s404, "企业钱包"); |
| | | if (entity.SignStatus != EnumEnterpriseWalletSignStatus.Normal) throw Oops.Oh(EnumErrorCodeType.s510, "未签约"); |