feat(billing): comfy recharge to points + admin credit adjust
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+127
@@ -14,6 +14,8 @@ pub struct AppConfig {
|
||||
#[serde(default)]
|
||||
pub comfyui: ComfyUIConfig,
|
||||
#[serde(default)]
|
||||
pub pixelle_video: PixelleVideoConfig,
|
||||
#[serde(default)]
|
||||
pub payment: PaymentConfig,
|
||||
}
|
||||
|
||||
@@ -79,9 +81,30 @@ pub struct ComfyUIConfig {
|
||||
pub agent_model: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PixelleVideoConfig {
|
||||
pub enabled: bool,
|
||||
pub api_base_url: Option<String>,
|
||||
pub api_key: Option<String>,
|
||||
#[serde(default = "default_pixelle_backend_provider")]
|
||||
pub backend_provider: String,
|
||||
pub frame_template: String,
|
||||
pub media_workflow: Option<String>,
|
||||
pub tts_workflow: Option<String>,
|
||||
pub runninghub_media_workflow: Option<String>,
|
||||
pub runninghub_tts_workflow: Option<String>,
|
||||
pub mode: String,
|
||||
pub n_scenes: i64,
|
||||
pub video_fps: i64,
|
||||
pub poll_interval_secs: u64,
|
||||
pub timeout_secs: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PaymentConfig {
|
||||
pub enabled: bool,
|
||||
#[serde(default)]
|
||||
pub provider: PaymentProvider,
|
||||
pub public_base_url: Option<String>,
|
||||
pub product_name_prefix: String,
|
||||
pub currency: String,
|
||||
@@ -92,8 +115,31 @@ pub struct PaymentConfig {
|
||||
pub max_pending_orders: i64,
|
||||
pub stripe_secret_key: Option<String>,
|
||||
pub stripe_webhook_secret: Option<String>,
|
||||
pub comfy_customer_token: Option<String>,
|
||||
pub comfy_customer_token_endpoint: Option<String>,
|
||||
pub comfy_firebase_api_key: Option<String>,
|
||||
pub comfy_oauth_client_id: Option<String>,
|
||||
pub comfy_oauth_client_secret: Option<String>,
|
||||
pub comfy_oauth_refresh_token: Option<String>,
|
||||
pub comfy_customer_api_base_url: Option<String>,
|
||||
pub comfy_checkout_endpoint: Option<String>,
|
||||
pub success_path: String,
|
||||
pub cancel_path: String,
|
||||
/// When true, confirming a comfy_cloud recharge grants workflow points
|
||||
/// (amount_usd * usd_to_points_rate) instead of crediting the USD pool.
|
||||
#[serde(default = "default_comfy_recharge_to_points")]
|
||||
pub comfy_recharge_to_points: bool,
|
||||
/// Points granted per 1 USD when comfy_recharge_to_points is enabled.
|
||||
#[serde(default = "default_usd_to_points_rate")]
|
||||
pub usd_to_points_rate: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum PaymentProvider {
|
||||
#[default]
|
||||
ComfyCloud,
|
||||
Stripe,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
@@ -115,10 +161,22 @@ fn default_comfyui_container_name() -> String {
|
||||
"boosapi-comfyui-workflow".to_string()
|
||||
}
|
||||
|
||||
fn default_pixelle_backend_provider() -> String {
|
||||
"comfy".to_string()
|
||||
}
|
||||
|
||||
fn default_workflow_points_cost() -> f64 {
|
||||
10.0
|
||||
}
|
||||
|
||||
fn default_comfy_recharge_to_points() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_usd_to_points_rate() -> f64 {
|
||||
100.0
|
||||
}
|
||||
|
||||
impl Default for ComfyUIConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -142,10 +200,32 @@ impl Default for ComfyUIConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PixelleVideoConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
api_base_url: Some("http://127.0.0.1:8000".to_string()),
|
||||
api_key: None,
|
||||
backend_provider: default_pixelle_backend_provider(),
|
||||
frame_template: "1080x1920/image_default.html".to_string(),
|
||||
media_workflow: None,
|
||||
tts_workflow: None,
|
||||
runninghub_media_workflow: Some("runninghub/video_wan2.1_fusionx.json".to_string()),
|
||||
runninghub_tts_workflow: Some("runninghub/tts_edge.json".to_string()),
|
||||
mode: "fixed".to_string(),
|
||||
n_scenes: 5,
|
||||
video_fps: 30,
|
||||
poll_interval_secs: 5,
|
||||
timeout_secs: 900,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PaymentConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
provider: PaymentProvider::ComfyCloud,
|
||||
public_base_url: None,
|
||||
product_name_prefix: "BossAI 账户充值".to_string(),
|
||||
currency: "usd".to_string(),
|
||||
@@ -156,8 +236,55 @@ impl Default for PaymentConfig {
|
||||
max_pending_orders: 3,
|
||||
stripe_secret_key: None,
|
||||
stripe_webhook_secret: None,
|
||||
comfy_customer_token: None,
|
||||
comfy_customer_token_endpoint: None,
|
||||
comfy_firebase_api_key: None,
|
||||
comfy_oauth_client_id: None,
|
||||
comfy_oauth_client_secret: None,
|
||||
comfy_oauth_refresh_token: None,
|
||||
comfy_customer_api_base_url: None,
|
||||
comfy_checkout_endpoint: None,
|
||||
success_path: "/user/recharge?payment=success&order={ORDER_ID}".to_string(),
|
||||
cancel_path: "/user/recharge?payment=cancel&order={ORDER_ID}".to_string(),
|
||||
comfy_recharge_to_points: true,
|
||||
usd_to_points_rate: 100.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AppConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
server: ServerConfig {
|
||||
host: "127.0.0.1".to_string(),
|
||||
port: 4000,
|
||||
log_level: "info".to_string(),
|
||||
cors_origins: vec!["*".to_string()],
|
||||
},
|
||||
db: DbConfig {
|
||||
url: "sqlite::memory:".to_string(),
|
||||
max_connections: 1,
|
||||
ssl: false,
|
||||
runtime_db_url: None,
|
||||
runtime_db_dialect: None,
|
||||
runtime_db_ssl: None,
|
||||
},
|
||||
auth: AuthConfig {
|
||||
jwt_secret: "test-secret".to_string(),
|
||||
jwt_expiry_hours: 72,
|
||||
auth_token: "test-admin-token".to_string(),
|
||||
proxy_token: "sk-test-proxy".to_string(),
|
||||
},
|
||||
proxy: ProxyConfig {
|
||||
upstream_timeout_secs: 300,
|
||||
first_byte_timeout_secs: 60,
|
||||
max_retries: 3,
|
||||
proxy_log_retention_days: 30,
|
||||
template_proxy_url: None,
|
||||
},
|
||||
comfyui: ComfyUIConfig::default(),
|
||||
pixelle_video: PixelleVideoConfig::default(),
|
||||
payment: PaymentConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user