Included XML files for the "pay to new number" and "pay to old number" features in the Ozon platform.
107 lines
4.2 KiB
C
107 lines
4.2 KiB
C
#pragma once
|
|
|
|
#include <QString>
|
|
#include <QByteArray>
|
|
#include <QDateTime>
|
|
|
|
enum class TransactionType {
|
|
Card,
|
|
Phone,
|
|
Iban,
|
|
Unknown
|
|
};
|
|
|
|
enum class TransactionStatus {
|
|
Wait,
|
|
Complete,
|
|
Unknown
|
|
};
|
|
|
|
|
|
inline QString transactionTypeToString(const TransactionType type) {
|
|
switch (type) {
|
|
case TransactionType::Card: return "card";
|
|
case TransactionType::Phone: return "phone";
|
|
case TransactionType::Iban: return "iban";
|
|
default: return "unknown";
|
|
}
|
|
}
|
|
|
|
inline TransactionType transactionTypeFromString(const QString &str) {
|
|
if (str == "card") return TransactionType::Card;
|
|
if (str == "phone") return TransactionType::Phone;
|
|
if (str == "iban") return TransactionType::Iban;
|
|
return TransactionType::Unknown;
|
|
}
|
|
|
|
inline QString transactionStatusToString(const TransactionStatus type) {
|
|
switch (type) {
|
|
case TransactionStatus::Wait: return "wait";
|
|
case TransactionStatus::Complete: return "complete";
|
|
default: return "unknown";
|
|
}
|
|
}
|
|
|
|
inline TransactionStatus transactionStatusFromString(const QString &str) {
|
|
if (str == "wait") return TransactionStatus::Wait;
|
|
if (str == "complete") return TransactionStatus::Complete;
|
|
return TransactionStatus::Unknown;
|
|
}
|
|
|
|
struct TransactionInfo {
|
|
int id = -1;
|
|
int accountId = -1;
|
|
|
|
double amount = 0;
|
|
double fee = 0;
|
|
TransactionStatus status = TransactionStatus::Unknown;
|
|
TransactionType type = TransactionType::Unknown;
|
|
QString phone;
|
|
QString name;
|
|
|
|
QString description;
|
|
QString updatedDescription;
|
|
|
|
QString bankName;
|
|
QString bankTime;
|
|
|
|
QString bankTrExternalId;
|
|
|
|
QDateTime updateTime;
|
|
QDateTime completeTime;
|
|
QDateTime timestamp;
|
|
|
|
QByteArray receiptImage;
|
|
};
|
|
|
|
inline QString convertTransactionToString(const TransactionInfo &tx) {
|
|
QStringList lines;
|
|
QStringList emptyFields;
|
|
|
|
lines << "TransactionInfo {";
|
|
|
|
if (tx.id != -1) lines << " id: " + QString::number(tx.id); else emptyFields << "id";
|
|
if (tx.accountId != -1) lines << " accountId: " + QString::number(tx.accountId); else emptyFields << "accountId";
|
|
if (tx.amount != 0.0) lines << " amount: " + QString::number(tx.amount); else emptyFields << "amount";
|
|
if (tx.fee != 0.0) lines << " fee: " + QString::number(tx.fee); else emptyFields << "fee";
|
|
if (tx.status != TransactionStatus::Unknown) lines << " status: " + transactionStatusToString(tx.status); else emptyFields << "status";
|
|
if (tx.type != TransactionType::Unknown) lines << " type: " + transactionTypeToString(tx.type); else emptyFields << "type";
|
|
if (!tx.phone.isEmpty()) lines << " phone: " + tx.phone; else emptyFields << "phone";
|
|
if (!tx.description.isEmpty()) lines << " description: " + tx.description; else emptyFields << "description";
|
|
if (!tx.updatedDescription.isEmpty()) lines << " updatedDescription: " + tx.updatedDescription; else emptyFields << "updatedDescription";
|
|
if (!tx.bankName.isEmpty()) lines << " bankName: " + tx.bankName; else emptyFields << "bankName";
|
|
if (!tx.bankTime.isEmpty()) lines << " bankTime: " + tx.bankTime; else emptyFields << "bankTime";
|
|
if (!tx.name.isEmpty()) lines << " name: " + tx.name; else emptyFields << "name";
|
|
if (!tx.bankTrExternalId.isEmpty()) lines << " bankTrExternalId: " + tx.bankTrExternalId; else emptyFields << "bankTrExternalId";
|
|
if (tx.updateTime.isValid()) lines << " updateTime: " + tx.updateTime.toString(Qt::ISODate); else emptyFields << "updateTime";
|
|
if (tx.completeTime.isValid()) lines << " completeTime: " + tx.completeTime.toString(Qt::ISODate); else emptyFields << "completeTime";
|
|
if (tx.timestamp.isValid()) lines << " timestamp: " + tx.timestamp.toString(Qt::ISODate); else emptyFields << "timestamp";
|
|
|
|
if (!emptyFields.isEmpty()) {
|
|
lines << " --- empty: " + emptyFields.join(", ");
|
|
}
|
|
lines << "}";
|
|
|
|
return lines.join('\n');
|
|
}
|