Skip to content

Commit

Permalink
Upgrade to ABP 5.0.1
Browse files Browse the repository at this point in the history
Complete permission check
Use options to configure payment methods
Payment list and Refund list will be get with details
Use distributed event bus with outbox
Fix some bugs
Add UTs
  • Loading branch information
gdlcf88 committed Jan 1, 2022
1 parent ded70ed commit 3adea26
Show file tree
Hide file tree
Showing 188 changed files with 37,636 additions and 25,027 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: NuGet/setup-nuget@v1.0.5
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'

- name: read common.props
id: commonProps
Expand Down Expand Up @@ -39,8 +42,16 @@ jobs:
cd dest
del * -Exclude EasyAbp.*
del * -Exclude *.${{ steps.getVersion.outputs.first_match }}.nupkg
del *.HttpApi.Client.ConsoleTestApp*
del *.Host.Shared*
del *.Blazor.Host.*
del *.Blazor.Server.Host.*
del *.Host.Shared.*
del *.HttpApi.Host.*
del *.IdentityServer.*
del *.Web.Host.*
del *.Web.Unified.*
del *.HttpApi.Client.ConsoleTestApp.*
del *.Tests.*
del *.TestBase.*
dir -name
- name: dotnet nuget push to GitHub
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>

<AbpVersion>4.4.0</AbpVersion>
<EasyAbpAbpWeChatModuleVersion>1.7.12</EasyAbpAbpWeChatModuleVersion>
<AbpVersion>5.0.1</AbpVersion>
<EasyAbpAbpWeChatModuleVersion>1.8.0</EasyAbpAbpWeChatModuleVersion>

</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ stages:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '5.x'
version: '6.x'

- task: DotNetCoreCLI@2
displayName: 'restore'
Expand Down Expand Up @@ -83,7 +83,7 @@ stages:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '5.x'
version: '6.x'
- task: CmdLine@2
displayName: 'install dotnet-ef'
inputs:
Expand Down
4 changes: 2 additions & 2 deletions common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>1.10.4</Version>
<Version>2.0.0</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>
Expand All @@ -20,7 +20,7 @@

<ItemGroup>
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.1" PrivateAssets="All" />
<PackageReference Include="Fody" Version="6.2.0">
<PackageReference Include="Fody" Version="6.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
10 changes: 5 additions & 5 deletions docs/Prepayment/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# PaymentService.Prepayment

[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2FEasyAbp%2FPaymentService%2Fmaster%2FDirectory.Build.props)](https://abp.io)
[![NuGet](https://img.shields.io/nuget/v/EasyAbp.PaymentService.Prepayment.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.PaymentService.Prepayment.Domain.Shared)
[![NuGet Download](https://img.shields.io/nuget/dt/EasyAbp.PaymentService.Prepayment.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.PaymentService.Prepayment.Domain.Shared)
[![Discord online](https://badgen.net/discord/online-members/S6QaezrCRq?label=Discord)](https://discord.gg/S6QaezrCRq)
[![GitHub stars](https://img.shields.io/github/stars/EasyAbp/PaymentService?style=social)](https://www.github.com/EasyAbp/PaymentService)

Prepayment implementation of the EasyAbp.PaymentService module.
Expand Down Expand Up @@ -36,12 +38,10 @@ We have launched an online demo for this module: [https://pay.samples.easyabp.io

1. Register the Prepayment payment method:
```csharp
public override void OnApplicationInitialization(ApplicationInitializationContext context)
Configure<PaymentServiceOptions>(options =>
{
var resolver = context.ServiceProvider.GetRequiredService<IPaymentServiceResolver>();

resolver.TryRegisterProvider(PrepaymentPaymentServiceProvider.PaymentMethod, typeof(PrepaymentPaymentServiceProvider));
}
options.Providers.Configure<PrepaymentPaymentServiceProvider>(PrepaymentPaymentServiceProvider.PaymentMethod);
});
```

2. Configure the prepayment to define a account group:
Expand Down
15 changes: 8 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2FEasyAbp%2FPaymentService%2Fmaster%2FDirectory.Build.props)](https://abp.io)
[![NuGet](https://img.shields.io/nuget/v/EasyAbp.PaymentService.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.PaymentService.Domain.Shared)
[![NuGet Download](https://img.shields.io/nuget/dt/EasyAbp.PaymentService.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.PaymentService.Domain.Shared)
[![Discord online](https://badgen.net/discord/online-members/S6QaezrCRq?label=Discord)](https://discord.gg/S6QaezrCRq)
[![GitHub stars](https://img.shields.io/github/stars/EasyAbp/PaymentService?style=social)](https://www.github.com/EasyAbp/PaymentService)

An abp application module that provides payment service.
Expand Down Expand Up @@ -33,15 +34,15 @@ We have launched an online demo for this module: [https://pay.samples.easyabp.io

## Usage

1. Register the Free payment method, it is used to pay with 0.00 amount:
1. Register the Free payment method, it is used to pay when the amount is 0.00:

```csharp
public override void OnApplicationInitialization(ApplicationInitializationContext context)
Configure<PaymentServiceOptions>(options =>
{
var resolver = context.ServiceProvider.GetRequiredService<IPaymentServiceResolver>();

resolver.TryRegisterProvider(FreePaymentServiceProvider.PaymentMethod, typeof(FreePaymentServiceProvider));
}
options.Providers.Configure<FreePaymentServiceProvider>(FreePaymentServiceProvider.PaymentMethod);
// options.Providers.Configure<PrepaymentPaymentServiceProvider>(PrepaymentPaymentServiceProvider.PaymentMethod);
// options.Providers.Configure<WeChatPayPaymentServiceProvider>(WeChatPayPaymentServiceProvider.PaymentMethod);
});
```

2. Choose the payment service providers you want:
Expand All @@ -58,4 +59,4 @@ We have launched an online demo for this module: [https://pay.samples.easyabp.io
- [ ] Support Paypal.
- [ ] Support Alipay.
- [ ] Support Bitcoin payment.
- [ ] Unit tests.
- [x] Unit tests.
10 changes: 5 additions & 5 deletions docs/WeChatPay/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# PaymentService.WeChatPay

[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2FEasyAbp%2FPaymentService%2Fmaster%2FDirectory.Build.props)](https://abp.io)
[![NuGet](https://img.shields.io/nuget/v/EasyAbp.PaymentService.WeChatPay.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.PaymentService.WeChatPay.Domain.Shared)
[![NuGet Download](https://img.shields.io/nuget/dt/EasyAbp.PaymentService.WeChatPay.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.PaymentService.WeChatPay.Domain.Shared)
[![Discord online](https://badgen.net/discord/online-members/S6QaezrCRq?label=Discord)](https://discord.gg/S6QaezrCRq)
[![GitHub stars](https://img.shields.io/github/stars/EasyAbp/PaymentService?style=social)](https://www.github.com/EasyAbp/PaymentService)

WeChatPay implementation of the EasyAbp.PaymentService module.
Expand Down Expand Up @@ -36,12 +38,10 @@ We have launched an online demo for this module: [https://pay.samples.easyabp.io

1. Register the WeChatPay payment method:
```csharp
public override void OnApplicationInitialization(ApplicationInitializationContext context)
Configure<PaymentServiceOptions>(options =>
{
var resolver = context.ServiceProvider.GetRequiredService<IPaymentServiceResolver>();

resolver.TryRegisterProvider(WeChatPayPaymentServiceProvider.PaymentMethod, typeof(WeChatPayPaymentServiceProvider));
}
options.Providers.Configure<WeChatPayPaymentServiceProvider>(WeChatPayPaymentServiceProvider.PaymentMethod);
});
```

2. Configure the [WeChatPay settings](https://github.com/EasyAbp/PaymentService/blob/master/modules/EasyAbp.PaymentService.WeChatPay/src/EasyAbp.PaymentService.WeChatPay.Domain/EasyAbp/PaymentService/WeChatPay/Settings/WeChatPaySettings.cs), you can try to use [SettingUI](https://github.com/EasyAbp/Abp.SettingUi) to finish this work.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Authorization" Version="$(AbpVersion)" />
<ProjectReference Include="..\EasyAbp.PaymentService.Prepayment.Domain.Shared\EasyAbp.PaymentService.Prepayment.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\EasyAbp.PaymentService\src\EasyAbp.PaymentService.Domain.Shared\EasyAbp.PaymentService.Domain.Shared.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace EasyAbp.PaymentService.Prepayment
{
[DependsOn(
typeof(PaymentServicePrepaymentDomainSharedModule),
typeof(PaymentServiceDomainSharedModule),
typeof(AbpDddApplicationContractsModule),
typeof(AbpAuthorizationModule)
)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public override async Task<AccountDto> GetAsync(Guid id)
return dto;
}

protected override IQueryable<Account> CreateFilteredQuery(GetAccountListInput input)
protected override async Task<IQueryable<Account>> CreateFilteredQueryAsync(GetAccountListInput input)
{
return base.CreateFilteredQuery(input).WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value);
return (await base.CreateFilteredQueryAsync(input))
.WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value);
}

[Authorize]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public override async Task<PagedResultDto<TransactionDto>> GetListAsync(GetTrans
return await base.GetListAsync(input);
}

protected override IQueryable<Transaction> CreateFilteredQuery(GetTransactionListInput input)
protected override async Task<IQueryable<Transaction>> CreateFilteredQueryAsync(GetTransactionListInput input)
{
return base.CreateFilteredQuery(input).Where(x => x.AccountId == input.AccountId);
return (await base.CreateFilteredQueryAsync(input)).Where(x => x.AccountId == input.AccountId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public WithdrawalRequestAppService(
_repository = repository;
}

protected override IQueryable<WithdrawalRequest> CreateFilteredQuery(GetWithdrawalRequestListInput input)
protected override async Task<IQueryable<WithdrawalRequest>> CreateFilteredQueryAsync(GetWithdrawalRequestListInput input)
{
return base.CreateFilteredQuery(input)
return (await base.CreateFilteredQueryAsync(input))
.WhereIf(input.PendingOnly, x => !x.ReviewTime.HasValue)
.WhereIf(input.AccountId.HasValue, x => x.AccountId == input.AccountId.Value)
.WhereIf(input.AccountUserId.HasValue, x => x.AccountUserId == input.AccountUserId.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="5.0.*" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.*" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Volo.Abp.Data;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
using Volo.Abp.Users;

namespace EasyAbp.PaymentService.Prepayment.PaymentService
Expand Down Expand Up @@ -47,14 +48,15 @@ public PrepaymentPaymentServiceProvider(
_accountGroupConfigurationProvider = accountGroupConfigurationProvider;
}

[UnitOfWork(true)]
public override async Task OnPaymentStartedAsync(Payment payment, ExtraPropertyDictionary configurations)
{
if (payment.ActualPaymentAmount <= decimal.Zero)
{
throw new PaymentAmountInvalidException(payment.ActualPaymentAmount, PaymentMethod);
throw new PaymentAmountInvalidException(payment.ActualPaymentAmount, payment.PaymentMethod);
}

if (!Guid.TryParse(configurations.GetOrDefault("AccountId") as string, out var accountId))
if (!Guid.TryParse(configurations.GetOrDefault("AccountId").ToString(), out var accountId))
{
throw new ArgumentNullException("AccountId");
}
Expand Down Expand Up @@ -110,6 +112,7 @@ public override async Task OnCancelStartedAsync(Payment payment)
await _paymentManager.CompleteCancelAsync(payment);
}

[UnitOfWork(true)]
public override async Task OnRefundStartedAsync(Payment payment, Refund refund)
{
if (!Guid.TryParse(payment.GetProperty<string>("AccountId"), out var accountId))
Expand All @@ -121,7 +124,7 @@ public override async Task OnRefundStartedAsync(Payment payment, Refund refund)

var configuration = _accountGroupConfigurationProvider.Get(account.AccountGroupName);

var accountChangedBalance = payment.ActualPaymentAmount;
var accountChangedBalance = refund.RefundAmount;

var transaction = new Transaction(_guidGenerator.Create(), _currentTenant.Id, account.Id, account.UserId,
payment.Id, TransactionType.Debit, PrepaymentConsts.RefundActionName, payment.PaymentMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="..\..\..\..\common.props" />

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace />
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace EasyAbp.PaymentService.Prepayment.Accounts
{
public class AccountRepository : EfCoreRepository<IPrepaymentDbContext, Account, Guid>, IAccountRepository
public class AccountRepository : EfCoreRepository<IPaymentServicePrepaymentDbContext, Account, Guid>, IAccountRepository
{
public AccountRepository(IDbContextProvider<IPrepaymentDbContext> dbContextProvider) : base(dbContextProvider)
public AccountRepository(IDbContextProvider<IPaymentServicePrepaymentDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace EasyAbp.PaymentService.Prepayment.EntityFrameworkCore
{
[ConnectionStringName(PrepaymentDbProperties.ConnectionStringName)]
public interface IPrepaymentDbContext : IEfCoreDbContext
public interface IPaymentServicePrepaymentDbContext : IEfCoreDbContext
{
/* Add DbSet for each Aggregate Root here. Example:
* DbSet<Question> Questions { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace EasyAbp.PaymentService.Prepayment.EntityFrameworkCore
{
[ConnectionStringName(PrepaymentDbProperties.ConnectionStringName)]
public class PrepaymentDbContext : AbpDbContext<PrepaymentDbContext>, IPrepaymentDbContext
public class PaymentServicePrepaymentDbContext : AbpDbContext<PaymentServicePrepaymentDbContext>, IPaymentServicePrepaymentDbContext
{
/* Add DbSet for each Aggregate Root here. Example:
* public DbSet<Question> Questions { get; set; }
Expand All @@ -19,7 +19,7 @@ public class PrepaymentDbContext : AbpDbContext<PrepaymentDbContext>, IPrepaymen
public DbSet<WithdrawalRecord> WithdrawalRecords { get; set; }
public DbSet<WithdrawalRequest> WithdrawalRequests { get; set; }

public PrepaymentDbContext(DbContextOptions<PrepaymentDbContext> options)
public PaymentServicePrepaymentDbContext(DbContextOptions<PaymentServicePrepaymentDbContext> options)
: base(options)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class PaymentServicePrepaymentEntityFrameworkCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<PrepaymentDbContext>(options =>
context.Services.AddAbpDbContext<PaymentServicePrepaymentDbContext>(options =>
{
/* Add custom repositories here. Example:
* options.AddRepository<Question, EfCoreQuestionRepository>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static void ConfigurePaymentServicePrepayment(
/* Configure more properties here */
b.Property(x => x.Balance).HasColumnType("decimal(20,8)");
b.Property(x => x.LockedBalance).HasColumnType("decimal(20,8)");
b.Property(x => x.PendingWithdrawalAmount).HasColumnType("decimal(20,8)");
b.HasIndex(x => x.UserId);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace EasyAbp.PaymentService.Prepayment.Transactions
{
public class TransactionRepository : EfCoreRepository<IPrepaymentDbContext, Transaction, Guid>, ITransactionRepository
public class TransactionRepository : EfCoreRepository<IPaymentServicePrepaymentDbContext, Transaction, Guid>, ITransactionRepository
{
public TransactionRepository(IDbContextProvider<IPrepaymentDbContext> dbContextProvider) : base(dbContextProvider)
public TransactionRepository(IDbContextProvider<IPaymentServicePrepaymentDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace EasyAbp.PaymentService.Prepayment.WithdrawalRecords
{
public class WithdrawalRecordRepository : EfCoreRepository<IPrepaymentDbContext, WithdrawalRecord, Guid>,
public class WithdrawalRecordRepository : EfCoreRepository<IPaymentServicePrepaymentDbContext, WithdrawalRecord, Guid>,
IWithdrawalRecordRepository
{
public WithdrawalRecordRepository(IDbContextProvider<IPrepaymentDbContext> dbContextProvider) : base(
public WithdrawalRecordRepository(IDbContextProvider<IPaymentServicePrepaymentDbContext> dbContextProvider) : base(
dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace EasyAbp.PaymentService.Prepayment.WithdrawalRequests
{
public class WithdrawalRequestRepository : EfCoreRepository<IPrepaymentDbContext, WithdrawalRequest, Guid>, IWithdrawalRequestRepository
public class WithdrawalRequestRepository : EfCoreRepository<IPaymentServicePrepaymentDbContext, WithdrawalRequest, Guid>, IWithdrawalRequestRepository
{
public WithdrawalRequestRepository(IDbContextProvider<IPrepaymentDbContext> dbContextProvider) : base(dbContextProvider)
public WithdrawalRequestRepository(IDbContextProvider<IPaymentServicePrepaymentDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
<ProjectReference Include="..\EasyAbp.PaymentService.Prepayment.Application.Contracts\EasyAbp.PaymentService.Prepayment.Application.Contracts.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="**\*generate-proxy.json" />
<Content Remove="**\*generate-proxy.json" />
</ItemGroup>

</Project>
Loading

0 comments on commit 3adea26

Please sign in to comment.