ecshop二次开发之后台秒杀
1.进入admin->includes->inc_menu.PHP中此文件为定义左侧功能模块超链接
2.添加include/inc_menu.php秒杀管理超链接找链接
- $modules['03_promotion']['16_seckill'] = 'seckill_goods.php?act=add';
3.找到languages/zh_cn/admin/common.php 添加秒杀功能
- $_LANG['16_seckill']='秒杀管理';
4.添加权限管理中的秒杀权限
1>向数据库中添加秒杀权限,包括查看秒杀表与添加秒杀
数据库表中的数据:ecs_admin_action
2>找到languages/zh_cn/admin/priv_action.php
- //秒杀管理
- $_LANG['seckill'] = '秒杀管理';
- $_LANG['seckill_list'] = '秒杀显示';
- $_LANG['seckill_add'] = '秒杀添加';
3>找到添加include/inc_priv.php 添加秒杀权限的加载配置
- //秒杀管理
- $purview['16_seckill'] = 'seckill';
配置完成后
打开 后台>权限管理>管理员列表>分配权限
3.配置秒杀的语言包
在languages/zh_cn/admin/下配置seckill_goods.php;
- <?php
- /**
- * ECSHOP 管理中心秒杀活动语言文件
- * ============================================================================
- * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
- * 网站地址: http://www.ecshop.com;
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * $Author: liubo $
- * $Id: seckill.php 17217 2011-01-19 06:29:08Z liubo $
- */
- /* menu */
- $_LANG['seckill_list'] = '秒杀活动列表';
- $_LANG['add_seckill'] = '添加秒杀活动';
- $_LANG['edit_seckill'] = '编辑秒杀活动';
- $_LANG['seckill_log'] = '秒杀活动出价记录';
- $_LANG['continue_add_seckill'] = '继续添加秒杀活动';
- $_LANG['back_seckill_list'] = '返回秒杀活动列表';
- $_LANG['add_seckill_ok'] = '添加秒杀活动成功';
- $_LANG['edit_seckill_ok'] = '编辑秒杀活动成功';
- $_LANG['settle_deposit_ok'] = '处理冻结的保证金成功';
- /* list */
- $_LANG['act_is_going'] = '仅显示进行中的活动';
- $_LANG['act_name'] = '秒杀活动名称';
- $_LANG['goods_name'] = '商品名称';
- $_LANG['start_time'] = '开始时间';
- $_LANG['end_time'] = '结束时间';
- $_LANG['deposit'] = '保证金';
- $_LANG['start_price'] = '起拍价';
- $_LANG['end_price'] = '一口价';
- $_LANG['amplitude'] = '加价幅度';
- $_LANG['seckill_not_exist'] = '您要操作的秒杀活动不存在';
- $_LANG['seckill_cannot_remove'] = '该秒杀活动已经有人出价,不能删除';
- $_LANG['js_languages']['batch_drop_confirm'] = '您确实要删除选中的秒杀活动吗?';
- $_LANG['batch_drop_ok'] = '操作完成(已经有人出价的秒杀活动不能删除)';
- $_LANG['no_record_selected'] = '没有选择记录';
- $_LANG['label_goods_num']='秒杀数量:';
- /* info */
- $_LANG['label_act_name'] = '秒杀活动名称:';
- $_LANG['notice_act_name'] = '如果留空,取秒杀商品的名称(该名称仅用于后台,前台不会显示)';
- $_LANG['label_act_desc'] = '秒杀活动描述:';
- $_LANG['label_search_goods'] = '根据商品编号、名称或货号搜索商品';
- $_LANG['label_goods_name'] = '秒杀商品名称:';
- $_LANG['label_start_time'] = '秒杀开始时间:';
- $_LANG['label_end_time'] = '秒杀结束时间:';
- $_LANG['label_status'] = '当前状态:';
- $_LANG['label_start_price'] = '起拍价:';
- $_LANG['label_end_price'] = '一口价:';
- $_LANG['label_no_top'] = '无封顶';
- $_LANG['label_amplitude'] = '加价幅度:';
- $_LANG['label_deposit'] = '保证金:';
- $_LANG['bid_user_count'] = '已有 %s 个买家出价';
- $_LANG['settle_frozen_money'] = '怎样处理买家的冻结资金?';
- $_LANG['unfreeze'] = '解冻保证金';
- $_LANG['deduct'] = '扣除保证金';
- $_LANG['invalid_status'] = '当前状态不正确';
- $_LANG['no_deposit'] = '没有保证金需要处理';
- $_LANG['unfreeze_seckill_deposit'] = '解冻秒杀活动的保证金:%s';
- $_LANG['deduct_seckill_deposit'] = '扣除秒杀活动的保证金:%s';
- $_LANG['seckill_status'][PRE_START] = '未开始';
- $_LANG['seckill_status'][UNDER_WAY] = '进行中';
- $_LANG['seckill_status'][FINISHED] = '已结束';
- $_LANG['seckill_status'][SETTLED] = '已结束';
- $_LANG['pls_search_goods'] = '请先搜索商品';
- $_LANG['search_result_empty'] = '没有找到商品,请重新搜索';
- $_LANG['pls_select_goods'] = '请选择秒杀商品';
- $_LANG['goods_not_exist'] = '您要秒杀的商品不存在';
- $_LANG['js_languages']['start_price_not_number'] = '起拍价格式不正确(数字)';
- $_LANG['js_languages']['end_price_not_number'] = '一口价格式不正确(数字)';
- $_LANG['js_languages']['end_gt_start'] = '一口价应该大于起拍价';
- $_LANG['js_languages']['amplitude_not_number'] = '加价幅度格式不正确(数字)';
- $_LANG['js_languages']['deposit_not_number'] = '保证金格式不正确(数字)';
- $_LANG['js_languages']['start_lt_end'] = '秒杀开始时间不能大于结束时间';
- $_LANG['js_languages']['search_is_null'] = '没有搜索到任何商品,请重新搜索';
- /* log */
- $_LANG['bid_user'] = '买家';
- $_LANG['bid_price'] = '出价';
- $_LANG['bid_time'] = '时间';
- $_LANG['status'] = '状态';
- ?>
4.仿照拍卖功能做秒杀功能
进入upload->admin中建立seckill_goods.php代码如下(就是复制auction.php中复制将auction改为seckill)在这里我已经写好了直接复制
- <?php
- /**
- * ECSHOP 管理中心拍卖活动管理
- * ============================================================================
- * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
- * 网站地址: http://www.ecshop.com;
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * $Author: liubo $
- * $Id: auction.php 17217 2011-01-19 06:29:08Z liubo $
- */
- define('IN_ECS', true);
- require(dirname(__FILE__) . '/includes/init.php');
- require(ROOT_PATH . 'includes/lib_goods.php');
- $exc = new exchange($ecs->table('goods_activity'), $db, 'act_id', 'act_name');
- /*------------------------------------------------------ */
- //-- 活动列表页
- /*------------------------------------------------------ */
- if ($_REQUEST['act'] == 'list')
- {
- /* 检查权限 */
- admin_priv('seckill');
- /* 模板赋值 */
- $smarty->assign('full_page', 1);
- $smarty->assign('ur_here', $_LANG['seckill_list']);
- $smarty->assign('action_link', array('href' => 'seckill.php?act=add', 'text' => $_LANG['add_seckill']));
- $list = seckill_list();
- $smarty->assign('seckill_list', $list['item']);
- $smarty->assign('filter', $list['filter']);
- $smarty->assign('record_count', $list['record_count']);
- $smarty->assign('page_count', $list['page_count']);
- $smarty->assign('form_action','add');
- $sort_flag = sort_flag($list['filter']);
- $smarty->assign($sort_flag['tag'], $sort_flag['img']);
- /* 显示商品列表页面 */
- assign_query_info();
- $smarty->display('seckill_list.htm');
- }
- /*------------------------------------------------------ */
- //-- 分页、排序、查询
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'query')
- {
- $list = seckill_list();
- $smarty->assign('seckill_list', $list['item']);
- $smarty->assign('filter', $list['filter']);
- $smarty->assign('record_count', $list['record_count']);
- $smarty->assign('page_count', $list['page_count']);
- $sort_flag = sort_flag($list['filter']);
- $smarty->assign($sort_flag['tag'], $sort_flag['img']);
- make_json_result($smarty->fetch('seckill_list.htm'), '',
- array('filter' => $list['filter'], 'page_count' => $list['page_count']));
- }
- /*------------------------------------------------------ */
- //-- 删除
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'remove')
- {
- check_authz_json('seckill');
- $id = intval($_GET['id']);
- $name = $auction['act_name'];
- $exc->drop($id);
- /* 记日志 */
- admin_log($name, 'remove', 'seckill');
- /* 清除缓存 */
- clear_cache_files();
- $url = 'seckill_goods.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']);
- ecs_header("Location: $url\n");
- exit;
- }
- /*------------------------------------------------------ */
- //-- 批量操作
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'batch')
- {
- /* 取得要操作的记录编号 */
- if (empty($_POST['checkboxes']))
- {
- sys_msg($_LANG['no_record_selected']);
- }
- else
- {
- /* 检查权限 */
- admin_priv('auction');
- $ids = $_POST['checkboxes'];
- /* 删除记录 */
- $sql = "DELETE FROM " . $ecs->table('goods_activity') .
- " WHERE act_id " . db_create_in($ids) .
- " AND act_type = '" . GAT_SECKILL . "'";
- $db->query($sql);
- /* 记日志 */
- admin_log('', 'batch_remove', 'seckill');
- /* 清除缓存 */
- clear_cache_files();
- $links[] = array('text' => $_LANG['back_seckill_list'], 'href' => 'seckill_goods.php?act=list&' . list_link_postfix());
- sys_msg($_LANG['batch_drop_ok'], 0, $links);
- }
- }
- /*------------------------------------------------------ */
- //-- 添加、编辑
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'add' || $_REQUEST['act'] == 'edit')
- {
- /* 检查权限 */
- admin_priv('seckill');
- /* 是否添加 */
- $is_add = $_REQUEST['act'] == 'add';
- $smarty->assign('form_action', $is_add ? 'insert' : 'update');
- /* 初始化、取得拍卖活动信息 */
- if ($is_add)
- {
- $auction = array(
- 'act_id' => 0,
- 'act_name' => '',
- 'act_desc' => '',
- 'goods_id' => 0,
- 'product_id' => 0,
- 'goods_name' => $_LANG['pls_search_goods'],
- 'start_time' => date('Y-m-d', time() + 86400),
- 'end_time' => date('Y-m-d', time() + 4 * 86400),
- );
- }
- /*
- else
- {
- if (empty($_GET['id']))
- {
- sys_msg('invalid param');
- }
- $id = intval($_GET['id']);
- $auction = auction_info($id, true);
- if (empty($auction))
- {
- sys_msg($_LANG['auction_not_exist']);
- }
- $auction['status'] = $_LANG['auction_status'][$auction['status_no']];
- $smarty->assign('bid_user_count', sprintf($_LANG['bid_user_count'], $auction['bid_user_count']));
- }
- */
- $smarty->assign('seckill', $seckill);
- /* 赋值时间控件的语言 */
- $smarty->assign('cfg_lang', $_CFG['lang']);
- /* 商品货品表 */
- $smarty->assign('good_products_select', get_good_products_select($seckill['goods_id']));
- /* 显示模板 */
- if ($is_add)
- {
- $smarty->assign('ur_here', $_LANG['add_seckill']);
- }
- $smarty->assign('action_link', list_link($is_add));
- assign_query_info();
- $smarty->display('seckill_goods_info.htm');
- }
- /*------------------------------------------------------ */
- //-- 添加、编辑后提交
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update')
- {
- /* 检查权限 */
- admin_priv('seckill');
- /* 是否添加 */
- $is_add = $_REQUEST['act'] == 'insert';
- /* 检查是否选择了商品 */
- $goods_id = intval($_POST['goods_id']);
- if ($goods_id <= 0)
- {
- sys_msg($_LANG['pls_select_goods']);
- }
- $sql = "SELECT goods_name FROM " . $ecs->table('goods') . " WHERE goods_id = '$goods_id'";
- $row = $db->getRow($sql);
- if (empty($row))
- {
- sys_msg($_LANG['goods_not_exist']);
- }
- $goods_name = $row['goods_name'];
- /* 提交值 */
- $seckill = array(
- 'act_id' => intval($_POST['id']),
- 'act_name' => empty($_POST['act_name']) ? $goods_name : sub_str($_POST['act_name'], 255, false),
- 'act_desc' => $_POST['act_desc'],
- 'act_type' => GAT_SECKILL,
- 'goods_id' => $goods_id,
- 'product_id' => empty($_POST['product_id']) ? 0 : $_POST['product_id'],
- 'goods_name' => $goods_name,
- 'start_time' => local_strtotime($_POST['start_time']),
- 'end_time' => local_strtotime($_POST['end_time']),
- 'ext_info' => serialize(array(
- 'start_price' => round(floatval($_POST['start_price']), 2),
- 'seckill_num' => round(floatval($_POST['seckill_num']), 2)
- ))
- );
- /* 保存数据 */
- if ($is_add)
- {
- $seckill['is_finished'] = 0;
- $db->autoExecute($ecs->table('goods_activity'), $seckill, 'INSERT');
- $seckill['act_id'] = $db->insert_id();
- }
- else
- {
- $db->autoExecute($ecs->table('goods_activity'), $seckill, 'UPDATE', "act_id = '$seckill[act_id]'");
- }
- /* 记日志 */
- if ($is_add)
- {
- admin_log($auction['act_name'], 'add', 'seckill');
- }
- else
- {
- admin_log($auction['act_name'], 'edit', 'seckill');
- }
- /* 清除缓存 */
- clear_cache_files();
- /* 提示信息 */
- if ($is_add)
- {
- $links = array(
- array('href' => 'seckill_goods.php?act=add', 'text' => $_LANG['continue_add_seckill']),
- array('href' => 'seckill_goods.php?act=list', 'text' => $_LANG['back_seckill_list'])
- );
- sys_msg($_LANG['add_seckill_ok'], 0, $links);
- }
- else
- {
- $links = array(
- array('href' => 'seckill_goods.php?act=list&' . list_link_postfix(), 'text' => $_LANG['back_seckill_list'])
- );
- sys_msg($_LANG['edit_seckill_ok'], 0, $links);
- }
- }
- /*------------------------------------------------------ */
- //-- 处理冻结资金
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'settle_money')
- {
- /* 检查权限 */
- admin_priv('auction');
- /* 检查参数 */
- if (empty($_POST['id']))
- {
- sys_msg('invalid param');
- }
- $id = intval($_POST['id']);
- $auction = auction_info($id);
- if (empty($auction))
- {
- sys_msg($_LANG['auction_not_exist']);
- }
- if ($auction['status_no'] != FINISHED)
- {
- sys_msg($_LANG['invalid_status']);
- }
- if ($auction['deposit'] <= 0)
- {
- sys_msg($_LANG['no_deposit']);
- }
- /* 处理保证金 */
- $exc->edit("is_finished = 2", $id); // 修改状态
- if (isset($_POST['unfreeze']))
- {
- /* 解冻 */
- log_account_change($auction['last_bid']['bid_user'], $auction['deposit'],
- (-1) * $auction['deposit'], 0, 0, sprintf($_LANG['unfreeze_auction_deposit'], $auction['act_name']));
- }
- else
- {
- /* 扣除 */
- log_account_change($auction['last_bid']['bid_user'], 0,
- (-1) * $auction['deposit'], 0, 0, sprintf($_LANG['deduct_auction_deposit'], $auction['act_name']));
- }
- /* 记日志 */
- admin_log($auction['act_name'], 'edit', 'auction');
- /* 清除缓存 */
- clear_cache_files();
- /* 提示信息 */
- sys_msg($_LANG['settle_deposit_ok']);
- }
- /*------------------------------------------------------ */
- //-- 搜索商品
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'search_goods')
- {
- check_authz_json('auction');
- include_once(ROOT_PATH . 'includes/cls_json.php');
- $json = new JSON;
- $filter = $json->decode($_GET['JSON']);
- $arr['goods'] = get_goods_list($filter);
- if (!empty($arr['goods'][0]['goods_id']))
- {
- $arr['products'] = get_good_products($arr['goods'][0]['goods_id']);
- }
- make_json_result($arr);
- }
- /*------------------------------------------------------ */
- //-- 搜索货品
- /*------------------------------------------------------ */
- elseif ($_REQUEST['act'] == 'search_products')
- {
- include_once(ROOT_PATH . 'includes/cls_json.php');
- $json = new JSON;
- $filters = $json->decode($_GET['JSON']);
- if (!empty($filters->goods_id))
- {
- $arr['products'] = get_good_products($filters->goods_id);
- }
- make_json_result($arr);
- }
- /*
- * 取得秒杀活动列表
- * @return array
- */
- function seckill_list()
- {
- $result = get_filter();
- if ($result === false)
- {
- /* 过滤条件 */
- $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
- if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1)
- {
- $filter['keyword'] = json_str_iconv($filter['keyword']);
- }
- $filter['is_going'] = empty($_REQUEST['is_going']) ? 0 : 1;
- $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 = "";
- if (!empty($filter['keyword']))
- {
- $where .= " AND goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'";
- }
- if ($filter['is_going'])
- {
- $now = gmtime();
- $where .= " AND is_finished = 0 AND start_time <= '$now' AND end_time >= '$now' ";
- }
- $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods_activity') .
- " WHERE act_type = '" . GAT_SECKILL . "' $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_SECKILL . "' $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']);
- $arr = array_merge($row, $ext_info);
- $arr['start_time'] = local_date('Y-m-d H:i', $arr['start_time']);
- $arr['end_time'] = local_date('Y-m-d H:i', $arr['end_time']);
- $list[] = $arr;
- }
- $arr = array('item' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
- return $arr;
- }
- /**
- * 列表链接
- * @param bool $is_add 是否添加(插入)
- * @param string $text 文字
- * @return array('href' => $href, 'text' => $text)
- */
- function list_link($is_add = true, $text = '')
- {
- $href = 'seckill_goods.php?act=list';
- if (!$is_add)
- {
- $href .= '&' . list_link_postfix();
- }
- if ($text == '')
- {
- $text = $GLOBALS['_LANG']['seckill_list'];
- }
- return array('href' => $href, 'text' => $text);
- }
- ?>
5.在加载秒杀对应常量找到includes/inc_constant.php添加秒杀功能对应的常量
- define('GAT_SECKILL', 5);
6.在upload->admin->templates中建立两个html页面进行显示和添加分别是sckill_goods_info.php和seckill_list.php
1.seckill_list.php代码如下:
- <!-- $Id: auction_info.htm 16992 2010-01-19 08:45:49Z wangleisvn $ -->
- {include file="pageheader.htm"}
- <script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
- <link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
- {insert_scripts files="validator.js,../js/transport.js,../js/utils.js}
- <div class="main-div">
- <form method="post" action="seckill_goods.php" name="theForm" enctype="multipart/form-data" onSubmit="return validate()">
- <table cellspacing="1" cellpadding="3" width="100%">
- <tr>
- <td class="label">{$lang.label_act_name}</td>
- <td><input name="act_name" type="text" id="act_name" value="{$seckill.act_name}" maxlength="60" />
- {$lang.notice_act_name}</td>
- </tr>
- <tr>
- <td class="label">{$lang.label_act_desc}</td>
- <td><textarea name="act_desc" cols="60" rows="4" id="act_desc">{$seckill.act_desc}</textarea></td>
- </tr>
- <tr>
- <td align="right">{$lang.label_search_goods}</td>
- <td><input name="keyword" type="text" id="keyword">
- <input name="search" type="button" id="search" value="{$lang.button_search}" class="button" onclick="searchGoods()" /></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_goods_name}</td>
- <td><select name="goods_id" id="goods_id" onchange="javascript:change_good_products();">
- <option value="{$seckill.goods_id}" selected="selected">{$seckill.goods_name}</option>
- </select>
- <select name="product_id" {if $auction.product_id <= 0}style="display:none"{/if}>
- {html_options options=$good_products_select selected=$auction.product_id}
- </select></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_start_time}</td>
- <td><input name="start_time" type="text" id="start_time" value="{$seckill.start_time}" readonly="readonly" />
- <input name="selbtn1" type="button" id="selbtn1" onclick="return showCalendar('start_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn1');" value="{$lang.btn_select}" class="button" /></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_end_time}</td>
- <td><input name="end_time" type="text" id="end_time" value="{$seckill.end_time}" readonly="readonly" />
- <input name="selbtn2" type="button" id="selbtn2" onclick="return showCalendar('end_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn2');" value="{$lang.btn_select}" class="button" /></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_start_price}</td>
- <td><input name="start_price" type="text" id="start_price" value=""></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_goods_num}</td>
- <td><input name="seckill_num" type="text" id="seckill_num" value=""></td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- {if $seckill.act_id eq 0 or $seckill.status_no eq "0" or $auction.status_no eq "1"}
- <input type="submit" class="button" value="{$lang.button_submit}" />
- <input type="reset" class="button" value="{$lang.button_reset}" />
- <input type="hidden" name="act" value="{$form_action}" />
- {elseif $seckill.status_no eq "2"}
- {$lang.settle_frozen_money}
- <input type="submit" class="button" value="{$lang.unfreeze}" name="unfreeze" />
- <input type="submit" class="button" value="{$lang.deduct}" name="deduct" />
- <input type="hidden" name="act" value="settle_money" />
- {/if}
- <input type="hidden" name="id" value="{$seckill.act_id}" /></td>
- </tr>
- </table>
- </form>
- </div>
- {literal}
- <script language="JavaScript">
- <!--
- var display_yes = (Browser.isIE) ? 'block' : 'table-row-group';
- onload = function()
- {
- // 开始检查订单
- startCheckOrder();
- }
- /**
- * 检查表单输入的数据
- */
- function validate()
- {
- validator = new Validator("theForm");
- validator.isNumber('start_price', start_price_not_number, false);
- validator.isNumber('end_price', end_price_not_number, false);
- if (document.forms['theForm'].elements['no_top'].checked == false)
- {
- validator.gt('end_price', 'start_price', end_gt_start);
- }
- validator.isNumber('amplitude', amplitude_not_number, false);
- validator.isNumber('deposit', deposit_not_number, false);
- validator.islt('start_time', 'end_time', start_lt_end);
- return validator.passed();
- }
- function checked_no_top(o)
- {
- if (o.checked)
- {
- o.form.elements['end_price'].value = '';
- o.form.elements['end_price'].disabled = true;
- }
- else
- {
- o.form.elements['end_price'].disabled = false;
- }
- }
- function searchGoods()
- {
- var filter = new Object;
- filter.keyword = document.forms['theForm'].elements['keyword'].value;
- Ajax.call('auction.php?is_ajax=1&act=search_goods', filter, searchGoodsResponse, 'GET', 'JSON');
- }
- function searchGoodsResponse(result)
- {
- if (result.error == '1' && result.message != '')
- {
- alert(result.message);
- return;
- }
- var frm = document.forms['theForm'];
- var sel = frm.elements['goods_id'];
- var sp = frm.elements['product_id'];
- if (result.error == 0)
- {
- /* 清除 options */
- sel.length = 0;
- sp.length = 0;
- /* 创建 options */
- var goods = result.content.goods;
- if (goods)
- {
- for (i = 0; i < goods.length; i++)
- {
- var opt = document.createElement("OPTION");
- opt.value = goods[i].goods_id;
- opt.text = goods[i].goods_name;
- sel.options.add(opt);
- }
- }
- else
- {
- var opt = document.createElement("OPTION");
- opt.value = 0;
- opt.text = search_is_null;
- sel.options.add(opt);
- }
- /* 创建 product options */
- var products = result.content.products;
- if (products)
- {
- sp.style.display = display_yes;
- for (i = 0; i < products.length; i++)
- {
- var p_opt = document.createElement("OPTION");
- p_opt.value = products[i].product_id;
- p_opt.text = products[i].goods_attr_str;
- sp.options.add(p_opt);
- }
- }
- else
- {
- sp.style.display = 'none';
- var p_opt = document.createElement("OPTION");
- p_opt.value = 0;
- p_opt.text = search_is_null;
- sp.options.add(p_opt);
- }
- }
- return;
- }
- function change_good_products()
- {
- var filter = new Object;
- filter.goods_id = document.forms['theForm'].elements['goods_id'].value;
- Ajax.call('snatch.php?is_ajax=1&act=search_products', filter, searchProductsResponse, 'GET', 'JSON');
- }
- function searchProductsResponse(result)
- {
- var frm = document.forms['theForm'];
- var sp = frm.elements['product_id'];
- if (result.error == 0)
- {
- /* 清除 options */
- sp.length = 0;
- /* 创建 product options */
- var products = result.content.products;
- if (products.length)
- {
- sp.style.display = display_yes;
- for (i = 0; i < products.length; i++)
- {
- var p_opt = document.createElement("OPTION");
- p_opt.value = products[i].product_id;
- p_opt.text = products[i].goods_attr_str;
- sp.options.add(p_opt);
- }
- }
- else
- {
- sp.style.display = 'none';
- var p_opt = document.createElement("OPTION");
- p_opt.value = 0;
- p_opt.text = search_is_null;
- sp.options.add(p_opt);
- }
- }
- if (result.message.length > 0)
- {
- alert(result.message);
- }
- }
- //-->
- </script>
- {/literal}
- {include file="pagefooter.htm"}
2.seckill_goods_info.php代码如下:
- <!-- $Id: auction_info.htm 16992 2010-01-19 08:45:49Z wangleisvn $ -->
- {include file="pageheader.htm"}
- <script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
- <link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
- {insert_scripts files="validator.js,../js/transport.js,../js/utils.js}
- <div class="main-div">
- <form method="post" action="seckill_goods.php" name="theForm" enctype="multipart/form-data" onSubmit="return validate()">
- <table cellspacing="1" cellpadding="3" width="100%">
- <tr>
- <td class="label">{$lang.label_act_name}</td>
- <td><input name="act_name" type="text" id="act_name" value="{$seckill.act_name}" maxlength="60" />
- {$lang.notice_act_name}</td>
- </tr>
- <tr>
- <td class="label">{$lang.label_act_desc}</td>
- <td><textarea name="act_desc" cols="60" rows="4" id="act_desc">{$seckill.act_desc}</textarea></td>
- </tr>
- <tr>
- <td align="right">{$lang.label_search_goods}</td>
- <td><input name="keyword" type="text" id="keyword">
- <input name="search" type="button" id="search" value="{$lang.button_search}" class="button" onclick="searchGoods()" /></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_goods_name}</td>
- <td><select name="goods_id" id="goods_id" onchange="javascript:change_good_products();">
- <option value="{$seckill.goods_id}" selected="selected">{$seckill.goods_name}</option>
- </select>
- <select name="product_id" {if $auction.product_id <= 0}style="display:none"{/if}>
- {html_options options=$good_products_select selected=$auction.product_id}
- </select></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_start_time}</td>
- <td><input name="start_time" type="text" id="start_time" value="{$seckill.start_time}" readonly="readonly" />
- <input name="selbtn1" type="button" id="selbtn1" onclick="return showCalendar('start_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn1');" value="{$lang.btn_select}" class="button" /></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_end_time}</td>
- <td><input name="end_time" type="text" id="end_time" value="{$seckill.end_time}" readonly="readonly" />
- <input name="selbtn2" type="button" id="selbtn2" onclick="return showCalendar('end_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn2');" value="{$lang.btn_select}" class="button" /></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_start_price}</td>
- <td><input name="start_price" type="text" id="start_price" value=""></td>
- </tr>
- <tr>
- <td class="label">{$lang.label_goods_num}</td>
- <td><input name="seckill_num" type="text" id="seckill_num" value=""></td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- {if $seckill.act_id eq 0 or $seckill.status_no eq "0" or $auction.status_no eq "1"}
- <input type="submit" class="button" value="{$lang.button_submit}" />
- <input type="reset" class="button" value="{$lang.button_reset}" />
- <input type="hidden" name="act" value="{$form_action}" />
- {elseif $seckill.status_no eq "2"}
- {$lang.settle_frozen_money}
- <input type="submit" class="button" value="{$lang.unfreeze}" name="unfreeze" />
- <input type="submit" class="button" value="{$lang.deduct}" name="deduct" />
- <input type="hidden" name="act" value="settle_money" />
- {/if}
- <input type="hidden" name="id" value="{$seckill.act_id}" /></td>
- </tr>
- </table>
- </form>
- </div>
- {literal}
- <script language="JavaScript">
- <!--
- var display_yes = (Browser.isIE) ? 'block' : 'table-row-group';
- onload = function()
- {
- // 开始检查订单
- startCheckOrder();
- }
- /**
- * 检查表单输入的数据
- */
- function validate()
- {
- validator = new Validator("theForm");
- validator.isNumber('start_price', start_price_not_number, false);
- validator.isNumber('end_price', end_price_not_number, false);
- if (document.forms['theForm'].elements['no_top'].checked == false)
- {
- validator.gt('end_price', 'start_price', end_gt_start);
- }
- validator.isNumber('amplitude', amplitude_not_number, false);
- validator.isNumber('deposit', deposit_not_number, false);
- validator.islt('start_time', 'end_time', start_lt_end);
- return validator.passed();
- }
- function checked_no_top(o)
- {
- if (o.checked)
- {
- o.form.elements['end_price'].value = '';
- o.form.elements['end_price'].disabled = true;
- }
- else
- {
- o.form.elements['end_price'].disabled = false;
- }
- }
- function searchGoods()
- {
- var filter = new Object;
- filter.keyword = document.forms['theForm'].elements['keyword'].value;
- Ajax.call('auction.php?is_ajax=1&act=search_goods', filter, searchGoodsResponse, 'GET', 'JSON');
- }
- function searchGoodsResponse(result)
- {
- if (result.error == '1' && result.message != '')
- {
- alert(result.message);
- return;
- }
- var frm = document.forms['theForm'];
- var sel = frm.elements['goods_id'];
- var sp = frm.elements['product_id'];
- if (result.error == 0)
- {
- /* 清除 options */
- sel.length = 0;
- sp.length = 0;
- /* 创建 options */
- var goods = result.content.goods;
- if (goods)
- {
- for (i = 0; i < goods.length; i++)
- {
- var opt = document.createElement("OPTION");
- opt.value = goods[i].goods_id;
- opt.text = goods[i].goods_name;
- sel.options.add(opt);
- }
- }
- else
- {
- var opt = document.createElement("OPTION");
- opt.value = 0;
- opt.text = search_is_null;
- sel.options.add(opt);
- }
- /* 创建 product options */
- var products = result.content.products;
- if (products)
- {
- sp.style.display = display_yes;
- for (i = 0; i < products.length; i++)
- {
- var p_opt = document.createElement("OPTION");
- p_opt.value = products[i].product_id;
- p_opt.text = products[i].goods_attr_str;
- sp.options.add(p_opt);
- }
- }
- else
- {
- sp.style.display = 'none';
- var p_opt = document.createElement("OPTION");
- p_opt.value = 0;
- p_opt.text = search_is_null;
- sp.options.add(p_opt);
- }
- }
- return;
- }
- function change_good_products()
- {
- var filter = new Object;
- filter.goods_id = document.forms['theForm'].elements['goods_id'].value;
- Ajax.call('snatch.php?is_ajax=1&act=search_products', filter, searchProductsResponse, 'GET', 'JSON');
- }
- function searchProductsResponse(result)
- {
- var frm = document.forms['theForm'];
- var sp = frm.elements['product_id'];
- if (result.error == 0)
- {
- /* 清除 options */
- sp.length = 0;
- /* 创建 product options */
- var products = result.content.products;
- if (products.length)
- {
- sp.style.display = display_yes;
- for (i = 0; i < products.length; i++)
- {
- var p_opt = document.createElement("OPTION");
- p_opt.value = products[i].product_id;
- p_opt.text = products[i].goods_attr_str;
- sp.options.add(p_opt);
- }
- }
- else
- {
- sp.style.display = 'none';
- var p_opt = document.createElement("OPTION");
- p_opt.value = 0;
- p_opt.text = search_is_null;
- sp.options.add(p_opt);
- }
- }
- if (result.message.length > 0)
- {
- alert(result.message);
- }
- }
- //-->
- </script>
- {/literal}
- {include file="pagefooter.htm"}
7.在这里后台秒杀正式完成
显示结果:
ecshop二次开发之后台秒杀的更多相关文章
- EcShop二次开发系列教程–总纲
EcShop作为老牌的B2C独立网店系统,功能非常全名,强大的文件.数据库缓存机制,保证前后台系统执行速度更快.系统平稳运行.但是过多的功能也或多或少的会影响到系统的整个效率,所有在使用EcShop搭 ...
- ecshop二次开发 给商品添加自定义字段
说起自定义字段,我想很多的朋友像我一样会想起一些开源的CMS(比如Dedecms.Phpcms.帝国)等,他们是可以在后台直接添加自定义字段的. 抱着这种想法我在Ecshop的后台一顿找,不过肿么都木 ...
- Ecshop二次开发必备基础
EcShop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的PHP开源产品.B2C方面有Ecshop ...
- EcShop二次开发学习方法和Ecshop二次开发必备基础
ecshop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的php开源产品.B2C方面有Ecshop ...
- ECShop二次开发指南(一)
ECSHOP是一套完整的网络商店解决方案,包括前台的商品展示.购物流程和强大易用的后台管理.由于 ecshop简单易用,使用者几乎可以在3几分钟简单的设置一下就可以拥有一个网上商店系统,所以很多的B2 ...
- EcShop二次开发学习方法
EcShop二次开发学习方法 (2012-03-08 11:10:08) 转载▼ 标签: 京东 公用函数库 二次开发 sql语言 数据库设计 杂谈 分类: ecshop 近年来,随着互联网的发展,电子 ...
- ECSHOP二次开发指南
ECSHOP二次开发指南 发布时间:2013-05-28 12:47:00 来源: 评论:0 点击: 次 [字号:大 中 小] QQ空间新浪微博腾讯微博人人网豆瓣网百度空间百度搜藏开心网复制更 ...
- ecshop二次开发之购物车常见问题
1.ecshop二次开发中保存注册用户购物车数据解决方法:ecshop购物车是数据库中cart表来支持的,在ecshop表中rec_id是编号,user_id是注册用户的id,session_id表示 ...
- ecshop二次开发秒杀、限时折扣、清仓等功能
限时抢购,秒杀商品的二次开发 1,先在后台admin/templates 中找goods_info.htm文件到促销部分,改为一个下拉列表的分别是促销,限时,秒杀,值分别是1,2,3这样,代码如下: ...
随机推荐
- 关于obj文件的理解
编译器先编译.cpp为obj文件,看看文件内有没有冲突,然后再进行链接,链接头文件引入的lib库等等,然后就生成exe文件了,下面这个图说的很好:
- 新增的Java MapReduce API
http://book.51cto.com/art/201106/269647.htm Hadoop的版本0.20.0包含有一个新的 Java MapReduce API,有时也称为"上下文 ...
- JS播放视频代码
<div class="col-md-8"> <div id="moviecontainer"></div> </di ...
- [转]js模块化(一)
java有类文件.Python有import关键词.Ruby有require关键词.C#有using关键词.PHP有include和require.CSS有@import关键词,但是对ES5版本的ja ...
- c语言学习笔记 - 顺序查找和哨兵查找比较
今天学习C时用到了顺序查找和哨兵查找,做了一个比较,主要是学习下哨兵查找法 例如在一个数组里查找一个元素,没找到返回-1,找到了则返回这个数组的下标也就是键值. 用循序查找法: void arr_se ...
- Maven实战错误笔记:使用mvn archetype:generate报错:Unable to add module to the current project as it is not of packaging type 'pom'
在使用mvn archetype:generate生成Maven实战03:HelloWorld中的HelloWorld的项目骨架时报了这个错,从字面上分析是可能与pom.xml文件有关,然后我看了一下 ...
- wsgi Python的WEB框架
Bottle是一个快速.简洁.轻量级的基于WSIG的微型Web框架,此框架只由一个 .py 文件,除了Python的标准库外,其不依赖任何其他模块. pip install bottle easy_i ...
- 图像Ping技术
在CORS出现以前,要实现跨域Ajax通信颇费一些周折.开发人员想出了一些办法,利用DOM中能够执行跨域清求的功能,在不依赖XHR对象的情况下也能发送某种请求.虽然CORS技术已经无处不在,但开发人员 ...
- scanf("%c", &ch)和scanf(" %c", &ch)和scanf("%s", str)的注意事项
scanf("%c", &ch)和scanf(" %c", &ch): %c会读取回车和空格,所以一定要使用后者,即在%c前面加一个空格. %s ...
- Java问题解读系列之基础相关---含继承时的执行顺序
今天来研究一下含继承.静态成员.非静态成员时Java程序的执行顺序: 一.不含继承,含有静态变量.静态代码块 创建一个子类,该类包含静态变量.静态代码块.静态方法.构造方法 /** * @create ...