diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index 408114613..b014228ea 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -975,8 +975,9 @@ function getModuleControllerAuth() $group = $_SESSION['onethink_admin']['user_group_id']; //获取全部权限列表 $ruleList = M("AuthGroup")->field("rules")->where("id='{$group}'")->find()['rules']; + //获取所有含有规则的数据 - $mc = "MODULE_NAME."/".CONTROLLER_NAME"; + $mc = MODULE_NAME."/".CONTROLLER_NAME; $authlist = M("AuthRule")->field('name')->where("name like '{$mc}%' AND id in ($ruleList)")->select(); $Auth = []; foreach ($authlist as $k => $v) { diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 8b78724a3..84062767f 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -112,7 +112,7 @@ class CompanyStatementController extends ThinkController if(isset($_REQUEST['verify_status'])){ $map['verify_status'] = $_REQUEST['verify_status']; } - $this->checkListOrCountAuthRestMap($map);//导出权限 + // $this->checkListOrCountAuthRestMap($map);//导出权限 //条件end $data = M("company_statement","tab_") ->field("id,withdraw_type,company_name,company_belong,statement_begin_time,statement_end_time,statement_money,platform_amount,verify_status,verify_log,op_time,remark") @@ -704,40 +704,60 @@ class CompanyStatementController extends ThinkController //获取要结算的公司及日期 public function getNewStatement() { - $senddata = []; - //1.获取要计算的公司 - $statement = M("company_statement","tab_")->field("count(id) count,company_id")->group("company_id")->select(); - $has_company_id =implode(",",array_column($statement, 'company_id')); - if(empty($has_company_id)){ - $where = "1=1"; - }else{ - $where = "(first_company_type > 0 AND first_company_id NOT IN ({$has_company_id}) ) OR ( second_company_type > 0 AND second_company_id NOT IN ({$has_company_id}) )"; - } - - $relation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($where)->select(); + $senddata = [ + "up_company_id"=>[], + "dowm_company_id"=>[], + ]; + $statement = M("company_statement","tab_")->field("count(id) count,company_id,company_belong")->group("company_id,company_belong")->select(); $up_company_id = []; $dowm_company_id= []; - foreach($relation as $k=>$v){ + foreach( $statement as $k=>$v){ + if($v['company_belong'] == 9){ + $up_company_id[] = $v['company_id']; + }else{ + $dowm_company_id[]= $v['company_id']; + } + } + ; + //获取上游 + if(empty($up_company_id)){ + $upwhere = "1=1"; + }else{ + $up_company_id =implode(",",$up_company_id); + $upwhere = "(first_company_type = 1 AND first_company_id NOT IN ({$up_company_id}) ) OR ( second_company_type = 1 AND second_company_id NOT IN ({$up_company_id}) )"; + } + $uprelation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($upwhere)->select(); + + foreach($uprelation as $k=>$v){ if($v['first_company_type'] == 0){ - if($v['second_company_type'] == 1){ - $up_company_id[] = $v['second_company_id']; - }else{ - $dowm_company_id[] = $v['second_company_id']; - } + $senddata["up_company_id"][] = $v['second_company_id']; }else{ - if($v['first_company_type'] == 1){ - $up_company_id[] = $v['first_company_id']; - }else{ - $dowm_company_id[]=$v['first_company_id']; - } + $senddata["up_company_id"][] = $v['first_company_id']; } } - if(count($up_company_id) < 1 && count($dowm_company_id) < 1){ - $this->ajaxReturn(["error"=>'无新增关系,无需重算']); + + //获取下游 + if(empty($dowm_company_id)){ + $downwhere = "1=1"; + }else{ + $dowm_company_id =implode(",",$dowm_company_id); + $downwhere = "(first_company_type = 1 AND first_company_id NOT IN ({$dowm_company_id}) ) OR ( second_company_type = 1 AND second_company_id NOT IN ({$dowm_company_id}) )"; + } + $downrelation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($downwhere)->select(); + + foreach($downrelation as $k=>$v){ + if($v['first_company_type'] == 0){ + $senddata["dowm_company_id"][] = $v['second_company_id']; + }else{ + $senddata["dowm_company_id"][] = $v['first_company_id']; + } } - $senddata['up_company_id'] = implode(",",$up_company_id); - $senddata['dowm_company_id'] = implode(",",$dowm_company_id); + if(count($senddata["up_company_id"]) < 1 && count($senddata["dowm_company_id"]) < 1){ + $this->ajaxReturn(["error"=>'无新增关系,无需重算']); + } + $senddata['up_company_id'] = implode(",",$senddata['up_company_id']); + $senddata['dowm_company_id'] = implode(",",$senddata['dowm_company_id']); //获取要结算的日期 $start = strtotime('-1 month'); @@ -754,7 +774,6 @@ class CompanyStatementController extends ThinkController } $senddata['datelist'] = $datelist; $senddata['count'] = count($datelist); - $this->ajaxReturn(["success"=>'ok',"data"=>$senddata]); } public function updateNewStatement() diff --git a/Application/Admin/Controller/CompanyStatementLackController.class.php b/Application/Admin/Controller/CompanyStatementLackController.class.php index 7def57060..ecc86fd4b 100644 --- a/Application/Admin/Controller/CompanyStatementLackController.class.php +++ b/Application/Admin/Controller/CompanyStatementLackController.class.php @@ -62,7 +62,7 @@ class CompanyStatementLackController extends ThinkController $map['is_payment'] = $_REQUEST['is_payment']; } - $this->checkListOrCountAuthRestMap($map);//导出权限 + // $this->checkListOrCountAuthRestMap($map);//导出权限 //条件end $data = $this->DBModel diff --git a/Application/Admin/Controller/CompanyStatementPoolController.class.php b/Application/Admin/Controller/CompanyStatementPoolController.class.php index 8c72a240c..3444a8998 100644 --- a/Application/Admin/Controller/CompanyStatementPoolController.class.php +++ b/Application/Admin/Controller/CompanyStatementPoolController.class.php @@ -96,7 +96,7 @@ class CompanyStatementPoolController extends ThinkController } - $this->checkListOrCountAuthRestMap($map);//导出权限 + // $this->checkListOrCountAuthRestMap($map);//导出权限 //条件end $data = $this->DBModel ->field("*") diff --git a/Application/Payment/Common/function.php b/Application/Payment/Common/function.php index 408114613..7a866d34e 100644 --- a/Application/Payment/Common/function.php +++ b/Application/Payment/Common/function.php @@ -976,7 +976,7 @@ function getModuleControllerAuth() //获取全部权限列表 $ruleList = M("AuthGroup")->field("rules")->where("id='{$group}'")->find()['rules']; //获取所有含有规则的数据 - $mc = "MODULE_NAME."/".CONTROLLER_NAME"; + $mc = MODULE_NAME."/".CONTROLLER_NAME; $authlist = M("AuthRule")->field('name')->where("name like '{$mc}%' AND id in ($ruleList)")->select(); $Auth = []; foreach ($authlist as $k => $v) {