ecshop会员注册推荐送现金二次开发

ecshop中的会员注册和推荐推广功能还不是很完善,随着电子商务系统的发展和进步,越来越多的推广需求需要ecshop做的更灵活,这就造成了很大必要的对ecshop推广系统进行处理和重新开发。
第一步:打开模板里的user_clips.dwt文件,增加以下代码。用来显示推荐的会员列表
         <!-- {if $action eq 'list_fuwu'} -->
          <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
           <tr align="center">
            <td bgcolor="#ffffff">会员ID</td>
            <td bgcolor="#ffffff">会员名称</td>
            <td bgcolor="#ffffff">注册时间</td>
           </tr>
           <!-- {foreach from=$my_comments key=level item=val name=affdb} -->
           <tr align="center">
            <td bgcolor="#ffffff">{$val.user_id}</td>
            <td bgcolor="#ffffff">{$val.user_name}</td>
            <td bgcolor="#ffffff">{$val.reg_time}</td>
           </tr>
           <!-- {/foreach} -->
          </table>
          <!-- #BeginLibraryItem "/library/pages.lbi" --><!-- #EndLibraryItem -->
         <!-- {/if} -->
         <!-- #显示推荐的会员列表 by www.ecshop.cx end-->
第二步:打开根目录里的user.php文件,增加以下代码。用来显示推荐的会员列表和计算金额
/* 推荐的会员列表 by www.ecshop.cx */
elseif ($action == 'list_fuwu')
{
    $rankid = intval($_REQUEST['rank_id']);
    $parent_id = intval($_REQUEST['parent_id']);
    if ($parent_id && $rankid)
    {
        function get_comments($num, $start, $pid, $uk)
        {
            global $ecs;
            global $db;
            $res = $db->getAll("SELECT * FROM " . $ecs->table('users') . " WHERE parent_id = ".$pid." AND uk = ".$uk . " LIMIT $start, $num");
            return $res;
        }
        $sql = "SELECT COUNT(*) FROM ".$ecs->table('users')." WHERE parent_id = '$parent_id' AND uk = '$rankid'";
        $record_count = $GLOBALS['db']->getOne($sql);
        $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
        $pager = get_pager("user.php?act=list_fuwu&parent_id=$parent_id&rank_id=$rankid", array(), $record_count, $page, 10);
        $msg_lists = get_comments(10, $pager['start'], $parent_id, $rankid);
        if ($msg_lists)
        {
            foreach($msg_lists as $k => $v)
            {
                $msg_lists[$k][reg_time] = date("Y-m-d", $v[reg_time]);
            }
        }
        $GLOBALS['smarty']->assign('rand',        mt_rand());
        $GLOBALS['smarty']->assign('pager',       $pager);
        $GLOBALS['smarty']->assign('my_comments', $msg_lists);
        $smarty->display('user_clips.dwt');
    }
}
/* 计算推荐送现金 by www.ecshop.cx */
elseif ($action == 'fuwu')
{
    //统计推荐
    $result = array(); //推荐会员返回统计信息
    $re = $db -> getAll("SELECT rank_id, rank_name FROM ".$ecs->table('user_rank')." ORDER BY rank_id ASC");
    if ($re)
    {
        foreach ($re as $k => $v)
        {
            if ($v['rank_name'])
            {
                $n = $v['rank_name'];
                $result[$n]['money'] = 0;
                //取得会员数量
                $con = $db -> getOne("SELECT count(*) c FROM ".$ecs->table('users')." WHERE user_rank = ".$v[rank_id]." AND parent_id =".$_SESSION['user_id']." AND user_rank = uk");
                //统计金额
                //$string = '推荐'..'注册提成'
                $ua = $db -> getAll("SELECT user_name FROM ".$ecs->table('users')." WHERE user_rank = ".$v[rank_id]." AND parent_id =".$_SESSION['user_id']." AND user_rank = uk");
                if ($ua)
                {
                    foreach ($ua as $k => $v)
                    {
                        $string = '推荐'.$v[user_name].'注册提成';
                        $money = $db -> getOne("SELECT user_money FROM ".$ecs->table('account_log')." WHERE change_desc = '$string'");
                        $result[$n]['money'] += $money; //计算推荐金额
                    }
                }
                $result[$n]['num'] = $con;
                $result[$n]['rank_id'] = $v['rank_id'];
            }
        }
    }
    //格式化金额
    if ($result)
    {
        foreach ($result as $k => $v)
        {
            $result[$k]['money'] = price_format($v['money'], false);
        }
    }
    $smarty ->assign('affdb',   $result);
    $smarty->assign('shopname', $_CFG['shop_name']);
    $smarty->assign('userid',   $user_id);
    $smarty->assign('shopurl',  $ecs->url());
    $smarty->assign('logosrc',  'themes/' . $_CFG['template'] . '/images/logo.gif');
    $smarty->display('user_clips.dwt');
}
第三步:打开/admin/affliliate.php文件,找到 if ($_REQUEST['act'] == 'list') 代码里面增加以下代码
    $re = $db -> getAll("SELECT * FROM ".$ecs->table('user_rank')." ORDER BY rank_id");
    $smarty -> assign('rank', $re);
继续找到 elseif ($_REQUEST['act'] == 'updata') 代码里面增加以下代码
    if ($_POST['rank'])
    {
        $ar = array_combine($_POST['rn'], $_POST['rank']);
        if ($ar)
        {
            foreach ($ar as $k => $v)
            {
                $sql = " UPDATE ".$ecs->table('user_rank')." SET qian = ".$v." WHERE rank_id = $k";
                $db -> query($sql);
            }
        }
    }
第四步:打开/admin/templates/affliate.htm文件,中增加以下代码
                <tr>
                    <td align="right" class="label">推荐会员送现金:</td>
                    <td>
                    {foreach from = $rank item = item}
                    {$item.rank_name}:<input type="text" name="rank[]" value="{$item.qian}" size="3">
                    <input type="hidden" name="rn[]" value="{$item.rank_id}">
                    {/foreach}
                    </td>
                </tr>
第五步:打开/themes/default/user_clips.dwt,中增加以下代码,用来列表推荐信息
         <!-- #显示推荐的会员列表 by www.ecshop.cx start-->
         <!-- {if $action eq 'list_fuwu'} -->
          <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
           <tr align="center">
            <td bgcolor="#ffffff">会员ID</td>
            <td bgcolor="#ffffff">会员名称</td>
            <td bgcolor="#ffffff">注册时间</td>
           </tr>
           <!-- {foreach from=$my_comments key=level item=val name=affdb} -->
           <tr align="center">
            <td bgcolor="#ffffff">{$val.user_id}</td>
            <td bgcolor="#ffffff">{$val.user_name}</td>
            <td bgcolor="#ffffff">{$val.reg_time}</td>
           </tr>
           <!-- {/foreach} -->
          </table>
          <!-- #BeginLibraryItem "/library/pages.lbi" --><!-- #EndLibraryItem -->
         <!-- {/if} -->
         <!-- #显示推荐的会员列表 by www.ecshop.cx end-->

本文原创地址:https://www.ecshop.cx/article-347.html
版权所有 © 转载时必须以链接形式注明出处!

觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。

实时购买动态 ×

匿名网友 在 2019-10-14 购买了 ECSHOP阿里云存储Kindeditor编辑器插件【实现kindeditor文件图片上传到阿里云oss】

';