$value) { $pro_id1[] = $value['id']; } if (!empty($pro_id1)) { $pro_id2 = array_merge($pro_id1, array(get_pid())); } else { $pro_id2 = array(get_pid()); } // $map['promote_id'] = array('in', $pro_id2); if ($_REQUEST['user_account'] == '%') { $map['user_account'] = array('like', '%\\' . $_REQUEST['user_account'] . '%'); unset($_REQUEST['user_account']); } elseif ($_REQUEST['user_account'] == 0) { $map['user_account'] = array('like', '%' . $_REQUEST['user_account'] . '%'); unset($_REQUEST['user_account']); } elseif (isset($_REQUEST['user_account']) && trim($_REQUEST['user_account'])) { $map['user_account'] = array('like', '%' . $_REQUEST['user_account'] . '%'); unset($_REQUEST['user_account']); } if (isset($_REQUEST['game_appid']) && $_REQUEST['game_appid'] != '' && $_REQUEST['game_appid'] != 0) { $map['game_id'] = $_REQUEST['game_appid']; } if ($_REQUEST['promote_id'] > 0) { if (PID == $_REQUEST['promote_id']) { $map['promote_id'] = PID; } else { $pro_id1 = get_prmoote_chlid_account($_REQUEST['promote_id']); $pro_arr = array_column($pro_id1, 'id'); $pro_arr[] = $_REQUEST['promote_id']; $map['promote_id'] = array('in', $pro_arr); } } if (isset($_REQUEST['order_number']) && trim($_REQUEST['order_number'])) { $map['pay_order_number'] = array('like', '%' . $_REQUEST['order_number'] . '%'); unset($_REQUEST['order_number']); } if (!empty($_REQUEST['time_start']) || !empty($_REQUEST['time_end'])) { $map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['time_start']), $_REQUEST['time_end'] == '' ? time() : strtotime($_REQUEST['time_end']) + 24 * 60 * 60 - 1)); unset($_REQUEST['time_start']); unset($_REQUEST['time_end']); } if (I('request.version', 1) == 1) { $map['pay_way'] = array('neq', -1); } else { $map['pay_way'] = array('eq', -1); } if (isset($_REQUEST['sdk_version']) && trim($_REQUEST['sdk_version'])) { $map['sdk_version'] = (int)$_REQUEST['sdk_version']; unset($_REQUEST['sdk_version']); } $map['pay_status'] = 1; $map['is_check'] = array('neq', 2); $total1 = M('spend', "tab_")->where($map)->sum('pay_amount'); $total2 = M('spend', "tab_")->where($map)->sum('cost'); $this->assign("total_amount", $total1); $this->assign("total_cost", $total2); $this->meta_title = "用户充值"; $this->lists("Spend", $p, $map); } public function register($p = 0) { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 $row = 10; if (isset($_REQUEST['row'])) { $row = $_REQUEST['row']; } else { $row = 10; } if ($_REQUEST['promote_id'] > 0) { if (PID == $_REQUEST['promote_id']) { $map['tab_user.promote_id'] = $_REQUEST['promote_id']; } else { $pro_id = get_prmoote_chlid_account($_REQUEST['promote_id']); foreach ($pro_id as $key => $value) { $pro_id1[] = $value['id']; } if (!empty($pro_id1)) { $pro_id2 = array_merge($pro_id1, [$_REQUEST['promote_id']]); } else { $pro_id2 = $_REQUEST['promote_id']; } $map['tab_user.promote_id'] = array('in', $pro_id2); } } else { $pro_id = get_prmoote_chlid_account(session('promote_auth.pid')); foreach ($pro_id as $key => $value) { $pro_id1[] = $value['id']; } if (!empty($pro_id1)) { $pro_id2 = array_merge($pro_id1, array(get_pid())); } else { $pro_id2 = array(get_pid()); } $map['tab_user.promote_id'] = array('in', $pro_id2); } if ($_REQUEST['user_account'] == '%') { $map['tab_user.account'] = array('like', '%\\' . $_REQUEST['user_account'] . '%'); } elseif (isset($_REQUEST['user_account']) && $_REQUEST['user_account'] == 0) { $map['tab_user.account'] = array('like', '%' . $_REQUEST['user_account'] . '%'); } elseif (isset($_REQUEST['user_account']) && trim($_REQUEST['user_account'])) { $map['tab_user.account'] = array('like', '%' . $_REQUEST['user_account'] . '%'); } if (isset($_REQUEST['game_appid']) && $_REQUEST['game_appid'] != 0) { $map['tab_user.fgame_id'] = $_REQUEST['game_appid']; } if (isset($_REQUEST['sdk_version']) && (int)$_REQUEST['sdk_version'] > 0) { $map['tab_user_play.sdk_version'] = (int)$_REQUEST['sdk_version']; } if (!empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) { $map['tab_user.register_time'] = array('BETWEEN', array(strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 24 * 60 * 60 - 1)); } elseif (!empty($_REQUEST['time_start']) && empty($_REQUEST['time_end'])) { $map['tab_user.register_time'] = array('egt', strtotime($_REQUEST['time_start'])); } elseif (empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) { $map['tab_user.register_time'] = array('elt', strtotime($_REQUEST['time_end']) + 24 * 60 * 60 - 1); } if (!empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { $map['tab_user.register_time'] = array('BETWEEN', array(strtotime($_REQUEST['start']), strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1)); } $map['tab_user.is_check'] = array('neq', 2); $map['tab_user.puid'] = 0; $data = D('User') ->field('tab_user.*,tab_user_play.server_name,tab_user_play.sdk_version') ->join('left join tab_user_play on tab_user.id = tab_user_play.user_id') ->where('tab_user.fgame_id = tab_user_play.game_id or tab_user.fgame_id is null') ->where($map) ->order('tab_user.id desc') ->group('tab_user.account') ->page($page, $row) ->select(); $count = count($data); $parameter = $_REQUEST; $parameter['p'] = I('get.p', 1); $parameter['row'] = I('get.row'); $page = set_pagination($count, $row, $parameter); if ($page) { $this->assign('_page', $page); } $this->assign('p', $page); $this->assign('count', $count); $this->assign('list_data', $data); $this->meta_title = '注册明细'; $this->display(); } /** *我的对账单 */ public function bill() { $map['promote_id'] = get_pid(); if (isset($_REQUEST['bill_number']) && !empty($_REQUEST['bill_number'])) { $map['bill_number'] = $_REQUEST['bill_number']; } if (isset($_REQUEST['game_id']) && !empty($_REQUEST['game_id'])) { $map['game_id'] = $_REQUEST['game_id']; } if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['bill_start_time'] = array('egt', strtotime($_REQUEST['timestart'])); $map['bill_end_time'] = array('elt', strtotime($_REQUEST['timeend']) + 24 * 3600 - 1); } $model = array( 'm_name' => 'bill', 'map' => $map, 'template_list' => 'bill', 'title' => '我的对账单', ); $user = A('User', 'Event'); $user->bill_list($model, $_GET['p']); } /** *我的结算 */ public function my_earning($p = 1) { $pro_map['id'] = get_pid(); $pro = M("promote", "tab_")->where($pro_map)->find(); $map['promote_id'] = get_pid(); if ($pro['parent_id'] == 0) { if (isset($_REQUEST['settlement_number']) && !empty($_REQUEST['settlement_number'])) { $map['settlement_number'] = ['like', '%' . $_REQUEST['settlement_number'] . '%']; } if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { /*$map['bill_start_time'] = array('egt',strtotime($_REQUEST['timestart'])); $map['bill_end_time'] = array('elt',strtotime($_REQUEST['timeend'])+24*3600-1);*/ $map['starttime'] = array('egt', strtotime($_REQUEST['timestart'])); $map['endtime'] = array('elt', strtotime($_REQUEST['timeend']) + 24 * 3600 - 1); } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { $map['starttime'] = array('egt', strtotime($_REQUEST['timestart'])); } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['endtime'] = array('elt', strtotime($_REQUEST['timeend']) + 24 * 3600 - 1); } $model = array( 'm_name' => 'TotalSettlement', 'map' => $map, 'fields' => true, 'order' => 'create_time desc ', 'template_list' => 'my_earning', 'title' => '我的结算', ); } else { if (isset($_REQUEST['settlement_number']) && !empty($_REQUEST['settlement_number'])) { $map['settlement_number'] = ['like', '%' . $_REQUEST['settlement_number'] . '%']; } if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['settlement_start_time'] = array('egt', strtotime($_REQUEST['timestart'])); $map['settlement_end_time'] = array('elt', strtotime($_REQUEST['timeend']) + 24 * 3600 - 1); } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { $map['settlement_start_time'] = array('egt', strtotime($_REQUEST['timestart'])); } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['settlement_end_time'] = array('elt', strtotime($_REQUEST['timeend']) + 24 * 3600 - 1); } $model = array( 'm_name' => 'son_settlement', 'fields' => 'settlement_number,settlement_start_time,create_time, settlement_end_time,game_id,game_name,promote_id, promote_account,pattern,bind_coin_status,floor(sum(sum_money*100))/100 as sum_money, sum(reg_number) as reg_number,ratio,money,floor(sum(jie_money*100))/100 as jie_money,status,ti_status', 'map' => $map, 'template_list' => 'my_earning_sub', 'order' => 'create_time desc', 'group' => 'settlement_number, create_time', 'title' => '我的结算', ); } $user = A('User', 'Event'); $this->assign("parent_id", $pro['parent_id']); $user->shou_list($model, $p); } /** *子渠道结算单 */ public function son_earning_($p = 1) { if (PLEVEL == 0) { if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend']) && !empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $starttime = strtotime($_REQUEST['timestart']); $endtime = strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1; $this->assign('starttime', $starttime); $this->assign('endtime', $endtime); $map[0]['register_time'] = array('BETWEEN', array($starttime, $endtime)); $map[1]['pay_time'] = array('BETWEEN', array($starttime, $endtime)); unset($_REQUEST['timestart']); unset($_REQUEST['timeend']); $map[1]['parent_id'] = $map[0]['u.parent_id'] = PID; if (isset($_REQUEST['ch_promote_id']) && !empty($_REQUEST['ch_promote_id'])) { $map[1]['s.promote_id'] = $map[0]['u.promote_id'] = $_REQUEST['ch_promote_id']; } $model = array( 'title' => '子渠道结算单', 'template_list' => 'son_earning', ); $user = A('User', 'Event'); $user->check_bill($model, $p, $map); } else { $this->display(); } } else { $model = array( 'm_name' => 'SonSettlement', 'order' => 'id ', 'title' => '结算账单', 'template_list' => 'son_earning', ); $user = A('User', 'Event'); $user->money_list($model, $p); } } //子渠道结算单 public function son_list($p = 0) { if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['settlement_start_time'] = array('egt', strtotime($_REQUEST['timestart'])); $map['settlement_end_time'] = array('elt', strtotime($_REQUEST['timeend']) + 86399); } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { $map['settlement_start_time'] = array('egt', strtotime($_REQUEST['timestart'])); $map['settlement_end_time'] = array('elt', time()); } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['settlement_end_time'] = array('elt', strtotime($_REQUEST['timeend']) + 86399); } if (!empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { $start = strtotime($_REQUEST['start']); $end = strtotime($_REQUEST['end']) + 86399; $map['create_time'] = array('BETWEEN', array($start, $end)); } elseif (!empty($_REQUEST['start']) && empty($_REQUEST['end'])) { $start = strtotime($_REQUEST['start']); $end = time(); $map['create_time'] = array('BETWEEN', array($start, $end)); } elseif (empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { $end = strtotime($_REQUEST['end']) + 86399; $map['create_time'] = array('elt', $end); } if (!empty($_REQUEST['ch_promote_id'])) { $map['promote_id'] = $_REQUEST['ch_promote_id']; } else { $promote = M('Promote', 'tab_')->field('id')->where(['parent_id' => PID])->select(); $zi_p = implode(',', array_column($promote, 'id')); $map['promote_id'] = array('in', "$zi_p"); } $model = array( 'm_name' => 'SonSettlement', 'fields' => array( 'settlement_number', 'settlement_start_time', 'settlement_end_time', 'promote_id', 'promote_account', 'bind_coin_status', 'FLOOR(sum(sum_money*100))/100 as sum_money', 'sum(reg_number) as reg_number', 'FLOOR(sum(jie_money*100))/100 as jie_money', 'ti_status', 'create_time' ), 'order' => 'create_time desc', 'group' => 'settlement_number,create_time', 'title' => '子渠道结算单', 'template_list' => 'son_list', ); $user = A('User', 'Event'); $user->money_list($model, $p, $map); } /** *子渠道结算单 */ public function son_earning($p = 0) { if (!empty($_REQUEST['timestart']) || !empty($_REQUEST['timeend'])) { $starttime = empty($_REQUEST['timestart']) ? strtotime("-7 day {$_REQUEST['timeend']}") : strtotime($_REQUEST['timestart']); $endtime = empty($_REQUEST['timeend']) ? mktime(23, 59, 59, date('m'), date('d') - 1, date('Y')) : strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1; $this->assign('starttime', date('Y-m-d', $starttime)); $this->assign('endtime', date('Y-m-d', $endtime)); $mapp['u.register_time'] = array('BETWEEN', array($starttime, $endtime)); $mapp['u.' . SETTLEMENT_GRADE] = 0; $map['s.pay_time'] = array('BETWEEN', array($starttime, $endtime)); $map['s.pay_status'] = 1; $map['s.' . SETTLEMENT_GRADE] = 0; if ($_REQUEST['bind_coin'] == 0) { $map['s.pay_way'] = array('neq', -1); } unset($_REQUEST['timestart']); unset($_REQUEST['timeend']); if (isset($_REQUEST['ch_promote_id']) && !empty($_REQUEST['ch_promote_id'])) { $chid = $_REQUEST['ch_promote_id']; $promote_child = get_sub_channel_id($chid, PRO_GRADE + 1); $map['s.promote_id'] = $mapp['u.promote_id'] = array('in', $promote_child); } else { $promote_child = get_zi_promote_id(PID); if (empty($promote_child)) { $this->error('该渠道无子渠道'); } $map['s.promote_id'] = $mapp['u.promote_id'] = array('in', $promote_child); } $model = array( 'fields' => 'sum(s.pay_amount) as total_amount,s.promote_account,s.promote_id,s.game_name,s.game_id,s.sub_status', 'm_name' => 'Spend', 'title' => '子渠道结算单', 'template_list' => 'son_earning', 'join' => 'tab_apply on tab_Spend.game_id=tab_apply.game_id and tab_Spend.promote_id=tab_apply.promote_id', 'group' => 's.promote_id,s.game_id', 'currentid' => $chid ? $chid : '', ); $mmap = array($mapp, $map); $user = A('User', 'Event'); $user->check_child_bill($model, $p, $mmap); } else { $this->meta_title = '子渠道结算'; $this->display(); } } public function generatesub() { //$data = $_REQUEST; if (empty($_REQUEST['ids'])) { $this->error('请选择要结算的数据'); } else { $settData = array(); $settlement_number = 'js_' . date('YmdHis', time()) . rand(100, 999); $create_time = time(); $start = $_REQUEST['timestart']; $end = $_REQUEST['timeend']; foreach ($_REQUEST['ids'] as $key => $value) { $data = json_decode($value, true); $data['settlement_number'] = $settlement_number; $data['create_time'] = time(); $data['settlement_start_time'] = strtotime($data['settlement_start_time']); $data['settlement_end_time'] = strtotime($data['settlement_end_time']); switch ($data['cooperation']) { case 'CPS': $data['pattern'] = 0; $cps = $data['ratio']; $data['jie_money'] = round(($cps * $data['sum_money']) / 100, 2); break; case 'CPA': $data['pattern'] = 1; $cpa = $data['money']; $data['jie_money'] = round($cpa * $data['reg_number'], 2); break; } $userMap['register_time'] = array('BETWEEN', array($data['settlement_start_time'], $data['settlement_end_time'] + 86399)); $userMap['fgame_id'] = $data['game_id']; $userMap[SETTLEMENT_GRADE] = $spendMap[SETTLEMENT_GRADE] = 0; $userMap['promote_id'] = $spendMap['promote_id'] = array('in', $data['tpid']); $spendMap['game_id'] = $data['game_id']; $spendMap['pay_time'] = $userMap['register_time']; $user = M('user', 'tab_')->where($userMap)->save(array(SETTLEMENT_GRADE => 1)); $spend = M('spend', 'tab_')->where($spendMap)->save(array(SETTLEMENT_GRADE => 1)); $settData[$key] = $data; } $result = M('SonSettlement', 'tab_')->addAll($settData); if ($result) { /*$this->success('生成结算单成功!',U('son_earning?success=1',array('timestart' => $start,'timeend' => $end)),true);*/ $this->success('生成结算单成功!', U('son_list'), true); } else { $this->error('生成结算单失败!', U('son_earning?fall=1', array('timestart' => $start, 'timeend' => $end)), true); } } $this->error('生成结算单失败!!!', U('son_earning?fall=1', array('timestart' => $start, 'timeend' => $end)), true); } //申请提现 public function apply_withdraw($id, $op = 0) { $map['id'] = $id; $with = M("withdraw", "tab_"); $totalSett = M("TotalSettlement", "tab_")->where($map)->find(); $with_map['settlement_number'] = $totalSett['settlement_number']; $fid = $with->where($with_map)->find(); if ($fid == null) { $add['settlement_number'] = $totalSett['settlement_number']; $add['sum_money'] = $totalSett['jie_money'] ? $totalSett['jie_money'] : $totalSett['sum_money']; $add['promote_id'] = $totalSett['promote_id']; $add['promote_account'] = $totalSett['promote_account']; $add['create_time'] = time(); $add['status'] = 0; $with->add($add); M("TotalSettlement", "tab_")->where($map)->save(array('ti_status' => 0)); $settMap['promote_id'] = $totalSett['promote_id']; $settMap['starttime'] = $totalSett['starttime']; $settMap['endtime'] = $totalSett['endtime']; $settMap['create_time'] = $totalSett['create_time']; M("settlement", "tab_")->where($settMap)->save(array('ti_status' => 0)); echo json_encode(array("status" => 1)); } else { if ($op > 0) { $with->where($with_map)->setField('status', 0); M("settlement", "tab_")->where($map)->setField('ti_status', 0); M("TotalSettlement", "tab_")->where($map)->save(array('ti_status' => 0)); echo json_encode(array("status" => 1)); } else { echo json_encode(array("status" => 0)); } } } //申请提现 public function son_apply_withdraw($settlement_number = '') { $map['settlement_number'] = $settlement_number; $with_map['settlement_number'] = $totalSett['settlement_number']; $result = M("SonSettlement", "tab_")->where($map)->save(array('ti_status' => 0)); if ($result !== false) { echo json_encode(array("status" => 1)); } else { echo json_encode(array("status" => 0)); } } public function audit_withdraw($settlement_number = '') { $map['settlement_number'] = $settlement_number; $with_map['settlement_number'] = $totalSett['settlement_number']; $result = M("SonSettlement", "tab_")->where($map)->save(array('ti_status' => 1)); if ($result !== false) { $this->success('审核成功'); } else { $this->error('审核失败'); } } public function arpu_analysis() { $this->meta_title = "ARPU统计"; A('User', 'Event')->arpu_analysis(); } public function cha_userarpu($p = 0) { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据arraypage $arraypage = $page ? $page : 1; //默认显示第一页数据 $row = 10; if (isset($_REQUEST['row'])) { $row = $_REQUEST['row']; } else { $row = 10; } $time = $_REQUEST['time']; $promote_id = $_REQUEST['promote_id']; /* if ($promote_id <1) { $pid = D('Promote')->get_child_promote(PID,'id'); if (empty($pid[0])) { $promote_id = PID; } else { $id = implode(',',array_column($pid,'id')); $promote_id = PID.','.$id; } } */ $join = "left join tab_user u on u.fgame_id = tab_game.id"; if ($time == '') { $this->error('参数错误,缺少时间'); } else { $map['register_time'] = array('between', array(strtotime($time), strtotime($time) + 24 * 60 * 60 - 1)); } /* if($promote_id!=''){ $map_list['promote_id']=array('in',$promote_id); $map['promote_id']=array('in',$promote_id); $join .= " AND u.promote_id = {$promote_id}"; } */ if ($promote_id > 0) { if (PID == $promote_id) { $pro_arr[] = PID; } else { $pro_id1 = get_prmoote_chlid_account2($promote_id); $pro_arr = array_column($pro_id1, 'id'); $pro_arr[] = $promote_id; } $map['promote_id'] = array('in', $pro_arr); $map_list['promote_id'] = array('in', $pro_arr); $promote_id = implode(',', $pro_arr); $join .= " AND u.promote_id in ({$promote_id})"; } else { $pid = D('Promote')->get_child_promote(PID, 'id'); if (empty($pid[0])) { $pro_arr[] = PID; } else { $pro_arr = array_column($pid, 'id'); $pro_arr[] = PID; } $map['promote_id'] = array('in', $pro_arr); $map_list['promote_id'] = array('in', $pro_arr); $promote_id = implode(',', $pro_arr); $join .= " AND u.promote_id in ({$promote_id})"; } $spend2 = D('Spend'); $data = M('Game', 'tab_')->field('id as game_id, game_name')->order('id desc')->select(); foreach ($data as $key => $value) { $game_id = $value['game_id']; $map_list['game_id'] = $game_id; $user = M('User', 'tab_'); $spend = M('spend', 'tab_'); //新增人数 $rdata = $user ->field('count(id) as register_num') ->where(array('fgame_id' => $game_id)) ->where(array_merge($map, ['puid' => 0])) ->find(); $data[$key]['register_num'] = $rdata['register_num']; //活跃玩家 //$data[$key]['act_user'] = $this->count_act_user($time,$game_id,$promote_id); $activedata = D('User')->login_count_by_time(strtotime($time), strtotime($time) + 86399, $game_id, $promote_id); $data[$key]['act_user'] = $activedata[0]['login_num'] ? $activedata[0]['login_num'] : 0; //1日留存 $mapl = $map_list; $mapl["FROM_UNIXTIME(register_time,'%Y-%m-%d')"] = $time; $mapl['tab_user.promote_id'] = $mapl['promote_id']; $mapl['tab_user.puid'] = 0; unset($mapl['promote_id']); $login_time = date('Y-m-d', strtotime("+1 day", strtotime($time))); $num = $user ->field('count(DISTINCT tab_user.id) as num') ->join("right join tab_user_login_record as ur on ur.user_id = tab_user.id and FROM_UNIXTIME(ur.login_time,'%Y-%m-%d') = '{$login_time}'") ->where($mapl) ->find(); $data[$key]['keep_num'] = round($num['num'] / $data[$key]['register_num'], 4) * 100; //充值 $mapl = $map_list; empty($game_name) || $mapl['game_name'] = array('like', '%' . $game_name . '%'); $mapl['pay_status'] = 1; $mapl["FROM_UNIXTIME(pay_time,'%Y-%m-%d')"] = $time; if (I('bangbi') == 1) { $mapl['pay_way'] = array('neq', '-10'); $bangbi = true; } else { $mapl['pay_way'] = array('neq', -1); $bangbi = false; } $spend = $spend->field("IFNULL(sum(pay_amount),0) as money,IFNULL(count(distinct user_id),0) as people")->where($mapl)->find(); $data[$key]['spend'] = $spend['money']; //付费玩家数 $data[$key]['spend_people'] = $spend['people']; //新付费玩家 $newsdata = $spend2->pay_count_by_time_class([$time], $game_id, $promote_id, 1, $bangbi); $data[$key]['spend_news'] = $newsdata[0]['pay_num'] ? $newsdata[0]['pay_num'] : 0; //付费率 $data[$key]['spend_rate'] = round($data[$key]['spend_people'] / $data[$key]['act_user'], 4) * 100; //ARPU $data[$key]['ARPU'] = round($data[$key]['spend'] / $data[$key]['act_user'], 2); //ARPPU $data[$key]['ARPPU'] = round($data[$key]['spend'] / $data[$key]['spend_people'], 2); if ($data[$key]['register_num'] == 0 && $data[$key]['act_user'] == 0 && $data[$key]['keep_num'] == 0 && $data[$key]['spend'] == 0 && $data[$key]['spend_people'] == 0) { unset($data[$key]); } } $count = count($data); /* if($count > $row){ $page = new \Think\Page($count, $row); $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%'); $this->assign('_page', $page->show()); } */ /*$page = set_pagination($count,++$count); if($page) {$this->assign('_page', $page);}*/ $this->assign('_page', '