|
|
|
#include "commodityservice.h"
|
|
|
|
|
|
|
|
QList<QSharedPointer<IShopItem> > CommodityService::shopItems()
|
|
|
|
{
|
|
|
|
QList<QSharedPointer<IShopItem> > ret;
|
|
|
|
|
|
|
|
foreach (QSharedPointer<CommodityData> data, all()) {
|
|
|
|
ret.append(qSharedPointerDynamicCast<IShopItem, CommodityData>(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CommodityService::addedToVoucher(int itemId, int countAdded)
|
|
|
|
{
|
|
|
|
QSharedPointer<CommodityData> commodity = loadById(itemId);
|
|
|
|
|
|
|
|
if (!commodity.isNull())
|
|
|
|
{
|
|
|
|
commodity->setCount(commodity->count() - countAdded);
|
|
|
|
}
|
|
|
|
|
|
|
|
update(commodity);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShopItemPtr CommodityService::shopItem(int itemId)
|
|
|
|
{
|
|
|
|
CommodityDataPtr item = this->loadById(itemId);
|
|
|
|
return qSharedPointerDynamicCast<IShopItem, CommodityData>(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISeller *CommodityService::seller()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CommodityService::defaultSort()
|
|
|
|
{
|
|
|
|
return "name";
|
|
|
|
}
|