feat: 积分质押功能

This commit is contained in:
2025-04-03 16:17:20 +08:00
parent 229f1d181b
commit 8119bcefdc
40 changed files with 2552 additions and 108 deletions

View File

@@ -29,6 +29,10 @@ service novatask {
@doc "根据地址修复质押"
@handler StakeByAddress
post /stake_by_address (StakeByAddressReq)
@doc "GameAction"
@handler GameAction
post /game_action (GameActionReq) returns (GameActionResp)
}
type EmailReward {
@@ -46,3 +50,14 @@ type StakeByAddressReq {
Address []string `json:"address"`
}
type GameActionReq {
RoleId int64 `json:"role_id"`
Action string `json:"action"`
}
type GameActionResp {
Ret int `json:"ret"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}

View File

@@ -5,6 +5,7 @@ import "carv.api"
import "admin.api"
import "game7.api"
import "kgen.api"
import "stakepoint.api"
info (
desc: "nova api"

55
doc/api/stakepoint.api Normal file
View File

@@ -0,0 +1,55 @@
syntax = "v1"
@server (
prefix: /gapi/stakepoint/v1
jwt: Auth
group: stakepoint
)
service novatask {
@doc "获取质押档位列表"
@handler GetStakeLevelList
get /level (GetStakeLevelListReq) returns (GetStakeLevelListResp)
@doc "质押积分操作"
@handler StakePoint
post /stake (StakePointReq)
}
type GetStakeLevelListReq {
RoleID int64 `form:"role_id"` // 角色id
}
type PointStakeLevel {
Id int `json:"id"` // 档位id
Title string `json:"title"` // 档位标题
Level int `json:"level"` // 精灵等级
Points int `json:"points"` // 积分数量
Days float64 `json:"days"` // 质押天数
RenewDays float64 `json:"renew_days"` // 续期天数
}
type StakeLevel {
Id int `json:"id"`
Title string `json:"title"` // 档位标题
Level int `json:"level"` // 精灵等级
Points int `json:"points"` // 积分数量
Days float64 `json:"days"` // 质押天数
RenewDays float64 `json:"renew_days"` // 续期天数
StartTime string `json:"start_time"` // 开始时间
EndTime string `json:"end_time"` // 结束时间
CanRenew bool `json:"can_renew"` // 是否可续约
}
type GetStakeLevelListResp {
State int `json:"state"` // 状态1表示已开启可质押 0表示不可质押
Staking *StakeLevel `json:"staking,optional"` // 质押中的档位信息
RenewLevel *StakeLevel `json:"renew_level,optional"` // 已续约的档位信息
Levels []PointStakeLevel `json:"levels"` // 档位列表
}
type StakePointReq {
RoleID int64 `json:"role_id"` // 角色id
LevelId int `json:"level_id"` // 档位id
Action int `json:"action"` // 操作类型1表示质押2表示升级质押 3表示续约
}

View File

@@ -4,9 +4,9 @@ CREATE TABLE `nh_task_progress`
`uid` int(11) unsigned NOT NULL,
`task_id` int(11) unsigned NOT NULL COMMENT '任务id',
`task_seq` int(11) NOT NULL COMMENT '用于可重复任务的序列号',
`stage` tinyint NOT NULL DEFAULT 0 COMMENT '任务的阶段, 0:未完成 1:待校验 2:已完成未领取 3:已领取',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`stage` tinyint NOT NULL DEFAULT 0 COMMENT '任务的阶段, 0:未完成 1:待校验 2:已完成未领取 3:已领取',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uid_task_id_seq` (`uid`, `task_id`, `task_seq`)
) COMMENT ='用户任务节点';
@@ -14,12 +14,12 @@ CREATE TABLE `nh_task_progress`
CREATE TABLE `nh_nft_holder`
(
`id` int unsigned NOT NULL AUTO_INCREMENT,
`address` varchar(80) NOT NULL COMMENT '钱包地址',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`address` varchar(80) NOT NULL COMMENT '钱包地址',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`balance` int(11) NOT NULL DEFAULT 0 COMMENT '余额',
`update_seq` int NOT NULL COMMENT '更新序列号',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`update_seq` int NOT NULL COMMENT '更新序列号',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY (`token_id`),
INDEX (`update_seq`)
@@ -28,12 +28,12 @@ CREATE TABLE `nh_nft_holder`
CREATE TABLE `nh_nft_holder_change_log`
(
`id` int unsigned NOT NULL AUTO_INCREMENT,
`address` varchar(80) NOT NULL COMMENT '钱包地址',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`address` varchar(80) NOT NULL COMMENT '钱包地址',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`value` int(11) NOT NULL COMMENT '变化数量',
`balance` int(11) NOT NULL COMMENT '余额',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`)
) COMMENT ='nft 持有表变化日志';
@@ -42,11 +42,11 @@ CREATE TABLE `nh_task_nft_stake`
`id` int unsigned NOT NULL AUTO_INCREMENT,
`uid` int unsigned NOT NULL COMMENT '用户钱包',
`role_id` bigint unsigned NOT NULL COMMENT '角色id',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '类型0=小塔罗1=大塔罗',
`state` tinyint NOT NULL DEFAULT 0 COMMENT '状态1质押中 0已取消质押',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`state` tinyint NOT NULL DEFAULT 0 COMMENT '状态1质押中 0已取消质押',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY (`token_id`)
) COMMENT ='nft质押表';
@@ -56,16 +56,16 @@ CREATE TABLE `nh_task_nft_stake_log`
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户钱包',
`role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色id',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`operate` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态1质押 2取消质押, 3转出',
`callback_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '下发通知状态:0未通知,1已通知,2通知异常',
`callback_num` int(10) NOT NULL DEFAULT '0' COMMENT '发送通知次数',
`callback_at` timestamp NULL DEFAULT NULL COMMENT '发送通知最新时间',
`callback_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '通知回调备注',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`callback_at` timestamp NULL DEFAULT NULL COMMENT '发送通知最新时间',
`callback_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '通知回调备注',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
KEY `callback_status` (`callback_status`) USING BTREE
KEY `callback_status` (`callback_status`) USING BTREE
) COMMENT ='nft质押日志表';
CREATE TABLE `nh_task_nft_stake_reward`
@@ -101,9 +101,24 @@ CREATE TABLE `nh_email_reward`
CREATE TABLE `nh_nft_tarot`
(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`tarot_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '类型0=小塔罗1=大塔罗',
`tarot_img` varchar(128) NOT NULL COMMENT '塔罗图片',
`token_id` varchar(32) NOT NULL COMMENT 'token id',
`tarot_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '类型0=小塔罗1=大塔罗',
`tarot_img` varchar(128) NOT NULL COMMENT '塔罗图片',
PRIMARY KEY (`id`),
UNIQUE KEY (`token_id`)
) COMMENT ='塔罗信息';
) COMMENT ='塔罗信息';
CREATE TABLE `nh_stake_points`
(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`uid` int unsigned NOT NULL COMMENT '用户id',
`role_id` bigint unsigned NOT NULL COMMENT '角色id',
`level_id` int(11) unsigned NOT NULL COMMENT '档位id',
`level` int unsigned NOT NULL COMMENT '档位',
`points` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '积分数量',
`start_time` timestamp NOT NULL COMMENT '开始时间戳',
`end_time` timestamp NOT NULL COMMENT '结束时间戳',
`status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态1=质押中2=已升级3=已续约4=已过期',
PRIMARY KEY (`id`),
INDEX (`uid`, `role_id`, `level_id`, `status`)
) COMMENT ='积分质押表';

View File

@@ -69,6 +69,33 @@
]
}
},
"/gapi/admin/game_action": {
"post": {
"summary": "GameAction",
"operationId": "GameAction",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GameActionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/GameActionReq"
}
}
],
"tags": [
"admin"
]
}
},
"/gapi/admin/nft_holder_update": {
"get": {
"summary": "NFT持有者更新",
@@ -437,6 +464,71 @@
]
}
},
"/gapi/stakepoint/v1/level": {
"get": {
"summary": "获取质押档位列表",
"operationId": "GetStakeLevelList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GetStakeLevelListResp"
}
}
},
"parameters": [
{
"name": "role_id",
"description": " 角色id",
"in": "query",
"required": true,
"type": "integer",
"format": "int64"
}
],
"tags": [
"stakepoint"
],
"consumes": [
"multipart/form-data"
],
"security": [
{
"apiKey": []
}
]
}
},
"/gapi/stakepoint/v1/stake": {
"post": {
"summary": "质押积分操作",
"operationId": "StakePoint",
"responses": {
"200": {
"description": "A successful response.",
"schema": {}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/StakePointReq"
}
}
],
"tags": [
"stakepoint"
],
"security": [
{
"apiKey": []
}
]
}
},
"/gapi/task/v1/bind_tribally": {
"get": {
"summary": "绑定Tribally账号",
@@ -946,6 +1038,44 @@
"type"
]
},
"GameActionReq": {
"type": "object",
"properties": {
"role_id": {
"type": "integer",
"format": "int64"
},
"action": {
"type": "string"
}
},
"title": "GameActionReq",
"required": [
"role_id",
"action"
]
},
"GameActionResp": {
"type": "object",
"properties": {
"ret": {
"type": "integer",
"format": "int32"
},
"msg": {
"type": "string"
},
"data": {
"type": "object"
}
},
"title": "GameActionResp",
"required": [
"ret",
"msg",
"data"
]
},
"GetCommunityListResp": {
"type": "object",
"properties": {
@@ -974,6 +1104,50 @@
"wallet_address"
]
},
"GetStakeLevelListReq": {
"type": "object",
"properties": {
"role_id": {
"type": "integer",
"format": "int64",
"description": " 角色id"
}
},
"title": "GetStakeLevelListReq",
"required": [
"role_id"
]
},
"GetStakeLevelListResp": {
"type": "object",
"properties": {
"state": {
"type": "integer",
"format": "int32",
"description": " 状态1表示已开启可质押 0表示不可质押"
},
"staking": {
"$ref": "#/definitions/StakeLevel",
"description": " 质押中的档位信息"
},
"renew_level": {
"$ref": "#/definitions/StakeLevel",
"description": " 已续约的档位信息"
},
"levels": {
"type": "array",
"items": {
"$ref": "#/definitions/PointStakeLevel"
},
"description": " 档位列表"
}
},
"title": "GetStakeLevelListResp",
"required": [
"state",
"levels"
]
},
"GetTaskListReq": {
"type": "object",
"properties": {
@@ -1141,6 +1315,49 @@
"total"
]
},
"PointStakeLevel": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32",
"description": " 档位id"
},
"title": {
"type": "string",
"description": " 档位标题"
},
"level": {
"type": "integer",
"format": "int32",
"description": " 精灵等级"
},
"points": {
"type": "integer",
"format": "int32",
"description": " 积分数量"
},
"days": {
"type": "number",
"format": "double",
"description": " 质押天数"
},
"renew_days": {
"type": "number",
"format": "double",
"description": " 续期天数"
}
},
"title": "PointStakeLevel",
"required": [
"id",
"title",
"level",
"points",
"days",
"renew_days"
]
},
"Result": {
"type": "object",
"properties": {
@@ -1169,6 +1386,64 @@
"address"
]
},
"StakeLevel": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"title": {
"type": "string",
"description": " 档位标题"
},
"level": {
"type": "integer",
"format": "int32",
"description": " 精灵等级"
},
"points": {
"type": "integer",
"format": "int32",
"description": " 积分数量"
},
"days": {
"type": "number",
"format": "double",
"description": " 质押天数"
},
"renew_days": {
"type": "number",
"format": "double",
"description": " 续期天数"
},
"start_time": {
"type": "string",
"description": " 开始时间"
},
"end_time": {
"type": "string",
"description": " 结束时间"
},
"can_renew": {
"type": "boolean",
"format": "boolean",
"description": " 是否可续约"
}
},
"title": "StakeLevel",
"required": [
"id",
"title",
"level",
"points",
"days",
"renew_days",
"start_time",
"end_time",
"can_renew"
]
},
"StakeNftList": {
"type": "object",
"properties": {
@@ -1190,6 +1465,32 @@
"token_ids"
]
},
"StakePointReq": {
"type": "object",
"properties": {
"role_id": {
"type": "integer",
"format": "int64",
"description": " 角色id"
},
"level_id": {
"type": "integer",
"format": "int32",
"description": " 档位id"
},
"action": {
"type": "integer",
"format": "int32",
"description": " 操作类型1表示质押2表示升级质押 3表示续约"
}
},
"title": "StakePointReq",
"required": [
"role_id",
"level_id",
"action"
]
},
"StakeReward": {
"type": "object",
"properties": {