Commit 98efd01e authored by qinhaitao's avatar qinhaitao

feat: 🎸 初始化设置

parent a2bdbe9b
...@@ -25,7 +25,7 @@ export default class Test2Controller { ...@@ -25,7 +25,7 @@ export default class Test2Controller {
* 统计数据 * 统计数据
*/ */
@checkParams(['activityId', 'startDay', 'endDay']) @checkParams(['activityId', 'startDay', 'endDay'])
@preUpdate([updateVip(1, 2), updateSignTask, updateOrderGoods]) @preUpdate([updateVip, updateSignTask, updateOrderGoods])
@services([CommonStatService]) @services([CommonStatService])
async test2getStats( async test2getStats(
context: IContext<IParams>, context: IContext<IParams>,
......
...@@ -20,9 +20,10 @@ export default function checkParams(params: string[]): IFunction { ...@@ -20,9 +20,10 @@ export default function checkParams(params: string[]): IFunction {
descriptor.value = function (...args: any[]) { descriptor.value = function (...args: any[]) {
const [context, otherArgs = {}, services = [], preCheckData = {}] = args const [context, otherArgs = {}, services = [], preCheckData = {}] = args
const dataKeys = Object.keys(context.data).filter(v => !v.endsWith('?')) const dataKeys = Object.keys(context.data)
for (let i = 0; i < params.length; i++) { const requiredParams = params.filter(v => !v.endsWith('?'))
const param = params[i] for (let i = 0; i < requiredParams.length; i++) {
const param = requiredParams[i]
if (!dataKeys.includes(param) || context.data?.[param] === '') { if (!dataKeys.includes(param) || context.data?.[param] === '') {
logFn(context) logFn(context)
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少${param}参数`) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少${param}参数`)
......
...@@ -99,6 +99,7 @@ export default class AwardsService extends UserService { ...@@ -99,6 +99,7 @@ export default class AwardsService extends UserService {
) )
return { return {
expiredTime: activityInfo.awardReceiveExpiredTime,
list: this.formatMyPrizeList(myPrizeList, activityInfo.awardReceiveExpiredTime) list: this.formatMyPrizeList(myPrizeList, activityInfo.awardReceiveExpiredTime)
} }
} }
......
...@@ -71,10 +71,14 @@ class UserService extends BaseService { ...@@ -71,10 +71,14 @@ class UserService extends BaseService {
inviteId, inviteId,
userNick, userNick,
openId, openId,
gameTimes: 0,
totalScore: 0,
maxScore: 0,
// 待领取次数初始化, 根据需自定义添加 // 待领取次数初始化, 根据需自定义添加
remainTimes: { remainTimes: {
follow: isFollow ? follow.value : 0, follow: isFollow ? follow.value : 0,
member: vipInfo.isVip ? member.value : 0 member: vipInfo.isVip ? member.value : 0,
...initRemainTimes
}, },
member: { member: {
flag: !!vipInfo.isVip flag: !!vipInfo.isVip
...@@ -93,6 +97,16 @@ class UserService extends BaseService { ...@@ -93,6 +97,16 @@ class UserService extends BaseService {
updateTime: Date.now() 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) { if (isFollow) {
user.taskInfo[today].follow = [{ createTime: Date.now() }] user.taskInfo[today].follow = [{ createTime: Date.now() }]
...@@ -161,7 +175,7 @@ class UserService extends BaseService { ...@@ -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 { activityId } = this.context.data
//获取排名 //获取排名
let list = await this.userdao.find<IUserInfo>( let list = await this.userdao.find<IUserInfo>(
...@@ -197,7 +211,7 @@ class UserService extends BaseService { ...@@ -197,7 +211,7 @@ class UserService extends BaseService {
* @return {number} 排行 * @return {number} 排行
* @memberof UserService * @memberof UserService
*/ */
async getMyRankInfo(sortValueKey: string, sortTimeKey: string, userInfo: IUserInfo) { async getMyRankInfo(sortValueKey = 'totalScore', sortTimeKey = 'updateScoreTime', userInfo: IUserInfo) {
let { activityId } = this.context.data let { activityId } = this.context.data
const { openId } = this.context const { openId } = this.context
const userValue = userInfo[sortValueKey] 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