ecshop注册推荐送现金插件开发

2016-09-07 22:02 来源:www.chinab4c.com 作者:ecshop专家

ecshop注册推荐送现金插件开发,chinab4c提供该ecshop插件教程

1:模板user_clips.dwt增加以下代码。用来显示推荐的会员列表
{if $action=='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}
2:user.php中增加以下代码
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;
      $sql ="  select  * from ".$ecs->table('users')." where parent_id = '$pid' and uk = '$uk' limit $start, $num";
     
     $res = $db->getAll($sql);
    
     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');
}
}
3:user.php中增以下代码。用来计算服务费用
// 服务费用
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');
}
4:admin/affliliate.php中的list中增加以下代码
//##################
//推荐VIP会员送现金
//##################
$re = $db -> getAll("select * from ".$ecs->table('user_rank')." order by rank_id");
$smarty -> assign('rank',$re);
//##################
//推荐VIP会员送现金
//##################
 
5:admin/affliliate.php中的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);
   }
  }
  
}
5:affliate.htm中增加以下代码
<tr>
                    <td align="right" class="label">推荐VIP会员送现金:</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>
6:user_clips.dwt中增加以下代码。用来列表推荐信息
<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
    <tr align="center">
      <td bgcolor="#ffffff">{$lang.affiliate_lever}</td>
      <td bgcolor="#ffffff">{$lang.affiliate_num}</td>
      
      <td bgcolor="#ffffff">提成金额</td>
    </tr>
    <!-- {foreach from=$affdb1 key=level item=val name=affdb} -->
    <tr align="center">
      <td bgcolor="#ffffff">{$level}</td>
      <td bgcolor="#ffffff"><a href="?act=list_fuwu&parent_id={$smarty.session.user_id}&rank_id={$val.rank_id}">{$val.num}</a></td>
      
      <td bgcolor="#ffffff">{$val.money}</td>
    </tr>
    <!-- {/foreach} -->
  </table>
完毕!
(责任编辑:chinab4c)