zs 3 months ago
parent
commit
eb66d2541e
1 changed files with 14 additions and 8 deletions
  1. 14 8
      src/controller/match/matchExt.controller.ts

+ 14 - 8
src/controller/match/matchExt.controller.ts

@@ -607,7 +607,7 @@ export class MatchExtController implements BaseController {
      *    reg.final_score_details=>  ${details}
      */
     await this.service.checkMatchExtStatus(match_id, '7');
-    const id = get(data, 'id')
+    const id = get(data, 'id');
     if (!id) {
       // 抛出异常
       throw new ServiceError(ErrorCode.MATCH_REG_NOT_FOUND);
@@ -618,15 +618,21 @@ export class MatchExtController implements BaseController {
       throw new ServiceError(ErrorCode.MATCH_REG_NOT_FOUND);
     }
     // 合并评审记录
-    const oldDetails: Array<any> = get(regData, 'final_score_details')
-    const final_score_details: object = get(data, 'details')
-    const alreadyGiven = oldDetails.findIndex(f => get(final_score_details, 'name') && f.name === get(final_score_details, 'name'))
-    if (alreadyGiven >= 0) {
-      // 已经给过了,最新的覆盖
-      oldDetails.splice(alreadyGiven, 0, final_score_details)
+    const oldDetails: Array<any> = get(regData, 'final_score_details') || [];
+    const final_score_details: object = get(data, 'details');
+    if (oldDetails && oldDetails.length > 0) {
+      // 判断之前的评审记录是否存在
+      const alreadyGiven = oldDetails.findIndex(f => get(final_score_details, 'name') && f.name === get(final_score_details, 'name'));
+      if (alreadyGiven >= 0) {
+        // 已经给过了,最新的覆盖
+        oldDetails.splice(alreadyGiven, 0, final_score_details);
+      } else {
+        // 没有给,那就直接push
+        oldDetails.push(final_score_details);
+      }
     } else {
       // 没有给,那就直接push
-      oldDetails.push(final_score_details)
+      oldDetails.push();
     }
     // 计算总分
     const final_score_total = oldDetails.reduce((p, n) => p + get(n, 'score', 0), 0);