限时抢购,秒杀商品的二次开发

1,先在后台admin/templates 中找goods_info.htm文件到促销部分,改为一个下拉列表的分别是促销,限时,秒杀,值分别是1,2,3
这样,代码如下:

<!--                  限时抢购开始 liangfang edit-->
<tr>
<td class="label"><label for="is_promote">
<input type="checkbox" id="is_promote_switch" name="is_promote_switch" value="1" {if $goods.is_promote}checked="checked"{/if} onclick="handlePromote(this.checked);" /> 是否参加促销</label>
<select name="is_promote" id="is_promote">
<option value="1" {if $goods.is_promote eq 1}selected="selected"{/if} >{$lang.lab_promote_price}</option>
<option value="2" {if $goods.is_promote eq 2}selected="selected"{/if} >限时价:</option>
<option value="3" {if $goods.is_promote eq 3}selected="selected"{/if} >秒杀价:</option>
</select></td>
<td id="promote_3"><input type="text" id="promote_1" name="promote_price" value="{$goods.promote_price}" size="20" /></td>
</tr>
<tr id="promote_4">
<td class="label" id="promote_5">{$lang.lab_promote_date}</td>
<td id="promote_6">
<input name="promote_start_date" type="text" id="promote_start_date" size="15" value='{$goods.promote_start_date}' readonly="readonly" /><input name="selbtn1" type="button" id="selbtn1" onclick="return showCalendar('promote_start_date', '%Y-%m-%d %H:%M', '24', false, 'selbtn1');" value="{$lang.btn_select}" class="button"/> - <input name="promote_end_date" type="text" id="promote_end_date" size="15" value='{$goods.promote_end_date}' readonly="readonly" /><input name="selbtn2" type="button" id="selbtn2" onclick="return showCalendar('promote_end_date', '%Y-%m-%d %H:%M', '24', false, 'selbtn2');" value="{$lang.btn_select}" class="button"/>
</td>
</tr>
<!-- 限时抢购结束-->

其中对时间选择框进行了重新设置为显示小时和分钟。
2,把admin下的goods.php 改一句话,注释部分是原先的代码

        $is_promote = empty($promote_price) ? 0 : $_POST['is_promote'];//liangfang edit
// $is_promote = empty($promote_price) ? 0 : 1;

3、把下面的方法复制到你需要调用的页面:(方法中的sql条件WHERE is_promote = '2'是控制调用促销/限时/秒杀的)

/**
* 获得分类下的秒杀-限时折扣
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods_zhekou($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
{
$display = $GLOBALS['display'];
$where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
"g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')'; if ($brand > 0)
{
$where .= "AND g.brand_id=$brand ";
} if ($min > 0)
{
$where .= " AND g.shop_price >= $min ";
} if ($max > 0)
{
$where .= " AND g.shop_price <= $max ";
} /* 获得商品列表 */ $now_time = gmtime();
$sql = "SELECT g.goods_id,g.goods_thumb,g.goods_name,g.shop_price,g.promote_price,g.promote_start_date,g.promote_end_date 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 is_promote = '2' and promote_start_date <= '$now_time' and promote_end_date >= '$now_time' and is_on_sale = 1 and is_alone_sale = 1 and is_delete = 0 order by promote_start_date ";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
}
else
{
$promote_price = 0;
} /* 处理商品水印图片 */
$watermark_img = ''; if ($promote_price != 0)
{
$watermark_img = "watermark_promote_small";
}
elseif ($row['is_new'] != 0)
{
$watermark_img = "watermark_new_small";
}
elseif ($row['is_best'] != 0)
{
$watermark_img = "watermark_best_small";
}
elseif ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot_small';
} if ($watermark_img != '')
{
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
} $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if($display == 'grid')
{
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
else
{
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['keywords'] = $row['keywords'];
} return $arr;
}
/**
* 获得分类下的清仓捡耙活
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods_clear($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
{
$display = $GLOBALS['display'];
$where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
"g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')'; if ($brand > 0)
{
$where .= "AND g.brand_id=$brand ";
} if ($min > 0)
{
$where .= " AND g.shop_price >= $min ";
} if ($max > 0)
{
$where .= " AND g.shop_price <= $max ";
} /* 获得商品列表 */ $now_time = gmtime();
$sql = "SELECT g.goods_id,g.goods_thumb,g.goods_name,g.shop_price,g.promote_price,g.promote_start_date,g.promote_end_date 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 is_promote = '3' and promote_start_date <= '$now_time' and promote_end_date >= '$now_time' and is_on_sale = 1 and is_alone_sale = 1 and is_delete = 0 order by promote_start_date ";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
}
else
{
$promote_price = 0;
} /* 处理商品水印图片 */
$watermark_img = ''; if ($promote_price != 0)
{
$watermark_img = "watermark_promote_small";
}
elseif ($row['is_new'] != 0)
{
$watermark_img = "watermark_new_small";
}
elseif ($row['is_best'] != 0)
{
$watermark_img = "watermark_best_small";
}
elseif ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot_small';
} if ($watermark_img != '')
{
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
} $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if($display == 'grid')
{
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
else
{
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['keywords'] = $row['keywords'];
} return $arr;
}
/**
* 获得分类下的爆款促销
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods_cuxiao($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
{
$display = $GLOBALS['display'];
$where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
"g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')'; if ($brand > 0)
{
$where .= "AND g.brand_id=$brand ";
} if ($min > 0)
{
$where .= " AND g.shop_price >= $min ";
} if ($max > 0)
{
$where .= " AND g.shop_price <= $max ";
} /* 获得商品列表 */ $now_time = gmtime();
$sql = "SELECT g.goods_id,g.goods_thumb,g.goods_name,g.shop_price,g.promote_price,g.promote_start_date,g.promote_end_date 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 is_promote = '1' and promote_start_date <= '$now_time' and promote_end_date >= '$now_time' and is_on_sale = 1 and is_alone_sale = 1 and is_delete = 0 order by promote_start_date ";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
}
else
{
$promote_price = 0;
} /* 处理商品水印图片 */
$watermark_img = ''; if ($promote_price != 0)
{
$watermark_img = "watermark_promote_small";
}
elseif ($row['is_new'] != 0)
{
$watermark_img = "watermark_new_small";
}
elseif ($row['is_best'] != 0)
{
$watermark_img = "watermark_best_small";
}
elseif ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot_small';
} if ($watermark_img != '')
{
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
} $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if($display == 'grid')
{
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
else
{
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['keywords'] = $row['keywords'];
} return $arr;
}

4、在下面这句代码下加入调用的代码;

$smarty->assign('goods_list',       $goodslist);
/**清仓捡耙活商品列表**/
$goodslist_clear = category_get_goods_clear($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order);
if($display == 'grid')
{
if(count($goodslist_clear) % 2 != 0)
{
$goodslist_clear[] = array();
}
}
$smarty->assign('goodslist_clear', $goodslist_clear);
/**清仓捡耙活商品列表**/
/**爆款促销列表**/
$goodslist_cx = category_get_goods_cuxiao($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order);
if($display == 'grid')
{
if(count($goodslist_cx) % 2 != 0)
{
$goodslist_cx[] = array();
}
}
$smarty->assign('goodslist_cx', $goodslist_cx);
/**爆款促销列表**/
/**限时折扣列表**/
$goodslist_zhekou = category_get_goods_zhekou($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order);
if($display == 'grid')
{
if(count($goodslist_zhekou) % 2 != 0)
{
$goodslist_zhekou[] = array();
}
}
$smarty->assign('goodslist_zhekou', $goodslist_zhekou);
/**限时折扣列表**/

ecshop二次开发秒杀、限时折扣、清仓等功能的更多相关文章

  1. Ecshop二次开发必备基础

    EcShop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的PHP开源产品.B2C方面有Ecshop ...

  2. EcShop二次开发学习方法和Ecshop二次开发必备基础

    ecshop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的php开源产品.B2C方面有Ecshop ...

  3. EcShop二次开发学习方法

    EcShop二次开发学习方法 (2012-03-08 11:10:08) 转载▼ 标签: 京东 公用函数库 二次开发 sql语言 数据库设计 杂谈 分类: ecshop 近年来,随着互联网的发展,电子 ...

  4. ECSHOP二次开发指南

    ECSHOP二次开发指南 发布时间:2013-05-28 12:47:00   来源:   评论:0 点击: 次 [字号:大 中 小] QQ空间新浪微博腾讯微博人人网豆瓣网百度空间百度搜藏开心网复制更 ...

  5. EcShop二次开发系列教程–总纲

    EcShop作为老牌的B2C独立网店系统,功能非常全名,强大的文件.数据库缓存机制,保证前后台系统执行速度更快.系统平稳运行.但是过多的功能也或多或少的会影响到系统的整个效率,所有在使用EcShop搭 ...

  6. ecshop二次开发 给商品添加自定义字段

    说起自定义字段,我想很多的朋友像我一样会想起一些开源的CMS(比如Dedecms.Phpcms.帝国)等,他们是可以在后台直接添加自定义字段的. 抱着这种想法我在Ecshop的后台一顿找,不过肿么都木 ...

  7. ecshop二次开发之购物车常见问题

    1.ecshop二次开发中保存注册用户购物车数据解决方法:ecshop购物车是数据库中cart表来支持的,在ecshop表中rec_id是编号,user_id是注册用户的id,session_id表示 ...

  8. ECShop二次开发指南(一)

    ECSHOP是一套完整的网络商店解决方案,包括前台的商品展示.购物流程和强大易用的后台管理.由于 ecshop简单易用,使用者几乎可以在3几分钟简单的设置一下就可以拥有一个网上商店系统,所以很多的B2 ...

  9. ecshop二次开发 给商品添加自定义字段【包含我自己进一步的开发实例详解】

    本文包含商品自定义添加教程及进一步的开发实例: 教程: 说起自定义字段,我想很多的朋友像我一样会想起一些开源的CMS(比如Dedecms.Phpcms.帝国)等,他们是可以在后台直接添加自定义字段的. ...

随机推荐

  1. MVC配置原理-源码

    目录 举例 修改SpringBoot的默认配置 全面接管SpringMVC 参考链接 在进行项目编写前,我们还需要知道一个东西,就是SpringBoot对我们的SpringMVC还做了哪些配置,包括如 ...

  2. Pikachu-RCE模块

    一.概述 1.1 RCE漏洞 可以让攻击者直接向后台服务器远程注入操作系统命令或者代码,从而控制后台系统. 1.2 远程系统命令执行一般出现这种漏洞,是因为应用系统从设计上需要给用户提供指定的远程命令 ...

  3. 线程队列 concurrent 协程 greenlet gevent

    死锁问题 所谓死锁:是指两个或两个以上的进程或线程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这些永远在互相等待的进 ...

  4. 网关服务Kong和konga介绍安装使用教程

    介绍 Kong是一款基于OpenResty(Nginx + Lua模块)编写的高可用.易扩展的,由Mashape公司开源的API Gateway项目.Kong是基于NGINX和Apache Cassa ...

  5. NOIP 模拟 $28\; \rm 割海成路之日$

    题解 \(by\;zj\varphi\) 用两个集合分别表示 \(1\) 边联通块,\(1,2\) 边联通块 . \(\rm son_x\) 表示当前节点通过 \(3\) 类边能到的 \(2\) 联通 ...

  6. Rabbit-用户上线接收消息

    application-dev.yml spring: rabbitmq: username: admin password: admin host: 192.168.0.45 port: 5672 ...

  7. TypeScript 入门指南 【大白话】

    前言 聊聊为何要学习TypeScript? 从开发角度来讲, TypeScript 作为强类型语言,对属性有类型约束.在日常开发中少了减少了不必要的因参数类型造成的BUG,当你在使用同事封装好的函数时 ...

  8. ingress-nginx-controller 部署以及优化

    一.说明 本文使用的ingress-nginx v1.0 最新版本,v1.0 适用于 Kubernetes 版本 >= v1.19 小于这个版本的k8s集群,请降级ingress-nginx. ...

  9. Javascript - 异步操作和读取文件

    node.js读取文件 node.js内置了异步读取文件的模块,可以很方便地读取文件的数据.先创建三个txt文档,在根目录下创建一个readFile.js 输入以下代码,然后在vscode的终端中输入 ...

  10. ARP协议工作原理实验

    一.实验目的 验证"在向目的主机发送数据包时会先查询ARP高速缓存,如果ARP高速缓存中已保存了目的主机的MAC地址,不进行ARP查询,使用ARP高速缓存中的MAC地址:如果缓存中没有IP对 ...