organization_10119

This commit is contained in:
dengbw
2022-10-19 16:04:27 +08:00
parent f8d8e0f63b
commit cdfdf8ba71
4 changed files with 79 additions and 26 deletions
+17 -4
View File
@@ -39,6 +39,16 @@ class Activity extends BaseController
$list = [];
$where['status>='] = 0;
$title && $where['title LIKE "%' . trim($title) . '%"'] = null;
if ($_SESSION['brandName']) {//品牌机构
$str_organizationIds = '-1';
$re_org = $this->mdSyliveOrganization->get(['organizationName' => $_SESSION['brandName'], 'parentId' => 0, 'status' => 0]);
if ($re_org['organizationId']) {//查找大区
$res_all = $this->mdSyliveOrganization->select(['parentId' => $re_org['organizationId'], 'organizationType' => 2, 'status' => 0]
, 'sortNumber asc,organizationId desc', 0, 0, 'organizationId');
$res_all && $str_organizationIds = implode(',', array_column($res_all, 'organizationId'));
}
$where["activityId in(select distinct(activityId) as activityId from lc_market_sylive_activity_biz WHERE areaId in({$str_organizationIds}) AND status=0)"] = null;
}
$count = $this->mdSyliveActivity->count($where);
if ($count) {
$this->load->library('MyEncryption');
@@ -401,7 +411,8 @@ class Activity extends BaseController
$livePV = $this->mdPolyvViewlog->count($where_pv);
$re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv);
if ($re_sum['playDuration']) {
$watchDuration = round($re_sum['playDuration'] / $livePV);
$playDuration = ceil($re_sum['playDuration'] / 60);
$watchDuration = round($playDuration / $livePV);
}
}
}
@@ -439,7 +450,8 @@ class Activity extends BaseController
$livePV = $this->mdPolyvViewlog->count($where_pv);
$re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv);
if ($re_sum['playDuration']) {
$watchDuration = round($re_sum['playDuration'] / $livePV);
$playDuration = ceil($re_sum['playDuration'] / 60);
$watchDuration = round($playDuration / $livePV);
}
}
}
@@ -473,7 +485,8 @@ class Activity extends BaseController
$livePV = $this->mdPolyvViewlog->count($where_pv);
$re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv);
if ($re_sum['playDuration']) {
$watchDuration = round($re_sum['playDuration'] / $livePV);
$playDuration = ceil($re_sum['playDuration'] / 60);
$watchDuration = round($playDuration / $livePV);
}
}
}
@@ -494,7 +507,7 @@ class Activity extends BaseController
$duration = ceil($re_duration['duration'] / 60);
$livePV = $re_livePV['livePV'];
$watchDuration = round($duration / $livePV);
$pvDuration = round($livePV / $re_liveUV['liveUV'],1);
$pvDuration = round($livePV / $re_liveUV['liveUV'], 1);
}
}
$activityData1 = [['name' => '参与区域数', 'value' => count($areaData)], ['name' => '参与门店数', 'value' => count($bizData)]
@@ -27,6 +27,22 @@ class Organization extends BaseController
$where['status>='] = 0;
$unOrganizationType && $where['organizationType<>'] = $unOrganizationType;
$sort_order = 'sortNumber asc,organizationId desc';
if ($_SESSION['brandName']) {//只找该品牌机构
$re_org = $this->mdSyliveOrganization->get(['organizationName' => $_SESSION['brandName'], 'parentId' => 0, 'status' => 0]);
if ($re_org['organizationId']) {
$organizationIds[] = $re_org['organizationId'];
$res_all = $this->mdSyliveOrganization->select($where, 'organizationType asc,parentId asc', 0, 0, 'organizationId,parentId');
foreach ($res_all as $k => $v) {
if (in_array($v['parentId'], $organizationIds)) {
$organizationIds[] = $v['organizationId'];
}
}
$str_organizationIds = implode(',', array_unique($organizationIds));
$where["organizationId in({$str_organizationIds})"] = null;
} else {
$where['organizationId'] = -1;
}
}
$res = $this->mdSyliveOrganization->select($where, $sort_order);
foreach ($res as $k => $v) {
$res[$k]['organizationId'] = intval($v['organizationId']);
@@ -57,6 +73,9 @@ class Organization extends BaseController
$sortNumber = intval($this->input_param('sortNumber'));
$comments = $this->input_param('comments');
$city = $this->input_param('city');
if ($_SESSION['brandName'] && !$parentId) {//品牌机构必顺选择上级机构
$this->return_json('请选择上级机构');
}
if (!$organizationName) {
$this->return_json('请输入机构名称');
}
@@ -95,6 +114,12 @@ class Organization extends BaseController
$comments = $this->input_param('comments');
$city = $this->input_param('city');
!$comments && $comments = '';
if ($_SESSION['brandName']) {//品牌机构
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $organizationId]);
if ($re_org && $re_org['parentId'] == 0) {
$this->return_json('无此机构修改权限,请联系管理员');
}
}
if (!$organizationId) {
$this->return_json('参数错误');
}
+8
View File
@@ -96,6 +96,14 @@ class Role extends BaseController
if (!$id) {
$this->return_json('添加角色失败');
}
if ($roleCode == 'brand') {//角色品牌
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
$re_org = $this->mdSyliveOrganization->get(['organizationName' => $roleName, 'parentId' => 0, 'status' => 0]);
if (!$re_org) {//创建品牌
$addDate = ['parentId' => 0, 'organizationName' => $roleName, 'organizationType' => 1, 'createTime' => date('Y-m-d H:i:s')];
$this->mdSyliveOrganization->add($addDate);
}
}
$this->return_response();
}
+29 -22
View File
@@ -67,31 +67,38 @@ class ApiAuthHook
} else if (strstr($route, '/page')) {//列表搜索权限
$authority_set = 'list';
}
$menuIds = '';
if ($re_admin['roleId']) {//查找角色
$this->CI->load->model('market/Market_sys_role_model');
$re_role = $this->CI->Market_sys_role_model->get(['roleId' => $re_admin['roleId'], 'status' => 0]);
if ($re_role) {
$menuIds = $re_role['menuIds'];
if ($re_role['roleCode'] == 'brand') {//品牌角色
$_SESSION['brandName'] = $re_role['roleName'];
}
}
}
if ($authority_set) {
$show = true;
$authority = $authorityAry[1] . ':' . $authorityAry[2] . ':' . $authority_set;//system:user:save
if ($re_admin['roleId']) {
$this->CI->load->model('market/Market_sys_role_model');
$re_role = $this->CI->Market_sys_role_model->get(['roleId' => $re_admin['roleId'], 'status' => 0]);
if ($re_role['menuIds']) {
if (strstr($route, '/roleMenu')) {//角色分配权限
$authority = 'system:role:' . $authority_set;
} else if (strstr($route, '/dictionaryData')) {//字典项权限
$authority = 'system:dictionary:' . $authority_set;
} else if (strstr($route, '/sylive/user')) {//机构用户权限
$authority = 'sylive:organization:' . $authority_set;
}
$this->CI->load->model('market/Market_sys_menu_model');
$re_menu = $this->CI->Market_sys_menu_model->get(["menuId in({$re_role['menuIds']})" => null, 'status' => 0
, 'authority' => $authority]);
if ($re_menu) {
$show = false;
if ($re_menu['title'] == '登录日志' || $re_menu['title'] == '操作日志') {
} else {
$_SESSION['operation_description'] = $re_menu['title'];//操作功能
$re_menu2 = $this->CI->Market_sys_menu_model->get(["menuId" => $re_menu['parentId'], 'status' => 0]);
$_SESSION['operation_module'] = $re_menu2['title'] ? $re_menu2['title'] : $re_menu['title'];//操作模块
}
if ($menuIds) {
if (strstr($route, '/roleMenu')) {//角色分配权限
$authority = 'system:role:' . $authority_set;
} else if (strstr($route, '/dictionaryData')) {//字典项权限
$authority = 'system:dictionary:' . $authority_set;
} else if (strstr($route, '/sylive/user')) {//机构用户权限
$authority = 'sylive:organization:' . $authority_set;
}
$this->CI->load->model('market/Market_sys_menu_model');
$re_menu = $this->CI->Market_sys_menu_model->get(["menuId in({$menuIds})" => null, 'status' => 0
, 'authority' => $authority]);
if ($re_menu) {
$show = false;
if ($re_menu['title'] == '登录日志' || $re_menu['title'] == '操作日志') {
} else {
$_SESSION['operation_description'] = $re_menu['title'];//操作功能
$re_menu2 = $this->CI->Market_sys_menu_model->get(["menuId" => $re_menu['parentId'], 'status' => 0]);
$_SESSION['operation_module'] = $re_menu2['title'] ? $re_menu2['title'] : $re_menu['title'];//操作模块
}
}
}