# Jungle Treasure 后端模块 Laf 云函数采用单模块结构: - `functions/jungleTreasure.ts`:礼包配置、类型、状态工具、客户端读取和领取接口; - `functions/jungleTreasure.yaml`:对应的 Laf 云函数定义。 其他云函数统一通过下面的方式引用公共模块: ```ts import { getJunglePaidTierByProductId, unlockJungleTierByProductId, } from "@/jungleTreasure"; ``` 不再保留独立的 `jungleConfig`、`jungleState` 和 `types` 模块。 ## 状态规则 - `0`:付费档位未解锁; - `1`:已解锁未领取,免费档位默认是 `1`; - `2`:已经领取。 状态数组固定为 51 项。领取接口不检查前置档位,只检查目标档位自身是否为 `1`。 付费商品依次对应第 `4/10/16/22/28/34/40/46` 档。支付回调根据 `jungleTreasure.ts` 中的 `productId` 查找档位,不在支付代码中重复维护映射。 ## 接口 读取: ```json { "action": "read", "uid": "用户 _id", "token": "登录 token" } ``` 领取: ```json { "action": "claim", "uid": "用户 _id", "token": "登录 token", "tierId": 5 } ``` 原来的 `save` 操作已停用。旧版 `claimedTierIds` 数据会在首次读取时自动迁移为三状态数组。