Commit 03ceceb4 authored by maggie's avatar maggie

save

parent 03c6bb44
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
}, },
"task": { "task": {
"getTaskList": { "getTaskList": {
"desc": "任务列表",
"decorators": [ "decorators": [
{ {
"type": "common", "type": "common",
...@@ -129,26 +130,150 @@ ...@@ -129,26 +130,150 @@
"service": "task", "service": "task",
"function": "initTask", "function": "initTask",
"params": [ "params": [
{ "type": "string", "value": "member" },
{ "type": "string", "value": "加入会员" },
{ "type": "var", "value": "activityInfo" }, { "type": "var", "value": "activityInfo" },
{ "type": "var", "value": "userInfo" } { "type": "var", "value": "userInfo" }
], ],
"return": true "return": true
}
]
},
"doCompleteTask": {
"desc": "完成任务",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [
"activityId",
"taskType"
]
},
{
"type": "common",
"name": "registeInfos",
"params": [
"session"
]
},
{
"type": "common",
"name": "preCheck",
"params": [
{
"type": "common",
"behave": "check",
"name": "checkActivityTime"
},
{
"type": "common",
"behave": "check",
"name": "checkTaskLimit"
}, },
{
"type": "common",
"behave": "check",
"name": "checkExchangeCreditsTask"
}
]
}
],
"main": [
{ {
"type": "common", "type": "common",
"service": "task", "service": "task",
"function": "initTask", "function": "completeTask",
"params": [ "params": [
{ "type": "string", "value": "follow" }, { "type": "var", "value": "context.data.taskType" },
{ "type": "string", "value": "关注店铺" },
{ "type": "var", "value": "activityInfo" }, { "type": "var", "value": "activityInfo" },
{ "type": "var", "value": "userInfo" } { "type": "var", "value": "userInfo" }
], ],
"return": true "return": true
} }
] ]
},
"receiveTaskRewards": {
"desc": "领取任务奖励",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [
"activityId",
"taskType",
"rewardsKey"
]
},
{
"type": "common",
"name": "preCheck",
"params": [
{
"type": "common",
"behave": "check",
"name": "checkActivityTime"
},
{
"type": "common",
"behave": "check",
"name": "checkRemainTimes"
}
]
}
],
"main": [
{
"type": "common",
"service": "task",
"function": "receiveTaskRewards",
"params": [
{ "type": "var", "value": "context.data.taskType" },
{ "type": "var", "value": "context.data.rewardsKey" },
{ "type": "var", "value": "userInfo" }
],
"return": true
}
]
},
"getCollectGoodsList": {
"desc": "获取收藏商品列表",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [
"activityId",
"itemIds"
]
},
{
"type": "common",
"name": "registeInfos",
"params": [
"session"
]
}
],
"main": [
{
"type": "common",
"service": "base",
"function": "getItemListByIds",
"params": [
{ "type": "var", "value": "context.data.itemIds" },
{ "type": "var", "value": "session" }
]
},
{
"type": "common",
"service": "task",
"function": "getItemListWithCollectStatus",
"params": [
{ "type": "var", "value": "commonBaseGetitemlistbyidsResult1" },
{ "type": "var", "value": "userInfo" }
],
"return": true
}
]
} }
} }
} }
......
/** @format */
{% import "macro.njk" as macro -%}
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import { resultsModel } from '../../sdk'
{{-macro.genControllerService(service)}}
export default class Stat {
{%- for fn, item in model %}
/**
* {{item.desc}}
*/
{{-macro.genDecorator(model[fn].decorators)}}
@services([{{-macro.genServicesDecorator(model[fn].main)}}])
async {{fn}}(
context: IContext<IParams>,
{ activityInfo, userInfo{{-macro.genRegisteInfosParams(model[fn].decorators)}} }: IControllerInfos,
{{-macro.genServicesParams(model[fn].main)}}
) {
{{-macro.genMain(model[fn].main)}}
{{-macro.genReturn(model[fn].main)}}
}
{%- endfor %}
}
...@@ -3,11 +3,11 @@ import commonDecorator, { services } from '../../decorator/common' ...@@ -3,11 +3,11 @@ import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check' import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update' import commonUtilUpdate from '../../utils/common/update'
import { resultsModel } from '../../sdk' import { resultsModel } from '../../sdk'
import { TaskService } from '../../service' import { TaskService, BaseService } from '../../service'
export default class Task { export default class Task {
/** /**
* * 任务列表
*/ */
@commonDecorator.checkParams(['activityId']) @commonDecorator.checkParams(['activityId'])
@commonDecorator.registeInfos(['vipInfo']) @commonDecorator.registeInfos(['vipInfo'])
...@@ -19,11 +19,59 @@ export default class Task { ...@@ -19,11 +19,59 @@ export default class Task {
{ activityInfo, userInfo, vipInfo }: IControllerInfos, { activityInfo, userInfo, vipInfo }: IControllerInfos,
[taskService]: [TaskService] [taskService]: [TaskService]
) { ) {
const commonTaskInittaskResult1 = await taskService.initTask('member', '加入会员', activityInfo, userInfo) const commonTaskInittaskResult1 = await taskService.initTask(activityInfo, userInfo)
const commonTaskInittaskResult2 = await taskService.initTask('follow', '关注店铺', activityInfo, userInfo)
return resultsModel.success({ return resultsModel.success({
...commonTaskInittaskResult1, ...commonTaskInittaskResult1
...commonTaskInittaskResult2 })
}
/**
* 完成任务
*/
@commonDecorator.checkParams(['activityId', 'taskType'])
@commonDecorator.registeInfos(['session'])
@commonDecorator.preCheck([commonUtilCheck.checkActivityTime, commonUtilCheck.checkTaskLimit, commonUtilCheck.checkExchangeCreditsTask])
@services([TaskService])
async doCompleteTask(
context: IContext<IParams>,
{ activityInfo, userInfo, session }: IControllerInfos,
[taskService]: [TaskService]
) {
const commonTaskCompletetaskResult1 = await taskService.completeTask(context.data.taskType, activityInfo, userInfo)
return resultsModel.success({
...commonTaskCompletetaskResult1
})
}
/**
* 领取任务奖励
*/
@commonDecorator.checkParams(['activityId', 'taskType', 'rewardsKey'])
@commonDecorator.preCheck([commonUtilCheck.checkActivityTime, commonUtilCheck.checkRemainTimes])
@services([TaskService])
async receiveTaskRewards(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[taskService]: [TaskService]
) {
const commonTaskReceivetaskrewardsResult1 = await taskService.receiveTaskRewards(context.data.taskType, context.data.rewardsKey, userInfo)
return resultsModel.success({
...commonTaskReceivetaskrewardsResult1
})
}
/**
* 获取收藏商品列表
*/
@commonDecorator.checkParams(['activityId', 'itemIds'])
@commonDecorator.registeInfos(['session'])
@services([BaseService, TaskService])
async getCollectGoodsList(
context: IContext<IParams>,
{ activityInfo, userInfo, session }: IControllerInfos,
[baseService, taskService]: [BaseService, TaskService]
) {
const commonBaseGetitemlistbyidsResult1 = await baseService.getItemListByIds(context.data.itemIds, session)
const commonTaskGetitemlistwithcollectstatusResult2 = await taskService.getItemListWithCollectStatus(commonBaseGetitemlistbyidsResult1, userInfo)
return resultsModel.success({
...commonTaskGetitemlistwithcollectstatusResult2
}) })
} }
} }
...@@ -13,11 +13,11 @@ export default class User { ...@@ -13,11 +13,11 @@ export default class User {
@commonDecorator.registeInfos(['session']) @commonDecorator.registeInfos(['session'])
@services([UserService]) @services([UserService])
async getVipInfo( async getVipInfo(
context: IContext<IVipParams>, context: IContext<IParams>,
{ activityInfo }: IControllerInfos, { activityInfo, userInfo, session }: IControllerInfos,
[userService]: [UserService] [userService]: [UserService]
): Promise<IResult<IVipInfo>> { ) {
const commonUserGetshopvipResult = await userService.getShopVip(context, activityInfo) const commonUserGetshopvipResult1 = await userService.getShopVip(context, session)
return resultsModel.success({ return resultsModel.success({
...commonUserGetshopvipResult1 ...commonUserGetshopvipResult1
}) })
......
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