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
c3d63752
Commit
c3d63752
authored
Feb 22, 2023
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
财务开票模块更新
parent
d60851ca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
67 deletions
+74
-67
server/app/Finance/Repositories/Eloquent/InvoiceRecordRepositoryEloquent.php
...Repositories/Eloquent/InvoiceRecordRepositoryEloquent.php
+6
-0
server/app/Finance/Repositories/Eloquent/RhawnInvoiceRepositoryEloquent.php
.../Repositories/Eloquent/RhawnInvoiceRepositoryEloquent.php
+1
-1
server/app/Finance/Services/Api/BaiwangApiService.php
server/app/Finance/Services/Api/BaiwangApiService.php
+9
-57
server/app/Finance/Services/InvoiceService.php
server/app/Finance/Services/InvoiceService.php
+46
-9
server/app/Http/Controllers/V1/Finance/InvoiceController.php
server/app/Http/Controllers/V1/Finance/InvoiceController.php
+12
-0
No files found.
server/app/Finance/Repositories/Eloquent/InvoiceRecordRepositoryEloquent.php
View file @
c3d63752
...
...
@@ -44,4 +44,10 @@ class InvoiceRecordRepositoryEloquent extends BaseRepository implements InvoiceR
return
$result
;
}
public
function
getInvoiceRecordByRealNumber
(
$realNumber
)
{
$result
=
$this
->
getList
([
'invoice_real_number'
=>
$realNumber
]);
return
$result
;
}
}
server/app/Finance/Repositories/Eloquent/RhawnInvoiceRepositoryEloquent.php
View file @
c3d63752
...
...
@@ -27,7 +27,7 @@ class RhawnInvoiceRepositoryEloquent extends BaseRepository implements RhawnInvo
{
$invoice
=
$this
->
where
(
'soi_id'
,
$id
)
->
get
()
->
toArray
();
if
(
$invoice
){
return
$invoice
;
return
current
(
$invoice
)
;
}
return
null
;
}
...
...
server/app/Finance/Services/Api/BaiwangApiService.php
View file @
c3d63752
...
...
@@ -38,14 +38,11 @@ class BaiwangApiService extends PlatformAbstractService
}
}
public
function
queryOrder
(
$params
=
[]
)
public
function
queryOrder
(
$params
)
{
try
{
if
(
$this
->
checkPlatformStatus
()){
$queryParams
=
[
'qyId'
=>
'23020214385104316'
,
'ddlsh'
=>
'15382750'
];
$queryParams
=
$params
;
$response
=
$this
->
sendPost
(
$this
->
getPlatformApiUrl
()
.
'/cloud/queryOrder'
,
$queryParams
);
return
$this
->
response
(
$response
);
}
...
...
@@ -66,9 +63,7 @@ class BaiwangApiService extends PlatformAbstractService
if
(
$this
->
checkPlatformStatus
()){
$requestParams
=
$params
;
$response
=
$this
->
sendPost
(
$this
->
getPlatformApiUrl
()
.
'/cloud/applyElecInvoice'
,
$requestParams
);
$token
=
$this
->
response
(
$response
);
return
$token
[
'data'
];
return
$this
->
response
(
$response
);
}
}
catch
(
\Throwable
$exception
){
...
...
@@ -85,14 +80,9 @@ class BaiwangApiService extends PlatformAbstractService
{
try
{
if
(
$this
->
checkPlatformStatus
()){
$tokenParams
=
[
'accessId'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessId'
],
'accessSecret'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessSecret'
]
];
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/openApi/v1/token'
,
$tokenParams
);
$token
=
$this
->
apiResponse
(
$response
);
return
$token
[
'data'
];
$requestParams
=
$params
;
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/cloud/elecInvoiceCancel'
,
$requestParams
);
return
$this
->
response
(
$response
);
}
}
catch
(
\Exception
$exception
){
...
...
@@ -107,21 +97,6 @@ class BaiwangApiService extends PlatformAbstractService
*/
public
function
cancelElecRedInvoice
(
$params
)
{
try
{
if
(
$this
->
checkPlatformStatus
()){
$tokenParams
=
[
'accessId'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessId'
],
'accessSecret'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessSecret'
]
];
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/openApi/v1/token'
,
$tokenParams
);
$token
=
$this
->
apiResponse
(
$response
);
return
$token
[
'data'
];
}
}
catch
(
\Exception
$exception
){
return
$this
->
exception
(
$exception
);
}
}
/**
...
...
@@ -131,21 +106,6 @@ class BaiwangApiService extends PlatformAbstractService
*/
public
function
queryRedInvoiceConfirmState
(
$params
)
{
try
{
if
(
$this
->
checkPlatformStatus
()){
$tokenParams
=
[
'accessId'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessId'
],
'accessSecret'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessSecret'
]
];
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/openApi/v1/token'
,
$tokenParams
);
$token
=
$this
->
apiResponse
(
$response
);
return
$token
[
'data'
];
}
}
catch
(
\Exception
$exception
){
return
$this
->
exception
(
$exception
);
}
}
...
...
@@ -158,14 +118,9 @@ class BaiwangApiService extends PlatformAbstractService
{
try
{
if
(
$this
->
checkPlatformStatus
()){
$tokenParams
=
[
'accessId'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessId'
],
'accessSecret'
=>
$this
->
platformInfo
[
'platform_params'
][
'prod_accessSecret'
]
];
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/openApi/v1/token'
,
$tokenParams
);
$token
=
$this
->
apiResponse
(
$response
);
return
$token
[
'data'
];
$requestParams
=
$params
;
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/cloud/invoiceDownload'
,
$requestParams
);
return
$this
->
response
(
$response
);
}
}
catch
(
\Exception
$exception
){
...
...
@@ -206,9 +161,6 @@ class BaiwangApiService extends PlatformAbstractService
$options
[
'body'
]
=
$this
->
requestParamsEncode
(
$paramsBody
);
var_dump
(
$this
->
requestParamsEncode
(
$paramsBody
));
exit
;
list
(
$url
,
$method
)
=
explode
(
$this
->
platformInfo
[
'platform_url'
],
$uri
);
// auth签名
$header
=
array_merge
(
$header
,
$this
->
authHeaders
(
$method
));
...
...
server/app/Finance/Services/InvoiceService.php
View file @
c3d63752
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Finance\Services
;
use
App\Finance\Repositories\Contracts\InvoiceRecordRepository
;
...
...
@@ -231,7 +222,53 @@ class InvoiceService
public
function
cancelBlueInvoice
()
{
if
(
!
isset
(
$invoiceParams
[
'invoice_platform'
])
||
empty
(
$invoiceParams
[
'invoice_platform'
])){
throw
new
\Exception
(
'开票平台不存在'
,
502
);
}
if
(
!
isset
(
$invoiceParams
[
'invoice_real_number'
])
||
empty
(
$invoiceParams
[
'invoice_real_number'
])){
throw
new
\Exception
(
'发票号码不存在'
,
502
);
}
if
(
!
isset
(
$invoiceParams
[
'invoice_cancel_by'
])
||
empty
(
$invoiceParams
[
'invoice_cancel_by'
])){
throw
new
\Exception
(
'发票作废人不存在'
,
502
);
}
if
(
!
isset
(
$invoiceParams
[
'invoice_platform'
])
||
empty
(
$invoiceParams
[
'invoice_platform'
])){
throw
new
\Exception
(
'开票平台不存在'
,
502
);
}
if
(
!
in_array
(
$invoiceParams
[
'invoice_platform'
],[
'rhawn'
,
'bhua'
])){
throw
new
\Exception
(
'开票平台不在允许范围内'
,
502
);
}
//查询发票号码对应的数据
$invoiceInfo
=
$this
->
invoiceRecordRepository
->
getInvoiceRecordByRealNumber
(
$invoiceParams
[
'invoice_real_number'
]);
if
(
!
$invoiceInfo
){
throw
new
\Exception
(
'发票数据不存在'
,
502
);
}
if
(
$invoiceInfo
[
'invoice_status'
]
!=
1
){
throw
new
\Exception
(
'该发票不是确认状态,无法作废'
,
502
);
}
$platformInfo
=
$this
->
apiService
->
getPlatformInfo
()[
'platform_params'
][
$invoiceParams
[
'invoice_platform'
]];
$cancelInvoiceParams
=
[];
$cancelInvoiceParams
[
'qyId'
]
=
$platformInfo
[
'qyid'
];
$cancelInvoiceParams
[
'ddlsh'
]
=
$invoiceInfo
[
'invoice_number'
];
$cancelInvoiceParams
[
'dlzh'
]
=
$platformInfo
[
'nsrsbh'
];
$cancelInvoiceParams
[
'zfr'
]
=
$invoiceParams
[
'invoice_real_number'
];
//记录请求参数
$this
->
apiService
->
storePlatformDataEntries
(
'invoice_cancel_'
.
$invoiceInfo
[
'invoice_number'
]
.
'_'
.
$invoiceInfo
[
'invoice_real_number'
],
$cancelInvoiceParams
);
$response
=
$this
->
apiService
->
cancelElecInvoice
(
$cancelInvoiceParams
);
if
(
$response
){
$this
->
invoiceRecordRepository
->
saveInvoice
([
'invoice_number'
=>
$invoiceInfo
[
'invoice_number'
],
'invoice_status'
=>
2
]);
return
true
;
}
throw
new
\Exception
(
'发票作废失败'
,
502
);
}
public
function
confirmRedInvoice
()
...
...
server/app/Http/Controllers/V1/Finance/InvoiceController.php
View file @
c3d63752
...
...
@@ -29,6 +29,18 @@ class InvoiceController extends Controller
}
}
public
function
cancelInvoice
(
Request
$request
)
{
$requestParams
=
$this
->
formatKeysfromArray
(
$request
->
all
(),
'toUnderScore'
);
try
{
$result
=
$this
->
invoiceService
->
cancelBlueInvoice
(
$requestParams
);
return
Response
::
success
(
$result
,
'发票作废申请成功'
);
}
catch
(
\Throwable
$exception
){
return
$this
->
returnErrorExecptionResponse
(
$exception
,
$exception
->
getMessage
());
}
}
public
function
baiwangInvoiceCallBack
(
Request
$request
)
{
$requestContent
=
$request
->
getContent
();
...
...
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