From f411255443afd6fa72bc0ba541d631808542b85c Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 21 May 2021 11:45:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8E=B7=E5=8F=96=E5=88=B8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8A=A5=E9=94=99=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/api.md | 1 + src/api/controllers/game_user.controller.ts | 3 ++- src/models/UserReward.ts | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/api.md b/doc/api.md index 19eaff9..53e97a8 100644 --- a/doc/api.md +++ b/doc/api.md @@ -75,6 +75,7 @@ | answer | 回答的选项 | | type | 回答类型, 0: 正常, 1: 超时 | | mode | 游戏类型, 0: 单人, 1: 多人 | +| debug | 多人模式时, 如果该字段有值, 则直接进入下一轮 | 3. Response: JSON diff --git a/src/api/controllers/game_user.controller.ts b/src/api/controllers/game_user.controller.ts index 0b72207..b809cd8 100644 --- a/src/api/controllers/game_user.controller.ts +++ b/src/api/controllers/game_user.controller.ts @@ -49,7 +49,8 @@ class GameUserController extends BaseController { @router('post /api/:accountid/tickets') async userTickets(req: any) { const { accountid, sid } = req.params - return await UserReward.ticketList( accountid, sid ) + const result = await UserReward.ticketList( accountid, sid ) + return result } } diff --git a/src/models/UserReward.ts b/src/models/UserReward.ts index ccc4498..2456805 100644 --- a/src/models/UserReward.ts +++ b/src/models/UserReward.ts @@ -11,6 +11,7 @@ import { Shop } from './shop/Shop' import { Coupon } from './shop/Coupon' import { getCouponUrl } from '../services/File' import { PuzzleSessionClass } from './match/PuzzleSession' +import { isObjectId } from '../utils/string.util' const nanoid = customAlphabet('2345678abcdefghjkmnpqrstwxy', 10) @@ -76,12 +77,18 @@ class UserRewardClass extends BaseModule { public static async ticketList(accountId: string, shopId?: string) { let params:any = { accountId } + let shopMap: Map = new Map() if (shopId) { + if (!isObjectId(shopId)) { + let shopData = await Shop.fetchByID(shopId) + shopId = shopData.id + shopMap.set(shopId, shopData.showName) + } params.shop = shopId } let records = await UserReward.find(params) let results: any = [] - let shopMap: Map = new Map() + let couponMap : Map = new Map() for (let record of records) { let sid = record.shop @@ -104,6 +111,7 @@ class UserRewardClass extends BaseModule { status: record.status }) } + return results } public compactInfo() {