70 lines
2.0 KiB
PHP
Executable File
70 lines
2.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
use App\Enums\BoolEnum;
|
|
use App\Enums\LottState;
|
|
use App\Enums\LottType;
|
|
use App\Enums\PayState;
|
|
use App\Model\Dlt;
|
|
use App\Model\LotteryType;
|
|
use App\Model\Order;
|
|
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 RefreshOrderDltResult implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
protected $dltId;
|
|
|
|
public function __construct($dltId)
|
|
{
|
|
$this->dltId = $dltId;
|
|
$this->queue = config('queue.names.refresh_order_odds');
|
|
}
|
|
public function getData() {
|
|
return [
|
|
'$dltId' => $this->dltId
|
|
];
|
|
}
|
|
public function handle()
|
|
{
|
|
Log::info('RefreshOrderDltResult::start, dltId:' . $this->dltId);
|
|
$lotteryType = LotteryType::where('type', LottType::DLT)->first();
|
|
if (!$lotteryType) {
|
|
Log::error('RefreshOrderDltResult 无dlt彩种');
|
|
return;
|
|
}
|
|
|
|
$dlt = Dlt::find($this->dltId);
|
|
if (!$dlt) {
|
|
Log::error('RefreshOrderDltResult dltId not found:' . $this->dltId);
|
|
return;
|
|
}
|
|
if ($dlt->state != BoolEnum::YES) {
|
|
Log::error('RefreshOrderDltResult dltId not publish result:' . $this->dltId);
|
|
return;
|
|
}
|
|
Order::where('lottery_type_id', $lotteryType->id)
|
|
->where('issue_num', $dlt->issue_num)
|
|
->where('pay_state', PayState::SUCCESS)
|
|
->where('lottery_state', LottState::WAIT)
|
|
->chunkById(500, function($orders) use ($dlt) {
|
|
foreach ($orders as $order) {
|
|
$this->dispatchComputeOrderPrize($order->id);
|
|
}
|
|
});
|
|
}
|
|
|
|
private function dispatchComputeOrderPrize($orderId)
|
|
{
|
|
Log::info('dispatch ComputeDltOrderPrize, orderId:'.$orderId);
|
|
ComputeDltOrderPrize::dispatch($orderId);
|
|
}
|
|
}
|