fix(DiscountCode),VER 1.0.5.6

- Fix discount code use one time per user and customer
- Add Version 1.0.5.6
subProduct
Amir Hossein Khademi 2024-06-11 18:14:47 +03:30
parent da64ae5b40
commit 5edd394252
4 changed files with 11 additions and 5 deletions

View File

@ -1 +1 @@
1.0.4.5 1.0.5.6

View File

@ -6,8 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization> <InvariantGlobalization>true</InvariantGlobalization>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyVersion>1.0.4.5</AssemblyVersion> <AssemblyVersion>1.0.5.6</AssemblyVersion>
<FileVersion>1.0.4.5</FileVersion> <FileVersion>1.0.5.6</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -26,7 +26,7 @@
"ASPNETCORE_URLS": "http://+:80" "ASPNETCORE_URLS": "http://+:80"
}, },
"publishAllPorts": true, "publishAllPorts": true,
"DockerfileRunArguments": " --network=mother -p 32780:80" "DockerfileRunArguments": " --network=mother -p 32770:80"
} }
}, },
"$schema": "http://json.schemastore.org/launchsettings.json", "$schema": "http://json.schemastore.org/launchsettings.json",

View File

@ -24,9 +24,15 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
if (_currentUserService.UserId != null && Guid.TryParse(_currentUserService.UserId, out Guid userId)) if (_currentUserService.UserId != null && Guid.TryParse(_currentUserService.UserId, out Guid userId))
{ {
var customer = await _repositoryWrapper.SetRepository<Customer>()
.TableNoTracking
.FirstOrDefaultAsync(c => c.UserId == userId, cancellationToken);
if (customer == null)
throw new BaseApiException(ApiResultStatusCode.NotFound, "Customer not found");
var discountedUserOrder = await _repositoryWrapper.SetRepository<Order>() var discountedUserOrder = await _repositoryWrapper.SetRepository<Order>()
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(f => f.CustomerId == userId && f.DiscountCode == discount.Code, cancellationToken); .FirstOrDefaultAsync(f => f.CustomerId == customer.Id && f.DiscountCode == discount.Code, cancellationToken);
if (discountedUserOrder != null) if (discountedUserOrder != null)
throw new AppException("شما یک بار از این کد تخفیف استفاده کرده اید", ApiResultStatusCode.BadRequest); throw new AppException("شما یک بار از این کد تخفیف استفاده کرده اید", ApiResultStatusCode.BadRequest);
} }