更新.gitignore以排除部署配置文件,删除不再使用的一键部署脚本,优化小程序部署流程,增强文档说明。

This commit is contained in:
乘风
2026-01-31 17:39:21 +08:00
parent ceac5b73ff
commit 70497d3047
45 changed files with 9346 additions and 272 deletions

View File

@@ -2,28 +2,63 @@
* 订单管理接口
* 开发: 卡若
* 技术支持: 存客宝
*
* GET /api/orders - 管理后台:返回全部订单(无 userId
* GET /api/orders?userId= - 按用户返回订单
*/
import { type NextRequest, NextResponse } from "next/server"
import { query } from "@/lib/db"
function rowToOrder(row: Record<string, unknown>) {
return {
id: row.id,
orderSn: row.order_sn,
userId: row.user_id,
openId: row.open_id,
productType: row.product_type,
productId: row.product_id,
amount: row.amount,
description: row.description,
status: row.status,
transactionId: row.transaction_id,
payTime: row.pay_time,
createdAt: row.created_at,
updatedAt: row.updated_at,
}
}
export async function GET(request: NextRequest) {
try {
const { searchParams } = new URL(request.url)
const userId = searchParams.get("userId")
if (!userId) {
return NextResponse.json({ code: 400, message: "缺少用户ID" }, { status: 400 })
let rows: Record<string, unknown>[] = []
try {
if (userId) {
rows = (await query(
"SELECT * FROM orders WHERE user_id = ? ORDER BY created_at DESC",
[userId]
)) as Record<string, unknown>[]
} else {
// 管理后台:无 userId 时返回全部订单
rows = (await query(
"SELECT * FROM orders ORDER BY created_at DESC"
)) as Record<string, unknown>[]
}
} catch (e) {
console.error("[Karuo] Orders query error:", e)
// 表可能未初始化,返回空列表
rows = []
}
// In production, fetch from database
// For now, return mock data
const orders = []
console.log("[Karuo] Fetching orders for user:", userId)
const orders = rows.map(rowToOrder)
return NextResponse.json({
code: 0,
message: "获取成功",
data: orders,
success: true,
orders,
})
} catch (error) {
console.error("[Karuo] Get orders error:", error)