|
@@ -651,76 +651,14 @@ export class MatchExtController implements BaseController {
|
|
|
await this.service.update({ match_id }, { status: '8' });
|
|
|
await this.matchRegService.update({ match_id, ext_status: '7', final_confirm: '0' }, { ext_status: '8' });
|
|
|
}
|
|
|
-
|
|
|
- @Get('/firstStep/:match_id', { routerName: '进入初审阶段' })
|
|
|
- async toFirstStep(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
- // 进入初审阶段,查询选手名单(未被退回的),根据选手名单的报名顺序,排列名单,并赋予开始时间
|
|
|
- /**赛事拓展数据 */
|
|
|
- const extData = await this.service.fetch({ match_id });
|
|
|
- if (extData) {
|
|
|
- const nowStatus = get(extData, 'status');
|
|
|
- // 如果状态不是 '0', 说明状态不对,
|
|
|
- // if (nowStatus !== '0') throw new ServiceError(ErrorCode.MATCH_EXT_STATUS_ERROR)
|
|
|
- // 修改流程进度为下一步----初审
|
|
|
- await this.service.update({ match_id }, { status: '1' });
|
|
|
- }
|
|
|
- const start_time = get(data, 'start_time');
|
|
|
- const regQuery = { match_id, status: '0' };
|
|
|
- await this.matchRegService.update(regQuery, { start_time });
|
|
|
- /**赛事报名数据 */
|
|
|
- const { data: list } = await this.matchRegService.query(regQuery);
|
|
|
- // 获取赛事名称
|
|
|
- const matchData = await this.matchService.fetch({ id: match_id });
|
|
|
- // 发送短信通知
|
|
|
- const msg = `您参加的赛事: ${get(matchData, 'name')} 将于 ${start_time}开始初审,具体安排请通过网页或小程序查看.请您提前做好准备.`;
|
|
|
- for (const i of list) {
|
|
|
- const user_id = get(i, 'user_id');
|
|
|
- if (!user_id) continue;
|
|
|
- const ups = await this.service.getUserProps(user_id, ['phone']);
|
|
|
- const phone = get(ups, 'phone');
|
|
|
- try {
|
|
|
- await this.smsService.send(phone, msg);
|
|
|
- } catch (error) {
|
|
|
- console.error('matchExt - toFirstStep:发送短信发生错误');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Post('/secondStep/:match_id', { routerName: '进入决赛准备阶段' })
|
|
|
- async toSecondStep(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
- // 进入决赛准备阶段,获取前端传来的人数,保存在拓展表里.
|
|
|
- const extData = await this.service.fetch({ match_id });
|
|
|
- const final_persons = get(data, 'final_persons');
|
|
|
- // TODO: 抛出异常,缺少进入决赛人数设置
|
|
|
- // if (!final_persons) throw new ServiceError(ErrorCode.MATCH_EXT_NO_FINAL_PERSON)
|
|
|
- if (extData) {
|
|
|
- const nowStatus = get(extData, 'status');
|
|
|
- // 如果状态不是 '1', 说明状态不对,
|
|
|
- // TODO:抛出异常 赛事状态错误
|
|
|
- // if (nowStatus !== '1') throw new ServiceError(ErrorCode.MATCH_EXT_STATUS_ERROR)
|
|
|
- // 修改流程进度为下一步----决赛准备阶段
|
|
|
- await this.service.update({ match_id }, { status: '2', final_persons });
|
|
|
- }
|
|
|
- // 根据进入决赛的人数,查询列表; 初审分数在走这个接口前就需要上完.
|
|
|
- const query = { match_id };
|
|
|
- const others = { skip: 0, limit: final_persons, others: { score: 'DESC' } };
|
|
|
- const { data: list } = await this.matchRegService.query(query, others);
|
|
|
- // 获取赛事名称
|
|
|
- const matchData = await this.matchService.fetch({ id: match_id });
|
|
|
- const match_name = get(matchData, 'name');
|
|
|
- const msg = `您在赛事: ${match_name}中已进入决赛,请通过网站或小程序进入平台进行信息确认.`;
|
|
|
- const lastList = [];
|
|
|
- for (const i of list) {
|
|
|
- const user_id = get(i, 'user_id');
|
|
|
- if (!user_id) continue;
|
|
|
- // 发短信通知去确认
|
|
|
- const ups = await this.service.getUserProps(user_id, ['phone']);
|
|
|
- const phone = get(ups, 'phone');
|
|
|
- try {
|
|
|
- await this.smsService.send(phone, msg);
|
|
|
- } catch (error) {
|
|
|
- console.error('matchExt - toSecondStep:发送短信发生错误');
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 人为规定的决赛实时名单
|
|
|
+ * @param match_id 赛事id
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+ @Post('/lastList/:match_id', { routerName: '赛事决赛名单' })
|
|
|
+ async lastList(@Param('match_id') match_id: string) {
|
|
|
+ const list = await this.matchRegService.getArrangeList(match_id)
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|