diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 7fd9fc095..fc7bef092 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -434,7 +434,6 @@ class ConsoleController extends Think { $start = I('start', date('Y-m-d')); $end = I('end', date('Y-m-d')); $gameIds = I('game_ids', ''); - $startTime = strtotime($start . ' 00:00:00'); $endTime = strtotime($end . ' 23:59:59'); $gameIdRows = explode(',', $gameIds); diff --git a/Application/Admin/Controller/PromoteLimitRuleController.class.php b/Application/Admin/Controller/PromoteLimitRuleController.class.php new file mode 100644 index 000000000..839704544 --- /dev/null +++ b/Application/Admin/Controller/PromoteLimitRuleController.class.php @@ -0,0 +1,233 @@ +field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true); + if (count($companyPromoteIds) > 0) { + $promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds; + $promoteIds[] = 0; + } else { + $promoteIds = [0]; + } + } + if (count($promoteIds)) { + $conditions['promote_id'] = ['in', $promoteIds]; + } + $query = M('promote_limit_rules', 'tab_')->where($conditions); + + $countQuery = clone $query; + $rules = $query->page($page, $row)->select(); + $count = $countQuery->count(); + + $recordPromotes = []; + $recordCompanys = []; + if (count($rules) > 0) { + $recordPromotes = M('promote', 'tab_')->field(['id', 'account', 'company_id'])->where(['id' => ['in', array_column($rules, 'promote_id')]])->select(); + $recordCompanyIds = array_column($recordPromotes, 'company_id'); + if (count($recordCompanyIds) > 0) { + $recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select(); + } + $recordPromotes = index_by_column('id', $recordPromotes); + $recordCompanys = index_by_column('id', $recordCompanys); + } + + $companyTypes = [ + 0 => '内团', + 1 => '外团', + 2 => '外团-分发联盟', + 3 => '无' + ]; + + $records = []; + foreach ($rules as $rule) { + $records[] = [ + 'id' => $rule['id'], + 'promote_account' => $recordPromotes[$rule['promote_id']]['account'], + 'company_name' => $recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_name'], + 'company_belong' => $companyTypes[$recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_belong']], + 'limit_rule' => $this->getDisplayRule($rule), + ]; + } + $companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select(); + + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } + $this->assign('records', $records); + $this->assign('companys', $companys); + $this->display(); + } + + private function getDisplayRule($rule) + { + if ($rule['started_at'] === null && $rule['ended_at'] === null) { + return '永久'; + } elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) { + return '从前 至 '.$rule['ended_at']; + } elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) { + return $rule['started_at'] . ' 至 永久'; + } else { + return $rule['started_at'] . ' ~ ' . $rule['ended_at']; + } + } + + public function edit() + { + $this->meta_title = '编辑推广限制'; + $id = I('id', 0); + $companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select(); + $record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find(); + $promote = null; + $company = null; + if ($record) { + $promote = M('promote', 'tab_')->where(['id' => $record['promote_id']])->field(['id', 'company_id', 'account'])->find(); + $company = M('promote_company', 'tab_')->where(['id' => $promote['company_id']])->field(['id', 'company_name'])->find(); + } + $this->assign('promote', $promote); + $this->assign('company', $company); + $this->assign('companys', $companys); + $this->assign('record', $record); + $this->display('form'); + } + + public function save() + { + $id = I('id', 0); + $promoteId = I('promote_id', 0); + $startedAt = I('started_at', ''); + $endedAt = I('ended_at', ''); + + $startedAt = $startedAt === '' ? null : $startedAt; + $endedAt = $endedAt === '' ? null : $endedAt; + + if ($startedAt && $endedAt && strtotime($startedAt) > strtotime($endedAt)) { + return $this->error('开始时间不能大于结束时间'); + } + + $record = null; + if ($id > 0) { + $record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find(); + if (!$record) { + return $this->error('修改记录不存在'); + } + } else { + if (empty($promoteId)) { + return $this->error('请选择会长'); + } + $promoteRecord = M('promote_limit_rules', 'tab_')->where(['promote_id' => $promoteId])->find(); + if ($promoteRecord) { + return $this->error('该会长已经设定限制规则,请前往更新'); + } + } + + if ($record) { + $data = []; + $data['started_at'] = $startedAt; + $data['ended_at'] = $endedAt; + $data['update_time'] = time(); + M('promote_limit_rules', 'tab_')->where(['id' => $id])->save($data); + addOperationLog([ + 'op_type' => 1, + 'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt, + 'op_name' => '修改推广限制', + 'url' => U('PresidentDeposit/edit', ['id'=>$id]), 'menu'=>'推广员-推广员管理-推广限制-修改推广限制' + ]); + } else { + $data = []; + $data['promote_id'] = $promoteId; + $data['started_at'] = $startedAt; + $data['ended_at'] = $endedAt; + $data['create_time'] = time(); + $data['update_time'] = time(); + M('promote_limit_rules', 'tab_')->add($data); + addOperationLog([ + 'op_type' => 0, + 'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt, + 'op_name' => '新增推广限制', + 'url' => U('PresidentDeposit/edit', ['promote_id'=>$promoteId]), 'menu'=>'推广员-推广员管理-推广限制-新增推广限制' + ]); + } + + return $this->success('保存成功', U('records')); + } + + public function delete() + { + $id = I('id', 0); + M('promote_limit_rules', 'tab_')->where(['id' => $id])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => $id, + 'op_name' => '删除会长推广限制', + 'url' => U('PresidentDeposit/delete', ['id' => $id]), + 'menu' => '推广员-推广员管理-推广限制-删除推广限制' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function batchDelete() + { + $ids = I('ids', []); + if (count($ids) == 0) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '无选中项' + ]); + } + M('promote_limit_rules', 'tab_')->where(['id' => ['in', $ids]])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => implode(',', $ids), + 'op_name' => '批量删除会长推广限制', + 'url' => U('PresidentDeposit/batchDelete', ['ids' => implode(',', $ids)]), + 'menu' => '推广员-推广员管理-推广限制-批量删除推广限制' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function getPromotesByCompany() + { + $companyId = I('company_id', 0); + $promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['level' => 1, 'company_id' => $companyId])->select(); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => [ + 'promotes' => $promotes + ] + ]); + } +} diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index d11d33087..eb690a23d 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -147,7 +147,8 @@ class StatController extends ThinkController $start = I('start', date('Y-m-d',strtotime('-7 day'))); $end = empty(I('end')) ? time_format(time(),'Y-m-d') : I('end'); $dataOrder = I('data_order', ''); - $gameId = I('game_id', 0); + $baseGameId = I('game_id', 0); + $deviceType = I('device_type', ''); $promoteId = I('promote_id', 0); $orderType = 'asc'; @@ -162,10 +163,14 @@ class StatController extends ThinkController $status = true; $data = false; $error = ''; - if ($gameId == 0) { + if ($baseGameId == 0) { $error = '请选择游戏!'; $status = false; } + if ($deviceType == '') { + $error = '请选择设备类型!'; + $status = false; + } $startTime = strtotime($start . ' 00:00:00'); $endTime = strtotime($end . ' 23:59:59') + 1; if ((($endTime - $startTime)/(24*3600)) > 31) { @@ -173,6 +178,10 @@ class StatController extends ThinkController $status = false; } if ($status) { + + $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find(); + $gameId = $deviceType == 'android' ? $baseGame['android_game_id'] : $baseGame['ios_game_id']; + $client = new Client([ 'base_uri' => C('TASK_URL'), 'timeout' => 10.0, @@ -218,6 +227,9 @@ class StatController extends ThinkController $this->assign('error', $error); } + $baseGames = M('base_game', 'tab_')->select(); + + $this->assign('baseGames', $baseGames); $this->checkListOrCountAuthRestMap($map,[]); $this->assign('data', $data); @@ -676,6 +688,165 @@ AND UNIX_TIMESTAMP( } public function userarpu($p=0) + { + $start = I('start', date('Y-m-d')); + $end = I('end', date('Y-m-d')); + $baseGameIds = I('game_ids', ''); + $promoteId = I('promote_id', 0); + $dataOrder = I('data_order', ''); + $deviceType = I('device_type', ''); + $containBindCoins = I('contain_bind_coins', 0); + + $orderType = ''; + $order = 0; + if ($dataOrder != '') { + $dataOrderRow = explode(',', $dataOrder); + $order = $dataOrderRow[0]; + $orderType = $dataOrderRow[1]; + } + + $promoteIds = []; + if ($promoteId > 0) { + $promote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $promoteId])->find(); + $promoteIds = M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->getField('id', true); + $promoteIds[] = $promote['id']; + } + + $startTime = strtotime($start . ' 00:00:00'); + $endTime = strtotime($end . ' 23:59:59'); + $baseGameIdRows = $baseGameIds ? explode(',', $baseGameIds) : []; + $baseGames = M('base_game', 'tab_')->select(); + + $gameIds = null; + $conditions = []; + if (count($baseGameIdRows)) { + $tmpBaseGames = M('base_game', 'tab_')->where(['id' => ['in', $baseGameIdRows]])->select(); + $gameIds = array_merge(array_column($tmpBaseGames, 'android_game_id'), array_column($tmpBaseGames, 'ios_game_id')); + } + if (count($promoteIds)) { + $conditions['promote_id'] = ['in', $promoteIds]; + } + if ($deviceType != '') { + if ($gameIds) { + $gameIds = ( + $deviceType == 'android' ? + array_intersect($gameIds, array_column($baseGames, 'android_game_id')) : + array_intersect($gameIds, array_column($baseGames, 'ios_game_id')) + ); + } else { + $gameIds = ( + $deviceType == 'android' ? + array_column($baseGames, 'android_game_id') : + array_column($baseGames, 'ios_game_id') + ); + } + } + + if ($gameIds && count($gameIds)) { + if (count($gameIds)) { + $conditions['game_id'] = ['in', $gameIds]; + } else { + $conditions['game_id'] = ['in', 0]; + } + } + + // 新增用户 + + /* M('user', 'tab_') + ->field('count(*) count, FROM_UNIXTIME(register_time, "%Y-%m-%d") date') + ->where([ + 'game_id' => ['in', $gameIdRows], + 'register_time' => ['between', [$startTime, $endTime]] + ]) + ->group('date') + ->select(); */ + + $newUsers = M('user_play', 'tab_') + ->field('count(DISTINCT user_id) count, FROM_UNIXTIME(create_time, "%Y-%m-%d") date') + ->where(array_merge($conditions, ['create_time' => ['between', [$startTime, $endTime]]])) + ->group('date') + ->select(); + $newUsers = index_by_column('date', $newUsers); + + // 活跃用户 + $loginUsers = M('login_daily_record', 'tab_') + ->field('count(DISTINCT user_id) count, FROM_UNIXTIME(create_time, "%Y-%m-%d") date') + ->where(array_merge($conditions, ['create_time' => ['between', [$startTime, $endTime]]])) + ->group('date') + ->select(); + $loginUsers = index_by_column('date', $loginUsers); + + $spendConditions = array_merge($conditions, [ + 'pay_time' => ['between', [$startTime, $endTime]], + 'pay_status' => 1, + ]); + if ($containBindCoins == 0) { + $spendConditions['pay_way'] = ['gt', -1]; + } + + // 付费玩家,付费金额 + $payLogs = M('spend', 'tab_') + ->field('count(DISTINCT user_id) count, sum(pay_amount) amount, FROM_UNIXTIME(pay_time, "%Y-%m-%d") date') + ->where($spendConditions) + ->group('date') + ->select(); + $payLogs = index_by_column('date', $payLogs); + + $rows = []; + for ($time = $startTime; $time < $endTime; $time = $time + 24*3600) { + $date = date('Y-m-d', $time); + $newUser = isset($newUsers[$date]) ? $newUsers[$date]['count'] : 0; + $loginUser = isset($loginUsers[$date]) ? $loginUsers[$date]['count'] : 0; + $payAmount = isset($payLogs[$date]) ? $payLogs[$date]['amount'] : 0; + $payUser = isset($payLogs[$date]) ? $payLogs[$date]['count'] : 0; + $rows[] = [ + 'date' => $date, + 'new_user' => $newUser, + 'login_user' => $loginUser, + 'pay_amount' => $payAmount, + 'pay_user' => $payUser, + 'pay_rate' => $loginUser > 0 ? (round($payUser / $loginUser * 100, 2)) : '0', + 'arpu' => $loginUser > 0 ? (round($payAmount / $loginUser, 2)) : '0.00', + 'arppu' => $payUser > 0 ? (round($payAmount / $payUser, 2)) : '0.00', + ]; + } + + if (I('export', 0) == 1) { + $fields = [ + 'date' => '日期', + 'new_user' => '新增玩家', + 'login_user' => '活跃玩家', + 'pay_account' => '充值金额', + 'pay_user' => '付费玩家', + 'pay_rate' => '付费率', + 'arpu' => 'ARPU', + 'arppu' => 'ARPPU', + ]; + foreach ($rows as &$item) { + $item['pay_rate'] = $item['pay_rate'] . '%'; + } + + addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'ARPU分析','url'=>U('Stat/userarpu'),'menu'=>'统计-数据分析-ARPU分析']); + + data2csv($rows, '数据分析_ARPU分析', $fields); + exit; + } + + if ($dataOrder) { + $sort = $order == 3 ? SORT_DESC : SORT_ASC; + $orderColumn = array_column($rows, $orderType); + array_multisort($orderColumn, $sort, SORT_REGULAR, $rows); + } + + $this->meta_title = 'ARPU统计'; + $this->assign('baseGames', $baseGames); + $this->assign('records', $rows); + $this->assign('order', $order); + $this->assign('orderType', $orderType); + $this->display(); + } + + public function userarpu_old($p=0) { $request=$_REQUEST; $page = intval($p); diff --git a/Application/Admin/Model/PromoteModel.class.php b/Application/Admin/Model/PromoteModel.class.php index b5d1d781f..3e42063d4 100644 --- a/Application/Admin/Model/PromoteModel.class.php +++ b/Application/Admin/Model/PromoteModel.class.php @@ -80,6 +80,10 @@ class PromoteModel extends Model{ } } + public function login_phone($user) { + $this->autoLogin($user); + } + diff --git a/Application/Admin/View/PromoteLimitRule/form.html b/Application/Admin/View/PromoteLimitRule/form.html new file mode 100644 index 000000000..2912f2344 --- /dev/null +++ b/Application/Admin/View/PromoteLimitRule/form.html @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
*推广公司: + + {$company.company_name} + + + +
*会长: + + {$promote.account} + + + +
开始时间: + +
结束时间: + +
+
+ +
+ + + 返回 + +
+
+
+
+ + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + \ No newline at end of file diff --git a/Application/Admin/View/PromoteLimitRule/records.html b/Application/Admin/View/PromoteLimitRule/records.html new file mode 100644 index 000000000..80a197769 --- /dev/null +++ b/Application/Admin/View/PromoteLimitRule/records.html @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ 搜索 + 添加 + 删除 +
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 推广公司会长账号内外团限制时间操作
aOh! 暂时还没有内容!
+ + {$data.company_name}{$data.promote_account}{$data.company_belong}{$data.limit_rule} +
+ 编辑 + 删除 +
+
+
+
+
+ + + + {$_page|default=''} +
+ + +
+ + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/Stat/userarpu.html b/Application/Admin/View/Stat/userarpu.html index 0a336bf3b..b3404e974 100644 --- a/Application/Admin/View/Stat/userarpu.html +++ b/Application/Admin/View/Stat/userarpu.html @@ -48,18 +48,18 @@ 活跃玩家 当天登录的玩家总数 -
  • +
  • 付费玩家 当天付费的玩家数量
  • -
  • +
  • 付费率 付费玩家/活跃玩家 @@ -83,12 +83,12 @@
    参与统计设置: - +
    @@ -103,11 +103,18 @@
    - - - - + + + + +
    +
    +
    - 导出 + 导出 {$_page|default=''}
    @@ -212,11 +192,12 @@ @@ -251,8 +232,8 @@ $(function(){ if(interval < 0 || start == ''){ layer.msg('请选择搜索时间'); return false; - }else if(interval>90){ - layer.msg('请选择90日内的时间段'); + }else if(interval>31){ + layer.msg('请选择31日内的时间段'); return false; } @@ -285,8 +266,8 @@ $(function(){ $(".paixu").click(function(){ var that=$(this); $data_order=that.attr('data-order'); - $order_type='{$userarpu_order}'; - if($order_type==''||$order_type=='4'){ + $order_type='{$order}'; + if($order_type==0||$order_type=='4'){ $(".sortBy").attr('name','data_order'); val='3,'+$data_order; $(".sortBy").attr('value',val); diff --git a/Application/Admin/View/Stat/userarpu_old.html b/Application/Admin/View/Stat/userarpu_old.html new file mode 100644 index 000000000..de5c56d00 --- /dev/null +++ b/Application/Admin/View/Stat/userarpu_old.html @@ -0,0 +1,407 @@ + + + + + + + + + + + + + +
    +
    +
    + 参与统计设置: + + +
    +
    + +
    +
    + +
    +
    + +  -  + +
    +
    + +
    +
    + +
    + +
    + 搜索 +
    +
    +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    日期▲日期▼日期游戏名称渠道名称新增玩家▲新增玩家▼新增玩家活跃玩家▲活跃玩家▼活跃玩家1日留存▲1日留存▼1日留存充值▲充值▼充值付费玩家▲付费玩家▼付费玩家新付费玩家▲新付费玩家▼新付费玩家付费率▲付费率▼付费率ARPU▲ARPU▼ARPUARPPU▲ARPPU▼ARPPU累计付费玩家▲累计付费玩家▼累计付费玩家详情
    {$vo.time}{$game_name}{$promote_name}{$vo.register_num}{$vo.act_user}{$vo.keep_num}%{$vo.spend}{$vo.spend_people}{$vo.new_pop}{$vo.spend_rate}%{$vo.ARPU}{$vo.ARPPU}{$vo.pop_num}查看
    +
    +
    +
    + 导出 + {$_page|default=''} +
    +
    + + + + +if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Application/Admin/View/Stat/userretention.html b/Application/Admin/View/Stat/userretention.html index aafdbb393..b12f2c343 100644 --- a/Application/Admin/View/Stat/userretention.html +++ b/Application/Admin/View/Stat/userretention.html @@ -47,10 +47,17 @@
    + + + + +
    +
    +
    记住账号 +
    diff --git a/Application/Home/View/default/Index/phoneLogin.html b/Application/Home/View/default/Index/phoneLogin.html new file mode 100644 index 000000000..95416a3d3 --- /dev/null +++ b/Application/Home/View/default/Index/phoneLogin.html @@ -0,0 +1,264 @@ + + + + + + + +
    +
    + + + +
    +
    +
    +
    + +
    + + + +
    + +
    + +
    +
    + + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index d985cc274..8c9a800f7 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -103,6 +103,7 @@