import express from 'express'; const router = express.Router(); // GET /api/finance — 财务记录列表 router.get('/', async (req, res) => { try { const Parse = (globalThis as any).Parse; const q = new Parse.Query('FinanceRecord'); q.descending('orderDate'); q.limit(100); const { status } = req.query; if (status && status !== 'all') { q.equalTo('status', status); } const list = await q.find({ useMasterKey: true }); const data = list.map((r: any) => r.toJSON()); res.json({ success: true, data }); } catch (e: any) { res.status(500).json({ success: false, error: e.message }); } }); // POST /api/finance/verify — 核销确认 router.post('/verify', async (req, res) => { try { const Parse = (globalThis as any).Parse; const { id } = req.body; if (!id) { return res.status(400).json({ success: false, error: '缺少 id' }); } const q = new Parse.Query('FinanceRecord'); const record = await q.get(id, { useMasterKey: true }); record.set('verified', true); const saved = await record.save(null, { useMasterKey: true }); res.json({ success: true, data: saved.toJSON() }); } catch (e: any) { res.status(500).json({ success: false, error: e.message }); } }); export default router;