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

修改基础模板

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