feat: ClubMembershipCycle IHasHistory + PackageId in WalletHistory (F1)
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m33s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m33s
- ClubMembershipCycle now implements IHasHistory<ClubMembershipCycleHistory> - CreateHistorySnapshot: New* fields from current state, Old* auto-filled by interceptor - Parses action string to ClubMembershipCycleAction enum - Add PackageId to 6 UserWalletHistory creation sites (F1 fix): - VerifyPackagePurchaseCommandHandler: balanceLog + discountLog (order.PackageId) - CheckAndProcessDayaLoansCommandHandler: mainLog + discountLog (package.Id) - CreateManualPaymentCommandHandler: walletLog (package.Id) - PackageService.CustomerVerifyPackagePurchase: walletLog (purchase.PackageId) - Non-package flows (orders, commissions, manual) correctly keep PackageId=null
This commit is contained in:
+4
-2
@@ -231,7 +231,8 @@ public class CheckAndProcessDayaLoansCommandHandler : IRequestHandler<CheckAndPr
|
|||||||
CurrentNetworkBalance = wallet.NetworkBalance,
|
CurrentNetworkBalance = wallet.NetworkBalance,
|
||||||
ChangeNerworkValue = 0,
|
ChangeNerworkValue = 0,
|
||||||
IsIncrease = true,
|
IsIncrease = true,
|
||||||
RefrenceId = transaction.Id
|
RefrenceId = transaction.Id,
|
||||||
|
PackageId = package.Id
|
||||||
};
|
};
|
||||||
await _context.UserWalletHistories.AddAsync(mainLog, cancellationToken);
|
await _context.UserWalletHistories.AddAsync(mainLog, cancellationToken);
|
||||||
|
|
||||||
@@ -249,7 +250,8 @@ public class CheckAndProcessDayaLoansCommandHandler : IRequestHandler<CheckAndPr
|
|||||||
CurrentDiscountBalance = 0,
|
CurrentDiscountBalance = 0,
|
||||||
ChangeDiscountValue = discountAmount,
|
ChangeDiscountValue = discountAmount,
|
||||||
IsIncrease = true,
|
IsIncrease = true,
|
||||||
RefrenceId = transaction.Id
|
RefrenceId = transaction.Id,
|
||||||
|
PackageId = package.Id
|
||||||
};
|
};
|
||||||
await _context.UserWalletHistories.AddAsync(discountLog, cancellationToken);
|
await _context.UserWalletHistories.AddAsync(discountLog, cancellationToken);
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -130,7 +130,8 @@ public class CreateManualPaymentCommandHandler : IRequestHandler<CreateManualPay
|
|||||||
CurrentDiscountBalance =0,
|
CurrentDiscountBalance =0,
|
||||||
ChangeDiscountValue = discountBalanceAmount,
|
ChangeDiscountValue = discountBalanceAmount,
|
||||||
IsIncrease = true,
|
IsIncrease = true,
|
||||||
RefrenceId = transaction.Id
|
RefrenceId = transaction.Id,
|
||||||
|
PackageId = package.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
await _context.UserWalletHistories.AddAsync(walletLog, cancellationToken);
|
await _context.UserWalletHistories.AddAsync(walletLog, cancellationToken);
|
||||||
|
|||||||
+4
-2
@@ -139,7 +139,8 @@ public class VerifyPackagePurchaseCommandHandler
|
|||||||
CurrentDiscountBalance = wallet.DiscountBalance - discountAmount, // قبل از شارژ DiscountBalance
|
CurrentDiscountBalance = wallet.DiscountBalance - discountAmount, // قبل از شارژ DiscountBalance
|
||||||
ChangeDiscountValue = 0,
|
ChangeDiscountValue = 0,
|
||||||
IsIncrease = true,
|
IsIncrease = true,
|
||||||
RefrenceId = transaction.Id
|
RefrenceId = transaction.Id,
|
||||||
|
PackageId = order.PackageId
|
||||||
};
|
};
|
||||||
await _context.UserWalletHistories.AddAsync(balanceLog, cancellationToken);
|
await _context.UserWalletHistories.AddAsync(balanceLog, cancellationToken);
|
||||||
|
|
||||||
@@ -154,7 +155,8 @@ public class VerifyPackagePurchaseCommandHandler
|
|||||||
CurrentDiscountBalance = wallet.DiscountBalance,
|
CurrentDiscountBalance = wallet.DiscountBalance,
|
||||||
ChangeDiscountValue = discountAmount,
|
ChangeDiscountValue = discountAmount,
|
||||||
IsIncrease = true,
|
IsIncrease = true,
|
||||||
RefrenceId = transaction.Id
|
RefrenceId = transaction.Id,
|
||||||
|
PackageId = order.PackageId
|
||||||
};
|
};
|
||||||
await _context.UserWalletHistories.AddAsync(discountLog, cancellationToken);
|
await _context.UserWalletHistories.AddAsync(discountLog, cancellationToken);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
using CMSMicroservice.Domain.Common;
|
||||||
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
namespace CMSMicroservice.Domain.Entities.Club;
|
namespace CMSMicroservice.Domain.Entities.Club;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// دوره خرید پکیج — هر بار خرید پکیج ۵۶M یک Cycle جدید ایجاد میشود.
|
/// دوره خرید پکیج — هر بار خرید پکیج ۵۶M یک Cycle جدید ایجاد میشود.
|
||||||
/// برای حل مشکل overwrite شدن ClubMembership.ActivatedAt در محاسبه کمیسیون.
|
/// برای حل مشکل overwrite شدن ClubMembership.ActivatedAt در محاسبه کمیسیون.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ClubMembershipCycle : BaseAuditableEntity
|
public class ClubMembershipCycle : BaseAuditableEntity, IHasHistory<History.ClubMembershipCycleHistory>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// شناسه کاربر
|
/// شناسه کاربر
|
||||||
@@ -74,4 +77,26 @@ public class ClubMembershipCycle : BaseAuditableEntity
|
|||||||
|
|
||||||
/// <summary>تاریخچه تغییرات دوره (Q27)</summary>
|
/// <summary>تاریخچه تغییرات دوره (Q27)</summary>
|
||||||
public virtual ICollection<History.ClubMembershipCycleHistory>? CycleHistories { get; set; }
|
public virtual ICollection<History.ClubMembershipCycleHistory>? CycleHistories { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ساخت snapshot تاریخچه از وضعیت فعلی چرخه.
|
||||||
|
/// مقادیر New* از وضعیت فعلی پر میشوند.
|
||||||
|
/// مقادیر Old* توسط HistoryTrackingSaveChangesInterceptor از OriginalValues پر میشوند.
|
||||||
|
/// </summary>
|
||||||
|
public History.ClubMembershipCycleHistory CreateHistorySnapshot(string action, string? performedBy)
|
||||||
|
{
|
||||||
|
return new History.ClubMembershipCycleHistory
|
||||||
|
{
|
||||||
|
ClubMembershipCycleId = Id,
|
||||||
|
UserId = UserId,
|
||||||
|
CycleNumber = CycleNumber,
|
||||||
|
NewIsCurrentCycle = IsCurrentCycle,
|
||||||
|
NewMagicStartedAt = MagicStartedAt,
|
||||||
|
NewMagicCompletedAt = MagicCompletedAt,
|
||||||
|
Action = Enum.TryParse<ClubMembershipCycleAction>(action, out var a)
|
||||||
|
? a
|
||||||
|
: ClubMembershipCycleAction.ManualFix,
|
||||||
|
PerformedBy = performedBy
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,7 +331,8 @@ public class PackageService : PackageContract.PackageContractBase
|
|||||||
CurrentDiscountBalance = wallet.DiscountBalance,
|
CurrentDiscountBalance = wallet.DiscountBalance,
|
||||||
ChangeDiscountValue = discountAmount,
|
ChangeDiscountValue = discountAmount,
|
||||||
IsIncrease = true,
|
IsIncrease = true,
|
||||||
RefrenceId = transaction.Id
|
RefrenceId = transaction.Id,
|
||||||
|
PackageId = purchase.PackageId
|
||||||
};
|
};
|
||||||
_context.UserWalletHistories.Add(walletLog);
|
_context.UserWalletHistories.Add(walletLog);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user