修改68ecshop 个人中心 分销不显示问题 user.php user_affiliate.lbi

mobile/user.php  红色代表添加的内容

// 用户推荐页面
function action_affiliate()
{
//全局变量
$user = $GLOBALS[‘user’];
$_CFG = $GLOBALS[‘_CFG’];
$_LANG = $GLOBALS[‘_LANG’];
$smarty = $GLOBALS[‘smarty’];
$db = $GLOBALS[‘db’];
$ecs = $GLOBALS[‘ecs’];
$user_id = $_SESSION[‘user_id’];
$affiliate=unserialize($GLOBALS[‘_CFG’][‘affiliate’]);

$goodsid = intval(isset($_REQUEST[‘goodsid’]) ? $_REQUEST[‘goodsid’] : 0);
if(empty($goodsid))
{
// 我的推荐页面

$page = ! empty($_REQUEST[‘page’]) && intval($_REQUEST[‘page’]) > 0 ? intval($_REQUEST[‘page’]) : 1;
$size = ! empty($_CFG[‘page_size’]) && intval($_CFG[‘page_size’]) > 0 ? intval($_CFG[‘page_size’]) : 10;

empty($affiliate) && $affiliate = array();

if(empty($affiliate[‘config’][‘separate_by’]))
{
// 推荐注册分成
$affdb = array();
$num = count($affiliate[‘item’]);

$up_uid = “‘$user_id'”;
$all_uid = “‘$user_id'”;

$user_array=array();
$fenxiao_title = array(‘0′ =>’一级用户’,’1′ =>’二级用户’,’2′ =>’三级用户’,’3′ =>’四级用户’,’4′ =>’五级用户’);
$smarty->assign(‘fenxiao_title’, $fenxiao_title);
for($i = 1; $i <= $num; $i ++)
{
$count = 0;
if($up_uid)
{
$sql = “SELECT user_id,user_name FROM ” . $ecs->table(‘users’) . ” WHERE parent_id IN($up_uid)”;
$query = $db->query($sql);
$up_uid = ”;
$aid=0;
while($rt = $db->fetch_array($query))
{
$user_array[$i-1][$aid][‘user_id’]=$rt[‘user_id’];
$user_array[$i-1][$aid][‘user_name’]=$rt[‘user_name’];
$up_uid .= $up_uid ? “,’$rt[user_id]'” : “‘$rt[user_id]'”;
if($i < $num)
{
$all_uid .= “, ‘$rt[user_id]'”;
}
$aid++;
$count ++;
}
}
$affdb[$i][‘num’] = $count;
$affdb[$i][‘point’] = $affiliate[‘item’][$i – 1][‘level_point’];
$affdb[$i][‘money’] = $affiliate[‘item’][$i – 1][‘level_money’];
}
$smarty->assign(‘affdb’, $affdb);
$smarty->assign(‘user_array’, $user_array);
// echo “<pre/>”;
// print_r($user_array);
// exit;

$sqlcount = “SELECT count(*) FROM ” . $ecs->table(‘order_info’) . ” o” . ” LEFT JOIN” . $ecs->table(‘users’) . ” u ON o.user_id = u.user_id” . ” LEFT JOIN ” . $ecs->table(‘affiliate_log’) . ” a ON o.order_id = a.order_id” . ” WHERE o.user_id > 0 AND (u.parent_id IN ($all_uid) AND o.is_separate = 0 OR a.user_id = ‘$user_id’ AND o.is_separate > 0)”;

$sql = “SELECT o.*, a.log_id, a.user_id as suid, a.user_name as auser, a.money, a.point, a.separate_type FROM ” . $ecs->table(‘order_info’) . ” o” . ” LEFT JOIN” . $ecs->table(‘users’) . ” u ON o.user_id = u.user_id” . ” LEFT JOIN ” . $ecs->table(‘affiliate_log’) . ” a ON o.order_id = a.order_id” . ” WHERE o.user_id > 0 AND (u.parent_id IN ($all_uid) AND o.is_separate = 0 OR a.user_id = ‘$user_id’ AND o.is_separate > 0)” . ” ORDER BY order_id DESC”;

/*
* SQL解释:
*
* 订单、用户、分成记录关联
* 一个订单可能有多个分成记录
*
* 1、订单有效 o.user_id > 0
* 2、满足以下之一:
* a.直接下线的未分成订单 u.parent_id IN ($all_uid) AND o.is_separate = 0
* 其中$all_uid为该ID及其下线(不包含最后一层下线)
* b.全部已分成订单 a.user_id = ‘$user_id’ AND o.is_separate > 0
*
*/

$affiliate_intro = nl2br(sprintf($_LANG[‘affiliate_intro’][$affiliate[‘config’][‘separate_by’]], $affiliate[‘config’][‘expire’], $_LANG[‘expire_unit’][$affiliate[‘config’][‘expire_unit’]], $affiliate[‘config’][‘level_register_all’], $affiliate[‘config’][‘level_register_up’], $affiliate[‘config’][‘level_money_all’], $affiliate[‘config’][‘level_point_all’]));
}
else
{
// 推荐订单分成
$sqlcount = “SELECT count(*) FROM ” . $ecs->table(‘order_info’) . ” o” . ” LEFT JOIN” . $ecs->table(‘users’) . ” u ON o.user_id = u.user_id” . ” LEFT JOIN ” . $ecs->table(‘affiliate_log’) . ” a ON o.order_id = a.order_id” . ” WHERE o.user_id > 0 AND (o.parent_id = ‘$user_id’ AND o.is_separate = 0 OR a.user_id = ‘$user_id’ AND o.is_separate > 0)”;

$sql = “SELECT o.*, a.log_id,a.user_id as suid, a.user_name as auser, a.money, a.point, a.separate_type,u.parent_id as up FROM ” . $ecs->table(‘order_info’) . ” o” . ” LEFT JOIN” . $ecs->table(‘users’) . ” u ON o.user_id = u.user_id” . ” LEFT JOIN ” . $ecs->table(‘affiliate_log’) . ” a ON o.order_id = a.order_id” . ” WHERE o.user_id > 0 AND (o.parent_id = ‘$user_id’ AND o.is_separate = 0 OR a.user_id = ‘$user_id’ AND o.is_separate > 0)” . ” ORDER BY order_id DESC”;

/*
* SQL解释:
*
* 订单、用户、分成记录关联
* 一个订单可能有多个分成记录
*
* 1、订单有效 o.user_id > 0
* 2、满足以下之一:
* a.订单下线的未分成订单 o.parent_id = ‘$user_id’ AND o.is_separate = 0
* b.全部已分成订单 a.user_id = ‘$user_id’ AND o.is_separate > 0
*
*/

$affiliate_intro = nl2br(sprintf($_LANG[‘affiliate_intro’][$affiliate[‘config’][‘separate_by’]], $affiliate[‘config’][‘expire’], $_LANG[‘expire_unit’][$affiliate[‘config’][‘expire_unit’]], $affiliate[‘config’][‘level_money_all’], $affiliate[‘config’][‘level_point_all’]));
}
// echo “<pre/>”;
// print_r($affiliate_intro);
// exit;
$count = $db->getOne($sqlcount);

$max_page = ($count > 0) ? ceil($count / $size) : 1;
if($page > $max_page)
{
$page = $max_page;
}

$res = $db->SelectLimit($sql, $size, ($page – 1) * $size);
$logdb = array();
while($rt = $GLOBALS[‘db’]->fetchRow($res))
{
if(! empty($rt[‘suid’]))
{
// 在affiliate_log有记录
if($rt[‘separate_type’] == – 1 || $rt[‘separate_type’] == – 2)
{
// 已被撤销
$rt[‘is_separate’] = 3;
}
}
$rt[‘order_sn’] = substr($rt[‘order_sn’], 0, strlen($rt[‘order_sn’]) – 5) . “***” . substr($rt[‘order_sn’], – 2, 2);
$logdb[] = $rt;
}

$url_format = “user.php?act=affiliate&page=”;

$pager = array(
‘page’ => $page, ‘size’ => $size, ‘sort’ => ”, ‘order’ => ”, ‘record_count’ => $count, ‘page_count’ => $max_page, ‘page_first’ => $url_format . ‘1’, ‘page_prev’ => $page > 1 ? $url_format . ($page – 1) : “javascript:;”, ‘page_next’ => $page < $max_page ? $url_format . ($page + 1) : “javascript:;”, ‘page_last’ => $url_format . $max_page, ‘array’ => array()
);
for($i = 1; $i <= $max_page; $i ++)
{
$pager[‘array’][$i] = $i;
}

$smarty->assign(‘url_format’, $url_format);
$smarty->assign(‘pager’, $pager);

$smarty->assign(‘affiliate_intro’, $affiliate_intro);
$smarty->assign(‘affiliate_type’, $affiliate[‘config’][‘separate_by’]);

$smarty->assign(‘logdb’, $logdb);
}
else
{
// 单个商品推荐
$smarty->assign(‘userid’, $user_id);
$smarty->assign(‘goodsid’, $goodsid);

$types = array(
1, 2, 3, 4, 5
);
$smarty->assign(‘types’, $types);

$goods = get_goods_info($goodsid);
$shopurl = $ecs->url();
$goods[‘goods_img’] = (strpos($goods[‘goods_img’], ‘http://’) === false && strpos($goods[‘goods_img’], ‘https://’) === false) ? $shopurl . $goods[‘goods_img’] : $goods[‘goods_img’];
$goods[‘goods_thumb’] = (strpos($goods[‘goods_thumb’], ‘http://’) === false && strpos($goods[‘goods_thumb’], ‘https://’) === false) ? $shopurl . $goods[‘goods_thumb’] : $goods[‘goods_thumb’];
$goods[‘shop_price’] = price_format($goods[‘shop_price’]);

$smarty->assign(‘goods’, $goods);
}

$smarty->assign(‘shopname’, $_CFG[‘shop_name’]);
$smarty->assign(‘userid’, $user_id);
$smarty->assign(‘shopurl’, $ecs->url());
$smarty->assign(‘logosrc’, ‘themesmobile/’ . $_CFG[‘template’] . ‘/images/logo.gif’);

$smarty->display(‘user_clips.dwt’);
}

修改模板部分

mobile\themesmobile\68ecshopcom_mobile\library\user_affiliate.lbi

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<style>
.utitle2{ height:30px; line-height:30px; font-size:14px; font-family:微软雅黑; border:#ddd 1px solid; background:#f5f5f5; color:#000;margin:10px 0px 10px; text-indent:15px;}
</style>

<!– *我的推荐 –>
<!– {if $affiliate.on eq 1} –>
<!– {if $action eq ‘affiliate’} –>
<!– {if !$goodsid || $goodsid eq 0} –>
<div class=”utitle2″>{$lang.affiliate_detail}</div>
<div class=”blank”></div>
<p class=”tuijian”>{$affiliate_intro}</p>
<!– {if $affiliate.config.separate_by eq 0} –>
<!– 所有会员列表–>
<!– {foreach from=$user_array key=level item=val name=affdb} –>
<table width=”95%” border=”0″ cellpadding=”5″ cellspacing=”1″ bgcolor=”#dddddd” class=”data_table”>
<tr align=”center”>
<td colspan=”2″ bgcolor=”#ffffff”>{$fenxiao_title.$level}</td>

</tr>

<tr align=”center”>
<td bgcolor=”#ffffff”>编号</td>
<td bgcolor=”#ffffff”>用户名</td>

</tr>
<!– {foreach from=$val key=level item=vals name=affdb} –>
<tr align=”center”>
<td bgcolor=”#ffffff”>{$vals.user_id}</td>
<td bgcolor=”#ffffff”>{$vals.user_name}</td>
</tr>
<!– {/foreach} –>

</table>
<!– {/foreach} –>
<!– 所有会员列表–>
<!– 下线人数、分成 –>

<div class=”utitle2″><a name=”myrecommend” >{$lang.affiliate_member}</a></div>
<div class=”tui_main”>
<table width=”95%” border=”0″ cellpadding=”5″ cellspacing=”1″ bgcolor=”#dddddd” class=”data_table”>
<tr align=”center”>
<td bgcolor=”#ffffff”>{$lang.affiliate_lever}</td>
<td bgcolor=”#ffffff”>{$lang.affiliate_num}</td>
<td bgcolor=”#ffffff”>{$lang.level_point}</td>
<td bgcolor=”#ffffff”>{$lang.level_money}</td>
</tr>
<!– {foreach from=$affdb key=level item=val name=affdb} –>
<tr align=”center”>
<td bgcolor=”#ffffff”>{$level}</td>
<td bgcolor=”#ffffff”>{$val.num}</td>
<td bgcolor=”#ffffff”>{$val.point}</td>
<td bgcolor=”#ffffff”>{$val.money}</td>
</tr>
<!– {/foreach} –>
</table>
</div>
<!– /下线人数、分成 –>
<!– {else} –>
<!– 介绍订单数、分成 –>
<!– /介绍订单数、分成 –>
<!– {/if} –>
<!– 我的推荐清单 –>

<div class=”utitle2″>分成规则</div>
<div class=”tui_main”>
<table width=”95%” border=”0″ cellpadding=”5″ cellspacing=”1″ bgcolor=”#dddddd” class=”data_table”>
<tr align=”center”>
<td bgcolor=”#ffffff”>{$lang.order_number}</td>
<td bgcolor=”#ffffff”>{$lang.affiliate_money}</td>
<td bgcolor=”#ffffff”>{$lang.affiliate_point}</td>
<td bgcolor=”#ffffff”>{$lang.affiliate_mode}</td>
<td bgcolor=”#ffffff”>{$lang.affiliate_status}</td>
</tr>
<!– {foreach from=$logdb item=val name=logdb} –>
<tr align=”center”>
<td bgcolor=”#ffffff”>{$val.order_sn}</td>
<td bgcolor=”#ffffff”>{$val.money}</td>
<td bgcolor=”#ffffff”>{$val.point}</td>
<td bgcolor=”#ffffff”><!– {if $val.separate_type == 1 || $val.separate_type === 0} –>{$lang.affiliate_type.$val.separate_type}<!– {else} –>{$lang.affiliate_type.$affiliate_type}<!– {/if} –></td>
<td bgcolor=”#ffffff”>{$lang.affiliate_stats[$val.is_separate]}</td>
</tr>
{foreachelse}
<tr><td colspan=”5″ align=”center” bgcolor=”#ffffff”>{$lang.no_records}</td>
</tr>
<!– {/foreach} –>
<!– {if $logdb} –>
<tr>
<td colspan=”5″ bgcolor=”#ffffff”>
<form action=”{$smarty.server.PHP_SELF}” method=”get”>
<div id=”pager”> {$lang.pager_1}{$pager.record_count}{$lang.pager_2}{$lang.pager_3}{$pager.page_count}{$lang.pager_4} <span> <a href=”{$pager.page_first}”>{$lang.page_first}</a> <a href=”{$pager.page_prev}”>{$lang.page_prev}</a> <a href=”{$pager.page_next}”>{$lang.page_next}</a> <a href=”{$pager.page_last}”>{$lang.page_last}</a> </span>
<select name=”page” id=”page” onchange=”selectPage(this)”>
{html_options options=$pager.array selected=$pager.page}
</select>
<input type=”hidden” name=”act” value=”affiliate” />
</div>
</form>
</td>
</tr>
<!– {/if} –>
</table>
</div>
<script type=”text/javascript” language=”JavaScript”>
<!–
{literal}
function selectPage(sel)
{
sel.form.submit();
}
{/literal}
//–>
</script>
<!– /我的推荐清单 –>
<div class=”utitle2″>{$lang.affiliate_code}</div>
<div class=”tui_main”>
<table width=”95%” border=”0″ cellpadding=”5″ cellspacing=”1″ bgcolor=”#dddddd” class=”data_table”>
<tr>
<td bgcolor=”#ffffff”><a href=”{$shopurl}?u={$userid}” target=”_blank” class=”f6″>{$shopname}</a></td>
<td bgcolor=”#ffffff”><textarea onclick=”this.select();” style=”width:80%; font-size:14px; height:50px; border:#eeeeee 1px solid; margin-top:10px; line-height:150%”>{$shopurl}?u={$userid}</textarea> </td>
</tr>

<!–start Add By www.68ecshop.com ecshop开发中心 企业QQ800007396 –>
<tr>
<td bgcolor=”#ffffff”>分享到</td>
<td bgcolor=”#ffffff”><img src=”erweima_png.php?data={$shopurl}?u={$userid}” width=150 height=150>

<div class=”bdsharebuttonbox” data-tag=”share_1″>
<a class=”bds_mshare” data-cmd=”mshare”></a>
<a class=”bds_qzone” data-cmd=”qzone” href=”#”></a>
<a class=”bds_tsina” data-cmd=”tsina”></a>
<a class=”bds_baidu” data-cmd=”baidu”></a>
<a class=”bds_renren” data-cmd=”renren”></a>
<a class=”bds_tqq” data-cmd=”tqq”></a>
</div>
<script>
window._bd_share_config = {
common : {
bdText : ‘{$page_title}’,
bdDesc : ‘{$page_title}’,
bdUrl : ‘{$shopurl}?u={$userid}’,
bdPic : ‘{$shopurl}erweima_png.php?data={$shopurl}?u={$userid}’
},
share : [{
“bdSize” : 16
}],

image : [{
viewType : ‘list’,
viewPos : ‘top’,
viewColor : ‘black’,
viewSize : ’16’,
viewList : [‘qzone’,’tsina’,’huaban’,’tqq’,’renren’]
}],
selectShare : [{
“bdselectMiniList” : [‘qzone’,’tqq’,’kaixin001′,’bdxc’,’tqf’]
}]
}
with(document)0[(getElementsByTagName(‘head’)[0]||body).appendChild(createElement(‘script’)).src=’http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion=’+~(-new Date()/36e5)];
</script>
</td>
</tr>
<!–end Add By www.68ecshop.com ecshop开发中心 企业QQ800007396 –>
</table>
</div>
<!– {else} –>
<!– 单个商品推荐 –>
<style type=”text/css”>
.types a{ text-decoration:none; color:#006bd0;}
</style>
<div class=”utitle2″>{$lang.affiliate_code}</div>
<div class=”tui_main”>
<table width=”95%” border=”0″ cellpadding=”5″ cellspacing=”1″ bgcolor=”#dddddd” class=”data_table”>
<tr align=”center”>
<td bgcolor=”#ffffff”>{$lang.affiliate_view}</td>
<td bgcolor=”#ffffff”>{$lang.affiliate_code}</td>
</tr>
<!– {foreach from=$types item=val name=types} –>
<tr align=”center”>
<td bgcolor=”#ffffff” class=”types”><script src=”{$shopurl}affiliate.php?charset={$ecs_charset}&gid={$goodsid}&u={$userid}&type={$val}”></script></td>
<td bgcolor=”#ffffff”>javascript {$lang.affiliate_codetype}<br>
<textarea cols=30 rows=2 id=”txt{$smarty.foreach.types.iteration}” style=”border:1px solid #ccc;”><script src=”{$shopurl}affiliate.php?charset={$ecs_charset}&gid={$goodsid}&u={$userid}&type={$val}”></script></textarea>[<a href=”#” title=”Copy To Clipboard” onClick=”Javascript:copyToClipboard(document.getElementById(‘txt{$smarty.foreach.types.iteration}’).value);alert(‘{$lang.copy_to_clipboard}’);” class=”f6″>{$lang.code_copy}</a>]
<br>iframe {$lang.affiliate_codetype}<br><textarea cols=30 rows=2 id=”txt{$smarty.foreach.types.iteration}_iframe” style=”border:1px solid #ccc;”><iframe width=”250″ height=”270″ src=”{$shopurl}affiliate.php?charset={$ecs_charset}&gid={$goodsid}&u={$userid}&type={$val}&display_mode=iframe” frameborder=”0″ scrolling=”no”></iframe></textarea>[<a href=”#” title=”Copy To Clipboard” onClick=”Javascript:copyToClipboard(document.getElementById(‘txt{$smarty.foreach.types.iteration}_iframe’).value);alert(‘{$lang.copy_to_clipboard}’);” class=”f6″>{$lang.code_copy}</a>]
<br />{$lang.bbs}UBB {$lang.affiliate_codetype}<br /><textarea cols=30 rows=2 id=”txt{$smarty.foreach.types.iteration}_ubb” style=”border:1px solid #ccc;”>{if $val != 5}[url={$shopurl}goods.php?id={$goodsid}&u={$userid}][img]{if $val < 3}{$goods.goods_thumb}{else}{$goods.goods_img}{/if}[/img][/url]{/if}

[url={$shopurl}goods.php?id={$goodsid}&u={$userid}][b]{$goods.goods_name}[/b][/url]
{if $val != 1 && $val != 3}[s]{$goods.market_price}[/s]{/if} [color=red]{$goods.shop_price}[/color]</textarea>[<a href=”#” title=”Copy To Clipboard” onClick=”Javascript:copyToClipboard(document.getElementById(‘txt{$smarty.foreach.types.iteration}_ubb’).value);alert(‘{$lang.copy_to_clipboard}’);” class=”f6″>{$lang.code_copy}</a>]
{if $val == 5}<br />{$lang.im_code} {$lang.affiliate_codetype}<br /><textarea cols=30 rows=2 id=”txt{$smarty.foreach.types.iteration}_txt” style=”border:1px solid #ccc;”>{$lang.show_good_to_you} {$goods.goods_name}

{$shopurl}goods.php?id={$goodsid}&u={$userid}</textarea>[<a href=”#” title=”Copy To Clipboard” onClick=”Javascript:copyToClipboard(document.getElementById(‘txt{$smarty.foreach.types.iteration}_txt’).value);alert(‘{$lang.copy_to_clipboard}’);” class=”f6″>{$lang.code_copy}</a>]{/if}</td>
</tr>
<!– {/foreach} –>
</table>
</div>
<script language=”Javascript”>
copyToClipboard = function(txt)
{
if(window.clipboardData)
{
window.clipboardData.clearData();
window.clipboardData.setData(“Text”, txt);
}
else if(navigator.userAgent.indexOf(“Opera”) != -1)
{
//暂时无方法:-(
}
else if (window.netscape)
{
try
{
netscape.security.PrivilegeManager.enablePrivilege(“UniversalXPConnect”);
}
catch (e)
{
alert(“{$lang.firefox_copy_alert}”);
return false;
}
var clip = Components.classes[‘@mozilla.org/widget/clipboard;1’].createInstance(Components.interfaces.nsIClipboard);
if (!clip)
return;
var trans = Components.classes[‘@mozilla.org/widget/transferable;1’].createInstance(Components.interfaces.nsITransferable);
if (!trans)
return;
trans.addDataFlavor(‘text/unicode’);
var str = new Object();
var len = new Object();
var str = Components.classes[“@mozilla.org/supports-string;1”].createInstance(Components.interfaces.nsISupportsString);
var copytext = txt;
str.data = copytext;
trans.setTransferData(“text/unicode”,str,copytext.length*2);
var clipid = Components.interfaces.nsIClipboard;
if (!clip)
return false;
clip.setData(trans,null,clipid.kGlobalClipboard);
}
}
</script>
<!– /单个商品推荐 –>
<!– {/if} –>
<!– {/if} –>

<!– {/if} –>

<!– /我的推荐 –>