首页用户注册充值信息修正

master
zyx 5 years ago
parent 5527b0bc31
commit c6da6fb705

@ -184,8 +184,6 @@
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$('.side-sub-menu').eq(0).show();
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮

@ -203,8 +203,6 @@
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$('.side-sub-menu').eq(0).show();
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮

@ -169,8 +169,6 @@
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$('.side-sub-menu').eq(0).show();
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮

@ -172,8 +172,6 @@
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$('.side-sub-menu').eq(0).show();
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮

@ -39,8 +39,8 @@ class PromoteController extends BaseController
$loginPromote = $this->getLoginPromote();
$whiteList = [1, 8, 84];
$isOpenQuery = in_array($loginPromote['id'], $whiteList) || in_array($loginPromote['parent_id'], $whiteList) || in_array($loginPromote['grand_id'], $whiteList) ? true : false;
$isOpenQuery = in_array($loginPromote['id'], $whiteList) || in_array($loginPromote['parent_id'], $whiteList) || in_array($loginPromote['grand_id'], $whiteList) ? true : false;
if (!$isOpenQuery) {
$this->display('prepare');
exit(0);
@ -103,16 +103,25 @@ class PromoteController extends BaseController
$promote = M("promote","tab_")->field("parent_id,grand_id")->where("id=".get_pid())->find();
$promoteId = array(get_pid());
if ($promote['parent_id'] == 1) {
$promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid()." or grand_id=". get_pid())->select();
$promoteId = array_column($promoteId,'id');
array_push($promoteId,get_pid());
} elseif ($promote['parent_id'] > 0 && $promote['grand_id'] == 0) {
$promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid())->select();
$promoteId = array_column($promoteId,'id');
array_push($promoteId,get_pid());
}
// $map = "promote_id = {$promote_id} ";
// if ($promote['parent_id'] == 1) {
// $promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid()." or grand_id=". get_pid())->select();
// $promoteId = array_column($promoteId,'id');
// array_push($promoteId,get_pid());
//计算当日用户充值数据
$map['_string'] = "promote_id = {$promote_id} or tab_promote.parent_id = {$promote_id} or tab_promote.grand_id = {$promote_id} ";
$pay_time = " between 0 and ".time();
$spendData = $this->caculateSpend($pay_time,$map['_string']);
// } elseif ($promote['parent_id'] > 0 && $promote['grand_id'] == 0) {
// $promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid())->select();
// $promoteId = array_column($promoteId,'id');
// array_push($promoteId,get_pid());
//
// $map = "promote_id = {$promote_id} or tab_promote.parent_id = {$promote_id} ";
// }
// var_dump($map);
$promoteId = implode(',',$promoteId);
if ($promoteId) {
$user_count = M("user", "tab_")->where("promote_id IN({$promoteId})")->count();
@ -120,6 +129,22 @@ class PromoteController extends BaseController
$user_count = 0;
}
$today=total(1);
$week=total(2);
$mounth=total(3);
//计算今日的统计数据
$data=M('User','tab_')
->field('promote_account,promote_id,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count,
IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1 ,
count(IF(register_time '.$today.',1,null)) as today,
count(IF(register_time '.$week.',1,null)) as week,
count(IF(register_time '.$mounth.',1,null)) as mounth')
->join('tab_promote on promote_id = tab_promote.id','left')
->where($map)
->group('promote_id1')
->having('promote_id != 0')
->order('count desc,register_time')
->find();
$total_money = $this->pay_total(0, 0,$promoteId);
$today_add_user_money = $this->pay_total(1,1,$promoteId);
@ -127,6 +152,32 @@ class PromoteController extends BaseController
$yesterday_start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
$yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
//计算昨天用户的统计数据,当日用户充值数据
$pay_time = " between {$yesterday_start} and {$yesterday_end}";
$createTime = ['between',array($yesterday_start,$yesterday_end-1)];
$yesterdaySpendData = $this->caculateSpend($pay_time,$map['_string'],$createTime);
$todayAddSpendData = $this->caculateSpend($pay_time,$map['_string'],[],1);
$mounthAddSpendData = $this->caculateSpend($pay_time,$map['_string'],[],2);
// var_dump($mounthAddSpendData);die();
$map['register_time'] = ['between',array($yesterday_start,$yesterday_end-1)];
$yesterdayData = M('User','tab_')
->field('promote_account,promote_id,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count,
IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1 ,
count(IF(register_time '.$today.',1,null)) as today,
count(IF(register_time '.$week.',1,null)) as week,
count(IF(register_time '.$mounth.',1,null)) as mounth')
->join('tab_promote on promote_id = tab_promote.id','left')
->where($map)
->group('promote_id1')
->having('promote_id != 0')
->order('count desc,register_time')
->find();
$yesterday_user_regist_count = M("user", "tab_")->where(
array("promote_id" => array('in',$promoteId),
"register_time" => array("BETWEEN", array($yesterday_start, $yesterday_end))))
@ -142,13 +193,20 @@ class PromoteController extends BaseController
->count();
$today_total_money = $this->pay_total(1, 0,$promoteId);
$this->assign('data',$data);
$this->assign('yesterdayData',$yesterdayData);
$this->assign('spendData',$spendData);
$this->assign('yesterdaySpendData',$yesterdaySpendData);
$this->assign('todayAddSpendData',$todayAddSpendData);
$this->assign('mounthAddSpendData',$mounthAddSpendData);
$this->assign("user_count", $user_count);
$this->assign("total_money", $total_money);
$this->assign("today_add_user_money", $today_add_user_money);
$this->assign("month_add_user_money", $month_add_user_money);
$this->assign("yesterday_user_regist_count", $yesterday_user_regist_count);
$this->assign("yesterday_total_money", $yesterday_total_money);
$this->assign("yesterday_regist_user_count", $yesterday_regist_user_count);
$this->assign("yesterday_total_money", $yesterday_total_money);
$this->assign("today_regist_user_count", $today_regist_user_count);
$this->assign("today_total_money", $today_total_money);
@ -167,6 +225,92 @@ class PromoteController extends BaseController
$this->display();
}
private function caculateSpend($pay_time,$condition,$create = [],$type = 0) {
$spend=M('Spend','tab_');
$today=total(1);
$week=total(2);
$mounth=total(3);
$map1['promote_id'] = $map['promote_id']=array('gt',0);
$map1['pay_status'] = $map['pay_status']=1;
$userId = [];
$promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid()." or grand_id=". get_pid())->select();
$promoteId = array_column($promoteId,'id');
$promoteId = implode(',',$promoteId).",".get_pid();
$whereUser['promote_id'] = ['IN',$promoteId];
if ($type == 1) {
$start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
$whereUser['register_time'] = ['between',array($start,$end-1)];
$userId = M('user','tab_')->field('id')->where($whereUser)->select();
} else if ($type == 2) {
$start = mktime(0, 0, 0, date('m'), 1, date('Y'));
$end = mktime(0, 0, 0, date('m') + 1, 1, date('Y')) - 1;
$whereUser['register_time'] = ['between',array($start,$end-1)];
$userId = M('user','tab_')->field('id')->where($whereUser)->select();
}
$userId = implode(',',array_column($userId,'id'));
if ($userId) {
$map1['user_id'] = $map['user_id']=['IN',$userId];
} else if (!$userId&&$type!=0) {
return array('today'=>0,'mounth'=>0);
}
if ($create) {
$map['create_time'] = $create;
}
$bindrecharge_data = M('bind_recharge','tab_')
->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time,
floor(sum(IF(create_time '.$pay_time.',real_amount,0))*100) as scount,
floor(sum(IF(create_time '.$today.',real_amount,0))*100) as today,
floor(sum(IF(create_time '.$week.',real_amount,0))*100) as week,
floor(sum(IF(create_time '.$mounth.',real_amount,0))*100) as mounth')
->where($map1)
->group('promote_id')
->select(false);
$deposit_data = M('deposit','tab_')
->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time,
floor(sum(IF(create_time '.$pay_time.',pay_amount,0))*100) as scount,
floor(sum(IF(create_time '.$today.',pay_amount,0))*100) as today,
floor(sum(IF(create_time '.$week.',pay_amount,0))*100) as week,
floor(sum(IF(create_time '.$mounth.',pay_amount,0))*100) as mounth')
// ->join('tab_user on tab_user.id = tab_spend.user_id','left')
->where($map1)
->group('promote_id')
->select(false);
$spendData=$spend
->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time,
floor(sum(IF(pay_time '.$pay_time.',pay_amount,0))*100) as scount,
floor(sum(IF(pay_time '.$today.',pay_amount,0))*100) as today,
floor(sum(IF(pay_time '.$week.',pay_amount,0))*100) as week,
floor(sum(IF(pay_time '.$mounth.',pay_amount,0))*100) as mounth')
// ->join('tab_user on tab_user.id = tab_spend.user_id','left')
->where($map)
->union(' ('.$bindrecharge_data.') ')
->union(' ('.$deposit_data.') ')
->group('promote_id')
->select(false);
$spendData = $spend->field('a.promote_account,a.promote_id,a.time,sum(a.scount) as count,sum(a.today) as today,sum(a.week) as week,sum(a.mounth) as mounth,IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1')
->join('tab_promote on promote_id = tab_promote.id','left')
->where($condition)
->table('('.$spendData.') as a')->group('promote_id1')->order('count desc,a.ordertime')->find();
$spendData['rand']=1;
$spendData['count']=$spendData['count']/100;
$spendData['today']=$spendData['today']/100;
$spendData['week']=$spendData['week']/100;
$spendData['mounth']=$spendData['mounth']/100;
return $spendData;
}
private function pay_total($type = 0, $newadd = 1,$promoteId="")
{
if ($_REQUEST['promote_id'] === null || $_REQUEST['promote_id'] === '0') {

@ -5,16 +5,16 @@
<block name="body">
<div class="page-overview promote-index-overview index-overview clearfix poll">
<ul>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>推广总用户</p><span>{$user_count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>推广总充值</p><span>¥{$total_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>当日新增用户充值</p><span>¥{$today_add_user_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>当月新增用户充值</p><span>¥{$month_add_user_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>推广总用户</p><span>{$data.count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>推广总充值</p><span>¥{$spendData.count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>当日新增用户充值</p><span>¥{$todayAddSpendData.today}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>当月新增用户充值</p><span>¥{$mounthAddSpendData.mounth}</span></div> </li>
</ul>
<ul style="margin-top: 10px">
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>昨日注册用户</p><span>{$yesterday_user_regist_count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>昨日充值金额</p><span>¥{$yesterday_total_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>今日注册用户</p><span>{$today_regist_user_count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>今日充值金额</p><span>¥{$today_total_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>昨日注册用户</p><span>{$yesterdayData.count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>昨日充值金额</p><span>¥{$yesterdaySpendData.count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>今日注册用户</p><span>{$data.today}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>今日充值金额</p><span>¥{$spendData.today}</span></div> </li>
</ul>
</div>
<div class="index-tab-list">

Loading…
Cancel
Save