50], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'batch_delivery_id' => 'Batch Delivery ID', 'order_no' => 'Order No', 'express_no' => 'Express No', 'content' => 'Content', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData($params) { try { $mobel = new self(); if (!$mobel->load($params, '') || !$mobel->save()) throw new \Exception($mobel->getErrorMessage()); return $mobel; } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } public static function exportHandle(array $data) { $download_id = $data['download_id'] ?? 0; $download = Download::findOne(['id' => $download_id]); if ($download) { try { $params = json_decode($download->params,true); $filename = $download->name; $type = $download->type; $list = self::find()->select("order_no,express_no,content")->where(['mall_id' => $params['mall_id'], 'batch_delivery_id' => $params['batch_delivery_id'], 'status' => StatusEnum::ENABLED])->asArray()->all(); $have_select_field_arr = ['订单号','物流单号','失败原因']; $csv = new CsvTool(); $csv->filename = $filename; $csv->file_dirname = DownloadEnum::getTypeStorageDirMap($type); $csv->export_mode = CsvTool::EXPORT_MODE_ASYNC; $csv->header = $have_select_field_arr; foreach ($list as $item) { is_numeric($item['express_no']) && $item['express_no'] = $item['express_no'] . "\t"; $rows[] = $item; } $csv->data = $rows; $csv->export(); $csv->updateDown($download,$params['mall_id']); return true; } catch (\Exception $e) { $download->status = 3; $res = $download->save(); self::setStaticError($e->getMessage()); return $e->getMessage(); } } } }