|
@@ -215,12 +215,20 @@ class ProductCategory extends Controller
|
|
|
* @date 2025-12-18
|
|
* @date 2025-12-18
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- public function delete(Request $request, ProductCategoryModel $ProductCategoryModel)
|
|
|
|
|
|
|
+ public function delete(Request $request, ProductCategoryModel $ProductCategoryModel,LowPriceGoodsModel $LowPriceGoodsModel,ViolationProductModel $ViolationProductModel)
|
|
|
{
|
|
{
|
|
|
// 验证参数
|
|
// 验证参数
|
|
|
$request->scene('delete')->validate();
|
|
$request->scene('delete')->validate();
|
|
|
// 接收数据
|
|
// 接收数据
|
|
|
$id = request('id', 0);
|
|
$id = request('id', 0);
|
|
|
|
|
+ $low_price_goods_count = $LowPriceGoodsModel->where(['category_id' => $id])->count();
|
|
|
|
|
+ if ($low_price_goods_count > 0) {
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '该分类下存在低价商品配置,删除失败']);
|
|
|
|
|
+ }
|
|
|
|
|
+ $violation_product_count = $ViolationProductModel->where(['category_id' => $id])->count();
|
|
|
|
|
+ if ($violation_product_count > 0) {
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '该分类下存在禁止商品配置,删除失败']);
|
|
|
|
|
+ }
|
|
|
// 查询用户
|
|
// 查询用户
|
|
|
$where = ['id' => $id];
|
|
$where = ['id' => $id];
|
|
|
// 执行删除
|
|
// 执行删除
|