@ -17,6 +17,7 @@ class MarketPercentageController extends ThinkController
private $leavePercentage;
private $unSettlementList;
private $marketPercentage;
private $MarketEvent;
private $returnMarketPercentageArray = [];
private $returnWaitMarketPercentageArray = [];
@ -39,14 +40,19 @@ class MarketPercentageController extends ThinkController
//不结算列表
$this->leavePercentage->unSettlementList();
$this->unSettlementList = $this->leavePercentage->returnUnSettlementList();
$this->MarketEvent = A("Market","Event");
parent::_initialize();
}
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['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['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : '';
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['admin_id'] = $admin_id;
$map['is_settlement'] = 1;
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']);
$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']) : '';
}
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
$map['department_id'] =["in",[0,$markerGroup['department_id']]];
if( !$this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
$map['admin_id'] = $admin_id ;
}
}
// dd($map);
// $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) {
// unset($map['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 = [];
if (isset($_REQUEST['time_start']) & & isset($_REQUEST['time_end'])) {
@ -589,9 +606,9 @@ class MarketPercentageController extends ThinkController
} else {
$map['id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()];
$data = M("auth_group")
->where("title like '%市场%' and title != '市场总监'" )
->where($map )
->select(false);
$data = M("auth_group_access")
@ -619,47 +636,30 @@ class MarketPercentageController extends ThinkController
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");
// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):'';
$_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'];
$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 || session('user_group_id') == 25) {
unset($map['admin_id']);
// $markerData = M("ucenter_member")->field("id")->where(['work_status' => 1])->select();
//
// if ($markerData) {
// $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')];
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
$map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])];
}else{
$map['admin_id'] = $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 = [];
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]['end_time'] = date("Y-m-t", strtotime($value['pay_time']));
if ($value['level'] == 21) {
$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'] = '经理';
}
$data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']);
if (!$value['market_check']) {
$data[$key]['market_check_detail'] = "-----";
@ -1019,15 +1011,11 @@ class MarketPercentageController extends ThinkController
public function personMarketStaffSettle($row = 10, $p = 1)
{
// var_dump(getMarketAdmin());
$map = [];
$map['group_id'] = ['in', '11,12,21,25'];
$map = [
"_string"=>'1=1'
];
//获取权限
$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['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'];
$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 || session('user_group_id') == 25) {
unset($map['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')];
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
$map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])];
}else{
$map['admin_id'] = $admin_id ;
}
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
}
$_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : '';
$search_date = [];
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);
if ($value['level'] == 21) {
$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'] = '经理';
}
$data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']);
if ($value['status'] > 0) {
$data[$key]['is_send'] = '已发放';
@ -1262,13 +1237,14 @@ class MarketPercentageController extends ThinkController
public function sendBonus()
{
$groupIds = $this->MarketEvent->getMarketGroupId();
$map['pay_time'] = $_REQUEST['pay_time'];
$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' ]])
->where(['group_id' => ['in', $groupIds ]])
->select();
if ($admin_data) {
$map['admin_id'] = ['in', array_column($admin_data, 'admin_id')];
@ -1348,12 +1324,12 @@ class MarketPercentageController extends ThinkController
}
$map = [];
$groupIds = $this->MarketEvent->getMarketGroupId();
$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' ]])
->where(['group_id' => ['in', $groupIds ]])
->select();
if ($admin_data) {
$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'];
}
}
$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,
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) {
// dump($value);
if ($value['level'] == 21) {
$data[$key]['level'] = '初级';
} else if ($value['level'] == 11) {
$data[$key]['level'] = '中级';
} else if ($value['level'] == 12) {
$data[$key]['level'] = '高级';
}
$data[$key]['level'] = $this->MarketEvent->getLevelName($value['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);