Commit b3295a84 authored by 李尚科's avatar 李尚科

fix

parent 45aa6401
Pipeline #14779 passed with stage
in 12 seconds
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
const Service = require('egg').Service; const Service = require('egg').Service;
const moment = require('moment'); const moment = require('moment');
const R = require('ramda');
class CallriskService extends Service { class CallriskService extends Service {
...@@ -77,15 +78,19 @@ class CallriskService extends Service { ...@@ -77,15 +78,19 @@ class CallriskService extends Service {
const call_overview = await this.getCallOverview(report_id); const call_overview = await this.getCallOverview(report_id);
const call_type = await this.getCallType(report_id); const call_type = await this.getCallType(report_id);
const call_active = await this.getCallActive(report_id); let call_active = await this.getCallActive(report_id);
const call_behavior = await this.getCallBehavior(report_id); const call_behavior = await this.getCallBehavior(report_id);
//订单是否在有效期内 //订单是否在有效期内
const net_time = basics.net_time; const net_time = basics.net_time;
const months = (net_time / 30).toFixed(); const months = parseInt(net_time / 30);
const days = net_time % 30; const days = net_time % 30;
basics.net_time = months + '月' + (days ? days + '天' : ''); basics.net_time = months + '月' + (days ? days + '天' : '');
basics.mobile = basics.mobile.substring(0, 3) + '****' + basics.mobile.substring(7, 11);//手机号(只展示前三位和后四位) basics.mobile = basics.mobile.substring(0, 3) + '****' + basics.mobile.substring(7, 11);//手机号(只展示前三位和后四位)
const diff = function (a, b) { return b.call_count - a.call_count };
const city_active = R.sort(diff)(call_active.city_active).slice(0, 3);
console.info(city_active);
call_active.city_active = JSON.stringify(city_active);
const report_valid = await ctx.service.credit.order.getReportValid('callrisk', report_id); const report_valid = await ctx.service.credit.order.getReportValid('callrisk', report_id);
let report = { let report = {
basics: { data: basics }, basics: { data: basics },
...@@ -97,7 +102,7 @@ class CallriskService extends Service { ...@@ -97,7 +102,7 @@ class CallriskService extends Service {
}; };
report.basics.data.call_result_assessment = await this.getEvaluationLevel(report); report.basics.data.call_result_assessment = await this.getEvaluationLevel(report);
const ret = this.formatHeadExplainMsg(report); const ret = await this.formatHeadExplainMsg(report);
return ret; return ret;
} }
...@@ -135,7 +140,6 @@ class CallriskService extends Service { ...@@ -135,7 +140,6 @@ class CallriskService extends Service {
const { ctx } = this; const { ctx } = this;
const call_active = await ctx.prometheusModel.CreditCallriskCallActive.one({ where: { report_id } }); const call_active = await ctx.prometheusModel.CreditCallriskCallActive.one({ where: { report_id } });
return call_active; return call_active;
} }
...@@ -482,6 +486,7 @@ class CallriskService extends Service { ...@@ -482,6 +486,7 @@ class CallriskService extends Service {
const call_type = report.call_type.data; const call_type = report.call_type.data;
const call_active = report.call_active.data; const call_active = report.call_active.data;
const call_behavior = report.call_behavior.data; const call_behavior = report.call_behavior.data;
const basics_msg = `我们将依据您授权的运营商通话认证,对您的通话行为进行多维度的分析和评估,帮助您更清楚的了解目前的贷款风险点。`; const basics_msg = `我们将依据您授权的运营商通话认证,对您的通话行为进行多维度的分析和评估,帮助您更清楚的了解目前的贷款风险点。`;
...@@ -525,16 +530,16 @@ class CallriskService extends Service { ...@@ -525,16 +530,16 @@ class CallriskService extends Service {
} }
//TODO 计算近6个月每个月通话的城市有几个。 //TODO 计算近6个月每个月通话的城市有几个。
const call_most_city = call_active.city_active.slice(0, 3); const call_most_city = call_active.city_active.slice(0, 3);
let total_time = 0; const total_time = parseInt(call_active.routine_call_time) + parseInt(call_active.night_call_time);
let top_three_city_total_time = 0; let top_three_city_total_time = 0;
for (let i in call_most_city) { for (let i in call_most_city) {
const call_city = call_most_city[i]; const call_city = call_most_city[i];
top_three_city_total_time += call_city.call_time; top_three_city_total_time += call_city.call_time;
} }
for (let j in call_active.city_active) { // for (let j in call_active.city_active) {
const call = call_active.city_active[j]; // const call = call_active.city_active[j];
total_time += call.call_time; // total_time += call.call_time;
} // }
const percent = (top_three_city_total_time / total_time).toFixed(2); const percent = (top_three_city_total_time / total_time).toFixed(2);
let call_active_text = ['变化不大', '较好', '有利于']; let call_active_text = ['变化不大', '较好', '有利于'];
if (percent <= 0.6) { if (percent <= 0.6) {
......
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