exoprt(10132,null,$end_time); } public function exoprt($mchid,$start_time = null,$end_time = null) { $cond['mchid'] = $mchid; $cond['vr_order.order_state'] = 40; if(!is_null($start_time) && !is_null($end_time)) { $cond["refill_order.notify_time&refill_order.notify_time"] = ['_multi' => true, ['egt', $start_time], ['lt', $end_time]]; } elseif(!is_null($start_time)) { $cond["refill_order.notify_time"] = ['egt', $start_time]; } elseif(!is_null($end_time)) { $cond["refill_order.notify_time"] = ['lt', $end_time]; } $path = BASE_DATA_PATH . "/log/{$mchid}.csv"; $fp = fopen($path, 'w'); fputcsv($fp,['序号','商户订单号','卡号','面额','流水号',"下单时间","回调时间"]); $count = 1000; $i = 0; $index = 0; while (true) { $start = $i * $count; $items = Model('')->table('refill_order,vr_order') ->field('mch_order,refill_order.card_no,refill_amount,mch_amount,official_sn,from_unixtime(order_time) as sorder_time,from_unixtime(notify_time) as snotify_time') ->join('inner') ->on('refill_order.order_id=vr_order.order_id') ->where($cond) ->limit("{$start},{$count}") ->select(); if(empty($items)) { break; } $i++; foreach ($items as $item) { $index++; $data = [$index,$item['mch_order'],$item['card_no'],$item['refill_amount'],$item['mch_amount'],$item['official_sn'],$item['sorder_time'],$item['snotify_time']]; fputcsv($fp,$data); } } fclose($fp); } } //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestExportOrder::testXingzhiyu)( .*)?$/" --test-suffix TestExportOrder.php /var/www/html/test