市场专员业绩计bug修正

master
zhengyongxing 4 years ago
parent 2da9821caf
commit 8430444b8e

@ -336,7 +336,6 @@ class MarketPercentageController extends ThinkController
public function personMarketStaffSettle($row = 10, $p = 1) { public function personMarketStaffSettle($row = 10, $p = 1) {
// getDateMarket();die();
$map = []; $map = [];
$map['group_id'] = ['in','11,12,21']; $map['group_id'] = ['in','11,12,21'];
@ -762,6 +761,11 @@ class MarketPercentageController extends ThinkController
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->find(); ->find();
if ($is_hav) { if ($is_hav) {
//已发放不再修改状态
if ($is_hav['type'] == 2) {
$insert['type'] = 2;
}
// $this->ajaxReturn(['status'=>1,'msg'=>'已经发放过']); // $this->ajaxReturn(['status'=>1,'msg'=>'已经发放过']);
$is_add = M("market_altogether","tab_") $is_add = M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
@ -786,7 +790,10 @@ class MarketPercentageController extends ThinkController
// dump($map['pay_time']);die(); // dump($map['pay_time']);die();
foreach($data as $key => $value) { foreach($data as $key => $value) {
$sign = 0;
if (!$data[$key]['extend_commission']) {
$sign = 1;
}
$market_percentage = json_decode($value['market_percentage'],true); $market_percentage = json_decode($value['market_percentage'],true);
if ($market_percentage['time'] == 1) { if ($market_percentage['time'] == 1) {
@ -822,10 +829,11 @@ class MarketPercentageController extends ThinkController
} }
$update['extend_commission'] = $data[$key]['extend_commission']; $update['extend_commission'] = $data[$key]['extend_commission'];
if ($sign) {
M("market_altogether","tab_") M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->save($update); ->save($update);
}
} }

@ -951,266 +951,290 @@ class TimingController extends AdminController {
$map['pay_time'] = date("Y-m",strtotime('-1 month')); $map['pay_time'] = date("Y-m",strtotime('-1 month'));
if ($_REQUEST['pay_time']) { if ($_REQUEST['pay_time']) {
$map['pay_time'] = $_REQUEST['pay_time']; $map['pay_time'] = $_REQUEST['pay_time'];
} }
//所有管理员插入数据
$this->insertAllUserBonus($map['pay_time']);
$month = date("m",strtotime($_REQUEST['pay_time'])); if ($_REQUEST['pay_time'] == 'all') {
$yes = date("Y",strtotime($_REQUEST['pay_time'])); $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(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") 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_access access on admin_id=access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_auth_group auth on access.group_id=auth.id")
->join("left join sys_member member on access.uid=member.uid") ->join("left join sys_member member on access.uid=member.uid")
->where(['group_id'=>['in','11,12,21']]) ->where(['group_id'=>['in','11,12,21']])
->group("admin_id,pay_time") ->group("admin_id,pay_time")
->select(); ->select();
$wait_amount = []; $wait_amount = [];
foreach ($all_data as $key => $value) { foreach ($all_data as $key => $value) {
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses']; $sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
$market_percentage = json_decode($value['market_percentage'],true); $market_percentage = json_decode($value['market_percentage'],true);
//业绩提成 //业绩提成
$all_data[$key]['performance_commission'] = $all_data[$key]['performance_commission'] =
number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) + number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) +
$value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', ''); $value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', '');
$sum_amount <$market_percentage['performance_revenue'] ? ($all_data[$key]['performance_commission'] = 0):""; $sum_amount <$market_percentage['performance_revenue'] ? ($all_data[$key]['performance_commission'] = 0):"";
//绩效考核奖金 //绩效考核奖金
$all_data[$key]['achievement_bonus'] = $all_data[$key]['achievement_bonus'] =
number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) + number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) +
$value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', ''); $value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', '');
$sum_amount <$market_percentage['appraisal_bonuses'] ? ($all_data[$key]['achievement_bonus'] = 0):""; $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]['commission'] = number_format($all_data[$key]['performance_commission']+$all_data[$key]['achievement_bonus'], 2, '.', '');
//应发金额 //应发金额
$all_data[$key]['extend_commission'] = $all_data[$key]['extend_commission'] =
substr(number_format($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+ 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]['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]['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); $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']; $wait_amount[$value['admin_id'].$value['pay_time']] = $all_data[$key]['wait_commission'];
$check_month = date("m",strtotime($value['pay_time'])); $check_month = date("m",strtotime($value['pay_time']));
$check_yes = date("Y",strtotime($value['pay_time'])); $check_yes = date("Y",strtotime($value['pay_time']));
if ($market_percentage['time'] == 1) { if ($market_percentage['time'] == 1) {
if ($month == '07'&&($check_month=='01'||$check_month=='02'||$check_month=='03')) { if ($month == '07'&&($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time']; $where['season'][] = $value['pay_time'];
} elseif($month == '10'&&($check_month=='04'||$check_month=='05'||$check_month=='06')) { } elseif($month == '10'&&($check_month=='04'||$check_month=='05'||$check_month=='06')) {
$where['season'][] = $value['pay_time']; $where['season'][] = $value['pay_time'];
} elseif($month == '04'&&($check_month=='01'||$check_month=='02'||$check_month=='03')) { } elseif($month == '04'&&($check_month=='01'||$check_month=='02'||$check_month=='03')) {
$where['season'][] = $value['pay_time']; $where['season'][] = $value['pay_time'];
} elseif($month == '01'&&($check_month=='07'||$check_month=='08'||$check_month=='09')&&$check_yes==($yes-1)) { } elseif($month == '01'&&($check_month=='07'||$check_month=='08'||$check_month=='09')&&$check_yes==($yes-1)) {
$where['season'][] = $value['pay_time']; $where['season'][] = $value['pay_time'];
} }
} elseif($market_percentage['time'] == 2) { } 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')) { 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']; $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)) { } 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']; $where['half_year'][] = $value['pay_time'];
} }
} elseif($market_percentage['time'] == 3) { } 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)) { 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']; $where['year'][] = $value['pay_time'];
} }
} else { } else {
if ($check_month==($month-1)) { if ($check_month==($month-1)) {
$where['month'][] = $value['pay_time']; $where['month'][] = $value['pay_time'];
}
} }
} }
}
// dump($wait_amount);die(); // dump($wait_amount);die();
$data = M("settleup_marketorder","tab_") $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, ->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") 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_access access on admin_id=access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_auth_group auth on access.group_id=auth.id")
->join("left join sys_member member on access.uid=member.uid") ->join("left join sys_member member on access.uid=member.uid")
->where($map) ->where($map)
->group("admin_id,pay_time") ->group("admin_id,pay_time")
->select(); ->select();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if ($value['group_id'] == 21) { if ($value['group_id'] == 21) {
$data[$key]['level'] = '初级'; $data[$key]['level'] = '初级';
} else if ($value['group_id'] == 11) { } else if ($value['group_id'] == 11) {
$data[$key]['level'] = '中级'; $data[$key]['level'] = '中级';
} else if ($value['group_id'] == 12) { } else if ($value['group_id'] == 12) {
$data[$key]['level'] = '高级'; $data[$key]['level'] = '高级';
} }
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses']; $sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];
$market_percentage = json_decode($value['market_percentage'],true); $market_percentage = json_decode($value['market_percentage'],true);
//业绩提成 //业绩提成
$data[$key]['performance_commission'] = $data[$key]['performance_commission'] =
number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) + number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) +
$value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', ''); $value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', '');
$sum_amount <$market_percentage['performance_revenue'] ? ($data[$key]['performance_commission'] = 0):""; $sum_amount <$market_percentage['performance_revenue'] ? ($data[$key]['performance_commission'] = 0):"";
//绩效考核奖金 //绩效考核奖金
$data[$key]['achievement_bonus'] = $data[$key]['achievement_bonus'] =
number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) + number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) +
$value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', ''); $value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', '');
$sum_amount <$market_percentage['appraisal_bonuses'] ? ($data[$key]['achievement_bonus'] = 0):""; $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]['commission'] = number_format($data[$key]['performance_commission']+$data[$key]['achievement_bonus'], 2, '.', '');
//应发金额 //应发金额
$data[$key]['extend_commission'] = $data[$key]['extend_commission'] =
substr(number_format($data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+ 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]['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]['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); $data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100)), 4, '.', ''),0,-2);
$month = date("m",strtotime($value['pay_time'])); $month = date("m",strtotime($value['pay_time']));
$yes = date("Y",strtotime($value['pay_time'])); $yes = date("Y",strtotime($value['pay_time']));
$check_month = date("m",strtotime($_REQUEST['pay_time'])); $check_month = date("m",strtotime($date));
$insert['pay_time'] = $data[$key]['pay_time']; $insert['pay_time'] = $data[$key]['pay_time'];
$insert['admin_id'] = $data[$key]['admin_id']; $insert['admin_id'] = $data[$key]['admin_id'];
$insert['real_name'] = $data[$key]['real_name']; $insert['real_name'] = $data[$key]['real_name'];
$insert['nickname'] = $data[$key]['nickname']; $insert['nickname'] = $data[$key]['nickname'];
$insert['level'] = $data[$key]['group_id']; $insert['level'] = $data[$key]['group_id'];
$insert['pay_amount'] = $data[$key]['pay_amount']; $insert['pay_amount'] = $data[$key]['pay_amount'];
$insert['extend_commission'] = $data[$key]['extend_commission']; $insert['extend_commission'] = $data[$key]['extend_commission'];
if ($month != $check_month) { if ($month != $check_month) {
$insert['pay_amount'] = 2; $insert['pay_amount'] = 2;
} }
$insert['wait_commission'] = $data[$key]['wait_commission']; $insert['wait_commission'] = $data[$key]['wait_commission'];
$insert['remark'] = "月初自动发放"; $insert['remark'] = "月初自动发放";
$insert['create_time'] = time(); $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_") $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_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) ->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();
//遍历统计数据 foreach($data as $key => $value) {
$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) { $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); } 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')) {
if ($market_percentage['time'] == 1) { $where['half_year'][] = $value['pay_time'];
if ($month == '07'&&($check_month=='01'||$check_month=='02'||$check_month=='03')) { } 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['season'][] = $value['pay_time']; $where['half_year'][] = $value['pay_time'];
} elseif($month == '10'&&($check_month=='04'||$check_month=='05'||$check_month=='06')) { }
$where['season'][] = $value['pay_time']; } elseif($market_percentage['time'] == 3) {
} elseif($month == '04'&&($check_month=='01'||$check_month=='02'||$check_month=='03')) { 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['season'][] = $value['pay_time']; $where['year'][] = $value['pay_time'];
} elseif($month == '01'&&($check_month=='07'||$check_month=='08'||$check_month=='09')&&$check_yes==($yes-1)) { }
$where['season'][] = $value['pay_time']; } else {
if ($check_month==($month-1)) {
$where['month'][] = $value['pay_time'];
}
} }
} elseif($market_percentage['time'] == 2) { if ($market_percentage['time'] == 1) {
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']; if ($where['season']) {
} 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)) { M("market_altogether","tab_")
$where['half_year'][] = $value['pay_time']; ->where(['pay_time'=>['in',array_unique($where['season'])],'admin_id'=>$value['admin_id']])
} ->save(['type'=>2]);
} 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 ($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 ($where['season']) { } elseif($month == '10') {
M("market_altogether","tab_") $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'];
->where(['pay_time'=>['in',array_unique($where['season'])],'admin_id'=>$value['admin_id']]) } elseif($month == '04') {
->save(['type'=>2]); $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') { if ($where['half_year']) {
$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']; M("market_altogether","tab_")
} elseif($month == '10') { ->where(['pay_time'=>['in',array_unique($where['half_year'])],'admin_id'=>$value['admin_id']])
$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']; ->save(['type'=>2]);
} 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']) { if ($month == '07') {
M("market_altogether","tab_") $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'] +
->where(['pay_time'=>['in',array_unique($where['half_year'])],'admin_id'=>$value['admin_id']]) $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
->save(['type'=>2]); } 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') { if ($where['year']) {
$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'] + M("market_altogether","tab_")
$wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06']; ->where(['pay_time'=>['in',array_unique($where['year'])],'level'=>$value['admin_id']])
} elseif($month == '01') { ->save(['type'=>2]);
$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']) { if ($month == '01') {
M("market_altogether","tab_") $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'] +
->where(['pay_time'=>['in',array_unique($where['year'])],'level'=>$value['admin_id']]) $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'] +
->save(['type'=>2]); $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') { $update['extend_commission'] = $data[$key]['extend_commission'];
$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'] + M("market_altogether","tab_")
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'] + ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12']; ->save($update);
}
} 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_") } while ($date < date('Y-m', strtotime("{$end} -1 month")));
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->save($update);
}
echo date("Y-m-d H:i:s")."----------------------月初发放市场专员应发份额----------------------\n"; echo date("Y-m-d H:i:s")."----------------------月初发放市场专员应发份额----------------------\n";

Loading…
Cancel
Save