|
|
|
@ -81,7 +81,7 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
} else if ($value['company_belong'] == 1) {
|
|
|
|
|
$data[$key]['company_belong'] = '外团';
|
|
|
|
|
} else if ($value['company_belong'] == 2) {
|
|
|
|
|
$data[$key]['company_belong'] = '分发联盟';
|
|
|
|
|
$data[$key]['company_belong'] = '外团-分发联盟';
|
|
|
|
|
} else {
|
|
|
|
|
$data[$key]['company_belong'] = '无';
|
|
|
|
|
}
|
|
|
|
@ -146,6 +146,50 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
->select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$all_data = M("settleup_marketorder","tab_")
|
|
|
|
|
->field("pay_time,promote_account,company_belong,member.real_name,develop_type,game_name,
|
|
|
|
|
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,admin_id,
|
|
|
|
|
sum(if((develop_type = 1 or develop_type = 2), pay_amount, 0)) performance_revenue,sum(if(develop_type = 3, pay_amount, 0)) appraisal_bonuses")
|
|
|
|
|
->join("left join sys_auth_group_access access on admin_id=access.uid")
|
|
|
|
|
->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
->join("left join sys_member member on access.uid=member.uid")
|
|
|
|
|
->where(['group_id'=>['in','11,12,21']])
|
|
|
|
|
->group("admin_id,pay_time")
|
|
|
|
|
->order("pay_time DESC")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$wait_amount = [];
|
|
|
|
|
foreach ($all_data as $key => $value) {
|
|
|
|
|
|
|
|
|
|
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
|
|
|
|
|
|
|
|
|
|
$market_percentage = json_decode($value['market_percentage'],true);
|
|
|
|
|
//业绩提成
|
|
|
|
|
$all_data[$key]['performance_commission'] =
|
|
|
|
|
number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) +
|
|
|
|
|
$value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', '');
|
|
|
|
|
|
|
|
|
|
$sum_amount <$market_percentage['performance_revenue'] ? ($all_data[$key]['performance_commission'] = 0):"";
|
|
|
|
|
//绩效考核奖金
|
|
|
|
|
$all_data[$key]['achievement_bonus'] =
|
|
|
|
|
number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) +
|
|
|
|
|
$value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', '');
|
|
|
|
|
$sum_amount <$market_percentage['appraisal_bonuses'] ? ($all_data[$key]['achievement_bonus'] = 0):"";
|
|
|
|
|
//总提成
|
|
|
|
|
$all_data[$key]['commission'] = number_format($all_data[$key]['performance_commission']+$all_data[$key]['achievement_bonus'], 2, '.', '');
|
|
|
|
|
//应发金额
|
|
|
|
|
$all_data[$key]['extend_commission'] =
|
|
|
|
|
substr(number_format($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
//待发金额
|
|
|
|
|
$all_data[$key]['wait_commission'] = substr(number_format($all_data[$key]['commission'] - ( $all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100) ), 4, '.', ''),0,-2);
|
|
|
|
|
$wait_amount[$value['admin_id'].$value['pay_time']] = $all_data[$key]['wait_commission'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$all_data = [];
|
|
|
|
|
|
|
|
|
|
$count = M("settleup_marketorder","tab_")
|
|
|
|
|
->field("pay_time,promote_account,company_belong,real_name,develop_type,game_name,
|
|
|
|
|
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage")
|
|
|
|
@ -162,8 +206,6 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
|
|
|
|
$wait_amount = [];
|
|
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
|
|
if ($value['group_id'] == 21) {
|
|
|
|
@ -197,8 +239,8 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
$data[$key]['commission'] = number_format($data[$key]['performance_commission']+$data[$key]['achievement_bonus'], 2, '.', '');
|
|
|
|
|
//应发金额
|
|
|
|
|
$data[$key]['extend_commission'] =
|
|
|
|
|
number_format($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 2, '.', '');
|
|
|
|
|
substr(number_format($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$month = date("m",strtotime($value['pay_time']));
|
|
|
|
@ -222,29 +264,31 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
$wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
}
|
|
|
|
|
} elseif($market_percentage['time'] == 3) {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'01'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'02'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'03'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].($yes-1).'-'.'04'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'05'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'06'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
if ($month == '01') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'] +
|
|
|
|
|
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'] +
|
|
|
|
|
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'] +
|
|
|
|
|
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[date("Y-m",strtotime("last month",strtotime($value['pay_time'])))];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//待发金额
|
|
|
|
|
$data[$key]['wait_commission'] = number_format($data[$key]['commission'] - $data[$key]['extend_commission'], 2, '.', '');
|
|
|
|
|
$wait_amount[$value['admin_id'].$value['pay_time']] = $data[$key]['wait_commission'];
|
|
|
|
|
$data[$key]['wait_commission'] = substr(number_format($data[$key]['commission'] - ( $data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100) ), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
if ($market_percentage['remain_time'] == 1) {
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
$data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
} elseif($month == '10') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'];
|
|
|
|
|
$data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'];
|
|
|
|
|
} elseif($month == '04') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'];
|
|
|
|
|
$data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'];
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
$data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
}
|
|
|
|
|
} elseif($market_percentage['remain_time'] == 2) {
|
|
|
|
|
// } elseif($market_percentage['remain_time'] == 2) {
|
|
|
|
|
// if ($month == '07') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
@ -252,7 +296,7 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
// }
|
|
|
|
|
} elseif($market_percentage['remain_time'] == 3) {
|
|
|
|
|
// } elseif($market_percentage['remain_time'] == 3) {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'01'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'02'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'03'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'].($yes-1).'-'.'04'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'05'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'06'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
|
|
|
|
@ -262,6 +306,9 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dump($market_percentage);
|
|
|
|
|
// dump($wait_amount);die();
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['export']) {
|
|
|
|
|
|
|
|
|
|
$title = ['pay_time' => '时间',
|
|
|
|
@ -321,6 +368,51 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
->select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $all_data = M("settleup_marketorder","tab_")
|
|
|
|
|
// ->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,member.real_name,develop_type,game_name,
|
|
|
|
|
// sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id,
|
|
|
|
|
// sum(if((develop_type = 1 or develop_type = 2), pay_amount, 0)) performance_revenue,sum(if(develop_type = 3, pay_amount, 0)) appraisal_bonuses")
|
|
|
|
|
// ->join("left join sys_auth_group_access access on admin_id=access.uid")
|
|
|
|
|
// ->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
// ->join("left join sys_member member on access.uid=member.uid")
|
|
|
|
|
// ->where(['group_id'=>['in','11,12,21']])
|
|
|
|
|
// ->group("admin_id,pay_time")
|
|
|
|
|
// ->select();
|
|
|
|
|
//
|
|
|
|
|
// $wait_amount = [];
|
|
|
|
|
// foreach ($all_data as $key => $value) {
|
|
|
|
|
//
|
|
|
|
|
// $sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
|
|
|
|
|
//
|
|
|
|
|
// $market_percentage = json_decode($value['market_percentage'],true);
|
|
|
|
|
// //业绩提成
|
|
|
|
|
// $all_data[$key]['performance_commission'] =
|
|
|
|
|
// number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) +
|
|
|
|
|
// $value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', '');
|
|
|
|
|
//
|
|
|
|
|
// $sum_amount <$market_percentage['performance_revenue'] ? ($all_data[$key]['performance_commission'] = 0):"";
|
|
|
|
|
// //绩效考核奖金
|
|
|
|
|
// $all_data[$key]['achievement_bonus'] =
|
|
|
|
|
// number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) +
|
|
|
|
|
// $value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', '');
|
|
|
|
|
// $sum_amount <$market_percentage['appraisal_bonuses'] ? ($all_data[$key]['achievement_bonus'] = 0):"";
|
|
|
|
|
// //总提成
|
|
|
|
|
// $all_data[$key]['commission'] = number_format($all_data[$key]['performance_commission']+$all_data[$key]['achievement_bonus'], 2, '.', '');
|
|
|
|
|
// //应发金额
|
|
|
|
|
// $all_data[$key]['extend_commission'] =
|
|
|
|
|
// number_format($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
// $all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 2, '.', '');
|
|
|
|
|
//
|
|
|
|
|
// //待发金额
|
|
|
|
|
// $all_data[$key]['wait_commission'] = number_format($all_data[$key]['commission'] - ( $all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
// $all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100) ), 2, '.', '');
|
|
|
|
|
// $wait_amount[$value['admin_id'].$value['pay_time']] = $all_data[$key]['wait_commission'];
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// dump($data);die();
|
|
|
|
|
$all_data = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$count = M("settleup_marketorder","tab_")
|
|
|
|
|
->field("pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name,
|
|
|
|
|
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname")
|
|
|
|
@ -338,8 +430,6 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
|
|
|
|
// dump($data);die();
|
|
|
|
|
|
|
|
|
|
$sum['performance_commission'] = 0;
|
|
|
|
|
$sum['achievement_bonus'] = 0;
|
|
|
|
|
|
|
|
|
@ -364,8 +454,7 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
$data[$key]['is_send'] = is_sendBonus($value['pay_time'],$value['admin_id']);
|
|
|
|
|
|
|
|
|
|
$market_percentage = json_decode($value['market_percentage'],true);
|
|
|
|
|
// $data[$key]['performance_revenue'] = number_format($market_percentage['performance_revenue'], 2, '.', '');
|
|
|
|
|
// $data[$key]['appraisal_bonuses'] = number_format($market_percentage['appraisal_bonuses'], 2, '.', '');
|
|
|
|
|
|
|
|
|
|
//业绩提成
|
|
|
|
|
$data[$key]['performance_commission'] =
|
|
|
|
|
number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) +
|
|
|
|
@ -383,16 +472,86 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
$sum['commission'] += $data[$key]['commission'];
|
|
|
|
|
//应发金额
|
|
|
|
|
$data[$key]['extend_commission'] =
|
|
|
|
|
number_format($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 2, '.', '');
|
|
|
|
|
substr(number_format($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 4, '.', ''),0,-2);
|
|
|
|
|
$sum['extend_commission'] += $data[$key]['extend_commission'];
|
|
|
|
|
|
|
|
|
|
$month = date("m",strtotime($value['pay_time']));
|
|
|
|
|
$yes = date("Y",strtotime($value['pay_time']));
|
|
|
|
|
|
|
|
|
|
if ($market_percentage['time'] == 1) {
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'];
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
} elseif($month == '10') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
} elseif($month == '04') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'];
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
}
|
|
|
|
|
} elseif($market_percentage['time'] == 2) {
|
|
|
|
|
// dump($wait_amount);die();
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
}
|
|
|
|
|
} elseif($market_percentage['time'] == 3) {
|
|
|
|
|
if ($month == '01') {
|
|
|
|
|
// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'] +
|
|
|
|
|
// $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'];
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$data[$key]['is_send_use'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//待发金额
|
|
|
|
|
$data[$key]['wait_commission'] = number_format($data[$key]['commission'] - $data[$key]['extend_commission'], 2, '.', '');
|
|
|
|
|
$data[$key]['wait_commission'] = substr(number_format($data[$key]['commission'] - ($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100)), 4, '.', ''),0,-2);
|
|
|
|
|
$sum['wait_commission'] += $data[$key]['wait_commission'];
|
|
|
|
|
|
|
|
|
|
// $wait_amount[$value['admin_id'].$value['pay_time']] = $data[$key]['wait_commission'];
|
|
|
|
|
|
|
|
|
|
// if ($market_percentage['remain_time'] == 1) {
|
|
|
|
|
// if ($month == '07') {
|
|
|
|
|
// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
// } elseif($month == '10') {
|
|
|
|
|
// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'];
|
|
|
|
|
// } elseif($month == '04') {
|
|
|
|
|
// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'];
|
|
|
|
|
// } elseif($month == '01') {
|
|
|
|
|
// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
// }
|
|
|
|
|
//// } elseif($market_percentage['remain_time'] == 2) {
|
|
|
|
|
//// if ($month == '07') {
|
|
|
|
|
//// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'] +
|
|
|
|
|
//// $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
//// } elseif($month == '01') {
|
|
|
|
|
//// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
|
|
|
|
|
//// $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
//// }
|
|
|
|
|
//// } elseif($market_percentage['remain_time'] == 3) {
|
|
|
|
|
//// $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'01'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'02'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'03'] +
|
|
|
|
|
//// $wait_amount[$value['admin_id'].($yes-1).'-'.'04'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'05'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'06'] +
|
|
|
|
|
//// $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
|
|
|
|
|
//// $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
// }
|
|
|
|
|
// $sum['wait_commission'] += $data[$key]['wait_commission'];
|
|
|
|
|
|
|
|
|
|
$sum['company_profit'] += $value['company_profit'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dump($data);die();
|
|
|
|
|
$this->assign("sum",$sum);
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['export']) {
|
|
|
|
@ -433,9 +592,57 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'数据错误']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$group_config = M("auth_group_access access")
|
|
|
|
|
->field("market_percentage")
|
|
|
|
|
->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
->where(['uid'=>$_REQUEST['admin_id']])
|
|
|
|
|
->find();
|
|
|
|
|
$group_config = json_decode($group_config['market_percentage'],true);
|
|
|
|
|
$month = date("m",strtotime($_REQUEST['pay_time']));
|
|
|
|
|
$yes = date("Y",strtotime($_REQUEST['pay_time']));
|
|
|
|
|
if ($group_config['time'] == 1) {
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
$where = [$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03'];
|
|
|
|
|
if ($_REQUEST['all']) {
|
|
|
|
|
$where = array_merge($where,[$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06']);
|
|
|
|
|
}
|
|
|
|
|
} elseif($month == '10') {
|
|
|
|
|
$where = [$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06'];
|
|
|
|
|
if ($_REQUEST['all']) {
|
|
|
|
|
$where = array_merge($where,[$yes.'-'.'07',$yes.'-'.'08',$yes.'-'.'09']);
|
|
|
|
|
}
|
|
|
|
|
} elseif($month == '04') {
|
|
|
|
|
$where = [($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12'];
|
|
|
|
|
if ($_REQUEST['all']) {
|
|
|
|
|
$where = array_merge($where,[$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03']);
|
|
|
|
|
}
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
$where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09'];
|
|
|
|
|
if ($_REQUEST['all']) {
|
|
|
|
|
$where = array_merge($where,[$yes.'-'.'10',$yes.'-'.'11',$yes.'-'.'12']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} elseif($group_config['time'] == 2) {
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
$where = [$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03',$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06'];
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
$where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09',($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12'];
|
|
|
|
|
}
|
|
|
|
|
} elseif($group_config['time'] == 3) {
|
|
|
|
|
if ($month == '01') {
|
|
|
|
|
$where = [($yes-1).'-'.'01',($yes-1).'-'.'02',($yes-1).'-'.'03',($yes-1).'-'.'04',($yes-1).'-'.'05',($yes-1).'-'.'06',
|
|
|
|
|
($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09',($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$where = array_merge($where,[$_REQUEST['pay_time']]);
|
|
|
|
|
$map['pay_time'] = ['in',$where];
|
|
|
|
|
|
|
|
|
|
$data = M("settleup_marketorder","tab_")
|
|
|
|
|
->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name,
|
|
|
|
|
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id")
|
|
|
|
|
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id,
|
|
|
|
|
sum(if((develop_type = 1 or develop_type = 2), pay_amount, 0)) performance_revenue,sum(if(develop_type = 3, pay_amount, 0)) appraisal_bonuses")
|
|
|
|
|
->join("left join sys_auth_group_access access on admin_id=access.uid")
|
|
|
|
|
->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
->join("left join sys_member member on access.uid=member.uid")
|
|
|
|
@ -443,6 +650,47 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
->group("admin_id,pay_time")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$all_data = M("settleup_marketorder","tab_")
|
|
|
|
|
->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,member.real_name,develop_type,game_name,
|
|
|
|
|
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id,
|
|
|
|
|
sum(if((develop_type = 1 or develop_type = 2), pay_amount, 0)) performance_revenue,sum(if(develop_type = 3, pay_amount, 0)) appraisal_bonuses")
|
|
|
|
|
->join("left join sys_auth_group_access access on admin_id=access.uid")
|
|
|
|
|
->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
->join("left join sys_member member on access.uid=member.uid")
|
|
|
|
|
->where(['group_id'=>['in','11,12,21']])
|
|
|
|
|
->group("admin_id,pay_time")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$wait_amount = [];
|
|
|
|
|
foreach ($all_data as $key => $value) {
|
|
|
|
|
|
|
|
|
|
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
|
|
|
|
|
|
|
|
|
|
$market_percentage = json_decode($value['market_percentage'],true);
|
|
|
|
|
//业绩提成
|
|
|
|
|
$all_data[$key]['performance_commission'] =
|
|
|
|
|
number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) +
|
|
|
|
|
$value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', '');
|
|
|
|
|
|
|
|
|
|
$sum_amount <$market_percentage['performance_revenue'] ? ($all_data[$key]['performance_commission'] = 0):"";
|
|
|
|
|
//绩效考核奖金
|
|
|
|
|
$all_data[$key]['achievement_bonus'] =
|
|
|
|
|
number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) +
|
|
|
|
|
$value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', '');
|
|
|
|
|
$sum_amount <$market_percentage['appraisal_bonuses'] ? ($all_data[$key]['achievement_bonus'] = 0):"";
|
|
|
|
|
//总提成
|
|
|
|
|
$all_data[$key]['commission'] = number_format($all_data[$key]['performance_commission']+$all_data[$key]['achievement_bonus'], 2, '.', '');
|
|
|
|
|
//应发金额
|
|
|
|
|
$all_data[$key]['extend_commission'] =
|
|
|
|
|
substr(number_format($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
//待发金额
|
|
|
|
|
$all_data[$key]['wait_commission'] = substr(number_format($all_data[$key]['commission'] - ( $all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100) ), 4, '.', ''),0,-2);
|
|
|
|
|
$wait_amount[$value['admin_id'].$value['pay_time']] = $all_data[$key]['wait_commission'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
|
@ -453,54 +701,124 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
} else if ($value['group_id'] == 12) {
|
|
|
|
|
$data[$key]['level'] = '高级';
|
|
|
|
|
}
|
|
|
|
|
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
|
|
|
|
|
|
|
|
|
|
$market_percentage = json_decode($value['market_percentage'],true);
|
|
|
|
|
$data[$key]['performance_revenue'] = number_format($market_percentage['performance_revenue'], 2, '.', '');
|
|
|
|
|
$data[$key]['appraisal_bonuses'] = number_format($market_percentage['appraisal_bonuses'], 2, '.', '');
|
|
|
|
|
// $data[$key]['performance_revenue'] = number_format($market_percentage['performance_revenue'], 2, '.', '');
|
|
|
|
|
// $data[$key]['appraisal_bonuses'] = number_format($market_percentage['appraisal_bonuses'], 2, '.', '');
|
|
|
|
|
//业绩提成
|
|
|
|
|
$data[$key]['performance_commission'] =
|
|
|
|
|
number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) +
|
|
|
|
|
$value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', '');
|
|
|
|
|
$sum_amount <$market_percentage['performance_revenue'] ? ($data[$key]['performance_commission'] = 0):"";
|
|
|
|
|
//绩效考核奖金
|
|
|
|
|
$data[$key]['achievement_bonus'] =
|
|
|
|
|
number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) +
|
|
|
|
|
$value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', '');
|
|
|
|
|
$sum_amount <$market_percentage['appraisal_bonuses'] ? ($data[$key]['achievement_bonus'] = 0):"";
|
|
|
|
|
//总提成
|
|
|
|
|
$data[$key]['commission'] = number_format($data[$key]['performance_commission']+$data[$key]['achievement_bonus'], 2, '.', '');
|
|
|
|
|
//应发金额
|
|
|
|
|
$data[$key]['extend_commission'] =
|
|
|
|
|
number_format($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['performance_commission'] * ($market_percentage['month_bonus_ratio']/100), 2, '.', '');
|
|
|
|
|
substr(number_format($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
//待发金额
|
|
|
|
|
$data[$key]['wait_commission'] = number_format($data[$key]['commission'] - $data[$key]['extend_commission'], 2, '.', '');
|
|
|
|
|
}
|
|
|
|
|
$data[$key]['wait_commission'] = substr(number_format($data[$key]['commission'] - ($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100)), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
$insert['pay_time'] = $data[0]['pay_time'];
|
|
|
|
|
$insert['admin_id'] = $data[0]['admin_id'];
|
|
|
|
|
$insert['real_name'] = $data[0]['real_name'];
|
|
|
|
|
$insert['nickname'] = $data[0]['nickname'];
|
|
|
|
|
$insert['level'] = $data[0]['level'];
|
|
|
|
|
$insert['pay_amount'] = $data[0]['pay_amount'];
|
|
|
|
|
$insert['extend_commission'] = $data[0]['extend_commission'];
|
|
|
|
|
$insert['wait_commission'] = $data[0]['wait_commission'];
|
|
|
|
|
$insert['remark'] = "{$data[0]['nickname']}发起提成发放";
|
|
|
|
|
$insert['create_time'] = time();
|
|
|
|
|
|
|
|
|
|
$is_hav = M("market_altogether","tab_")
|
|
|
|
|
->where(['pay_time'=>$data[0]['pay_time'],'admin_id'=>$data[0]['admin_id']])
|
|
|
|
|
->find();
|
|
|
|
|
if ($is_hav) {
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'msg'=>'已经发放过']);
|
|
|
|
|
}
|
|
|
|
|
$month = date("m",strtotime($value['pay_time']));
|
|
|
|
|
$yes = date("Y",strtotime($value['pay_time']));
|
|
|
|
|
|
|
|
|
|
$is_add = M("market_altogether","tab_")->add($insert);
|
|
|
|
|
if ($market_percentage['time'] == 1) {
|
|
|
|
|
//跨级发放验证当前发放月份
|
|
|
|
|
$check_month = date("m",strtotime($_REQUEST['pay_time']));
|
|
|
|
|
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'];
|
|
|
|
|
if ($_REQUEST['all']&&$check_month==$month) {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'] + $data[$key]['wait_commission'];
|
|
|
|
|
}
|
|
|
|
|
} elseif($month == '10') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
if ($_REQUEST['all']&&$check_month==$month) {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].$yes.'-'.'08'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'] + $data[$key]['wait_commission'];
|
|
|
|
|
}
|
|
|
|
|
} elseif($month == '04') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
if ($_REQUEST['all']&&$check_month==$month) {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'] + $data[$key]['wait_commission'];
|
|
|
|
|
}
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'];
|
|
|
|
|
if ($_REQUEST['all']&&$check_month==$month) {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'] + $data[$key]['wait_commission'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} elseif($market_percentage['time'] == 2) {
|
|
|
|
|
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
|
|
|
|
|
$wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
|
|
|
|
|
}
|
|
|
|
|
} elseif($market_percentage['time'] == 3) {
|
|
|
|
|
if ($month == '01') {
|
|
|
|
|
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'] +
|
|
|
|
|
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'] +
|
|
|
|
|
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'] +
|
|
|
|
|
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// else {
|
|
|
|
|
// $data[$key]['is_send_use'] = 1;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$insert['pay_time'] = $data[$key]['pay_time'];
|
|
|
|
|
$insert['admin_id'] = $data[$key]['admin_id'];
|
|
|
|
|
$insert['real_name'] = $data[$key]['real_name'];
|
|
|
|
|
$insert['nickname'] = $data[$key]['nickname'];
|
|
|
|
|
$insert['level'] = $data[$key]['level'];
|
|
|
|
|
$insert['pay_amount'] = $data[$key]['pay_amount'];
|
|
|
|
|
$insert['extend_commission'] = $data[$key]['extend_commission'];
|
|
|
|
|
$insert['wait_commission'] = $data[$key]['wait_commission'];
|
|
|
|
|
$insert['remark'] = "{$data[$key]['nickname']}发起提成发放";
|
|
|
|
|
if ($_REQUEST['all']) {
|
|
|
|
|
$insert['remark'] = '离职发放';
|
|
|
|
|
$insert['type'] = 1;
|
|
|
|
|
}
|
|
|
|
|
$insert['create_time'] = time();
|
|
|
|
|
|
|
|
|
|
$is_hav = M("market_altogether","tab_")
|
|
|
|
|
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
|
|
|
|
|
->find();
|
|
|
|
|
if ($is_hav) {
|
|
|
|
|
// $this->ajaxReturn(['status'=>1,'msg'=>'已经发放过']);
|
|
|
|
|
$is_add = M("market_altogether","tab_")
|
|
|
|
|
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
|
|
|
|
|
->save($insert);
|
|
|
|
|
} else {
|
|
|
|
|
$is_add = M("market_altogether","tab_")->add($insert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $is_add = M("market_altogether","tab_")->add($insert);
|
|
|
|
|
|
|
|
|
|
if (!$is_add) {
|
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'发放失败']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($is_add) {
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'msg'=>'发放成功']);
|
|
|
|
|
} else {
|
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'发放失败']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'msg'=>'发放成功']);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function reCaculateBonus() {
|
|
|
|
@ -508,8 +826,8 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
$pay_time = $_REQUEST['pay_time'];
|
|
|
|
|
|
|
|
|
|
if (!$pay_time) {
|
|
|
|
|
// $pay_time = "all";
|
|
|
|
|
$pay_time = date("Y-m",strtotime('-1 month'));
|
|
|
|
|
$pay_time = "all";
|
|
|
|
|
// $pay_time = date("Y-m",strtotime('-1 month'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exec("php cli.php timing/caculateMarketStream/time/{$pay_time} > /dev/null &");
|
|
|
|
@ -519,6 +837,7 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
|
|
|
|
|
public function showBonusList($row = 10, $p = 1) {
|
|
|
|
|
|
|
|
|
|
// echo date("Y-m",strtotime("last month",strtotime("2020-07")));die();
|
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
|
|
$_REQUEST['pay_time']?$map['pay_time'] = $_REQUEST['pay_time']:'';
|
|
|
|
@ -527,7 +846,8 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
$_REQUEST['level']?$map['level'] = $_REQUEST['level']:'';
|
|
|
|
|
|
|
|
|
|
$data = M("market_altogether","tab_")
|
|
|
|
|
->field("real_name,admin_id,nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, sum(wait_commission) wait_commission,remark")
|
|
|
|
|
->field("max(pay_time) pay_time,real_name,admin_id,nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, sum(wait_commission) wait_commission,remark,group_id,max(type) type")
|
|
|
|
|
->join("left join sys_auth_group_access access on admin_id=access.uid")
|
|
|
|
|
->where($map);
|
|
|
|
|
if ($_REQUEST['export']) {
|
|
|
|
|
$data = $data
|
|
|
|
@ -536,10 +856,117 @@ class MarketPercentageController extends ThinkController
|
|
|
|
|
->select();
|
|
|
|
|
} else {
|
|
|
|
|
$data = $data->page($p, $row)
|
|
|
|
|
->order("pay_time DESC")
|
|
|
|
|
->order("id DESC")
|
|
|
|
|
->group("admin_id")
|
|
|
|
|
->select();
|
|
|
|
|
}
|
|
|
|
|
// dump($data);die();
|
|
|
|
|
foreach($data as $key => $value) {
|
|
|
|
|
|
|
|
|
|
if ($value['group_id'] == 21) {
|
|
|
|
|
$data[$key]['level'] = '初级';
|
|
|
|
|
} else if ($value['group_id'] == 11) {
|
|
|
|
|
$data[$key]['level'] = '中级';
|
|
|
|
|
} else if ($value['group_id'] == 12) {
|
|
|
|
|
$data[$key]['level'] = '高级';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$group_config = M("auth_group_access access")
|
|
|
|
|
->field("market_percentage")
|
|
|
|
|
->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
->where(['uid'=>$value['admin_id']])
|
|
|
|
|
->find();
|
|
|
|
|
$group_config = json_decode($group_config['market_percentage'],true);
|
|
|
|
|
$month = date("m",strtotime($value['pay_time']));
|
|
|
|
|
$yes = date("Y",strtotime($value['pay_time']));
|
|
|
|
|
|
|
|
|
|
$where = [$value['pay_time']];
|
|
|
|
|
if ($group_config['time'] == 1) {
|
|
|
|
|
//到季发放剩余金额条件
|
|
|
|
|
if ($month == '07') {
|
|
|
|
|
$where = [$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06'];
|
|
|
|
|
} elseif($month == '10') {
|
|
|
|
|
$where = [$yes.'-'.'07',$yes.'-'.'08',$yes.'-'.'09'];
|
|
|
|
|
} elseif($month == '04') {
|
|
|
|
|
$where = [$yes.'-'.'01',$yes.'-'.'11',$yes.'-'.'12'];
|
|
|
|
|
} elseif($month == '01') {
|
|
|
|
|
$where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09'];
|
|
|
|
|
}
|
|
|
|
|
//未到季发放剩余金额条件
|
|
|
|
|
if ($month == '02') {
|
|
|
|
|
$where = [$yes.'-'.'01'];
|
|
|
|
|
} elseif($month == '03') {
|
|
|
|
|
$where = [$yes.'-'.'01',$yes.'-'.'02'];
|
|
|
|
|
} elseif($month == '05') {
|
|
|
|
|
$where = [$yes.'-'.'04'];
|
|
|
|
|
} elseif($month == '06') {
|
|
|
|
|
$where = [$yes.'-'.'04',$yes.'-'.'05'];
|
|
|
|
|
} elseif($month == '08') {
|
|
|
|
|
$where = [$yes.'-'.'07'];
|
|
|
|
|
} elseif($month == '09') {
|
|
|
|
|
$where = [$yes.'-'.'07',$yes.'-'.'08'];
|
|
|
|
|
} elseif($month == '11') {
|
|
|
|
|
$where = [$yes.'-'.'10'];
|
|
|
|
|
} elseif($month == '12') {
|
|
|
|
|
$where = [$yes.'-'.'10',$yes.'-'.'11'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$where = array_merge($where,[$value['pay_time']]);
|
|
|
|
|
}
|
|
|
|
|
// var_dump($where);die();
|
|
|
|
|
$surplus_data = M("settleup_marketorder","tab_")
|
|
|
|
|
->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name,
|
|
|
|
|
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id,
|
|
|
|
|
sum(if((develop_type = 1 or develop_type = 2), pay_amount, 0)) performance_revenue,sum(if(develop_type = 3, pay_amount, 0)) appraisal_bonuses")
|
|
|
|
|
->join("left join sys_auth_group_access access on admin_id=access.uid")
|
|
|
|
|
->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
->join("left join sys_member member on access.uid=member.uid")
|
|
|
|
|
->where(['pay_time'=>['in',$where],'admin_id'=>$value['admin_id']])
|
|
|
|
|
->group("admin_id,pay_time")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
// $paytime = $value['pay_time'];
|
|
|
|
|
|
|
|
|
|
// $surplus_data = M()->table("({$surplus_data}) a")
|
|
|
|
|
// ->field("a.*")
|
|
|
|
|
// ->join("left join tab_market_altogether market on a.admin_id=market.admin_id and a.pay_time=market.pay_time")
|
|
|
|
|
// ->where("(market.admin_id is null) or (a.pay_time = '{$paytime}')")
|
|
|
|
|
// ->select();
|
|
|
|
|
|
|
|
|
|
$data[$key]['wait_commission'] = 0;
|
|
|
|
|
foreach($surplus_data as $k => $v) {
|
|
|
|
|
$sum_amount = $v['performance_revenue'] + $v['appraisal_bonuses'];
|
|
|
|
|
|
|
|
|
|
$market_percentage = json_decode($v['market_percentage'],true);
|
|
|
|
|
//业绩提成
|
|
|
|
|
$surplus_data[$k]['performance_commission'] =
|
|
|
|
|
number_format($v['company_profit']*($market_percentage['develop_commission_ratio']/100) +
|
|
|
|
|
$v['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', '');
|
|
|
|
|
$sum_amount <$market_percentage['performance_revenue'] ? ($surplus_data[$k]['performance_commission'] = 0):"";
|
|
|
|
|
//绩效考核奖金
|
|
|
|
|
$surplus_data[$k]['achievement_bonus'] =
|
|
|
|
|
number_format($v['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) +
|
|
|
|
|
$v['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', '');
|
|
|
|
|
$sum_amount <$market_percentage['appraisal_bonuses'] ? ($surplus_data[$k]['achievement_bonus'] = 0):"";
|
|
|
|
|
//总提成
|
|
|
|
|
$surplus_data[$k]['commission'] = number_format($surplus_data[$k]['performance_commission']+$surplus_data[$k]['achievement_bonus'], 2, '.', '');
|
|
|
|
|
//应发金额
|
|
|
|
|
$surplus_data[$k]['extend_commission'] =
|
|
|
|
|
substr(number_format($surplus_data[$k]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$surplus_data[$k]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
//待发金额
|
|
|
|
|
$surplus_data[$k]['wait_commission'] = substr(number_format($surplus_data[$k]['commission'] - ($surplus_data[$k]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+
|
|
|
|
|
$surplus_data[$k]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100)), 4, '.', ''),0,-2);
|
|
|
|
|
|
|
|
|
|
$data[$key]['wait_commission'] = $data[$key]['wait_commission'] + $surplus_data[$k]['wait_commission'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($data[$key]['type'] == 1) {
|
|
|
|
|
$data[$key]['wait_commission'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['export']) {
|
|
|
|
|
|
|
|
|
|