Commit 2411f3ea by 朱继来

调整定时任务,添加取消订单

parent 23bd0904
......@@ -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
......@@ -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');
});
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 sign in to comment