Commit 03ceceb4 authored by maggie's avatar maggie

save

parent 03c6bb44
......@@ -75,6 +75,7 @@
},
"task": {
"getTaskList": {
"desc": "任务列表",
"decorators": [
{
"type": "common",
......@@ -129,26 +130,150 @@
"service": "task",
"function": "initTask",
"params": [
{ "type": "string", "value": "member" },
{ "type": "string", "value": "加入会员" },
{ "type": "var", "value": "activityInfo" },
{ "type": "var", "value": "userInfo" }
],
"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",
"service": "task",
"function": "initTask",
"function": "completeTask",
"params": [
{ "type": "string", "value": "follow" },
{ "type": "string", "value": "关注店铺" },
{ "type": "var", "value": "context.data.taskType" },
{ "type": "var", "value": "activityInfo" },
{ "type": "var", "value": "userInfo" }
],
"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'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import { resultsModel } from '../../sdk'
import { TaskService } from '../../service'
import { TaskService, BaseService } from '../../service'
export default class Task {
/**
*
* 任务列表
*/
@commonDecorator.checkParams(['activityId'])
@commonDecorator.registeInfos(['vipInfo'])
......@@ -19,11 +19,59 @@ export default class Task {
{ activityInfo, userInfo, vipInfo }: IControllerInfos,
[taskService]: [TaskService]
) {
const commonTaskInittaskResult1 = await taskService.initTask('member', '加入会员', activityInfo, userInfo)
const commonTaskInittaskResult2 = await taskService.initTask('follow', '关注店铺', activityInfo, userInfo)
const commonTaskInittaskResult1 = await taskService.initTask(activityInfo, userInfo)
return resultsModel.success({
...commonTaskInittaskResult1,
...commonTaskInittaskResult2
...commonTaskInittaskResult1
})
}
/**
* 完成任务
*/
@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 {
@commonDecorator.registeInfos(['session'])
@services([UserService])
async getVipInfo(
context: IContext<IVipParams>,
{ activityInfo }: IControllerInfos,
context: IContext<IParams>,
{ activityInfo, userInfo, session }: IControllerInfos,
[userService]: [UserService]
): Promise<IResult<IVipInfo>> {
const commonUserGetshopvipResult = await userService.getShopVip(context, activityInfo)
) {
const commonUserGetshopvipResult1 = await userService.getShopVip(context, session)
return resultsModel.success({
...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