Commit aa531f54 authored by Hsinli's avatar Hsinli

Merge branch 'master' of t-git.51gjj.com:fangbin/51business

parents b15105a3 5181e47b
Pipeline #14316 passed with stage
in 14 seconds
...@@ -5,7 +5,7 @@ const Controller = require('egg').Controller; ...@@ -5,7 +5,7 @@ const Controller = require('egg').Controller;
class CallriskController extends Controller { class CallriskController extends Controller {
/** /**
* 获取黑名单报告 * 通话记录风险检测报告
*/ */
async getReport() { async getReport() {
...@@ -14,8 +14,8 @@ class CallriskController extends Controller { ...@@ -14,8 +14,8 @@ class CallriskController extends Controller {
if (!report_id) { if (!report_id) {
ctx.failed('error report id'); ctx.failed('error report id');
} }
const ret = await ctx.service.credit.callrisk.getReport(report_id); const result = await ctx.service.credit.callrisk.getReport(report_id);
ctx.success(ret); ctx.success({ result });
} }
...@@ -24,12 +24,12 @@ class CallriskController extends Controller { ...@@ -24,12 +24,12 @@ class CallriskController extends Controller {
*/ */
async callriskInit() { async callriskInit() {
const { ctx } = this; const { ctx } = this;
const ret = await ctx.service.credit.apply.callriskInit(); const result = await ctx.service.credit.apply.callriskInit();
ctx.success(ret); ctx.success({ result });
} }
/** /**
* 获取数据报告信息 * 立即检测
*/ */
async applyCallriskReport() { async applyCallriskReport() {
...@@ -42,22 +42,38 @@ class CallriskController extends Controller { ...@@ -42,22 +42,38 @@ class CallriskController extends Controller {
password: { type: 'string', required: true } password: { type: 'string', required: true }
} }
ctx.validate(rule, input_params); ctx.validate(rule, input_params);
await ctx.service.credit.callrisk.checkThreeElements(input_params); const result = await ctx.service.credit.apply.applyCallrisk(input_params);
const ret = await ctx.service.credit.apply.applyCallrisk(input_params); ctx.success({ result });
ctx.success(ret);
} }
async confirmCaptcha() { async getCode() {
const { ctx } = this; const { ctx } = this;
const code = ctx.request.body.code; const order_id = ctx.request.body.order_id;
const result = await ctx.service.credit.callrisk.verifyCode(code); const result = await ctx.service.credit.callrisk.getCode(order_id);
// const result = true;
ctx.success({ result }); ctx.success({ result });
} }
async commitTask() {
const { ctx } = this;
const { order_id, code } = ctx.request.body;
const result = await ctx.service.credit.callrisk.commitTask({ order_id, code });
ctx.success({ result });
}
async queryTaskStatus() {
const { ctx } = this;
const order_id = ctx.params.order_id;
const result = await ctx.service.credit.callrisk.queryTaskStatus(order_id);
ctx.success({ result });
}
} }
......
...@@ -25,6 +25,22 @@ module.exports = app => { ...@@ -25,6 +25,22 @@ module.exports = app => {
r_code: STRING, r_code: STRING,
r_msg: STRING, r_msg: STRING,
r_order_id: STRING, r_order_id: STRING,
operator: {
type: STRING,
allowNull: true,
field: 'operator',
get() {
const operator = this.getDataValue('operator');
if (operator) {
try {
return JSON.parse(operator);
} catch (error) {
return [];
}
}
return [];
},
},
valid: INTEGER, valid: INTEGER,
created_at: { created_at: {
type: DATE, type: DATE,
......
...@@ -18,15 +18,15 @@ module.exports = app => { ...@@ -18,15 +18,15 @@ module.exports = app => {
}, },
active_call_count: { active_call_count: {
type: INTEGER, type: INTEGER,
allowNull: false, allowNull: true,
}, },
passive_call_count: { passive_call_count: {
type: INTEGER, type: INTEGER,
allowNull: false, allowNull: true,
}, },
each_call_count: { each_call_count: {
type: INTEGER, type: INTEGER,
allowNull: false, allowNull: true,
}, },
silence_count_3day: { silence_count_3day: {
type: INTEGER, type: INTEGER,
...@@ -50,7 +50,7 @@ module.exports = app => { ...@@ -50,7 +50,7 @@ module.exports = app => {
}, },
maximum_active_call_city: { maximum_active_call_city: {
type: STRING, type: STRING,
allowNull: false, allowNull: true,
}, },
maximum_passive_call_count: { maximum_passive_call_count: {
type: INTEGER, type: INTEGER,
...@@ -62,7 +62,7 @@ module.exports = app => { ...@@ -62,7 +62,7 @@ module.exports = app => {
}, },
maximum_passive_call_city: { maximum_passive_call_city: {
type: STRING, type: STRING,
allowNull: false, allowNull: true,
}, },
maximum_call_time: { maximum_call_time: {
type: INTEGER, type: INTEGER,
...@@ -74,7 +74,7 @@ module.exports = app => { ...@@ -74,7 +74,7 @@ module.exports = app => {
}, },
maximum_call_time_city: { maximum_call_time_city: {
type: STRING, type: STRING,
allowNull: false, allowNull: true,
}, },
// is_deleted: { // is_deleted: {
// type: INTEGER, // type: INTEGER,
......
...@@ -4,23 +4,20 @@ const moment = require('moment'); ...@@ -4,23 +4,20 @@ const moment = require('moment');
module.exports = app => { module.exports = app => {
const { INTEGER, STRING, DATE, TEXT } = app.Sequelize; const { INTEGER, STRING, DATE, TEXT } = app.Sequelize;
const CreditYysOrder = app.prometheusModel.define('credit_yys_order', { const CreditLogYys = app.prometheusModel.define('credit_log_yys', {
id: { id: {
type: INTEGER, type: INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
tyorder_idpe: INTEGER, r_order_sn: STRING,
user_id: STRING, user_id: STRING,
app_user_id: STRING, app_user_id: STRING,
app_id: STRING, app_id: STRING,
app_type_id: STRING, app_type_id: STRING,
name: STRING, request_url: STRING,
phone: STRING, params: STRING,
id_card: STRING, resp: TEXT,
password: STRING,
r_order_sn: STRING,
operator: TEXT,
valid: INTEGER, valid: INTEGER,
created_at: { created_at: {
type: DATE, type: DATE,
...@@ -38,9 +35,9 @@ module.exports = app => { ...@@ -38,9 +35,9 @@ module.exports = app => {
} }
}, { }, {
timestamps: false, timestamps: false,
tableName: 'credit_yys_order', tableName: 'credit_log_yys',
}); });
return CreditYysOrder; return CreditLogYys;
}; };
...@@ -26,7 +26,10 @@ module.exports = app => { ...@@ -26,7 +26,10 @@ module.exports = app => {
router.get('/callrisk/report/:report_id', 'credit.callrisk.getReport');//获取报告信息 router.get('/callrisk/report/:report_id', 'credit.callrisk.getReport');//获取报告信息
router.post('/callrisk/report', 'credit.callrisk.applyCallriskReport');//查询个人通话信息 router.post('/callrisk/report', 'credit.callrisk.applyCallriskReport');//查询个人通话信息
router.get('/callrisk/init', 'credit.callrisk.callriskInit');//进入个人通话风险检测页面 router.get('/callrisk/init', 'credit.callrisk.callriskInit');//进入个人通话风险检测页面
router.post('/callrisk/confirm_captcha', 'credit.callrisk.confirmCaptcha');//获取短信验证码 // router.post('/callrisk/confirm_captcha', 'credit.callrisk.confirmCaptcha');//获取短信验证码
router.post('/callrisk/get_code', 'credit.callrisk.getCode');//获取短信验证码
router.post('/callrisk/commit', 'credit.callrisk.commitTask');//提交任务
router.get('/callrisk/query/:order_id', 'credit.callrisk.queryTaskStatus');//检查任务状态
}; };
...@@ -336,102 +336,76 @@ class ApplyService extends Service { ...@@ -336,102 +336,76 @@ class ApplyService extends Service {
const app_type_id = ctx.appTypeId; const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId; const app_user_id = ctx.appUserId;
const app_id = ctx.appId; const app_id = ctx.appId;
const type = TypeConfigp['callrisk'];//个人通话类型 const type = TypeConfig['callrisk'];//个人通话类型
let report_id = null;
//数盒魔方三要素校验 //数盒魔方三要素校验
await ctx.service.credit.common.shuhemofangCheck('callrisk', input); // await ctx.service.credit.callrisk.checkThreeElements(input);
// await ctx.service.credit.common.shuhemofangCheck('callrisk', input);
//判断用户当前三要素是否是二次查询未支付订单 //判断用户当前三要素是否是二次查询未支付订单
const check_second_ret = await this.checkSecond(); const check_second_ret = await this.checkSecond({ name, phone, id_card });
if (!check_second_ret.order_id) { if (check_second_ret.order_id) {
return check_second_ret; return check_second_ret;
} }
// let ret = {
// order_id,
// report_id: null,
// first: check_second_ret.first,
// second: check_second_ret.second,
// order_sn: null
// }
//生成订单 //生成订单
const order_data = { type, name, phone, id_card }; const order_data = { type, name, phone, id_card };
const order = await ctx.service.credit.order.createOrder(order_data); const order = await ctx.service.credit.order.createOrder(order_data);
const order_id = order.id; const order_id = order.id;
//运营商API.创建订单号 //创建yys-order apply 记录
const order_sn_info = await ctx.service.credit.yys.getOrderSn(phone); const apply = await this.createYysApply({ name, phone, id_card, password, order_id });
if (orderSnInfo.code !== 0) { const order_sn = apply.r_order_id;
ctx.failed('getOrderSn error msg:' + orderSnInfo.msg);
} //第一次调用运营商获取验证码接口
const order_sn = order_sn_info.data.orderSn; const operator_params = apply.operator.params;
const addYysOrder = { let get_code_params = { orderSn: order_sn, data: {} };
order_id, for (let k in operator_params) {
user_id, const operator_params_val = operator_params[k];
app_type_id, if (operator_params_val.name === 'phone') {
app_user_id, continue;
app_id, }
name, get_code_params.data[operator_params_val.name] = input[operator_params_val.name];
phone, }
id_card, // get_code_params.data.phoneCode = '';
password, const yys_get_code = await ctx.service.credit.yys.getCode(get_code_params);
r_order_sn: order_sn,
order_sn_operator: orderSnInfo.data.operator
}
const yys_order_info = await ctx.prometheusModel.CreditYysOrder.create(addYysOrder);
// ret.order_sn = yys_order_info.data.orderSn;
//调用运营商获取验证码接口
const yys_get_code = await ctx.service.credit.yys.getCode({ password, order_sn });
if (yys_get_code.code !== 0) { if (yys_get_code.code !== 0) {
ctx.failed('getCode error msg:' + yys_get_code.msg); ctx.failed('getCode error msg:' + yys_get_code.msg);
} }
const order_no = await ctx.service.credit.common.getOrdertNo('callrisk', order_id);
// //提交任务 await ctx.prometheusModel.CreditOrder.update({ order_no, apply_id: apply.id }, { where: { id: order_id } });
// const yys_commit = await this.commitYys(orderSnInfo.data.orderSn, { phone, name, ID: id_card, password, phoneCode });
// if (yys_commit.code !== 0) {
// ctx.failed('getCode error msg:' + yys_commit.msg);
// }
return { order_id, report_id, first: check_second_ret.first, second: check_second_ret.second, order_sn }; return { order_id, report_id, first: check_second_ret.first, second: check_second_ret.second, order_sn };
} }
async createApply() {
async createYysApply(input) {
const { ctx } = this; const { ctx } = this;
const user_id = ctx.userId; const user_id = ctx.userId;
const app_type_id = ctx.appTypeId; const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId; const app_user_id = ctx.appUserId;
const app_id = ctx.appId; const app_id = ctx.appId;
//获取签名 const { name, phone, id_card, password, order_id } = input;
const timestamp = String(new Date().getTime());
const appKey = ''; //运营商API.创建订单号
const sign_params = { appKey, timestamp, }; const order_sn_info = await ctx.service.credit.yys.getOrderSn(phone);
const sign = await ctx.service.credit.common.sign(sign_params, this.config.BLACKLIST_APPLY_APPSECRET); if (order_sn_info.code !== 0) {
//调用数据接口获取个人通话风险数据 TODO ctx.failed('getOrderSn error msg:' + order_sn_info.msg);
const params = { sign, phone, name, idcard, } }
const url = '';
const result = await ctx.helper.send_request(url, params, { method: 'POST' }); //创建申请订单
const apply_data = { const apply_data = {
type, type: 2, user_id, app_user_id, app_id, app_type_id, name, phone, id_card,
user_id, appkey: this.config.YYS_APP_KEY,
app_user_id, service_code: password,
app_id, r_code: order_sn_info.code,
app_type_id, r_msg: order_sn_info.msg,
timestamp, r_order_id: order_sn_info.data.orderSn,
appkey: '', operator: JSON.stringify(order_sn_info.data.operator)
sign,
r_code: result.data.code,
r_msg: result.data.msg,
r_order_id: result.data.data.order_id,
} }
const apply = await ctx.prometheusModel.CreditApply.create(apply_data); const apply = await ctx.prometheusModel.CreditApply.create(apply_data);
if (result.data.code !== 0) {
ctx.failed('数据获取异常');
}
return apply; return apply;
} }
...@@ -441,7 +415,7 @@ class ApplyService extends Service { ...@@ -441,7 +415,7 @@ class ApplyService extends Service {
const { ctx } = this; const { ctx } = this;
const { name, phone, id_card } = input; const { name, phone, id_card } = input;
const { user_id } = this; const { user_id } = this;
const type = TypeConfigp['callrisk'];//个人通话类型 const type = TypeConfig['callrisk'];//个人通话类型
let first = false;//首次通过三要素验证后弹框提示:报告生成后,将无法查询其他人的报告 let first = false;//首次通过三要素验证后弹框提示:报告生成后,将无法查询其他人的报告
let second = false;//再次查询的是待支付中的订单 let second = false;//再次查询的是待支付中的订单
let order_id = null; let order_id = null;
......
...@@ -531,13 +531,34 @@ class CallriskService extends Service { ...@@ -531,13 +531,34 @@ class CallriskService extends Service {
const { ctx } = this; const { ctx } = this;
const user_id = ctx.userId; const user_id = ctx.userId;
// const { order_id } = input; // const { order_id } = input;
const yys_order_info = await ctx.prometheusModel.CreditYysOrder.one({ where: { order_id, user_id } }); // const yys_order_info = await ctx.prometheusModel.CreditYysOrder.findOne({ where: { order_id } });
if (!yys_order_info || !yys_order_info.id) { // if (!yys_order_info || !yys_order_info.id) {
ctx.failed('error order_sn'); // ctx.failed('error order_sn');
// }
const order_info = await ctx.prometheusModel.CreditOrder.findOne({ where: { id: order_id } });
const apply_info = await ctx.prometheusModel.CreditApply.findOne({ where: { id: order_info.apply_id } });
if (!order_info || !order_info.id) {
ctx.failed('error order');
}
const order_sn = apply_info.r_order_id;
const input_params = {
phone: order_info.phone,
name: order_info.name,
ID: order_info.id_card,
password: apply_info.service_code,
};
const operator_params = apply_info.operator.params;
let get_code_params = { orderSn: order_sn, data: {} };
for (let k in operator_params) {
const operator_params_val = operator_params[k];
// if (operator_params_val.name === 'phone') {
// continue;
// }
get_code_params.data[operator_params_val.name] = input_params[operator_params_val.name];
} }
const password = yys_order_info.password;
const params = { order_sn, password }; const ret = await ctx.service.credit.yys.getCode(get_code_params);
const ret = await ctx.service.credit.yys.getCode(params);
if (ret.code !== 0) { if (ret.code !== 0) {
ctx.failed('getCode error msg:' + ret.msg); ctx.failed('getCode error msg:' + ret.msg);
} }
...@@ -545,30 +566,33 @@ class CallriskService extends Service { ...@@ -545,30 +566,33 @@ class CallriskService extends Service {
return { order_id }; return { order_id };
} }
//提交任务给运营商 //提交任务
async commitYys(input) { async commitTask(input) {
const { ctx } = this; const { ctx } = this;
const user_id = ctx.userId; const user_id = ctx.userId;
const { order_id, code } = input; const { order_id, code } = input;
const yys_order = await ctx.prometheusModel.CreditYysOrder.one({ where: { order_id, user_id } });
// const order_id = yys_order.order_id; // const order_id = yys_order.order_id;
const order_info = await ctx.prometheusModel.CreditOrder.one({ where: { id: order_id, user_id } }); const order_info = await ctx.prometheusModel.CreditOrder.findOne({ where: { id: order_id } });
const input = { const apply_info = await ctx.prometheusModel.CreditApply.findOne({ where: { id: order_info.apply_id } });
if (!order_info || !order_info.id) {
ctx.failed('error order_sn');
}
const input_params = {
phone: order_info.phone, phone: order_info.phone,
name: order_info.name, name: order_info.name,
ID: order_info.id_card, ID: order_info.id_card,
password: yys_order.password, password: apply_info.service_code,
phoneCode: code, phoneCode: code,
}; };
const operator = yys_order.operator; const operator = apply_info.operator;
const params = operator.params; const params = operator.params;
let request_params = {}; let request_params = {};
for (let i in params) { for (let i in params) {
const column = params[i].name; const column = params[i].name;
request_params[column] = input[column]; request_params[column] = input_params[column];
} }
const request_data = { orderSn, params: request_params }; const request_data = { orderSn: apply_info.r_order_id, params: request_params };
const yys_commit = await ctx.service.credit.yys.commit(request_data); const yys_commit = await ctx.service.credit.yys.commit(request_data);
if (yys_commit.code !== 0) { if (yys_commit.code !== 0) {
...@@ -587,15 +611,187 @@ class CallriskService extends Service { ...@@ -587,15 +611,187 @@ class CallriskService extends Service {
const app_type_id = ctx.appTypeId; const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId; const app_user_id = ctx.appUserId;
const app_id = ctx.appId; const app_id = ctx.appId;
// const code_array = []; const code_array = [];
const yys_order = await ctx.prometheusModel.CreditYysOrder({ where: { order_id, user_id } }); // const yys_order = await ctx.prometheusModel.CreditYysOrder.findOne({ where: { order_id } });
const order_sn = yys_order.r_order_sn; const order_info = await ctx.prometheusModel.CreditOrder.findOne({ where: { id: order_id } });
const apply_info = await ctx.prometheusModel.CreditApply.findOne({ where: { id: order_info.apply_id } });
const order_sn = apply_info.r_order_id;
const query_resp = await ctx.service.credit.yys.query(order_sn); const query_resp = await ctx.service.credit.yys.query(order_sn);
const r_code = query_resp.code; const r_code = query_resp.code === undefined ? -999 : query_resp.code;
// return query_resp;
if (r_code === -999) {
return { code: r_code, msg: query_resp.message };
}
if (r_code !== 0) { if (r_code !== 0) {
return query_resp; return query_resp;
} }
const yys_report_data = await ctx.service.credit.yys.getData(order_sn);//拉取报告数据 // const query_resp = {code: 0, msg: 'sdfsdfsd'};
//获取报告内容
// const yys_report_data = await ctx.service.credit.yys.getData(order_sn);//拉取报告数据
const yys_report_data = {
"code": 0,
"data": {
"user_brief": {
"mobile": "13771111111", //手机号
"operator": "移动", //运营商
"net_time": 5137, //入网时长
"call_result_assessment": "",
"report_time": "2019-09-18 17:46:10", //报告生成时间
"report_No": "36edd55e-9ce7-4767-bd95-72077d086512" //报告编号
},
"call_overview": [ //通话概览
{
"month": "201904", //月份
"call_time_month": "11127", //月通话时长统计
"call_fee_month": "150.82", //月话费
"call_active_count_month": "108", //月主叫次数
"call_passive_count_month": "92", //月被叫次数
"call_count_month": "200" //月总通话次数
},
{
"month": "201905",
"call_time_month": "11048",
"call_fee_month": "137.72",
"call_active_count_month": "110",
"call_passive_count_month": "90",
"call_count_month": "200"
},
{
"month": "201906",
"call_time_month": "8637",
"call_fee_month": "132.40",
"call_active_count_month": "94",
"call_passive_count_month": "97",
"call_count_month": "191"
},
{
"month": "201907",
"call_time_month": "11803",
"call_fee_month": "140.52",
"call_active_count_month": "108",
"call_passive_count_month": "92",
"call_count_month": "200"
},
{
"month": "201908",
"call_time_month": "8636",
"call_fee_month": "165.89",
"call_active_count_month": "131",
"call_passive_count_month": "69",
"call_count_month": "200"
},
{
"month": "201909",
"call_time_month": "7509",
"call_fee_month": "97.77",
"call_active_count_month": "109",
"call_passive_count_month": "53",
"call_count_month": "162"
}
],
"call_type_analysis": {
"bank_call_count": 0, //银行通话次数
"bank_call_time": 0, //银行通话时长
"bank_number_count": 0, //银行通话号码个数
"loan_call_count": 0, //贷款通话次数
"loan_call_time": 0, //贷款通话时长
"loan_number_count": 0, //贷款通话号码个数
"court_call_count": 0, //法院通话次数
"collection_call_count": 0, //催收通话次数
"laywer_call_count": 0, //律师通话次数
"macao_call_count": 0, //澳门电话通话次数
"110_call_count": 0, //110通话次数
"120_call_count": 0 //120/119通话次数
},
"call_active_analysis": {
"routine_call_time": 58540, //常规时间通话时长
"night_call_time": 220, //深夜时间通话时长
"routine_call_count": 1148, //常规时间通话次数
"night_call_count": 5, //深夜时间通话次数
"time": [
{
"time_interval": "0-3", //时间区间
"call_count": 3, //通话次数
"call_time": 158 //通话时长
},
{
"time_interval": "3-6",
"call_count": 2,
"call_time": 62
},
{
"time_interval": "6-9",
"call_count": 127,
"call_time": 4860
},
{
"time_interval": "9-12",
"call_count": 222,
"call_time": 12602
},
{
"time_interval": "12-15",
"call_count": 136,
"call_time": 7672
},
{
"time_interval": "15-18",
"call_count": 305,
"call_time": 13768
},
{
"time_interval": "18-21",
"call_count": 288,
"call_time": 15716
},
{
"time_interval": "21-24",
"call_count": 70,
"call_time": 3922
}
],
"location": [
{
"city": "徐州", //具体城市
"ranking": 1, //通话次数排名
"call_count": "1153", //通话次数
"call_time": "58760" //通话时长
}
]
},
"call_behavior_analysis": {
"silence_count_3day": 4, //静默3天以上的次数
"silence_time_3day": 46, //静默总时长
"silence_time_rate_3day": "0.27", //静默时长占比
"silence_cycle": [
{
"silence_begin_time": "2019-04-15 12:04:32", //静默开始时间
"silence_end_time": "2019-05-01 07:05:47" //静默结束时间
},
{
"silence_begin_time": "2019-05-21 19:59:24",
"silence_end_time": "2019-06-01 08:29:57"
},
{
"silence_begin_time": "2019-07-24 09:34:45",
"silence_end_time": "2019-08-01 06:35:52"
},
{
"silence_begin_time": "2019-08-21 11:28:24",
"silence_end_time": "2019-09-01 07:03:25"
}
],
"maximum_active_call_count": "85", //最多主叫通话次数
"maximum_active_call_number": "13758076123", //最多主叫通话次数对应号码
"maximum_passive_call_count": "9", //最多被叫通话次数
"maximum_passive_call_number": "13852154123", //最多被叫通话次数对应号码
"maximum_call_time": "990", //最多通话时长
"maximum_call_time_number": "15852276123" //最多通话时长对应号码
}
},
"orderSn": "36edd55e-9ce7-4767-bd95-72077d086512"
};
if (yys_report_data.code !== 0) { if (yys_report_data.code !== 0) {
return { code: -1, msg: yys_report_data.msg } return { code: -1, msg: yys_report_data.msg }
} }
...@@ -604,10 +800,10 @@ class CallriskService extends Service { ...@@ -604,10 +800,10 @@ class CallriskService extends Service {
const user_brief = yys_report_data.data.user_brief; const user_brief = yys_report_data.data.user_brief;
const report = { const report = {
report_no: '', report_no: '',
user_id, user_id: 12,
app_type_id, app_type_id: 12,
app_user_id, app_user_id: 12,
app_id, app_id: 12,
mobile: user_brief.mobile, mobile: user_brief.mobile,
operator: user_brief.operator, operator: user_brief.operator,
net_time: user_brief.net_time, net_time: user_brief.net_time,
...@@ -653,8 +849,60 @@ class CallriskService extends Service { ...@@ -653,8 +849,60 @@ class CallriskService extends Service {
} }
await ctx.prometheusModel.CreditCallriskCallType.add(call_type_report); await ctx.prometheusModel.CreditCallriskCallType.add(call_type_report);
//通话活跃分析
const call_active = yys_report_data.data.call_active_analysis;
const call_active_report = {
report_id,
routine_call_time: call_active.routine_call_time,
night_call_time: call_active.night_call_time,
routine_call_count: call_active.routine_call_count,
night_call_count: call_active.night_call_count,
time_interval_active: JSON.stringify(call_active.time),
city_active: JSON.stringify(call_active.location),
}
await ctx.prometheusModel.CreditCallriskCallActive.add(call_active_report);
//通话活跃分析
const call_behavior = yys_report_data.data.call_behavior_analysis;
const call_behavior_report = {
report_id,
// active_call_count: call_behavior.active_call_count,
// passive_call_count: call_behavior.passive_call_count,
// each_call_count: call_behavior.each_call_count,
silence_count_3day: call_behavior.silence_count_3day,
silence_time_3day: call_behavior.silence_time_3day,
silence_time_rate_3day: call_behavior.silence_time_rate_3day,
maximum_active_call_count: call_behavior.maximum_active_call_count,
maximum_active_call_number: call_behavior.maximum_active_call_number,
// maximum_active_call_city: call_behavior.maximum_active_call_city,
maximum_passive_call_count: call_behavior.maximum_passive_call_count,
maximum_passive_call_number: call_behavior.maximum_passive_call_number,
// maximum_passive_call_city: call_behavior.maximum_passive_call_city,
maximum_call_time: call_behavior.maximum_call_time,
maximum_call_time_number: call_behavior.maximum_call_time_number,
// maximum_call_time_city: call_behavior.maximum_call_time_city,
}
const call_behavior_id = await ctx.prometheusModel.CreditCallriskCallBehavior.add(call_behavior_report);
//通话活跃静默周期记录
const silence_cycle_report = [];
for (let j in call_behavior.silence_cycle) {
const silence_cycle = call_behavior.silence_cycle[j];
silence_cycle_report.push({
report_id,
call_behavior_id,
silence_begin_time: silence_cycle.silence_begin_time,
silence_end_time: silence_cycle.silence_end_time,
});
}
await ctx.prometheusModel.CreditCallriskSilenceCycle.bulkCreate(silence_cycle_report);
await ctx.prometheusModel.CreditOrder.update({ report_id, state: '待支付', order_time: moment().format('YYYY-MM-DD HH:mm:ss'), state_time: moment().format('YYYY-MM-DD HH:mm:ss') }, { where: {} });
// const report_no = await ctx.service.credit.common.getReportNo('callrisk', report_id);
// await ctx.prometheusModel.CreditCallriskReport.update({ report_no }, { where: { id: report_id } });
return r_code; return Object.assign({ report_id }, query_resp);
} }
......
...@@ -19,7 +19,14 @@ class YysService extends Service { ...@@ -19,7 +19,14 @@ class YysService extends Service {
} }
let url = this.config.NODE_BASE_URL + '/yys_api/getorderSn' + '?appKey=' + this.config.YYS_APP_KEY; let url = this.config.NODE_BASE_URL + '/yys_api/getorderSn' + '?appKey=' + this.config.YYS_APP_KEY;
let resp = await ctx.helper.send_request(url, params, { method: 'POST' }); let resp = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info({ url: JSON.stringify(resp) }); ctx.logger.info(JSON.stringify({ yys_getorderSn_params: params, yys_getorderSn_result: resp }));
if (resp.data.code === undefined || resp.data.code !== 0) {
ctx.failed('getorderSn error:' + resp.data.msg);
}
let order_sn = resp.data.data.orderSn;
await this.addCreditLogYys(order_sn, '/yys_api/getorderSn', params, resp.data);
// ctx.logger.info(JSON.stringify(resp));
// ctx.logger.info(JSON.stringify({ yys_getorderSn_params: params, yys_getorderSn_result: resp }));
return resp.data; return resp.data;
} }
...@@ -29,15 +36,17 @@ class YysService extends Service { ...@@ -29,15 +36,17 @@ class YysService extends Service {
*/ */
async getCode(params) { async getCode(params) {
const { ctx } = this; const { ctx } = this;
let params = { // let params_data = {
orderSn: params.order_sn, // orderSn: params.order_sn,
data: { // data: {
password: params.password // password: params.password
} // }
} // }
let url = this.config.NODE_BASE_URL + '/yys_api/getCode' + '?appKey=' + this.config.YYS_APP_KEY; let url = this.config.NODE_BASE_URL + '/yys_api/getCode' + '?appKey=' + this.config.YYS_APP_KEY;
let resp = await ctx.helper.send_request(url, params, { method: 'POST' }); let resp = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info({ url: JSON.stringify(resp) }); ctx.logger.info(JSON.stringify({ yys_getCode_params: params, yys_getCode_result: resp }));
await this.addCreditLogYys(params.orderSn, '/yys_api/getCode', params, resp.data);
// console.info(resp);
return resp.data; return resp.data;
} }
...@@ -57,7 +66,8 @@ class YysService extends Service { ...@@ -57,7 +66,8 @@ class YysService extends Service {
// } // }
const url = this.config.NODE_BASE_URL + '/yys_api/commit' + '?appKey=' + this.config.YYS_APP_KEY; const url = this.config.NODE_BASE_URL + '/yys_api/commit' + '?appKey=' + this.config.YYS_APP_KEY;
const resp = await ctx.helper.send_request(url, params, { method: 'POST' }); const resp = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info({ url: JSON.stringify(resp) }); ctx.logger.info(JSON.stringify({ yys_commit_params: params, yys_commit_result: resp }));
await this.addCreditLogYys(params.orderSn, '/yys_api/commit', params, resp.data);
return resp.data; return resp.data;
} }
...@@ -72,7 +82,8 @@ class YysService extends Service { ...@@ -72,7 +82,8 @@ class YysService extends Service {
} }
let url = this.config.NODE_BASE_URL + '/yys_api/query' + '?appKey=' + this.config.YYS_APP_KEY; let url = this.config.NODE_BASE_URL + '/yys_api/query' + '?appKey=' + this.config.YYS_APP_KEY;
let resp = await ctx.helper.send_request(url, params, { method: 'POST' }); let resp = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info({ url: JSON.stringify(resp) }); ctx.logger.info(JSON.stringify({ yys_query_params: params, yys_query_result: resp }));
await this.addCreditLogYys(orderSn, '/yys_api/query', params, resp.data);
return resp.data; return resp.data;
} }
...@@ -88,19 +99,33 @@ class YysService extends Service { ...@@ -88,19 +99,33 @@ class YysService extends Service {
let params = { let params = {
sign: "", sign: "",
signParams: { signParams: {
appKey: this.config.YYS_APP_KEY, appKey: this.config.YYS_REPORT_KEY,
timestamp: String(new Date().getTime()), timestamp: String(new Date().getTime()),
}, },
orderSn, orderSn,
} }
params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_APPLY_APPSECRET); params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_REPORT_APPSECRET);
const url = this.config.YYS_APPLY_URL; const url = this.config.YYS_REPORT_URL;
const result = await ctx.helper.send_request(url, params, { method: 'POST' }); const result = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info(JSON.stringify({ thxdReport_parmas: params, thxdReport_result: result })); ctx.logger.info(JSON.stringify({ thxdReport_parmas: params, thxdReport_result: result }));
return result.data; return result.data;
} }
async addCreditLogYys(order_sn, request_url, params, resp) {
const { ctx } = this;
const user_id = ctx.userId;
const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId;
const app_id = ctx.appId;
const log_data = { user_id, app_type_id, app_user_id, app_id, r_order_sn: order_sn, request_url, params: JSON.stringify(params), resp: JSON.stringify(resp) }
const ret = await ctx.prometheusModel.CreditLogYys.create(log_data);
return ret;
}
} }
......
...@@ -172,6 +172,12 @@ module.exports = appInfo => { ...@@ -172,6 +172,12 @@ module.exports = appInfo => {
//我的信用-通化检测 //我的信用-通化检测
config.YYS_APP_KEY = 'A86BB96F55B64DCE87A46E919A347993'; config.YYS_APP_KEY = 'A86BB96F55B64DCE87A46E919A347993';
config.YYS_APPLY_APPSECRET = 'a695e9b3c0f1e3f15fb0b958fd3a4b67';
//运营商报告
config.YYS_REPORT_KEY = 'F4E0CA710F484CFFB1756741696E29A3';
config.YYS_REPORT_APPSECRET = '233B8E10E31B4C899EE6FEB3AEC22F140B6528BF';
config.YYS_REPORT_URL = 'http://47.96.253.64:8049/mycredit/thxdReport';
return config; return config;
......
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