diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index a6007b121..5f48b6929 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -841,21 +841,12 @@ function getAllPromoteListByType($promoteType = 1, $retOne = false, $promoteId = break; case 2: case 3: - $promoteData = D('Promote')->where(array('id' => $promoteId))->find(); - - if ($promoteData['grand_id'] > 0) { - return []; - } elseif ($promoteData['parent_id'] > 0) { - $promoteType--; - } - $childPromoteIds = getAllPromoteIdsByType((string)$promoteId, $promoteType); + case 4: + $map['chain'] = ['like', '%/' . $promoteId . '/%']; + $map['level'] = $promoteType; break; } - if (!empty($childPromoteIds)) { - $map['id'] = ['in', $childPromoteIds]; - } - if (!empty($map)) { if ($retOne) { $childPromoteData = D('Promote')->where($map)->getField('id', true); @@ -968,9 +959,27 @@ function getParentPromoteId($promoteId) //获会长渠道ID function getGrandPromoteId($promoteId) { + $model = D('Promote'); $map['id'] = $promoteId; - return D('Promote')->where($map)->getField('grand_id'); + $data = $model->field('parent_id,chain,level')->where($map)->find(); + if (empty($data)) { + return 0; + } + + switch ($data['level']) { + case 1: + return $promoteId; + break; + case 2: + return $data['parent_id']; + break; + case 3: + case 4: + $ids = explode('/', $data['chain']); + return (isset($ids[1]) ? $ids[1] : 0); + break; + } } function getGamePermission($gameId) diff --git a/Application/Home/Controller/ApplyController.class.php b/Application/Home/Controller/ApplyController.class.php index 9a03ac1e0..b754c6d3b 100644 --- a/Application/Home/Controller/ApplyController.class.php +++ b/Application/Home/Controller/ApplyController.class.php @@ -62,13 +62,13 @@ class ApplyController extends BaseController //首页 $type-查询的游戏平台类型 0-全部 10-安卓+ios 2-ios 1-安卓 public function index($serverType = 1) { - $promoteId = empty(I('promote_id')) ? PID : I('promote_id');//搜索的渠道ID + $loginPromote = $this->getLoginPromote(); + + $promoteId = empty(I('promote_id')) ? $loginPromote['id'] : I('promote_id');//搜索的渠道ID $promoteRole = empty(I('promote_role')) ? 1 : I('promote_role');//渠道角色 $parentPromoteId = getParentPromoteId($promoteId);//上级渠道ID - $grandPromoteId = getGrandPromoteId($promoteId); - $grandPromoteId = empty($grandPromoteId) ? $parentPromoteId : $grandPromoteId;//本账号会长渠道ID + $grandPromoteId = getGrandPromoteId($promoteId);//本账号会长渠道ID $childGameAddPermission = getChildGameAddPermission($grandPromoteId);//游戏添加权限 - $thisParentPromoteId = getParentPromoteId(PID);//本账号上级渠道ID $map['tab_game.online_status'] = 1;//开发者游戏上线状态 $map['tab_game.down_port'] = 1;//游戏端口 第三方接口不能申请 @@ -183,11 +183,9 @@ class ApplyController extends BaseController $this->assign('list_data', $data); $this->assign("count", $count); + $this->assign('loginPromote', $loginPromote); $this->assign("promoteId", $promoteId); - $this->assign('parentPromoteId', $parentPromoteId); - $this->assign('thisParentPromoteId', $thisParentPromoteId); $this->assign('promoteRole', $promoteRole); - $this->assign('pID', PID); $this->assign('promoteData', getAllPromoteListByType($promoteRole)); $this->assign('type', $type); $this->assign('myGame', ($serverType == 1) ? 'specialMyGameList' : 'myGameList'); @@ -248,13 +246,13 @@ class ApplyController extends BaseController // $where['_logic']='or'; } else { $where['_complex'] = $map; - if(empty($noDeveloperGameArr)) { - $where['tab_game.id'] = ['in','-100']; - }else { - $where['tab_game.id'] = ['in',$noDeveloperGameArr]; + if (empty($noDeveloperGameArr)) { + $where['tab_game.id'] = ['in', '-100']; + } else { + $where['tab_game.id'] = ['in', $noDeveloperGameArr]; } - - $where['_logic']='or'; + + $where['_logic'] = 'or'; } $data = M('Game', 'tab_') @@ -598,9 +596,11 @@ class ApplyController extends BaseController public function my_game($serverType = 1) { + $loginPromote = $this->getLoginPromote(); + //渠道可申请游戏 if (empty($_REQUEST['promote_id'])) { - $promoteId = get_pid(); + $promoteId = $loginPromote['id']; } else { $promoteId = $_REQUEST['promote_id']; } @@ -689,10 +689,8 @@ class ApplyController extends BaseController $this->assign("url", $url); $this->assign("count", $count); $this->assign("row", $row); + $this->assign('loginPromote', $loginPromote); $this->assign('promoteId', $promoteId); - $this->assign('thisParentPromoteId', getParentPromoteId(PID)); - $this->assign('parentPromoteId', getParentPromoteId($promoteId)); - $this->assign('pID', PID); $this->assign('promoteRole', $promoteRole); $this->assign('promoteData', getAllPromoteListByType($promoteRole)); $this->assign('list_data', $data); @@ -1006,14 +1004,20 @@ class ApplyController extends BaseController public function apply() { if ($_POST['game_id']) { + $loginPromote = $this->getLoginPromote(); $gameMap['tab_game.id'] = $_POST['game_id']; $promoteId = I('promote_id'); if (empty($promoteId)) { - $promoteId = PID; + $promoteId = $loginPromote['id']; + } + + if ($promoteId == $loginPromote['id']) { + $promoteData = $loginPromote; + } else { + $promoteData = D('Promote')->where(array('id' => $promoteId))->find(); } - $promoteData = D('Promote')->where(array('id' => $promoteId))->find(); $grandPromoteId = getGrandPromoteId($promoteId); $grandPromoteId = empty($grandPromoteId) ? $promoteData['parent_id'] : $grandPromoteId;//本账号会长渠道ID $childGameAddPermission = getChildGameAddPermission($grandPromoteId);//游戏添加权限 @@ -1594,6 +1598,7 @@ class ApplyController extends BaseController switch ($promoteRole) { case 2: case 3: + case 4: $data = getAllPromoteListByType($promoteRole); break; } @@ -1617,11 +1622,6 @@ class ApplyController extends BaseController $gameData['sdk_name'] = getSDKTypeName($gameData['sdk_version']); - $promoteData = D('Promote')->where(array('id' => PID))->find(); - if ($promoteData['parent_id'] > 0 && $promoteData['grand_id'] == 0) { - $promoteType = 3; - } - $promoteIds = getAllPromoteListByType($promoteType); $newPromoteData = []; @@ -1643,6 +1643,7 @@ class ApplyController extends BaseController function addGameToPromote() { + $loginPromote = $this->getLoginPromote(); $gameId = I('game_id'); $promoteIds = I('promote_ids'); @@ -1665,7 +1666,7 @@ class ApplyController extends BaseController foreach ($promoteIds as $value) { $thisPromoteData = D('Promote')->where(array('id' => $value))->find(); - if (empty($thisPromoteData) || !hasPromotePermission(PID, $value)) { + if (empty($thisPromoteData) || !hasPromotePermission($loginPromote['id'], $value)) { $data['status'] = -1; $data['msg'] = '渠道权限异常'; diff --git a/Application/Home/View/default/Apply/index.html b/Application/Home/View/default/Apply/index.html index 6b99364ce..1997e6726 100644 --- a/Application/Home/View/default/Apply/index.html +++ b/Application/Home/View/default/Apply/index.html @@ -100,7 +100,9 @@ color: #999; } - + .btn-role-border { + border-left: 0; + } @@ -154,29 +156,41 @@ - + -
+
+

部长

+
+ +
+

部长

+
+ + + + + +

组长

-
+

组长

- - -
+ + +

推广员

-
+

推广员

- +
@@ -202,12 +216,12 @@ - - @@ -448,7 +462,7 @@ if (data.length > 0) { $.each(data, function (index, item) { - var promoteTitle = item['account'] + '(' + item['nickname'] + ')'; + var promoteTitle = item['account'] + '(' + item['real_name'] + ')'; html += '
- + -
+
+

部长

+
+ +
+

部长

+
+ + + + + +

组长

-
+

组长

- - -
+ + +

推广员

-
+

推广员

- +
@@ -181,12 +197,12 @@ - - @@ -252,10 +268,15 @@ ?>
- - 添加组长游戏 + + 添加部长游戏 + + + 添加组长游戏 + + + 添加推广员游戏 - 添加推广员游戏 复制下载链接 @@ -542,7 +563,7 @@ if (data.length > 0) { $.each(data, function (index, item) { - var promoteTitle = item['account'] + '(' + item['nickname'] + ')'; + var promoteTitle = item['account'] + '(' + item['real_name'] + ')'; html += '