From d40ce89901f636256e531ce1cdefc985cb11d1f4 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Fri, 3 Jul 2020 09:58:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B8=82=E5=9C=BA=E4=B8=93=E5=91=98?= =?UTF-8?q?=E4=B8=9A=E7=BB=A9=E7=BB=93=E7=AE=97=E5=8F=91=E6=94=BE=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=80=89=E9=A1=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 1ee9ab7e5..defa3a834 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2648,7 +2648,7 @@ function withMarketAdminCondition($map, $searchMarketAdminId = 0) } function getMarketMonth() { - $start = date("Y-m", strtotime("+1 month")); + $start = date("Y-m", strtotime("+4 month")); //开始月份 $range = []; $i = 1; From 4bfa0dfa2f5863d4d10ae0521dce26dc6c31d4f8 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Sat, 4 Jul 2020 15:58:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B8=82=E5=9C=BA=E4=B8=93=E5=91=98?= =?UTF-8?q?=E4=B8=9A=E7=BB=A9=E7=BB=93=E7=AE=97=E7=BB=93=E6=9E=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 7 +- .../Controller/AdminController.class.php | 8 +- .../MarketPercentageController.class.php | 926 +++++------------- .../Controller/TimingController.class.php | 467 ++++----- .../View/MarketPercentage/edittaxratio.html | 6 +- .../personmarketstaffsettle.html | 48 +- 6 files changed, 446 insertions(+), 1016 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index defa3a834..e1376ff08 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2585,13 +2585,12 @@ function is_sendBonus($pay_time = '',$admin_id = '') { ->where(['pay_time'=>$pay_time,'admin_id'=>$admin_id]) ->find(); - if ($market_altogether && $market_altogether['type'] != 0) { - return '已发放'; + if ($market_altogether['status'] > 0) { + return 1; } else { - return '未发放'; + return 0; } - } function getPromoteIdsByTopIds($ids) diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index f932da18e..133778918 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -641,21 +641,21 @@ class AdminController extends Controller { //验证count if(IS_ROOT){ $this->assign('caculate_check',true); + $this->assign('send_bonus_check',true); $this->assign('role_export_check',true); $this->assign($countfield,true); }else{ $exportRule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_export_check"); -// var_dump($this->checkRule($exportRule,array('in','1,2')));die(); - $this->assign('role_export_check',$this->checkRule($exportRule,array('in','1,2'))); - + $sendBonus = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_send_bonus_check"); + $this->assign('send_bonus_check',$this->checkRule($sendBonus,array('in','1,2'))); $caculateRule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_caculate_check"); $this->assign('caculate_check',$this->checkRule($caculateRule,array('in','1,2'))); -// var_dump($caculateRule);die(); + $countRule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_count_check"); $this->assign($countfield,$this->checkRule($countRule,array('in','1,2'))); diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index aaf6b79ac..dac14829b 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -29,6 +29,7 @@ class MarketPercentageController extends ThinkController if ($_REQUEST['export']) { $data = $data->where($map) ->group("promote_id,game_name,pay_time") + ->order("pay_time DESC") ->select(); } else { $data = $data->page($p, $row) @@ -123,82 +124,32 @@ class MarketPercentageController extends ThinkController $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; - $_REQUEST['group_id']?($map['group_id'] = $_REQUEST['group_id']):''; + $_REQUEST['group_id']?($map['level'] = $_REQUEST['group_id']):''; + + $data = M("market_altogether","tab_") + ->where($map); -// dump(getMarketAdmin());die(); - $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"); if ($_REQUEST['export']) { - $data = $data->where($map) - ->group("admin_id,pay_time") + $data = $data + ->field("tab_market_altogether.*,market_percentage") + ->join("left join sys_auth_group_access access on tab_market_altogether.admin_id = access.uid") + ->join("left join sys_auth_group auth on access.group_id=auth.id") + ->page($p, $row) ->order("pay_time DESC") ->select(); } else { - $data = $data->where($map) - ->group("admin_id,pay_time") + $data = $data + ->field("tab_market_altogether.*,market_percentage") + ->join("left join sys_auth_group_access access on tab_market_altogether.admin_id = access.uid") + ->join("left join sys_auth_group auth on access.group_id=auth.id") ->order("pay_time DESC") ->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") - ->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") + $count = M("market_altogether","tab_") ->where($map) - ->group("admin_id,pay_time") - ->select(false); - $count = M()->table("({$count}) count")->count(); + ->count(); $page = set_pagination($count, $row); if ($page) { @@ -206,108 +157,141 @@ class MarketPercentageController extends ThinkController } $this->checkListOrCountAuthRestMap($map,[]); + + $all_data = M("market_altogether","tab_") + ->where($map) + ->select(); + $wait_amount = []; + foreach ($all_data as $key => $value) { + + $wait_amount[$value['admin_id'].$value['pay_time'].'performance_commission'] = $value['wait_performance_commission']; + $wait_amount[$value['admin_id'].$value['pay_time'].'achievement_bonus'] = $value['wait_achievement_commission']; + + } + foreach ($data as $key => $value) { - if ($value['group_id'] == 21) { + $data[$key]['start_time'] = date("Y-m-1",strtotime($value['pay_time'])); + $data[$key]['end_time'] = date("Y-m-t",strtotime($value['pay_time'])); + + if ($value['level'] == 21) { $data[$key]['level'] = '初级'; - } else if ($value['group_id'] == 11) { + } else if ($value['level'] == 11) { $data[$key]['level'] = '中级'; - } else if ($value['group_id'] == 12) { + } else if ($value['level'] == 12) { $data[$key]['level'] = '高级'; } - $sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses']; - - $data[$key]['start_time'] = date("Y-m-1",strtotime($value['pay_time'])); - $data[$key]['end_time'] = date("Y-m-t",strtotime($value['pay_time'])); - $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) + - $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); - $month = date("m",strtotime($value['pay_time'])); $yes = date("Y",strtotime($value['pay_time'])); + + $data[$key]['commission'] = number_format($data[$key]['performance_commission'] + $data[$key]['achievement_bonus'], 2, '.', ''); + $data[$key]['wait_commission'] = substr(number_format($value['wait_performance_commission'] + $value['wait_achievement_commission'], 4, '.', ''),0,-2); + 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]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_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']; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'performance_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']; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_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']; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_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']; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_commission'] + + $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_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'] + - $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]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'performance_commission'] + + $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_commission']; } } 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]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'.'performance_commission'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'.'performance_commission'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'.'performance_commission'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'.'performance_commission']; } } else { - $data[$key]['extend_commission'] += $wait_amount[date("Y-m",strtotime("last month",strtotime($value['pay_time'])))]; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] .date("Y-m",strtotime("last month",strtotime($value['pay_time']))).'performance_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]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06']; + + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; + // dump($data[$key]['extend_commission']);die(); } 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']; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'achievement_bonus']; } 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']; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus']; + } + elseif($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; + } + } elseif($market_percentage['remain_time'] == 2) { + if ($month == '07') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus'] + + $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; } 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']; + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'achievement_bonus'] + + $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; } -// } 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']; + } elseif($market_percentage['remain_time'] == 3) { + if ($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'.'achievement_bonus'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'.'achievement_bonus'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'.'achievement_bonus'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'.'achievement_bonus']; + } + } else { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] .date("Y-m",strtotime("last month",strtotime($value['pay_time']))).'achievement_bonus']; } +// $data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'], 2, '.', ''); + $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; - } + if ($market_percentage['time'] == 1) { + + if ($month == '07') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_commission']; + } elseif($month == '10') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'performance_commission']; + } elseif($month == '04') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_commission']; + } elseif($month == '01') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_commission']; + } + } + + if ($market_percentage['remain_time'] == 1) { + if ($month == '07') { -// dump($market_percentage); -// dump($wait_amount);die(); + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; + // dump($data[$key]['extend_commission']);die(); + } elseif($month == '10') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'achievement_bonus']; + } elseif($month == '04') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus']; + } + elseif($month == '01') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; + } + } + + } if ($_REQUEST['export']) { @@ -350,37 +334,23 @@ class MarketPercentageController extends ThinkController unset($map['admin_id']); } - $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"); + $data = M("market_altogether","tab_") + ->where($map); if ($_REQUEST['export']) { - $data = $data->where($map) - ->group("admin_id,pay_time") + $data = $data + ->page($p, $row) ->order("pay_time DESC") ->select(); } else { $data = $data - ->where($map) - ->group("admin_id,pay_time") ->order("pay_time DESC") ->select(); } - $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") - ->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") + $count = M("market_altogether","tab_") ->where($map) - ->group("admin_id,pay_time") - ->select(false); - $count = M()->table("({$count}) count")->count(); + ->count(); $page = set_pagination($count, $row); if ($page) { @@ -388,86 +358,47 @@ class MarketPercentageController extends ThinkController } $this->checkListOrCountAuthRestMap($map,[]); + $sum['company_profit'] = 0; $sum['performance_commission'] = 0; $sum['achievement_bonus'] = 0; - $sum['commission'] = 0; $sum['extend_commission'] = 0; - $sum['wait_commission'] = 0; - $sum['company_profit'] = 0; foreach ($data as $key => $value) { - if ($value['group_id'] == 21) { + $data[$key]['start_time'] = date("Y-m-1",strtotime($value['pay_time'])); + $data[$key]['end_time'] = date("Y-m-t",strtotime($value['pay_time'])); + + if ($value['level'] == 21) { $data[$key]['level'] = '初级'; - } else if ($value['group_id'] == 11) { + } else if ($value['level'] == 11) { $data[$key]['level'] = '中级'; - } else if ($value['group_id'] == 12) { + } else if ($value['level'] == 12) { $data[$key]['level'] = '高级'; } - $sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses']; + if ($value['status'] > 0) { + $data[$key]['is_send'] = '已发放'; + } else { + $data[$key]['is_send'] = '未发放'; + } - $data[$key]['is_send'] = is_sendBonus($value['pay_time'],$value['admin_id']); + $data[$key]['wait_commission'] = + number_format($value['wait_performance_commission'] + $value['wait_achievement_commission'], 2, '.', ''); - $market_percentage = json_decode($value['market_percentage'],true); + $data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus']; + $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; - //业绩提成 - $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):""; - $sum['performance_commission'] += $data[$key]['performance_commission']; - //绩效考核奖金 - $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):""; - $sum['achievement_bonus'] += $data[$key]['achievement_bonus']; - //总提成 - $data[$key]['commission'] = number_format($data[$key]['performance_commission']+$data[$key]['achievement_bonus'], 2, '.', ''); + $sum['company_profit'] += $value['company_profit']; + $sum['performance_commission'] += $value['performance_commission']; + $sum['achievement_bonus'] += $value['achievement_bonus']; $sum['commission'] += $data[$key]['commission']; - //应发金额 - $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); - $sum['extend_commission'] += $data[$key]['extend_commission']; + $sum['extend_commission'] += $data[$key]['extend_commission'] ; + $sum['wait_commission'] += $value['wait_performance_commission'] + $value['wait_achievement_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]['is_send_use'] = 1; - } elseif($month == '10') { - $data[$key]['is_send_use'] = 1; - } elseif($month == '04') { - $data[$key]['is_send_use'] = 1; - } elseif($month == '01') { - $data[$key]['is_send_use'] = 1; - } - } elseif($market_percentage['time'] == 2) { -// dump($wait_amount);die(); - if ($month == '07') { - $data[$key]['is_send_use'] = 1; - } elseif($month == '01') { - $data[$key]['is_send_use'] = 1; - } - } elseif($market_percentage['time'] == 3) { - if ($month == '01') { - $data[$key]['is_send_use'] = 1; - } - } else { - $data[$key]['is_send_use'] = 1; - } - //待发金额 - $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']; - - $sum['company_profit'] += $value['company_profit']; } $this->assign("sum",$sum); @@ -489,7 +420,6 @@ class MarketPercentageController extends ThinkController 'is_send'=>'剩余金额发放状态']; $data = array_merge($data,[$sum]); - data2csv($data,'个人总提成列表',$title); } $arraypage = $p; @@ -501,39 +431,6 @@ class MarketPercentageController extends ThinkController } - public function insertAllUserBonus($time,$admin_id=0) { - -// $time = $_REQUEST['time']; - $data = M("member") - ->field("access.uid admin_id,real_name,nickname,group_id level,0 pay_amount,0 extend_commission,0 wait_commission") - ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") - ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id'=>['in','11,12,21'],'sys_member.uid'=>$admin_id]) - ->select(); - - - - foreach ($data as $key => $value) { - $value['pay_time'] = $time; - $value['remark'] = '自动发放'; - $value['create_time'] = time(); - - $sign = M("market_altogether","tab_") - ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$time]) - ->find(); - - if (!$sign) { - M("market_altogether","tab_")->add($value); - } else { - M("market_altogether","tab_") - ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$time]) - ->save($value); - } - - } - - } - public function sendBonus() { $map['pay_time'] = $_REQUEST['pay_time']; @@ -546,359 +443,83 @@ class MarketPercentageController extends ThinkController $check_data = M("market_altogether","tab_") ->where(['pay_time'=>$_REQUEST['pay_time'],'admin_id'=>$_REQUEST['admin_id']]) ->find(); -// dump($check_data);die(); - if (!$_REQUEST['all']&&$check_data) { - - if ($check_data['type'] > 0 || $check_data['extend_commission']!='0.00'||($check_data['type'] == 0&&$check_data['extend_commission']=='0.00')) { - $this->ajaxReturn(['status'=>0,'msg'=>'已经发放过']); - } - } - $this->insertAllUserBonus($_REQUEST['pay_time'],$_REQUEST['admin_id']); - - $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']; - - } - } else { - $where = [date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time'])))]; - } - - $where = array_merge($where,[$_REQUEST['pay_time']]); - $map['pay_time'] = ['in',$where]; -// var_dump(date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time']))));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, - 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(); -// dump(end($data));die(); - - - - - $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']; - - } - - $wait_commission = 0; - - 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_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'] = - 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'])); - 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 ($_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']; - if ($_REQUEST['all']&&$check_month==$month) { - $data[$key]['extend_commission'] += $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'] + - $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'] += $data[$key]['wait_commission']; - } - } - } 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']; - if ($_REQUEST['all']&&$check_month==$month) { - $data[$key]['extend_commission'] += $data[$key]['wait_commission']; - } - } - } - else { - $data[$key]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($value['pay_time'])))]; - if ($_REQUEST['all']&&$check_month==$month) { - $data[$key]['extend_commission'] += $data[$key]['wait_commission']; - } - } - - $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']; - $insert['wait_commission'] = $data[$key]['wait_commission']; -// dump($insert['extend_commission']); - $insert['remark'] = "{$data[$key]['nickname']}发起提成发放"; - if ($_REQUEST['all']) { - if ($check_month==$month) { - $wait_commission = $data[$key]['wait_commission']; - } - $insert['remark'] = '离职发放'; - $insert['type'] = 1; - } elseif($month != $check_month) { - $insert['type'] = 2; - } else { - $insert['type'] = 0; - } - - $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) { - //已发放不再修改状态 - if ($is_hav['type'] == 2) { - $insert['type'] = 2; - } - -// $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); - } + //正常发放添加判断,不让他重新发放 + if (!$_REQUEST['all']&&$check_data) { - if (!$is_add) { - $this->ajaxReturn(['status'=>0,'msg'=>'发放失败']); + if ($check_data['status'] >0) { + $this->ajaxReturn(['status'=>0,'msg'=>'已经发放过,请勿重复操作']); } - } - - //遍历统计数据 - $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'=>$_REQUEST['pay_time'],'admin_id'=>$_REQUEST['admin_id']]) - ->select(); -// dump($data);die(); - foreach($data as $key => $value) { - $sign = 0; - if ($value['extend_commission']=='0.00') { - $sign = 1; - } - $market_percentage = json_decode($value['market_percentage'],true); -// $month = date("m",strtotime($value['pay_time'])); - - $month = date("m",strtotime($value['pay_time'])); - $yes = date("Y",strtotime($value['pay_time'])); - $check_month = date("m",strtotime($_REQUEST['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 ($_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']; - } - } 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.'-'.'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']; - 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']; - } - } 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.'-'.'04'] + - $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06']; - } - } - } 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]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time'])))]; - + //判断是否已经离职发放过 + if($_REQUEST['all']) { + if ($check_data['status']==2) { + $this->ajaxReturn(['status'=>0,'msg'=>'离职发放已经发放过']); } - - $update['extend_commission'] = $data[$key]['extend_commission']; - - if ($sign) { - M("market_altogether","tab_") - ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) - ->save($update); - } - } +// $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']; +// } +// } else { +// $where = [date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time'])))]; +// } + $save['status'] = 1; + $save['remark'] = '手动发放'; if ($_REQUEST['all']) { - - M("market_altogether","tab_") - ->where(['admin_id'=>$_REQUEST['admin_id']]) - ->save(['type'=>1]); + unset($map['pay_time']); + $save['status'] = 2; + $save['remark'] = '离职发放'; } + $is_save = M("market_altogether","tab_") + ->where($map) + ->save($save); - $this->ajaxReturn(['status'=>1,'msg'=>'发放成功']); + if ($is_save) { + $this->ajaxReturn(['status'=>1,'msg'=>'发放成功']); + } else { + $this->ajaxReturn(['status'=>0,'msg'=>'发放失败']); + } } @@ -920,7 +541,6 @@ 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']:''; @@ -929,8 +549,10 @@ class MarketPercentageController extends ThinkController $_REQUEST['level']?$map['group_id'] = $_REQUEST['level']:''; $data = M("market_altogether","tab_") - ->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,type") - ->join("left join sys_auth_group_access access on admin_id=access.uid") + ->field("max(pay_time) pay_time,real_name,admin_id,nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, + sum(performance_commission) performance_commission,sum(achievement_bonus) achievement_bonus, + sum(if(status > 0, wait_performance_commission, '0.00')) + sum(if(status > 0, wait_achievement_commission,'0.00')) wait_extend_commission, + sum(if(status = 0, wait_performance_commission, '0.00')) + sum(if(status = 0, wait_achievement_commission, '0.00')) wait_commission, remark,level,status") ->where($map); if ($_REQUEST['export']) { $data = $data @@ -946,108 +568,19 @@ class MarketPercentageController extends ThinkController // dump($data);die(); foreach($data as $key => $value) { - if ($value['group_id'] == 21) { + if ($value['level'] == 21) { $data[$key]['level'] = '初级'; - } else if ($value['group_id'] == 11) { + } else if ($value['level'] == 11) { $data[$key]['level'] = '中级'; - } else if ($value['group_id'] == 12) { + } else if ($value['level'] == 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']; - } + $data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus']; - if($data[$key]['type'] == 1) { - $data[$key]['wait_commission'] = 0; - } + $data[$key]['extend_commission'] = number_format($data[$key]['commission'] - $data[$key]['wait_commission'], 2, '.', ''); + $data[$key]['pay_amount'] = number_format($data[$key]['pay_amount'] , 2, '.', ''); + $data[$key]['wait_commission'] = number_format($data[$key]['wait_commission'] , 2, '.', ''); } @@ -1094,13 +627,10 @@ class MarketPercentageController extends ThinkController } $data = $_POST; - $data['timestart'] = strtotime($data['timestart']); - - $data = json_encode($data); + $data['time'] = strtotime($data['timestart']); + $data['create_time'] = time(); - $is_save = M("tool","tab_") - ->where(['name'=>'tax_radio']) - ->save(['config'=>$data]); + $is_save = M("tax_radio","tab_")->add($data); if ($is_save) { $this->success("保存成功",U("index")); @@ -1110,16 +640,14 @@ class MarketPercentageController extends ThinkController } else { - $data = M("tool","tab_") - ->field("config") - ->where(['name'=>'tax_radio'])->find(); - - $data['config'] = json_decode($data['config'],true); + $data = M("tax_radio","tab_") + ->field("tax_radio,time timestart") + ->order("time DESC") + ->find(); - $data['config']['timestart'] = date("Y-m-d",$data['config']['timestart']); -// var_dump($data['config']);die(); + $data['timestart'] = Date("Y-m",$data['timestart']); - $this->assign('data',$data['config']); + $this->assign('data',$data); $this->display("edittaxratio"); } diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 88daeabf1..76e4ed042 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -803,6 +803,24 @@ class TimingController extends AdminController { ->where(['name'=>['in',"alipay,weixin,wei_xin,wei_xin_app,jubaobar,weixin_gf,jft,jft_wap,goldpig,ptb_pay,bind_pay,sqpay,heepay,yeepay"]]) ->select(); + //公司税费计算 + $tax_radio = []; + $tax_data = M("tax_radio","tab_") + ->field("tax_radio,time") + ->order("time ASC") + ->select(); + + foreach ($tax_data as $key => $value) { + + $tax_radio[$key]['start'] = $value['time']; + $tax_radio[$key]['end'] = $tax_data[$key+1]['time']; + $tax_radio[$key]['tax_radio'] = $value['tax_radio']; + + if (!$tax_data[$key+1]['time']) { + $tax_radio[$key]['end'] = 99999999999; + } + } + $pay_rate = []; foreach ($paywayData as $key => $value) { $pay_config = json_decode($value['config'],true); @@ -851,16 +869,9 @@ class TimingController extends AdminController { ->where(['develop_type'=>['egt',1]]) ->select(); // dump($promote_data);die(); + // - $tax_radio = 0; - $data = M("tool","tab_") - ->field("config") - ->where(['name'=>'tax_radio'])->find(); - - $data = json_decode($data['config'],true); - if (time() >= $data['timestart']) { - $tax_radio = $data['tax_radio']; - } +// dump($tax_radio);die(); foreach ($promote_data as $key => $value) { @@ -879,8 +890,16 @@ class TimingController extends AdminController { $promote_data[$key]['promote_amount'] = $value['pay_amount'] * ($promote_radio * 0.01); //渠道费用 $promote_data[$key]['channel_amount'] = $channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name']]; + $tax = 0; //公司税费 - $promote_data[$key]['company_tax'] = ($value['pay_amount']-$promote_data[$key]['cp_amount']- $promote_data[$key]['promote_amount'])*($tax_radio/100); + foreach($tax_radio as $k => $v) { + if (strtotime($value['pay_time'])>=$v['start'] && strtotime($value['pay_time'])<$v['end']) { + $tax = $v['tax_radio']; + } + } + + $promote_data[$key]['company_tax'] = ($value['pay_amount']-$promote_data[$key]['cp_amount']- $promote_data[$key]['promote_amount'])*($tax/100); + //毛利 $promote_data[$key]['company_profit'] = $value['pay_amount']-$promote_data[$key]['cp_amount']-$promote_data[$key]['promote_amount']-$promote_data[$key]['channel_amount']-$promote_data[$key]['company_tax']; @@ -909,16 +928,18 @@ class TimingController extends AdminController { } } - +// var_dump($_REQUEST['time']); + $this->createMarketBonus($_REQUEST['time']); echo date("Y-m-d H:i:s")."----------------------市场结算管理计算----------------------\n"; } + public function insertAllUserBonus($time) { // $time = $_REQUEST['time']; $data = M("member") - ->field("access.uid admin_id,real_name,nickname,group_id level,0 pay_amount,0 extend_commission,0 wait_commission") + ->field("access.uid admin_id,real_name,nickname,group_id level") ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") ->join("left join sys_auth_group auth on access.group_id=auth.id") ->where(['group_id'=>['in','11,12,21']]) @@ -926,7 +947,7 @@ class TimingController extends AdminController { foreach ($data as $key => $value) { $value['pay_time'] = $time; - $value['remark'] = '自动发放'; + $value['remark'] = ""; $value['create_time'] = time(); $sign = M("market_altogether","tab_") @@ -934,322 +955,196 @@ class TimingController extends AdminController { ->find(); if (!$sign) { M("market_altogether","tab_")->add($value); - } else { - M("market_altogether","tab_") - ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$time]) - ->save($value); } } } - // - public function sendMarketBonus() { - echo date("Y-m-d H:i:s")."----------------------月初发放市场专员应发份额----------------------\n"; + public function createMarketBonus($pay_time) { - $map['pay_time'] = date("Y-m",strtotime('-1 month')); + if ($pay_time&&$pay_time!='all') { + $map['pay_time'] = $pay_time; + } - if ($_REQUEST['pay_time']) { - $map['pay_time'] = $_REQUEST['pay_time']; + if (!$pay_time) { + $pay_time = date("Y-m",strtotime('-1 month')); + $map['pay_time'] = date("Y-m",strtotime('-1 month')); } - if ($_REQUEST['pay_time'] == 'all') { + if ($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')); + $i++; + $this->insertAllUserBonus($date); + } while ($date < date('Y-m', strtotime("{$end} -1 month"))); + +// $map['pay_time'] = []; + unset($map['pay_time']); + } else{ + $this->insertAllUserBonus($pay_time); } - $i = 0; - do { - $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); - echo "{$date}:\n"; - $i++; - - $map['pay_time'] = $date; - - //所有管理员插入数据 - $this->insertAllUserBonus($map['pay_time']); - - $month = date("m",strtotime($date)); - $yes = date("Y",strtotime($date)); - - $all_data = M("settleup_marketorder","tab_") + $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") + 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(company_tax) company_tax, sum(cp_amount) cp_amount,sum(promote_amount) promote_amount") ->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=='10'||$check_month=='11'||$check_month=='12')&&$check_yes==($yes-1)) { - $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']; - } -// var_dump($check_month);die(); - - } 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, - 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(); - 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($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['type'] = 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"; - - $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']]) - ->save($insert); - } + 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); + + $insert['pay_time'] = $value['pay_time']; + $insert['real_name'] = $value['real_name']; + $insert['admin_id'] = $value['admin_id']; + $insert['nickname'] = $value['nickname']; + + $insert['level'] = $value['group_id']; + $insert['pay_amount'] = $value['pay_amount']; + $insert['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); + $insert['wait_commission'] = $all_data[$key]['wait_commission']; + $insert['remark'] = ''; + $insert['create_time'] = time(); + $insert['company_profit'] = $value['company_profit']; + $insert['company_tax'] = $value['company_tax']; + + $insert['cp_amount'] = $value['cp_amount']; + $insert['promote_amount'] = $value['promote_amount']; + $insert['performance_revenue'] = $value['performance_revenue']; + $insert['appraisal_bonuses'] = $value['appraisal_bonuses']; + + $insert['performance_commission'] = $all_data[$key]['performance_commission']; + $insert['achievement_bonus'] = $all_data[$key]['achievement_bonus']; + //待发业绩奖金 + $insert['wait_performance_commission'] = number_format($all_data[$key]['performance_commission'] * (1-($market_percentage['performance_monthly_ratio']/100)), 2, '.', ''); + //待发绩效奖金 + $insert['wait_achievement_commission'] = number_format($all_data[$key]['achievement_bonus'] * (1-($market_percentage['month_bonus_ratio']/100)), 2, '.', ''); +// $insert['wait_commission'] = ($insert['wait_performance_commission']+$insert['wait_achievement_commission']); + $is_hav = M("market_altogether","tab_") + ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$value['pay_time']]) + ->find(); + if (!$is_hav) { + M("market_altogether","tab_")->add($insert); + } else { + M("market_altogether","tab_") + ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$value['pay_time']]) + ->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) { - -// $sign = 0; -// if ($value['extend_commission']=='0.00') { -// $sign = 1; -// } - - $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']; - } - } + } - 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]); - } + public function sendMarketBonus(){ + echo date("Y-m-d H:i:s")."----------------------月初发放市场专员应发份额----------------------\n"; - 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) { + $map['pay_time'] = date("Y-m",strtotime('-1 month')); - 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 ($_REQUEST['time']) { + $map['pay_time'] = $_REQUEST['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'] + - $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 ($_REQUEST['time'] == 'all') { + unset($map['pay_time']); + } - if ($where['year']) { - M("market_altogether","tab_") - ->where(['pay_time'=>['in',array_unique($where['year'])],'level'=>$value['admin_id']]) - ->save(['type'=>2]); - } + $data = M("market_altogether","tab_") + ->where($map) + ->select(); +// dump($map);die(); + foreach ($data as $key => $value) { - 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)))]; + $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 =[]; + + if ($group_config['time'] == 1) { +// var_dump($month);die(); + if ($month == '07') { + $where = [$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03']; + } elseif($month == '10') { + $where = [$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06']; + } elseif($month == '04') { + $where = [($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12']; + } elseif($month == '01') { + $where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09']; } - $update['extend_commission'] = $data[$key]['extend_commission']; - + } 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']; + } + } else { + $where = [date("Y-m",strtotime("last month",strtotime($value['pay_time'])))]; + } + echo "{$value['pay_time']}:{$value['real_name']}发放\n"; + $save['status'] = 1; + $save['remark'] = '自动发放'; + if ($where) { + $map['pay_time'] = ['in',$where]; + $map['admin_id'] = $value['admin_id']; -// if ($sign) { -// M("market_altogether","tab_") -// ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) -// ->save($update); -// } M("market_altogether","tab_") - ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) - ->save($update); - + ->where($map) + ->save($save); } - - } while ($date < date('Y-m', strtotime("{$end} -1 month"))); - - + } - echo date("Y-m-d H:i:s")."----------------------月初发放市场专员应发份额----------------------\n"; + echo date("Y-m-d H:i:s")."----------------------市场结算管理计算----------------------\n"; } diff --git a/Application/Admin/View/MarketPercentage/edittaxratio.html b/Application/Admin/View/MarketPercentage/edittaxratio.html index 7198806d7..0ad1b906f 100644 --- a/Application/Admin/View/MarketPercentage/edittaxratio.html +++ b/Application/Admin/View/MarketPercentage/edittaxratio.html @@ -11,7 +11,7 @@ @@ -82,14 +82,14 @@ $(function(){ $('#timestart').datetimepicker({ - format: 'yyyy-mm-dd', + format: 'yyyy-mm', language:"zh-CN", minView:2, autoclose:true }); $('#datetimepicker').datetimepicker({ - format: 'yyyy-mm-dd', + format: 'yyyy-mm', language:"zh-CN", minView:2, autoclose:true, diff --git a/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html b/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html index fa2649a52..f6204aefd 100644 --- a/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html +++ b/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html @@ -113,24 +113,16 @@ {$data['commission']|default='0.00'} {$data['extend_commission']|default='0.00'} {$data['wait_commission']|default='0.00'} - {$data['is_send']|default='0.00'} + {$data['is_send']|default='未发放'} - - - - 发放 - - - - - - + + + 发放 + + 离职发放 + + + @@ -259,14 +251,14 @@ /* 状态搜索子菜单 */ /*发放提成*/ $('.send').click(function(){ - var time = $("#time").val(); - var admin_id = $("#time :selected").attr('data-admin_id'); + var time = $(this).attr('data-time'); + var admin_id = $(this).attr('data-admin_id'); layer.confirm('是否确认发放提成!', { title:'发放提成?', icon:0, closeBtn:0, - btn: ['发放','离职发放','取消'] //按钮 + btn: ['发放','取消'] //按钮 }, function(){ $.ajax({ type: "POST", @@ -285,6 +277,22 @@ } } }); + }, function(){ + layer.close(); + }); + + }) + + + $('.send_back').click(function(){ + var time = $(this).attr('data-time'); + var admin_id = $(this).attr('data-admin_id'); + + layer.confirm('是否确认发放提成!', { + title:'发放提成?', + icon:0, + closeBtn:0, + btn: ['发放','取消'] //按钮 }, function(){ $.ajax({ type: "POST", From 5c76d1180d5c6627811db9610f53c3baabbb5b68 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Sat, 4 Jul 2020 16:49:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=B8=82=E5=9C=BA=E4=B8=93=E5=91=98?= =?UTF-8?q?=E4=B8=9A=E7=BB=A9=E7=BB=93=E7=AE=97=E7=BB=93=E6=9E=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/MarketPercentageController.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index dac14829b..0fa2c8660 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -159,7 +159,7 @@ class MarketPercentageController extends ThinkController $all_data = M("market_altogether","tab_") - ->where($map) +// ->where($map) ->select(); $wait_amount = []; foreach ($all_data as $key => $value) { @@ -189,6 +189,7 @@ class MarketPercentageController extends ThinkController $data[$key]['commission'] = number_format($data[$key]['performance_commission'] + $data[$key]['achievement_bonus'], 2, '.', ''); $data[$key]['wait_commission'] = substr(number_format($value['wait_performance_commission'] + $value['wait_achievement_commission'], 4, '.', ''),0,-2); + $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; if ($market_percentage['time'] == 1) { @@ -260,7 +261,7 @@ class MarketPercentageController extends ThinkController $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] .date("Y-m",strtotime("last month",strtotime($value['pay_time']))).'achievement_bonus']; } // $data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'], 2, '.', ''); - $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; +// if ($market_percentage['time'] == 1) { @@ -292,6 +293,7 @@ class MarketPercentageController extends ThinkController } } +// die(); if ($_REQUEST['export']) {