forked from gongxuegit/tiku-backend.net
feat: add commission settlement endpoints
This commit is contained in:
@@ -215,6 +215,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is CommissionException commissionException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
commissionException.Message,
|
||||
CommissionStatusCode(commissionException.Code),
|
||||
commissionException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is PaymentProviderException paymentProviderException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
@@ -410,4 +420,17 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
|
||||
private static int CommissionStatusCode(string code)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"commission_access_denied" => StatusCodes.Status403Forbidden,
|
||||
"commission_member_not_found" or "commission_settlement_not_found" or "commission_proof_not_found" =>
|
||||
StatusCodes.Status404NotFound,
|
||||
"commission_no_unsettled_sources" or "commission_below_minimum" or "commission_status_invalid" or
|
||||
"commission_proof_closed" => StatusCodes.Status409Conflict,
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user