function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order) { $cate_where = $cate > 0 ? 'AND ' . get_children($cate) : ''; /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price, g.is_new,' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, " . '(select AVG(r.comment_rank) from ' . $GLOBALS['ecs']->table('comment') . ' as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_rank, ' . '(select IFNULL(sum(og.goods_number), 0) from ' . $GLOBALS['ecs']->table('order_goods') . ' as og where og.goods_id = g.goods_id) AS sell_number, ' . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order}"; $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($GLOBALS['display'] == 'grid') { $arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_sn'] = $row['goods_sn']; $arr[$row['goods_id']]['comment_rank'] = $row['comment_rank']; $arr[$row['goods_id']]['sell_number'] = $row['sell_number']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $arr; }
function setSomeGoodsValue(&$goods, $dsct) { $dsct['discountVal'] = floatval($dsct['discountVal']); if ($dsct['discountType'] == 2) { if ($dsct['discountVal'] > 100 || $dsct['discountVal'] < 0) { $dsct['discountVal'] = 100; } } foreach ($goods as $k => $v) { $goods[$k]['url'] = build_uri('goods', array('gid' => $goods[$k]['goods_id']), $goods[$k]['goods_name']); switch ($dsct['discountType']) { case 1: //现金减免 $goods[$k]['discountPrice'] = $goods[$k]['market_price'] - $dsct['discountVal'] > 0 ? $goods[$k]['market_price'] - $dsct['discountVal'] : 0; break; case 2: //打折 $goods[$k]['discountPrice'] = $goods[$k]['market_price'] * $dsct['discountVal'] / 100.0; break; } $goods[$k]['shop_price'] = price_format($goods[$k]['shop_price']); $goods[$k]['market_price'] = price_format($goods[$k]['market_price']); $goods[$k]['discountPrice'] = price_format($goods[$k]['discountPrice']); } }
function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order) { $cate_where = 0 < $cate ? "AND " . get_children($cate) : ""; $sql = "SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price,g.is_promote, g.is_new, g.is_best, g.is_hot," . ("IFNULL(mp.user_price, g.shop_price * '" . $_SESSION['discount'] . "') AS shop_price, g.promote_price, ") . "(select AVG(r.comment_rank) from " . $GLOBALS['ecs']->table("comment") . " as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_rank, (select IFNULL(sum(r.id_value), 0) from " . $GLOBALS['ecs']->table("comment") . " as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_count, (select IFNULL(sum(og.goods_number), 0) from " . $GLOBALS['ecs']->table("order_goods") . " as og where og.goods_id = g.goods_id) AS sell_number, g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM " . $GLOBALS['ecs']->table("goods") . " AS g LEFT JOIN " . $GLOBALS['ecs']->table("member_price") . " AS mp " . ("ON mp.goods_id = g.goods_id AND mp.user_rank = '" . $_SESSION['user_rank'] . "' ") . ("WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '" . $brand_id . "' {$cate_where}") . ("ORDER BY " . $sort . " {$order}"); $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if (0 < $row['promote_price']) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($GLOBALS['display'] == "grid") { $arr[$row['goods_id']]['short_name'] = 0 < $GLOBALS['_CFG']['goods_name_length'] ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_sn'] = $row['goods_sn']; $arr[$row['goods_id']]['comment_count'] = $row['comment_count']; $arr[$row['goods_id']]['comment_rank'] = $row['comment_rank']; $arr[$row['goods_id']]['sell_number'] = $row['sell_number']; $arr[$row['goods_id']]['is_promote'] = $row['is_promote']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['promote_price'] = 0 < $promote_price ? price_format($promote_price) : ""; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], TRUE); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri("goods", array("gid" => $row['goods_id']), $row['goods_name']); } return $arr; }
/** * 获得文章分类下的文章列表 * * @access public * @param integer $cat_id * @param integer $page * @param integer $size * * @return array */ function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '') { //取出所有非0的文章 if ($cat_id == '-1') { $cat_str = 'cat_id > 0'; } else { $cat_str = get_article_children($cat_id); } //增加搜索条件,如果有搜索内容就进行搜索 if ($requirement != '') { $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('ecsmart_article') . ' WHERE is_open = 1 AND title like \'%' . $requirement . '%\' ' . ' ORDER BY article_type DESC, article_id DESC'; } else { $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('ecsmart_article') . ' WHERE is_open = 1 AND ' . $cat_str . ' ORDER BY article_type DESC, article_id DESC'; } $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); if ($res) { while ($row = $GLOBALS['db']->fetchRow($res)) { $article_id = $row['article_id']; $arr[$article_id]['id'] = $article_id; $arr[$article_id]['title'] = $row['title']; $arr[$article_id]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title']; $arr[$article_id]['author'] = empty($row['author']) || $row['author'] == '_SHOPHELP' ? $GLOBALS['_CFG']['shop_name'] : $row['author']; $arr[$article_id]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $article_id), $row['title']) : trim($row['file_url']); $arr[$article_id]['add_time'] = date($GLOBALS['_CFG']['date_format'], $row['add_time']); } } return $arr; }
/** * 获得推荐商品 * * @access public * @param string $type 推荐类型,可以是 best, new, hot * @return array */ function get_index_best($limit = '') { $time = gmtime(); //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中 $sql = 'SELECT g.goods_id, g.goods_name,g.click_count, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' "; $sql .= ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = "best" '; $sql .= ' ORDER BY g.sort_order, g.last_update DESC'; $sql .= " {$limit}"; $result = $GLOBALS['db']->getAll($sql); foreach ($result as $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : ''; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = '../' . get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = '../' . get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $goods[$idx]['sell_count'] = selled_count($row['goods_id']); $goods[$idx]['pinglun'] = get_evaluation_sum($row['goods_id']); $goods[$idx]['count'] = selled_count($row['goods_id']); $goods[$idx]['click_count'] = $row['click_count']; } return $goods; }
/** * 调用购物车信息 * * @access public * @return string */ function insert_cart_info() { $sql = 'SELECT c.*,g.goods_name,g.goods_thumb,g.goods_id,c.goods_number,c.goods_price' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " AS c " . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON g.goods_id=c.goods_id " . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'"; $row = $GLOBALS['db']->GetAll($sql); $arr = array(); foreach ($row as $k => $v) { $arr[$k]['goods_thumb'] = get_image_path($v['goods_id'], $v['goods_thumb'], true); $arr[$k]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($v['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $v['goods_name']; $arr[$k]['url'] = build_uri('goods', array('gid' => $v['goods_id']), $v['goods_name']); $arr[$k]['goods_number'] = $v['goods_number']; $arr[$k]['goods_name'] = $v['goods_name']; $arr[$k]['goods_price'] = price_format($v['goods_price']); $arr[$k]['rec_id'] = $v['rec_id']; } $sql = 'SELECT SUM(goods_number) AS number, SUM(goods_price * goods_number) AS amount' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'"; $row = $GLOBALS['db']->GetRow($sql); if ($row) { $number = intval($row['number']); $amount = floatval($row['amount']); } else { $number = 0; $amount = 0; } $GLOBALS['smarty']->assign('str', sprintf($GLOBALS['_LANG']['cart_info'], $number, price_format($amount, false))); $GLOBALS['smarty']->assign('goods', $arr); $output = $GLOBALS['smarty']->fetch('library/cart_info.lbi'); return $output; }
/** * 取得当前活动信息 * * @access public * * @return 活动名称 */ function get_snatch($id) { $sql = "SELECT g.goods_id, g.goods_sn, g.is_real, g.goods_name, g.extension_code, g.market_price, g.shop_price AS org_price, product_id, " . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "g.promote_price, g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb,g.goods_img, " . "ga.act_name AS snatch_name, ga.start_time, ga.end_time, ga.ext_info, ga.act_desc AS `desc` " . "FROM " . $this->pre . "goods_activity AS ga " . "LEFT JOIN " . $this->pre . "goods AS g " . "ON g.goods_id = ga.goods_id " . "LEFT JOIN " . $this->pre . "member_price AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE ga.act_id = '{$id}' AND g.is_delete = 0"; $goods = $this->row($sql); if ($goods) { $promote_price = bargain_price($goods['promote_price'], $goods['promote_start_date'], $goods['promote_end_date']); $goods['formated_market_price'] = price_format($goods['market_price']); $goods['formated_shop_price'] = price_format($goods['shop_price']); $goods['formated_promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $goods['goods_thumb'] = get_image_path($goods['goods_id'], $goods['goods_thumb'], true); $goods['goods_img'] = get_image_path($goods['goods_id'], $goods['goods_img'], true); $goods['url'] = build_uri('goods', array('gid' => $goods['goods_id']), $goods['goods_name']); $goods['start_time'] = local_date(C('time_format'), $goods['start_time']); $info = unserialize($goods['ext_info']); if ($info) { foreach ($info as $key => $val) { $goods[$key] = $val; } $goods['is_end'] = gmtime() > $goods['end_time']; $goods['formated_start_price'] = price_format($goods['start_price']); $goods['formated_end_price'] = price_format($goods['end_price']); $goods['formated_max_price'] = price_format($goods['max_price']); } /* 将结束日期格式化为格林威治标准时间时间戳 */ $goods['gmt_end_time'] = $goods['end_time']; $goods['end_time'] = local_date(C('time_format'), $goods['end_time']); $goods['snatch_time'] = sprintf(L('snatch_start_time'), $goods['start_time'], $goods['end_time']); return $goods; } else { return false; } }
/** * 调用浏览历史 * * @access public * @return string */ function insert_history() { $time = gmtime(); $str = ''; if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price ,promote_price,promote_start_date,promote_end_date,is_promote FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = $GLOBALS['db']->query($sql); $res = array(); while ($row = $GLOBALS['db']->fetch_array($query)) { $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); if ($row['is_promote'] == 1 && $time > $row['promote_start_date'] && $time < $row['promote_end_date']) { $goods['shop_price'] = price_format($row['promote_price']); } else { $goods['shop_price'] = price_format($row['shop_price']); } $goods['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $str .= '<ul class="clearfix"><li class="goodsimg"><a href="' . $goods['url'] . '" target="_blank"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '" class="B_blue" /></a></li><li><a href="' . $goods['url'] . '" target="_blank" title="' . $goods['goods_name'] . '">' . $goods['short_name'] . '</a><br />' . $GLOBALS['_LANG']['shop_price'] . '<font class="f1">' . $goods['shop_price'] . '</font><br /></li></ul>'; } $str .= '<ul id="clear_history"><a onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</a></ul>'; } return $str; }
function get_child($cat_id) { $sql = 'SELECT cat_id,cat_name ,parent_id ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$cat_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($sql); foreach ($res as $idx => $row) { $array[$idx]['id'] = $row['cat_id']; $array[$idx]['name'] = $row['cat_name']; $array[$idx]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); } return $array; }
/** * 分配帮助信息 * * @access public * @return array */ function get_shop_help() { $sql = 'SELECT c.cat_id, c.cat_name, c.sort_order, a.article_id, a.title, a.file_url, a.open_type ' . 'FROM ' . $this->pre . 'article AS a ' . 'LEFT JOIN ' . $this->pre . 'article_cat AS c ' . 'ON a.cat_id = c.cat_id WHERE c.cat_type = 5 AND a.is_open = 1 ' . 'ORDER BY c.sort_order ASC, a.article_id'; $res = $this->query($sql); $arr = array(); foreach ($res as $key => $row) { $arr[$row['cat_id']]['cat_id'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']); $arr[$row['cat_id']]['cat_name'] = $row['cat_name']; $arr[$row['cat_id']]['article'][$key]['article_id'] = $row['article_id']; $arr[$row['cat_id']]['article'][$key]['title'] = $row['title']; $arr[$row['cat_id']]['article'][$key]['short_title'] = C('article_title_length') > 0 ? sub_str($row['title'], C('article_title_length')) : $row['title']; $arr[$row['cat_id']]['article'][$key]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']); } return $arr; }
function get_clild_list($pid) { //开始获取子分类 $sql_sub = "select * from " . $GLOBALS['ecs']->table('category') . " where parent_id=" . $pid . " and is_show=1"; $subres = $GLOBALS['db']->getAll($sql_sub); if ($subres) { foreach ($subres as $sidx => $subrow) { $children[$sidx]['id'] = $subrow['cat_id']; $children[$sidx]['name'] = $subrow['cat_name']; $children[$sidx]['url'] = build_uri('category', array('cid' => $subrow['cat_id']), $subrow['cat_name']); } } else { $children = null; } return $children; }
/** * 获取用户信息 */ public function get_user_info() { $callback = $this->input->get('callback'); if (!is_login()) { exit($callback . "(" . json_encode(array('is_login' => 0)) . ")"); } else { $data = current_user(); $info['user_id'] = $data['uid']; $info['nickname'] = $data['username']; $info['img_url'] = $this->config->item('img3_url') . avatar($data['uid']); $info['profile_url'] = $this->config->item('q_url') . build_uri('u', array('id' => $data['uid'])); $str = 'img_url=' . $info['img_url'] . '&nickname=' . $info['nickname'] . '&profile_url=' . $info['profile_url'] . '&user_id=' . $info['user_id']; $info['user']['sign'] = $this->get_signature($str, '4f7b47c758a7e071f0225035c44cd5a4'); exit($callback . "(" . json_encode(array('is_login' => 1, 'user' => $info)) . ")"); } }
/** * 获得促销商品 * * @access public * @return array */ function get_flash_sale_goods($cats = '') { $time = gmtime(); $order_type = $GLOBALS['_CFG']['recommend_order']; /* 取得促销lbi的数量限制 */ $num = get_library_number("recommend_promotion"); $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, " . "g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ' . " AND g.is_promote = 1 AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}' "; $sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY rnd'; $result = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($result as $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? $promote_price : ''; } else { $goods[$idx]['promote_price'] = ''; } $sql = 'SELECT sum(goods_number) AS goods_number FROM ' . $GLOBALS['ecs']->table('order_goods') . ' WHERE goods_id =' . $row['goods_id'] . ' GROUP BY goods_id'; $goods_number = $GLOBALS['db']->getOne($sql); if (empty($goods_number)) { $goods_number = 0; } if (!empty($row['promote_end_date'])) { $goods[$idx]['end_date'] = $row['promote_end_date']; } $goods[$idx]['soldnum'] = get_soldnum($row['goods_id']); $goods[$idx]['jiesheng'] = $row['market_price'] - $row['promote_price']; $goods[$idx]['zhekou'] = sprintf("%1\$.1f", $row['promote_price'] / $row['shop_price'] * 10); $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['number'] = $goods_number; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $goods[$idx]['market_price'] = $row['market_price']; $goods[$idx]['shop_price'] = $row['shop_price']; $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $properties = get_goods_properties($row['goods_id']); // 获得商品的规格和属性 $goods[$idx]['pro'] = $properties['pro']['商品属性']; } return $goods; }
/** * 取得某页的批发商品 * @param int $size 每页记录数 * @param int $page 当前页 * @param string $where 查询条件 * @return array */ function wholesale_list($size, $page, $where) { $list = array(); $sql = "SELECT w.*, g.goods_thumb, g.goods_name as goods_name, g.shop_price, g.market_price " . "FROM " . $this->pre . "wholesale AS w, " . $this->pre . "goods AS g " . $where . " AND w.goods_id = g.goods_id limit " . ($page - 1) * $size . ',' . $size; $res = $this->query($sql); foreach ($res as $row) { $row['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $row['goods_url'] = build_uri('info', array('id' => $row['goods_id']), $row['goods_name']); $properties = model('Goods')->get_goods_properties($row['goods_id']); $row['goods_attr'] = $properties['pro']; $price_ladder = $this->get_price_ladder($row['goods_id']); $row['price_ladder'] = $price_ladder; $row['low_price'] = empty($price_ladder) ? price_format($row['shop_price']) : price_format($this->get_low_price($price_ladder)); $list[] = $row; } return $list; }
function queryListByCatId($cat_id) { $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name, a.content ' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac' . " WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_id = {$cat_id}" . ' ORDER BY a.article_type DESC, a.add_time DESC LIMIT 2'; $res = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($res as $idx => $row) { $arr[$idx]['id'] = $row['article_id']; $arr[$idx]['title'] = $row['title']; $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title']; $arr[$idx]['cat_name'] = $row['cat_name']; $arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); $arr[$idx]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']); $arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']); $arr[$idx]['content'] = strip_tags($row['content']); $arr[$idx]['file_url'] = $row['file_url']; } return $arr; }
function show_tree($categories, $letters, $properties, $category_letter_index) { $content = ''; foreach ($categories as $rs) { $hide = is_hide($letters, $category_letter_index, $rs->id); $content = $content . '<li' . ($rs->children && $hide == false ? ' class="plus"' : '') . '>'; if (in_array($rs->letter, $letters)) { $content = $content . '<a class="c" href="/' . build_uri($letters, $properties, $category_letter_index, $rs->letter) . '">' . $rs->name . '</a>'; } else { $content = $content . '<a href="/' . build_uri($letters, $properties, $category_letter_index, $rs->letter) . '">' . $rs->name . '</a>'; } $content = $content . '</li>'; if ($rs->children) { $content = $content . '<ul' . ($hide || in_array($rs->letter, $letters) ? ' class="show"' : '') . '>' . show_tree($rs->children, $letters, $properties, $category_letter_index) . '</ul>'; } } return $content; }
/** * 取得某页的拍卖活动 * @param int $size 每页记录数 * @param int $page 当前页 * @param str $sort 分类 * @param str $order 排序 * @return array */ function auction_list($size, $page, $sort, $order) { $auction_list = array(); $auction_list['finished'] = $auction_list['finished'] = array(); $now = gmtime(); $start = ($page - 1) * $size; $sort = $sort != 'goods_id' ? 't.' . $sort : $sort; $sql = "SELECT a.*,t.act_banner ,t.sales_count ,t.click_num , IFNULL(g.goods_thumb, '') AS goods_thumb " . "FROM " . $this->pre . "goods_activity AS a " . "LEFT JOIN " . $this->pre . "goods AS g ON a.goods_id = g.goods_id " . "LEFT JOIN " . $this->pre . "touch_goods_activity AS t ON a.act_id = t.act_id " . "LEFT JOIN " . $this->pre . "touch_goods as tg ON g.goods_id = tg.goods_id " . "WHERE a.act_type = '" . GAT_AUCTION . "' " . "AND a.start_time <= '{$now}' AND a.end_time >= '{$now}' AND a.is_finished < 2 ORDER BY {$sort} {$order} LIMIT {$start} ,{$size} "; $res = $this->query($sql); foreach ($res as $row) { $ext_info = unserialize($row['ext_info']); $auction = array_merge($row, $ext_info); $auction['status_no'] = auction_status($auction); $auction['start_time'] = local_date(C('time_format'), $auction['start_time']); $auction['end_time'] = local_date(C('time_format'), $auction['end_time']); $auction['formated_start_price'] = price_format($auction['start_price']); $auction['formated_end_price'] = price_format($auction['end_price']); $auction['formated_deposit'] = price_format($auction['deposit']); $auction['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $auction['act_banner'] = $row['act_banner'] ? $row['act_banner'] : $auction['goods_thumb']; $auction['url'] = build_uri('info', array('id' => $auction['act_id'])); if ($auction['status_no'] < 2) { $auction_list['under_way'][] = $auction; } else { $auction_list['finished'][] = $auction; } //增加扩展表判断 $sql = 'SELECT count(*) as count FROM ' . $this->pre . "touch_goods_activity WHERE `act_id` = '" . $auction['act_id'] . "'"; $res = $this->row($sql); if ($res['count']) { $this->table = 'touch_goods_activity'; $data['cur_price'] = $auction['start_price']; $condition['act_id'] = $auction['act_id']; $this->update($condition, $data); } else { $this->table = 'touch_goods_activity'; $data1['act_id'] = $auction['act_id']; $data1['cur_price'] = $auction['start_price']; $this->insert($data1); } } $auction_list = @array_merge($auction_list['under_way'], $auction_list['finished']); return $auction_list; }
/** * 调用浏览历史 * * @access public * @return string */ function insert_history() { $str = ''; $history = array(); if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . M()->pre . 'goods' . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = M()->query($sql); $res = array(); foreach ($query as $key => $row) { $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('goods_name_length')) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods['shop_price'] = price_format($row['shop_price']); $goods['url'] = build_uri('goods/index', array('gid' => $row['goods_id']), $row['goods_name']); $history[] = $goods; } } return $history; }
function get_all_brand() { $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo,b.blogo " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b where b.is_show=1 ORDER BY b.sort_order desc"; $row = $GLOBALS['db']->getAll($sql); $brand_en = array(); foreach ($row as $key => $val) { $val['url'] = build_uri('brand', array('cid' => $cat, 'bid' => $val['brand_id']), $val['brand_name']); $val['brand_logo'] = '/data/brandlogo/' . $val['brand_logo']; $val['brand_text'] = '/data/brandlogo/' . $val['blogo']; preg_match("/([a-zA-Z\\s0-9\\.\\']*)/is", $val['brand_name'], $en); $kvalue = substr($en[1], 0, 1); if ($kvalue) { $brand_en[strtoupper($kvalue)][] = $val; } } if ($brand_en) { ksort($brand_en); } //print_r($brand_en); return $brand_en; }
/** * 调用浏览历史 */ function insert_siy_history() { $str = ''; if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = $GLOBALS['db']->query($sql); $res = array(); $str .= '<div id="history" class="box"> <b class="tp"><b></b></b> <div class="hd"><h3>' . $GLOBALS['_LANG']['view_history'] . '</h3><span class="more" onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</span></div> <div class="bd"> <ul class="goods-list">'; while ($row = $GLOBALS['db']->fetch_array($query)) { $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods['shop_price'] = price_format($row['shop_price']); $goods['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $str .= ' <li> <span class="photo"> <a href="' . $goods['url'] . '" title="' . $goods['goods_name'] . '" class="image"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '"/></a> </span> <span class="info"> <a href="' . $goods['url'] . '" title="' . $goods['goods_name'] . '" class="name">' . $goods['short_name'] . '</a> <em class="price">' . $goods['shop_price'] . '</em> </span> <span class="action"> <a href="' . $goods['url'] . '" class="detail">' . $GLOBALS['_LANG']['btn_detail'] . '</a> </span> </li>'; } $str .= ' </ul> </div> <b class="bt"><b></b></b> </div>'; } return $str; }
/** * 调用浏览历史 * * @access public * @return string */ function insert_history() { $str = ''; if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql = 'SELECT goods_id, goods_name FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = $GLOBALS['db']->query($sql); $res = array(); while ($row = $GLOBALS['db']->fetch_array($query)) { $res[$row['goods_id']] = $row; } $tureorder = explode(',', $_COOKIE['ECS']['history']); foreach ($tureorder as $key => $val) { $goods_name = htmlspecialchars($res[$val]['goods_name']); if ($goods_name) { $short_name = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($goods_name, $GLOBALS['_CFG']['goods_name_length']) : $goods_name; $str .= '<li><a href="' . build_uri('goods', array('gid' => $val), $goods_name) . '" title="' . $goods_name . '">' . $short_name . '</a></li>'; } } } return $str; }
/** * 获得文章关联的商品 * * @access public * @param integer $id * @return array */ function article_related_goods($id) { $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' . 'FROM ' . $GLOBALS['ecs']->table('goods_article') . ' ga ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = ga.goods_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE ga.article_id = '{$id}' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0"; $res = $GLOBALS['db']->query($sql); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); if ($row['promote_price'] > 0) { $arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']); } else { $arr[$row['goods_id']]['promote_price'] = 0; } } return $arr; }
/** * 获取指定用户的收藏商品列表 * * @access public * @param int $user_id 用户ID * @param int $num 列表最大数量 * @param int $start 列表其实位置 * * @return array $arr */ function get_collection_goods($user_id, $num = 10, $start = 0) { $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, g.promote_start_date,g.promote_end_date, c.rec_id, c.is_attention' . ' FROM ' . $GLOBALS['ecs']->table('collect_goods') . ' AS c' . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g " . "ON g.goods_id = c.goods_id " . " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " WHERE c.user_id = '{$user_id}' ORDER BY c.rec_id DESC"; $res = $GLOBALS['db']->selectLimit($sql, $num, $start); $goods_list = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $goods_list[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods_list[$row['goods_id']]['rec_id'] = $row['rec_id']; $goods_list[$row['goods_id']]['is_attention'] = $row['is_attention']; $goods_list[$row['goods_id']]['goods_id'] = $row['goods_id']; $goods_list[$row['goods_id']]['goods_name'] = $row['goods_name']; $goods_list[$row['goods_id']]['market_price'] = number_format($row['market_price'], 2, '.', '.'); $goods_list[$row['goods_id']]['shop_price'] = number_format($row['shop_price']); $goods_list[$row['goods_id']]['promote_price'] = $promote_price > 0 ? number_format($promote_price) : ''; $goods_list[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $goods_list; }
function setSomeGoodsValue(&$goods, $dsct, $shangouActivty) { $dsct['discountVal'] = convertStringToIntegerArr($dsct['discountVal']); foreach ($goods as $k => $v) { $goods[$k]['url'] = build_uri('goods', array('gid' => $goods[$k]['goods_id']), $goods[$k]['goods_name']); switch ($dsct['discountType']) { case 1: //现金减免 $goods[$k]['discountPrice'] = $goods[$k]['market_price'] - $dsct['discountVal'][$k] > 0 ? $goods[$k]['market_price'] - $dsct['discountVal'][$k] : 0; break; case 2: //打折 $goods[$k]['discountPrice'] = $goods[$k]['market_price'] * floatval($dsct['discountVal'][$k]) / 100.0; break; } $goods[$k]['market_price'] = price_format($goods[$k]['market_price']); $goods[$k]['shop_price'] = price_format($goods[$k]['shop_price']); $goods[$k]['discountPrice'] = price_format($goods[$k]['discountPrice']); $goods[$k]['discount'] = intval($dsct['discountVal'][$k] / 10); $goods[$k]['begin_date'] = local_date("m月d日 H : i", $shangouActivty['start_time']); $goods[$k]['start_time'] = $shangouActivty['start_time']; $goods[$k]['end_time'] = $shangouActivty['end_time']; } }
/*------------------------------------------------------ */ //-- 切换是否显示在导航栏 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'toggle_show_in_nav') { check_authz_json('cat_manage'); $id = intval($_POST['id']); $val = intval($_POST['val']); if (cat_update($id, array('show_in_nav' => $val)) != false) { if ($val == 1) { //显示 $vieworder = $db->getOne("SELECT max(vieworder) FROM " . $ecs->table('nav') . " WHERE type = 'middle'"); $vieworder += 2; $catname = $db->getOne("SELECT cat_name FROM " . $ecs->table('category') . " WHERE cat_id = '{$id}'"); //显示在自定义导航栏中 $_CFG['rewrite'] = 0; $uri = build_uri('category', array('cid' => $id), $catname); $nid = $db->getOne("SELECT id FROM " . $ecs->table('nav') . " WHERE ctype = 'c' AND cid = '" . $id . "' AND type = 'middle'"); if (empty($nid)) { //不存在 $sql = "INSERT INTO " . $ecs->table('nav') . " (name,ctype,cid,ifshow,vieworder,opennew,url,type) VALUES('" . $catname . "', 'c', '{$id}','1','{$vieworder}','0', '" . $uri . "','middle')"; } else { $sql = "UPDATE " . $ecs->table('nav') . " SET ifshow = 1 WHERE ctype = 'c' AND cid = '" . $id . "' AND type = 'middle'"; } $db->query($sql); } else { //去除 $db->query("UPDATE " . $ecs->table('nav') . "SET ifshow = 0 WHERE ctype = 'c' AND cid = '" . $id . "' AND type = 'middle'"); } clear_cache_files(); make_json_result($val); } else {
function get_user_backorders($user_id, $num = 10, $start = 0) { /* 取得订单列表 */ $arr = array(); $sql = "SELECT bo.*, g.goods_name " . " FROM " . $GLOBALS['ecs']->table('back_order') . " AS bo left join " . $GLOBALS['ecs']->table('goods') . " AS g " . " on bo.goods_id=g.goods_id " . " WHERE user_id = '{$user_id}' ORDER BY add_time DESC"; $res = $GLOBALS['db']->SelectLimit($sql, $num, $start); while ($row = $GLOBALS['db']->fetchRow($res)) { $row['order_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']); $row['refund_money_1'] = price_format($row['refund_money_1'], false); $row['goods_url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $row['status_back_1'] = $row['status_back']; $row['status_back'] = $GLOBALS['_LANG']['bos'][$row['back_type'] == 4 && $row['status_back'] != 8 ? $row['back_type'] : $row['status_back']] . ' - ' . $GLOBALS['_LANG']['bps'][$row['status_refund']]; $arr[] = $row; } return $arr; }
function get_supplier_goods($gtype = 0) { $gtype = intval($gtype); if ($gtype <= 0) { return; } $sql = "SELECT DISTINCT g.goods_id,g.* FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('supplier_goods_cat') . " AS gc, " . $GLOBALS['ecs']->table('supplier_cat_recommend') . " AS cr \n\tWHERE cr.recommend_type =" . $gtype . " AND cr.supplier_id =" . $_GET['suppId'] . " AND cr.cat_id = gc.cat_id AND gc.goods_id = g.goods_id \n\tAND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 \n\tORDER BY g.sort_order, g.last_update DESC LIMIT 10"; $result = $GLOBALS['db']->getAll($sql); $goods = array(); if ($result) { foreach ($result as $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : ''; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = '../' . get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = '../' . get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } } return $goods; }
/** * 获得指定分类下的子分类的数组 * * @access public * @param int $cat_id 分类的ID * @param int $selected 当前选中分类的ID * @param boolean $re_type 返回的类型: 值为真时返回下拉列表,否则返回数组 * @param int $level 限定返回的级数。为0时返回所有级数 * @return mix */ function article_cat_list($cat_id = 0, $selected = 0, $re_type = true, $level = 0) { static $res = NULL; if ($res === NULL) { $data = read_static_cache('art_cat_pid_releate'); if ($data === false) { $sql = "SELECT c.*, COUNT(s.cat_id) AS has_children, COUNT(a.article_id) AS aricle_num " . ' FROM ' . $GLOBALS['ecs']->table('article_cat') . " AS c" . " LEFT JOIN " . $GLOBALS['ecs']->table('article_cat') . " AS s ON s.parent_id=c.cat_id" . " LEFT JOIN " . $GLOBALS['ecs']->table('article') . " AS a ON a.cat_id=c.cat_id" . " GROUP BY c.cat_id " . " ORDER BY parent_id, sort_order ASC"; $res = $GLOBALS['db']->getAll($sql); write_static_cache('art_cat_pid_releate', $res); } else { $res = $data; } } if (empty($res) == true) { return $re_type ? '' : array(); } $options = article_cat_options($cat_id, $res); // 获得指定分类下的子分类的数组 /* 截取到指定的缩减级别 */ if ($level > 0) { if ($cat_id == 0) { $end_level = $level; } else { $first_item = reset($options); // 获取第一个元素 $end_level = $first_item['level'] + $level; } /* 保留level小于end_level的部分 */ foreach ($options as $key => $val) { if ($val['level'] >= $end_level) { unset($options[$key]); } } } $pre_key = 0; foreach ($options as $key => $value) { $options[$key]['has_children'] = 1; if ($pre_key > 0) { if ($options[$pre_key]['cat_id'] == $options[$key]['parent_id']) { $options[$pre_key]['has_children'] = 1; } } $pre_key = $key; } if ($re_type == true) { $select = ''; foreach ($options as $var) { $select .= '<option value="' . $var['cat_id'] . '" '; $select .= ' cat_type="' . $var['cat_type'] . '" '; $select .= $selected == $var['cat_id'] ? "selected='ture'" : ''; $select .= '>'; if ($var['level'] > 0) { $select .= str_repeat(' ', $var['level'] * 4); } $select .= htmlspecialchars(addslashes($var['cat_name'])) . '</option>'; } return $select; } else { foreach ($options as $key => $value) { $options[$key]['url'] = build_uri('article_cat', array('acid' => $value['cat_id']), $value['cat_name']); } return $options; } }
function get_on_top_goods($id, $num = 5) { $sql = 'SELECT cat_id,cat_name FROM ' . $GLOBALS['ecs']->table('category') . ' WHERE is_on_top = 1 AND parent_id =' . $id; $res = $GLOBALS['db']->getAll($sql); foreach ($res as $idx => $row) { $arr[$idx]['cat_url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); $arr[$idx]['cat_name'] = $row['cat_name']; $children = get_children($row['cat_id']); $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . ') '; $order_rule = 'ORDER BY g.sort_order, g.goods_id DESC'; $sql .= $order_rule; if ($num > 0) { $sql .= ' LIMIT ' . $num; } $goods_res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($goods_res as $goods_idx => $goods_row) { if ($goods_row['promote_price'] > 0) { $promote_price = bargain_price($goods_row['promote_price'], $goods_row['promote_start_date'], $goods_row['promote_end_date']); $goods[$goods_idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$goods_idx]['promote_price'] = ''; } $goods[$goods_idx]['id'] = $goods_row['goods_id']; $goods[$goods_idx]['name'] = $goods_row['goods_name']; $goods[$goods_idx]['brief'] = $goods_row['goods_brief']; $goods[$goods_idx]['market_price'] = price_format($goods_row['market_price']); $goods[$goods_idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($goods_row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $goods_row['goods_name']; $goods[$goods_idx]['shop_price'] = price_format($goods_row['shop_price']); $goods[$goods_idx]['thumb'] = get_image_path($goods_row['goods_id'], $goods_row['goods_thumb'], true); $goods[$goods_idx]['goods_img'] = get_image_path($goods_row['goods_id'], $goods_row['goods_img']); $goods[$goods_idx]['url'] = build_uri('goods', array('gid' => $goods_row['goods_id']), $goods_row['goods_name']); } $arr[$idx]['goods'] = $goods; } return $arr; }
if ($file != "." and $file != ".." and $file_arr[1] == "news") { $arch_arr[] = $file_arr[0]; } } closedir($handle); if (is_array($arch_arr)) { $arch_arr = array_reverse($arch_arr); foreach ($arch_arr as $arch_file) { $news_lines = file(SERVDIR . "/cdata/archives/{$arch_file}.news.arch"); $count = count($news_lines); $last = $count - 1; $first_news_arr = explode("|", $news_lines[$last]); $last_news_arr = explode("|", $news_lines[0]); $first_timestamp = $first_news_arr[0]; $last_timestamp = $last_news_arr[0]; $arch_url = RWU('archread', $PHP_SELF . build_uri('subaction,archive', array('list-archive', $arch_file))); echo "<a href=\"{$arch_url}&{$user_query}\">" . date("d M Y", $first_timestamp) . " - " . date("d M Y", $last_timestamp) . ", (<b>{$count}</b>)</a><br />"; } } } else { if ($CN_HALT != true and $static != true and ($subaction == "showcomments" or $subaction == "showfull" or $subaction == "addcomment") and (!isset($category) or $category == "" or $requested_cats[$ucat] == true)) { if ($subaction == "addcomment") { $allow_add_comment = true; $allow_comments = true; } if ($subaction == "showcomments") { $allow_comments = true; } if (($subaction == "showcomments" or $allow_comments == true) and $config_show_full_with_comments == "yes") { $allow_full_story = true; }