task claim时, 增加判断是否有链上记录

This commit is contained in:
CounterFire2023 2024-04-08 14:52:49 +08:00
parent 4762663202
commit 845bb7bfd3
5 changed files with 22 additions and 16 deletions

View File

@ -16,6 +16,7 @@
"cfg": {"icon": "twitter"},
"start": "2024-01-01 00:00",
"end": "2025-01-01 00:00",
"checkChain": true,
"params": {}
}, {
"id": "e2fclylj30vwcpe0szl",
@ -30,6 +31,7 @@
"cfg": {"account": "@_CounterFire", "icon": "twitter"},
"start": "2024-01-01 00:00",
"end": "2025-01-01 00:00",
"checkChain": true,
"params": {"time": 6, "failRate": 60}
}, {
"id": "e2feyflj30vwcpe0sjy",
@ -44,6 +46,7 @@
"cfg": {"icon": "twitter"},
"start": "2024-01-01 00:00",
"end": "2025-01-01 00:00",
"checkChain": true,
"params": {"time": 6, "failRate": 60}
}, {
"id": "e2fuah0j30vwcpe0my7",
@ -58,20 +61,7 @@
"cfg": {"icon": "twitter", "content": "Just joined Counter Fire! 🎮 Excited about the endless opportunities ahead. 🔥 Let's team up and conquer together! Come in with me #CounterFire #GamingAdventures"},
"start": "2024-01-01 00:00",
"end": "2025-01-01 00:00",
"params": {"time": 6, "failRate": 60}
}, {
"id": "e2fuah0j30vwcpe1my7",
"task": "TwitterRetweet",
"title": "",
"type": 1,
"desc": "Click Verify button and retweet on the tweet",
"category": "Social Tasks",
"score": 200,
"autoclaim": false,
"pretasks": ["e2yhq2lj30vwcpedv7p"],
"cfg": {"icon": "twitter", "content": "输入框自动生成,活动开始时添加内容)"},
"start": "2024-01-01 00:00",
"end": "2025-01-01 00:00",
"checkChain": true,
"params": {"time": 6, "failRate": 60}
}
],

View File

@ -154,7 +154,6 @@ class BoxController extends BaseController {
throw new ZError(13, 'waiting for chain confirm')
}
// TODO:: 待规则确定后, 检查用户是否符合助力条件
const chest = await ActivityChest.findOne({ shareCode: code, activity: user.activity })
if (!chest) {
throw new ZError(12, 'chest not found')

View File

@ -317,7 +317,11 @@ class GameController extends BaseController {
if (!isObjectId(id)) {
throw new ZError(12, 'invalid id')
}
const chainRecord = await GeneralScription.findOne({ from: user.address.toLowerCase(), op: 'explore', data: id })
const chainRecord = await GeneralScription.findOne({
from: user.address.toLowerCase(),
op: 'explore',
data: id,
})
if (!chainRecord) {
throw new ZError(13, 'waiting for chain confirm')
}

View File

@ -3,6 +3,7 @@ import { TaskCfg, TaskTypeEnum } from 'models/ActivityInfo'
import { TaskStatus, TaskStatusEnum } from 'models/ActivityUser'
import { join } from 'path'
import { formatDate } from 'zutils/utils/date.util'
import { GeneralScription } from 'models/chain/GeneralScription'
const fs = require('fs')
const prod = process.env.NODE_ENV === 'production'
@ -191,6 +192,16 @@ export default class TasksController extends BaseController {
if (currentTask.status !== TaskStatusEnum.SUCCESS && currentTask.status !== TaskStatusEnum.PART_SUCCESS) {
throw new ZError(13, 'task not end')
}
if (cfg.checkChain) {
const chainRecord = await GeneralScription.findOne({
from: user.address.toLowerCase(),
op: 'task_claim',
data: task,
})
if (!chainRecord) {
throw new ZError(14, 'waiting for chain confirm')
}
}
const Task = require('../tasks/' + currentTask.task)
const taskInstance = new Task.default({ user, activity })

View File

@ -39,6 +39,8 @@ export class TaskCfg {
end?: string
@prop({ type: mongoose.Schema.Types.Mixed })
params: any
@prop({ default: true })
checkChain: boolean
public isStart() {
const now = Date.now()