setName('xQueue:Book'); // $this->setDescription('导入章节内容'); $this->setName('xQueue:KamiOrderStatusStandardUp')->setDescription('[ 卡密列表 - 自动同步 ] 标准商户默认更新'); } /** * @param Input $input * @param Output $output * @throws \think\admin\Exception */ protected function execute(Input $input, Output $output) { ini_set('memory_limit', '1024M'); $merchants=MerchantService::instance()->db()->field('id')->where(['merchant_type'=>1,'kami_status' => 1])->select()->toArray(); if(!$merchants) $this->setQueueSuccess("未找到需要处理的标准卡密商家"); $merchant_num = count($merchants); $count_sum = 0; $total_sum=0; foreach($merchants as $merchant) { $orderService = OrderService::instance(); $where1 = [ 'status' => '7', 'mid'=>$merchant['id'] ]; $where[] = [ 'product_key', 'like', '%cardbuy%' ]; list($count, $total) = [0, $orderService->db()->where($where)->where($where1)->count()]; // print_r(1);die; // $orderlist = $kami91server->db()->where($where)->where($where1)->order('id asc')->select()->toArray(); $orderService->db()->where($where)->where($where1)->chunk(100, function (Collection $data) use (&$count, $total, $orderService) { // var_dump($orderlist);die; foreach ($data->toArray() as $vo) { $count++; // $orderService = OrderService::instance(); if(isset($vo['response'])){ $callJson = $vo['response']; if(isset($callJson) && is_string($callJson)) { $callArray = json_decode($callJson, true); if(is_array($callArray)) { if(isset($callArray['kami'])) { $callArray = $callArray['kami']; $callArray['s_number']=$callArray['cardno']; $callJson = json_encode($callArray); } } } } if(!isset($callJson) || !is_string($callJson)) { $callJson = '{}'; } $orderService->db()->where(['id' => $vo['id']])->update(['status' => 2,'merchant_callback_error' =>2,'channel_callback_msg'=>$callJson]); $this->setQueueProgress("同步订单状态 {$vo['order_id']} ", $count / $total * 100); } }); } $this->setQueueSuccess("同步 {$count} 个订单状态完成!"); } }