diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index cc7e5adef..d21624a70 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -964,3 +964,22 @@ function checkEncryptionAuth(&$value,$string){ } } +/** + * 获取控制器得自操作权限 + */ +function getModuleControllerAuth() +{ + $group = $_SESSION['onethink_admin']['user_group_id']; + //获取全部权限列表 + $ruleList = M("AuthGroup")->field("rules")->where("id='{$group}'")->find()['rules']; + //获取所有含有规则的数据 + $mc = "MODULE_NAME."/".CONTROLLER_NAME"; + $authlist = M("AuthRule")->field('name')->where("name like '{$mc}%' AND id in ($ruleList)")->select(); + $Auth = []; + foreach ($authlist as $k => $v) { + $a = str_replace("{$mc}/","",$v['name']); + $Auth[] = $a; + } + return $Auth; +} + diff --git a/Application/Admin/Controller/CompanyGameRatioController.class.php b/Application/Admin/Controller/CompanyGameRatioController.class.php new file mode 100644 index 000000000..2b224f023 --- /dev/null +++ b/Application/Admin/Controller/CompanyGameRatioController.class.php @@ -0,0 +1,277 @@ +"管理员拒绝", + "-1"=>"市场部拒绝", + "0"=>"待审核", + "1"=>"市场部通过", + "2"=>"管理员通过" + ]; + public function _initialize() + { + $this->admininfo = $_SESSION['onethink_admin']['user_auth']; + $this->DBModel = M("company_game_ratio","tab_"); + parent::_initialize(); + } + + public function index() + { + dd(MODULE_NAME."/".CONTROLLER_NAME ); + $params = I('get.'); + $page = $params['p'] ? intval($params['p']) : 1; + $row = $params['row'] ? intval($params['row']) : 10; + + $gamewhere['_string'] = '1 = 1'; + $where['_string'] = '1 = 1'; + if(isset($params['relation_game_id'])){ + $gamewhere['relation_game_id'] = $params['relation_game_id']; + $where['m.relation_game_id'] = $params['relation_game_id']; + } + if(isset($params['company_id'])){ + $where['m.company_id'] = $params['company_id']; + } + if(isset($params['status'])){ + $where['m.status'] = $params['status']; + } + //TODO:未计算公司类型 + $this->checkListOrCountAuthRestMap($where); + $gameres = M("game","tab_")->field("tab_game.relation_game_id,tab_game.relation_game_name,IF(tab_game.original_package_name='','未配置',tab_game.original_package_name) original_package_name,tab_game_type.type_name game_type_name")->where($gamewhere)->join("tab_game_type on tab_game.game_type_id = tab_game_type.id")->group("tab_game.relation_game_id")->select(false); + $dbres = M("company_game_ratio_log","tab_") + ->alias('m') + ->field("m.*,g.*,p.company_name,p.company_belong") + ->join("left JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id") + ->join("left JOIN tab_promote_company p ON m.company_id = p.id") + ->where($where) + ->order('create_time desc, id desc'); + if(isset($params['export'])){ + $dbres = $dbres->select(); + }else{ + $dbres = $dbres->page($page, $row)->select(); + } + foreach($dbres as $k=>&$v){ + $v['settlement_type'] ='--'; + $v['begin_time'] = date("Y-m-d",$v['begin_time']); + $v['end_time'] = $v['end_time'] ? date('Y-m-d', $v['end_time']) : '永久'; + $v['company_belong'] ="下游".getCompanyBlong($v['company_belong']); + $v['verify_log'] = json_decode($v['verify_log'], true); + $v["create"]= "{$v['verify_log']['create_user']}
{$v['verify_log']['create_time']}"; + if(isset($v['verify_log']['market_user'])){ + if($v['status'] == -1){ + $ts = "审核拒绝"; + }else{ + $ts = "审核通过"; + } + $v["market"]= "{$ts}({$v['verify_log']['market_user']})
{$v['verify_log']['market_time']}"; + }else{ + $v["market"] = '--'; + } + + if(isset($v['verify_log']['admin_user'])){ + if($v['status'] == -2){ + $ts = "审核拒绝"; + }else{ + $ts = "审核通过"; + } + $v["admin"]= "{$ts}({$v['verify_log']['admin_user']})
{$v['verify_log']['admin_time']}"; + }else{ + $v["admin"] = '--'; + } + //新 + $thisTurnoverRatios = $v['turnover_ratio'] ? json_decode($v['turnover_ratio'], true) : []; + $thisRatioDtl = "默认:{$v['ratio']}%"; + if ($thisTurnoverRatios) { + if (I('export', 0) == 1) { + $symbol = "\n"; + } else { + $symbol = "
"; + } + foreach ($thisTurnoverRatios as $thisTurnoverRatio) { + $thisIntervalClosedStatusText = isset($thisTurnoverRatio['instanceof']) ? ($thisTurnoverRatio['instanceof'] == 1 ? '≥' : '>') : '≥'; + $thisRatioDtl .= "{$symbol}月流水{$thisIntervalClosedStatusText}{$thisTurnoverRatio['turnover']},比例:{$thisTurnoverRatio['ratio']}%"; + } + } + $v['turnover_ratio_str'] = $thisRatioDtl; + //旧 + $lastTurnoverRatios = $v['last_turnover_ratio'] ? json_decode($v['last_turnover_ratio'], true) : []; + $lastRatioDtl = "默认:{$v['last_ratio']}%"; + if ($lastTurnoverRatios) { + if (I('export', 0) == 1) { + $symbol = "\n"; + } else { + $symbol = "
"; + } + foreach ($lastTurnoverRatios as $thisTurnoverRatio) { + $thisIntervalClosedStatusText = isset($thisTurnoverRatio['instanceof']) ? ($thisTurnoverRatio['instanceof'] == 1 ? '≥' : '>') : '≥'; + $lastRatioDtl .= "{$symbol}月流水{$thisIntervalClosedStatusText}{$thisTurnoverRatio['turnover']},比例:{$thisTurnoverRatio['ratio']}%"; + } + } + $v['last_turnover_ratio_str'] = $lastRatioDtl; + + } + $count = M("company_game_ratio_log","tab_")->alias('m')->field("count(id) count")->where($where)->find()['count']; + $this->assign('data', $dbres); + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } + $this->assign('status',$this->Status); + + $this->assign("companyList",D("PromoteCompany")->getList()); + $this->assign("gameList",D("Game")->getRelationGameLits()); + $this->display(); + } + + public function add() + { + if ($_POST) { + $params = I('post.'); + if (empty($params['begin_time'])) { + $this->error('请选择开始时间'); + } + if (!empty($params['end_time'])) { + if (strtotime($params['end_time']) < strtotime($params['begin_time'])) { + $this->error('结束时间不得小于开始时间'); + } + } + if (!isset($params['ratio']) || $params['ratio'] === '') { + $this->error('默认分成比例不能为空'); + } + $save['turnover_ratio'] = $this->setTurnoverRatio($params); + $save['ratio'] = $params['ratio'] ?? 0; + $save['relation_game_id'] = $params['relation_game_id'] ?? 0; + $save['company_id'] = $params['company_id'] ?? 0; + $save['begin_time'] = strtotime($params['begin_time']); + $save['end_time'] = $params['end_time'] ? strtotime($params['end_time'])+86399 : 0; + $save['remark'] = $params['remark'] ?? ''; + $save['status'] = 0; + $save['verify_log']=json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s")]); + //获取旧比例 + $this->getOldRatio($save); + //判断已有未审核 + $where = [ + "relation_game_id"=>$save['company_id'], + "company_id"=>$save['company_id'], + "status"=>["LT",2]//管理员未确认 + ]; + $hasdb = M("company_game_ratio_log","tab_")->field("count(id) count")->where($where)->find()['count']; + if($hasdb > 0){ + $this->error('已经有审批单,请直接搜索后修改'); + } + + $id = M("company_game_ratio_log","tab_")->add($save); + addOperationLog(['op_type'=>0,'key'=>$id,'op_name'=>'新增','url'=>U('index')]); + $this->ajaxReturn(["msg"=>"添加成功","code"=>1,"url"=>U("index")]); + + } else { + $companyList = D("PromoteCompany")->getList(); + $this->assign("companyList",$companyList); + $this->assign("gameList",D("Game")->getRelationGameLits()); + $this->display(); + } + + } + public function edit() + { + + } + public function del() + { + + } + public function setTurnoverRatio($params) + { + $save['turnover_ratio'] = []; + if (!empty(array_filter($params['turnover'])) || !empty(array_filter($params['turnover_ratio'])) ) { + if (is_array($params['turnover']) && is_array($params['turnover_ratio']) && is_array($params['instanceof'])) { + foreach ($params['turnover'] as $turnover) { + if (empty($turnover)) { + $this->error('月流水不能为空'); + } + } + foreach ($params['turnover_ratio'] as $turnoverRatio) { + if (empty($turnoverRatio)) { + $this->error('月流水分成比例不能为空'); + } + } + foreach ($params['instanceof'] as $intervalClosedStatus) { + if (!in_array($intervalClosedStatus, [1, 2])) { + $this->error('月流水分符号不能为空'); + } + } + $turnoverCount = count($params['turnover']); + $sortTurnover = $params['turnover']; + sort($sortTurnover); + if ($params['turnover'] != $sortTurnover || $turnoverCount != count(array_unique($params['turnover']))) { + $this->error('月流水必须以正序的方式填写,且必须大于上一个月流水'); + } + $ratio = $params['ratio'] ?? 0; + if ($params['turnover_ratio'][0] <= $ratio) { + $this->error('月流水分成比例必须大于默认分成比例'); + } + $turnoverRatioCount = count($params['turnover_ratio']); + $sortTurnoverRatio = $params['turnover_ratio']; + sort($sortTurnoverRatio); + if ($params['turnover_ratio'] != $sortTurnoverRatio || $turnoverRatioCount != count(array_unique($params['turnover_ratio']))) { + $this->error('月流水分成比例必须以正序的方式填写,且必须大于上一个月流水分成比例'); + } + + foreach ($params['turnover'] as $key => $turnover) { + $save['turnover_ratio'][] = [ + 'turnover' => bcdiv($turnover, 1, 2), + 'ratio' => bcdiv($params['turnover_ratio'][$key], 1, 2), + 'instanceof' => (isset($params['instanceof'][$key]) ? $params['instanceof'][$key] : 1), + ]; + } + $save['turnover_ratio'] = json_encode($save['turnover_ratio']); + } + } + return $save['turnover_ratio']; + + } + public function getOldRatio(&$save) + { + $tmap = [ + "company_id"=>$save['company_id'], + "relation_game_id"=>$save['relation_game_id'], + ]; + $ratio_dbres = $this->DBModel->where($tmap)->find(); + if(isset($ratio_dbres['ratio'])){ + $save['last_ratio']=$ratio_dbres['ratio']; + $save['last_turnover_ratio']=$ratio_dbres['turnover_ratio']; + return ; + } + + $cmap = [ + "id"=>$save['company_id'], + ]; + $com = M("promote_company","tab_")->field("company_belong")->where($cmap)->find(); + if(!isset($com['company_belong'])){ + $save['last_ratio']=0; + $save['last_turnover_ratio']=""; + return ; + } + //查询模板 + $mmap = [ + "company_belong"=>$com['company_belong'], + "relation_game_id"=>$save['relation_game_id'] + ]; + $mould = M("game_ratio_mould","tab_")->where($mmap)->find(); + if(isset($mould['ratio'])){ + $save['last_ratio']=$mould['ratio']; + $save['last_turnover_ratio']=$mould['turnover_ratio']; + }else{ + $save['last_ratio']=0; + $save['last_turnover_ratio']=""; + } + return ; + + } + + +} \ No newline at end of file diff --git a/Application/Admin/Model/GameModel.class.php b/Application/Admin/Model/GameModel.class.php index 34bf62d73..797ef88dd 100644 --- a/Application/Admin/Model/GameModel.class.php +++ b/Application/Admin/Model/GameModel.class.php @@ -444,6 +444,15 @@ class GameModel extends Model{ } } + //获取关联游戏列表 + public function getRelationGameLits($field=false,$where='1=1') + { + if(!$field){ + $field = "relation_game_id,relation_game_name,original_package_name"; + } + return $this->field($field)->where($where)->group("relation_game_id")->select(); + + } } diff --git a/Application/Admin/Model/PromoteCompanyModel.class.php b/Application/Admin/Model/PromoteCompanyModel.class.php new file mode 100644 index 000000000..cf00f3833 --- /dev/null +++ b/Application/Admin/Model/PromoteCompanyModel.class.php @@ -0,0 +1,28 @@ +tablePrefix ='tab_'; + /* 执行构造方法 */ + parent::__construct($name, $tablePrefix, $connection); + } + // + public function getList() + { + return $this->field("id,company_name")->where("status=1")->select(); + # code... + } +} \ No newline at end of file diff --git a/Application/Admin/View/CompanyGameRatio/add.html b/Application/Admin/View/CompanyGameRatio/add.html new file mode 100644 index 000000000..8e5bb21c3 --- /dev/null +++ b/Application/Admin/View/CompanyGameRatio/add.html @@ -0,0 +1,433 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*推广公司: + + +
*已申请游戏: + + 因功能未完善,当前可选择全部游戏 +
原包名: + 请先选择游戏 + +
*分成比例设定: + + + % + +
+
+
+ + + +
+
+ +
*生效期限: +
+ + - + +
+ 结束时间不填则默认永久。 +
备注: + + +
+
+ +
+ + + 返回 + +
+
+
+
+
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + + diff --git a/Application/Admin/View/CompanyGameRatio/edit.html b/Application/Admin/View/CompanyGameRatio/edit.html new file mode 100644 index 000000000..85aeba38a --- /dev/null +++ b/Application/Admin/View/CompanyGameRatio/edit.html @@ -0,0 +1,461 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
游戏类型: + {$data.game_type_name} + +
现包名: + {$data.relation_game_name} + +
原包名: + {$data.original_package_name} + +
公司类型: + 下游{$data.company_belong} + +
*分成比例设定: + + + % + 当前需要修改成的分成比例 +
+
+
+ + + +
+ +
+ + +
+ + +
+ +
+ + % + +
+
+
+
+ +
+
+ + +
+ + + 返回 + +
+
+
+
+ + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + + diff --git a/Application/Admin/View/CompanyGameRatio/index.html b/Application/Admin/View/CompanyGameRatio/index.html new file mode 100644 index 000000000..2e8fee657 --- /dev/null +++ b/Application/Admin/View/CompanyGameRatio/index.html @@ -0,0 +1,296 @@ + + + + + + + + + + + + + +
+ + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ 搜索 +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 公司名称内外团结算周期游戏类型原游戏名称现游戏名称生效时间原比例申请比例创建记录市场部审批管理员审批备注操作
aOh! 暂时还没有内容!
+ + + + + + {$data.company_name}{$data.company_belong}{$data.settlement_type}{$data.game_type_name}{$data.original_package_name}{$data.relation_game_name}{$data.begin_time} ~~ {$data.end_time} +
+ {$data.last_turnover_ratio_str} +
+
+
+ {$data.turnover_ratio_str} +
+
+
+ {$data.create} +
+
+ + +
+ {$data.market} +
+ +
+ {$data.market} +
+
+
+ +
+ {$data.admin} +
+ +
+ {$data.admin} +
+
+
+ {$data.remark} + + 编辑 + 删除 +
+
+ +
+ +
+ + 导出 + + {$_page|default=''} +
+ +
+
+
    +
  1. +
    + 备注: + +
    +
    拒绝
    +
  2. +
+
+
+
+ + + + + + diff --git a/Data/update.sql b/Data/update.sql index 77c30614c..1645f3ef1 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1758,16 +1758,6 @@ INSERT INTO `tab_tool` (`name`,`title`, `config`,`type`, `status`, `create_time` --新增上游结算接口 INSERT INTO `sys_kv` (`key`, `value`, `type`, `remark`) VALUES ('aggregate_cp_settlement_api', 'http://admin.wmtxkj.com/index.php?g=api&m=FinanceWeekCount&a=returnCPSettlement', 'string', '聚合cp结算Api地址'); ---修改公司与游戏比例 -TRUNCATE TABLE `tab_promote_game_ratio`; -TRUNCATE TABLE `tab_promote_game_ratio_log`; - -ALTER TABLE `tab_promote_game_ratio` -CHANGE COLUMN `promote_id` `company_id` int(11) NOT NULL DEFAULT 0 COMMENT '下游推广公司id' AFTER `id`; - -ALTER TABLE `tab_promote_game_ratio_log` -CHANGE COLUMN `promote_id` `company_id` int(11) NOT NULL DEFAULT 0 COMMENT '下游推广公司id' AFTER `id`; - --新增游戏分成模板 CREATE TABLE `tab_game_ratio_mould` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键', @@ -1783,3 +1773,35 @@ CREATE TABLE `tab_game_ratio_mould` ( KEY `company_belong` (`company_belong`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='游戏默认分成比例'; +-- 公司分成比例 +CREATE TABLE `tab_company_game_ratio` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `company_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广公司id', + `relation_game_id` int(11) NOT NULL DEFAULT '0' COMMENT '关联游戏id', + `ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '默认分成比例', + `turnover_ratio` varchar(2000) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '流水分成比例', + `begin_time` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间', + `end_time` int(11) NOT NULL DEFAULT '0' COMMENT '过期时间', + PRIMARY KEY (`id`), + KEY `company_id` (`company_id`) USING BTREE, + KEY `relation_game_id` (`relation_game_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +CREATE TABLE `tab_company_game_ratio_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `company_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广公司id', + `relation_game_id` int(11) NOT NULL DEFAULT '0' COMMENT '关联游戏id', + `ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '分成比例', + `turnover_ratio` varchar(2000) COLLATE utf8mb4_bin NOT NULL COMMENT '流水分成比例', + `last_ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '上次的分成比例', + `last_turnover_ratio` varchar(2000) COLLATE utf8mb4_bin NOT NULL COMMENT '上次流水分成比例', + `begin_time` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间', + `end_time` int(11) NOT NULL DEFAULT '0' COMMENT '过期时间', + `remark` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '备注', + `status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '审核状态:-2管理员拒绝 -1市场部拒绝 0-待审核 1-市场部通过 2管理员通过', + `verify_log` varchar(2000) COLLATE utf8mb4_bin NOT NULL COMMENT '审核详细信息', + PRIMARY KEY (`id`), + KEY `company_id` (`company_id`) USING BTREE, + KEY `status` (`status`) USING BTREE, + KEY `relation_game_id` (`relation_game_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; \ No newline at end of file