Merge remote-tracking branch 'entropy-xu/payment-billing-plans'

# Conflicts:
#	crates/aether-data/src/lifecycle/bootstrap/postgres.rs
#	crates/aether-data/src/lifecycle/migrate/tests.rs
#	frontend/src/views/admin/Users.vue
This commit is contained in:
fawney19
2026-05-15 16:37:17 +08:00
97 changed files with 14795 additions and 402 deletions

View File

@@ -6,4 +6,6 @@ pub(crate) use aether_data::repository::wallet::{
pub(crate) use aether_data_contracts::repository::billing::{
AdminBillingCollectorRecord, AdminBillingCollectorWriteInput, AdminBillingMutationOutcome,
AdminBillingPresetApplyResult, AdminBillingRuleRecord, AdminBillingRuleWriteInput,
BillingPlanRecord, BillingPlanWriteInput, PaymentGatewayConfigRecord,
PaymentGatewayConfigWriteInput, UserDailyQuotaAvailabilityRecord, UserPlanEntitlementRecord,
};

View File

@@ -21,7 +21,9 @@ pub(crate) use self::admin_types::{
AdminBillingCollectorRecord, AdminBillingCollectorWriteInput, AdminBillingMutationOutcome,
AdminBillingPresetApplyResult, AdminBillingRuleRecord, AdminBillingRuleWriteInput,
AdminPaymentCallbackRecord, AdminSecurityBlacklistEntry, AdminWalletPaymentOrderRecord,
AdminWalletRefundRecord, AdminWalletTransactionRecord,
AdminWalletRefundRecord, AdminWalletTransactionRecord, BillingPlanRecord,
BillingPlanWriteInput, PaymentGatewayConfigRecord, PaymentGatewayConfigWriteInput,
UserDailyQuotaAvailabilityRecord, UserPlanEntitlementRecord,
};
pub use self::app::AppState;
pub(crate) use self::cache::{

View File

@@ -1,7 +1,9 @@
use super::{
AdminBillingCollectorRecord, AdminBillingCollectorWriteInput, AdminBillingMutationOutcome,
AdminBillingPresetApplyResult, AdminBillingRuleRecord, AdminBillingRuleWriteInput, AppState,
GatewayError, LocalMutationOutcome,
BillingPlanRecord, BillingPlanWriteInput, GatewayError, LocalMutationOutcome,
PaymentGatewayConfigRecord, PaymentGatewayConfigWriteInput, UserDailyQuotaAvailabilityRecord,
UserPlanEntitlementRecord,
};
fn data_error(err: impl ToString) -> GatewayError {
@@ -405,4 +407,111 @@ impl AppState {
.map(local_mutation_outcome)
.map_err(data_error)
}
pub(crate) async fn find_payment_gateway_config(
&self,
provider: &str,
) -> Result<Option<PaymentGatewayConfigRecord>, GatewayError> {
self.data
.find_payment_gateway_config(provider)
.await
.map_err(data_error)
}
pub(crate) async fn upsert_payment_gateway_config(
&self,
input: &PaymentGatewayConfigWriteInput,
) -> Result<LocalMutationOutcome<PaymentGatewayConfigRecord>, GatewayError> {
self.data
.upsert_payment_gateway_config(input)
.await
.map(local_mutation_outcome)
.map_err(data_error)
}
pub(crate) async fn list_billing_plans(
&self,
include_disabled: bool,
) -> Result<Option<Vec<BillingPlanRecord>>, GatewayError> {
self.data
.list_billing_plans(include_disabled)
.await
.map_err(data_error)
}
pub(crate) async fn find_billing_plan(
&self,
plan_id: &str,
) -> Result<Option<BillingPlanRecord>, GatewayError> {
self.data
.find_billing_plan(plan_id)
.await
.map_err(data_error)
}
pub(crate) async fn create_billing_plan(
&self,
input: &BillingPlanWriteInput,
) -> Result<LocalMutationOutcome<BillingPlanRecord>, GatewayError> {
self.data
.create_billing_plan(input)
.await
.map(local_mutation_outcome)
.map_err(data_error)
}
pub(crate) async fn update_billing_plan(
&self,
plan_id: &str,
input: &BillingPlanWriteInput,
) -> Result<LocalMutationOutcome<BillingPlanRecord>, GatewayError> {
self.data
.update_billing_plan(plan_id, input)
.await
.map(local_mutation_outcome)
.map_err(data_error)
}
pub(crate) async fn set_billing_plan_enabled(
&self,
plan_id: &str,
enabled: bool,
) -> Result<LocalMutationOutcome<BillingPlanRecord>, GatewayError> {
self.data
.set_billing_plan_enabled(plan_id, enabled)
.await
.map(local_mutation_outcome)
.map_err(data_error)
}
pub(crate) async fn delete_billing_plan(
&self,
plan_id: &str,
) -> Result<LocalMutationOutcome<()>, GatewayError> {
self.data
.delete_billing_plan(plan_id)
.await
.map(local_mutation_outcome)
.map_err(data_error)
}
pub(crate) async fn list_user_plan_entitlements(
&self,
user_id: &str,
) -> Result<Option<Vec<UserPlanEntitlementRecord>>, GatewayError> {
self.data
.list_user_plan_entitlements(user_id)
.await
.map_err(data_error)
}
pub(crate) async fn find_user_daily_quota_availability(
&self,
user_id: &str,
) -> Result<Option<UserDailyQuotaAvailabilityRecord>, GatewayError> {
self.data
.find_user_daily_quota_availability(user_id)
.await
.map_err(data_error)
}
}

View File

@@ -1,7 +1,9 @@
use super::super::{
AdminBillingCollectorRecord, AdminBillingCollectorWriteInput, AdminBillingMutationOutcome,
AdminBillingPresetApplyResult, AdminBillingRuleRecord, AdminBillingRuleWriteInput, AppState,
GatewayError, LocalMutationOutcome,
BillingPlanRecord, BillingPlanWriteInput, GatewayError, LocalMutationOutcome,
PaymentGatewayConfigRecord, PaymentGatewayConfigWriteInput, UserDailyQuotaAvailabilityRecord,
UserPlanEntitlementRecord,
};
mod admin;

View File

@@ -1,9 +1,10 @@
use aether_data::repository::wallet::{
AdjustWalletBalanceInput, CompleteAdminWalletRefundInput, CreateManualWalletRechargeInput,
CreateWalletRechargeOrderInput, CreateWalletRechargeOrderOutcome,
CreateWalletRefundRequestInput, CreateWalletRefundRequestOutcome, CreditAdminPaymentOrderInput,
FailAdminWalletRefundInput, ProcessAdminWalletRefundInput, ProcessPaymentCallbackInput,
ProcessPaymentCallbackOutcome, WalletMutationOutcome,
CreatePlanPurchaseOrderInput, CreatePlanPurchaseOrderOutcome, CreateWalletRechargeOrderInput,
CreateWalletRechargeOrderOutcome, CreateWalletRefundRequestInput,
CreateWalletRefundRequestOutcome, CreditAdminPaymentOrderInput, FailAdminWalletRefundInput,
ProcessAdminWalletRefundInput, ProcessPaymentCallbackInput, ProcessPaymentCallbackOutcome,
WalletMutationOutcome,
};
use crate::{AppState, GatewayError};
@@ -19,6 +20,16 @@ impl AppState {
.map_err(|err| GatewayError::Internal(err.to_string()))
}
pub(crate) async fn create_plan_purchase_order(
&self,
input: CreatePlanPurchaseOrderInput,
) -> Result<Option<CreatePlanPurchaseOrderOutcome>, GatewayError> {
self.data
.create_plan_purchase_order(input)
.await
.map_err(|err| GatewayError::Internal(err.to_string()))
}
pub(crate) async fn create_wallet_refund_request(
&self,
input: CreateWalletRefundRequestInput,