Commit ef577930 authored by hangjun83's avatar hangjun83

财务开票模块更新

parent 6d3c9e69
...@@ -498,12 +498,7 @@ class InvoiceService ...@@ -498,12 +498,7 @@ class InvoiceService
if(isset($invoiceParams['invoice_pdf_url']) && !empty($invoiceParams['invoice_pdf_url'])){ if(isset($invoiceParams['invoice_pdf_url']) && !empty($invoiceParams['invoice_pdf_url'])){
$filename = $invoiceParams['platform_invoice_id'].'_'.$invoiceParams['invoice_number'].'_'.$invoiceParams['invoice_real_date'].'.pdf'; $filename = $invoiceParams['platform_invoice_id'].'_'.$invoiceParams['invoice_number'].'_'.$invoiceParams['invoice_real_date'].'.pdf';
$path = config('filesystems.default.root').'public/finance/invoice/'.$invoiceParams['invoice_platform'].'/'.$invoiceParams['platform_invoice_id'].'/'; $path = config('filesystems.default.root').'public/finance/invoice/'.$invoiceParams['invoice_platform'].'/'.$invoiceParams['platform_invoice_id'].'/';
if(!Storage::exists($path.$filename)){ $this->saveInvoicePdf($path.$filename, $invoiceParams['invoice_pdf_url']);
$pdf = $this->apiService->clientRequest('get',$invoiceParams['invoice_pdf_url'],[]);
if($pdf){
Storage::put($path.$filename,$pdf);
}
}
} }
//生成download发票的url //生成download发票的url
$urlParams = [ $urlParams = [
...@@ -522,8 +517,8 @@ class InvoiceService ...@@ -522,8 +517,8 @@ class InvoiceService
$message = '<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8"></head><bodyclass="">'; $message = '<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8"></head><bodyclass="">';
$message .= "<div style='width:800px;'>"; $message .= "<div>";
$message .= '尊敬的<h4 style="font-color: #C33203;font-weight: bold">'.$customerInfo['cust_name'].'</h4>,<h4 style="font-color: #C33203;font-weight: bold">'. $platformName . '</4>给您开具了电子发票,请查收。'; $message .= '尊敬的<span style="font-color: #C33203;font-weight: bold">'.$customerInfo['cust_name'].'</span>,<span style="font-color: #C33203;font-weight: bold">'. $platformName . '</span>给您开具了电子发票,请查收。';
$message .= "<br /><h3 style='border-bottom: 1px solid #dbdbdb;'>发票信息:</h3><br />"; $message .= "<br /><h3 style='border-bottom: 1px solid #dbdbdb;'>发票信息:</h3><br />";
$message .= "<span style='height:55px;background-color: #EDF3F5'>开票日期 : ".date('Y-m-d H:i:s',$invoiceParams['invoice_real_date'])."</span><br/>"; $message .= "<span style='height:55px;background-color: #EDF3F5'>开票日期 : ".date('Y-m-d H:i:s',$invoiceParams['invoice_real_date'])."</span><br/>";
$message .= "<span style='height:55px;background-color: #EDF3F5'>销方名称 : ".$platformName."</span><br />"; $message .= "<span style='height:55px;background-color: #EDF3F5'>销方名称 : ".$platformName."</span><br />";
...@@ -566,19 +561,39 @@ class InvoiceService ...@@ -566,19 +561,39 @@ class InvoiceService
throw new \Exception('电子发票无效无法提供下载',502); throw new \Exception('电子发票无效无法提供下载',502);
}*/ }*/
if(empty($invoiceInfo['invoice_pdf_url'])){
$invoiceResponse = $this->queryInvoiceInfo([
'invoice_platform' => $invoiceInfo['invoice_platform'],
'invoice_number' => $invoiceInfo['invoice_number']
]);
$updatedInvoiceResult = $this->invoiceRecordRepository->saveInvoice([
'invoice_number' => $invoiceInfo['invoice_number'],
'invoice_pdf_url' => $invoiceResponse['pdf'],
]);
$invoiceInfo['invoice_pdf_url'] = $updatedInvoiceResult['invoice_pdf_ur'];
}
$filename = $invoiceInfo['platform_invoice_id'].'_'.$invoiceInfo['invoice_number'].'_'.$invoiceInfo['invoice_real_date'].'.pdf'; $filename = $invoiceInfo['platform_invoice_id'].'_'.$invoiceInfo['invoice_number'].'_'.$invoiceInfo['invoice_real_date'].'.pdf';
$path = config('filesystems.default.root').'public/finance/invoice/'.$invoiceInfo['invoice_platform'].'/'.$invoiceInfo['platform_invoice_id'].'/'; $path = config('filesystems.default.root').'public/finance/invoice/'.$invoiceInfo['invoice_platform'].'/'.$invoiceInfo['platform_invoice_id'].'/';
if(!Storage::exists($path.$filename)){ $this->saveInvoicePdf($path.$filename, $invoiceInfo['invoice_pdf_url']);
$pdf = $this->apiService->clientRequest('get',$invoiceInfo['invoice_pdf_url'],[]);
if($pdf){
Storage::put($path.$filename,$pdf);
}
}
$downloadUrl = $invoiceInfo['invoice_platform'] == 'rhawn' ? 'http://download.rhawn.cn/' : 'http://download.chem-mall.com'; $downloadUrl = $invoiceInfo['invoice_platform'] == 'rhawn' ? 'http://download.rhawn.cn/' : 'http://download.chem-mall.com';
return [ 'path' => $downloadUrl.$path.$filename, 'filename' => $filename]; return [ 'path' => $downloadUrl.$path.$filename, 'filename' => $filename];
} }
public function saveInvoicePdf($path,$pdfUrl)
{
$cmd = 'chmod -R 777 storage/';
trim(shell_exec("$cmd 2>&1"));
if(!Storage::exists($path)){
$pdf = $this->apiService->clientRequest('get',$$pdfUrl,[]);
if($pdf){
Storage::put($path, $pdf);
}
}
}
public function getInvoicePdfDownloadUrl() public function getInvoicePdfDownloadUrl()
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment