48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
namespace common\jobs;
|
|
|
|
use common\core\BaseModel;
|
|
use common\models\ProductOrder;
|
|
use common\models\ProductOrderLog;
|
|
use common\enums\ProductOrderEnum;
|
|
|
|
|
|
use yii\queue\JobInterface;
|
|
use yii\queue\Queue;
|
|
|
|
//产品订单自动收货
|
|
class ProductOrderAutoReceivedJob extends BaseJob implements JobInterface
|
|
{
|
|
public $orderId;
|
|
|
|
/**
|
|
* @param Queue $queue which pushed and is handling the job
|
|
*/
|
|
public function execute($queue)
|
|
{
|
|
try {
|
|
ProductOrderLog::saveLog($this->orderId,'产品订单自动收货队列start');
|
|
$this->setRequest();
|
|
//判断是否已发货状态且到达自动收货时间
|
|
$ProductOrder = ProductOrder::findOne([
|
|
'id' => $this->orderId,
|
|
'is_pay' => 1,
|
|
'is_send' => 1, // 已发货
|
|
'status' => 2 //待收货
|
|
]);
|
|
if (!$ProductOrder) {
|
|
throw new \Exception('订单不存在');
|
|
}
|
|
|
|
$ProductOrder->status = ProductOrderEnum::CONFIRM;
|
|
$ProductOrder->received_time = time();
|
|
$ProductOrder->save();
|
|
|
|
|
|
ProductOrderLog::saveLog($this->orderId,'产品订单自动收货队列end');
|
|
} catch (\Exception $exception) {
|
|
ProductOrderLog::saveLog($this->orderId,'产品订单自动收货队列异常:'.$exception->getMessage().'------'.$exception->getLine());
|
|
return;
|
|
}
|
|
}
|
|
} |