|
@@ -56,16 +56,16 @@ class GroupService extends CrudService {
|
|
}
|
|
}
|
|
|
|
|
|
// 检查是否可以加入团
|
|
// 检查是否可以加入团
|
|
- async checkGroupCanJoin({ id }) {
|
|
|
|
|
|
+ async checkGroupCanJoin({ id, customer }) {
|
|
const data = await this.model.findById(id);
|
|
const data = await this.model.findById(id);
|
|
if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到团数据');
|
|
if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到团数据');
|
|
const { person_limit, persons = [], status } = data;
|
|
const { person_limit, persons = [], status } = data;
|
|
if (status === '1') return { result: false, msg: '当前团已结束' };
|
|
if (status === '1') return { result: false, msg: '当前团已结束' };
|
|
else if (status === '-1') return { result: false, msg: '当前团已关闭' };
|
|
else if (status === '-1') return { result: false, msg: '当前团已关闭' };
|
|
// 检查是否已经参团
|
|
// 检查是否已经参团
|
|
- const customer = _.get(this.ctx, 'user._id');
|
|
|
|
- if (!customer) throw new BusinessError(ErrorCode.NOT_LOGIN, '用户未登录');
|
|
|
|
- const r = data.persons.find(f => f.customer === customer);
|
|
|
|
|
|
+ const cus = _.get(this.ctx, 'user._id', customer);
|
|
|
|
+ if (!cus) throw new BusinessError(ErrorCode.NOT_LOGIN, '用户未登录');
|
|
|
|
+ const r = data.persons.find(f => f.customer === cus);
|
|
if (r) return { result: false, msg: '您已参团' };
|
|
if (r) return { result: false, msg: '您已参团' };
|
|
|
|
|
|
// 为0是正常的团员
|
|
// 为0是正常的团员
|