|
@@ -23,8 +23,7 @@ export class MatchExtController implements BaseController {
|
|
|
@Inject()
|
|
|
smsService: AliyunSmsService;
|
|
|
@Inject()
|
|
|
- matchService: MatchService
|
|
|
-
|
|
|
+ matchService: MatchService;
|
|
|
|
|
|
@Get('/')
|
|
|
@ApiTags('列表查询')
|
|
@@ -57,7 +56,7 @@ export class MatchExtController implements BaseController {
|
|
|
async update(@Param('id') id: number, @Body() data: object) {
|
|
|
if (!id) throw new ServiceError(ErrorCode.ID_NOT_FOUND);
|
|
|
// 所有的修改,是不允许修改状态的
|
|
|
- const newData = omit(data, ['status'])
|
|
|
+ const newData = omit(data, ['status']);
|
|
|
const result = await this.service.update({ id }, newData);
|
|
|
return result;
|
|
|
}
|
|
@@ -69,9 +68,9 @@ export class MatchExtController implements BaseController {
|
|
|
if (!id) throw new ServiceError(ErrorCode.ID_NOT_FOUND);
|
|
|
// 不允许删除非报名中的赛事
|
|
|
const data = await this.service.fetch({ id });
|
|
|
- if (!data) return
|
|
|
- const status = get(data, 'status')
|
|
|
- if (status != '0') {
|
|
|
+ if (!data) return;
|
|
|
+ const status = get(data, 'status');
|
|
|
+ if (status !== '0') {
|
|
|
// 抛出异常:赛事不处于报名中的状态,无法删除.
|
|
|
throw new ServiceError(ErrorCode.MATCH_EXT_IS_BEGINNING);
|
|
|
}
|
|
@@ -99,22 +98,22 @@ export class MatchExtController implements BaseController {
|
|
|
* ext.status = "0"
|
|
|
* 赛事表:
|
|
|
* match.status = "1"
|
|
|
- * 修改内容:
|
|
|
+ * 修改内容:
|
|
|
* 赛事拓展表:
|
|
|
* ext.status => "1" 变为 报名阶段-已结束
|
|
|
* 赛事表:
|
|
|
* match.status =>"2" 变为 进行中
|
|
|
* 赛事报名表:
|
|
|
* 处于 报名阶段(ext_status='0') 且 已通过审核的报名信息(status='1') 变为 初赛阶段(ext_status='1')且未通过审核(status='0')的报名信息
|
|
|
- * reg.ext_status: "0" => "1"
|
|
|
+ * reg.ext_status: "0" => "1"
|
|
|
* reg.status: "1" => "0"
|
|
|
*/
|
|
|
- const match_id = get(data, 'match_id')
|
|
|
- await this.service.checkMatchStatus(match_id, "1")
|
|
|
- await this.service.checkMatchExtStatus(match_id, "0")
|
|
|
- await this.matchService.update({ id: match_id }, { status: '2' })
|
|
|
- await this.service.update({ match_id }, { status: "1" })
|
|
|
- await this.matchRegService.update({ match_id, ext_status: '0', status: '1' }, { ext_status: '1', status: '0' })
|
|
|
+ const match_id = get(data, 'match_id');
|
|
|
+ await this.service.checkMatchStatus(match_id, '1');
|
|
|
+ await this.service.checkMatchExtStatus(match_id, '0');
|
|
|
+ await this.matchService.update({ id: match_id }, { status: '2' });
|
|
|
+ await this.service.update({ match_id }, { status: '1' });
|
|
|
+ await this.matchRegService.update({ match_id, ext_status: '0', status: '1' }, { ext_status: '1', status: '0' });
|
|
|
return 'ok';
|
|
|
}
|
|
|
|
|
@@ -129,19 +128,19 @@ export class MatchExtController implements BaseController {
|
|
|
async regBack(@Body() data: object) {
|
|
|
// 只修改状态,不做时间修改,时间修改用另一个接口
|
|
|
/**
|
|
|
- * 检查内容:
|
|
|
- * 赛事拓展表:
|
|
|
- * ext.status = "1"
|
|
|
- * 修改内容:
|
|
|
- * 赛事拓展表:
|
|
|
- * ext.status => "2" 变为 初赛阶段-组织初审
|
|
|
- * 赛事报名表:
|
|
|
- * reg.ext_status: "1" => '2'
|
|
|
- */
|
|
|
- const match_id = get(data, 'match_id')
|
|
|
- await this.service.checkMatchExtStatus(match_id, "1")
|
|
|
- await this.service.update({ match_id }, { status: '2' })
|
|
|
- await this.matchRegService.update({ match_id, ext_status: '1' }, { ext_status: '2' })
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "1"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status => "2" 变为 初赛阶段-组织初审
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status: "1" => '2'
|
|
|
+ */
|
|
|
+ const match_id = get(data, 'match_id');
|
|
|
+ await this.service.checkMatchExtStatus(match_id, '1');
|
|
|
+ await this.service.update({ match_id }, { status: '2' });
|
|
|
+ await this.matchRegService.update({ match_id, ext_status: '1' }, { ext_status: '2' });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -150,48 +149,48 @@ export class MatchExtController implements BaseController {
|
|
|
* @property match_id 赛事id
|
|
|
* @property start_time 初赛时间
|
|
|
*/
|
|
|
- @Post("/step2/fill", { routerName: '初赛阶段-组织初审-补充初赛时间信息' })
|
|
|
+ @Post('/step2/fill', { routerName: '初赛阶段-组织初审-补充初赛时间信息' })
|
|
|
async step2Fill(@Body() data: object) {
|
|
|
/**
|
|
|
- * 检查内容:
|
|
|
- * 赛事拓展表:
|
|
|
- * ext.status = "2"
|
|
|
- * 修改内容:
|
|
|
- * 赛事报名表:
|
|
|
- * reg.ext_status: '2'
|
|
|
- * reg.start_time: => ${start_time}
|
|
|
- */
|
|
|
- const match_id = get(data, 'match_id')
|
|
|
- await this.service.checkMatchExtStatus(match_id, "2")
|
|
|
- const start_time = get(data, 'start_time')
|
|
|
+ * 检查内容:
|
|
|
+ * 赛事拓展表:
|
|
|
+ * ext.status = "2"
|
|
|
+ * 修改内容:
|
|
|
+ * 赛事报名表:
|
|
|
+ * reg.ext_status: '2'
|
|
|
+ * reg.start_time: => ${start_time}
|
|
|
+ */
|
|
|
+ const match_id = get(data, 'match_id');
|
|
|
+ await this.service.checkMatchExtStatus(match_id, '2');
|
|
|
+ const start_time = get(data, 'start_time');
|
|
|
// 验证是否是正确的时间格式
|
|
|
- const is_time = dayjs(start_time).isValid()
|
|
|
+ const is_time = dayjs(start_time).isValid();
|
|
|
if (!is_time) {
|
|
|
// 抛出异常: 时间格式错误
|
|
|
- throw new ServiceError(ErrorCode.TIME_FORMAT_ERROR)
|
|
|
+ throw new ServiceError(ErrorCode.TIME_FORMAT_ERROR);
|
|
|
}
|
|
|
// 获取报名信息数据id
|
|
|
- const ids = get(data, 'ids', [])
|
|
|
- await this.matchRegService.update({ id: ids, ext_status: '2', status: '0' }, { start_time })
|
|
|
+ const ids = get(data, 'ids', []);
|
|
|
+ await this.matchRegService.update({ id: ids, ext_status: '2', status: '0' }, { start_time });
|
|
|
}
|
|
|
|
|
|
@Post('/step3', { routerName: '初赛阶段-公示名单' })
|
|
|
- async step3(@Body() data: object) { }
|
|
|
+ async step3(@Body() data: object) {}
|
|
|
|
|
|
@Post('/step4', { routerName: '初赛阶段-赛事进行' })
|
|
|
- async step4(@Body() data: object) { }
|
|
|
+ async step4(@Body() data: object) {}
|
|
|
|
|
|
@Post('/step5', { routerName: '决赛阶段-组织决赛' })
|
|
|
- async step5(@Body() data: object) { }
|
|
|
+ async step5(@Body() data: object) {}
|
|
|
|
|
|
@Post('/step6', { routerName: '决赛阶段-名单公示' })
|
|
|
- async step6(@Body() data: object) { }
|
|
|
+ async step6(@Body() data: object) {}
|
|
|
|
|
|
@Post('/step7', { routerName: '决赛阶段-赛事进行' })
|
|
|
- async step7(@Body() data: object) { }
|
|
|
+ async step7(@Body() data: object) {}
|
|
|
|
|
|
@Post('/step8', { routerName: '决赛阶段-赛事结束' })
|
|
|
- async step8(@Body() data: object) { }
|
|
|
+ async step8(@Body() data: object) {}
|
|
|
|
|
|
@Get('/firstStep/:match_id', { routerName: '进入初赛阶段' })
|
|
|
async toFirstStep(@Param('match_id') match_id: string, @Body() data: object) {
|
|
@@ -199,7 +198,7 @@ export class MatchExtController implements BaseController {
|
|
|
/**赛事拓展数据 */
|
|
|
const extData = await this.service.fetch({ match_id });
|
|
|
if (extData) {
|
|
|
- const nowStatus = get(extData, 'status')
|
|
|
+ const nowStatus = get(extData, 'status');
|
|
|
// 如果状态不是 '0', 说明状态不对,
|
|
|
// if (nowStatus !== '0') throw new ServiceError(ErrorCode.MATCH_EXT_STATUS_ERROR)
|
|
|
// 修改流程进度为下一步----初赛
|
|
@@ -211,13 +210,13 @@ export class MatchExtController implements BaseController {
|
|
|
/**赛事报名数据 */
|
|
|
const { data: list } = await this.matchRegService.query(regQuery);
|
|
|
// 获取赛事名称
|
|
|
- const matchData = await this.matchService.fetch({ id: match_id })
|
|
|
+ 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 ups = await this.service.getUserProps(user_id, ['phone']);
|
|
|
const phone = get(ups, 'phone');
|
|
|
try {
|
|
|
await this.smsService.send(phone, msg);
|
|
@@ -231,11 +230,11 @@ export class MatchExtController implements BaseController {
|
|
|
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')
|
|
|
+ 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')
|
|
|
+ const nowStatus = get(extData, 'status');
|
|
|
// 如果状态不是 '1', 说明状态不对,
|
|
|
// TODO:抛出异常 赛事状态错误
|
|
|
// if (nowStatus !== '1') throw new ServiceError(ErrorCode.MATCH_EXT_STATUS_ERROR)
|
|
@@ -243,19 +242,19 @@ export class MatchExtController implements BaseController {
|
|
|
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 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 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 ups = await this.service.getUserProps(user_id, ['phone']);
|
|
|
const phone = get(ups, 'phone');
|
|
|
try {
|
|
|
await this.smsService.send(phone, msg);
|