$goods['comment_count'] = get_comment_count($goods['goods_id']);
 /* 购买该商品可以得到多少钱的红包 */
 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']);
     }
 }
 $goods['goods_desc'] = str_replace('src="/images/', 'src="' . $config['site_url'] . 'images/', $goods['goods_desc']);
 //修复产品详情的图片 by wang
 $smarty->assign('goods', $goods);
 $smarty->assign('goods_id', $goods['goods_id']);
 $smarty->assign('promote_end_time', $goods['gmt_end_time']);
 $smarty->assign('sales_count', get_goods_sales_count($goods['goods_id']));
 // by wang
 $smarty->assign('categories', get_categories_tree($goods['cat_id']));
 // 分类树
 /* meta */
 $smarty->assign('keywords', htmlspecialchars($goods['keywords']));
 $smarty->assign('description', htmlspecialchars($goods['goods_brief']));
 $catlist = array();
 foreach (get_parent_cats($goods['cat_id']) as $k => $v) {
     $catlist[] = $v['cat_id'];
 }
 assign_template('c', $catlist);
 /* 上一个商品下一个商品 */
 $prev_gid = $db->getOne("SELECT goods_id FROM " . $ecs->table('goods') . " WHERE cat_id=" . $goods['cat_id'] . " AND goods_id > " . $goods['goods_id'] . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 LIMIT 1");
 if (!empty($prev_gid)) {
     $prev_good['url'] = build_uri('goods', array('gid' => $prev_gid), $goods['goods_name']);
示例#2
0
文件: category.php 项目: dlpc/ecshop
/**
 * 获得分类下的商品
 *
 * @access  public
 * @param   string  $children
 * @return  array
 */
function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
{
    //获取显示商品条件 add by hg for date 2014-03-26
    $agency_where = agency_goods();
    if ($agency_where != null) {
        $agency_where = 'g.' . $agency_where;
    }
    $display = $GLOBALS['display'];
    $where = "{$agency_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'] = strlen($row['goods_name']) > 16 ? mb_substr($row['goods_name'], 0, 16, 'utf-8') . '..' : $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']);
        $arr[$row['goods_id']]['sales_count'] = get_goods_sales_count($row['goods_id']);
    }
    return $arr;
}