|
|
@@ -41,25 +41,26 @@ class CheckOrderExpire extends Command
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
- $date = date('Y-m-d H:i:s', time() - 1800);//30分钟
|
|
|
+ while (true){
|
|
|
+ $date = date('Y-m-d H:i:s', time() - 1800);//30分钟
|
|
|
|
|
|
- Order::where('order_status', 1)
|
|
|
- ->where('created_at', '<=', $date)
|
|
|
- ->chunkById(100,function ($list){
|
|
|
- foreach ($list as $item){
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- //取消订单
|
|
|
- Order::where('id',$item->{'id'})->update(['order_status'=>3]);
|
|
|
+ Order::where('order_status', 1)
|
|
|
+ ->where('created_at', '<=', $date)
|
|
|
+ ->chunkById(100,function ($list){
|
|
|
+ foreach ($list as $item){
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ //取消订单
|
|
|
+ Order::where('id',$item->{'id'})->update(['order_status'=>3]);
|
|
|
|
|
|
- DB::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
- DB::rollBack();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
+ DB::commit();
|
|
|
+ }catch (\Exception $e){
|
|
|
+ DB::rollBack();
|
|
|
+ }
|
|
|
|
|
|
- return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ sleep(5);
|
|
|
+ }
|
|
|
}
|
|
|
}
|