Initial commit

This commit is contained in:
user
2026-07-12 14:34:52 +04:00
commit 3abf6bd9c2
557 changed files with 68706 additions and 0 deletions
+76
View File
@@ -0,0 +1,76 @@
#ifndef REFUND_GENERATOR_H
#define REFUND_GENERATOR_H
#include "base_generator.h"
#include "date_time_generator.h"
#include <QDateTime>
#include <QRandomGenerator>
#include <QString>
// Forward declaration
class RefundsRepository;
class SessionsRepository;
class TicketsRepository;
class RefundGenerator : public BaseGenerator, public DateTimeGenerator {
private:
struct ReservationContext {
QDateTime beginAt;
QDateTime refundAt;
QDateTime soldAt;
double refundAmount;
qint32 ticketId;
};
struct CacheValue {
QDateTime beginAt;
QDateTime soldAt;
double ticketPrice;
};
private:
QMap<qint32 /* ticketId */, CacheValue> // WARNING: There can be a lot
ticketIdToCacheValue_; // of records, so 1 QPair is used, not 3 QMap
QPair<double, double> refundRatioRange_;
ReservationContext reservationContext_;
qsizetype remainingCapacity_;
RefundsRepository *refundsRepository_;
SessionsRepository *sessionsRepository_;
TicketsRepository *ticketsRepository_;
public:
RefundGenerator(const QPair<double, double> &refundRatioRange,
const QPair<qint64, qint64> &dayRange,
const QPair<QTime, QTime> &timeRange);
private:
void initializeRepositories();
void initializeTicketIdToCacheValueMap();
inline void initializeRemainingCapacity();
private:
inline qint64 calculateDurationMs(const CacheValue &cacheValue) const;
// Vitual methods
private: // Const methods
QString createFailureMessage(const QString &errorMessage) const override;
QString createSuccessMessage() const override;
qsizetype calculateRemainingCapacity() const override;
private: // Non-const methods
RepositoryResult createRecord() override;
bool prepareData() override;
void clearStaleData() override;
};
void RefundGenerator::initializeRemainingCapacity() {
remainingCapacity_ = ticketIdToCacheValue_.size();
}
qint64
RefundGenerator::calculateDurationMs(const CacheValue &cacheValue) const {
return cacheValue.soldAt.msecsTo(cacheValue.beginAt);
}
#endif