feat: 添加 GET /api/payment/orders 接口,返回用户订单记录
This commit is contained in:
@@ -973,6 +973,28 @@ pub async fn sync_order(
|
||||
})))
|
||||
}
|
||||
|
||||
/// GET /api/payment/orders — 获取当前用户的订单记录
|
||||
#[get("/api/payment/orders")]
|
||||
pub async fn get_user_orders(
|
||||
pool: web::Data<PgPool>,
|
||||
claims: web::ReqData<Claims>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let orders = db::get_user_orders(pool.get_ref(), claims.user_id).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(serde_json::json!({
|
||||
"success": true,
|
||||
"data": orders.iter().map(|o| serde_json::json!({
|
||||
"order_no": o.order_no,
|
||||
"package_type": o.package_type,
|
||||
"amount": o.amount,
|
||||
"status": o.status,
|
||||
"paid_at": o.paid_at,
|
||||
"expires_at": o.expires_at,
|
||||
"created_at": o.created_at,
|
||||
})).collect::<Vec<_>>()
|
||||
})))
|
||||
}
|
||||
|
||||
/// GET /api/user/quota
|
||||
#[get("/api/user/quota")]
|
||||
pub async fn get_user_quota(
|
||||
|
||||
Reference in New Issue
Block a user