#pragma once #include "ShopItemObject.h" #include "ProductInfo.h" namespace ConvenienceStore { class ProductItem : public ShopItemObject { public: static ProductItem* CreateProduct( ProductItem* pProductItem ); static ProductItem* CreateProduct( CShopCategory* shop_category_ptr_, CShopPackage* shop_package_ptr_, eCHAR_TYPE char_type); private: CShopCategory* shop_category_ptr_; CShopPackage* shop_package_ptr_; IconImage* package_image_ptr_; std::vector product_info_array_; Define::ShopProductType product_item_type_; protected: ProductItem(); ProductItem(CShopCategory* shop_category, CShopPackage* shop_package); public: ProductItem( ProductItem* form_ptr ); virtual ~ProductItem(); virtual LPCTSTR GetName() { return shop_package_ptr_->PackageProductName; } virtual ShopItemObjectType GetObjectType() { return OBJECT_TYPE_PRODUCT; } virtual IconImage* GetIconImage() { return package_image_ptr_; } virtual bool is_equl(const ProductItem* product) const { return (this == product); } virtual bool is_package(); //!StartDate; } virtual tm& GetEndDate() { return shop_package_ptr_->EndDate; } LPCTSTR GetDescription() { return shop_package_ptr_->Description; } int GetDisplaySequence() { return shop_category_ptr_->ProductDisplaySeq; } int GetPackageSequence() { return shop_package_ptr_->PackageProductSeq; } LPCTSTR GetCautionText() { return shop_package_ptr_->Caution; } public: bool IsWasteItem() { return product_item_type_ == Define::kShopProduct_Waste; } // 消耗性 bool IsInfiniteItem() { return product_item_type_ == Define::kShopProduct_Infinite; }// 永久性 bool IsDateItem() { return product_item_type_ == Define::kShopProduct_Date; } //期限 public: static bool SortProductByDateInc(ProductItem*& ref_left, ProductItem*& ref_right); static bool SortProductByDateDesc(ProductItem*& ref_left, ProductItem*& ref_right); static bool SortProductByPriceInc(ProductItem*& ref_left, ProductItem*& ref_right); static bool SortProductByPriceDesc(ProductItem*& ref_left, ProductItem*& ref_right); static bool SortProductByNameInc(ProductItem*& ref_left, ProductItem*& ref_right); static bool SortProductByNameDesc(ProductItem*& ref_left, ProductItem*& ref_right); size_t GetProductCount() { return shop_package_ptr_->GetProductCount(); } std::vector& GetInfoVector() { return product_info_array_; } CShopCategory* GetShopCategory() const { return shop_category_ptr_; } CShopPackage* GetShopPackage() const { return shop_package_ptr_; } }; }