fix: 产品详情接口未找到产品时报错误问题
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 2s

This commit is contained in:
2026-03-28 11:46:23 +08:00
parent 90b4bccbcf
commit 8a9d66f5d3

View File

@@ -24,7 +24,7 @@ class Product
'category_id',
'created_at',
'is_show',
'page/d' => 1,
'page/d' => 1,
'size/d' => 10
]);
@@ -83,7 +83,7 @@ class Product
])
->bypk(request()->param('id'))
->find()
->bindAttr('category', ['category_name'])
?->bindAttr('category', ['category_name'])
->hidden(['category']);
if (empty($product)) {
return error('产品不存在');
@@ -108,7 +108,7 @@ class Product
// 获取关联产品
$product->related = ProductRelatedModel::field([
'related_product_id',
'related_product_id',
'sort'
])
->with(['product' => function($query) {
@@ -149,8 +149,8 @@ class Product
'seo_desc'
]);
$put = array_merge(
$put,
['skus' => json_decode($put['skus'], true)],
$put,
['skus' => json_decode($put['skus'], true)],
['related' => json_decode($put['related'], true)],
);
@@ -305,7 +305,7 @@ class Product
return success('操作成功');
}
// 导出
public function export()
{
@@ -444,7 +444,7 @@ class Product
});
}
}
return $products->toArray();
}
}