Commit 30ce4855 authored by hangjun83's avatar hangjun83

财务开票模块更新

parent 04192fee
......@@ -10,6 +10,7 @@ use App\Finance\Repositories\Eloquent\RhawnInvoiceRepositoryEloquent;
use App\Finance\Services\Api\BaiwangApiService;
use App\Mailer\MailService;
use App\Repositories\Contracts\ThirdApiPlatformRepository;
use App\Repositories\Transformers\Finance\InvoiceRecordStatusDetailTransformer;
use App\Repositories\Transformers\Finance\InvoiceRecordTransformer;
use App\Services\ThirdPlatform\PlatformBaseService;
use App\Support\Facades\SimpleLogs;
......@@ -784,5 +785,22 @@ class InvoiceService
}
}
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);
}
//查询该发票接口请求参数
$values = $this->apiService->getPlatformDataEntries('invoice_apply_'.$requestParams['invoice_number'],'data_values');
return app(InvoiceRecordStatusDetailTransformer::class)->transform(array_merge($invoiceResult,['params' => $values]));
}
}
......@@ -23,7 +23,23 @@ class InvoiceController extends Controller
$requestParams = $this->formatKeysfromArray($request->all(),'toUnderScore');
try{
$result = $this->invoiceService->getInvoiceRecordList($requestParams);
return Response::success($result,'发票申请成功');
return Response::success($result,'获取成功');
}catch(\Throwable $exception){
return $this->returnErrorExecptionResponse($exception,$exception->getMessage());
}
}
public function getInvoiceStatusDetail(Request $request)
{
$message = [
'invoiceNumber.required' => "发票流水号不能为空",
];
$this->validateRequest($request, $message);
$requestParams = $this->formatKeysfromArray($request->all(),'toUnderScore');
try{
$result = $this->invoiceService->getInvoiceStatusDetailByInvoiceNumber($requestParams);
return Response::success($result,'状态详情获取成功');
}catch(\Throwable $exception){
return $this->returnErrorExecptionResponse($exception,$exception->getMessage());
}
......
<?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\Repositories\Transformers\Finance;
use League\Fractal\TransformerAbstract;
class InvoiceRecordStatusDetailTransformer extends TransformerAbstract
{
public function transform($invoice)
{
$invoiceTransReturn = [];
if($invoice){
foreach($invoice as $invo){
$temp = [];
$temp['invoice_number'] = $invo['invoice_number'];
$temp['api_response'] = $invo['invoice_real_number'];
$temp['invoice_status'] = $invo['invoice_status']; //发票状态 0:已申请待确认 1:已确认 2: 发票失败 3:开票作废已申请 4:蓝字发票作废
$temp['request_params'] = $invo['params'];
array_push($invoiceTransReturn,$temp);
}
}
return $invoiceTransReturn;
}
}
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