博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ecshop首页调用团购信息产品购买人数
阅读量:5836 次
发布时间:2019-06-18

本文共 1933 字,大约阅读时间需要 6 分钟。

hot3.png

1:index.php

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, 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']);

$stat = group_buy_stat($row['group_buy_id'], $ext_info['deposit']);

$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['vn'] = $stat['valid_goods'];

$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'],'');

$group_buy_list[] = $row;

}

}

return $group_buy_list;

}

在这个函数里面,我们调用了$stat = group_buy_stat($row['group_buy_id'], $ext_info['deposit']);方法,这样一来我们就可以知道每个团购商品他的一些销售情况。

然后在模板里面。直接这样调用就可以

<div class="index_group">售出 <strong>{$goods1.vn}</strong> 件</div>

演示地址:

转载于:https://my.oschina.net/Android1989/blog/298125

你可能感兴趣的文章
lsa声卡/dev/snd/pcmC0D0p的open打开流程
查看>>
浅谈什么是正向代理和反向代理,如何使用nginx搭建正向代理和反向代理
查看>>
转 通过phpize为php在不重新编译php情况下安装模块openssl
查看>>
搭建Jupyter学习环境
查看>>
html基础
查看>>
深入理解java虚拟机(三)--类文件结构
查看>>
Null value was assigned to a property of primitive type setter of
查看>>
UIRecorder 学习了解
查看>>
三元表达式,推导式,递归,匿名函数,内置函数
查看>>
zabbix3.4配置之邮件报警机制(通过zabbix自有的邮件机制)
查看>>
SQL server查看触发器是否被禁用
查看>>
jupyter notebook的安装与基本操作
查看>>
C#: using JsonReader avoid Deserialize Json to dynamic
查看>>
[C++基础]在构造函数内部调用构造函数
查看>>
跟随我在oracle学习php(8)
查看>>
FZU - 1688 Binary land
查看>>
Spring 3.1.0 Hibernate 3.0 Eclipse Spring WEB例子
查看>>
转换流,Properties 集合
查看>>
bootstrap列排序
查看>>
redis 常用操作
查看>>