lrf 2 years ago
parent
commit
34991d4fff
1 changed files with 3 additions and 1 deletions
  1. 3 1
      app/service/matchSign.js

+ 3 - 1
app/service/matchSign.js

@@ -84,7 +84,9 @@ class MatchSignService extends CrudService {
     if (!next) throw new BusinessError(ErrorCode.DATA_INVALID, '年龄不符合组别条件');
     const matchProject = await this.matchProjectModel.findById(project_id);
     if (!matchProject) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到组别项目');
-    const { age: projectAge, gender } = matchProject;
+    const { age: projectAge, gender, num } = matchProject;
+    const joinNum = await this.matchProjectModel.count({ match_id, group_id });
+    if (joinNum >= num) throw new BusinessError(ErrorCode.DATA_INVALID, '该项目已经到达人数限制,无法报名');
     next = this.checkAgeInRange(projectAge, cardAge);
     if (!next) throw new BusinessError(ErrorCode.DATA_INVALID, '年龄不符合组别项目条件');
     if (gender !== '2') {