Load.php 783 字节
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/5/25
 * Time: 14:10
 */

namespace app\index\controller;


use app\common\controller\Frontend;
use app\index\model\OrderDetail;
use think\Db;

/**
 * 定时任务
 * Class Load
 * @package app\index\controller
 */
class Load extends Frontend
{
    /**
     * 待收货15天后自动改为已收货
     */
    public function index(){
        $orderDetailModel = new OrderDetail();
        $data = $orderDetailModel->where(['status'=>'3']);
        $ids = [];
        foreach($data as $key => $vo){
            if($vo['deliverytime']*15*24*60*60 >= time()){
                $ids[] = $vo['id'];
            }
        }
        Db::name('order_detail')->where(['id'=>['in',$ids]])->update(['status'=>'6']);
    }
}