@ -951,266 +951,290 @@ class TimingController extends AdminController {
$map['pay_time'] = date("Y-m",strtotime('-1 month'));
if ($_REQUEST['pay_time']) {
$map['pay_time'] = $_REQUEST['pay_time'];
}
//所有管理员插入数据
$this->insertAllUserBonus($map['pay_time']);
$month = date("m",strtotime($_REQUEST['pay_time']));
$yes = date("Y",strtotime($_REQUEST['pay_time']));
if ($_REQUEST['pay_time'] == 'all') {
$end = date("Y-m",time());
$start = '2019-08';
} elseif($_REQUEST['pay_time']) {
$end = $_REQUEST['pay_time'];
$start = $_REQUEST['pay_time'];
} else {
$end = date("Y-m",strtotime('-1 month'));
$start = date("Y-m",strtotime('-1 month'));
}
$i = 0;
do {
$date = date('Y-m', strtotime($start . ' + ' . $i . ' month'));
echo "{$date}:";
$i++;
$map['pay_time'] = $date;
$all_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,
//所有管理员插入数据
$this->insertAllUserBonus($map['pay_time']);
$month = date("m",strtotime($date));
$yes = date("Y",strtotime($date));
$all_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(['group_id'=>['in','11,12,21']])
->group("admin_id,pay_time")
->select();
->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'];
$check_month = date("m",strtotime($value['pay_time']));
$check_yes = date("Y",strtotime($value['pay_time']));
if ($market_percentage['time'] == 1) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '10'& & ($check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '04'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09')& & $check_yes==($yes-1)) {
$where['season'][] = $value['pay_time'];
}
$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'];
$check_month = date("m",strtotime($value['pay_time']));
$check_yes = date("Y",strtotime($value['pay_time']));
if ($market_percentage['time'] == 1) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '10'& & ($check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '04'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09')& & $check_yes==($yes-1)) {
$where['season'][] = $value['pay_time'];
}
} elseif($market_percentage['time'] == 2) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['half_year'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09'||$check_month=='10'||$check_month=='11'||$check_month=='12')& & $check_yes==($yes-1)) {
$where['half_year'][] = $value['pay_time'];
}
} elseif($market_percentage['time'] == 3) {
if ($month == '01'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')& & $check_yes==($yes-1)) {
$where['year'][] = $value['pay_time'];
}
} else {
if ($check_month==($month-1)) {
$where['month'][] = $value['pay_time'];
} elseif($market_percentage['time'] == 2) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['half_year'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09'||$check_month=='10'||$check_month=='11'||$check_month=='12')& & $check_yes==($yes-1)) {
$where['half_year'][] = $value['pay_time'];
}
} elseif($market_percentage['time'] == 3) {
if ($month == '01'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')& & $check_yes==($yes-1)) {
$where['year'][] = $value['pay_time'];
}
} else {
if ($check_month==($month-1)) {
$where['month'][] = $value['pay_time'];
}
}
}
}
// dump($wait_amount);die();
$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,
$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($map)
->group("admin_id,pay_time")
->select();
->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($map)
->group("admin_id,pay_time")
->select();
foreach ($data as $key => $value) {
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'] = '高级';
}
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
$market_percentage = json_decode($value['market_percentage'],true);
//业绩提成
$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'] =
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'] = 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);
$month = date("m",strtotime($value['pay_time']));
$yes = date("Y",strtotime($value['pay_time']));
$check_month = date("m",strtotime($_REQUEST['pay_time'] ));
$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]['group_id'];
$insert['pay_amount'] = $data[$key]['pay_amount'];
$insert['extend_commission'] = $data[$key]['extend_commission'];
if ($month != $check_month) {
$insert['pay_amount'] = 2;
}
$insert['wait_commission'] = $data[$key]['wait_commission'];
$insert['remark'] = "月初自动发放";
$insert['create_time'] = time();
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'] = '高级';
}
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
$market_percentage = json_decode($value['market_percentage'],true);
//业绩提成
$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'] =
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'] = 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);
$month = date("m",strtotime($value['pay_time']));
$yes = date("Y",strtotime($value['pay_time']));
$check_month = date("m",strtotime($date ));
$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]['group_id'];
$insert['pay_amount'] = $data[$key]['pay_amount'];
$insert['extend_commission'] = $data[$key]['extend_commission'];
if ($month != $check_month) {
$insert['pay_amount'] = 2;
}
$insert['wait_commission'] = $data[$key]['wait_commission'];
$insert['remark'] = "月初自动发放";
$insert['create_time'] = time();
echo "{$data[$key]['level']}市场专员:{$insert['real_name']}发放应发奖金及绩效:{$insert['extend_commission']}\n";
echo "{$data[$key]['level']}市场专员:{$insert['real_name']}发放应发奖金及绩效:{$insert['extend_commission']}\n";
$is_hav = M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->find();
if (!$is_hav) {
M("market_altogether","tab_")->add($insert);
} else {
M("market_altogether","tab_")
$is_hav = M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->save($insert);
->find();
if (!$is_hav) {
M("market_altogether","tab_")->add($insert);
} else {
M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->save($insert);
}
}
}
//遍历统计数据
$data = M("market_altogether","tab_")
->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'=>$map['pay_time']])
->select();
//遍历统计数据
$data = M("market_altogether","tab_")
->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'=>$map['pay_time']])
->select();
foreach($data as $key => $value) {
foreach($data as $key => $value) {
$market_percentage = json_decode($value['market_percentage'],true);
if ($market_percentage['time'] == 1) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '10'& & ($check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '04'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09')& & $check_yes==($yes-1)) {
$where['season'][] = $value['pay_time'];
}
$market_percentage = json_decode($value['market_percentage'],true);
if ($market_percentage['time'] == 1) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '10'& & ($check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '04'& & ($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09')& & $check_yes==($yes-1)) {
$where['season'][] = $value['pay_time'];
} elseif($market_percentage['time'] == 2) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['half_year'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09'||$check_month=='10'||$check_month=='11'||$check_month=='12')& & $check_yes==($yes-1)) {
$where['half_year'][] = $value['pay_time'];
}
} elseif($market_percentage['time'] == 3) {
if ($month == '01'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')& & $check_yes==($yes-1)) {
$where['year'][] = $value['pay_time'];
}
} else {
if ($check_month==($month-1)) {
$where['month'][] = $value['pay_time'];
}
}
} elseif($market_percentage['time'] == 2) {
if ($month == '07'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['half_year'][] = $value['pay_time'];
} elseif($month == '01'& & ($check_month=='07'||$check_month=='08'||$check_month=='09'||$check_month=='10'||$check_month=='11'||$check_month=='12')& & $check_yes==($yes-1)) {
$where['half_year'][] = $value['pay_time'];
}
} elseif($market_percentage['time'] == 3) {
if ($month == '01'& & ($check_month=='01'||$check_month=='02'||$check_month=='03'||$check_month=='04'||$check_month=='05'||$check_month=='06')& & $check_yes==($yes-1)) {
$where['year'][] = $value['pay_time'];
}
} else {
if ($check_month==($month-1)) {
$where['month'][] = $value['pay_time'];
}
}
if ($market_percentage['time'] == 1) {
//跨级发放验证当前发放月份
if ($where['season']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['season'])],'admin_id'=>$value['admin_id']])
->save(['type'=>2]);
}
if ($market_percentage['time'] == 1) {
//跨级发放验证当前发放月份
if ($where['season']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['season'])],'admin_id'=>$value['admin_id']])
->save(['type'=>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'];
} 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'];
} 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'];
} 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'];
}
} 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'];
} 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'];
} 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'];
} 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'];
}
} elseif($market_percentage['time'] == 2) {
if ($where['half_year']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['half_year'])],'admin_id'=>$value['admin_id']])
->save(['type'=>2]);
}
if ($where['half_year']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['half_year'])],'admin_id'=>$value['admin_id']])
->save(['type'=>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 == '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 ($where['year']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['year'])],'level'=>$value['admin_id']])
->save(['type'=>2]);
}
if ($where['year']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['year'])],'level'=>$value['admin_id']])
->save(['type'=>2]);
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 {
if ($where['month']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['month'])],'admin_id'=>$value['admin_id']])
->save(['type'=>2]);
}
$data[$key]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($date)))];
}
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 {
if ($where['month']) {
M("market_altogether","tab_")
->where(['pay_time'=>['in',array_unique($where['month'])],'admin_id'=>$value['admin_id']])
->save(['type'=>2]);
}
$data[$key]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time'])))];
$update['extend_commission'] = $data[$key]['extend_commission'];
M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->save($update);
}
$update['extend_commission'] = $data[$key]['extend_commission'];
M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->save($update);
} while ($date < date ( ' Y-m ' , strtotime ( " { $ end } -1 month " ) ) ) ;
}
echo date("Y-m-d H:i:s")."----------------------月初发放市场专员应发份额----------------------\n";