fix: 添加用户取消订单 + 管理员手动退款端点
This commit is contained in:
@@ -1003,6 +1003,25 @@ pub async fn sync_order(
|
||||
})))
|
||||
}
|
||||
|
||||
/// POST /api/payment/cancel-order — 用户主动取消待支付订单
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CancelOrderRequest {
|
||||
pub order_id: String,
|
||||
}
|
||||
|
||||
#[post("/api/payment/cancel-order")]
|
||||
pub async fn cancel_order(
|
||||
pool: web::Data<PgPool>,
|
||||
claims: web::ReqData<Claims>,
|
||||
body: web::Json<CancelOrderRequest>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
db::cancel_payment_order(pool.get_ref(), &body.order_id, claims.user_id).await?;
|
||||
Ok(HttpResponse::Ok().json(serde_json::json!({
|
||||
"success": true,
|
||||
"message": "订单已取消"
|
||||
})))
|
||||
}
|
||||
|
||||
/// GET /api/payment/orders — 获取当前用户的订单记录
|
||||
#[get("/api/payment/orders")]
|
||||
pub async fn get_user_orders(
|
||||
|
||||
Reference in New Issue
Block a user