Ver código fonte

[智价云] 商品规格配置接口添加(低价&管控&违规)

tangyuanwang 1 dia atrás
pai
commit
aea9dd68a2

+ 46 - 1
app/Http/Controllers/Api/WashConfig/ControlGoods.php

@@ -15,7 +15,7 @@ use App\Models\Api\WashConfig\ControlGoods as ControlGoodsModel;
 class ControlGoods extends Api
 {
     /**
-     * 列表
+     * 商品列表
      * @author    唐远望
      * @version   1.0
      * @date      2025-12-15
@@ -50,6 +50,51 @@ class ControlGoods extends Api
             ->where($map)
             ->orderByDesc('id')
             ->select(['id','product_name'])
+            ->distinct('product_name')
+            ->paginate($limit);
+        // 分配数据
+        if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
+        // 加载模板
+        return        json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
+    }
+
+    /**
+     * 规格列表
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-12-15
+     * 
+     */
+    public function spec_list(Request $request, ControlGoodsModel $ControlGoodsModel)
+    {
+        $user_info = $this->checkLogin();
+        if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
+        $request->scene('spec_list')->validate();
+        // 查询条件
+        $map  = [];
+        $limit = request('limit', config('page_num', 10));
+        $status    = request('status', '0');
+        $start_time = request('start_time', '');
+        $end_time = request('end_time', '');
+        $product_specs = request('product_specs', '');
+        $platform = request('platform', '');
+        $store_scope = request('store_scope', '');
+        $company_scope = request('company_scope', '');
+        // 时间条件
+        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
+        if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
+        // 其他条件
+        if (is_numeric($status)) $map[] = ['status', '=', $status];
+        if ($product_specs) $map[] = ['product_specs', 'like', "%$product_specs%"];
+        if ($platform) $map[] = ['platform', 'like', "%$platform%"];
+        if ($store_scope) $map[] = ['store_scope', '=', $store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=', $company_scope];
+        // 查询数据
+        $result = $ControlGoodsModel->query()
+            ->where($map)
+            ->orderByDesc('id')
+            ->select(['id','product_specs'])
+            ->distinct('product_specs')
             ->paginate($limit);
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);

+ 46 - 1
app/Http/Controllers/Api/WashConfig/LowPriceGoods.php

@@ -16,7 +16,7 @@ use App\Models\Manager\WashConfig\LowPriceGoods as LowPriceGoodsModel;
 class LowPriceGoods extends Api
 {
     /**
-     * 列表
+     * 商品列表
      * @author    唐远望
      * @version   1.0
      * @date      2025-12-02
@@ -51,6 +51,51 @@ class LowPriceGoods extends Api
             ->where($map)
             ->orderByDesc('id')
             ->select(['id','product_name'])
+            ->distinct('product_name')
+            ->paginate($limit);
+        // 分配数据
+        if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
+        // 加载模板
+        return        json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
+    }
+
+    /**
+     * 规格列表
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-12-15
+     * 
+     */
+    public function spec_list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel)
+    {
+        $user_info = $this->checkLogin();
+        if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
+        $request->scene('spec_list')->validate();
+        // 查询条件
+        $map  = [];
+        $limit = request('limit', config('page_num', 10));
+        $status    = request('status', '0');
+        $start_time = request('start_time', '');
+        $end_time = request('end_time', '');
+        $product_specs = request('product_specs', '');
+        $platform = request('platform', '');
+        $store_scope = request('store_scope', '');
+        $company_scope = request('company_scope', '');
+        // 时间条件
+        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
+        if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
+        // 其他条件
+        if (is_numeric($status)) $map[] = ['status', '=', $status];
+        if ($product_specs) $map[] = ['product_specs', 'like', "%$product_specs%"];
+        if ($platform) $map[] = ['platform', 'like', "%$platform%"];
+        if ($store_scope) $map[] = ['store_scope', '=', $store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=', $company_scope];
+        // 查询数据
+        $result = $LowPriceGoodsModel->query()
+            ->where($map)
+            ->orderByDesc('id')
+            ->select(['id','product_specs'])
+            ->distinct('product_specs')
             ->paginate($limit);
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);

+ 46 - 1
app/Http/Controllers/Api/WashConfig/ViolationProduct.php

@@ -16,7 +16,7 @@ use App\Models\Api\WashConfig\ViolationProduct as ViolationProductModel;
 class ViolationProduct extends Api
 {
     /**
-     * 列表
+     * 商品列表
      * @author    唐远望
      * @version   1.0
      * @date      2025-12-03
@@ -51,6 +51,51 @@ class ViolationProduct extends Api
             ->where($map)
             ->orderByDesc('id')
             ->select(['id','product_name'])
+            ->distinct('product_name')
+            ->paginate($limit);
+        // 分配数据
+        if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
+        // 加载模板
+        return        json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
+    }
+
+    /**
+     * 规格列表
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-12-15
+     * 
+     */
+    public function spec_list(Request $request, ViolationProductModel $ViolationProductModel)
+    {
+        $user_info = $this->checkLogin();
+        if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
+        $request->scene('spec_list')->validate();
+        // 查询条件
+        $map  = [];
+        $limit = request('limit', config('page_num', 10));
+        $status    = request('status', '0');
+        $start_time = request('start_time', '');
+        $end_time = request('end_time', '');
+        $product_specs = request('product_specs', '');
+        $platform = request('platform', '');
+        $store_scope = request('store_scope', '');
+        $company_scope = request('company_scope', '');
+        // 时间条件
+        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
+        if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
+        // 其他条件
+        if (is_numeric($status)) $map[] = ['status', '=', $status];
+        if ($product_specs) $map[] = ['product_specs', 'like', "%$product_specs%"];
+        if ($platform) $map[] = ['platform', 'like', "%$platform%"];
+        if ($store_scope) $map[] = ['store_scope', '=', $store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=', $company_scope];
+        // 查询数据
+        $result = $ViolationProductModel->query()
+            ->where($map)
+            ->orderByDesc('id')
+            ->select(['id','product_specs'])
+            ->distinct('product_specs')
             ->paginate($limit);
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);

+ 1 - 0
app/Http/Controllers/Api/WashConfig/ViolationStore.php

@@ -51,6 +51,7 @@ class ViolationStore extends Api
             ->where($map)
             ->orderByDesc('id')
             ->select(['id','company_name'])
+            ->distinct('company_name')
             ->paginate($limit);
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);

+ 1 - 0
app/Http/Requests/Api/WashConfig/ControlGoods.php

@@ -47,6 +47,7 @@ class ControlGoods extends BaseRequest
         'edit'                  => ['id','platform','product_name', 'product_specs'],
         'set_status'              => ['id', 'status'],
         'delete'                  => ['id'],
+        'spec_list'             => ['page', 'limit'],
     ];
 
     /**

+ 1 - 0
app/Http/Requests/Api/WashConfig/ViolationProduct.php

@@ -47,6 +47,7 @@ class ViolationProduct extends BaseRequest
         'edit'                  => ['id','platform','product_name', 'product_specs'],
         'set_status'              => ['id', 'status'],
         'delete'                  => ['id'],
+        'spec_list'             => ['page', 'limit'],
     ];
 
     /**

+ 1 - 0
app/Http/Requests/Manager/WashConfig/LowPriceGoods.php

@@ -47,6 +47,7 @@ class LowPriceGoods extends BaseRequest
         'edit'                  => ['id','platform', 'product_name', 'product_specs', 'suggested_price'],
         'set_status'              => ['id', 'status'],
         'delete'                  => ['id'],
+        'spec_list'             => ['page', 'limit'],
     ];
 
     /**

+ 6 - 0
routes/api.php

@@ -55,12 +55,18 @@ Route::any('personnel_employee/list', [App\Http\Controllers\Api\Personnel\Employ
 // ------数据清洗配置------
 // 低价商品-列表
 Route::any('low_price_goods/list', [App\Http\Controllers\Api\WashConfig\LowPriceGoods::class, 'list']);
+// 低价商品规格-列表
+Route::any('low_price_goods_spec/list', [App\Http\Controllers\Api\WashConfig\LowPriceGoods::class, 'spec_list']);
 
 // 强管控商品-列表
 Route::any('strong_control_goods/list', [App\Http\Controllers\Api\WashConfig\ControlGoods::class, 'list']);
+// 强管控商品规格-列表
+Route::any('strong_control_goods_spec/list', [App\Http\Controllers\Api\WashConfig\ControlGoods::class, 'spec_list']);
 
 // 违规商品-列表
 Route::any('violation_goods/list', [App\Http\Controllers\Api\WashConfig\ViolationProduct::class, 'list']);
+// 违规商品规格-列表
+Route::any('violation_goods_spec/list', [App\Http\Controllers\Api\WashConfig\ViolationProduct::class, 'spec_list']);
 
 // 违规店铺公司-列表
 Route::any('violation_store/list', [App\Http\Controllers\Api\WashConfig\ViolationStore::class, 'list']);