52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace common\jobs;
|
|
|
|
use common\forms\LedgerForm;
|
|
use common\models\oldDb\ProductOrder;
|
|
use common\models\oldDb\ProductOrderLog;
|
|
use yii\queue\JobInterface;
|
|
use yii\queue\Queue;
|
|
|
|
//产品订单支付分账
|
|
class ProductOrderPaidJob 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,
|
|
'cancel_status' => 0,
|
|
'refund_status' => 0,
|
|
]);
|
|
// if (!$ProductOrder || $ProductOrder->type != 2) {
|
|
// throw new \Exception('订单不存在');
|
|
// }
|
|
if (!$ProductOrder) {
|
|
throw new \Exception('订单不存在');
|
|
}
|
|
|
|
$ledgerForm = new LedgerForm();
|
|
$ledgerForm->order_id = $this->orderId;
|
|
$ledgerForm->create();
|
|
|
|
//订单支付分账后立即结算
|
|
// \Yii::$app->queue->delay(0)->push(new ProductOrderSendJob([
|
|
// 'orderId' => $this->orderId
|
|
// ]));
|
|
|
|
ProductOrderLog::saveLog($this->orderId,'产品订单支付分账队列end');
|
|
} catch (\Exception $exception) {
|
|
ProductOrderLog::saveLog($this->orderId,'产品订单支付分账队列异常:'.$exception->getMessage());
|
|
return;
|
|
}
|
|
}
|
|
} |