|
|
@@ -0,0 +1,210 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers\Manager\Process;
|
|
|
+
|
|
|
+use App\Http\Controllers\Controller;
|
|
|
+use App\Http\Requests\Manager\Process\ViolationProduct as Request;
|
|
|
+use App\Models\Manager\Process\ViolationProduct as ViolationProductModel;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 违规处理-违规商品
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ */
|
|
|
+class ViolationProduct extends Controller
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 列表
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function list(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ {
|
|
|
+ $request->scene('list')->validate();
|
|
|
+ // 查询条件
|
|
|
+ $map = [];
|
|
|
+ $limit = request('limit', config('page_num', 10));
|
|
|
+ $status = request('status', '');
|
|
|
+ $start_time = request('start_time', '');
|
|
|
+ $end_time = request('end_time', '');
|
|
|
+ $product_name = request('product_name', '');
|
|
|
+ $first_responsible_person = request('first_responsible_person', '');
|
|
|
+ $responsible_person = request('responsible_person', '');
|
|
|
+ $platform = request('platform', '');
|
|
|
+ $company_name = request('company_name', '');
|
|
|
+ $store_name = request('store_name', '');
|
|
|
+ $source_responsible_person = request('source_responsible_person', '');
|
|
|
+ $processing_status = request('processing_status', '');
|
|
|
+ // 时间条件
|
|
|
+ if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
+ if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
+ // 其他条件
|
|
|
+ if ($status) $map[] = ['status', '=', $status];
|
|
|
+ if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
|
|
|
+
|
|
|
+ if ($first_responsible_person) $map[] = ['first_responsible_person', 'like', "%$first_responsible_person%"];
|
|
|
+ if ($responsible_person) $map[] = ['responsible_person', 'like', "%$responsible_person%"];
|
|
|
+ if ($platform) $map[] = ['platform', 'like', "%$platform%"];
|
|
|
+ if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
|
|
|
+ if ($store_name) $map[] = ['store_name', 'like', "%$store_name%"];
|
|
|
+ if ($source_responsible_person) $map[] = ['source_responsible_person', 'like', "%$source_responsible_person%"];
|
|
|
+ if ($processing_status) $map[] = ['processing_status', '=', $processing_status];
|
|
|
+ // 查询数据
|
|
|
+ $result = $ViolationProductModel->query()
|
|
|
+ ->where($map)
|
|
|
+ ->orderByDesc('id')
|
|
|
+ ->paginate($limit)->toarray();
|
|
|
+ // 分配数据
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '暂无数据']);
|
|
|
+ // 加载模板
|
|
|
+ return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ */
|
|
|
+ public function detail(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ {
|
|
|
+ $request->scene('detail')->validate();
|
|
|
+ // 接收参数
|
|
|
+ $id = request('id', 0);
|
|
|
+ $map = ['id' => $id];
|
|
|
+ $data = $ViolationProductModel->where($map)->first();
|
|
|
+ if (!$data) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
|
+ // 加载模板
|
|
|
+ return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function add(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ {
|
|
|
+ $request->scene('add')->validate();
|
|
|
+ // 接收数据
|
|
|
+ $all_data = request()->all();
|
|
|
+ $store_scope = request('store_scope', '');
|
|
|
+ $all_data['store_scope'] = $store_scope;
|
|
|
+ //查询是否存在
|
|
|
+ $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
|
|
|
+ $data = $ViolationProductModel->where($map)->first();
|
|
|
+ if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
|
+ // 写入数据表
|
|
|
+ $result = $ViolationProductModel->addLowPriceGoods($all_data);
|
|
|
+ // 如果操作失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '新增失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '新增成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function edit(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ {
|
|
|
+ $request->scene('edit')->validate();
|
|
|
+ // 接收参数
|
|
|
+ $id = request('id', 0);
|
|
|
+ // 接收数据
|
|
|
+ $all_data = request()->all();
|
|
|
+ $store_scope = request('store_scope', '');
|
|
|
+ $all_data['store_scope'] = $store_scope;
|
|
|
+ //查询是否存在
|
|
|
+ $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
|
|
|
+ $data = $ViolationProductModel->where($map)->where('id', '!=', $id)->first();
|
|
|
+ if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
|
+ // 更新数据表
|
|
|
+ $where = ['id' => $id];
|
|
|
+ $result = $ViolationProductModel->updateLowPriceGoods($where, $all_data);
|
|
|
+ // 如果操作失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '修改失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '修改成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改状态
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function set_status(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ {
|
|
|
+ // 验证参数
|
|
|
+ $request->scene('set_status')->validate();
|
|
|
+ // 接收数据
|
|
|
+ $id = request('id', 0);
|
|
|
+ $status = request('status', 0);
|
|
|
+ // 查询用户
|
|
|
+ $where = ['id' => $id];
|
|
|
+ // 执行修改
|
|
|
+ $result = $ViolationProductModel->changeStatus($where, $status);
|
|
|
+ // 提示新增失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '设置失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '设置成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改处理状态
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function set_processing_status(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ {
|
|
|
+ // 验证参数
|
|
|
+ $request->scene('set_processing_status')->validate();
|
|
|
+ // 接收数据
|
|
|
+ $id = request('id', 0);
|
|
|
+ $processing_status = request('processing_status', 0);
|
|
|
+ // 查询用户
|
|
|
+ $where = ['id' => $id];
|
|
|
+ // 执行修改
|
|
|
+ $result = $ViolationProductModel->changeProcessingStatus($where, $processing_status);
|
|
|
+ // 提示新增失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '设置失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '设置成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-08
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function delete(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ {
|
|
|
+ // 验证参数
|
|
|
+ $request->scene('delete')->validate();
|
|
|
+ // 接收数据
|
|
|
+ $id = request('id', 0);
|
|
|
+ // 查询用户
|
|
|
+ $where = ['id' => $id];
|
|
|
+ // 执行删除
|
|
|
+ $result = $ViolationProductModel->deleteLowPriceGoods($where);
|
|
|
+ // 提示删除失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '删除失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '删除成功']);
|
|
|
+ }
|
|
|
+}
|