This commit is contained in:
masoodafar-web
2025-11-25 02:46:57 +03:30
parent 50ccd10e24
commit 34f66fcb2d
14 changed files with 457 additions and 420 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,8 @@ using CMSMicroservice.Protobuf.Protos.UserAddress;
using CMSMicroservice.Protobuf.Protos.UserCarts;
using CMSMicroservice.Protobuf.Protos.UserContract;
using CMSMicroservice.Protobuf.Protos.UserOrder;
using CMSMicroservice.Protobuf.Protos.UserWallet;
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
using PYMSMicroservice.Protobuf.Protos.Transaction;
namespace FrontOffice.BFF.Application.Common.Interfaces;
@@ -27,6 +29,8 @@ public interface IApplicationContractContext
UserAddressContract.UserAddressContractClient UserAddress { get; }
UserOrderContract.UserOrderContractClient UserOrder { get; }
OtpTokenContract.OtpTokenContractClient OtpToken { get; }
UserWalletContract.UserWalletContractClient UserWallet { get; }
UserWalletChangeLogContract.UserWalletChangeLogContractClient UserWalletChangeLog { get; }
#endregion
#region PYMS

View File

@@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FrontOffice.BFF.Domain\FrontOffice.BFF.Domain.csproj" />
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.UserOrder.Protobuf\FrontOffice.BFF.UserOrder.Protobuf.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,16 +1,28 @@
using CMSMicroservice.Protobuf.Protos.UserOrder;
namespace FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
public class SubmitShopBuyOrderCommandHandler : IRequestHandler<SubmitShopBuyOrderCommand, SubmitShopBuyOrderResponseDto>
public class
SubmitShopBuyOrderCommandHandler : IRequestHandler<SubmitShopBuyOrderCommand, SubmitShopBuyOrderResponseDto>
{
private readonly IApplicationContractContext _context;
private readonly ICurrentUserService _currentUserService;
public SubmitShopBuyOrderCommandHandler(IApplicationContractContext context)
public SubmitShopBuyOrderCommandHandler(IApplicationContractContext context, ICurrentUserService currentUserService)
{
_context = context;
_currentUserService = currentUserService;
}
public async Task<SubmitShopBuyOrderResponseDto> Handle(SubmitShopBuyOrderCommand request, CancellationToken cancellationToken)
public async Task<SubmitShopBuyOrderResponseDto> Handle(SubmitShopBuyOrderCommand request,
CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new SubmitShopBuyOrderResponseDto();
var result = await _context.UserOrder.SubmitShopBuyOrderAsync(new SubmitShopBuyOrderRequest()
{
UserId = _currentUserService.UserId.Value,
TotalAmount = request.TotalAmount
}, cancellationToken: cancellationToken);
return result.Adapt<SubmitShopBuyOrderResponseDto>();
// return new SubmitShopBuyOrderResponseDto();
}
}
}

View File

@@ -1,3 +1,7 @@
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
namespace FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
public class SubmitShopBuyOrderResponseDto
{

View File

@@ -1,16 +1,26 @@
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
namespace FrontOffice.BFF.Application.UserWalletCQ.Queries.GetAllUserWalletChangeLog;
public class GetAllUserWalletChangeLogQueryHandler : IRequestHandler<GetAllUserWalletChangeLogQuery, Unit>
{
private readonly IApplicationContractContext _context;
private readonly ICurrentUserService _currentUserService;
public GetAllUserWalletChangeLogQueryHandler(IApplicationContractContext context)
public GetAllUserWalletChangeLogQueryHandler(IApplicationContractContext context, ICurrentUserService currentUserService)
{
_context = context;
_currentUserService = currentUserService;
}
public async Task<Unit> Handle(GetAllUserWalletChangeLogQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
await _context.UserWalletChangeLog.GetAllUserWalletChangeLogByFilterAsync(new GetAllUserWalletChangeLogByFilterRequest()
{
Filter = new GetAllUserWalletChangeLogByFilterFilter()
{
UserId = _currentUserService.UserId.Value
}
}, cancellationToken: cancellationToken);
return new Unit();
}
}

View File

@@ -1,16 +1,32 @@
using CMSMicroservice.Protobuf.Protos.UserWallet;
namespace FrontOffice.BFF.Application.UserWalletCQ.Queries.GetUserWallet;
public class GetUserWalletQueryHandler : IRequestHandler<GetUserWalletQuery, GetUserWalletResponseDto>
{
private readonly IApplicationContractContext _context;
private readonly ICurrentUserService _currentUserService;
public GetUserWalletQueryHandler(IApplicationContractContext context)
public GetUserWalletQueryHandler(IApplicationContractContext context, ICurrentUserService currentUserService)
{
_context = context;
_currentUserService = currentUserService;
}
public async Task<GetUserWalletResponseDto> Handle(GetUserWalletQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetUserWalletResponseDto();
var userWallet = await _context.UserWallet.GetAllUserWalletByFilterAsync(new GetAllUserWalletByFilterRequest()
{
Filter = new GetAllUserWalletByFilterFilter()
{
UserId = _currentUserService.UserId.Value,
}
});
if (userWallet.Models.Count == 0)
{
throw new NotFoundException("UserWallet", _currentUserService.UserId.Value);
}
return userWallet.Models.FirstOrDefault().Adapt<GetUserWalletResponseDto>();
}
}
}

View File

@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.124" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.127" />
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.76.0">

View File

@@ -6,6 +6,8 @@ using CMSMicroservice.Protobuf.Protos.UserAddress;
using CMSMicroservice.Protobuf.Protos.UserCarts;
using CMSMicroservice.Protobuf.Protos.UserContract;
using CMSMicroservice.Protobuf.Protos.UserOrder;
using CMSMicroservice.Protobuf.Protos.UserWallet;
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
using FrontOffice.BFF.Application.Common.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using PYMSMicroservice.Protobuf.Protos.Transaction;
@@ -54,6 +56,8 @@ public class ApplicationContractContext : IApplicationContractContext
public UserOrderContract.UserOrderContractClient UserOrder => GetService<UserOrderContract.UserOrderContractClient>();
public OtpTokenContract.OtpTokenContractClient OtpToken => GetService<OtpTokenContract.OtpTokenContractClient>();
public UserWalletContract.UserWalletContractClient UserWallet => GetService<UserWalletContract.UserWalletContractClient>();
public UserWalletChangeLogContract.UserWalletChangeLogContractClient UserWalletChangeLog => GetService<UserWalletChangeLogContract.UserWalletChangeLogContractClient>();
#endregion
#region PYMS

View File

@@ -23,6 +23,7 @@
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.Products.Protobuf\FrontOffice.BFF.Products.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.ShopingCart.Protobuf\FrontOffice.BFF.ShopingCart.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.Transaction.Protobuf\FrontOffice.BFF.Transaction.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.UserWallet.Protobuf\FrontOffice.BFF.UserWallet.Protobuf.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.User.Protobuf\FrontOffice.BFF.User.Protobuf.csproj" />

View File

@@ -1,4 +1,3 @@
using FrontOffice.BFF.Protobuf.Protos.UserOrder;
using FrontOffice.BFF.WebApi.Common.Services;
using FrontOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder;
using FrontOffice.BFF.Application.UserOrderCQ.Commands.UpdateUserOrder;
@@ -6,6 +5,8 @@ using FrontOffice.BFF.Application.UserOrderCQ.Commands.DeleteUserOrder;
using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetUserOrder;
using FrontOffice.BFF.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter;
using FrontOffice.BFF.Application.UserOrderCQ.Commands.SubmitShopBuyOrder;
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
namespace FrontOffice.BFF.WebApi.Services;
public class UserOrderService : UserOrderContract.UserOrderContractBase
{

View File

@@ -1,9 +1,10 @@
using FrontOffice.BFF.Protobuf.Protos.UserWallet;
using FrontOffice.BFF.WebApi.Common.Services;
using FrontOffice.BFF.Application.UserWalletCQ.Queries.GetAllUserWalletChangeLog;
using FrontOffice.BFF.Application.UserWalletCQ.Queries.GetUserWallet;
using FrontOffice.BFF.Application.UserWalletCQ.Commands.TransferUserWalletBallance;
using FrontOffice.BFF.Application.UserWalletCQ.Commands.WithdrawBalance;
using FrontOffice.BFF.UserWallet.Protobuf.Protos.UserWallet;
namespace FrontOffice.BFF.WebApi.Services;
public class UserWalletService : UserWalletContract.UserWalletContractBase
{

View File

@@ -26,6 +26,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.BFF.Products.Pr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.BFF.ShopingCart.Protobuf", "Protobufs\FrontOffice.BFF.ShopingCart.Protobuf\FrontOffice.BFF.ShopingCart.Protobuf.csproj", "{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.BFF.UserWallet.Protobuf", "Protobufs\FrontOffice.BFF.UserWallet.Protobuf\FrontOffice.BFF.UserWallet.Protobuf.csproj", "{03F99CE9-F952-47B0-B71A-1F4865E52443}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -76,6 +78,10 @@ Global
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}.Release|Any CPU.Build.0 = Release|Any CPU
{03F99CE9-F952-47B0-B71A-1F4865E52443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03F99CE9-F952-47B0-B71A-1F4865E52443}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03F99CE9-F952-47B0-B71A-1F4865E52443}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03F99CE9-F952-47B0-B71A-1F4865E52443}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -88,5 +94,6 @@ Global
{F59861D9-01D6-44C9-85A9-E6050D55D290} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
{CB77669F-5B48-4AC6-B20E-A928660E93F8} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
{03F99CE9-F952-47B0-B71A-1F4865E52443} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
EndGlobalSection
EndGlobal

View File

@@ -1,5 +1,5 @@
using FluentValidation;
using FrontOfficeMicroservice.Protobuf.Protos.UserOrder;
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
namespace FrontOfficeMicroservice.Protobuf.Validator.UserOrder;
public class SubmitShopBuyOrderRequestValidator : AbstractValidator<SubmitShopBuyOrderRequest>