linux宝塔计划任务调用Laravel artisan 命令

/www/server/php/80/bin/php /www/wwwroot/digital-platform/artisan hotel_confirm
在这里插入图片描述

<?php

namespace App\Console\Commands;

use App\Constant\HotelConstant;
use App\Models\GoodsOrder;
use App\Models\HotelOrder;
use App\Models\HotelRoom;
use App\Models\HotelRoomCalendar;
use App\Services\Goods\Interfaces\GoodsOrderServiceInterface;
use App\Services\Goods\Services\GoodsAutoService;
use App\Services\Hotel\Interfaces\HotelServiceInterface;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class HotelAutoOrderConfirm extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'hotel_confirm';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '酒店已经入住订单自动退房';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->line('start');
        Log::channel('hotellog')->debug('酒店定时-start');

        $this->orderConfirm();
        Log::channel('hotellog')->debug('酒店定时-ok');
    }
    public function orderConfirm()
    {
        $order_model = new HotelOrder();
        $order_service = app()->make(HotelServiceInterface::class);
        // 将订单状态为 1(未支付)时间在超过 配置时间的订单取消 minutes
        $order_list = $order_model->where('order_status',HotelConstant::CONFIRM_LIVING)->where('end_at','=',today_())->get(); //update(['order_status'=>0,'updated_at'=>now()])
        if($order_list->isEmpty()){
            return 'nothing';
        }
        $ids = [];
        foreach($order_list as $v){
            try{
                DB::beginTransaction();
                $rs = $order_service->editOrderStatus($v['id'],HotelConstant::ORDER_DONE,'admin');
                if(!$rs['code']){
                    Log::channel('hotellog')->debug('fail');
                }
                DB::commit();

            }catch(\Exception $e){
                DB::rollBack();
                Log::channel('qwlog')->debug($e->getMessage());
            }
        }

        return 'success';
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值