public function actionExport() { $params = $this->getQuery(); $accountId = $this->getAccountId(); $condition = TradePayment::getSearchCondition($accountId, $params); $data = TradePayment::findOne($condition); if (empty($data)) { return ['result' => 'error', 'message' => 'no datas', 'data' => []]; } $key = Yii::t('channel', 'payment_file_name') . '_' . date('Y-m-d H:i:s'); $fields = 'transactionId,user,expectedAmount,realAmount,subject,paymentTime'; $sort = ['paymentTime' => -1]; $fileTitle = Yii::t('channel', 'export_payment_title'); $header = ['transactionId', 'userName', 'realAmount', 'expectedAmount', 'subject', 'paymentTime']; $header = array_combine($header, explode(',', $fileTitle)); $args = ['accountId' => (string) $accountId, 'key' => $key, 'header' => $header, 'fields' => $fields, 'sort' => $sort, 'params' => [], 'collection' => 'tradePayment', 'condition' => serialize($condition), 'classFunction' => '\\backend\\modules\\channel\\models\\TradePayment::preProcessData', 'description' => 'Direct: Export TradePayment data']; $jobId = Yii::$app->job->create('backend\\modules\\common\\job\\MongoExportFile', $args); unset($header, $args); return ['result' => 'success', 'message' => 'exporting file', 'data' => ['jobId' => $jobId, 'key' => $key]]; }