setName('xQueue:Book'); // $this->setDescription('导入章节内容'); $this->setName('xQueue:KamiOrderAssociation')->setDescription('[ 卡密列表 - 自动同步 ] 关联系统订单'); } /** * @param Input $input * @param Output $output * @throws \think\admin\Exception */ protected function execute(Input $input, Output $output) { ini_set('memory_limit', '1024M'); $kami91server = Kami91OrderService::instance(); $where1 = [ 'status' => '1' , ]; $where[] = [ 'product_key','like','%cardbuy%' ]; list($count, $total) = [0, $kami91server->db()->where($where)->where($where1)->count()]; // $orderlist = $kami91server->db()->where($where)->where($where1)->order('id asc')->select()->toArray(); $kami91server->db()->where($where)->where($where1)->chunk(100, function (Collection $data) use (&$count, $total) { // var_dump($orderlist);die; foreach ($data->toArray() as $vo) { // $orderService = OrderService::instance(); $order = OrderService::instance()->get('', $vo['merchant_order_id'], $vo['mid']); if ($order) { $count++; $upData = array(); $upData['order_id'] = $order['order_id']; $upData['status'] = 4; Kami91OrderService::instance()->db()->where(array('merchant_order_id' => $vo['merchant_order_id']))->update($upData); $this->setQueueProgress("同步关联订单 {$vo['order_id']} ", $count / $total * 100); } } }); $this->setQueueSuccess("同步关联 {$count} 个订单完成!"); } }