<?php

namespace App\Admin\Actions\Coupon;

use App\Jobs\CheckCouponByLog;
use App\Jobs\CheckCouponLog;
use Encore\Admin\Actions\Action;
use Illuminate\Http\Request;

class RefreshPAOrder extends Action
{
    public $name = '刷新平安订单id';

    protected $selector = '.refresh-order';

    public function handle(Request $request)
    {
        $table = 'api_log_'.date('Ym');

        CheckCouponLog::dispatch($table);
        CheckCouponByLog::dispatch($table);

        return $this->response()->success('正在获取数据，请等待片刻后刷新页面查看！')->refresh();
    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-default refresh-order "><i class="fa fa-refresh"></i>  刷新平安订单id</a>
HTML;
    }
}
