ecshop开发中首次登陆增加会员积分

首先说一下需求,需求如下:


接下来说一下整体的思路:

我们应该认识到,积分是买家的,所以积分增加其实就是在前台登录的时候才会有效。而商家是管理后台的,所以后台只是展示一下前台用户登录后的信息。

我在这里说两种简单的方法,memcache和查询数据库。

后台添加会员积分栏目——>后台会员积分模板展示——>在前台登录的时候判断时间——>后台增加积分

其实难点也就是第三步,判断登录时间。

1>后台添加会员积分栏目

打开ecshop/upload/languages/zh_cn/common.php,在里面增加会员积分

打开echop/upload/admin/incluces/inc_,enu.php,在里面加积分页面

2>后台会员积分展示

可以自己写样式,如果觉得麻烦,可以直接复制users_list.html页面,改里面的用户列表部分就可以了

user_integral.html

{if $full_page}
<!-- $Id: users_list.htm 17053 2010-03-15 06:50:26Z sxc_shop $ -->
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}



    <!-- start users list -->
    <div class="list-div" id="listDiv">
        {/if}
        <!--用户列表部分-->
        <table cellpadding="3" cellspacing="1">
            <tr>
                <th>
                    <input οnclick='listTable.selectAll(this, "checkboxes")' type="checkbox">
                    <a href="javascript:listTable.sort('user_id'); ">{$lang.record_id}</a>{$sort_user_id}
                </th>
                <th>会员名称</th>
                <th>邮件地址</th>
                <th>注册日期</th>
                <th>会员积分</th>
            <tr>
                {foreach from=$user_list item=user}
            <tr>
                <td><input type="checkbox" name="checkboxes[]" value="{$user.user_id}" notice="{if $user.user_money ne 0}1{else}0{/if}"/>{$user.user_id}</td>
                <td class="first-cell">{$user.user_name|escape}</td>
                <td align="center">{$user.email}</td>
                <td align="center">{$user.reg_time}</td>
                <td align="center">{$user.user_integral}</td>
            </tr>
            {foreachelse}
            <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
            {/foreach}
            <tr>
                <td colspan="2">
                    <input type="hidden" name="act" value="batch_remove" />
                    <input type="submit" id="btnSubmit" value="{$lang.button_remove}" disabled="true" class="button" /></td>
                <td align="right" nowrap="true" colspan="8">
                    {include file="page.htm"}
                </td>
            </tr>
        </table>

        {if $full_page}
    </div>
    <!-- end users list -->

{/literal}
{include file="pagefooter.htm"}
{/if}
user_intergral.php

<?php

/**
 * ECSHOP 会员管理程序
 * ============================================================================
 * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
 * 网站地址: http://www.ecshop.com;
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用;不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: liubo $
 * $Id: users.php 17217 2011-01-19 06:29:08Z liubo $
 */

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

/*------------------------------------------------------ */
//-- 用户帐号列表
/*------------------------------------------------------ */

if ($_REQUEST['act'] == 'list')
{
    /* 检查权限 */
    admin_priv('users_manage');
    $sql = "SELECT rank_id, rank_name, min_points FROM ".$ecs->table('user_rank')." ORDER BY min_points ASC ";
    $rs = $db->query($sql);

    $ranks = array();
    while ($row = $db->FetchRow($rs))
    {
        $ranks[$row['rank_id']] = $row['rank_name'];
    }

    $smarty->assign('user_ranks',   $ranks);
    $smarty->assign('ur_here',      $_LANG['03_users_list']);
    $smarty->assign('action_link',  array('text' => $_LANG['04_users_add'], 'href'=>'users.php?act=add'));

    $user_list = user_list();

    $smarty->assign('user_list',    $user_list['user_list']);
    $smarty->assign('filter',       $user_list['filter']);
    $smarty->assign('record_count', $user_list['record_count']);
    $smarty->assign('page_count',   $user_list['page_count']);
    $smarty->assign('full_page',    1);
    $smarty->assign('sort_user_id', '<img src="images/sort_desc.gif">');

    assign_query_info();
    $smarty->display('user_integral.htm');
}
function user_list()
{
    $result = get_filter();
    if ($result === false)
    {
        /* 过滤条件 */
        $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1)
        {
            $filter['keywords'] = json_str_iconv($filter['keywords']);
        }
        $filter['rank'] = empty($_REQUEST['rank']) ? 0 : intval($_REQUEST['rank']);
        $filter['pay_points_gt'] = empty($_REQUEST['pay_points_gt']) ? 0 : intval($_REQUEST['pay_points_gt']);
        $filter['pay_points_lt'] = empty($_REQUEST['pay_points_lt']) ? 0 : intval($_REQUEST['pay_points_lt']);

        $filter['sort_by']    = empty($_REQUEST['sort_by'])    ? 'user_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC'     : trim($_REQUEST['sort_order']);

        $ex_where = ' WHERE 1 ';
        if ($filter['keywords'])
        {
            $ex_where .= " AND user_name LIKE '%" . mysql_like_quote($filter['keywords']) ."%'";
        }
        if ($filter['rank'])
        {
            $sql = "SELECT min_points, max_points, special_rank FROM ".$GLOBALS['ecs']->table('user_rank')." WHERE rank_id = '$filter[rank]'";
            $row = $GLOBALS['db']->getRow($sql);
            if ($row['special_rank'] > 0)
            {
                /* 特殊等级 */
                $ex_where .= " AND user_rank = '$filter[rank]' ";
            }
            else
            {
                $ex_where .= " AND rank_points >= " . intval($row['min_points']) . " AND rank_points < " . intval($row['max_points']);
            }
        }
        if ($filter['pay_points_gt'])
        {
            $ex_where .=" AND pay_points >= '$filter[pay_points_gt]' ";
        }
        if ($filter['pay_points_lt'])
        {
            $ex_where .=" AND pay_points < '$filter[pay_points_lt]' ";
        }

        $filter['record_count'] = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('users') . $ex_where);

        /* 分页大小 */
        $filter = page_and_size($filter);
        $sql = "SELECT user_id, user_name, email,  reg_time ,user_integral".
            " FROM " . $GLOBALS['ecs']->table('users') . $ex_where .
            " ORDER by " . $filter['sort_by'] . ' ' . $filter['sort_order'] .
            " LIMIT " . $filter['start'] . ',' . $filter['page_size'];

        $filter['keywords'] = stripslashes($filter['keywords']);
        set_filter($filter, $sql);
    }
    else
    {
        $sql    = $result['sql'];
        $filter = $result['filter'];
    }

    $user_list = $GLOBALS['db']->getAll($sql);

    $count = count($user_list);
    for ($i=0; $i<$count; $i++)
    {
        $user_list[$i]['reg_time'] = local_date($GLOBALS['_CFG']['date_format'], $user_list[$i]['reg_time']);
    }

    $arr = array('user_list' => $user_list, 'filter' => $filter,
        'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);

    return $arr;
}
3>前台登录判断时间

在前台登录,打开firebug,先清除内容,然后点全部,保持。在登录的时候会显示出请求的处理页面,在里面找到请求方式,看请求的是哪个方法


在ecshop/upload/user.php中全文检索act_login方法,找到处理登录的act_login方法。

数据库添字段 today_time

memcache方法如下


直接查库方法如下:


 以上就是今天的简单分享!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值