Commit 82837cc4 authored by 何娜's avatar 何娜

taxh5 ip定位修复

parent 8e5a1516
Pipeline #7185 passed with stage
in 9 seconds
......@@ -17,7 +17,7 @@ class PartnerService extends Service {
try {
return JSON.parse(data);
} catch (err) {
ctx.logger.error('【Scripts】fetchParams', redisThemePrefix + appKey, 'result:', data, err);
ctx.logger.error('【Scripts】fetchTheme', redisThemePrefix + appKey, 'result:', data, err);
await this.app.redis.del(redisThemePrefix + appKey);
}
}
......@@ -32,7 +32,7 @@ class PartnerService extends Service {
subject: 'it'
}
});
ctx.logger.info(`【Partner】 fetchTheme ${host + fetchTheme}/${appKey}`, ret.data);
ctx.logger.info(`【Partner】 fetchTheme ${host + fetchTheme}/${appKey}`, JSON.stringify(ret.data));
if (ret.status === 200 && ret.data && ret.data.length > 0 && ret.data[0].appKey === appKey) {
await this.app.redis.set(redisThemePrefix + appKey, JSON.stringify(ret.data[0]), 'EX', 300);
}
......@@ -63,7 +63,7 @@ class PartnerService extends Service {
appKey
}
});
ctx.logger.info(`【Partner】 fetchTheme ${host + fetchInfo}?appKey=${appKey}`, ret.data);
ctx.logger.info(`【Partner】 fetchInfo ${host + fetchInfo}?appKey=${appKey}`, JSON.stringify(ret.data));
if (ret.status === 200 && ret.data && ret.data.length > 0 && ret.data[0].appKey === appKey) {
await this.app.redis.set(redisInfoPrefix + appKey, JSON.stringify(ret.data[0]), 'EX', 300);
}
......@@ -91,7 +91,7 @@ class PartnerService extends Service {
dataType: 'json',
method: 'GET',
});
ctx.logger.info(`【Partner】 fetchTheme ${url}`, JSON.stringify(ret.data));
ctx.logger.info(`【Partner】 fetchScripts ${url}`, JSON.stringify(ret.data));
if (ret.status === 200 && ret.data && ret.data.id === appKey) {
await this.app.redis.set(redisScriptsPrefix + appKey, JSON.stringify(ret.data), 'EX', 300);
}
......
......@@ -124,9 +124,10 @@ class ScriptsService extends Service {
}
async fetchCityFormIp() {
const { ctx } = this;
const { ip } = ctx.request;
ctx.logger.info(ctx.request);
const url = `https://api.map.baidu.com/location/ip?ak=3TBenWOhPygtFFazaR5kSibU&ip=${ip}`;
let { ip } = ctx.request;
ctx.logger.info('【fetchCityFormIp】ip', ip);
ip = ip.split(',');
const url = `https://api.map.baidu.com/location/ip?ak=3TBenWOhPygtFFazaR5kSibU&ip=${ip[0]}`;
const result = await ctx.curl(url, {
charset: 'utf-8',
timeout: ['30s', '30s'],
......@@ -148,7 +149,7 @@ class ScriptsService extends Service {
dataType: 'json',
contentType: 'json',
});
ctx.logger.info(`fetchScriptByCityName,${baseURL + fetchScriptByCityNameUrl + '?name=' + name}`, 'result:', result.data);
ctx.logger.info(`fetchScriptByCityName,${baseURL + fetchScriptByCityNameUrl + '?name=' + name}`, 'result:', JSON.stringify(result.data));
return result.data;
}
......
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