Commit c2fa8bed authored by hangjun83's avatar hangjun83

财务开票模块更新

parent f5761843
...@@ -10,6 +10,7 @@ use App\Finance\Repositories\Eloquent\RhawnInvoiceRepositoryEloquent; ...@@ -10,6 +10,7 @@ use App\Finance\Repositories\Eloquent\RhawnInvoiceRepositoryEloquent;
use App\Finance\Services\Api\BaiwangApiService; use App\Finance\Services\Api\BaiwangApiService;
use App\Mailer\MailService; use App\Mailer\MailService;
use App\Repositories\Contracts\ThirdApiPlatformRepository; use App\Repositories\Contracts\ThirdApiPlatformRepository;
use App\Repositories\Transformers\Finance\InvoiceRecordTransformer;
use App\Services\ThirdPlatform\PlatformBaseService; use App\Services\ThirdPlatform\PlatformBaseService;
use App\Support\Facades\SimpleLogs; use App\Support\Facades\SimpleLogs;
use App\Support\Traits\Helpers; use App\Support\Traits\Helpers;
...@@ -754,4 +755,34 @@ class InvoiceService ...@@ -754,4 +755,34 @@ class InvoiceService
} }
public function getInvoiceRecordList($requestParams)
{
$offset = !isset($requestParams['page_size']) || empty($requestParams['page_size']) ? 2000 : $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 = [];
$invoiceList = $this->invoiceRecordRepository->getList($where,$offset,$limit);
$invocieTotal = 0;
if($invoiceList){
$invoiceList = app(InvoiceRecordTransformer::class)->transform($invoiceList);
$invocieTotal = $this->invoiceRecordRepository->count($where);
}
$dataReturn = [];
$dataReturn['data'] = $invoiceList;
$dataReturn['total_page'] = ceil($invocieTotal / $offset);
$dataReturn['page_no'] = $pageNo;
return $dataReturn;
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':'.__FUNCTION__,'error');
throw $exception;
}
}
} }
<?php
namespace App\Http\Controllers\V1\Finance\Front;
use App\Finance\Services\InvoiceService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Jiannei\Response\Laravel\Support\Facades\Response;
use App\Http\Controllers\V1\Controller;
use App\Support\Traits\Helpers;
class InvoiceController extends Controller
{
use Helpers;
public function __construct(InvoiceService $invoiceService)
{
$this->invoiceService = $invoiceService;
}
public function getInvoiceRecordList(Request $request)
{
$requestParams = $this->formatKeysfromArray($request->all(),'toUnderScore');
try{
$result = $this->invoiceService->getInvoiceRecordList($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 InvoiceRecordTransformer extends TransformerAbstract
{
public function transform($invoice)
{
$invoiceTransReturn = [];
if($invoice){
foreach($invoice as $invo){
$temp = [];
$temp['invoice_number'] = $invo['invoice_number'];
$temp['invoice_real_number'] = $invo['invoice_real_number'];
$temp['invoice_type'] = $invo['invoice_type'] == 1 ? 'blue' : 'red';
$temp['invoice_status'] = $invo['invoice_status']; //发票状态 0:已申请待确认 1:已确认 2: 发票失败 3:开票作废已申请 4:蓝字发票作废
$temp['invoice_money'] = $invo['invoice_money'];
$temp['invoice_platform'] = $invo['invoice_platform'];
$temp['invoice_platform_id'] = $invo['invoice_platform_id'];
$temp['invoice_creater_by'] = $invo['invoice_creater_by'];
$temp['invoice_category'] = $invo['invoice_category'];
$temp['invoice_items'] = $invo['invoice_items'];
$temp['invoice_customer'] = $invo['invoice_customer'];
$temp['invoice_real_date'] = date('Y-m-d H:i:s',$invo['invoice_real_date']);
$temp['invoice_pdf_url'] = $invo['invoice_pdf_url'];
$temp['invoice_created_at'] = $invo['invoice_created_at'];
$temp['invoice_updated_at'] = $invo['invoice_updated_at'];
array_push($invoiceTransReturn,$temp);
}
}
return $invoiceTransReturn;
}
}
...@@ -13,7 +13,7 @@ class CreateFinanceInvoicesRecordUpdateApiResponseTable extends Migration ...@@ -13,7 +13,7 @@ class CreateFinanceInvoicesRecordUpdateApiResponseTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::create('finance_invoices_record', function (Blueprint $table) { Schema::create('finance_invoice_record', function (Blueprint $table) {
$table->text('api_response')->nullable()->comment('api返回接口'); $table->text('api_response')->nullable()->comment('api返回接口');
}); });
} }
...@@ -25,7 +25,7 @@ class CreateFinanceInvoicesRecordUpdateApiResponseTable extends Migration ...@@ -25,7 +25,7 @@ class CreateFinanceInvoicesRecordUpdateApiResponseTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::create('finance_invoices_record', function (Blueprint $table) { Schema::create('finance_invoice_record', function (Blueprint $table) {
$table->dropColumn('api_response'); $table->dropColumn('api_response');
}); });
} }
......
...@@ -23,5 +23,9 @@ $api->version('v1', function($api) { ...@@ -23,5 +23,9 @@ $api->version('v1', function($api) {
$api->post('/finance/invoice/downloadInvoice', ['permission' => 'finance.downloadInvoice', 'uses'=>'InvoiceController@downloadInvoice']); $api->post('/finance/invoice/downloadInvoice', ['permission' => 'finance.downloadInvoice', 'uses'=>'InvoiceController@downloadInvoice']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Finance\Front','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/finance/invoice/getInvoiceRecordList', ['permission' => 'finance.getInvoiceRecordList', 'uses'=>'InvoiceController@getInvoiceRecordList']);
});
}); });
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