|
|
|
@ -24,14 +24,9 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
public function index($p = 1)
|
|
|
|
|
{
|
|
|
|
|
$month = I('month', date('Y-m'));
|
|
|
|
|
$month = $month ? $month : date('Y-m');
|
|
|
|
|
$baseGameId = I('base_game_id', 0);
|
|
|
|
|
$loginPromote = $this->getLoginPromote();
|
|
|
|
|
|
|
|
|
|
$promoteGradeService = new PromoteGradeService();
|
|
|
|
|
$setting = $promoteGradeService->getCurrentSetting($loginPromote);
|
|
|
|
|
if (is_null($setting)) {
|
|
|
|
|
return $this->error('未设置评级规则');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$parentId = I('parent_id', 0);
|
|
|
|
|
$promoteId = I('promote_id', 0);
|
|
|
|
|
$searchLevel = 0;
|
|
|
|
@ -51,6 +46,9 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
$currentDisplay = '自己';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$searchLevel = $parent['level'] + 1;
|
|
|
|
|
$searchLevelName = $promoteService->getLevelName($searchLevel);
|
|
|
|
|
|
|
|
|
|
$subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'group_remark'])->where(['parent_id' => $parent['id']])->select();
|
|
|
|
|
|
|
|
|
|
$map = ['parent_id' => $parent['id']];
|
|
|
|
@ -58,34 +56,71 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
$map['id'] = $promoteId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map);
|
|
|
|
|
list($promotes, $pagination, $count) = $this->paginate($query);
|
|
|
|
|
$promoteGradeService = new PromoteGradeService();
|
|
|
|
|
|
|
|
|
|
if (I('p', 1) == 1) {
|
|
|
|
|
array_unshift($promotes, $parent);
|
|
|
|
|
$error = '';
|
|
|
|
|
$status = true;
|
|
|
|
|
$setting = null;
|
|
|
|
|
$pagination = null;
|
|
|
|
|
if ($baseGameId == 0) {
|
|
|
|
|
$status = false;
|
|
|
|
|
$error = '请选择游戏';
|
|
|
|
|
} else {
|
|
|
|
|
$monthNumber = date('Ym', strtotime($month . '-01'));
|
|
|
|
|
$setting = $promoteGradeService->getCurrentSetting($loginPromote, $baseGameId, $monthNumber);
|
|
|
|
|
if (is_null($setting)) {
|
|
|
|
|
$status = false;
|
|
|
|
|
$error = '该游戏在此月份未设置评级规则';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$records = $promoteGradeService->searchGradeByPromotes($promotes, [
|
|
|
|
|
'month' => $month,
|
|
|
|
|
], $setting);
|
|
|
|
|
$records = [];
|
|
|
|
|
if ($status) {
|
|
|
|
|
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map);
|
|
|
|
|
list($promotes, $pagination, $count) = $this->paginate($query);
|
|
|
|
|
|
|
|
|
|
if (I('p', 1) == 1) {
|
|
|
|
|
array_unshift($promotes, $parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$records = $promoteGradeService->searchGradeByPromotes($promotes, [
|
|
|
|
|
'month' => $month,
|
|
|
|
|
], $setting);
|
|
|
|
|
|
|
|
|
|
if (I('p', 1) == 1) {
|
|
|
|
|
$records[0]['current_display'] = $currentDisplay;
|
|
|
|
|
if (I('p', 1) == 1) {
|
|
|
|
|
$records[0]['current_display'] = $currentDisplay;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->meta_title = '团队评级';
|
|
|
|
|
|
|
|
|
|
$this->assign('month', $month);
|
|
|
|
|
$baseGames = $promoteService->getVisibleBaseGames($loginPromote);
|
|
|
|
|
$this->assign('baseGames', $baseGames);
|
|
|
|
|
$this->assign('error', $error);
|
|
|
|
|
$this->assign('prevParentId', $prevParentId);
|
|
|
|
|
$this->assign('searchLevelName', $searchLevelName);
|
|
|
|
|
$this->assign('subPromotes', $subPromotes);
|
|
|
|
|
$this->assign('parentId', $parentId);
|
|
|
|
|
$this->assign('records', $records);
|
|
|
|
|
$this->assign('month', $month);
|
|
|
|
|
$this->assign('pagination', $pagination);
|
|
|
|
|
$this->display();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getMonthRangeDisplay($monthBegin, $monthEnd)
|
|
|
|
|
{
|
|
|
|
|
if ($monthBegin == 0 && $monthEnd == 0) {
|
|
|
|
|
return '永久';
|
|
|
|
|
} elseif ($monthBegin == 0 && $monthEnd > 0) {
|
|
|
|
|
return '从前 至 ' . date('Y-m', strtotime($monthEnd . '01'));
|
|
|
|
|
} elseif ($monthBegin > 0 && $monthEnd == 0) {
|
|
|
|
|
return date('Y-m', strtotime($monthBegin . '01')) . ' 至 永久';
|
|
|
|
|
} else {
|
|
|
|
|
return date('Y-m', strtotime($monthBegin . '01')) . ' 至 ' . date('Y-m', strtotime($monthEnd . '01'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function settings()
|
|
|
|
|
{
|
|
|
|
|
$this->checkSettingPermission();
|
|
|
|
@ -93,6 +128,13 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
$loginPromote = $this->getLoginPromote();
|
|
|
|
|
$items = M('promote_grade_setting', 'tab_')->where(['company_id' => $loginPromote['company_id']])->select();
|
|
|
|
|
|
|
|
|
|
$baseGameIds = array_column($items, 'base_game_id');
|
|
|
|
|
$itemBaseGames = [];
|
|
|
|
|
if (count($baseGameIds) > 0) {
|
|
|
|
|
$itemBaseGames = M('base_game', 'tab_')->where(['id' => ['in', $baseGameIds]])->select();
|
|
|
|
|
$itemBaseGames = index_by_column('id', $itemBaseGames);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$symbols = PromoteGradeService::$symbols;
|
|
|
|
|
|
|
|
|
|
$records = [];
|
|
|
|
@ -100,11 +142,16 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
$i = 0;
|
|
|
|
|
$config = json_decode($item['config'], true);
|
|
|
|
|
$gradeCount = count($config['grades']) + 1;
|
|
|
|
|
$baseGame = $itemBaseGames[$item['base_game_id']] ?? null;
|
|
|
|
|
$baseGameName = $baseGame ? $baseGame['name'] : '--';
|
|
|
|
|
$monthRangeDisplay = $this->getMonthRangeDisplay($item['month_begin'], $item['month_end']);
|
|
|
|
|
if ($gradeCount == 1) {
|
|
|
|
|
$records[] = [
|
|
|
|
|
'id' => $item['id'],
|
|
|
|
|
'name' => $item['name'],
|
|
|
|
|
'game_name' => $baseGameName,
|
|
|
|
|
'grade_count' => $gradeCount,
|
|
|
|
|
'month_range' => $monthRangeDisplay,
|
|
|
|
|
'reach_level' => $config['reach_level'],
|
|
|
|
|
'grade_name' => $config['default_grade_name'],
|
|
|
|
|
'grade_value' => '全部'
|
|
|
|
@ -114,7 +161,9 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
$records[] = [
|
|
|
|
|
'id' => $item['id'],
|
|
|
|
|
'name' => $item['name'],
|
|
|
|
|
'game_name' => $baseGameName,
|
|
|
|
|
'grade_count' => $gradeCount,
|
|
|
|
|
'month_range' => $monthRangeDisplay,
|
|
|
|
|
'reach_level' => $config['reach_level'],
|
|
|
|
|
'grade_name' => $config['default_grade_name'],
|
|
|
|
|
'grade_value' => ($firstGrade['symbol'] == 1 ? '<' : '<=') . $firstGrade['value']
|
|
|
|
@ -123,7 +172,9 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
$records[] = [
|
|
|
|
|
'id' => $item['id'],
|
|
|
|
|
'name' => $item['name'],
|
|
|
|
|
'game_name' => $baseGameName,
|
|
|
|
|
'grade_count' => 0,
|
|
|
|
|
'month_range' => $monthRangeDisplay,
|
|
|
|
|
'reach_level' => $config['reach_level'],
|
|
|
|
|
'grade_name' => $grade['name'],
|
|
|
|
|
'grade_value' => $symbols[$grade['symbol']] . $grade['value']
|
|
|
|
@ -131,6 +182,10 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promoteService = new PromoteService();
|
|
|
|
|
$baseGames = $promoteService->getVisibleBaseGames($loginPromote);
|
|
|
|
|
$this->assign('baseGames', $baseGames);
|
|
|
|
|
$this->assign('records', $records);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
@ -138,6 +193,8 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
public function setting()
|
|
|
|
|
{
|
|
|
|
|
$this->checkSettingPermission();
|
|
|
|
|
$loginPromote = $this->getLoginPromote();
|
|
|
|
|
|
|
|
|
|
$id = I('id', 0);
|
|
|
|
|
$setting = null;
|
|
|
|
|
if ($id > 0) {
|
|
|
|
@ -148,6 +205,10 @@ class PromoteGradeController extends BaseController
|
|
|
|
|
$setting['config'] = json_decode($setting['config'], true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promoteService = new PromoteService();
|
|
|
|
|
$baseGames = $promoteService->getVisibleBaseGames($loginPromote);
|
|
|
|
|
$this->assign('baseGames', $baseGames);
|
|
|
|
|
$this->assign('setting', $setting);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|