Implemented communication with EET portal.

This commit is contained in:
2017-02-17 23:13:59 +01:00
parent fecee4d6e7
commit 9e8d69827f
13 changed files with 433 additions and 1 deletions
+62
View File
@@ -3,6 +3,11 @@
#include "isellableservice.h"
#include "shop-odb.hxx"
#include "settings/shopsettings.h"
#include <eetcpp.h>
#include <QEventLoop>
ShopService::ShopService()
{
}
@@ -101,6 +106,7 @@ void ShopService::pay(VoucherPtr voucher)
voucher->setNumSer(numSerStr);
voucher->setStatus(Voucher::PAID);
voucher->setEetStatus(Voucher::EET_FOR_SEND);
voucher->setPayDateTime(QDateTime::currentDateTime());
this->update(voucher);
@@ -119,6 +125,62 @@ void ShopService::updateRelatedItem(VoucherItem* item, int countAdded)
selSrv->addedToVoucher(item->refId(), countAdded);
}
}
void ShopService::processEet(VoucherPtr voucher)
{
if (voucher->eetStatus() == Voucher::EET_NOT_ENTERING)
{
return;
}
SettingsService srvSettings("SHOP");
ShopSettingsPtr settings = srvSettings.loadSettings<ShopSettings>();
loadSettings();
EetRequest request;
request.setCelkTrzba(voucher->totalPrice().toDouble());
request.setDatTrzby(voucher->payDateTime());
request.setIdPokl(settings->eetRegisterId());
request.setIdProvoz(settings->eetShopId());
request.setPrvniZaslani(voucher->eetStatus() == Voucher::EET_FOR_SEND);
request.setDicPopl(m_gs->dic());
request.setPoradCis(voucher->numSer());
request.setDatOdesl(QDateTime::currentDateTime());
request.setRezim((EetRequest::EetRezim)settings->eetMode());
EetSender *sender = new EetSender(this);
sender->setupSigner(settings->eetCertificate(), settings->eetKeyPassword());
sender->setPlayground(settings->eetPlayground());
QEventLoop loop;
connect(sender, &EetSender::sendFinished, [this, voucher, sender, &loop](){
Transaction tx;
if (sender->resut()->status() == EetResult::RESPONSE_OK)
{
voucher->setEetBkp(sender->resut()->bkp());
voucher->setEetPkp(sender->resut()->pkp());
voucher->setEetFik(sender->resut()->fik());
voucher->setEetSendDateTime(QDateTime::currentDateTime());
voucher->setEetStatus(Voucher::EET_SENT);
}
else
{
voucher->setEetStatus(Voucher::EET_ERROR);
}
this->update(voucher);
tx.commit();
sender->deleteLater();
loop.quit();
});
sender->sendRequest(&request);
loop.exec();
}
void ShopService::moveItems(QList<VoucherItemPtr> items, VoucherPtr source, VoucherPtr target)
{
Transaction tx;