fix: 移除订单自动确认,仅依赖支付宝回调验签;rsa2_verify 支持裸 base64 DER 公钥;.env 取消 git 跟踪

This commit is contained in:
2026-08-10 15:34:44 +08:00
parent 2ce97243ab
commit 49d740e27c
4 changed files with 10 additions and 71 deletions

View File

@@ -371,45 +371,6 @@ pub async fn get_user_orders(
}
/// 扫描超过 10 分钟的待支付订单,尝试自动确认(用于回调重试)
/// 返回成功确认的订单数量
pub async fn check_and_retry_pending_orders(pool: &PgPool) -> Result<u64, AppError> {
// 查找超过 10 分钟仍为 pending 的订单
let stuck_orders: Vec<(String,)> = sqlx::query_as(
r#"
SELECT order_no FROM payment_orders
WHERE status = 'pending'
AND created_at < NOW() - INTERVAL '10 minutes'
AND created_at > NOW() - INTERVAL '24 hours'
ORDER BY created_at ASC
"#,
)
.fetch_all(pool)
.await
.map_err(|e| AppError::Database(format!("查询待处理订单失败: {}", e)))?;
if stuck_orders.is_empty() {
return Ok(0);
}
tracing::info!(
"发现 {} 个待处理订单,尝试自动确认...",
stuck_orders.len()
);
let mut confirmed: u64 = 0;
for (order_no,) in &stuck_orders {
match confirm_payment_order_by_orderno(pool, order_no).await {
Ok(_) => {
confirmed += 1;
tracing::info!("定时任务自动确认订单: {}", order_no);
}
Err(e) => {
tracing::warn!("定时任务无法确认订单 {}: {}", order_no, e);
}
}
}
Ok(confirmed)
}
/// 检查会员到期前 7 天的用户,发送即将到期通知
pub async fn check_member_expiry_soon(pool: &PgPool) -> Result<u64, AppError> {