feat(migrations): add ImageDocumentId column to ManualPayments table
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m36s

feat(mappings): implement DiscountCategoryProfile for mapping between application DTOs and protobuf responses
This commit is contained in:
masoodafar-web
2026-01-03 07:37:45 +03:30
parent bea43a0569
commit d3d021c007
6 changed files with 4048 additions and 6 deletions
@@ -73,12 +73,12 @@ public class CreateManualPaymentCommandHandler : IRequestHandler<CreateManualPay
// 4. محاسبه مبالغ
var balanceAmount = SystemConstants.BasePackageAmount; // 56M
var discountBalanceAmount = SystemConstants.BasePackageAmount * 2; // 112M
var totalAmount = balanceAmount + discountBalanceAmount; // 168M
// 5. ثبت تراکنش
var transaction = new Transaction
{
Amount = totalAmount,
Amount = balanceAmount,
Description = $"عضویت دستی باشگاه مشتریان - {request.Description} - مرجع: {request.ReferenceNumber}",
PaymentStatus = PaymentStatus.Success,
PaymentDate = DateTime.Now,
@@ -93,7 +93,7 @@ public class CreateManualPaymentCommandHandler : IRequestHandler<CreateManualPay
var manualPayment = new ManualPayment
{
UserId = request.UserId,
Amount = totalAmount,
Amount = balanceAmount,
Type = request.Type,
Description = request.Description,
ReferenceNumber = request.ReferenceNumber,
@@ -119,11 +119,11 @@ public class CreateManualPaymentCommandHandler : IRequestHandler<CreateManualPay
var walletLog = new UserWalletChangeLog
{
WalletId = wallet.Id,
CurrentBalance = wallet.Balance,
CurrentBalance = 0,
ChangeValue = balanceAmount,
CurrentNetworkBalance = wallet.NetworkBalance,
ChangeNerworkValue = 0,
CurrentDiscountBalance = wallet.DiscountBalance,
CurrentDiscountBalance =0,
ChangeDiscountValue = discountBalanceAmount,
IsIncrease = true,
RefrenceId = transaction.Id
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class u20 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "ImageDocumentId",
schema: "CMS",
table: "ManualPayments",
type: "bigint",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ImageDocumentId",
schema: "CMS",
table: "ManualPayments");
}
}
}
@@ -1879,6 +1879,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<long?>("ImageDocumentId")
.HasColumnType("bigint");
b.Property<string>("ImagePath")
.HasColumnType("nvarchar(max)");
@@ -3,7 +3,7 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.167</Version>
<Version>0.0.168</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
@@ -0,0 +1,61 @@
using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountCategories;
using CMSMicroservice.Protobuf.Protos.DiscountCategory;
using Mapster;
using AppDiscountCategoryDto = CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountCategories.DiscountCategoryDto;
using ProtoDiscountCategoryDto = CMSMicroservice.Protobuf.Protos.DiscountCategory.DiscountCategoryDto;
namespace CMSMicroservice.WebApi.Common.Mappings;
public class DiscountCategoryProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
// Map from Application DTO to Proto Response
config.NewConfig<GetDiscountCategoriesResponseDto, GetDiscountCategoriesResponse>()
.MapWith(src => MapToResponse(src));
// Map individual category DTO
config.NewConfig<AppDiscountCategoryDto, ProtoDiscountCategoryDto>()
.MapWith(src => MapCategory(src));
}
private static GetDiscountCategoriesResponse MapToResponse(GetDiscountCategoriesResponseDto src)
{
var response = new GetDiscountCategoriesResponse();
if (src.Categories != null)
{
foreach (var category in src.Categories)
{
response.Categories.Add(MapCategory(category));
}
}
return response;
}
private static ProtoDiscountCategoryDto MapCategory(AppDiscountCategoryDto src)
{
var proto = new ProtoDiscountCategoryDto
{
Id = src.Id,
Name = src.Name ?? string.Empty,
Title = src.Title ?? string.Empty,
Description = src.Description,
ImagePath = src.ImagePath,
ParentCategoryId = src.ParentCategoryId,
SortOrder = src.SortOrder,
IsActive = src.IsActive,
ProductCount = src.ProductCount
};
// Recursively map children
if (src.Children != null)
{
foreach (var child in src.Children)
{
proto.Children.Add(MapCategory(child));
}
}
return proto;
}
}