Kaynağa Gözat

Merge branch 'master' of http://git.cc-lotus.info/financial_platform/service-financial

wq 4 yıl önce
ebeveyn
işleme
c4433872cb

+ 3 - 3
app/controller/.companyidentify.js

@@ -9,12 +9,12 @@ module.exports = {
       '!business',
       '!capital',
       '!establish_date',
-      '!valid_period',
+      'valid_period',
       '!person',
       '!opening_bank',
       'status',
       // '!code',
-      // 'business_license',
+      'business_license',
       // 'establish_date',
       // 'due_date',
       // 'type',
@@ -61,7 +61,7 @@ module.exports = {
       'opening_bank',
       'status',
       // 'uid',
-      // 'business_license',
+      'business_license',
       // 'company_name',
       // 'establish_date',
       // 'due_date',

+ 2 - 2
app/model/companyidentify.js

@@ -13,12 +13,12 @@ const CompanyidentifySchema = {
   business: { type: String, required: true, maxLength: 200 }, // 经营范围                   必填
   capital: { type: String, required: true, maxLength: 200 }, // 注册资本                    必填
   establish_date: { type: String, required: true, maxLength: 200 }, // 成立日期             必填
-  valid_period: { type: String, required: true, maxLength: 200 }, //    公司营业期限终止日期      "长期"表示为"29991231"
+  valid_period: { type: String, required: false, maxLength: 200 }, //    公司营业期限终止日期      "长期"表示为"29991231"
   person: { type: String, required: true, maxLength: 200 }, //      法定代表人      必填
   opening_bank: { type: String, required: true, maxLength: 200 }, //      开户行      必填
   status: { type: String, required: false, maxLength: 200, default: '1' }, // 认证状态,0-认证中,1-认证通过,2-认证失败  改为默认认证通过
 
-  // business_license: { type: String, required: false, maxLength: 200 }, // 营业执照图片
+  business_license: { type: String }, // 营业执照图片 -- 存base64码
   // establish_date: { type: String, required: false, maxLength: 200 }, // 成立日期
   // due_date: { type: String, required: false, maxLength: 200 }, // 营业到期日期
   // type: { type: String, required: false, maxLength: 200 }, // 企业类型

+ 1 - 1
app/model/companyup.js

@@ -14,7 +14,7 @@ const CompanyupSchema = {
   business: { type: String, required: true, maxLength: 200 }, // 经营范围                   必填
   capital: { type: String, required: true, maxLength: 200 }, // 注册资本                    必填
   establish_date: { type: String, required: true, maxLength: 200 }, // 成立日期             必填
-  valid_period: { type: String, required: true, maxLength: 200 }, //    公司营业期限终止日期      "长期"表示为"29991231"
+  valid_period: { type: String, required: false, maxLength: 200 }, //    公司营业期限终止日期      "长期"表示为"29991231"
   person: { type: String, required: true, maxLength: 200 }, //      法定代表人      必填
 
 

+ 3 - 3
app/service/companyidentify.js

@@ -19,8 +19,8 @@ class CompanyidentifyService extends CrudService {
 
   // 重写创建方法
   async create(data) {
-    const { uid, company_name, reg_num, type, address, business, capital, establish_date, valid_period, person, opening_bank } = data;
-    assert(company_name && reg_num && type && address && business && capital && establish_date && valid_period && person && opening_bank, '缺少部分信息项');
+    const { uid, company_name, business_license, reg_num, type, address, business, capital, establish_date, person, opening_bank } = data;
+    assert(company_name && business_license && reg_num && type && address && business && capital && establish_date && person && opening_bank, '缺少部分信息项');
 
     const res = await this.model.create(data);
     // 给用户发送消息告知注册成功
@@ -36,7 +36,7 @@ class CompanyidentifyService extends CrudService {
     if (status === '1') {
       // 将企业认证信息表中的部分字段提取出来,创建用户对应的企业信息表
       // const newdata = _.pick(companyidentify, [ 'uid', 'company_name', 'introduction', 'registered_addr', 'business_addr', 'profession_one', 'profession_two', 'profession_three', 'profession_four' ]);
-      const newdata = _.pick(companyidentify, [ 'uid', 'company_name', 'reg_num', 'type', 'address', 'business', 'capital', 'establish_date', 'valid_period', 'person' ]);
+      const newdata = _.pick(companyidentify, [ 'uid', 'company_name', 'reg_num', 'type', 'address', 'business', 'capital', 'establish_date', 'person' ]);
       // 将企业用户表中的权限改为1(认证)
       const companyuser = await this.umodel.findById(companyidentify.uid);
       companyuser.roles = '1';

+ 0 - 222
app/service/intelligentDocking.js

@@ -235,11 +235,6 @@ class IntelligentDockingService extends CrudService {
       { $unwind: { path: '$institution', preserveNullAndEmptyArrays: true } },
       { $unwind: { path: '$finance_claims', preserveNullAndEmptyArrays: true } },
       { $unwind: { path: '$dictionary', preserveNullAndEmptyArrays: true } },
-
-      // { $unwind: '$company', preserveNullAndEmptyArrays: true },
-      // { $unwind: '$institution', preserveNullAndEmptyArrays: true },
-      // { $unwind: '$finance_claims', preserveNullAndEmptyArrays: true },
-      // { $unwind: '$dictionary', preserveNullAndEmptyArrays: true },
       { $unwind: { path: '$follow', preserveNullAndEmptyArrays: true } },
       { $project:
           {
@@ -285,223 +280,6 @@ class IntelligentDockingService extends CrudService {
     return { result, total };
   }
 
-  // 金控端查询列表
-  async jinkongList(data) {
-    const query = {};
-    if (data.id) { // 单查  对接需求id
-      query._id = ObjectId(data.id);
-    }
-    if (data.jg_id) { // 金融机构ID
-      query.jg_id = data.jg_id;
-    }
-    if (data.uid) { // 企业ID
-      query.uid = data.uid;
-    }
-    if (data.cid) { // 产品id
-      query.cid = data.cid;
-    }
-    if (data.status) { // 状态
-      query.status = data.status;
-    }
-    const skip = Number.parseInt(data.skip) || 1;
-    const limit = Number.parseInt(data.limit) || 10;
-
-    // const total = await this.model.countDocuments(query);
-    const total = await this.model.aggregate([
-      { $match: query },
-      { $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,
-            jg_id: { $toObjectId: '$jg_id' },
-            cid: { $toObjectId: '$cid' },
-            uid: '$uid',
-            xqId: { $toString: '$_id' },
-            time: '$meta.createdAt',
-          },
-      },
-      { $lookup:
-          {
-            from: 'institution',
-            localField: 'jg_id',
-            foreignField: '_id',
-            as: 'institution',
-          },
-      },
-      { $lookup:
-          {
-            from: 't_finance_claims',
-            localField: 'cid',
-            foreignField: '_id',
-            as: 'finance_claims',
-          },
-      },
-      { $lookup:
-          {
-            from: 'dictionary',
-            localField: 'ensure_id',
-            foreignField: 'code',
-            as: 'dictionary',
-          },
-      },
-      { $lookup:
-          {
-            from: 'intelligent_follow',
-            localField: 'xqId',
-            foreignField: 'intelligentId',
-            as: 'follow',
-          },
-      },
-      { $unwind: '$institution' },
-      { $unwind: '$finance_claims' },
-      { $unwind: '$dictionary' },
-      { $unwind: { path: '$follow', 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',
-          },
-      },
-      { $sort: { time: -1 } },
-    ]);
-    const result = await this.model.aggregate([
-      { $match: query },
-      { $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,
-            jg_id: { $toObjectId: '$jg_id' },
-            cid: { $toObjectId: '$cid' },
-            uid: '$uid',
-            xqId: { $toString: '$_id' },
-            time: '$meta.createdAt',
-          },
-      },
-      { $lookup:
-          {
-            from: 'company_identify',
-            localField: 'uid',
-            foreignField: 'uid',
-            as: 'company',
-          },
-      },
-      { $lookup:
-          {
-            from: 'institution',
-            localField: 'jg_id',
-            foreignField: '_id',
-            as: 'institution',
-          },
-      },
-      { $lookup:
-          {
-            from: 't_finance_claims',
-            localField: 'cid',
-            foreignField: '_id',
-            as: 'finance_claims',
-          },
-      },
-      { $lookup:
-          {
-            from: 'dictionary',
-            localField: 'ensure_id',
-            foreignField: 'code',
-            as: 'dictionary',
-          },
-      },
-      // { $lookup:
-      //     {
-      //       from: 'dictionary',
-      //       localField: 'when',
-      //       foreignField: 'code',
-      //       as: 'when',
-      //     },
-      // },
-      { $lookup:
-          {
-            from: 'intelligent_follow',
-            localField: 'xqId',
-            foreignField: 'intelligentId',
-            as: 'follow',
-          },
-      },
-      { $unwind: '$company' },
-      { $unwind: '$institution' },
-      { $unwind: '$finance_claims' },
-      { $unwind: '$dictionary' },
-      { $unwind: { path: '$follow', 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 } },
-    ]);
-    return { result, total: total.length };
-  }
-
   // 拒绝接口
   async refuse(data) {
     const { intelligentId, guanzhuid, userid, reason } = data;// intelligentId, userid, reason 需求id,银行id,拒绝理由

+ 74 - 3
app/service/intelligentFollow.js

@@ -49,6 +49,9 @@ class IntelligentFollowService extends CrudService {
   // 关注列表
   async getFollowList(data) {
     const match = {};
+    if (data.followId) { // 关注表id
+      match._id = ObjectId(data.followId);
+    }
     if (data.userid) { // 金融机构ID---客户经理
       match.uuid = data.userid;
     }
@@ -63,16 +66,84 @@ class IntelligentFollowService extends CrudService {
     const total = await this.model.countDocuments(match);
     const res = await this.model.aggregate([
       { $match: match },
-      { $project: { intelligentId: { $toObjectId: '$intelligentId' }, creditStatus: 1, savetime: '$meta.createdAt' } },
+      { $project:
+          {
+            intelligentId: { $toObjectId: '$intelligentId' },
+            uuid: 1,
+            creditStatus: 1,
+            credit_money: 1,
+            sxcpname: 1,
+            sxhowlong: 1,
+            sxcplilue: 1,
+            savetime: '$meta.createdAt',
+            time: '$meta.createdAt',
+          },
+      },
       { $lookup: {
         from: 'intelligent_docking',
         localField: 'intelligentId',
         foreignField: '_id',
         as: 'intelligent' } },
-      { $unwind: '$intelligent' },
+      // { $unwind: '$intelligent' },
+      { $unwind: { path: '$intelligent', preserveNullAndEmptyArrays: true } },
+
+      { $project:
+          {
+            intelligentId: 1,
+            uuid: 1,
+            creditStatus: 1,
+            credit_money: 1,
+            sxcpname: 1,
+            sxhowlong: 1,
+            sxcplilue: 1,
+            time: 1,
+            savetime: '$meta.createdAt',
+            intelligent: '$intelligent',
+            jg_id: { $toObjectId: '$intelligent.jg_id' },
+            cid: { $toObjectId: '$intelligent.cid' },
+            uid: '$intelligent.uid',
+            ensure_id: '$intelligent.ensure_id',
+          },
+      },
+      { $lookup:
+              {
+                from: 'company_identify',
+                localField: 'uid',
+                foreignField: 'uid',
+                as: 'company',
+              },
+      },
+      { $lookup:
+              {
+                from: 'institution',
+                localField: 'jg_id',
+                foreignField: '_id',
+                as: 'institution',
+              },
+      },
+      { $lookup:
+              {
+                from: 't_finance_claims',
+                localField: 'cid',
+                foreignField: '_id',
+                as: 'finance_claims',
+              },
+      },
+      { $lookup:
+              {
+                from: 'dictionary',
+                localField: 'ensure_id',
+                foreignField: 'code',
+                as: 'dictionary',
+              },
+      },
+      { $unwind: { path: '$company', preserveNullAndEmptyArrays: true } },
+      { $unwind: { path: '$institution', preserveNullAndEmptyArrays: true } },
+      { $unwind: { path: '$finance_claims', preserveNullAndEmptyArrays: true } },
+      { $unwind: { path: '$dictionary', preserveNullAndEmptyArrays: true } },
       { $skip: (skip - 1) * limit },
       { $limit: limit },
-      { $sort: { savetime: -1 } },
+      { $sort: { time: -1 } },
     ]);
     const newres = { res, total };
     return newres;