setName('xQueue:Book'); // $this->setDescription('导入章节内容'); $this->setName('xQueue:LinSuoKa')->setDescription('临时锁卡任务'); } /** * @param Input $input * @param Output $output * @throws \think\admin\Exception */ protected function execute(Input $input, Output $output) { ini_set('memory_limit', '1024M'); $channelService = ChannelService::instance(); list($count, $total) = [0, Db::name('test_ts')->whereNotNull('merchant_order_id')->count()]; // $taobao = new \app\openapi\controller\Taobao($this->app); Db::name('test_ts')->whereNotNull('merchant_order_id')->chunk(100, function (Collection $data) use (&$count, $total, $channelService) { // var_dump($orderlist);die; foreach ($data->toArray() as $vo) { $table = 'merchant_order_lastweek_history'; $order = Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->find(); // var_dump($vo);die; if(!$order){ $table = 'merchant_order'; $order = Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->find(); if(!$order){ $table = 'merchant_order_last_history'; $order = Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->find(); if(!$order) { continue; } } } $suoka = $channelService->call('lockCard', $order['cid'], $order); // var_dump($suoka);die; if($suoka !== 'ok' && $suoka !== 'old_ok'){ Db::name('test_ts_suoka_error')->insert(['merchant_order_id'=>$vo['merchant_order_id']]); Db::name('test_ts')->whereLike('merchant_order_id', $vo['merchant_order_id'])->delete();//这个用like会不会太范了?不会,因为order是唯一只是怕空格影响 // var_dump($vo); }else{ // Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>3]);// Db::name('test_ts_suoka_yes')->insert(['merchant_order_id'=>$vo['merchant_order_id']]); Db::name('test_ts')->whereLike('merchant_order_id', $vo['merchant_order_id'])->delete();//这个用like会不会太范了?不会,因为order是唯一只是怕空格影响 $count++; $this->setQueueProgress(" {$vo['merchant_order_id']} ", $count / $total * 100); } } }); $this->setQueueSuccess("总计 {$total} 个, 处理成功 {$count} 个错误订单退款!"); } #上周 }