123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Jobs;
- use App\Handlers\BaseBikeControl;
- use App\Handlers\BikeControl;
- use App\Handlers\BikeStatusInfoSyncHandler;
- use App\Models\Bike;
- use App\Models\LocationsLog;
- use Carbon\Carbon;
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Support\Facades\Log;
- class CloseBikeJob implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $bike;
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(Bike $bike)
- {
- $this->bike = $bike;
- $this->delay(Carbon::now()->addMinutes(30));
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $bike_no = $this->bike->bike_no;
- $box_no = $this->bike->box_no;
- $order = (new BikeStatusInfoSyncHandler())->getRideBikeOrderInfo($bike_no);
- if (isset($order['role']) && in_array($order['role'], [BikeStatusInfoSyncHandler::ROLE_BIND, BikeStatusInfoSyncHandler::ROLE_WORKER])) {
- $bike_location = LocationsLog::getNewestLocationByBikeNo($bike_no);
- (new BikeStatusInfoSyncHandler())->toBikeWaitRideStatus($bike_no, $bike_location['lng'], $bike_location['lat'], $this->bike->put_status);
- (new BaseBikeControl($box_no))::closeLock();
- }
- return;
- }
- }
|