Merge pull request 'feature/more_payment' (#430) from feature/more_payment into master

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/430
master
廖金灵 4 years ago
commit 813a05a04c

@ -1704,6 +1704,7 @@ function resetUserAuth()
session('user_auth', $userAuth); session('user_auth', $userAuth);
session('user_auth_sign', data_auth_sign($userAuth)); session('user_auth_sign', data_auth_sign($userAuth));
session('user_auth_promote_ids', null); session('user_auth_promote_ids', null);
session('user_auth_company_ids', null);
} }
/** /**
@ -2819,7 +2820,8 @@ function getAvailableBalance($promote_id=0,$game_id=0,$server_id='') {
function getMarketGroupIds() function getMarketGroupIds()
{ {
return M('auth_group', 'sys_')->where(['title' => ['like', '%市场专员%']])->getField('id', true); $map['id'] = ['in',A('Market','Event')->getNoLeaderMarketGroupId()];
return M('auth_group', 'sys_')->where($map)->getField('id', true);
} }
function getAdmins() function getAdmins()
@ -2829,7 +2831,7 @@ function getAdmins()
function getMarketAdmins() function getMarketAdmins()
{ {
$ids = getMarketGroupIds(); $ids = A('Market','Event')->getMarketGroupId();
if (count($ids) == 0) { if (count($ids) == 0) {
return []; return [];
} }
@ -2888,13 +2890,15 @@ function isMarketLeader()
if(IS_SUBSITE){ if(IS_SUBSITE){
return false; return false;
} }
$authGroup = M('auth_group','sys_')->where(['title'=>'市场总监'])->find(); $gid = session('user_group_id');
if (!$authGroup) { $markerGroup = A("Market","Event")->isMarketAdminGroup($gid);
return false; if($markerGroup){
if($markerGroup['department_level'] == A("Market","Event")->getConfig("DirectorLevel")){
//总监
return true;
}
} }
$userAuth = session('user_auth'); return false;
$adminIds = M('auth_group_access', 'sys_')->where(['group_id' => $authGroup['id']])->getField('uid', true);
return in_array($userAuth['uid'], $adminIds);
} }
function isMarketAdmin() function isMarketAdmin()
@ -2917,12 +2921,7 @@ function isMarketAdmin()
*/ */
function getMarketAdmin() { function getMarketAdmin() {
$map['group_id'] = ['in','11,12,21,25']; $map['group_id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()];
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['menber.uid'] = $admin_id;
if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23||session('user_group_id') == 25) {
unset($map['menber.uid']);
}
$data = M("auth_group_access") $data = M("auth_group_access")
->field("real_name,menber.uid,nickname") ->field("real_name,menber.uid,nickname")
@ -3116,11 +3115,11 @@ function promote_listsMarket($type){
setPowerPromoteIds($map,'id'); setPowerPromoteIds($map,'id');
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; // $admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['admin_id'] = $admin_id; // $map['admin_id'] = $admin_id;
if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23) { // if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23) {
unset($map['admin_id']); // unset($map['admin_id']);
} // }
$data = M('promote','tab_')->where($map)->select(); $data = M('promote','tab_')->where($map)->select();
@ -3136,46 +3135,6 @@ function promote_listsMarket($type){
return $data; return $data;
} }
//市场部获取公司或推广员id
function getMarketAuthPromoteId()
{
$map['level'] = 1;
if (isMarketLeader()) {
//搜索所有市场部管理员id
$mid = M("AuthGroup")->where("title like '%市场%'")->getField("id",true);
$mid = implode(",",$mid);
$admin_id = M("AuthGroupAccess")->where("group_id in ({$mid})")->getField("uid",true);
$admin_id = implode(",",$admin_id);
$map['admin_id'] = ['in', $admin_id];
}elseif(isMarketAdmin()){
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
$map['admin_id'] = $adminId;
}else{
return false;
}
$dbres = M("Promote","tab_")->where($map)->getField("id",true);
if(empty($dbres)){
return -1;
}else{
return implode(",",$dbres);
}
}
function throwPromoteIdToCompanyId($p_ids)
{
$dbres = M("Promote","tab_")->where("id in ({$p_ids})")->field("count(*) count,company_id")->group("company_id")->select();
if(empty($dbres)){
return -1;
}else{
return implode(",",array_column($dbres,"company_id"));
}
}
/** /**
* 选择收款商户 * 选择收款商户

@ -617,9 +617,16 @@ function getAllGame()
*/ */
function getPromoteCompany() function getPromoteCompany()
{ {
// $companyId = A("Market","Event")->getAdminCompanyId();
$where = [
"status"=>1
];
// if($companyId != 'all'){
// $where['id'] = ["in",$companyId];
// }
$list = M("PromoteCompany", 'tab_') $list = M("PromoteCompany", 'tab_')
->field('id,company_name') ->field('id,company_name')
->where("status = 1") ->where($where)
->select(); ->select();
array_unshift($list,array("id"=>0,"company_name"=>C(DEFAULT_COMPANY)));//默认0 array_unshift($list,array("id"=>0,"company_name"=>C(DEFAULT_COMPANY)));//默认0
return $list; return $list;
@ -1093,3 +1100,8 @@ function getAffairMember() {
} }
function getMarketLevel()
{
return A("Market","Event")->getConfig('LevelConfig');
}

@ -92,8 +92,15 @@ class AuthManagerController extends AdminController{
public function index(){ public function index(){
$list = $this->lists('AuthGroup',array('module'=>'admin'),'id asc',true,true); $list = $this->lists('AuthGroup',array('module'=>'admin'),'id asc',true,true);
$list = int_to_string($list); $list = int_to_string($list);
foreach ($list as &$v) {
if(empty($v['department_name'])) $v['department_name'] = "--";
}
$this->assign( '_list', $list ); $this->assign( '_list', $list );
$this->assign( '_use_tip', true ); $this->assign( '_use_tip', true );
$marketGroup = A("Market","Event")->getMarketGroupId();
$this->assign( 'market_group', explode(",",$marketGroup));
$this->meta_title = '权限管理'; $this->meta_title = '权限管理';
$this->checkListOrCountAuthRestMap($map,[]); $this->checkListOrCountAuthRestMap($map,[]);

@ -6,6 +6,7 @@ class CompanyGameRatioController extends AdminController
{ {
public $admininfo; public $admininfo;
public $DBModel; public $DBModel;
public $MarketEvent;
public $OpAuthList=[]; public $OpAuthList=[];
public $Status = [ public $Status = [
"-2"=>"管理员拒绝", "-2"=>"管理员拒绝",
@ -24,6 +25,7 @@ class CompanyGameRatioController extends AdminController
{ {
$this->admininfo = $_SESSION['onethink_admin']['user_auth']; $this->admininfo = $_SESSION['onethink_admin']['user_auth'];
$this->DBModel = M("company_game_ratio","tab_"); $this->DBModel = M("company_game_ratio","tab_");
$this->MarketEvent = A("Market","Event");
parent::_initialize(); parent::_initialize();
} }
@ -78,18 +80,16 @@ class CompanyGameRatioController extends AdminController
} }
} }
} }
$gid = session('user_group_id');
$isMarketAdmin = isMarketAdmin(); $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($isMarketAdmin) { if($markerGroup){
$userAuth = session('user_auth'); $companyIds = $this->MarketEvent->getAdminCompanyId();
$adminId = $userAuth['uid']; //取消0
$companyIds = M('promote', 'tab_')->where(['admin_id' => $adminId, 'level' => 1])->getField('company_id', true); $companyIds = implode(",",array_diff(explode(",",$companyIds),[0]));
$companyIds = array_unique($companyIds); $marketCondition = 'm.company_id in(' . $companyIds . ')';
$marketCondition = ''; if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){
if (count($companyIds) > 0) { //总监
$marketCondition = 'm.company_id in(' . implode(',', $companyIds) . ')'; $marketCondition .= " OR (m.company_id = 0 AND m.company_belong != 0 )";
} else {
$marketCondition = '1<>1';
} }
$where['_string'] = isset($where['_string']) ? $where['_string'] . ' and ' . $marketCondition : $marketCondition; $where['_string'] = isset($where['_string']) ? $where['_string'] . ' and ' . $marketCondition : $marketCondition;
} }
@ -265,6 +265,22 @@ class CompanyGameRatioController extends AdminController
} }
} }
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
$companyIds = $this->MarketEvent->getAdminCompanyId();
//取消0
$companyIds = implode(",",array_diff(explode(",",$companyIds),[0]));
$marketCondition = 'm.company_id in(' . $companyIds . ')';
if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){
//总监
$marketCondition .= " OR (m.company_id = 0 AND m.company_belong != 0 )";
}
$where['_string'] = isset($where['_string']) ? $where['_string'] . ' and ' . $marketCondition : $marketCondition;
}
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
$time_start = strtotime($_REQUEST['time_start']); $time_start = strtotime($_REQUEST['time_start']);
$time_end = strtotime($_REQUEST['time_end'])+ 86399; $time_end = strtotime($_REQUEST['time_end'])+ 86399;

@ -34,6 +34,7 @@ class CompanyStatementController extends ThinkController
]; ];
public $admininfo; public $admininfo;
public $DBModel; public $DBModel;
private $MarketEvent;
static $specialCompoent; static $specialCompoent;
@ -42,6 +43,7 @@ class CompanyStatementController extends ThinkController
{ {
$this->admininfo = $_SESSION['onethink_admin']['user_auth']; $this->admininfo = $_SESSION['onethink_admin']['user_auth'];
$this->DBModel = SM("CompanyStatement","tab_"); $this->DBModel = SM("CompanyStatement","tab_");
$this->MarketEvent = A("Market","Event");
$Factory = BaseFactory::getInstance(); $Factory = BaseFactory::getInstance();
self::$specialCompoent = $Factory->factoryClass("SpecialCompoent"); self::$specialCompoent = $Factory->factoryClass("SpecialCompoent");
@ -60,16 +62,26 @@ class CompanyStatementController extends ThinkController
$map = [ $map = [
"_string"=>"1=1" "_string"=>"1=1"
]; ];
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
$companyIds = $this->MarketEvent->getAdminCompanyId();
$map['_string'] .= ' AND company_id in(' . $companyIds . ') and company_belong not in (0,9)';
}
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
$time_start = strtotime($_REQUEST['time_start']); $time_start = strtotime($_REQUEST['time_start']);
$time_end = strtotime($_REQUEST['time_end'])+ 86399; $time_end = strtotime($_REQUEST['time_end'])+ 86399;
$map["_string"] = "( (statement_begin_time BETWEEN {$time_start} AND {$time_end}) OR (statement_end_time BETWEEN {$time_start} AND {$time_end}) )"; $map["_string"] .= " AND ( (statement_begin_time BETWEEN {$time_start} AND {$time_end}) OR (statement_end_time BETWEEN {$time_start} AND {$time_end}) )";
} elseif (isset($_REQUEST['time_start'])) { } elseif (isset($_REQUEST['time_start'])) {
$time_start = strtotime($_REQUEST['time_start']); $time_start = strtotime($_REQUEST['time_start']);
$map["_string"] = "( (statement_begin_time >= {$time_start} ) OR (statement_end_time >= {$time_start}) )"; $map["_string"] .= " AND ( (statement_begin_time >= {$time_start} ) OR (statement_end_time >= {$time_start}) )";
} elseif (isset($_REQUEST['time_end'])) { } elseif (isset($_REQUEST['time_end'])) {
$time_end = strtotime($_REQUEST['time_end'])+ 86399; $time_end = strtotime($_REQUEST['time_end'])+ 86399;
$map["_string"] = "( (statement_begin_time <= {$time_end} ) OR (statement_end_time <= {$time_end}) )"; $map["_string"] .= " AND ( (statement_begin_time <= {$time_end} ) OR (statement_end_time <= {$time_end}) )";
} }
if (isset($_REQUEST['time_start2']) && isset($_REQUEST['time_end2'])) { if (isset($_REQUEST['time_start2']) && isset($_REQUEST['time_end2'])) {

@ -42,20 +42,20 @@ class FinancePromoteController extends AdminController
$senddata = []; $senddata = [];
//获取各会长的充值方式 //获取各会长的充值方式
$cash = self::getJoinPromoteData([],$istimeselect); $cash = $this->getJoinPromoteData([],$istimeselect);
foreach($cash as $k=>$v){ foreach($cash as $k=>$v){
$senddata[$v['p_id']] = $v; $senddata[$v['p_id']] = $v;
} }
$unsenddata = []; $unsenddata = [];
$uncash = self::getJoinUnPayPromoteData([],$istimeselect); $uncash = $this->getJoinUnPayPromoteData([],$istimeselect);
foreach($uncash as $k=>$v){ foreach($uncash as $k=>$v){
$unsenddata[$v['p_id']] = $v; $unsenddata[$v['p_id']] = $v;
} }
//内冲 //内冲
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin"); $inside = $this->getJoinPromoteData([],$istimeselect,"promote_coin");
foreach($inside as $k=>$v){ foreach($inside as $k=>$v){
if(array_key_exists($v['p_id'],$senddata)){ if(array_key_exists($v['p_id'],$senddata)){
$senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount']; $senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount'];
@ -113,7 +113,7 @@ class FinancePromoteController extends AdminController
unset($_REQUEST['company_id']); unset($_REQUEST['company_id']);
unset($_REQUEST['company_belong']); unset($_REQUEST['company_belong']);
$_REQUEST['promote_id'] = 0; $_REQUEST['promote_id'] = 0;
$gfcash = self::getJoinPromoteData([],$istimeselect); $gfcash = $this->getJoinPromoteData([],$istimeselect);
$senddata[0] = $gfcash[0]; $senddata[0] = $gfcash[0];
$pmap['status']=1; $pmap['status']=1;
@ -256,7 +256,8 @@ class FinancePromoteController extends AdminController
} }
$isMarketLeader = isMarketLeader(); $isMarketLeader = isMarketLeader();
if ($isMarketLeader) { if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0]; $marketPromoteIds = getPowerPromoteIds();
$map['_string'] = "s.promote_id in ($marketPromoteIds)";
} }
if (!empty(I('develop_type'))) { if (!empty(I('develop_type'))) {
@ -340,7 +341,8 @@ class FinancePromoteController extends AdminController
} }
$isMarketLeader = isMarketLeader(); $isMarketLeader = isMarketLeader();
if ($isMarketLeader) { if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0]; $marketPromoteIds = getPowerPromoteIds();
$map['_string'] = "s.promote_id in ($marketPromoteIds)";
} }
if (!empty(I('develop_type'))) { if (!empty(I('develop_type'))) {

@ -23,6 +23,13 @@ class GameRatioMouldController extends AdminController
//获取游戏id //获取游戏id
$gamewhere['_string'] = '1 = 1'; $gamewhere['_string'] = '1 = 1';
$where['_string'] = '1 = 1'; $where['_string'] = '1 = 1';
$markerGroup = A("Market","Event")->isMarketAdminGroup(session('user_group_id'));
if($markerGroup){
$where['_string'] .= " AND m.company_belong > 0";
}
if(isset($params['relation_game_id'])){ if(isset($params['relation_game_id'])){
$gamewhere['relation_game_id'] = $params['relation_game_id']; $gamewhere['relation_game_id'] = $params['relation_game_id'];
$where['m.relation_game_id'] = $params['relation_game_id']; $where['m.relation_game_id'] = $params['relation_game_id'];

@ -17,6 +17,7 @@ class MarketPercentageController extends ThinkController
private $leavePercentage; private $leavePercentage;
private $unSettlementList; private $unSettlementList;
private $marketPercentage; private $marketPercentage;
private $MarketEvent;
private $returnMarketPercentageArray = []; private $returnMarketPercentageArray = [];
private $returnWaitMarketPercentageArray = []; private $returnWaitMarketPercentageArray = [];
@ -39,6 +40,7 @@ class MarketPercentageController extends ThinkController
//不结算列表 //不结算列表
$this->leavePercentage->unSettlementList(); $this->leavePercentage->unSettlementList();
$this->unSettlementList = $this->leavePercentage->returnUnSettlementList(); $this->unSettlementList = $this->leavePercentage->returnUnSettlementList();
$this->MarketEvent = A("Market","Event");
parent::_initialize(); parent::_initialize();
} }
@ -46,7 +48,11 @@ class MarketPercentageController extends ThinkController
public function index($row = 10, $p = 1) public function index($row = 10, $p = 1)
{ {
$map = []; // $this->MarketEvent->getAdminCompanyId();
$map = [
"is_settlement"=>1,
"_string"=>"1=1"
];
// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; // $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):'';
$_REQUEST['promote_id'] ? ($map['promote_id'] = $_REQUEST['promote_id']) : ''; $_REQUEST['promote_id'] ? ($map['promote_id'] = $_REQUEST['promote_id']) : '';
@ -55,22 +61,33 @@ class MarketPercentageController extends ThinkController
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
($_REQUEST['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : ''; ($_REQUEST['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : '';
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; $admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['admin_id'] = $admin_id; $gid = session('user_group_id');
$map['is_settlement'] = 1; $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) { if($markerGroup){
unset($map['admin_id']); $map['department_id'] =["in",[0,$markerGroup['department_id']]];
$admin_data = M("member") if( !$this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
->field("access.uid admin_id") $map['admin_id'] = $admin_id ;
->join("left join sys_auth_group_access access on sys_member.uid = access.uid") }
->join("left join sys_auth_group auth on access.group_id=auth.id") }
->where(['group_id' => ['in', '11,12,21,25']]) // dd($map);
->select();
if ($admin_data) { // $map['admin_id'] = $admin_id;
$map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; // if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) {
} // unset($map['admin_id']);
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; // $admin_data = M("member")
} // ->field("access.uid admin_id")
// ->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
// ->join("left join sys_auth_group auth on access.group_id=auth.id")
// ->where(['group_id' => ['in', '11,12,21,25']])
// ->select();
// if ($admin_data) {
// $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')];
// }
// $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
// }
$search_date = []; $search_date = [];
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
@ -589,9 +606,9 @@ class MarketPercentageController extends ThinkController
} else { } else {
$map['id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()];
$data = M("auth_group") $data = M("auth_group")
->where("title like '%市场%' and title != '市场总监'") ->where($map)
->select(false); ->select(false);
$data = M("auth_group_access") $data = M("auth_group_access")
@ -619,47 +636,30 @@ class MarketPercentageController extends ThinkController
public function marketStaffSettle($row = 10, $p = 1) public function marketStaffSettle($row = 10, $p = 1)
{ {
$map = []; $map = [
"_string"=>'1=1'
];
$map['group_id'] = ['in', '11,12,21,25'];
//获取权限 //获取权限
$marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage");
// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):'';
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
$_REQUEST['group_id'] ? ($map['level'] = $_REQUEST['group_id']) : ''; $_REQUEST['level'] ? ($map['level'] = $_REQUEST['level']) : '';
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; $admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['admin_id'] = $admin_id; $gid = session('user_group_id');
if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23 || session('user_group_id') == 25) { $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
unset($map['admin_id']); if($markerGroup){
if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
// $markerData = M("ucenter_member")->field("id")->where(['work_status' => 1])->select(); $map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])];
// }else{
// if ($markerData) { $map['admin_id'] = $admin_id ;
// $admin_map['sys_member.uid'] = ['not in', array_column($markerData, 'id')];
// }
$admin_data = M("member")
->field("access.uid admin_id")
->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id")
->where(['group_id' => ['in', '11,12,21,25']])
// ->where($admin_map)
->select();
if ($admin_data) {
$map['admin_id'] = ['in', array_column($admin_data, 'admin_id')];
} }
// if (!in_array($_REQUEST['admin_id'], array_column($markerData, 'id'))) {
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
// } else {
// $this->display("marketstaffsettle");
// die();
// }
} }
$_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : '';
$search_date = []; $search_date = [];
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
@ -815,15 +815,7 @@ class MarketPercentageController extends ThinkController
$data[$key]['start_time'] = date("Y-m-1", strtotime($value['pay_time'])); $data[$key]['start_time'] = date("Y-m-1", strtotime($value['pay_time']));
$data[$key]['end_time'] = date("Y-m-t", strtotime($value['pay_time'])); $data[$key]['end_time'] = date("Y-m-t", strtotime($value['pay_time']));
if ($value['level'] == 21) { $data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']);
$data[$key]['level'] = '初级';
} else if ($value['level'] == 11) {
$data[$key]['level'] = '中级';
} else if ($value['level'] == 12) {
$data[$key]['level'] = '高级';
}else if ($value['level'] == 25) {
$data[$key]['level'] = '经理';
}
if (!$value['market_check']) { if (!$value['market_check']) {
$data[$key]['market_check_detail'] = "-----"; $data[$key]['market_check_detail'] = "-----";
@ -1019,15 +1011,11 @@ class MarketPercentageController extends ThinkController
public function personMarketStaffSettle($row = 10, $p = 1) public function personMarketStaffSettle($row = 10, $p = 1)
{ {
// var_dump(getMarketAdmin()); $map = [
$map = []; "_string"=>'1=1'
];
$map['group_id'] = ['in', '11,12,21,25'];
//获取权限 //获取权限
$marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage");
// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):'';
// $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):'';
$_REQUEST['group_id'] ? ($map['group_id'] = $_REQUEST['group_id']) : ''; $_REQUEST['group_id'] ? ($map['group_id'] = $_REQUEST['group_id']) : '';
($_REQUEST['status'] || $_REQUEST['status'] == '0') ? ($map['tab_market_altogether.status'] = $_REQUEST['status']) : ''; ($_REQUEST['status'] || $_REQUEST['status'] == '0') ? ($map['tab_market_altogether.status'] = $_REQUEST['status']) : '';
@ -1040,22 +1028,17 @@ class MarketPercentageController extends ThinkController
} }
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; $admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['admin_id'] = $admin_id; $gid = session('user_group_id');
if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23 || session('user_group_id') == 25) { $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
unset($map['admin_id']); if($markerGroup){
if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
$admin_data = M("member") $map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])];
->field("access.uid admin_id") }else{
->join("left join sys_auth_group_access access on sys_member.uid = access.uid") $map['admin_id'] = $admin_id ;
->join("left join sys_auth_group auth on access.group_id=auth.id")
->where(['group_id' => ['in', '11,12,21,25']])
->select();
if ($admin_data) {
$map['admin_id'] = ['in', array_column($admin_data, 'admin_id')];
} }
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
} }
$_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : '';
$search_date = []; $search_date = [];
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
@ -1148,15 +1131,7 @@ class MarketPercentageController extends ThinkController
$market_percentage = json_decode($value['market_percentage'], true); $market_percentage = json_decode($value['market_percentage'], true);
if ($value['level'] == 21) { $data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']);
$data[$key]['level'] = '初级';
} else if ($value['level'] == 11) {
$data[$key]['level'] = '中级';
} else if ($value['level'] == 12) {
$data[$key]['level'] = '高级';
}else if ($value['level'] == 25) {
$data[$key]['level'] = '经理';
}
if ($value['status'] > 0) { if ($value['status'] > 0) {
$data[$key]['is_send'] = '已发放'; $data[$key]['is_send'] = '已发放';
@ -1262,13 +1237,14 @@ class MarketPercentageController extends ThinkController
public function sendBonus() public function sendBonus()
{ {
$groupIds = $this->MarketEvent->getMarketGroupId();
$map['pay_time'] = $_REQUEST['pay_time']; $map['pay_time'] = $_REQUEST['pay_time'];
$admin_data = M("member") $admin_data = M("member")
->field("access.uid admin_id") ->field("access.uid admin_id")
->join("left join sys_auth_group_access access on sys_member.uid = access.uid") ->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_auth_group auth on access.group_id=auth.id")
->where(['group_id' => ['in', '11,12,21']]) ->where(['group_id' => ['in', $groupIds]])
->select(); ->select();
if ($admin_data) { if ($admin_data) {
$map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')];
@ -1348,12 +1324,12 @@ class MarketPercentageController extends ThinkController
} }
$map = []; $map = [];
$groupIds = $this->MarketEvent->getMarketGroupId();
$admin_data = M("member") $admin_data = M("member")
->field("access.uid admin_id") ->field("access.uid admin_id")
->join("left join sys_auth_group_access access on sys_member.uid = access.uid") ->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_auth_group auth on access.group_id=auth.id")
->where(['group_id' => ['in', '11,12,21']]) ->where(['group_id' => ['in', $groupIds]])
->select(); ->select();
if ($admin_data) { if ($admin_data) {
$map['tab_market_altogether.admin_id'] = ['in', array_column($admin_data, 'admin_id')]; $map['tab_market_altogether.admin_id'] = ['in', array_column($admin_data, 'admin_id')];
@ -1424,7 +1400,6 @@ class MarketPercentageController extends ThinkController
$map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time']; $map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time'];
} }
} }
$data = SM("market_altogether", "tab_") $data = SM("market_altogether", "tab_")
->field("max(tab_market_altogether.pay_time) pay_time,tab_market_altogether.real_name,tab_market_altogether.admin_id,tab_market_altogether.nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, ->field("max(tab_market_altogether.pay_time) pay_time,tab_market_altogether.real_name,tab_market_altogether.admin_id,tab_market_altogether.nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission,
IF((work_status!=0 and ((leave_time-UNIX_TIMESTAMP(concat(tab_market_altogether.pay_time,'-01'))<86400*30) or UNIX_TIMESTAMP(concat(tab_market_altogether.pay_time,'-01'))>leave_time)),0,performance_commission) performance_commission, IF((work_status!=0 and ((leave_time-UNIX_TIMESTAMP(concat(tab_market_altogether.pay_time,'-01'))<86400*30) or UNIX_TIMESTAMP(concat(tab_market_altogether.pay_time,'-01'))>leave_time)),0,performance_commission) performance_commission,
@ -1468,13 +1443,7 @@ class MarketPercentageController extends ThinkController
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
// dump($value); // dump($value);
if ($value['level'] == 21) { $data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']);
$data[$key]['level'] = '初级';
} else if ($value['level'] == 11) {
$data[$key]['level'] = '中级';
} else if ($value['level'] == 12) {
$data[$key]['level'] = '高级';
}
//绩效系数计算 //绩效系数计算
// $data[$key]['achievement_bonus'] = $data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1); // $data[$key]['achievement_bonus'] = $data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1);

@ -246,7 +246,12 @@ class MarketPerformanceSetController extends Controller {
$userid = array_merge(array_keys($value),$userid); $userid = array_merge(array_keys($value),$userid);
} }
$userid = array_unique($userid); $userid = array_unique($userid);
$this->marketUserInfo = M("member")->where(["uid"=>['in',$userid]])->getField("uid,real_name",true); $this->marketUserInfo = M("auth_group_access")
->alias("acc")
->where(["acc.uid"=>['in',$userid]])
->join("sys_member as mem on acc.uid = mem.uid")
->join("sys_auth_group as gro on acc.group_id = gro.id")
->getField("acc.uid,mem.real_name,gro.department_id",true);
} }
/** /**
@ -468,7 +473,8 @@ class MarketPerformanceSetController extends Controller {
$baseArr = $this->companyInfo[$company_id]; $baseArr = $this->companyInfo[$company_id];
$baseArr['pay_time'] = $this->date; $baseArr['pay_time'] = $this->date;
$baseArr['is_settlement'] = 1; $baseArr['is_settlement'] = 1;
$baseArr['real_name'] = $this->marketUserInfo[$markertUserId]; $baseArr['real_name'] = $this->marketUserInfo[$markertUserId]['real_name'];
$baseArr['department_id'] = $this->marketUserInfo[$markertUserId]['department_id'];
$baseArr['admin_id'] = $markertUserId; $baseArr['admin_id'] = $markertUserId;
foreach ($games as $k => $v) { foreach ($games as $k => $v) {
$game = $this->gameInfo[$k]; $game = $this->gameInfo[$k];
@ -520,54 +526,51 @@ class MarketPerformanceSetController extends Controller {
public function marketManagerSet($count_date) public function marketManagerSet($count_date)
{ {
if(!$this->isInit) $this->configInit($count_date); if(!$this->isInit) $this->configInit($count_date);
//获取所有的经理
$marketManagerGroupId = "25"; $MarketEvent = A("Market","Event");
$this->marketAltogetherModel->where(['pay_time'=>$this->date,'level'=>$marketManagerGroupId])->delete(); $level = $MarketEvent->getConfig('ManagerLevel');
//获取毛利统计 $this->marketAltogetherModel->where(['pay_time'=>$this->date,'level'=>$level])->delete();
$dbres = $this->settleupMarketorderModel->where(['pay_time'=>$this->date])->field("sum(pay_amount) pay_amount,sum(refund_amount) refund_amount,develop_type")->group('develop_type')->select(); $markertManager = $MarketEvent->getManagerPerformanInfo();
$count = [ if(!$markertManager) return;
'pay_amount'=>0, foreach ($markertManager as $k => $manager) {
'performance_revenue'=>0, //获取毛利统计
'appraisal_bonuses'=>0 $dbres = $this->settleupMarketorderModel->where(['pay_time'=>$this->date,'department_id'=>$manager['department_id']])->field("sum(pay_amount) pay_amount,sum(refund_amount) refund_amount,develop_type")->group('develop_type')->select();
]; $count = [
foreach ($dbres as $k => $v) { 'pay_amount'=>0,
$tmpPayAmount = $v['pay_amount']-$v['refund_amount']; 'performance_revenue'=>0,
$count['pay_amount'] += $tmpPayAmount; 'appraisal_bonuses'=>0
if($v['develop_type'] == 3){ ];
$count['appraisal_bonuses'] += $tmpPayAmount; foreach ($dbres as $k => $v) {
}else{ $tmpPayAmount = $v['pay_amount']-$v['refund_amount'];
$count['performance_revenue'] += $tmpPayAmount; $count['pay_amount'] += $tmpPayAmount;
if($v['develop_type'] == 3){
$count['appraisal_bonuses'] += $tmpPayAmount;
}else{
$count['performance_revenue'] += $tmpPayAmount;
}
} }
} $config = json_decode($manager['market_percentage'],true);
//获取经理配置及经理 $achievement_bonus = round(($count['appraisal_bonuses']*$config['maintain_appraisal_bonuses_ratio'] + $count['performance_revenue']*$config['appraisal_bonuses_ratio'])/100,2);
$config = M("auth_group")->where("id = {$marketManagerGroupId}")->getField("market_percentage");
$config = json_decode($config,true);
$user = M("auth_group_access")->alias("access")->join("left join sys_member member on access.uid=member.uid")->where(['group_id'=>$marketManagerGroupId])->field("access.uid,real_name,nickname")->select();
if(!$user) return;
//获取经理抽成公式
$achievement_bonus = round(($count['appraisal_bonuses']*$config['maintain_appraisal_bonuses_ratio'] + $count['performance_revenue']*$config['appraisal_bonuses_ratio'])/100,2);
$baseData = [
'pay_time'=>$this->date,
'level'=>$marketManagerGroupId,
'pay_amount' => $count['pay_amount'],
'extend_commission'=> round($achievement_bonus*$config['month_bonus_ratio']/100,2),
'wait_commission' => round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2),
'create_time'=>time(),
'performance_revenue'=>$count['performance_revenue'],
'appraisal_bonuses'=>$count['appraisal_bonuses'],
'achievement_bonus'=>$achievement_bonus,
'wait_achievement_commission'=>round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2)
];
foreach ($user as $k=> $v) {
$baseData['real_name'] = $v['real_name'];
$baseData['nickname'] = $v['nickname'];
$baseData['admin_id'] = $v['uid'];
$baseData = [
'pay_time'=>$this->date,
'level'=>$level,
'pay_amount' => $count['pay_amount'],
'extend_commission'=> round($achievement_bonus*$config['month_bonus_ratio']/100,2),
'wait_commission' => round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2),
'create_time'=>time(),
'performance_revenue'=>$count['performance_revenue'],
'appraisal_bonuses'=>$count['appraisal_bonuses'],
'achievement_bonus'=>$achievement_bonus,
'wait_achievement_commission'=>round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2),
'real_name'=>$manager['real_name'],
'admin_id'=>$manager['uid'],
'nickname'=>$manager['nickname'],
'department_id'=>$manager['department_id']
];
$res = $this->marketAltogetherModel->add($baseData); $res = $this->marketAltogetherModel->add($baseData);
echo "marketManagerSet {$manager['real_name']}/{$res}".PHP_EOL;
echo "marketManagerSet {$v['real_name']}/{$res}".PHP_EOL;
} }
} }
/** /**
* 设置每月第一个周一自动重算 * 设置每月第一个周一自动重算

@ -9,6 +9,93 @@ namespace Admin\Controller;
*/ */
class OldCountController extends \Think\Controller class OldCountController extends \Think\Controller
{ {
/**
* 新增市场部其他用户组
*/
public function moreDepartment()
{
//1.新增组
$manager = M('auth_group','sys_')->where("title = '高级市场专员'")->find();
$dbres = M('auth_group','sys_')->where("title LIKE '%市场%' AND id != 18")->select();
foreach ($dbres as &$v) {
if($v['id'] == 25){
$v['rules'] = $manager['rules'];
$v['data_empower_type'] =3;
$v['show_data'] =1;
$v['show_market_admin'] =1;
$v['show_promote'] =1;
}
if(mb_strpos($v['title'],"初级")){
$v['department_level'] = 1;
}
if(mb_strpos($v['title'],"中级")){
$v['department_level'] = 2;
}
if(mb_strpos($v['title'],"高级")){
$v['department_level'] = 3;
}
if(mb_strpos($v['title'],"经理")){
$v['department_level'] = 4;
}
if(mb_strpos($v['title'],"总监")){
$v['department_level'] = 5;
}
$v['title'] = "一部".$v['title'];
$v['department_id'] = 1;
$v['department_name'] = "市场一部";
M('auth_group','sys_')->save($v);
unset($v['id']);
$v['title'] = str_replace("一部","二部",$v['title']);
$v['department_id'] = 2;
$v['department_name'] = '市场二部';
M('auth_group','sys_')->add($v);
}
//3.增加部门表数据
M("department")->add([
'id'=>1,
'name'=>'市场一部',
'group_ids'=>'11,12,14,21,25',
'leader_group'=>'14',
'create_time'=>time(),
'update_time'=>time()
]);
M("department")->add([
'id'=>2,
'name'=>'市场二部',
'group_ids'=>'26,27,28,29,30',
'leader_group'=>'28',
'create_time'=>time(),
'update_time'=>time()
]);
//4.修改旧等级
M("market_altogether","tab_")->where("level = 21")->save(['level'=>1]);
M("market_altogether","tab_")->where("level = 11")->save(['level'=>2]);
M("market_altogether","tab_")->where("level = 12")->save(['level'=>3]);
M("market_altogether","tab_")->where("level = 25")->save(['level'=>4]);
}
public function setDataPresidentInit()
{
$marketEvent = A("Market","Event");
//获取所有二部公司
$uids = $marketEvent->getDepartmentUserId(2);
$promoteids = M("Promote","tab_")->where(["admin_id"=>['in',$uids],"level"=>1])->getField("id",true);
$marketEvent->removePresident($promoteids);
$save = [
"id"=>28,
"data_president"=>implode(",",$promoteids)
];
M('auth_group','sys_')->save($save);
}
//删除吴宏还是高级时候的数据 //删除吴宏还是高级时候的数据
public function deleteWuhongAltogether() public function deleteWuhongAltogether()
{ {
@ -691,6 +778,17 @@ class OldCountController extends \Think\Controller
} }
return $time_arr; return $time_arr;
} }
public function eventTest($event,$action,$arg = false)
{
$Event = A($event,"Event");
if(!$arg){
$res = $Event->$action();
}else{
$res = call_user_func_array(array($Event, $action), explode(":",$arg));
}
dd($res);
}

@ -30,6 +30,11 @@ class PresidentDepositController extends ThinkController
$where['_string'] .= ' and company_belong=' . $companyType; $where['_string'] .= ' and company_belong=' . $companyType;
} }
$marketCompanyIds = A("Market","Event")->getAdminCompanyId();
if($marketCompanyIds != 'all'){
$where['_string'] .= ' and id in (' . $marketCompanyIds .')';
}
$depositWhere = []; $depositWhere = [];
$depositStrWhere = '1=1'; $depositStrWhere = '1=1';

@ -49,11 +49,13 @@ class PromoteCompanyController extends ThinkController
$company_name = trim(I('company_name')); $company_name = trim(I('company_name'));
//市场部权限begin //市场部权限begin
$pro_id = getMarketAuthPromoteId(); $pro_id = getPowerPromoteIds();
if($pro_id){ if($pro_id != 'all'){
$promotemap["_string"] .=" AND p.id in ({$pro_id})"; $promotemap["_string"] .=" AND p.id in ({$pro_id})";
$c_id = throwPromoteIdToCompanyId($pro_id); $c_id = A("Market",'Event')->getAdminCompanyId();
$map["_string"] .=" AND id in ({$c_id})"; if($c_id != 'all'){
$map["_string"] .=" AND id in ({$c_id})";
}
} }
//市场部权限end //市场部权限end
@ -1436,15 +1438,12 @@ class PromoteCompanyController extends ThinkController
M("Promote","tab_")->where("company_id = '{$company_id}'")->save($savedata); M("Promote","tab_")->where("company_id = '{$company_id}'")->save($savedata);
// 权限跟随 // 权限跟随
if($is_change_belong){ if($is_change_belong){
$authGroup = M('auth_group',"sys_")->where(['title'=>'市场总监'])->find();
$subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $company_id])->getField('id', true); $subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $company_id])->getField('id', true);
$dataPresident = explode(',', $authGroup['data_president']);
if ($save['company_belong'] == 1 || $save['company_belong'] == 2) { if ($save['company_belong'] == 1 || $save['company_belong'] == 2) {
$dataPresident = array_unique(array_merge($dataPresident, $subPromoteIds)); A("Market","Event")->pushPresident($subPromoteIds);
} else { } else {
$dataPresident = array_diff($dataPresident, $subPromoteIds); A("Market","Event")->removePresident($subPromoteIds);
} }
M('auth_group',"sys_")->where(['title'=>'市场总监'])->save(['data_president'=>implode(',', $dataPresident)]);
resetUserAuth(); resetUserAuth();
} }
} }

@ -14,6 +14,7 @@ class SocietyInfoController extends ThinkController
{ {
private $modelName = 'SocietyInfo'; private $modelName = 'SocietyInfo';
private $admininfo = ''; private $admininfo = '';
private $MarketEvent;
private $level = [ private $level = [
1=>'S', 1=>'S',
2=>'A', 2=>'A',
@ -24,6 +25,7 @@ class SocietyInfoController extends ThinkController
public function _initialize() public function _initialize()
{ {
$this->admininfo = $_SESSION['onethink_admin']['user_auth']; $this->admininfo = $_SESSION['onethink_admin']['user_auth'];
$this->MarketEvent = A("Market","Event");
parent::_initialize(); parent::_initialize();
} }
//列表 //列表
@ -32,11 +34,20 @@ class SocietyInfoController extends ThinkController
$model = M($this->modelName, 'tab_'); $model = M($this->modelName, 'tab_');
$map = []; $map = [];
if ($this->checkRule("Admin/SocietyInfo/lists", array('in','1,2')) || isMarketLeader() || is_administrator()) { if (is_administrator()) {
// 设置权限、admin、市场总监可以看所有数据 // 设置权限、admin、市场总监可以看所有数据
} else { } else {
// 其他用户只能看自己的 $gid = session('user_group_id');
$map['create_account'] = $this->admininfo['username']; $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){
//总监
$map['create_account'] = ["in",$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'],"nickname")];
}
}else{
// 其他用户只能看自己的
$map['create_account'] = $this->admininfo['username'];
}
} }
if ($_REQUEST['text']||$_REQUEST['text']=='0') { if ($_REQUEST['text']||$_REQUEST['text']=='0') {

@ -86,6 +86,18 @@ class SpendController extends ThinkController
unset($_REQUEST['merchant_id']); unset($_REQUEST['merchant_id']);
} }
if (isset($_REQUEST['promote_id'])) {
$promoteId = intval($_REQUEST['promote_id']);
if ($promoteId == 0) {
$map['promote_id'] = 0;
} else {
$promoteMap['chain'] = ['like', "%/$promoteId/%"];
$promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promoteId;
$map['promote_id'] = ['in', $promoteIds];
}
}
$marketAdminId = 0; $marketAdminId = 0;
$isMarketAdmin = isMarketAdmin(); $isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) { if ($isMarketAdmin) {
@ -96,21 +108,9 @@ class SpendController extends ThinkController
} }
if ($marketAdminId > 0) { if ($marketAdminId > 0) {
$map['market_admin_id'] = $marketAdminId; $map['market_admin_id'] = $marketAdminId;
} else {
setPowerPromoteIds($map,'promote_id');
} }
setPowerPromoteIds($map,'promote_id');
if (isset($_REQUEST['promote_id'])) {
$promoteId = intval($_REQUEST['promote_id']);
if ($promoteId == 0) {
$map['promote_id'] = 0;
} else {
$promoteMap['chain'] = ['like', "%/$promoteId/%"];
$promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promoteId;
$map['promote_id'] = ['in', $promoteIds];
}
}
if ($_REQUEST['data_order'] != '') { if ($_REQUEST['data_order'] != '') {
$data_order = reset(explode(',', $_REQUEST['data_order'])); $data_order = reset(explode(',', $_REQUEST['data_order']));
$data_order_type = end(explode(',', $_REQUEST['data_order'])); $data_order_type = end(explode(',', $_REQUEST['data_order']));

@ -853,11 +853,12 @@ class TimingController extends AdminController {
public function insertAllUserBonus($time) { public function insertAllUserBonus($time) {
// $time = $_REQUEST['time']; // $time = $_REQUEST['time'];
$groupIds = A("Market","Event")->getGeneralMarketGroup();
$data = M("member") $data = M("member")
->field("access.uid admin_id,real_name,nickname,group_id level") ->field("access.uid admin_id,real_name,nickname,auth.department_level level")
->join("left join sys_auth_group_access access on sys_member.uid = access.uid") ->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_auth_group auth on access.group_id=auth.id")
->where(['group_id'=>['in','11,12,21']]) ->where(['group_id'=>['in',$groupIds]])
->select(); ->select();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
@ -909,14 +910,14 @@ class TimingController extends AdminController {
} }
$map['is_settlement'] = 1; $map['is_settlement'] = 1;
$groupIds = A("Market","Event")->getGeneralMarketGroup();
//获取admin_id //获取admin_id
$accessData = M("auth_group_access") $accessData = M("auth_group_access")
->alias("access") ->alias("access")
->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_auth_group auth on access.group_id=auth.id")
->join("left join sys_member member on access.uid=member.uid") ->join("left join sys_member member on access.uid=member.uid")
->where(['group_id'=>['in','11,12,21']]) ->where(['group_id'=>['in',$groupIds]])
->getField("access.uid,group_id,market_percentage,nickname"); ->getField("access.uid,auth.department_level level,group_id,market_percentage,nickname");
$all_data = SM("settleup_marketorder","tab_") $all_data = SM("settleup_marketorder","tab_")
->field("id,admin_id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name, ->field("id,admin_id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name,
@ -1003,7 +1004,7 @@ class TimingController extends AdminController {
$insert['admin_id'] = $value['admin_id']; $insert['admin_id'] = $value['admin_id'];
$insert['nickname'] = $value['nickname']; $insert['nickname'] = $value['nickname'];
$insert['level'] = $value['group_id']; $insert['level'] = $value['level'];
$insert['pay_amount'] = $value['pay_amount']; $insert['pay_amount'] = $value['pay_amount'];
$insert['extend_commission'] = substr( $insert['extend_commission'] = substr(
number_format(($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100) number_format(($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)

@ -0,0 +1,236 @@
<?php
namespace Admin\Event;
use Think\Controller;
class MarketEvent extends Controller
{
private $MarketDepartmentId = "1,2";
private $ManagerLevel = "4";
private $DirectorLevel = "5";
private $LevelConfig = [
'1'=>'初级',
'2'=>'中级',
'3'=>'高级',
'4'=>'经理'
];
/**
* 获取所有市场部组id
*/
public function getMarketGroupId()
{
$res = M('department','sys_')->where("id in ({$this->MarketDepartmentId})")->getField("group_ids",true);
$sendData = '';
foreach ($res as $value) {
$sendData .= $value.",";
}
return rtrim($sendData,",");
}
/**
* 获取市场专员gid(除了总监)
*/
public function getNoLeaderMarketGroupId()
{
$where = [
"department_id"=>['in',$this->MarketDepartmentId],
"department_level"=>['neq',$this->DirectorLevel]
];
$dbres = M('auth_group','sys_')->where($where)->getField("id",true);
return implode(",",$dbres);
}
/**
* 获取普通的市场专员初中高的gid
*/
public function getGeneralMarketGroup()
{
$where = [
"department_id"=>['in',$this->MarketDepartmentId],
"department_level"=>['LT',4]
];
$dbres = M('auth_group','sys_')->where($where)->getField("id",true);
return implode(",",$dbres);
}
/**
* 获取经理信息
*/
public function getManagerPerformanInfo()
{
$where = [
"department_id"=>['in',$this->MarketDepartmentId],
"department_level"=>['eq',$this->ManagerLevel]
];
$dbres = M('auth_group','sys_')->where($where)->getField("id",true);
$market = M("auth_group_access")
->alias("acc")
->where(["acc.group_id"=>['in',$dbres]])
->join("sys_member as mem on acc.uid = mem.uid")
->join("sys_auth_group as gro on acc.group_id = gro.id")
->getField("acc.uid,mem.nickname,mem.real_name,gro.department_id,gro.market_percentage",true);
return $market;
}
/**
* 获取配置信息
* @param [string] $key
* @return void
*/
public function getConfig($key)
{
return $this->$key;
}
/**
* 获取等级名称
*/
public function getLevelName($level)
{
return $this->LevelConfig[$level];
}
public function isMarketAdminGroup($gid)
{
$where = [
"department_id"=>['in',$this->MarketDepartmentId],
"id"=>$gid
];
return M('auth_group','sys_')->field("id,department_id,department_level")->where($where)->find();
}
public function isDepartmentLeder($department_id,$uid)
{
$gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id');
return M('department','sys_')->where("id = '{$department_id}' and leader_group = '$gid'")->field("id")->find();
}
public function isMarketLeder($uid)
{
$gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id');
return M("auth_group")->where("id = '{$gid}' and department_level = '{$this->DirectorLevel}'")->field("id")->find();
}
/**
* 添加部门总监的会长权限
* $uid,$promote_id
*/
public function addPresident($uid,$promote_id)
{
$leader_group = M("auth_group_access")
->alias("acc")
->where(['acc.uid'=>$uid])
->join("sys_auth_group as gro on acc.group_id = gro.id")
->join("sys_department as dep on gro.department_id = dep.id")
->getField("dep.leader_group",1);
if(!$leader_group){
return true;
}
$info = M('auth_group','sys_')->where(['id'=>$leader_group])->find();
$dataPresident = explode(',', $info['data_president']);
$dataPresident = array_unique(array_merge($dataPresident, array($promote_id)));
return $this->saveLeaderPresident($leader_group,$dataPresident);;
}
/**
* 移除原有权限
* @param [array] $promoteIds
* @return void
*/
public function removePresident($promoteIds)
{
if(!is_array($promoteIds)){
$promoteIds = explode(",",$promoteIds);
};
$leaderPresident = $this->getLeaderPresident();
foreach ($leaderPresident as $k => $v) {
$dataPresident = explode(',', $v);
$dataPresident = array_diff($dataPresident, $promoteIds);
$this->saveLeaderPresident($k,$dataPresident);
}
}
/**
* 添加原有权限,设计重复问题
* @param [array] $promoteIds
* @return void
*/
public function pushPresident($promoteIds)
{
if(!is_array($promoteIds)){
$promoteIds = explode(",",$promoteIds);
};
foreach ($promoteIds as $k => $v) {
$admin_id = M("Promote","tab_")->where("id = {$v}")->getField("admin_id");
$this->addPresident($admin_id,$v);
}
return true;
}
private function getLeaderPresident()
{
$where = [
"department_id"=>['in',$this->MarketDepartmentId],
"department_level"=>['eq',$this->DirectorLevel]
];
return M('auth_group','sys_')->where($where)->getField("id,data_president",true);
}
private function saveLeaderPresident($gid,$data_president)
{
if(is_array($data_president)){
$data_president = implode(",",$data_president);
};
$savedata = [
"id"=>$gid,
"data_president"=>$data_president
];
return M('auth_group','sys_')->save($savedata);
}
public function getDepartmentUserId($department_id,$type = "uid")
{
$field = "mem.".$type;
$res = M("auth_group_access")
->alias("acc")
->field($field)
->where(['gro.department_id'=>$department_id])
->join("sys_member as mem on acc.uid = mem.uid")
->join("sys_auth_group as gro on acc.group_id = gro.id")
->select();
return array_column($res,$type);
}
public function getAdminCompanyId()
{
if (!empty(session('user_auth_company_ids'))) {
return session('user_auth_company_ids');
}
$userAuth = session('user_auth');
$companyIds = 'all';
$userAuth['data_president']= trim($userAuth['data_president'], ",");
if (!empty($userAuth['data_empower_type'])) {//数据权限 1 全部 2 部分数据 3 自己底下的会长
//等于1默认全部数据不进行筛选
if (in_array($userAuth['data_empower_type'], [2, 3])) {
$companyIds = '';
//自己创建的会长
$myPromote_ids = M('promote', 'tab_')
->field('GROUP_CONCAT(id) as promote_ids')
->where(['admin_id' => $userAuth['uid']])
->find();
$myPromote_ids = $myPromote_ids['promote_ids'];
if ($myPromote_ids) {
if ($userAuth['data_empower_type'] == 2) {//部分会长加上自己创建的会长
// $userAuth['data_president'] .= "," . $myPromote_ids;
} elseif ($userAuth['data_empower_type'] == 3) {//自己创建的会长和底下推广员
$userAuth['data_president'] = $myPromote_ids;
}
}
$dbres = M('promote', 'tab_')
->field('company_id')
->where(['id' =>['in',$userAuth['data_president']],'level'=>1])
->group('company_id')
->getField('company_id',true);
$companyIds = implode(",",$dbres);
}
}
session('user_auth_company_ids', $companyIds);
return $companyIds;
}
}

@ -22,6 +22,8 @@
<th class="">用户组</th> <th class="">用户组</th>
<th class="">详情</th> <th class="">详情</th>
<th class="">部门</th>
<th class="">授权</th> <th class="">授权</th>
<th class="">状态</th> <th class="">状态</th>
<th class="">操作</th> <th class="">操作</th>
@ -33,11 +35,7 @@
<tr> <tr>
<td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td> <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
<td> <td>
<if condition="IS_SUBSITE"> <a href="{:U('AuthManager/editgroup?id='.$vo['id'])}">{$vo.title}</a>
{$vo.title}
<else />
<a href="{:U('AuthManager/editgroup?id='.$vo['id'])}">{$vo.title}</a>
</if>
</td> </td>
<td> <td>
<span> <span>
@ -48,13 +46,17 @@
</empty> </empty>
</span> </span>
</td> </td>
<td>
{$vo.department_name}
</td>
<td> <td>
<a href="{:U('AuthManager/access?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >访问授权</a> <a href="{:U('AuthManager/access?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >访问授权</a>
<a href="{:U('AuthManager/user?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >成员授权</a> <a href="{:U('AuthManager/user?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >成员授权</a>
<if condition="!IS_SUBSITE"> <if condition="!IS_SUBSITE">
<a href="{:U('AuthManager/category?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >分类授权</a> <a href="{:U('AuthManager/category?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >分类授权</a>
<a href="{:U('AuthManager/dataempower?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >数据授权</a> <a href="{:U('AuthManager/dataempower?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >数据授权</a>
<if condition="$vo['id'] eq 11 or $vo['id'] eq 12 or $vo['id'] eq 21 or $vo['id'] eq 25"> <if condition="in_array($vo['id'],$market_group)">
<a href="{:U('AuthManager/AuthMarketMember?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >市场专员分成</a> <a href="{:U('AuthManager/AuthMarketMember?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >市场专员分成</a>
</if> </if>
</if> </if>

@ -109,16 +109,16 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="l"><i class="mustmark">*</i>原市场员:</td> <td class="l"><i class="mustmark">*</i>原市场员:</td>
<td class="r"> <td class="r">
<span id="from-market-name" class="form_radio table_btn" style="color: red;">--</span> <span id="from-market-name" class="form_radio table_btn" style="color: red;">--</span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="l"><i class="mustmark">*</i>新市场员:</td> <td class="l"><i class="mustmark">*</i>新市场员:</td>
<td class="r"> <td class="r">
<select name="to_id" id="market-select" class="select_gallery"> <select name="to_id" id="market-select" class="select_gallery">
<option value="">请选择新市场</option> <option value="">请选择新市场</option>
<?php foreach($marketAdmins as $admin):?> <?php foreach($marketAdmins as $admin):?>
<option value="<?=$admin['id']?>"><?=$admin['username']?></option> <option value="<?=$admin['id']?>"><?=$admin['username']?></option>
<?php endforeach;?> <?php endforeach;?>
@ -156,8 +156,8 @@
<th>推广公司</th> <th>推广公司</th>
<th>会长账号</th> <th>会长账号</th>
<th>内外团</th> <th>内外团</th>
<th>原市场</th> <th>原市场</th>
<th>新市场</th> <th>新市场</th>
<th>订单切分时间</th> <th>订单切分时间</th>
<th>备注</th> <th>备注</th>
<th>操作</th> <th>操作</th>
@ -278,7 +278,7 @@ $(function(){
return layer.msg('请选择会长') return layer.msg('请选择会长')
} }
if (marketId == '') { if (marketId == '') {
return layer.msg('请新市场员') return layer.msg('请新市场员')
} }
if (promoteIds.includes(promoteId)) { if (promoteIds.includes(promoteId)) {
return layer.msg('该会长已添加') return layer.msg('该会长已添加')

@ -150,12 +150,11 @@
</select> </select>
</div> </div>
<div class="input-list input-list-game search_label_rehab"> <div class="input-list input-list-game search_label_rehab">
<select id="group_id" name="group_id" class="select_gallery" style="width:120px;"> <select id="level" name="level" class="select_gallery" style="width:120px;">
<option value="" selected="">请选择级别</option> <option value="" selected="">请选择级别</option>
<option value="21" <if condition="$_GET['group_id'] eq 1">selected</if>>初级</option> <volist name=":getMarketLevel()" id="vo">
<option value="11" <if condition="$_GET['group_id'] eq 2">selected</if>>中级</option> <option value="{$i}" <if condition="$i eq $_GET['level']">selected=selected</if>>{$vo}</option>
<option value="12" <if condition="$_GET['group_id'] eq 2">selected</if>>高级</option> </volist>
<option value="25" <if condition="$_GET['group_id'] eq 2">selected</if>>经理</option>
</select> </select>
</div> </div>
<input type="hidden" name="" value="" class="sortBy"> <input type="hidden" name="" value="" class="sortBy">

@ -88,9 +88,9 @@
<div class="input-list input-list-game search_label_rehab"> <div class="input-list input-list-game search_label_rehab">
<select id="level" name="level" class="select_gallery" style="width:120px;"> <select id="level" name="level" class="select_gallery" style="width:120px;">
<option value="" selected="">请选择级别</option> <option value="" selected="">请选择级别</option>
<option value="21" <if condition="$_GET['level'] eq 1">selected</if>>初级</option> <volist name=":getMarketLevel()" id="vo">
<option value="11" <if condition="$_GET['level'] eq 2">selected</if>>中级</option> <option value="{$i}" <if condition="$i eq $_GET['level']">selected=selected</if>>{$vo}</option>
<option value="12" <if condition="$_GET['level'] eq 2">selected</if>>高级</option> </volist>
</select> </select>
</div> </div>
<input type="hidden" name="" value="" class="sortBy"> <input type="hidden" name="" value="" class="sortBy">

@ -43,12 +43,10 @@ class MarketService
M('promote', 'tab_')->where($map)->save(['admin_id' => $toId]); M('promote', 'tab_')->where($map)->save(['admin_id' => $toId]);
M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->save(['admin_id' => $toId]); M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->save(['admin_id' => $toId]);
$authGroup = M('auth_group', 'sys_')->where(['title'=>'市场总监'])->find(); $marketEvent = A("Market","Event");
$dataPresident = explode(',', $authGroup['data_president']); $marketEvent->removePresident($promote['id']);
if (!in_array($promote['id'], $dataPresident)) { $marketEvent->addPresident($toId,$promote['id']);
M('auth_group', 'sys_')->where(['title'=>'市场总监'])->save(['data_president' => $authGroup['data_president'] . ',' . $promote['id']]); resetUserAuth();
resetUserAuth();
}
} }
public function shiftSpend($promoteIds, $fromId, $toId, $time = null) public function shiftSpend($promoteIds, $fromId, $toId, $time = null)

@ -272,15 +272,13 @@ class PromoteCompanyService
// 权限跟随 // 权限跟随
if($isChangeBelong){ if($isChangeBelong){
$authGroup = M('auth_group', 'sys_')->where(['title'=>'市场总监'])->find();
$subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $companyId])->getField('id', true); $subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $companyId])->getField('id', true);
$dataPresident = explode(',', $authGroup['data_president']);
if ($companyInfo['company_belong'] == 1 || $companyInfo['company_belong'] == 2) { if ($companyInfo['company_belong'] == 1 || $companyInfo['company_belong'] == 2) {
$dataPresident = array_unique(array_merge($dataPresident, $subPromoteIds)); A("Market","Event")->pushPresident($subPromoteIds);
} else { } else {
$dataPresident = array_diff($dataPresident, $subPromoteIds); A("Market","Event")->removePresident($subPromoteIds);
} }
M('auth_group', 'sys_')->where(['title' => '市场总监'])->save(['data_president' => implode(',', $dataPresident)]);
resetUserAuth(); resetUserAuth();
} }
} }

@ -1123,8 +1123,7 @@ class PromoteService {
// 如果是外团的,则自动加入市场总监审核列表 // 如果是外团的,则自动加入市场总监审核列表
if ($data['level'] == 1 && in_array($data['company_belong'], [1, 2])) { if ($data['level'] == 1 && in_array($data['company_belong'], [1, 2])) {
$id = M('promote', 'tab_')->getLastInsID(); $id = M('promote', 'tab_')->getLastInsID();
$info = M('sys_auth_group')->where(['title'=>'市场总监'])->find(); A('Market','Event')->addPresident($data['admin_id'],$id);
M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>$info['data_president'].",".$id]);
resetUserAuth(); resetUserAuth();
} }

Loading…
Cancel
Save