diff --git a/Application/Admin/Controller/AggregateFinanceSetController.class.php b/Application/Admin/Controller/AggregateFinanceSetController.class.php index 9d6598787..78fcef9c6 100644 --- a/Application/Admin/Controller/AggregateFinanceSetController.class.php +++ b/Application/Admin/Controller/AggregateFinanceSetController.class.php @@ -178,7 +178,7 @@ class AggregateFinanceSetController extends Controller { } $v['pay_type'] = $pay_type; - $v['verify_status'] = 3; + $v['verify_status'] = 1; } $Aggregate->add($v); } @@ -311,7 +311,7 @@ class AggregateFinanceSetController extends Controller { $v['pay_type'] = $pay_type; - $v['verify_status'] = 3; + $v['verify_status'] = 1; } // } else { // $v['second_party_info'] = diff --git a/Application/Admin/Controller/AggregateFinanceStatementController.class.php b/Application/Admin/Controller/AggregateFinanceStatementController.class.php index f9b6a2824..836e43617 100644 --- a/Application/Admin/Controller/AggregateFinanceStatementController.class.php +++ b/Application/Admin/Controller/AggregateFinanceStatementController.class.php @@ -8,6 +8,7 @@ namespace Admin\Controller; class AggregateFinanceStatementController extends ThinkController { public $verify_status = [ + "-4"=>"汇总审批拒绝", "-3"=>"撤销汇总", "-1"=>"审批拒绝", "0"=>"未申请开票", @@ -17,6 +18,7 @@ class AggregateFinanceStatementController extends ThinkController "4"=>"已上传凭证", "5"=>"已到账", "6"=>"已汇总", + "7"=>"汇总审批同意", ]; public $admininfo; public $OpAuthList=[]; @@ -110,8 +112,12 @@ class AggregateFinanceStatementController extends ThinkController $data[$key]['withdraw_type_1'] = ($value['withdraw_type'] == 1 ? "月结" :"周结"); $data[$key]['withdraw_type_2'] = ($value['withdraw_type'] == 2 ? "补点" :"正常结算"); + $data[$key]['detail'] = json_decode($value['detail'],true); + + $data[$key]['oplist'] = $this->OpAuth($value); } +// dump($data);die(); $count = M("aggregate_statement","tab_")->field("count(id) count,SUM(ratio_money) ratio_money")->where($map)->find(); $map['withdraw_type'] = ["NEQ",2]; $pay_money_count = M("aggregate_statement","tab_")->field("SUM(pay_money) pay_money")->where($map)->find()['pay_money']; @@ -431,8 +437,10 @@ class AggregateFinanceStatementController extends ThinkController "info"=>"审批拒绝成功" )); } + //已开票 public function Invoiced(){ + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); $ids = $_REQUEST['ids']; $savedata = ["verify_status"=>3,"create_time"=>time(),"admin_name"=>$this->admininfo["username"],"admin_id"=>$this->admininfo["uid"]]; @@ -440,6 +448,7 @@ class AggregateFinanceStatementController extends ThinkController $ids = explode(",",$ids); foreach($ids as $k=>$v){ + $this->setAggregateDetail(2,1,'已开票',$v); $this->doAddOperationLog($v,"已开票"); } @@ -457,9 +466,10 @@ class AggregateFinanceStatementController extends ThinkController $ids = explode(",",$ids); foreach($ids as $k=>$v){ + $this->setAggregateDetail(3,1,'已到账',$v); $this->doAddOperationLog($id,"已到账"); } - + $this->ajaxReturn(array( 'status' => 1, "info"=>"已到账成功" @@ -471,13 +481,16 @@ class AggregateFinanceStatementController extends ThinkController if(!isset($_REQUEST['ids'])) $this->error("参数错误"); $ids = explode(",",$_REQUEST['ids']); foreach ($ids as $k => $v) { + $res = A("AggregateFinanceSet")->updateAggregateFinanceData($v); if(!$res){ + $this->ajaxReturn(array( 'status' => 0, "info"=>"重算结算金额失败" )); }else{ + M("aggregate_statement","tab_")->where(['id'=>$v])->save(['detail'=>'']); $this->doAddOperationLog($v,"重算结算金额"); } } @@ -758,6 +771,9 @@ class AggregateFinanceStatementController extends ThinkController //操作对应菜单 $optist = []; switch ($info['verify_status']) { + case '-4': + $optist = ["viewStatement"]; + break; case '-3': $optist = ["viewStatement","editStatement","addRemark","viewRemark","editRemark"]; break; @@ -785,6 +801,9 @@ class AggregateFinanceStatementController extends ThinkController case "6": $optist = ["viewStatement","addRemark","viewRemark","editRemark"]; break; + case "7": + $optist = ["viewStatement"]; + break; default: break; } @@ -836,6 +855,7 @@ class AggregateFinanceStatementController extends ThinkController } } } + return $resarr; } //操作日志 @@ -906,6 +926,7 @@ class AggregateFinanceStatementController extends ThinkController $Pool = M("aggregate_statement_pool","tab_"); $Statemen = M("aggregate_statement","tab_"); foreach ($datas as $k => $v) { + if(count($v['company_list']) <= 0){continue;} $v['statement_num'] = "PL_".date('Ymd').date('His').sp_random_num(3); //保存公司信息 @@ -913,7 +934,10 @@ class AggregateFinanceStatementController extends ThinkController foreach ($company_list as $ke => $va) { $this->addStatementInfo($va,$k,$v); } - + $get_statement_ids = $v['statement_ids']; + foreach ($get_statement_ids as $key => $value) { + $this->setAggregateDetail(0,1,'已汇总',$value); + } if(empty($v['create_lack_ids']) && empty($v['del_lack_ids']) && empty($v['info_ids'])){ continue;} $v['statement_ids'] = implode(",",$v['statement_ids']); @@ -935,9 +959,14 @@ class AggregateFinanceStatementController extends ThinkController $v["withdraw_type"] = 0; } $pool_id = $Pool->add($v); + + if($pool_id == false){ $this->ajaxReturn(array('status' => 0,"info"=>"汇总失败")); } + + + if(!empty($info)){ $save["pool_id"]=$pool_id; M("aggregate_statement_info","tab_")->where("id in ({$info})")->save($save); @@ -1144,5 +1173,30 @@ class AggregateFinanceStatementController extends ThinkController M("aggregate_statement","tab_")->save($v); } } + //type 0 汇总 1 审批 2 开票 3 到账 + public function setAggregateDetail($type=0, $status = 1,$detail_info = "",$id = 0) { + + $data = M("aggregate_statement","tab_")->where(['id'=>$id])->find(); + + $detail['detail'] = json_decode($data['detail'],true); + + $adminInfo = $_SESSION['onethink_admin']['user_auth']; + if ($type == 0) { + $detail['detail']['pool'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['pool_status'] = $status; + } else if($type == 1) { + $detail['detail']['apply'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['apply_status'] = $status; + } else if($type == 2) { + $detail['detail']['invoiced'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['invoiced_status'] = $status; + } else if($type == 3) { + $detail['detail']['received'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['received_status'] = $status; + } + + M("aggregate_statement","tab_")->where(['id'=>$id])->save(['detail'=>json_encode($detail['detail'])]); + + } } diff --git a/Application/Admin/Controller/AggregateStatementPoolController.class.php b/Application/Admin/Controller/AggregateStatementPoolController.class.php index 12e59041b..6edde72ac 100644 --- a/Application/Admin/Controller/AggregateStatementPoolController.class.php +++ b/Application/Admin/Controller/AggregateStatementPoolController.class.php @@ -440,12 +440,55 @@ class AggregateStatementPoolController extends ThinkController } + + //type 0 汇总 1 审批 2 开票 3 到账 + public function setAggregateDetail($type=0, $status = 1,$detail_info = "",$id = 0) { + + $data = M("aggregate_statement","tab_")->where(['id'=>$id])->find(); + + $detail['detail'] = json_decode($data['detail'],true); + + $adminInfo = $_SESSION['onethink_admin']['user_auth']; + if ($type == 0) { + $detail['detail']['pool'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['pool_status'] = $status; + } else if($type == 1) { + $detail['detail']['apply'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['apply_status'] = $status; + if ($status == 1) { + $verify_status = 7; + } else { + $verify_status = -4; + } + M("aggregate_statement","tab_")->where(['id'=>$id])->save(['verify_status'=>$verify_status]); + } else if($type == 2) { + $detail['detail']['invoiced'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['invoiced_status'] = $status; + } else if($type == 3) { + $detail['detail']['received'] = $detail_info."({$adminInfo["username"]})".date("Y-m-d H:i:s"); + $detail['detail']['received_status'] = $status; + } + + M("aggregate_statement","tab_")->where(['id'=>$id])->save(['detail'=>json_encode($detail['detail'])]); + + } + protected function setVerifyStatus($old_status,$change_status,$op_pre) { + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); $ids = $_REQUEST['ids']; - $dbres = $this->DBModel->field("id,verify_status,verify_log")->where("id in ({$ids})")->select(); + $dbres = $this->DBModel->field("id,verify_status,verify_log,statement_ids")->where("id in ({$ids})")->select(); + + + foreach($dbres as $k=>&$v){ + $get_statement_ids = explode(',',$v['statement_ids']); + + foreach ($get_statement_ids as $key => $value) { + $this->setAggregateDetail(1,$change_status==1?1:0,$change_status==1?'审批通过':'审批拒绝',$value); + } + if($v['verify_status'] != $old_status) continue; $v['verify_log'] = json_decode($v['verify_log'],true); $v['verify_log'][$op_pre.'_user']=$this->admininfo["username"]; @@ -816,17 +859,29 @@ class AggregateStatementPoolController extends ThinkController M()->rollback(); $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); } + //删除自己 $poolres = $this->DBModel->where("id = {$info['id']}")->delete(); + if($poolres === false){ M()->rollback(); $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); } //修改结算单信息 $st_res = M("aggregate_statement","tab_")->field("id,verify_status")->where("id in ({$sids})")->select(); + foreach($st_res as $k=>&$v){ + + if ($v['verify_status'] == 5) { + M()->rollback(); + $this->ajaxReturn(array('status' => 0,"info"=>"拥有已到账的结算单,不能撤销汇总")); + } + $v['verify_status']=-3; + $v['detail']=""; + $stres = M("aggregate_statement","tab_")->save($v); + if($stres === false){ M()->rollback(); $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); diff --git a/Application/Admin/View/AggregateFinanceStatement/lists.html b/Application/Admin/View/AggregateFinanceStatement/lists.html index 43f80cc77..77dc2959c 100644 --- a/Application/Admin/View/AggregateFinanceStatement/lists.html +++ b/Application/Admin/View/AggregateFinanceStatement/lists.html @@ -49,7 +49,7 @@
@@ -135,8 +135,12 @@ 结算流水 结算金额 审批状态 - 操作人 - 操作时间 + 汇总状态 + 汇总审批状态 + 开票状态 + 到账状态 + + 操作 @@ -160,8 +164,12 @@ {$data.pay_money} {$data.ratio_money} {$data.verify_status_str} - {$data.admin_name} - {$data.create_time} + {$data['detail']['pool']|default="-------"}{$data['detail']['pool']|default="-------"} + {$data['detail']['apply']|default="-------"}{$data['detail']['apply']|default="-------"} + {$data['detail']['invoiced']|default="-------"}{$data['detail']['invoiced']|default="-------"} + {$data['detail']['received']|default="-------"}{$data['detail']['received']|default="-------"} + + {$vo} @@ -170,7 +178,7 @@ - 合计结算总流水:{$pay_money}元(补点单据不重复计算在内)    结算总金额:{$total}元 + 合计结算总流水:{$pay_money}元(补点单据不重复计算在内)    结算总金额:{$total}元 @@ -234,18 +242,18 @@ $("#pool").on("click",function(){ var flag = false; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - if($(elem).data("status") == -1||$(elem).data("status") == 0 || $(elem).data("status") == 6){ + if($(elem).data("status") != 2 && $(elem).data("status") != -3){ flag = true; }else{ return $(elem).val(); } }).get().join(","); if(text == ''){ - layer.msg("" + '无需要汇总的结算单,[审核拒绝,系统生成结算单,已汇总]状态不可以进行审批通过' + ""); + layer.msg("" + '无需要汇总的结算单,[审批同意,撤销汇总]状态才进行汇总' + ""); return; } if(flag){ - layer.confirm("发起汇总不会对 [审核拒绝,系统生成结算单,已汇总] 结算单处理,选择中包含其他的状态的结算单将被忽略,点击取消停止操作",{title:false}, function(index){ + layer.confirm("发起汇总仅对 [审批同意,撤销汇总] 结算单处理,选择中包含其他的状态的结算单将被忽略,点击取消停止操作",{title:false}, function(index){ _doPoolApply(); layer.close(index); }); @@ -334,7 +342,7 @@ return; } if(flag){ - layer.confirm("审批拒绝仅会对 [已申请发票] 结算单处理,选择中包含其他的状态的结算单将被忽略,点击取消停止操作",{title:false}, function(index){ + layer.confirm("审批拒绝仅会对 [已申请发票] 结算单处理,选择中包含其他的状态的结算单将被忽略,点击取消停止操作",{title:false}, function(index){ _doRefuseApply(); layer.close(index); }); @@ -364,14 +372,14 @@ $("#Invoiced").on("click",function(){ var flag = false; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - if($(elem).data("status") != 2){ + if($(elem).data("status") != 7){ flag = true; }else{ return $(elem).val(); } }).get().join(","); if(text == ''){ - layer.msg("" + '无需要进行已开票的结算单,仅[审批同意]状态可以进行已开票' + ""); + layer.msg("" + '无需要进行已开票的结算单,仅[汇总审批同意]状态可以进行已开票' + ""); return; } if(flag){ @@ -453,7 +461,7 @@ // return $(elem).val(); }).get().join(","); if(text == ''){ - layer.msg("" + '无需要进行重新结算的结算单,仅[未申请发票][申请开票][审批拒绝]状态可以进行重新结算' + ""); + layer.msg("" + '无需要进行重新结算的结算单,仅[未申请发票][申请开票][审批拒绝][汇总审批撤回]状态可以进行重新结算' + ""); return; } layer.confirm("重算结算金额会对结算单回退到未申请发票状态,请慎重处理,点击取消停止操作",{title:false}, function(index){ diff --git a/Data/update.sql b/Data/update.sql index 37508fdaa..c86802243 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2628,4 +2628,7 @@ ALTER TABLE `tab_company_info` ADD COLUMN `invoice_item` varchar(255) NULL DEFAULT '' COMMENT '开票内容' AFTER `fax_ratio`, ADD COLUMN `invoice_type` varchar(255) NULL DEFAULT '' COMMENT '开票类型' AFTER `invoice_item`, ADD COLUMN `register_phone` varchar(24) NULL DEFAULT '' COMMENT '注册电话' AFTER `invoice_type`, -ADD COLUMN `register_address` varchar(255) NULL DEFAULT '' COMMENT '注册地址' AFTER `register_phone`; \ No newline at end of file +ADD COLUMN `register_address` varchar(255) NULL DEFAULT '' COMMENT '注册地址' AFTER `register_phone`; + +ALTER TABLE `tab_aggregate_statement` +ADD COLUMN `detail` longtext NULL COMMENT '审批详情' AFTER `remark`; \ No newline at end of file