69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use RuLong\Area\Models\Area;
|
|
use RuLong\Order\Models\OrderExpress;
|
|
|
|
/**
|
|
* 业绩奖金
|
|
*/
|
|
class CityOrderProfit implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue;
|
|
|
|
/**
|
|
* 队列名称
|
|
* @var string
|
|
*/
|
|
public $queue = 'Bonus';
|
|
|
|
/**
|
|
* 队列执行 延迟时间
|
|
* @var integer
|
|
*/
|
|
// public $delay = 7*24*3600;
|
|
public $delay = 0;
|
|
|
|
/**
|
|
* 最大尝试次数
|
|
* @var integer
|
|
*/
|
|
public $tries = 1;
|
|
|
|
/**
|
|
* 脚本超时时间
|
|
* @var integer
|
|
*/
|
|
public $timeout = 50;
|
|
|
|
protected $express;
|
|
|
|
public function __construct(OrderExpress $express)
|
|
{
|
|
$this->express = $express->fresh();
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
$area = Area::where('sn', $this->express->city_sn)->first();
|
|
if ($area && $area->user) {
|
|
$amount = $this->express->order->amount;
|
|
$rate = $parent->identity->info->configs['orderPerf'] ?? 0; //结算比例
|
|
$price = bcadd($amount * $rate / 100, 0, 2);
|
|
if ($price > 0) {
|
|
$source = [
|
|
'order_id' => $this->express->order_id,
|
|
'user_id' => $this->express->order->user_id,
|
|
'amount' => $amount,
|
|
'rate' => $rate,
|
|
];
|
|
$area->user->rule('orderPerf', $price, false, $source);
|
|
}
|
|
}
|
|
}
|
|
}
|