61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Activity;
|
|
use App\Models\CouponCard;
|
|
use Log;
|
|
use Redis;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
class CouponUseCreate implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
protected $number=0;
|
|
protected $id;
|
|
protected $config=[];
|
|
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($number,$id,$config=[])
|
|
{
|
|
//
|
|
$this->number=$number;
|
|
$this->id=$id;
|
|
$this->config=$config;
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
//
|
|
$insert_data=make_card($this->number,$this->id,1,$this->config);
|
|
$result=CouponCard::insert($insert_data);
|
|
if($result==$this->number){
|
|
//更新活动优惠券数量
|
|
$total=CouponCard::where('active_id',$this->id)->count();
|
|
$r=Activity::where('id',$this->id)->update([
|
|
'card_number'=>$total
|
|
]);
|
|
|
|
|
|
Log::channel('coupon_card')->notice('优惠券活动id:'.$this->id.',插入数量'.$this->number.'状态为:'.$r.';创建人id是:'.
|
|
$this->config['create_user_type'].'~'.$this->config['create_user_id']);
|
|
}
|
|
}
|
|
}
|