Commit 2c5e3cdc authored by 何娜's avatar 何娜

taxAPI 修改接口返回结构+帮助信息fix

parent b07faeb2
Pipeline #6958 passed with stage
in 3 seconds
......@@ -100,8 +100,7 @@ class OrderController extends Controller {
code: 0,
data: {
orderSn: orderId
},
msg: ''
}
}
} catch (err) {
ctx.logger.error('fetchOrderId', err);
......@@ -119,24 +118,31 @@ class OrderController extends Controller {
const { cityId } = ctx.params;
const cityName = await await service.scripts.fetchScriptName(cityId);
const helpData = await service.scripts.fetchHelp(cityId);
let helpInfo = [];
for(let item of helpData[0].help_list){
helpInfo.push({
desc: item.content,
link: {
label: item.button_name,
url: item.button_url,
},
})
}
ctx.success({
code: "0",
data: {
cityId,
city: cityName,
help: helpInfo
if(helpData && helpData.length > 0){
let helpInfo = [];
for(let item of helpData[0].help_list){
helpInfo.push({
desc: item.content,
link: {
label: item.button_name,
url: item.button_url,
},
})
}
ctx.success({
code: "0",
data: {
cityId,
city: cityName,
help: helpInfo
}
});
}else{
return ctx.body = {
code: "-1",
msg: "未查询到此地区帮助信息"
}
});
}
}
}
......
......@@ -25,8 +25,7 @@ class TokenController extends Controller {
const token = await service.signature.createToken(ctx.request.body);
return ctx.body = {
code: 0,
data: { token },
msg: ''
data: { token }
}
} catch (err) {
ctx.logger.error('partnerCreate', err);
......
......@@ -9,6 +9,37 @@ class PartnerService extends Service {
this.partnerAPI = partnerAPI;
}
async fetchInfo(appKey){
const { ctx, partnerAPI: { fetchInfo, host, redisInfoPrefix } } = this;
if (appKey) {
const data = await this.app.redis.get(redisInfoPrefix + appKey);
ctx.logger.info('【Scripts】fetchInfo redis data', redisInfoPrefix + appKey, 'result:', data);
if (data) {
try {
return JSON.parse(data);
} catch (err) {
ctx.logger.info('【Scripts】fetchInfo redis err', redisInfoPrefix + appKey, 'result:', data, err);
await this.app.redis.del(redisInfoPrefix + appKey);
}
}
}
const ret = await ctx.curl(`${host + fetchInfo}`, {
charset: 'utf-8',
timeout: ['30s', '30s'],
dataType: 'json',
method: 'GET',
data: {
appKey
}
});
ctx.logger.info(`【Partner】 fetchTheme ${host + fetchInfo}?appKey=${appKey}`, 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);
}
return ret.data[0];
}
async notice(order) {
const { ctx } = this;
const { orderId, notifyUrl, notice } = order;
......
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