add-admin-donw_img

This commit is contained in:
lccsw
2022-05-20 11:30:08 +08:00
parent b44a91b2c9
commit 721394f0ab
2 changed files with 79 additions and 1 deletions
+78
View File
@@ -28,4 +28,82 @@ class Img extends CI_Controller
$data = '/liche/0f48c61017285abc0cff63f59ea5a25f.jpg,/liche/be842659e04f9b5b7bf3f9ab1459c611.jpg';
echo base64_encode($data);
}
//下载合同图片
public function down_contracts(){
$this->load->library('Ordersv2List');
$this->load->model('receiver/order/receiver_orders_v2_model');
$this->load->model('receiver/order/receiver_order_contracts_model', 'order_contracts_model');
require_once COMMPATH.'/third_party/TCPDF/tcpdf.php';
$brand_id = $this->input->get('brand_id');
$page = $this->input->get('page');
!$page && $page = 1;
$params = [
'status_pid' => 0,
'status' => 1,
'brand_id' => $brand_id,
'page' => $page
];
$result = $this->ordersv2list->lists($params['status_pid'], $params);
$lists = $result['lists'];
$type_arr = [0=>'汽车购车协议',1=>'委托服务协议',2=>'车辆确定',3=>'车辆交付'];
$old_type_arr = [0=>'整车合同',1=>'委托服务协议',2=>'车辆确定',3=>'交车信息',4=>'车辆买卖合同补充协议',5=>'委托服务补充协议'];
if($lists){
foreach ($lists as $key => $val) {
echo "开始订单:{$val['o_id']}<br>";
$row = $this->receiver_orders_v2_model->get(['id'=>$val['o_id']],'sid');
$contract = $this->order_contracts_model->select(['o_id'=>$val['o_id'],"imgs <> ''"],'','','','id,o_id,file,imgs,type');
if($contract){
foreach ($contract as $v) {
$imgs = json_decode($v['imgs'],true);
if(is_array($imgs)){
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
//删除预定义的打印 页眉/页尾
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//设置默认等宽字体
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('stsongstdlight', '', 20);
$pdf->AddPage();
$options = array(
// 解决SSL证书验证失败的问题
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
)
);
//设置文件信息
foreach ($imgs as $item) {
$img_url = build_qiniu_image_url($item);
$res = file_get_contents($img_url,false, stream_context_create($options));
$pdf->Ln();
$pdf->Image('@'.$res, '', '', '', '', '', $img_url,'' , false, 300, '', false, false, 0.05, false, false, false);
}
$path = FCPATH."pdf/{$row['sid']}";
if (!file_exists($path)) {
$oldumask = umask(0);
mkdir($path, 0777, true);
umask($oldumask);
}
if($val['o_id']>=10000){
$file_name = $type_arr[$v['type']] ? $type_arr[$v['type']].'.pdf' : '其它_'.time().'.pdf';
}else{
$file_name = $old_type_arr[$v['type']] ? $old_type_arr[$v['type']].'.pdf' : '其它_'.time().'.pdf';
}
$pdf->Output( $path.'/'.$file_name,'F');
echo "合同id:{$v['id']},保存成功{$path}/{$file_name}<br>";
}else{
echo "合同id:{$v['id']},没有图片<br>";
}
}
}else{
echo "订单:{$val['o_id']},没有合同<br>";
}
}
}else{
echo "执行结束";
}
}
}
@@ -89,7 +89,7 @@ class Orders_status_entity{
$where=[
'o_id' => $oid,
];
if(!$pid_status){
if(!strlen($pid_status)){
$row = $this->ci->receiver_order_status_model->get($where,"id,max(pid_status) as pid_status");
$pid_status = $row['pid_status'];
}