Commit e63c7c72 authored by 高诸锋's avatar 高诸锋

【fix】

parent b272b2fa
Pipeline #5755 passed with stage
in 4 seconds
......@@ -21,6 +21,30 @@ class TaskController extends Controller {
this.taskIdRule = {
taskId: { type: 'string', format: /\d+/ },
};
this.centersInfoRule = {
sign: 'string',
type: { type: 'enum', values: ['shebao'] },
params: {
type: 'object',
rule: {
token: 'string',
appKey: 'string',
timestamp: 'string',
},
},
};
this.getCityConfig = {
sign: 'string',
type: { type: 'enum', values: ['shebao'] },
params: {
type: 'object',
rule: {
token: 'string',
appKey: 'string',
timestamp: 'string',
},
},
};
}
async create() {
......@@ -142,12 +166,33 @@ class TaskController extends Controller {
});
}
async fetchCityConfig() {
async fetchCentersInfo() {
const { ctx, service } = this;
try {
ctx.validate(this.cityListRule);
ctx.validate(this.centersInfoRule);
// await service.signature.signatureCheck(ctx.request.body);
const result = await service.scripts.getCityList(ctx.request.body);
const result = await service.scripts.getCentersInfo(ctx.request.body);
ctx.body = result;
return;
} catch (err) {
ctx.status = 200;
if (err.code === 'invalid_param') {
ctx.body = { code: -1, msg: '请求参数有误' };
return;
}
if (/[a-zA-Z]+/.test(err.message)) {
ctx.body = { code: err.code || -1, msg: '系统错误, 请稍后再试' };
return;
}
ctx.body = { code: err.code || -1, msg: err.message || '' };
}
}
async fetchCityConfig() {
const { ctx, service } = this;
try {
ctx.validate(this.centersInfoRule);
const result = await service.scripts.getCityInfo(ctx.request.body);
ctx.body = result;
return;
} catch (err) {
......
......@@ -34,6 +34,7 @@ module.exports = app => {
sbRouter.post('/getToken', controller.partner.getToken); // 合作方获取token
sbRouter.post('/getOrderSn', controller.order.fetchOrderId); // 合作方获取订单号(老版H5)
sbRouter.post('/getData', controller.order.partnerShow); // 合作方获取订单数据
sbRouter.post('/getCityConfig', controller.task.fetchCityConfig); // 合作方获取城市配置
sbRouter.post('/getCentersInfo', controller.task.fetchCentersInfo); // 合作方获取社保中心配置
sbRouter.post('/getCityConfig', controller.task.fetchCityConfig); // 合作方获取社保省份和社保中心关系
sbRouter.get('/orderData/:appKey/:orderId', controller.order.orderShow); // 获取展示页面数据
};
......@@ -15,7 +15,8 @@ class ScriptsService extends Service {
this.fetchHelpUrl = scriptsAPI.fetchHelpUrl;
this.redisScriptsKey = scriptsAPI.redisScriptsKey;
this.redisParamsKey = scriptsAPI.redisParamsKey;
this.cityListUrl = scriptsAPI.cityListUrl;
this.centersInfoUrl = scriptsAPI.centersInfoUrl;
this.cityInfoUrl = scriptsAPI.cityInfoUrl;
}
async fetchScripts() {
......@@ -173,10 +174,28 @@ class ScriptsService extends Service {
return scriptList;
}
async getCityList(params) {
async getCentersInfo(params) {
try {
const { cityListUrl, ctx } = this;
const result = await ctx.curl(cityListUrl, {
const { centersInfoUrl, ctx } = this;
const result = await ctx.curl(centersInfoUrl, {
charset: 'utf-8',
timeout: ['30s', '30s'],
dataType: 'json',
contentType: 'json',
method: 'POST',
data: params,
});
return result.data;
} catch (err) {
this.ctx.logger.error(err);
return { code: -1, msg: '系统错误,请稍后重试' };
}
}
async getCityInfo(params) {
try {
const { cityInfoUrl, ctx } = this;
const result = await ctx.curl(cityInfoUrl, {
charset: 'utf-8',
timeout: ['30s', '30s'],
dataType: 'json',
......
......@@ -31,7 +31,8 @@ module.exports = () => {
fetchHelpUrl: '/chaos/hf/help',
fetchNoticeUrl: '/chaos/hf/notice',
fetchHubSeriptsUrl: '/chaos/hf/hubs',
cityListUrl: '',
centersInfoUrl: 'https://t.51gjj.com/shebao/centersInfo',
cityInfoUrl: 'https://t.51gjj.com/shebao/cityConfig',
fetchScriptByCityNameUrl: '/chaos/hf/city_scripts',
redisScriptsKey: 'DATA_SERVER_SHEBAO.SCRIPTS',
redisParamsKey: 'DATA_SERVER_SHEBAO.PARAMS',
......
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