fix: add missing UserWalletChangeLog for discount shop purchases and discount wallet charge
Bug: when buying from discount shop, DiscountBalance was deducted from DB but no UserWalletChangeLog was created — making it invisible in wallet history. Same issue existed for discount wallet top-up (charge). Fixed in 3 handlers: - PlaceOrderCommandHandler (fully paid by discount balance path) - CompleteOrderPaymentCommandHandler (gateway + discount balance path) - VerifyDiscountWalletChargeCommandHandler (discount wallet charge)
This commit is contained in:
+15
@@ -114,6 +114,21 @@ public class VerifyDiscountWalletChargeCommandHandler
|
||||
_context.Transactions.Add(transaction);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
// ثبت لاگ تغییرات کیف پول (بعد از ایجاد Transaction برای داشتن TransactionId)
|
||||
_context.UserWalletChangeLogs.Add(new Domain.Entities.UserWalletChangeLog
|
||||
{
|
||||
WalletId = wallet.Id,
|
||||
CurrentBalance = wallet.Balance,
|
||||
ChangeValue = 0,
|
||||
CurrentNetworkBalance = wallet.NetworkBalance,
|
||||
ChangeNerworkValue = 0,
|
||||
CurrentDiscountBalance = wallet.DiscountBalance,
|
||||
ChangeDiscountValue = request.Amount,
|
||||
IsIncrease = true,
|
||||
RefrenceId = transaction.Id
|
||||
});
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
// لینک PaymentTransaction به Transaction داخلی
|
||||
if (paymentTx != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user