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

fix

parent fea40a22
Pipeline #14886 passed with stage
in 36 seconds
...@@ -313,10 +313,10 @@ module.exports = { ...@@ -313,10 +313,10 @@ module.exports = {
return 1; return 1;
}, },
//固定位数前补充 0 操作 //固定位数前补充 0 操作
PrefixInteger(num, length) { PrefixInteger(num, length) {
return (Array(length).join('0') + num).slice(-length); return (Array(length).join('0') + num).slice(-length);
}, },
async xmlTojson(data) { async xmlTojson(data) {
const ret_p = new Promise((resolve, reject) => { const ret_p = new Promise((resolve, reject) => {
XML2JS.parseString(data, (err, result) => { XML2JS.parseString(data, (err, result) => {
...@@ -337,6 +337,33 @@ module.exports = { ...@@ -337,6 +337,33 @@ module.exports = {
const bulider = new XML2JS.Builder(); const bulider = new XML2JS.Builder();
const xml_params = bulider.buildObject(data); const xml_params = bulider.buildObject(data);
return xml_params; return xml_params;
},
//获取手机号码归属地
async getPhoneCity(phone) {
const { ctx } = this;
const url = 'https://mobsec-dianhua.baidu.com/dianhua_api/open/location';
let location = '--';
const result = await ctx.helper.send_request(url, { tel: phone }, { method: 'GET', timeout: 6000 });
if (result.status !== 200) {
return location;
}
const ret = result.data;
let city = '';
if (ret.response && ret.response[phone] && ret.response[phone].detail && ret.response[phone].detail.area) {
city = ret.response[phone].detail.area[0].city;
}
let provinece = '';
if (ret.response && ret.response[phone] && ret.response[phone].detail && ret.response[phone].detail.province) {
provinece = ret.response[phone].detail.province;
}
if (city == provinece) {
city = '';
}
location = provinece + city;
return location;
} }
}; };
...@@ -372,7 +372,8 @@ class BlacklistService extends Service { ...@@ -372,7 +372,8 @@ 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 city = await ctx.service.credit.common.getIdCardCity(inputParams.id_card);
let city = await ctx.helper.getPhoneCity(inputParams.phone);//2019-10-14 20:36:00 lisk 改为获取手机号归属地
let reportData = { let reportData = {
name: inputParams.name, name: inputParams.name,
......
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