public function goods_filter(&$filter, &$object) { if (!$filter['goods_id']) { $filter['goods_id'] = array(); } if (!is_array($filter['goods_id'])) { $filter['goods_id'] = (array) $filter['goods_id']; } if (count($filter['goods_id'])) { return $filter; //有goods_id filter 时,不折腾 } $filter = utils::addslashes_array($filter); //拦截货品相关filter $filter = $this->fix_product_filter($filter, $object); //子类、扩展分类商品 $filter = $this->_cat_merge($filter, $object); //关键词搜 if ($filter['keyword']) { $keyword = $filter['keyword']; foreach ($object->app->model('goods_keywords')->getList('goods_id', array('keyword|has' => $filter['keyword'])) as $item) { array_push($filter['goods_id'], $item['goods_id']); } $goods_select_sql = 'SELECT goods_id FROM ' . $object->table_name(1) . ' WHERE name LIKE "%' . $keyword . '%" OR brief LIKE "%' . $keyword . '%"'; foreach ($object->db->select($goods_select_sql) as $item) { array_push($filter['goods_id'], $item['goods_id']); } unset($filter['keyword']); if (empty($filter['goods_id'])) { $filter['intro|has'] = $keyword; } } if ($filter['product_filter']) { foreach ($object->app->model('products')->getList('goods_id', $filter['product_filter']) as $item) { array_push($filter['goods_id'], $item['goods_id']); } unset($filter['product_filter']); } if ($filter['name']) { $filter['name|has'] = $filter['name']; unset($filter['name']); } if (!$filter['goods_type']) { $filter['goods_type'] = 'normal'; } if (is_array($filter['goods_id'])) { $filter['goods_id'] = array_unique($filter['goods_id']); } foreach ($filter as $k => $v) { if (!isset($v) || empty($v)) { unset($filter[$k]); } } return $filter; }
function products() { $objGoods = $this->app->model('goods'); $imageDefault = app::get('image')->getConf('image.set'); $this->pagedata['image_set'] = $imageDefault; $this->pagedata['defaultImage'] = $imageDefault['S']['default_image']; $filter = array(); foreach (explode(',', $_POST['goods']) as $gid) { $filter['goods_id'][] = $gid; } $aProduct = $objGoods->getList('*,find_in_set(goods_id,"' . utils::addslashes_array($_POST['goods']) . '") as rank', $filter, 0, -1, array('rank', 'asc')); $aData = $this->get_current_member(); if (!$aData['member_id']) { $this->pagedata['login'] = '******'; } $view = $this->app->getConf('gallery.default_view'); if ($view == 'index') { $view = 'list'; } if (is_array($aProduct) && count($aProduct) > 0) { $objProduct = $this->app->model('products'); if ($this->app->getConf('site.show_mark_price') == 'true') { $setting['mktprice'] = $this->app->getConf('site.show_mark_price'); if (isset($aProduct)) { foreach ($aProduct as $pk => $pv) { if (empty($aProduct[$pk]['mktprice'])) { $aProduct[$pk]['mktprice'] = $objProduct->getRealMkt($pv['price']); } } } } else { $setting['mktprice'] = 0; } $setting['saveprice'] = $this->app->getConf('site.save_price'); $setting['buytarget'] = $this->app->getConf('site.buy.target'); $this->pagedata['setting'] = $setting; //spec_desc $siteMember = $this->get_current_member(); $this->site_member_lv_id = $siteMember['member_lv']; $oGoodsLv = $this->app->model('goods_lv_price'); $oMlv = $this->app->model('member_lv'); $mlv = $oMlv->db_dump($this->site_member_lv_id, 'dis_count'); foreach ($aProduct as $key => &$val) { $temp = $objProduct->getList('product_id, spec_info, price, freez, store, marketable, goods_id', array('goods_id' => $val['goods_id'], 'marketable' => 'true')); $aProduct[$key]['spec_desc'] = unserialize($val['spec_desc']); if ($this->site_member_lv_id) { $tmpGoods = array(); foreach ($oGoodsLv->getList('product_id,price', array('goods_id' => $val['goods_id'], 'level_id' => $this->site_member_lv_id)) as $k => $v) { $tmpGoods[$v['product_id']] = $v['price']; } foreach ($temp as &$tv) { $tv['price'] = isset($tmpGoods[$tv['product_id']]) ? $tmpGoods[$tv['product_id']] : $mlv['dis_count'] * $tv['price']; } $val['price'] = isset($tmpGoods[$tv['product_id']]) ? $tmpGoods[$tv['product_id']] : $mlv['dis_count'] * $val['price']; } $promotion_price = kernel::single('b2c_goods_promotion_price')->process($val); if ($promotion_price) { if ($promotion_price['price']) { $val['timebuyprice'] = $promotion_price['price']; } else { $val['timebuyprice'] = $val['price']; } $val['show_button'] = $promotion_price['show_button']; $val['timebuy_over'] = $promotion_price['timebuy_over']; } $val['spec_desc_info'] = $temp; $aProduct[$key]['product_id'] = $temp[0]['product_id']; if (empty($val['image_default_id'])) { $aProduct[$key]['image_default_id'] = $imageDefault['S']['default_image']; } } $this->pagedata['products'] =& $aProduct; } $this->page('wap/gallery/type/' . $view . '.html', true); }
function goods_filter(&$filter, &$object) { $filter = utils::addslashes_array($filter); $ObjProducts = $object->app->model('products'); $where = array(); if (isset($filter['marketable'])) { if ($filter['marketable'] === 'true') { $filter['marketable'] = 'true'; } if ($filter['marketable'] === 'false') { $filter['marketable'] = 'false'; } } if ($filter['type_id'] == '_ANY_') { unset($filter['type_id']); } // 此导致商品高级筛选(销售价介于) if (is_numeric($filter['price']) && isset($filter['_price_search'])) { $filter['price|' . $filter['_price_search']] = $filter['price']; if ($filter['price_from'] && $filter['price_to']) { $filter['price|' . $filter['_price_search']] = array($filter['price_from'], $filter['price_to']); } unset($filter['price']); unset($filter['_price_search']); } if ($filter['cat_id'][0] == "_ANY_" || $filter['cat_id'] == "_ANY_") { unset($filter['cat_id']); } if ($filter['cat_id'] || $filter['cat_id'] === 0) { if (!is_array($filter['cat_id'])) { $filter['cat_id'] = array($filter['cat_id']); } else { foreach ($filter['cat_id'] as $vCat_id) { if ($vCat_id !== '_ANY_' && $vCat_id !== '') { $aCat_id[] = intval($vCat_id); } } $filter['cat_id'] = $aCat_id; } if (!isset($object->__show_goods)) { $object->__show_goods = $object->app->getConf('system.category.showgoods'); } if ($object->__show_goods) { if (count($filter['cat_id']) > 0) { $where[] = 'cat_id in (' . implode($filter['cat_id'], ' , ') . ')'; } } else { if ($filter['cat_id']) { $oCat = $object->app->model('goods_cat'); $fcat_id = $filter['cat_id']; $aCat = $oCat->getList('cat_path,cat_id', array('cat_id' => $fcat_id)); } $pathplus = ''; if (count($aCat)) { foreach ($aCat as $v) { $pathplus .= ' cat_path LIKE \'' . $v['cat_path'] . $v['cat_id'] . ',%\' OR'; } } if ($aCat) { foreach ($object->db->select('SELECT cat_id FROM sdb_b2c_goods_cat WHERE ' . $pathplus . ' cat_id in (' . implode($filter['cat_id'], ' , ') . ')') as $rows) { $aCatid[] = $rows['cat_id']; } } else { unset($aCatid); } /* if(in_array('0', $filter['cat_id'])){ $aCatid[] = 0; }*/ if (!is_null($aCatid)) { $where[] = 'cat_id IN (' . implode(',', $aCatid) . ')'; } else { if ($filter['cat_id'] && $filter['cat_id'][0]) { $where[] = 'cat_id IN (' . implode(',', $filter['cat_id']) . ')'; } } } $filter['cat_id'] = null; } if (isset($filter['area']) && $filter['area']) { $where[] = 'goods_id < ' . $filter['area'][0] . ' and goods_id >' . $filter['area'][1]; //$where[] = 'and goods_id < 1000'; unset($filter['area']); } if ($filter['type_id'] == "_ANY_" || empty($filter['type_id'][0])) { unset($filter['type_id']); } if (is_array($filter['tag'])) { foreach ($filter['tag'] as $tk => $tv) { if ($tv == '_ANY_') { unset($filter['tag'][$tk]); } } } if (isset($filter['brand_id']) && $filter['brand_id']) { if (is_array($filter['brand_id'])) { foreach ($filter['brand_id'] as $brand_id) { if ($brand_id != '_ANY_') { $aBrand[] = intval($brand_id); } } if (count($aBrand) > 0) { $where[] = 'brand_id IN(' . implode(',', $aBrand) . ')'; } } elseif ($filter['brand_id'] > 0) { $where[] = 'brand_id = ' . $filter['brand_id']; } unset($filter['brand_id']); } if (isset($filter['goods_id']) && $filter['goods_id']) { if (is_array($filter['goods_id'])) { if ($filter['goods_id'][0] != '_ALL_') { foreach ($filter['goods_id'] as $goods_id) { if ($goods_id != '_ANY_') { $goods[] = intval($goods_id); } } } } else { $goods[] = intval($filter['goods_id']); } } unset($filter['goods_id']); /** 下面查询通过商品主键组合查询条件 - left join 相应的表 **/ if (isset($filter['keyword']) && $filter['keyword']) { $filter['keywords'] = array($filter['keyword']); } unset($filter['keyword']); if (isset($filter['keywords']) && $filter['keywords'] && !in_array('_ANY_', $filter['keywords'])) { $keywordsList = $object->getGoodsIdByKeyword($filter['keywords'], $filter['_keyword_search']); $keywordsGoods = array(); foreach ($keywordsList as $keyword) { $keywordsGoods[] = intval($keyword['goods_id']); } if (!empty($keywordsGoods) && !empty($goods)) { $keywordsGoods = array_intersect($keywordsGoods, $goods); if (empty($keywordsGoods)) { $goods = array('-1'); } else { $goods = $keywordsGoods; } } else { if (!empty($keywordsGoods)) { $goods = $keywordsGoods; } else { $goods = array('-1'); } } } unset($filter['keywords']); if (isset($filter['bn']) && $filter['bn']) { $sBn = ''; if (is_array($filter['bn'])) { $sBn = trim($filter['bn'][0]); } else { $sBn = trim($filter['bn']); } $bnGoodsId = $object->getGoodsIdByBn($sBn, $filter['_bn_search']); if (!empty($bnGoodsId) && !empty($goods)) { $bnGoodsId = array_intersect($bnGoodsId, $goods); if (empty($bnGoodsId)) { $goods = array('-1'); } else { $goods = $bnGoodsId; } } else { if (!empty($bnGoodsId)) { $goods = $bnGoodsId; } else { $goods = array('-1'); } } unset($filter['bn']); } if (isset($filter['barcode']) && $filter['barcode']) { $goods_id = $ObjProducts->getList('goods_id', array('barcode' => $filter['barcode'])); //$goods_id = $ObjProducts->dump(array('barcode'=>$filter['barcode']),'goods_id'); if (isset($goods_id[0]['goods_id'])) { $filter['goods_id'] = $goods_id[0]['goods_id']; } else { $filter['goods_id'] = 0; } unset($filter['barcode']); } $filter = (array) $filter; foreach ($filter as $k => $v) { if (substr($k, 0, 2) == 'p_') { if (strpos($k, '|') !== false) { unset($filter[$k]); list($k, $type) = explode('|', $k); $_str = $this->_inner_getFilterType($type, $v, false); if (strpos($_str, '{field}') !== false) { $where[] = str_replace('{field}', $tPre . $k, $_str); } else { $where[] = $tPre . $k . $_str; } $_str = null; } else { $ac = array(); if (is_array($v)) { foreach ($v as $m) { if ($m !== '_ANY_' && $m !== '') { $ac[] = $tPre . $k . '=\'' . $m . '\''; } } if (count($ac) > 0) { $where[] = '(' . implode($ac, ' or ') . ')'; } } elseif (isset($v) && $v != '' && $v != '_ANY_') { $where[] = $tPre . $k . '=\'' . $v . '\''; } } unset($filter[$k]); } else { if (substr($k, 0, 2) == 's_') { $sSpecId = array(); if (is_array($v)) { foreach ($v as $n) { if ($n !== '_ANY_' && $n != false) { $sSpecId[] = $n; } } unset($filter[$k]); } if (count($sSpecId) > 0) { $sql = 'SELECT goods_id FROM sdb_b2c_goods_spec_index WHERE spec_value_id IN ( ' . implode(',', $sSpecId) . ' )'; $sGoodsId = $object->db->select($sql); $sgid = array(); foreach ($sGoodsId as $si) { $sgid[] = $si['goods_id']; } if (!empty($goods)) { $sgid = array_intersect($sgid, $goods); } if (!empty($sgid)) { $goods = $sgid; } else { $goods = array(-1); } } } } } if (isset($goods) && count($goods) > 0) { $where[] = 'goods_id IN (' . implode(',', $goods) . ')'; } if (isset($filter['price']) && is_array($filter['price'])) { if ($filter['price'][0] == 0 || $filter['price'][0]) { $where[] = 'price >= ' . intval($filter['price'][0]); } if ($filter['price'][1] == '0' || $filter['price'][1]) { $where[] = 'price <= ' . intval($filter['price'][1]); } if (!is_numeric($filter['price'][0]) || !is_numeric($filter['price'][1])) { unset($filter['price']); } /* if($filter['price'][0] && $filter['price'][1]){ $where[] = 'price >= '.min($filter['price']).' AND price <= '.max($filter['price']); }*/ unset($filter['price']); } else { if ($filter['priceto']) { if (empty($filter['pricefrom'])) { $filter['pricefrom'] = 0; } $where[] = 'price >= ' . $filter['pricefrom'] . ' AND price <= ' . $filter['priceto']; unset($filter['pricefrom']); unset($filter['priceto']); } else { if (!is_numeric($filter['price'])) { unset($filter['price']); } else { unset($filter['pricefrom']); unset($filter['priceto']); } } } if (isset($filter['cost'])) { if (!is_numeric($filter['cost'])) { unset($filter['cost']); } } if (isset($filter['mktprice'])) { if (!is_numeric($filter['mktprice'])) { unset($filter['mktprice']); } } if (is_numeric($filter['store']) && $filter['_store_search']) { $filter['store|' . $filter['_store_search']] = $filter['store']; if ($filter['store_from'] && $filter['store_to']) { $filter['store|' . $filter['_store_search']] = array($filter['store_from'], $filter['store_to']); } unset($filter['store'], $filter['_store_search']); } if (isset($filter['store']) && !is_numeric($filter['store'])) { unset($filter['store']); } if (isset($filter['gkey']) && trim($filter['gkey'])) { $filter['name'] = trim($filter['gkey']); } if ($filter['searchname']) { $filter['name'][] = $filter['searchname']; } if (isset($filter['name']) && $filter['name']) { if (is_array($filter['name'])) { $filter['name'] = implode('+', $filter['name']); if ($filter['name']) { $filter['name'] = str_replace('%xia%', '_', $filter['name']); $filter['name'] = preg_replace('/[\'|\\"]/', '+', $filter['name']); $GLOBALS['search'] = $filter['name']; $filter['name'] = urldecode($filter['name']); $where[] = $object->wFilter($filter['name']); } } else { //后台搜索 $GLOBALS['search'] = $filter['name']; $where[] = 'name LIKE \'%' . trim(mysql_real_escape_string($filter['name'])) . '%\''; } $filter['name'] = null; } if (isset($filter['spec_desc'])) { if ($filter['spec_desc'] === 'true') { $where[] = '(spec_desc IS NOT NULL && spec_desc != \'\' && spec_desc != \'a:0:{}\')'; } if ($filter['spec_desc'] === 'false') { $where[] = '(spec_desc IS NULL || spec_desc = \'\' || spec_desc = \'a:0:{}\')'; } unset($filter['spec_desc']); } if (!$filter['goods_type']) { $filter['goods_type'] = 'normal'; } foreach ($filter as $k => $v) { if (!isset($v)) { unset($filter[$k]); } } return parent::dbeav_filter_parser($filter, null, $where, $object); }
function dbeav_filter_parser($filter, $tableAlias = null, $baseWhere = null, &$object) { $this->use_like = $object->filter_use_like; $filter = utils::addslashes_array($filter); $schema = $object->get_schema(); $idColumn = $schema['idColumn']; $tPre = ($tableAlias ? $tableAlias : '`' . $object->table_name(true) . '`') . '.'; $where = $baseWhere ? $baseWhere : array(1); if (isset($filter['tag']) && ($tag = $filter['tag'])) { if (is_array($filter['tag'])) { foreach ($filter['tag'] as $tk => $tv) { if ($tv == '_ANY_') { unset($filter['tag'][$tk]); } } } if (isset($filter['tag'])) { unset($filter['tag']); } if (is_array($tag)) { if (count($tag) == 0) { unset($tag); } } else { $tag = array($tag); } if ($tag == '_ANY_' || $tag == array('_ANY_')) { unset($tag); } if ($tag) { $a = array(); if (is_array($tag) && count($tag) > 0) { foreach ($object->db->select("select rel_id from sdb_desktop_tag_rel where tag_id in (" . implode(',', $tag) . ")") as $r) { $a[] = $r['rel_id']; } } if (count($a) > 0) { $where[] = "{$tPre}{$idColumn} in ('" . implode("','", $a) . "')"; } else { $where[] = ' 0'; } } } if (isset($filter['final_amount']) && !is_array($filter['final_amount']) && !is_numeric($filter['final_amount'])) { unset($filter['final_amount']); } if (isset($filter['advance']) && !is_array($filter['advance']) && !is_numeric($filter['advance'])) { unset($filter['advance']); } $cols = array_merge($object->searchOptions(), $object->_columns()); //idColumn为数组时单独处理 if (!is_array($idColumn) && ($filter[$idColumn] == '_ALL_' || $filter[$idColumn] == array('_ALL_'))) { unset($filter[$idColumn]); } elseif (!is_array($idColumn) && isset($filter[$idColumn])) { $where[] = " {$tPre}{$idColumn} in ('" . implode("','", (array) $filter[$idColumn]) . "') "; unset($filter[$idColumn]); } if (is_array($filter)) { foreach ($filter as $k => $v) { if (is_null($v)) { $where[] = $tPre . $k . ' is NULL '; continue; } if ($k == 'filter_sql') { $where[] = str_replace('{table}', $tPre, stripslashes($v)); continue; } if (isset($cols[$k]) || strpos($k, '|')) { if (strpos($k, '|') !== false) { list($k, $type) = explode('|', $k); unset($filter[$k]); $_str = $this->_inner_getFilterType($type, $v, false); if (strpos($_str, '{field}') !== false) { $where[] = str_replace('{field}', $tPre . $k, $_str); } else { $where[] = $tPre . $k . $_str; } $_str = null; continue; } if (is_array($v)) { $where[] = $tPre . $k . $this->_inner_getFilterType('in', $v, false); continue; } $ac = array(); if ($cols[$k]['type'] == 'time' || $cols[$k]['type'] == 'last_modify') { if ($filter['_' . $k . '_search'] == 'between') { $a_v = array(); $a_v[] = strtotime($filter[$k . '_from'] . ' ' . $filter['_DTIME_']['H'][$k . '_from'] . ':' . $filter['_DTIME_']['M'][$k . '_from'] . ':00'); $a_v[] = strtotime($filter[$k . '_to'] . ' ' . $filter['_DTIME_']['H'][$k . '_to'] . ':' . $filter['_DTIME_']['M'][$k . '_to'] . ':00'); if (!empty($filter[$k . '_from']) && empty($filter[$k . '_to'])) { $where[] = $tPre . $k . $this->_inner_getFilterType('bthan', $a_v[0]); } elseif (empty($filter[$k . '_from']) && !empty($filter[$k . '_to'])) { $where[] = $tPre . $k . $this->_inner_getFilterType('lthan', $a_v[1]); } elseif (!empty($filter[$k . '_from']) && !empty($filter[$k . '_to'])) { $where[] = str_replace('{field}', $tPre . $k, $this->_inner_getFilterType($filter['_' . $k . '_search'], $a_v)); } } else { $a_v = strtotime($filter[$k] . ' ' . $filter['_DTIME_']['H'][$k] . ':' . $filter['_DTIME_']['M'][$k] . ':00'); $where[] = $tPre . $k . $this->_inner_getFilterType($filter['_' . $k . '_search'], $a_v); } } elseif (!is_array($cols[$k]['type']) && ($cols[$k]['type'] == 'money' || $cols[$k]['type'] == 'number' || $cols[$k]['type'] == 'float' || strpos($cols[$k]['type'], 'decimal') !== false) && $filter['_' . $k . '_search']) { if ($filter['_' . $k . '_search'] == 'between') { $a_v = array($filter[$k . '_from'], $filter[$k . '_to']); if (!empty($filter[$k . '_from']) && empty($filter[$k . '_to'])) { $where[] = $tPre . $k . $this->_inner_getFilterType('bthan', $a_v[0]); } elseif (empty($filter[$k . '_from']) && !empty($filter[$k . '_to'])) { $where[] = $tPre . $k . $this->_inner_getFilterType('lthan', $a_v[1]); } elseif (!empty($filter[$k . '_from']) && !empty($filter[$k . '_to'])) { $where[] = str_replace('{field}', $tPre . $k, $this->_inner_getFilterType($filter['_' . $k . '_search'], $a_v)); } } else { $where[] = $tPre . $k . $this->_inner_getFilterType($filter['_' . $k . '_search'], $v); } } else { if (isset($cols[$k]['filtertype']) && isset($filter['_' . $k . '_search'])) { $where[] = $tPre . $k . $this->_inner_getFilterType($filter['_' . $k . '_search'], $v); } else { if (isset($cols[$k]['searchtype']) && !isset($filter['object_filter'])) { $where[] = $tPre . $k . $this->_inner_getFilterType($cols[$k]['searchtype'], $v); } else { if (substr($k, 0, 1) != '_') { if ($k != 'object_filter') { if ($cols[$k]['type'] == 'region') { if (isset($v)) { $v = explode(':', $v); } unset($v[2]); $v = implode(':', $v); $where[] = $tPre . $k . ' like \'' . $v . '%\''; } elseif (is_array($v)) { foreach ($v as $m) { if ($m !== '_ANY_' && $m !== '' && $m != '_ALL_') { $ac[] = $cols[$k]['fuzzySearch'] ? $tPre . $k . ' like \'%' . $m . '%\'' : $tPre . $k . '=\'' . $m . '\''; } else { $ac = array(); break; } } if (count($ac) > 0) { $where[] = '(' . implode($ac, ' or ') . ')'; } } elseif (isset($v)) { $where[] = $tPre . $k . '=\'' . $v . '\''; } } } } } } } } } return implode($where, ' AND '); }
function goods_filter(&$filter, &$object) { if (!is_array($filter) || isset($filter['goods_id']) && count($filter['goods_id']) == 1) { return $this->_pre_filter($filter); } $filter = utils::addslashes_array($filter); //过滤基本的条件 $filter = $this->base_filter($filter); $ObjProducts = $object->app->model('products'); //分类 $filter = $this->get_cat_filter($filter, $object); /** 下面查询通过商品主键组合查询条件 - left join 相应的表 **/ //关键字查找到对应的goodsId if (isset($filter['search_keywords'][0])) { if ($filter['filter_sql']) { $filter['filter_sql'] .= ' and ' . $object->wFilter($filter['search_keywords'][0]); } else { $filter['filter_sql'] = $object->wFilter($filter['search_keywords'][0]); } } if (isset($filter['keyword']) && $filter['keyword']) { $filter['keywords'] = array($filter['keyword']); unset($filter['keyword']); } if (isset($filter['keywords']) && $filter['keywords'] && !in_array('_ANY_', $filter['keywords'])) { $keywordsList = $object->getGoodsIdByKeyword($filter['keywords'], $filter['_keyword_search']); $keywordsGoods = array(); foreach ($keywordsList as $keyword) { $keywordsGoods[] = intval($keyword['goods_id']); } if (!empty($keywordsGoods) && !empty($goods)) { $keywordsGoods = array_intersect($keywordsGoods, $goods); if (empty($keywordsGoods)) { $goods = array('-1'); } else { $goods = $keywordsGoods; } } else { if (!empty($keywordsGoods)) { $goods = $keywordsGoods; } else { $goods = array('-1'); } } } unset($filter['keywords']); //包含商品bn和货品bn都可以搜索到 if (isset($filter['bn']) && $filter['bn']) { $sBn = ''; if (is_array($filter['bn'])) { $sBn = trim($filter['bn'][0]); } else { $sBn = trim($filter['bn']); } $bnGoodsId = $object->getGoodsIdByBn($sBn, $filter['_bn_search']); if (!empty($bnGoodsId) && !empty($goods)) { $bnGoodsId = array_intersect($bnGoodsId, $goods); if (empty($bnGoodsId)) { $goods = array('-1'); } else { $goods = $bnGoodsId; } } else { if (!empty($bnGoodsId)) { $goods = $bnGoodsId; } else { $goods = array('-1'); } } unset($filter['bn']); } //货品编号 if (isset($filter['barcode']) && $filter['barcode']) { $goods_id = $ObjProducts->getList('goods_id', array('barcode' => $filter['barcode'])); if (isset($goods_id[0]['goods_id'])) { $filter['goods_id'] = $goods_id[0]['goods_id']; } else { $filter['goods_id'] = 0; } unset($filter['barcode']); } //规格筛选 mysql中 if (count($filter['spec_value_id']) > 0) { $sql = 'SELECT goods_id FROM sdb_b2c_goods_spec_index WHERE spec_value_id IN ( ' . implode(',', $filter['spec_value_id']) . ' )'; $sGoodsId = $object->db->select($sql); $sgid = array(); foreach ($sGoodsId as $si) { $sgid[] = $si['goods_id']; } if (!empty($goods)) { $sgid = array_intersect($sgid, $goods); } if (!empty($sgid)) { $goods = $sgid; } else { $goods = array(-1); } } if (isset($goods) && count($goods) > 0) { $filter['goods_id'] = $goods; } if (isset($filter['name']) && $filter['name']) { if (is_array($filter['name'])) { $filter['name'] = implode(' ', $filter['name']); if ($filter['name']) { $filter['name|has'] = urldecode($filter['name']); } } else { //后台搜索 $GLOBALS['search'] = $filter['name']; $filter['name|has'] = $filter['name']; } unset($filter['name']); } if (!$filter['goods_type']) { $filter['goods_type'] = 'normal'; } //前台商品列表页是否有货 if ($filter['is_store'] == 'on') { if ($filter['filter_sql']) { $filter['filter_sql'] .= " and (nostore_sell = '1' OR store >= 0.000001)"; } else { $filter['filter_sql'] = "(nostore_sell = '1' OR store >= 0.000001)"; } } foreach ($filter as $k => $v) { if (!isset($v)) { unset($filter[$k]); } } if (is_array($filter['goods_id'])) { $filter['goods_id'] = array_unique($filter['goods_id']); } return $filter; }