Index.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. namespace app\abutment\logic;
  3. use think\facade\Config;
  4. use think\facade\Db;
  5. class Index
  6. {
  7. //获取上线平台列表
  8. public static function getPlatformList(string $keyword = '', int $page = 1, int $size = 15)
  9. {
  10. $db = Db::name('platform')->where('is_del', 0);
  11. if ($keyword != '') $db->whereLike('platform_name', '%' . $keyword . '%');
  12. $count = $db->count('id');
  13. $list = $db
  14. ->field('id platform_id,platform_code,platform_name,platform_type')
  15. ->order('id')
  16. ->page($page, $size)
  17. ->select()
  18. ->toArray();
  19. return json_show(0, '请求成功', ['count' => $count, 'list' => $list]);
  20. }
  21. //获取分类列表
  22. public static function getCatList(string $keyword = '', int $pid = 0)
  23. {
  24. $db = Db::name('cat')->where(['is_del' => 0, 'pid' => $pid]);
  25. if ($keyword != '') $db->whereLike('cat_name', '%' . $keyword . '%');
  26. $count = $db->count('id');
  27. $list = $db
  28. ->field('id cat_id,cat_name,level')
  29. ->order('id')
  30. ->select()
  31. ->toArray();
  32. return json_show(0, '请求成功', ['count' => $count, 'list' => $list]);
  33. }
  34. //获取品牌列表
  35. public static function getBrandList(string $keyword = '', int $page = 1, int $size = 15)
  36. {
  37. $db = Db::name('brand')->where('is_del', 0);
  38. if ($keyword != '') $db->whereLike('brand_name', '%' . $keyword . '%');
  39. $count = $db->count('id');
  40. $list = $db
  41. ->field('id brand_id,brand_name')
  42. ->order('id')
  43. ->page($page, $size)
  44. ->select()
  45. ->toArray();
  46. return json_show(0, '请求成功', ['count' => $count, 'list' => $list]);
  47. }
  48. //获取单位列表
  49. public static function getUnitList(string $keyword = '', int $page = 1, int $size = 15)
  50. {
  51. $db = Db::name('unit')->where('is_del', 0);
  52. if ($keyword != '') $db->whereLike('unit', '%' . $keyword . '%');
  53. $count = $db->count('id');
  54. $list = $db
  55. ->field('id unit_id,unit unit_name')
  56. ->order('id')
  57. ->page($page, $size)
  58. ->select()
  59. ->toArray();
  60. return json_show(0, '请求成功', ['count' => $count, 'list' => $list]);
  61. }
  62. //获取规格标题列表
  63. public static function getSpecsTitleList(string $keyword = '')
  64. {
  65. $db = Db::name('specs')->where('is_del', 0);
  66. if ($keyword != '') $db->whereLike('spec_name', '%' . $keyword . '%');
  67. $list = $db
  68. ->field('id spec_id,spec_name')
  69. ->order('addtime', 'desc')
  70. ->select()
  71. ->toArray();
  72. return json_show(0, '请求成功', $list);
  73. }
  74. //获取规格值列表
  75. public static function getSpecsValueByTitleList(int $spec_id = 0)
  76. {
  77. $db = Db::name('spec_value')->where('is_del', 0);
  78. if ($spec_id != '') $db->where('spec_id', $spec_id);
  79. $list = $db
  80. ->field('id spec_value_id,spec_id ,spec_value')
  81. ->order('id')
  82. ->select()
  83. ->toArray();
  84. return json_show(0, '请求成功', $list);
  85. }
  86. //获取省市区列表
  87. public static function getAreaList(int $level = 1, string $pid_code = '')
  88. {
  89. switch ($level) {
  90. case 1:
  91. $list = Db::name('province')
  92. ->field('province_code,name')
  93. ->order('id')
  94. ->select()
  95. ->toArray();
  96. break;
  97. case 2:
  98. $list = Db::name('city')
  99. ->field('city_code,name')
  100. ->where('province_code', $pid_code)
  101. ->order('id')
  102. ->select()
  103. ->toArray();
  104. break;
  105. case 3:
  106. $list = Db::name('area')
  107. ->field('area_code,name')
  108. ->where('city_code', $pid_code)
  109. ->order('id')
  110. ->select()
  111. ->toArray();
  112. break;
  113. }
  114. return json_show(0, '获取成功', $list);
  115. }
  116. //获取业务公司编码
  117. public static function getCompanyNoList(string $keyword = '')
  118. {
  119. $db = Db::name('business')->where('is_del', 0);
  120. if ($keyword != '') $db->whereLike('company|companyNo', '%' . $keyword . '%');
  121. $list = $db
  122. ->field('companyNo,company')
  123. ->order('id')
  124. ->select()
  125. ->toArray();
  126. return json_show(0, '请求成功', $list);
  127. }
  128. }