Commit 57f911e6 authored by 李尚科's avatar 李尚科

credit callrisk fix

parent 89282201
Pipeline #13421 passed with stage
in 29 seconds
......@@ -7,14 +7,21 @@ class CallriskController extends Controller {
/**
* 获取黑名单报告
*/
async getCallriskReport() {
async getReport() {
const { ctx } = this;
let ret = await ctx.service.credit.callrisk.getReport();
const report_no = ctx.params.report_no;
let ret = await ctx.service.credit.callrisk.getReport(report_no);
ctx.success(ret);
}
async queryCallRisk() {
const { ctx } = this;
}
}
......
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM } = app.Sequelize;
const CreditCallriskCallActive = app.prometheusModel.define('credit_callrisk_call_active', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
report_id: {
type: INTEGER,
allowNull: false,
},
routine_call_time: {
type: INTEGER,
allowNull: false,
},
night_call_time: {
type: INTEGER,
allowNull: false,
},
routine_call_count: {
type: INTEGER,
allowNull: false,
},
night_call_count: {
type: INTEGER,
allowNull: false,
},
time_interval_active: {
type: INTEGER,
allowNull: false,
},
city_active: {
type: INTEGER,
allowNull: false,
},
// is_deleted: {
// type: INTEGER,
// allowNull: false,
// },
// updated_at: {
// type: DATE,
// allowNull: true,
// get() {
// const date = this.getDataValue('updated_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// },
// created_at: {
// type: DATE,
// allowNull: false,
// get() {
// const date = this.getDataValue('created_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// }
}, {
timestamps: false,
tableName: 'credit_callrisk_call_active',
});
CreditCallriskCallActive.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CreditCallriskCallActive.findOne({
attributes: attributes,
where: where,
});
}
CreditCallriskCallActive.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CreditCallriskCallActive.findAll({
attributes: attributes,
where: where,
order,
});
}
CreditCallriskCallActive.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
const { count, rows } = await CreditCallriskCallActive.findAndCountAll(condition);
return { page, count, rows };
}
CreditCallriskCallActive.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await CreditCallriskCallActive.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
CreditCallriskCallActive.edit = async (data) => {
const where = data.where;
const params = data.params;
try {
const res = await CreditCallriskCallActive.update(params, { where: where })
return res;
} catch (error) {
throw (error);
}
}
return CreditCallriskCallActive;
};
\ No newline at end of file
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM } = app.Sequelize;
const CreditCallriskCallBehavior = app.prometheusModel.define('credit_callrisk_call_behavior', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
report_id: {
type: INTEGER,
allowNull: false,
},
active_call_count: {
type: INTEGER,
allowNull: false,
},
passive_call_count: {
type: INTEGER,
allowNull: false,
},
each_call_count: {
type: INTEGER,
allowNull: false,
},
silence_count_3day: {
type: INTEGER,
allowNull: false,
},
silence_time_3day: {
type: INTEGER,
allowNull: false,
},
silence_time_rate_3day: {
type: INTEGER,
allowNull: false,
},
maximum_active_call_count: {
type: INTEGER,
allowNull: false,
},
maximum_active_call_number: {
type: INTEGER,
allowNull: false,
},
maximum_active_call_city: {
type: STRING,
allowNull: false,
},
maximum_passive_call_count: {
type: INTEGER,
allowNull: false,
},
maximum_passive_call_number: {
type: INTEGER,
allowNull: false,
},
maximum_passive_call_city: {
type: STRING,
allowNull: false,
},
maximum_call_time: {
type: INTEGER,
allowNull: false,
},
maximum_call_time_number: {
type: INTEGER,
allowNull: false,
},
maximum_call_time_city: {
type: STRING,
allowNull: false,
},
// is_deleted: {
// type: INTEGER,
// allowNull: false,
// },
// updated_at: {
// type: DATE,
// allowNull: true,
// get() {
// const date = this.getDataValue('updated_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// },
// created_at: {
// type: DATE,
// allowNull: false,
// get() {
// const date = this.getDataValue('created_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// }
}, {
timestamps: false,
tableName: 'credit_callrisk_call_behavior',
});
CreditCallriskCallBehavior.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CreditCallriskCallBehavior.findOne({
attributes: attributes,
where: where,
});
}
CreditCallriskCallBehavior.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CreditCallriskCallBehavior.findAll({
attributes: attributes,
where: where,
order,
});
}
CreditCallriskCallBehavior.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
const { count, rows } = await CreditCallriskCallBehavior.findAndCountAll(condition);
return { page, count, rows };
}
CreditCallriskCallBehavior.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await CreditCallriskCallBehavior.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
CreditCallriskCallBehavior.edit = async (data) => {
const where = data.where;
const params = data.params;
try {
const res = await CreditCallriskCallBehavior.update(params, { where: where })
return res;
} catch (error) {
throw (error);
}
}
return CreditCallriskCallBehavior;
};
\ No newline at end of file
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM } = app.Sequelize;
const CreditCallriskCallOverview = app.prometheusModel.define('credit_callrisk_call_overview', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
report_id: {
type: INTEGER,
allowNull: false,
},
month: {
type: INTEGER,
allowNull: false,
},
call_time_month: {
type: INTEGER,
allowNull: false,
},
call_fee_month: {
type: INTEGER,
allowNull: false,
},
call_active_count_month: {
type: INTEGER,
allowNull: false,
},
call_passive_count_month: {
type: INTEGER,
allowNull: false,
},
call_count_month: {
type: INTEGER,
allowNull: false,
},
// is_deleted: {
// type: INTEGER,
// allowNull: false,
// },
// updated_at: {
// type: DATE,
// allowNull: true,
// get() {
// const date = this.getDataValue('updated_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// },
// created_at: {
// type: DATE,
// allowNull: false,
// get() {
// const date = this.getDataValue('created_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// }
}, {
timestamps: false,
tableName: 'credit_callrisk_call_overview',
});
CreditCallriskCallOverview.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CreditCallriskCallOverview.findOne({
attributes: attributes,
where: where,
});
}
CreditCallriskCallOverview.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CreditCallriskCallOverview.findAll({
attributes: attributes,
where: where,
order,
});
}
CreditCallriskCallOverview.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
const { count, rows } = await CreditCallriskCallOverview.findAndCountAll(condition);
return { page, count, rows };
}
CreditCallriskCallOverview.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await CreditCallriskCallOverview.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
CreditCallriskCallOverview.edit = async (data) => {
const where = data.where;
const params = data.params;
try {
const res = await CreditCallriskCallOverview.update(params, { where: where })
return res;
} catch (error) {
throw (error);
}
}
return CreditCallriskCallOverview;
};
\ No newline at end of file
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM } = app.Sequelize;
const CreditCallriskCallType= app.prometheusModel.define('credit_callrisk_call_type', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
report_id: {
type: INTEGER,
allowNull: false,
},
bank_call_count: {
type: INTEGER,
allowNull: false,
},
bank_call_time: {
type: INTEGER,
allowNull: false,
},
bank_number_count: {
type: INTEGER,
allowNull: false,
},
loan_call_count: {
type: INTEGER,
allowNull: false,
},
loan_call_time: {
type: INTEGER,
allowNull: false,
},
loan_number_count: {
type: INTEGER,
allowNull: false,
},
court_call_count: {
type: INTEGER,
allowNull: false,
},
collection_call_count: {
type: INTEGER,
allowNull: false,
},
laywer_call_count: {
type: INTEGER,
allowNull: false,
},
macao_call_count: {
type: INTEGER,
allowNull: false,
},
c110_call_count: {
type: INTEGER,
allowNull: false,
},
c120_call_count: {
type: INTEGER,
allowNull: false,
},
// is_deleted: {
// type: INTEGER,
// allowNull: false,
// },
// updated_at: {
// type: DATE,
// allowNull: true,
// get() {
// const date = this.getDataValue('updated_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// },
// created_at: {
// type: DATE,
// allowNull: false,
// get() {
// const date = this.getDataValue('created_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// }
}, {
timestamps: false,
tableName: 'credit_callrisk_call_type',
});
CreditCallriskCallType.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CreditCallriskCallType.findOne({
attributes: attributes,
where: where,
});
}
CreditCallriskCallType.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CreditCallriskCallType.findAll({
attributes: attributes,
where: where,
order,
});
}
CreditCallriskCallType.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
const { count, rows } = await CreditCallriskCallType.findAndCountAll(condition);
return { page, count, rows };
}
CreditCallriskCallType.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await CreditCallriskCallType.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
CreditCallriskCallType.edit = async (data) => {
const where = data.where;
const params = data.params;
try {
const res = await CreditCallriskCallType.update(params, { where: where })
return res;
} catch (error) {
throw (error);
}
}
return CreditCallriskCallType;
};
\ No newline at end of file
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM } = app.Sequelize;
const CreditCallriskReport = app.prometheusModel.define('credit_callrisk_report', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
report_no: {
type: STRING,
allowNull: false,
},
user_id: {
type: STRING,
allowNull: false,
},
app_type_id: {
type: STRING,
allowNull: false,
},
app_user_id: {
type: STRING,
allowNull: false,
},
app_id: {
type: STRING,
allowNull: false,
},
mobile: {
type: STRING,
allowNull: false,
},
operator: {
type: STRING,
allowNull: false,
},
net_time: {
type: STRING,
allowNull: false,
},
call_result_assessment: {
type: STRING,
allowNull: false,
},
// status: {
// type: ENUM('offline', 'online'),
// allowNull: false,
// },
// is_deleted: {
// type: INTEGER,
// allowNull: false,
// },
// updated_at: {
// type: DATE,
// allowNull: true,
// get() {
// const date = this.getDataValue('updated_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// },
// created_at: {
// type: DATE,
// allowNull: false,
// get() {
// const date = this.getDataValue('created_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// }
}, {
timestamps: false,
tableName: 'credit_callrisk_report',
});
CreditCallriskReport.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CreditCallriskReport.findOne({
attributes: attributes,
where: where,
});
}
CreditCallriskReport.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CreditCallriskReport.findAll({
attributes: attributes,
where: where,
order,
});
}
CreditCallriskReport.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
const { count, rows } = await CreditCallriskReport.findAndCountAll(condition);
return { page, count, rows };
}
CreditCallriskReport.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await CreditCallriskReport.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
CreditCallriskReport.edit = async (data) => {
const where = data.where;
const params = data.params;
try {
const res = await CreditCallriskReport.update(params, { where: where })
return res;
} catch (error) {
throw (error);
}
}
return CreditCallriskReport;
};
\ No newline at end of file
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM } = app.Sequelize;
const CreditCallriskSilenceCycle = app.prometheusModel.define('credit_callrisk_silence_cycle', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
report_id: {
type: INTEGER,
allowNull: false,
},
call_behavior_id: {
type: INTEGER,
allowNull: false,
},
silence_begin_time: {
type: INTEGER,
allowNull: false,
},
silence_end_time: {
type: INTEGER,
allowNull: false,
},
// is_deleted: {
// type: INTEGER,
// allowNull: false,
// },
// updated_at: {
// type: DATE,
// allowNull: true,
// get() {
// const date = this.getDataValue('updated_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// },
// created_at: {
// type: DATE,
// allowNull: false,
// get() {
// const date = this.getDataValue('created_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// },
// }
}, {
timestamps: false,
tableName: 'credit_callrisk_silence_cycle',
});
CreditCallriskSilenceCycle.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CreditCallriskSilenceCycle.findOne({
attributes: attributes,
where: where,
});
}
CreditCallriskSilenceCycle.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CreditCallriskSilenceCycle.findAll({
attributes: attributes,
where: where,
order,
});
}
CreditCallriskSilenceCycle.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
const { count, rows } = await CreditCallriskSilenceCycle.findAndCountAll(condition);
return { page, count, rows };
}
CreditCallriskSilenceCycle.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await CreditCallriskSilenceCycle.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
CreditCallriskSilenceCycle.edit = async (data) => {
const where = data.where;
const params = data.params;
try {
const res = await CreditCallriskSilenceCycle.update(params, { where: where })
return res;
} catch (error) {
throw (error);
}
}
return CreditCallriskSilenceCycle;
};
\ No newline at end of file
......@@ -9,7 +9,8 @@ module.exports = app => {
//我的信用-个人通话风险
router.get('/callrisk/report', 'credit.callrisk.getCallriskReport');
router.get('/callrisk/report/:report_no', 'credit.callrisk.getReport');//获取报告信息
router.post('/callrisk/query', 'credit.callrisk.queryCallRisk');//查询个人通话信息
};
......@@ -9,23 +9,97 @@ class CallriskService extends Service {
/**
* 黑名单报告
* 获取个人通话检测报告
*/
async getReport() {
async getReportB() {
const { ctx } = this;
const ret = await this.formatReport();
const report = await this.formatReport();
const ret = await this.formatHeadExplainMsg(report);
return ret;
}
async getReport(report_no) {
const { ctx } = this;
const basics = await ctx.prometheusModel.CreditCallriskReport.one({ where: { report_no } });
if (!basics || !basics.id) {
ctx.failed('error report_no');
}
const report_id = basics.id;
const call_overview = await this.getCallOverview(report_id);
const call_type = await this.getCallType(report_id);
const call_active = await this.getCallActive(report_id);
const call_behavior = await this.getCallBehavior(report_id);
const report = {
basics: { data: basics },
call_overview: { data: call_overview },
call_type: { data: call_type },
call_active: { data: call_active },
call_behavior: { data: call_behavior },
};
const ret = this.formatHeadExplainMsg(report);
return ret;
}
async getCallOverview(report_id) {
const { ctx } = this;
const call_overviews = await ctx.prometheusModel.CreditCallriskCallOverview.all({ where: { report_id } });
if (!call_overviews || call_overviews.length === 0) {
return [];
}
let data = {};
const monthes = [];
for (let i in call_overviews) {
const call_overview = call_overviews[i];
// monthes.push(call_overview.month);
// data.push(call_overview);
data[call_overview.month] = call_overview;
}
return data;
}
async getCallType(report_id) {
const { ctx } = this;
const call_type = await ctx.prometheusModel.CreditCallriskCallType.one({ where: { report_id } });
const data = call_type;
return data;
}
async getCallActive(report_id) {
const { ctx } = this;
const call_active = await ctx.prometheusModel.CreditCallriskCallActive.one({ where: { report_id } });
return call_active;
}
async getCallBehavior(report_id) {
const { ctx } = this;
const call_behavior = await ctx.prometheusModel.CreditCallriskCallBehavior.one({ where: { report_id } });
const call_behavior_silence_cycles = await ctx.prometheusModel.CreditCallriskSilenceCycle.all({ where: { report_id } });
call_behavior.silence_cycle = call_behavior ? [] : call_behavior_silence_cycles;
return call_behavior;
}
async formatReport() {
const call_overview_monthes = ['3月'];
const ret = {
basics: {
msg: '我们将依据您授权的运营商通话认证',//解析文案
msg: '我们将依据您授权的运营商通话认证,对您的通话行为进行多维度的分析和评估,帮助您更清楚的了解目前的贷款风险点。',//解析文案
data: {
mobile: '159****2898', //手机号
operator: '美国长城', //运营商
......@@ -37,7 +111,7 @@ class CallriskService extends Service {
},
call_overview: {//通话概览
msg: '解读:您当前检测的手机号码入网时长',
msg: '解读:您当前检测的手机号码入网时长,若少于6个月,会在一定程度影响您的贷款通过率。近6个月的月均话费和通话次数,反应了您个人通话的稳定性,在一定程度会影响到贷款机构对您的评估。',
monthes: ['2月', '2月', '2月', '2月', '2月', '2月',],
data: {
'2月': {
......@@ -85,7 +159,7 @@ class CallriskService extends Service {
}
},
call_type: {//通话类型分析
msg: '解读:近6个月,金融类通话累计为【*次】',
msg: `解读:近6个月,贷款类通话累计为【次】,金融业务通话【正常/较异常】您在短期内可能的申请贷款次数较正常,有利于贷款机构对您的评估;`,
data: {
bank_call_count: '12', //银行通话次数
bank_call_time: '34', //银行通话时长
......@@ -102,7 +176,7 @@ class CallriskService extends Service {
}
},
call_active: {//通话活跃分析
msg: '解读:您的夜间通话次数占【较高/较低】,【',
msg: '',
data: {
routine_call_time: '132', //常规时间通话时长
night_call_time: '323', //深夜时间通话时长
......@@ -210,6 +284,183 @@ class CallriskService extends Service {
}
//参数只要最终输出的报告格式数据
async getEvaluationLevel(report) {
const { ctx } = this;
const basics = report.basics.data;
const call_overview = report.call_overview.data;
// const call_type = report.call_type.data;
// const call_active = report.call_active.data;
const call_behavior = report.call_behavior.data;
//入网时长分数计算
const net_time = parseInt(basics.net_time);//入网时长
let net_time_score = 0;
if (net_time < 3) {
net_time_score = 40;
} else if (net_time < 6) {
net_time_score = 30;
} else if (net_time < 12) {
net_time_score = 15;
} else if (net_time < 24) {
net_time_score = 10;
}
//话费分数计算
let month_fee_sum = 0;
for (let i in call_overview.data) {
const month_call_overview = call_overview.data[i];
month_fee_sum += month_call_overview.call_fee_month;
}
const fee_avg = month_fee_sum / call_overview.data.length;//平均月话费
let fee_avg_score = 0;
if (fee_avg < 20) {
fee_avg_score = 20;
} else if (fee_avg < 30) {
fee_avg_score = 10;
}
//通话类型分数计算
let call_type_score = 0;
if (loan_call_count >= 1) {
call_type_score += 7;
}
if (bank_call_count >= 1) {
call_type_score += 2;
}
if (court_call_count >= 1) {
call_type_score += 5;
}
if (collection_call_count >= 1) {
call_type_score += 10;
}
if (laywer_call_count >= 1) {
call_type_score += 4;
}
if (macao_call_count >= 1) {
call_type_score += 4;
}
//通话活跃分数计算
const call_time_percent = night_call_time / routine_call_time;
const call_count_percent = night_call_count / routine_call_count;
let call_time_score = 0;
let call_count_score = 0;
if (call_time_percent >= 0.2) {
call_time_score = 30;
} else if (call_time_percent > 0.15) {
call_time_score = 25;
} else if (call_time_percent > 0.07) {
call_time_score = 20;
} else if (call_time_percent > 0.03) {
call_time_score = 10;
}
if (call_count_percent >= 0.2) {
call_count_score = 30;
} else if (call_count_percent > 0.15) {
call_count_score = 25;
} else if (call_count_percent > 0.07) {
call_count_score = 20;
} else if (call_count_percent > 0.03) {
call_count_score = 10;
}
const call_active_score = call_time_score < call_count_score ? call_time_score : call_count_score;
//通话行为分数计算
let call_behavior_socre = 0;
const silence_count_3day = call_behavior.silence_count_3day;
if (silence_count_3day >= 7) {
call_behavior_socre = 30;
} else if (silence_count_3day >= 4) {
call_behavior_socre = 20;
} else if (silence_count_3day >= 1) {
call_behavior_socre = 10;
}
const sum_score = net_time_score + fee_avg_score + call_type_score + call_active_score + call_behavior_socre;
let call_result_assessment = '优质';
if (sum_score >= 60) {
call_result_assessment = '高';
} else if (sum_score >= 20) {
call_result_assessment = '中';
} else if (sum_score >= 10) {
call_result_assessment = '低';
}
return call_result_assessment;
}
//参数只要最终输出的报告格式数据
async formatHeadExplainMsg(report) {
const { ctx } = this;
const call_type = report.call_type.data;
const call_active = report.call_active.data;
const call_behavior = report.call_behavior.data;
const basics_msg = `我们将依据您授权的运营商通话认证,对您的通话行为进行多维度的分析和评估,帮助您更清楚的了解目前的贷款风险点。`;
const call_overview_msg = `解读:您当前检测的手机号码入网时长,若少于6个月,会在一定程度影响您的贷款通过率。近6个月的月均话费和通话次数,反应了您个人通话的稳定性,在一定程度会影响到贷款机构对您的评估。`;
//通话类型解析
const loan_call_count = call_type.loan_call_count;
const court_call_count = call_type.court_call_count;
const collection_call_count = call_type.collection_call_count;
const laywer_call_count = call_type.laywer_call_count;
const macao_call_count = call_type.macao_call_count;
let advantage_text = '有利于';
let loan_call_status = '正常';
if (loan_call_count >= 3) {
loan_call_status = '较异常';
advantage_text = '不利于';
}
let risk_call_status = '正常';
if (court_call_count > 1 || collection_call_count > 1 || laywer_call_count > 3 || macao_call_count > 3) {
risk_call_status = '多';
advantage_text = '不利于';
}
if (collection_call_count == 0 && laywer_call_count <= 3 && macao_call_count <= 3 && court_call_count <= 1) {
risk_call_status = '少';
}
let illegal_text = '低';
if (court_call_count > 1 || collection_call_count > 1 || laywer_call_count > 3) {
illegal_text = '高';
advantage_text = '不利于';
}
const call_type_msg = `解读:近6个月,贷款类通话累计为【${loan_call_count}次】,金融业务通话【${loan_call_status}】您在短期内可能的申请贷款次数较正常,有利于贷款机构对您的评估;近6个月来,您的疑似风险通话次数较【${risk_call_status}】,您与违法违规事件关联度较【${illegal_text}】,【${advantage_text}】贷款机构对您的评估`;
//通话活跃度解析
let call_count_array = ['较低', '比较符合', '有利于'];
const call_count_percent = call_active.night_call_time / call_active.routine_call_time;
if (call_count_percent > 0.1) {
call_count_array = ['较高', '不符合', '不利于'];
}
//TODO 计算近6个月每个月通话的城市有几个。
const call_active_msg = `您的夜间通话次数占【${call_count_array[0]}】,【${call_count_array[1]}】日常社交时间,【${call_count_array[2]}】贷款机构对您的放贷评估。您的通话活跃地区【变动较大/变化不大】,您当前个人的社交/社会状态稳定度【较好/一般】,【有利于/不利于】贷款机构对您的放贷评估。`;
//通话行为解析
let call_behavior_array = ['较少', '稳定', '有利于',];
if (call_behavior.silence_count_3day > 3) {
call_behavior_array = ['较少', '稳定', '有利于',];
}
const call_behavior_msg = `您的静默时长、静默次数以及周期,占整体比例【${call_behavior_array[0]}】,通话活跃变动幅度【${call_behavior_array[1]}】,【${call_behavior_array[2]}】贷款机构对您的放贷评估`;
report.basics.msg = basics_msg;
report.call_overview.msg = call_overview_msg;
report.call_type.msg = call_type_msg;
report.call_active.msg = call_active_msg;
report.call_behavior.msg = call_behavior_msg;
return report;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment