This commit is contained in:
eric
2026-03-16 05:41:47 -05:00
parent ff31ef8001
commit c54d46517c
16 changed files with 796 additions and 286 deletions

View File

@@ -45,6 +45,7 @@ export async function POST(request: NextRequest) {
const whyJoin = String(formData.why_join || "").trim();
const region = String(formData.region || "").trim();
const availableTime = String(formData.available_time || "").trim();
const isVolunteer = !!formData.is_volunteer;
if (!intro && (status || activityType || whyJoin || region || availableTime)) {
const extra = [status && `状态:${status}`, activityType && `活动偏好:${activityType}`, whyJoin && `原因:${whyJoin}`, region && `区域:${region}`, availableTime && `时间:${availableTime}`].filter(Boolean).join(" | ");
intro = extra;
@@ -52,39 +53,22 @@ export async function POST(request: NextRequest) {
const isDigitalNomad = session === "digital-nomad";
const contact = wechatOrPhone || wechat || phone;
if (!nickname || !intro || !session || !agreeRules || !xiaohongshuUrl) {
if (!nickname || !session || !agreeRules) {
return NextResponse.json(
{ ok: false, error: "请填写必填项(含小红书主页地址、自我介绍)" },
{ ok: false, error: "请填写必填项" },
{ status: 400 }
);
}
if (!contact) {
return NextResponse.json(
{ ok: false, error: "请填写微信号或手机号" },
{ status: 400 }
);
}
if (isDigitalNomad && (!education || !graduationYear)) {
return NextResponse.json(
{ ok: false, error: "请选择学历和毕业时间" },
{ ok: false, error: "请填写微信号" },
{ status: 400 }
);
}
const userId = getUserIdFromCookie(request) || generateAnonId();
const EDUCATION_GRAD_AGE: Record<string, number> = {
"高中及以下": 18,
大专: 21,
本科: 22,
硕士: 25,
博士: 28,
};
const gradAge = EDUCATION_GRAD_AGE[education] ?? 22;
const estimatedAge = new Date().getFullYear() - parseInt(graduationYear, 10) + gradAge;
const ageRangeForRecord = isDigitalNomad && education && graduationYear
? `推算约${estimatedAge}岁(学历${education}+${graduationYear}毕业)`
: ageRange;
const ageRangeForRecord = ageRange || "";
const record = {
user_id: userId,
@@ -104,6 +88,7 @@ export async function POST(request: NextRequest) {
amount: 0,
age_range: ageRangeForRecord,
first_time: firstTime,
is_volunteer: isVolunteer,
};
try {
@@ -167,6 +152,8 @@ async function tryPocketBaseDirect(
type: record.type ?? "",
order_id: record.order_id ?? "",
amount: record.amount ?? 0,
is_volunteer: record.is_volunteer ?? false,
xiaohongshu_url: record.xiaohongshu_url ?? "",
};
try {