<?php




namespace ln\listens;

use app\common\repositories\system\merchant\MerchantApplymentsRepository;
use ln\services\TimerService;
use Swoole\Timer;
use think\facade\Log;
use ln\interfaces\ListenerInterface;

class MerchantApplyMentsCheckListen extends TimerService implements ListenerInterface
{
    public function handle($event): void
    {
        //申请状态: 0.平台未提交，-1.平台驳回，10.平台提交审核中，11.需用户操作 ，20.已完成，30.已冻结，40.驳回
        $make =  app()->make(MerchantApplymentsRepository::class);

        $this->tick(1000 * 60 * 30, function () use($make) {
            $ret = $make->getSearch(['is_del' => 0])->where('status','in',[10,11,30])->select();
            try {
                foreach ($ret as $item) {
                    $make->check($item['mer_id']);
                }
            } catch (\Exception $e) {
                Log::info('自动查询分账商户审核失败' . date('Y-m-d H:i:s', time()));
            }
        });
    }
}
