Commit eddb7e69 authored by 何娜's avatar 何娜

重新获取任务时,增加对之前订单号的判断

parent df23894f
Pipeline #5879 passed with stage
in 2 seconds
......@@ -33,23 +33,27 @@ class OrderService extends Service {
async update(params) {
const { ctx } = this;
const order = await ctx.model.TaskStatus.findOne({
const order = await ctx.model.TaskStatus.findAll({
where: { orderId: params.orderId },
order: [['createDate', 'DESC']],
});
if (!order) {
if (order.length === 0) {
ctx.throw(400, { message: 'no order' });
return;
}
const { appKey, taskId, notifyUrl, callbackUrl, userId } = order;
if (taskId) {
if (params.userId) {
await ctx.model.TaskStatus.create({ appKey, status: 'init', notifyUrl, callbackUrl, ...params })
} else {
await ctx.model.TaskStatus.create({ appKey, status: 'init', notifyUrl, callbackUrl, ...params, userId })
for (const item of order) {
if (item.status === 'success') {
ctx.throw(400, { message: 'orderId success' });
return;
}
}
const { appKey, taskId, notifyUrl, backUrl, userId } = order[0];
if (taskId) {
await ctx.model.TaskStatus.create({ appKey, status: 'init', notifyUrl, backUrl, userId, ...params })
} else {
await order.update(params);
await order[0].update(params);
}
return order;
return order[0];
}
}
......
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