ecshop二次开发秒杀、限时折扣、清仓等功能

转载 2015年07月07日 13:50:55

ecshop二次开发秒杀、限时折扣、清仓等功能

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

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.进入admin->includes->inc_menu.php中此文件为定义左侧功能模块超链接 2.添加include/inc_menu.php秒...
  • haoyunyun888
  • haoyunyun888
  • 2016年05月11日 20:04
  • 10056

ecshop二次开发--前台秒杀

1.进入后台系统管理-》自定义导航栏-》添加一个秒杀活动 2.点击秒杀活动 3. 4.生成订单 ...
  • haoyunyun888
  • haoyunyun888
  • 2016年05月14日 10:05
  • 3182

限时抢购秒杀系统架构分析与实战

转发:http://www.jb51.net/article/77560.htm 1 秒杀业务分析 正常电子商务流程 (1)查询商品;(2)创建订单;(3)扣减库存;(4)更新订...
  • evan_shc
  • evan_shc
  • 2016年02月03日 15:38
  • 2724

ecshop 中添加限时抢购功能(倒计时)

第一步:在后台admin/templates/goods_info.htm中找到大概165行修改
  • u010987803
  • u010987803
  • 2014年04月29日 13:33
  • 1436

限时抢购团购倒计时活动完整js代码

团购——限时抢 div,img{ margin:0; padding:0; border:0; } .content3{ background:url(http://im...
  • sinat_21206105
  • sinat_21206105
  • 2016年09月13日 15:10
  • 4815

ecshop二次开发秒杀

1.进入后台系统管理-》自定义导航栏-》添加一个秒杀活动 2.点击秒杀活动 3. ...
  • caozaifei
  • caozaifei
  • 2016年09月17日 09:31
  • 144

电商网站秒杀活动

秒杀活动通常是这样定义:活动方在有限的时间段内(通常是M分钟到H小时不等的时间)给出指定数量O个P商品的大减价抢购名额。 这类秒杀活动一般都会出现如下情况↓↓   第一、在某一时间内QPS超过系...
  • qq_34341290
  • qq_34341290
  • 2017年05月09日 10:08
  • 289

jquery插件之倒计时-团购秒杀

1.1 帮助文档关键字     倒计时 秒杀 timer 1.2.  使用场景                             这样的倒计时在购物网站中会经常使用到,比...
  • u010779348
  • u010779348
  • 2016年08月10日 15:25
  • 212

商品秒杀倒计时功能+ViewPager实现画廊效果

模式一:列表形式展示数据,倒计时完成移除此条数据效果: 涉及到的技术:RecyclerView、CardView、Fresco、CountDownTimer等,可以到本博客去查找// 倒计时...
  • Konfyt_Android
  • Konfyt_Android
  • 2016年10月21日 13:30
  • 770

Android 定时器+倒计时 仿淘宝秒杀

目录结构 imageViewHolder  public class imageViewHolder extends RecyclerView.ViewHolder { public ...
  • u010566681
  • u010566681
  • 2017年01月04日 15:15
  • 1117
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:ecshop二次开发秒杀、限时折扣、清仓等功能
举报原因:
原因补充:

(最多只允许输入30个字)