6
0
Fork 0

userCreated

base
panliang 2026-05-15 19:32:48 +08:00
parent 3e2696aa6d
commit 8f28128f53
3 changed files with 63 additions and 17 deletions

View File

@ -178,20 +178,6 @@ class DrawActivityPrizeController extends Controller
->setLabelClass(['asterisk']);
$form->select('type', '类型')->options(DrawPrizeType::options())->setLabelClass(['asterisk']);
$form->text('amount', '面值/数量')->setLabelClass(['asterisk']);
// $form->radio('limited', '是否限量')
// ->options([
// 0 => '否',
// 1 => '是',
// ])
// ->when(1, function (Form $form) {
// $form->number('stock', '库存')->min(0)->setLabelClass(['asterisk']);
// })
// ->default(1)
// ->customFormat(function ($v) {
// return $v ? 1 : 0;
// })
// ->setLabelClass(['asterisk']);
}
$form->number('weight', '权重')

View File

@ -0,0 +1,60 @@
<?php
namespace App\Console\Commands;
use App\Models\DrawActivity;
use App\Models\DrawTicketLog;
use App\Models\User;
use App\Services\DrawTicketService;
use Illuminate\Console\Command;
/**
* 每月赠送用户抽奖次数
*/
class DrawTicketSendMonthly extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'draw-activity:ticket-send-monthly';
/**
* The console command description.
*
* @var string
*/
protected $description = '每月赠送用户抽奖次数';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
// 有效的抽奖活动
$drawActivity = DrawActivity::onlyRunning()->first();
$list = User::query()->all();
$service = new DrawTicketService();
foreach ($list as $user) {
// 如果用户已有抽奖次数, 则不赠送
$log = DrawTicketLog::where('draw_activity_id', $drawActivity->id)->where('user_id', $user->id)->where('number', '>', 0)->first();
if (!$log) {
$service->change($user, $drawActivity, 1);
}
}
return 0;
}
}

View File

@ -24,9 +24,9 @@ class EventServiceProvider extends ServiceProvider
\App\Listeners\OrderPrint::class,
\App\Listeners\OrderAutoComplete::class,
],
\App\Events\UserCreated::class => [
\App\Listeners\SendDrawTicket::class,
],
// \App\Events\UserCreated::class => [
// \App\Listeners\SendDrawTicket::class,
// ],
];
/**