Commit 16a0fbee authored by 王波's avatar 王波

修改基础模板

parent 1f2739df
......@@ -81,7 +81,8 @@
"type": "common",
"name": "registeInfos",
"params": [
"vipInfo"
"vipInfo",
"task"
]
},
{
......@@ -107,12 +108,12 @@
{
"type": "common",
"behave": "update",
"name": "updateSignTask"
"name": "updateSignGrowTask"
},
{
"type": "common",
"behave": "update",
"name": "updateOrderGoods"
"name": "updateGrowOrderGoods"
}
]
}
......@@ -120,11 +121,12 @@
"main": [
{
"type": "common",
"service": "task",
"service": "Growtask",
"function": "initTaskList",
"params": [
{ "type": "var", "value": "userInfo" },
{ "type": "var", "value": "activityInfo" }
{ "type": "var", "value": "activityInfo" },
{ "type": "var", "value": "task" }
],
"return": true
}
......@@ -145,7 +147,8 @@
"type": "common",
"name": "registeInfos",
"params": [
"session"
"session",
"task"
]
},
{
......@@ -161,7 +164,7 @@
{
"type": "common",
"behave": "check",
"name": "checkTaskLimit"
"name": "checkGrowTaskLimit"
},
{
"type": "common",
......@@ -174,12 +177,13 @@
"main": [
{
"type": "common",
"service": "task",
"service": "Growtask",
"function": "completeTask",
"params": [
{ "type": "var", "value": "context.data.taskType" },
{ "type": "var", "value": "activityInfo" },
{ "type": "var", "value": "userInfo" }
{ "type": "var", "value": "userInfo" },
{ "type": "var", "value": "task" }
],
"return": true
}
......@@ -217,7 +221,7 @@
"main": [
{
"type": "common",
"service": "task",
"service": "Growtask",
"function": "receiveTaskRewards",
"params": [
{ "type": "var", "value": "context.data.taskType" },
......@@ -259,7 +263,7 @@
},
{
"type": "common",
"service": "task",
"service": "Growtask",
"function": "getItemListWithCollectStatus",
"params": [
{ "type": "var", "value": "commonBaseGetItemListByIdsResult1" },
......
......@@ -108,7 +108,6 @@ export enum STAT_TYPE {
INITE_SUCCESS
}
// 每次参与消耗次数
export const JOIN_NEED_TIMES = 1
......
/** @format */
import { services, checkParams, registeInfos, preCheck, preUpdate } from '../../decorator/common'
import { checkActivityTime, checkTaskLimit, checkExchangeCreditsTask, checkRemainTimes } from '../../utils/common/check'
import { updateVip, updateSignTask, updateOrderGoods } from '../../utils/common/update'
import {
checkActivityTime,
checkGrowTaskLimit,
checkExchangeCreditsTask,
checkRemainTimes
} from '../../utils/common/check'
import { updateVip, updateSignGrowTask, updateGrowOrderGoods } from '../../utils/common/update'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonTaskService, CommonBaseService } from '../../service/common'
import { CommonGrowtaskService, CommonBaseService } from '../../service/common'
export default class TaskController {
/**
* 任务列表
*/
@checkParams(['activityId'])
@registeInfos(['vipInfo'])
@services([CommonTaskService])
@registeInfos(['vipInfo', 'task'])
@services([CommonGrowtaskService])
@preCheck([checkActivityTime])
@preUpdate([updateVip, updateSignTask, updateOrderGoods])
@preUpdate([updateVip, updateSignGrowTask, updateGrowOrderGoods])
async getTaskList(
context: IContext<IParams>,
{ activityInfo, userInfo, vipInfo }: IControllerInfos,
[commonTaskService]: [CommonTaskService]
{ activityInfo, userInfo, vipInfo, task }: IControllerInfos,
[commonGrowtaskService]: [CommonGrowtaskService]
) {
const commonTaskInitTaskListResult1 = await commonTaskService.initTaskList(userInfo, activityInfo)
const commonGrowtaskInitTaskListResult1 = await commonGrowtaskService.initTaskList(userInfo, activityInfo, task)
return resultsModel.success({
...commonTaskInitTaskListResult1
...commonGrowtaskInitTaskListResult1
})
}
/**
* 完成任务
*/
@checkParams(['activityId', 'taskType'])
@registeInfos(['session'])
@services([CommonTaskService])
@preCheck([checkActivityTime, checkTaskLimit, checkExchangeCreditsTask])
@registeInfos(['session', 'task'])
@services([CommonGrowtaskService])
@preCheck([checkActivityTime, checkGrowTaskLimit, checkExchangeCreditsTask])
async doCompleteTask(
context: IContext<IParams>,
{ activityInfo, userInfo, session }: IControllerInfos,
[commonTaskService]: [CommonTaskService]
{ activityInfo, userInfo, session, task }: IControllerInfos,
[commonGrowtaskService]: [CommonGrowtaskService]
) {
const commonTaskCompleteTaskResult1 = await commonTaskService.completeTask(
const commonGrowtaskCompleteTaskResult1 = await commonGrowtaskService.completeTask(
context.data.taskType,
activityInfo,
userInfo
userInfo,
task
)
return resultsModel.success({
...commonTaskCompleteTaskResult1
...commonGrowtaskCompleteTaskResult1
})
}
/**
* 领取任务奖励
*/
@checkParams(['activityId', 'taskType', 'rewardsKey'])
@services([CommonTaskService])
@services([CommonGrowtaskService])
@preCheck([checkActivityTime, checkRemainTimes])
async receiveTaskRewards(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonTaskService]: [CommonTaskService]
[commonGrowtaskService]: [CommonGrowtaskService]
) {
const commonTaskReceiveTaskRewardsResult1 = await commonTaskService.receiveTaskRewards(
const commonGrowtaskReceiveTaskRewardsResult1 = await commonGrowtaskService.receiveTaskRewards(
context.data.taskType,
context.data.rewardsKey,
userInfo
)
return resultsModel.success({
...commonTaskReceiveTaskRewardsResult1
...commonGrowtaskReceiveTaskRewardsResult1
})
}
/**
......@@ -71,19 +77,19 @@ export default class TaskController {
*/
@checkParams(['activityId', 'itemIds'])
@registeInfos(['session'])
@services([CommonBaseService, CommonTaskService])
@services([CommonBaseService, CommonGrowtaskService])
async getCollectGoodsList(
context: IContext<IParams>,
{ activityInfo, userInfo, session }: IControllerInfos,
[commonBaseService, commonTaskService]: [CommonBaseService, CommonTaskService]
[commonBaseService, commonGrowtaskService]: [CommonBaseService, CommonGrowtaskService]
) {
const commonBaseGetItemListByIdsResult1 = await commonBaseService.getItemListByIds(context.data.itemIds, session)
const commonTaskGetItemListWithCollectStatusResult2 = await commonTaskService.getItemListWithCollectStatus(
const commonGrowtaskGetItemListWithCollectStatusResult2 = await commonGrowtaskService.getItemListWithCollectStatus(
commonBaseGetItemListByIdsResult1,
userInfo
)
return resultsModel.success({
...commonTaskGetItemListWithCollectStatusResult2
...commonGrowtaskGetItemListWithCollectStatusResult2
})
}
}
......@@ -2,7 +2,7 @@
import { services, preCheck, registeInfos, preUpdate, checkParams } from '../decorator/common'
import { resultsModel } from '../sdk'
import { CommonStatService, CommonGrowTaskService } from '../service/common'
import { CommonStatService, CommonGrowtaskService } from '../service/common'
import { STAT_TYPE } from '../constants'
import { checkActivityTime, checkInviteId, checkHelpRecord, checkNewVip } from '../utils/common/check'
import { updateHelpRecord, updateVip } from '../utils/common/update'
......@@ -14,13 +14,13 @@ export default class Share {
*/
@checkParams(['activityId', 'inviteId'])
@registeInfos(['vipInfo'])
@services([CommonGrowTaskService, CommonStatService])
@services([CommonGrowtaskService, CommonStatService])
@preCheck([checkActivityTime, checkInviteId, checkNewVip, checkHelpRecord])
@preUpdate([updateVip, updateHelpRecord])
async doHelp(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[growTaskService, statService]: [CommonGrowTaskService, CommonStatService],
[growTaskService, statService]: [CommonGrowtaskService, CommonStatService],
{ inviteUserInfo }: IPreCheckData
) {
// 如果邀请任务是每日的,则需要请求每日任务信息
......
......@@ -2,7 +2,7 @@
import { checkParams, services, registeInfos, preCheck } from '../decorator/common'
import { resultsModel } from '../sdk'
import { CommonGrowTaskService, CommonBaseService } from '../service/common'
import { CommonGrowtaskService, CommonBaseService } from '../service/common'
import { ITaskInfo } from '../service/common/task.service'
import {
checkActivityTime,
......@@ -20,13 +20,13 @@ export default class Task {
*/
@checkParams(['activityId'])
@registeInfos(['vipInfo', 'task'])
@services([CommonGrowTaskService])
@services([CommonGrowtaskService])
@preCheck([checkActivityTime])
@preUpdate([updateVip, updateSignGrowTask, updateGrowOrderGoods])
async getTaskList(
context: IContext<IParams>,
{ userInfo, activityInfo, task }: IControllerInfos,
[growTaskService]: [CommonGrowTaskService]
[growTaskService]: [CommonGrowtaskService]
): Promise<IResult<{ list: ITaskInfo[] }>> {
// 读取B端 tasks字段配置自动生成任务列表
const result = await growTaskService.initTaskList(userInfo, activityInfo, task)
......@@ -44,12 +44,12 @@ export default class Task {
*/
@checkParams(['activityId', 'taskType', 'itemId?', 'credits?'])
@registeInfos(['session', 'task'])
@services([CommonGrowTaskService])
@services([CommonGrowtaskService])
@preCheck([checkActivityTime, checkGrowTaskLimit, checkExchangeCreditsTask])
async doCompleteTask(
context: IContext<IParams>,
{ userInfo, activityInfo, task }: IControllerInfos,
[growTaskService]: [CommonGrowTaskService]
[growTaskService]: [CommonGrowtaskService]
) {
const { taskType } = context.data
......@@ -64,12 +64,12 @@ export default class Task {
* 领取的奖励增加的key值 如: gameTimes 前端传入
*/
@checkParams(['activityId', 'taskType', 'rewardsKey'])
@services([CommonGrowTaskService])
@services([CommonGrowtaskService])
@preCheck([checkActivityTime, checkRemainTimes])
async receiveTaskRewards(
context: IContext<IParams>,
{ userInfo }: IControllerInfos,
[growTaskService]: [CommonGrowTaskService]
[growTaskService]: [CommonGrowtaskService]
): Promise<IResult<{ rewards: number }>> {
const { rewardsKey } = context.data
const { taskType } = context.data
......@@ -84,11 +84,11 @@ export default class Task {
*/
@checkParams(['activityId', 'itemIds'])
@registeInfos(['session'])
@services([CommonBaseService, CommonGrowTaskService])
@services([CommonBaseService, CommonGrowtaskService])
async getCollectGoodsList(
context: IContext<IParams>,
{ session, userInfo }: IControllerInfos,
[commonBaseService, growTaskService]: [CommonBaseService, CommonGrowTaskService]
[commonBaseService, growTaskService]: [CommonBaseService, CommonGrowtaskService]
) {
const { itemIds } = context.data
......
......@@ -8,7 +8,7 @@ import CommonTaskService from './task.service'
import CommonStatService from './stat.service'
import CommonGameService from './game.service'
import CommonSignService from './sign.service'
import CommonGrowTaskService from './growTask.service'
import CommonGrowtaskService from './growTask.service'
const common = {
CommonAccessService,
......@@ -19,7 +19,7 @@ const common = {
CommonStatService,
CommonGameService,
CommonSignService,
CommonGrowTaskService
CommonGrowtaskService
}
export default common
......@@ -33,5 +33,5 @@ export {
CommonStatService,
CommonGameService,
CommonSignService,
CommonGrowTaskService
CommonGrowtaskService
}
......@@ -2,8 +2,7 @@
type IActivityInfo = ICommonActivityInfo & ICustomActivityInfo
interface ICustomActivityInfo {
}
interface ICustomActivityInfo {}
interface ICommonActivityInfo {
_id?: string
id?: string
......
......@@ -15,11 +15,13 @@ export default async function updateSignTask(
if (todayCompleteTimes === 0) {
const result = await updateTaskInfo(context, task._id, 'sign', { createTime: Date.now() })
return result === 1 ? {
$inc: {
'remainTimes.sign': value || 0
},
} : {}
return result === 1
? {
$inc: {
'remainTimes.sign': value || 0
}
}
: {}
}
return {}
}
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