Files
liche/api/controllers/plan/Liche.php
T
2022-04-01 11:22:52 +08:00

74 lines
2.7 KiB
PHP

<?php
/**
* Notes:博饼任务
* Created on: 2021/8/20 17:15
* Created by: dengbw
*/
class Liche extends HD_Controller
{
public function __construct(){
parent::__construct();
$this->load->model('receiver/order/receiver_order_contracts_model');
$this->load->model('receiver/order/receiver_orders_v2_model');
$this->load->library('receiver/orders_v2_entity');
}
//获取未签名pdf
public function un_sign_pdf(){
$row = $this->receiver_order_contracts_model->get(['o_id>='=>Orders_v2_entity::V2_START_ID,'flag'=>0,'file !='=>'','status'=>1]);
$receiver = $this->receiver_orders_v2_model->get(['id' => $row['o_id']]);
if(file_exists(FCPATH.$row['file']) && $receiver){
$companys = $this->orders_v2_entity->get_biz_mchid($receiver['biz_id'],$receiver['brand_id']);
$url = http_host_com();
$width = 130;
$s_img = build_qiniu_image_url($companys['company']['img_seal']);
if($row['type']==1){
$page = 2;
$height = 380;
$s_img = build_qiniu_image_url($companys['srv_company']['img_seal']);
}elseif ($row['type']==3){
$page = 1;
$height = 620;
} else{
$page = 3;
$height = 160;
}
$data = [
'id' => $row['id'],
'o_id' => $row['o_id'],
's_page' => $page,
'width' => $width,
'height' => $height,
's_img' => $s_img,
'file_url' => $url.'/'.$row['file']
];
die(json_encode($data,JSON_UNESCAPED_UNICODE));
}else{
$this->receiver_order_contracts_model->update(['flag'=>1],['id'=>$row['id']]);
}
}
//覆盖pdf文件
public function up_pdf(){
$id = $this->input->post('id');
$row = $this->receiver_order_contracts_model->get(['id'=>$id,'flag'=>0]);
if($row){
$file_path_arr = explode('/',$row['file']);
// $file_name = array_pop($file_path_arr);
// $file_name = 'test.pdf';
// $file_path = implode('/',$file_path_arr);
// $res = move_uploaded_file($_FILES['file']['tmp_name'],FCPATH.$file_path.'/'.$file_name);
move_uploaded_file($_FILES['file']['tmp_name'],FCPATH.$row['file']);
$res = $this->receiver_order_contracts_model->update(['flag'=>1],['id'=>$row['id']]);
if($res){
$data = [
'code' => 1,
'msg' => '保存成功'
];
die(json_encode($data,JSON_UNESCAPED_UNICODE));
}
}
}
}