Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2411f3ea
authored
Apr 08, 2018
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整定时任务,添加取消订单
parent
23bd0904
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
15 deletions
app/Http/Controllers/OrderController.php
app/Http/routes.php
app/Http/Controllers/OrderController.php
View file @
2411f3ea
...
...
@@ -1237,8 +1237,13 @@ Class OrderController extends Controller
return
$response
;
}
// 检查订单付款时间 (状态)
public
function
checkOrderPay
()
/**
* 定时任务:提前一天上午10点
* 检查订单付款时间
* 过滤条件:状态、测试人员、是否是真实数据、付款时间大于当前时间
* @return [type] [description]
*/
public
function
checkOrderSendSms
()
{
$order
=
DB
::
connection
(
'order'
)
->
table
(
'lie_order'
)
...
...
@@ -1260,18 +1265,6 @@ Class OrderController extends Controller
if
(
!
empty
(
$order
))
{
foreach
(
$order
as
$v
)
{
// 到达付款时间后自动取消订单
if
(
$v
->
pay_time
==
time
())
{
$update
=
DB
::
connection
(
'order'
)
->
table
(
'lie_order'
)
->
where
(
'order_id'
,
'='
,
$v
->
order_id
)
->
update
([
'status'
=>
-
1
]);
if
(
$update
)
{
continue
;
}
}
// 提前一天推送消息
$diff
=
$v
->
pay_time
-
time
();
...
...
@@ -1302,4 +1295,37 @@ Class OrderController extends Controller
}
}
// 定时任务:每5分钟
// 付款时间到达后自动取消订单
public
function
checkOrderCancel
()
{
$time
=
strtotime
(
date
(
'Y-m-d'
,
time
()));
// 当天0点
$order
=
DB
::
connection
(
'order'
)
->
table
(
'lie_order'
)
->
whereIn
(
'status'
,
[
'2'
,
'3'
])
->
whereNotIn
(
'user_id'
,
$this
->
testMobile
())
->
where
(
'is_type'
,
'='
,
0
)
->
where
(
'pay_time'
,
'>='
,
$time
)
->
select
(
'order_id'
,
'pay_time'
)
->
orderBy
(
'create_time'
,
'DESC'
)
->
get
();
if
(
!
empty
(
$order
))
{
foreach
(
$order
as
$v
)
{
// 到达付款时间后自动取消订单
if
(
$v
->
pay_time
<=
time
())
{
$update
=
DB
::
connection
(
'order'
)
->
table
(
'lie_order'
)
->
where
(
'order_id'
,
'='
,
$v
->
order_id
)
->
update
([
'status'
=>
-
1
,
'pay_time'
=>
0
]);
if
(
$update
)
{
continue
;
}
}
}
}
}
}
\ No newline at end of file
app/Http/routes.php
View file @
2411f3ea
...
...
@@ -63,6 +63,7 @@ Route::group(['middleware' => 'web'], function () {
// 不需要登陆态
Route
::
group
([
'middleware'
=>
'api'
],
function
()
{
Route
::
get
(
'/api/check/paytime'
,
'OrderController@checkOrderPay'
);
Route
::
get
(
'/api/check/sendsms'
,
'OrderController@checkOrderSendSms'
);
Route
::
get
(
'/api/check/cancelorder'
,
'OrderController@checkOrderCancel'
);
});
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