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
98c98588
Commit
98c98588
authored
Apr 06, 2023
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发票相关接口
parent
19ce92a9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
305 additions
and
5 deletions
+305
-5
server/app/Finance/Repositories/Eloquent/RhawnInvoiceItemsRepositoryEloquent.php
...sitories/Eloquent/RhawnInvoiceItemsRepositoryEloquent.php
+17
-0
server/app/Http/Controllers/V1/Rhawn/InvoiceController.php
server/app/Http/Controllers/V1/Rhawn/InvoiceController.php
+104
-0
server/app/Rhawn/Repositories/Contracts/RhawnInvoiceRepository.php
...p/Rhawn/Repositories/Contracts/RhawnInvoiceRepository.php
+21
-0
server/app/Rhawn/Repositories/Eloquent/RhawnInvoiceRepositoryEloquent.php
.../Repositories/Eloquent/RhawnInvoiceRepositoryEloquent.php
+34
-0
server/app/Rhawn/Repositories/Eloquent/RhawnSoitemsRepositoryEloquent.php
.../Repositories/Eloquent/RhawnSoitemsRepositoryEloquent.php
+8
-4
server/app/Rhawn/Repositories/Models/RhawnInvoice.php
server/app/Rhawn/Repositories/Models/RhawnInvoice.php
+60
-0
server/app/Rhawn/Services/RhawnOrdersService.php
server/app/Rhawn/Services/RhawnOrdersService.php
+1
-0
server/app/Services/Api/BhuaProductsService.php
server/app/Services/Api/BhuaProductsService.php
+1
-1
server/app/Services/Api/RhawnInvoicesService.php
server/app/Services/Api/RhawnInvoicesService.php
+55
-0
server/routes/api/rhawn.php
server/routes/api/rhawn.php
+4
-0
No files found.
server/app/Finance/Repositories/Eloquent/RhawnInvoiceItemsRepositoryEloquent.php
View file @
98c98588
...
...
@@ -39,4 +39,21 @@ class RhawnInvoiceItemsRepositoryEloquent extends BaseRepository implements Rhaw
return
$invoiceItemInfo
;
}
public
function
getInvoiceSorderItemsBySoItemsId
(
$itemId
)
{
$invoiceItemInfo
=
null
;
$invoiceItemInfo
=
$this
->
join
(
'dpdetail'
,
'dpdetail.dpd_id'
,
'soidetail.dpd_id'
)
->
join
(
'soitems'
,
'soitems.si_id'
,
'dpdetail.si_id'
)
->
join
(
'sorders'
,
'sorders.so_id'
,
'soitems.so_id'
)
->
join
(
'products'
,
'products.p_id'
,
'soitems.p_id'
)
->
whereIn
(
'soidetail.soid_id'
,
$itemId
)
/*->select(
'soidetail.soi_id','soidetail.soid_id', 'soidetail.soid_amount', 'dpdetail.dpd_num',
'products.p_code', 'products.p_cn_name', 'products.p_pack', 'products.p_pack_unit', 'products.p_price'
)*/
->
get
()
->
toArray
();
return
$invoiceItemInfo
;
}
}
server/app/Http/Controllers/V1/Rhawn/InvoiceController.php
0 → 100644
View file @
98c98588
<?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\Http\Controllers\V1\Rhawn
;
use
App\Services\Api\RhawnInvoicesService
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
use
App\Http\Controllers\V1\Controller
;
use
App\Support\Traits\Helpers
;
use
OpenApi\Annotations\Post
;
use
OpenApi\Annotations\RequestBody
;
use
OpenApi\Annotations\MediaType
;
use
OpenApi\Annotations\Schema
;
use
OpenApi\Annotations\Property
;
use
OpenApi\Annotations\Response
as
AnnotationResponse
;
use
OpenApi\Annotations
as
OA
;
class
InvoiceController
extends
Controller
{
use
Helpers
;
public
function
__construct
(
RhawnInvoicesService
$rhawnInvoicesService
)
{
$this
->
rhawnInvoicesService
=
$rhawnInvoicesService
;
$this
->
controllerType
=
'rhawn'
;
}
/**
* @Post(
* path="/openapi/rhawn/invoice/getInvoiceSorderItems",
* tags={"罗恩 - 发票相关接口"},
* summary="发票订单列表数据",
* description="发票订单列表",
* @RequestBody(
* @MediaType(
* mediaType="application/json",
* @Schema(
* required={"invoiceNumber"},
* @Property(property="invoiceNumber", @Schema(type="string"),description="返回数据集数量"),
* example={"invoiceNumber" : 0999899011}
* ),
* )
* ),
* @OA\Parameter(
* description="用户获取的token值",
* in="header",
* name="authorization",
* required=true,
* @OA\Schema(type="string"),
* @OA\Examples(example="authorization", value="bearerNWJiNDhkNzlmNjg0N2FlMmZiYjliZWM3NGVkNzIyMjNleUpsZUhCcGNtVWlPakUyTmpRMk1EazJORGNzSW1oaGMyZ2lPaUl5ZEhsc1JIQlhkWFpNUVdaWGJVRllJbjA9",summary=""),
* ),
* @AnnotationResponse(
* response="200",
* description="正常操作响应",
* @MediaType(
* mediaType="application/json",
* @Schema(
* allOf={
* @Schema(ref="#/components/schemas/ApiResponse"),
* @Schema(
* type="object",
* @Property(property="data", ref="#/components/schemas/invoiceOrderItemsList")
* )
* }
* )
* )
* ),
* security={
* {"bearer_token":{}}
* }
* )
*/
public
function
getInvoiceSorderItems
(
Request
$request
)
{
$customerCode
=
$request
->
get
(
'customer_code'
);
if
(
!
$customerCode
){
return
Response
::
ok
(
'客户编号不存在!'
);
}
$this
->
checkCustomerType
(
$customerCode
,
$this
->
controllerType
);
$requestParams
=
$this
->
formatKeysfromArray
(
$request
->
all
(),
'toUnderScore'
);
$requestParams
=
array_merge
(
$requestParams
,[
'customer_code'
=>
$customerCode
]);
try
{
$orderList
=
$this
->
rhawnInvoicesService
->
getInoviceItems
(
$requestParams
);
if
(
$orderList
){
$orderList
=
$this
->
formatKeysfromArray
(
$orderList
,
'toCamelCase'
);
}
return
Response
::
success
(
$orderList
,
'操作成功'
);
}
catch
(
\Throwable
$exception
){
return
$this
->
returnErrorExecptionResponse
(
$exception
,
'获取订单列表失败'
);
}
}
}
server/app/Rhawn/Repositories/Contracts/RhawnInvoiceRepository.php
0 → 100644
View file @
98c98588
<?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\Rhawn\Repositories\Contracts
;
use
Prettus\Repository\Contracts\RepositoryInterface
;
/**
* Interface UserRepository.
*/
interface
RhawnInvoiceRepository
extends
RepositoryInterface
{
}
server/app/Rhawn/Repositories/Eloquent/RhawnInvoiceRepositoryEloquent.php
0 → 100644
View file @
98c98588
<?php
namespace
App\Rhawn\Repositories\Eloquent
;
use
App\Rhawn\Repositories\Contracts\RhawnInvoiceRepository
;
use
App\Rhawn\Repositories\Models\RhawnInvoice
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Validation\Rules\In
;
class
RhawnInvoiceRepositoryEloquent
extends
BaseRepository
implements
RhawnInvoiceRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public
function
model
()
{
return
RhawnInvoice
::
class
;
}
public
function
getInvoiceItemsByInvoiceNumber
(
$invoiceNumber
)
{
$invoiceDetailInfo
=
$this
->
join
(
'soidetail'
,
'soinvoice.soi_id'
,
'soidetail.soi_id'
)
->
where
(
'soinvoice.soi_no'
,
'='
,
$invoiceNumber
)
->
get
()
->
toArray
();
if
(
!
$invoiceDetailInfo
){
return
null
;
}
return
$invoiceDetailInfo
;
}
}
server/app/Rhawn/Repositories/Eloquent/RhawnSoitemsRepositoryEloquent.php
View file @
98c98588
...
...
@@ -54,8 +54,12 @@ class RhawnSoitemsRepositoryEloquent extends BaseRepository implements RhawnSoit
->
join
(
'sorders'
,
'sorders.so_id'
,
'soitems.so_id'
)
->
join
(
'products'
,
'soitems.p_id'
,
'products.p_id'
)
->
join
(
'chemicals'
,
'products.c_id'
,
'chemicals.c_id'
)
->
join
(
'brands'
,
'products.b_id'
,
'brands.b_id'
)
->
where
(
'soitems.si_id'
,
$itemId
);
->
join
(
'brands'
,
'products.b_id'
,
'brands.b_id'
);
if
(
is_array
(
$itemId
)){
$soItems
->
whereIn
(
'soitems.si_id'
,
$itemId
);
}
else
{
$soItems
->
where
(
'soitems.si_id'
,
$itemId
);
}
if
(
!
is_null
(
$pid
)){
$soItems
=
$soItems
->
where
(
'soitems.p_id'
,
$pid
);
}
...
...
@@ -74,10 +78,10 @@ class RhawnSoitemsRepositoryEloquent extends BaseRepository implements RhawnSoit
*/
public
function
getSorderItemFromItemId
(
$si_id
)
{
$item
=
$this
->
find
(
$si_id
);
/*
$item = $this->find($si_id);
if(!$item){
throw new \LogicException('该订单项不存在!',500);
}
}
*/
//查询订单的详情
$soModel
=
RhawnSoitems
::
query
()
...
...
server/app/Rhawn/Repositories/Models/RhawnInvoice.php
0 → 100644
View file @
98c98588
<?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\Rhawn\Repositories\Models
;
use
App\Repositories\Models\Model
;
class
RhawnInvoice
extends
Model
{
// 销售订单
protected
$table
=
'soinvoice'
;
protected
$connection
=
'rhawn_mysql'
;
protected
$primaryKey
=
'soi_id'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
];
protected
$guarded
=
[
'created_at'
,
'updated_at'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected
$hidden
=
[
];
/**
* update时不做自动更新时间操作
* @return null
*/
public
function
getUpdatedAtColumn
()
{
return
null
;
}
public
function
getCreatedAtColumn
()
{
return
null
;
}
}
\ No newline at end of file
server/app/Rhawn/Services/RhawnOrdersService.php
View file @
98c98588
...
...
@@ -23,6 +23,7 @@ class RhawnOrdersService
public
function
__construct
()
{
$this
->
rhawnSorderRepository
=
app
(
RhawnSordersRepositoryEloquent
::
class
);
$this
->
rhawnSorderItemsRepository
=
app
(
RhawnSoitemsRepositoryEloquent
::
class
);
}
public
function
getCustomerOrderItems
(
$cusCode
,
$soItems
)
...
...
server/app/Services/Api/BhuaProductsService.php
View file @
98c98588
...
...
@@ -95,8 +95,8 @@ class BhuaProductsService
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':getProductsByBrandId'
,
'error'
);
throw
$exception
;
}
}
}
}
server/app/Services/Api/RhawnInvoicesService.php
0 → 100644
View file @
98c98588
<?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\Services\Api
;
use
App\Finance\Services\InvoiceService
;
use
App\Rhawn\Repositories\Eloquent\RhawnInvoiceRepositoryEloquent
;
use
Illuminate\Support\Facades\DB
;
class
RhawnInvoicesService
{
public
function
__construct
(
InvoiceService
$invoiceService
)
{
$this
->
rhawnOrdersService
=
app
(
\App\Rhawn\Services\RhawnOrdersService
::
class
);
$this
->
invoiceService
=
$invoiceService
;
$this
->
invoiceRepository
=
app
(
RhawnInvoiceRepositoryEloquent
::
class
);
}
public
function
getInoviceItems
(
$requestParams
)
{
if
(
!
isset
(
$requestParams
[
'invoice_real_number'
])
||
empty
(
$requestParams
[
'invoice_real_number'
])){
throw
new
\Exception
(
'发票号码为空'
,
502
);
}
$invoiceRecord
=
$this
->
invoiceService
->
invoiceRecordRepository
->
getInvoiceRecordByRealNumber
(
$requestParams
[
'invoice_real_number'
]);
if
(
!
$invoiceRecord
){
throw
new
\Exception
(
'该发票号码无效'
,
502
);
}
$invoiceRecord
=
current
(
$invoiceRecord
);
switch
(
$invoiceRecord
[
'invoice_platform'
]){
case
'rhawn'
:
$invoiceItems
=
$this
->
invoiceRepository
->
getInvoiceItemsByInvoiceNumber
(
$invoiceRecord
[
'invoice_real_number'
]);
break
;
}
if
(
!
$invoiceItems
){
throw
new
\Exception
(
'无法查询该发票号对应明细'
,
502
);
}
$invoiceItemsId
=
[];
foreach
(
$invoiceItems
as
$item
){
$invoiceItemsId
[]
=
$item
[
'soid_id'
];
}
$sorderItems
=
$this
->
rhawnOrdersService
->
rhawnSorderItemsRepository
->
getInvoiceSorderItemsBySoItemsId
(
$invoiceItemsId
);
var_dump
(
$sorderItems
);
exit
;
}
}
server/routes/api/rhawn.php
View file @
98c98588
...
...
@@ -36,6 +36,10 @@ $api->version('v1', function($api) {
$api
->
post
(
'/openapi/rhawn/products/getProductByCas'
,
[
'permission'
=>
'orders.getProductByCas'
,
'uses'
=>
'ProductsController@getProductByCas'
]);
});
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Rhawn'
,
'middleware'
=>
[
'throttle:60,1'
,
'apiAuth'
],
'providers'
=>
'jwt'
],
function
(
$api
)
{
$api
->
post
(
'/openapi/rhawn/invoice/getInvoiceSorderItems'
,
[
'permission'
=>
'orders.getInvoiceSorderItems'
,
'uses'
=>
'InvoiceController@getInvoiceSorderItems'
]);
});
// 百化接口
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Bhua'
,
'middleware'
=>
[
'throttle:60,1'
,
'apiAuth'
],
'providers'
=>
'jwt'
],
function
(
$api
)
{
// 新建订单
...
...
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