Added handling for event types (Balance, Phone) and respective processing logic in EventHandler. Introduced support for tracking and updating event statuses both locally and through network APIs. Enhanced data integrity and clarity by expanding the EventInfo model and associated database management.
76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
#pragma once
|
|
|
|
#include <QString>
|
|
#include <QDateTime>
|
|
|
|
enum class EventStatus {
|
|
Wait,
|
|
InProgress,
|
|
Complete,
|
|
Error,
|
|
Unknown
|
|
};
|
|
|
|
enum class EventType {
|
|
Phone,
|
|
Card,
|
|
Balance,
|
|
History,
|
|
Unknown
|
|
};
|
|
|
|
|
|
inline QString eventStatusToString(const EventStatus status) {
|
|
switch (status) {
|
|
case EventStatus::Wait: return "wait";
|
|
case EventStatus::Error: return "error";
|
|
case EventStatus::Complete: return "complete";
|
|
case EventStatus::InProgress: return "iPprogress";
|
|
default: return "unknown";
|
|
}
|
|
}
|
|
|
|
inline EventStatus eventStatusFromString(const QString &str) {
|
|
if (str == "error") return EventStatus::Error;
|
|
if (str == "wait") return EventStatus::Wait;
|
|
if (str == "complete") return EventStatus::Complete;
|
|
if (str == "iPprogress") return EventStatus::InProgress;
|
|
return EventStatus::Unknown;
|
|
}
|
|
|
|
inline QString eventTypeToString(const EventType type) {
|
|
switch (type) {
|
|
case EventType::Phone: return "phone";
|
|
case EventType::Card: return "card";
|
|
case EventType::Balance: return "balance";
|
|
case EventType::History: return "history";
|
|
default: return "unknown";
|
|
}
|
|
}
|
|
|
|
inline EventType eventTypeFromString(const QString &str) {
|
|
if (str == "phone") return EventType::Phone;
|
|
if (str == "card") return EventType::Card;
|
|
if (str == "balance") return EventType::Balance;
|
|
if (str == "history") return EventType::History;
|
|
return EventType::Unknown;
|
|
}
|
|
|
|
struct EventInfo {
|
|
int id = -1;
|
|
int externalId = -1;
|
|
int accountId = -1;
|
|
QString deviceId;
|
|
|
|
double amount = 0;
|
|
QString phone;
|
|
QString bankName;
|
|
QString comment;
|
|
|
|
EventStatus status = EventStatus::Unknown;
|
|
EventType type = EventType::Unknown;
|
|
|
|
QDateTime updateTime;
|
|
QDateTime completeTime;
|
|
QDateTime timestamp;
|
|
}; |