From b93af8a49a12d9476ee29087883ace6d2634412f Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 18 Nov 2021 14:05:47 +0800 Subject: [PATCH] edit-api-edit_order --- api/controllers/wxapp/licheb/Protocol.php | 6 +- api/libraries/liche/Progressopt.php | 5 ++ common/libraries/receiver/Orders_entity.php | 2 +- home/controllers/h5/Toole.php | 60 ++++++++++++++- home/views/h5/toole/pdf.php | 85 +++++++++++++++++++++ 5 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 home/views/h5/toole/pdf.php diff --git a/api/controllers/wxapp/licheb/Protocol.php b/api/controllers/wxapp/licheb/Protocol.php index f8830722..234d030c 100644 --- a/api/controllers/wxapp/licheb/Protocol.php +++ b/api/controllers/wxapp/licheb/Protocol.php @@ -262,11 +262,11 @@ class Protocol extends CI_Controller{ $diff_price = $diff_car = false; foreach($diff_key_arr as $item){ if($opt_row[$item]!=$row[$item]){ - $diff_price = $diff_car = true; + $diff_car = true; break; } } - if($money_json['price_discount']!=$opt_money_json['price_discount']){ + if($money_json['price_discount']!=$opt_money_json['price_discount'] || $row['price']!=$opt_row['price']){ $diff_price = true; } if($diff_car){ @@ -319,7 +319,7 @@ class Protocol extends CI_Controller{ $row['old_contract'] = $this->contracts_model->get(['o_id'=>$id,'type'=>1]); $contract = $this->contracts_model->get(['o_id'=>$id,'type'=>5]); $srv_price = 0; - $old_services = $services = ''; + $old_services = $services = '无'; if($row){ //获取修改前数据 $opt_row = $this->receiver_order_oplogs_model->select(['order_id'=>$row['id'],'type'=>3],'id desc',1,1);//最后修改日志 diff --git a/api/libraries/liche/Progressopt.php b/api/libraries/liche/Progressopt.php index a0d6150a..d0b8cc83 100644 --- a/api/libraries/liche/Progressopt.php +++ b/api/libraries/liche/Progressopt.php @@ -135,6 +135,11 @@ class Progressopt{ } }elseif($sign_count==1){ $url = '/pages/mine/signContract/daiLi?id='.$order['id']; + if($opt_row){ //修改内容 + if($opt_row['s_id']!=$order['s_id'] || $opt_row['v_id']!=$order['v_id'] || $opt_row['cor_id']!=$order['cor_id'] || $opt_row['incor_id']!=$order['incor_id'] || $opt_row['payway']!=$order['payway'] || $money_json['price_discount']!=$opt_money_json['price_discount']){ + $url = '/pages/mine/signContract/maiMaiBu?id='.$order['id'];//需要签合同补充协议 + } + } }else{ $url = '/pages/mine/signContract/zhengChe?id='.$order['id']; } diff --git a/common/libraries/receiver/Orders_entity.php b/common/libraries/receiver/Orders_entity.php index cec768d0..ba71339c 100644 --- a/common/libraries/receiver/Orders_entity.php +++ b/common/libraries/receiver/Orders_entity.php @@ -535,7 +535,7 @@ class Orders_entity{ ]; $this->ci->app_liche_orders_model->update($up_data,['o_id'=>$row['id']]); $sign_row = $this->ci->signs_model->get(['o_id'=>$row['id']]); - if($sign_row){ + if($sign_row && $row['status']>0){ $diff_key_arr = ['s_id','v_id','cor_id','incor_id','payway','srv_ids']; //修改其中一项需要签补充协议 $need_resign = false; foreach($diff_key_arr as $item){ diff --git a/home/controllers/h5/Toole.php b/home/controllers/h5/Toole.php index 35b9c4ba..a44a0d59 100644 --- a/home/controllers/h5/Toole.php +++ b/home/controllers/h5/Toole.php @@ -169,9 +169,67 @@ class Toole extends CI_Controller { } $this->show_json(1,'修改成功'); } - private function show_json($code,$msg){ + //重新生成pdf文件 + public function pdf(){ + $type = $this->input->get('type'); + $this->load->view('/h5/toole/pdf',$data); + } + + public function c_pdf(){ + $params = $this->input->post(); + if(!$params['oid']){ + $this->show_json(0,'请填写订单id'); + } + if(!$params['type']){ + $this->show_json(0,'请选择合同类型'); + } + if (false === strpos($_SERVER['HTTP_HOST'], 'dev')) { //不是dev判断订单是否存在 + $row = $this->orders_model->get(['id'=>$params['oid']]); + if(!$row){ + $this->show_json(0,'订单不存在'); + } + } + $url = 'https://api.liche.cn/wxapp/licheb/protocol/'; + if($params['type']==1){ //买卖合同 + $url.="car?id=".$params['oid']; + }elseif($params['type']==2){ //服务协议 + $url.="agent?id=".$params['oid']; + }else{ + $this->show_json(0,'参数错误,未知合同类型'); + } + $this->load->library('pdf'); + $pdf = new Pdf(); + $save_path = 'data/contracts/'.date('Ymd'); + $filename = time().'.pdf'; + $res = $pdf -> html2pdf($url,FCPATH.$save_path,$filename); + if(!$res){ + $this->show_json(0,'创建pdf文件失败'); + } + $data['pdf_url'] = http_host_com('home').'/'.$save_path.'/'.$filename; + $imgs = $pdf->pdf2img($data['pdf_url']);//pdf文件转图片 + $full_imgs = []; + if($imgs){ + $this->load->library('qiniu'); + //上传七牛并保存 + foreach($imgs as $key=>$val){ + $file_name = md5($val).'.jpg'; + $img_res = $this->qiniu->fetch($val,$file_name); + if($img_res){ + $imgs[$key] = $img_res['file']; + $full_imgs[$key] = $img_res['url']; + } + } + } + $data['imgs'] = $imgs; + $data['full_imgs'] = $full_imgs; + $this->show_json(1,'创建成功',$data); + } + + private function show_json($code,$msg,$info=[]){ $data['code'] = $code; $data['msg'] = $msg; + $data['data'] = $info; die(json_encode($data,JSON_UNESCAPED_UNICODE)); } + } diff --git a/home/views/h5/toole/pdf.php b/home/views/h5/toole/pdf.php new file mode 100644 index 00000000..17070f3f --- /dev/null +++ b/home/views/h5/toole/pdf.php @@ -0,0 +1,85 @@ + +
+ + + + +