You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1004 B
C++
43 lines
1004 B
C++
#include "commodityservice.h"
|
|
|
|
QList<QSharedPointer<IShopItem> > CommodityService::shopItems(const QString& category/* = ""*/)
|
|
{
|
|
QList<QSharedPointer<IShopItem> > ret;
|
|
|
|
foreach (QSharedPointer<CommodityData> data, all()) {
|
|
if (category.isEmpty() || (data->favorite() && data->category() == category)) {
|
|
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";
|
|
}
|