|
@@ -5,6 +5,8 @@ namespace App\Http\Controllers\manager\washConfig;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Http\Requests\Manager\WashConfig\ProductCategory as Request;
|
|
use App\Http\Requests\Manager\WashConfig\ProductCategory as Request;
|
|
|
use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
|
|
use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
|
|
|
|
|
+use App\Models\Manager\WashConfig\LowPriceGoods as LowPriceGoodsModel;
|
|
|
|
|
+use App\Models\Manager\WashConfig\ViolationProduct as ViolationProductModel;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 清洗配置-产品分类
|
|
* 清洗配置-产品分类
|
|
@@ -170,13 +172,24 @@ class ProductCategory extends Controller
|
|
|
* @date 2025-12-18
|
|
* @date 2025-12-18
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- public function set_status(Request $request, ProductCategoryModel $ProductCategoryModel)
|
|
|
|
|
|
|
+ public function set_status(Request $request, ProductCategoryModel $ProductCategoryModel,LowPriceGoodsModel $LowPriceGoodsModel,ViolationProductModel $ViolationProductModel)
|
|
|
{
|
|
{
|
|
|
// 验证参数
|
|
// 验证参数
|
|
|
$request->scene('set_status')->validate();
|
|
$request->scene('set_status')->validate();
|
|
|
// 接收数据
|
|
// 接收数据
|
|
|
$id = request('id', 0);
|
|
$id = request('id', 0);
|
|
|
$status = request('status', 0);
|
|
$status = request('status', 0);
|
|
|
|
|
+ //如果是禁用,校验是否被使用
|
|
|
|
|
+ if ($status == 1) {
|
|
|
|
|
+ $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];
|
|
|
$ProductCategory = $ProductCategoryModel->where($where)->first();
|
|
$ProductCategory = $ProductCategoryModel->where($where)->first();
|
|
@@ -202,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];
|
|
|
// 执行删除
|
|
// 执行删除
|