|
@@ -584,7 +584,54 @@ export class MatchExtController implements BaseController {
|
|
|
await this.matchRegService.update({ match_id, ext_status: '6', final_confirm: '0' }, { ext_status: '7' });
|
|
|
}
|
|
|
|
|
|
- // TODO:决赛大屏,评委打分
|
|
|
+ // TODO:决赛大屏
|
|
|
+ /**
|
|
|
+ * 评委打分,前端将评委的数据传来.然后再做总分计算,总分通过平均分方式计算
|
|
|
+ * @param match_id 赛事id
|
|
|
+ * @param data body
|
|
|
+ * @property id 报名数据id
|
|
|
+ * @property {Object} details 决赛总分数详情
|
|
|
+ */
|
|
|
+ @Post('/step7/score/:match_id', { routerName: '决赛阶段-赛事进行' })
|
|
|
+ async step7Score(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "7"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status: "7"
|
|
|
+ * reg.final_confirm: "0"
|
|
|
+ * reg.id: ${id}
|
|
|
+ * reg.final_score_details=> ${details}
|
|
|
+ */
|
|
|
+ await this.service.checkMatchExtStatus(match_id, '7');
|
|
|
+ const id = get(data, 'id')
|
|
|
+ if (!id) {
|
|
|
+ // 抛出异常
|
|
|
+ throw new ServiceError(ErrorCode.MATCH_REG_NOT_FOUND);
|
|
|
+ }
|
|
|
+ const query = { id, match_id, ext_status: '7', final_confirm: '0' };
|
|
|
+ const regData = await this.matchRegService.fetch(query);
|
|
|
+ if (!regData) {
|
|
|
+ throw new ServiceError(ErrorCode.MATCH_REG_NOT_FOUND);
|
|
|
+ }
|
|
|
+ // 合并评审记录
|
|
|
+ const oldDetails: Array<any> = get(regData, 'final_score_details')
|
|
|
+ const final_score_details: object = get(data, 'details')
|
|
|
+ const alreadyGiven = oldDetails.findIndex(f => get(final_score_details, 'name') && f.name === get(final_score_details, 'name'))
|
|
|
+ if (alreadyGiven >= 0) {
|
|
|
+ // 已经给过了,最新的覆盖
|
|
|
+ oldDetails.splice(alreadyGiven, 0, final_score_details)
|
|
|
+ } else {
|
|
|
+ // 没有给,那就直接push
|
|
|
+ oldDetails.push(final_score_details)
|
|
|
+ }
|
|
|
+ // 计算总分
|
|
|
+ const final_score_total = oldDetails.reduce((p, n) => p + get(n, 'score', 0), 0);
|
|
|
+ const final_score = final_score_total / oldDetails.length;
|
|
|
+ await this.matchRegService.update(query, { final_score, final_score_details: oldDetails });
|
|
|
+ }
|
|
|
|
|
|
@Post('/step8', { routerName: '决赛阶段-赛事结束' })
|
|
|
async step8(@Body() data: object) {
|