function get_all_distrib_goods() { $sql = "SELECT g.goods_id,g.goods_name,g.goods_thumb,g.shop_price,g.market_price FROM " . $GLOBALS['ecs']->table('ecsmart_distrib_goods') . " as dg," . $GLOBALS['ecs']->table('goods') . " as g WHERE dg.goods_id = g.goods_id AND (dg.distrib_time = 0 OR (dg.start_time <='" . gmtime() . "' AND dg.end_time >= '" . gmtime() . "')) limit 10"; $list = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($list as $key => $val) { $arr[$key]['goods_id'] = $val['goods_id']; $arr[$key]['goods_name'] = $val['goods_name']; $arr[$key]['goods_thumb'] = $val['goods_thumb']; $arr[$key]['shop_price'] = $val['shop_price']; $arr[$key]['market_price'] = $val['market_price']; $arr[$key]['wap_count'] = selled_wap_count($val['goods_id']); } return $arr; }
function index_topic_goods($index_goods_id) { global $ecs, $db; $buf = array(); $ids = explode(",", $index_goods_id); $n_ids = array(); foreach ($ids as $k => $v) { $v = intval(trim($v)); if (!$v) { continue; } $n_ids[] = $v; } $index_goods_id = implode(",", $n_ids); if (!$index_goods_id) { return $buf; } $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, 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, 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.goods_id in ({$index_goods_id})"; $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { $row['market_price'] = price_format($row['market_price']); $row['shop_price'] = price_format($row['shop_price']); $row['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $row['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $row['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $row['short_name'] = sub_str($row['goods_name'], 8); $row['short_name2'] = sub_str($row['goods_name'], 12); $row['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $row['goods_img'] = get_image_path($row['goods_id'], $row['goods_thumb']); $row['wap_count'] = selled_wap_count($row['goods_id']); $row['short_style_name'] = add_style($row['short_name'], $row['goods_name_style']); if ($display == 'grid') { $row['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $row['goods_name'] = $row['goods_name']; } $buf[] = $row; } return $buf; }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order, $limit = '') { $display = $GLOBALS['display']; $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 AND ({$children} OR " . get_extension_goods($children) . ')'; if ($brand > 0) { $where .= "AND g.brand_id={$brand} "; } if ($min > 0) { $where .= " AND g.shop_price >= {$min} "; } if ($max > 0) { $where .= " AND g.shop_price <= {$max} "; } /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . '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 {$where} {$ext} ORDER BY {$sort} {$order} {$limit}"; /* 代码增加_start By www.68ecshop.com */ if ($sort == 'salenum') { $sql = 'SELECT SUM(o.goods_number) as salenum, g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . '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']}' " . "LEFT JOIN " . $GLOBALS['ecs']->table('order_goods') . " as o ON o.goods_id = g.goods_id " . "WHERE {$where} {$ext} group by g.goods_id ORDER BY {$sort} {$order} {$limit}"; } /* 代码增加_end By www.68ecshop.com */ if (empty($limit)) { $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); } else { $res = $GLOBALS['db']->query($sql); } $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; } /* 处理商品水印图片 */ $watermark_img = ''; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } elseif ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } elseif ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } elseif ($row['is_hot'] != 0) { $watermark_img = 'watermark_hot_small'; } if ($watermark_img != '') { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($display == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $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']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $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']); $arr[$row['goods_id']]['wap_count'] = selled_wap_count($row['goods_id']); $arr[$row['goods_id']]['wap_pingjia'] = get_evaluation_sum($row['goods_id']); } return $arr; }
/** * 获得品牌下的商品 * * @access private * @param integer $brand_id * @return array */ function brand_get_goods($brand_id, $cate, $size, $page, $sort, $order, $ext = '', $limit = '') { $cate_where = $cate > 0 ? 'AND ' . get_children($cate) : ''; /* 获得商品列表 */ $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, " . '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 {$ext} AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order} {$limit}"; /* 代码增加_start By www.68ecshop.com */ if ($sort == 'salenum') { $sql = 'SELECT SUM(o.goods_number) as salenum, g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . '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']}' " . "LEFT JOIN " . $GLOBALS['ecs']->table('order_goods') . " as o ON o.goods_id = g.goods_id " . " WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 {$ext} AND g.brand_id = '{$brand_id}' {$cate_where} group by g.goods_id ORDER BY {$sort} {$order} {$limit}"; } /* 代码增加_end By www.68ecshop.com */ if (empty($limit)) { $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); } else { $res = $GLOBALS['db']->query($sql); } $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']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $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']; //yyy修改start $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']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; //yyy修改end $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['wap_count'] = selled_wap_count($row['goods_id']); $arr[$row['goods_id']]['wap_pingjia'] = get_evaluation_sum($row['goods_id']); } return $arr; }
$arr[$row['goods_id']]['type'] = $row['goods_type']; $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']]['click_count'] = $row['click_count']; //yyy添加start $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']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['wap_pingjia'] = get_evaluation_sum($row['goods_id']); //yyy添加end $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['wap_count'] = selled_wap_count($row['goods_id']); } if ($display == 'grid') { if (count($arr) % 2 != 0) { $arr[] = array(); } } $smarty->assign('goods_list', $arr); $smarty->assign('category', $category); $smarty->assign('keywords', htmlspecialchars(stripslashes($_REQUEST['keywords']))); $smarty->assign('search_keywords', stripslashes(htmlspecialchars_decode($_REQUEST['keywords']))); $smarty->assign('brand', $_REQUEST['brand']); $smarty->assign('min_price', $min_price); $smarty->assign('max_price', $max_price); $smarty->assign('outstock', $_REQUEST['outstock']); /* 分页 */
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order, $limit = '') { $display = $GLOBALS['display']; $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 "; if ($brand > 0) { $where .= "AND g.brand_id={$brand} "; } if ($min > 0) { $where .= " AND g.shop_price >= {$min} "; } if ($max > 0) { $where .= " AND g.shop_price <= {$max} "; } if ($children) { $where .= " AND {$children}"; } /* 获得商品列表 */ $sql = "SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, " . " g.promote_price, g.goods_type, " . "g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM " . $GLOBALS['ecs']->table('ecsmart_distrib_goods') . " as dg left join " . $GLOBALS['ecs']->table('goods') . " as g on dg.goods_id = g.goods_id " . "WHERE {$where} AND (dg.distrib_time = 0 OR (dg.start_time <='" . gmtime() . "' AND dg.end_time >= '" . gmtime() . "')) ORDER BY {$sort} {$order} {$limit}"; if ($sort == 'salenum') { $sql = "SELECT SUM(o.goods_number) as salenum,g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, " . " g.promote_price, g.goods_type, " . "g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM " . $GLOBALS['ecs']->table('ecsmart_distrib_goods') . " as dg left join " . $GLOBALS['ecs']->table('goods') . " as g on dg.goods_id = g.goods_id " . "LEFT JOIN " . $GLOBALS['ecs']->table('order_goods') . " as o ON o.goods_id = dg.goods_id " . "WHERE {$where} AND (dg.distrib_time = 0 OR (dg.start_time <='" . gmtime() . "' AND dg.end_time >= '" . gmtime() . "')) group by o.goods_id {$limit}"; } if (empty($limit)) { $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); } else { $res = $GLOBALS['db']->query($sql); } $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; } /* 处理商品水印图片 */ $watermark_img = ''; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } elseif ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } elseif ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } elseif ($row['is_hot'] != 0) { $watermark_img = 'watermark_hot_small'; } if ($watermark_img != '') { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($display == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['org_price']); $arr[$row['goods_id']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $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']); $arr[$row['goods_id']]['wap_count'] = selled_wap_count($row['goods_id']); } return $arr; }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $other_has, $other_youhuo, $min, $max, $ext, $size, $page, $sort, $order, $limit = '') { $filter = isset($_REQUEST['filter']) ? intval($_REQUEST['filter']) : 0; $display = $GLOBALS['display']; $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 AND ({$children} OR " . get_extension_goods($children) . ')'; if ($filter == 1) { $where .= ' AND g.supplier_id=0 '; } elseif ($filter == 2) { $where .= ' AND g.supplier_id>0 '; } else { } if ($brand > 0) { $where .= "AND g.brand_id={$brand} "; } if ($min >= 0 && $max > $min) { $where .= " AND (g.shop_price between {$min} AND {$max}) "; } // if ($max > 0) // { // $where .= " AND g.shop_price <= $max "; // } if ($other_has > 0) { switch ($other_has) { case 1: break; case 2: $where .= " AND g.supplier_id = 0 "; break; case 3: $where .= " AND g.supplier_id > 0 "; break; } } if ($other_youhuo > 0) { $where .= " AND g.goods_number > 0 "; } /* 获得区域id_代码添加_START_68ecshop */ $area_goods = ''; $province_id = empty($_COOKIE['region_1']) ? 0 : intval($_COOKIE['region_1']); $city_id = empty($_COOKIE['region_2']) ? 0 : intval($_COOKIE['region_2']); $district_id = empty($_COOKIE['region_3']) ? 0 : intval($_COOKIE['region_3']); $xiangcun_id = empty($_COOKIE['region_4']) ? 0 : intval($_COOKIE['region_4']); $where_area = ''; if ($province_id > 0) { $where_area .= " AND province = {$province_id} "; } if ($city_id > 0) { $where_area .= " AND city= {$city_id} "; } if ($district_id > 0) { $where_area .= " AND district = {$district_id} "; } if ($xiangcun_id > 0) { $where_area .= " AND xiangcun = {$xiangcun_id} "; } $store_ids = $GLOBALS['db']->getCol("select store_id from " . $GLOBALS['ecs']->table('store_shipping_region') . " where 1=1 " . $where_area); if (empty($store_ids)) { $store_ids = array(0); } $store_chr_ids = $GLOBALS['db']->getCol("select store_id from " . $GLOBALS['ecs']->table('store_main') . " where parent_id <> 0 and parent_id in (" . implode(',', $store_ids) . ")"); if (empty($store_chr_ids)) { $store_chr_ids = array(0); } $stort_goods_ids = $GLOBALS['db']->getCol("select goods_id from " . $GLOBALS['ecs']->table('store_goods_stock') . " where store_id in (" . implode(',', $store_chr_ids) . ")"); if (empty($stort_goods_ids)) { $stort_goods_ids = array(0); } if (!empty($stort_goods_ids)) { $area_goods = " and g.goods_id in (" . implode(',', $stort_goods_ids) . ") "; } /* 获得区域id_代码添加_END_68ecshop */ /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . '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 {$where} {$area_goods} {$ext} ORDER BY {$sort} {$order} {$limit}"; /* 代码增加_start By www.68ecshop.com */ if ($sort == 'salenum') { $sql = 'SELECT SUM(o.goods_number) as salenum, g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . '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']}' " . "LEFT JOIN " . $GLOBALS['ecs']->table('order_goods') . " as o ON o.goods_id = g.goods_id " . "WHERE {$where} {$area_goods} {$ext} group by g.goods_id ORDER BY {$sort} {$order} {$limit}"; } /* 代码增加_end By www.68ecshop.com */ if (empty($limit)) { $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); } else { $res = $GLOBALS['db']->query($sql); } $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; } /* 处理商品水印图片 */ $watermark_img = ''; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } elseif ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } elseif ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } elseif ($row['is_hot'] != 0) { $watermark_img = 'watermark_hot_small'; } if ($watermark_img != '') { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($display == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $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']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $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']); $arr[$row['goods_id']]['wap_count'] = selled_wap_count($row['goods_id']); $arr[$row['goods_id']]['wap_pingjia'] = get_evaluation_sum($row['goods_id']); } return $arr; }
/** * 获得品牌下的商品 * * @access private * @param integer $brand_id * @return array */ function brand_get_goods($brand_id, $cate, $size, $page, $sort, $order) { $cate_where = ($cate > 0) ? 'AND ' . get_children($cate) : ''; /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name,g.click_count, 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, 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']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $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']]['click_count'] = $row['click_count']; //yyy修改start $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']); //yyy修改end $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['wap_count'] = selled_wap_count($row['goods_id']); } return $arr; }