|
|
<?php
|
|
|
|
|
|
namespace app\api\job;
|
|
|
|
|
|
use think\queue\Job;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 发送优惠券自动操作
|
|
|
*/
|
|
|
class OrderAutoOper extends BaseJob
|
|
|
{
|
|
|
/**
|
|
|
* 订单自动关闭
|
|
|
*/
|
|
|
public function autoClose(Job $job, $data){
|
|
|
try {
|
|
|
$order_id = $data['order_id'];
|
|
|
$order = \app\api\model\Order::get($order_id);
|
|
|
if ($order && $order['pay_status'] == '10' && $order['order_status'] == '10') {
|
|
|
\think\Db::transaction(function () use ($order) {
|
|
|
(new \app\api\controller\Order)->cancelOrderAction($order);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 删除 job
|
|
|
$job->delete();
|
|
|
} catch (\Exception $e) {
|
|
|
// 队列执行失败
|
|
|
\think\Log::write('queue-' . get_class() . '-autoClose' . ':执行失败,错误信息:' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|