Example #1
0
/**
 * 获得文章分类下的文章列表
 *
 * @access  public
 * @param   integer     $cat_id
 * @param   integer     $page
 * @param   integer     $size
 *
 * @return  array
 */
function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '')
{
    //取出所有非0的文章
    if ($cat_id == '-1') {
        $cat_str = 'cat_id > 0';
    } else {
        $cat_str = get_article_children($cat_id);
    }
    //增加搜索条件,如果有搜索内容就进行搜索
    if ($requirement != '') {
        $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('ecsmart_article') . ' WHERE is_open = 1 AND title like \'%' . $requirement . '%\' ' . ' ORDER BY article_type DESC, article_id DESC';
    } else {
        $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('ecsmart_article') . ' WHERE is_open = 1 AND ' . $cat_str . ' ORDER BY article_type DESC, article_id DESC';
    }
    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
    $arr = array();
    if ($res) {
        while ($row = $GLOBALS['db']->fetchRow($res)) {
            $article_id = $row['article_id'];
            $arr[$article_id]['id'] = $article_id;
            $arr[$article_id]['title'] = $row['title'];
            $arr[$article_id]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
            $arr[$article_id]['author'] = empty($row['author']) || $row['author'] == '_SHOPHELP' ? $GLOBALS['_CFG']['shop_name'] : $row['author'];
            $arr[$article_id]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $article_id), $row['title']) : trim($row['file_url']);
            $arr[$article_id]['add_time'] = date($GLOBALS['_CFG']['date_format'], $row['add_time']);
        }
    }
    return $arr;
}
Example #2
0
/**
 * 调用浏览历史
 *
 * @access  public
 * @return  string
 */
function insert_history()
{
    $time = gmtime();
    $str = '';
    if (!empty($_COOKIE['ECS']['history'])) {
        $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id');
        $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price ,promote_price,promote_start_date,promote_end_date,is_promote FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
        $query = $GLOBALS['db']->query($sql);
        $res = array();
        while ($row = $GLOBALS['db']->fetch_array($query)) {
            $goods['goods_id'] = $row['goods_id'];
            $goods['goods_name'] = $row['goods_name'];
            $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
            $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
            if ($row['is_promote'] == 1 && $time > $row['promote_start_date'] && $time < $row['promote_end_date']) {
                $goods['shop_price'] = price_format($row['promote_price']);
            } else {
                $goods['shop_price'] = price_format($row['shop_price']);
            }
            $goods['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
            $str .= '<ul class="clearfix"><li class="goodsimg"><a href="' . $goods['url'] . '" target="_blank"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '" class="B_blue" /></a></li><li><a href="' . $goods['url'] . '" target="_blank" title="' . $goods['goods_name'] . '">' . $goods['short_name'] . '</a><br />' . $GLOBALS['_LANG']['shop_price'] . '<font class="f1">' . $goods['shop_price'] . '</font><br /></li></ul>';
        }
        $str .= '<ul id="clear_history"><a onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</a></ul>';
    }
    return $str;
}
Example #3
0
function get_supplier_goods($gtype = 0, $limit = 10)
{
    $gtype = intval($gtype);
    if ($gtype <= 0) {
        return;
    }
    $sql = "SELECT DISTINCT g.goods_id,g.* FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('supplier_goods_cat') . " AS gc, " . $GLOBALS['ecs']->table('supplier_cat_recommend') . " AS cr \n\tWHERE cr.recommend_type =" . $gtype . " AND cr.supplier_id =" . $_GET['suppId'] . " AND cr.cat_id = gc.cat_id AND gc.goods_id = g.goods_id \n\tAND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 \n\tORDER BY g.sort_order, g.last_update DESC LIMIT " . $limit;
    $result = $GLOBALS['db']->getAll($sql);
    $goods = array();
    if ($result) {
        foreach ($result as $idx => $row) {
            if ($row['promote_price'] > 0) {
                $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
                $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
            } else {
                $goods[$idx]['promote_price'] = '';
            }
            $goods[$idx]['id'] = $row['goods_id'];
            $goods[$idx]['name'] = $row['goods_name'];
            $goods[$idx]['brief'] = $row['goods_brief'];
            $goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
            $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
            $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
            $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
            $goods[$idx]['market_price'] = price_format($row['market_price']);
            $goods[$idx]['shop_price'] = price_format($row['shop_price']);
            $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
            $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
            //$goods[$idx]['url']          = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
        }
    }
    return $goods;
}
Example #4
0
function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order)
{
    $cate_where = 0 < $cate ? "AND " . get_children($cate) : "";
    $sql = "SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price,g.is_promote, g.is_new, g.is_best, g.is_hot," . ("IFNULL(mp.user_price, g.shop_price * '" . $_SESSION['discount'] . "') AS shop_price, g.promote_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(r.id_value), 0) from " . $GLOBALS['ecs']->table("comment") . " as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_count, (select IFNULL(sum(og.goods_number), 0) from " . $GLOBALS['ecs']->table("order_goods") . " as og where og.goods_id = g.goods_id) AS sell_number, g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM " . $GLOBALS['ecs']->table("goods") . " AS g LEFT JOIN " . $GLOBALS['ecs']->table("member_price") . " AS mp " . ("ON mp.goods_id = g.goods_id AND mp.user_rank = '" . $_SESSION['user_rank'] . "' ") . ("WHERE 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 (0 < $row['promote_price']) {
            $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
        } else {
            $promote_price = 0;
        }
        $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
        if ($GLOBALS['display'] == "grid") {
            $arr[$row['goods_id']]['short_name'] = 0 < $GLOBALS['_CFG']['goods_name_length'] ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        }
        $arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
        $arr[$row['goods_id']]['goods_sn'] = $row['goods_sn'];
        $arr[$row['goods_id']]['comment_count'] = $row['comment_count'];
        $arr[$row['goods_id']]['comment_rank'] = $row['comment_rank'];
        $arr[$row['goods_id']]['sell_number'] = $row['sell_number'];
        $arr[$row['goods_id']]['is_promote'] = $row['is_promote'];
        $arr[$row['goods_id']]['is_new'] = $row['is_new'];
        $arr[$row['goods_id']]['is_best'] = $row['is_best'];
        $arr[$row['goods_id']]['is_hot'] = $row['is_hot'];
        $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
        $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
        $arr[$row['goods_id']]['promote_price'] = 0 < $promote_price ? 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;
}
Example #5
0
/**
 * 获得推荐商品
 *
 * @access  public
 * @param   string      $type       推荐类型,可以是 best, new, hot
 * @return  array
 */
function get_index_best($limit = '')
{
    $time = gmtime();
    //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
    $sql = 'SELECT g.goods_id, g.goods_name,g.click_count, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' ";
    $sql .= ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = "best" ';
    $sql .= ' ORDER BY g.sort_order, g.last_update DESC';
    $sql .= " {$limit}";
    $result = $GLOBALS['db']->getAll($sql);
    foreach ($result as $idx => $row) {
        if ($row['promote_price'] > 0) {
            $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
            $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
        } else {
            $goods[$idx]['promote_price'] = '';
        }
        $goods[$idx]['id'] = $row['goods_id'];
        $goods[$idx]['name'] = $row['goods_name'];
        $goods[$idx]['brief'] = $row['goods_brief'];
        $goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
        $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
        $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
        $goods[$idx]['market_price'] = price_format($row['market_price']);
        $goods[$idx]['shop_price'] = price_format($row['shop_price']);
        $goods[$idx]['thumb'] = '../' . get_image_path($row['goods_id'], $row['goods_thumb'], true);
        $goods[$idx]['goods_img'] = '../' . get_image_path($row['goods_id'], $row['goods_img']);
        $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
        $goods[$idx]['sell_count'] = selled_count($row['goods_id']);
        $goods[$idx]['pinglun'] = get_evaluation_sum($row['goods_id']);
        $goods[$idx]['count'] = selled_count($row['goods_id']);
        $goods[$idx]['click_count'] = $row['click_count'];
    }
    return $goods;
}
Example #6
0
function get_cat_id_goods_list($cat_id = '', $num = '', $ext = '')
{
    $sql = 'Select g.goods_id,g.guige, g.cat_id,c.parent_id, g.goods_name, g.goods_number, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote,b.brand_name " . 'FROM ' . $GLOBALS['hhs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['hhs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' . "LEFT JOIN " . $GLOBALS['hhs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " left join " . $GLOBALS['hhs']->table('brand') . " as b on g.brand_id=b.brand_id " . " Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_new = 1 AND g.is_delete = 0 and g.is_mall=1 " . ($sql .= " AND (c.parent_id =" . $cat_id . " OR g.cat_id = " . $cat_id . " OR g.cat_id " . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ")");
    $sql .= $ext;
    $sql .= " LIMIT {$num}";
    $res = $GLOBALS['db']->getAll($sql);
    $goods = array();
    foreach ($res as $idx => $row) {
        $goods[$idx]['id'] = $row['goods_id'];
        $goods[$idx]['name'] = $row['goods_name'];
        $goods[$idx]['guige'] = $row['guige'];
        $goods[$idx]['brief'] = $row['goods_brief'];
        $goods[$idx]['brand_name'] = $row['brand_name'];
        $goods[$idx]['goods_number'] = $row['goods_number'];
        $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
        $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
        $goods[$idx]['market_price'] = price_format($row['market_price']);
        $goods[$idx]['shop_price'] = price_format($row['shop_price']);
        $goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb'];
        $goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img'];
        $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
        if ($GLOBALS['SID']) {
            $goods[$idx]['shop_price'] = price_format($row['s_goods_price']);
        }
    }
    return $goods;
}
Example #7
0
/**
 * 通过判断is_feed 向UCenter提交Feed
 *
 * @access public
 * @param  integer $value_id  $order_id or $comment_id
 * @param  interger $feed_type BUY_GOODS or COMMENT_GOODS
 *
 * @return void
 */
function add_feed($id, $feed_type)
{
    $feed = array();
    if ($feed_type == BUY_GOODS) {
        if (empty($id)) {
            return;
        }
        $id = intval($id);
        $order_res = $GLOBALS['db']->getAll("SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_desc, g.goods_thumb, o.goods_price FROM " . $GLOBALS['ecs']->table('order_goods') . " AS o, " . $GLOBALS['ecs']->table('goods') . " AS g WHERE o.order_id='{$id}' AND o.goods_id=g.goods_id");
        foreach ($order_res as $goods_data) {
            if (!empty($goods_data['goods_thumb'])) {
                $url = $GLOBALS['ecs']->url() . $goods_data['goods_thumb'];
            } else {
                $url = $GLOBALS['ecs']->url() . $GLOBALS['_CFG']['no_picture'];
            }
            $link = $GLOBALS['ecs']->url() . "goods.php?id=" . $goods_data["goods_id"];
            $feed['icon'] = "goods";
            $feed['title_template'] = '<b>{username} ' . $GLOBALS['_LANG']['feed_user_buy'] . ' {goods_name}</b>';
            $feed['title_data'] = array('username' => $_SESSION['user_name'], 'goods_name' => $goods_data['goods_name']);
            $feed['body_template'] = '{goods_name}  ' . $GLOBALS['_LANG']['feed_goods_price'] . ':{goods_price}  ' . $GLOBALS['_LANG']['feed_goods_desc'] . ':{goods_desc}';
            $feed['body_data'] = array('goods_name' => $goods_data['goods_name'], 'goods_price' => $goods_data['goods_price'], 'goods_desc' => sub_str(strip_tags($goods_data['goods_desc']), 150, true));
            $feed['images'][] = array('url' => $url, 'link' => $link);
            uc_call("uc_feed_add", array($feed['icon'], $_SESSION['user_id'], $_SESSION['user_name'], $feed['title_template'], $feed['title_data'], $feed['body_template'], $feed['body_data'], '', '', $feed['images']));
        }
    }
    return;
}
Example #8
0
/**
 * 调用购物车信息
 *
 * @access  public
 * @return  string
 */
function insert_cart_info()
{
    $sql = 'SELECT c.*,g.goods_name,g.goods_thumb,g.goods_id,c.goods_number,c.goods_price' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " AS c " . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON g.goods_id=c.goods_id " . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'";
    $row = $GLOBALS['db']->GetAll($sql);
    $arr = array();
    foreach ($row as $k => $v) {
        $arr[$k]['goods_thumb'] = get_image_path($v['goods_id'], $v['goods_thumb'], true);
        $arr[$k]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($v['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $v['goods_name'];
        $arr[$k]['url'] = build_uri('goods', array('gid' => $v['goods_id']), $v['goods_name']);
        $arr[$k]['goods_number'] = $v['goods_number'];
        $arr[$k]['goods_name'] = $v['goods_name'];
        $arr[$k]['goods_price'] = price_format($v['goods_price']);
        $arr[$k]['rec_id'] = $v['rec_id'];
    }
    $sql = 'SELECT SUM(goods_number) AS number, SUM(goods_price * goods_number) AS amount' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'";
    $row = $GLOBALS['db']->GetRow($sql);
    if ($row) {
        $number = intval($row['number']);
        $amount = floatval($row['amount']);
    } else {
        $number = 0;
        $amount = 0;
    }
    $GLOBALS['smarty']->assign('str', sprintf($GLOBALS['_LANG']['cart_info'], $number, price_format($amount, false)));
    $GLOBALS['smarty']->assign('goods', $arr);
    $output = $GLOBALS['smarty']->fetch('library/cart_info.lbi');
    return $output;
}
 /**
  * 获得文章分类下的文章列表
  * 
  * @access public
  * @param integer $cat_id            
  * @param integer $page            
  * @param integer $size            
  * @return array
  */
 public function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '')
 {
     // 取出所有非0的文章
     if ($cat_id == '-1') {
         $cat_str = 'cat_id > 0';
     } else {
         $cat_str = get_article_children($cat_id);
     }
     $condition = 'is_open = 1 AND ' . $cat_str;
     // 增加搜索条件,如果有搜索内容就进行搜索
     if ($requirement != '') {
         $condition .= ' AND title like \'%' . $requirement . '%\'';
     }
     $limit = ($page - 1) * $size . ',' . $size;
     $list = $this->select($condition, 'article_id, title, author, add_time, file_url, open_type,link', ' article_id DESC', $limit);
     $i = 1;
     $arr = array();
     if (is_array($list)) {
         foreach ($list as $vo) {
             $article_id = $vo['article_id'];
             $arr[$article_id]['id'] = $article_id;
             $arr[$article_id]['index'] = $i;
             $arr[$article_id]['title'] = $vo['title'];
             $arr[$article_id]['short_title'] = C('article_title_length') > 0 ? sub_str($vo['title'], C('article_title_length')) : $vo['title'];
             $arr[$article_id]['author'] = empty($vo['author']) || $vo['author'] == '_SHOPHELP' ? C('shop_name') : $vo['author'];
             $arr[$article_id]['url'] = $vo['link'] ? $vo['link'] : url('article/info', array('aid' => $article_id));
             $arr[$article_id]['add_time'] = date(C('date_format'), $vo['add_time']);
             $i++;
         }
     }
     return $arr;
 }
Example #10
0
File: brand.php Project: qgz/ecshop
function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order)
{
    $cate_where = $cate > 0 ? 'AND ' . get_children($cate) : '';
    /* 获得商品列表 */
    $sql = 'SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price, g.is_new,' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_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, ' . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.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;
        }
        $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
        if ($GLOBALS['display'] == 'grid') {
            $arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        }
        $arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
        $arr[$row['goods_id']]['goods_sn'] = $row['goods_sn'];
        $arr[$row['goods_id']]['comment_rank'] = $row['comment_rank'];
        $arr[$row['goods_id']]['sell_number'] = $row['sell_number'];
        $arr[$row['goods_id']]['is_new'] = $row['is_new'];
        $arr[$row['goods_id']]['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;
}
Example #11
0
 function show_chooseform()
 {
     echo "\t\t<script language=\"JavaScript\" type=\"text/javascript\">\n";
     echo "\t\t<!--\n";
     echo "\t\tdocument.forms['payform'].js.value=1;\n";
     echo "\t\t-->;\n";
     echo "\t\t</script>\n";
     echo "\t\t<script language='javascript' type='text/javascript' src='https://secure.payu.com/paygw/UTF/js/" . $this->pos . "/" . sub_str($this->key1, 0, 2) . "/template:3/ext_calc:1/paytype.js'></script>\n";
     echo "\t\t<script language='JavaScript' type='text/JavaScript'>\n\t\t\t\t\t\t\t\t\t\tPlnPrintTemplate();\n\t\t\t\t\t\t\t\t\t</script>\n";
 }
    /**
     * 获得分类下的商品
     *
     * @access  public
     * @param   string  $children
     * @return  array
     */
    function exchange_get_goods($children, $min, $max, $ext, $size, $page, $sort, $order) {
        $display = $GLOBALS['display'];
        $where = "eg.is_exchange = 1 AND g.is_delete = 0 AND " .
                "($children OR " . model('Goods')->get_extension_goods($children) . ')';

        if ($min > 0) {
            $where .= " AND eg.exchange_integral >= $min ";
        }

        if ($max > 0) {
            $where .= " AND eg.exchange_integral <= $max ";
        }

        /* 获得商品列表 */
        $start = ($page - 1) * $size;
        $sort = $sort =='sales_volume'? 'xl.sales_volume': $sort;
        $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.goods_name_style, eg.exchange_integral, ' .
                'g.goods_type, g.goods_brief, g.goods_thumb , g.goods_img, eg.is_hot ' .
                'FROM ' . $this->pre . 'exchange_goods AS eg LEFT JOIN  ' . $this->pre . 'goods AS g ' .
                'ON  eg.goods_id = g.goods_id ' . ' LEFT JOIN ' . $this->pre . 'touch_goods AS xl ' . ' ON g.goods_id=xl.goods_id ' .
                " WHERE $where $ext ORDER BY $sort $order LIMIT $start ,$size ";
        $res = $this->query($sql);
        $arr = array();
        foreach ($res as $row) {
            $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
            if ($display == 'grid') {
                $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
            } else {
                $arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
            }
            $arr[$row['goods_id']]['name'] = $row['goods_name'];
            $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
            $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
            $arr[$row['goods_id']] ['market_price'] = price_format($row ['market_price']);
            $arr[$row['goods_id']]['exchange_integral'] = $row['exchange_integral'];
            $arr[$row['goods_id']]['type'] = $row['goods_type'];
            $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
            $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
            $arr[$row['goods_id']]['url'] = build_uri('exchange_goods', array('gid' => $row['goods_id']), $row['goods_name']);
            $arr[$row['goods_id']]['sc'] = model('GoodsBase')->get_goods_collect($row['goods_id']);
            $arr[$row['goods_id']]['mysc'] = 0;
            // 检查是否已经存在于用户的收藏夹
            if ($_SESSION ['user_id']) {
                unset($where);
                // 用户自己有没有收藏过
                $where['goods_id'] = $row ['goods_id'];
                $where['user_id'] = $_SESSION ['user_id'];
                $rs = $this->model->table('collect_goods')->where($where)->count();
                $arr[$row['goods_id']]['mysc'] = $rs;
            }
        }
        return $arr;
    }
    /**
     * 获得品牌下的商品
     *
     * @access private
     * @param integer $brand_id 
     * @return array
     */
    function brand_get_goods($brand_id, $cate, $sort, $order, $size, $page) {
        $cate_where = ($cate > 0) ? 'AND ' . get_children($cate) : '';

        $start = ($page - 1) * $size;
        /* 获得商品列表 */
        $sort = $sort =='sales_volume'? 'xl.sales_volume': $sort;
        $sql = 'SELECT g.goods_id, g.goods_name,g.goods_number, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $this->pre . 'goods AS g ' . 'LEFT JOIN ' . $this->pre . 'touch_goods AS xl ' . "ON g.goods_id=xl.goods_id " . 'LEFT JOIN ' . $this->pre . 'member_price AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '$brand_id' $cate_where" . "ORDER BY $sort $order LIMIT $start , $size";
        $res = $this->query($sql);
        $arr = array();
        foreach ($res as $row) {
            if ($row['promote_price'] > 0) {
                $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
            } else {
                $promote_price = 0;
            }

            $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'];
            }
            $arr[$row['goods_id']]['discount'] = $row['market_price'] > 0 ? (round((($promote_price > 0 ? $promote_price : $row['shop_price']) / $row['market_price']) * 10)) : 0;
            $arr[$row['goods_id']]['goods_number'] = $row['goods_number'];
            $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/index', array(
                'id' => $row['goods_id']
                    ), $row['goods_name']);
            $arr[$row['goods_id']]['sales_count'] = model('GoodsBase')->get_sales_count($row['goods_id']);
            $arr[$row['goods_id']]['sc'] = model('GoodsBase')->get_goods_collect($row['goods_id']);
            $arr[$row['goods_id']]['promotion'] = model('GoodsBase')->get_promotion_show($row['goods_id']);
            $arr[$row['goods_id']]['mysc'] = 0;
            // 检查是否已经存在于用户的收藏夹
            if ($_SESSION['user_id']) {
                unset($where);
                // 用户自己有没有收藏过
                $where['goods_id'] = $row['goods_id'];
                $where['user_id'] = $_SESSION['user_id'];
                $rs = $this->model->table('collect_goods')
                        ->where($where)
                        ->count();
                $arr[$row['goods_id']]['mysc'] = $rs;
            }
        }

        return $arr;
    }
Example #14
0
function format_content($input, $length)
{
    if (strlen($input) <= $length) {
        return $input;
    }
    $first = sub_str($input, 0, $length);
    if (strlen($input) <= $length * 2) {
        $last = sub_str($input, $length);
    } else {
        $last = sub_str($input, $length, $length - 3) . '...';
    }
    return "{$first}<br />{$last}";
}
Example #15
0
 /**
  * 分配帮助信息
  *
  * @access  public
  * @return  array
  */
 function get_shop_help()
 {
     $sql = 'SELECT c.cat_id, c.cat_name, c.sort_order, a.article_id, a.title, a.file_url, a.open_type ' . 'FROM ' . $this->pre . 'article AS a ' . 'LEFT JOIN ' . $this->pre . 'article_cat AS c ' . 'ON a.cat_id = c.cat_id WHERE c.cat_type = 5 AND a.is_open = 1 ' . 'ORDER BY c.sort_order ASC, a.article_id';
     $res = $this->query($sql);
     $arr = array();
     foreach ($res as $key => $row) {
         $arr[$row['cat_id']]['cat_id'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);
         $arr[$row['cat_id']]['cat_name'] = $row['cat_name'];
         $arr[$row['cat_id']]['article'][$key]['article_id'] = $row['article_id'];
         $arr[$row['cat_id']]['article'][$key]['title'] = $row['title'];
         $arr[$row['cat_id']]['article'][$key]['short_title'] = C('article_title_length') > 0 ? sub_str($row['title'], C('article_title_length')) : $row['title'];
         $arr[$row['cat_id']]['article'][$key]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
     }
     return $arr;
 }
Example #16
0
function get_articles_cat_name($cat_name, $limit)
{
    $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name ' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac' . ' WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_type = 1 AND ac.cat_name="' . $cat_name . '" ORDER BY a.article_type DESC, a.add_time DESC LIMIT ' . $limit;
    $res = $GLOBALS['db']->getAll($sql);
    $arr = array();
    foreach ($res as $idx => $row) {
        $arr[$idx]['id'] = $row['article_id'];
        $arr[$idx]['title'] = $row['title'];
        $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
        $arr[$idx]['cat_name'] = $row['cat_name'];
        $arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
        $arr[$idx]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
        $arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);
    }
    return $arr;
}
Example #17
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;
}
Example #18
0
function queryListByCatId($cat_id, $page, $size, $keywords)
{
    $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name, a.content ' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac' . " WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_id = {$cat_id}" . ' ORDER BY a.article_type DESC, a.add_time DESC LIMIT ' . $size * ($page - 1) . ',' . $size * $page;
    $res = $GLOBALS['db']->getAll($sql);
    $arr = array();
    foreach ($res as $idx => $row) {
        $arr[$idx]['id'] = $row['article_id'];
        $arr[$idx]['title'] = $row['title'];
        $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
        $arr[$idx]['cat_name'] = $row['cat_name'];
        $arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
        $arr[$idx]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
        $arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);
        $arr[$idx]['content'] = strip_tags($row['content']);
        $arr[$idx]['file_url'] = $row['file_url'];
    }
    return $arr;
}
Example #19
0
function get_shop_help2()
{
    $sql = 'SELECT c.cat_id, a.link, c.cat_name, a.content, c.sort_order, a.article_id, a.title, a.file_url, a.open_type ' . 'FROM ' . $GLOBALS['ecs']->table('article') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('article_cat') . ' AS c ' . 'ON a.cat_id = c.cat_id WHERE c.cat_type = 5 AND a.is_open = 1 AND a.open_type = 0 ' . 'ORDER BY c.sort_order ASC, a.article_id';
    $res = $GLOBALS['db']->getAll($sql);
    $arr = array();
    foreach ($res as $key => $row) {
        if (!empty($row['link']) && $row['link'] != 'http://' && $row['link'] != 'https://') {
            continue;
        }
        if (empty($row['content'])) {
            continue;
        }
        $arr[$row['cat_id']]['name'] = $row['cat_name'];
        $arr[$row['cat_id']]['article'][$key]['id'] = $row['article_id'];
        $arr[$row['cat_id']]['article'][$key]['title'] = $row['title'];
        $arr[$row['cat_id']]['article'][$key]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
    }
    return $arr;
}
Example #20
0
 public function E($value, $modify, $attrib = '')
 {
     $value = $this->view->escape($string);
     switch ($modify) {
         /* 截取字符。默认截取80个字 */
         case 'truncate':
             $value = sub_str($value, intval($attrib) ? intval($attrib) : 80, true);
             break;
             /* 为变量增加CSS样式,默认红色 */
         /* 为变量增加CSS样式,默认红色 */
         case 'style':
             $value = '<span style="' . ($attrib ? $attrib : 'color:#ff0000') . '">' . $value . '</span>';
             break;
             /* 为变量CSS类名 */
         /* 为变量CSS类名 */
         case 'class':
             $value = '<span' . ($attrib ? ' class="' . $attrib . '"' : '') . '>' . $value . '</span>';
             break;
     }
     return $value;
 }
Example #21
0
/**
 * 调用浏览历史
 *
 * @access  public
 * @return  string
 */
function insert_history()
{
    $str = '';
    $history = array();
    if (!empty($_COOKIE['ECS']['history'])) {
        $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id');
        $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . M()->pre . 'goods' . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
        $query = M()->query($sql);
        $res = array();
        foreach ($query as $key => $row) {
            $goods['goods_id'] = $row['goods_id'];
            $goods['goods_name'] = $row['goods_name'];
            $goods['short_name'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('goods_name_length')) : $row['goods_name'];
            $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
            $goods['shop_price'] = price_format($row['shop_price']);
            $goods['url'] = url('goods/index', array('id' => $row['goods_id']));
            $history[] = $goods;
        }
    }
    return $history;
}
Example #22
0
/**
 * 变量值格式化
 *
 * @params mix  $value   要修饰的值
 * @params str  $modify  修饰类型
 * @params str  $attrib  修饰类型的属性
 *
 * @return str  返回修饰后的字符
 */
function f($value, $modify, $attrib = '')
{
    switch ($modify) {
        /* html 中的 js string 编码(以单引号为边界). 编码( " ) 转义( ' => \' ) */
        case 'hstr':
            $value = addslashes(strtr($value, array('"' => '&quot;')));
            break;
            /* html 编码( & , " , < , > , 空格, 换行 ) */
        /* html 编码( & , " , < , > , 空格, 换行 ) */
        case 'html':
            $value = strtr(htmlspecialchars($value), array(' ' => '&nbsp;', "\r\n" => '<br />', "\n" => '<br />'));
            break;
            /* 格式化时间。默认格式YYYY-MM-DD HH:II, 无效值则返回'' */
        /* 格式化时间。默认格式YYYY-MM-DD HH:II, 无效值则返回'' */
        case 'date':
            $value = $value >= 57600 && $value <= 2147443200 ? date(f($attrib, 'default', 'Y-m-d H:i'), $value) : '';
            break;
            /* html formc 编码( & , " , < , > ) */
        /* html formc 编码( & , " , < , > ) */
        case 'formc':
            $value = htmlspecialchars($value);
            break;
            /* 字符颜色,格式化成FONT。默认红色 */
        /* 字符颜色,格式化成FONT。默认红色 */
        case 'color':
            $value = '<font color="' . ($attrib ? $attrib : '#ff0000') . '">' . $value . '</font>';
            break;
            /* 变量默认值。默认值:'', false, 0, '0', null, array() ) */
        /* 变量默认值。默认值:'', false, 0, '0', null, array() ) */
        case 'default':
            $value = empty($value) ? $attrib : $value;
            break;
            /* 字符截取。默认截取80个字 */
        /* 字符截取。默认截取80个字 */
        case 'truncate':
            $value = sub_str($value, intval($attrib) ? intval($attrib) : 80, true);
            break;
    }
    return $value;
}
Example #23
0
/**
 * 调用浏览历史
 */
function insert_siy_history()
{
    $str = '';
    if (!empty($_COOKIE['ECS']['history'])) {
        $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id');
        $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
        $query = $GLOBALS['db']->query($sql);
        $res = array();
        $str .= '<div id="history" class="box">
	<b class="tp"><b></b></b>
	<div class="hd"><h3>' . $GLOBALS['_LANG']['view_history'] . '</h3><span class="more" onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</span></div>
	<div class="bd">
		<ul class="goods-list">';
        while ($row = $GLOBALS['db']->fetch_array($query)) {
            $goods['goods_id'] = $row['goods_id'];
            $goods['goods_name'] = $row['goods_name'];
            $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
            $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
            $goods['shop_price'] = price_format($row['shop_price']);
            $goods['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
            $str .= '		<li>
				<span class="photo">
					<a href="' . $goods['url'] . '" title="' . $goods['goods_name'] . '" class="image"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '"/></a>
				</span>
				<span class="info">
					<a href="' . $goods['url'] . '" title="' . $goods['goods_name'] . '" class="name">' . $goods['short_name'] . '</a>
					<em class="price">' . $goods['shop_price'] . '</em>
				</span>
				<span class="action">
					<a href="' . $goods['url'] . '" class="detail">' . $GLOBALS['_LANG']['btn_detail'] . '</a>
				</span>
			</li>';
        }
        $str .= '	</ul>
	</div>
	<b class="bt"><b></b></b>
</div>';
    }
    return $str;
}
/**
 * 调用浏览历史
 *
 * @access  public
 * @return  string
 */
function insert_history()
{
    $str = '';
    if (!empty($_COOKIE['ECS']['history'])) {
        $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id');
        $sql = 'SELECT goods_id, goods_name FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
        $query = $GLOBALS['db']->query($sql);
        $res = array();
        while ($row = $GLOBALS['db']->fetch_array($query)) {
            $res[$row['goods_id']] = $row;
        }
        $tureorder = explode(',', $_COOKIE['ECS']['history']);
        foreach ($tureorder as $key => $val) {
            $goods_name = htmlspecialchars($res[$val]['goods_name']);
            if ($goods_name) {
                $short_name = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($goods_name, $GLOBALS['_CFG']['goods_name_length']) : $goods_name;
                $str .= '<li><a href="' . build_uri('goods', array('gid' => $val), $goods_name) . '" title="' . $goods_name . '">' . $short_name . '</a></li>';
            }
        }
    }
    return $str;
}
Example #25
0
 /**
  * 获得文章关联的商品
  *
  * @access  public
  * @param   integer $id
  * @return  array
  */
 function article_related_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('goods_article') . ' ga ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = ga.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 ga.article_id = '{$id}' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0";
     $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']]['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;
 }
Example #26
0
    $surplus_amount = get_user_surplus($user_id);
    if (empty($surplus_amount)) {
        $surplus_amount = 0;
    }
    //获取余额记录
    $account_log = array();
    $sql = "SELECT * FROM " . $ecs->table('account_log') . " WHERE user_id = '{$user_id}'" . " AND {$account_type} <> 0 " . " ORDER BY log_id DESC";
    $res = $GLOBALS['db']->selectLimit($sql, $pager['size'], $pager['start']);
    while ($row = $db->fetchRow($res)) {
        $row['change_time'] = local_date($_CFG['date_format'], $row['change_time']);
        $row['type'] = $row[$account_type] > 0 ? $_LANG['account_inc'] : $_LANG['account_dec'];
        $row['user_money'] = price_format(abs($row['user_money']), false);
        $row['frozen_money'] = price_format(abs($row['frozen_money']), false);
        $row['rank_points'] = abs($row['rank_points']);
        $row['pay_points'] = abs($row['pay_points']);
        $row['short_change_desc'] = sub_str($row['change_desc'], 60);
        $row['amount'] = $row[$account_type];
        $account_log[] = $row;
    }
    //模板赋值
    $smarty->assign('surplus_amount', price_format($surplus_amount, false));
    $smarty->assign('account_log', $account_log);
    $smarty->assign('pager', $pager);
    $smarty->display('user_transaction.dwt');
} elseif ($action == 'account_log') {
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    /* 获取记录条数 */
    $sql = "SELECT COUNT(*) FROM " . $ecs->table('user_account') . " WHERE user_id = '{$user_id}'" . " AND process_type " . db_create_in(array(SURPLUS_SAVE, SURPLUS_RETURN));
    $record_count = $db->getOne($sql);
    //分页函数
Example #27
0
function action_account_detail()
{
    $user = $GLOBALS['user'];
    $_CFG = $GLOBALS['_CFG'];
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user_id = $_SESSION['user_id'];
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    $account_type = 'user_money';
    /* 获取记录条数 */
    $sql = "SELECT COUNT(*) FROM " . $ecs->table('account_log') . " WHERE user_id = '{$user_id}'" . " AND {$account_type} <> 0 ";
    $record_count = $db->getOne($sql);
    // 分页函数
    $pager = get_pager('user.php', array('act' => $action), $record_count, $page);
    // 获取剩余余额
    $surplus_amount = get_user_surplus($user_id);
    if (empty($surplus_amount)) {
        $surplus_amount = 0;
    }
    /* /查看账户明细页面 获取会员用户的余额 jx 2015-1-1 */
    $surplus_yue = get_user_yue($user_id);
    if (empty($surplus_yue)) {
        $surplus_yue = 0;
    }
    // 获取余额记录
    $account_log = array();
    $sql = "SELECT * FROM " . $ecs->table('account_log') . " WHERE user_id = '{$user_id}'" . " AND {$account_type} <> 0 " . " ORDER BY log_id DESC";
    $res = $GLOBALS['db']->selectLimit($sql, $pager['size'], $pager['start']);
    while ($row = $db->fetchRow($res)) {
        $row['change_time'] = local_date($_CFG['date_format'], $row['change_time']);
        $row['type'] = $row[$account_type] > 0 ? $_LANG['account_inc'] : $_LANG['account_dec'];
        $row['user_money'] = price_format(abs($row['user_money']), false);
        $row['frozen_money'] = price_format(abs($row['frozen_money']), false);
        $row['rank_points'] = abs($row['rank_points']);
        $row['pay_points'] = abs($row['pay_points']);
        $row['short_change_desc'] = sub_str($row['change_desc'], 60);
        $row['amount'] = $row[$account_type];
        $account_log[] = $row;
    }
    // 模板赋值
    $smarty->assign('surplus_amount', price_format($surplus_amount, false));
    $smarty->assign('account_log', $account_log);
    $smarty->assign('surplus_yue', $surplus_yue);
    $smarty->assign('pager', $pager);
    $smarty->display('user_transaction.dwt');
}
        if ($word[$i] == $search[$search_ct] || $search[$search_ct] == "*") {
            //print "SUCCESS: " . $word[$i] . "==" . $search[$search_ct] . "\n";
            if ($search[$search_ct] != "*") {
                $search_ct++;
            }
            if ($search[$search_ct] == "*" && $wild_ct == 0) {
                $wild_ct++;
            }
            if ($wild_ct >= 1 && $search[$search_ct + 1] == $word[$i + 1]) {
                $search_ct++;
            }
        }
    }
    if ($wild_ct > 0) {
        $search_ct -= $wild_ct;
    }
    if ($search_ct == strlen($search)) {
        return "true";
    } else {
        return "false";
    }
}
$fh = fopen($argv[1], "r");
while (!feof($fh)) {
    $test = trim(fgets($fh));
    if ($test != "") {
        $args = explode(",", $test);
        echo sub_str($args[0], $args[1]) . "\n";
    }
}
fclose($fh);
Example #29
0
/**
 * 取得销售排行数据信息
 * @param   bool  $is_pagination  是否分页
 * @return  array   销售排行数据
 */
function get_sales_order($is_pagination = true)
{
    $filter['start_date'] = empty($_REQUEST['start_date']) ? '' : local_strtotime($_REQUEST['start_date']);
    $filter['end_date'] = empty($_REQUEST['end_date']) ? '' : local_strtotime($_REQUEST['end_date']);
    $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'goods_num' : trim($_REQUEST['sort_by']);
    $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
    $where = " WHERE og.order_id = oi.order_id " . order_query_sql('finished', 'oi.');
    if ($filter['start_date']) {
        $where .= " AND oi.add_time >= '" . $filter['start_date'] . "'";
    }
    if ($filter['end_date']) {
        $where .= " AND oi.add_time <= '" . $filter['end_date'] . "'";
    }
    $sql = "SELECT COUNT(distinct(og.goods_id)) FROM " . $GLOBALS['ecs']->table('order_info') . ' AS oi,' . $GLOBALS['ecs']->table('order_goods') . ' AS og ' . $where;
    $filter['record_count'] = $GLOBALS['db']->getOne($sql);
    /* 分页大小 */
    $filter = page_and_size($filter);
    $sql = "SELECT og.goods_id, og.goods_sn, og.goods_name, oi.order_status, " . "SUM(og.goods_number) AS goods_num, SUM(og.goods_number * og.goods_price) AS turnover " . "FROM " . $GLOBALS['ecs']->table('order_goods') . " AS og, " . $GLOBALS['ecs']->table('order_info') . " AS oi  " . $where . " GROUP BY og.goods_id " . ' ORDER BY ' . $filter['sort_by'] . ' ' . $filter['sort_order'];
    if ($is_pagination) {
        $sql .= " LIMIT " . $filter['start'] . ', ' . $filter['page_size'];
    }
    $sales_order_data = $GLOBALS['db']->getAll($sql);
    foreach ($sales_order_data as $key => $item) {
        $sales_order_data[$key]['wvera_price'] = price_format($item['goods_num'] ? $item['turnover'] / $item['goods_num'] : 0);
        $sales_order_data[$key]['short_name'] = sub_str($item['goods_name'], 30, true);
        $sales_order_data[$key]['turnover'] = price_format($item['turnover']);
        $sales_order_data[$key]['taxis'] = $key + 1;
    }
    $arr = array('sales_order_data' => $sales_order_data, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #30
0
function get_on_top_goods($id, $num = 5)
{
    $sql = 'SELECT cat_id,cat_name FROM ' . $GLOBALS['ecs']->table('category') . ' WHERE is_on_top = 1 AND parent_id =' . $id;
    $res = $GLOBALS['db']->getAll($sql);
    foreach ($res as $idx => $row) {
        $arr[$idx]['cat_url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
        $arr[$idx]['cat_name'] = $row['cat_name'];
        $children = get_children($row['cat_id']);
        $sql = 'SELECT g.goods_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 . ') ';
        $order_rule = 'ORDER BY g.sort_order, g.goods_id DESC';
        $sql .= $order_rule;
        if ($num > 0) {
            $sql .= ' LIMIT ' . $num;
        }
        $goods_res = $GLOBALS['db']->getAll($sql);
        $goods = array();
        foreach ($goods_res as $goods_idx => $goods_row) {
            if ($goods_row['promote_price'] > 0) {
                $promote_price = bargain_price($goods_row['promote_price'], $goods_row['promote_start_date'], $goods_row['promote_end_date']);
                $goods[$goods_idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
            } else {
                $goods[$goods_idx]['promote_price'] = '';
            }
            $goods[$goods_idx]['id'] = $goods_row['goods_id'];
            $goods[$goods_idx]['name'] = $goods_row['goods_name'];
            $goods[$goods_idx]['brief'] = $goods_row['goods_brief'];
            $goods[$goods_idx]['market_price'] = price_format($goods_row['market_price']);
            $goods[$goods_idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($goods_row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $goods_row['goods_name'];
            $goods[$goods_idx]['shop_price'] = price_format($goods_row['shop_price']);
            $goods[$goods_idx]['thumb'] = get_image_path($goods_row['goods_id'], $goods_row['goods_thumb'], true);
            $goods[$goods_idx]['goods_img'] = get_image_path($goods_row['goods_id'], $goods_row['goods_img']);
            $goods[$goods_idx]['url'] = build_uri('goods', array('gid' => $goods_row['goods_id']), $goods_row['goods_name']);
        }
        $arr[$idx]['goods'] = $goods;
    }
    return $arr;
}