|
|
@ -3,6 +3,11 @@
|
|
|
|
#include "isellableservice.h"
|
|
|
|
#include "isellableservice.h"
|
|
|
|
#include "shop-odb.hxx"
|
|
|
|
#include "shop-odb.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "settings/shopsettings.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <eetcpp.h>
|
|
|
|
|
|
|
|
#include <QEventLoop>
|
|
|
|
|
|
|
|
|
|
|
|
ShopService::ShopService()
|
|
|
|
ShopService::ShopService()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -101,6 +106,7 @@ void ShopService::pay(VoucherPtr voucher)
|
|
|
|
|
|
|
|
|
|
|
|
voucher->setNumSer(numSerStr);
|
|
|
|
voucher->setNumSer(numSerStr);
|
|
|
|
voucher->setStatus(Voucher::PAID);
|
|
|
|
voucher->setStatus(Voucher::PAID);
|
|
|
|
|
|
|
|
voucher->setEetStatus(Voucher::EET_FOR_SEND);
|
|
|
|
voucher->setPayDateTime(QDateTime::currentDateTime());
|
|
|
|
voucher->setPayDateTime(QDateTime::currentDateTime());
|
|
|
|
|
|
|
|
|
|
|
|
this->update(voucher);
|
|
|
|
this->update(voucher);
|
|
|
@ -119,6 +125,62 @@ void ShopService::updateRelatedItem(VoucherItem* item, int countAdded)
|
|
|
|
selSrv->addedToVoucher(item->refId(), 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)
|
|
|
|
void ShopService::moveItems(QList<VoucherItemPtr> items, VoucherPtr source, VoucherPtr target)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Transaction tx;
|
|
|
|
Transaction tx;
|
|
|
|