From 8430fa1813b6d27d8eadb1ac36f53e9cd3e847fe Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Thu, 24 Dec 2020 20:31:47 +0800 Subject: [PATCH] =?UTF-8?q?12.18=E5=8A=9F=E8=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinancialSummaryController.class.php | 1 + .../FinancialSummarySetController.class.php | 41 ++- .../MarketPercentageController.class.php | 339 ++++++++++++++---- .../Controller/PlatformController.class.php | 2 + .../StatementMangementController.class.php | 46 ++- .../MarketPercentage/marketstaffsettle.html | 94 ++++- .../personmarketstaffsettle.html | 5 +- .../View/Platform/promotepay_statistics.html | 2 +- Data/update.sql | 6 +- 9 files changed, 444 insertions(+), 92 deletions(-) diff --git a/Application/Admin/Controller/FinancialSummaryController.class.php b/Application/Admin/Controller/FinancialSummaryController.class.php index b2f60892b..ef50a22c2 100644 --- a/Application/Admin/Controller/FinancialSummaryController.class.php +++ b/Application/Admin/Controller/FinancialSummaryController.class.php @@ -14,6 +14,7 @@ class FinancialSummaryController extends AdminController "outer_count"=>"外团", "outer_branch_count"=>"外团-分发", "other_group_count"=>"无归属团", + "unsettlement_count"=>"不结算流水", ); public function _initialize() { diff --git a/Application/Admin/Controller/FinancialSummarySetController.class.php b/Application/Admin/Controller/FinancialSummarySetController.class.php index b2af3c6b7..2c0419200 100644 --- a/Application/Admin/Controller/FinancialSummarySetController.class.php +++ b/Application/Admin/Controller/FinancialSummarySetController.class.php @@ -133,7 +133,6 @@ class FinancialSummarySetController extends \Think\Controller $map = array( "payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), "pay_status"=>1, - 'is_check'=>['neq',2], ); $res = $this->SpendModel ->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count") @@ -267,7 +266,6 @@ class FinancialSummarySetController extends \Think\Controller $map = array( "payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), "pay_status"=>1, - 'is_check'=>['neq',2], ); $res = $this->SpendModel ->alias('s') @@ -307,6 +305,7 @@ class FinancialSummarySetController extends \Think\Controller $inside_nobind_count += ($v['cash_count']*100+$v['balance_coin_count']*100); } } + //处理数据 $this->adddata[] = array( "key_name"=>'inside_count', @@ -349,6 +348,41 @@ class FinancialSummarySetController extends \Think\Controller "type"=>3,"sort"=>4, "sum_money"=>number_format($other_group_nobind_count/100, 2, '.', '') ); + + $unsettlement_count = 0; + $unsettlement_nobind_count = 0; + + $unmap = $map; + $unmap['is_check'] = 2; + $unSettlementRes = $this->SpendModel + ->alias('s') + ->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count, + IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count, + IFNULL(SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END),0) as bind_coin_count, + promote.company_belong") + ->where($unmap) + ->join("tab_promote promote ON s.promote_id = promote.id", "left") + ->select(); + + foreach ($unSettlementRes as $key => $value) { + + $unsettlement_count += $value['cash_count']*100 + $value['balance_coin_count']*100 + $value['bind_coin_count']*100; + $unsettlement_nobind_count += $value['cash_count']*100 + $value['balance_coin_count']*100; + + } + //不结算金额 + $this->adddata[] = array( + "key_name"=>'unsettlement_count', + "type"=>2,"sort"=>5, + "sum_money"=>number_format($unsettlement_count/100, 2, '.', '') + ); + //不结算金额不含绑币 + $this->adddata[] = array( + "key_name"=>'unsettlement_count', + "type"=>3,"sort"=>5, + "sum_money"=>number_format($unsettlement_nobind_count/100, 2, '.', '') + ); + } public function setChannelMoney(){ @@ -454,7 +488,6 @@ class FinancialSummarySetController extends \Think\Controller "s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), "s.pay_status"=>1, "s.merchant_id"=>["GT","0"], - 'is_check'=>['neq',2], ); $spres=$this->SpendModel ->alias("s") @@ -547,7 +580,7 @@ class FinancialSummarySetController extends \Think\Controller payed_time,game_id,main_name,merchant_way,merchant.account") ->join("left join tab_test_white_list on tab_spend.user_id=tab_test_white_list.user_id") ->join("left join tab_payment_merchant merchant on merchant.id=tab_spend.merchant_id") - ->where(['pay_status'=>1,'tab_spend.pay_way'=>['egt',1],'merchant.status'=>1,'merchant.type'=>1,'is_check'=>['neq',2]]) + ->where(['pay_status'=>1,'tab_spend.pay_way'=>['egt',1],'merchant.status'=>1,'merchant.type'=>1]) ->where($map) ->group("merchant_id") ->select(false); diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index 14c4b2f2b..60a6c5b20 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -11,6 +11,21 @@ use User\Api\UserApi as UserApi; class MarketPercentageController extends ThinkController { + protected $coefficient = []; + + protected function _initialize() + { + + $coefficient_data = M("coefficient","tab_")->where("1=1")->select(); + + foreach ($coefficient_data as $key => $value) { + + $this->coefficient[$value['pay_time']][$value['admin_id']] = $value['coefficient']/100; + + } + parent::_initialize(); + } + public function index($row = 10, $p = 1){ $map = []; @@ -367,6 +382,173 @@ class MarketPercentageController extends ThinkController } + public function addcoefficient() { + + $batch = date('Ymd').date('His').sp_random_num(3); + $this->assign("batch",$batch); + $this->meta_title = 'EXCEL导入'; + $this->display(); + + } + + public function loopAdd() + { + $p = $_REQUEST; + +// $batch = $p['batch']; + $checkarr = $p['checkarr']; + //循环获取添加 + if(count($checkarr) < 1){ + $this->ajaxReturn(["status"=>1,"msg"=>"ok"]); + } + + $data = M("auth_group") + ->where(['title'=>['like','%市场专员%']]) + ->select(false); + + $member = M("auth_group_access") + ->field("sys_member.nickname,sys_member.real_name,sys_member.uid,sys_auth_group_access.group_id") + ->join("left join ({$data}) auth on auth.id = sys_auth_group_access.group_id") + ->join("left join sys_member on sys_member.uid = sys_auth_group_access.uid") + ->where("auth.title is not null") + ->select(); + + $handle_member = []; + + foreach($member as $key => $value) { + + $handle_member[$value['real_name']] = $value; + + } + + $save = []; + $coefficient = M('coefficient',"tab_"); + + foreach ($checkarr as $k => $v) { + + if(!strtotime($v['pay_time'])) { + $this->ajaxReturn(["status"=>0,"msg"=>"导入失败,序号{$v['sort']}行日期格式错误"]); + } + + if ($handle_member[$v['nickname']]) { + if ($save[$v['nickname'].$v['pay_time']]) { + $this->ajaxReturn(["status"=>0,"msg"=>"导入失败,序号{$v['sort']}行存在重复记录"]); + } + + $hav_coefficient = $coefficient + ->where(['admin_id'=>$handle_member[$v['nickname']]['uid'],'pay_time'=>$v['pay_time']]) + ->find(); + + if ($hav_coefficient) { + $this->ajaxReturn(["status"=>0,"msg"=>"导入失败,日期{$v['pay_time']}市场员{$handle_member[$v['nickname']]['real_name']}已经存在,请勿重复导入"]); + } + + $save[$v['nickname'].$v['pay_time']]['pay_time'] = $v['pay_time']; + $save[$v['nickname'].$v['pay_time']]['real_name'] = $handle_member[$v['nickname']]['real_name']; + $save[$v['nickname'].$v['pay_time']]['admin_id'] = $handle_member[$v['nickname']]['uid']; + $save[$v['nickname'].$v['pay_time']]['nickname'] = $handle_member[$v['nickname']]['nickname']; + $save[$v['nickname'].$v['pay_time']]['coefficient'] = $v['coefficient']*100; + + if ($v['coefficient'] > 1) { + $this->ajaxReturn(["status"=>0,"msg"=>"导入失败,序号{$v['sort']}行系数错误,系数超过最大值1"]); + } + + } else { + $this->ajaxReturn(["status"=>0,"msg"=>"导入失败,导入的市场员{$v['nickname']}不存在"]); + } + + } + + $save = array_values($save); + + if ($coefficient->addAll($save)) { + $this->ajaxReturn(["status"=>1,"msg"=>"导入成功"]); + } + + } + + public function coefficientSave() { + + $pay_time =date('Y-m',strtotime(date('Y',time()).'-'.(date('m',time())-1).'-01')); + + if ($_REQUEST['is_get']) { + unset($_GET['is_get']); + $data = $_GET; + + $admin = $_SESSION['onethink_admin']['user_auth']['username']; + $coefficient_check_detail = "已审批({$admin})
".date("Y-m-d H:i:s",time()); + $marketSave['coefficient_check'] = 1; + $marketSave['coefficient_check_detail'] = $coefficient_check_detail; + + foreach ($data as $key => $value) { + //解析键值信息 + $info = explode('-',$key); + $save['nickname'] = $info[0]; + $save['admin_id'] = $info[1]; + $save['real_name'] = $info[2]; + $save['coefficient'] = $value*100; + + $save['pay_time'] = $pay_time; + + $is_hav = M("coefficient","tab_") + ->where([ + 'pay_time'=>$save['pay_time'], + 'admin_id'=>$save['admin_id'] + ]) + ->find(); + if ($is_hav) { + + if ($is_hav['coefficient'] != $save['coefficient']) { + $save['update_time'] = time(); + M("coefficient","tab_") + ->where([ + 'pay_time'=>$save['pay_time'], + 'admin_id'=>$save['admin_id'] + ])->save(['coefficient'=>$save['coefficient']]); + + M("market_altogether","tab_")->where([ + 'pay_time'=>$save['pay_time'], + 'admin_id'=>$save['admin_id'] + ])->save($marketSave); + + } + + } else { + $save['create_time'] = time(); + M("coefficient","tab_")->add($save); + M("market_altogether","tab_")->where([ + 'pay_time'=>$save['pay_time'], + 'admin_id'=>$save['admin_id'] + ])->save($marketSave); + + } + + } + + $this->ajaxReturn(['status'=>1,'msg'=>"绩效编辑成功"]); + + + } else { + + $data = M("auth_group") + ->where(['title'=>['like','%市场专员%']]) + ->select(false); + + $data = M("auth_group_access") + ->field("sys_member.nickname,sys_member.real_name,sys_member.uid,sys_auth_group_access.group_id,IF(coefficient is not NULL, coefficient, 100) coefficient") + ->join("left join ({$data}) auth on auth.id = sys_auth_group_access.group_id") + ->join("left join sys_member on sys_member.uid = sys_auth_group_access.uid") + ->join("left join tab_coefficient on tab_coefficient.admin_id = sys_member.uid and pay_time='{$pay_time}'") + ->where("auth.title is not null") + ->select(); + + $this->assign('list_data',$data); + + $this->display("coefficient"); + } + + } + public function marketStaffSettle($row = 10, $p = 1) { $map = []; @@ -493,13 +675,19 @@ class MarketPercentageController extends ThinkController $this->checkListOrCountAuthRestMap($map,[]); if(IS_ROOT){ + $this->assign('coefficient_check',true); $this->assign('market_check',true); $this->assign('finance_check',true); + $this->assign('coefficient_in_check',true); }else { + $exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_coefficient_check"); + $this->assign('coefficient_check',$this->checkRule($exportRule,array('in','1,2'))); $exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_market_check"); $this->assign('market_check',$this->checkRule($exportRule,array('in','1,2'))); $exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_finance_check"); $this->assign('finance_check',$this->checkRule($exportRule,array('in','1,2'))); + $exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_coefficient_in_check"); + $this->assign('coefficient_in_check',$this->checkRule($exportRule,array('in','1,2'))); } $all_data = M("market_altogether","tab_") @@ -546,17 +734,20 @@ class MarketPercentageController extends ThinkController if(!$value['market_check']) { $data[$key]['market_check_detail'] = "-----"; -//({$admin})
".date("Y-m-d H:m:s",time()); } if (!$value['finance_check']) { $data[$key]['finance_check_detail'] = "-----"; -//({$admin})
".date("Y-m-d H:m:s",time()); + } + + if (!$value['coefficient_check']) { + $data[$key]['coefficient_check_detail'] = "-----"; } if ($_REQUEST['export']) { $data[$key]['market_check_detail'] = str_replace("
",'',$data[$key]['market_check_detail']); $data[$key]['finance_check_detail'] = str_replace("
",'',$data[$key]['finance_check_detail']); + $data[$key]['coefficient_check_detail'] = str_replace("
",'',$data[$key]['coefficient_check_detail']); } $market_percentage = json_decode($value['market_percentage'],true); @@ -569,11 +760,18 @@ class MarketPercentageController extends ThinkController //维护奖金考核比例 $data[$key]['maintain_appraisal_bonuses_ratio'] = $market_percentage['maintain_appraisal_bonuses_ratio']; + $data[$key]['coefficient'] = $this->coefficient[$value['pay_time']][$value['admin_id']]; + $month = date("m",strtotime($value['pay_time'])); $yes = date("Y",strtotime($value['pay_time'])); + $achievement_bonus = number_format($data[$key]['achievement_bonus'], 2, '.', ''); + + //绩效系数计算 + $data[$key]['achievement_bonus'] = number_format($data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', ''); + $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]['wait_commission'] = substr(number_format($value['wait_performance_commission'] + $value['wait_achievement_commission']*($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 4, '.', ''),0,-2); $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; //两个起提流水都没达到时,不展示税后毛利 @@ -583,7 +781,6 @@ class MarketPercentageController extends ThinkController $value['company_profit'] = "0.00"; } - if ($market_percentage['time'] == 1) { if ($month == '07') { @@ -688,6 +885,8 @@ class MarketPercentageController extends ThinkController $data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'],2,'.',''); $data[$key]['wait_commission'] = number_format($data[$key]['wait_commission'],2,'.',''); + $data[$key]['achievement_bonus'] = $achievement_bonus; + $sum['performance_revenue'] += $data[$key]['performance_revenue']; $sum['appraisal_bonuses'] += $data[$key]['appraisal_bonuses']; $sum['performance_commission'] += $data[$key]['performance_commission']; @@ -696,6 +895,8 @@ class MarketPercentageController extends ThinkController $sum['extend_commission'] += $data[$key]['extend_commission']; $sum['company_profit'] += $data[$key]['company_profit']; + + } $sum['wait_commission'] = '-------'; $sum['pay_time'] = '总计'; @@ -715,9 +916,11 @@ class MarketPercentageController extends ThinkController 'performance_profit'=>'维护税后毛利', 'performance_commission' => '业绩提成', 'achievement_bonus' => '绩效考核奖金', + 'coefficient'=>'绩效系数', 'commission' => '当月合计', 'extend_commission' => '应发金额', 'wait_commission' => '待发金额', + 'coefficient_check_detail'=>'绩效确认', 'market_check_detail' => '市场部确认', 'finance_check_detail' => '财务部审批']; @@ -786,7 +989,7 @@ class MarketPercentageController extends ThinkController // $data[$key]['performance_commission'] = "=ROUND(J{$line}*(F{$line}/100)+J{$line}*(G{$line}/100),2)"; // $data[$key]['achievement_bonus'] = "=ROUND(J{$line}*(H{$line}/100)+J{$line}*(I{$line}/100),2)"; - $data[$key]['commission'] = "=ROUND(L{$line}+M{$line},2)"; + $data[$key]['commission'] = "=ROUND(L{$line}+M{$line}*N{$line},2)"; } $data = array_merge($data,[$sum]); @@ -952,21 +1155,30 @@ class MarketPercentageController extends ThinkController $value['company_profit'] = "0.00"; } + $data[$key]['coefficient'] = $this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1; + $data[$key]['wait_commission'] = - number_format($value['wait_performance_commission'] + $value['wait_achievement_commission'], 2, '.', ''); + number_format($value['wait_performance_commission'] + $value['wait_achievement_commission']*($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', ''); + + $achievement_bonus = number_format($data[$key]['achievement_bonus'], 2, '.', ''); - $data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus']; + //绩效系数计算 + $data[$key]['achievement_bonus'] = number_format($data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', ''); + + $data[$key]['commission'] = number_format($data[$key]['performance_commission'] + $data[$key]['achievement_bonus'], 2, '.', '');; $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; $sum['performance_revenue'] += $value['performance_revenue']; $sum['appraisal_bonuses'] += $value['appraisal_bonuses']; + $data[$key]['achievement_bonus'] = $achievement_bonus; + $sum['company_profit'] += $value['company_profit']; $sum['performance_commission'] += $value['performance_commission']; - $sum['achievement_bonus'] += $value['achievement_bonus']; + $sum['achievement_bonus'] += $data[$key]['achievement_bonus']; $sum['commission'] += $data[$key]['commission']; $sum['extend_commission'] += $data[$key]['extend_commission'] ; - $sum['wait_commission'] += $value['wait_performance_commission'] + $value['wait_achievement_commission']; + $sum['wait_commission'] += $data[$key]['wait_commission']; } @@ -993,6 +1205,7 @@ class MarketPercentageController extends ThinkController 'company_profit'=>'税后毛利', 'performance_commission' => '业绩提成', 'achievement_bonus' => '绩效考核奖金', + 'coefficient'=>'绩效系数', 'commission' => '当月总提成', 'extend_commission' => '本月发放', 'wait_commission' => '本月未发', @@ -1053,51 +1266,6 @@ class MarketPercentageController extends ThinkController } } -// $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']) { @@ -1150,12 +1318,12 @@ class MarketPercentageController extends ThinkController ->where(['group_id'=>['in','11,12,21']]) ->select(); if ($admin_data) { - $map['admin_id'] = ['in',array_column($admin_data,'admin_id')]; + $map['tab_market_altogether.admin_id'] = ['in',array_column($admin_data,'admin_id')]; } - $_REQUEST['pay_time']?$map['pay_time'] = $_REQUEST['pay_time']:''; - $_REQUEST['real_name']?$map['real_name'] = $_REQUEST['real_name']:''; - $_REQUEST['nickname']?$map['nickname'] = $_REQUEST['nickname']:''; + $_REQUEST['pay_time']?$map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time']:''; + $_REQUEST['real_name']?$map['tab_market_altogether.real_name'] = $_REQUEST['real_name']:''; + $_REQUEST['nickname']?$map['tab_market_altogether..nickname'] = $_REQUEST['nickname']:''; $_REQUEST['level']?$map['level'] = $_REQUEST['level']:''; @@ -1172,7 +1340,7 @@ class MarketPercentageController extends ThinkController }while ($date < date('Y-m', strtotime("{$end}"))); if ($search_date) { - $map['pay_time'] = ['in', $search_date]; + $map['tab_market_altogether.pay_time'] = ['in', $search_date]; } } elseif (isset($_REQUEST['time_start'])) { @@ -1187,7 +1355,7 @@ class MarketPercentageController extends ThinkController }while ($date < date('Y-m', strtotime("{$end}"))); if ($search_date) { - $map['pay_time'] = ['in', $search_date]; + $map['tab_market_altogether.pay_time'] = ['in', $search_date]; } } elseif (isset($_REQUEST['time_end'])) { @@ -1202,51 +1370,62 @@ class MarketPercentageController extends ThinkController }while ($date < date('Y-m', strtotime("{$end}"))); if ($search_date) { - $map['pay_time'] = ['in', $search_date]; + $map['tab_market_altogether.pay_time'] = ['in', $search_date]; } } if($_REQUEST['pay_time']) { if (in_array($_REQUEST['pay_time'],$search_date)) { - $map['pay_time'] = $_REQUEST['pay_time']; + $map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time']; } elseif(isset($_REQUEST['time_start']) || isset($_REQUEST['time_end'])) { $this->checkListOrCountAuthRestMap($map,[]); $this->assign("list_data",[]); $this->display("showbonuslist"); die(); } else { - $map['pay_time'] = $_REQUEST['pay_time']; + $map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time']; } } $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(performance_commission) performance_commission,sum(achievement_bonus) achievement_bonus, + ->field("max(tab_market_altogether.pay_time) pay_time,tab_market_altogether.real_name,tab_market_altogether.admin_id,tab_market_altogether.nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, + sum(performance_commission) performance_commission,sum(achievement_bonus* IF(coefficient is not NULL, coefficient, 100)/100) achievement_bonus, sum(wait_performance_commission)+sum(wait_achievement_commission) wait_amount, - 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") + sum(if(status > 0, wait_performance_commission, '0.00')) + sum(if(status > 0, wait_achievement_commission,'0.00') * IF(coefficient is not NULL, coefficient, 100)/100 ) wait_extend_commission, + sum(if(status = 0, wait_performance_commission, '0.00')) + round(sum(if(status = 0, wait_achievement_commission,'0.00') * IF(coefficient is not NULL, coefficient, 100)/100),2) wait_commission, remark,status") ->where($map); if ($_REQUEST['export']) { $data = $data - ->order("pay_time DESC,company_profit DESC") - ->group("admin_id") - ->select(); + ->join("left join tab_coefficient on tab_market_altogether.admin_id=tab_coefficient.admin_id and tab_coefficient.pay_time=tab_market_altogether.pay_time") + ->order("tab_market_altogether.pay_time DESC,company_profit DESC") + ->group("tab_market_altogether.admin_id,tab_market_altogether.pay_time") + ->select(false); } else { $data = $data // ->page($p, $row) - ->order("pay_time DESC,company_profit DESC") - ->group("admin_id") - ->select(); + ->join("left join tab_coefficient on tab_market_altogether.admin_id=tab_coefficient.admin_id and tab_coefficient.pay_time=tab_market_altogether.pay_time") + ->order("tab_market_altogether.pay_time DESC,company_profit DESC") + ->group("tab_market_altogether.admin_id,tab_market_altogether.pay_time") + ->select(false); } + $data = M()->table("({$data})a") + ->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(wait_amount) wait_amount, + sum(wait_extend_commission) wait_extend_commission,sum(wait_commission) wait_commission,remark,status") + ->group("admin_id") + ->select(); + +// var_dump($data);die(); + $sum = []; $sum['pay_amount'] = 0; $sum['extend_commission'] = 0; $sum['wait_commission'] = 0; foreach($data as $key => $value) { - +// dump($value); if ($value['level'] == 21) { $data[$key]['level'] = '初级'; } else if ($value['level'] == 11) { @@ -1255,7 +1434,13 @@ class MarketPercentageController extends ThinkController $data[$key]['level'] = '高级'; } - $data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus']; + //绩效系数计算 +// $data[$key]['achievement_bonus'] = $data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1); + + $data[$key]['commission'] = number_format($data[$key]['performance_commission'] + $data[$key]['achievement_bonus'], 2, '.', ''); + +// $data[$key]['wait_commission'] = +// number_format($value['wait_performance_commission'] + $value['wait_achievement_commission']*($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', ''); $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, '.', ''); @@ -1374,7 +1559,7 @@ class MarketPercentageController extends ThinkController $this->ajaxReturn(['status'=>0,'info'=>'操作失败,id不能为空']); } $admin = $_SESSION['onethink_admin']['user_auth']['username']; - $market_check_detail = "市场部已确认({$admin})
".date("Y-m-d H:m:s",time()); + $market_check_detail = "市场部已确认({$admin})
".date("Y-m-d H:i:s",time()); $is_save = M("market_altogether","tab_") ->where(['id'=>['in',$ids],'market_check'=>0]) @@ -1397,7 +1582,7 @@ class MarketPercentageController extends ThinkController } $admin = $_SESSION['onethink_admin']['user_auth']['username']; - $finance_check_detail = "财务部已审批({$admin})
".date("Y-m-d H:m:s",time()); + $finance_check_detail = "财务部已审批({$admin})
".date("Y-m-d H:i:s",time()); $is_save = M("market_altogether","tab_") ->where(['id'=>['in',$ids],'finance_check'=>0]) diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index a5195ed65..f9d886ea6 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -1328,6 +1328,7 @@ class PlatformController extends ThinkController 'admin_username' => '当前市场专员', 'relation_game_name' => '游戏', "count"=>"累计充值", + "unpay_count"=>"累计充值", "rand"=>"排行榜", "today"=>"今日充值", "week"=>"本周充值", @@ -1351,6 +1352,7 @@ class PlatformController extends ThinkController public function data_total($data) { $total['sum_count'] = array_sum(array_column($data, 'count')); + $total['unpay_count'] = array_sum(array_column($data, 'unpay_count')); $total['sum_today'] = array_sum(array_column($data, 'today')); $total['sum_week'] = array_sum(array_column($data, 'week')); $total['sum_mounth'] = array_sum(array_column($data, 'mounth')); diff --git a/Application/Admin/Controller/StatementMangementController.class.php b/Application/Admin/Controller/StatementMangementController.class.php index 5948cf2e9..8dd589ec4 100644 --- a/Application/Admin/Controller/StatementMangementController.class.php +++ b/Application/Admin/Controller/StatementMangementController.class.php @@ -328,7 +328,7 @@ class StatementMangementController extends ThinkController ->join('tab_reward_detail as rd on rd.record_id = r.id', 'LEFT') ->where($map) ->group('r.id') -// ->order('create_time DESC') + ->order('create_time DESC') ->select(); if ($result) { @@ -520,8 +520,15 @@ class StatementMangementController extends ThinkController } $settlmentSet = array_merge($settlment_info[RewardModel::REWARD_TYPE_REWARD] ?? [], $settlment_info[RewardModel::REWARD_TYPE_PUNISH] ?? []); +// dump($settlmentSet);die(); if ($id) { + + $checkReward = $this->checkRewardDetail($settlmentSet); + if ($checkReward) { + return $this->error("奖惩确认时间需在结算时间以后,请重新选择"); + } + $upt = M('reward_record', 'tab_')->where(['id'=>$id])->save($data); if ($upt === false) { $this->error('保存失败'); @@ -536,6 +543,11 @@ class StatementMangementController extends ThinkController } } else { + $checkReward = $this->checkRewardDetail($settlmentSet); + if ($checkReward) { + return $this->error("奖惩确认时间需在结算时间以后,请重新选择"); + } + $data['create_time'] = time(); $data['creater_id'] = is_login(); $ins = M('reward_record', 'tab_')->add($data); @@ -609,6 +621,38 @@ class StatementMangementController extends ThinkController } } + public function checkRewardDetail($settlmentSet = []) { + + foreach ($settlmentSet as $key => $value) { + + if ($value['company_id']) { + + $sql = "(select statement_begin_time,statement_end_time,company_id,company_name from tab_company_statement + union all select statement_begin_time,statement_end_time,company_id,company_name from tab_company_statement_info + union all select statement_begin_time,statement_end_time,company_id,company_name from tab_company_lack_statement_info where is_pool=0)statement_info"; + + $data = M()->table("$sql") + ->where( + [ + 'statement_begin_time'=>['elt',$value['confirm_time']], + 'statement_end_time'=>['egt',$value['confirm_time']], + 'company_id'=>$value['company_id'] + ] + ) + ->select(); + + if ($data) { + return true; + + } + + } + } + + return false; + + } + public function rewardManageDetail($id=0) { $games = M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select(); diff --git a/Application/Admin/View/MarketPercentage/marketstaffsettle.html b/Application/Admin/View/MarketPercentage/marketstaffsettle.html index 577aa2b34..0ab9ee713 100644 --- a/Application/Admin/View/MarketPercentage/marketstaffsettle.html +++ b/Application/Admin/View/MarketPercentage/marketstaffsettle.html @@ -58,6 +58,47 @@ right: 20px; left: auto; } + + .tooltip { + position: relative; + display: inline-block; + color: #056dae; + } + + .tooltip .tooltiptext { + visibility: hidden; + width: 250%; + background-color: #fff; + color: #fff; + text-align: center; + border-radius: 6px; + padding: 5px 0; + position: absolute; + z-index: 1; + bottom: 80%; + left: 0; + margin-left: -70%; + border: #000 solid 1px; + } + + .tooltip .tooltiptext::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: black transparent transparent transparent; + } + + .tooltip:hover .tooltiptext { + + color: #000; + visibility: visible; + line-height: 20px; + } +