master
ELF 3 years ago
parent 4c4a2c0b22
commit 1912e2b203

@ -2885,6 +2885,23 @@ function getAdminUsernameList(array $ids)
return $items;
}
function getAdminDepartmentList(array $ids)
{
if (count($ids) == 0) {
return [];
}
$rows = M('auth_group_access', 'sys_')->field(['uid', 'group_id'])->where(['uid' => ['in', $ids]])->select();
$groups = M('auth_group', 'sys_')->field(['id', 'department_id', 'department_name'])->where(['uid' => ['in', array_column($rows, 'group_id')]])->select();
$groups = index_by_column('id', $groups);
$items = [];
foreach ($rows as $row) {
$group = $groups[$row['group_id']] ?? null;
$items[$row['uid']] = $group ? $group['department_name'] : '--';
}
return $items;
}
function isMarketLeader()
{
if(IS_SUBSITE){
@ -2919,9 +2936,9 @@ function isMarketAdmin()
* 获取市场专员
*
*/
function getMarketAdmin() {
$map['group_id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()];
function getMarketAdmin($departmentId = null) {
$map = [];
$map['group_id'] = ['in',A("Market","Event")->getNoLeaderMarketGroupId($departmentId)];
$data = M("auth_group_access")
->field("real_name,menber.uid,nickname")

@ -664,4 +664,11 @@ class AjaxController extends ThinkController{
$promotes = M('promote', 'tab_')->where($companyMap)->field(['id', 'account'])->select();
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['promotes' => $promotes]]);
}
public function getAdminsByDepartment()
{
$departmentId = I('department_id', 0);
$admins = getMarketAdmin($departmentId);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['admins' => $admins]]);
}
}

@ -142,7 +142,9 @@ class FinancePromoteController extends AdminController
}
}
$promotes = index_by_column('id', $promotes);
$adminUsernames = getAdminUsernameList(array_column($promotes, 'admin_id'));
$adminIds = array_column($promotes, 'admin_id');
$adminUsernames = getAdminUsernameList($adminIds);
$adminDepartments = getAdminDepartmentList($adminIds);
foreach($senddata as $k=>$v){
$promote = $promotes[$v['p_id']] ?? null;
$v['company_belong'] = $v['company_belong'] ?:0;
@ -156,6 +158,7 @@ class FinancePromoteController extends AdminController
$v['promote_account'] = get_promote_name($v['p_id']);
($v['promote_account']=='官方渠道')?($v['promote_account']=C('OFFICIEL_CHANNEL')):'';
$v['admin_username'] = $adminUsernames[$promote['admin_id']] ?? '无';
$v['admin_department'] = $adminDepartments[$promote['admin_id']] ?? '无';
$v['develop_type_text'] = getCompanyDevelopTypeText($v['develop_type']);
$v['inside_cash_count'] = number_format($v['inside_cash_count'],2,'.','');
$v['allcount'] = number_format($v['cash_count']-0+$v['balance_coin_count']+$v['bind_coin_count'],2,'.','');
@ -179,6 +182,7 @@ class FinancePromoteController extends AdminController
"company_name"=>"推广公司",
"promote_account"=>"会长渠道",
"admin_username"=>"所属市场专员",
"admin_department"=>"所属市场部",
"company_belong"=>"团体类型",
"develop_type_text"=>"开发类型",
"cash_count"=>"游戏现金金额",
@ -219,6 +223,9 @@ class FinancePromoteController extends AdminController
$this->checkListOrCountAuthRestMap($map,[]);
$departments = M('department', 'sys_')->select();
$this->assign('departments', $departments);
//外团占比
$this->assign('outBelong',number_format($outBelong/$count['all_count']*100,2,'.',''));
//内团占比
@ -264,21 +271,22 @@ class FinancePromoteController extends AdminController
$map['company.develop_type'] = ['in',I('develop_type')];
}
$adminId = 0;
$adminIds = null;
// $havingPids = [];
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
$adminIds = [$userAuth['uid']];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
$adminIds = [I('admin_id')];
}
}
/* if ($adminId > 0) {
$havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
$havingPids = count($havingPids) > 0 ? $havingPids : [0];
} */
if (is_null($adminIds) && isset($_REQUEST['department_id'])) {
$admins = getMarketAdmin($_REQUEST['department_id']);
$adminIds = count($admins) ? array_column($admins, 'uid') : [-1];
}
if($type == "spend"){
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
@ -290,8 +298,8 @@ class FinancePromoteController extends AdminController
if ($isMarketLeader) {
$map['s.market_admin_id'] = ['gt', 0];
}
if ($adminId > 0) {
$map['s.market_admin_id'] = $adminId;
if (is_array($adminIds)) {
$map['s.market_admin_id'] = ['in', $adminIds];
}
$map['s.pay_status']=1;
$map['s.is_check']=2;
@ -349,21 +357,22 @@ class FinancePromoteController extends AdminController
$map['company.develop_type'] = ['in',I('develop_type')];
}
$adminId = 0;
$adminIds = null;
// $havingPids = [];
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
$adminIds = [$userAuth['uid']];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
$adminIds = [I('admin_id')];
}
}
/* if ($adminId > 0) {
$havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
$havingPids = count($havingPids) > 0 ? $havingPids : [0];
} */
if (is_null($adminIds) && isset($_REQUEST['department_id'])) {
$admins = getMarketAdmin($_REQUEST['department_id']);
$adminIds = count($admins) ? array_column($admins, 'uid') : [-1];
}
if($type == "spend"){
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
@ -375,8 +384,8 @@ class FinancePromoteController extends AdminController
if ($isMarketLeader) {
$map['s.market_admin_id'] = ['gt', 0];
}
if ($adminId > 0) {
$map['s.market_admin_id'] = $adminId;
if (is_array($adminIds)) {
$map['s.market_admin_id'] = ['in', $adminIds];
}
$map['s.pay_status']=1;
// $map['s.is_check']=1;
@ -400,20 +409,9 @@ class FinancePromoteController extends AdminController
if($istimeselect){
$map['s.create_time']=$istimeselect;
}
$adminId = 0;
// $havingPids = [];
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
if ($adminId > 0) {
$map['promote.admin_id'] = $adminId;
// $havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
if (is_array($adminIds)) {
$map['promote.admin_id'] = ['in', $adminIds];
// $havingPids = M('promote', 'tab_')->where(['admin_id' => ['in', $adminIds]])->getField('id', true);
// $havingPids = count($havingPids) > 0 ? $havingPids : [0];
}
$map['s.status']=1;

@ -30,11 +30,12 @@ class MarketEvent extends Controller
/**
* 获取市场专员gid(除了总监)
*/
public function getNoLeaderMarketGroupId()
public function getNoLeaderMarketGroupId($departmentId = null)
{
$departmentIds = $departmentId ? [$departmentId] : $this->MarketDepartmentId;
$where = [
"department_id"=>['in',$this->MarketDepartmentId],
"department_level"=>['neq',$this->DirectorLevel]
"department_id"=>['in', $departmentIds],
"department_level"=>['neq', $this->DirectorLevel]
];
$dbres = M('auth_group','sys_')->where($where)->getField("id",true);
return implode(",",$dbres);

@ -137,6 +137,15 @@
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="department_id" name="department_id" class="select_gallery" style="width:120px;">
<option value="">请选择市场部</option>
<?php foreach($departments as $department):?>
<option value="<?=$department['id']?>" <?php if($department['id'] == I('department_id')):?>selected<?php endif;?>><?=$department['name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="admin_id" name="admin_id" class="select_gallery" style="width:120px;">
<option value="">请选择市场专员</option>
@ -202,6 +211,7 @@
<th>推广公司</th>
<th>会长渠道</th>
<th>当前所属市场专员</th>
<th>所属市场部</th>
<th>内外团</th>
<th>开发类型</th>
<th class="tooltip"><a class="paixu" data-order='cash_count'>
@ -256,6 +266,7 @@
<td>{$data.company_name}</td>
<td>{$data['promote_account']}</td>
<td>{$data['admin_username']}</td>
<td>{$data['admin_department']}</td>
<td>{$data['company_belong']}</td>
<td>{$data['develop_type_text']}</td>
<td>{$data.cash_count}</td>
@ -303,7 +314,7 @@
</volist>
</empty>
<tr class="data_summary" style="text-align: center;">
<td colspan="5" style="text-align: center;">汇总:</td>
<td colspan="6" style="text-align: center;">汇总:</td>
<td style="text-align: center;">{$all_count['cash_count']}</td>
<td style="text-align: center;">{$all_count['balance_coin_count']}</td>
<td style="text-align: center;">{$all_count['bind_coin_count']}</td>
@ -521,6 +532,39 @@
$("#company_id").change(function(){
getPromotersByCompanyid();
})
var adminId = "{:I('admin_id')}";
var departmentId = "{:I('department_id')}";
function getAdminsByDepartmentId() {
var departmentId = $("#department_id option:selected").val();
if(!departmentId){
departmentId = -1;
}
$.ajax({
url: "{:U('Ajax/getAdminsByDepartment')}",
type: "get",
data: { department_id: departmentId},
dataType: 'json',
success: function (response) {
str = '<option value="">请选择市场专员</option>';
admins = response.data.admins;
for (var i in admins) {
str += "<option value='" + admins[i].uid + "' " + (adminId && admins[i].uid == adminId ? 'selected' : '') + ">" + admins[i].nickname + "</option>"
}
$("#admin_id").empty();
$("#admin_id").append(str);
$("#admin_id").select2();
}
})
}
getAdminsByDepartmentId();
$("#admin_id").change(function(){
adminId = $("#admin_id option:selected").val();
})
$("#department_id").change(function(){
getAdminsByDepartmentId();
})
})

Loading…
Cancel
Save