records('A'); } public function accumulative() { $this->records('C'); } public function daily() { $this->records('B'); } public function firstPay() { $this->records('D'); } public function dayAccumulative() { $this->records('E'); } public function weekly() { $this->records('F'); } public function records($awardType) { $params = I('get.'); $params['is_export'] = ($params['export'] ?? 0); $params['page'] = ($params['p'] ?? 1); $params['limit'] = ($params['row'] ?? 10); $baseGameId = $params['base_game_id'] ?? 0; $isExport = $params['is_export'] == 1; if ($params['reviewer_id'] > 0) { $params['review_type'] = 0; } $service = new GameRebateService(); [$records, $count] = $service->listQuery($params, $awardType); $pageTitle = $service->typeDisplayNames[$awardType]; $pageName = $service->typeNames[$awardType]; if (count($records) > 0) { $records = $service->listRange($records); if ($isExport) { $field = $service->getExportHeadings($awardType); addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出' . $pageTitle . '记录','url'=>U('GameRebate/' . $pageName),'menu'=>'推广员-发放福利管理-' . '导出' . $pageTitle . '记录']); data2csv($records, $pageTitle, $field); exit; } } $page = set_pagination($count, $params['limit'] == 'all' ? 99999999 : $params['limit']); 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', $service->sendStatusList); $this->assign('reviewStatusList', $service->reviewStatusList); $this->assign('records', $records); $this->display('records'); } public function review() { $ids = I('ids', []); $status = I('status', 0); try { $adminInfo = $_SESSION['onethink_admin']['user_auth']; $handler = []; $handler['id'] = $adminInfo['uid']; $handler['username'] = $adminInfo['username']; $handler['type'] = 0; $service = new GameRebateService(); $service->review($ids, $status, $handler); $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]]); } public function simulateSpendList() { $params = I('get.'); $isExport = $params['is_export'] ?? 0; $page = $params['page'] ?? 0; $limit = $params['limit'] ?? 0; $baseGameId = $params['base_game_id'] ?? 0; $serverId = $params['server_id'] ?? ''; $roleName = $params['role_name'] ?? ''; $userAccount = $params['user_account'] ?? ''; $reviewStatus = $params['review_status'] ?? -1; $sendStatus = $params['send_status'] ?? -1; $reviewerId = $params['reviewer_id'] ?? 0; $reviewType = $params['review_type'] ?? -1; $where = [ '_string' => '1=1', ]; 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 ($reviewType != -1) { $where['review_type'] = $reviewType; } if (I('review_time_start', '') != '') { $where['_string'] .= ' and review_time>=' . strtotime(I('review_time_start') . ' 00:00:00'); } if (I('review_time_end', '') != '') { $where['_string'] .= ' and review_time<=' . strtotime(I('review_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'); } /* if ($promote) { $promoteService = new PromoteService(); $subSql = M('user', 'tab_')->field(['id'])->where(['_string' => 'promote_id in(' . $promoteService->subInSql($promote) . ')'])->select(false); $where['_string'] .= ' and user_id in(' . $subSql . ')'; } */ $query = M('simulate_spend', 'tab_')->where($where); $count = 0; $records = []; if ($isExport == 1 || $limit == 'all') { $records = $query->order('create_time desc')->select(); $count = count($records); } else { $countQuery = clone $query; $records = $query->order('create_time desc')->page($page, $limit)->select(); $count = $countQuery->count(); } if (count($records) > 0) { $users = []; $userIds = array_column($records, 'user_id'); $users = M('user', 'tab_')->field(['id', 'promote_account'])->where(['id' => ['in', $userIds]])->select(); $users = index_by_column('id', $users); foreach ($records as $key => $record) { $user = $users[$record['user_id']]; $payAmount = 0; /** @todo */ $records[$key]['pay_amount'] = $payAmount; $records[$key]['total_amount'] = $payAmount + $record['amount']; $records[$key]['promote_account'] = $user['promote_account']; $records[$key]['status_text'] = $this->reviewStatusList[$record['status']]; $records[$key]['review_time'] = $record['review_time'] > 0 ? date('Y-m-d H:i:s', $record['review_time']) : '--'; $records[$key]['create_time'] = $record['create_time'] > 0 ? date('Y-m-d H:i:s', $record['create_time']) : '--'; } if ($isExport) { $field = [ 'order_no' => '订单号', 'base_game_name' => '游戏名称', 'server_name' => '区服', 'user_account' => '玩家账号', 'role_id' => '角色ID', 'role_name' => '角色名称', 'promote_account' => '所属推广员', 'pay_amount' => '当前累充金额', 'amount' => '模拟发放金额', 'total_amount' => '可触发返利功能金额', 'create_time' => '添加时间', 'status_text' => '审核状态', 'review_time' => '审核时间', 'reviewer_username' => '审核人', 'remark' => '备注', ]; addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出转区转游模拟发放记录','url'=>U('GameRebate/simulateSpendList'),'menu'=>'推广员-发放福利管理-' . '导出转区转游模拟发放记录']); data2csv($records, '转区转游模拟发放', $field); exit; } } $page = set_pagination($count, $params['limit'] == 'all' ? 99999999 : $params['limit']); 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('servers', $gameRepository->getServersByBaseGameId($baseGameId)); $this->assign('admins', $admins); $this->assign('baseGames', $baseGames); $this->assign('reviewStatusList', []); $this->assign('records', $records); $this->display('records'); } public function addSimulateSpend() { $params = I('post.'); try { $adminInfo = $_SESSION['onethink_admin']['user_auth']; $handler = []; $handler['id'] = $adminInfo['uid']; $handler['username'] = $adminInfo['username']; $service = new GameRebateService(); $service->addSimulateSpend($params, $handler); $this->ajaxReturn([ 'status' => 1, 'message' => '保存成功' ]); } catch (\Exception $e) { $this->ajaxReturn([ 'status' => 0, 'message' => $e->getMessage() ]); } } public function reviewSimulateSpend() { $ids = I('ids', []); $status = I('status', 0); try { $adminInfo = $_SESSION['onethink_admin']['user_auth']; $handler = []; $handler['id'] = $adminInfo['uid']; $handler['username'] = $adminInfo['username']; $service = new GameRebateService(); $service->reviewSimulateSpend($ids, $status, $handler); $this->ajaxReturn([ 'status' => 1, 'message' => '操作成功' ]); } catch (\Exception $e) { $this->ajaxReturn([ 'status' => 0, 'message' => $e->getMessage() ]); } } }