mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 06:00:55 +00:00
automate the schedule
This commit is contained in:
@@ -12,7 +12,7 @@ import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as Handlebars from "handlebars";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { SchedulingStatus } from "@edr/types";
|
||||
// import { SchedulingStatus } from "@edr/types";
|
||||
import { Booking } from "../bookings/entities/booking.entity";
|
||||
|
||||
import {
|
||||
@@ -125,7 +125,13 @@ export class PaymentService {
|
||||
|
||||
if (result.status === ProviderPaymentStatus.SUCCEEDED) {
|
||||
await this.datasource.transaction(async (mg) => {
|
||||
await mg.update(Booking, { id: resp.refId }, { status: "PAID" })
|
||||
const booking = await mg.findOne(Booking, { where: { id: resp.refId } })
|
||||
if (booking?.status === "AWAITING_PAYMENT") {
|
||||
// Batch flow: mark paid but keep the reservation — the batch settle job allocates it.
|
||||
await mg.update(Booking, { id: resp.refId }, { paymentStatus: "PAID" })
|
||||
} else {
|
||||
await mg.update(Booking, { id: resp.refId }, { status: "PAID" })
|
||||
}
|
||||
await mg.update(PaymentEntity, { id: resp.id }, { status: "success" })
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user