diff --git a/Addons/SiteStat/SiteStatAddon.class.php b/Addons/SiteStat/SiteStatAddon.class.php index 0e2da09be..7fbb7c8d0 100644 --- a/Addons/SiteStat/SiteStatAddon.class.php +++ b/Addons/SiteStat/SiteStatAddon.class.php @@ -625,7 +625,7 @@ class SiteStatAddon extends Addon { $user = M("User", "tab_"); $game = M("Game", "tab_"); - $spend = M('Spend', "tab_"); + $spend = M('Spend s use index(game_stayus)', "tab_"); $deposit = M('Deposit', "tab_"); $apply = M('Apply', "tab_"); $applyapp = M('app_apply', "tab_"); diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 1680e8213..4afd0f3c2 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -72,6 +72,12 @@ class MemberController extends ThinkController $map['tab_user.register_type'] = ['in', [0, 3, 4, 5, 6]]; } } + //判断重复 + $is_repeat = false; + if (isset($_REQUEST['is_repeat'])) { + $map['tab_user.is_repeat'] = $_REQUEST['is_repeat']; + $is_repeat = true; + } if (isset($_REQUEST['status'])) { @@ -126,10 +132,10 @@ class MemberController extends ThinkController } //判断是否有列表和统计的权限 $this->checkListOrCountAuthRestMap($map,["tab_user.id","tab_user.account","tab_user.device_number"]); - //计算用户列表 $data = M("user","tab_") - ->field("tab_user.id,`device_number`,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(ss.pay_amount,0) AS recharge_total") + ->field("tab_user.id,`device_number`,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark, + `register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(ss.pay_amount,0) AS recharge_total,tab_user.is_repeat") ->where($map) ->group("tab_user.id") ->order($order); @@ -193,12 +199,13 @@ class MemberController extends ThinkController $v['login_time'] = date('Y-m-d H:i:s',$v['login_time']); $v['lock_status'] = get_info_status($v['lock_status'],4); $v['check_status'] = $v['check_status']==1 ? "正常" :"拉黑"; + $v['is_repeat'] = $v['is_repeat']==1 ? "是" :"否"; } $field = array( "id"=>"账号ID","account"=>"玩家账号","promote_account"=>"所属推广员","balance"=>"账户平台币","recharge_total"=>"累计充值","gold_coin"=>"金币", "small_count"=>"小号","vip_level"=>"VIP等级","register_type"=>"注册方式","register_time"=>"注册时间","register_ip"=>"注册IP","login_time"=>"最后登录时间", - "device_number"=>"设备号","lock_remark"=>"锁定备注","lock_status"=>"账号状态","check_status"=>"拉黑状态" + "device_number"=>"设备号","is_repeat"=>"去重数据","lock_remark"=>"锁定备注","lock_status"=>"账号状态","check_status"=>"拉黑状态" ); //操作日志 unset($_GET['export']); @@ -211,71 +218,51 @@ class MemberController extends ThinkController data2csv($data,"玩家_玩家列表",$field); } - if($havs){ - //判断是否需要vip等级分类 - $user_count = M("user","tab_") - ->field("tab_user.id,IFNULL(sum(ss.pay_amount), 0) AS recharge_total") - ->where($map) - ->group("tab_user.id") - ->having($havs); - if($game_map){ - $user_count->join(" - (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id - "); - } - if($gameplay){ - $user_count->join(" - (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id - "); - } - $user_count->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left"); - - $user_count = $user_count->select(false); - $count = M()->table('(' . $user_count . ') as a ')->field("count(*) user_count,sum(a.recharge_total) recharge_total")->find(); - $user_count = $count['user_count']; - $now_count = $count['recharge_total']; - + //计算总人数 + if($is_repeat){ + $field ="count(*) user_count,IFNULL(sum(ss.pay_amount), 0) recharge_total"; }else{ - //计算总人数 - $user_count = M("user","tab_") - ->field("count(*) user_count") - ->where($map); - if($game_map){ - $user_count->join(" - (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id - "); - } - if($gameplay){ - $user_count->join(" - (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id - "); - } - $user_count = $user_count->find()['user_count']; - - //累计充值统计 - $user_sql = M("user","tab_") - ->field('id') - ->where($map); - if($game_map){ - $user_sql->join(" - (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id - "); - } - if($gameplay){ - $user_sql->join(" - (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id - "); - } - $user_sql = $user_sql->select(false); + $field = "IFNULL(SUM(CASE WHEN is_repeat > 0 THEN 1 ELSE 0 END),0) as repeat_count,IFNULL(SUM(CASE WHEN is_repeat = 0 THEN 1 ELSE 0 END),0) as no_repeat_count,IFNULL(sum(ss.pay_amount), 0) recharge_total"; + } + if($havs){ + $map["_string"] = get_vip_level_limit('ss.pay_amount', $_REQUEST['viplevel']); + } - $now_count = M("UserData","tab_") - ->alias('ss') - ->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total") - ->where("user_id in (".$user_sql.")")->find()['recharge_total']; + $user_count = M("user","tab_") + ->field($field) + ->where($map); + if($game_map){ + $user_count->join(" + (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id + "); + } + if($gameplay){ + $user_count->join(" + (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id + "); + } + $user_count->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left"); + $userDbRes = $user_count->find(); + if($is_repeat){ + $user_count =$userDbRes['user_count']; + if($_REQUEST['is_repeat'] == 0){ + $repeat_count = 0; + $no_repeat_count = $user_count; + }else{ + $repeat_count = $user_count; + $no_repeat_count = 0; + } + }else{ + $user_count = $userDbRes['no_repeat_count']-0+$userDbRes['repeat_count']; + $repeat_count = $userDbRes['repeat_count']; + $no_repeat_count = $userDbRes['no_repeat_count']; } - $this->assign('user_count',$user_count); - $this->assign('now_count', $now_count?:0); + $this->assign('repeat_count',$repeat_count); + $this->assign('no_repeat_count',$no_repeat_count); + + $this->assign('user_count',$user_count); + $this->assign('now_count', $userDbRes['recharge_total']); $page = set_pagination($user_count, $row); if ($page) { $this->assign('_page', $page); diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index 4f99ee409..79da46dd1 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -233,9 +233,15 @@ class PromoteController extends ThinkController if ($this->accountExist($account)) { $this->error('该账号已存在'); } - $res = M('promote', 'tab_')->where(['mobile_phone' => $mobile_phone])->field('id')->find(); - if ($res) { - $this->error('该手机号已存在'); + if(!empty($mobile_phone)){ + //判断手机格式 + if (!preg_match("/^1[3456789]{1}\d{9}$/", $mobile_phone)) { + $this->error('手机格式错误'); + } + $res = M('promote', 'tab_')->where(['mobile_phone' => $mobile_phone])->field('id')->find(); + if ($res) { + $this->error('该手机号已存在'); + } } $company_belong = $_REQUEST['company_belong'] ?? 0; $company_relation = $_REQUEST['company_relation'] ?? 0; @@ -694,6 +700,9 @@ class PromoteController extends ThinkController */ public function spend_list() { + if(!array_key_exists("timeStart",$_REQUEST)){ + $this->redirect(ACTION_NAME, array('timeStart' => date('Y-m-d',strtotime('-30 day')),"timeEnd"=>date('Y-m-d'))); + } if (isset($_REQUEST['game_name'])) { if ($_REQUEST['game_name']=='全部') { unset($_REQUEST['game_name']); @@ -799,7 +808,7 @@ class PromoteController extends ThinkController setPowerPromoteIds($map); // dd($map); $model = array( - 'm_name' => 'Spend', + 'm_name' => 'spend use index(promote_time)', 'map' => $map, 'order' => 'id desc', 'title' => '渠道充值', @@ -814,9 +823,9 @@ class PromoteController extends ThinkController ]; //为数据权限添加 setPowerPromoteIds($map2); - $total = null_to_0(D('Spend')->where($map1)->sum('pay_amount'));//累计充值 - $ttotal = null_to_0(D('Spend')->where(['pay_time' => total(1, false)])->where($map2)->sum('pay_amount'));//昨日充值 - $ytotal = null_to_0(D('Spend')->where(['pay_time' => total(5, false)])->where($map2)->sum('pay_amount'));//今日充值 + $total = null_to_0(M('Spend use index(promote_time)',"tab_")->where($map1)->sum('pay_amount'));//累计充值 + $ttotal = null_to_0(M('Spend use index(promote_time)',"tab_")->where(['pay_time' => total(1, false)])->where($map2)->sum('pay_amount'));//昨日充值 + $ytotal = null_to_0(M('Spend use index(promote_time)',"tab_")->where(['pay_time' => total(5, false)])->where($map2)->sum('pay_amount'));//今日充值 // dd($total,$ttotal,$ytotal); $this->assign('total', $total); $this->assign('ttotal', $ttotal); diff --git a/Application/Admin/Event/SpendEvent.class.php b/Application/Admin/Event/SpendEvent.class.php index 141f6b7ca..1ef3df1d3 100644 --- a/Application/Admin/Event/SpendEvent.class.php +++ b/Application/Admin/Event/SpendEvent.class.php @@ -31,8 +31,8 @@ class SpendEvent extends ThinkEvent { $model['order'] = $data_order_type.' '.$sort; } - $new_model = D($name); - $data = D($name) + $new_model = M($name,"tab_"); + $data = $new_model // 查询条件 ->where($map) /* 默认通过id逆序排列 */ @@ -44,7 +44,7 @@ class SpendEvent extends ThinkEvent { /* 执行查询 */ ->select(); /* 查询记录总数 */ - $count = D($name) + $count = $new_model // 查询条件 ->where($map) /* 默认通过id逆序排列 */ diff --git a/Application/Admin/View/Member/user_info.html b/Application/Admin/View/Member/user_info.html index 663496c7a..96313eaab 100644 --- a/Application/Admin/View/Member/user_info.html +++ b/Application/Admin/View/Member/user_info.html @@ -136,6 +136,13 @@
+
+ +