Index.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use app\common\library\Area;
  6. /**
  7. * 首页接口
  8. */
  9. class Index extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. //测试完成
  14. public function test(){
  15. //取车坐标
  16. $get_longitude = input('get_longitude',118.416344);
  17. $get_latitude = input('get_latitude',35.054922);
  18. $back_longitude = input('back_longitude',117.974034);
  19. $back_latitude = input('back_latitude',35.271183);
  20. $company_can = [];//符合公司ids
  21. $companys = Db::name('company')->column('id');
  22. foreach($companys as $key => $val){
  23. $store_zuobiao = Db::name('store')->where('company_id',$val)->column('zuobiao');//某公司下所有门店的坐标
  24. if(empty($store_zuobiao)){
  25. continue;
  26. }
  27. dump($store_zuobiao);
  28. $newArr = []; //坐标集合
  29. foreach($store_zuobiao as $k => $v){
  30. if(empty($v)){ continue;}
  31. $v = json_decode($v, true);
  32. if(!is_array($v)){ continue;}
  33. /*if(isset($v[0]) && is_array($v[0])){
  34. $newArr[] = $v[0];
  35. }*/
  36. $newArr[] = $v;
  37. }
  38. dump($newArr);
  39. if(empty($newArr)){
  40. continue;
  41. }
  42. $area = new Area($newArr);
  43. $get_bol = $area->checkPoint($get_longitude, $get_latitude);
  44. $back_bol = $area->checkPoint($back_longitude, $back_latitude);
  45. dump($get_bol);
  46. dump($back_bol);
  47. //借车点和还车点都满足
  48. if($get_bol !== false && $back_bol !== false && $get_bol >= 0 && $back_bol >= 0){
  49. echo $val;
  50. $company_can[] = $val;
  51. }
  52. echo '<hr>';
  53. }
  54. dump($company_can);
  55. //取车坐标
  56. }
  57. /**
  58. * 首页
  59. *
  60. */
  61. public function index()
  62. {
  63. $this->success('请求成功');
  64. }
  65. //轮播图
  66. public function banner(){
  67. $list = Db::name('banner')->field('id,image,url,type')->where('status',1)->order('weight desc')->select();
  68. $list = list_domain_image($list,['image']);
  69. $this->success(1,$list);
  70. }
  71. //轮播图
  72. public function banner_info(){
  73. $id = input('id',0);
  74. $list = Db::name('banner')->field('id,image,url,type,title,content')->where('id',$id)->find();
  75. $list = info_domain_image($list,['image']);
  76. $this->success(1,$list);
  77. }
  78. //公告
  79. public function notice_index(){
  80. $one = Db::name('public_notice')->order('weigh desc')->select();
  81. $this->success('success',$one);
  82. }
  83. //公告详情
  84. public function notice_info(){
  85. $id = input('id',0);
  86. $one = Db::name('public_notice')->where('id',$id)->find();
  87. $this->success('success',$one);
  88. }
  89. //为你推荐
  90. public function intro_car(){
  91. $where = [];
  92. $where['car.status'] = 1;
  93. $orderby = 'car.price asc';
  94. //列表
  95. $list = Db::name('car')
  96. ->field('
  97. car.*,
  98. min(car.price) price_min,count(car.id) as baojianum,group_concat(car.id) as concat_car_id,
  99. p.type_id,p.brand_id,p.model_id,p.image,p.images,p.gear_id,p.pailiang,p.seat_id,
  100. company.back_ids,company.service_ids,
  101. brand.name as brand_name,model.name as model_name,gear.name as gear_name,seat.name as seat_name
  102. ')
  103. ->join('car_public p','car.carpublic_id = p.id','LEFT')
  104. ->join('company','car.company_id = company.id','LEFT')
  105. ->join('store','car.store_id = store.id','LEFT')
  106. ->join('car_enum_brand brand','p.brand_id = brand.id','LEFT')
  107. ->join('car_enum_model model','p.model_id = model.id','LEFT')
  108. ->join('car_enum_gear gear','p.gear_id = gear.id','LEFT')
  109. ->join('car_enum_seat seat','p.seat_id = seat.id','LEFT')
  110. ->where($where)->order($orderby)->group('carpublic_id')->limit(10)->select();
  111. $list = list_domain_image($list,['image','images']);
  112. $this->success('success',$list);
  113. }
  114. //帮助中心
  115. public function customer_hub(){
  116. //
  117. $top = Db::name('customer_hub')->field('id,title,pid')->where('id',1)->find();
  118. $top['child'] = Db::name('customer_hub')->field('id,title,pid')->where('pid',$top['id'])->order('id asc')->select();
  119. //
  120. $parent = Db::name('customer_hub')->field('id,title,pid')->where('pid',0)->where('id','gt',1)->order('id asc')->select();
  121. foreach($parent as $key => &$val){
  122. $val['child'] = Db::name('customer_hub')->field('id,title,pid')->where('pid',$val['id'])->order('id asc')->select();
  123. }
  124. //
  125. $rs['top'] = $top;
  126. $rs['list'] = $parent;
  127. $rs['mobile'] = config('site.kefu_mobile');
  128. $this->success(1,$rs);
  129. }
  130. //帮助中心,详情
  131. public function customer_info(){
  132. $id = input('id',0);
  133. $info = Db::name('customer_hub')->where('id',$id)->find();
  134. $this->success(1,$info);
  135. }
  136. //首页下方图片文章
  137. public function basedata(){
  138. $list = Db::name('index_basedata')->field('id,name,image,openpage')->order('id asc')->select();
  139. $list = list_domain_image($list,['image']);
  140. $this->success(1,$list);
  141. }
  142. //首页下方图片文章
  143. public function basedata_info(){
  144. $id = input('id',0);
  145. $info = Db::name('index_basedata')->where('id',$id)->find();
  146. $info = info_domain_image($info,['image']);
  147. $this->success(1,$info);
  148. }
  149. }