Merge branch 'hotfix/promote_query' into dev

master
jbrazz 5 years ago
commit 5527b0bc31

@ -8,6 +8,8 @@
namespace Admin\Controller;
use Admin\Model\PromoteModel;
class AjaxController extends ThinkController{
/**
@ -125,4 +127,9 @@ class AjaxController extends ThinkController{
$this->AjaxReturn($return_msg);
}
}
public function getPromotersByLevel($level=1)
{
$this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevel($level)]);
}
}

@ -19,9 +19,15 @@ class MemberController extends ThinkController
if($_REQUEST['promote_id']=='UC'){
$maps['tab_user.promote_account'] = 'UC用户';
$hav .= "tab_user.promote_account = 'UC用户' ";
}else{
$maps['tab_user.promote_id'] = I('promote_id');
$hav .= "tab_user.promote_id = " . I('promote_id');
} else if ($_REQUEST['promote_id']==0) {
$maps['tab_user.promote_id'] = 0;
$hav .= "tab_user.promote_id = 0";
} else{
$promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select();
if ($promoter_ids) {
$maps['tab_user.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
$hav .= "tab_user.promote_id in (".implode(',', array_column($promoter_ids, 'id')).") ";
}
}
}
if(I('type',1) == 1){
@ -56,8 +62,7 @@ class MemberController extends ThinkController
$maps['tab_user.register_type'] = ['in',[0,3,4,5,6]];
}
}
if (isset($_REQUEST['account'])) {
empty($hav) || $hav .= ' AND ';
$hav .= "tab_user.account like '%" . I('account') . "%'";
@ -105,10 +110,10 @@ class MemberController extends ThinkController
unset($_REQUEST['status']);
}
if (isset($_REQUEST['viplevel'])) {
$havs = get_vip_level_limit('recharge_total',$_REQUEST['viplevel']);
}
if (isset($_REQUEST['viplevel'])) {
$havs = get_vip_level_limit('recharge_total',$_REQUEST['viplevel']);
}
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
@ -158,13 +163,13 @@ class MemberController extends ThinkController
->select(false);
$data = $usermodel->table('('.$sql1.') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,(a.deposit_total+IFNULL(sum(ss.pay_amount),0)) as recharge_total,check_status')
->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1')
->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1')
->join(isset($_REQUEST['game_id']) ? "tab_user_play as up on up.user_id = a.id and up.game_id = {$_REQUEST['game_id']} " : false)
->page($page, $row)
->having($havs)
->group('a.id')
->order($order)
->select();
// var_dump($data);die;
//计数
@ -172,6 +177,7 @@ class MemberController extends ThinkController
$sql = M('user', 'tab_')->field('tab_user.id,(IFNULL(sum(b.pay_amount),0) + IFNULL(sum(ss.pay_amount),0)) AS recharge_total')
->join('left join tab_deposit AS b ON tab_user.id = b.user_id AND b.pay_status = 1')
->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1')
->join(isset($_REQUEST['game_id']) ? "tab_user_play as up on up.user_id = tab_user.id and up.game_id = {$_REQUEST['game_id']} " : false)
->where($map)
->group('tab_user.id')
->where($hav)

@ -44,21 +44,23 @@ class RechargeSumController extends ThinkController{
$map['pay_way'] = array('egt',0);
}
if(!empty($_REQUEST['promote_id']) && $_REQUEST['promote_id'] != "ALL"){
switch ($_REQUEST['promote_id']) {
case 'GUANFANG':
$map['promote_id'] = 0;
$rmap['promote_id'] = 0;
break;
case 'PROMOTE':
$map['promote_id'] = array('neq',0);
$rmap['promote_id'] = array('neq',0);
break;
default:
$map['promote_id'] = $_REQUEST['promote_id'];
$rmap['promote_id'] = $_REQUEST['promote_id'];
break;
}
if(!empty($_REQUEST['promote_id'])){
// switch ($_REQUEST['promote_id']) {
// case 'GUANFANG':
// $map['promote_id'] = 0;
// $rmap['promote_id'] = 0;
// break;
// case 'PROMOTE':
// $map['promote_id'] = array('neq',0);
// $rmap['promote_id'] = array('neq',0);
// break;
// default:
// $map['promote_id'] = $_REQUEST['promote_id'];
// $rmap['promote_id'] = $_REQUEST['promote_id'];
// break;
// }
$promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select();
$promoter_ids ? $rmap['promote_id'] = $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null;
}
//当天注册人数

@ -11,65 +11,72 @@ class SpendController extends ThinkController {
const model_name = 'Spend';
public function lists(){
if(isset($_REQUEST['user_account'])){
$map['user_account']=array('like','%'.trim($_REQUEST['user_account']).'%');
$map['tab_spend.user_account']=array('like','%'.trim($_REQUEST['user_account']).'%');
unset($_REQUEST['user_account']);
}
if(isset($_REQUEST['spend_ip'])){
$map['spend_ip']=array('like','%'.trim($_REQUEST['spend_ip']).'%');
$map['tab_spend.spend_ip']=array('like','%'.trim($_REQUEST['spend_ip']).'%');
unset($_REQUEST['spend_ip']);
}
if(isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])){
$map['pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1));
$map['tab_spend.pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1));
unset($_REQUEST['time-start']);unset($_REQUEST['time-end']);
}elseif(isset($_REQUEST['time-start'])){
$map['pay_time'] = ['GT',strtotime(I('time-start'))];
$map['tab_spend.pay_time'] = ['GT',strtotime(I('time-start'))];
unset($_REQUEST['time-start']);
}elseif(isset($_REQUEST['time-end'])){
$map['pay_time'] = ['LT',strtotime(I('time-end'))+86399];
$map['tab_spend.pay_time'] = ['LT',strtotime(I('time-end'))+86399];
unset($_REQUEST['time-end']);
}
if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){
$map['pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
$map['tab_spend.pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
}elseif(isset($_REQUEST['start'])){
$map['pay_time'] = ['GT',strtotime(I('start'))];
$map['tab_spend.pay_time'] = ['GT',strtotime(I('start'))];
unset($_REQUEST['start']);
}elseif(isset($_REQUEST['end'])){
$map['pay_time'] = ['LT',strtotime(I('end'))+86399];
$map['tab_spend.pay_time'] = ['LT',strtotime(I('end'))+86399];
unset($_REQUEST['end']);
}
if(isset($_REQUEST['game_name'])){
if($_REQUEST['game_name']=='全部'){
unset($_REQUEST['game_name']);
}else{
$map['game_name']=$_REQUEST['game_name'];
$map['tab_spend.game_name']=$_REQUEST['game_name'];
unset($_REQUEST['game_name']);
}
}
if(isset($_REQUEST['server_name'])){
$map['server_name']=$_REQUEST['server_name'];
$map['tab_spend.server_name']=$_REQUEST['server_name'];
unset($_REQUEST['server_name']);
}
if(isset($_REQUEST['pay_order_number'])){
$map['pay_order_number']=array('like','%'.trim($_REQUEST['pay_order_number']).'%');
$map['tab_spend.pay_order_number']=array('like','%'.trim($_REQUEST['pay_order_number']).'%');
unset($_REQUEST['pay_order_number']);
}
if(isset($_REQUEST['pay_status'])){
$map['pay_status']=$_REQUEST['pay_status'];
$map['tab_spend.pay_status']=$_REQUEST['pay_status'];
unset($_REQUEST['pay_status']);
}
if(isset($_REQUEST['pay_way'])){
if($_REQUEST['pay_way']==2){
$map['pay_way']=['in','2,3,4'];
$map['tab_spend.pay_way']=['in','2,3,4'];
}else{
$map['pay_way']=$_REQUEST['pay_way'];
$map['tab_spend.pay_way']=$_REQUEST['pay_way'];
}
unset($_REQUEST['pay_way']);
}
if(isset($_REQUEST['pay_game_status'])){
$map['pay_game_status']=$_REQUEST['pay_game_status'];
$map['tab_spend.pay_game_status']=$_REQUEST['pay_game_status'];
unset($_REQUEST['pay_game_status']);
}
if(isset($_REQUEST['promote_id'])) {
$map['_complex'] = ['tp.parent_id'=>$_REQUEST['promote_id'], 'tp.grand_id'=>$_REQUEST['promote_id'], 'tp.id'=>$_REQUEST['promote_id'], '_logic' => 'or'];
$tab_promote_join = "left join tab_promote as tp on tp.id = tab_spend.promote_id";
//unset($_REQUEST['promote_id']);
} else {
$tab_promote_join = false;
}
if($_REQUEST['data_order']!=''){
$data_order=reset(explode(',',$_REQUEST['data_order']));
@ -84,9 +91,9 @@ class SpendController extends ThinkController {
$map1=$map;
$map1['pay_status']=1;
$total=null_to_0(D(self::model_name)->where($map1)->sum('pay_amount'));
$ttotal=null_to_0(D(self::model_name)->where('pay_time'.total(1))->where(array('pay_status'=>1))->sum('pay_amount'));
$ytotal=null_to_0(D(self::model_name)->where('pay_time'.total(5))->where(array('pay_status'=>1))->sum('pay_amount'));
$total=null_to_0(D(self::model_name)->where($map1)->join($tab_promote_join)->sum('pay_amount'));
$ttotal=null_to_0(D(self::model_name)->where('pay_time'.total(1))->where(array('pay_status'=>1))->join($tab_promote_join)->sum('pay_amount'));
$ytotal=null_to_0(D(self::model_name)->where('pay_time'.total(5))->where(array('pay_status'=>1))->join($tab_promote_join)->sum('pay_amount'));
$this->assign('total',$total);
$this->assign('ttotal',$ttotal);
$this->assign('ytotal',$ytotal);
@ -104,6 +111,6 @@ class SpendController extends ThinkController {
$this->assign('_page',$data['page']);
$this->display();
}
}

@ -569,6 +569,11 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){
$map['role_name'] = trim($_REQUEST['role_name']);
unset($_REQUEST['role_name']);
}
if (isset($_REQUEST['promote_id'])) {
$promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select();
$promoter_ids ? $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null;
}
empty(I('user_account')) || $map['user_account'] = ['like',"%".I('user_account')."%"];
$list = $this->lists(M('user_play_info', 'tab_'), $map, 'play_time desc');
$this->assign('list', $list);

@ -371,4 +371,21 @@ class PromoteModel extends Model{
return $user;
}
public function getPromotersByLevel($level=1)
{
$result = [];
switch ($level) {
case 1: // 会长
$result = $this->field("id, nickname")->where("grand_id = 0 and parent_id = 0")->select();
break;
case 2: // 组长
$result = $this->field("id, nickname")->where("grand_id = 0 and parent_id > 0")->select();
break;
case 3: //组员
$result = $this->field("id, nickname")->where("parent_id > 0 and grand_id > 0")->select();
break;
}
return $result;
}
}

@ -720,14 +720,14 @@ protected function _after_select(&$result,$options){
} else {
$row = 10;
}
$list = $this->field($field?:true)
$list = $this->field("tab_spend.*")
->join("left join tab_promote as tp on tp.id = tab_spend.promote_id")
->where($map)
->page($page, $row)
->order($order?$order:'pay_time desc')
->order($order?$order:'tab_spend.pay_time desc')
->select();
$count = $this->where($map)->count();
$count = $this->where($map)->join("left join tab_promote as tp on tp.id = tab_spend.promote_id")->count();
$data['data'] = $list;
@ -738,6 +738,7 @@ protected function _after_select(&$result,$options){
}
return $data;
}
}
}

@ -73,7 +73,7 @@
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<!-- <div class="input-list input-list-promote search_label_rehab">
<select style="width: 120px;" id="promote_id" name="promote_id" class="select_gallery" >
<option value="">所属推广员</option>
@ -83,7 +83,7 @@
<option promote-id="{$vo.id}" value="{$vo.id}">{$vo.account}</option>
</volist>
</select>
</div>
</div> -->
<if condition="I('type') eq 1 or I('type') eq ''">
<div class="input-list input-list-resway search_label_rehab">
@ -103,15 +103,38 @@
<option value="0" <if condition="I('status') eq '0'" >selected="true"</if>>已{:L('Lock')}</option>
</select>
</div>
<div class="sleft">
<select id="viplevel" name="viplevel" class="select_gallery">
<option value="">VIP等级</option>
<option value="0">VIP 0</option>
<option value="1">VIP 1</option>
<option value="2">VIP 2</option>
<option value="3">VIP 3</option>
</select>
</div>
<div class="sleft">
<select id="viplevel" name="viplevel" class="select_gallery">
<option value="">VIP等级</option>
<option value="0">VIP 0</option>
<option value="1">VIP 1</option>
<option value="2">VIP 2</option>
<option value="3">VIP 3</option>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="game_id" name="game_id" class="select_gallery" >
<option value="">游戏名称</option>
<volist name=":get_game_list()" id="vo">
<option game-id="{$vo.id}" value="{$vo.id}">{$vo.game_name}</option>
</volist>
</select>
</div>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_level" style="color:#444" class="select_gallery" id="promote_level">
<option value="">请选择推广员等级</option>
<option value="1" <?php if ($_POST['promote_level'] == 1):?>selected<?php endif;?>>会长</option>
<option value="2" <?php if ($_POST['promote_level'] == 2):?>selected<?php endif;?>>组长</option>
</select>
-
</div>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_id" style="color:#444" class="select_gallery" id="promote_id">
<option value="">请选择推广员</option>
<option value="0" <?php if ($_POST['promote_id'] == 0):?>selected<?php endif;?>>官方渠道</option>
<option value="UC" <?php if ($_POST['promote_id'] == 'UC'):?>selected<?php endif;?>>UC用户</option>
</select>
</div>
<input type="hidden" name="" value="" class="sortBy">
<input type="hidden" name="type" value="{:I('type')}" class="sortBy">
<input type="hidden" name="balance_status" value="" id="balance_status">
@ -375,6 +398,30 @@ $(function(){
autoclose:true,
pickerPosition:'bottom-left'
})
var promote_id = "{:I('promote_id')}";
$("#promote_level").change(function(){
$.ajax({
url:"{:U('Ajax/getPromotersByLevel')}",
type:"get",
data:{level:$("#promote_level option:selected").val()},
dataType:'json',
success:function(response){
str = '<option value="">请选择推广员</option><option value="0"'+(promote_id && 0 == promote_id?'selected':'')+'>官方渠道</option><option value="UC" '+(promote_id && 'UC' == promote_id?'selected':'')+'>UC用户</option>';
// $.each(response.data, function(index, item){
// console.log(item.id);
// str += '<option value="'+item.id+' '+(promote_id && item.id == promote_id?'selected':'')+'">'+item.nickname+'</option>';
// });
data = response.data;
for (var i in data){
str += "<option value='"+data[i].id+"' "+(promote_id && data[i].id == promote_id?'selected':'')+">"+data[i].nickname+"</option>"
}
$("#promote_id").empty();
$("#promote_id").append(str);
$("#promote_id").select2();
}
})
});
$("#promote_level").change();
})
function shenhe(){
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {

@ -55,7 +55,7 @@
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<!-- <div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" >
<option value="">渠道来源</option>
<option value="GUANFANG">官方渠道</option>
@ -64,7 +64,7 @@
<option promote-id="{$vo.id}" value="{$vo.id}">{$vo.account}</option>
</volist>
</select>
</div>
</div> -->
<div class="input-list input-list-promote search_label_rehab">
<select id="game_id" name="game_id" class="select_gallery" >
<option value="">游戏名称</option>
@ -73,6 +73,20 @@
</volist>
</select>
</div>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_level" style="color:#444" class="select_gallery" id="promote_level">
<option value="">请选择推广员等级</option>
<option value="1" <?php if ($_POST['promote_level'] == 1):?>selected<?php endif;?>>会长</option>
<option value="2" <?php if ($_POST['promote_level'] == 2):?>selected<?php endif;?>>组长</option>
<option value="3" <?php if ($_POST['promote_level'] == 3):?>selected<?php endif;?>>组员</option>
</select>
-
</div>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_id" style="color:#444" class="select_gallery" id="promote_id">
<option value="">请选择推广员</option>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('RechargeSum/summation',array('row'=>I('row')))}">搜索</a>
</div>
@ -268,6 +282,32 @@ $(function(){
autoclose: true,
pickerPosition: 'bottom-left'
})
var promote_id = "{:I('promote_id')}";
console.log(promote_id);
$("#promote_level").change(function(){
$.ajax({
url:"{:U('Ajax/getPromotersByLevel')}",
type:"get",
data:{level:$("#promote_level option:selected").val()},
dataType:'json',
success:function(response){
str = "<option value=''>请选择推广员</option>";
// $.each(response.data, function(index, item){
// console.log(item.id);
// str += '<option value="'+item.id+' '+(promote_id && item.id == promote_id?'selected':'')+'">'+item.nickname+'</option>';
// });
data = response.data;
for (var i in data){
str += "<option value='"+data[i].id+"' "+(promote_id && data[i].id == promote_id?'selected':'')+">"+data[i].nickname+"</option>"
}
$("#promote_id").empty();
$("#promote_id").append(str);
$("#promote_id").select2();
}
})
});
$("#promote_level").change();
})
</script>
</block>

@ -96,6 +96,20 @@
<option value="2">已退款</option>
</select>
</div>
<br>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_level" style="color:#444" class="select_gallery" id="promote_level">
<option value="">请选择推广员等级</option>
<option value="1" <?php if ($_POST['promote_level'] == 1):?>selected<?php endif;?>>会长</option>
<option value="2" <?php if ($_POST['promote_level'] == 2):?>selected<?php endif;?>>组长</option>
</select>
-
</div>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_id" style="color:#444" class="select_gallery" id="promote_id">
<option value="">请选择推广员</option>
</select>
</div>
<input type="hidden" name="" value="" class="sortBy">
<div class="input-list search_item">
@ -463,6 +477,33 @@
}
})
});
var promote_id = "{:I('promote_id')}";
console.log(promote_id);
$("#promote_level").change(function(){
$.ajax({
url:"{:U('Ajax/getPromotersByLevel')}",
type:"get",
data:{level:$("#promote_level option:selected").val()},
dataType:'json',
success:function(response){
str = "<option value=''>请选择推广员</option>";
// $.each(response.data, function(index, item){
// console.log(item.id);
// str += '<option value="'+item.id+' '+(promote_id && item.id == promote_id?'selected':'')+'">'+item.nickname+'</option>';
// });
data = response.data;
for (var i in data){
str += "<option value='"+data[i].id+"' "+(promote_id && data[i].id == promote_id?'selected':'')+">"+data[i].nickname+"</option>"
}
$("#promote_id").empty();
$("#promote_id").append(str);
$("#promote_id").select2();
}
})
});
$("#promote_level").change();
var game_id = "{:I('game_name')}";
var game_server = "{:I('server_name')}";
if(game_id){

@ -69,7 +69,21 @@
<option value="">游戏区服</option>
</select>
</div>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_level" style="color:#444" class="select_gallery" id="promote_level">
<option value="">请选择推广员等级</option>
<option value="1" <?php if ($_POST['promote_level'] == 1):?>selected<?php endif;?>>会长</option>
<option value="2" <?php if ($_POST['promote_level'] == 2):?>selected<?php endif;?>>组长</option>
</select>
-
</div>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="promote_id" style="color:#444" class="select_gallery" id="promote_id">
<option value="">请选择推广员</option>
<option value="0" <?php if ($_POST['promote_id'] == 0):?>selected<?php endif;?>>官方渠道</option>
<option value="UC" <?php if ($_POST['promote_id'] == 'UC'):?>selected<?php endif;?>>UC用户</option>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('rolelist',array('row'=>I('row')))}">搜索</a>
</div>
@ -224,5 +238,29 @@ $(".select_gallery").select2();
}
})
}
var promote_id = "{:I('promote_id')}";
$("#promote_level").change(function(){
$.ajax({
url:"{:U('Ajax/getPromotersByLevel')}",
type:"get",
data:{level:$("#promote_level option:selected").val()},
dataType:'json',
success:function(response){
str = '<option value="">请选择推广员</option>';
// $.each(response.data, function(index, item){
// console.log(item.id);
// str += '<option value="'+item.id+' '+(promote_id && item.id == promote_id?'selected':'')+'">'+item.nickname+'</option>';
// });
data = response.data;
for (var i in data){
str += "<option value='"+data[i].id+"' "+(promote_id && data[i].id == promote_id?'selected':'')+">"+data[i].nickname+"</option>"
}
$("#promote_id").empty();
$("#promote_id").append(str);
$("#promote_id").select2();
}
})
});
$("#promote_level").change();
</script>
</block>

Loading…
Cancel
Save