|
@@ -12,6 +12,7 @@ import { ErrorCode, ServiceError } from '../../error/service.error';
|
|
import { MessageUserType } from '../../public/var';
|
|
import { MessageUserType } from '../../public/var';
|
|
import { Admin } from '../../entity/system/admin.entity';
|
|
import { Admin } from '../../entity/system/admin.entity';
|
|
import { Design } from '../../entity/platform/design.entity';
|
|
import { Design } from '../../entity/platform/design.entity';
|
|
|
|
+import { Incubator } from '../../entity/users/incubator.entity';
|
|
|
|
|
|
@Provide()
|
|
@Provide()
|
|
export class ContactApplyService extends BaseServiceV2 {
|
|
export class ContactApplyService extends BaseServiceV2 {
|
|
@@ -37,6 +38,8 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
user: Repository<User>;
|
|
user: Repository<User>;
|
|
@InjectEntityModel(Admin)
|
|
@InjectEntityModel(Admin)
|
|
admin: Repository<Admin>;
|
|
admin: Repository<Admin>;
|
|
|
|
+ @InjectEntityModel(Incubator)
|
|
|
|
+ incubator: Repository<Incubator>;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 审核成功后,返回给申请人申请的 联系方式
|
|
* 审核成功后,返回给申请人申请的 联系方式
|
|
@@ -127,15 +130,18 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
async checkUserSourceRange() {
|
|
async checkUserSourceRange() {
|
|
const user = get(this.ctx, 'user', {});
|
|
const user = get(this.ctx, 'user', {});
|
|
const is_super = get(user, 'is_super');
|
|
const is_super = get(user, 'is_super');
|
|
|
|
+ const config = await this.design.createQueryBuilder().getOne();
|
|
|
|
+ if (!config) throw new ServiceError(ErrorCode.DATA_NOT_FOUND);
|
|
|
|
+ const setting = get(config, 'contactApplyConfig', {});
|
|
// 超级管理员都查
|
|
// 超级管理员都查
|
|
- if (is_super === '0') return [];
|
|
|
|
|
|
+ if (is_super === '0') {
|
|
|
|
+ const keys = Object.keys(setting)
|
|
|
|
+ return keys;
|
|
|
|
+ }
|
|
// 接下来取出部门
|
|
// 接下来取出部门
|
|
const dept = get(user, 'dept');
|
|
const dept = get(user, 'dept');
|
|
// 抛出异常: 本管理员无部门,无法查询预约申请
|
|
// 抛出异常: 本管理员无部门,无法查询预约申请
|
|
if (!dept) throw new ServiceError(ErrorCode.CONTACTAPPLY_DEPT_NO_ADMIN);
|
|
if (!dept) throw new ServiceError(ErrorCode.CONTACTAPPLY_DEPT_NO_ADMIN);
|
|
- const config = await this.design.createQueryBuilder().getOne();
|
|
|
|
- if (!config) throw new ServiceError(ErrorCode.DATA_NOT_FOUND);
|
|
|
|
- const setting = get(config, 'contactApplyConfig', {});
|
|
|
|
// 整理出本部门管理的数据来源
|
|
// 整理出本部门管理的数据来源
|
|
const sources: Array<string> = [];
|
|
const sources: Array<string> = [];
|
|
for (const key in setting) {
|
|
for (const key in setting) {
|
|
@@ -204,7 +210,10 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
async checkHasApply(data) {
|
|
async checkHasApply(data) {
|
|
const apply_user = get(data, 'apply_user');
|
|
const apply_user = get(data, 'apply_user');
|
|
const target_user = get(data, 'target_user');
|
|
const target_user = get(data, 'target_user');
|
|
- const builder = this.model.createQueryBuilder().where(`"apply_user" = :apply_user`, { apply_user }).andWhere(`"target_user" = :target_user`, { target_user });
|
|
|
|
|
|
+ const source = get(data, 'source');
|
|
|
|
+ const builder = this.model.createQueryBuilder().where(`"apply_user" = :apply_user`, { apply_user });
|
|
|
|
+ if (source !== 'incubator') builder.andWhere(`"target_user" = :target_user`, { target_user });
|
|
|
|
+ else builder.andWhere(`"source" =:source`, { source });
|
|
// const apply = await builder.andWhere(`"status" = :status`, { status: '1' }).getOne();
|
|
// const apply = await builder.andWhere(`"status" = :status`, { status: '1' }).getOne();
|
|
// 查询是不是有其他状态的申请: 未审核,已拒绝,如果有,就根据状态返回提示语
|
|
// 查询是不是有其他状态的申请: 未审核,已拒绝,如果有,就根据状态返回提示语
|
|
const othersApply = await builder.getOne();
|
|
const othersApply = await builder.getOne();
|
|
@@ -228,6 +237,12 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
const sourceData = get(data, 'sourceData');
|
|
const sourceData = get(data, 'sourceData');
|
|
if (get(sourceData, 'tel')) contacts.phone = get(sourceData, 'tel');
|
|
if (get(sourceData, 'tel')) contacts.phone = get(sourceData, 'tel');
|
|
if (get(sourceData, 'contacts')) contacts.person = get(sourceData, 'contacts');
|
|
if (get(sourceData, 'contacts')) contacts.person = get(sourceData, 'contacts');
|
|
|
|
+ } else if (source === 'incubator') {
|
|
|
|
+ const sourceData = get(data, 'sourceData');
|
|
|
|
+ const person = get(sourceData, 'person');
|
|
|
|
+ const phone = get(sourceData, 'person_phone');
|
|
|
|
+ if (person) contacts.person = person;
|
|
|
|
+ if (phone) contacts.phone = phone;
|
|
}
|
|
}
|
|
if (Object.keys(contacts).length <= 0) {
|
|
if (Object.keys(contacts).length <= 0) {
|
|
const user = get(data, 'userData');
|
|
const user = get(data, 'userData');
|