feat: Enhance network membership and withdrawal processing with user tracking and logging

This commit is contained in:
masoodafar-web
2025-12-01 20:52:18 +03:30
parent 4aaf2247ff
commit 25fc73ae28
47 changed files with 9545 additions and 284 deletions

View File

@@ -0,0 +1,122 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class UpdateNetworkWeeklyBalanceWithCarryover : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "LeftLegCarryover",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "LeftLegNewMembers",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "LeftLegRemainder",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "LeftLegTotal",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "RightLegCarryover",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "RightLegNewMembers",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "RightLegRemainder",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "RightLegTotal",
schema: "CMS",
table: "NetworkWeeklyBalances",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LeftLegCarryover",
schema: "CMS",
table: "NetworkWeeklyBalances");
migrationBuilder.DropColumn(
name: "LeftLegNewMembers",
schema: "CMS",
table: "NetworkWeeklyBalances");
migrationBuilder.DropColumn(
name: "LeftLegRemainder",
schema: "CMS",
table: "NetworkWeeklyBalances");
migrationBuilder.DropColumn(
name: "LeftLegTotal",
schema: "CMS",
table: "NetworkWeeklyBalances");
migrationBuilder.DropColumn(
name: "RightLegCarryover",
schema: "CMS",
table: "NetworkWeeklyBalances");
migrationBuilder.DropColumn(
name: "RightLegNewMembers",
schema: "CMS",
table: "NetworkWeeklyBalances");
migrationBuilder.DropColumn(
name: "RightLegRemainder",
schema: "CMS",
table: "NetworkWeeklyBalances");
migrationBuilder.DropColumn(
name: "RightLegTotal",
schema: "CMS",
table: "NetworkWeeklyBalances");
}
}
}

View File

@@ -0,0 +1,70 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddWorkerExecutionLog : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "WorkerExecutionLogs",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ExecutionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
WeekNumber = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
StartedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
CompletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
DurationMs = table.Column<long>(type: "bigint", nullable: true),
Status = table.Column<int>(type: "int", nullable: false),
ProcessedCount = table.Column<int>(type: "int", nullable: false),
ErrorCount = table.Column<int>(type: "int", nullable: false),
ErrorMessage = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
ErrorStackTrace = table.Column<string>(type: "nvarchar(max)", nullable: true),
Details = table.Column<string>(type: "nvarchar(max)", nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkerExecutionLogs", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_WorkerExecutionLogs_StartedAt",
schema: "CMS",
table: "WorkerExecutionLogs",
column: "StartedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkerExecutionLogs_Status",
schema: "CMS",
table: "WorkerExecutionLogs",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_WorkerExecutionLogs_WeekNumber",
schema: "CMS",
table: "WorkerExecutionLogs",
column: "WeekNumber");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "WorkerExecutionLogs",
schema: "CMS");
}
}
}

View File

@@ -0,0 +1,57 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddProcessedByToWithdrawal : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "ProcessedAt",
schema: "CMS",
table: "UserCommissionPayouts",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProcessedBy",
schema: "CMS",
table: "UserCommissionPayouts",
type: "nvarchar(200)",
maxLength: 200,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "RejectionReason",
schema: "CMS",
table: "UserCommissionPayouts",
type: "nvarchar(500)",
maxLength: 500,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProcessedAt",
schema: "CMS",
table: "UserCommissionPayouts");
migrationBuilder.DropColumn(
name: "ProcessedBy",
schema: "CMS",
table: "UserCommissionPayouts");
migrationBuilder.DropColumn(
name: "RejectionReason",
schema: "CMS",
table: "UserCommissionPayouts");
}
}
}

View File

@@ -261,6 +261,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<DateTime?>("PaidAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("ProcessedAt")
.HasColumnType("datetime2");
b.Property<string>("ProcessedBy")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("RejectionReason")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<int>("Status")
.HasColumnType("int");
@@ -360,6 +371,76 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.ToTable("WeeklyCommissionPools", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WorkerExecutionLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime?>("CompletedAt")
.HasColumnType("datetime2");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("Details")
.HasColumnType("nvarchar(max)");
b.Property<long?>("DurationMs")
.HasColumnType("bigint");
b.Property<int>("ErrorCount")
.HasColumnType("int");
b.Property<string>("ErrorMessage")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property<string>("ErrorStackTrace")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("ExecutionId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int>("ProcessedCount")
.HasColumnType("int");
b.Property<DateTime>("StartedAt")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<string>("WeekNumber")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");
b.HasKey("Id");
b.HasIndex("StartedAt");
b.HasIndex("Status");
b.HasIndex("WeekNumber");
b.ToTable("WorkerExecutionLogs", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b =>
{
b.Property<long>("Id")
@@ -810,9 +891,33 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<int>("LeftLegBalances")
.HasColumnType("int");
b.Property<int>("LeftLegCarryover")
.HasColumnType("int");
b.Property<int>("LeftLegNewMembers")
.HasColumnType("int");
b.Property<int>("LeftLegRemainder")
.HasColumnType("int");
b.Property<int>("LeftLegTotal")
.HasColumnType("int");
b.Property<int>("RightLegBalances")
.HasColumnType("int");
b.Property<int>("RightLegCarryover")
.HasColumnType("int");
b.Property<int>("RightLegNewMembers")
.HasColumnType("int");
b.Property<int>("RightLegRemainder")
.HasColumnType("int");
b.Property<int>("RightLegTotal")
.HasColumnType("int");
b.Property<int>("TotalBalances")
.HasColumnType("int");