Files
soul/app/api/distribution/auto-withdraw-config/route.ts
卡若 b60edb3d47 feat: 完整重构小程序匹配功能 + 修复UI对齐 + 文章数据API
主要更新:
1. 按H5网页端完全重构匹配功能(match页面)
   - 4种匹配类型: 创业合伙/资源对接/导师顾问/团队招募
   - 资源对接等类型弹出手机号/微信号输入框
   - 去掉重新匹配按钮,改为返回按钮

2. 修复所有卡片对齐和宽度问题
   - 目录页附录卡片居中
   - 首页阅读进度卡片满宽度
   - 我的页面菜单卡片对齐
   - 推广中心分享卡片统一宽度

3. 修复目录页图标和文字对齐
   - section-icon固定40rpx宽高
   - section-title与图标垂直居中

4. 更新真实完整文章标题(62篇)
   - 从book目录读取真实markdown文件名
   - 替换之前的简化标题

5. 新增文章数据API
   - /api/db/chapters - 获取完整书籍结构
   - 支持按ID获取单篇文章内容
2026-01-21 15:49:12 +08:00

109 lines
2.8 KiB
TypeScript

/**
* 自动提现配置API
*/
import { NextRequest, NextResponse } from 'next/server';
// 内存存储(实际应用中应该存入数据库)
const autoWithdrawConfigs: Map<string, {
userId: string;
enabled: boolean;
minAmount: number;
method: 'wechat' | 'alipay';
account: string;
name: string;
createdAt: string;
updatedAt: string;
}> = new Map();
// GET: 获取用户自动提现配置
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const userId = searchParams.get('userId');
if (!userId) {
return NextResponse.json({ error: '缺少用户ID' }, { status: 400 });
}
const config = autoWithdrawConfigs.get(userId);
return NextResponse.json({
success: true,
config: config || null,
});
}
// POST: 保存/更新自动提现配置
export async function POST(req: NextRequest) {
try {
const body = await req.json();
const { userId, enabled, minAmount, method, account, name } = body;
if (!userId) {
return NextResponse.json({ error: '缺少用户ID' }, { status: 400 });
}
// 验证参数
if (enabled) {
if (!minAmount || minAmount < 10) {
return NextResponse.json({ error: '最低提现金额不能少于10元' }, { status: 400 });
}
if (!account) {
return NextResponse.json({ error: '请填写提现账号' }, { status: 400 });
}
if (!name) {
return NextResponse.json({ error: '请填写真实姓名' }, { status: 400 });
}
}
const now = new Date().toISOString();
const existingConfig = autoWithdrawConfigs.get(userId);
const config = {
userId,
enabled: Boolean(enabled),
minAmount: Number(minAmount) || 100,
method: method || 'wechat',
account: account || '',
name: name || '',
createdAt: existingConfig?.createdAt || now,
updatedAt: now,
};
autoWithdrawConfigs.set(userId, config);
console.log('[AutoWithdrawConfig] 保存配置:', {
userId,
enabled: config.enabled,
minAmount: config.minAmount,
method: config.method,
});
return NextResponse.json({
success: true,
config,
message: enabled ? '自动提现已启用' : '自动提现已关闭',
});
} catch (error) {
console.error('[AutoWithdrawConfig] 保存失败:', error);
return NextResponse.json({ error: '保存配置失败' }, { status: 500 });
}
}
// DELETE: 删除自动提现配置
export async function DELETE(req: NextRequest) {
const { searchParams } = new URL(req.url);
const userId = searchParams.get('userId');
if (!userId) {
return NextResponse.json({ error: '缺少用户ID' }, { status: 400 });
}
autoWithdrawConfigs.delete(userId);
return NextResponse.json({
success: true,
message: '配置已删除',
});
}