Commit 1df4d685 authored by gongguan's avatar gongguan

游戏记录增加是否是vip的信息;加inviteId的信息;提交分数接口防并发的判断字段status

parent e8902da6
/** @format */ /** @format */
import { services, checkParams, preCheck, preUpdate } from '../decorator/common' import { services, checkParams, preCheck, preUpdate, registeInfos } from '../decorator/common'
import { resultsModel } from '../sdk' import { resultsModel } from '../sdk'
import { CommonUserService, CommonGameService } from '../service/common' import { CommonUserService, CommonGameService } from '../service/common'
import { import {
...@@ -38,15 +38,16 @@ export default class Game { ...@@ -38,15 +38,16 @@ export default class Game {
} }
@checkParams(['activityId']) @checkParams(['activityId'])
@registeInfos(['vipInfo'])
@services([CommonGameService]) @services([CommonGameService])
@preCheck([checkActivityTime, checkVip, checkGameTimes(3)]) @preCheck([checkActivityTime, checkVip, checkGameTimes(3)])
@preUpdate([reduceGameTimes(3)]) @preUpdate([reduceGameTimes(3)])
async startGame( async startGame(
context: IContext<IParams>, context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos, { userInfo, activityInfo, vipInfo }: IControllerInfos,
[gameService]: [CommonGameService] [gameService]: [CommonGameService]
) { ) {
const joinResult = await gameService.addJoinRecord(userInfo) const joinResult = await gameService.addJoinRecord(userInfo, vipInfo)
return resultsModel.success({ return resultsModel.success({
...joinResult ...joinResult
......
...@@ -18,12 +18,13 @@ export default class GameService extends UserService { ...@@ -18,12 +18,13 @@ export default class GameService extends UserService {
this.joindao = new BaseDao(context, JOIN_DB_NAME) this.joindao = new BaseDao(context, JOIN_DB_NAME)
} }
async addJoinRecord(userInfo: IUserInfo) { async addJoinRecord(userInfo: IUserInfo, vipInfo: IVipInfo) {
const { const {
openId, openId,
data: { activityId } data: { activityId, inviteId }
} = this.context } = this.context
const { userNick, avatar } = userInfo const { userNick, avatar } = userInfo
const { isVip } = vipInfo
const now = Date.now() const now = Date.now()
const today = getToday() const today = getToday()
const record: IJoinRecord = { const record: IJoinRecord = {
...@@ -34,7 +35,10 @@ export default class GameService extends UserService { ...@@ -34,7 +35,10 @@ export default class GameService extends UserService {
createTime: now, createTime: now,
updateTime: now, updateTime: now,
score: 0, score: 0,
createDay: today createDay: today,
inviteId,
isVip,
status: 1
} }
const id = await this.joindao.insertOne(record) const id = await this.joindao.insertOne(record)
......
...@@ -12,4 +12,7 @@ interface IJoinRecord { ...@@ -12,4 +12,7 @@ interface IJoinRecord {
createDay: string createDay: string
duration?: number duration?: number
submitTime?: number submitTime?: number
inviteId?: string
isVip?: boolean
status?: number
} }
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