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