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


PHP group_buy_stat函数代码示例

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


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

示例1: group_buy_list

function group_buy_list()
{
    $result = get_filter();
    if ($result === false) {
        /* 过滤条件 */
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        if ($_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'act_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $where = !empty($filter['keyword']) ? " AND goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'" : '';
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_GROUP_BUY . "' {$where}";
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 分页大小 */
        $filter = page_and_size($filter);
        /* 查询 */
        $sql = "SELECT * " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_GROUP_BUY . "' {$where} " . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . $filter['start'] . ", {$filter['page_size']}";
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $res = $GLOBALS['db']->query($sql);
    $list = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $ext_info = unserialize($row['ext_info']);
        $stat = group_buy_stat($row['act_id'], $ext_info['deposit']);
        $arr = array_merge($row, $stat, $ext_info);
        /* 处理价格阶梯 */
        $price_ladder = $arr['price_ladder'];
        if (!is_array($price_ladder) || empty($price_ladder)) {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
        } else {
            foreach ($price_ladder as $key => $amount_price) {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
        }
        /* 计算当前价 */
        $cur_price = $price_ladder[0]['price'];
        // 初始化
        $cur_amount = $stat['valid_goods'];
        // 当前数量
        foreach ($price_ladder as $amount_price) {
            if ($cur_amount >= $amount_price['amount']) {
                $cur_price = $amount_price['price'];
            } else {
                break;
            }
        }
        $arr['cur_price'] = $cur_price;
        $status = group_buy_status($arr);
        $arr['start_time'] = local_date($GLOBALS['_CFG']['date_format'], $arr['start_time']);
        $arr['end_time'] = local_date($GLOBALS['_CFG']['date_format'], $arr['end_time']);
        $arr['cur_status'] = $GLOBALS['_LANG']['gbs'][$status];
        $list[] = $arr;
    }
    $arr = array('item' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
开发者ID:BGCX261,项目名称:zishashop-svn-to-git,代码行数:61,代码来源:group_buy.php

示例2: group_buy_info

/**
 * 取得团购活动信息
 * @param   int     $group_buy_id   团购活动id
 * @param   int     $current_num    本次购买数量(计算当前价时要加上的数量)
 * @return  array
 *                  status          状态:
 */
function group_buy_info($group_buy_id, $current_num = 0)
{
    /* 取得团购活动信息 */
    $group_buy_id = intval($group_buy_id);
    $sql = "SELECT *, act_id AS group_buy_id, act_desc AS group_buy_desc, start_time AS start_date, end_time AS end_date " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . "WHERE act_id = '{$group_buy_id}' " . "AND act_type = '" . GAT_GROUP_BUY . "'";
    $group_buy = $GLOBALS['db']->getRow($sql);
    /* 如果为空,返回空数组 */
    if (empty($group_buy)) {
        return array();
    }
    $ext_info = unserialize($group_buy['ext_info']);
    $group_buy = array_merge($group_buy, $ext_info);
    /* 格式化时间 */
    $group_buy['formated_start_date'] = local_date('Y-m-d H:i', $group_buy['start_time']);
    $group_buy['formated_end_date'] = local_date('Y-m-d H:i', $group_buy['end_time']);
    /* 格式化保证金 */
    $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
    /* 处理价格阶梯 */
    $price_ladder = $group_buy['price_ladder'];
    if (!is_array($price_ladder) || empty($price_ladder)) {
        $price_ladder = array(array('amount' => 0, 'price' => 0));
    } else {
        foreach ($price_ladder as $key => $amount_price) {
            $price_ladder[$key]['formated_price'] = price_format($amount_price['price'], false);
        }
    }
    $group_buy['price_ladder'] = $price_ladder;
    /* 统计信息 */
    $stat = group_buy_stat($group_buy_id, $group_buy['deposit']);
    $group_buy = array_merge($group_buy, $stat);
    /* 计算当前价 */
    $cur_price = $price_ladder[0]['price'];
    // 初始化
    $cur_amount = $stat['valid_goods'] + $current_num;
    // 当前数量
    foreach ($price_ladder as $amount_price) {
        if ($cur_amount >= $amount_price['amount']) {
            $cur_price = $amount_price['price'];
        } else {
            break;
        }
    }
    $group_buy['cur_price'] = $cur_price;
    $group_buy['formated_cur_price'] = price_format($cur_price, false);
    /* 最终价 */
    $group_buy['trans_price'] = $group_buy['cur_price'];
    $group_buy['formated_trans_price'] = $group_buy['formated_cur_price'];
    $group_buy['trans_amount'] = $group_buy['valid_goods'];
    /* 状态 */
    $group_buy['status'] = group_buy_status($group_buy);
    if (isset($GLOBALS['_LANG']['gbs'][$group_buy['status']])) {
        $group_buy['status_desc'] = $GLOBALS['_LANG']['gbs'][$group_buy['status']];
    }
    $group_buy['start_time'] = $group_buy['formated_start_date'];
    $group_buy['end_time'] = $group_buy['formated_end_date'];
    return $group_buy;
}
开发者ID:shaoslu,项目名称:jumei,代码行数:64,代码来源:lib_goods.php

示例3: index_get_group_buy

/**
 * 获得最新的团购活动
 *
 * @access  private
 * @return  array
 */
function index_get_group_buy()
{
    $time = gmtime();
    $limit = get_library_number('group_buy', 'index');
    $group_buy_list = array();
    if ($limit > 0) {
        $sql = 'SELECT gb.*,g.*,gb.act_id AS group_buy_id, gb.goods_id, gb.ext_info, gb.goods_name, g.goods_thumb, g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS gb, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE gb.act_type = '" . GAT_GROUP_BUY . "' " . "AND g.goods_id = gb.goods_id " . "AND gb.start_time <= '" . $time . "' " . "AND gb.end_time >= '" . $time . "' " . "AND g.is_delete = 0 " . "ORDER BY gb.act_id DESC " . "LIMIT {$limit}";
        $res = $GLOBALS['db']->query($sql);
        while ($row = $GLOBALS['db']->fetchRow($res)) {
            /* 如果缩略图为空,使用默认图片 */
            $row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
            $row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
            /* 根据价格阶梯,计算最低价 */
            $ext_info = unserialize($row['ext_info']);
            $price_ladder = $ext_info['price_ladder'];
            if (!is_array($price_ladder) || empty($price_ladder)) {
                $row['last_price'] = price_format(0);
            } else {
                foreach ($price_ladder as $amount_price) {
                    $price_ladder[$amount_price['amount']] = $amount_price['price'];
                }
            }
            ksort($price_ladder);
            $row['last_price'] = price_format(end($price_ladder));
            $row['url'] = build_uri('group_buy', array('gbid' => $row['group_buy_id']));
            $row['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
            $row['short_style_name'] = add_style($row['short_name'], '');
            $stat = group_buy_stat($row['act_id'], $row['deposit']);
            $row['valid_goods'] = $stat['valid_goods'];
            $group_buy_list[] = $row;
        }
    }
    return $group_buy_list;
}
开发者ID:moonlight-wang,项目名称:feilun,代码行数:40,代码来源:index.php

示例4: group_buy_list2

function group_buy_list2($limit,$id)
{
    /* 取得团购活动 */
    $gb_list = array();
    $now = gmtime();
    $sql = "SELECT b.*, IFNULL(g.goods_thumb, '') AS goods_thumb,g.goods_img,g.shop_price, b.act_id AS group_buy_id, ".
                "b.start_time AS start_date, b.end_time AS end_date " .
            "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " .
                "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " .
            "WHERE b.act_type = '" . GAT_GROUP_BUY . "' " .
            "AND b.start_time <= '$now' AND b.is_finished < 3 AND b.act_id !='$id' ORDER BY b.act_id DESC LIMIT ".$limit;
 	$res = $GLOBALS['db']->query($sql);

    while ($group_buy = $GLOBALS['db']->fetchRow($res))
    {
		
        $ext_info = unserialize($group_buy['ext_info']);
        $group_buy = array_merge($group_buy, $ext_info);

        /* 格式化时间 */
        $group_buy['formated_start_date']   = local_date($GLOBALS['_CFG']['time_format'], $group_buy['start_date']);
        $group_buy['formated_end_date']     = local_date($GLOBALS['_CFG']['time_format'], $group_buy['end_date']);

        /* 格式化保证金 */
        $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);

        /* 处理价格阶梯 */
        $price_ladder = $group_buy['price_ladder'];
		
		$stat = group_buy_stat($group_buy['act_id'], $ext_info['deposit']);
		$group_buy['cur_amount'] = $stat['valid_goods'];         // 当前数量
		$group_buy['jiesheng'] = price_format($group_buy['shop_price'] - $price_ladder[0]['price']);	//by ecmoban修改 zhouH
			
        if (!is_array($price_ladder) || empty($price_ladder))
        {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
        }
        else
        {
            foreach ($price_ladder as $key => $amount_price)
            {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
        }
        $group_buy['price_ladder'] = $price_ladder;

		

        /* 处理图片 */
        if (empty($group_buy['goods_thumb']))
        {
            $group_buy['goods_thumb'] = get_image_path($group_buy['goods_id'], $group_buy['goods_thumb'], true);
        }
        /* 处理链接 */
        $group_buy['url'] = build_uri('group_buy', array('gbid'=>$group_buy['group_buy_id']));
        /* 加入数组 */
        $gb_list[] = $group_buy;
    }

    return $gb_list;
}
开发者ID:blowfishJ,项目名称:galaxyCode,代码行数:61,代码来源:group_buy.php

示例5: group_buy_info

/**
 * 取得团购活动信息
 * @param   int     $group_buy_id   团购活动id
 * @param   int     $current_num    本次购买数量(计算当前价时要加上的数量)
 * @return  array
 *                  status          状态:
 */
function group_buy_info($group_buy_id, $current_num = 0)
{
    /* 取得团购活动信息 */
    //dqy add start 2011-8-24
    $group_buy_id = intval($group_buy_id);
    $sql = "SELECT b.*,g.*, b.act_id AS group_buy_id, b.act_desc AS group_buy_desc, b.start_time AS start_date, b.end_time AS end_date " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " . "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " . "WHERE act_id = '{$group_buy_id}' " . "AND act_type = '" . GAT_GROUP_BUY . "'";
    //dqy add end 2011-8-24
    $group_buy = $GLOBALS['db']->getRow($sql);
    /* 如果为空,返回空数组 */
    if (empty($group_buy)) {
        return array();
    }
    $ext_info = unserialize($group_buy['ext_info']);
    $group_buy = array_merge($group_buy, $ext_info);
    /* 格式化时间 */
    $group_buy['formated_start_date'] = local_date('Y-m-d H:i', $group_buy['start_time']);
    $group_buy['formated_end_date'] = local_date('Y-m-d H:i', $group_buy['end_time']);
    /* 格式化保证金 */
    $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
    /* 处理价格阶梯 */
    $price_ladder = $group_buy['price_ladder'];
    if (!is_array($price_ladder) || empty($price_ladder)) {
        $price_ladder = array(array('amount' => 0, 'price' => 0));
    } else {
        foreach ($price_ladder as $key => $amount_price) {
            $price_ladder[$key]['formated_price'] = price_format($amount_price['price'], false);
        }
    }
    $group_buy['price_ladder'] = $price_ladder;
    /* 统计信息 */
    $stat = group_buy_stat($group_buy_id, $group_buy['deposit']);
    $group_buy = array_merge($group_buy, $stat);
    /* 计算当前价 */
    $cur_price = $price_ladder[0]['price'];
    // 初始化
    $cur_amount = $stat['valid_goods'] + $current_num;
    // 当前数量
    foreach ($price_ladder as $amount_price) {
        if ($cur_amount >= $amount_price['amount']) {
            $cur_price = $amount_price['price'];
        } else {
            break;
        }
    }
    //yyy start
    $group_buy['goods_desc'] = $GLOBALS['db']->getOne("select goods_desc from " . $GLOBALS['ecs']->table('goods') . " where goods_id=" . $group_buy['goods_id']);
    //yyy end
    $group_buy['cur_price'] = $cur_price;
    $group_buy['formated_cur_price'] = price_format($cur_price, false);
    //dqy add start 2011-8-24
    if ($group_buy['shop_price'] == 0) {
        $group_buy['zhekou'] = 0;
    } else {
        $group_buy['zhekou'] = number_format(intval($group_buy['cur_price']) / intval($group_buy['shop_price']), 2) * 100;
    }
    $group_buy['jiesheng'] = $group_buy['shop_price'] - $group_buy['cur_price'];
    //dqy add end 2011-8-24
    /* 最终价 */
    $group_buy['trans_price'] = $group_buy['cur_price'];
    $group_buy['formated_trans_price'] = $group_buy['formated_cur_price'];
    $group_buy['trans_amount'] = $group_buy['valid_goods'];
    /* 状态 */
    $group_buy['status'] = group_buy_status($group_buy);
    if (isset($GLOBALS['_LANG']['gbs'][$group_buy['status']])) {
        $group_buy['status_desc'] = $GLOBALS['_LANG']['gbs'][$group_buy['status']];
    }
    $group_buy['start_time'] = $group_buy['formated_start_date'];
    $group_buy['end_time'] = $group_buy['formated_end_date'];
    return $group_buy;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:77,代码来源:lib_goods.php

示例6: group_buy_list_index

function group_buy_list_index()
{
    /* 取得团购活动 */
    $gb_list = array();
    $now = gmtime();
    $sql = "SELECT b.*, IFNULL(g.goods_thumb, '') AS goods_thumb, b.act_id AS group_buy_id, " . "b.start_time AS start_date, b.end_time AS end_date,g.shop_price " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " . "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " . "WHERE b.act_type = '" . GAT_GROUP_BUY . "' " . "AND b.start_time <= '{$now}' AND b.is_finished < 3 ORDER BY b.act_id DESC LIMIT 1";
    $res = $GLOBALS['db']->getAll($sql);
    foreach ($res as $group_buy) {
        $ext_info = unserialize($group_buy['ext_info']);
        $group_buy = array_merge($group_buy, $ext_info);
        $group_buy['cur_amount'] = group_buy_stat($group_buy['act_id'], $group_buy['deposit']);
        /* 格式化时间 */
        $group_buy['formated_start_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['start_date']);
        $group_buy['formated_end_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['end_date']);
        /* 格式化保证金 */
        $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
        /* 处理价格阶梯 */
        $price_ladder = $group_buy['price_ladder'];
        if (!is_array($price_ladder) || empty($price_ladder)) {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
        } else {
            foreach ($price_ladder as $key => $amount_price) {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
        }
        $group_buy['price_ladder'] = $price_ladder;
        /* 处理图片 */
        if (empty($group_buy['goods_thumb'])) {
            $group_buy['goods_thumb'] = get_image_path($group_buy['goods_id'], $group_buy['goods_thumb'], true);
        }
        /* 处理链接 */
        $group_buy['url'] = build_uri('group_buy', array('gbid' => $group_buy['group_buy_id']));
        /* 加入数组 */
    }
    return $group_buy;
}
开发者ID:norain2050,项目名称:benhu,代码行数:36,代码来源:index.php

示例7: group_buy_list_goods

function group_buy_list_goods($size = 100, $page = 1)
{
    /* 取得团购活动 */
    $gb_list = array();
    $now = gmtime();
    $sql = "SELECT b.*, IFNULL(g.goods_thumb, '') AS goods_thumb, g.market_price, g.shop_price, b.act_id AS group_buy_id, " . "b.start_time AS start_date, b.end_time AS end_date " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " . "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " . "WHERE b.act_type = '" . GAT_GROUP_BUY . "' " . "AND b.start_time <= '{$now}' AND b.is_finished < 3 ORDER BY b.act_id DESC";
    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
    while ($group_buy = $GLOBALS['db']->fetchRow($res)) {
        $ext_info = unserialize($group_buy['ext_info']);
        $group_buy = array_merge($group_buy, $ext_info);
        /* 格式化时间 */
        $group_buy['formated_start_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['start_date']);
        $group_buy['formated_end_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['end_date']);
        /* 格式化保证金 */
        $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
        /* 处理价格阶梯 */
        $price_ladder = $group_buy['price_ladder'];
        if (!is_array($price_ladder) || empty($price_ladder)) {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
        } else {
            foreach ($price_ladder as $key => $amount_price) {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
        }
        $group_buy['price_ladder'] = $price_ladder;
        /* 处理图片 */
        if (empty($group_buy['goods_thumb'])) {
            $group_buy['goods_thumb'] = get_image_path($group_buy['goods_id'], $group_buy['goods_thumb'], true);
        }
        /* 处理链接 */
        $group_buy['url'] = build_uri('group_buy', array('gbid' => $group_buy['group_buy_id']));
        /* 统计信息 */
        $stat = group_buy_stat($group_buy['group_buy_id'], $group_buy['deposit']);
        $group_buy = array_merge($group_buy, $stat);
        /* 计算当前价 */
        $cur_price = $price_ladder[0]['price'];
        // 初始化
        $cur_amount = $stat['valid_goods'];
        // 当前数量
        foreach ($price_ladder as $amount_price) {
            if ($cur_amount >= $amount_price['amount']) {
                $cur_price = $amount_price['price'];
            } else {
                break;
            }
        }
        $group_buy['cur_price'] = $cur_price;
        $group_buy['cur_amount'] = $cur_amount + $group_buy['product_id'];
        $market_price = $group_buy['market_price'];
        $group_buy['saving'] = $market_price - $cur_price;
        $group_buy['save_rate'] = $market_price ? round($cur_price / $market_price, 2) * 10 : 0;
        /* 加入数组 */
        $gb_list[] = $group_buy;
    }
    return $gb_list;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:56,代码来源:init.php

示例8: group_buy_list

/**
 * 根据sql语句获取团购活动列表
 * @param   string     $sql   sql查询语句
 * @return  array
 */
function group_buy_list($sql)
{
    /* 取得团购活动 */
    $gb_list = array();
    //  echo $sql;exit();
    $res = $GLOBALS['db']->query($sql);
    while ($group_buy = $GLOBALS['db']->fetchRow($res)) {
        $ext_info = unserialize($group_buy['ext_info']);
        $group_buy = array_merge($group_buy, $ext_info);
        /* 格式化时间 */
        $group_buy['formated_start_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['start_date']);
        $group_buy['formated_end_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['end_date']);
        /* 格式化保证金 */
        $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
        /*商品原价*/
        $group_buy['shop_price'] = price_format($group_buy['shop_price'], false);
        /* 处理价格阶梯 */
        $price_ladder = $group_buy['price_ladder'];
        if (!is_array($price_ladder) || empty($price_ladder)) {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
        } else {
            foreach ($price_ladder as $key => $amount_price) {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
        }
        $group_buy['price_ladder'] = $price_ladder;
        /*团购节省和折扣计算 by ecmoban start*/
        $price = $group_buy['market_price'];
        //原价
        $nowprice = $group_buy['price_ladder'][0]['price'];
        //现价
        $group_buy['jiesheng'] = $price - $nowprice;
        //节省金额
        if ($nowprice > 0) {
            $group_buy['zhekou'] = round(10 / ($price / $nowprice), 1);
        } else {
            $group_buy['zhekou'] = 0;
        }
        $stat = group_buy_stat($group_buy['act_id'], $ext_info['deposit']);
        $group_buy['cur_amount'] = $stat['valid_goods'];
        // 当前数量
        /* 处理图片 */
        if (empty($group_buy['goods_thumb'])) {
            $group_buy['goods_thumb'] = get_image_path($group_buy['goods_id'], $group_buy['goods_thumb'], true);
        }
        /* 处理链接 */
        $group_buy['url'] = build_uri('group_buy', array('gbid' => $group_buy['group_buy_id']));
        /* 加入数组 */
        $gb_list[] = $group_buy;
    }
    return $gb_list;
}
开发者ID:norain2050,项目名称:benhu,代码行数:57,代码来源:group_buy.php

示例9: index_get_group_buyex

function index_get_group_buyex()
{
    $time = gmtime();
    $limit = get_library_number("group_buy", "index");
    $group_buy_list = array();
    if (0 < $limit) {
        $sql = "SELECT gb.act_id AS group_buy_id, gb.goods_id, gb.ext_info, gb.goods_name,gb.end_time, g.goods_thumb,g.market_price, g.goods_img, gb.act_desc FROM " . $GLOBALS['ecs']->table("goods_activity") . " AS gb, " . $GLOBALS['ecs']->table("goods") . " AS g WHERE gb.act_type = '" . GAT_GROUP_BUY . "' AND g.goods_id = gb.goods_id AND gb.start_time <= '" . $time . "' AND gb.end_time >= '" . $time . "' AND g.is_delete = 0 ORDER BY gb.act_id DESC " . ("LIMIT " . $limit);
        $res = $GLOBALS['db']->query($sql);
        while ($row = $GLOBALS['db']->fetchRow($res)) {
            $row['market_price_no_format'] = $row['market_price'];
            $row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
            $row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], TRUE);
            $ext_info = unserialize($row['ext_info']);
            $row = array_merge($row, $ext_info);
            $price_ladder = $ext_info['price_ladder'];
            if (!is_array($price_ladder) && empty($price_ladder)) {
                $row['last_price'] = price_format(0);
            } else {
                foreach ($price_ladder as $amount_price) {
                    $price_ladder[$amount_price['amount']] = $amount_price['price'];
                }
            }
            ksort($price_ladder);
            $row['last_price_no_format'] = end($price_ladder);
            $row['last_price'] = price_format(end($price_ladder));
            $stat = group_buy_stat($row['group_buy_id'], $row['deposit']);
            $row['valid_order'] = $stat['valid_order'];
            $row['url'] = build_uri("group_buy", array("gbid" => $row['group_buy_id']));
            $row['short_name'] = 0 < $GLOBALS['_CFG']['goods_name_length'] ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
            $row['short_style_name'] = add_style($row['short_name'], "");
            $row['market_price'] = price_format($row['market_price']);
            $row['end_time'] = local_date('M d, Y H:i:s', $row['end_time']);
            $group_buy_list[] = $row;
        }
    }
    return $group_buy_list;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:37,代码来源:init.php

示例10: index_get_group_buy

/**
 * 获得最新的团购活动
 *
 * @access  private
 * @return  array
 */
function index_get_group_buy()
{
    $time = gmtime();
    $limit = get_library_number('group_buy', 'index');
    $group_buy_list = array();
    if ($limit > 0) {
        $sql = 'SELECT gb.act_id AS group_buy_id, gb.goods_id, gb.ext_info, gb.goods_name, gb.start_time, gb.end_time, g.goods_thumb, g.goods_img, g.market_price ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS gb, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE gb.act_type = '" . GAT_GROUP_BUY . "' " . "AND g.goods_id = gb.goods_id " . "AND gb.start_time <= '" . $time . "' " . "AND gb.end_time >= '" . $time . "' " . "AND g.is_delete = 0 " . "ORDER BY gb.act_id DESC " . "LIMIT {$limit}";
        $res = $GLOBALS['db']->query($sql);
        while ($row = $GLOBALS['db']->fetchRow($res)) {
            /* 如果缩略图为空,使用默认图片 */
            $row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
            $row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
            /* 根据价格阶梯,计算最低价 */
            $ext_info = unserialize($row['ext_info']);
            $price_ladder = $ext_info['price_ladder'];
            if (!is_array($price_ladder) || empty($price_ladder)) {
                $row['last_price'] = price_format(0);
            } else {
                foreach ($price_ladder as $amount_price) {
                    $price_ladder[$amount_price['amount']] = $amount_price['price'];
                }
            }
            ksort($price_ladderp);
            $row['last_price'] = price_format(end($price_ladder));
            /*团购节省和折扣计算 by ecmoban start*/
            $price = $row['market_price'];
            //原价
            $nowprice = $row['last_price'];
            //现价
            $row['jiesheng'] = $price - $nowprice;
            //节省金额
            if ($nowprice > 0) {
                $row['zhekou'] = round(10 / ($price / $nowprice), 1);
            } else {
                $row['zhekou'] = 0;
            }
            $activity_row = $GLOBALS['db']->getRow($sql);
            $stat = group_buy_stat($row['act_id'], $ext_info['deposit']);
            $row['cur_amount'] = $stat['valid_goods'];
            // 当前数量
            $row['start_time'] = $row['start_time'];
            // 开始时间
            $row['end_time'] = $row['end_time'];
            // 结束时间
            /*团购节省和折扣计算 by ecmoban end*/
            $row['url'] = build_uri('group_buy', array('gbid' => $row['group_buy_id']));
            $row['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
            $row['short_style_name'] = add_style($row['short_name'], '');
            $group_buy_id = $row['group_buy_id'];
            /* 统计信息 */
            $stat = group_buy_stat($group_buy_id, $group_buy['deposit']);
            $row = array_merge($row, $stat);
            $group_buy_list[] = $row;
        }
    }
    return $group_buy_list;
}
开发者ID:jinjing1989,项目名称:wei,代码行数:63,代码来源:index.php

示例11: group_buy_list

/**
 * 取得某页的所有团购活动
 * @param   int     $size   每页记录数
 * @param   int     $page   当前页
 * @return  array
 */
function group_buy_list($size, $page)
{
    /* 取得团购活动 */
    $gb_list = array();
    $now = gmtime();
    $sql = "SELECT b.*, IFNULL(g.goods_thumb, '') AS goods_thumb, b.act_id AS group_buy_id, g.market_price," . "b.start_time AS start_date, b.end_time AS end_date " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " . "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " . "WHERE b.act_type = '" . GAT_GROUP_BUY . "' " . "AND b.start_time <= '{$now}' AND b.is_finished < 3 ORDER BY b.act_id DESC";
    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
    while ($group_buy = $GLOBALS['db']->fetchRow($res)) {
        $ext_info = unserialize($group_buy['ext_info']);
        $group_buy = array_merge($group_buy, $ext_info);
        /* 格式化时间 */
        $group_buy['formated_start_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['start_date']);
        $group_buy['formated_end_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['end_date']);
        /* 格式化保证金 */
        $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
        /* 处理价格阶梯 */
        $price_ladder = $group_buy['price_ladder'];
        if (!is_array($price_ladder) || empty($price_ladder)) {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
        } else {
            foreach ($price_ladder as $key => $amount_price) {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
        }
        $group_buy['price_ladder'] = $price_ladder;
        /*团购节省和折扣计算 by ecmoban start*/
        $price = $group_buy['market_price'];
        //原价
        $nowprice = $group_buy['price_ladder'][0]['price'];
        //现价
        $group_buy['jiesheng'] = $price - $nowprice;
        //节省金额
        if ($nowprice > 0) {
            $group_buy['zhekou'] = round(10 / ($price / $nowprice), 1);
        } else {
            $group_buy['zhekou'] = 0;
        }
        $stat = group_buy_stat($group_buy['act_id'], $ext_info['deposit']);
        $group_buy['cur_amount'] = $stat['valid_goods'];
        // 当前数量
        /* 处理图片 */
        if (empty($group_buy['goods_thumb'])) {
            $group_buy['goods_thumb'] = get_image_path($group_buy['goods_id'], $group_buy['goods_thumb'], true);
        }
        /* 处理链接 */
        $group_buy['url'] = build_uri('group_buy', array('gbid' => $group_buy['group_buy_id']));
        /* 加入数组 */
        $gb_list[] = $group_buy;
    }
    return $gb_list;
}
开发者ID:GYWang1983,项目名称:fruit,代码行数:57,代码来源:group_buy.php

示例12: group_buy_list_hot

function group_buy_list_hot()
{
    /* 取得团购活动 */
    $gb_list = array();
    $now = gmtime();
    /*新团购模板加入*/
    $sql = "SELECT b.*, IFNULL(g.goods_thumb, '') AS goods_thumb, IFNULL(g.goods_img, '') AS goods_img, g.goods_brief, g.market_price, g.shop_price, b.act_id AS group_buy_id, " . "b.start_time AS start_date, b.end_time AS end_date " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " . "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " . "WHERE b.act_type = '" . GAT_GROUP_BUY . "' and b.isg_new=1 " . "AND b.start_time <= '{$now}' AND b.is_finished < 3 ORDER BY b.act_id DESC";
    $res = $GLOBALS['db']->query($sql);
    while ($group_buy = $GLOBALS['db']->fetchRow($res)) {
        $ext_info = unserialize($group_buy['ext_info']);
        $stat = group_buy_stat($group_buy['act_id'], $ext_info['deposit']);
        $group_buy = array_merge($group_buy, $ext_info);
        /*新团购模板加入 时间倒计时 */
        $group_buy['gmt_end_date'] = $group_buy['end_date'];
        $time = gmtime();
        if ($time >= $group_buy['start_date'] && $time <= $group_buy['end_date']) {
            $group_buy['gmt_end_time'] = local_date('M d, Y H:i:s', $group_buy['end_date']);
        } else {
            $group_buy['gmt_end_time'] = 0;
        }
        /* 格式化时间 */
        $group_buy['formated_start_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['start_date']);
        $group_buy['formated_end_date'] = local_date($GLOBALS['_CFG']['time_format'], $group_buy['end_date']);
        /* 格式化保证金 */
        $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
        /*新团购模板加入 调用购买人数
                $arrgoods = group_buy_stat($group_buy['act_id'],$group_buy['formated_deposit']);
        		foreach($arrgoods as $key=>$arr){
        		     $arrgoods[$arr]['valid_goods'] = $arr['valid_goods'];
        			 $valid_goods = $arrgoods[$key]['valid_goods'];
        		     $group_buy['valid_goods'] = $valid_goods;
               }*/
        // 当前数量
        $group_buy['cur_amount'] = $stat['valid_goods'];
        /* 处理价格阶梯 */
        $price_ladder = $group_buy['price_ladder'];
        if (!is_array($price_ladder) || empty($price_ladder)) {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
            $last_price = 0;
        } else {
            foreach ($price_ladder as $key => $amount_price) {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
            $last_price = $amount_price['price'];
        }
        /*新团购模板加入 折扣及节省多少*/
        $group_buy['formated_rebate_price'] = price_format($group_buy['market_price'] - $last_price);
        $group_buy['t_discount'] = sprintf("%01.1f", $last_price / $group_buy['market_price'] * 10);
        $group_buy['market_price'] = price_format($group_buy['market_price']);
        $group_buy['price_ladder'] = $price_ladder;
        $group_buy['lower_orders'] = $group_buy['lower_orders'];
        $group_buy['goods_brief'] = $group_buy['goods_brief'];
        /* 处理图片 */
        if (empty($group_buy['goods_thumb'])) {
            $group_buy['goods_thumb'] = get_image_path($group_buy['goods_id'], $group_buy['goods_thumb'], true);
        }
        /* 处理链接 */
        $group_buy['url'] = build_uri('group_buy', array('gbid' => $group_buy['group_buy_id']));
        /* 加入数组 */
        $gb_list[] = $group_buy;
    }
    return $gb_list;
}
开发者ID:norain2050,项目名称:mhFault,代码行数:63,代码来源:group_buy.php

示例13: group_buy_info

/**
 * 取得团购活动信息
 * @param   int     $group_buy_id   团购活动id
 * @param   int     $current_num    本次购买数量(计算当前价时要加上的数量)
 * @return  array
 *                  status          状态:
 */
function group_buy_info($group_buy_id, $current_num = 0)
{
    /* 取得团购活动信息 */
    $group_buy_id = intval($group_buy_id);
    //默认语句
    //        $sql = "SELECT *, act_id AS group_buy_id, act_desc AS group_buy_desc, start_time AS start_date, end_time AS end_date " .
    //            "FROM " . $GLOBALS['ecs']->table('goods_activity') .
    //            "WHERE act_id = '$group_buy_id' " .
    //            "AND act_type = '" . GAT_GROUP_BUY . "'";
    //自己修改
    $sql = "SELECT " . $GLOBALS['ecs']->table('goods_activity') . ".*, shop_price, act_id AS group_buy_id, act_desc AS group_buy_desc, start_time AS start_date, end_time AS end_date " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . "," . $GLOBALS['ecs']->table('goods') . "WHERE act_id = '{$group_buy_id}' " . "AND act_type = '" . GAT_GROUP_BUY . "' AND " . $GLOBALS['ecs']->table('goods') . ".goods_id=" . $GLOBALS['ecs']->table('goods_activity') . ".goods_id";
    $group_buy = $GLOBALS['db']->getRow($sql);
    /* 如果为空,返回空数组 */
    if (empty($group_buy)) {
        return array();
    }
    $ext_info = unserialize($group_buy['ext_info']);
    $group_buy = array_merge($group_buy, $ext_info);
    /* 格式化时间 */
    $group_buy['formated_start_date'] = local_date('Y-m-d H:i', $group_buy['start_time']);
    $group_buy['formated_end_date'] = local_date('Y-m-d H:i', $group_buy['end_time']);
    /* 格式化保证金 */
    $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);
    /* 处理价格阶梯 */
    $price_ladder = $group_buy['price_ladder'];
    if (!is_array($price_ladder) || empty($price_ladder)) {
        $price_ladder = array(array('amount' => 0, 'price' => 0));
    } else {
        foreach ($price_ladder as $key => $amount_price) {
            $price_ladder[$key]['formated_price'] = price_format($amount_price['price'], false);
        }
    }
    $group_buy['price_ladder'] = $price_ladder;
    /*
    *    array(2) (
           [0] => array(3) (
             [amount] => (int) 10
             [price] => (float) 69
             [formated_price] => (string) ¥69.00元
           )
           [1] => array(3) (
             [amount] => (int) 20
             [price] => (float) 65
             [formated_price] => (string) ¥65.00元
           )
         )
    * 
    */
    /* 统计信息 */
    $stat = group_buy_stat($group_buy_id, $group_buy['deposit']);
    $group_buy = array_merge($group_buy, $stat);
    /* 计算当前价 */
    $cur_price = $price_ladder[0]['price'];
    // 初始化
    $cur_amount = $stat['valid_goods'] + $current_num;
    // 当前数量
    //循环,当数量大于某一个量值的时候,价格就更改为相应段的团购价,从低到高判断
    foreach ($price_ladder as $amount_price) {
        if ($cur_amount >= $amount_price['amount']) {
            $cur_price = $amount_price['price'];
        } else {
            break;
        }
    }
    $group_buy['cur_price'] = $cur_price;
    //转换为页面上显示的可读形式
    $group_buy['formated_cur_price'] = price_format($cur_price, false);
    /* 最终价 */
    $group_buy['trans_price'] = $group_buy['cur_price'];
    $group_buy['formated_trans_price'] = $group_buy['formated_cur_price'];
    $group_buy['trans_amount'] = $group_buy['valid_goods'];
    /* 状态 */
    $group_buy['status'] = group_buy_status($group_buy);
    if (isset($GLOBALS['_LANG']['gbs'][$group_buy['status']])) {
        $group_buy['status_desc'] = $GLOBALS['_LANG']['gbs'][$group_buy['status']];
    }
    $group_buy['start_time'] = $group_buy['formated_start_date'];
    $group_buy['end_time'] = $group_buy['formated_end_date'];
    return $group_buy;
}
开发者ID:jz233,项目名称:TheProject,代码行数:87,代码来源:lib_goods.php

示例14: group_buy_info

/**
 * 取得团购活动信息
 * @param   int     $group_buy_id   团购活动id
 * @param   int     $current_num    本次购买数量(计算当前价时要加上的数量)
 * @return  array
 *                  status          状态:
 */
function group_buy_info($group_buy_id, $current_num = 0)
{
    /* 取得团购活动信息 */
    $group_buy_id = intval($group_buy_id);
    $sql = "SELECT b.*,g.*, b.act_id AS group_buy_id, b.act_desc AS group_buy_desc, b.start_time AS start_date, b.end_time AS end_date " .
            "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " .
			"LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " .
            "WHERE act_id = '$group_buy_id' " .
            "AND act_type = '" . GAT_GROUP_BUY . "'";
    $group_buy = $GLOBALS['db']->getRow($sql);

    /* 如果为空,返回空数组 */
    if (empty($group_buy))
    {
        return array();
    }

    $ext_info = unserialize($group_buy['ext_info']);
    $group_buy = array_merge($group_buy, $ext_info);

    /* 格式化时间 */
    $group_buy['formated_start_date'] = local_date('Y-m-d H:i', $group_buy['start_time']);
    $group_buy['formated_end_date'] = local_date('Y-m-d H:i', $group_buy['end_time']);

    /* 格式化保证金 */
    $group_buy['formated_deposit'] = price_format($group_buy['deposit'], false);

    /* 处理价格阶梯 */
    $price_ladder = $group_buy['price_ladder'];
    if (!is_array($price_ladder) || empty($price_ladder))
    {
        $price_ladder = array(array('amount' => 0, 'price' => 0));
    }
    else
    {
        foreach ($price_ladder as $key => $amount_price)
        {
            $price_ladder[$key]['formated_price'] = price_format($amount_price['price'], false);
        }
    }
    $group_buy['price_ladder'] = $price_ladder;

    /* 统计信息 */
    $stat = group_buy_stat($group_buy_id, $group_buy['deposit']);
    $group_buy = array_merge($group_buy, $stat);

    /* 计算当前价 */
    $cur_price  = $price_ladder[0]['price']; // 初始化
    $cur_amount = $stat['valid_goods'] + $current_num; // 当前数量
    foreach ($price_ladder as $amount_price)
    {
        if ($cur_amount >= $amount_price['amount'])
        {
            $cur_price = $amount_price['price'];
        }
        else
        {
            break;
        }
    }
    $group_buy['cur_price'] = $cur_price;
    $group_buy['formated_cur_price'] = price_format($cur_price, false);
	
	/*团购节省和折扣计算 by ecmoban start*/
	$price    = $group_buy['market_price']; //原价 
	$nowprice = $group_buy['cur_price']; //现价
	$group_buy['jiesheng'] = $price-$nowprice; //节省金额 
	if($nowprice > 0)
	{
		$group_buy['zhekou'] = round(10 / ($price / $nowprice), 1); 
	}
	else 
	{ 
		$group_buy['zhekou'] = 0; 
	}
	/*团购节省和折扣计算 by ecmoban end*/
	
    /* 最终价 */
    $group_buy['trans_price'] = $group_buy['cur_price'];
    $group_buy['formated_trans_price'] = $group_buy['formated_cur_price'];
    $group_buy['trans_amount'] = $group_buy['valid_goods'];

    /* 状态 */
    $group_buy['status'] = group_buy_status($group_buy);
    if (isset($GLOBALS['_LANG']['gbs'][$group_buy['status']]))
    {
        $group_buy['status_desc'] = $GLOBALS['_LANG']['gbs'][$group_buy['status']];
    }

    $group_buy['start_time'] = $group_buy['formated_start_date'];
    $group_buy['end_time'] = $group_buy['formated_end_date'];

    return $group_buy;
//.........这里部分代码省略.........
开发者ID:blowfishJ,项目名称:galaxyCode,代码行数:101,代码来源:lib_goods.php

示例15: group_buy_info1

function group_buy_info1($group_buy_id)
{
    $group_buy_id = intval($group_buy_id);
    $sql = "SELECT b.*,g.*, b.act_id AS group_buy_id, b.act_desc AS group_buy_desc, b.start_time AS start_date, b.end_time AS end_date " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS b " . "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON b.goods_id = g.goods_id " . "WHERE act_id <> '{$group_buy_id}' " . "AND act_type = '" . GAT_GROUP_BUY . "' and is_finished =0 ";
    $group_buy = array();
    $group_list = $GLOBALS['db']->getAll($sql);
    foreach ($group_list as $key => $rows) {
        $group_buy[$key]['act_id'] = $rows['act_id'];
        $group_buy[$key]['goods_name'] = $rows['goods_name'];
        $group_buy[$key]['goods_thumb'] = $rows['goods_thumb'];
        $group_buy[$key]['buy_num'] = $rows['buy_num'];
        $group_buy[$key]['url'] = build_uri('group_buy', array('group_buy_id' => $rows['cat_id']));
        $stat = group_buy_stat($rows['group_buy_id'], $rows['deposit']);
        $group_buy[$key]['valid_goods'] = $stat['valid_goods'];
    }
    return $group_buy;
}
开发者ID:a494008974,项目名称:bzbshop,代码行数:17,代码来源:group_buy.php


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