6220049161
- Added SystemConstants class to centralize hardcoded values for club configuration, commission configuration, and package amounts. - Introduced SmsTemplates class to manage SMS message templates for various user notifications. - Implemented automatic SMS sending for Daya Loan approval notifications. - Updated BackOffice UI to include App Version management features. - Fixed mapping issues in Mapster profiles for improved data handling. - Updated changelog and documentation to reflect recent changes and configurations.
121 lines
3.9 KiB
Markdown
121 lines
3.9 KiB
Markdown
# 🔧 SystemConstants - مقادیر ثابت سیستم
|
|
|
|
> **فایل**: `CMSMicroservice.Domain/Common/SystemConstants.cs`
|
|
> **آخرین بروزرسانی**: ۷ دی ۱۴۰۴
|
|
|
|
---
|
|
|
|
## 📋 هدف
|
|
|
|
این کلاس شامل تمام مقادیر ثابت سیستم است که در چندین جای مختلف استفاده میشوند.
|
|
به جای hardcode کردن اعداد در کد، از این ثابتها استفاده کنید.
|
|
|
|
---
|
|
|
|
## 📊 مقادیر موجود
|
|
|
|
### Club Configuration
|
|
|
|
| ثابت | مقدار | توضیح |
|
|
|------|-------|-------|
|
|
| `ClubJoiningPercentage` | 0.35 (35%) | درصد کمیسیون پیوستن به باشگاه |
|
|
| `ClubActivationThreshold` | 0.5 (50%) | آستانه فعالسازی باشگاه |
|
|
|
|
### Commission Configuration
|
|
|
|
| ثابت | مقدار | توضیح |
|
|
|------|-------|-------|
|
|
| `MaxCalculationAttempts` | 3 | حداکثر تلاش برای محاسبه کمیسیون |
|
|
| `DefaultCommissionPoolDays` | 7 | تعداد روزهای استخر کمیسیون |
|
|
|
|
### Package Amounts
|
|
|
|
| ثابت | مقدار | توضیح |
|
|
|------|-------|-------|
|
|
| `GoldenPackageAmount` | 56,000,000 | مبلغ پکیج طلایی (56 میلیون ریال) |
|
|
| `DayaLoanAmount` | 56,000,000 | مبلغ وام دایا (56 میلیون ریال) |
|
|
|
|
---
|
|
|
|
## 💻 کد
|
|
|
|
```csharp
|
|
namespace CMSMicroservice.Domain.Common;
|
|
|
|
/// <summary>
|
|
/// مقادیر ثابت سیستم که در چند جای مختلف استفاده میشوند
|
|
/// </summary>
|
|
public static class SystemConstants
|
|
{
|
|
// Club Configuration
|
|
public const decimal ClubJoiningPercentage = 0.35m; // 35% کمیسیون پیوستن به باشگاه
|
|
public const decimal ClubActivationThreshold = 0.5m; // 50% آستانه فعالسازی
|
|
|
|
// Commission Configuration
|
|
public const int MaxCalculationAttempts = 3; // حداکثر تلاش محاسبه
|
|
public const int DefaultCommissionPoolDays = 7; // روزهای استخر کمیسیون
|
|
|
|
// Package Amounts
|
|
public const long GoldenPackageAmount = 56_000_000; // 56 میلیون - پکیج طلایی
|
|
public const long DayaLoanAmount = 56_000_000; // 56 میلیون - وام دایا
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 🔍 نحوه استفاده
|
|
|
|
### در Handler ها:
|
|
|
|
```csharp
|
|
using CMSMicroservice.Domain.Common;
|
|
|
|
public class ProcessDayaLoanApprovalCommandHandler
|
|
{
|
|
public async Task<Unit> Handle(...)
|
|
{
|
|
// به جای: var amount = 56_000_000;
|
|
var amount = SystemConstants.DayaLoanAmount;
|
|
|
|
await DepositToWallet(userId, amount);
|
|
}
|
|
}
|
|
```
|
|
|
|
### در Validation ها:
|
|
|
|
```csharp
|
|
public class ValidateGoldenPackagePurchaseQueryHandler
|
|
{
|
|
public async Task<bool> Handle(...)
|
|
{
|
|
var requiredAmount = SystemConstants.GoldenPackageAmount;
|
|
return user.WalletBalance >= requiredAmount;
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## ⚠️ قوانین
|
|
|
|
1. **همیشه از ثابتها استفاده کنید** - هرگز مقادیر magic number در کد ننویسید
|
|
2. **تغییر مقادیر** - برای تغییر یک مقدار، فقط این فایل را تغییر دهید
|
|
3. **ثابتهای جدید** - اگر مقداری در بیش از یک جا استفاده میشود، به این فایل اضافه کنید
|
|
4. **نامگذاری** - از نامهای توصیفی استفاده کنید (مثلاً `GoldenPackageAmount` نه `Amount1`)
|
|
|
|
---
|
|
|
|
## 📁 فایلهای مرتبط
|
|
|
|
- `SmsTemplates.cs` - قالبهای پیامک
|
|
- `ProcessDayaLoanApprovalCommandHandler.cs` - استفاده از DayaLoanAmount
|
|
- `ValidateGoldenPackagePurchaseQueryHandler.cs` - استفاده از GoldenPackageAmount
|
|
|
|
---
|
|
|
|
## 🔗 Related Docs
|
|
|
|
- [email-sms-configuration.md](email-sms-configuration.md) - تنظیمات SMS و قالبها
|
|
- [CHANGELOG-2025-12-27.md](../../CHANGELOG-2025-12-27.md) - تاریخچه تغییرات
|