修正获取券列表报错的bug

This commit is contained in:
zhl 2021-05-21 11:45:57 +08:00
parent 8050ce9e23
commit f411255443
3 changed files with 12 additions and 2 deletions

View File

@ -75,6 +75,7 @@
| answer | 回答的选项 |
| type | 回答类型, 0: 正常, 1: 超时 |
| mode | 游戏类型, 0: 单人, 1: 多人 |
| debug | 多人模式时, 如果该字段有值, 则直接进入下一轮 |
3. Response: JSON

View File

@ -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
}
}

View File

@ -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<string, string> = 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<string, string> = new Map()
let couponMap : Map<string, any> = 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() {