diff --git a/Application/Admin/Controller/PromoteGameRatioController.class.php b/Application/Admin/Controller/PromoteGameRatioController.class.php index e1653bac4..137c63913 100644 --- a/Application/Admin/Controller/PromoteGameRatioController.class.php +++ b/Application/Admin/Controller/PromoteGameRatioController.class.php @@ -66,9 +66,11 @@ class PromoteGameRatioController extends ThinkController $thisPromoteVerStatus = '未知'; $thisGameName = '未知'; $thisGameRatio = '0.00'; + $thisStatusText = self::$statusList[$promoteGameRatio['status']]; + $thisStatusText = ($promoteGameRatio['status'] == -1) ? '' . $thisStatusText . '' : $thisStatusText; $thisApplicant = getPromoteAccount($promoteGameRatio['applicant_id']); $thisReviewer = $promoteGameRatio['reviewer_id'] ? getPromoteAccount($promoteGameRatio['reviewer_id']) : '待确认'; - if ($promoteGameRatio['ratio'] > 0) { + if ($promoteGameRatio['ratio'] > 0 && $promoteGameRatio['begin_time']) { $thisBeninTime = date('Y/m/d', $promoteGameRatio['begin_time']); } else { $thisBeninTime = date('Y/m/d', $this->getPromoteApplyCreateTime($thisPromoteId, $thisGameId)); @@ -102,13 +104,15 @@ class PromoteGameRatioController extends ThinkController 'ratio' => $promoteGameRatio['ratio'] . '%', 'valid_date' => $validDate, 'remark' => $promoteGameRatio['remark'], - 'status_text' => self::$statusList[$promoteGameRatio['status']], + 'status' => $promoteGameRatio['status'], + 'status_text' => $thisStatusText, 'applicant' => $thisApplicant ?? '未知', 'reviewer' => $thisReviewer ?? '未知', ]; } } +// var_dump(get_defined_constants());die; $this->assign('records', $records); $this->assign('count', $count); $this->assign('gameList', getAllGameList()); @@ -121,7 +125,48 @@ class PromoteGameRatioController extends ThinkController public function applyRatio() { if ($_POST) { + $params = I('post.'); + $time = time(); + $save['ratio'] = $params['ratio'] ?? 0; + $save['begin_time'] = $params['begin_time'] ? strtotime($params['begin_time']) : 0; + $save['end_time'] = $params['end_time'] ? strtotime($params['end_time']) : 0; + $save['remark'] = $params['remark'] ?? ''; + $save['status'] = 0; + $save['update_time'] = $time; + if (!empty($params['id'])) {//修改 + $promoteGameRatio = D(self::MODEL_NAME)->find($params['id']); + if (empty($promoteGameRatio)) { + $this->error('参数异常'); + } + $save['id'] = intval($params['id']); + $result = D(self::MODEL_NAME)->save($save); + } else {//新增 + if (empty($params['promote_id'])) { + $this->error('请选择会长账号'); + } + if (empty($params['game_id'])) { + $this->error('请选择要申请的游戏'); + } + $promoteId = intval($params['promote_id']); + $gameId = intval($params['game_id']); + $map['promote_id'] = $promoteId; + $map['game_id'] = $gameId; + $promoteGameRatio = D(self::MODEL_NAME)->where($map)->find(); + if ($promoteGameRatio) { + $this->error('网络异常'); + } + $save['promote_id'] = $promoteId; + $save['game_id'] = $gameId; + $save['applicant_id'] = is_login(); + $save['create_time'] = $time; + $result = D(self::MODEL_NAME)->add($save); + } + if ($result === false) { + $this->error('保存失败'); + } else { + $this->success('保存成功', U('lists')); + } } else { $params = I('get.'); $id = $params['id'] ?? 0; @@ -129,13 +174,19 @@ class PromoteGameRatioController extends ThinkController $metaTitle = '游戏分成比例申请'; if ($id) { $metaTitle .= '--修改'; - $field = 'promote_id, game_id, ratio, begin_time, end_time, remark'; + $field = 'id, promote_id, game_id, ratio, begin_time, end_time, remark'; $map['id'] = $id; $promoteGameRatio = D(self::MODEL_NAME)->field($field)->where($map)->find(); if (empty($promoteGameRatio)) { $this->error('数据异常'); } + $promoteGameRatio['begin_time'] = $promoteGameRatio['begin_time'] ? date('Y-m-d', $promoteGameRatio['begin_time']) : ''; + $promoteGameRatio['end_time'] = $promoteGameRatio['end_time'] ? date('Y-m-d', $promoteGameRatio['end_time']) : ''; + $gameRatio = M('game', 'tab_')->where(array(['id' => $promoteGameRatio['game_id']]))->getField('ratio'); + $gameRatio = ($gameRatio ?? '0.00') . '%'; + $this->assign('record', $promoteGameRatio); + $this->assign('gameRatio', $gameRatio); } $this->assign('gameList', getAllGameList()); @@ -145,6 +196,31 @@ class PromoteGameRatioController extends ThinkController } } + public function setStatus($status) + { + $params = I('post.'); + $ids = $params['ids'] ?? []; + if (empty($ids)) { + $this->error('操作失败'); + } + if (empty($status) || !in_array($status, [-1, 1])) { + $this->error('操作失败'); + } + $time = time(); + $map['id'] = ['in', $ids]; + $map['status'] = 0; + $save['status'] = $status; + $save['reviewer_id'] = is_login(); + $save['review_time'] = $time; + $save['update_time'] = $time; + $result = D(self::MODEL_NAME)->where($map)->save($save); + if ($result) { + $this->success('操作成功'); + } else { + $this->error('操作失败'); + } + } + private function getPromoteApplyCreateTime($promoteId, $gameId) { $map['promote_id'] = $promoteId; @@ -152,4 +228,21 @@ class PromoteGameRatioController extends ThinkController $createTime = $apply = M('apply', 'tab_')->where($map)->getField('apply_time'); return $createTime; } + + public function getGameRatio() + { + $gameId = I('post.game_id', 0); + $gameId = intval($gameId); + $gameRatio = ''; + if ($gameId) { + $map['id'] = $gameId; + $gameRatio = M('game', 'tab_')->where($map)->getField('ratio'); + $gameRatio = ($gameRatio ?? '0.00') . '%'; + } + $data = [ + 'status' => 1, + 'ratio' => $gameRatio, + ]; + $this->ajaxReturn($data); + } } \ No newline at end of file diff --git a/Application/Admin/View/PromoteGameRatio/applyRatio.html b/Application/Admin/View/PromoteGameRatio/applyRatio.html index fe674744d..069e7c047 100644 --- a/Application/Admin/View/PromoteGameRatio/applyRatio.html +++ b/Application/Admin/View/PromoteGameRatio/applyRatio.html @@ -1,9 +1,12 @@ - - - + + + + + + {$meta_title} @@ -31,7 +37,7 @@ *会长账号: - + disabled> 会长账号 @@ -49,7 +55,7 @@ *已申请游戏: - + disabled> 游戏名称 @@ -67,7 +73,7 @@ 原分成比例: - + {$gameRatio|default=''} @@ -75,6 +81,7 @@ 现分成比例: + % 当前需要修改成的分成比例 @@ -82,9 +89,9 @@ 开始时间: - + - - + 结束时间不填则默认永久。 @@ -92,14 +99,14 @@ 备注: - + {$record['remark']|default=''} - + @@ -133,49 +140,46 @@ diff --git a/Application/Admin/View/PromoteGameRatio/lists.html b/Application/Admin/View/PromoteGameRatio/lists.html index 305976f2d..b82ce950e 100644 --- a/Application/Admin/View/PromoteGameRatio/lists.html +++ b/Application/Admin/View/PromoteGameRatio/lists.html @@ -41,8 +41,8 @@ 游戏分成比例申请 - 审核通过 - 审核拒绝 + 审核通过 + 审核拒绝 @@ -117,7 +117,13 @@ - + + + + + + + {$record.promote_id} {$record.promote_account} {$record.promote_mobile_phone} diff --git a/Data/update.sql b/Data/update.sql index b27e6a430..a8ea688a4 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -728,19 +728,20 @@ ADD COLUMN `flooring_page_video_cover` int(11) NOT NULL DEFAULT 0 COMMENT '落 --2019-12-16 --公会分成比例管理 -CREATE TABLE `tab_promote_game_ratio` ( +CREATE TABLE `tab_promote_game_ratio` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `promote_id` int(11) NOT NULL DEFAULT 0 COMMENT '推广员id', - `game_id` int(11) NOT NULL DEFAULT 0 COMMENT '游戏id', - `ratio` decimal(5, 2) NOT NULL DEFAULT 0 COMMENT '分成比例', - `begin_time` int(10) NOT NULL DEFAULT 0 COMMENT '开始时间', - `end_time` int(10) NOT NULL DEFAULT 0 COMMENT '过期时间', - `remark` varchar(255) NOT NULL COMMENT '备注', - `status` tinyint(3) NOT NULL DEFAULT 0 COMMENT '审核状态:-1-未通过 0-待审核 1-通过', - `applicant_id` int(11) NOT NULL DEFAULT 0 COMMENT '申请人', - `reviewer_id` int(11) NOT NULL DEFAULT 0 COMMENT '审核人', - `create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间', - `update_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间', + `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id', + `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id', + `ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '分成比例', + `begin_time` int(10) NOT NULL DEFAULT '0' COMMENT '开始时间', + `end_time` int(10) NOT NULL DEFAULT '0' COMMENT '过期时间', + `remark` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '备注', + `status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '审核状态:-1-未通过 0-待审核 1-通过', + `review_time` int(10) NOT NULL DEFAULT '0' COMMENT '审核时间', + `applicant_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请人', + `reviewer_id` int(11) NOT NULL DEFAULT '0' COMMENT '审核人', + `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间', + `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', PRIMARY KEY (`id`), - INDEX `promote_id`(`promote_id`, `game_id`, `status`) USING BTREE -); \ No newline at end of file + KEY `promote_id` (`promote_id`,`game_id`,`status`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; \ No newline at end of file