function get_supplier_goods($gtype = 0, $limit = 10) { $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 " . $limit; $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 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; }
function get_cat_id_goods_list($cat_id = '', $num = '', $ext = '') { $sql = 'Select g.goods_id,g.guige, g.cat_id,c.parent_id, g.goods_name, g.goods_number, 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, " . "g.is_best, g.is_new, g.is_hot, g.is_promote,b.brand_name " . 'FROM ' . $GLOBALS['hhs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['hhs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' . "LEFT JOIN " . $GLOBALS['hhs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " left join " . $GLOBALS['hhs']->table('brand') . " as b on g.brand_id=b.brand_id " . " Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_new = 1 AND g.is_delete = 0 and g.is_mall=1 " . ($sql .= " AND (c.parent_id =" . $cat_id . " OR g.cat_id = " . $cat_id . " OR g.cat_id " . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ")"); $sql .= $ext; $sql .= " LIMIT {$num}"; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res as $idx => $row) { $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['guige'] = $row['guige']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['goods_number'] = $row['goods_number']; $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'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb']; $goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img']; $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); if ($GLOBALS['SID']) { $goods[$idx]['shop_price'] = price_format($row['s_goods_price']); } } return $goods; }
function as_woo_enqueue_scripts() { if (!function_exists('is_woocommerce_activated')) { add_style('as-woocommerce', get_template_directory_uri() . '/css/woocommerce.css'); add_script('as-woocommerce', get_template_directory_uri() . '/js/woocommerce.js', array("jquery"), false, true); add_script('as-elevatezoom', get_template_directory_uri() . '/js/libs/jquery.elevatezoom.js', array("jquery"), false, true); } }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function exchange_get_goods($children, $min, $max, $ext, $size, $page, $sort, $order) { $display = $GLOBALS['display']; $where = "eg.is_exchange = 1 AND g.is_delete = 0 AND " . "($children OR " . model('Goods')->get_extension_goods($children) . ')'; if ($min > 0) { $where .= " AND eg.exchange_integral >= $min "; } if ($max > 0) { $where .= " AND eg.exchange_integral <= $max "; } /* 获得商品列表 */ $start = ($page - 1) * $size; $sort = $sort =='sales_volume'? 'xl.sales_volume': $sort; $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.goods_name_style, eg.exchange_integral, ' . 'g.goods_type, g.goods_brief, g.goods_thumb , g.goods_img, eg.is_hot ' . 'FROM ' . $this->pre . 'exchange_goods AS eg LEFT JOIN ' . $this->pre . 'goods AS g ' . 'ON eg.goods_id = g.goods_id ' . ' LEFT JOIN ' . $this->pre . 'touch_goods AS xl ' . ' ON g.goods_id=xl.goods_id ' . " WHERE $where $ext ORDER BY $sort $order LIMIT $start ,$size "; $res = $this->query($sql); $arr = array(); foreach ($res as $row) { $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']]['exchange_integral'] = $row['exchange_integral']; $arr[$row['goods_id']]['type'] = $row['goods_type']; $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('exchange_goods', array('gid' => $row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['sc'] = model('GoodsBase')->get_goods_collect($row['goods_id']); $arr[$row['goods_id']]['mysc'] = 0; // 检查是否已经存在于用户的收藏夹 if ($_SESSION ['user_id']) { unset($where); // 用户自己有没有收藏过 $where['goods_id'] = $row ['goods_id']; $where['user_id'] = $_SESSION ['user_id']; $rs = $this->model->table('collect_goods')->where($where)->count(); $arr[$row['goods_id']]['mysc'] = $rs; } } return $arr; }
/** * 获得促销商品 * * @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; }
function as_on_add_styles() { // AS Icon Font add_style('as-icon-font', TEMPLATEURL . '/css/as-icon-font.css', array(), '1.0', 'all'); // Dialog add_style('as-dialog', TEMPLATEURL . '/css/libs/dialog/dialog.css', array(), '1.0', 'all'); add_style('as-dialog-wilma', TEMPLATEURL . '/css/libs/dialog/dialog-wilma.css', array('as-dialog'), '1.0', 'all'); // Style.css add_style('as-style', get_stylesheet_uri()); // Responsive Style add_style('responsive-style', TEMPLATEURL . '/css/responsive-style.css', array(), '1.0', 'all'); // Custom Style add_style('custom', TEMPLATEURL . '/css/custom-style.php', array(), '1.0', 'all'); //video add_style('video', TEMPLATEURL . '/css/libs/html5/video.css', array(), '1.0', 'all'); //audio add_style('audio', TEMPLATEURL . '/css/libs/html5/audio.css', array(), '1.0', 'all'); add_style('popup', TEMPLATEURL . '/css/libs/popup.css', array(), '1.0', 'all'); }
function index() { add_style("box.css"); echo '<div class="content">'; echo '<h1>Thanks for using Rainframework!</h1>'; echo 'To Install and Use some Classes you will add some informations about you'; //load form class $this->load_library("Form", "form"); $this->form->init_form(URL . "ajax.php/install/install", "post"); $this->form->open_table("Userdata"); $this->form->add_item("text", "adminname", "Admin-Name", "Enter here your Adminname maybe needed later!!", null, "required"); $this->form->add_item("text", "adminemail", "Admin-Email", "for Login", null, "required,email"); $this->form->add_item("password", "adminpassword1", "Admin-Password", "for Login", null, "required", array("id" => "adminpass1")); $this->form->add_item("password", "adminpassword2", "Admin-Password2", "Repeat your Password", null, "required"); $this->form->add_button(); $this->form->add_validation("adminpassword2", 'equalTo="#adminpass1"', "not equalTo Admin-Password"); $this->form->close_table(); $this->form->draw($ajax = true, $return_string = false); echo '<div style="text-align: right; font-size: 0.7em;">'; echo 'installerversion BETA.1.0'; echo '</div>'; }
function cat_get_goods($keywords, $children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $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 ($keywords != "") { $where .= " AND g.goods_name LIKE '%" . $keywords . "%' "; } if (0 < $brand) { $where .= "AND g.brand_id=" . $brand . " "; } if (0 < $min) { $where .= " AND g.shop_price >= " . $min . " "; } if (0 < $max) { $where .= " AND g.shop_price <= " . $max . " "; } $sql = "SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_name_style, g.market_price,g.is_promote, 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, ") . "(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 " . $where . " {$ext} 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; } $watermark_img = ""; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } else { if ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } else { if ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } else { if ($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']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['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']]['comment_count'] = $row['comment_count']; $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']]['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']]['promote_price'] = 0 < $promote_price ? 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']); } return $arr; }
function get_catindex_recommend_goods($type = '', $cats = '') { $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, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb, 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 '; switch ($type) { case 'best': $sql .= ' AND is_best = 1'; break; case 'new': $sql .= ' AND is_new = 1'; break; case 'hot': $sql .= ' AND is_hot = 1'; break; } if (!empty($cats)) { $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) . ")"; } $sql .= ' ORDER BY g.sort_order, g.last_update DESC '; $res = $GLOBALS['db']->selectLimit($sql, 8); $idx = 0; $goods = 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[$idx]['promote_price'] = $promote_price; $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['goods_brief'] = $row['goods_brief']; $goods[$idx]['goods_name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $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]['market_price'] = price_format($row['market_price']); $goods[$idx]['goods_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]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $idx++; } return $goods; }
<?php /** * RainFramework * ------------- * Realized by Federico Ulfo & maintained by the Rain Team * Distributed under MIT license http://www.opensource.org/licenses/mit-license.php */ // load language of the form load_lang("form"); // add style add_style("default.css", LIBRARY_DIR . "Form/tpl/"); // add javascript add_script("jquery/jquery.min.js"); add_script("jquery/jquery.validate.min.js"); class Rain_Form { // form variable private $name, $action, $method, $target; // html generated private $html; // hidden inputs private $hidden; // flag private $upload_file; // flag private $tiny_mce = false, $validation = false; // form counter private static $form_counter = 0; function Rain_Form($action = null, $method = "get", $name = null, $target = null, $layout = "default") {
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; }
if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $row['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $row['promote_price'] = ''; } if ($row['shop_price'] > 0) { $row['shop_price'] = price_format($row['shop_price']); } else { $row['shop_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'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $row['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $row['short_style_name'] = add_style($row['short_name'], $row['goods_name_style']); foreach ($arr as $key => $value) { foreach ($value as $val) { if ($val == $row['goods_id']) { $key = $key == 'default' ? $_LANG['all_goods'] : $key; $sort_goods_arr[$key][] = $row; } } } } /* 模板赋值 */ assign_template(); $position = assign_ur_here(); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here'] . '> ' . $topic['title']);
/** * 获得指定分类下的推荐商品 * * @access public * @param string $type 推荐类型,可以是 best, new, hot, promote * @param string $cats 分类的ID * @param integer $min 商品积分下限 * @param integer $max 商品积分上限 * @param string $ext 商品扩展查询 * @return array */ function get_exchange_recommend_goods($type = '', $cats = '', $min = 0, $max = 0, $ext = '') { $price_where = $min > 0 ? " AND g.shop_price >= {$min} " : ''; $price_where .= $max > 0 ? " AND g.shop_price <= {$max} " : ''; $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, eg.exchange_integral, ' . 'g.goods_brief, g.goods_thumb, goods_img, b.brand_name ' . 'FROM ' . $GLOBALS['ecs']->table('exchange_goods') . ' AS eg ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = eg.goods_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . 'WHERE eg.is_exchange = 1 AND g.is_delete = 0 ' . $price_where . $ext; $num = 0; $type2lib = array('best' => 'exchange_best', 'new' => 'exchange_new', 'hot' => 'exchange_hot'); $num = get_library_number($type2lib[$type], 'exchange_list'); switch ($type) { case 'best': $sql .= ' AND eg.is_best = 1'; break; case 'new': $sql .= ' AND eg.is_new = 1'; break; case 'hot': $sql .= ' AND eg.is_hot = 1'; break; } if (!empty($cats)) { $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) . ")"; } $order_type = $GLOBALS['_CFG']['recommend_order']; $sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY RAND()'; $res = $GLOBALS['db']->selectLimit($sql, $num); $idx = 0; $goods = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $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]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['exchange_integral'] = $row['exchange_integral']; $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('exchange_goods', array('gid' => $row['goods_id']), $row['goods_name']); $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $idx++; } return $goods; }
function cat_get_goods($keywords, $children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $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 ($keywords != '') { $where .= " AND g.goods_name LIKE '%{$keywords}%' "; } 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_sn, 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, " . '(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, click_count ' . '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}"; $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; } /* 处理商品水印图片 */ $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']]['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']]['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']]['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']]['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']); } return $arr; }
function index_get_group_buy() { $time = gmtime(); $limit = get_library_number('group_buy', 'index'); $group_buy_list = array(); if ($limit > 0) { $sql = 'SELECT gb.act_id AS group_buy_id, gb.goods_id, gb.ext_info, gb.goods_name,g.market_price,g.shop_price, g.goods_thumb, g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS gb, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE gb.act_type = '" . GAT_GROUP_BUY . "' " . "AND g.goods_id = gb.goods_id " . "AND gb.start_time <= '" . $time . "' " . "AND gb.end_time >= '" . $time . "' " . "AND g.is_delete = 0 " . "ORDER BY gb.act_id DESC " . "LIMIT {$limit}"; $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { /* 如果缩略图为空,使用默认图片 */ $row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); /* 根据价格阶梯,计算最低价 */ $ext_info = unserialize($row['ext_info']); $price_ladder = $ext_info['price_ladder']; if (!is_array($price_ladder) || empty($price_ladder)) { $row['last_price'] = price_format(0); } else { foreach ($price_ladder as $amount_price) { $price_ladder[$amount_price['amount']] = $amount_price['price']; } } ksort($price_ladder); $row['last_price'] = price_format(end($price_ladder)); /*团购节省和折扣计算 by ecmoban start*/ $price = $row['shop_price']; //原价 $nowprice = end($price_ladder); //现价 $row['jiesheng'] = $price - $nowprice; //节省金额 if ($nowprice > 0) { $row['zhekou'] = round(10 / ($price / $nowprice), 1); } else { $row['zhekou'] = 0; } $row['url'] = build_uri('group_buy', array('gbid' => $row['group_buy_id'])); $row['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $row['short_style_name'] = add_style($row['short_name'], ''); $group_buy_list[] = $row; } } return $group_buy_list; }
function get_cat_recommend_goods($type = "", $cats = "", $cat_num = 0, $brand = 0, $min = 0, $max = 0, $ext = "") { $brand_where = 0 < $brand ? " AND g.brand_id = '" . $brand . "'" : ""; $price_where = 0 < $min ? " AND g.shop_price >= " . $min . " " : ""; $price_where .= 0 < $max ? " AND g.shop_price <= " . $max . " " : ""; $sql = "SELECT g.goods_id, g.goods_name, g.goods_name_style,g.goods_sn, g.market_price, g.shop_price AS org_price, g.promote_price, " . ("IFNULL(mp.user_price, g.shop_price * '" . $_SESSION['discount'] . "') AS shop_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, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, b.brand_id, g.is_best, g.is_new, g.is_hot, g.is_promote 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 " . $brand_where . $price_where . $ext; $num = 0; $type2lib = array("best" => "recommend_best", "new" => "recommend_new", "hot" => "recommend_hot", "promote" => "recommend_promotion"); if ($cat_num == 0) { $num = get_library_number($type2lib[$type]); } else { $num = $cat_num; } switch ($type) { case "best": $sql .= " AND is_best = 1"; break; case "new": $sql .= " AND is_new = 1"; break; case "hot": $sql .= " AND is_hot = 1"; break; case "promote": $time = gmtime(); $sql .= " AND is_promote = 1 AND promote_start_date <= '" . $time . "' AND promote_end_date >= '{$time}'"; } if (!empty($cats)) { $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) . ")"; } $order_type = $GLOBALS['_CFG']['recommend_order']; $sql .= $order_type == 0 ? " ORDER BY g.sort_order, g.last_update DESC" : " ORDER BY RAND()"; $res = $GLOBALS['db']->selectLimit($sql, $num); $idx = 0; $goods = 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']); $goods[$idx]['promote_price'] = 0 < $promote_price ? price_format($promote_price) : ""; } else { $goods[$idx]['promote_price'] = ""; } $row['comment_rank'] = ceil($row['comment_rank']) == 0 ? 5 : ceil($row['comment_rank']); $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['goods_sn'] = $row['goods_sn']; $goods[$idx]['comment_rank'] = $row['comment_rank']; $goods[$idx]['sell_number'] = $row['sell_number']; $goods[$idx]['is_new'] = $row['is_new']; $goods[$idx]['is_best'] = $row['is_best']; $goods[$idx]['is_hot'] = $row['is_hot']; $goods[$idx]['is_promote'] = $row['is_promote']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_id'] = $row['brand_id']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['short_name'] = 0 < $GLOBALS['_CFG']['goods_name_length'] ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $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]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); ++$idx; } return $goods; }
/** * 获得推荐商品 * * @access public * @param string $type 推荐类型,可以是 best, new, hot * @return array */ function get_recommend_goods_wap($type = '', $num, $cats = '') { if (!in_array($type, array('best', 'new', 'hot'))) { return array(); } //取不同推荐对应的商品 static $type_goods = array(); if (empty($type_goods[$type])) { //初始化数据 $type_goods['best'] = array(); $type_goods['new'] = array(); $type_goods['hot'] = array(); $data = read_static_cache('recommend_goods'); if ($data === false) { $sql = 'SELECT g.goods_id, g.is_best, g.is_new, g.is_hot, g.is_promote, b.brand_name,g.sort_order ' . ' FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . ' LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.is_best = 1 OR g.is_new =1 OR g.is_hot = 1)' . ' ORDER BY g.sort_order, g.last_update DESC'; $goods_res = $GLOBALS['db']->getAll($sql); //定义推荐,最新,热门,促销商品 $goods_data['best'] = array(); $goods_data['new'] = array(); $goods_data['hot'] = array(); $goods_data['brand'] = array(); if (!empty($goods_res)) { foreach ($goods_res as $data) { if ($data['is_best'] == 1) { $goods_data['best'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']); } if ($data['is_new'] == 1) { $goods_data['new'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']); } if ($data['is_hot'] == 1) { $goods_data['hot'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']); } if ($data['brand_name'] != '') { $goods_data['brand'][$data['goods_id']] = $data['brand_name']; } } } write_static_cache('recommend_goods', $goods_data); } else { $goods_data = $data; } $time = gmtime(); $order_type = $GLOBALS['_CFG']['recommend_order']; //按推荐数量及排序取每一项推荐显示的商品 order_type可以根据后台设定进行各种条件显示 static $type_array = array(); $type2lib = array('best' => 'recommend_best', 'new' => 'recommend_new', 'hot' => 'recommend_hot'); if (empty($type_array)) { foreach ($type2lib as $key => $data) { if (!empty($goods_data[$key])) { $data_count = count($goods_data[$key]); $num = $data_count > $num ? $num : $data_count; if ($order_type == 0) { //usort($goods_data[$key], 'goods_sort'); $rand_key = array_slice($goods_data[$key], 0, $num); foreach ($rand_key as $key_data) { $type_array[$key][] = $key_data['goods_id']; } } else { $rand_key = array_rand($goods_data[$key], $num); if ($num == 1) { $type_array[$key][] = $goods_data[$key][$rand_key]['goods_id']; } else { foreach ($rand_key as $key_data) { $type_array[$key][] = $goods_data[$key][$key_data]['goods_id']; } } } } else { $type_array[$key] = array(); } } } //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中 $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, g.goods_img, g.original_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']}' "; $type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']); $type_merge = array_unique($type_merge); $sql .= ' WHERE g.goods_id ' . db_create_in($type_merge); $sql .= ' ORDER BY g.sort_order, g.last_update DESC'; $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]['original_img'] = get_image_path($row['goods_id'], $row['original_img'], 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']); if (in_array($row['goods_id'], $type_array['best'])) { $type_goods['best'][] = $goods[$idx]; } if (in_array($row['goods_id'], $type_array['new'])) { $type_goods['new'][] = $goods[$idx]; } if (in_array($row['goods_id'], $type_array['hot'])) { $type_goods['hot'][] = $goods[$idx]; } } } return $type_goods[$type]; }
/** * 获得分类下的商品 * * @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 public * @param string $children * @return array */ private function category_get_goods() { $display = $GLOBALS['display']; $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 "; if ($this->keywords != '') { $where .= " AND (( 1 " . $this->keywords . " ) ) "; } else { $where .= " AND ({$this->children} OR " . model('Goods')->get_extension_goods($this->children) . ') '; } if ($this->type) { switch ($this->type) { case 'best': $where .= ' AND g.is_best = 1'; break; case 'new': $where .= ' AND g.is_new = 1'; break; case 'hot': $where .= ' AND g.is_hot = 1'; break; case 'promotion': $time = gmtime(); $where .= " AND g.promote_price > 0 AND g.promote_start_date <= '{$time}' AND g.promote_end_date >= '{$time}'"; break; default: $where .= ''; } } if ($this->brand > 0) { $where .= "AND g.brand_id={$this->brand} "; } if ($this->price_min > 0) { $where .= " AND g.shop_price >= {$this->price_min} "; } if ($this->price_max > 0) { $where .= " AND g.shop_price <= {$this->price_max} "; } $start = ($this->page - 1) * $this->size; $sort = $this->sort == 'sales_volume' ? 'xl.sales_volume' : $this->sort; /* 获得商品列表 */ $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, xl.sales_volume ' . 'FROM ' . $this->model->pre . 'goods AS g ' . ' LEFT JOIN ' . $this->model->pre . 'touch_goods AS xl ' . ' ON g.goods_id=xl.goods_id ' . ' LEFT JOIN ' . $this->model->pre . 'member_price AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE {$where} {$this->ext} ORDER BY {$sort} {$this->order} LIMIT {$start} , {$this->size}"; $res = $this->model->query($sql); $arr = array(); foreach ($res as $row) { // 销量统计 $sales_volume = (int) $row['sales_volume']; if (mt_rand(0, 3) == 3) { $sales_volume = model('GoodsBase')->get_sales_count($row['goods_id']); $sql = 'REPLACE INTO ' . $this->model->pre . 'touch_goods(`goods_id`, `sales_volume`) VALUES(' . $row['goods_id'] . ', ' . $sales_volume . ')'; $this->model->query($sql); } 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'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('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']]['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'] = url('goods/index', array('id' => $row['goods_id'])); $arr[$row['goods_id']]['sales_count'] = $sales_volume; $arr[$row['goods_id']]['sc'] = model('GoodsBase')->get_goods_collect($row['goods_id']); $arr[$row['goods_id']]['mysc'] = 0; // 检查是否已经存在于用户的收藏夹 if ($_SESSION['user_id']) { unset($where); // 用户自己有没有收藏过 $where['goods_id'] = $row['goods_id']; $where['user_id'] = $_SESSION['user_id']; $rs = $this->model->table('collect_goods')->where($where)->count(); $arr[$row['goods_id']]['mysc'] = $rs; } $arr[$row['goods_id']]['promotion'] = model('GoodsBase')->get_promotion_show($row['goods_id']); $arr[$row['goods_id']]['comment_count'] = model('Comment')->get_goods_comment($row['goods_id'], 0); //商品总评论数量 $arr[$row['goods_id']]['favorable_count'] = model('Comment')->favorable_comment($row['goods_id'], 0); //获得商品好评数量 } return $arr; }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $size, $page) { $display = $GLOBALS['display']; $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 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, ' . "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('supplier_goods_cat') . ' AS sgc ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "ON sgc.goods_id = g.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 {$where} ORDER BY g.goods_id desc"; $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; } /* 处理商品水印图片 */ $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']]['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']); } return $arr; }
/** * 获得促销商品 * * @access public * @return array */ function get_promote_goods($cats = '') { $time = gmtime(); $order_type = C('recommend_order'); /* 取得促销lbi的数量限制 */ $num = model('Common')->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 ' . $this->pre . 'goods AS g ' . 'LEFT JOIN ' . $this->pre . 'brand AS b ON b.brand_id = g.brand_id ' . "LEFT JOIN " . $this->pre . "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 = $this->query($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'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('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'] = url('goods/index', array('id' => $row['goods_id'])); } return $goods; }
/** * 获得指定分类下的推荐商品 * * @access public * @param string $type 推荐类型,可以是 best, new, hot, promote * @param string $cats 分类的ID * @param integer $brand 品牌的ID * @param integer $min 商品价格下限 * @param integer $max 商品价格上限 * @param string $ext 商品扩展查询 * @return array */ function get_category_recommend_goods($type = '', $cats = '', $brand = 0, $min = 0, $max = 0, $ext = '') { $brand_where = $brand > 0 ? " AND g.brand_id = '{$brand}'" : ''; $price_where = $min > 0 ? " AND g.shop_price >= {$min} " : ''; $price_where .= $max > 0 ? " AND g.shop_price <= {$max} " : ''; $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 ' . 'FROM ' . $this->pre . 'goods AS g ' . 'LEFT JOIN ' . $this->pre . 'brand AS b ON b.brand_id = g.brand_id ' . "LEFT JOIN " . $this->pre . "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 ' . $brand_where . $price_where . $ext; $num = 0; $type2lib = array('best' => 'recommend_best', 'new' => 'recommend_new', 'hot' => 'recommend_hot', 'promote' => 'recommend_promotion'); $num = model('Common')->get_library_number($type2lib[$type]); switch ($type) { case 'best': $sql .= ' AND is_best = 1'; break; case 'new': $sql .= ' AND is_new = 1'; break; case 'hot': $sql .= ' AND is_hot = 1'; break; case 'promote': $time = gmtime(); $sql .= " AND is_promote = 1 AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}'"; break; } if (!empty($cats)) { $sql .= " AND (" . $cats . " OR " . model('goods')->get_extension_goods($cats) . ")"; } $order_type = C('recommend_order'); $sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY RAND() ' . ' LIMIT ' . $num; $res = $this->query($sql); $idx = 0; $goods = array(); foreach ($res as $key => $value) { if ($value['promote_price'] > 0) { $promote_price = bargain_price($value['promote_price'], $value['promote_start_date'], $value['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id'] = $value['goods_id']; $goods[$idx]['name'] = $value['goods_name']; $goods[$idx]['brief'] = $value['goods_brief']; $goods[$idx]['brand_name'] = $value['brand_name']; $goods[$idx]['short_name'] = C('goods_name_length') > 0 ? sub_str($value['goods_name'], C('goods_name_length')) : $value['goods_name']; $goods[$idx]['market_price'] = price_format($value['market_price']); $goods[$idx]['shop_price'] = price_format($value['shop_price']); $goods[$idx]['thumb'] = get_image_path($value['goods_id'], $value['goods_thumb'], true); $goods[$idx]['goods_img'] = get_image_path($value['goods_id'], $value['goods_img']); $goods[$idx]['url'] = url('goods/index', array('id' => $value['goods_id'])); $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $value['goods_name_style']); $idx++; } return $goods; }
/** * 取得拍卖活动列表 * @return array */ function index_get_auction() { $now = gmtime(); $limit = get_library_number('auction', 'index'); $sql = "SELECT a.act_id, a.goods_id, a.goods_name, a.ext_info, g.goods_thumb " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS a," . $GLOBALS['ecs']->table('goods') . " AS g" . " WHERE a.goods_id = g.goods_id" . " AND a.act_type = '" . GAT_AUCTION . "'" . " AND a.is_finished = 0" . " AND a.start_time <= '{$now}'" . " AND a.end_time >= '{$now}'" . " AND g.is_delete = 0" . " ORDER BY a.start_time DESC" . " LIMIT {$limit}"; $res = $GLOBALS['db']->query($sql); $list = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $ext_info = unserialize($row['ext_info']); $arr = array_merge($row, $ext_info); $arr['formated_start_price'] = price_format($arr['start_price']); $arr['formated_end_price'] = price_format($arr['end_price']); $arr['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr['url'] = build_uri('auction', array('auid' => $arr['act_id'])); $arr['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($arr['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $arr['goods_name']; $arr['short_style_name'] = add_style($arr['short_name'], ''); $list[] = $arr; } return $list; }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $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}"; $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; } /* 处理商品水印图片 */ $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']; //zhong 改开始 if ($row['market_price'] > 0) { $arr[$row['goods_id']]['zhekou'] = round($row['shop_price'] / $row['market_price'] * 100) / 10 + "" . "折"; } $goods_id = $row['goods_id']; $count = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('comment') . " where comment_type=0 and id_value ='{$goods_id}'"); $arr[$row['goods_id']]['review_count'] = $count; //zhong 改结束 $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']); } return $arr; }
//$repayrecord = get_goods_repay($goods_id); //获得还款记录 /* 获取所属大类的名称 */ /*$sql = 'select a.cat_name from'.$ecs->table("category").' as a,'.$ecs->table("category").' as b where a.cat_id = b.parent_id and b.cat_id='.$goods["cat_id"]; $goods_row = $db->getRow($sql); $goods_row_catname = $goods_row['cat_name'];*/ if ($goods === false) { /* 如果没有找到任何记录则跳回到首页 */ ecs_header("Location: ./\n"); exit; } else { if ($goods['brand_id'] > 0) { $goods['goods_brand_url'] = build_uri('brand', array('bid' => $goods['brand_id']), $goods['goods_brand']); } $shop_price = $goods['shop_price']; $linked_goods = get_linked_goods($goods_id); $goods['goods_style_name'] = add_style($goods['goods_name'], $goods['goods_name_style']); /* 购买该商品可以得到多少钱的红包 */ if ($goods['bonus_type_id'] > 0) { $time = gmtime(); $sql = "SELECT type_money FROM " . $ecs->table('bonus_type') . " WHERE type_id = '{$goods['bonus_type_id']}' " . " AND send_type = '" . SEND_BY_GOODS . "' " . " AND send_start_date <= '{$time}'" . " AND send_end_date >= '{$time}'"; $goods['bonus_money'] = floatval($db->getOne($sql)); if ($goods['bonus_money'] > 0) { $goods['bonus_money'] = price_format($goods['bonus_money']); } } $smarty->assign('goods', $goods); $smarty->assign('goods_id', $goods['goods_id']); $smarty->assign('bid_record', $bidrecord); $smarty->assign('promote_end_time', $goods['gmt_end_time']); $smarty->assign('categories', get_categories_tree()); // 分类树
/** * 获得促销商品 * * @access public * @param string $order_rule 指定商品排序规则 * @return array */ function wap_get_promote_goods($order_rule = '') { $time = gmtime(); /* 取得促销lbi的数量限制 */ $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}' "; $order_rule = empty($order_rule) ? 'ORDER BY g.sort_order, g.last_update DESC' : $order_rule; $sql .= $order_rule; $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']); } return $goods; }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $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}"; //echo $sql."<br>size==".$size; // print_r($sql); $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; } /* 处理商品水印图片 */ $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']; } $properties = get_goods_properties($row['goods_id']); // 获得商品的规格和属性 $arr[$row['goods_id']]['properties_pro'] = $properties['pro']['商品属性']; $arr[$row['goods_id']]['soldnum'] = get_soldnum($row['goods_id']); $arr[$row['goods_id']]['comments_number'] = get_comments_number($row['goods_id']); $arr[$row['goods_id']]['brief'] = $row['goods_brief']; $arr[$row['goods_id']]['is_new'] = $row['is_new'] ? $row['is_new'] : 0; $arr[$row['goods_id']]['is_best'] = $row['is_best'] ? $row['is_best'] : 0; $arr[$row['goods_id']]['is_hot'] = $row['is_hot'] ? $row['is_hot'] : 0; $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']]['promote_price'] = $promote_price > 0 ? $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']); } return $arr; }
/** * 获得指定分类下的推荐商品 * * @access public * @param string $type 推荐类型,可以是 best, new, hot, promote * @param string $cats 分类的ID * @param integer $brand 品牌的ID * @param integer $min 商品价格下限 * @param integer $max 商品价格上限 * @param string $ext 商品扩展查询 * @return array */ function get_category_recommend_goods($type = '', $cats = '', $brand = 0, $min = 0, $max = 0, $ext = '') { $brand_where = $brand > 0 ? " AND g.brand_id = '{$brand}'" : ''; $price_where = $min > 0 ? " AND g.shop_price >= {$min} " : ''; $price_where .= $max > 0 ? " AND g.shop_price <= {$max} " : ''; $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 ' . '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 ' . $brand_where . $price_where . $ext; $num = 0; $type2lib = array('best' => 'recommend_best', 'new' => 'recommend_new', 'hot' => 'recommend_hot', 'promote' => 'recommend_promotion'); $num = get_library_number($type2lib[$type]); switch ($type) { case 'best': $sql .= ' AND is_best = 1'; break; case 'new': $sql .= ' AND is_new = 1'; break; case 'hot': $sql .= ' AND is_hot = 1'; break; case 'promote': $time = gmtime(); $sql .= " AND is_promote = 1 AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}'"; break; } if (!empty($cats)) { $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) . ")"; } $order_type = $GLOBALS['_CFG']['recommend_order']; $sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY RAND()'; $res = $GLOBALS['db']->selectLimit($sql, $num); $idx = 0; $goods = 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']); $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]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $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]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $idx++; } return $goods; }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $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) { /* 代码修改_start By www.68ecshop.com */ if (strstr($brand, '_')) { $brand_sql = str_replace("_", ",", $brand); $where .= "AND g.brand_id in ({$brand_sql}) "; } else { $where .= "AND g.brand_id={$brand} "; } /* 代码修改_end By www.68ecshop.com */ } if ($min > 0) { $where .= " AND g.shop_price >= {$min} "; } if ($max > 0) { $where .= " AND g.shop_price <= {$max} "; } if ($sort == goods_number) { $where .= " AND g.goods_number != 0 "; } /* 获得商品列表 */ $sort = $sort == 'shop_price' ? 'shop_p' : $sort; $sql = "SELECT g.goods_id, g.goods_name, g.goods_name_style, g.click_count, g.goods_number, 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, " . " IF(g.promote_price != '' " . " AND g.promote_start_date < " . gmtime() . " AND g.promote_end_date > " . gmtime() . ", g.promote_price, shop_price) " . " AS shop_p, 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}"; if ($sort == 'salenum') { $sql = "SELECT IFNULL(o.num,0) AS salenum, g.goods_id, g.goods_name, g.click_count, g.goods_number, 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 " . " (SELECT " . " SUM(og.`goods_number`) " . " AS num,og.goods_id " . " FROM " . " ecs_order_goods AS og, " . " ecs_order_info AS oi " . " WHERE oi.pay_status = 2 " . " AND oi.order_status >= 1 " . " AND oi.order_id = og.order_id " . " GROUP BY og.goods_id) " . " AS o " . " ON o.goods_id = g.goods_id " . " WHERE {$where} {$ext} " . " 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; } /* 处理商品水印图片 */ $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']]['goods_number'] = $row['goods_number']; $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['is_promote'] = $row['is_promote']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['is_best'] = $row['is_best']; $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']]['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']]['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']; /* 检查是否已经存在于用户的收藏夹 */ $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; } } return $arr; }