|
|
@@ -232,6 +232,18 @@ class ToolController extends BaseController
|
|
|
public function actionOrderInvoiceExportPdf()
|
|
|
{
|
|
|
try {
|
|
|
+ // 检测是否为命令行环境,如果是则创建模拟的user组件
|
|
|
+ if (Yii::$app instanceof yii\console\Application) {
|
|
|
+ // 创建一个模拟的User组件,避免在命令行环境中报错
|
|
|
+ $userComponent = new \yii\web\User(['identityClass' => 'common\models\User']);
|
|
|
+ // 模拟一个用户身份,设置管理员ID为1(可根据实际情况修改)
|
|
|
+ $userIdentity = new \stdClass();
|
|
|
+ $userIdentity->id = 1; // 管理员ID
|
|
|
+ $userComponent->setIdentity($userIdentity);
|
|
|
+ // 将模拟的user组件绑定到应用实例
|
|
|
+ Yii::$app->set('user', $userComponent);
|
|
|
+ }
|
|
|
+
|
|
|
// 创建ShopExportForm实例
|
|
|
$formModel = new \backendApi\modules\v1\models\exportForms\ShopExportForm();
|
|
|
|