|
|
|
@ -181,6 +181,9 @@ class CompanyStatementPoolController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
//获取基本信息
|
|
|
|
|
$infolist = M("company_statement_info","tab_")->where("pool_id = '{$id}'")->select();
|
|
|
|
|
//获取母单
|
|
|
|
|
$statement_num = M("company_statement_pool","tab_")->field('statement_num')->where("id={$id}")->find()['statement_num'];
|
|
|
|
|
$this->assign("title",$statement_num);
|
|
|
|
|
|
|
|
|
|
if($infolist[0]['company_type'] == 3){
|
|
|
|
|
//上游
|
|
|
|
@ -501,88 +504,60 @@ class CompanyStatementPoolController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//撤销汇总
|
|
|
|
|
public function cancelPool()
|
|
|
|
|
{
|
|
|
|
|
//开启事务
|
|
|
|
|
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
|
|
|
|
|
$ids = $_REQUEST['ids'];
|
|
|
|
|
$dbres = $this->DBModel->field("id,statement_ids,verify_status")->where("id in ({$ids})")->select();
|
|
|
|
|
$sids = [];
|
|
|
|
|
foreach($dbres as $k=>$v){
|
|
|
|
|
if(in_array($v['verify_status'],[3,4])) continue; //有打款就不允许回退
|
|
|
|
|
$statement_ids = explode(",",$v['statement_ids']);
|
|
|
|
|
$sids = array_merge($sids,$statement_ids);
|
|
|
|
|
}
|
|
|
|
|
$sids = implode(",",$sids);
|
|
|
|
|
M()->startTrans();//事务
|
|
|
|
|
//删除info
|
|
|
|
|
$infores = M("company_statement_info","tab_")->where("pool_id in ($ids)")->delete();
|
|
|
|
|
if($infores === false){
|
|
|
|
|
M()->rollback();
|
|
|
|
|
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
|
|
|
|
|
}
|
|
|
|
|
//删除自己
|
|
|
|
|
$poolres = $this->DBModel->where("id in ({$ids})")->delete();
|
|
|
|
|
if($poolres === false){
|
|
|
|
|
M()->rollback();
|
|
|
|
|
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
|
|
|
|
|
}
|
|
|
|
|
//修改结算单信息
|
|
|
|
|
$st_res = M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select();
|
|
|
|
|
foreach($st_res as $k=>&$v){
|
|
|
|
|
$v['verify_log'] = json_decode($v['verify_log'],true);
|
|
|
|
|
$v['verify_log'][$op_pre.'_user']=$this->admininfo["username"];
|
|
|
|
|
$v['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s");
|
|
|
|
|
$v['verify_log'] = json_encode($v['verify_log']);
|
|
|
|
|
$v['verify_status']=-2;
|
|
|
|
|
$stres = M("company_statement","tab_")->save($v);
|
|
|
|
|
if($stres === false){
|
|
|
|
|
M()->rollback();
|
|
|
|
|
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
M()->commit();
|
|
|
|
|
$this->ajaxReturn(array(
|
|
|
|
|
'status' => 1,
|
|
|
|
|
"info"=>"重算金额成功"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导出
|
|
|
|
|
public function export()
|
|
|
|
|
{
|
|
|
|
|
public function cancelPool(){
|
|
|
|
|
if(!isset($_REQUEST['id'])) $this->error("参数错误");
|
|
|
|
|
$id = $_REQUEST['id'];
|
|
|
|
|
//获取基础信息
|
|
|
|
|
|
|
|
|
|
$data = M("CompanyStatement","tab_")->where(['id' => $id])->find();
|
|
|
|
|
$data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方
|
|
|
|
|
$data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方
|
|
|
|
|
$data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录
|
|
|
|
|
//收款方
|
|
|
|
|
$all_sum_money = $data['pay_amount'];//合计平台总额
|
|
|
|
|
$all_pay_amount = $data['statement_money'];//合计结算金额
|
|
|
|
|
}
|
|
|
|
|
// public function cancelPool()
|
|
|
|
|
// {
|
|
|
|
|
// //开启事务
|
|
|
|
|
// if(!isset($_REQUEST['ids'])) $this->error("参数错误");
|
|
|
|
|
// $ids = $_REQUEST['ids'];
|
|
|
|
|
// $dbres = $this->DBModel->field("id,statement_ids,verify_status")->where("id in ({$ids})")->select();
|
|
|
|
|
// $sids = [];
|
|
|
|
|
// foreach($dbres as $k=>$v){
|
|
|
|
|
// if(in_array($v['verify_status'],[3,4])) continue; //有打款就不允许回退
|
|
|
|
|
// $statement_ids = explode(",",$v['statement_ids']);
|
|
|
|
|
// $sids = array_merge($sids,$statement_ids);
|
|
|
|
|
// }
|
|
|
|
|
// $sids = implode(",",$sids);
|
|
|
|
|
// M()->startTrans();//事务
|
|
|
|
|
// //删除info
|
|
|
|
|
// $infores = M("company_statement_info","tab_")->where("pool_id in ($ids)")->delete();
|
|
|
|
|
// if($infores === false){
|
|
|
|
|
// M()->rollback();
|
|
|
|
|
// $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
|
|
|
|
|
// }
|
|
|
|
|
// //删除自己
|
|
|
|
|
// $poolres = $this->DBModel->where("id in ({$ids})")->delete();
|
|
|
|
|
// if($poolres === false){
|
|
|
|
|
// M()->rollback();
|
|
|
|
|
// $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
|
|
|
|
|
// }
|
|
|
|
|
// //修改结算单信息
|
|
|
|
|
// $st_res = M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select();
|
|
|
|
|
// foreach($st_res as $k=>&$v){
|
|
|
|
|
// $v['verify_log'] = json_decode($v['verify_log'],true);
|
|
|
|
|
// $v['verify_log'][$op_pre.'_user']=$this->admininfo["username"];
|
|
|
|
|
// $v['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s");
|
|
|
|
|
// $v['verify_log'] = json_encode($v['verify_log']);
|
|
|
|
|
// $v['verify_status']=-2;
|
|
|
|
|
// $stres = M("company_statement","tab_")->save($v);
|
|
|
|
|
// if($stres === false){
|
|
|
|
|
// M()->rollback();
|
|
|
|
|
// $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// M()->commit();
|
|
|
|
|
// $this->ajaxReturn(array(
|
|
|
|
|
// 'status' => 1,
|
|
|
|
|
// "info"=>"重算金额成功"
|
|
|
|
|
// ));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
$big_all_sum_money = convertAmountToCn($data['statement_money']);//大写
|
|
|
|
|
|
|
|
|
|
if($data['pay_type'] == 2){
|
|
|
|
|
$data['receive_company'] = $data['second_party_info'];//收款方
|
|
|
|
|
$data['pay_company'] = $data['first_party_info'];
|
|
|
|
|
}else{
|
|
|
|
|
$data['receive_company'] = $data['first_party_info'];
|
|
|
|
|
$data['pay_company'] = $data['second_party_info'];
|
|
|
|
|
}
|
|
|
|
|
if($data['receive_company']['invoice_type'] == 1){
|
|
|
|
|
$data['receive_company']['invoice_type']="专票";
|
|
|
|
|
}else{
|
|
|
|
|
$data['receive_company']['invoice_type']="普票";
|
|
|
|
|
}
|
|
|
|
|
if ($data['company_belong'] == 9) {//上游
|
|
|
|
|
excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money);
|
|
|
|
|
} else {//下游
|
|
|
|
|
excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function OpAuth($info)
|
|
|
|
|
{
|
|
|
|
|