jingcai-php/app/Jobs/ComputeCustomerWinLevelScor...

74 lines
2.1 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace App\Jobs;
use App\Enums\BoolEnum;
use App\Enums\LottState;
use App\Enums\LottType;
use App\Enums\OrderType;
use App\Events\LotteryResultEvent;
use App\Events\OrderWinedEvent;
use App\Model\Config;
use App\Model\Customer\Customer;
use App\Model\Order;
use App\Model\OrderJczqResult;
use App\Model\OrderZuhe;
use App\Model\Zq\JczqResult;
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\Arr;
use Illuminate\Support\Facades\Log;
class ComputeCustomerWinLevelScore implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $orderId;
public function __construct($orderId)
{
$this->orderId = $orderId;
$this->queue = config('queue.names.compute_customer_level');
}
// 1、普通累加方案金额和2倍中奖
// 1、合买累加方案金额和2倍中奖参与人只累加购买
// 1、发单累加方案金额和2倍中奖跟单人累加购买和中
public function handle()
{
Log::info('ComputeCustomerWinLevelScore, orderId:'. $this->orderId);
$order = Order::find( $this->orderId);
if (!$order) {
return;
}
if ($order->lottery_prize <= 0) {
Log::error('CustomerWinAddLevelListener 订单没有中奖', [
'order' => $order->toArray()
]);
return;
}
if ($order->type == OrderType::GENDAN) {
Customer::levelScoreIncr($order->customer_id, $order->lottery_prize);
return;
}
if ($order->type == OrderType::UNION) {
if ($order->id != $order->pid) {
return;
}
$money = ($order->lottery_prize / $order->union_piece_total) * ($order->union_piece_self +$order->union_piece_keep);
Customer::levelScoreIncr($order->customer_id, $money * 2);
return;
}
Customer::levelScoreIncr($order->customer_id,2*$order->lottery_prize);
}
}