Exemple #1
0
/**
 * 获取指定栏目id一下的所有子分类id
 * @param type $cateid
 */
function getCateSubIds($cateid)
{
    $ret_Sun_cate_id = array();
    $db = System::load_sys_class('model');
    $sun_cate = $db->GetList("SELECT cateid from `@#_category` where `parentid` = '{$cateid}'");
    if ($sun_cate) {
        foreach ($sun_cate as $v) {
            $ret_Sun_cate_id[] = $v['cateid'];
            $ret_Sun_cate_id = array_merge($ret_Sun_cate_id, getCateSubIds($v['cateid']));
        }
    }
    return $ret_Sun_cate_id;
}
Exemple #2
0
 public function jf_glist()
 {
     $select = $this->segment(4) ? $this->segment(4) : '0_0_0';
     $select = explode("_", $select);
     $select[] = '0';
     $select[] = '0';
     $cid = abs(intval($select[0]));
     $bid = abs(intval($select[1]));
     $order = abs(intval($select[2]));
     $orders = '';
     switch ($order) {
         case '1':
             $orders = 'order by `shenyurenshu` ASC';
             break;
         case '2':
             $orders = "and `renqi` = '1'";
             break;
         case '3':
             $orders = 'order by `shenyurenshu` ASC';
             break;
         case '4':
             $orders = 'order by `time` DESC';
             break;
         case '5':
             $orders = 'order by `money` DESC';
             break;
         case '6':
             $orders = 'order by `money` ASC';
             break;
         default:
             $orders = 'order by `shenyurenshu` ASC';
     }
     /* 设置了查询分类ID 和品牌ID */
     if (!$cid) {
         $brand = $this->db->GetList("select id,cateid,name from `@#_jf_brand` where 1 order by `order` DESC");
         $daohang_title = '所有分类';
     } else {
         $brand = $this->db->GetList("select id,cateid,name from `@#_jf_brand` where `cateid` LIKE '%{$cid}%' order by `order` DESC");
         $daohang = $this->db->GetOne("select cateid,name,parentid,info from `@#_category` where `cateid` = '{$cid}' LIMIT 1");
         $daohang['info'] = unserialize($daohang['info']);
         $daohang_title = empty($daohang['info']['meta_title']) ? $daohang['name'] : $daohang['info']['meta_title'];
         $keywords = $daohang['info']['meta_keywords'];
         $description = $daohang['info']['meta_description'];
     }
     $title = $daohang_title . "_商品列表_" . _cfg("web_name");
     //分页
     $num = 20;
     /* 设置了查询分类ID 和品牌ID */
     if ($cid && $bid) {
         $sun_id_str = "'" . $cid . "'";
         //$sun_cate = $this->db->GetList("SELECT cateid from `@#_category` where `parentid` = '$daohang[cateid]'");
         //foreach ($sun_cate as $v) {
         //    $sun_id_str .= "," . "'" . $v['cateid'] . "'";
         //}
         $sun_cate = getCateSubIds($daohang['cateid']);
         $sun_id_str .= ",'" . implode("','", $sun_cate) . "'";
         echo "==>{$sun_id_str}<br>\n";
         $total = $this->db->GetCount("select id from `@#_jf_shoplist` WHERE zongrenshu!=canyurenshu and `q_uid` is null and `brandid`='{$bid}'  and `cateid` in ({$sun_id_str})");
     } else {
         if ($bid) {
             $total = $this->db->GetCount("select id from `@#_jf_shoplist` WHERE zongrenshu!=canyurenshu and `q_uid` is null and `brandid`='{$bid}'");
         } elseif ($cid) {
             $sun_id_str = "'" . $cid . "'";
             //                $sun_cate = $this->db->GetList("SELECT cateid from `@#_category` where `parentid` = '$daohang[cateid]'");
             //                foreach ($sun_cate as $v) {
             //                    $sun_id_str .= "," . "'" . $v['cateid'] . "'";
             //                }
             $sun_cate = getCateSubIds($daohang['cateid']);
             $sun_id_str .= ",'" . implode("','", $sun_cate) . "'";
             $total = $this->db->GetCount("select id from `@#_jf_shoplist` WHERE zongrenshu!=canyurenshu and `q_uid` is null and `cateid` in ({$sun_id_str})");
         } else {
             $total = $this->db->GetCount("select id from `@#_jf_shoplist` WHERE zongrenshu!=canyurenshu and `q_uid` is null");
         }
     }
     $page = System::load_sys_class('page');
     if (isset($_GET['p'])) {
         $pagenum = $_GET['p'];
     } else {
         $pagenum = 1;
     }
     $page->config($total, $num, $pagenum, "0");
     if ($pagenum > $page->page) {
         $pagenum = $page->page;
     }
     if ($cid && $bid) {
         $shoplist = $this->db->GetPage("select * from `@#_jf_shoplist` where zongrenshu!=canyurenshu and `q_uid` is null and `brandid`='{$bid}' and `cateid` in ({$sun_id_str}) {$orders}", array("num" => $num, "page" => $pagenum, "type" => 1, "cache" => 0));
     } else {
         if ($bid) {
             $shoplist = $this->db->GetPage("select * from `@#_jf_shoplist` where zongrenshu!=canyurenshu and `q_uid` is null and `brandid`='{$bid}' {$orders}", array("num" => $num, "page" => $pagenum, "type" => 1, "cache" => 0));
         } elseif ($cid) {
             $shoplist = $this->db->GetPage("select * from `@#_jf_shoplist` where zongrenshu!=canyurenshu and `q_uid` is null and `cateid` in ({$sun_id_str}) {$orders}", array("num" => $num, "page" => $pagenum, "type" => 1, "cache" => 0));
         } else {
             $shoplist = $this->db->GetPage("select * from `@#_jf_shoplist` where zongrenshu!=canyurenshu and `q_uid` is null {$orders}", array("num" => $num, "page" => $pagenum, "type" => 1, "cache" => 0));
         }
     }
     $this_time = time();
     include templates("index", "jf_glist");
 }