35 lines
		
	
	
		
			1021 B
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			35 lines
		
	
	
		
			1021 B
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								declare (strict_types = 1);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace app\subscribe;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\model\Order AS OrderModel;
							 | 
						||
| 
								 | 
							
								use app\repository\OrderRepository;
							 | 
						||
| 
								 | 
							
								use think\facade\Log;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class Order
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    public function onOrderCheck()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        Log::info('触发事件');
							 | 
						||
| 
								 | 
							
								        $day = 3;//自动收货时间 发货后N天
							 | 
						||
| 
								 | 
							
								        $expiredList = OrderRepository::getInstance()->expiredList();
							 | 
						||
| 
								 | 
							
								        $needAcceptList = OrderRepository::getInstance()->autoReceiptList($day);
							 | 
						||
| 
								 | 
							
								//        var_dump($expiredList->isEmpty());
							 | 
						||
| 
								 | 
							
								//        var_dump($needAcceptList->isEmpty());
							 | 
						||
| 
								 | 
							
								//        exit;
							 | 
						||
| 
								 | 
							
								        if (!$expiredList->isEmpty()) {
							 | 
						||
| 
								 | 
							
								            OrderModel::whereIn('id', $expiredList->column('id'))->save([
							 | 
						||
| 
								 | 
							
								                'status' => OrderModel::STATUS_EXPIRED,
							 | 
						||
| 
								 | 
							
								            ]);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        if (!$needAcceptList->isEmpty()) {
							 | 
						||
| 
								 | 
							
								            OrderModel::whereIn('id', $needAcceptList->column('id'))->save([
							 | 
						||
| 
								 | 
							
								                'status' => OrderModel::STATUS_COMPLETED,
							 | 
						||
| 
								 | 
							
								                'completed_at' => date('Y-m-d H:i:s'),
							 | 
						||
| 
								 | 
							
								            ]);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |