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
da0c1e7c
Commit
da0c1e7c
authored
Jun 25, 2025
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新提交
parent
f9bd94a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
130 additions
and
132 deletions
+130
-132
server/app/Finance/Services/InvoiceService.php
server/app/Finance/Services/InvoiceService.php
+130
-132
No files found.
server/app/Finance/Services/InvoiceService.php
View file @
da0c1e7c
...
...
@@ -209,7 +209,7 @@ class InvoiceService
$replaceNameKeywords
=
[
'镧'
,
'铈'
,
'镨'
,
'钕'
,
'钷'
,
'钐'
,
'铕'
,
'钆'
,
'铽'
,
'镝'
,
'钬'
,
'铒'
,
'铥'
,
'镱'
,
'镥'
,
'钪'
,
'钇'
,
'石油醚'
,
'异辛烷'
,
'煤油'
];
foreach
(
$replaceNameKeywords
as
$keyword
){
//if(strpos($item['item_name'],$keyword)){
$item
[
'item_name'
]
=
str_replace
(
$keyword
,
'试剂'
,
$item
[
'item_name'
]);
$item
[
'item_name'
]
=
str_replace
(
$keyword
,
'试剂'
,
$item
[
'item_name'
]);
//}
}
$applyInvoiceItems
[
'spmc'
]
=
$item
[
'item_name'
];
//$this->charsetToGBK($item['item_name']);
...
...
@@ -468,24 +468,24 @@ class InvoiceService
case
1
:
$status
=
'开票中'
;
break
;
}
SimpleLogs
::
writeLog
(
'当前票据 ['
.
$res
[
'invoice_number'
]
.
'] 状态为 : '
.
$status
,
__CLASS__
.
':'
.
__FUNCTION__
);
continue
;
}
$params
=
[];
$params
[
'ddlsh'
]
=
$res
[
'invoice_number'
];
$params
[
'status'
]
=
$invoiceResponse
[
'status'
];
switch
(
$invoiceResponse
[
'status'
]){
case
2
:
$params
[
'ycyy'
]
=
''
;
$params
[
'status'
]
=
1
;
break
;
case
3
:
$params
[
'ycyy'
]
=
$invoiceResponse
[
'ycyy'
];
$params
[
'status'
]
=
2
;
break
;
}
$this
->
apiService
->
storePlatformDataEntries
(
'invoice_callBack_'
.
$res
[
'invoice_number'
]
.
'_applyInvoice'
,
$params
);
$queueParams
=
[
'params'
=>
$params
,
'type'
=>
'applyInvoiceCallBack'
];
//塞入队列
$this
->
apiService
->
pushQueue
([
'params'
=>
$queueParams
,
'consumer'
=>
__CLASS__
,
'method'
=>
'invoiceApiCallBack'
],
'invoiceCallBack'
);
}
continue
;
}
$params
=
[];
$params
[
'ddlsh'
]
=
$res
[
'invoice_number'
];
$params
[
'status'
]
=
$invoiceResponse
[
'status'
];
switch
(
$invoiceResponse
[
'status'
]){
case
2
:
$params
[
'ycyy'
]
=
''
;
$params
[
'status'
]
=
1
;
break
;
case
3
:
$params
[
'ycyy'
]
=
$invoiceResponse
[
'ycyy'
];
$params
[
'status'
]
=
2
;
break
;
}
$this
->
apiService
->
storePlatformDataEntries
(
'invoice_callBack_'
.
$res
[
'invoice_number'
]
.
'_applyInvoice'
,
$params
);
$queueParams
=
[
'params'
=>
$params
,
'type'
=>
'applyInvoiceCallBack'
];
//塞入队列
$this
->
apiService
->
pushQueue
([
'params'
=>
$queueParams
,
'consumer'
=>
__CLASS__
,
'method'
=>
'invoiceApiCallBack'
],
'invoiceCallBack'
);
}
}
}
...
...
@@ -673,10 +673,8 @@ class InvoiceService
if
(
$cusInfo
){
$cusInfo
=
current
(
$cusInfo
);
$result
=
$this
->
mailService
->
sendMailToHtml
(
$invoiceParams
[
'invoice_platform'
],
$title
,
$cusInfo
[
'cus_invoice_email'
],
$message
);
if
(
$result
){
app
(
EmailSendLogsService
::
class
)
->
saveEmailLogs
(
$platformName
,
$invoiceParams
[
'invoice_platform'
],
$cusInfo
,
$message
);
SimpleLogs
::
writeLog
(
$message
,
__CLASS__
.
':'
.
__FUNCTION__
.
' 邮件发送成功:'
);
}
app
(
EmailSendLogsService
::
class
)
->
saveEmailLogs
(
$platformName
,
$invoiceParams
[
'invoice_platform'
],
$cusInfo
,
$message
);
SimpleLogs
::
writeLog
(
$message
,
__CLASS__
.
':'
.
__FUNCTION__
.
' 邮件发送成功:'
);
$this
->
apiService
->
storePlatformDataEntries
(
'invoice_sended_mail_list'
,
array_merge
(
$sended
,[
$invoiceParams
[
'invoice_real_number'
]]));
}
}
...
...
@@ -800,115 +798,115 @@ class InvoiceService
}
}
public
function
manualDownLoadInvoicePdf
(
$params
)
{
$downloadUrl
=
base64_decode
(
$params
);
if
(
!
$downloadUrl
){
throw
new
\Exception
(
'不是有效的下载地址'
);
}
$downloadUrl
=
urldecode
(
$downloadUrl
);
$uriList
=
explode
(
'/'
,
$downloadUrl
);
$filename
=
''
;
foreach
(
$uriList
as
$uri
){
if
(
strstr
(
$uri
,
'.pdf'
)){
$nameList
=
explode
(
'_'
,
str_replace
(
strstr
(
$uri
,
'.pdf'
),
''
,
$uri
));
$filename
=
$nameList
[
1
]
.
'.pdf'
;
}
}
$path
=
config
(
'filesystems.default.root'
)
.
'public/finance/invoice/manual/'
;
$this
->
saveInvoicePdf
(
$path
.
$filename
,
$downloadUrl
);
}
public
function
getInvoiceRecordList
(
$requestParams
)
{
$offset
=
!
isset
(
$requestParams
[
'page_size'
])
||
empty
(
$requestParams
[
'page_size'
])
?
200
:
$requestParams
[
'page_size'
];
if
(
$offset
>
200
){
$offset
=
200
;
}
$pageNo
=
!
isset
(
$requestParams
[
'page_no'
])
||
empty
(
$requestParams
[
'page_no'
])
?
1
:
$requestParams
[
'page_no'
];
$limit
=
$pageNo
==
1
?
0
:
$pageNo
*
$offset
;
try
{
$where
=
[];
if
(
isset
(
$requestParams
[
'invoice_number'
])
&&
!
empty
(
$requestParams
[
'invoice_number'
])){
$where
[
'invoice_number'
]
=
$requestParams
[
'invoice_number'
];
}
if
(
isset
(
$requestParams
[
'invoice_real_number'
])
&&
!
empty
(
$requestParams
[
'invoice_real_number'
])){
$where
[
'invoice_real_number'
]
=
$requestParams
[
'invoice_real_number'
];
}
if
(
isset
(
$requestParams
[
'invoice_platform_id'
])
&&
!
empty
(
$requestParams
[
'invoice_platform_id'
])){
$where
[
'platform_invoice_id'
]
=
$requestParams
[
'invoice_platform_id'
];
}
if
(
isset
(
$requestParams
[
'invoice_created_at'
])
&&
!
empty
(
$requestParams
[
'invoice_created_at'
])){
$where
[
'created_at'
]
=
date
(
'Y-m-d'
,
strtotime
(
$requestParams
[
'invoice_created_at'
]));
}
$invoiceList
=
$this
->
invoiceRecordRepository
->
getList
(
$where
,
$limit
,
$offset
);
if
(
$invoiceList
){
$invoiceList
=
app
(
InvoiceRecordTransformer
::
class
)
->
transform
(
$invoiceList
);
}
$invocieTotal
=
$this
->
invoiceRecordRepository
->
counts
(
$where
);
return
$this
->
invoiceRecordRepository
->
pagePaginate
(
$invoiceList
,
$invocieTotal
,
$requestParams
);
/*$dataReturn = [];
$dataReturn['data'] = $invoiceList;
$dataReturn['total'] = $invocieTotal;
$total = ceil($invocieTotal / $offset) - 1;
$dataReturn['total_page'] = ceil($invocieTotal / $offset) - 1 == 0 ? 1;
$dataReturn['page_no'] = $pageNo;*/
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':'
.
__FUNCTION__
,
'error'
);
throw
$exception
;
}
}
public
function
getInvoiceStatusDetailByInvoiceNumber
(
$requestParams
)
{
if
(
!
isset
(
$requestParams
[
'invoice_number'
])
||
empty
(
$requestParams
[
'invoice_number'
])){
throw
new
\Exception
(
'发票流水号为空'
,
502
);
}
$invoiceResult
=
$this
->
invoiceRecordRepository
->
getInvoiceRecordByNumber
(
$requestParams
);
if
(
!
$invoiceResult
){
throw
new
\Exception
(
'该发票流水号不存在'
,
502
);
}
$invoiceResult
=
current
(
$invoiceResult
);
//查询该发票接口请求参数
$values
=
$this
->
apiService
->
getPlatformDataEntries
(
'invoice_apply_'
.
$requestParams
[
'invoice_number'
],
'data_values'
);
$invoiceResult
=
array_merge
(
$invoiceResult
,[
'params'
=>
$values
]);
return
app
(
InvoiceRecordStatusDetailTransformer
::
class
)
->
transform
([
$invoiceResult
]);
}
public
function
delInvoiceRecord
(
$requestParams
)
{
if
(
!
isset
(
$requestParams
[
'invoice_number'
])
||
empty
(
$requestParams
[
'invoice_number'
])){
throw
new
\Exception
(
'发票流水号为空'
,
502
);
}
$invoiceResult
=
$this
->
invoiceRecordRepository
->
getInvoiceRecordByNumber
(
$requestParams
);
if
(
!
$invoiceResult
){
throw
new
\Exception
(
'该发票流水号不存在'
,
502
);
}
$invoiceResult
=
current
(
$invoiceResult
);
$result
=
$this
->
invoiceRecordRepository
->
delInvoiceByNumber
(
$invoiceResult
[
'invoice_number'
]);
if
(
$result
){
$this
->
apiService
->
removePlatformDataEntries
(
'invoice_apply_'
.
$invoiceResult
[
'invoice_number'
]);
}
return
true
;
}
public
function
manualDownLoadInvoicePdf
(
$params
)
{
$downloadUrl
=
base64_decode
(
$params
);
if
(
!
$downloadUrl
){
throw
new
\Exception
(
'不是有效的下载地址'
);
}
$downloadUrl
=
urldecode
(
$downloadUrl
);
$uriList
=
explode
(
'/'
,
$downloadUrl
);
$filename
=
''
;
foreach
(
$uriList
as
$uri
){
if
(
strstr
(
$uri
,
'.pdf'
)){
$nameList
=
explode
(
'_'
,
str_replace
(
strstr
(
$uri
,
'.pdf'
),
''
,
$uri
));
$filename
=
$nameList
[
1
]
.
'.pdf'
;
}
}
$path
=
config
(
'filesystems.default.root'
)
.
'public/finance/invoice/manual/'
;
$this
->
saveInvoicePdf
(
$path
.
$filename
,
$downloadUrl
);
}
public
function
getInvoiceRecordList
(
$requestParams
)
{
$offset
=
!
isset
(
$requestParams
[
'page_size'
])
||
empty
(
$requestParams
[
'page_size'
])
?
200
:
$requestParams
[
'page_size'
];
if
(
$offset
>
200
){
$offset
=
200
;
}
$pageNo
=
!
isset
(
$requestParams
[
'page_no'
])
||
empty
(
$requestParams
[
'page_no'
])
?
1
:
$requestParams
[
'page_no'
];
$limit
=
$pageNo
==
1
?
0
:
$pageNo
*
$offset
;
try
{
$where
=
[];
if
(
isset
(
$requestParams
[
'invoice_number'
])
&&
!
empty
(
$requestParams
[
'invoice_number'
])){
$where
[
'invoice_number'
]
=
$requestParams
[
'invoice_number'
];
}
if
(
isset
(
$requestParams
[
'invoice_real_number'
])
&&
!
empty
(
$requestParams
[
'invoice_real_number'
])){
$where
[
'invoice_real_number'
]
=
$requestParams
[
'invoice_real_number'
];
}
if
(
isset
(
$requestParams
[
'invoice_platform_id'
])
&&
!
empty
(
$requestParams
[
'invoice_platform_id'
])){
$where
[
'platform_invoice_id'
]
=
$requestParams
[
'invoice_platform_id'
];
}
if
(
isset
(
$requestParams
[
'invoice_created_at'
])
&&
!
empty
(
$requestParams
[
'invoice_created_at'
])){
$where
[
'created_at'
]
=
date
(
'Y-m-d'
,
strtotime
(
$requestParams
[
'invoice_created_at'
]));
}
$invoiceList
=
$this
->
invoiceRecordRepository
->
getList
(
$where
,
$limit
,
$offset
);
if
(
$invoiceList
){
$invoiceList
=
app
(
InvoiceRecordTransformer
::
class
)
->
transform
(
$invoiceList
);
}
$invocieTotal
=
$this
->
invoiceRecordRepository
->
counts
(
$where
);
return
$this
->
invoiceRecordRepository
->
pagePaginate
(
$invoiceList
,
$invocieTotal
,
$requestParams
);
/*$dataReturn = [];
$dataReturn['data'] = $invoiceList;
$dataReturn['total'] = $invocieTotal;
$total = ceil($invocieTotal / $offset) - 1;
$dataReturn['total_page'] = ceil($invocieTotal / $offset) - 1 == 0 ? 1;
$dataReturn['page_no'] = $pageNo;*/
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':'
.
__FUNCTION__
,
'error'
);
throw
$exception
;
}
}
public
function
getInvoiceStatusDetailByInvoiceNumber
(
$requestParams
)
{
if
(
!
isset
(
$requestParams
[
'invoice_number'
])
||
empty
(
$requestParams
[
'invoice_number'
])){
throw
new
\Exception
(
'发票流水号为空'
,
502
);
}
$invoiceResult
=
$this
->
invoiceRecordRepository
->
getInvoiceRecordByNumber
(
$requestParams
);
if
(
!
$invoiceResult
){
throw
new
\Exception
(
'该发票流水号不存在'
,
502
);
}
$invoiceResult
=
current
(
$invoiceResult
);
//查询该发票接口请求参数
$values
=
$this
->
apiService
->
getPlatformDataEntries
(
'invoice_apply_'
.
$requestParams
[
'invoice_number'
],
'data_values'
);
$invoiceResult
=
array_merge
(
$invoiceResult
,[
'params'
=>
$values
]);
return
app
(
InvoiceRecordStatusDetailTransformer
::
class
)
->
transform
([
$invoiceResult
]);
}
public
function
delInvoiceRecord
(
$requestParams
)
{
if
(
!
isset
(
$requestParams
[
'invoice_number'
])
||
empty
(
$requestParams
[
'invoice_number'
])){
throw
new
\Exception
(
'发票流水号为空'
,
502
);
}
$invoiceResult
=
$this
->
invoiceRecordRepository
->
getInvoiceRecordByNumber
(
$requestParams
);
if
(
!
$invoiceResult
){
throw
new
\Exception
(
'该发票流水号不存在'
,
502
);
}
$invoiceResult
=
current
(
$invoiceResult
);
$result
=
$this
->
invoiceRecordRepository
->
delInvoiceByNumber
(
$invoiceResult
[
'invoice_number'
]);
if
(
$result
){
$this
->
apiService
->
removePlatformDataEntries
(
'invoice_apply_'
.
$invoiceResult
[
'invoice_number'
]);
}
return
true
;
}
}
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