Authored by Rock Zhang

添加筛选数据处理model

  1 +<?php
  2 +
  3 +namespace Product;
  4 +
  5 +use Configs\CacheConfig;
  6 +use LibModels\Wap\Product\SearchData;
  7 +use LibModels\Wap\Category\BrandData;
  8 +use LibModels\Wap\Category\ClassData;
  9 +use Plugin\DataProcess\ListProcess;
  10 +
  11 +/**
  12 + * 搜索相关的模板数据模型
  13 + *
  14 + * @name Filter
  15 + * @package Product
  16 + * @copyright yoho.inc
  17 + * @version 1.0 (2015-11-1 17:35:52)
  18 + */
  19 +class FilterModel
  20 +{
  21 +
  22 + /**
  23 + * 获取筛选的数据
  24 + *
  25 + * @param array $condition 查询条件
  26 + * @return array
  27 + */
  28 + public static function getFilterData($condition)
  29 + {
  30 + $result = array();
  31 +
  32 + // 区别各种列表页面的筛选数据
  33 + if (isset($condition['brand'])) {
  34 + $listData = BrandData::filterBrandData($condition);
  35 + } else if(isset($condition['sort'])) {
  36 + $listData = ClassData::filterClassData($condition);
  37 + } else {
  38 + $listData = SearchData::searchByCondition($condition);
  39 + }
  40 +
  41 + if (isset($listData['data']) && isset($listData['data']['filter'])) {
  42 + $result['filter'] = ListProcess::getFilterData($listData['data']['filter']);
  43 + }
  44 +
  45 + return $result;
  46 + }
  47 +
  48 +}