You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.3 KiB
PHTML
106 lines
3.3 KiB
PHTML
4 years ago
|
<?php
|
||
|
|
||
|
|
||
|
namespace Home\Controller;
|
||
|
|
||
|
use Base\Model\PromoteModel;
|
||
|
use Base\Service\PromoteService;
|
||
|
use Base\Service\PromoteGradeService;
|
||
|
|
||
|
class PromoteGradeController extends BaseController
|
||
|
{
|
||
|
public function index($p = 1)
|
||
|
{
|
||
|
$loginPromote = $this->getLoginPromote();
|
||
|
|
||
|
/* $promoteGradeService = new PromoteGradeService();
|
||
|
if (!$promoteGradeService->hadSetting($loginPromote)) {
|
||
|
return $this->error('未设置评级规则');
|
||
|
} */
|
||
|
|
||
|
$time = I('time', date('Y-m-d'));
|
||
|
if (!empty($time)) {
|
||
|
$defaultTime = $time;
|
||
|
} else {
|
||
|
$defaultTime = date('Y-m-d', time());
|
||
|
}
|
||
|
$parentId = I('parent_id', 0);
|
||
|
$promoteId = I('promote_id', 0);
|
||
|
$status = I('status', 0);
|
||
|
$searchLevel = 0;
|
||
|
$searchLevelName = '';
|
||
|
$currentDisplay = '';
|
||
|
$prevParentId = 0;
|
||
|
|
||
|
$promoteService = new PromoteService();
|
||
|
|
||
|
$parent = null;
|
||
|
if ($parentId > 0) {
|
||
|
$parent = M('promote', 'tab_')->where(['id' => $parentId])->find();
|
||
|
$currentDisplay = $promoteService->getLevelName($parent['level']) . '推广';
|
||
|
$prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id'];
|
||
|
} else {
|
||
|
$parent = $loginPromote;
|
||
|
$currentDisplay = '自己';
|
||
|
}
|
||
|
|
||
|
$subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'group_remark'])->where(['parent_id' => $parent['id']])->select();
|
||
|
|
||
|
$map = ['parent_id' => $parent['id']];
|
||
|
if ($promoteId > 0) {
|
||
|
$map['id'] = $promoteId;
|
||
|
}
|
||
|
|
||
|
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map);
|
||
|
list($promotes, $pagination, $count) = $this->paginate($query);
|
||
|
|
||
|
$records = $promoteGradeService->searchGradeByPromotes($promotes, [
|
||
|
'month' => $month,
|
||
|
]);
|
||
|
|
||
|
$this->meta_title = '团队评级';
|
||
|
|
||
|
$this->assign('records', $records);
|
||
|
$this->assign('prevParentId', $prevParentId);
|
||
|
$this->assign('searchLevelName', $searchLevelName);
|
||
|
$this->assign('subPromotes', $subPromotes);
|
||
|
|
||
|
$this->assign('records', $records);
|
||
|
$this->assign('pagination', $pagination);
|
||
|
$this->display();
|
||
|
|
||
|
}
|
||
|
|
||
|
public function settings()
|
||
|
{
|
||
|
$loginPromote = $this->getLoginPromote();
|
||
|
$items = M('promote_grade_setting', 'tab_')->where(['company_id' => $loginPromote['company_id']])->select();
|
||
|
|
||
|
$records = [];
|
||
|
foreach ($items as $key => $item) {
|
||
|
$i = 0;
|
||
|
$config = json_decode($item['config'], true);
|
||
|
$gradeCount = count($config['grades']);
|
||
|
foreach ($config['grades'] as $grade) {
|
||
|
$records['id'] = $item['id'];
|
||
|
$records['grade_count'] = $item['id'];
|
||
|
$records['reach_level'] = $config['reach_level'];
|
||
|
$records['grade_name'] = $grade['name'];
|
||
|
$records['grade_value'] = $grade['symbol'] . $grade['value'];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$this->assign('records', $records);
|
||
|
$this->display();
|
||
|
}
|
||
|
|
||
|
public function setting()
|
||
|
{
|
||
|
$this->display();
|
||
|
}
|
||
|
|
||
|
public function saveSetting()
|
||
|
{
|
||
|
var_dump(I('post.'));
|
||
|
}
|
||
|
}
|