#include "shopservice.h" ShopService::ShopService() { } QSharedPointer ShopService::createVoucher() { QSharedPointer voucher(new Voucher); voucher->setStatus(Voucher::NEW); return voucher; } void ShopService::addShopItem(QSharedPointer voucher, QSharedPointer item, int count) { QSharedPointer vItem(new VoucherItem); vItem->setName(item->name()); vItem->setUnitPrice(item->unitPrice()); vItem->setCount(count); vItem->setRefId(item->id()); vItem->setItemPlugin(item->pluginId()); voucher->addItem(vItem); } void ShopService::calculate(QSharedPointer voucher) { QDecDouble total; foreach (QSharedPointer item, voucher->items()) { QDecDouble itemPrice = item->unitPrice() * item->count(); total += itemPrice; } voucher->setTotalPrice(total); }