lrf 7 月之前
父节点
当前提交
dc8112c51a
共有 1 个文件被更改,包括 20 次插入5 次删除
  1. 20 5
      src/service/users/contactApply.service.ts

+ 20 - 5
src/service/users/contactApply.service.ts

@@ -17,6 +17,7 @@ import { Sector } from '../../entity/platform/sector.entity';
 import { Project } from '../../entity/platform/project.entity';
 import { Achievement } from '../../entity/platform/achievement.entity';
 import { Sign } from '../../entity/platform/sign.entity';
+import { Match } from '../../entity/platform/match.entity';
 
 @Provide()
 export class ContactApplyService extends BaseServiceV2 {
@@ -43,7 +44,8 @@ export class ContactApplyService extends BaseServiceV2 {
   sector: Repository<Sector>;
   @InjectEntityModel(Sign)
   sign: Repository<Sign>;
-
+  @InjectEntityModel(Match)
+  match: Repository<Match>;
   @InjectEntityModel(Expert)
   expert: Repository<Expert>;
 
@@ -51,7 +53,6 @@ export class ContactApplyService extends BaseServiceV2 {
   user: Repository<User>;
   @InjectEntityModel(Admin)
   admin: Repository<Admin>;
-  
 
   /**不需要对象用户和匹配度计算数据类型:孵化基地,产业集群 */
   skipCheckList = ['incubator', 'sector'];
@@ -122,7 +123,15 @@ export class ContactApplyService extends BaseServiceV2 {
       const otherData = await this.searchCompleteData(get(i, 'source'), get(i, 'source_id'));
       const sourceData = get(otherData, 'sourceData');
       const propName = this.getSourceProp(get(i, 'source'));
-      const sourcePropValue = get(sourceData, propName);
+      let sourcePropValue = get(sourceData, propName);
+      if (get(i, 'source') === 'sign') {
+        // 路演类型: 是从报名id为source_id,但是来源应该是路演标题
+        const match_id = get(sourceData, 'match');
+        if (match_id) {
+          const match = await this.match.createQueryBuilder().where(`id =:id`, { id: match_id }).getOne();
+          sourcePropValue = get(match, propName);
+        }
+      }
       if (sourcePropValue) obj.source_name = sourcePropValue;
       // exam_admin
       if (get(i, 'exam_admin')) {
@@ -234,7 +243,7 @@ export class ContactApplyService extends BaseServiceV2 {
     const source_id = get(data, 'source_id');
     const builder = this.model.createQueryBuilder().where(`"apply_user" = :apply_user`, { apply_user });
     // if (!this.skipCheckList.includes(source)) builder.andWhere(`"target_user" = :target_user`, { target_user });
-    if(this.skipCheckList.includes(source)) {
+    if (this.skipCheckList.includes(source)) {
       builder.andWhere(`"source" =:source`, { source });
       builder.andWhere(`"source_id" =:source_id`, { source_id });
     }
@@ -261,6 +270,12 @@ export class ContactApplyService extends BaseServiceV2 {
       const sourceData = get(data, 'sourceData');
       if (get(sourceData, 'tel')) contacts.phone = get(sourceData, 'tel');
       if (get(sourceData, 'contacts')) contacts.person = get(sourceData, 'contacts');
+    } else if (source === 'sign') {
+      const sourceData = get(data, 'sourceData');
+      const person = get(sourceData, 'name');
+      const phone = get(sourceData, 'phone');
+      if (person) contacts.person = person;
+      if (phone) contacts.phone = phone;
     } else if (source === 'incubator') {
       const sourceData = get(data, 'sourceData');
       const person = get(sourceData, 'person');
@@ -321,7 +336,7 @@ export class ContactApplyService extends BaseServiceV2 {
         str = '产业集群';
         break;
       case 'sign':
-        str = '活动路演'
+        str = '活动路演';
         break;
       default:
         break;