lrf 3 kuukautta sitten
vanhempi
commit
9b8ec8ca56
1 muutettua tiedostoa jossa 60 lisäystä ja 3 poistoa
  1. 60 3
      src/controller/match/matchExt.controller.ts

+ 60 - 3
src/controller/match/matchExt.controller.ts

@@ -211,8 +211,8 @@ export class MatchExtController implements BaseController {
     *    reg.ext_status: "3";
     */
     await this.service.checkMatchExtStatus(match_id, "3")
-    const list = await this.matchRegService.query({ match_id, ext_status: '3' })
-    return list;
+    const data = await this.matchRegService.query({ match_id, ext_status: '3' })
+    return data;
   }
 
   /**
@@ -293,7 +293,64 @@ export class MatchExtController implements BaseController {
   }
 
   @Post('/step5', { routerName: '决赛阶段-组织决赛' })
-  async step5(@Body() data: object) { }
+  async step5(@Body() data: object) {
+    /**
+    * 检查内容:
+    *  赛事拓展表:
+    *    ext.status = "4"
+    * 修改内容: 
+    *  赛事拓展表:
+    *    ext.status => "5"
+    *  赛事报名表:
+    *    reg.ext_status: "4"
+    *    reg.status: '1'
+    *    reg.status: '1' => '0'
+    *    reg.ext_status: '4' => '5'
+    */
+    const match_id = get(data, 'match_id')
+    await this.service.checkMatchExtStatus(match_id, "4")
+    await this.service.update({ id: match_id }, { status: '5' })
+    await this.matchRegService.update({ match_id, ext_status: '4', status: '1' }, { status: '0', ext_status: '5' })
+  }
+
+  // TODO: 设置某些人决赛时间
+
+  @Get('/step5/sms/:match_id', { routerName: '决赛阶段-组织决赛-短信通知' })
+  async step5Sms(@Param('match_id') match_id: string, @Body() data: object) {
+    /**
+     * 检查内容:
+     *  赛事拓展表:
+     *    ext.status = "5"
+     * 组织内容: 
+     *  赛事报名表:
+     *    reg.ext_status:'5'
+     *    reg.status: '0'
+     *    reg.final_confirm:'0'
+     *  1.获取赛事信息----标题
+     *  2.获取赛事报名信息----每个人的决赛时间
+     *  3.获取用户信息----昵称,电话
+     *  4.组织短信: ${昵称} 您参加的赛事: ${标题} 将于 ${决赛时间} 开始, 
+     * 请您在网站或小程序中进行确认,以避免主办方将您误认为拒赛而采用其他选手代替
+     */
+    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' })
+    for (const i of extList) {
+      const user_id = get(i, 'user_id')
+      if (!user_id) continue;
+      const userInfo = this.userService.fetch({ id: user_id })
+      if (!userInfo) continue;
+      const phone = get(userInfo, 'phone')
+      if (!phone) continue;
+      const nick_name = get(userInfo, 'nick_name')
+      if (!nick_name) continue;
+      const start_time = get(i, 'start_time')
+      const smsMsg = `${nick_name} 您参加的赛事: ${match_name} 将于 ${start_time} 开始, 请您在网站或小程序中进行确认,以避免主办方将您误认为拒赛而采用其他选手代替`
+      // TODO: 发短信
+
+    }
+  }
 
   @Post('/step6', { routerName: '决赛阶段-名单公示' })
   async step6(@Body() data: object) { }