|
@@ -24,7 +24,6 @@ class IntelligentDockingService extends CrudService {
|
|
|
assert(uid, company_name && person && phone && money && ensure_id && orientation && additional_information, '缺少部分信息项');
|
|
|
|
|
|
// 判断该企业是否有在进行中的需求(一个企业只能有一个进行中的需求)
|
|
|
- // const companyList = await this.model.find({ uid, status: '0' });
|
|
|
const companyList = await this.model.aggregate([
|
|
|
{ $match: { uid } },
|
|
|
{ $project:
|
|
@@ -70,7 +69,7 @@ class IntelligentDockingService extends CrudService {
|
|
|
|
|
|
]);
|
|
|
if (companyList.length > 0) {
|
|
|
- return '您有一个正在进行中的对接需求,请完成后再近些申请';
|
|
|
+ return '您有一个融资需求正在处理,请点击我的-我的融资查看状态。';
|
|
|
}
|
|
|
// 需求
|
|
|
const condition = { orientation, money, ensure_id };
|
|
@@ -83,7 +82,7 @@ class IntelligentDockingService extends CrudService {
|
|
|
|
|
|
let res;
|
|
|
if (products.length > 0) {
|
|
|
- console.log(products[0]);
|
|
|
+ // console.log(products[0]);
|
|
|
data.cid = products[0]._id;
|
|
|
data.jg_id = products[0].uid;// 金融机构id
|
|
|
|
|
@@ -141,7 +140,8 @@ class IntelligentDockingService extends CrudService {
|
|
|
if (orientation && orientation[0] === '2505') {
|
|
|
_sort.claims_max_money = -1;
|
|
|
}
|
|
|
- const res = await this.tmodel.find(match).sort(_sort).limit(Number(5));
|
|
|
+ // const res = await this.tmodel.find(match).sort(_sort).limit(Number(5));
|
|
|
+ const res = await this.tmodel.find(match).sort(_sort);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -404,21 +404,21 @@ class IntelligentDockingService extends CrudService {
|
|
|
|
|
|
// 拒绝接口
|
|
|
async refuse(data) {
|
|
|
- const { intelligentId, guanzhuid, userid, reason } = data;// intelligentId, userid, reason 需求id,银行id,拒绝理由
|
|
|
+ const { intelligentId, guanzhuid, userid, reason } = data; // intelligentId, userid, reason : 需求id,银行id,拒绝理由
|
|
|
const intelligent = await this.model.findById(intelligentId);// 对接需求
|
|
|
const guanzhu = await this.fmodel.findById(guanzhuid);
|
|
|
|
|
|
let res;
|
|
|
- if (intelligent.refuse_times < 3) {
|
|
|
+ if (intelligent.refuse_times < 5) {
|
|
|
// 重新对接产品
|
|
|
// 需求
|
|
|
const condition = {
|
|
|
orientation: intelligent.orientation,
|
|
|
money: intelligent.money,
|
|
|
- claims_min_term: intelligent.claims_min_term,
|
|
|
- claims_max_term: intelligent.claims_max_term,
|
|
|
- mongey_min_rate: intelligent.mongey_min_rate,
|
|
|
- mongey_max_rate: intelligent.mongey_max_rate,
|
|
|
+ // claims_min_term: intelligent.claims_min_term,
|
|
|
+ // claims_max_term: intelligent.claims_max_term,
|
|
|
+ // mongey_min_rate: intelligent.mongey_min_rate,
|
|
|
+ // mongey_max_rate: intelligent.mongey_max_rate,
|
|
|
ensure_id: intelligent.ensure_id,
|
|
|
};
|
|
|
// 对接产品
|
|
@@ -437,45 +437,76 @@ class IntelligentDockingService extends CrudService {
|
|
|
return item.jr_id;
|
|
|
}).includes(item.uid);
|
|
|
});
|
|
|
-
|
|
|
- console.log('对接的产品items', items);
|
|
|
- console.log('ids', ids);
|
|
|
+ console.log('items', items);
|
|
|
|
|
|
if (items.length > 0) {
|
|
|
+ console.log('iiiiiiiiiiiiiiiiiiiiii');
|
|
|
+
|
|
|
+ // 需求表
|
|
|
intelligent.cid = items[0]._id;
|
|
|
intelligent.jg_id = items[0].uid;// 金融机构id
|
|
|
const date = new Date();
|
|
|
const create_time = moment(date).format('YYYY-MM-DD HH:mm:ss');
|
|
|
intelligent.create_time = create_time;
|
|
|
+ // 关注表
|
|
|
+ const guanzhu = await this.fmodel.deleteOne({ _id: ObjectId(guanzhuid) });
|
|
|
+ console.log(guanzhu);
|
|
|
+ // guanzhu.uid = items[0].uid;// 金融机构id
|
|
|
+ // guanzhu.uuid = '';
|
|
|
+ // guanzhu.creditStatus = '';// 状态改为未接单
|
|
|
} else {
|
|
|
- // 拒绝后没有匹配的银行
|
|
|
- guanzhu.creditStatus = '3';
|
|
|
- await guanzhu.save();
|
|
|
- // 对接需求表状态
|
|
|
- intelligent.status = '1';
|
|
|
- await intelligent.save();
|
|
|
- this.ctx.service.viewnews.insertViewNews('智能对接', '无银行受理该需求,改需求已自动关闭', intelligent.uid);
|
|
|
+ console.log('rrrrrrrrrrrrrrrrrrrrrr');
|
|
|
|
|
|
- return '没有更多对接产品!';
|
|
|
+ // 拒绝后没有匹配的产品,查全部,过滤已拒绝的银行
|
|
|
+ const refuseList = await this.tmodel.find();
|
|
|
+ // ids.push({ jr_id: intelligent.jg_id, reason });
|
|
|
+ console.log('ids', ids);
|
|
|
+
|
|
|
+ const ritems = refuseList.filter(item => {
|
|
|
+ if (ids.length === 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return !ids.map(item => {
|
|
|
+ return item.jr_id;
|
|
|
+ }).includes(item.uid);
|
|
|
+ });
|
|
|
+ if (ritems.length > 0) {
|
|
|
+ console.log('ritemssssssssssssssssssssss');
|
|
|
+ console.log('ritems', ritems[0]);
|
|
|
+ console.log('ritems', ritems[0].uid);
|
|
|
+
|
|
|
+ intelligent.cid = ritems[0]._id;
|
|
|
+ intelligent.jg_id = ritems[0].uid;// 金融机构id
|
|
|
+ const date = new Date();
|
|
|
+ const create_time = moment(date).format('YYYY-MM-DD HH:mm:ss');
|
|
|
+ intelligent.create_time = create_time;
|
|
|
+ // 关注表
|
|
|
+ const guanzhu = await this.fmodel.deleteOne({ _id: ObjectId(guanzhuid) });
|
|
|
+ console.log('guanzhu', guanzhu);
|
|
|
+ // guanzhu.uid = ritems[0].uid;// 金融机构id
|
|
|
+ // guanzhu.uuid = '';
|
|
|
+ // guanzhu.creditStatus = '';// 状态改为未接单
|
|
|
+ }
|
|
|
}
|
|
|
- // intelligent.ids.push({ jr_id: intelligent.jg_id, reason });
|
|
|
intelligent.ids = ids;
|
|
|
|
|
|
intelligent.refuse_times = intelligent.refuse_times + 1;
|
|
|
- if (intelligent.refuse_times === 3) {
|
|
|
+ if (intelligent.refuse_times === 5) {
|
|
|
guanzhu.creditStatus = '3';
|
|
|
guanzhu.refusemessage = reason;
|
|
|
await guanzhu.save();
|
|
|
// 对接需求表状态
|
|
|
intelligent.status = '1';
|
|
|
- this.ctx.service.viewnews.insertViewNews('智能对接', '您已被拒绝3次,不再指派银行受理,请重新提交申请,详情请查看智能对接需求列表', intelligent.uid);
|
|
|
+ this.ctx.service.viewnews.insertViewNews('智能对接', '您已被拒绝5次,不再指派银行受理,请重新提交申请,详情请查看智能对接需求列表', intelligent.uid);
|
|
|
+ } else {
|
|
|
+ return '没有更多对接产品!';
|
|
|
}
|
|
|
res = await intelligent.save();
|
|
|
} else {
|
|
|
return '没有更多对接产品!';
|
|
|
}
|
|
|
} else {
|
|
|
- res = '您已被拒绝3次,请重新提交申请';
|
|
|
+ res = '您已被拒绝5次,请重新提交申请';
|
|
|
}
|
|
|
return res;
|
|
|
}
|