徐总多门店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
jiuhaoshenghuo/app/jobs/order/UnpaidOrderCancelJob.php

59 lines
1.8 KiB

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\jobs\order;
use app\services\order\StoreOrderRefundServices;
use app\services\order\StoreOrderServices;
use crmeb\basic\BaseJobs;
use crmeb\traits\QueueTrait;
use think\facade\Log;
/**
* 未支付订单到期取消
* Class UnpaidOrderCancelJob
* @package app\jobs
*/
class UnpaidOrderCancelJob extends BaseJobs
{
use QueueTrait;
/**
* @param $orderId
* @return bool|mixed
*/
public function doJob($orderId)
{
/** @var StoreOrderServices $services */
$services = app()->make(StoreOrderServices::class);
$orderInfo = $services->get($orderId);
if (!$orderInfo) {
return true;
}
if ($orderInfo->paid) {
return true;
}
if ($orderInfo->is_del) {
return true;
}
if ($orderInfo->pay_type == 'offline') {
return true;
}
try {
$services->cancelOrder((int)$orderInfo['id'], 0, '订单未支付已超过系统预设时间');
} catch (\Throwable $e) {
Log::error('自动取消订单失败,失败原因:' . $e->getMessage());
}
return true;
}
}