Commit f2ca4b8e authored by 姜登's avatar 姜登

兼容老版nofity

parent c80f5038
Pipeline #4003 passed with stage
in 9 minutes 20 seconds
......@@ -41,7 +41,7 @@ class OrderController extends Controller {
taskId: '',
userId: userId,
cityId: '',
notifyUrl: notifyUrl || '',
notifyUrl: notifyUrl || (ctx.app.notifyMap.get(appKey) && ctx.app.notifyMap.get(appKey).notifyUrl) || '',
backUrl: backUrl || '',
appKey: appKey,
status: 'init',
......
......@@ -6,7 +6,7 @@
module.exports = app => {
const { router, controller } = app;
const gjjRouter = app.router.namespace(app.config.projectRootPath);
const gjjRouter = router.namespace(app.config.projectRootPath);
gjjRouter.post('/tasks', controller.task.create); // 创建任务
gjjRouter.get('/tasks/:taskId', controller.task.show); // 获取任务状态
gjjRouter.post('/tasks/:taskId/submit', controller.task.submit); // 提交任务参数
......@@ -35,7 +35,9 @@ module.exports = app => {
gjjRouter.post('/getToken', controller.token.partnerCreate);// 合作方创建token
gjjRouter.post('/getData', controller.order.partnerShow);// 合作方获取订单数据
// gjjRouter.post('/getorderSn');
gjjRouter.post('/getData', controller.order.partnerShow);// 合作方获取订单数据
gjjRouter.post('/getCityConfig', controller.task.fetchCityConfig)//获取城市配置
......
......@@ -19,5 +19,5 @@ module.exports = {
} catch (e) {
ctx.logger.error('【schedule/flash_cus_pro】catch error:', JSON.stringify(e));
}
},
}
};
const Subscription = require('egg').Subscription;
class UpdateCache extends Subscription {
// 通过 schedule 属性来设置定时任务的执行间隔等配置
static get schedule() {
return {
interval: '5m', // 5分钟间隔
type: 'all', // 所有woker
immediate: true,
};
}
// subscribe 是真正定时任务执行时被运行的函数
async subscribe() {
try {
const { ctx } = this;
const { host, customerUrl } = ctx.app.config.signatureAPI;
const notifyMap = new Map();
const ret = await ctx.curl(host + customerUrl, {
charset: 'utf-8',
timeout: ['30s', '30s'],
dataType: 'json',
contentType: 'json',
});
// ctx.logger.info(JSON.stringify(ret.data));
if (ret.data.code == '0') {
ret.data.data.customerList.map(customer => {
if ('callBackUrl' in customer) {
notifyMap.set(customer.appKey, { notifyUrl: customer.callBackUrl });
}
});
ctx.app.notifyMap = notifyMap;
}
} catch (e) {
this.ctx.logger.error('【schedule/notifyUrlTask】catch error:', JSON.stringify(e));
}
}
}
module.exports = UpdateCache;
\ No newline at end of file
......@@ -68,6 +68,7 @@ module.exports = () => {
signatureUrl: '/Access/SignValidityCheck',
fetchParnterUrl: '',
signatureType: 'gjj',
customerUrl:'/customer/query',
};
config.lockKeys = {
......
......@@ -33,7 +33,7 @@
"start": "egg-scripts start --daemon --title=egg-server-hf_h5_server",
"stop": "egg-scripts stop --title=egg-server-hf_h5_server",
"docker": "eggctl start --title=egg-server-hf_h5_serverr",
"dev": "egg-bin dev --workers=4",
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "egg-bin test",
......
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