<?php

namespace App\Console\Commands\MeiTu;

use App\Jobs\PartnerCallbackJob;
use App\Models\Partner\PartnerBeautyUser;
use Illuminate\Console\Command;

class CallbackCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'meitu:callback';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '美图优化的回滚';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $partners = PartnerBeautyUser::where('replaced_at', '>', 0)
            ->where('callback_at', 0)
            ->where('original_photo', '<>', '')
            ->where('new_photo', '<>', '')
            ->pluck('id');
        foreach ($partners as $id) {
            PartnerCallbackJob::dispatch($id)->onQueue("{meitu:callback}");
        }
    }
}
