Sale.php 2.05 KB
<?php

namespace Product;

use Api\Yohobuy;
use Plugin\HelperSearch;
use Plugin\Images;
/**
 * sale首页模板数据模型
 *
 */
class SaleModel 
{

    public static function getSaleSearchData($customCondition, $customOptions, $specialInfo) 
    {
        $urlList = array();
        
        //获取$condition和$option 筛选条件和排序条件
        $searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
        
        // 组合搜索商品url
        $urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
        
        // 组合搜索分类url
        $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
        
        //组合用户浏览记录url
        //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
        
        //批量调接口
        $result = Yohobuy::getMulti($urlList, array(), true);
        
        //组织模板数据格式
        $data = HelperSearch::getList($result, $searchCondition['options']);
        
        //组织sale数据
        if (isset($specialInfo['data']) && !empty($specialInfo['data']['banner_img'])) {
            $banner = json_decode($specialInfo['data']['banner_img'], true);
            foreach ($banner as $k => $v) {
                $v['img'] = Images::getSourceUrl($v['img'], 'couponImg');
                $specialInfo['data']['banner'][] = $v;
            }
             $special = $specialInfo['data'];
        }
        //Sale首页 banner数据
        $data['saleBanner']['bannerHeight'] = $special['banner'][0]['height'];
        $data['saleBanner']['img'] = $special['banner'][0]['img'];
        $data['saleTitle']['name'] = '全部商品';
        $data['saleTitle']['count'] = $data['totalCount'];
        
         //获取广告位数据
        if (isset($special['left_ad_code'])) {
            $nodeContent = HelperSearch::formatNodeContent($special['left_ad_code']);
            $data['leftContent'][]['picLink']['list'] = $nodeContent;
        }
        
        return $data;
    }

}