server/laf-cloud/signInActivity.README.md

31 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 七日签到数据库配置
部署云函数前,需要在 `sign_in_activity_config` 集合中创建且只创建一条 `enabled: true` 的有效配置。
活动中的用户通过 `activityId` 读取配置,因此旧配置不能在仍有用户参与时删除。
`login` 不判断或开启签到活动;前端调用 `signInActivityInfo` 时,后端使用 `users.levelAmount` 判断资格:未达到目标关卡返回 `data: false`,达到目标关卡则创建活动并返回完整奖励与领取状态。
```js
{
activityId: "sign_in_v1",
enabled: true,
triggerLevel: 23,
durationDays: 14,
timezone: "UTC+8",
rewards: [
{ day: 1, items: [{ type: "infinite_health", count: 900 }] },
{ day: 2, items: [{ type: "hammer", count: 1 }] },
{ day: 3, items: [{ type: "infinite_health", count: 1800 }] },
{ day: 4, items: [{ type: "freeze", count: 1 }, { type: "magic_wand", count: 1 }] },
{ day: 5, items: [{ type: "coin", count: 600 }] },
{ day: 6, items: [{ type: "hammer", count: 1 }, { type: "freeze", count: 1 }, { type: "magic_wand", count: 1 }] },
{ day: 7, items: [{ type: "infinite_health", count: 3600 }, { type: "cat_skin", count: 1, itemId: 12 }] }
],
createdAt: Date.now(),
updatedAt: Date.now()
}
```
奖励 `type` 只允许:`coin`、`freeze`、`hammer`、`magic_wand`、`infinite_health`、`cat_skin`;`count` 必须大于 0。`cat_skin` 必须提供大于 0 的整数 `itemId`。
本期可直接导入的完整配置见 `sign-in-activity-config.json`;其中专属猫暂定为 `itemId: 12`,启用前必须确认客户端资源和发奖逻辑均已支持猫 12。
`sign_in_activity_claims` 使用后端生成的 SHA-256 `_id` 实现同用户、同活动、同自然日的领取幂等,无需客户端传入领取天数。