Commit 5fcb95e2 authored by 姜登's avatar 姜登

notify

parent c602296a
Pipeline #8625 passed with stage
in 11 seconds
......@@ -95,27 +95,45 @@ class PartnerService extends Service {
async notice(order) {
const { ctx, service } = this;
const { orderId, notifyUrl, userId, notice } = order;
const dbRes = await service.order.getOneByOrderId({ orderId, notice: 1 });
if (!dbRes && notifyUrl && notice !== '1') {
const ret = await ctx.curl(notifyUrl, {
charset: 'utf-8',
timeout: [30000, 30000],
contentType: 'json',
method: 'POST',
data: {
order_id: orderId,
user_id: userId || '',
status: 'success',
},
}
);
ctx.logger.info(`【Partner】 notice ${notifyUrl}`, 'orderId:', orderId, 'result:', ret.status, JSON.stringify(ret.data));
if (ret.status === 200) {
await order.update({ notice: '1' });
try {
const { orderId, notifyUrl, userId, notice, appKey } = order;
const dbRes = await service.order.getOneByOrderId({ orderId, notice: 1 });
if (!dbRes && notifyUrl && notice !== '1') {
const ret = await ctx.curl(notifyUrl, {
charset: 'utf-8',
timeout: [30000, 30000],
contentType: 'json',
method: 'POST',
data: {
order_id: orderId,
user_id: userId || '',
status: 'success',
},
});
if ((appKey === '2A1B338EA5DC489BBFFBCBB4708EF875' || appKey === '99C5C908336048EBBE3AC95F65AC9FEC' || appKey === 'E0191124612C4CD3ACC82867EA6AB7CE') && ctx.app.notifyMap && ctx.app.notifyMap.get(appKey)) {
const secondNotifyUrl = ctx.app.notifyMap.get(appKey).notifyUrl;
const appRet = await ctx.curl(secondNotifyUrl, {
charset: 'utf-8',
timeout: [30000, 30000],
contentType: 'json',
method: 'POST',
data: {
order_id: orderId,
user_id: userId || '',
status: 'success',
},
});
ctx.logger.info(`【Partner】 APPnotice ${secondNotifyUrl}`, 'orderId:', orderId, 'result:', appRet.status, JSON.stringify(appRet.data));
}
ctx.logger.info(`【Partner】 notice ${notifyUrl}`, 'orderId:', orderId, 'result:', ret.status, JSON.stringify(ret.data));
if (ret.status === 200) {
await order.update({ notice: '1' });
}
} else {
ctx.logger.info('【Partner】 notice no send', 'orderId:', orderId);
}
} else {
ctx.logger.info('【Partner】 notice no send', 'orderId:', orderId);
} catch (err) {
ctx.logger.warn('【Partner】 notice error', JSON.stringify(order), JSON.stringify(err));
}
return;
}
......
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