68 lines
2.3 KiB
PHP
68 lines
2.3 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
use mikehaertl\pdftk\Pdf;
|
|
|
|
class Pdfapi extends CI_Controller {
|
|
|
|
//pdf填充表单域接口 dev使用
|
|
public function fill_pdf()
|
|
{
|
|
$file_url = $this->input->post('file_url');
|
|
$fill_data = $this->input->post('fill_data');
|
|
if(!$file_url || !$fill_data){
|
|
die(json_encode(['code'=>0,'msg'=>'参数错误']));
|
|
}
|
|
$fill_data = json_decode($fill_data,true);
|
|
$url = base64_decode(urldecode($file_url));
|
|
$file_path = FCPATH.'tmp.pdf';
|
|
$arrContextOptions = [
|
|
"ssl" => [
|
|
"verify_peer"=>false,
|
|
"verify_peer_name"=>false,
|
|
],
|
|
|
|
];
|
|
$file = file_get_contents($file_url,false,stream_context_create($arrContextOptions));
|
|
file_put_contents($file_path, $file);
|
|
if(file_exists($file_path)){
|
|
$pdf = new Pdf($file_path);
|
|
$result = $pdf->fillForm($fill_data)->needAppearances()->saveAs('fill.pdf');
|
|
if ($result === false) {
|
|
die(json_encode(['code'=>0,'msg'=>$pdf->getError()]));
|
|
}else{
|
|
$data = [
|
|
'file_path' => http_host_com('api').'/fill.pdf',
|
|
];
|
|
@unlink($file_path);
|
|
die(json_encode(['code'=>1,'msg'=>'保存成功','data'=>$data]));
|
|
}
|
|
}else{
|
|
die(json_encode(['code'=>0,'msg'=>'保存文件失败']));
|
|
}
|
|
|
|
}
|
|
public function add_pdf(){
|
|
$o_id = $this->input->get('oid');
|
|
$this->load->library('receiver/orders_v2_entity');
|
|
if($o_id){
|
|
$res = $this->orders_v2_entity->create_pdf($o_id);
|
|
die(json_encode($res,JSON_UNESCAPED_UNICODE));
|
|
}
|
|
}
|
|
|
|
//获取物流信息
|
|
public function get_wuliu(){
|
|
$sign_str = "dzwl145Afe";
|
|
$this->load->library('AliWuliu');
|
|
$no = $this->input->get('no');
|
|
$type = $this->input->get('type');
|
|
$sign = $this->input->get('sign');
|
|
if(!$no || $sign!=md5($sign_str)){
|
|
$res = ["code"=>0,"msg"=>"参数错误"];
|
|
die(json_encode($res,JSON_UNESCAPED_UNICODE));
|
|
}
|
|
$res = $this->aliwuliu->kdi($no, $type);
|
|
echo json_encode($res,JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|