records('A'); } public function accumulative() { $this->records('C'); } public function daily() { $this->records('B'); } public function records($awardType) { $page = I('p', 1); $row = I('row', 10); $baseGameId = I('base_game_id', 0); $serverId = I('server_id', ''); $roleName = I('role_name', ''); $userAccount = I('user_account', ''); $reviewStatus = I('review_status', -1); $sendStatus = I('send_status', -1); $reviewerId = I('reviewer_id', 0); $where = [ '_string' => '1=1', ]; $where['type'] = $awardType; if ($baseGameId != 0) { $where['base_game_id'] = $baseGameId; } if ($userAccount != '') { $where['user_account'] = ['like', $userAccount . '%']; } if ($roleName != '') { $where['role_name'] = ['like', $roleName . '%']; } if ($serverId != '') { $where['server_id'] = $serverId; } if ($reviewStatus != -1) { $where['review_status'] = $reviewStatus; } if ($sendStatus != -1) { $where['send_status'] = $sendStatus; } if ($reviewerId != 0) { $where['reviewer_id'] = $reviewerId; } if (I('send_time_start', '') != '') { $where['_string'] .= ' and send_time>=' . strtotime(I('send_time_start') . ' 00:00:00'); } if (I('send_time_end', '') != '') { $where['_string'] .= ' and send_time<=' . strtotime(I('send_time_end') . ' 23:59:59'); } if (I('create_time_start', '') != '') { $where['_string'] .= ' and create_time>=' . strtotime(I('create_time_start') . ' 00:00:00'); } if (I('create_time_end', '') != '') { $where['_string'] .= ' and create_time<=' . strtotime(I('create_time_end') . ' 23:59:59'); } $query = M('rebate_orders', 'tab_')->where($where); $records = []; if (I('export', 0) == 1 || $row == 'all') { $records = $query->order('create_time desc')->select(); } else { $countQuery = clone $query; $records = $query->order('create_time desc')->page($page, $row)->select(); $count = $countQuery->count(); } $sendStatusList = [ 0 => '待发放', 1 => '发放成功', 2 => '发放异常', ]; $reviewStatusList = [ 0 => '待审核', 1 => '审核通过', 2 => '审核拒绝', ]; $pageTitles = [ 'A' => '单笔充值福利', 'B' => '月卡福利发放', 'C' => '累充福利发放', ]; $pageNames = [ 'A' => 'single', 'B' => 'daily', 'C' => 'accumulative', ]; $pageTitle = $pageTitles[$awardType]; $pageName = $pageNames[$awardType]; $newLine = I('export', 0) == 1 ? "\n" : '
'; if (count($records) > 0) { foreach ($records as $key => $record) { $records[$key]['review_status_text'] = $reviewStatusList[$record['review_status']]; $records[$key]['review_time'] = $record['review_time'] > 0 ? date('Y-m-d H:i:s', $record['review_time']) : '--'; $records[$key]['send_status_text'] = $sendStatusList[$record['send_status']]; $records[$key]['send_time'] = $record['send_time'] > 0 ? date('Y-m-d H:i:s', $record['send_time']) : '--'; $records[$key]['create_time'] = $record['create_time'] > 0 ? date('Y-m-d H:i:s', $record['create_time']) : '--'; $records[$key]['award_date_range'] = is_null($record['award_started_at']) || is_null($record['award_ended_at']) ? '' : $record['award_started_at'] . ' ~ ' . $record['award_ended_at']; $records[$key]['gift_content'] = implode($newLine, explode('|', $record['gift_content'])); } if (I('export', 0) == 1) { $field = [ 'base_game_name' => '游戏名称', 'server_name' => '区服', 'user_account' => '账号', 'role_id' => '角色ID', 'role_name' => '角色名称', 'gift_content' => '奖励内容', 'create_time' => '订单生成时间', 'review_status_text' => '审核状态', 'review_time' => '审核时间', 'send_status_text' => '发放状态', 'send_time' => '发放时间', 'reviewer_username' => '审核人', ]; if ($awardType == 'A') { $field['pay_amount'] = '充值金额'; } elseif ($awardType == 'B') { $field['pay_amount'] = '当日累计充值金额'; $field['award_date_range'] = '可领取福利日期'; } elseif ($awardType == 'C') { $field['amount'] = '达到档位金额'; } addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出' . $pageTitle . '记录','url'=>U('GameRebate/' . $pageName),'menu'=>'推广员-发放福利管理-' . '导出' . $pageTitle . '记录']); data2csv($records, $pageTitle, $field); exit; } } $page = set_pagination($count, $row == 'all' ? 99999999 : $row); if($page) { $this->assign('_page', $page); } $admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select(); $baseGames = M('base_game', 'tab_')->select(); $gameRepository = new GameRepository(); $this->assign('pageTitle', $pageTitle); $this->assign('pageName', $pageName); $this->assign('awardType', $awardType); $this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId)); $this->assign('admins', $admins); $this->assign('baseGames', $baseGames); $this->assign('sendStatusList', $sendStatusList); $this->assign('reviewStatusList', $reviewStatusList); $this->assign('records', $records); $this->display('records'); } public function review() { $ids = I('ids', []); $status = I('status', 0); try { $service = new GameRebateService(); $service->review($ids, $status); $this->ajaxReturn([ 'status' => 1, 'message' => '操作成功' ]); } catch (\Exception $e) { $this->ajaxReturn([ 'status' => 0, 'message' => $e->getMessage() ]); } } public function getServers() { $gameId = I('game_id', 0); $gameRepository = new GameRepository(); $servers = $gameRepository->getServersByBaseGameId($gameId); return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]); } }