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
4f74f3b2
Commit
4f74f3b2
authored
Apr 24, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、修复分页功能 2、增加查看日志
parent
6551960b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
10 deletions
+58
-10
server/app/Http/Controllers/V1/BhOrdersController.php
server/app/Http/Controllers/V1/BhOrdersController.php
+22
-2
server/app/Repositories/Eloquent/BaseRepository.php
server/app/Repositories/Eloquent/BaseRepository.php
+35
-8
server/routes/api/tools.php
server/routes/api/tools.php
+1
-0
No files found.
server/app/Http/Controllers/V1/BhOrdersController.php
View file @
4f74f3b2
...
@@ -98,9 +98,14 @@ class BhOrdersController extends Controller
...
@@ -98,9 +98,14 @@ class BhOrdersController extends Controller
*/
*/
public
function
getBhSorderRefundTaskToPage
(
Request
$request
)
public
function
getBhSorderRefundTaskToPage
(
Request
$request
)
{
{
$message
=
[
'type.required'
=>
"类型无效"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
try
{
$
order
=
$this
->
bhOrdersService
->
getSordersRefundTask
(
$request
);
$
task
=
$this
->
bhOrdersService
->
getSordersRefundTask
(
$request
);
return
Response
::
success
(
$
order
,
'添加成功'
);
return
Response
::
success
(
$
task
,
'添加成功'
);
}
catch
(
\Exception
$exception
){
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
...
@@ -145,4 +150,19 @@ class BhOrdersController extends Controller
...
@@ -145,4 +150,19 @@ class BhOrdersController extends Controller
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
}
}
public
function
getSorderRefundTaskLogsToPage
(
Request
$request
)
{
$message
=
[
'taskId.required'
=>
"任务id必填"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$logs
=
$this
->
bhOrdersService
->
getBhSorderTaskLog
(
$request
);
return
Response
::
success
(
$this
->
formatKeysfromArray
(
$logs
),
'操作成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
}
}
server/app/Repositories/Eloquent/BaseRepository.php
View file @
4f74f3b2
...
@@ -13,6 +13,7 @@ namespace App\Repositories\Eloquent;
...
@@ -13,6 +13,7 @@ namespace App\Repositories\Eloquent;
use
App\Repositories\Presenters\Presenter
;
use
App\Repositories\Presenters\Presenter
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Pagination\LengthAwarePaginator
;
use
Prettus\Repository\Eloquent\BaseRepository
as
BaseRepositoryEloquent
;
use
Prettus\Repository\Eloquent\BaseRepository
as
BaseRepositoryEloquent
;
abstract
class
BaseRepository
extends
BaseRepositoryEloquent
abstract
class
BaseRepository
extends
BaseRepositoryEloquent
...
@@ -25,17 +26,16 @@ abstract class BaseRepository extends BaseRepositoryEloquent
...
@@ -25,17 +26,16 @@ abstract class BaseRepository extends BaseRepositoryEloquent
/**
/**
* Retrieve all data of repository, simple paginated.
* Retrieve all data of repository, simple paginated.
*
*
* @param
null|int
$limit
* @param
null|int
$limit
* @param
array
$columns
* @param
array
$columns
* @return mixed
* @return mixed
*/
*/
public
function
cursorPaginate
(
$
current
,
$
limit
=
null
,
$columns
=
[
'*'
])
public
function
cursorPaginate
(
$limit
=
null
,
$columns
=
[
'*'
])
{
{
$this
->
applyCriteria
();
$this
->
applyCriteria
();
$this
->
applyScope
();
$this
->
applyScope
();
$limit
=
is_null
(
$limit
)
?
config
(
'repository.pagination.limit'
,
15
)
:
(
int
)
$limit
;
$limit
=
is_null
(
$limit
)
?
config
(
'repository.pagination.limit'
,
15
)
:
(
int
)
$limit
;
$results
=
$this
->
model
->
select
(
$columns
)
->
limit
(
$limit
)
->
get
();
$results
=
$this
->
model
->
select
(
$columns
)
->
limit
(
$limit
)
->
get
();
if
(
$this
->
model
instanceof
Builder
)
{
if
(
$this
->
model
instanceof
Builder
)
{
...
@@ -46,12 +46,39 @@ abstract class BaseRepository extends BaseRepositoryEloquent
...
@@ -46,12 +46,39 @@ abstract class BaseRepository extends BaseRepositoryEloquent
$count
=
$results
->
count
();
$count
=
$results
->
count
();
$next
=
$count
===
$limit
?
optional
(
$results
->
last
())
->
{
$primaryKey
}
:
null
;
$next
=
$count
===
$limit
?
optional
(
$results
->
last
())
->
{
$primaryKey
}
:
null
;
$this
->
resetModel
();
$dataResult
=
$this
->
parserResult
(
$results
);
$prev
=
request
(
'prev'
);
$page
=
request
(
'page'
)
?:
1
;
$this
->
presenter
->
makeCursor
((
int
)
$current
,
$prev
?
(
int
)
$prev
:
''
,
$next
,
$count
);
//每页的条数
$perPage
=
$limit
;
//计算每页分页的初始位置
$offset
=
(
$page
*
$perPage
)
-
$perPage
;
//实例化Paginator类,(删掉上一步的count($video_list)参数即可 )并传入对应的参数
$data
=
new
LengthAwarePaginator
(
array_slice
(
$dataResult
,
$offset
,
$perPage
,
true
),
count
(
$dataResult
),
$perPage
,
$page
);
return
$data
;
}
$this
->
resetModel
();
return
$this
->
parserResult
(
$results
);
public
function
customPaginate
(
$limit
=
null
,
$columns
=
[
'*'
])
{
$paginateResult
=
$this
->
paginate
(
$limit
,
$columns
);
$dataList
=
[];
// 将model对象转换城数组
foreach
(
$paginateResult
->
items
()
as
$data
){
$dataList
[]
=
$data
->
toArray
();
}
$returnRecord
=
[];
$returnRecord
[
'data'
]
=
$dataList
;
$returnRecord
[
'current_page'
]
=
$paginateResult
->
currentPage
();
$returnRecord
[
'total'
]
=
$paginateResult
->
total
();
$returnRecord
[
'page'
]
=
$paginateResult
->
currentPage
()
+
1
;
if
(
$returnRecord
[
'page'
]
>=
$paginateResult
->
lastPage
()){
$returnRecord
[
'page'
]
=
$paginateResult
->
lastPage
();
}
return
$returnRecord
;
}
}
}
}
server/routes/api/tools.php
View file @
4f74f3b2
...
@@ -24,6 +24,7 @@ $api->version('v1', function($api) {
...
@@ -24,6 +24,7 @@ $api->version('v1', function($api) {
$api
->
post
(
'/adminapi/tools/bh/getBhSordersDetail'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@getBhSordersDetail'
]);
$api
->
post
(
'/adminapi/tools/bh/getBhSordersDetail'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@getBhSordersDetail'
]);
$api
->
get
(
'/adminapi/tools/bh/getBhSorderRefundTask'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@getBhSorderRefundTaskToPage'
]);
$api
->
get
(
'/adminapi/tools/bh/getBhSorderRefundTask'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@getBhSorderRefundTaskToPage'
]);
$api
->
post
(
'/adminapi/tools/bh/execBhSorderRefundTask'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@execBhSorderRefundTask'
]);
$api
->
post
(
'/adminapi/tools/bh/execBhSorderRefundTask'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@execBhSorderRefundTask'
]);
$api
->
get
(
'/adminapi/tools/bh/getSorderRefundTaskLogs'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@getSorderRefundTaskLogs'
]);
});
});
...
...
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