feat(commission): add per-package calculation support
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 15m3s

- SP sp_CalculateWeeklyBalances: added @PackageId, @InputMaxBalancesPerLeg, @InputMaxNetworkLevel params; filters by PackageId
- SP sp_CalculateWeeklyCommissionPool: added @PackageId param; all queries filter by PackageId/WeeklyPoolId for isolation
- ICommissionCalculationStrategy: added optional PackageId param to both methods
- StoredProcedureCommissionCalculationStrategy: loops per-package for both Balance and Pool methods; filters by packageId if provided
- OrmCommissionCalculationStrategy: signature updated to match interface
- TriggerWeeklyCalculationCommand: added PackageId optional field
- TriggerWeeklyCalculationCommandHandler: passes PackageId to strategy
- GetWeeklyCommissionPoolQuery: added optional PackageId filter
- GetWeeklyCommissionPoolQueryHandler: filters pool by PackageId if provided
- GetAllWeeklyPoolsQuery/Handler/DTO: added PackageId filter + PackageTitle in response
- Proto commission.proto: added package_id to TriggerWeeklyCalculationRequest, GetWeeklyCommissionPoolRequest, WeeklyCommissionPoolModel, GetWeeklyCommissionPoolResponse, GetAllWeeklyPoolsRequest
- CommissionProfile: added explicit mappings for TriggerWeeklyCalculation, GetWeeklyCommissionPool, GetAllWeeklyPools

Fixes: SP picks wrong pool when multiple packages per week
Fixes: SP ignores PackageId on ForceRecalculate (now uses WeeklyPoolId)
Fixes: Zero-balance pools not fully recorded (now sets TotalBalances=0, ValuePerBalance=0)
This commit is contained in:
masoodafar-web
2026-04-24 03:43:20 +03:30
parent a35e2eeb92
commit 4d6d77531d
14 changed files with 1548 additions and 40 deletions
@@ -197,6 +197,7 @@ message RejectWithdrawalRequest
message GetWeeklyCommissionPoolRequest
{
int64 week_definition_id = 1;
google.protobuf.Int64Value package_id = 2; // اگر خالی باشد اولین pool هفته را برمی‌گرداند
}
message GetWeeklyCommissionPoolResponse
@@ -209,6 +210,8 @@ message GetWeeklyCommissionPoolResponse
bool is_calculated = 7;
google.protobuf.Timestamp calculated_at = 8;
google.protobuf.Timestamp created = 9;
int64 package_id = 10;
string package_title = 11;
}
// GetUserCommissionPayouts Query
@@ -357,8 +360,9 @@ message GetAllWeeklyPoolsRequest
google.protobuf.Int64Value from_week_definition_id = 1; // WeekDefinitionId filter (optional)
google.protobuf.Int64Value to_week_definition_id = 2; // WeekDefinitionId filter (optional)
google.protobuf.BoolValue only_calculated = 3; // Only show calculated pools
int32 page_index = 4;
int32 page_size = 5;
google.protobuf.Int64Value package_id = 4; // فیلتر بر اساس پکیج (optional)
int32 page_index = 5;
int32 page_size = 6;
}
message GetAllWeeklyPoolsResponse
@@ -378,6 +382,8 @@ message WeeklyCommissionPoolModel
bool is_calculated = 7;
google.protobuf.Timestamp calculated_at = 8;
google.protobuf.Timestamp created = 9;
int64 package_id = 10;
string package_title = 11;
}
// GetWithdrawalRequests Query
@@ -407,6 +413,7 @@ message TriggerWeeklyCalculationRequest
bool skip_balances = 3; // Skip balance calculation (only pool and payouts)
bool skip_pool = 4; // Skip pool calculation (only balances and payouts)
bool skip_payouts = 5; // Skip payout processing (only balances and pool)
google.protobuf.Int64Value package_id = 6; // اگر مقدار دارد فقط این پکیج محاسبه می‌شود - در غیر این صورت همه پکیج‌ها
}
message TriggerWeeklyCalculationResponse