Ejemplo n.º 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;
}
Ejemplo n.º 2
0
function action_back_order()
{
    $user = $GLOBALS['user'];
    $_CFG = $GLOBALS['_CFG'];
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user_id = $_SESSION['user_id'];
    $order_id = !empty($_REQUEST['order_id']) ? intval($_REQUEST['order_id']) : 0;
    $goods_id = !empty($_REQUEST['goods_id']) ? intval($_REQUEST['goods_id']) : 0;
    $product_id = !empty($_REQUEST['product_id']) ? intval($_REQUEST['product_id']) : 0;
    $sql = "select og.goods_id, og.goods_name, og.goods_sn, og.goods_number, og.goods_price, og.product_id, og.goods_attr, o.order_id, o.order_sn, o.user_id, o.shipping_time_end " . " from " . $GLOBALS['ecs']->table('order_info') . " AS o left join " . $GLOBALS['ecs']->table('order_goods') . " AS og " . " on o.order_id=og.order_id where og.goods_id='{$goods_id}' and og.order_id='{$order_id}' and og.product_id='{$product_id}'";
    $row_goods = $GLOBALS['db']->getRow($sql);
    if (!$row_goods || $row_goods['user_id'] != $_SESSION['user_id']) {
        show_message('对不起!您没权限针对该商品发起退款/退货及维修', '返回订单列表页', 'user.php?act=order_list', 'info');
    } else {
        $row_goods['total_price'] = $row_goods['goods_price'] * $row_goods['goods_number'];
        $row_goods['goods_price_format'] = price_format($row_goods['goods_price'], false);
        $row_goods['total_price_format'] = price_format($row_goods['total_price'], false);
        $smarty->assign('back_goods', $row_goods);
        $properties = get_goods_properties($goods_id);
        // 获得商品的规格和属性
        $smarty->assign('specification', $properties['spe']);
        // 商品规格
    }
    // 收货地址 www.68ecshop.com增加
    include_once ROOT_PATH . 'includes/lib_transaction.php';
    $order = $db->getRow("SELECT * FROM " . $ecs->table('order_info') . " WHERE order_id='{$order_id}'");
    $smarty->assign('order', $order);
    $smarty->assign('shop_province', get_regions(1, $order['country']));
    $smarty->assign('shop_city', get_regions(2, $order['province']));
    $smarty->assign('shop_district', get_regions(3, $order['city']));
    $smarty->assign('name_of_region', array($_CFG['name_of_region_1'], $_CFG['name_of_region_2'], $_CFG['name_of_region_3'], $_CFG['name_of_region_4']));
    $smarty->assign('country_list', get_regions());
    $smarty->display('user_transaction.dwt');
}
Ejemplo n.º 3
0
             $smarty->assign('prev_good', $prev_good);//上一个商品
         }
 
         $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']);
 /* current position */
 $smarty->assign('page_title', $position['title']);
 // 页面标题
 $smarty->assign('ur_here', $position['ur_here']);
 // 当前位置
 $properties = get_goods_properties($goods_id);
 // 获得商品的规格和属性
 $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);
 // 关联商品
 $smarty->assign('goods_article_list', get_linked_articles($goods_id));
 // 关联文章
 $smarty->assign('recommend_goods', get_recommend_goods('hot'));
 //获得相关推荐商品
 $smarty->assign('fittings', get_goods_fittings(array($goods_id)));
 // 配件
Ejemplo n.º 4
0
/**
 * 取得某页的批发商品
 * @param   int     $size   每页记录数
 * @param   int     $page   当前页
 * @param   string  $where  查询条件
 * @return  array
 */
function wholesale_list($size, $page, $where)
{
    $list = array();
    $sql = "SELECT w.*, g.goods_thumb, g.goods_name as goods_name " . "FROM " . $GLOBALS['ecs']->table('wholesale') . " AS w, " . $GLOBALS['ecs']->table('goods') . " AS g " . $where . " AND w.goods_id = g.goods_id ";
    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        if (empty($row['goods_thumb'])) {
            $row['goods_thumb'] = $GLOBALS['_CFG']['no_picture'];
        }
        $row['goods_url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
        $properties = get_goods_properties($row['goods_id']);
        $row['goods_attr'] = $properties['pro'];
        $price_ladder = get_price_ladder($row['goods_id']);
        $row['price_ladder'] = $price_ladder;
        $list[] = $row;
    }
    return $list;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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']);

        /* current position */
        $smarty->assign('page_title',          $position['title']);                    // 页面标题
        $smarty->assign('ur_here',             $position['ur_here']);                  // 当前位置

        $properties = get_goods_properties($goods_id);  // 获得商品的规格和属性

        $smarty->assign('properties',          $properties['pro']);                              // 商品属性
        $smarty->assign('specification',       $properties['spe']);                              // 商品规格
		
		//print_r($properties['spe']);
        $smarty->assign('attribute_linked',    get_same_attribute_goods($properties));           // 相同属性的关联商品
        $smarty->assign('related_goods',       $linked_goods);                                   // 关联商品
        $smarty->assign('goods_article_list',  get_linked_articles($goods_id));                  // 关联文章
        $smarty->assign('fittings',            get_goods_fittings(array($goods_id)));                   // 配件
        $smarty->assign('rank_prices',         get_user_rank_prices($goods_id, $shop_price));    // 会员等级价格
        $smarty->assign('pictures',            get_goods_gallery($goods_id));                    // 商品相册
        $smarty->assign('bought_goods',        get_also_bought($goods_id));                      // 购买了该商品的用户还购买了哪些商品
        $smarty->assign('goods_rank',          get_goods_rank($goods_id));                       // 商品的销售排名
		$smarty->assign('related_cat',         get_related_cat($goods['cat_id'])); 
		
Ejemplo n.º 7
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.comments_number, 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;
        }
        /*团购节省和折扣计算 by ecmoban start*/
        $price = $row['market_price'];
        //原价
        if ($row['promote_price'] > 0) {
            $nowprice = $row['promote_price'];
            //现价
        } else {
            $nowprice = $row['shop_price'];
            //现价
        }
        $row['jiesheng'] = $price - $nowprice;
        //节省金额
        if ($nowprice > 0) {
            $row['zhekou'] = round(10 / ($price / $nowprice), 1);
        } else {
            $row['zhekou'] = 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']);
        // 获得商品的规格和属性
        foreach ($properties['spe'] as $value) {
            if ($value['is_show_img'] == 1) {
                foreach ($value['values'] as $values) {
                    $arr[$row['goods_id']]['attr_img'][] = $values['thumb_url'];
                }
            }
        }
        $arr[$row['goods_id']]['name'] = $row['goods_name'];
        $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
        $arr[$row['goods_id']]['zhekou'] = $row['zhekou'];
        $arr[$row['goods_id']]['comments_number'] = $row['comments_number'];
        $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;
}
Ejemplo n.º 8
0
function get_link_goods($goods_id)
{
    $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' . 'FROM ' . $GLOBALS['ecs']->table('link_goods') . ' lg ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = lg.link_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 lg.goods_id = '{$goods_id}' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "LIMIT " . $GLOBALS['_CFG']['related_goods_number'];
    $res = $GLOBALS['db']->query($sql);
    $arr = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
        $arr[$row['goods_id']]['properties'] = get_goods_properties($row['goods_id']);
        $arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
        $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_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']]['market_price'] = price_format($row['market_price']);
        $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
        $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
        if ($row['promote_price'] > 0) {
            $arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
            $arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']);
        } else {
            $arr[$row['goods_id']]['promote_price'] = 0;
        }
    }
    return $arr;
}
Ejemplo n.º 9
0
function action_view()
{
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    /* 取得参数:预售活动id */
    $pre_sale_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    if ($pre_sale_id <= 0) {
        ecs_header("Location: pre_sale.php\n");
        exit;
    }
    /* 取得预售活动信息 */
    $pre_sale = pre_sale_info($pre_sale_id);
    if (empty($pre_sale)) {
        ecs_header("Location: pre_sale.php\n");
        exit;
    }
    // elseif ($pre_sale['is_on_sale'] == 0 || $pre_sale['is_alone_sale'] == 0)
    // {
    // header("Location: ./\n");
    // exit;
    // }
    /* 评价数量 */
    $pre_sale['comment_count'] = goods_comment_count($pre_sale['goods_id']);
    /* 累计销量 */
    $pre_sale['sale_count'] = goods_sale_count($pre_sale['goods_id']);
    /* 赠送积分 */
    $pre_sale['give_integral'] = $pre_sale['gift_integral'];
    /* 缓存id:语言,预售活动id,状态,(如果是进行中)当前数量和是否登录 */
    $cache_id = $_CFG['lang'] . '-' . $pre_sale_id . '-' . $pre_sale['status'];
    // 活动进行中
    if ($pre_sale['status'] == PSS_UNDER_WAY) {
        $cache_id = $cache_id . '-' . $pre_sale['valid_goods'] . '-' . intval($_SESSION['user_id'] > 0);
    }
    $cache_id = sprintf('%X', crc32($cache_id));
    /* 如果没有缓存,生成缓存 */
    if (!$smarty->is_cached('pre_sale_goods.dwt', $cache_id) || true) {
        $pre_sale['gmt_end_date'] = $pre_sale['end_date'];
        $smarty->assign('pre_sale', $pre_sale);
        /* 取得预售商品信息 */
        $goods_id = $pre_sale['goods_id'];
        $goods = get_goods_info($goods_id);
        if (empty($goods)) {
            ecs_header("Location: pre_sale.php\n");
            exit;
        }
        $goods['url'] = build_uri('goods', array('gid' => $goods_id), $goods['goods_name']);
        $goods = array_merge($goods, $pre_sale);
        $gift_integral = $pre_sale['gift_integral'];
        $goods['give_integral'] = $pre_sale['gift_integral'];
        // $parent_cat_id = get_parent_cat_id($goods['cat_id']);
        // $goods['child_cat'] = get_child_cat($parent_cat_id); // 相关分类
        // $goods['get_cat_brands'] = get_cat_brands($parent_cat_id);; // 同类品牌
        $smarty->assign('url', $_SERVER["REQUEST_URI"]);
        $smarty->assign('volume_price', $goods_volume_price);
        $smarty->assign('goods_id', $goods['goods_id']);
        $smarty->assign('promote_end_time', $goods['gmt_end_time']);
        $smarty->assign('helps', get_shop_help());
        // 网店帮助
        $smarty->assign('top_goods', get_top10());
        // 销售排行
        $smarty->assign('promotion_info', get_promotion_info());
        // yyy添加start
        $count1 = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('comment') . " where comment_type=0 and id_value ='{$goods_id}' and status=1");
        $smarty->assign('review_count', $count1);
        // 评论数
        // 评价晒单 增加 by www.68ecshop.com
        $rank_num['rank_a'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND comment_rank in (5,4)");
        $rank_num['rank_b'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND comment_rank in (3,2)");
        $rank_num['rank_c'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND comment_rank = 1");
        $rank_num['rank_total'] = $rank_num['rank_a'] + $rank_num['rank_b'] + $rank_num['rank_c'];
        $rank_num['rank_pa'] = $rank_num['rank_a'] > 0 ? round($rank_num['rank_a'] / $rank_num['rank_total'] * 100, 1) : 0;
        $rank_num['rank_pb'] = $rank_num['rank_b'] > 0 ? round($rank_num['rank_b'] / $rank_num['rank_total'] * 100, 1) : 0;
        $rank_num['rank_pc'] = $rank_num['rank_c'] > 0 ? round($rank_num['rank_c'] / $rank_num['rank_total'] * 100, 1) : 0;
        $rank_num['shaidan_num'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('shaidan') . " WHERE goods_id = '{$goods_id}' AND status = 1");
        $smarty->assign('rank_num', $rank_num);
        $res = $GLOBALS['db']->getAll("SELECT * FROM " . $GLOBALS['ecs']->table('goods_tag') . " WHERE goods_id = '{$goods_id}' AND state = 1");
        foreach ($res as $v) {
            $v['tag_num'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND FIND_IN_SET({$v['tag_id']},comment_tag)");
            $tag_arr[] = $v;
        }
        require_once 'includes/lib_comment.php';
        $tag_arr = array_sort($tag_arr, 'tag_num', 'desc');
        if ($tag_arr) {
            foreach ($tag_arr as $key => $val) {
                if ($_CFG['tag_show_num'] > 0) {
                    if ($key + 1 <= $_CFG['tag_show_num']) {
                        $comment_tags[] = $val;
                    }
                } else {
                    $comment_tags[] = $val;
                }
            }
        }
        $smarty->assign('comment_tags', $comment_tags);
        /* meta */
        $smarty->assign('keywords', htmlspecialchars($goods['keywords']));
        $smarty->assign('description', htmlspecialchars($goods['goods_brief']));
        $goods['goods_style_name'] = add_style($goods['goods_name'], $goods['goods_name_style']);
        $smarty->assign('goods', $goods);
        $smarty->assign('goods_id', $goods['goods_id']);
        /* 取得商品的规格 */
        $properties = get_goods_properties($goods_id);
        $smarty->assign('specification', $properties['spe']);
        // 商品规格
        $smarty->assign('pictures', get_goods_gallery_attr_2($goods_id, $goods_attr_id));
        // 商品相册
        $smarty->assign('new_goods', get_recommend_goods('new'));
        // 最新商品
        $smarty->assign('shop_country', $_CFG['shop_country']);
        /* 代码增加_start By www.ecshop68.com */
        $sql_attr = "SELECT a.attr_id, ga.goods_attr_id FROM " . $GLOBALS['ecs']->table('attribute') . " AS a left join " . $GLOBALS['ecs']->table('goods_attr') . "  AS ga on a.attr_id=ga.attr_id  WHERE a.is_attr_gallery=1 and ga.goods_id='" . $goods_id . "' order by ga.goods_attr_id ";
        $goods_attr = $GLOBALS['db']->getRow($sql_attr);
        if ($goods_attr) {
            $goods_attr_id = $goods_attr['goods_attr_id'];
            $smarty->assign('attr_id', $goods_attr['attr_id']);
        } else {
            $smarty->assign('attr_id', 0);
        }
        $prod_exist_arr = array();
        $sql_prod = "select goods_attr from " . $GLOBALS['ecs']->table('products') . " where product_number>0 and goods_id='{$goods_id}' order by goods_attr";
        $res_prod = $GLOBALS['db']->query($sql_prod);
        while ($row_prod = $GLOBALS['db']->fetchRow($res_prod)) {
            $prod_exist_arr[] = "|" . $row_prod['goods_attr'] . "|";
        }
        $smarty->assign('prod_exist_arr', $prod_exist_arr);
        // 模板赋值
        $smarty->assign('cfg', $_CFG);
        assign_template();
        $position = assign_ur_here(0, $goods['goods_name']);
        $smarty->assign('page_title', $position['title']);
        // 页面标题
        $smarty->assign('ur_here', $position['ur_here']);
        // 当前位置
        /* 代码增加_start By www.68ecshop.com */
        $goods['supplier_name'] = "网站自营";
        if ($goods['supplier_id'] > 0) {
            $sql_supplier = "SELECT s.supplier_id,s.supplier_name,s.add_time,sr.rank_name FROM " . $ecs->table("supplier") . " as s left join " . $ecs->table("supplier_rank") . " as sr ON s.rank_id=sr.rank_id WHERE s.supplier_id=" . $goods[supplier_id] . " AND s.status=1";
            $shopuserinfo = $db->getRow($sql_supplier);
            $goods['supplier_name'] = $shopuserinfo['supplier_name'];
            get_dianpu_baseinfo($goods['supplier_id'], $shopuserinfo);
        }
        assign_dynamic('pre_sale_goods');
    }
    // 更新商品点击次数
    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('goods') . ' SET click_count = click_count + 1 ' . "WHERE goods_id = '" . $pre_sale['goods_id'] . "'";
    $GLOBALS['db']->query($sql);
    $smarty->assign('now_time', gmtime());
    // 当前系统时间
    $smarty->display('pre_sale_goods.dwt', $cache_id);
}
Ejemplo n.º 10
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;
}
Ejemplo n.º 11
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']]['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']);
 }
Ejemplo n.º 12
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;
}