|
|
@@ -0,0 +1,176 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers\Manager\WashConfig;
|
|
|
+
|
|
|
+use App\Http\Controllers\Controller;
|
|
|
+use App\Http\Requests\Manager\WashConfig\ViolationStore as Request;
|
|
|
+use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 数据清洗-违规店铺配置
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-03
|
|
|
+ */
|
|
|
+class ViolationStore extends Controller
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 列表
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-03
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function list(Request $request, ViolationStoreModel $ViolationStoreModel)
|
|
|
+ {
|
|
|
+ $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', '');
|
|
|
+ $store_name = request('store_name', '');
|
|
|
+ $company_name = request('company_name', '');
|
|
|
+ $social_credit_code = request('social_credit_code', '');
|
|
|
+ // 时间条件
|
|
|
+ if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
+ if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
+ // 其他条件
|
|
|
+ if ($status) $map[] = ['status', '=', $status];
|
|
|
+ if ($social_credit_code) $map[] = ['social_credit_code', 'like', "%$social_credit_code%"];
|
|
|
+ if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
|
|
|
+ if ($store_name) $map[] = ['store_name', 'like', "%$store_name%"];
|
|
|
+ // 查询数据
|
|
|
+ $result = $ViolationStoreModel->query()
|
|
|
+ ->where($map)
|
|
|
+ ->orderByDesc('id')
|
|
|
+ ->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-03
|
|
|
+ */
|
|
|
+ public function detail(Request $request, ViolationStoreModel $ViolationStoreModel)
|
|
|
+ {
|
|
|
+ $request->scene('detail')->validate();
|
|
|
+ // 接收参数
|
|
|
+ $id = request('id', 0);
|
|
|
+ $map = ['id' => $id];
|
|
|
+ $data = $ViolationStoreModel->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-03
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function add(Request $request, ViolationStoreModel $ViolationStoreModel)
|
|
|
+ {
|
|
|
+ $request->scene('add')->validate();
|
|
|
+ // 接收数据
|
|
|
+ $all_data = request()->all();
|
|
|
+ $store_scope = request('store_scope', '');
|
|
|
+ $all_data['store_scope'] = $store_scope;
|
|
|
+ //查询是否存在
|
|
|
+ $map = ['store_name' => $all_data['store_name'], 'company_name' => $all_data['company_name']];
|
|
|
+ $data = $ViolationStoreModel->where($map)->first();
|
|
|
+ if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
|
+ // 写入数据表
|
|
|
+ $result = $ViolationStoreModel->addViolationStore($all_data);
|
|
|
+ // 如果操作失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '新增失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '新增成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-03
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function edit(Request $request, ViolationStoreModel $ViolationStoreModel)
|
|
|
+ {
|
|
|
+ $request->scene('edit')->validate();
|
|
|
+ // 接收参数
|
|
|
+ $id = request('id', 0);
|
|
|
+ // 接收数据
|
|
|
+ $all_data = request()->all();
|
|
|
+ $store_scope = request('store_scope','');
|
|
|
+ $all_data['store_scope'] = $store_scope;
|
|
|
+ //查询是否存在
|
|
|
+ $map = ['store_name' => $all_data['store_name'], 'company_name' => $all_data['company_name']];
|
|
|
+ $data = $ViolationStoreModel->where($map)->where('id', '!=', $id)->first();
|
|
|
+ if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
|
+ // 更新数据表
|
|
|
+ $where = ['id' => $id];
|
|
|
+ $result = $ViolationStoreModel->updateViolationStore($where, $all_data);
|
|
|
+ // 如果操作失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '修改失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '修改成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改状态
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-03
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function set_status(Request $request, ViolationStoreModel $ViolationStoreModel)
|
|
|
+ {
|
|
|
+ // 验证参数
|
|
|
+ $request->scene('set_status')->validate();
|
|
|
+ // 接收数据
|
|
|
+ $id = request('id', 0);
|
|
|
+ $status = request('status', 0);
|
|
|
+ // 查询用户
|
|
|
+ $where = ['id' => $id];
|
|
|
+ // 执行修改
|
|
|
+ $result = $ViolationStoreModel->changeStatus($where, $status);
|
|
|
+ // 提示新增失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '设置失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '设置成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-03
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function delete(Request $request, ViolationStoreModel $ViolationStoreModel)
|
|
|
+ {
|
|
|
+ // 验证参数
|
|
|
+ $request->scene('delete')->validate();
|
|
|
+ // 接收数据
|
|
|
+ $id = request('id', 0);
|
|
|
+ // 查询用户
|
|
|
+ $where = ['id' => $id];
|
|
|
+ // 执行删除
|
|
|
+ $result = $ViolationStoreModel->deleteViolationStore($where);
|
|
|
+ // 提示删除失败
|
|
|
+ if (!$result) return json_send(['code' => 'error', 'msg' => '删除失败']);
|
|
|
+ // 告知结果
|
|
|
+ return json_send(['code' => 'success', 'msg' => '删除成功']);
|
|
|
+ }
|
|
|
+}
|