Exemplo n.º 1
0
 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';
 }
Exemplo n.º 2
0
 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';
 }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
 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')));
 }
Exemplo n.º 6
0
    /**
     * 输出 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);
    }
Exemplo n.º 7
0
 /**
  * 查询下线的商品
  *
  * @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);
 }