| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | <?phpnamespace app\cron;use app\common\model\Config;use app\common\model\Orders as OrderModel;use app\common\util\AppMsg;use think\Db;use yunwuxin\cron\Task;//订单超过三个小时未完成提醒class OrdersReminder extends Task{    public function configure()    {        $this->spliceIntoPosition(1, '*/20'); //每20分钟执行一次    }    /**     * 执行任务     * @return mixed     */    protected function execute()    {        try{            $this->push();        }catch (\Exception $e){            trace($e->getMessage());        }    }    public function push(){        $list= Db::name('orders')            ->alias('a')            ->join('todo b','a.id = b.order_id')            ->where('a.del',0)            ->where('b.del',0)            ->where('order_mode',4)            ->where('todo_mode','in',[1,2])            ->field('b.create_time,b.to_user_id')            ->select();        $ids = [];        foreach ($list as $k=>$v){            $time = time();            $cTime = strtotime($v['create_time']);            $diff = $time - $cTime;            if ($diff > 60*60*3){                $ids[] = $v['to_user_id'];            }        }        $ids = array_unique($ids);        if(!empty($ids)){            send_jpush($ids,AppMsg::PUSH_WORKER_ORDER_SEND,'您的订单未完成,请及时处理');        }    }}
 |