update
This commit is contained in:
@@ -12,21 +12,42 @@ option csharp_namespace = "BackOffice.BFF.Commission.Protobuf";
|
||||
service CommissionContract
|
||||
{
|
||||
// Commands
|
||||
rpc CalculateWeeklyBalances(CalculateWeeklyBalancesRequest) returns (google.protobuf.Empty);
|
||||
rpc CalculateWeeklyCommissionPool(CalculateWeeklyCommissionPoolRequest) returns (google.protobuf.Empty);
|
||||
rpc ProcessUserPayouts(ProcessUserPayoutsRequest) returns (google.protobuf.Empty);
|
||||
rpc RequestWithdrawal(RequestWithdrawalRequest) returns (google.protobuf.Empty);
|
||||
rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (ProcessWithdrawalResponse);
|
||||
rpc ApproveWithdrawal(ApproveWithdrawalRequest) returns (ApproveWithdrawalResponse);
|
||||
rpc RejectWithdrawal(RejectWithdrawalRequest) returns (RejectWithdrawalResponse);
|
||||
rpc CalculateWeeklyBalances(CalculateWeeklyBalancesRequest) returns (google.protobuf.Empty){
|
||||
};
|
||||
rpc CalculateWeeklyCommissionPool(CalculateWeeklyCommissionPoolRequest) returns (google.protobuf.Empty){
|
||||
};
|
||||
rpc ProcessUserPayouts(ProcessUserPayoutsRequest) returns (google.protobuf.Empty){
|
||||
};
|
||||
rpc RequestWithdrawal(RequestWithdrawalRequest) returns (google.protobuf.Empty){
|
||||
};
|
||||
rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (google.protobuf.Empty){
|
||||
};
|
||||
|
||||
// Queries
|
||||
rpc GetWeeklyCommissionPool(GetWeeklyCommissionPoolRequest) returns (GetWeeklyCommissionPoolResponse);
|
||||
rpc GetUserCommissionPayouts(GetUserCommissionPayoutsRequest) returns (GetUserCommissionPayoutsResponse);
|
||||
rpc GetCommissionPayoutHistory(GetCommissionPayoutHistoryRequest) returns (GetCommissionPayoutHistoryResponse);
|
||||
rpc GetUserWeeklyBalances(GetUserWeeklyBalancesRequest) returns (GetUserWeeklyBalancesResponse);
|
||||
rpc GetAllWeeklyPools(GetAllWeeklyPoolsRequest) returns (GetAllWeeklyPoolsResponse);
|
||||
rpc GetWithdrawalRequests(GetWithdrawalRequestsRequest) returns (GetWithdrawalRequestsResponse);
|
||||
rpc GetWeeklyCommissionPool(GetWeeklyCommissionPoolRequest) returns (GetWeeklyCommissionPoolResponse){
|
||||
};
|
||||
rpc GetUserCommissionPayouts(GetUserCommissionPayoutsRequest) returns (GetUserCommissionPayoutsResponse){
|
||||
};
|
||||
rpc GetCommissionPayoutHistory(GetCommissionPayoutHistoryRequest) returns (GetCommissionPayoutHistoryResponse){
|
||||
};
|
||||
rpc GetUserWeeklyBalances(GetUserWeeklyBalancesRequest) returns (GetUserWeeklyBalancesResponse){
|
||||
};
|
||||
rpc GetAllWeeklyPools(GetAllWeeklyPoolsRequest) returns (GetAllWeeklyPoolsResponse){
|
||||
};
|
||||
rpc GetWithdrawalRequests(GetWithdrawalRequestsRequest) returns (GetWithdrawalRequestsResponse){
|
||||
};
|
||||
rpc ApproveWithdrawal(ApproveWithdrawalRequest) returns (google.protobuf.Empty){
|
||||
};
|
||||
rpc RejectWithdrawal(RejectWithdrawalRequest) returns (google.protobuf.Empty){
|
||||
};
|
||||
|
||||
// Worker Control APIs
|
||||
rpc TriggerWeeklyCalculation(TriggerWeeklyCalculationRequest) returns (TriggerWeeklyCalculationResponse){
|
||||
};
|
||||
rpc GetWorkerStatus(GetWorkerStatusRequest) returns (GetWorkerStatusResponse){
|
||||
};
|
||||
rpc GetWorkerExecutionLogs(GetWorkerExecutionLogsRequest) returns (GetWorkerExecutionLogsResponse){
|
||||
};
|
||||
}
|
||||
|
||||
// ============ Commands ============
|
||||
@@ -62,41 +83,23 @@ message RequestWithdrawalRequest
|
||||
// ProcessWithdrawal Command
|
||||
message ProcessWithdrawalRequest
|
||||
{
|
||||
int64 withdrawal_id = 1;
|
||||
string transaction_id = 2;
|
||||
string admin_note = 3;
|
||||
}
|
||||
|
||||
message ProcessWithdrawalResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
int64 payout_id = 1;
|
||||
bool is_approved = 2;
|
||||
google.protobuf.StringValue reason = 3; // Required for rejection
|
||||
}
|
||||
|
||||
// ApproveWithdrawal Command
|
||||
message ApproveWithdrawalRequest
|
||||
{
|
||||
int64 withdrawal_id = 1;
|
||||
string admin_note = 2;
|
||||
}
|
||||
|
||||
message ApproveWithdrawalResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
int64 payout_id = 1;
|
||||
google.protobuf.StringValue notes = 2; // Optional admin notes
|
||||
}
|
||||
|
||||
// RejectWithdrawal Command
|
||||
message RejectWithdrawalRequest
|
||||
{
|
||||
int64 withdrawal_id = 1;
|
||||
string reject_reason = 2;
|
||||
}
|
||||
|
||||
message RejectWithdrawalResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
int64 payout_id = 1;
|
||||
string reason = 2; // Required reason for rejection
|
||||
}
|
||||
|
||||
// ============ Queries ============
|
||||
@@ -213,43 +216,12 @@ message UserWeeklyBalanceModel
|
||||
google.protobuf.Timestamp created = 10;
|
||||
}
|
||||
|
||||
// GetWithdrawalRequests Query
|
||||
message GetWithdrawalRequestsRequest
|
||||
{
|
||||
int32 page_index = 1;
|
||||
int32 page_size = 2;
|
||||
google.protobuf.Int32Value status = 3; // 0=Pending, 1=Approved, 2=Rejected, 3=Processed
|
||||
google.protobuf.Int64Value user_id = 4;
|
||||
}
|
||||
|
||||
message GetWithdrawalRequestsResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated WithdrawalRequestModel models = 2;
|
||||
}
|
||||
|
||||
message WithdrawalRequestModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string user_name = 3;
|
||||
string phone_number = 4;
|
||||
int64 amount = 5;
|
||||
int32 status = 6; // 0=Pending, 1=Approved, 2=Rejected, 3=Processed
|
||||
string method = 7; // Bank, Crypto, Cash
|
||||
string bank_account = 8;
|
||||
string bank_name = 9;
|
||||
google.protobuf.Timestamp requested_at = 10;
|
||||
google.protobuf.Timestamp processed_at = 11;
|
||||
string admin_note = 12;
|
||||
}
|
||||
|
||||
// GetAllWeeklyPools Query
|
||||
message GetAllWeeklyPoolsRequest
|
||||
{
|
||||
google.protobuf.StringValue from_week = 1;
|
||||
google.protobuf.StringValue to_week = 2;
|
||||
google.protobuf.BoolValue only_calculated = 3;
|
||||
google.protobuf.StringValue from_week = 1; // Format: "YYYY-Www" (optional)
|
||||
google.protobuf.StringValue to_week = 2; // Format: "YYYY-Www" (optional)
|
||||
google.protobuf.BoolValue only_calculated = 3; // Only show calculated pools
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
}
|
||||
@@ -271,3 +243,107 @@ message WeeklyCommissionPoolModel
|
||||
google.protobuf.Timestamp calculated_at = 7;
|
||||
google.protobuf.Timestamp created = 8;
|
||||
}
|
||||
|
||||
// GetWithdrawalRequests Query
|
||||
message GetWithdrawalRequestsRequest
|
||||
{
|
||||
google.protobuf.Int32Value status = 1; // CommissionPayoutStatus enum: Pending=1, Approved=2, Rejected=3
|
||||
google.protobuf.Int64Value user_id = 2;
|
||||
google.protobuf.StringValue week_number = 3;
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
}
|
||||
|
||||
message GetWithdrawalRequestsResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated WithdrawalRequestModel models = 2;
|
||||
}
|
||||
|
||||
message WithdrawalRequestModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string user_name = 3;
|
||||
string week_number = 4;
|
||||
int64 amount = 5;
|
||||
int32 status = 6; // CommissionPayoutStatus enum
|
||||
int32 withdrawal_method = 7; // WithdrawalMethod enum
|
||||
string iban_number = 8;
|
||||
google.protobuf.Timestamp requested_at = 9;
|
||||
google.protobuf.Timestamp processed_at = 10;
|
||||
string processed_by = 11;
|
||||
string reason = 12;
|
||||
google.protobuf.Timestamp created = 13;
|
||||
}
|
||||
|
||||
// ============ Worker Control APIs ============
|
||||
|
||||
// TriggerWeeklyCalculation Command
|
||||
message TriggerWeeklyCalculationRequest
|
||||
{
|
||||
string week_number = 1; // Format: "YYYY-Www" (e.g., "2025-W48")
|
||||
bool force_recalculate = 2; // اگر true باشد، محاسبات قبلی را حذف و دوباره محاسبه میکند
|
||||
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)
|
||||
}
|
||||
|
||||
message TriggerWeeklyCalculationResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
string execution_id = 3; // Unique ID for tracking this execution
|
||||
google.protobuf.Timestamp started_at = 4;
|
||||
}
|
||||
|
||||
// GetWorkerStatus Query
|
||||
message GetWorkerStatusRequest
|
||||
{
|
||||
// Empty - returns current worker status
|
||||
}
|
||||
|
||||
message GetWorkerStatusResponse
|
||||
{
|
||||
bool is_running = 1;
|
||||
bool is_enabled = 2;
|
||||
google.protobuf.StringValue current_execution_id = 3;
|
||||
google.protobuf.StringValue current_week_number = 4;
|
||||
google.protobuf.StringValue current_step = 5; // "Balances" | "Pool" | "Payouts" | "Idle"
|
||||
google.protobuf.Timestamp last_run_at = 6;
|
||||
google.protobuf.Timestamp next_scheduled_run = 7;
|
||||
int32 total_executions = 8;
|
||||
int32 successful_executions = 9;
|
||||
int32 failed_executions = 10;
|
||||
}
|
||||
|
||||
// GetWorkerExecutionLogs Query
|
||||
message GetWorkerExecutionLogsRequest
|
||||
{
|
||||
google.protobuf.StringValue week_number = 1; // Filter by week
|
||||
google.protobuf.StringValue execution_id = 2; // Filter by specific execution
|
||||
google.protobuf.BoolValue success_only = 3; // Show only successful runs
|
||||
google.protobuf.BoolValue failed_only = 4; // Show only failed runs
|
||||
int32 page_index = 5;
|
||||
int32 page_size = 6;
|
||||
}
|
||||
|
||||
message GetWorkerExecutionLogsResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated WorkerExecutionLogModel models = 2;
|
||||
}
|
||||
|
||||
message WorkerExecutionLogModel
|
||||
{
|
||||
string execution_id = 1;
|
||||
string week_number = 2;
|
||||
string step = 3; // "Balances" | "Pool" | "Payouts" | "Full"
|
||||
bool success = 4;
|
||||
google.protobuf.StringValue error_message = 5;
|
||||
google.protobuf.Timestamp started_at = 6;
|
||||
google.protobuf.Timestamp completed_at = 7;
|
||||
int64 duration_ms = 8; // Duration in milliseconds
|
||||
int32 records_processed = 9;
|
||||
google.protobuf.StringValue details = 10; // JSON or text details
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user