Files
lelong/app/Jobs/WhatsappPemenang.php
T
ismailmasseran e29a5891c8 Bugfix/list clickup issue (#5)
Reviewed-on: #5
Co-authored-by: ISMAIL MASSERAN <ismail@koppkb.com>
Co-committed-by: ISMAIL MASSERAN <ismail@koppkb.com>
2026-10-19 13:30:36 +08:00

54 lines
1.5 KiB
PHP

<?php
namespace App\Jobs;
use App\Services\WhatsAppCloudService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class WhatsappPemenang implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $user_notelbimbit;
public $total_bid_win_converted;
public function __construct($user_notelbimbit, $total_bid_win_converted)
{
$this->user_notelbimbit = $user_notelbimbit;
$this->total_bid_win_converted = $total_bid_win_converted;
$this->onQueue('default');
}
public function handle(WhatsAppCloudService $whatsapp)
{
if (! $whatsapp->isEnabled()) {
Log::warning('WhatsappPemenang skipped: WhatsApp Cloud API not enabled.');
return;
}
$recipient = $whatsapp->resolveRecipient($this->user_notelbimbit);
if (! $recipient) {
Log::warning('WhatsappPemenang: invalid phone', [
'notelbimbit' => $this->user_notelbimbit,
]);
return;
}
// {{1}} jumlah bidaan menang (formatted, without RM)
$whatsapp->sendTemplate(
$recipient,
config('whatsapp.pemenang_template'),
[$this->total_bid_win_converted],
config('whatsapp.pemenang_template_lang')
);
}
}