当前位置: 首页>>代码示例>>PHP>>正文


PHP get_library_number函数代码示例

本文整理汇总了PHP中get_library_number函数的典型用法代码示例。如果您正苦于以下问题:PHP get_library_number函数的具体用法?PHP get_library_number怎么用?PHP get_library_number使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_library_number函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gz_get_category_recommend_goods

function gz_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, g.original_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]['original_img'] = get_image_path($row['goods_id'], $row['original_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;
}
开发者ID:blowfishJ,项目名称:galaxyCode,代码行数:55,代码来源:category.php

示例2: get_flash_sale_goods

/**
 * 获得促销商品
 *
 * @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;
}
开发者ID:muqidi,项目名称:PHP,代码行数:53,代码来源:flash_sale.php

示例3: get_brands

/**
 * 获得某个分类下
 *
 * @access  public
 * @param   int     $cat
 * @return  array
 */
function get_brands($cat = 0, $app = 'brand')
{
    global $page_libs;
    $template = basename(PHP_SELF);
    $template = substr($template, 0, strrpos($template, '.'));
    include_once ROOT_PATH . ADMIN_PATH . '/includes/lib_template.php';
    static $static_page_libs = null;
    if ($static_page_libs == null) {
        $static_page_libs = $page_libs;
    }
    $children = $cat > 0 ? ' AND ' . get_children($cat) : '';
    $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, b.brand_desc, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, " . $GLOBALS['ecs']->table('goods') . " AS g " . "WHERE g.brand_id = b.brand_id {$children} AND is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY tag DESC, b.sort_order ASC";
    if (isset($static_page_libs[$template]['/library/brands.lbi'])) {
        $num = get_library_number("brands");
        $sql .= " LIMIT {$num} ";
    }
    $row = $GLOBALS['db']->getAll($sql);
    foreach ($row as $key => $val) {
        $row[$key]['url'] = build_uri($app, array('cid' => $cat, 'bid' => $val['brand_id']), $val['brand_name']);
        $row[$key]['brand_desc'] = htmlspecialchars($val['brand_desc'], ENT_QUOTES);
    }
    return $row;
}
开发者ID:YangZeSummer,项目名称:NanJingSecond-Hand,代码行数:30,代码来源:lib_common.php

示例4: index_get_auction

/**
 * 取得拍卖活动列表
 * @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;
}
开发者ID:seanguo166,项目名称:microdistribution,代码行数:24,代码来源:index.php

示例5: get_exchange_recommend_goods

/**
 * 获得指定分类下的推荐商品
 *
 * @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;
}
开发者ID:nirvana-info,项目名称:old_bak,代码行数:53,代码来源:exchange.php

示例6: get_promote_goods_group

/**
 * 获得促销商品
 *
 * @access  public
 * @return  array
 */
function get_promote_goods_group($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, g.original_img, 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 15 ";
    $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]['valid_goods'] = selled_count($row['goods_id']);
        $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]['original_img'] = get_image_path($row['goods_id'], $row['original_img']);
        $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
    }
    return $goods;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:41,代码来源:pro_goods.php

示例7: brand_recommend_goods

/**
 * 获得指定品牌下的推荐和促销商品.
 *
 * @param string $type
 * @param int    $brand
 *
 * @return array
 */
function brand_recommend_goods($type, $brand, $cat = 0)
{
    static $result = null;
    $time = gmtime();
    if ($result === null) {
        if ($cat > 0) {
            $cat_where = 'AND ' . get_children($cat);
        } else {
            $cat_where = '';
        }
        $sql = 'SELECT g.goods_id, g.goods_name, 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 ' . '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.brand_id = '{$brand}' AND " . "(g.is_best = 1 OR (g.is_promote = 1 AND promote_start_date <= '{$time}' AND " . "promote_end_date >= '{$time}')) {$cat_where}" . 'ORDER BY g.sort_order, g.last_update DESC';
        $result = $GLOBALS['db']->getAll($sql);
    }
    /* 取得每一项的数量限制 */
    $num = 0;
    $type2lib = array('best' => 'recommend_best', 'new' => 'recommend_new', 'hot' => 'recommend_hot', 'promote' => 'recommend_promotion');
    $num = get_library_number($type2lib[$type]);
    $idx = 0;
    $goods = array();
    foreach ($result as $row) {
        if ($idx >= $num) {
            break;
        }
        if ($type == 'best' && $row['is_best'] == 1 || $type == 'promote' && $row['is_promote'] == 1 && $row['promote_start_date'] <= $time && $row['promote_end_date'] >= $time) {
            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_style_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']);
            ++$idx;
        }
    }
    return $goods;
}
开发者ID:netroby,项目名称:ecshop,代码行数:53,代码来源:brand.php

示例8: get_cat_recommend_goods

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;
}
开发者ID:norain2050,项目名称:mhFault,代码行数:66,代码来源:diyfile.php

示例9: get_categories_tree

    // 网店帮助
    $smarty->assign('categories', get_categories_tree());
    // 分类树
    $smarty->assign('top_goods', get_top10());
    // 销售排行
    $smarty->assign('cat_list', cat_list(0, 0, true, 2, false));
    $smarty->assign('brand_list', get_brand_list());
    $smarty->assign('promotion_info', get_promotion_info());
    $smarty->assign('enabled_mes_captcha', intval($_CFG['captcha']) & CAPTCHA_MESSAGE);
    $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('comment') . " WHERE STATUS =1 AND comment_type =0 ";
    $record_count = $db->getOne($sql);
    $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('feedback') . " WHERE `msg_area`='1' AND `msg_status` = '1' ";
    $record_count += $db->getOne($sql);
    /* 获取留言的数量 */
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    $pagesize = get_library_number('message_list', 'message_board');
    $pager = get_pager('message.php', array(), $record_count, $page, $pagesize);
    $msg_lists = get_msg_list($pagesize, $pager['start']);
    assign_dynamic('message_board');
    $smarty->assign('rand', mt_rand());
    $smarty->assign('msg_lists', $msg_lists);
    $smarty->assign('pager', $pager);
    $smarty->display('message_board.dwt');
}
/**
 * 获取留言的详细信息
 *
 * @param   integer $num
 * @param   integer $start
 *
 * @return  array
开发者ID:jinjing1989,项目名称:wei,代码行数:31,代码来源:message.php

示例10: index_get_group_buy

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;
}
开发者ID:shaoslu,项目名称:jumei,代码行数:44,代码来源:category.php

示例11: get_cat_recommend_goods

function get_cat_recommend_goods($type = '', $cat_id = 0, $cat_num = 0, $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.goods_sn,  g.market_price, g.shop_price AS org_price, g.promote_price,g.seller_note, ' . "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,b.brand_logo ' . '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}'";
            break;
    }
    $cats = get_children($cat_id);
    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;
    $index = 1;
    $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) : '';
            $goods[$idx]['promote_price2'] = $promote_price;
            $goods[$idx]['saving'] = $row['market_price'] - $promote_price;
        } else {
            $goods[$idx]['promote_price'] = '';
        }
        $index++;
        $goods[$idx]['i'] = $index;
        $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]['seller_note'] = $row['seller_note'];
        $goods[$idx]['is_new'] = $row['is_new'];
        $goods[$idx]['brief'] = $row['goods_brief'];
        $goods[$idx]['brand_name'] = $row['brand_name'];
        $goods[$idx]['brand_id'] = $row['brand_id'];
        $goods[$idx]['brand_logo'] = $row['brand_logo'];
        $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]['promote_limit_time'] = $row['promote_end_date'] - $row['promote_start_date'];
        $goods[$idx]['promote_end_date'] = local_date('m/d/Y H:i:s', $row['promote_end_date']);
        $goods[$idx]['promote_end_date2'] = $row['promote_end_date'];
        $market_price = $row['market_price'];
        $promote_price = $goods[$idx]['promote_price2'];
        $shop_price = $row['shop_price'];
        $goods[$idx]['saving'] = $market_price - $promote_price;
        $goods[$idx]['save_rate'] = $market_price ? round($promote_price / $market_price, 2) * 10 : 0;
        $goods[$idx]['save_rate2'] = $market_price ? round($shop_price / $market_price, 2) * 10 : 0;
        $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
        $idx++;
    }
    return $goods;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:80,代码来源:init.php

示例12: get_category_recommend_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} " : '';
    /*获取显示商品条件 add by hg for date 2014-03-26 */
    $agency_where = agency_goods();
    if ($agency_where != null) {
        $agency_where = 'g.' . $agency_where;
    }
    /*end*/
    $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 ' . $agency_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'];
        /* 折扣节省计算 by ecmoban start */
        if ($row['market_price'] > 0) {
            $discount_arr = get_discount($row['goods_id']);
            //函数get_discount参数goods_id
        }
        $goods[$idx]['zhekou'] = $discount_arr['discount'];
        //zhekou
        $goods[$idx]['jiesheng'] = $discount_arr['jiesheng'];
        //jiesheng
        /* 折扣节省计算 by ecmoban end */
        $goods[$idx]['comments_number'] = $row['comments_number'];
        $goods[$idx]['sales_volume'] = $row['sales_volume'];
        $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'] = !preg_match('/¥/', price_format($row['market_price'])) ? '' : price_format($row['market_price']);
        $goods[$idx]['shop_price'] = !preg_match('/¥/', price_format($row['shop_price'])) ? '<span style="font-size:12px;text-decoration:line-through;font-weight:normal;color:#666666;">市场价:' . price_format($row['market_price'], true, true) . '</span>' : 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;
}
开发者ID:dlpc,项目名称:ecshop,代码行数:84,代码来源:lib_goods.php

示例13: get_brands

/**
 * 获得某个分类下
 *
 * @access  public
 * @param   int     $cat
 * @return  array
 */
function get_brands($cat = 0, $app = 'brand')
{
    global $page_libs;
    $touch =& get_instance();
    $template = $touch->router->fetch_class();
    //    include_once(ROOT_PATH . ADMIN_PATH . '/includes/lib_template.php'); //by carson
    static $static_page_libs = null;
    if ($static_page_libs == null) {
        $static_page_libs = $page_libs;
    }
    $children = $cat > 0 ? ' AND ' . get_children($cat) : '';
    $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, b.brand_desc, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag " . "FROM {pre}brand AS b, {pre}goods AS g " . "WHERE g.brand_id = b.brand_id {$children} AND is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY tag DESC, b.sort_order ASC";
    if (isset($static_page_libs[$template]['/library/brands.lbi'])) {
        $num = get_library_number("brands");
        $sql .= " LIMIT {$num} ";
    }
    $row = $GLOBALS['db']->getAll($sql);
    foreach ($row as $key => $val) {
        $row[$key]['brand_logo'] = get_image_path(0, $val['brand_logo']);
        $row[$key]['url'] = build_uri($app, array('cid' => $cat, 'bid' => $val['brand_id']), $val['brand_name']);
        $row[$key]['brand_desc'] = htmlspecialchars($val['brand_desc'], ENT_QUOTES);
    }
    return $row;
}
开发者ID:connwap135,项目名称:ectouch,代码行数:31,代码来源:common_helper.php

示例14: get_exchange_recommend_goods

/**
 * 获得指定分类下的推荐商品
 *
 * @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, eg.needed_money,eg.begin_time, g.shop_price, 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 AND begin_time < ' . gmtime() . ' ' . $price_where . $ext;
    $num = 0;
    $type2lib = array('best' => 'exchange_best', 'new' => 'exchange_new', 'hot' => 'exchange_hot');
    $num = get_library_number($type2lib[$type], 'exchange_list');
    if (!empty($cats)) {
        $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) . ")";
    }
    switch ($type) {
        case 'best':
            $sql .= ' AND eg.is_best = 1 ORDER BY eg.exchange_integral DESC';
            break;
        case 'new':
            $sql .= ' AND eg.is_new = 1 ORDER BY eg.needed_money DESC';
            break;
        case 'hot':
            $sql .= ' AND eg.is_hot = 1';
            break;
    }
    $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]['shop_price'] = price_format($row['shop_price']);
        $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', array('act' => 'view', 'id' => $row['goods_id']));
        $goods[$idx]['needed_money'] = price_format($row['needed_money']);
        $goods[$idx]['begin_date'] = gmdate('m-d', $row['begin_time']);
        $goods[$idx]['begin_hour'] = gmdate('h:i', $row['begin_time']);
        $goods[$idx]['integral_integer'] = floor($row['shop_price'] - $row['needed_money']);
        $goods[$idx]['integral_decimal'] = end(explode('.', number_format($row['shop_price'] - $row['needed_money'], 1)));
        $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
        $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
        $idx++;
    }
    return $goods;
}
开发者ID:norain2050,项目名称:benhu,代码行数:58,代码来源:exchange.php

示例15: get_recommend_goods2

/**
 * 获得推荐商品
 *
 * @access  public
 * @param   string      $type       推荐类型,可以是 best, new, hot
 * @return  array
 */
function get_recommend_goods2($type = '', $cats = '', $goodsnum = '')
{
    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])) {
                    if ($goodsnum != '') {
                        $num = $goodsnum;
                    } else {
                        $num = get_library_number($data);
                    }
                    $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, g.click_count, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, b.brand_name, b.brand_id, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . ",(select count(c.rec_id) from " . $GLOBALS['ecs']->table("collect_goods") . " as c where c.goods_id = g.goods_id) AS collect_count " . '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']}' ";
        $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 collect_count desc, 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'];
//.........这里部分代码省略.........
开发者ID:nanhuacrab,项目名称:ecshop,代码行数:101,代码来源:init.php


注:本文中的get_library_number函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。