模块修改
This commit is contained in:
@@ -189,7 +189,7 @@ class GiveGift extends Model
|
|||||||
|
|
||||||
//计算收礼人得益
|
//计算收礼人得益
|
||||||
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
||||||
if($receiver_earnings <= 0){
|
if($receiver_earnings < 0){
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
|
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
|
||||||
}
|
}
|
||||||
@@ -302,63 +302,21 @@ class GiveGift extends Model
|
|||||||
foreach ($gift_box as $gv) {
|
foreach ($gift_box as $gv) {
|
||||||
//记录送礼利率和各方收益
|
//记录送礼利率和各方收益
|
||||||
//收礼人是否加入公会
|
//收礼人是否加入公会
|
||||||
$configs = get_system_config();
|
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
||||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
||||||
//收益增加 加入工会的收益
|
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gv['gift_price'],$gv['give_gift_id'],$receiver_earningss,$room_owner_earningss);
|
||||||
if ($is_join_guild) {
|
if (!$gift_rate['code']==0) {
|
||||||
$ratiog = $configs['room_gift_guild_ratio'];
|
|
||||||
} else {
|
|
||||||
$ratiog = 0;
|
|
||||||
}
|
|
||||||
//未加入工会的收益
|
|
||||||
$ratiogr = $configs['room_gift_ratio'];
|
|
||||||
//收礼人最终的收益比例
|
|
||||||
$ratio = $ratiogr + $ratiog;
|
|
||||||
//房主收益大于0 就代表有收益 且在房间
|
|
||||||
if ($room_owner_earningsg > 0) {
|
|
||||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
|
||||||
} else {
|
|
||||||
$guid_ratio = 0;
|
|
||||||
}
|
|
||||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
|
||||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
|
||||||
$app_earning = coin_earning($gv['gift_price'], $app_ratio);
|
|
||||||
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
|
||||||
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
|
||||||
$gift_rate = $this->change_give_gift_profit($gv['give_gift_id'], $ratio, $receiver_earningss, $configs['room_author_ratio'], $room_owner_earningss, $app_ratio, $app_earning);
|
|
||||||
if (!$gift_rate) {
|
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//记录送礼利率和各方收益
|
//记录送礼利率和各方收益
|
||||||
//收礼人是否加入公会
|
//收礼人是否加入公会
|
||||||
$configs = get_system_config();
|
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gift_price,$give_gift,$receiver_earnings,$room_owner_earnings);
|
||||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
if (!$gift_rate['code']==0) {
|
||||||
//收益增加 加入工会的收益
|
|
||||||
if ($is_join_guild) {
|
|
||||||
$ratiog = $configs['room_gift_guild_ratio'];
|
|
||||||
} else {
|
|
||||||
$ratiog = 0;
|
|
||||||
}
|
|
||||||
//未加入工会的收益
|
|
||||||
$ratiogr = $configs['room_gift_ratio'];
|
|
||||||
//收礼人最终的收益比例
|
|
||||||
$ratio = $ratiogr + $ratiog;
|
|
||||||
//房主收益大于0 就代表有收益 且在房间
|
|
||||||
if ($room_owner_earningsg > 0) {
|
|
||||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
|
||||||
} else {
|
|
||||||
$guid_ratio = 0;
|
|
||||||
}
|
|
||||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
|
||||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
|
||||||
$app_earning = coin_earning($gift_price, $app_ratio);
|
|
||||||
$gift_rate = $this->change_give_gift_profit($give_gift, $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning);
|
|
||||||
if (!$gift_rate) {
|
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -652,7 +610,7 @@ class GiveGift extends Model
|
|||||||
|
|
||||||
//计算收礼人得益
|
//计算收礼人得益
|
||||||
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
||||||
if($receiver_earnings <= 0){
|
if($receiver_earnings < 0){
|
||||||
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
|
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,62 +715,21 @@ class GiveGift extends Model
|
|||||||
foreach ($gift_box as $gv) {
|
foreach ($gift_box as $gv) {
|
||||||
//记录送礼利率和各方收益
|
//记录送礼利率和各方收益
|
||||||
//收礼人是否加入公会
|
//收礼人是否加入公会
|
||||||
$configs = get_system_config();
|
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
||||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
||||||
//收益增加 加入工会的收益
|
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gv['gift_price'],$gv['give_gift_id'],$receiver_earningss,$room_owner_earningss);
|
||||||
if ($is_join_guild) {
|
if (!$gift_rate['code']==0) {
|
||||||
$ratiog = $configs['room_gift_guild_ratio'];
|
|
||||||
} else {
|
|
||||||
$ratiog = 0;
|
|
||||||
}
|
|
||||||
//未加入工会的收益
|
|
||||||
$ratiogr = $configs['room_gift_ratio'];
|
|
||||||
//收礼人最终的收益比例
|
|
||||||
$ratio = $ratiogr + $ratiog;
|
|
||||||
//房主收益大于0 就代表有收益 且在房间
|
|
||||||
if ($room_owner_earningsg > 0) {
|
|
||||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
|
||||||
} else {
|
|
||||||
$guid_ratio = 0;
|
|
||||||
}
|
|
||||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
|
||||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
|
||||||
$app_earning = coin_earning($gv['gift_price'], $app_ratio);
|
|
||||||
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
|
||||||
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
|
||||||
$gift_rate = $this->change_give_gift_profit($gv['give_gift_id'], $ratio, $receiver_earningss, $configs['room_author_ratio'], $room_owner_earningss, $app_ratio, $app_earning);
|
|
||||||
if (!$gift_rate) {
|
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//记录送礼利率和各方收益
|
//记录送礼利率和各方收益
|
||||||
//收礼人是否加入公会
|
//收礼人是否加入公会
|
||||||
$configs = get_system_config();
|
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gift_price,$give_gift,$receiver_earnings,$room_owner_earnings);
|
||||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
if (!$gift_rate['code']==0) {
|
||||||
//收益增加 加入工会的收益
|
Db::rollback();
|
||||||
if ($is_join_guild) {
|
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||||
$ratiog = $configs['room_gift_guild_ratio'];
|
|
||||||
} else {
|
|
||||||
$ratiog = 0;
|
|
||||||
}
|
|
||||||
//未加入工会的收益
|
|
||||||
$ratiogr = $configs['room_gift_ratio'];
|
|
||||||
//收礼人最终的收益比例
|
|
||||||
$ratio = $ratiogr + $ratiog;
|
|
||||||
//房主收益大于0 就代表有收益 且在房间
|
|
||||||
if ($room_owner_earningsg > 0) {
|
|
||||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
|
||||||
} else {
|
|
||||||
$guid_ratio = 0;
|
|
||||||
}
|
|
||||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
|
||||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
|
||||||
$app_earning = coin_earning($gift_price, $app_ratio);
|
|
||||||
$gift_rate = $this->change_give_gift_profit($give_gift, $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning);
|
|
||||||
if (!$gift_rate) {
|
|
||||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -919,15 +836,13 @@ class GiveGift extends Model
|
|||||||
$ratio = $configs['gift_chat_earning'];
|
$ratio = $configs['gift_chat_earning'];
|
||||||
}elseif ($from_type == 2 || $from_type == 3){
|
}elseif ($from_type == 2 || $from_type == 3){
|
||||||
//收礼人是否加入公会
|
//收礼人是否加入公会
|
||||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id'=>$to_uid,'status'=>1,'quit_time' => 0])->field('guild_id')->find();
|
$is_join_guild = Db::name('vs_guild_user')->where(['user_id'=>$to_uid,'status'=>1,'quit_time' => 0])->field('guild_id,settlement_ratio')->find();
|
||||||
//收益增加 加入工会的收益
|
//收益增加 加入工会的收益
|
||||||
if($is_join_guild){
|
if($is_join_guild){
|
||||||
$ratiog = $configs['room_gift_guild_ratio'];
|
$ratio = $is_join_guild['settlement_ratio'];
|
||||||
}else{
|
}else{
|
||||||
$ratiog = 0;
|
$ratio = $configs['room_gift_ratio'];
|
||||||
}
|
}
|
||||||
$ratiogr = $configs['room_gift_ratio'];
|
|
||||||
$ratio = $ratiogr +$ratiog;
|
|
||||||
}elseif ($from_type == 4){
|
}elseif ($from_type == 4){
|
||||||
$ratio = $configs['gift_zone_earnings'];
|
$ratio = $configs['gift_zone_earnings'];
|
||||||
}elseif ($from_type == 99){
|
}elseif ($from_type == 99){
|
||||||
@@ -1484,4 +1399,33 @@ class GiveGift extends Model
|
|||||||
return ['code' => 1, 'msg' => '成功', 'data' => $result_data];
|
return ['code' => 1, 'msg' => '成功', 'data' => $result_data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//记录收礼各方收益
|
||||||
|
public function record_gift_profit($to_uid,$room_owner_earningsg,$gift_price,$give_gift,$receiver_earnings,$room_owner_earnings){
|
||||||
|
//记录送礼利率和各方收益
|
||||||
|
//收礼人是否加入公会
|
||||||
|
$configs = get_system_config();
|
||||||
|
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id,settlement_ratio')->find();
|
||||||
|
//收益增加 加入工会的收益
|
||||||
|
if ($is_join_guild) {//加入工会的收益
|
||||||
|
$ratio = $is_join_guild['settlement_ratio'] ?? 0;
|
||||||
|
} else {//未加入工会的收益
|
||||||
|
$ratio = $configs['room_gift_ratio'];
|
||||||
|
}
|
||||||
|
//房主收益大于0 就代表有收益 且在房间
|
||||||
|
if ($room_owner_earningsg > 0) {
|
||||||
|
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||||
|
} else {
|
||||||
|
$guid_ratio = 0;
|
||||||
|
}
|
||||||
|
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||||
|
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||||
|
$app_earning = coin_earning($gift_price, $app_ratio);
|
||||||
|
$gift_rate = $this->change_give_gift_profit($give_gift, $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning);
|
||||||
|
if (!$gift_rate) {
|
||||||
|
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||||
|
}else {
|
||||||
|
return ['code' => 1, 'msg' => '礼物记录成功', 'data' => $gift_rate];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
//配置文件
|
//配置文件
|
||||||
return [
|
return [
|
||||||
'exception_handle' => '\\app\\adminapi\\library\\ExceptionHandle',
|
'exception_handle' => '\\app\\guildadmin\\library\\ExceptionHandle',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\controller;
|
namespace app\guildadmin\controller;
|
||||||
|
|
||||||
use app\admin\command\Menu;
|
use app\admin\command\Menu;
|
||||||
use app\GuildAdmin\model\AuthGroup;
|
use app\guildadmin\model\AuthGroup;
|
||||||
use app\GuildAdmin\model\AuthGroupAccess;
|
use app\guildadmin\model\AuthGroupAccess;
|
||||||
use app\GuildAdmin\model\AuthRule;
|
use app\guildadmin\model\AuthRule;
|
||||||
use app\common\controller\GuildAdmin;
|
use app\common\controller\guildadmin;
|
||||||
use fast\Random;
|
use fast\Random;
|
||||||
use fast\Tree;
|
use fast\Tree;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
@@ -21,7 +21,7 @@ use think\Validate;
|
|||||||
* @icon fa fa-users
|
* @icon fa fa-users
|
||||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||||
*/
|
*/
|
||||||
class Admin extends GuildAdmin
|
class Admin extends guildadmin
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,9 +37,9 @@ class Admin extends GuildAdmin
|
|||||||
public function _initialize()
|
public function _initialize()
|
||||||
{
|
{
|
||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
$this->model = model('GuildAdmin/Admin');
|
$this->model = model('guildadmin/Admin');
|
||||||
$this->authRuleModel = model('GuildAdmin/AuthRule');
|
$this->authRuleModel = model('guildadmin/AuthRule');
|
||||||
$this->authGroup = model('GuildAdmin/AuthGroup');
|
$this->authGroup = model('guildadmin/AuthGroup');
|
||||||
$this->guildId = Session::get('guild_id');
|
$this->guildId = Session::get('guild_id');
|
||||||
$this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin());
|
$this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin());
|
||||||
$this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin());
|
$this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin());
|
||||||
@@ -239,7 +239,7 @@ class Admin extends GuildAdmin
|
|||||||
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
||||||
return V(0,'请选择正确的父角色', null);
|
return V(0,'请选择正确的父角色', null);
|
||||||
}
|
}
|
||||||
$parentmodel = model("guildAdmin/AuthGroup")->get($params['pid']);
|
$parentmodel = model("guildadmin/AuthGroup")->get($params['pid']);
|
||||||
if (!$parentmodel) {
|
if (!$parentmodel) {
|
||||||
return V(0,'请选择正确的父角色', null);
|
return V(0,'请选择正确的父角色', null);
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ class Admin extends GuildAdmin
|
|||||||
}
|
}
|
||||||
$params['rules'] = explode(',', $params['rules']);
|
$params['rules'] = explode(',', $params['rules']);
|
||||||
|
|
||||||
$parentmodel = model("GuildAdmin/AuthGroup")->get($params['pid']);
|
$parentmodel = model("guildadmin/AuthGroup")->get($params['pid']);
|
||||||
if (!$parentmodel) {
|
if (!$parentmodel) {
|
||||||
return V(0,'请选择正确的父角色', null);
|
return V(0,'请选择正确的父角色', null);
|
||||||
}
|
}
|
||||||
@@ -305,13 +305,13 @@ class Admin extends GuildAdmin
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$row->save($params);
|
$row->save($params);
|
||||||
$children_auth_groups = model("GuildAdmin/AuthGroup")->all(['id' => ['in', implode(',', (Tree::instance()->getChildrenIds($row->id)))]]);
|
$children_auth_groups = model("guildadmin/AuthGroup")->all(['id' => ['in', implode(',', (Tree::instance()->getChildrenIds($row->id)))]]);
|
||||||
$childparams = [];
|
$childparams = [];
|
||||||
foreach ($children_auth_groups as $key => $children_auth_group) {
|
foreach ($children_auth_groups as $key => $children_auth_group) {
|
||||||
$childparams[$key]['id'] = $children_auth_group->id;
|
$childparams[$key]['id'] = $children_auth_group->id;
|
||||||
$childparams[$key]['rules'] = implode(',', array_intersect(explode(',', $children_auth_group->rules), $rules));
|
$childparams[$key]['rules'] = implode(',', array_intersect(explode(',', $children_auth_group->rules), $rules));
|
||||||
}
|
}
|
||||||
model("GuildAdmin/AuthGroup")->saveAll($childparams);
|
model("guildadmin/AuthGroup")->saveAll($childparams);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return V(1,"成功", null);
|
return V(1,"成功", null);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -358,7 +358,7 @@ class Admin extends GuildAdmin
|
|||||||
|
|
||||||
// 循环判断每一个组别是否可删除
|
// 循环判断每一个组别是否可删除
|
||||||
$grouplist = $this->authGroup->where('id', 'in', $ids)->select();
|
$grouplist = $this->authGroup->where('id', 'in', $ids)->select();
|
||||||
$groupaccessmodel = model('GuildAdmin/AuthGroupAccess');
|
$groupaccessmodel = model('guildadmin/AuthGroupAccess');
|
||||||
foreach ($grouplist as $k => $v) {
|
foreach ($grouplist as $k => $v) {
|
||||||
// 当前组别下有管理员
|
// 当前组别下有管理员
|
||||||
$groupone = $groupaccessmodel->get(['group_id' => $v['id']]);
|
$groupone = $groupaccessmodel->get(['group_id' => $v['id']]);
|
||||||
@@ -387,7 +387,7 @@ class Admin extends GuildAdmin
|
|||||||
*/
|
*/
|
||||||
public function role_tree()
|
public function role_tree()
|
||||||
{
|
{
|
||||||
$model = model('GuildAdmin/AuthGroup');
|
$model = model('guildadmin/AuthGroup');
|
||||||
$id = $this->request->post("id");
|
$id = $this->request->post("id");
|
||||||
$pid = $this->request->post("pid");
|
$pid = $this->request->post("pid");
|
||||||
$parentGroupModel = $model->get($pid);
|
$parentGroupModel = $model->get($pid);
|
||||||
@@ -398,7 +398,7 @@ class Admin extends GuildAdmin
|
|||||||
}
|
}
|
||||||
if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) {
|
if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) {
|
||||||
$id = $id ? $id : null;
|
$id = $id ? $id : null;
|
||||||
$ruleList = collection(model('GuildAdmin/AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
|
$ruleList = collection(model('guildadmin/AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
|
||||||
//读取父类角色所有节点列表
|
//读取父类角色所有节点列表
|
||||||
$parentRuleList = [];
|
$parentRuleList = [];
|
||||||
if (in_array('*', explode(',', $parentGroupModel->rules))) {
|
if (in_array('*', explode(',', $parentGroupModel->rules))) {
|
||||||
@@ -417,7 +417,7 @@ class Admin extends GuildAdmin
|
|||||||
//当前所有正常规则列表
|
//当前所有正常规则列表
|
||||||
$ruleTree->init($parentRuleList);
|
$ruleTree->init($parentRuleList);
|
||||||
//角色组列表
|
//角色组列表
|
||||||
$groupTree->init(collection(model('GuildAdmin/AuthGroup')->where('id', 'in', $this->childrenGroupIds)->select())->toArray());
|
$groupTree->init(collection(model('guildadmin/AuthGroup')->where('id', 'in', $this->childrenGroupIds)->select())->toArray());
|
||||||
|
|
||||||
//读取当前角色下规则ID集合
|
//读取当前角色下规则ID集合
|
||||||
$adminRuleIds = $this->auth->getRuleIds();
|
$adminRuleIds = $this->auth->getRuleIds();
|
||||||
@@ -547,7 +547,7 @@ class Admin extends GuildAdmin
|
|||||||
foreach ($group as $value) {
|
foreach ($group as $value) {
|
||||||
$dataset[] = ['uid' => $this->model->id, 'group_id' => $value];
|
$dataset[] = ['uid' => $this->model->id, 'group_id' => $value];
|
||||||
}
|
}
|
||||||
model('guildAdmin/AuthGroupAccess')->saveAll($dataset);
|
model('guildadmin/AuthGroupAccess')->saveAll($dataset);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return V(1,"添加成功", []);
|
return V(1,"添加成功", []);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -598,7 +598,7 @@ class Admin extends GuildAdmin
|
|||||||
|
|
||||||
if(!empty($group)){
|
if(!empty($group)){
|
||||||
// 先移除所有权限
|
// 先移除所有权限
|
||||||
model('guildAdmin/AuthGroupAccess')->where('uid', $params['id'])->delete();
|
model('guildadmin/AuthGroupAccess')->where('uid', $params['id'])->delete();
|
||||||
// 过滤不允许的组别,避免越权
|
// 过滤不允许的组别,避免越权
|
||||||
$group = array_intersect($this->childrenGroupIds, $group);
|
$group = array_intersect($this->childrenGroupIds, $group);
|
||||||
if (!$group) {
|
if (!$group) {
|
||||||
@@ -609,7 +609,7 @@ class Admin extends GuildAdmin
|
|||||||
foreach ($group as $value) {
|
foreach ($group as $value) {
|
||||||
$dataset[] = ['uid' => $params['id'], 'group_id' => $value];
|
$dataset[] = ['uid' => $params['id'], 'group_id' => $value];
|
||||||
}
|
}
|
||||||
model('guildAdmin/AuthGroupAccess')->saveAll($dataset);
|
model('guildadmin/AuthGroupAccess')->saveAll($dataset);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return V(1,"成功", []);
|
return V(1,"成功", []);
|
||||||
@@ -698,7 +698,7 @@ class Admin extends GuildAdmin
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$this->model->destroy($deleteIds);
|
$this->model->destroy($deleteIds);
|
||||||
model('guildAdmin/AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
|
model('guildadmin/AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return V(1,"成功", []);
|
return V(1,"成功", []);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\controller;
|
namespace app\guildadmin\controller;
|
||||||
|
|
||||||
use app\admin\command\Menu;
|
use app\admin\command\Menu;
|
||||||
use app\GuildAdmin\model\AuthGroup;
|
use app\guildadmin\model\AuthGroup;
|
||||||
use app\GuildAdmin\model\AuthGroupAccess;
|
use app\guildadmin\model\AuthGroupAccess;
|
||||||
use app\GuildAdmin\model\AuthRule;
|
use app\guildadmin\model\AuthRule;
|
||||||
use app\common\controller\GuildAdmin;
|
use app\common\controller\guildadmin;
|
||||||
use fast\Random;
|
use fast\Random;
|
||||||
use fast\Tree;
|
use fast\Tree;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
@@ -22,7 +22,7 @@ use think\Validate;
|
|||||||
* @icon fa fa-users
|
* @icon fa fa-users
|
||||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||||
*/
|
*/
|
||||||
class GuildData extends GuildAdmin
|
class GuildData extends guildadmin
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $noNeedLogin = [];
|
protected $noNeedLogin = [];
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\controller;
|
namespace app\guildadmin\controller;
|
||||||
|
|
||||||
use app\common\controller\GuildAdmin;
|
use app\common\controller\guildadmin;
|
||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Hook;
|
use think\Hook;
|
||||||
@@ -13,7 +13,7 @@ use think\Validate;
|
|||||||
* 后台首页
|
* 后台首页
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class Index extends GuildAdmin
|
class Index extends guildadmin
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $noNeedLogin = ['login'];
|
protected $noNeedLogin = ['login'];
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\controller;
|
namespace app\guildadmin\controller;
|
||||||
|
|
||||||
use app\admin\command\Menu;
|
use app\admin\command\Menu;
|
||||||
use app\GuildAdmin\model\AuthGroup;
|
use app\guildadmin\model\AuthGroup;
|
||||||
use app\GuildAdmin\model\AuthGroupAccess;
|
use app\guildadmin\model\AuthGroupAccess;
|
||||||
use app\GuildAdmin\model\AuthRule;
|
use app\guildadmin\model\AuthRule;
|
||||||
use app\common\controller\GuildAdmin;
|
use app\common\controller\guildadmin;
|
||||||
use fast\Random;
|
use fast\Random;
|
||||||
use fast\Tree;
|
use fast\Tree;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
@@ -22,7 +22,7 @@ use think\Validate;
|
|||||||
* @icon fa fa-users
|
* @icon fa fa-users
|
||||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||||
*/
|
*/
|
||||||
class Room extends GuildAdmin
|
class Room extends guildadmin
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $noNeedLogin = [];
|
protected $noNeedLogin = [];
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\library;
|
namespace app\guildadmin\library;
|
||||||
|
|
||||||
use app\guildAdmin\model\Admin;
|
use app\guildadmin\model\Admin;
|
||||||
use fast\Random;
|
use fast\Random;
|
||||||
use fast\Tree;
|
use fast\Tree;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
@@ -376,7 +376,7 @@ class Auth extends \fast\Auth
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 取出所有分组
|
// 取出所有分组
|
||||||
$groupList = \app\guildAdmin\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->where('guild_id', Session::get('guild_id'))->select();
|
$groupList = \app\guildadmin\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->where('guild_id', Session::get('guild_id'))->select();
|
||||||
$objList = [];
|
$objList = [];
|
||||||
foreach ($groups as $k => $v) {
|
foreach ($groups as $k => $v) {
|
||||||
if ($v['rules'] === '*') {
|
if ($v['rules'] === '*') {
|
||||||
@@ -408,7 +408,7 @@ class Auth extends \fast\Auth
|
|||||||
$childrenAdminIds = [];
|
$childrenAdminIds = [];
|
||||||
if (!$this->isSuperAdmin()) {
|
if (!$this->isSuperAdmin()) {
|
||||||
$groupIds = $this->getChildrenGroupIds(false);
|
$groupIds = $this->getChildrenGroupIds(false);
|
||||||
$childrenAdminIds = \app\guildAdmin\model\AuthGroupAccess::where('group_id', 'in', $groupIds)
|
$childrenAdminIds = \app\guildadmin\model\AuthGroupAccess::where('group_id', 'in', $groupIds)
|
||||||
->column('uid');
|
->column('uid');
|
||||||
} else {
|
} else {
|
||||||
//超级管理员拥有所有人的权限
|
//超级管理员拥有所有人的权限
|
||||||
@@ -495,12 +495,12 @@ class Auth extends \fast\Auth
|
|||||||
$selected = $referer = [];
|
$selected = $referer = [];
|
||||||
$refererUrl = Session::get('referer');
|
$refererUrl = Session::get('referer');
|
||||||
// 必须将结果集转换为数组
|
// 必须将结果集转换为数组
|
||||||
$ruleList = collection(\app\guildAdmin\model\AuthRule::where('status', 'normal')
|
$ruleList = collection(\app\guildadmin\model\AuthRule::where('status', 'normal')
|
||||||
->where('ismenu', 1)
|
->where('ismenu', 1)
|
||||||
->order('weigh', 'desc')
|
->order('weigh', 'desc')
|
||||||
->cache("__menu__")
|
->cache("__menu__")
|
||||||
->select())->toArray();
|
->select())->toArray();
|
||||||
$indexRuleList = \app\guildAdmin\model\AuthRule::where('status', 'normal')
|
$indexRuleList = \app\guildadmin\model\AuthRule::where('status', 'normal')
|
||||||
->where('ismenu', 0)
|
->where('ismenu', 0)
|
||||||
->where('name', 'like', '%/index')
|
->where('name', 'like', '%/index')
|
||||||
->column('name,pid');
|
->column('name,pid');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\library;
|
namespace app\guildadmin\library;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use think\exception\Handle;
|
use think\exception\Handle;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace app\guildAdmin\model;
|
namespace app\guildadmin\model;
|
||||||
|
|
||||||
use fast\Random;
|
use fast\Random;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use think\Session;
|
use think\Session;
|
||||||
use app\guildAdmin\library\Auth;
|
use app\guildadmin\library\Auth;
|
||||||
|
|
||||||
class Admin extends Model
|
class Admin extends Model
|
||||||
{
|
{
|
||||||
@@ -51,13 +51,13 @@ class Admin extends Model
|
|||||||
'rules' => '*',
|
'rules' => '*',
|
||||||
'status' => 'normal'
|
'status' => 'normal'
|
||||||
];
|
];
|
||||||
$group = model('guildAdmin/AuthGroup')->create($group_data);
|
$group = model('guildadmin/AuthGroup')->create($group_data);
|
||||||
if (!$group) {
|
if (!$group) {
|
||||||
return V(0,"失败", []);
|
return V(0,"失败", []);
|
||||||
}
|
}
|
||||||
$dataset = [];
|
$dataset = [];
|
||||||
$dataset[] = ['uid' => $this->id, 'group_id' => $group['id']];
|
$dataset[] = ['uid' => $this->id, 'group_id' => $group['id']];
|
||||||
model('guildAdmin/AuthGroupAccess')->saveAll($dataset);
|
model('guildadmin/AuthGroupAccess')->saveAll($dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\model;
|
namespace app\guildadmin\model;
|
||||||
|
|
||||||
use app\admin\library\Auth;
|
use app\admin\library\Auth;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\model;
|
namespace app\guildadmin\model;
|
||||||
|
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\model;
|
namespace app\guildadmin\model;
|
||||||
|
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\guildAdmin\model;
|
namespace app\guildadmin\model;
|
||||||
|
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|||||||
Reference in New Issue
Block a user