|
@@ -13,6 +13,7 @@ import { MessageUserType } from '../../public/var';
|
|
|
import { Admin } from '../../entity/system/admin.entity';
|
|
|
import { Design } from '../../entity/platform/design.entity';
|
|
|
import { Incubator } from '../../entity/users/incubator.entity';
|
|
|
+import { Sector } from '../../entity/platform/sector.entity';
|
|
|
|
|
|
@Provide()
|
|
|
export class ContactApplyService extends BaseServiceV2 {
|
|
@@ -41,10 +42,17 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
|
@InjectEntityModel(Incubator)
|
|
|
incubator: Repository<Incubator>;
|
|
|
|
|
|
+ @InjectEntityModel(Sector)
|
|
|
+ sector: Repository<Sector>;
|
|
|
+
|
|
|
+ /**不需要对象用户和匹配度计算数据类型:孵化基地,产业集群 */
|
|
|
+ skipCheckList = ['incubator', 'sector'];
|
|
|
/**
|
|
|
* 审核成功后,返回给申请人申请的 联系方式
|
|
|
+ * @param {number} id 申请id
|
|
|
+ * @param {object} inputContacts 产业集群需要填写的联系人和联系电话
|
|
|
*/
|
|
|
- async successMessage(id) {
|
|
|
+ async successMessage(id, inputContacts) {
|
|
|
const apply = await this.model.createQueryBuilder().where(`id =:id`, { id }).getOne();
|
|
|
// 抛异常,未找到数据
|
|
|
if (!apply) throw new ServiceError(ErrorCode.DATA_NOT_FOUND);
|
|
@@ -57,7 +65,9 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
|
const otherData = await this.searchCompleteData(source, source_id);
|
|
|
const sourceData = get(otherData, 'sourceData');
|
|
|
const sourcePropValue = get(sourceData, 'name');
|
|
|
- const contacts = this.getContactObject(otherData, source);
|
|
|
+ let contacts = {};
|
|
|
+ if (source === 'sector') contacts = inputContacts;
|
|
|
+ else contacts = this.getContactObject(otherData, source);
|
|
|
let msgStr = `您通过 ${sourceStr}数据 ${sourcePropValue ? `- ${sourcePropValue}` : ''} 获取对方联系方式的申请已通过.`;
|
|
|
// 拼接联系方式
|
|
|
const person = get(contacts, 'person');
|
|
@@ -103,7 +113,8 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
|
obj.source_id = get(i, 'source_id');
|
|
|
const otherData = await this.searchCompleteData(get(i, 'source'), get(i, 'source_id'));
|
|
|
const sourceData = get(otherData, 'sourceData');
|
|
|
- const sourcePropValue = get(sourceData, 'name');
|
|
|
+ const propName = this.getSourceProp(get(i, 'source'));
|
|
|
+ const sourcePropValue = get(sourceData, propName);
|
|
|
if (sourcePropValue) obj.source_name = sourcePropValue;
|
|
|
// exam_admin
|
|
|
if (get(i, 'exam_admin')) {
|
|
@@ -135,7 +146,7 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
|
const setting = get(config, 'contactApplyConfig', {});
|
|
|
// 超级管理员都查
|
|
|
if (is_super === '0') {
|
|
|
- const keys = Object.keys(setting)
|
|
|
+ const keys = Object.keys(setting);
|
|
|
return keys;
|
|
|
}
|
|
|
// 接下来取出部门
|
|
@@ -211,9 +222,13 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
|
const apply_user = get(data, 'apply_user');
|
|
|
const target_user = get(data, 'target_user');
|
|
|
const source = get(data, 'source');
|
|
|
+ const source_id = get(data, 'source_id');
|
|
|
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 });
|
|
|
+ if (!this.skipCheckList.includes(source)) builder.andWhere(`"target_user" = :target_user`, { target_user });
|
|
|
+ else {
|
|
|
+ builder.andWhere(`"source" =:source`, { source });
|
|
|
+ builder.andWhere(`"source_id" =:source_id`, { source_id });
|
|
|
+ }
|
|
|
// const apply = await builder.andWhere(`"status" = :status`, { status: '1' }).getOne();
|
|
|
// 查询是不是有其他状态的申请: 未审核,已拒绝,如果有,就根据状态返回提示语
|
|
|
const othersApply = await builder.getOne();
|
|
@@ -293,6 +308,35 @@ export class ContactApplyService extends BaseServiceV2 {
|
|
|
case 'incubator':
|
|
|
str = '孵化基地';
|
|
|
break;
|
|
|
+ case 'sector':
|
|
|
+ str = '产业集群';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+ getSourceProp(source: string) {
|
|
|
+ let str;
|
|
|
+ switch (source) {
|
|
|
+ case 'demand':
|
|
|
+ str = 'name';
|
|
|
+ break;
|
|
|
+ case 'supply':
|
|
|
+ str = 'name';
|
|
|
+ break;
|
|
|
+ case 'project':
|
|
|
+ str = 'name';
|
|
|
+ break;
|
|
|
+ case 'achievement':
|
|
|
+ str = 'name';
|
|
|
+ break;
|
|
|
+ case 'incubator':
|
|
|
+ str = 'name';
|
|
|
+ break;
|
|
|
+ case 'sector':
|
|
|
+ str = 'title';
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|