This commit is contained in:
masoodafar-web
2026-01-03 18:27:49 +03:30
parent 0369292d7f
commit 5965b98728
156 changed files with 16082 additions and 0 deletions
+264
View File
@@ -0,0 +1,264 @@
# 📝 Changelog - ۱۱ دی ۱۴۰۴ (31 December 2025)
> **Session**: Discount Shop Admin APIs Complete + BFF Layer Implementation
---
## 🎯 خلاصه Session
این session شامل موارد زیر بود:
1. **Product Image Gallery** - گالری تصاویر محصولات فروشگاه تخفیفی (CMS + BFF)
2. **GetAllDiscountOrders API** - API مدیریت سفارشات فروشگاه تخفیفی برای ادمین
3. **VAT Calculation** - محاسبه مالیات بر ارزش افزوده
4. **Sales Reports API** - گزارشات فروش روزانه/هفتگی/ماهانه با تقویم فارسی
5. **BFF WebApi Services** - سرویس‌های gRPC برای BackOffice.BFF
---
## ✨ تغییرات
### 1. 🖼️ Product Image Gallery (Phase 1) ✅
**توضیح**: پشتیبانی از گالری تصاویر برای محصولات فروشگاه تخفیفی
**فایل‌های CMS ایجاد شده**:
| فایل | توضیح |
|------|-------|
| `Domain/DiscountProduct/DiscountProductImage.cs` | Entity گالری تصویر |
| `Infrastructure/.../DiscountProductImageConfiguration.cs` | تنظیمات EF Core |
| `Application/.../AddDiscountProductImage/` | Command افزودن تصویر |
| `Application/.../UpdateDiscountProductImage/` | Command ویرایش تصویر |
| `Application/.../DeleteDiscountProductImage/` | Command حذف تصویر |
| `Application/.../ReorderDiscountProductImages/` | Command مرتب‌سازی تصاویر |
| `Application/.../GetDiscountProductImages/` | Query دریافت تصاویر |
**فایل‌های BFF Application ایجاد شده**:
| فایل | توضیح |
|------|-------|
| `DiscountProductCQ/Commands/AddDiscountProductImage/` | Command + Handler |
| `DiscountProductCQ/Commands/UpdateDiscountProductImage/` | Command + Handler |
| `DiscountProductCQ/Commands/DeleteDiscountProductImage/` | Command + Handler |
| `DiscountProductCQ/Commands/ReorderDiscountProductImages/` | Command + Handler |
| `DiscountProductCQ/Queries/GetDiscountProductImages/` | Query + Handler |
**Entity Structure**:
```csharp
public class DiscountProductImage : BaseEntity<long>
{
public long DiscountProductId { get; set; }
public string ImagePath { get; set; }
public string? ThumbnailPath { get; set; }
public string? Title { get; set; }
public string? AltText { get; set; }
public int SortOrder { get; set; }
public bool IsActive { get; set; }
}
```
---
### 2. 📋 GetAllDiscountOrders Admin API (Phase 2) ✅
**توضیح**: API برای مدیریت تمام سفارشات فروشگاه تخفیفی توسط ادمین
**فیلترهای پشتیبانی شده**:
- `UserId` - فیلتر بر اساس کاربر
- `PaymentStatus` - وضعیت پرداخت (Pending/Success/Reject)
- `DeliveryStatus` - وضعیت ارسال
- `UserMobile` - جستجو بر اساس موبایل
- `TrackingCode` - کد رهگیری
- `FromDate` / `ToDate` - بازه زمانی
- `MinAmount` / `MaxAmount` - بازه مبلغ
**فایل‌های CMS**:
- `Application/DiscountOrderCQ/Queries/GetAllDiscountOrders/`
- `WebApi/DiscountOrderService.cs` - افزودن RPC
**فایل‌های BFF**:
- `Application/DiscountOrderCQ/Queries/GetAllDiscountOrders/`
---
### 3. 💵 VAT Calculation (Phase 3) ✅
**توضیح**: سرویس محاسبه مالیات بر ارزش افزوده (۱۰٪)
**فایل‌های ایجاد شده**:
- `CMS/Application/Common/Services/VatCalculator.cs`
**متدها**:
```csharp
public class VatCalculator : IVatCalculator
{
public const decimal VatRate = 0.10m; // 10% VAT
public decimal CalculateVat(decimal amount);
public decimal CalculateTotalWithVat(decimal amount);
public decimal CalculateBaseFromTotal(decimal totalWithVat);
public (decimal baseAmount, decimal vatAmount, decimal total) CalculateBreakdown(decimal amount);
}
```
**یکپارچه‌سازی**: در `PlaceOrderCommandHandler` استفاده شده
---
### 4. 📊 Sales Reports API (Phase 4) ✅
**توضیح**: گزارشات فروش با پشتیبانی تقویم فارسی
**انواع گزارش**:
- `Summary` - خلاصه کلی
- `Daily` - روزانه
- `Weekly` - هفتگی
- `Monthly` - ماهانه
**فایل‌های CMS**:
- `Application/DiscountOrderCQ/Queries/GetDiscountSalesReport/`
**فایل‌های BFF**:
- `Application/DiscountOrderCQ/Queries/GetDiscountSalesReport/`
**Response Structure**:
```csharp
public class DiscountSalesReportDto
{
public SalesSummaryDto Summary { get; set; }
public List<PeriodSalesDto> Periods { get; set; }
}
public class SalesSummaryDto
{
public int TotalOrders { get; set; }
public int SuccessfulOrders { get; set; }
public int PendingOrders { get; set; }
public int RejectedOrders { get; set; }
public decimal TotalRevenue { get; set; }
public decimal TotalDiscountUsed { get; set; }
public decimal TotalGatewayPayments { get; set; }
public decimal TotalVat { get; set; }
public int UniqueCustomers { get; set; }
}
```
---
### 5. 🔌 BFF WebApi gRPC Services (Phase 5) ✅
**توضیح**: سرویس‌های gRPC در لایه WebApi برای expose کردن APIها
**فایل‌های ایجاد شده**:
| فایل | توضیح |
|------|-------|
| `BackOffice.BFF.WebApi/Services/DiscountProductService.cs` | سرویس محصولات تخفیفی |
| `BackOffice.BFF.WebApi/Services/DiscountOrderService.cs` | سرویس سفارشات تخفیفی |
**تغییرات Proto Projects**:
```xml
<!-- Before -->
<Protobuf GrpcServices="Client" />
<!-- After -->
<Protobuf GrpcServices="Both" />
```
**فایل‌های تغییر یافته**:
- `BackOffice.BFF.DiscountProduct.Protobuf.csproj`
- `BackOffice.BFF.DiscountOrder.Protobuf.csproj`
- `BackOffice.BFF.WebApi.csproj` - افزودن references
**DiscountProductService Endpoints**:
```csharp
// Product CRUD
CreateDiscountProduct
UpdateDiscountProduct
DeleteDiscountProduct
GetDiscountProductById
GetDiscountProducts
// Image Gallery (NEW)
AddDiscountProductImage
UpdateDiscountProductImage
DeleteDiscountProductImage
ReorderDiscountProductImages
GetDiscountProductImages
```
**DiscountOrderService Endpoints**:
```csharp
// Order Management
PlaceOrder
CompleteOrderPayment
UpdateOrderStatus
GetOrderById
GetUserOrders
// Admin APIs (NEW)
GetAllDiscountOrders
GetDiscountSalesReport
```
---
## 📁 ساختار فایل‌های جدید
```
CMS/src/
├── CMSMicroservice.Application/
│ ├── Common/Services/VatCalculator.cs
│ └── DiscountOrderCQ/Queries/
│ ├── GetAllDiscountOrders/
│ │ ├── GetAllDiscountOrdersQuery.cs
│ │ └── GetAllDiscountOrdersQueryHandler.cs
│ └── GetDiscountSalesReport/
│ ├── GetDiscountSalesReportQuery.cs
│ └── GetDiscountSalesReportQueryHandler.cs
├── CMSMicroservice.Domain/DiscountProduct/
│ └── DiscountProductImage.cs
├── CMSMicroservice.Infrastructure/.../
│ └── DiscountProductImageConfiguration.cs
└── CMSMicroservice.Protobuf/Protos/
├── discountproduct.proto (updated)
└── discountorder.proto (updated)
BackOffice.BFF/src/
├── BackOffice.BFF.Application/
│ ├── DiscountProductCQ/
│ │ ├── Commands/
│ │ │ ├── AddDiscountProductImage/
│ │ │ ├── UpdateDiscountProductImage/
│ │ │ ├── DeleteDiscountProductImage/
│ │ │ └── ReorderDiscountProductImages/
│ │ └── Queries/
│ │ └── GetDiscountProductImages/
│ └── DiscountOrderCQ/Queries/
│ ├── GetAllDiscountOrders/
│ └── GetDiscountSalesReport/
├── BackOffice.BFF.WebApi/Services/
│ ├── DiscountProductService.cs (NEW)
│ └── DiscountOrderService.cs (NEW)
└── Protobufs/
├── BackOffice.BFF.DiscountProduct.Protobuf/ (GrpcServices=Both)
└── BackOffice.BFF.DiscountOrder.Protobuf/ (GrpcServices=Both)
```
---
## ✅ Build Status
| Project | Status |
|---------|--------|
| CMS Solution | ✅ Build Succeeded |
| BackOffice.BFF Solution | ✅ Build Succeeded |
---
## 🔜 Next Steps
1. **BackOffice UI** - اتصال پنل ادمین به APIهای جدید
2. **FrontOffice.BFF** - پیاده‌سازی APIها برای فرانت‌آفیس (اگر نیاز باشد)
3. **Unit Tests** - نوشتن تست‌های واحد