service->owned( $id, $user_id )['resource_id']; $this->bookings->customerTransaction($id, [ $resource_id ], function () use ( $id, $user_id, $resource_id ): void { $b = $this->service->lockOwned( $id, $user_id, [ $resource_id ] ); if ( 'confirmed' !== $b['status'] || Time::fromSql( $b['starts_at'] ) > time() ) { throw new CatalogException( 'abece_booking_no_show_unavailable', __( 'Only a confirmed booking that has started can be marked as no-show.', 'abece-booking' ), 409 ); } $stamp = current_time( 'mysql', true ); $calculation = CancellationPolicyService::noShow( $b, $user_id ); $this->bookings->update( $id, [ 'no_show_fee' => $calculation['calculated_fee'], 'no_show_snapshot' => wp_json_encode( $calculation ), 'status' => 'no_show', 'no_show_at' => $stamp, 'no_show_by_user_id' => $user_id, 'updated_at' => $stamp ] ); $calculation['settled'] = $this->service->payments->settle( $this->bookings->find( $id ), $user_id ); $this->service->recordHistory( $id, 'no_show', 'confirmed', 'no_show', $user_id, $stamp, null, $calculation ); } ); $this->mailer->send( $this->bookings->find( $id ), 'no_show' ); return $this->service->detail( $id, $user_id ); } }