Пример #1
0
/**
 * 获得促销商品
 *
 * @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;
}
Пример #2
0
/**
 * 获得分类下的商品
 *
 * @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;
}
Пример #3
0
     //上一个商品
 }
 $next_gid = $db->getOne("SELECT max(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");
 if (!empty($next_gid)) {
     $next_good['url'] = build_uri('goods', array('gid' => $next_gid), $goods['goods_name']);
     $smarty->assign('next_good', $next_good);
     //下一个商品
 }
 $position = assign_ur_here($goods['cat_id'], $goods['goods_name']);
 $smarty->assign('page_title', $position['title']);
 // 页面标题
 $smarty->assign('ur_here', $position['ur_here']);
 // 当前位置
 $properties = get_goods_properties($goods_id);
 // 获得商品的规格和属性
 $smarty->assign('soldnum', get_soldnum($goods_id));
 // 商品销量
 $goodsyh = $db->getOne("SELECT goods_yh FROM " . $ecs->table('goods') . " WHERE goods_id = " . $goods_id . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0");
 $smarty->assign('goodsyh', $goodsyh);
 // 商品优惠信息
 $smarty->assign('package_buy_discount', $_CFG['package_buy']);
 $fuwu = $db->getOne("SELECT content FROM " . $ecs->table('article') . " WHERE article_id =52 ");
 //售后服务
 $smarty->assign('fuwu', $fuwu);
 $smarty->assign('properties', $properties['pro']);
 // 商品属性
 $smarty->assign('specification', $properties['spe']);
 // 商品规格
 $smarty->assign('attribute_linked', get_same_attribute_goods($properties));
 // 相同属性的关联商品
 $smarty->assign('related_goods', $linked_goods);
Пример #4
0
/**
 * 获得指定分类下的商品
 *
 * @access  public
 * @param   integer     $cat_id     分类ID
 * @param   integer     $num        数量
 * @param   string      $from       来自web/wap的调用
 * @param   string      $order_rule 指定商品排序规则
 * @return  array
 */
function assign_cat_goods($cat_id, $num = 0, $from = 'web', $order_rule = '')
{
    $sql = 'SELECT is_style_show,set_cat_style,set_style_color FROM ' . $GLOBALS['ecs']->table('category') . ' WHERE cat_id =' . $cat_id;
    $cat_info = $GLOBALS['db']->getRow($sql);
    $cat['is_style_show'] = $cat_info['is_style_show'];
    $cat['set_cat_style'] = $cat_info['set_cat_style'];
    $cat['set_style_color'] = $cat_info['set_style_color'] + 1;
    $children = get_children($cat_id);
    $sql = 'SELECT g.goods_id,g.cat_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ') ';
    $order_rule = empty($order_rule) ? 'ORDER BY g.sort_order, g.goods_id DESC' : $order_rule;
    $sql .= $order_rule;
    if ($num > 0) {
        $sql .= ' LIMIT ' . $num;
    }
    $res = $GLOBALS['db']->getAll($sql);
    $goods = array();
    foreach ($res 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]['soldnum'] = get_soldnum($row['goods_id']);
        $goods[$idx]['id'] = $row['goods_id'];
        $goods[$idx]['name'] = $row['goods_name'];
        $goods[$idx]['brief'] = $row['goods_brief'];
        $goods[$idx]['market_price'] = $row['market_price'];
        $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]['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']);
    }
    if ($from == 'web') {
        $GLOBALS['smarty']->assign('cat_goods_' . $cat_id, $goods);
    } elseif ($from == 'wap') {
        $cat['goods'] = $goods;
    }
    /* 分类信息 */
    $sql = 'SELECT cat_name FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'";
    $cat['name'] = $GLOBALS['db']->getOne($sql);
    $cat['url'] = build_uri('category', array('cid' => $cat_id), $cat['name']);
    $cat['id'] = $cat_id;
    //获取二级分类下的商品
    $cat_list_arr = cat_list($cat_id, 0, false);
    foreach ($cat_list_arr as $key => $value) {
        if ($value['level'] == 1) {
            $sql = 'SELECT g.goods_id,g.cat_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND is_delete = 0 AND ' . get_children($value['cat_id']) . ' ORDER BY g.sort_order, g.goods_id DESC';
            if ($num > 0) {
                $sql .= ' LIMIT ' . $num;
            }
            $goods_res = $GLOBALS['db']->getAll($sql);
            foreach ($goods_res as $idx => $row) {
                if ($row['promote_price'] > 0) {
                    $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
                    $goods_res[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
                } else {
                    $goods_res[$idx]['promote_price'] = '';
                }
                $goods_res[$idx]['market_price'] = price_format($row['market_price']);
                $goods_res[$idx]['shop_price'] = price_format($row['shop_price']);
                $goods_res[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
                $goods_res[$idx]['shop_price'] = price_format($row['shop_price']);
                $goods_res[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
                $goods_res[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
            }
            $cat_list_arr[$key]['goods'] = $goods_res;
        } else {
            unset($cat_list_arr[$key]);
        }
    }
    $cat['goods_level2'] = $cat_list_arr;
    /* 
    	// 销售排行
    	$sql = 'SELECT g.goods_name,sum(og.goods_number) AS number,g.shop_price,g.goods_thumb FROM '.$GLOBALS['ecs']->table('goods').' AS g LEFT JOIN '.$GLOBALS['ecs']->table('order_goods').' AS og ON g.goods_id=og.goods_id WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND (' . $children . 'OR ' . get_extension_goods($children) . ') GROUP BY g.goods_id ORDER BY number DESC LIMIT 10';
    	$sales_volume = $GLOBALS['db']->getAll($sql);
    
    	$cat['sales_volume'] = $sales_volume;
    	
    	
    	// 获取分类下品牌
    
    			$sql = "SELECT b.brand_id, b.brand_name, brand_logo , COUNT(*) AS goods_num ".
    					"FROM " . $GLOBALS['ecs']->table('brand') . "AS b, ".
    						$GLOBALS['ecs']->table('goods') . " AS g LEFT JOIN ". $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " .
    					"WHERE g.brand_id = b.brand_id AND ($children OR " . 'gc.cat_id ' . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ") AND b.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 b.sort_order, b.brand_id ASC LIMIT 10";
    		
    			$brands = $GLOBALS['db']->getAll($sql);
    			
    			foreach ($brands AS $key => $val)
    			{
    				
    				$brands[$key]['brand_name'] = $val['brand_name'];
    				$brands[$key]['url'] = build_uri('category', array('cid' => $cat_id, 'bid' => $val['brand_id'], 'price_min'=>$price_min, 'price_max'=> $price_max, 'filter_attr'=>$filter_attr_str), $cat['cat_name']);
    				$brands[$key]['logo'] = 'data/brandlogo/'.$val['brand_logo'];
    				// 判断品牌是否被选中 
    				if ($brand == $brands[$key]['brand_id'])
    				{
    					$brands[$key]['selected'] = 1;
    				}
    				else
    				{
    					$brands[$key]['selected'] = 0;
    				}
    			}			
    			$cat['brands'] = $brands;*/
    $cat['cat_clild'] = get_clild_list($cat_id);
    return $cat;
}
Пример #5
0
/**
 * 获得品牌下的商品
 *
 * @access  private
 * @param   integer  $brand_id
 * @return  array
 */
function brand_get_goods($brand_id, $cate, $size, $page, $sort, $order)
{
    $cate_where = $cate > 0 ? 'AND ' . get_children($cate) : '';
    /* 获得商品列表 */
    if ($sort == 'sales') {
        $sql = 'SELECT sum(og.goods_number) AS sales,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, g.goods_type  ' . '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 og ON g.goods_id = og.goods_id ' . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order}";
    } elseif ($sort == 'comments') {
        $sql = 'SELECT count(*) AS comments,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, g.goods_type ' . '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('comment') . ' AS c ON g.goods_id = c.id_value ' . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order}";
    } else {
        $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, g.goods_type  ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order}";
    }
    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
    $arr = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        if ($row['promote_price'] > 0) {
            $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
        } else {
            $promote_price = 0;
        }
        $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 ($GLOBALS['display'] == 'grid') {
            $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        } else {
            $arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
        }
        $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_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']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
        $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
        $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
        $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
        $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
    }
    return $arr;
}
Пример #6
0
     } 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']]['name'] = $row['goods_name'];
     $arr[$row['goods_id']]['type'] = $row['goods_type'];
     $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
     $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
     $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
     $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
     $arr[$row['goods_id']]['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']);
 }
 if ($display == 'grid') {
     if (count($arr) % 2 != 0) {
         $arr[] = array();
Пример #7
0
/**
 * 获得分类下的商品  超值兑换,精品上新 chen 0831
 *
 * @access  public
 * @param   string  $children
 * @return  array
 */
function exchange_get_goods($children, $min, $max, $ext, $size, $page, $sort, $order, $started_or_not)
{
    $display = $GLOBALS['display'];
    $where = "eg.is_exchange = 1 AND g.is_delete = 0 AND " . "({$children} OR " . get_extension_goods($children) . ')';
    if ($min > 0) {
        $where .= " AND eg.exchange_integral >= {$min} ";
    }
    if ($max > 0) {
        $where .= " AND eg.exchange_integral <= {$max} ";
    }
    /* 获得商品列表 */
    $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style,g.shop_price,eg.begin_time, eg.exchange_integral, eg.needed_money, ' . 'g.goods_type, g.goods_brief, g.goods_thumb , g.goods_img, eg.is_hot ' . 'FROM ' . $GLOBALS['ecs']->table('exchange_goods') . ' AS eg, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE eg.goods_id = g.goods_id AND {$started_or_not} AND {$where}  {$ext} ORDER BY {$sort} {$order}";
    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
    $arr = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        /* 处理商品水印图片 */
        $watermark_img = '';
        //        if ($row['is_new'] != 0)
        //        {
        //            $watermark_img = "watermark_new_small";
        //        }
        //        elseif ($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'];
        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']]['name'] = $row['goods_name'];
        $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
        $arr[$row['goods_id']]['exchange_integral'] = $row['exchange_integral'];
        $arr[$row['goods_id']]['type'] = $row['goods_type'];
        $arr[$row['goods_id']]['shop_price'] = $row['shop_price'];
        $arr[$row['goods_id']]['needed_money'] = $row['needed_money'];
        $arr[$row['goods_id']]['begin_date'] = local_date('m-d', $row['begin_time']);
        $arr[$row['goods_id']]['begin_hour'] = local_date('H:i', $row['begin_time']);
        $arr[$row['goods_id']]['integral_integer'] = floor($row['shop_price'] - $row['needed_money']);
        $arr[$row['goods_id']]['integral_decimal'] = end(explode('.', number_format($row['shop_price'] - $row['needed_money'], 2)));
        $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']);
    }
    return $arr;
}