master
ELF 5 years ago
parent 77c692c44d
commit 8224cfb362

@ -2532,6 +2532,17 @@ function getAdminUsernameList(array $ids)
return $items;
}
function isMarketLeader()
{
$authGroup = M('sys_auth_group')->where(['title'=>'市场总监'])->find();
if (!$authGroup) {
return false;
}
$userAuth = session('user_auth');
$adminIds = M('auth_group_access', 'sys_')->where(['group_id' => $authGroup['id']])->getField('uid', true);
return in_array($userAuth['uid'], $adminIds);
}
function isMarketAdmin()
{
$ids = getMarketGroupIds();

@ -91,6 +91,10 @@ class FinancePromoteController extends AdminController
$gfidlag =false;
}
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$nwtflag = false;
}
// dd($gfidlag && $gfgs && $nwtflag);
if($gfidlag && $gfgs && $nwtflag){
//计算官方渠道
@ -228,7 +232,11 @@ class FinancePromoteController extends AdminController
}
if (isset($_REQUEST['company_belong'])) {
$map['promote.company_belong'] = $_REQUEST['company_belong'];
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0];
}
if (!empty(I('develop_type'))) {
@ -455,12 +463,31 @@ class FinancePromoteController extends AdminController
$map['promote.company_id'] = $_REQUEST['company_id'];
}
if ($type == "spend") {
$adminId = 0;
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
$map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
}
if($istimeselect){
$map['s.pay_time']=$istimeselect;
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['s.market_admin_id'] = ['gt', 0];
$map['promote.admin_id'] = ['gt', 0];
}
if ($adminId) {
$map['s.market_admin_id'] = $adminId;
}
$map['s.pay_status']=1;
// dd($map);
$field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
@ -475,17 +502,6 @@ class FinancePromoteController extends AdminController
->join("tab_promote_company company ON promote.company_id = company.id", "left")
->group('promote_id');
$adminId = 0;
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
$havingPids = [];
if ($adminId > 0) {
$topIds = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
@ -500,14 +516,7 @@ class FinancePromoteController extends AdminController
}
$map['s.status']=1;
$map['s.source_id']=0;
$field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,IFNULL(promote.company_belong,0) company_belong";
$query = M("promote_coin s","tab_")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id", "left")
->group('promote_id');
$adminId = 0;
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
@ -518,6 +527,19 @@ class FinancePromoteController extends AdminController
$adminId = I('admin_id');
}
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0];
}
$field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,IFNULL(promote.company_belong,0) company_belong";
$query = M("promote_coin s","tab_")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id", "left")
->group('promote_id');
$havingPids = [];
if ($adminId > 0) {
@ -554,6 +576,10 @@ class FinancePromoteController extends AdminController
if (!empty(I('develop_type'))) {
$map['develop_type'] = I('develop_type');
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0];
}
//获取推广员
$title = '';
@ -681,6 +707,11 @@ class FinancePromoteController extends AdminController
}
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['market_admin_id'] = ['gt', 0];
}
if ($adminId > 0) {
$map['market_admin_id'] = $adminId;
}

@ -345,7 +345,6 @@ class PromoteCompanyController extends ThinkController
$authGroup = M('sys_auth_group')->where(['title'=>'市场总监'])->find();
$subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $company_id])->getField('id', true);
$dataPresident = explode(',', $authGroup['data_president']);
M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>$info['data_president'].",".$id]);
if ($save['company_belong'] == 1 || $save['company_belong'] == 2) {
$dataPresident = array_unique(array_merge($dataPresident, $subPromoteIds));
} else {

@ -30,17 +30,24 @@ class MarketService
$promoteIds = [$promote['id']];
$promoteIds = array_merge(array_column($promotes, 'id'), $promoteIds);
$this->shiftPromote($promoteId, $fromId, $toId);
$this->shiftPromote($promote, $fromId, $toId);
$this->shiftSpend($promoteIds, $fromId, $toId, $time);
$this->shiftDeposit($promoteIds, $fromId, $toId, $time);
}
public function shiftPromote($promoteId, $fromId, $toId, $time = null)
public function shiftPromote($promote, $fromId, $toId, $time = null)
{
$map = [];
$map['id'] = $promoteId;
$map['id'] = $promote['id'];
$map['admin_id'] = $fromId;
M('promote', 'tab_')->where($map)->save(['admin_id' => $toId]);
M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->save(['admin_id' => $promote['admin_id']]);
$authGroup = M('sys_auth_group')->where(['title'=>'市场总监'])->find();
$dataPresident = explode(',', $authGroup['data_president']);
if (!in_array($promote['id'], $dataPresident)) {
M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president' => $authGroup['data_president'] . ',' . $promote['id']]);
}
}
public function shiftSpend($promoteIds, $fromId, $toId, $time = null)

Loading…
Cancel
Save