ViolationStore.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Http\Controllers\Api\WashConfig;
  3. use App\Http\Controllers\Api\Api;
  4. use App\Http\Requests\Api\WashConfig\ViolationStore as Request;
  5. use App\Models\Api\WashConfig\ViolationStore as ViolationStoreModel;
  6. /**
  7. * 数据清洗-违规店铺(公司)配置
  8. * @author 唐远望
  9. * @version 1.0
  10. * @date 2025-12-03
  11. */
  12. class ViolationStore extends Api
  13. {
  14. /**
  15. * 列表
  16. * @author 唐远望
  17. * @version 1.0
  18. * @date 2025-12-03
  19. *
  20. */
  21. public function list(Request $request, ViolationStoreModel $ViolationStoreModel)
  22. {
  23. $user_info = $this->checkLogin();
  24. if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
  25. $request->scene('list')->validate();
  26. // 查询条件
  27. $map = [];
  28. $limit = request('limit', config('page_num', 10));
  29. $status = request('status', '0');
  30. $start_time = request('start_time', '');
  31. $end_time = request('end_time', '');
  32. $store_name = request('store_name', '');
  33. $company_name = request('company_name', '');
  34. $social_credit_code = request('social_credit_code', '');
  35. $store_type = request('store_type', '');
  36. // 时间条件
  37. if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
  38. if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
  39. // 其他条件
  40. if (is_numeric($status)) $map[] = ['status', '=', $status];
  41. if ($social_credit_code) $map[] = ['social_credit_code', 'like', "%$social_credit_code%"];
  42. if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
  43. if ($store_name) $map[] = ['store_name', 'like', "%$store_name%"];
  44. if ($store_type) $map[] = ['store_type', '=', $store_type];
  45. // 查询数据
  46. $result = $ViolationStoreModel->query()
  47. ->where($map)
  48. ->orderByDesc('id')
  49. ->select(['id','company_name'])
  50. ->paginate($limit);
  51. // 分配数据
  52. if (!$result) return json_send(['code' => 'error', 'msg' => '暂无数据']);
  53. // 加载模板
  54. return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
  55. }
  56. }