feat: add cleanup logic for unpaid and inactive orders in whIntentSucceededHandler
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
0f335365ef
commit
3939d78039
1 changed files with 10 additions and 0 deletions
|
|
@ -100,6 +100,16 @@ export const whIntentSucceededHandler = async ({
|
|||
userId: ordine.userid,
|
||||
});
|
||||
|
||||
// cleanup ordini non pagati e non attivi per lo stesso utente, stesso tipo e servizio (es. se paga acconto, cancellare altri ordini acconto non pagati)
|
||||
await trx
|
||||
.deleteFrom("ordini")
|
||||
.where("userid", "=", ordine.userid)
|
||||
.where("isActive", "=", false)
|
||||
.where("paymentstatus", "!=", paymentStatusEnum.enum.success)
|
||||
.where("type", "=", ordine.type)
|
||||
.where("servizio_id", "=", ordine.servizio_id)
|
||||
.execute();
|
||||
|
||||
const lock_expires = add(new Date(), { seconds: 30 }); // Lock for 30 sec
|
||||
|
||||
switch (ordine.type) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue