Exemplo n.º 1
0
 function _filter($filter)
 {
     $where = array(1);
     if ($filter['cpns_id']) {
         $where[] = 'sdb_pmt_gen_coupon.cpns_id=' . intval($filter['cpns_id']);
     }
     return parent::_filter($filter) . ' AND ' . implode($where, ' AND ');
 }
Exemplo n.º 2
0
 function _filter($filter)
 {
     $where = array(1);
     if ($filter['file_type']) {
         $where[] = 'file_type = ' . intval($filter['file_type']);
     }
     return parent::_filter($filter) . ' and ' . implode($where, ' AND ');
 }
Exemplo n.º 3
0
 function _filter($filter)
 {
     $where = array(1);
     if ($filter['pmta_name']) {
         $where[] = 'pmta_name like\'%' . $filter['pmta_name'] . '%\'';
     }
     return parent::_filter($filter) . ' and ' . implode($where, ' and ');
 }
Exemplo n.º 4
0
 function _filter($filter)
 {
     if ($this->filter) {
         return parent::_filter($filter) . $this->filter;
     } else {
         return parent::_filter($filter);
     }
 }
Exemplo n.º 5
0
 function _filter($filter)
 {
     if ($filter['target']) {
         $where = array('trigger_event like "' . $filter['target'] . ':%"');
         unset($filter['target']);
     } else {
         $where = array();
     }
     return parent::_filter($filter, $tbase, $where);
 }
Exemplo n.º 6
0
 function _filter($filter)
 {
     $where = array(1);
     $filter['to_type'] = 1;
     $where[] = 'for_id = 0';
     if ($filter['msg_from']) {
         $where[] = "msg_from ='" . $filter['msg_from'] . "'";
     }
     return parent::_filter($filter) . ' AND ' . implode($where, ' AND ');
 }
Exemplo n.º 7
0
 function _filter($filter)
 {
     $where = array(1);
     if ($filter['no_handle']) {
         $where[] = ' (status!=4 and  status!=5) ';
     }
     if (isset($filter['member_name']) && $filter['member_name'] !== '') {
         $aId = array(0);
         foreach ($this->db->select('SELECT member_id FROM sdb_members WHERE uname = \'' . $filter['member_name'] . '\'') as $rows) {
             $aId[] = $rows['member_id'];
         }
         $where[] = 'member_id IN (' . implode(',', $aId) . ')';
         unset($filter['member_name']);
     }
     return parent::_filter($filter) . ' and ' . implode($where, ' AND ');
 }
Exemplo n.º 8
0
 function _filter($filter)
 {
     $where = array(1);
     $where[] = 'cpns_type=\'1\'';
     $where[] = 'cpns_point is not null';
     if ($filter['cpns_name']) {
         $where[] = 'cpns_name like\'%' . $filter['cpns_name'] . '%\'';
     }
     if (isset($filter['ifvalid'])) {
         if ($filter['ifvalid'] === 1) {
             $curTime = time();
             $where[] = 'cpns_status=\'1\' AND pmt_time_begin <= ' . $curTime . ' and pmt_time_end >' . $curTime;
         }
     }
     return parent::_filter($filter, 'c') . ' AND cpns_point > 0 AND ' . implode($where, ' and ');
 }
Exemplo n.º 9
0
 function _filter($aFilter)
 {
     if ($aFilter['title'] != '') {
         $aFilter['title'] = addslashes($aFilter['title']);
         $where[] = 'title LIKE \'' . $aFilter['title'] . '%\'';
     }
     $ndata = $this->db->select("select node_id from sdb_sitemaps");
     foreach ($ndata as $key => $v) {
         $data[] = $v['node_id'];
     }
     $where[] = 'node_id in (' . implode(",", $data) . ')';
     if ($aFilter['article_id']) {
         if (is_array($aFilter['article_id'])) {
             foreach ($aFilter['article_id'] as $id) {
                 if ($id != '_ANY_') {
                     $aId[] = intval($id);
                 }
             }
             if (count($aId) > 0) {
                 $where[] = 'article_id IN (' . implode(',', $aId) . ')';
             }
         } else {
             $where[] = 'article_id=' . $aFilter['article_id'];
         }
     }
     if ($aFilter['node_id']) {
         if (is_array($aFilter['node_id'])) {
             foreach ($aFilter['node_id'] as $catid) {
                 if ($catid != '_ANY_') {
                     $aCats[] = intval($catid);
                 }
             }
             if (count($aCats) > 0) {
                 $where[] = 'node_id IN (' . implode(',', $aCats) . ')';
             }
         } else {
             $where[] = 'node_id=' . $aFilter['node_id'];
         }
     }
     unset($aFilter['node_id']);
     unset($aFilter['title']);
     if (count($where) > 0) {
         return implode(' AND ', $where) . ' AND ' . parent::_filter($aFilter);
     } else {
         return parent::_filter($aFilter);
     }
 }
Exemplo n.º 10
0
 function _filter($filter)
 {
     if ($filter['gname'] || $filter['gbn']) {
         if ($filter['gname']) {
             $gfilter['name'] = $filter['gname'];
         }
         if ($filter['gbn']) {
             $gfilter['bn'] = $filter['gbn'];
         }
         $oGoods = $this->system->loadModel('goods/products');
         $filter['goods_id'][] = -1;
         foreach ($oGoods->getList('goods_id', $gfilter, 0, 1000) as $rows) {
             $filter['goods_id'][] = $rows['goods_id'];
         }
     }
     if ($filter['notifytime']) {
         $where = ' and creat_time > ' . $filter['notifytime'];
     }
     return parent::_filter($filter) . $where;
 }
Exemplo n.º 11
0
 function _filter($filter)
 {
     $sdtime = '';
     if ($filter['sdtime']) {
         $sdtime = explode("/", $filter['sdtime']);
     } else {
         $sdtime = explode("/", $filter['sdtimecommon']);
     }
     if (count($sdtime) == 1) {
         $sdtime = explode('%2F', $sdtime[0]);
     }
     $where = array(1);
     $filter['start_date'] = $sdtime[0];
     $filter['end_date'] = $sdtime[1];
     if ($filter['start_date']) {
         $where[] = " mtime >= " . strtotime($filter['start_date']);
     }
     if ($filter['end_date']) {
         $where[] = " mtime <= " . (strtotime($filter['end_date']) + 3600 * 24);
     }
     unset($filter['sdtime'], $filter['sdtimecommon'], $sdtime);
     return parent::_filter($filter) . ' AND ' . implode($where, ' AND ');
 }
Exemplo n.º 12
0
 function _filter($filter)
 {
     $where = array(1);
     if (is_array($filter['giftcat_id'])) {
         foreach ($filter['gcat'] as $giftcat_id) {
             if ($giftcat_id != '_ANY_') {
                 $cats[] = $giftcat_id;
             }
             if (count($cats) > 0) {
                 $where[] = 'giftcat_id in (' . implode($cats, ',') . ')';
             }
         }
     }
     if ($filter['cat']) {
         $where[] = 'cat like\'%' . $filter['cat'] . '%\'';
     }
     if (isset($filter['shop_iffb'])) {
         if ($filter['shop_iffb'] === 1) {
             $where[] = 'shop_iffb=\'1\'';
         }
     }
     return parent::_filter($filter) . ' and ' . implode($where, ' and ');
 }
Exemplo n.º 13
0
 function _filter($filter)
 {
     $filter = is_array($filter) ? $filter : $_POST;
     $where = array(1);
     if (isset($filter['order_id'])) {
         if (is_array($filter['order_id'])) {
             if ($filter['order_id'][0] != '_ALL_') {
                 if (!isset($filter['order_id'][1])) {
                     $where[] = 'order_id LIKE \'' . addslashes(trim($filter['order_id'][0])) . '%\'';
                 } else {
                     $aOrder = array();
                     foreach ($filter['order_id'] as $order_id) {
                         $aOrder[] = 'order_id="' . addslashes(trim($order_id)) . '"';
                     }
                     $where[] = '(' . implode(' OR ', $aOrder) . ')';
                     unset($aOrder);
                 }
             }
         } else {
             $where[] = 'order_id LIKE \'' . addslashes(trim($filter['order_id'])) . '%\'';
         }
         unset($filter['order_id']);
     }
     if (array_key_exists('goods_na', $filter)) {
         //把商品名称加入商品搜索
         if ($filter['goods_na'] !== '') {
             $aId = array(0);
             foreach ($this->db->select('SELECT order_id FROM sdb_order_items WHERE name LIKE \'%' . addslashes(trim($filter['goods_na'])) . '%\'') as $rows) {
                 $aId[] = 'order_id = \'' . $rows['order_id'] . '\'';
             }
             $where[] = '(' . implode(' OR ', $aId) . ')';
         }
         unset($filter['goods_na']);
     }
     if (array_key_exists('shipping', $filter)) {
         //修改配送方式选择项
         if ($filter['shipping'] !== '') {
             $aId = array();
             foreach ($this->db->select('SELECT dt_name FROM sdb_dly_type  WHERE dt_id = \'' . addslashes(trim($filter['shipping'])) . '\'') as $rows) {
                 $aId[] = 'shipping  = \'' . addslashes(trim($rows['dt_name'])) . '\'';
             }
             $where[] = '(' . implode(' OR ', $aId) . ')';
         }
         unset($filter['shipping']);
     }
     if (array_key_exists('bn', $filter)) {
         if ($filter['bn'] !== '') {
             $aId = array(0);
             foreach ($this->db->select('SELECT order_id FROM sdb_order_items WHERE bn LIKE \'' . addslashes(trim($filter['bn'])) . '%\'') as $rows) {
                 $aId[] = 'order_id = \'' . addslashes($rows['order_id']) . '\'';
             }
             $where[] = '(' . implode(' OR ', $aId) . ')';
         }
         unset($filter['bn']);
     }
     if (array_key_exists('goods_name', $filter)) {
         if ($filter['goods_name'] !== '') {
             $aId = array(0);
             foreach ($this->db->select('SELECT order_id FROM sdb_order_items WHERE name LIKE \'%' . addslashes($filter['goods_name']) . '%\'') as $rows) {
                 $aId[] = 'order_id = \'' . $rows['order_id'] . '\'';
             }
             $where[] = '(' . implode(' OR ', $aId) . ')';
         }
         unset($filter['goods_name']);
     }
     if (array_key_exists('logi_no', $filter)) {
         if ($filter['logi_no'] !== '') {
             $objShipping =& $this->system->loadModel('trading/shipping');
             $aOrder = $objShipping->getOrdersByLogino($filter['logi_no']);
             $where[] = 'order_id IN (\'' . implode("','", $aOrder) . '\')';
         }
         unset($filter['logi_no']);
     }
     if (array_key_exists('member_name', $filter)) {
         if ($filter['member_name'] !== '') {
             $aId = array(0.1);
             foreach ($this->db->select('SELECT member_id FROM sdb_members WHERE uname = \'' . addslashes($filter['member_name']) . '\'') as $rows) {
                 $aId[] = $rows['member_id'];
             }
             $where[] = 'member_id IN (' . implode(',', $aId) . ')';
         }
         unset($filter['member_name']);
     }
     return parent::_filter($filter) . ' and ' . implode($where, ' AND ');
 }
Exemplo n.º 14
0
 function _filter($filter)
 {
     $where = array(1);
     if ($filter['cpns_name']) {
         $where[] = 'cpns_name like\'%' . $filter['cpns_name'] . '%\'';
     }
     $where[] = 'pmt_type=\'1\'';
     if (is_array($filter['cpns_id'])) {
         foreach ($filter['cpns_id'] as $cpns_id) {
             if ($cpns_id != '_ANY_') {
                 $coupons[] = 'c.cpns_id=' . intval($cpns_id);
             }
         }
         if (count($coupons) > 0) {
             $where[] = '(' . implode($coupons, ' or ') . ')';
         }
     }
     if (!empty($filter['cpns_type']) && is_string($filter['cpns_type'])) {
         $filter['cpns_type'] = explode(',', $filter['cpns_type']);
     }
     if (is_array($filter['cpns_type'])) {
         foreach ($filter['cpns_type'] as $type) {
             if ($type != '_ANY_') {
                 $cpns_type[] = 'c.cpns_type=\'' . intval($type) . '\'';
             }
         }
         if (count($cpns_type) > 0) {
             $where[] = '(' . implode($cpns_type, ' or ') . ')';
         }
     }
     if (isset($filter['ifvalid'])) {
         if ($filter['ifvalid'] === 1) {
             $curTime = time();
             $where[] = 'cpns_status=\'1\' and pmt_time_begin <= ' . $curTime . ' and pmt_time_end >' . $curTime;
         }
     }
     return parent::_filter($filter, 'c') . ' and ' . implode($where, ' and ');
 }
Exemplo n.º 15
0
 function _filter($filter)
 {
     $where = array(1);
     $aId = array(0);
     $aBrand = array();
     $serach_goodsid = false;
     if (isset($filter['brand_id']) && is_array($filter['brand_id'])) {
         foreach ($filter['brand_id'] as $brand_id) {
             if ($brand_id != '_ANY_') {
                 $aBrand[] = intval($brand_id);
             }
         }
         if (count($aBrand) > 0) {
             $serach_goodsid = true;
             foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND brand_id IN(' . implode(',', $aBrand) . ')') as $rows) {
                 $aId[] = $rows['goods_id'];
             }
         }
         unset($filter['brand_id']);
     }
     $aTag = array();
     if (isset($filter['tag']) && is_array($filter['tag'])) {
         foreach ($filter['tag'] as $tag) {
             if ($tag != '_ANY_') {
                 $aTag[] = intval($tag);
             }
         }
         if (count($aTag) > 0) {
             $tagId = array(0);
             foreach ($this->db->select('SELECT rel_id FROM sdb_tag_rel r LEFT JOIN sdb_tags t ON r.tag_id=t.tag_id WHERE t.tag_type = \'goods\' AND r.tag_id IN(' . implode(',', $aTag) . ')') as $rows) {
                 $tagId[] = $rows['rel_id'];
             }
             if ($serach_goodsid) {
                 $aId = array_intersect($aId, $tagId);
             } else {
                 $aId = $tagId;
             }
             $serach_goodsid = true;
         }
         unset($filter['tag']);
     }
     $aGoods = array();
     if (isset($filter['cat_id']) && is_array($filter['cat_id'])) {
         foreach ($filter['cat_id'] as $cat_id) {
             if ($cat_id != '_ANY_') {
                 $aGoods[] = intval($cat_id);
             }
         }
         if (count($aGoods) > 0) {
             $catId = array(0);
             $tmp_array = $this->db->select('SELECT cat_id FROM sdb_goods_cat WHERE cat_path IN (' . implode(',', $aGoods) . ')');
             $cId = array();
             array_push($cId, implode($aGoods));
             foreach ($tmp_array as $k => $v) {
                 array_push($cId, $v['cat_id']);
             }
             foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND cat_id IN(' . implode(',', $cId) . ')') as $rows) {
                 $catId[] = $rows['goods_id'];
             }
             if ($serach_goodsid) {
                 $aId = array_intersect($aId, $catId);
             } else {
                 $aId = $catId;
             }
             $serach_goodsid = true;
         }
         unset($filter['cat_id']);
     }
     $aType = array();
     if (isset($filter['type_id']) && $filter['type_id']) {
         $filter['type_id'] = intval($filter['type_id']);
         $typeId = array(0);
         foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND type_id =' . $filter['type_id']) as $rows) {
             $typeId[] = $rows['goods_id'];
         }
         if ($serach_goodsid) {
             $aId = array_intersect($aId, $typeId);
         } else {
             $aId = $typeId;
         }
         $serach_goodsid = true;
         unset($filter['type_id']);
     }
     $aProps = array();
     if (isset($filter['props']) && is_array($filter['props'])) {
         foreach ($filter['props'] as $cols => $rows) {
             foreach ($rows as $propid) {
                 if ($propid != '_ANY_') {
                     $aProps['p_' . $cols][] = intval($propid);
                 }
             }
         }
         if (count($aProps) > 0) {
             $catId = array(0);
             $p_where = array(1);
             foreach ($aProps as $cols => $rows) {
                 $p_where[] = $cols . ' IN(' . implode(',', $rows) . ')';
             }
             foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND ' . implode(' AND ', $p_where)) as $rows) {
                 $catId[] = $rows['goods_id'];
             }
             if ($serach_goodsid) {
                 $aId = array_intersect($aId, $catId);
             } else {
                 $aId = $catId;
             }
             $serach_goodsid = true;
         }
         unset($filter['props']);
     }
     if ($serach_goodsid) {
         $where[] = 'goods_id IN (' . implode(',', $aId) . ')';
     }
     if (isset($filter['product_id']) && is_array($filter['product_id'])) {
         foreach ($filter['product_id'] as $goods_id) {
             if ($goods_id != '_ANY_') {
                 $goods[] = intval($goods_id);
             }
         }
         if (count($goods) > 0) {
             $where[] = 'product_id IN (' . implode(',', $goods) . ')';
         }
     }
     if (isset($filter['notifytime']) && is_array($filter['notifytime'])) {
         $where[] = 'creat_time > ' . $filter['notifytime'];
     }
     if (isset($filter['price']) && is_array($filter['price'])) {
         foreach ($filter['price'] as $price) {
             if ($price != '_ANY_') {
                 $aPrice = explode('-', $price);
                 $aWhere[] = '(price >= ' . $aPrice[0] . ' AND price <= ' . $aPrice[1] . ')';
             }
         }
         if (!empty($aWhere)) {
             $where[] = '(' . implode(' OR ', $aWhere) . ')';
         }
         unset($filter['price']);
     } else {
         if (trim($filter['pricefrom']) !== '' || trim($filter['priceto']) !== '') {
             if ($filter['pricefrom'] !== '') {
                 $where[] = 'price >= ' . $filter['pricefrom'];
                 unset($filter['pricefrom']);
             }
             if ($filter['priceto'] !== '') {
                 $where[] = 'price <= ' . $filter['priceto'];
                 unset($filter['priceto']);
             }
         }
     }
     // 过滤掉同步过来的商品(绑定的商品只能是本地商品) $ wubin 2009-9-7 15:05:20
     if (isset($filter['is_local']) && $filter['is_local']) {
         // 是否只取本地商品
         $sSql = " AND goods_id IN ( SELECT goods_id FROM sdb_goods WHERE supplier_goods_id = 0 OR supplier_goods_id IS NULL ) ";
     } else {
         $sSql = "";
     }
     if (trim($filter['searchname'])) {
         $where[] = 'name like \'%' . trim($filter['searchname']) . '%\'';
         unset($filter['searchname']);
     }
     return parent::_filter($filter) . ' AND goods_id IS NOT NULL AND ' . implode(' AND ', $where) . (isset($filter['store_alarm']) ? ' AND store <=' . intval($filter['store_alarm']) : '');
 }
Exemplo n.º 16
0
 public function _filter($filter, $tbase = "")
 {
     if (isset($filter['keyword'])) {
         $filter['keyword'] = addslashes($filter['keyword']);
     }
     if (!function_exists("goods_filter")) {
         require CORE_INCLUDE_DIR . "/core/goods.filter.php";
     }
     $where = goods_filter($filter, $this);
     return parent::_filter($filter, $tbase, $where);
 }
Exemplo n.º 17
0
 function _filter($filter)
 {
     foreach ($filter as $k => $v) {
         $filter[$k] = str_replace("_", "\\_", $v);
     }
     $w = array();
     foreach ($filter as $k => $v) {
         if (substr($k, 0, 6) == 'attr__') {
             if (is_array($v)) {
                 $r = array();
                 foreach ($v as $n) {
                     $r[] = $this->db->quote($n);
                 }
                 $w[] = '(attr_id=' . intval(substr($k, 6)) . ' and value in(' . implode(',', $r) . '))';
             } else {
                 $w[] = '(attr_id=' . intval(substr($k, 6)) . ' and value=' . $this->db->quote($v) . ')';
             }
             $less[substr($value, 6)] = $v;
             unset($filter[$k]);
         }
     }
     if ($w) {
         $subselect = 'select member_id from sdb_member_mattrvalue where ' . implode(' and ', $w);
         if ($this->db->dbver == 3) {
             $m_id = array(0);
             //防止出现空join
             foreach ($this->db->select($subselect) as $r) {
                 $m_id[] = $r['member_id'];
             }
             $subselect = implode(',', $m_id);
         }
         $where = parent::_filter($filter);
         $where .= ' and member_id in (' . $subselect . ')';
         return $where;
     } else {
         return parent::_filter($filter);
     }
 }
Exemplo n.º 18
0
 function _filter($filter, $tbase = '')
 {
     $where = array();
     if ($filter['list_type'] == 'lack') {
         $oProduct = $this->system->loadModel('goods/finderPdt');
         $filter_p['store_alarm'] = $this->system->getConf('system.product.alert.num');
         foreach ($oProduct->getList('goods_id', $filter_p, 0, -1) as $row) {
             $filter['goods_id'][] = $row['goods_id'];
         }
     }
     if ($filter['cat_id']) {
         if (!is_array($filter['cat_id'])) {
             $filter['cat_id'] = array($filter['cat_id']);
         }
         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($this->__show_goods)) {
             $this->__show_goods = $this->system->getConf('system.category.showgoods');
         }
         if ($this->__show_goods) {
             if (count($filter['cat_id']) > 0) {
                 $where[] = 'cat_id in (' . implode($filter['cat_id'], ' , ') . ')';
             }
         } else {
             $oCat = $this->system->loadModel('goods/productCat');
             $aCat = $oCat->getFieldById($filter['cat_id'], array('cat_path', 'cat_id'));
             $pathplus = '';
             if (count($aCat)) {
                 foreach ($aCat as $v) {
                     $pathplus .= ' cat_path LIKE \'' . ($v['cat_path'] == ',' ? '' : $v['cat_path']) . $v['cat_id'] . ',%\' OR';
                 }
             }
             if ($aCat) {
                 foreach ($this->db->select('SELECT cat_id FROM sdb_goods_cat WHERE ' . $pathplus . ' cat_id in (' . implode($filter['cat_id'], ' , ') . ')') as $rows) {
                     $aCatid[] = $rows['cat_id'];
                 }
             } else {
                 unset($aCatid);
             }
             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 (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'])) {
             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']);
     if (isset($filter['tag']) && is_array($filter['tag'])) {
         foreach ($filter['tag'] as $tag) {
             if ($tag != '_ANY_') {
                 $aTag[] = intval($tag);
             }
         }
         if (count($aTag) > 0) {
             $tagId[] = -1;
             foreach ($this->db->select('SELECT rel_id FROM sdb_tag_rel r
                 LEFT JOIN sdb_tags t ON r.tag_id=t.tag_id
                 WHERE t.tag_type = \'goods\' AND r.tag_id IN(' . implode(',', $aTag) . ')') as $rows) {
                 $tagId[] = $rows['rel_id'];
             }
             if ($goods) {
                 $goods = array_intersect($goods, $tagId);
             } else {
                 $goods = $tagId;
             }
         }
         $filter['tag'] = null;
     }
     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'])) {
         $oGoods = $this->system->loadModel('trading/goods');
         $keywordsList = $oGoods->getGoodsIdByKeyword($filter['keywords']);
         $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 = $filter['bn'][0];
         } else {
             $sBn = $filter['bn'];
         }
         $bnGoodsId = $this->getGoodsIdByBn($sBn);
         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');
             }
         }
         $filter['bn'] = null;
     }
     foreach ($filter as $k => $v) {
         if (substr($k, 0, 2) == 'p_') {
             $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 != '') {
                 $where[] = $tPre . $k . '=\'' . $v . '\'';
             }
         } else {
             if (substr($k, 0, 2) == 's_') {
                 $sSpecId = array();
                 if (is_array($v)) {
                     foreach ($v as $n) {
                         if ($n !== '_ANY_' && $n != false) {
                             $sSpecId[] = $n;
                         }
                     }
                 }
                 if (count($sSpecId) > 0) {
                     $sGoodsId = $this->db->select('SELECT goods_id FROM sdb_goods_spec_index WHERE spec_value_id IN ( ' . implode(',', $sSpecId) . ' )');
                     $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($filter['price'][0] && $filter['price'][1]){
                         $where[] = 'price >= '.min($filter['price']).' AND price <= '.max($filter['price']);
                     }*/
         unset($filter['price']);
     } else {
         if (($filter['pricefrom'] == 0 || $filter['pricefrom']) && ($filter['priceto'] || $filter['priceto'])) {
             $where[] = 'price >= ' . $filter['pricefrom'] . ' AND price <= ' . $filter['priceto'];
             unset($filter['pricefrom']);
             unset($filter['priceto']);
         }
     }
     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'] = stripslashes($filter['name']);
                 $filter['name'] = preg_replace('/[\'|\\"]/', '+', $filter['name']);
                 $GLOBALS['search'] = $filter['name'];
                 $where[] = $this->wFilter($filter['name']);
             }
         } else {
             //后台搜索
             $GLOBALS['search'] = $filter['name'];
             $where[] = 'name LIKE \'%' . $filter['name'] . '%\'';
         }
         $filter['name'] = null;
     }
     $filter['goods_type'] = 'normal';
     return parent::_filter($filter, $tbase, $where);
 }
Exemplo n.º 19
0
 function _filter($filter)
 {
     $where = array(1);
     if (!empty($filter['payment_id'])) {
         if (is_array($filter['payment_id'])) {
             if ($filter['payment_id'][0] != '_ALL_') {
                 if (!isset($filter['payment_id'][1])) {
                     $where[] = 'payment_id = ' . $this->db->quote($filter['payment_id'][0]) . '';
                 } else {
                     $aOrder = array();
                     foreach ($filter['payment_id'] as $payment_id) {
                         $aOrder[] = 'payment_id=' . $this->db->quote($payment_id) . '';
                     }
                     $where[] = '(' . implode(' OR ', $aOrder) . ')';
                     unset($aOrder);
                 }
             }
         } else {
             $where[] = 'payment_id = ' . $this->db->quote($filter['payment_id']) . '';
         }
         unset($filter['payment_id']);
     }
     if (array_key_exists('uname', $filter) && trim($filter['uname']) != '') {
         $user_data = $this->db->select("select member_id from sdb_members where uname = '" . addslashes($filter['uname']) . "'");
         foreach ($user_data as $tmp_user) {
             $now_user[] = $tmp_user['member_id'];
         }
         $where[] = 'member_id IN (\'' . implode("','", $now_user) . '\')';
         unset($filter['uname']);
     } else {
         if (isset($filter['uname'])) {
             unset($filter['uname']);
         }
     }
     if (isset($filter['username']) && trim($filter['username'])) {
         $op_data = $this->db->select("select op_id from sdb_operators where username = '******'username']) . "'");
         foreach ($op_data as $tmp_op) {
             $now_op[] = $tmp_op['op_id'];
         }
         $where[] = 'op_id IN (\'' . implode("','", $now_op) . '\')';
         unset($filter['username']);
     } else {
         if (isset($filter['username'])) {
             unset($filter['username']);
         }
     }
     return parent::_filter($filter) . ' and ' . implode(' AND ', $where);
 }
Exemplo n.º 20
0
 function _filter($filter)
 {
     $where = array(1);
     if (is_array($filter['gcat'])) {
         foreach ($filter['gcat'] as $giftcat_id) {
             if ($giftcat_id != '_ANY_') {
                 $cats[] = $giftcat_id;
             }
             if (count($cats) > 0) {
                 $where[] = 'giftcat_id in (' . implode($cats, ',') . ')';
             }
         }
     }
     if (is_array($filter['giftcat_id'])) {
         foreach ($filter['giftcat_id'] as $giftcat_id) {
             if ($giftcat_id != '_ANY_') {
                 $giftcats[] = 'giftcat_id=' . intval($giftcat_id);
             }
         }
         if (count($giftcats) > 0) {
             $where[] = '(' . implode($giftcats, ' or ') . ')';
         }
     }
     if (is_array($filter['point'])) {
         foreach ($filter['point'] as $point) {
             if ($point != '_ANY_') {
                 $point = explode('-', $point);
                 $points[] = '(price >=' . $point[0] . ' and price <=' . $point[1] . ')';
             }
         }
         if (count($points) > 0) {
             $where[] = '(' . implode($points, ' or ') . ')';
         }
     }
     if ($filter['name']) {
         $where[] = 'name like\'%' . $filter['name'] . '%\'';
     }
     if (isset($filter['shop_iffb'])) {
         if ($filter['shop_iffb'] === 1) {
             $where[] = 'shop_iffb=\'1\'';
         } else {
             if ($filter['shop_iffb'] == 0) {
                 $where[] = 'shop_iffb=\'0\'';
             }
         }
     }
     if (isset($filter['time_ifvalid'])) {
         if ($filter['time_ifvalid'] == 1) {
             $curTime = time();
             $where[] = 'limit_start_time<=' . $curTime . ' and limit_end_time>' . $curTime;
         }
     }
     if (isset($filter['storage_ifenough'])) {
         if ($filter['storage_ifenough'] === 1) {
             //                $where[] = '(storage-freez>0)';
             $where[] = 'storage > 0';
             //赠品不考虑库存冻结
         }
     }
     return parent::_filter($filter) . ' and ' . implode($where, ' and ');
 }
Exemplo n.º 21
0
 function _filter($filter)
 {
     $where = array(1);
     if (is_array($filter['status'])) {
         foreach ($filter['status'] as $state) {
             if ($state != '_ANY_') {
                 $aState[] = $state;
             }
             if (count($aState) > 0) {
                 $where[] = 'status in (\'' . implode($aState, '\',\'') . '\')';
             }
         }
         unset($filter['status']);
     }
     if (is_array($filter['pay_status'])) {
         foreach ($filter['pay_status'] as $paystate) {
             if ($paystate !== '_ANY_') {
                 $aPaystate[] = intval($paystate);
             }
         }
         if (count($aPaystate) > 0) {
             $where[] = 'pay_status IN (' . implode($aPaystate, ',') . ')';
         }
         unset($filter['pay_status']);
     }
     if (is_array($filter['ship_status'])) {
         foreach ($filter['ship_status'] as $shipstate) {
             if ($shipstate !== '_ANY_') {
                 $aShipstate[] = intval($shipstate);
             }
         }
         if (count($aShipstate) > 0) {
             $where[] = 'ship_status IN (' . implode($aShipstate, ',') . ')';
         }
         unset($filter['ship_status']);
     }
     if (is_array($filter['areas'])) {
         foreach ($filter['areas'] as $area) {
             if ($area != '_ANY_') {
                 $aArea[] = 'shipping_area = "' . $area . '"';
             }
         }
         if (count($aArea) > 0) {
             $where[] = '(' . implode($aArea, ' OR ') . ')';
         }
         unset($filter['areas']);
     }
     if (is_array($filter['delivery'])) {
         foreach ($filter['delivery'] as $delivery) {
             if ($delivery != '_ANY_') {
                 $aDelivery[] = 'shipping_id = ' . intval($delivery);
             }
         }
         if (count($aDelivery) > 0) {
             $where[] = '(' . implode($aDelivery, ' OR ') . ')';
         }
         unset($filter['delivery']);
     }
     if (is_array($filter['payment'])) {
         foreach ($filter['payment'] as $payment) {
             if ($payment != '_ANY_') {
                 $aPayment[] = 'payment = ' . intval($payment);
             }
         }
         if (count($aPayment) > 0) {
             $where[] = '(' . implode($aPayment, ' OR ') . ')';
         }
         unset($filter['payment']);
     }
     if (isset($filter['order_id'])) {
         if (is_array($filter['order_id'])) {
             if (!isset($filter['order_id'][1])) {
                 $where[] = 'order_id LIKE \'' . $filter['order_id'][0] . '%\'';
             } else {
                 $aOrder = array();
                 foreach ($filter['order_id'] as $order_id) {
                     $aOrder[] = 'order_id="' . $order_id . '"';
                 }
                 $where[] = '(' . implode(' OR ', $aOrder) . ')';
                 unset($aOrder);
             }
         } else {
             $where[] = 'order_id LIKE \'' . $filter['order_id'] . '%\'';
         }
         unset($filter['order_id']);
     }
     if (isset($filter['bn']) && $filter['bn'] !== '') {
         $aId = array(0);
         foreach ($this->db->select('SELECT order_id FROM sdb_order_items WHERE bn LIKE \'' . $filter['bn'] . '%\'') as $rows) {
             $aId[] = 'order_id = \'' . $rows['order_id'] . '\'';
         }
         $where[] = '(' . implode(' OR ', $aId) . ')';
         unset($filter['bn']);
     }
     if (isset($filter['goods_name']) && $filter['goods_name'] !== '') {
         $aId = array(0);
         foreach ($this->db->select('SELECT order_id FROM sdb_order_items WHERE name LIKE \'%' . $filter['goods_name'] . '%\'') as $rows) {
             $aId[] = 'order_id = \'' . $rows['order_id'] . '\'';
         }
         $where[] = '(' . implode(' OR ', $aId) . ')';
         unset($filter['goods_name']);
     }
     if (isset($filter['logi_no']) && $filter['logi_no'] !== '') {
         $objShipping = $this->system->loadModel('trading/shipping');
         $aOrder = $objShipping->getOrdersByLogino($filter['logi_no']);
         $where[] = 'order_id IN (\'' . implode("','", $aOrder) . '\')';
     }
     if (isset($filter['ship_name'])) {
         $where[] = 'ship_name LIKE \'%' . $filter['ship_name'] . '%\'';
         unset($filter['ship_name']);
     }
     if (isset($filter['createtime'])) {
         $where[] = 'createtime > \'' . $filter['createtime'] . '\'';
         unset($filter['createtime']);
     }
     if (isset($filter['ship_addr'])) {
         $where[] = 'ship_addr LIKE \'%' . $filter['ship_addr'] . '%\'';
         unset($filter['ship_addr']);
     }
     if (isset($filter['ship_tel'])) {
         $where[] = 'ship_tel LIKE \'%' . $filter['ship_tel'] . '%\'';
         unset($filter['ship_tel']);
     }
     if (isset($filter['member_name']) && $filter['member_name'] !== '') {
         $aId = array(0);
         foreach ($this->db->select('SELECT member_id FROM sdb_members WHERE uname = \'' . $filter['member_name'] . '\'') as $rows) {
             $aId[] = $rows['member_id'];
         }
         $where[] = 'member_id IN (' . implode(',', $aId) . ')';
         unset($filter['member_name']);
     }
     if (isset($filter['return_order_id']) && $filter['return_order_id'] != "") {
         $where[] = 'order_id like "' . $filter['return_order_id'] . '%"';
         unset($filter['return_order_id']);
     }
     if (isset($filter['mark_text'])) {
         $where[] = 'mark_text LIKE \'%' . $filter['mark_text'] . '%\'';
         unset($filter['mark_text']);
     }
     return parent::_filter($filter) . ' and ' . implode($where, ' AND ');
 }
Exemplo n.º 22
0
 function _filter($filter)
 {
     $filter['goods_type'] = 'bind';
     return parent::_filter($filter);
 }
Exemplo n.º 23
0
 function _filter($filter)
 {
     $where = array(1);
     if (is_array($filter['member_lv_id'])) {
         foreach ($filter['member_lv_id'] as $lv) {
             if ($lv != '_ANY_') {
                 $member_lv[] = 'member_lv_id=' . intval($lv);
             }
         }
         if (count($member_lv) > 0) {
             $where[] = '(' . implode($member_lv, ' or ') . ')';
         }
         $filter['member_lv_id'] = '';
     }
     if (isset($filter['name'])) {
         $where[] = 'name LIKE \'' . $filter['name'] . '%\'';
         $filter['name'] = '';
     }
     if ($filter['area'] != "") {
         $pos = strrpos($filter['area'], ':');
         $filter['area'] = substr($filter['area'], 0, $pos);
         $where[] = 'area LIKE \'' . $filter['area'] . '%\'';
         $filter['area'] = '';
     }
     if (is_array($filter['tag'])) {
         foreach ($filter['tag'] as $tag) {
             if ($tag != '_ANY_') {
                 $aTag[] = intval($tag);
             }
         }
         if (count($aTag) > 0) {
             foreach ($this->db->select('SELECT rel_id FROM sdb_tag_rel r
                 LEFT JOIN sdb_tags t ON r.tag_id=t.tag_id
                 WHERE t.tag_type = \'member\' AND r.tag_id IN(' . implode(',', $aTag) . ')') as $rows) {
                 $filter['member_id'][] = $rows['rel_id'];
             }
             if (empty($filter['member_id'])) {
                 $filter['member_id'][] = -1;
             }
         }
         $filter['tag'] = null;
     }
     if (is_array($filter['point'])) {
         foreach ($filter['point'] as $point) {
             if ($point != '_ANY_') {
                 $aPoint = explode('-', $point);
                 $pointSql[] = 'point >= ' . $aPoint[0] . ' AND point <= ' . $aPoint[1];
             }
         }
         if (count($pointSql)) {
             $where[] = '(' . implode(' OR ', $pointSql) . ')';
         }
         unset($filter['point']);
     }
     if ($filter['minregtime'] && $filter['maxregtime']) {
         $where[] = ' (regtime>=' . strtotime($filter['minregtime']) . ' AND regtime<=' . strtotime($filter['maxregtime'] . ' 23:59:59') . ') ';
     } elseif ($filter['minregtime']) {
         $where[] = "regtime>=" . strtotime($filter['minregtime']);
     } elseif ($filter['maxregtime']) {
         $where[] = "regtime<=" . strtotime($filter['maxregtime'] . ' 23:59:59');
     }
     if ($filter['minadvance'] && $filter['maxadvance']) {
         if ($filter['minadvance'] == $filter['maxadvance']) {
             $where[] = 'advance=' . $filter['minadvance'];
         } elseif ($filter['minadvance'] < $filter['maxadvance']) {
             $where[] = ' (advance>=' . $filter['minadvance'] . ' AND advance<=' . $filter['maxadvance'] . ') ';
         }
     } elseif ($filter['minadvance']) {
         $where[] = 'advance>=' . $filter['minadvance'];
     } elseif ($filter['maxadvance']) {
         $where[] = 'advance<=' . $filter['maxadvance'];
     }
     return parent::_filter($filter) . ' AND ' . implode($where, ' AND ');
 }
Exemplo n.º 24
0
 function _filter($filter)
 {
     $where = array(1);
     $where[] = 'pmt_type=\'0\'';
     return parent::_filter($filter) . ' and ' . implode($where, ' and ');
 }
Exemplo n.º 25
0
 function _filter($filter)
 {
     $where = array(1);
     $aId = array(0);
     $aBrand = array();
     if (isset($filter['brand_id']) && is_array($filter['brand_id'])) {
         foreach ($filter['brand_id'] as $brand_id) {
             if ($brand_id != '_ANY_') {
                 $aBrand[] = intval($brand_id);
             }
         }
         if (count($aBrand) > 0) {
             foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND brand_id IN(' . implode(',', $aBrand) . ')') as $rows) {
                 $aId[] = $rows['goods_id'];
             }
         }
         unset($filter['brand_id']);
     }
     $aTag = array();
     if (isset($filter['tag']) && is_array($filter['tag'])) {
         foreach ($filter['tag'] as $tag) {
             if ($tag != '_ANY_') {
                 $aTag[] = intval($tag);
             }
         }
         if (count($aTag) > 0) {
             $tagId = array(0);
             foreach ($this->db->select('SELECT rel_id FROM sdb_tag_rel r LEFT JOIN sdb_tags t ON r.tag_id=t.tag_id WHERE t.tag_type = \'goods\' AND r.tag_id IN(' . implode(',', $aTag) . ')') as $rows) {
                 $tagId[] = $rows['rel_id'];
             }
             if (count($aBrand) > 0) {
                 $aId = array_intersect($aId, $tagId);
             } else {
                 $aId = $tagId;
             }
         }
         unset($filter['tag']);
     }
     if (count($aTag) || count($aBrand)) {
         $where[] = 'goods_id IN (' . implode(',', $aId) . ')';
     }
     if (isset($filter['product_id']) && is_array($filter['product_id'])) {
         foreach ($filter['product_id'] as $goods_id) {
             if ($goods_id != '_ANY_') {
                 $goods[] = intval($goods_id);
             }
         }
         if (count($goods) > 0) {
             $where[] = 'product_id IN (' . implode(',', $goods) . ')';
         }
     }
     if (isset($filter['notifytime']) && is_array($filter['notifytime'])) {
         $where[] = 'creat_time > ' . $filter['notifytime'];
     }
     if (isset($filter['price']) && is_array($filter['price'])) {
         foreach ($filter['price'] as $price) {
             if ($price != '_ANY_') {
                 $aPrice = explode('-', $price);
                 $aWhere[] = '(price >= ' . $aPrice[0] . ' AND price <= ' . $aPrice[1] . ')';
             }
         }
         if (!empty($aWhere)) {
             $where[] = '(' . implode(' OR ', $aWhere) . ')';
         }
         unset($filter['price']);
     }
     return parent::_filter($filter) . ' AND goods_id IS NOT NULL AND ' . implode(' AND ', $where) . (isset($filter['store_alarm']) ? ' AND store <=' . intval($filter['store_alarm']) : '');
 }