docs: 修改文档

This commit is contained in:
zheng020 2026-05-12 14:06:02 +08:00
parent 8231ef3a31
commit 08225a7a79

View File

@ -1076,7 +1076,111 @@ CREATE TABLE IF NOT EXISTS user_dazi_level (
---
## 十三、铸造奖励系统
## 十三、铸造消耗机制
### 13.1 铸爱次数与消耗水晶
用户铸造藏品时,每次铸造消耗水晶数根据累计铸爱次数动态计算。**达到第10次消耗1024水晶后重置铸爱次数重新从第1次开始。**
| 铸爱次数 | 消耗水晶数 | 备注 |
|---------|-----------|------|
| 1 | 2 | 内测从2开始跑 |
| 2 | 4 | |
| 3 | 8 | 建议为初始值 |
| 4 | 16 | |
| 5 | 32 | |
| 6 | 64 | |
| 7 | 128 | |
| 8 | 256 | 接近1天收益 |
| 9 | 512 | 20%概率获得5%永久收益提升(俗称小保底) |
| 10 | 1024 | 接近3天收益建议为最高值100%概率获得5%永久收益提升(俗称大保底) |
> **注:** 消耗水晶数上限为1024达到第10次后重置铸爱次数。
### 13.2 数据库设计
基于上述表格,铸造消耗配置表设计如下:
#### 13.2.1 铸造消耗配置表 (mint_cost_config)
- `mint_count`:铸爱次数
- `cost_crystal`消耗水晶数上限1024
- `probability`保底触发概率0-1000=不触发
- `reward_type`:触发奖励类型(收益提升等)
- `reward_value`奖励值如5代表5%
```sql
CREATE TABLE mint_cost_config (
id BIGSERIAL PRIMARY KEY,
mint_count INT NOT NULL UNIQUE,
cost_crystal BIGINT NOT NULL,
probability BIGINT DEFAULT 0,
reward_type VARCHAR(50) DEFAULT NULL,
reward_value BIGINT DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL
);
-- 初始数据
INSERT INTO mint_cost_config (mint_count, cost_crystal, probability, reward_type, reward_value, description, updated_at) VALUES
(1, 2, 0, NULL, 0, '内测从2开始跑水晶上限1024', UNIX_MILLIS()),
(2, 4, 0, NULL, 0, '', UNIX_MILLIS()),
(3, 8, 0, NULL, 0, '建议为初始值', UNIX_MILLIS()),
(4, 16, 0, NULL, 0, '', UNIX_MILLIS()),
(5, 32, 0, NULL, 0, '', UNIX_MILLIS()),
(6, 64, 0, NULL, 0, '', UNIX_MILLIS()),
(7, 128, 0, NULL, 0, '', UNIX_MILLIS()),
(8, 256, 0, NULL, 0, '接近1天收益', UNIX_MILLIS()),
(9, 512, 20, '收益提升', 5, '20%概率获得5%永久收益提升(俗称小保底)', UNIX_MILLIS()),
(10, 1024, 100, '收益提升', 5, '接近3天收益建议为最高值100%概率获得5%永久收益提升(俗称大保底)', UNIX_MILLIS());
```
#### 13.2.2 用户累计铸爱次数表 (user_mint_count)
```sql
CREATE TABLE user_mint_count (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
star_id BIGINT NOT NULL,
mint_count INT NOT NULL DEFAULT 0,
revenue_boost_bps INT NOT NULL DEFAULT 0, -- 永久收益提升基点如500=5%
updated_at BIGINT NOT NULL,
UNIQUE(user_id, star_id)
);
```
### 13.3 铸造扣水晶逻辑
```go
func (s *MintService) CreateMintOrder(userID, starID int64, ...) (orderID string, err error) {
// 1. 查询用户累计铸爱次数
mintCount := s.GetUserMintCount(userID, starID)
// 2. 获取铸造消耗配置
cost := s.GetMintCost(mintCount + 1) // 本次铸造是第 mintCount+1 次
// 3. 检查是否触发保底
var boost int64 = 0
if cost.Probability > 0 && rand.Intn(100) < cost.Probability {
boost = cost.RewardValue // 如5代表5%
}
// 4. 扣水晶
newBalance, err := s.userClient.UpdateCrystalBalance(ctx, userID, starID, -cost.CostCrystal,
"mint_cost", orderID, fmt.Sprintf("铸造藏品 #%s", orderID))
// 5. 累加铸爱次数,更新收益提升
if boost > 0 {
s.UpdateMintCountAndBoost(ctx, userID, starID, boost)
}
return orderID, nil
}
```
---
## 十四、铸造奖励系统
### 13.1 需求概述