lrf 4 months ago
parent
commit
5090b43ff3
2 changed files with 21 additions and 4 deletions
  1. 20 4
      src/controller/match/matchExt.controller.ts
  2. 1 0
      src/error/service.error.ts

+ 20 - 4
src/controller/match/matchExt.controller.ts

@@ -9,6 +9,7 @@ import { MatchRegistrationService } from '../../service/match/matchRegistration.
 import { UserService } from '../../service/system/user.service';
 import { AliyunSmsService } from '../../service/thirdParty/aliyunSms.service';
 import { MatchService } from '../../service/platform/match.service';
+import dayjs = require('dayjs');
 const namePrefix = '创新大赛拓展';
 @ApiTags(['创新大赛拓展'])
 @Controller('/matchExt', { tagName: namePrefix })
@@ -104,15 +105,16 @@ export class MatchExtController implements BaseController {
      *  赛事表:
      *    match.status =>"2" 变为 进行中
      *  赛事报名表:
-     *    处于 报名阶段 且 已通过审核的报名信息 变为 待审核(初赛阶段)
-     *    reg.status = "1" & reg.ext_status = "0" => reg.ext_status:"1" reg.status='0' 
+     *    处于 报名阶段(ext_status='0') 且 已通过审核的报名信息(status='1') 变为 初赛阶段(ext_status='1')且未通过审核(status='0')的报名信息
+     *    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' })
+    await this.matchRegService.update({ match_id, ext_status: '0', status: '1' }, { ext_status: '1', status: '0' })
     return 'ok';
   }
 
@@ -133,10 +135,13 @@ export class MatchExtController implements BaseController {
     * 修改内容: 
     *  赛事拓展表:
     *    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' })
   }
 
   /**
@@ -153,10 +158,21 @@ export class MatchExtController implements BaseController {
    *    ext.status = "2"
    * 修改内容: 
    *  赛事报名表:
-   *    reg.status = '0' 的 reg.start_time => ${start_time}
+   *    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()
+    if (!is_time) {
+      // 抛出异常: 时间格式错误
+      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 })
   }
 
   @Post('/step3', { routerName: '初赛阶段-公示名单' })

+ 1 - 0
src/error/service.error.ts

@@ -68,6 +68,7 @@ export enum ErrorCode {
   MATCH_EXT_STATUS_ERROR = "MATCH_EXT_STATUS_ERROR",
   MATCH_REG_NOT_FOUND = "MATCH_REG_NOT_FOUND",
   MATCH_REG_STATUS_ERROR ="MATCH_REG_STATUS_ERROR",
+  TIME_FORMAT_ERROR ="TIME_FORMAT_ERROR",
 
   // export
   NO_EXPORT_SETTING = 'NO_EXPORT_SETTING',