123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- use app\common\library\Area;
- /**
- * 首页接口
- */
- class Index extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- //测试完成
- public function test(){
- //取车坐标
- $get_longitude = input('get_longitude',118.416344);
- $get_latitude = input('get_latitude',35.054922);
- $back_longitude = input('back_longitude',117.974034);
- $back_latitude = input('back_latitude',35.271183);
- $company_can = [];//符合公司ids
- $companys = Db::name('company')->column('id');
- foreach($companys as $key => $val){
- $store_zuobiao = Db::name('store')->where('company_id',$val)->column('zuobiao');//某公司下所有门店的坐标
- if(empty($store_zuobiao)){
- continue;
- }
- dump($store_zuobiao);
- $newArr = []; //坐标集合
- foreach($store_zuobiao as $k => $v){
- if(empty($v)){ continue;}
- $v = json_decode($v, true);
- if(!is_array($v)){ continue;}
- /*if(isset($v[0]) && is_array($v[0])){
- $newArr[] = $v[0];
- }*/
- $newArr[] = $v;
- }
- dump($newArr);
- if(empty($newArr)){
- continue;
- }
- $area = new Area($newArr);
- $get_bol = $area->checkPoint($get_longitude, $get_latitude);
- $back_bol = $area->checkPoint($back_longitude, $back_latitude);
- dump($get_bol);
- dump($back_bol);
- //借车点和还车点都满足
- if($get_bol !== false && $back_bol !== false && $get_bol >= 0 && $back_bol >= 0){
- echo $val;
- $company_can[] = $val;
- }
- echo '<hr>';
- }
- dump($company_can);
- //取车坐标
- }
- /**
- * 首页
- *
- */
- public function index()
- {
- $this->success('请求成功');
- }
- //轮播图
- public function banner(){
- $list = Db::name('banner')->field('id,image,url,type')->where('status',1)->order('weight desc')->select();
- $list = list_domain_image($list,['image']);
- $this->success(1,$list);
- }
- //轮播图
- public function banner_info(){
- $id = input('id',0);
- $list = Db::name('banner')->field('id,image,url,type,title,content')->where('id',$id)->find();
- $list = info_domain_image($list,['image']);
- $this->success(1,$list);
- }
- //公告
- public function notice_index(){
- $one = Db::name('public_notice')->order('weigh desc')->select();
- $this->success('success',$one);
- }
- //公告详情
- public function notice_info(){
- $id = input('id',0);
- $one = Db::name('public_notice')->where('id',$id)->find();
- $this->success('success',$one);
- }
- //为你推荐
- public function intro_car(){
- $where = [];
- $where['car.status'] = 1;
- $orderby = 'car.price asc';
- //列表
- $list = Db::name('car')
- ->field('
- car.*,
- min(car.price) price_min,count(car.id) as baojianum,group_concat(car.id) as concat_car_id,
- p.type_id,p.brand_id,p.model_id,p.image,p.images,p.gear_id,p.pailiang,p.seat_id,
- company.back_ids,company.service_ids,
- brand.name as brand_name,model.name as model_name,gear.name as gear_name,seat.name as seat_name
- ')
- ->join('car_public p','car.carpublic_id = p.id','LEFT')
- ->join('company','car.company_id = company.id','LEFT')
- ->join('store','car.store_id = store.id','LEFT')
- ->join('car_enum_brand brand','p.brand_id = brand.id','LEFT')
- ->join('car_enum_model model','p.model_id = model.id','LEFT')
- ->join('car_enum_gear gear','p.gear_id = gear.id','LEFT')
- ->join('car_enum_seat seat','p.seat_id = seat.id','LEFT')
- ->where($where)->order($orderby)->group('carpublic_id')->limit(10)->select();
- $list = list_domain_image($list,['image','images']);
- $this->success('success',$list);
- }
- //帮助中心
- public function customer_hub(){
- //
- $top = Db::name('customer_hub')->field('id,title,pid')->where('id',1)->find();
- $top['child'] = Db::name('customer_hub')->field('id,title,pid')->where('pid',$top['id'])->order('id asc')->select();
- //
- $parent = Db::name('customer_hub')->field('id,title,pid')->where('pid',0)->where('id','gt',1)->order('id asc')->select();
- foreach($parent as $key => &$val){
- $val['child'] = Db::name('customer_hub')->field('id,title,pid')->where('pid',$val['id'])->order('id asc')->select();
- }
- //
- $rs['top'] = $top;
- $rs['list'] = $parent;
- $rs['mobile'] = config('site.kefu_mobile');
- $this->success(1,$rs);
- }
- //帮助中心,详情
- public function customer_info(){
- $id = input('id',0);
- $info = Db::name('customer_hub')->where('id',$id)->find();
- $this->success(1,$info);
- }
- //首页下方图片文章
- public function basedata(){
- $list = Db::name('index_basedata')->field('id,name,image,openpage')->order('id asc')->select();
- $list = list_domain_image($list,['image']);
- $this->success(1,$list);
- }
- //首页下方图片文章
- public function basedata_info(){
- $id = input('id',0);
- $info = Db::name('index_basedata')->where('id',$id)->find();
- $info = info_domain_image($info,['image']);
- $this->success(1,$info);
- }
- }
|