Commit 0bf31793 authored by maggie's avatar maggie

排行榜开奖

parent 3ea93a86
......@@ -559,6 +559,37 @@
"return": true
}
]
},
"endOfActivityRewards": {
"desc": "排行榜开奖",
"decorators": [
{
"type": "common",
"name": "noCheckUser"
}
],
"main": [
{
"type": "common",
"service": "base",
"function": "getNeedRewardsActivityList",
"params": [],
"return": false
},
{
"type": "common",
"service": "awards",
"function": "openPrize",
"params": [
{ "type": "var", "value": "commonBaseGetNeedRewardsActivityListResult1" },
{ "type": "var", "value": 1 },
{ "value": "sortKey" },
{ "value": "sortTimeKey" },
{ "type": "var", "value": 200 }
],
"return": true
}
]
}
},
"share": {
......
......@@ -109,7 +109,6 @@ export enum STAT_TYPE {
INITE_SUCCESS
}
// 每次参与消耗次数
export const JOIN_NEED_TIMES = 1
......
......@@ -103,19 +103,15 @@ export default class AwardsController {
[commonBaseService, commonAwardsService]: [CommonBaseService, CommonAwardsService]
) {
const activityList = await commonBaseService.getNeedRewardsActivityList()
const fail = []
const success = []
for (let activity of activityList) {
const res = await commonAwardsService.openPrize(activity, PRIZE_DATA_TYPE.RANKING, 'sortKey', 'sortTimeKey', 200)
if (res) {
success.push(activity._id)
} else {
fail.push(activity._id)
}
}
const openResult = await commonAwardsService.openPrize(
activityList,
PRIZE_DATA_TYPE.RANKING,
'sortKey',
'sortTimeKey',
200
)
return resultsModel.success({
fail,
success
...openResult
})
}
}
/** @format */
import { services, checkParams, preCheck, registeInfos } from '../../decorator/common'
import { services, checkParams, preCheck, registeInfos, noCheckUser } from '../../decorator/common'
import {
checkPrizeExpired,
checkValidObjectPrize,
......@@ -8,7 +8,7 @@ import {
} from '../../utils/common/check'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonAwardsService } from '../../service/common'
import { CommonAwardsService, CommonBaseService } from '../../service/common'
export default class AwardsController {
/**
......@@ -86,4 +86,26 @@ export default class AwardsController {
...commonAwardsDrawLotteryResult1
})
}
/**
* 排行榜开奖
*/
@noCheckUser
@services([CommonBaseService, CommonAwardsService])
async endOfActivityRewards(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonBaseService, commonAwardsService]: [CommonBaseService, CommonAwardsService]
) {
const commonBaseGetNeedRewardsActivityListResult1 = await commonBaseService.getNeedRewardsActivityList()
const commonAwardsOpenPrizeResult2 = await commonAwardsService.openPrize(
commonBaseGetNeedRewardsActivityListResult1,
1,
'sortKey',
'sortTimeKey',
200
)
return resultsModel.success({
...commonAwardsOpenPrizeResult2
})
}
}
......@@ -33,6 +33,7 @@ export default {
receiveObjectPrize: CommonAwardsControllerInstance.receiveObjectPrize,
receiveEnamePrize: CommonAwardsControllerInstance.receiveEnamePrize,
drawLotteryPrize: CommonAwardsControllerInstance.drawLotteryPrize,
endOfActivityRewards: CommonAwardsControllerInstance.endOfActivityRewards,
getShareInfo: CommonShareControllerInstance.getShareInfo,
doHelp: CommonShareControllerInstance.doHelp,
testAddStat: CustomTest1ControllerInstance.testAddStat,
......
......@@ -325,7 +325,10 @@ export default class AwardsService extends UserService {
* @param sortTimeKey
* @param limit
*/
async openPrize(activityInfo, prizeDataType, sortKey: string, sortTimeKey: string, limit?: number) {
async openPrize(activityList, prizeDataType, sortKey: string, sortTimeKey: string, limit?: number) {
const fail = []
const success = []
for (let activityInfo of activityList) {
const { _id } = activityInfo
await this.activitydao.update({ _id }, { $set: { openPrizeStatus: ACTIVITY_OPEN_PRIZE_STATUS.OPENING } })
const prizeConfigList = await this.getPrizeConfig({
......@@ -375,10 +378,12 @@ export default class AwardsService extends UserService {
}
if (result) {
await this.activitydao.update({ _id }, { $set: { openPrizeStatus: ACTIVITY_OPEN_PRIZE_STATUS.SUCCESS } })
return true
success.push(_id)
} else {
await this.activitydao.update({ _id }, { $set: { openPrizeStatus: ACTIVITY_OPEN_PRIZE_STATUS.FAIL } })
return false
fail.push(_id)
}
}
return { success, fail }
}
}
......@@ -2,8 +2,7 @@
type IActivityInfo = ICommonActivityInfo & ICustomActivityInfo
interface ICustomActivityInfo {
}
interface ICustomActivityInfo {}
interface ICommonActivityInfo {
_id?: string
id?: string
......
......@@ -2,8 +2,7 @@
type IAwards = ICommonAwards & ICustomAwards
interface ICustomAwards {
}
interface ICustomAwards {}
interface ICommonAwards {
_id?: string
id?: string
......
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