|
@@ -172,7 +172,9 @@ export class MatchExtController implements BaseController {
|
|
|
}
|
|
|
// 获取报名信息数据id
|
|
|
const ids = get(data, 'ids', []);
|
|
|
- await this.matchRegService.update({ id: ids, ext_status: '2', status: '0' }, { start_time });
|
|
|
+ for (const id of ids) {
|
|
|
+ await this.matchRegService.update({ id: id, ext_status: '2', status: '0' }, { start_time });
|
|
|
+ }
|
|
|
}
|
|
|
/**
|
|
|
* 进入: 初赛阶段-公示名单, 只修改状态即可
|
|
@@ -289,7 +291,9 @@ export class MatchExtController implements BaseController {
|
|
|
*/
|
|
|
await this.service.checkMatchExtStatus(match_id, "4")
|
|
|
const ids = get(data, 'ids', [])
|
|
|
- await this.matchRegService.update({ id: ids, ext_status: '4', status: '0' }, { status: '1' })
|
|
|
+ for (const id of ids) {
|
|
|
+ await this.matchRegService.update({ id: id, ext_status: '4', status: '0' }, { status: '1' })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Post('/step5', { routerName: '决赛阶段-组织决赛' })
|
|
@@ -313,7 +317,34 @@ export class MatchExtController implements BaseController {
|
|
|
await this.matchRegService.update({ match_id, ext_status: '4', status: '1' }, { status: '0', ext_status: '5' })
|
|
|
}
|
|
|
|
|
|
- // TODO: 设置某些人决赛时间
|
|
|
+ /**
|
|
|
+ * 设置某些人决赛时间
|
|
|
+ * @param match_id 赛事id
|
|
|
+ * @param data body
|
|
|
+ * @property ids 报名数据id列表
|
|
|
+ * @property start_time 决赛开始时间
|
|
|
+ */
|
|
|
+ @Post('/step5/time/:match_id', { routerName: '决赛阶段-组织决赛-设置决赛时间' })
|
|
|
+ async step5SetTime(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "5"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status: "5"
|
|
|
+ * reg.status: '0'
|
|
|
+ * reg.final_start_time => ${start_time}
|
|
|
+ */
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
+ const ids = get(data, 'ids', [])
|
|
|
+ const start_time = get(data, 'start_time')
|
|
|
+ for (const id of ids) {
|
|
|
+ await this.matchRegService.update({ id, ext_status: '5', status: '0' }, { final_start_time: start_time })
|
|
|
+ }
|
|
|
+ return 'ok'
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Get('/step5/sms/:match_id', { routerName: '决赛阶段-组织决赛-短信通知' })
|
|
|
async step5Sms(@Param('match_id') match_id: string, @Body() data: object) {
|
|
@@ -325,7 +356,7 @@ export class MatchExtController implements BaseController {
|
|
|
* 赛事报名表:
|
|
|
* reg.ext_status:'5'
|
|
|
* reg.status: '0'
|
|
|
- * reg.final_confirm:'0'
|
|
|
+ * reg.final_confirm:'1'
|
|
|
* 1.获取赛事信息----标题
|
|
|
* 2.获取赛事报名信息----每个人的决赛时间
|
|
|
* 3.获取用户信息----昵称,电话
|
|
@@ -335,7 +366,7 @@ export class MatchExtController implements BaseController {
|
|
|
await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
const matchInfo = await this.matchService.fetch({ id: match_id })
|
|
|
const match_name = get(matchInfo, 'name')
|
|
|
- const { data: extList } = await this.service.query({ match_id, ext_status: '5', status: '0', final_confirm: '0' })
|
|
|
+ const { data: extList } = await this.service.query({ match_id, ext_status: '5', status: '0', final_confirm: '1' })
|
|
|
for (const i of extList) {
|
|
|
const user_id = get(i, 'user_id')
|
|
|
if (!user_id) continue;
|
|
@@ -352,11 +383,199 @@ export class MatchExtController implements BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户确认参加决赛
|
|
|
+ * @param match_id 赛事id
|
|
|
+ * @param data body
|
|
|
+ * @property user_id 用户id
|
|
|
+ */
|
|
|
+ @Post('/step5/confirm/:match_id', { routerName: '决赛阶段-组织决赛-参加决赛确认' })
|
|
|
+ async step5Confirm(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "5"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status:'5'
|
|
|
+ * reg.status: '0'
|
|
|
+ * final_confirm => '0'
|
|
|
+ */
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
+ const user_id = get(data, 'user_id')
|
|
|
+ // 默认规定顺序,先来后到
|
|
|
+ const { data: list } = await this.matchRegService.query({ match_id, ext_status: '5', status: '0', final_confirm: '0' })
|
|
|
+ // 做默认序号,将已经确认的人查出来,然后排查序号,如果中间有缺少的序号,就先补充到缺少的序号中;如果没有缺少,那就往后默认排
|
|
|
+ let lastOrderNum = 1;
|
|
|
+ for (const i of list) {
|
|
|
+ const thisOrderNum = get(i, 'final_order_no')
|
|
|
+ // 按理说,不应该出现没有排序的情况
|
|
|
+ if (!thisOrderNum) continue;
|
|
|
+ // 顺序不一致,说明少了
|
|
|
+ if (lastOrderNum != thisOrderNum) {
|
|
|
+ // 少了就需要把当前的补上.会出现2种情况, 正常顺序<当前顺序: 按正常顺序进行补充;
|
|
|
+ // 正常顺序>当前顺序:说明从此开始,后面的序号都是乱的,是不应该出现的情况.如果出现了,就需要人为调整了.所以只考虑第一个情况
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // 下一个,如果不循环了,那就直接给新数据用
|
|
|
+ lastOrderNum = lastOrderNum + 1;
|
|
|
+ }
|
|
|
+ await this.matchRegService.update({ match_id, user_id, ext_status: '5', status: '0' }, { final_confirm: '0', final_order_no: lastOrderNum })
|
|
|
+ }
|
|
|
+
|
|
|
+ @Post('/step5/refuse/:match_id', { routerName: '决赛阶段-组织决赛-拒绝参加决赛' })
|
|
|
+ async step5Refuse(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "5"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status:'5'
|
|
|
+ * reg.status: '0'
|
|
|
+ * reg.status => '2'
|
|
|
+ */
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
+ const user_id = get(data, 'user_id')
|
|
|
+ await this.matchRegService.update({ match_id, user_id, ext_status: '5', status: '0' }, { status: '2' })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择初赛中的选手 补充到决赛中
|
|
|
+ * @param match_id 赛事id
|
|
|
+ * @param data body
|
|
|
+ * @property user_id 用户id
|
|
|
+ */
|
|
|
+ @Post('/step5/supplement/:match_id', { routerName: '决赛阶段-组织决赛-补充决赛人员' })
|
|
|
+ async step5Supplement(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "5"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status:'4'=>'5'
|
|
|
+ * reg.status =>'0'
|
|
|
+ */
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
+ const user_id = get(data, 'user_id')
|
|
|
+ await this.matchRegService.update({ match_id, user_id, ext_status: '4' }, { ext_status: '5', status: '0' })
|
|
|
+ }
|
|
|
+
|
|
|
+ @Get('/step5/list/:match_id', { routerName: '决赛阶段-组织决赛-决赛人员名单' })
|
|
|
+ async step5NameList(@Param('match_id') match_id: string) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "5"
|
|
|
+ * 组织内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status:'5'
|
|
|
+ * reg.final_confirm =>'0'
|
|
|
+ */
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
+ // 决赛名单,根据顺序升序
|
|
|
+ const { data: list } = await this.matchRegService.query({ match_id, ext_status: '5', final_confirm: '0' }, { order: { final_order_no: 'ASC' } })
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 决赛人员排序
|
|
|
+ * @param match_id 赛事id
|
|
|
+ * @param data body
|
|
|
+ * @property id 报名数据id
|
|
|
+ * @property num 排名位置
|
|
|
+ */
|
|
|
+ @Post('/step5/order/:match_id', { routerName: '决赛阶段-组织决赛-人员排序' })
|
|
|
+ async step5Order(@Param('match_id') match_id: string, @Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "5"
|
|
|
+ * 组织内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.final_order_no =>'0'
|
|
|
+ */
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
+ const { data: list } = await this.matchRegService.query({ match_id, ext_status: '5', final_confirm: '0' }, { order: { final_order_no: 'ASC' } })
|
|
|
+ const id = get(data, 'id')
|
|
|
+ if (!id) {
|
|
|
+ // 抛出异常:缺少报名信息
|
|
|
+ throw new ServiceError(ErrorCode.MATCH_EXT_DATA_NOT_FOUND)
|
|
|
+ }
|
|
|
+ const order_no = get(data, 'order_no');
|
|
|
+ // 没写,直接不该
|
|
|
+ if (!order_no) return 'ok'
|
|
|
+ /**数据原索引 */
|
|
|
+ const oldIndex = list.findIndex(f => f.id === id);
|
|
|
+ // 没数据,不改
|
|
|
+ if (oldIndex < 0) {
|
|
|
+ throw new ServiceError(ErrorCode.MATCH_REG_NOT_FOUND);
|
|
|
+ }
|
|
|
+ const oldData = list[oldIndex];
|
|
|
+ /**目标索引 */
|
|
|
+ let targetIndex = order_no - 1;
|
|
|
+ if (oldIndex === targetIndex) {
|
|
|
+ throw new ServiceError(ErrorCode.MATCH_REG_ORDER_NOT_CHANGE);
|
|
|
+ }
|
|
|
+ let removeIndex = oldIndex;
|
|
|
+ if (targetIndex < oldIndex) {
|
|
|
+ // 如果要移动到的索引 小于 原数据索引: 是在原数据前添加的,影响删除,需要原索引+1才能删除原数据
|
|
|
+ removeIndex = removeIndex + 1;
|
|
|
+ } else {
|
|
|
+ // 移动的索引要+1
|
|
|
+ targetIndex = targetIndex + 1;
|
|
|
+ }
|
|
|
+ list.splice(targetIndex, 0, oldData)
|
|
|
+ list.splice(removeIndex, 1)
|
|
|
+ // 重新排列
|
|
|
+ for (let index = 0; index < list.length; index++) {
|
|
|
+ const e = list[index];
|
|
|
+ const id = get(e, 'id')
|
|
|
+ await this.matchRegService.update({ id }, { final_order_no: index + 1 })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Post('/step6', { routerName: '决赛阶段-名单公示' })
|
|
|
- async step6(@Body() data: object) { }
|
|
|
+ async step6(@Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "5"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status => "6" 变为 决赛阶段-名单公示
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.final_confirm:'0'
|
|
|
+ * reg.ext_status: "5" => '6'
|
|
|
+ */
|
|
|
+ const match_id = get(data, 'match_id')
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "5")
|
|
|
+ await this.service.update({ match_id }, { status: '6' })
|
|
|
+ await this.matchRegService.update({ match_id, ext_status: '5', final_confirm: '0' }, { ext_status: '6' })
|
|
|
+ }
|
|
|
|
|
|
@Post('/step7', { routerName: '决赛阶段-赛事进行' })
|
|
|
- async step7(@Body() data: object) { }
|
|
|
+ async step7(@Body() data: object) {
|
|
|
+ /**
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "6"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status => "7" 变为 决赛阶段-赛事进行
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.final_confirm:'0'
|
|
|
+ * reg.ext_status: "6" => '7'
|
|
|
+ */
|
|
|
+ const match_id = get(data, 'match_id')
|
|
|
+ await this.service.checkMatchExtStatus(match_id, "6")
|
|
|
+ await this.service.update({ match_id }, { status: '7' })
|
|
|
+ await this.matchRegService.update({ match_id, ext_status: '6', final_confirm: '0' }, { ext_status: '7' })
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO:决赛大屏,评委打分
|
|
|
|
|
|
@Post('/step8', { routerName: '决赛阶段-赛事结束' })
|
|
|
async step8(@Body() data: object) { }
|