diff --git a/src/api/controllers/exam.controller.ts b/src/api/controllers/exam.controller.ts index ff67e57..0416eea 100644 --- a/src/api/controllers/exam.controller.ts +++ b/src/api/controllers/exam.controller.ts @@ -149,7 +149,7 @@ class ExamController extends BaseController { rspData.rankTotal = rankTotal let examData = await ShopExam.findById(history.activityId) let rewardList = [] - if (!examData && examData.rewardInfo && examData.rewardInfo.length > 0) { + if (examData && examData.rewardInfo && examData.rewardInfo.length > 0) { let rewards = examData.getReward(statMap.score) for (let reward of rewards) { let geted = await UserReward.examRewardGeted(history, accountid, reward.id) @@ -160,10 +160,9 @@ class ExamController extends BaseController { rewardList.push(data) } } - rspData.rewords = rewardList + rspData.rewards = rewardList } rspData.gameResult = gameResult - rspData.rewords = {} return rspData } } diff --git a/src/models/UserReward.ts b/src/models/UserReward.ts index 27a8d4d..bcdaae4 100644 --- a/src/models/UserReward.ts +++ b/src/models/UserReward.ts @@ -135,6 +135,8 @@ class UserRewardClass extends BaseModule { }) if (history.type === 1) { record.activityId = history.activityId + } else if (history.type === 2) { + record.examId = history.activityId } await record.save() ids.push(record.sid)