163 lines
5.8 KiB
PHP
163 lines
5.8 KiB
PHP
<?php
|
|
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Created by Vim
|
|
* User: lcc
|
|
* Desc: 预约信息
|
|
* Date: 2021.06.23
|
|
* Time: 14:08
|
|
*/
|
|
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
|
class Aptinfo extends Wxapp{
|
|
|
|
function __construct($inputs, $app_key){
|
|
parent::__construct($inputs, $app_key);
|
|
|
|
$this->login_white = array();//登录白名单
|
|
$this->check_status = array();//用户状态校验
|
|
$this->check_mobile = array();//需要手机号
|
|
$this->check_headimg =array();//授权微信信息
|
|
$this->load->model('app/liche/app_liche_cms_model', 'cms_model');
|
|
|
|
}
|
|
|
|
protected function get(){
|
|
$this->load->model("sys/sys_city_model");
|
|
$this->load->model('sys/sys_area_model');
|
|
|
|
$city_code = $this->input_param('c_code');
|
|
$cms_id = $this->input_param('cms_id');
|
|
|
|
!$city_code && $city_code = 350206;
|
|
$citys = $this->sys_city_model->select(['status'=>1],'','','','city_id,name');
|
|
|
|
$city_list = [];
|
|
foreach($citys as $key=>$val){
|
|
$areas = $this->sys_area_model->select(['city_id'=>$val['city_id'],'status'=>1],'','','','county_id,county_name');
|
|
if($areas){
|
|
$city_list[] = [
|
|
'id' => $val['city_id'],
|
|
'parid' => 1,
|
|
'name' => $val['name'],
|
|
'regtype' => 1
|
|
];
|
|
foreach($areas as $k1=>$v1){
|
|
$city_list[] = [
|
|
'id' => $v1['county_id'],
|
|
'parid' => $val['city_id'],
|
|
'name' => $v1['county_name'],
|
|
'regtype' => 2
|
|
];
|
|
}
|
|
}
|
|
}
|
|
//获取默认选中地区
|
|
$city_row = $this->sys_area_model->get(['county_id'=>$city_code,'status'=>1]);
|
|
if(!$city_row){
|
|
$city_row = $this->sys_area_model->get(['county_id'=>350206,'status'=>1]);
|
|
}
|
|
$default = $city_row['city_name'].'/'.$city_row['county_name'];
|
|
|
|
//获取背景图
|
|
$img = 'https://qs.haodian.cn/wechat_app/liche/buyCar/ex-default.jpg';
|
|
if($cms_id){
|
|
$cms = $this->cms_model->get(['id'=>$cms_id]);
|
|
$json = json_decode($cms['jsondata'], true);
|
|
$json['bg_img'] && $img = build_qiniu_image_url($json['bg_img']);
|
|
}
|
|
$data = [
|
|
'city_list' => $city_list,
|
|
'def_city' => $default,
|
|
'img' => $img,
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
protected function get_bizs(){
|
|
$data['data'] = [];
|
|
return $data; //展示隐藏没有门店
|
|
$city_id = $this->input_param('city_id');
|
|
if(!$city_id){
|
|
throw new Exception('参数错误', API_CODE_INVILD_PARAM);
|
|
}
|
|
|
|
$lat = $this->input_param('lat'); //纬度
|
|
$lng = $this->input_param('lng'); //经度
|
|
|
|
$this->load->model('biz/biz_model');
|
|
$filed = 'id,biz_name';
|
|
$lat = $this->db->escape($lat);
|
|
$lng = $this->db->escape($lng);
|
|
$city_id = $this->db->escape($city_id);
|
|
$where = " status=1 ";
|
|
$city_id && $where .= " and (city_id={$city_id} or county_id={$city_id}) ";
|
|
if($lat && $lng){
|
|
$sql = "select {$filed},round(sqrt(pow(lat-{$lat},2)+pow(lng-{$lng},2)),5)*80000 as dis from lc_biz where {$where} order by dis asc limit 20";
|
|
}else{
|
|
$sql = "select {$filed} from lc_biz where {$where} order by id desc limit 20";
|
|
}
|
|
$rows = $this->biz_model->db->query($sql)->result_array();
|
|
$list = [];
|
|
if($rows){
|
|
foreach($rows as $key=>$val){
|
|
$list[] = [
|
|
'id' => $val['id'],
|
|
'biz_name' => $val['biz_name']
|
|
];
|
|
}
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
//预约
|
|
protected function post(){
|
|
$cf_id = 1;
|
|
$this->load->model('receiver/receiver_clues_model','clues_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
|
|
$uid = $this->session['uid'];
|
|
$biz_id = $this->input_param('biz_id');
|
|
$series_id = $this->input_param('car_id');//车系id
|
|
$city_code = $this->input_param('city_id');
|
|
$recommend_id = intval($this->input_param('cf_uid')); //来源用户id
|
|
|
|
$series_row = $this->auto_series_model->get(['id'=>$series_id]);
|
|
$row = $this->clues_model->get(['cf_id'=>$cf_id,'cf_uid'=>$uid,'app_id'=>$this->app_id,'status'=>0]);
|
|
if($row){
|
|
$update = [
|
|
'en_time' => date('Y-m-d H:i:s')
|
|
];
|
|
$series_row['brand_id'] && $update['brand_id'] = $series_row['brand_id'];
|
|
$series_row['id'] && $update['s_id'] = $series_row['id'];
|
|
$this->clues_model->update($update,['id'=>$row['id']]);
|
|
throw new Exception('预约成功', API_CODE_SUCCESS);
|
|
}
|
|
|
|
$jsondata['info'] = [
|
|
'biz_id' => $biz_id ? $biz_id : '',
|
|
'city_code' => $city_code
|
|
];
|
|
$cf_platform = 'wxapp';
|
|
$add_data = [
|
|
'name' => $this->session['nickname'],
|
|
'mobile' => $this->session['mobile'],
|
|
'cf_uid' => $this->session['uid'],
|
|
'cf_id' => $cf_id,
|
|
'app_id' => $this->app_id,
|
|
'if_driver' => 1,
|
|
'cf_platform' => $cf_platform,
|
|
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE),
|
|
'en_time' => date('Y-m-d H:i:s'),
|
|
'c_time' => time()
|
|
];
|
|
|
|
$recommend_id && $add_data['recommend_id'] = $recommend_id;
|
|
$series_row['brand_id'] && $add_data['brand_id'] = $series_row['brand_id'];
|
|
$series_row['id'] && $add_data['s_id'] = $series_row['id'];
|
|
$this->clues_model->add($add_data);
|
|
throw new Exception('预约成功', API_CODE_SUCCESS);
|
|
}
|
|
|
|
}
|