Commit 98efd01e authored by qinhaitao's avatar qinhaitao

feat: 🎸 初始化设置

parent a2bdbe9b
......@@ -25,7 +25,7 @@ export default class Test2Controller {
* 统计数据
*/
@checkParams(['activityId', 'startDay', 'endDay'])
@preUpdate([updateVip(1, 2), updateSignTask, updateOrderGoods])
@preUpdate([updateVip, updateSignTask, updateOrderGoods])
@services([CommonStatService])
async test2getStats(
context: IContext<IParams>,
......
......@@ -20,9 +20,10 @@ export default function checkParams(params: string[]): IFunction {
descriptor.value = function (...args: any[]) {
const [context, otherArgs = {}, services = [], preCheckData = {}] = args
const dataKeys = Object.keys(context.data).filter(v => !v.endsWith('?'))
for (let i = 0; i < params.length; i++) {
const param = params[i]
const dataKeys = Object.keys(context.data)
const requiredParams = params.filter(v => !v.endsWith('?'))
for (let i = 0; i < requiredParams.length; i++) {
const param = requiredParams[i]
if (!dataKeys.includes(param) || context.data?.[param] === '') {
logFn(context)
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少${param}参数`)
......
......@@ -99,6 +99,7 @@ export default class AwardsService extends UserService {
)
return {
expiredTime: activityInfo.awardReceiveExpiredTime,
list: this.formatMyPrizeList(myPrizeList, activityInfo.awardReceiveExpiredTime)
}
}
......
......@@ -71,10 +71,14 @@ class UserService extends BaseService {
inviteId,
userNick,
openId,
gameTimes: 0,
totalScore: 0,
maxScore: 0,
// 待领取次数初始化, 根据需自定义添加
remainTimes: {
follow: isFollow ? follow.value : 0,
member: vipInfo.isVip ? member.value : 0
member: vipInfo.isVip ? member.value : 0,
...initRemainTimes
},
member: {
flag: !!vipInfo.isVip
......@@ -93,6 +97,16 @@ class UserService extends BaseService {
updateTime: Date.now()
}
function initRemainTimes(tasks: ITasks) {
let remainTimes = {} as IRemainTimesInfo
Object.keys(tasks).forEach(task => {
if (task !== 'follow' && task !== 'member') {
remainTimes[task] = 0
}
})
return remainTimes
}
// 初始化 如果已关注添加任务记录
if (isFollow) {
user.taskInfo[today].follow = [{ createTime: Date.now() }]
......@@ -161,7 +175,7 @@ class UserService extends BaseService {
}
// 获取排名列表
async getRank(sortValueKey: string, sortTimeKey: string, limit: number = 200) {
async getRank(sortValueKey = 'totalScore', sortTimeKey = 'updateScoreTime', limit = 200) {
let { activityId } = this.context.data
//获取排名
let list = await this.userdao.find<IUserInfo>(
......@@ -197,7 +211,7 @@ class UserService extends BaseService {
* @return {number} 排行
* @memberof UserService
*/
async getMyRankInfo(sortValueKey: string, sortTimeKey: string, userInfo: IUserInfo) {
async getMyRankInfo(sortValueKey = 'totalScore', sortTimeKey = 'updateScoreTime', userInfo: IUserInfo) {
let { activityId } = this.context.data
const { openId } = this.context
const userValue = userInfo[sortValueKey]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment