diff --git a/Application/Admin/Controller/PromoteGameRatioController.class.php b/Application/Admin/Controller/PromoteGameRatioController.class.php index 4f20fa453..0d08c400c 100644 --- a/Application/Admin/Controller/PromoteGameRatioController.class.php +++ b/Application/Admin/Controller/PromoteGameRatioController.class.php @@ -3,6 +3,7 @@ namespace Admin\Controller; use Think\Controller; +use Admin\Model\PromoteGameRatioModel; class PromoteGameRatioController extends ThinkController { @@ -20,6 +21,7 @@ class PromoteGameRatioController extends ThinkController public function lists() { $params = I('get.'); + $group = $params['group'] ?? 1; $promoteId = $params['promote_id'] ?? 0; $gameId = $params['game_id'] ?? 0; $status = $params['status'] ?? ''; @@ -38,9 +40,17 @@ class PromoteGameRatioController extends ThinkController } $field = 'create_time, update_time'; - $query = D(self::MODEL_NAME)->field($field, true) - ->where($map) - ->order('update_time desc, id desc'); + if ($group == 1) { + $query = D(self::MODEL_NAME)->field($field, true) + ->where($map) + ->order('update_time desc, id desc'); + $metaTitle = $csvTitle = '公会分成管理'; + } else { + $query = M(self::MODEL_NAME . '_log', 'tab_')->field($field, true) + ->where($map) + ->order('create_time desc, id desc'); + $metaTitle = $csvTitle = '公会分成申请记录'; + } if (I('export', 0) != 1) { $query->page($page, $row); } @@ -107,7 +117,7 @@ class PromoteGameRatioController extends ThinkController 'promote_status_text' => $thisPromoteStatus, 'promote_ver_status_text' => $thisPromoteVerStatus, 'game_name' => $thisGameName, - 'last_ratio' => (($thisLastRatioStatus == 1) ? $thisLastRatio : $thisGameRatio), + 'last_ratio' => (($thisLastRatioStatus == 1 || $group != 1) ? $thisLastRatio : $thisGameRatio), 'ratio' => $thisRatio, 'valid_date' => $validDate, 'remark' => $promoteGameRatio['remark'], @@ -139,7 +149,7 @@ class PromoteGameRatioController extends ThinkController 'applicant' => '申请人', 'reviewer' => '确认人', ]; - data2csv($records,"公会分成管理", $field); + data2csv($records,$csvTitle, $field); exit; } @@ -148,6 +158,7 @@ class PromoteGameRatioController extends ThinkController if($page) { $this->assign('_page', $page); } + $this->assign('group', $group); $this->assign('records', $records); $this->assign('count', $count); $this->assign('gameList', getAllGameList()); @@ -155,7 +166,7 @@ class PromoteGameRatioController extends ThinkController $this->assign('statusList', self::$statusList); $this->assign('reviewRule', $reviewRule); $this->assign('is_admin', is_administrator()); - $this->meta_title = '公会分成管理'; + $this->meta_title = $metaTitle; $this->display(); } @@ -236,8 +247,10 @@ class PromoteGameRatioController extends ThinkController } $save['id'] = intval($params['id']); $result = D(self::MODEL_NAME)->save($save); + $logResult = $result; } else { $result = true; + $logResult = false; } } else {//新增 if (empty($params['promote_id'])) { @@ -264,14 +277,27 @@ class PromoteGameRatioController extends ThinkController } $save['promote_id'] = $promoteId; $save['game_id'] = $gameId; + $save['last_turnover_ratio'] = ''; $save['applicant_id'] = is_login(); $save['create_time'] = $time; $result = D(self::MODEL_NAME)->add($save); + $logResult = $result; } if ($result === false) { $this->error('保存失败'); } else { + if ($logResult) { + if (empty($params['id'])) { + $promoteGameRatioId = $result; + } else { + $promoteGameRatioId = $params['id']; + } + + $model = new PromoteGameRatioModel(); + $model->addLog($promoteGameRatioId); + } + $this->success('保存成功', U('lists')); } } else { @@ -351,8 +377,10 @@ class PromoteGameRatioController extends ThinkController } $result = D(self::MODEL_NAME)->where($map)->save($save); if ($result) { - if ($status == 1) { - foreach ($ids as $id) { + $model = new PromoteGameRatioModel(); + foreach ($ids as $id) { + $model->addLog($id); + if ($status == 1) { $promoteGameRatio = D(self::MODEL_NAME)->find($id); if (!empty($promoteGameRatio)) { if ($promoteGameRatio['begin_time'] <= strtotime(date('Y-m-d', time()))) { diff --git a/Application/Admin/Model/PromoteGameRatioModel.class.php b/Application/Admin/Model/PromoteGameRatioModel.class.php index b6715ba2d..ca31346c2 100644 --- a/Application/Admin/Model/PromoteGameRatioModel.class.php +++ b/Application/Admin/Model/PromoteGameRatioModel.class.php @@ -6,6 +6,23 @@ use Think\Model; class PromoteGameRatioModel extends Model { + protected $db = 'promote_game_ratio'; + // 数据表前缀 protected $tablePrefix = 'tab_'; + + public function addLog($id) + { + $logSave = $this->find($id); + if (!empty($logSave)) { + if (empty($logSave['last_ratio_status'])) { + $logSave['last_ratio'] = D('game')->where(array('id' => $logSave['game_id']))->getField('ratio'); + $logSave['last_ratio'] = $logSave['last_ratio'] ?? 0; + } + $logSave['create_time'] = $logSave['update_time']; + unset($logSave['id']); + unset($logSave['update_time']); + M('promote_game_ratio_log', 'tab_')->add($logSave); + } + } } \ No newline at end of file diff --git a/Application/Admin/View/PromoteGameRatio/lists.html b/Application/Admin/View/PromoteGameRatio/lists.html index cdfaa7868..a9cb1d8f5 100644 --- a/Application/Admin/View/PromoteGameRatio/lists.html +++ b/Application/Admin/View/PromoteGameRatio/lists.html @@ -43,24 +43,30 @@ margin-left:-7px } - -
说明:此功能可设置所有公会对应的游戏分成比例。
-