From d188bb90720c9fc1c5180b83f7c23b078c838991 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Fri, 17 Sep 2021 09:29:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=84=E7=81=B5=E5=A5=91=E7=BA=A6=E8=BF=94?= =?UTF-8?q?=E5=88=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/GameApiController.class.php | 35 +- .../Controller/GameRebateController.class.php | 154 ++----- .../Controller/PromoteController.class.php | 1 + .../Admin/View/GameRebate/records.html | 14 + Application/Admin/View/Promote/edit.html | 14 + .../Base/Service/GameRebateService.class.php | 215 +++++++++- .../Tool/GameResource/XlqyClient.class.php | 176 ++++++++ .../Tool/GameResource/XyyClient.class.php | 12 +- .../Home/Controller/BaseController.class.php | 11 +- .../Controller/GameRebateController.class.php | 131 ++++++ .../Home/View/default/GameRebate/records.html | 404 ++++++++++++++++++ .../View/default/Public/promote_base.html | 11 + .../View/default/TestingResource/batches.html | 2 +- Data/update.sql | 10 +- 14 files changed, 1033 insertions(+), 157 deletions(-) create mode 100644 Application/Base/Tool/GameResource/XlqyClient.class.php create mode 100644 Application/Home/Controller/GameRebateController.class.php create mode 100644 Application/Home/View/default/GameRebate/records.html diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php index 7ed10785a..56a4bc6b1 100644 --- a/Application/Admin/Controller/GameApiController.class.php +++ b/Application/Admin/Controller/GameApiController.class.php @@ -13,6 +13,8 @@ use GuzzleHttp\Client; use think\Db; use Base\Tool\GameResource; use Base\Tool\GameResource\SbcqClient; +use Base\Tool\GameResource\XlqyClient; +use Base\Tool\GameResource\XyyClient; class GameApiController extends Think { @@ -64,6 +66,24 @@ class GameApiController extends Think { public function send() { + $giftItem = [ + 'id' => 240, + 'num' => 1, + ]; + $order = [ + 'id' => 1, + 'user_id' => 77, + 'user_account' => '13635240735', + 'server_id' => '157', + 'role_id' => '578157', + 'role_name' => '小蜗牛', + ]; + $client = new XlqyClient(); + $result = $client->sendEmail($giftItem, $order); + var_dump($result); + + return; + $giftItem = [ 'id' => 1782, 'num' => 1, @@ -137,14 +157,13 @@ class GameApiController extends Think { public function rebateSend() { $service = new GameRebateService(); - $service->sendAll('A'); - $service->sendAll('B'); - $service->sendAll('C'); - } + $service->sendOnce('A'); + $service->sendOnce('C'); + $service->sendOnce('D'); + $service->sendOnce('E'); - public function rebateSendDaily() - { - $service = new GameRebateService(); - $service->sendDaily(date('Y-m-d')); + $date = date('Y-m-d'); + $service->sendDaily('B', $date); + $service->sendDaily('F', $date); } } diff --git a/Application/Admin/Controller/GameRebateController.class.php b/Application/Admin/Controller/GameRebateController.class.php index 23c2ba243..b058557f7 100644 --- a/Application/Admin/Controller/GameRebateController.class.php +++ b/Application/Admin/Controller/GameRebateController.class.php @@ -27,139 +27,47 @@ class GameRebateController extends ThinkController $this->records('B'); } - public function records($awardType) + public function firstPay() { - $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; - } + $this->records('D'); + } - 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'); - } + public function dayAccumulative() + { + $this->records('E'); + } - 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'); - } + 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); - $query = M('rebate_orders', 'tab_')->where($where); + $baseGameId = $params['base_game_id'] ?? 0; + $isExport = $params['is_export'] == 1; - $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(); - } + $service = new GameRebateService(); + [$records, $count] = $service->listQuery($params, $awardType); - $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" : '
'; + $pageTitle = $service->typeDisplayNames[$awardType]; + $pageName = $service->typeNames[$awardType]; 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'] = '达到档位金额'; - } - + $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, $row == 'all' ? 99999999 : $row); + + $page = set_pagination($count, $params['limit'] == 'all' ? 99999999 : $params['limit']); if($page) { $this->assign('_page', $page); @@ -175,8 +83,8 @@ class GameRebateController extends ThinkController $this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId)); $this->assign('admins', $admins); $this->assign('baseGames', $baseGames); - $this->assign('sendStatusList', $sendStatusList); - $this->assign('reviewStatusList', $reviewStatusList); + $this->assign('sendStatusList', $service->sendStatusList); + $this->assign('reviewStatusList', $service->reviewStatusList); $this->assign('records', $records); $this->display('records'); } diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index 2fbc5ad0e..4d034330d 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -445,6 +445,7 @@ class PromoteController extends ThinkController $data['can_view_recharge'] = $_POST['can_view_recharge']; $data['ts_over_apply'] = $_POST['ts_over_apply'] ?? 0; $data['shift_over_apply'] = $_POST['shift_over_apply'] ?? 0; + $data['rebate_over_perm'] = $_POST['rebate_over_perm'] ?? 0; if (empty($pwd)) { unset($data['password']); } diff --git a/Application/Admin/View/GameRebate/records.html b/Application/Admin/View/GameRebate/records.html index b24ca8bc2..30f088fc5 100644 --- a/Application/Admin/View/GameRebate/records.html +++ b/Application/Admin/View/GameRebate/records.html @@ -192,6 +192,13 @@ 可领取福利日期 达到档位金额 + + 首充金额 + + 当日累计充值金额 + 达成日期 + + 可领取福利日期 奖励内容 订单生成时间 @@ -230,6 +237,13 @@ {$data.award_date_range} {$data.amount} + + {$data.pay_amount} + + {$data.pay_amount} + {$data.award_date} + + {$data.award_date_range} {$data.gift_content} diff --git a/Application/Admin/View/Promote/edit.html b/Application/Admin/View/Promote/edit.html index dea384bf2..f75d6667b 100644 --- a/Application/Admin/View/Promote/edit.html +++ b/Application/Admin/View/Promote/edit.html @@ -364,6 +364,20 @@ + + 返利管理权限: + + + + + + 开启后该推广员有权限查看并操作整个公会用户返利功能 + + 备注: diff --git a/Application/Base/Service/GameRebateService.class.php b/Application/Base/Service/GameRebateService.class.php index 3864afcc0..bd454cdce 100644 --- a/Application/Base/Service/GameRebateService.class.php +++ b/Application/Base/Service/GameRebateService.class.php @@ -2,13 +2,54 @@ namespace Base\Service; use Base\Tool\GameResource\SbcqClient; +use Base\Tool\GameResource\XlqyClient; use Base\Tool\GameResource\XyyClient; use Exception; use GuzzleHttp\Client; class GameRebateService { - public function sendByOrder($order) + + public $sendStatusList = [ + 0 => '待发放', + 1 => '发放成功', + 2 => '发放异常', + ]; + + public $reviewStatusList = [ + 0 => '待审核', + 1 => '审核通过', + 2 => '审核拒绝', + ]; + + public $typeDisplayNames = [ + 'A' => '单笔充值福利', + 'B' => '月卡福利发放', + 'C' => '累充福利发放', + 'D' => '首充福利发放', + 'E' => '单日累充福利发放', + 'F' => '周卡福利发放', + ]; + + public $typeNames = [ + 'A' => 'single', + 'B' => 'daily', + 'C' => 'accumulative', + 'D' => 'firstPay', + 'E' => 'dayAccumulative', + 'F' => 'weekly', + ]; + + public function isGiftItemSend($order, $item) + { + // 每日发放奖励暂时通过send_status来判断是否第一次发放 + if ($order['send_status'] = 1 && isset($item['once']) && $item['once']) { + return false; + } + return true; + } + + public function sendByOrder($order, $handleDate = null) { $gift = M('rebate_gifts', 'tab_')->where(['base_game_id' => $order['base_game_id'], 'type' => $order['type'], 'gift_key' => $order['gift_key']])->find(); $hasError = false; @@ -22,17 +63,26 @@ class GameRebateService } $giftItems = json_decode($gift['gifts'], true); foreach ($giftItems as $giftItem) { + if (!$this->isGiftItemSend($order, $giftItem)) { + continue; + } $result = $this->sendGift($order, $giftItem); if (!$result['status']) { $hasError = true; } $sendResult .= ($result['message'] ?? '') . ';'; } - M('rebate_orders', 'tab_')->where(['id' => $order['id']])->save([ + + $data = [ 'send_status' => $hasError ? 2 : 1, 'send_time' => time(), 'send_result' => $sendResult, - ]); + ]; + if ($handleDate) { + $data['current_award_date'] = $handleDate; + } + + M('rebate_orders', 'tab_')->where(['id' => $order['id']])->save($data); } private function getClient($baseGameId) @@ -45,8 +95,11 @@ class GameRebateService case 73: $client = new SbcqClient(); break; + case 75: + $client = new XlqyClient(); + break; /* case 9: - $client = new SbcqClient(); + $client = new XlqyClient(); break; */ default: throw new \Exception('客户端未实现'); @@ -89,31 +142,163 @@ class GameRebateService ]); } - public function sendAll($type) + public function sendOnce($type) { $orders = M('rebate_orders', 'tab_')->where(['type' => $type, 'review_status' => 1, 'send_status' => 0])->select(); foreach ($orders as $order) { - if ($type == 'B') { - if (time() < strtotime($order['award_started_at'] . ' 00:00:00') || time() > strtotime($order['award_ended_at'] . ' 23:59:59')) { - continue; - } - } $this->sendByOrder($order); } } - public function sendDaily($date) + public function sendDaily($type, $date) { $map = [ - 'type' => 'B', + 'type' => $type, 'review_status' => 1, - 'send_status' => 1, 'award_started_at' => ['elt', $date], - 'award_ended_at' => ['egt', $date] + 'award_ended_at' => ['egt', $date], + '_string' => '(current_award_date is null or current_award_date < "' . $date . '")' ]; $orders = M('rebate_orders', 'tab_')->where($map)->select(); foreach ($orders as $order) { - $this->sendByOrder($order); + $this->sendByOrder($order, $date); + } + } + + public function listQuery($params, $awardType, $promote = null) + { + $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; + + $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'); + } + + 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('rebate_orders', '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(); + } + return [$records, $count]; + } + + public function listRange(array $records, $isExport = false) + { + $users = []; + if (count($records) > 0) { + $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); + } + + $newLine = $isExport == 1 ? "\n" : '
'; + foreach ($records as $key => $record) { + $user = $users[$record['user_id']]; + $records[$key]['promote_account'] = $user['promote_account']; + $records[$key]['review_status_text'] = $this->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'] = $this->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'])); + } + return $records; + } + + public function getExportHeadings($awardType) + { + $fields = [ + 'base_game_name' => '游戏名称', + 'server_name' => '区服', + 'user_account' => '账号', + 'role_id' => '角色ID', + 'role_name' => '角色名称', + ]; + + if ($awardType == 'A') { + $fields['pay_amount'] = '充值金额'; + } elseif ($awardType == 'B') { + $fields['pay_amount'] = '当日累计充值金额'; + $fields['award_date_range'] = '可领取福利日期'; + } elseif ($awardType == 'C') { + $fields['amount'] = '达到档位金额'; + } elseif ($awardType == 'D') { + $fields['pay_amount'] = '首充金额'; + } elseif($awardType == 'E') { + $fields['pay_amount'] = '当日累计充值金额'; + $fields['award_date'] = '达成日期'; + } elseif($awardType == 'F') { + $fields['award_date_range'] = '可领取福利日期'; + } + + $fields = array_merge($fields, [ + 'gift_content' => '奖励内容', + 'create_time' => '订单生成时间', + 'review_status_text' => '审核状态', + 'review_time' => '审核时间', + 'send_status_text' => '发放状态', + 'send_time' => '发放时间', + 'reviewer_username' => '审核人', + ]); + return $fields; } } \ No newline at end of file diff --git a/Application/Base/Tool/GameResource/XlqyClient.class.php b/Application/Base/Tool/GameResource/XlqyClient.class.php new file mode 100644 index 000000000..2710ad30e --- /dev/null +++ b/Application/Base/Tool/GameResource/XlqyClient.class.php @@ -0,0 +1,176 @@ + ['uri' => '', 'method' => 'post'], + ]; + + public function __construct() + { + $this->client = new Client([ + 'base_uri' => 'http://xx2api.hnputihd.com/apip/payWM450S00/emRebate', + 'timeout' => 10.0, + ]); + } + + public function api($name, array $params = []) + { + $api = $this->apis[$name] ?? null; + if (is_null($api)) { + throw new \Exception('接口不存在'); + } + $params[self::SIGN_NAME] = $this->sign($name, $params); + try { + return $this->request($api, $params); + } catch (\Exception $e) { + $env = C('APP_ENV', null, 'prod'); + Log::error('rebate:XLQY ' . $e->getMessage()); + return ['code' => 3, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; + } + } + + public function request($api, $params) + { + if ($api['method'] == 'get') { + return $this->get($api['uri'], $params); + } else { + return $this->post($api['uri'], $params); + } + } + + protected function post($uri, array $params = []) + { + $response = $this->client->post($uri, [ + 'verify' => false, + 'form_params' => $params, + ]); + $result = (string)$response->getBody(); + Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result); + return json_decode($result, true); + } + + protected function get($uri, array $params = []) + { + $response = $this->client->get($uri, [ + 'verify' => false, + 'query' => $params, + ]); + $result = (string)$response->getBody(); + Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result); + return json_decode($result, true); + } + + protected function sign($name, $params) + { + if ($name == 'send-email') { + return md5( + $params['appId'] . + $params['orderNum'] . + $params['userId'] . + $params['mailId'] . + $params['serviceId'] . + $params['roleId'] . + $params['time'] . + self::SIGN_KEY + ); + } else { + return ''; + } + } + + public function sendEmail($giftItem, $order) + { + $data = [ + 'appId' => self::APP_ID, + 'userId' => $order['user_id'], + 'serviceId' => $order['server_id'], + 'roleId' => $order['role_id'], + 'mailId' => $giftItem['id'], + 'orderNum' => $this->generateOrderNumber($order), + 'time' => time(), + ]; + + $result = $this->api('send-email', $data); + return $this->getCommonResult($result); + } + + private function generateOrderNumber($order) + { + $length = 8 - strlen(strval($order['id'])); + return date('Ymd') . str_repeat('0', $length) . $order['id']; + } + + private function getCommonResult($result) + { + if ($result['code'] == 0) { + return [ + 'status' => true, + 'message' => $result['msg'], + 'result' => $result + ]; + } else { + return [ + 'status' => false, + 'message' => $result['msg'], + 'result' => $result + ]; + } + } + + /** + * @todo 暂时没有测试资源 + */ + public function apply($order, $role) + { + return $this->sendEmail($order['ref_amount'], $role); + } + + public function getResourceTypes($deviceType) + { + if ($deviceType == 'andriod') { + return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']]; + } elseif ($deviceType == 'ios') { + return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']]; + } + } + + public function getResources($typeId, $deviceType) + { + return [ + 1 => ['ref_id' => 1, 'name' => '60元宝', 'amount' => 6], + 2 => ['ref_id' => 2, 'name' => '300元宝', 'amount' => 30], + 3 => ['ref_id' => 3, 'name' => '980元宝', 'amount' => 98], + 4 => ['ref_id' => 4, 'name' => '1280元宝', 'amount' => 128], + 5 => ['ref_id' => 5, 'name' => '1980元宝', 'amount' => 198], + 6 => ['ref_id' => 6, 'name' => '3280元宝', 'amount' => 328], + 7 => ['ref_id' => 7, 'name' => '6480元宝', 'amount' => 648], + 8 => ['ref_id' => 8, 'name' => '10000元宝', 'amount' => 1000], + 9 => ['ref_id' => 9, 'name' => '20000元宝', 'amount' => 2000], + 10 => ['ref_id' => 10, 'name' => '30000元宝', 'amount' => 3000], + 11 => ['ref_id' => 11, 'name' => '50000元宝', 'amount' => 5000], + 12 => ['ref_id' => 12, 'name' => '100000元宝', 'amount' => 10000], + 13 => ['ref_id' => 13, 'name' => '200000元宝', 'amount' => 20000], + ]; + } +} \ No newline at end of file diff --git a/Application/Base/Tool/GameResource/XyyClient.class.php b/Application/Base/Tool/GameResource/XyyClient.class.php index 8304023f0..91dbfe513 100644 --- a/Application/Base/Tool/GameResource/XyyClient.class.php +++ b/Application/Base/Tool/GameResource/XyyClient.class.php @@ -32,13 +32,13 @@ class XyyClient ]); } - public function api($api, array $params = []) + public function api($name, array $params = []) { - $api = $this->apis[$api] ?? null; + $api = $this->apis[$name] ?? null; if (is_null($api)) { throw new \Exception('接口不存在'); } - $params[self::SIGN_NAME] = $this->sign($api, $params); + $params[self::SIGN_NAME] = $this->sign($name, $params); try { return $this->request($api, $params); } catch (\Exception $e) { @@ -79,11 +79,11 @@ class XyyClient return json_decode($result, true); } - protected function sign($api, $params) + protected function sign($name, $params) { - if ($api == 'send-email') { + if ($name == 'send-email') { return md5($params['prop_id'].$params['serverid'].$params['role_id'].self::SIGN_KEY); - } elseif ($api == 'send-gold') { + } elseif ($name == 'send-gold') { return md5($params['money'].$params['serverid'].$params['role_id'].self::SIGN_KEY); } else { return ''; diff --git a/Application/Home/Controller/BaseController.class.php b/Application/Home/Controller/BaseController.class.php index 54bb5b682..8a97f4be8 100644 --- a/Application/Home/Controller/BaseController.class.php +++ b/Application/Home/Controller/BaseController.class.php @@ -222,15 +222,20 @@ class BaseController extends HomeController $count = $countQuery->count(); $records = $query->page($page, $pageSize)->select(); + $pagination = $this->getPagination($count, $page, $pageSize); + + return [$records, $pagination, $count]; + } + + public function getPagination($count, $page, $pageSize) + { $params = [ 'p' => $page, 'row' => $pageSize ]; $params = array_merge($params, $_POST); $params = array_merge($params, $_GET); - $pagination = set_pagination($count, $pageSize, $params); - - return [$records, $pagination, $count]; + return set_pagination($count, $pageSize, $params); } public function getRecordsByIds($query, $ids, $params = []) diff --git a/Application/Home/Controller/GameRebateController.class.php b/Application/Home/Controller/GameRebateController.class.php new file mode 100644 index 000000000..7dcb078b1 --- /dev/null +++ b/Application/Home/Controller/GameRebateController.class.php @@ -0,0 +1,131 @@ +getLoginPromote(); + if ($loginPromote['rebate_over_perm'] == 0) { + return $this->error('无权限操作'); + } + } + + public function single() + { + $this->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) + { + $promoteService = new PromoteService(); + $loginPromote = $this->getLoginPromote(); + $permPromote = $promoteService->getTopPromote($loginPromote); + + $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; + + $service = new GameRebateService(); + [$records, $count] = $service->listQuery($params, $awardType, $permPromote); + + $pageTitle = $service->typeDisplayNames[$awardType]; + $pageName = $service->typeNames[$awardType]; + if (count($records) > 0) { + $records = $service->listRange($records); + if ($isExport) { + $field = $service->getExportHeadings($awardType); + data2csv($records, $pageTitle, $field); + exit; + } + } + + $pagination = $this->getPagination($count, $params['page'], $params['limit']); + + $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('pagination', $pagination); + $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]]); + } +} \ No newline at end of file diff --git a/Application/Home/View/default/GameRebate/records.html b/Application/Home/View/default/GameRebate/records.html new file mode 100644 index 000000000..6d871f254 --- /dev/null +++ b/Application/Home/View/default/GameRebate/records.html @@ -0,0 +1,404 @@ + + + + + + + + + +
+ +
+
+
当前位置:返利管理>{$pageTitle}
+
+ + {$pageTitle} + 说明:{$pageTitle} +
+ + +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 游戏名称区服账号角色ID角色名充值金额当日累计充值金额可领取福利日期达到档位金额首充金额当日累计充值金额达成日期可领取福利日期奖励内容订单生成时间发放状态发放时间审核状态审核时间审核人

暂无数据

+ + + + + + {$data.base_game_name}{$data.server_name}{$data.user_account}{$data.role_id}{$data.role_name}{$data.pay_amount}{$data.pay_amount}{$data.award_date_range}{$data.amount}{$data.pay_amount}{$data.pay_amount}{$data.award_date}{$data.award_date_range}{$data.gift_content}{$data.create_time} + {$data.send_status_text} + {$data.send_time} + {$data.review_status_text} + {$data.review_time}{$data.reviewer_username}
+ +
+ {$pagination} +
+
+
+
+
+
+ + + + + + + + + + \ 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 c68629efa..934fa69bd 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -136,6 +136,17 @@ 测试资源申请记录 + + + +