Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

liming 4 vuotta sitten
vanhempi
commit
9bb835c701
2 muutettua tiedostoa jossa 54 lisäystä ja 12 poistoa
  1. 53 11
      app/service/intelligentDocking.js
  2. 1 1
      app/service/intelligentFollow.js

+ 53 - 11
app/service/intelligentDocking.js

@@ -180,6 +180,7 @@ class IntelligentDockingService extends CrudService {
             mongey_min_rate: 1,
             mongey_max_rate: 1,
             when: 1,
+            refuse_times: 1,
             additional_information: 1,
             status: 1,
             jg_id: { $toObjectId: '$jg_id' },
@@ -221,14 +222,14 @@ class IntelligentDockingService extends CrudService {
             as: 'dictionary',
           },
       },
-      { $lookup:
-          {
-            from: 'dictionary',
-            localField: 'when',
-            foreignField: 'code',
-            as: 'when',
-          },
-      },
+      // { $lookup:
+      //     {
+      //       from: 'dictionary',
+      //       localField: 'when',
+      //       foreignField: 'code',
+      //       as: 'when',
+      //     },
+      // },
       { $lookup:
           {
             from: 'intelligent_follow',
@@ -242,7 +243,33 @@ class IntelligentDockingService extends CrudService {
       { $unwind: '$finance_claims' },
       { $unwind: '$dictionary' },
       { $unwind: { path: '$follow', preserveNullAndEmptyArrays: true } },
-      { $unwind: { path: '$when', preserveNullAndEmptyArrays: true } },
+      // { $unwind: { path: '$when', preserveNullAndEmptyArrays: true } },
+      { $project:
+          {
+            ensure_id: 1,
+            person: 1,
+            money: 1,
+            claims_min_term: 1,
+            claims_max_term: 1,
+            mongey_min_rate: 1,
+            mongey_max_rate: 1,
+            when: 1,
+            refuse_times: 1,
+            additional_information: 1,
+            status: 1,
+            creditStatus: '$follow.creditStatus',
+            jg_id: { $toObjectId: '$jg_id' },
+            cid: { $toObjectId: '$cid' },
+            uid: '$uid',
+            xqId: { $toString: '$_id' },
+            time: '$meta.createdAt',
+            company: '$company',
+            institution: '$institution',
+            finance_claims: '$finance_claims',
+            dictionary: '$dictionary',
+            follow: '$follow',
+          },
+      },
       { $skip: (skip - 1) * limit },
       { $limit: limit },
       { $sort: { time: -1 } },
@@ -274,8 +301,9 @@ class IntelligentDockingService extends CrudService {
 
       const ids = intelligent.ids;
       if (products.length > 0) {
-        console.log('对接的产品', products);
+        // console.log('对接的产品', products);
         // 拒绝ids 里存在对接的产品id
+        ids.push({ jr_id: intelligent.jg_id, reason });
         const items = products.filter(item => {
           if (ids.length === 0) {
             return true;
@@ -284,6 +312,10 @@ class IntelligentDockingService extends CrudService {
             return item.jr_id;
           }).includes(item.uid);
         });
+
+        console.log('对接的产品items', items);
+        console.log('ids', ids);
+
         if (items.length > 0) {
           intelligent.cid = items[0]._id;
           intelligent.jg_id = items[0].uid;// 金融机构id
@@ -291,9 +323,19 @@ class IntelligentDockingService extends CrudService {
           const create_time = moment(date).format('YYYY-MM-DD HH:mm:ss');
           intelligent.create_time = create_time;
         } else {
+          // 拒绝后没有匹配的银行
+          guanzhu.creditStatus = '3';
+          await guanzhu.save();
+          // 对接需求表状态
+          intelligent.status = '1';
+          await intelligent.save();
+          this.ctx.service.viewnews.insertViewNews('智能对接', '无银行受理该需求,改需求已自动关闭', intelligent.uid);
+
           return '没有更多对接产品!';
         }
-        intelligent.ids.push({ jr_id: userid, reason });
+        // intelligent.ids.push({ jr_id: intelligent.jg_id, reason });
+        intelligent.ids = ids;
+
         intelligent.refuse_times = intelligent.refuse_times + 1;
         if (intelligent.refuse_times === 3) {
           guanzhu.creditStatus = '3';

+ 1 - 1
app/service/intelligentFollow.js

@@ -152,7 +152,7 @@ class IntelligentFollowService extends CrudService {
     newdata.credit_money = 0;
     newdata.accept_time = 0;
     newdata.credit_time = 0;
-    console.log('new =============', newdata);
+    // console.log('new =============', newdata);
     const res = await this.model.create(newdata);
     console.dir(this.dmodel);
     const qy = await this.dmodel.findById(xqid);