/** * 获得推荐商品 * * @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 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; }
/** * 获得分类下的商品 * * @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; }
/* 代码添加_START By www.68ecshop.com */ $arr[$row['goods_id']]['goods_name_www_68ecshop_com'] = $arr[$row['goods_id']]['goods_name']; foreach ($replacef_www_68ecshop_com as $key_www_68ecshop_com => $temp_qq) { //$replacet[$key_www_68ecshop_com]= '<strong style="color:#cc0000;">'. $temp_qq .'</strong>';; $arr[$row['goods_id']]['goods_name_www_68ecshop_com'] = preg_replace('/(?!<[^>]*)' . $temp_qq . '(?![^<]*>)/i', '<strong style="color:#cc0000;">' . $temp_qq . '</strong>', $arr[$row['goods_id']]['goods_name_www_68ecshop_com']); } /* 代码添加_END By www.68ecshop.com */ $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']]['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']]['evaluation'] = get_evaluation_sum($row['goods_id']); $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']]['comment_count'] = get_comment_count($row['goods_id']); $arr[$row['goods_id']]['count'] = selled_count($row['goods_id']); $arr[$row['goods_id']]['click_count'] = $row['click_count']; $arr[$row['goods_id']]['goods_number'] = $row['goods_number']; /* 检查是否已经存在于用户的收藏夹 */ $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE user_id='{$_SESSION['user_id']}' AND goods_id = " . $row['goods_id']; if ($GLOBALS['db']->GetOne($sql) > 0) { $arr[$row['goods_id']]['is_collet'] = 1; } else { $arr[$row['goods_id']]['is_collet'] = 0; } }
} else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $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);
/** * 获得促销商品 * * @access public * @return array */ function get_promote_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_brief, 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'; $sql .= " LIMIT {$num} "; $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 ? 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'] = $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'] = 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']); } return $goods; }
$smarty->assign('fittings', get_goods_fittings(array($goods_id))); // 配件 $smarty->assign('rank_prices', get_user_rank_prices($goods_id, $shop_price)); // 会员等级价格 $smarty->assign('pictures', get_goods_gallery($goods_id)); // 商品相册 $smarty->assign('bought_goods', get_also_bought($goods_id)); // 购买了该商品的用户还购买了哪些商品 $smarty->assign('goods_rank', get_goods_rank($goods_id)); // 商品的销售排名 //yyy添加start //商品评价个数 $count = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('comment') . " where comment_type=0 and id_value ='{$goods_id}' and status=1"); $smarty->assign('review_count', $count); //yyy添加end $smarty->assign('order_num', selled_count($goods_id)); $smarty->assign('pinglun', get_evaluation_sum($goods_id)); $sql = "select * from " . $ecs->table('comment') . " where comment_type=0 and status=1 and comment_rank!=0 and id_value={$goods_id}"; $comments = $db->getall($sql); $coun12t = count($comments); $yixing = 0; $erxing = 0; $sanxing = 0; $sixing = 0; $wuxing = 0; $haoping = 0; foreach ($comments as $value) { if ($value['comment_rank'] == 1) { $yixing = $yixing + 1; $haoping = $haoping + 1; } if ($value['comment_rank'] == 2) {
/** * 获得分类下的商品 * * @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; }