public function __construct() { $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); // 我们只搜索有效商品 $this->searchExtraCondArray = array(array('is_delete = 0 AND is_on_sale = 1 AND is_alone_sale = 1'), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))); // 选择我们需要的字段 $this->searchFieldSelector = 'goods_id, cat_id, goods_sn, goods_name, brand_id, goods_number, market_price, shop_price, suppliers_id,' . 'virtual_buy_number, user_buy_number, user_pay_number, (virtual_buy_number + user_pay_number) as total_buy_number'; }
public function __construct() { $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); // 我们只搜索有效商品 $this->searchExtraCondArray = array(array('is_delete = 0 AND is_on_sale = 1 AND is_alone_sale = 1'), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))); // 选择我们需要的字段 $this->searchFieldSelector = 'goods_id, goods_name, market_price, shop_price'; }
public function get($f3) { global $smarty; $smartyCacheId = 'EtaoFeed|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '_\\' . __METHOD__); // 判断是否有缓存 enableSmartyCache(true, 1200); // 缓存 20 分钟 if ($smarty->isCached('empty.tpl', $smartyCacheId)) { goto out_display; } $currentStamp = Time::localTimeStr(); $sellerId = EtaoFeedPlugin::getOptionValue('etaofeed_seller_id'); $categoryUrl = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Category', null, false, true); $itemDir = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Item', null, false, true); $itemIdXmlList = ''; // 处理 delete 的商品 $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 0'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray())))); if ($totalGoodsCount <= 0) { goto query_update_goods; } $totalPageCount = ceil($totalGoodsCount / Item::$pageSize); for ($index = 0; $index < $totalPageCount; $index++) { $itemIdXmlList .= '<outer_id action="delete">1' . $index . '</outer_id>'; } query_update_goods: // 处理修改过的商品 $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 1'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray())))); if ($totalGoodsCount <= 0) { goto out_output; } $totalPageCount = ceil($totalGoodsCount / Item::$pageSize); for ($index = 0; $index < $totalPageCount; $index++) { $itemIdXmlList .= '<outer_id action="upload">2' . $index . '</outer_id>'; } out_output: $apiXml = <<<XML <?xml version="1.0" encoding="utf-8" ?> <root> <version>1.0</version> <modified>{$currentStamp}</modified> <seller_id>{$sellerId}</seller_id> <cat_url>{$categoryUrl}</cat_url> <dir>{$itemDir}/</dir> <item_ids>{$itemIdXmlList}</item_ids> </root> XML; $smarty->assign('outputContent', $apiXml); // 更新查询时间 //EtaoFeedPlugin::saveOptionValue('etaofeed_query_timestamp', Time::gmTime()); out_display: header('Content-Type:text/xml;charset=utf-8'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 //查询信息 $smarty->display('empty.tpl', $smartyCacheId); }
public function get($f3) { global $smarty; $cacheTime = 300; // 缓存5分钟 enableSmartyCache(true, $cacheTime); $smartyCacheId = 'Api|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); // 判断是否有缓存 if ($smarty->isCached('empty.tpl', $smartyCacheId)) { goto out_display; } // 查询商品 $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); $condArray = array(array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))); $apiGoodsService = new ApiGoodsService(); $goodsGalleryPromoteArray = $apiGoodsService->fetchGoodsGalleryPromote($condArray, 'aimeidaren_sort_order desc, sort_order desc, goods_id desc', 0, 0, $cacheTime); // 商品和图片 $goodsArray = $goodsGalleryPromoteArray['goods']; $goodsIdToGalleryArray = $goodsGalleryPromoteArray['goodsIdToGalleryArray']; $xmlItems = ''; $goodsArrayCount = count($goodsArray); for ($index = 0; $index < $goodsArrayCount; $index++) { $xmlItems .= $this->getGoodsItemXml($index + 1, $goodsArray[$index], $goodsIdToGalleryArray); } $apiXml = <<<XML <?xml version="1.0" encoding="utf-8" ?> <urlset> \t{$xmlItems} </urlset> XML; unset($xmlItems); $smarty->assign('outputContent', $apiXml); out_display: header('Content-Type:text/xml;charset=utf-8'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 //查询信息 $smarty->display('empty.tpl', $smartyCacheId); }
public function __construct() { $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); // 我们只搜索有效商品 $this->searchExtraCondArray = array(array('g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1'), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray(), 'g'))); }
/** * 输出 sitemapIndex 文件 */ public function outputSiteMapXml($f3, $fileName) { global $smarty; //缓存 60 分钟 enableSmartyCache(true, 3600, \Smarty::CACHING_LIFETIME_CURRENT); $smartyCacheId = 'Api|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); // 判断是否有缓存 if ($smarty->isCached('empty.tpl', $smartyCacheId)) { goto out_display; } // sitemap 列表 $siteMapFileList = ''; // 当前时间 $currentTime = time(); /***************** 生成 /Goods/View 列表 *******************/ // 查询商品数量,决定分页有多少页 $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray(), 'g')))); $pageCount = ceil($totalGoodsCount / $this->pageSize); // 取得当前的目录路径 $currentUrl = RouteHelper::getFullURL(); $currentUrl = substr($currentUrl, 0, strrpos($currentUrl, $fileName)); // 生成 goods 页面索引 for ($index = 0; $index < $pageCount; $index++) { $siteMapFileList .= '<sitemap><loc>' . $currentUrl . 'GoodsView_' . $currentTime . '_' . $index . '.xml</loc></sitemap>'; } /***************** 生成 /Goods/Search 列表 *******************/ // 生成 search 页面索引 $siteMapFileList .= '<sitemap><loc>' . $currentUrl . 'GoodsSearch_' . $currentTime . '_0.xml</loc></sitemap>'; /***************** 生成 /Article/View 列表 *******************/ // 查询商品数量,决定分页有多少页 $totalArticleCount = SearchHelper::count(SearchHelper::Module_Article, QueryBuilder::buildSearchParamArray(array('a.is_open' => 1))); $pageCount = ceil($totalArticleCount / $this->pageSize); // 生成 Article 页面索引 for ($index = 0; $index < $pageCount; $index++) { $siteMapFileList .= '<sitemap><loc>' . $currentUrl . 'ArticleView_' . $currentTime . '_' . $index . '.xml</loc></sitemap>'; } $apiXml = <<<XML <?xml version="1.0" encoding="utf-8" ?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> {$siteMapFileList} </sitemapindex> XML; $smarty->assign('outputContent', $apiXml); out_display: header('Content-Type:text/xml;charset=utf-8'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 //查询信息 $smarty->display('empty.tpl', $smartyCacheId); }
public function execute($cartInstance) { // 使用引用取得内部数据,方便操作 $cartContext =& $cartInstance->getCartContextRef(); if ($cartContext->isEmpty()) { // 没有数据,不需要计算 goto out_fail; } // 当前主题允许哪些系统的商品被加入到购物车 $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); $goodsFilterSystemArray = $currentThemeInstance->getGoodsFilterSystemArray(); // 从购物车中删除掉的 OrderGoods $removeOrderGoods = array(); // 对每个商品做检查 foreach ($cartContext->orderGoodsArray as &$orderGoodsItem) { // 商品已经下线了,不能购买 $goodsInfo = $orderGoodsItem->goods; if (empty($goodsInfo) || !$goodsInfo['is_on_sale']) { $removeOrderGoods[] = array($goodsInfo['goods_id'], null); $cartContext->addErrorMessage('商品 [' . $goodsInfo['goods_id'] . '] 已经下线'); continue; } $goodsAttr = $orderGoodsItem->getValue('goods_attr'); // 有规格的商品,用户必须做出选择 if (!empty($goodsInfo['goods_spec']) && empty($goodsAttr)) { $cartContext->addErrorMessage('商品 [' . $goodsInfo['goods_id'] . '] 必须选择规格'); $removeOrderGoods[] = array($goodsInfo['goods_id'], null); continue; } // 检查商品库存 if (!empty($goodsAttr)) { // 商品有规格选择 if (empty($goodsInfo['goods_spec'])) { $cartContext->addErrorMessage('商品 [' . $goodsInfo['goods_id'] . '|' . $goodsAttr . '] 选择非法'); $removeOrderGoods[] = array($goodsInfo['goods_id'], $goodsAttr); continue; } // 检查规格是否合法 $goodsSpecService = new GoodsSpecService(); $goodsSpecService->initWithJson($goodsInfo['goods_spec']); $goodsSpecDataArray = $goodsSpecService->getGoodsSpecDataArray($goodsAttr); if (empty($goodsSpecDataArray)) { $cartContext->addErrorMessage('商品 [' . $goodsInfo['goods_id'] . '|' . $goodsAttr . '] 选择非法'); $removeOrderGoods[] = array($goodsInfo['goods_id'], $goodsAttr); continue; } // 检查规格对应的库存 if ($orderGoodsItem->getValue('goods_number') > @$goodsSpecDataArray['goods_number']) { $cartContext->addErrorMessage('商品 [' . $goodsInfo['goods_id'] . '|' . $goodsAttr . '] 库存不足'); $removeOrderGoods[] = array($goodsInfo['goods_id'], $goodsAttr); continue; } } else { // 简单商品,没有规格,检查库存 if ($orderGoodsItem->getValue('goods_number') > $goodsInfo['goods_number']) { $cartContext->addErrorMessage('商品 [' . $goodsInfo['goods_id'] . '] 库存不足'); $removeOrderGoods[] = array($goodsInfo['goods_id'], null); continue; } } // 商品不属于当前系统,不能购买 $goodsSystemArray = Utils::parseTagString($goodsInfo['system_tag_list']); $intersectSystem = array_intersect($goodsSystemArray, $goodsFilterSystemArray); if (empty($intersectSystem)) { $removeOrderGoods[] = array($goodsInfo['goods_id'], null); continue; } } unset($orderGoodsItem); // 删除不合格的 orderGoods 记录 foreach ($removeOrderGoods as $removeItem) { $cartContext->removeGoods($removeItem[0], $removeItem[1]); $cartContext->addErrorMessage('商品 [' . $removeItem[0] . '] 不能购买,移除'); } return true; out_fail: return false; // 返回 false,后面的 pipeline 就不会被执行了 }
public function __construct() { $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); // 我们只搜索特定的系统的订单 $this->searchExtraCondArray = array(array(QueryBuilder::buildOrderFilterForSystem($currentThemeInstance->getOrderFilterSystemArray()))); }
/** * 查询下线的商品 * * @param $pageNo * * @return mixed */ private function queryDeleteGoods($pageNo) { $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); return SearchHelper::search(SearchHelper::Module_Goods, $this->fieldSelector, array(array('is_on_sale = 0'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))), array(array('g.goods_id', 'desc')), $pageNo * self::$pageSize, self::$pageSize); }
private function verifyOrderSystem($orderInfo) { $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); return in_array($orderInfo['system_id'], $currentThemeInstance->getOrderFilterSystemArray()); }