|
@@ -3,6 +3,7 @@ const { CrudService } = require('naf-framework-mongoose-free/lib/service');
|
|
|
const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
|
const _ = require('lodash');
|
|
|
const assert = require('assert');
|
|
|
+const user = require('../model/race/user');
|
|
|
|
|
|
|
|
|
class MatchTeamGroupService extends CrudService {
|
|
@@ -23,8 +24,38 @@ class MatchTeamGroupService extends CrudService {
|
|
|
*/
|
|
|
async findGroupPersonSelects({ project_id, person_type, team_id }) {
|
|
|
|
|
|
-
|
|
|
+ let allPerson;
|
|
|
+ if (person_type === 'TeamApply') {
|
|
|
+ allPerson = await this.teamApplyModel.find({ project_id, status: '1' });
|
|
|
+ } else {
|
|
|
+ allPerson = await this.matchSignModel.find({ project_id, pay_status: '1' });
|
|
|
+ }
|
|
|
|
|
|
+ const teamGroups = await this.model.find({ project_id });
|
|
|
+
|
|
|
+ let personList = _.flattenDeep(teamGroups.map(i => i.person));
|
|
|
+
|
|
|
+ if (team_id) {
|
|
|
+ const teamGroup = await this.model.findById(team_id);
|
|
|
+ const thisTeamPerson = _.flattenDeep(teamGroup.map(i => i.person));
|
|
|
+ personList = personList.filter(f => !thisTeamPerson.includes(f));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (person_type === 'TeamApply') {
|
|
|
+ allPerson = allPerson.filter(f => !personList.includes(f._id));
|
|
|
+ return allPerson;
|
|
|
+ }
|
|
|
+
|
|
|
+ allPerson = allPerson.filter(f => !personList.includes(f.user_id));
|
|
|
+ const users = [];
|
|
|
+ for (const i of allPerson) {
|
|
|
+ const { user_id } = i;
|
|
|
+ const r = await this.ctx.service.user.fetch({ id: user_id });
|
|
|
+ users.push(r);
|
|
|
+ }
|
|
|
+ return users;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|