Commit d3df0bbb authored by Hsinli's avatar Hsinli

add

parent a1001d14
Pipeline #14306 passed with stage
in 23 seconds
'use strict';
const moment = require('moment');
module.exports = app => {
const { INTEGER, STRING } = app.Sequelize;
const CreditIdCardCity = app.prometheusModel.define('credit_id_card_city', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
code: STRING,
name: STRING,
}, {
timestamps: false,
tableName: 'credit_id_card_city',
});
return CreditIdCardCity;
};
...@@ -23,7 +23,7 @@ module.exports = app => { ...@@ -23,7 +23,7 @@ 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');//获取短信验证码
......
...@@ -359,12 +359,14 @@ class BlacklistService extends Service { ...@@ -359,12 +359,14 @@ class BlacklistService extends Service {
let birth = parseInt(inputParams.id_card.substring(6, 10)); let birth = parseInt(inputParams.id_card.substring(6, 10));
let age = parseInt(moment().format('YYYY')) - birth; let age = parseInt(moment().format('YYYY')) - birth;
let city = await ctx.service.credit.common.getIdCardCity(inputParams.id_card);
let reportData = { let reportData = {
name: inputParams.name, name: inputParams.name,
id_card: inputParams.id_card, id_card: inputParams.id_card,
phone: inputParams.phone, phone: inputParams.phone,
age: age, age: age,
city: '', city: city,
blacklist_of_internet_loans: blacklistInfo.pre_loan_risk.blacklist_of_internet_loans, blacklist_of_internet_loans: blacklistInfo.pre_loan_risk.blacklist_of_internet_loans,
blacklist_of_court_dishonesty: blacklistInfo.pre_loan_risk.blacklist_of_court_dishonesty, blacklist_of_court_dishonesty: blacklistInfo.pre_loan_risk.blacklist_of_court_dishonesty,
blacklist_of_industry: blacklistInfo.pre_loan_risk.blacklist_of_industry, blacklist_of_industry: blacklistInfo.pre_loan_risk.blacklist_of_industry,
......
...@@ -373,6 +373,43 @@ class CommonService extends Service { ...@@ -373,6 +373,43 @@ class CommonService extends Service {
} }
} }
/**
* 根据身份证获取对应的省市区
* @param {*} idCard 身份证
*/
async getIdCardCity(idCard) {
const { ctx } = this;
let ret = '--';
let prefix3 = idCard.substring(0, 3) + '000';
let prefix6 = idCard.substring(0, 6);
let taskList = [
ctx.prometheusModel.CreditIdCardCity.findOne({ where: { code: prefix3 } }),
ctx.prometheusModel.CreditIdCardCity.findOne({ where: { code: prefix6 } }),
];
let retList = await Promise.all(taskList).then(result => {
return result;
}).catch(error => {
ctx.failed(error);
});
let provinece = retList[0];
let city = retList[1];
//数据获取
if (provinece === null && city === null) {
return ret;
}
//省和市
let provineceName = provinece === null ? '' : provinece.name;
let cityName = city === null ? '' : city.name;
if (provineceName === cityName) {
ret = provineceName;
} else {
ret = !provineceName ? (!cityName ? '--' : cityName) : (!cityName || cityName === '县') ? provineceName : (provineceName + '-' + cityName);
}
return ret;
}
} }
module.exports = CommonService; module.exports = CommonService;
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