50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace App\Listeners;
|
||
|
||
use App\Events\CouponCardEvent;
|
||
use App\Models\Activity;
|
||
use Illuminate\Queue\InteractsWithQueue;
|
||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
use Illuminate\Support\Facades\Log;
|
||
|
||
class CouponCardEventListener implements ShouldQueue
|
||
{
|
||
/**
|
||
* Create the event listener.
|
||
*
|
||
* @return void
|
||
*/
|
||
public $connection = 'redis';
|
||
|
||
/**
|
||
* 任务将被推送到的连接名称.
|
||
*
|
||
* @var string|null
|
||
*/
|
||
// public $queue = 'listeners';
|
||
public $queue = 'shop_coupon_card_del';
|
||
|
||
public function __construct()
|
||
{
|
||
|
||
}
|
||
|
||
/**
|
||
* Handle the event.
|
||
*
|
||
* @param CouponCardEvent $event
|
||
* @return void
|
||
*/
|
||
public function handle(CouponCardEvent $event)
|
||
{
|
||
//
|
||
Log::channel('coupon_card')->notice('shop_user_id:'.admin_shop('id').',删除活动优惠码,活动id::'.$event->active_id);
|
||
//删除优惠券使用数量
|
||
$r=$active=Activity::where('id',$event->active_id)->decrement('card_number',$event->number);
|
||
Log::channel('coupon_card')->notice('删除活动id'.$r);
|
||
// sleep(0);
|
||
|
||
}
|
||
}
|