lrf %!s(int64=2) %!d(string=hai) anos
pai
achega
205447cf16
Modificáronse 1 ficheiros con 10 adicións e 1 borrados
  1. 10 1
      app/service/teamApply.js

+ 10 - 1
app/service/teamApply.js

@@ -32,7 +32,7 @@ class TeamApplyService extends CrudService {
       const arr = [];
       for (const i of list) {
         const { user_id } = i;
-        const num = await this.model.count({ $or: [{ one_member_id: user_id }, { two_member_id: user_id }] });
+        const num = await this.checkHasTeamApply(project_id, user_id);
         if (num > 0) continue;
         i.user_name = _.get(i, 'user_id.user_id.name');
         i.user_id = _.get(i, 'user_id._id');
@@ -96,6 +96,15 @@ class TeamApplyService extends CrudService {
     const count = await this.model.count(condition);
     return count;
   }
+  /**
+   * 查询该比赛项目下,这个用户是否有组队申请
+   * @param {String} project_id 比赛项目
+   * @param {String} user_id 比赛模块用户数据id
+   * @return {number} 组队条数
+   */
+  async checkHasTeamApply(project_id, user_id) {
+    return await this.model.count({ project_id, $or: [{ one_member_id: user_id }, { two_member_id: user_id }] });
+  }
 
   selfQueryDeal(condition) {
     if (_.get(condition, 'user_id')) {