setName('xQueue:Book'); // $this->setDescription('导入章节内容'); $this->setName('xQueue:KamiOrderTimeoutRefund')->setDescription('[ 卡密列表 - 自动同步 ] 超时订单退款'); } /** * @param Input $input * @param Output $output * @throws \think\admin\Exception */ protected function execute(Input $input, Output $output) { ini_set('memory_limit', '1024M'); $orderService = OrderService::instance(); $cur = time(); $time = 60 * '2'; $whereRaw = $cur . '-unix_timestamp(create_at) >=' . $time; list($count, $total) = [0, $orderService->db()->whereRaw('status = 1 and ' . $whereRaw)->count()]; $orderService->db()->whereRaw('status = 1 and ' . $whereRaw)->chunk(100, function (Collection $data) use (&$count, $total, $orderService) { // var_dump($orderlist);die; foreach ($data->toArray() as $vo) { if ($vo['request'] && $vo['status'] == 1) { $count++; $vo['request'] = json_decode($vo['request'], true); \app\order\service\OrderService::instance()->setCallback(1, $vo['order_id'], 3); } $this->setQueueProgress("超时订单退款 {$vo['order_id']} ", $count / $total * 100); } }); $this->setQueueSuccess("完成 {$count} 个超时订单退款!"); } }