update activity cfg

This commit is contained in:
CounterFire2023 2024-01-09 17:23:49 +08:00
parent bd2b7b577b
commit a41fb9aa3a
6 changed files with 101 additions and 48 deletions

View File

@ -310,6 +310,8 @@ body:
"scoreTotal": 200, // 总积分 "scoreTotal": 200, // 总积分
"rankTotal": "-", "rankTotal": "-",
"invite": "邀请人address", "invite": "邀请人address",
"inviteCount": 0, // 我邀请的用户总数
"inviteScore": 0, // 我邀请用户总数获得的分数
"code": "自己的邀请码" "code": "自己的邀请码"
} }
``` ```

View File

@ -6,18 +6,18 @@
"tasks": [{ "tasks": [{
"id": "e2yhq2lj30vwcpedv7p", "id": "e2yhq2lj30vwcpedv7p",
"task": "TwitterConnect", "task": "TwitterConnect",
"title": "Connect Twitter", "title": "",
"type": 1, "type": 1,
"desc": "", "desc": "",
"score": 100, "score": 0,
"category": "", "category": "",
"autoclaim": true, "autoclaim": false,
"cfg": {"icon": "twitter"}, "cfg": {"icon": "twitter"},
"params": {} "params": {}
}, { }, {
"id": "e2fclylj30vwcpe0szl", "id": "e2fclylj30vwcpe0szl",
"task": "TwitterFollow", "task": "TwitterFollow",
"title": "Follow Twitter", "title": "",
"type": 1, "type": 1,
"desc": "Follow Counter Fires official X account", "desc": "Follow Counter Fires official X account",
"category": "Social Tasks", "category": "Social Tasks",
@ -29,7 +29,7 @@
}, { }, {
"id": "e2feyflj30vwcpe0sjy", "id": "e2feyflj30vwcpe0sjy",
"task": "TwitterFollow", "task": "TwitterFollow",
"title": "Follow Twitter", "title": "",
"type": 1, "type": 1,
"desc": "", "desc": "",
"category": "Social Tasks", "category": "Social Tasks",
@ -41,23 +41,35 @@
}, { }, {
"id": "e2fuah0j30vwcpe0my7", "id": "e2fuah0j30vwcpe0my7",
"task": "TwitterRetweet", "task": "TwitterRetweet",
"title": "ReTwitter", "title": "",
"type": 2, "type": 1,
"desc": "", "desc": "Show your friends Counter Fire.",
"category": "Social Tasks", "category": "Social Tasks",
"score": 100, "score": 150,
"autoclaim": false, "autoclaim": false,
"pretasks": ["e2yhq2lj30vwcpedv7p"], "pretasks": ["e2yhq2lj30vwcpedv7p"],
"cfg": {"icon": "twitter"}, "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"},
"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": "输入框自动生成,活动开始时添加内容)"},
"params": {"time": 6, "failRate": 60} "params": {"time": 6, "failRate": 60}
}, { }, {
"id": "e2far3lj30vwcpe0mh7", "id": "e2far3lj30vwcpe0mh7",
"task": "DiscordConnect", "task": "DiscordConnect",
"title": "Connect Discord", "title": "",
"type": 1, "type": 1,
"desc": "", "desc": "",
"category": "", "category": "",
"score": 100, "score": 0,
"autoclaim": false, "autoclaim": false,
"pretasks": [], "pretasks": [],
"cfg": {"icon": "discord"}, "cfg": {"icon": "discord"},
@ -65,8 +77,8 @@
}, { }, {
"id": "e2far3lj30vwcpe0mf8", "id": "e2far3lj30vwcpe0mf8",
"task": "DiscordJoin", "task": "DiscordJoin",
"title": "Join Discord", "title": "",
"type": 2, "type": 1,
"desc": "Join Counter Fires official Discord server", "desc": "Join Counter Fires official Discord server",
"category": "Social Tasks", "category": "Social Tasks",
"score": 100, "score": 100,
@ -78,10 +90,10 @@
"id": "e2fak2lj30vwcpe0awc", "id": "e2fak2lj30vwcpe0awc",
"task": "DiscordRole", "task": "DiscordRole",
"title": "Discord Role", "title": "Discord Role",
"type": 2, "type": 1,
"desc": "", "desc": "Get a role in Counter Fires official Discord ",
"category": "Social Tasks", "category": "Social Tasks",
"score": 100, "score": 200,
"autoclaim": false, "autoclaim": false,
"pretasks": ["e2far3lj30vwcpe0mf8"], "pretasks": ["e2far3lj30vwcpe0mf8"],
"cfg": {"icon": "discord"}, "cfg": {"icon": "discord"},
@ -89,7 +101,7 @@
}, { }, {
"id": "e2feyflj30vwcpe0sjx", "id": "e2feyflj30vwcpe0sjx",
"task": "YoutubeFollow", "task": "YoutubeFollow",
"title": "Follow Youtube", "title": "",
"type": 1, "type": 1,
"desc": "Follow Counter Fires official YTB account", "desc": "Follow Counter Fires official YTB account",
"category": "Social Tasks", "category": "Social Tasks",
@ -101,43 +113,43 @@
}, { }, {
"id": "e2feyflj30vwcpe0sjz", "id": "e2feyflj30vwcpe0sjz",
"task": "YoutubePost", "task": "YoutubePost",
"title": "Post Youtube", "title": "",
"type": 1, "type": 1,
"desc": "Post a video introducing @_CounterFire", "desc": "Post a video introducing @_CounterFire",
"category": "Social Tasks", "category": "Social Tasks",
"score": 100, "score": 500,
"autoclaim": false, "autoclaim": false,
"pretasks": [], "pretasks": [],
"cfg": {"icon": "youtube"}, "cfg": {"icon": "youtube"},
"params": {"time": 6, "failRate": 60} "params": {"time": 6, "failRate": 60}
}, { }, {
"id": "e2f7fplj30vwcpe0l98", "id": "e2fuah0j30vwcpe2my7",
"task": "OkxLogin", "task": "TwitterRetweet",
"title": "okx wallet login", "title": "",
"type": 2,
"desc": "Showcase your performance in Counter Fire to your friends!",
"category": "Social Tasks",
"score": 300,
"autoclaim": false,
"pretasks": ["e2yhq2lj30vwcpedv7p"],
"cfg": {"icon": "twitter", "content": "Just scored xx Flame on @_CounterFire! 🔥 Join me in the action-packed fun and let's play to earn! #GamingAdventures #CounterFire"},
"params": {"time": 6, "failRate": 60}
}, {
"id": "e2fuah0j30vwcpe2my7",
"task": "TwitterRetweet",
"title": "",
"type": 1, "type": 1,
"desc": "", "desc": "Post to confess your 💕 for @_CounterFire",
"category": "Special Quests", "category": "Referral to Earn",
"score": 100, "score": 100,
"autoclaim": false, "autoclaim": false,
"pretasks": [], "pretasks": ["e2yhq2lj30vwcpedv7p"],
"cfg": {"account": "okx", "icon": "okx"}, "cfg": {"icon": "twitter", "content": "Just scored xx Flame on @_CounterFire! 🔥 Join me in the action-packed fun and let's play to earn! #GamingAdventures #CounterFire"},
"params": {} "params": {"time": 6, "failRate": 60}
}, {
"id": "e2f7fplj30vwcpe0l96",
"task": "DailyCheckIn",
"title": "daily checkin",
"type": 2,
"desc": "",
"category": "Special Quests",
"score": 20,
"autoclaim": false,
"pretasks": [],
"cfg": {"score": [0, 15, 20, 20, 40, 40, 60]},
"params": {"days": 1, "score": [0, 15, 20, 20, 40, 40, 60]}
}, { }, {
"id": "e2f7fplj30vwcpe0l97", "id": "e2f7fplj30vwcpe0l97",
"task": "DailyCheckIn", "task": "DailyCheckIn",
"title": "daily checkin", "title": "",
"type": 1, "type": 1,
"desc": "Check-in for 3 consecutive days.", "desc": "Check-in for 3 consecutive days.",
"category": "Referral to Earn", "category": "Referral to Earn",
@ -146,16 +158,42 @@
"pretasks": [], "pretasks": [],
"cfg": {}, "cfg": {},
"params": {"days": 3} "params": {"days": 3}
}, {
"id": "e2f7fplj30vwcpe0l98",
"task": "OkxLogin",
"title": "",
"type": 1,
"desc": "Sign in via OKX Wallet.",
"category": "Referral to Earn",
"score": 300,
"autoclaim": false,
"pretasks": [],
"cfg": {"account": "okx", "icon": "okx"},
"params": {}
}, {
"id": "e2f7fplj30vwcpe0l96",
"task": "DailyCheckIn",
"title": "",
"type": 2,
"desc": "Daily check-in! Score more Flames with 7 days of consecutive check-ins. Ignite it now!",
"category": "Social Tasks",
"score": 20,
"autoclaim": false,
"pretasks": [],
"cfg": {"score": [0, 15, 20, 20, 40, 40, 60]},
"params": {"days": 1, "score": [0, 15, 20, 20, 40, 40, 60]}
}, { }, {
"id": "e2f7t4lj30vwcpe0ldr", "id": "e2f7t4lj30vwcpe0ldr",
"task": "ShareCode", "task": "ShareCode",
"title": "",
"desc": "Click here if your are referred by a friend!",
"type": 1, "type": 1,
"show": false, "show": true,
"autoclaim": false, "autoclaim": false,
"pretasks": [], "pretasks": [],
"cfg": {}, "cfg": {},
"score": 100, "score": 500,
"params": {"score": [100, 20]} "params": {"score": [500]}
}, { }, {
"id": "e2f7t4lj31vwcpe0ldr", "id": "e2f7t4lj31vwcpe0ldr",
"task": "BurnNft", "task": "BurnNft",

View File

@ -4,6 +4,7 @@ import { role, router } from 'decorators/router'
import logger from 'logger/logger' import logger from 'logger/logger'
import { ActivityUser } from 'models/ActivityUser' import { ActivityUser } from 'models/ActivityUser'
import {DEFAULT_EXPIRED, NonceRecord} from 'models/NonceRecord' import {DEFAULT_EXPIRED, NonceRecord} from 'models/NonceRecord'
import { ScoreRecord } from 'models/ScoreRecord'
import { LoginRecordQueue } from 'queue/loginrecord.queue' import { LoginRecordQueue } from 'queue/loginrecord.queue'
import { RedisClient } from 'redis/RedisClient' import { RedisClient } from 'redis/RedisClient'
import { queryCheckInList } from 'services/chain.svr' import { queryCheckInList } from 'services/chain.svr'
@ -94,6 +95,11 @@ class SignController extends BaseController {
invite = inviteUser.address invite = inviteUser.address
} }
} }
const records = await ScoreRecord.find({ user: user.id, activity: user.activity, scoreType: 'invite' })
let score = 0;
for (let record of records) {
score += record.score;
}
let result = { let result = {
address: user.address, address: user.address,
boost: user.boost || 1, boost: user.boost || 1,
@ -106,6 +112,8 @@ class SignController extends BaseController {
scoreTotal: totalScore ? parseInt(totalScore+'') : 0, scoreTotal: totalScore ? parseInt(totalScore+'') : 0,
rankTotal: totalRank ? totalRank : '-', rankTotal: totalRank ? totalRank : '-',
invite, invite,
inviteCount: records.length,
inviteScore: score,
code: user.inviteCode, code: user.inviteCode,
} }
return result; return result;

View File

@ -90,7 +90,8 @@ export default class TasksController extends BaseController {
for (let preTask of cfg.pretasks) { for (let preTask of cfg.pretasks) {
let preTaskData = user.taskProgress.find((t: TaskStatus) => { let preTaskData = user.taskProgress.find((t: TaskStatus) => {
if (preTask.type === TaskTypeEnum.DAILY) { if (preTask.type === TaskTypeEnum.DAILY) {
return t.id === `${preTask}:${formatDate(new Date())}` //这种情况下只要完成一次就算完成了
return t.id.indexOf(preTask) > -1
} }
return t.id === preTask return t.id === preTask
}); });

View File

@ -6,6 +6,7 @@ import { BaseModule } from './Base'
@dbconn() @dbconn()
@index({ user: 1 }, { unique: false }) @index({ user: 1 }, { unique: false })
@index({ activity: 1 }, { unique: false }) @index({ activity: 1 }, { unique: false })
@index({user: 1, activity: 1, type: 1}, { unique: false })
@modelOptions({ schemaOptions: { collection: 'score_record', timestamps: true }, options: { allowMixed: Severity.ALLOW } }) @modelOptions({ schemaOptions: { collection: 'score_record', timestamps: true }, options: { allowMixed: Severity.ALLOW } })
class ScoreRecordClass extends BaseModule { class ScoreRecordClass extends BaseModule {
@prop({ required: true}) @prop({ required: true})

View File

@ -29,8 +29,11 @@ export default class ShareCode extends ITask {
static show: boolean = false static show: boolean = false
async execute(data: any) { async execute(data: any) {
let {task} = data let { task } = data
let cfg = this.params.activity.tasks.find((t: TaskCfg) => t.id === task.id) let cfg = this.params.activity.tasks.find((t: TaskCfg) => t.id === task.id)
if (!this.params.user.inviteUser) {
throw new Error('not finished')
}
let scores = cfg.params.score; let scores = cfg.params.score;
task.status = TaskStatusEnum.SUCCESS task.status = TaskStatusEnum.SUCCESS
task.timeFinish = Date.now() task.timeFinish = Date.now()
@ -52,6 +55,6 @@ export default class ShareCode extends ITask {
await super.claimReward(task); await super.claimReward(task);
let cfg = this.params.activity.tasks.find((t: TaskCfg) => t.id === task.id) let cfg = this.params.activity.tasks.find((t: TaskCfg) => t.id === task.id)
let scores = cfg.params.score; let scores = cfg.params.score;
await updateInviteScore(this.params.user, scores, 0, task.task) await updateInviteScore(this.params.user, scores, 0, "invite")
} }
} }