diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 826c93902..7cec7df78 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -698,11 +698,56 @@ class CompanyStatementController extends ThinkController } + public function pool_splice() { + + $ids = $_REQUEST['ids']; + $arr_ids = explode(",",$ids); + $dbres = $this->DBModel->field("id,company_id")->where("id in ({$ids}) and withdraw_type=3")->select(); + + $upset_ids = array_column($dbres,"id"); + + $handle_data = []; + + $hkey = 0; + //拆分特殊补点单相同公司的 + foreach ($dbres as $key => $value) { + for (;;) { + if (!$handle_data[$hkey][$value["company_id"]]) { + $handle_data[$hkey][$value["company_id"]]= $value['id']; + break; + } else { + $hkey++; + } + if ($hkey>=50) break; + } + + } + + //特殊补点结算单发起汇总 + foreach ($handle_data as $key => $value) { + $pool_ids = implode(",",array_values($value)); + if ($pool_ids) { + $this->pool($pool_ids); + } + } + + //普通结算单发起汇总 + $arr_ids = implode(",",array_diff($arr_ids,$upset_ids)); + if ($arr_ids) { + $this->pool($arr_ids); + } + + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"汇总成功" + )); + } + //汇总 - public function pool() + public function pool($pool_ids = "") { - if(!isset($_REQUEST['ids'])) $this->error("参数错误"); - $ids = $_REQUEST['ids']; + if(!isset($pool_ids)) $this->error("参数错误"); + $ids = $pool_ids; $dbres = $this->DBModel->field("*")->where("id in ({$ids})")->select(); $check = []; @@ -828,10 +873,7 @@ class CompanyStatementController extends ThinkController //修改结算单规则 $this->updatePoolVerifyStatus($v['statement_ids'],2,"pool",$v['statement_num']); } - $this->ajaxReturn(array( - 'status' => 1, - "info"=>"汇总成功" - )); + } //结算单规则 protected function updatePoolVerifyStatus($ids,$change_status,$op_pre,$num){ diff --git a/Application/Admin/View/CompanyStatement/lists.html b/Application/Admin/View/CompanyStatement/lists.html index 32126b2e5..57ed0de84 100644 --- a/Application/Admin/View/CompanyStatement/lists.html +++ b/Application/Admin/View/CompanyStatement/lists.html @@ -474,7 +474,7 @@ var status = [0]; }else if(id=="pool"){ var opname = "发起汇总"; - var opurl = "{:U('pool')}"; + var opurl = "{:U('pool_splice')}"; var opst ="[审批通过,汇总撤销]"; var status = [1,-2]; }else if(id=="updateStatement"){