fix: validate discount wallet balance before applying discount in PlaceOrderCommandHandler
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m36s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m36s
This commit is contained in:
+12
-1
@@ -111,7 +111,18 @@ public class PlaceOrderCommandHandler : IRequestHandler<PlaceOrderCommand, Place
|
|||||||
|
|
||||||
// Always apply maximum possible discount (100%) — user cannot choose less
|
// Always apply maximum possible discount (100%) — user cannot choose less
|
||||||
var maxDiscountBalanceUsable = totalDiscountAmount;
|
var maxDiscountBalanceUsable = totalDiscountAmount;
|
||||||
var actualDiscountBalanceUsed = Math.Min(maxDiscountBalanceUsable, userWallet.DiscountBalance);
|
|
||||||
|
// بررسی کافی بودن موجودی کیف پول اعتباری (تخفیفی)
|
||||||
|
if (userWallet.DiscountBalance < maxDiscountBalanceUsable)
|
||||||
|
{
|
||||||
|
return new PlaceOrderResponseDto
|
||||||
|
{
|
||||||
|
Success = false,
|
||||||
|
Message = $"موجودی کیف پول اعتباری کافی نیست. مبلغ مورد نیاز: {maxDiscountBalanceUsable:N0} ریال، موجودی شما: {userWallet.DiscountBalance:N0} ریال"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var actualDiscountBalanceUsed = maxDiscountBalanceUsable;
|
||||||
|
|
||||||
_logger.LogInformation(
|
_logger.LogInformation(
|
||||||
"Discount auto-applied: max allowed={MaxAllowed}, wallet balance={WalletBalance}, used={Used}",
|
"Discount auto-applied: max allowed={MaxAllowed}, wallet balance={WalletBalance}, used={Used}",
|
||||||
|
|||||||
Reference in New Issue
Block a user