<?php

namespace App\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Redis;

/**
 * 卡片信息流层级池改变
 */
class PartnerFeedPoolChange
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  \App\Events\PartnerFeedPoolChange  $event
     * @return void
     */
    public function handle(\App\Events\PartnerFeedPoolChange $event)
    {
        $poolhash = array(
            'select',
            'new',
            'recommend',
            'low'
        );
        foreach ($poolhash as $value) {
            Redis::srem("feed:pool:{$value}:sex:{$event->model->sex}", $event->model->uid);
        }
        if (1 == $event->model->is_sell && $event->model->score >= 0) {
            Redis::sadd("feed:pool:{$event->model->feed_pool_level}:sex:{$event->model->sex}", [$event->model->uid]);
        }
    }
}
