Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
6a98f56d
Commit
6a98f56d
authored
Mar 06, 2023
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
财务开票模块更新
parent
f5cbe331
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
24 deletions
+59
-24
server/app/Finance/Services/InvoiceService.php
server/app/Finance/Services/InvoiceService.php
+39
-24
server/app/Http/Controllers/V1/Finance/InvoiceController.php
server/app/Http/Controllers/V1/Finance/InvoiceController.php
+19
-0
server/routes/api/finance.php
server/routes/api/finance.php
+1
-0
No files found.
server/app/Finance/Services/InvoiceService.php
View file @
6a98f56d
...
@@ -198,7 +198,7 @@ class InvoiceService
...
@@ -198,7 +198,7 @@ class InvoiceService
$applyInvoiceItems
[
'spmc'
]
=
$item
[
'item_name'
];
$applyInvoiceItems
[
'spmc'
]
=
$item
[
'item_name'
];
$applyInvoiceItems
[
'spbm'
]
=
'1070214010000000000'
;
//$item['p_code'];
$applyInvoiceItems
[
'spbm'
]
=
'1070214010000000000'
;
//$item['p_code'];
$applyInvoiceItems
[
'ggxh'
]
=
$item
[
'item_spec'
];
$applyInvoiceItems
[
'ggxh'
]
=
$item
[
'item_spec'
];
$applyInvoiceItems
[
'dw'
]
=
'EA'
;
$applyInvoiceItems
[
'dw'
]
=
$item
[
'item_unit'
]
;
$applyInvoiceItems
[
'je'
]
=
bcmul
(
$item
[
'item_price'
],
1
,
2
);
$applyInvoiceItems
[
'je'
]
=
bcmul
(
$item
[
'item_price'
],
1
,
2
);
$applyInvoiceItems
[
'sl'
]
=
$item
[
'item_nums'
];
$applyInvoiceItems
[
'sl'
]
=
$item
[
'item_nums'
];
$applyInvoiceItems
[
'dj'
]
=
bcdiv
(
$applyInvoiceItems
[
'je'
],
$applyInvoiceItems
[
'sl'
],
2
);
$applyInvoiceItems
[
'dj'
]
=
bcdiv
(
$applyInvoiceItems
[
'je'
],
$applyInvoiceItems
[
'sl'
],
2
);
...
@@ -286,17 +286,10 @@ class InvoiceService
...
@@ -286,17 +286,10 @@ class InvoiceService
public
function
confirmRedInvoice
()
public
function
confirmRedInvoice
()
{
{
}
}
public
function
cancelRedInvoice
()
public
function
cancelRedInvoice
()
{
{
}
public
function
downloadInvioce
(
$invoiceNumber
)
{
}
}
public
function
queryInvoiceInfo
(
$invoiceParams
)
public
function
queryInvoiceInfo
(
$invoiceParams
)
...
@@ -479,8 +472,13 @@ class InvoiceService
...
@@ -479,8 +472,13 @@ class InvoiceService
$updateResult
=
$this
->
rhawnInvoiceRepository
->
updateInvoiceById
(
$updatedInvoiceResult
[
'platform_invoice_id'
],
$updateParams
);
$updateResult
=
$this
->
rhawnInvoiceRepository
->
updateInvoiceById
(
$updatedInvoiceResult
[
'platform_invoice_id'
],
$updateParams
);
}
}
if
(
$updateResult
){
if
(
$updateResult
){
//获取发票地址
//塞入队列
$this
->
sendInvoiceEmail
(
$updatedInvoiceResult
);
$this
->
apiService
->
pushQueue
([
'params'
=>
$updatedInvoiceResult
,
'consumer'
=>
__CLASS__
,
'method'
=>
'sendInvoiceEmail'
],
'invoiceEmailPush'
);
//$this->sendInvoiceEmail($updatedInvoiceResult);
$this
->
apiService
->
removePlatformDataEntries
(
'invoice_callBack_'
.
$invoiceResponse
[
'ddlsh'
]
.
'_applyInvoice'
);
$this
->
apiService
->
removePlatformDataEntries
(
'invoice_callBack_'
.
$invoiceResponse
[
'ddlsh'
]
.
'_applyInvoice'
);
}
}
}
}
...
@@ -544,7 +542,6 @@ class InvoiceService
...
@@ -544,7 +542,6 @@ class InvoiceService
//$html = file_get_contents(resource_path('views/emails/invoice.blade.php'));
//$html = file_get_contents(resource_path('views/emails/invoice.blade.php'));
//查询购买方邮箱
//查询购买方邮箱
$cusInfo
=
$this
->
rhawnInvoiceRepository
->
queryCustomerInfoByInvoiceId
(
$invoiceParams
[
'platform_invoice_id'
]);
$cusInfo
=
$this
->
rhawnInvoiceRepository
->
queryCustomerInfoByInvoiceId
(
$invoiceParams
[
'platform_invoice_id'
]);
if
(
$cusInfo
){
if
(
$cusInfo
){
$cusInfo
=
current
(
$cusInfo
);
$cusInfo
=
current
(
$cusInfo
);
...
@@ -572,7 +569,25 @@ class InvoiceService
...
@@ -572,7 +569,25 @@ class InvoiceService
/*if($token != $params['token']){
/*if($token != $params['token']){
throw new \Exception('电子发票无效无法提供下载',502);
throw new \Exception('电子发票无效无法提供下载',502);
}*/
}*/
$downloadUrl
=
$this
->
getDownloadUrl
(
$invoiceInfo
);
return
[
'path'
=>
$downloadUrl
[
'downloadUrl'
],
'filename'
=>
$downloadUrl
[
'filename'
]];
}
private
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
);
}
}
}
private
function
getDownloadUrl
(
$invoiceInfo
)
{
if
(
empty
(
$invoiceInfo
[
'invoice_pdf_url'
])){
if
(
empty
(
$invoiceInfo
[
'invoice_pdf_url'
])){
$invoiceResponse
=
$this
->
queryInvoiceInfo
([
$invoiceResponse
=
$this
->
queryInvoiceInfo
([
'invoice_platform'
=>
$invoiceInfo
[
'invoice_platform'
],
'invoice_platform'
=>
$invoiceInfo
[
'invoice_platform'
],
...
@@ -590,24 +605,24 @@ class InvoiceService
...
@@ -590,24 +605,24 @@ class InvoiceService
$this
->
saveInvoicePdf
(
$path
.
$filename
,
$invoiceInfo
[
'invoice_pdf_url'
]);
$this
->
saveInvoicePdf
(
$path
.
$filename
,
$invoiceInfo
[
'invoice_pdf_url'
]);
$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
[
'downloadUrl'
=>
$downloadUrl
.
$path
.
$filename
,
'path'
=>
$path
,
'filename'
=>
$filename
];
}
}
public
function
saveInvoicePdf
(
$path
,
$pdfUrl
)
public
function
getInvoicePdfDownloadUrl
(
$params
)
{
{
$cmd
=
'chmod -R 777 storage/'
;
if
(
empty
(
$params
)){
trim
(
shell_exec
(
"
$cmd
2>&1"
));
return
false
;
if
(
!
Storage
::
exists
(
$path
)){
$pdf
=
$this
->
apiService
->
clientRequest
(
'get'
,
$pdfUrl
,[]);
if
(
$pdf
){
Storage
::
put
(
$path
,
$pdf
);
}
}
}
$invoiceInfo
=
$this
->
invoiceRecordRepository
->
getInvoiceRecordByRealNumber
(
$params
[
'invoice_real_number'
]);
if
(
!
$invoiceInfo
){
throw
new
\Exception
(
'没有对应的电子发票提供下载'
,
502
);
}
}
$invoiceInfo
=
current
(
$invoiceInfo
);
public
function
getInvoicePdfDownloadUrl
()
$downloadUrl
=
$this
->
getDownloadUrl
(
$invoiceInfo
);
{
return
$downloadUrl
;
}
}
}
}
server/app/Http/Controllers/V1/Finance/InvoiceController.php
View file @
6a98f56d
...
@@ -96,4 +96,23 @@ class InvoiceController extends Controller
...
@@ -96,4 +96,23 @@ class InvoiceController extends Controller
}
}
}
}
public
function
downloadInvoice
(
Request
$request
)
{
$requestParams
=
$this
->
formatKeysfromArray
(
$request
->
all
(),
'toUnderScore'
);
try
{
$result
=
$this
->
invoiceService
->
getInvoicePdfDownloadUrl
(
$requestParams
);
$headers
=
[
'Content-Type: application/pdf'
,
];
//下载电子发票
header
(
'Content-Type: application/octet-stream'
);
header
(
"Content-Transfer-Encoding: utf-8"
);
header
(
"Content-disposition: attachment; filename=
\"
"
.
basename
(
$result
[
'filename'
])
.
"
\"
"
);
readfile
(
$result
[
'path'
]);
}
catch
(
\Throwable
$exception
){
return
$this
->
returnErrorExecptionResponse
(
$exception
,
$exception
->
getMessage
());
}
}
}
}
server/routes/api/finance.php
View file @
6a98f56d
...
@@ -20,6 +20,7 @@ $api->version('v1', function($api) {
...
@@ -20,6 +20,7 @@ $api->version('v1', function($api) {
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Finance'
,
'middleware'
=>
[
'throttle:60,1'
,
'apiAuth'
],
'providers'
=>
'jwt'
],
function
(
$api
)
{
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Finance'
,
'middleware'
=>
[
'throttle:60,1'
,
'apiAuth'
],
'providers'
=>
'jwt'
],
function
(
$api
)
{
$api
->
post
(
'/finance/invoice/applyInvoice'
,
[
'permission'
=>
'finance.applyInvoice'
,
'uses'
=>
'InvoiceController@applyInvoice'
]);
$api
->
post
(
'/finance/invoice/applyInvoice'
,
[
'permission'
=>
'finance.applyInvoice'
,
'uses'
=>
'InvoiceController@applyInvoice'
]);
$api
->
post
(
'/finance/invoice/downloadInvoice'
,
[
'permission'
=>
'finance.downloadInvoice'
,
'uses'
=>
'InvoiceController@downloadInvoice'
]);
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment