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;
class CallriskController extends Controller {
/**
* 获取黑名单报告
* 通话记录风险检测报告
*/
async getReport() {
......@@ -14,8 +14,8 @@ class CallriskController extends Controller {
if (!report_id) {
ctx.failed('error report id');
}
const ret = await ctx.service.credit.callrisk.getReport(report_id);
ctx.success(ret);
const result = await ctx.service.credit.callrisk.getReport(report_id);
ctx.success({ result });
}
......@@ -24,12 +24,12 @@ class CallriskController extends Controller {
*/
async callriskInit() {
const { ctx } = this;
const ret = await ctx.service.credit.apply.callriskInit();
ctx.success(ret);
const result = await ctx.service.credit.apply.callriskInit();
ctx.success({ result });
}
/**
* 获取数据报告信息
* 立即检测
*/
async applyCallriskReport() {
......@@ -42,20 +42,36 @@ class CallriskController extends Controller {
password: { type: 'string', required: true }
}
ctx.validate(rule, input_params);
await ctx.service.credit.callrisk.checkThreeElements(input_params);
const ret = await ctx.service.credit.apply.applyCallrisk(input_params);
ctx.success(ret);
const result = await ctx.service.credit.apply.applyCallrisk(input_params);
ctx.success({ result });
}
async getCode() {
const { ctx } = this;
const order_id = ctx.request.body.order_id;
const result = await ctx.service.credit.callrisk.getCode(order_id);
ctx.success({ result });
}
async confirmCaptcha() {
async commitTask() {
const { ctx } = this;
const code = ctx.request.body.code;
const result = await ctx.service.credit.callrisk.verifyCode(code);
// const result = true;
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 => {
r_code: STRING,
r_msg: 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,
created_at: {
type: DATE,
......
......@@ -18,15 +18,15 @@ module.exports = app => {
},
active_call_count: {
type: INTEGER,
allowNull: false,
allowNull: true,
},
passive_call_count: {
type: INTEGER,
allowNull: false,
allowNull: true,
},
each_call_count: {
type: INTEGER,
allowNull: false,
allowNull: true,
},
silence_count_3day: {
type: INTEGER,
......@@ -50,7 +50,7 @@ module.exports = app => {
},
maximum_active_call_city: {
type: STRING,
allowNull: false,
allowNull: true,
},
maximum_passive_call_count: {
type: INTEGER,
......@@ -62,7 +62,7 @@ module.exports = app => {
},
maximum_passive_call_city: {
type: STRING,
allowNull: false,
allowNull: true,
},
maximum_call_time: {
type: INTEGER,
......@@ -74,7 +74,7 @@ module.exports = app => {
},
maximum_call_time_city: {
type: STRING,
allowNull: false,
allowNull: true,
},
// is_deleted: {
// type: INTEGER,
......
......@@ -4,23 +4,20 @@ const moment = require('moment');
module.exports = app => {
const { INTEGER, STRING, DATE, TEXT } = app.Sequelize;
const CreditYysOrder = app.prometheusModel.define('credit_yys_order', {
const CreditLogYys = app.prometheusModel.define('credit_log_yys', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
tyorder_idpe: INTEGER,
r_order_sn: STRING,
user_id: STRING,
app_user_id: STRING,
app_id: STRING,
app_type_id: STRING,
name: STRING,
phone: STRING,
id_card: STRING,
password: STRING,
r_order_sn: STRING,
operator: TEXT,
request_url: STRING,
params: STRING,
resp: TEXT,
valid: INTEGER,
created_at: {
type: DATE,
......@@ -38,9 +35,9 @@ module.exports = app => {
}
}, {
timestamps: false,
tableName: 'credit_yys_order',
tableName: 'credit_log_yys',
});
return CreditYysOrder;
return CreditLogYys;
};
......@@ -26,7 +26,10 @@ module.exports = app => {
router.get('/callrisk/report/:report_id', 'credit.callrisk.getReport');//获取报告信息
router.post('/callrisk/report', 'credit.callrisk.applyCallriskReport');//查询个人通话信息
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 {
const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId;
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();
if (!check_second_ret.order_id) {
const check_second_ret = await this.checkSecond({ name, phone, id_card });
if (check_second_ret.order_id) {
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 = await ctx.service.credit.order.createOrder(order_data);
const order_id = order.id;
//运营商API.创建订单号
const order_sn_info = await ctx.service.credit.yys.getOrderSn(phone);
if (orderSnInfo.code !== 0) {
ctx.failed('getOrderSn error msg:' + orderSnInfo.msg);
}
const order_sn = order_sn_info.data.orderSn;
const addYysOrder = {
order_id,
user_id,
app_type_id,
app_user_id,
app_id,
name,
phone,
id_card,
password,
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 });
//创建yys-order apply 记录
const apply = await this.createYysApply({ name, phone, id_card, password, order_id });
const order_sn = apply.r_order_id;
//第一次调用运营商获取验证码接口
const operator_params = apply.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[operator_params_val.name];
}
// get_code_params.data.phoneCode = '';
const yys_get_code = await ctx.service.credit.yys.getCode(get_code_params);
if (yys_get_code.code !== 0) {
ctx.failed('getCode error msg:' + yys_get_code.msg);
}
// //提交任务
// 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);
// }
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 } });
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 user_id = ctx.userId;
const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId;
const app_id = ctx.appId;
//获取签名
const timestamp = String(new Date().getTime());
const appKey = '';
const sign_params = { appKey, timestamp, };
const sign = await ctx.service.credit.common.sign(sign_params, this.config.BLACKLIST_APPLY_APPSECRET);
//调用数据接口获取个人通话风险数据 TODO
const params = { sign, phone, name, idcard, }
const url = '';
const result = await ctx.helper.send_request(url, params, { method: 'POST' });
const { name, phone, id_card, password, order_id } = input;
//运营商API.创建订单号
const order_sn_info = await ctx.service.credit.yys.getOrderSn(phone);
if (order_sn_info.code !== 0) {
ctx.failed('getOrderSn error msg:' + order_sn_info.msg);
}
//创建申请订单
const apply_data = {
type,
user_id,
app_user_id,
app_id,
app_type_id,
timestamp,
appkey: '',
sign,
r_code: result.data.code,
r_msg: result.data.msg,
r_order_id: result.data.data.order_id,
type: 2, user_id, app_user_id, app_id, app_type_id, name, phone, id_card,
appkey: this.config.YYS_APP_KEY,
service_code: password,
r_code: order_sn_info.code,
r_msg: order_sn_info.msg,
r_order_id: order_sn_info.data.orderSn,
operator: JSON.stringify(order_sn_info.data.operator)
}
const apply = await ctx.prometheusModel.CreditApply.create(apply_data);
if (result.data.code !== 0) {
ctx.failed('数据获取异常');
}
return apply;
}
......@@ -441,7 +415,7 @@ class ApplyService extends Service {
const { ctx } = this;
const { name, phone, id_card } = input;
const { user_id } = this;
const type = TypeConfigp['callrisk'];//个人通话类型
const type = TypeConfig['callrisk'];//个人通话类型
let first = false;//首次通过三要素验证后弹框提示:报告生成后,将无法查询其他人的报告
let second = false;//再次查询的是待支付中的订单
let order_id = null;
......
This diff is collapsed.
......@@ -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 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;
}
......@@ -29,15 +36,17 @@ class YysService extends Service {
*/
async getCode(params) {
const { ctx } = this;
let params = {
orderSn: params.order_sn,
data: {
password: params.password
}
}
// let params_data = {
// orderSn: params.order_sn,
// data: {
// password: params.password
// }
// }
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' });
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;
}
......@@ -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 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;
}
......@@ -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 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;
}
......@@ -88,19 +99,33 @@ class YysService extends Service {
let params = {
sign: "",
signParams: {
appKey: this.config.YYS_APP_KEY,
appKey: this.config.YYS_REPORT_KEY,
timestamp: String(new Date().getTime()),
},
orderSn,
}
params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_APPLY_APPSECRET);
const url = this.config.YYS_APPLY_URL;
params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_REPORT_APPSECRET);
const url = this.config.YYS_REPORT_URL;
const result = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info(JSON.stringify({ thxdReport_parmas: params, thxdReport_result: result }));
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 => {
//我的信用-通化检测
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;
......
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