Commit 730aa56a authored by Hsinli's avatar Hsinli

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

parents 66492aec 838d8d50
Pipeline #14659 passed with stage
in 34 seconds
...@@ -6,7 +6,7 @@ class TestController extends Controller { ...@@ -6,7 +6,7 @@ class TestController extends Controller {
const { service, ctx } = this; const { service, ctx } = this;
const from = { lng: 120.069206, lat: 30.291121 }; const from = { lng: 120.069206, lat: 30.291121 };
const to = { lng: 120.212997, lat: 30.29133 }; const to = { lng: 120.212997, lat: 30.29133 };
const ret = await service.course.lbs.getLBSDistance('driving', from, [ to ]); const ret = await service.course.lbs.getLBSDistance('walking', from, [ to, to ]);
ctx.success(ret); ctx.success(ret);
} }
} }
......
...@@ -39,7 +39,8 @@ class CallriskController extends Controller { ...@@ -39,7 +39,8 @@ class CallriskController extends Controller {
name: { type: 'string', required: true }, name: { type: 'string', required: true },
phone: { type: 'string', required: true }, phone: { type: 'string', required: true },
id_card: { type: 'string', required: true }, id_card: { type: 'string', required: true },
password: { type: 'string', required: true } password: { type: 'string', required: true },
net: { type: 'string', required: true },
} }
ctx.validate(rule, input_params); ctx.validate(rule, input_params);
const result = await ctx.service.credit.apply.applyCallrisk(input_params); const result = await ctx.service.credit.apply.applyCallrisk(input_params);
...@@ -70,7 +71,7 @@ class CallriskController extends Controller { ...@@ -70,7 +71,7 @@ class CallriskController extends Controller {
const { ctx } = this; const { ctx } = this;
const order_id = ctx.params.order_id; const order_id = ctx.params.order_id;
const result = await ctx.service.credit.callrisk.queryTaskStatus(order_id); const result = await ctx.service.credit.callrisk.queryTaskStatus(order_id);
ctx.success({ result }); ctx.success({ result });
} }
......
...@@ -34,7 +34,7 @@ class OrderController extends Controller { ...@@ -34,7 +34,7 @@ class OrderController extends Controller {
const { method, order_id, reject_url } = input_params; const { method, order_id, reject_url } = input_params;
let result = await ctx.service.credit.order.unifiedOrder(method, order_id); let result = await ctx.service.credit.order.unifiedOrder(method, order_id);
// result.reject_url = reject_url; // result.reject_url = reject_url;
result.url = `${result.url}&py=#shanp.com&redirect_url=${reject_url}`; result.url = `${result.url}&redirect_url=${reject_url}`;
ctx.success({ result }); ctx.success({ result });
} }
......
This diff is collapsed.
...@@ -4,66 +4,66 @@ ...@@ -4,66 +4,66 @@
const Service = require('egg').Service; const Service = require('egg').Service;
const AGE_CATS = [ const AGE_CATS = [
{ id: -2, name: '全部', value: 0 }, { id: -2, name: '全部', value: 0 },
{ id: -3, name: '3岁以下', value: 3 }, { id: -3, name: '3岁以下', value: 3 },
{ id: -4, name: '4岁', value: 4 }, { id: -4, name: '4岁', value: 4 },
{ id: -5, name: '5岁', value: 5 }, { id: -5, name: '5岁', value: 5 },
{ id: -6, name: '6岁', value: 6 }, { id: -6, name: '6岁', value: 6 },
{ id: -7, name: '7岁', value: 7 }, { id: -7, name: '7岁', value: 7 },
{ id: -8, name: '8岁', value: 8 }, { id: -8, name: '8岁', value: 8 },
{ id: -9, name: '9岁', value: 9 }, { id: -9, name: '9岁', value: 9 },
{ id: -10, name: '10岁', value: 10 }, { id: -10, name: '10岁', value: 10 },
{ id: -11, name: '11岁', value: 11 }, { id: -11, name: '11岁', value: 11 },
{ id: -12, name: '12岁', value: 12 }, { id: -12, name: '12岁', value: 12 },
{ id: -13, name: '12岁以上', value: 13 }, { id: -13, name: '12岁以上', value: 13 },
]; ];
const INSTITUTION_TYPE = [ const INSTITUTION_TYPE = [
{ id: -14, name: '全部', value: '' }, { id: -14, name: '全部', value: '' },
{ id: -15, name: '品牌', value: '品牌' }, { id: -15, name: '品牌', value: '品牌' },
]; ];
class OptionService extends Service { class OptionService extends Service {
/** /**
* 我的信用首页 * 我的信用首页
*/ */
async getOptions() { async getOptions() {
const { ctx } = this; const { ctx } = this;
const cats = await ctx.classModel.CourseCat.all({ where: { status: 1, is_deleted: 0 } }); const cats = await ctx.classModel.CourseCat.all({ where: { status: 1, is_deleted: 0 } });
const tree_cats = this.getTrees(cats, 0); const tree_cats = this.getTrees(cats, 0);
const options = { const options = {
cats: tree_cats, cats: tree_cats,
ages: AGE_CATS, ages: AGE_CATS,
institutions: INSTITUTION_TYPE, institutions: INSTITUTION_TYPE,
} };
return options; return options;
} }
getTrees(data, rootId) { getTrees(data, rootId) {
const ret = []; const ret = [];
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const node = data[i]; const node = data[i];
if (node.parent_id == rootId) { if (node.parent_id == rootId) {
const newNode = {}; const newNode = {};
// if (node.parent_id == 0) newNode._child.push({ id: 0, name: '全部', value: '' }); // if (node.parent_id == 0) newNode._child.push({ id: 0, name: '全部', value: '' });
newNode.id = node.id; newNode.id = node.id;
newNode.name = node.name; newNode.name = node.name;
newNode.tips = node.tips; newNode.tips = node.tips;
newNode.image = node.image; newNode.image = node.image;
newNode.color = node.color; newNode.color = node.color;
newNode.level = node.level; newNode.level = node.level;
newNode.value = node.id; newNode.value = node.id;
newNode._child = this.getTrees(data, node.id); newNode._child = this.getTrees(data, node.id);
if (newNode._child.length !== 0) newNode._child.unshift({ id: 0, name: '全部', value: 0 }); if (newNode._child.length !== 0) newNode._child.unshift({ id: 0, name: '全部', value: node.id });
ret.push(newNode); ret.push(newNode);
} }
}
return ret;
} }
return ret;
}
} }
......
...@@ -58,20 +58,29 @@ class ApplyService extends Service { ...@@ -58,20 +58,29 @@ class ApplyService extends Service {
return ret; return ret;
} }
/**
* 进入个人通话查询页面
*/
async callriskInit() { async callriskInit() {
const { ctx } = this; const { ctx } = this;
if (!ctx.userId) {
ctx.failed('登录异常');
}
let ret = { let ret = {
have_be_pay_order: false, have_be_pay_order: false,
order_id: null, order_id: null,
phone: '',
placeholder: { placeholder: {
name: '', name: '',
id_card: '' id_card: '',
} }
} }
let bePayOrder = await ctx.service.credit.order.getBePayOrder('callrisk'); let bePayOrder = await ctx.service.credit.order.getBePayOrder('callrisk');
if (bePayOrder.length !== 0) { if (bePayOrder.length !== 0) {
ret.have_be_pay_order = true; ret.have_be_pay_order = true;
ret.order_id = bePayOrder[0].id; ret.order_id = bePayOrder[0].id;
ret.phone = bePayOrder[0].phone.substring(0, 3) + '****' + bePayOrder[0].phone.substring(7, 11)
} }
//第一次查询成功的订单,反显姓名和身份证 //第一次查询成功的订单,反显姓名和身份证
...@@ -330,7 +339,7 @@ class ApplyService extends Service { ...@@ -330,7 +339,7 @@ class ApplyService extends Service {
async applyCallrisk(input) { async applyCallrisk(input) {
const { ctx } = this; const { ctx } = this;
const { name, phone, id_card, password } = input; const { name, phone, id_card, password, net } = input;
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;
...@@ -353,7 +362,7 @@ class ApplyService extends Service { ...@@ -353,7 +362,7 @@ class ApplyService extends Service {
const order_id = order.id; const order_id = order.id;
//创建yys-order apply 记录 //创建yys-order apply 记录
const apply = await this.createYysApply({ name, phone, id_card, password, order_id }); const apply = await this.createYysApply({ name, phone, id_card, password, net, order_id });
const order_sn = apply.r_order_id; const order_sn = apply.r_order_id;
//第一次调用运营商获取验证码接口 //第一次调用运营商获取验证码接口
...@@ -392,10 +401,10 @@ class ApplyService extends Service { ...@@ -392,10 +401,10 @@ 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 { name, phone, id_card, password, order_id } = input; const { name, phone, id_card, password, net, order_id } = input;
//运营商API.创建订单号 //运营商API.创建订单号
const order_sn_info = await ctx.service.credit.yys.getOrderSn(phone); const order_sn_info = await ctx.service.credit.yys.getOrderSn({ phone, net });
if (order_sn_info.code !== 0) { if (order_sn_info.code !== 0) {
ctx.failed('getOrderSn error msg:' + order_sn_info.msg); ctx.failed('getOrderSn error msg:' + order_sn_info.msg);
} }
...@@ -430,14 +439,14 @@ class ApplyService extends Service { ...@@ -430,14 +439,14 @@ class ApplyService extends Service {
let orderFilter = { let orderFilter = {
arrtibutes: ['id', 'name', 'id_card'], arrtibutes: ['id', 'name', 'id_card'],
where: { where: {
user_id: ctx.userId, user_id: user_id,
state: '已支付', state: '已支付',
type: 2, type: type,
valid: 1 valid: 1
} }
} }
let orderInfo = await ctx.prometheusModel.CreditOrder.findOne(orderFilter); let orderInfo = await ctx.prometheusModel.CreditOrder.findOne(orderFilter);
if (orderInfo !== null && (inputParams.name !== orderInfo.name || inputParams.id_card !== orderInfo.id_card)) { if (orderInfo !== null && (name !== orderInfo.name || id_card !== orderInfo.id_card)) {
ctx.failed('仅供本人查询使用,无法查询其他人信息'); ctx.failed('仅供本人查询使用,无法查询其他人信息');
} }
......
...@@ -82,7 +82,7 @@ class CallriskService extends Service { ...@@ -82,7 +82,7 @@ class CallriskService extends Service {
//订单是否在有效期内 //订单是否在有效期内
const report_valid = await ctx.service.credit.order.getReportValid('callrisk', report_id); const report_valid = await ctx.service.credit.order.getReportValid('callrisk', report_id);
const report = { let report = {
basics: { data: basics }, basics: { data: basics },
call_overview: { data: call_overview }, call_overview: { data: call_overview },
call_type: { data: call_type }, call_type: { data: call_type },
...@@ -90,6 +90,7 @@ class CallriskService extends Service { ...@@ -90,6 +90,7 @@ class CallriskService extends Service {
call_behavior: { data: call_behavior }, call_behavior: { data: call_behavior },
report_valid, report_valid,
}; };
report.basics.data.call_result_assessment = await this.getEvaluationLevel(report);
const ret = this.formatHeadExplainMsg(report); const ret = this.formatHeadExplainMsg(report);
...@@ -138,9 +139,30 @@ class CallriskService extends Service { ...@@ -138,9 +139,30 @@ class CallriskService extends Service {
const { ctx } = this; const { ctx } = this;
const call_behavior = await ctx.prometheusModel.CreditCallriskCallBehavior.one({ where: { report_id } }); const call_behavior = await ctx.prometheusModel.CreditCallriskCallBehavior.one({ where: { report_id } });
const call_behavior_silence_cycles = await ctx.prometheusModel.CreditCallriskSilenceCycle.all({ 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; const ret = {
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,
silence_cycle: call_behavior_silence_cycles,
call_each_other: {
active_call_count: call_behavior.active_call_count,
passive_call_count: call_behavior.passive_call_count,
each_call_count: call_behavior.each_call_count,
},
call_rank: {
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,
},
};
return call_behavior; return ret;
} }
async formatReport() { async formatReport() {
...@@ -338,8 +360,8 @@ class CallriskService extends Service { ...@@ -338,8 +360,8 @@ class CallriskService extends Service {
const { ctx } = this; const { ctx } = this;
const basics = report.basics.data; const basics = report.basics.data;
const call_overview = report.call_overview.data; const call_overview = report.call_overview.data;
// 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;
//入网时长分数计算 //入网时长分数计算
...@@ -357,11 +379,11 @@ class CallriskService extends Service { ...@@ -357,11 +379,11 @@ class CallriskService extends Service {
//话费分数计算 //话费分数计算
let month_fee_sum = 0; let month_fee_sum = 0;
for (let i in call_overview.data) { for (let i in call_overview) {
const month_call_overview = call_overview.data[i]; const month_call_overview = call_overview[i];
month_fee_sum += month_call_overview.call_fee_month; month_fee_sum += month_call_overview.call_fee_month;
} }
const fee_avg = month_fee_sum / call_overview.data.length;//平均月话费 const fee_avg = month_fee_sum / call_overview.length;//平均月话费
let fee_avg_score = 0; let fee_avg_score = 0;
if (fee_avg < 20) { if (fee_avg < 20) {
fee_avg_score = 20; fee_avg_score = 20;
...@@ -370,6 +392,12 @@ class CallriskService extends Service { ...@@ -370,6 +392,12 @@ class CallriskService extends Service {
} }
//通话类型分数计算 //通话类型分数计算
const loan_call_count = call_type.loan_call_count;
const bank_call_count = call_type.bank_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 call_type_score = 0; let call_type_score = 0;
if (loan_call_count >= 1) { if (loan_call_count >= 1) {
call_type_score += 7; call_type_score += 7;
...@@ -391,8 +419,8 @@ class CallriskService extends Service { ...@@ -391,8 +419,8 @@ class CallriskService extends Service {
} }
//通话活跃分数计算 //通话活跃分数计算
const call_time_percent = night_call_time / routine_call_time; const call_time_percent = call_active.night_call_time / call_active.routine_call_time;
const call_count_percent = night_call_count / routine_call_count; const call_count_percent = call_active.night_call_count / call_active.routine_call_count;
let call_time_score = 0; let call_time_score = 0;
let call_count_score = 0; let call_count_score = 0;
if (call_time_percent >= 0.2) { if (call_time_percent >= 0.2) {
...@@ -426,6 +454,7 @@ class CallriskService extends Service { ...@@ -426,6 +454,7 @@ class CallriskService extends Service {
call_behavior_socre = 10; call_behavior_socre = 10;
} }
console.info(net_time_score, fee_avg_score, call_type_score, call_active_score, call_behavior_socre);
const sum_score = net_time_score + fee_avg_score + call_type_score + call_active_score + call_behavior_socre; const sum_score = net_time_score + fee_avg_score + call_type_score + call_active_score + call_behavior_socre;
let call_result_assessment = '优质'; let call_result_assessment = '优质';
......
...@@ -12,13 +12,14 @@ class YysService extends Service { ...@@ -12,13 +12,14 @@ class YysService extends Service {
* 创建订单号 * 创建订单号
* @param {*} * @param {*}
*/ */
async getOrderSn(phone) { async getOrderSn({ phone, net }) {
const { ctx } = this; const { ctx } = this;
let params = { let params = {
phone: phone phone: phone,
net: Number(net),
} }
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', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_getorderSn_params: params, yys_getorderSn_result: resp })); ctx.logger.info(JSON.stringify({ yys_getorderSn_params: params, yys_getorderSn_result: resp }));
if (resp.data.code === undefined || resp.data.code !== 0) { if (resp.data.code === undefined || resp.data.code !== 0) {
ctx.failed('getorderSn error:' + resp.data.msg); ctx.failed('getorderSn error:' + resp.data.msg);
...@@ -43,7 +44,7 @@ class YysService extends Service { ...@@ -43,7 +44,7 @@ class YysService extends Service {
// } // }
// } // }
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', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_getCode_params: params, yys_getCode_result: 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); await this.addCreditLogYys(params.orderSn, '/yys_api/getCode', params, resp.data);
// console.info(resp); // console.info(resp);
...@@ -65,7 +66,7 @@ class YysService extends Service { ...@@ -65,7 +66,7 @@ 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', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_commit_params: params, yys_commit_result: 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); await this.addCreditLogYys(params.orderSn, '/yys_api/commit', params, resp.data);
return resp.data; return resp.data;
...@@ -81,7 +82,7 @@ class YysService extends Service { ...@@ -81,7 +82,7 @@ class YysService extends Service {
orderSn: orderSn, orderSn: orderSn,
} }
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', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_query_params: params, yys_query_result: resp })); ctx.logger.info(JSON.stringify({ yys_query_params: params, yys_query_result: resp }));
await this.addCreditLogYys(orderSn, '/yys_api/query', params, resp.data); await this.addCreditLogYys(orderSn, '/yys_api/query', params, resp.data);
return resp.data; return resp.data;
...@@ -106,7 +107,7 @@ class YysService extends Service { ...@@ -106,7 +107,7 @@ class YysService extends Service {
} }
params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_REPORT_APPSECRET); params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_REPORT_APPSECRET);
const url = this.config.YYS_REPORT_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', timeout: 30000 });
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;
......
...@@ -103,7 +103,7 @@ module.exports = appInfo => { ...@@ -103,7 +103,7 @@ module.exports = appInfo => {
// other sequelize configurations // other sequelize configurations
dialect: 'mysql', dialect: 'mysql',
host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com', host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com',
database: 'class_dev', database: 'class_uat',
username: 'class_testing', username: 'class_testing',
password: 'WV862L32451I6KD58tU9K', password: 'WV862L32451I6KD58tU9K',
port: 3306, port: 3306,
......
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