From f26475794f30f6c71257c04cb2fad989a9f47858 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 22 Mar 2022 17:19:46 +0800 Subject: [PATCH] introduce_322 --- admin/controllers/auto/Introduce.php | 173 +++++++- admin/controllers/biz/store/Store.php | 16 +- admin/views/auto/introduce/edit.php | 22 +- admin/views/auto/introduce/lists.php | 586 ++++++++++++++++++++------ api/controllers/wxapp/liche/Auto.php | 97 +++++ 5 files changed, 737 insertions(+), 157 deletions(-) create mode 100644 api/controllers/wxapp/liche/Auto.php diff --git a/admin/controllers/auto/Introduce.php b/admin/controllers/auto/Introduce.php index 7dd0fdb6..e51ac745 100644 --- a/admin/controllers/auto/Introduce.php +++ b/admin/controllers/auto/Introduce.php @@ -61,32 +61,89 @@ class Introduce extends HD_Controller ]; } } + $brandList = $this->mdAutoBrand->select(["status<>" => -1], 'id desc', 0, 0, 'id, name'); $this->data['lists'] = $lists; $this->data['params'] = $params; - $this->data['showInfo'] = ['statusAry' => $statusAry]; + $this->data['showInfo'] = ['statusAry' => $statusAry, 'brandList' => $brandList]; $this->data['_title'] = '车型介绍列表'; $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count); return $this->show_view('/auto/introduce/lists', true); } + //物料列表 + public function lists_material() + { + $params = $this->input->post(); + if (!$params['biz_id'] || !$params['introduces']) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + $list = []; + $introduces_ids = array_unique(array_column($params['introduces'], 'id')); + $str_ids = implode(',', $introduces_ids); + $res = $this->mdAutoIntroduce->select(["id in({$str_ids})" => null], "id desc", 0, 0); + $map_brand = $map_series = []; + $brand_ids = array_unique(array_column($res, 'brand_id')); + if ($brand_ids) { + $str_ids = implode(',', $brand_ids); + $map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]); + } + $s_ids = array_unique(array_column($res, 's_id')); + if ($s_ids) { + $str_ids = implode(',', $s_ids); + $map_series = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]); + } + foreach ($res as $key => $value) { + $brand_name = $map_brand[$value['brand_id']]; + $s_name = $map_series[$value['s_id']]; + $title = "{$brand_name}-{$s_name}"; + $scene = "{$value['id']}_{$params['biz_id']}"; + $page = 'pages/storeInfo/index';//pages/modelShow/index + $name = $params['biz_name'] . '_' . $title; + $qr_code = $this->qrcode($scene, $page, '1280px', $name); + $list[] = [ + 'title' => $title, + 'url' => "{$page}?id={$scene}", + 'qr_code' => $qr_code['url'] ? $qr_code['url'] : '', + ]; + } + $this->data['list'] = $list; + return $this->show_json(SYS_CODE_SUCCESS, '物料列表!'); + } //展示单条数据 public function get() { $id = intval($this->input->get('id')); - $info = []; if ($id) { $re = $this->mdAutoIntroduce->get(['id' => $id]); if (!$re) { return $this->show_json(SYS_CODE_FAIL, '车型不存在!'); } + $video = $re['video'] ? build_qiniu_image_url($re['video'], 0, 0, 'video') : ''; + $info = array( + 'id' => $re['id'], + 'brand_id' => $re['brand_id'], + 's_id' => $re['s_id'], + 'video_file_url' => $re['video'], + 'video' => $video, + 'video_cover' => $video . '?vframe/jpg/offset/1', + 'content' => $re['content'], + ); + $title = '请选择车型'; + if ($re['s_id']) { + $re_b = $this->mdAutoBrand->get(['id' => $re['brand_id']]); + $re_b && $title = $re_b['name']; + $re_s = $this->mdAutoSeries->get(['id' => $re['s_id']]); + $re_s && $title = $title ? $title . '-' . $re_s['name'] : $title; + } $_title = '编辑车型介绍'; - $showInfo = ['title' => '请选择车型', 'url' => '/auto/introduce/edit']; + $showInfo = ['title' => $title, 'url' => '/auto/introduce/edit']; } else { $_title = '新增车型介绍'; $info = array( 'brand_id' => 0, 's_id' => 0, + 'video_file_url' => '', 'video' => '', 'video_cover' => '', 'content' => '', @@ -97,40 +154,52 @@ class Introduce extends HD_Controller $this->data['_title'] = $_title; $this->data['info'] = $info; $this->data['showInfo'] = $showInfo; - return $this->show_view('/auto/introduce/edit',true); + return $this->show_view('/auto/introduce/edit', true); } //添加单条数据 public function add() { $params = $this->input->post(); - if (!$params['name']) { - return $this->show_json(SYS_CODE_FAIL, '标签名称不能为空!'); + $info = $params['info']; + if (!$info) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); } - $re = $this->mdCustomerTag->get(array('name' => $params['name'])); + if (!$info['brand_id'] || !$info['s_id']) { + return $this->show_json(SYS_CODE_FAIL, '请选择车型!'); + } + if (!$info['video_file_url']) { + return $this->show_json(SYS_CODE_FAIL, '请上传视频!'); + } + $re = $this->mdAutoIntroduce->get(array('brand_id' => $info['brand_id'], 's_id' => $info['s_id'])); if ($re) { - return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!'); + return $this->show_json(SYS_CODE_FAIL, '车型已存在了!'); } - $this->mdCustomerTag->add(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type']]); - return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + $this->mdAutoIntroduce->add(['brand_id' => $info['brand_id'], 's_id' => $info['s_id'], 'video' => $info['video_file_url'] + , 'content' => $info['content'], 'c_time' => time()]); + return $this->show_json(SYS_CODE_SUCCESS, '新增成功', '/auto/introduce'); } //编辑单条数据 public function edit() { $params = $this->input->post(); - if (!$params['id']) { - return $this->show_json(SYS_CODE_FAIL, '参数错误'); + $info = $params['info']; + if (!$info) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); } - if (!$params['name']) { - return $this->show_json(SYS_CODE_FAIL, '请输入标签名称'); + if (!$info['brand_id'] || !$info['s_id']) { + return $this->show_json(SYS_CODE_FAIL, '请选择车型!'); } - $re = $this->mdCustomerTag->get(array('name' => $params['name'])); - if ($re && $re['id'] != $params['id']) { - return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!'); + if (!$info['video_file_url']) { + return $this->show_json(SYS_CODE_FAIL, '请上传视频!'); } - $this->mdCustomerTag->update(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type']] - , ['id' => $params['id']]); + $re = $this->mdAutoIntroduce->get(array('brand_id' => $info['brand_id'], 's_id' => $info['s_id'])); + if ($re && $re['id'] != $info['id']) { + return $this->show_json(SYS_CODE_FAIL, '车型已存在了!'); + } + $this->mdAutoIntroduce->update(['brand_id' => $info['brand_id'], 's_id' => $info['s_id'], 'content' => $info['content'] + , 'video' => $info['video_file_url']], ['id' => $info['id']]); return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } @@ -167,4 +236,70 @@ class Introduce extends HD_Controller { } + + private function qrcode($scene, $page = '', $width = 0, $name = '') + { + $path = "{$page}?{$scene}"; + $width && $path .= "{$width}"; + $this->load->model('app/app_model', 'mdApp'); + $wxconfig = $this->mdApp->appConfig()[1]['wx']; + //$filename = "{$this->mdApp->appConfig()[1]['app_key']}/" . substr(md5($path), 8, 16); + $filename = "{$this->mdApp->appConfig()[1]['app_key']}/{$name}"; + $this->load->library('hdwechat', $wxconfig); + $result = $this->hdwechat->qrcode($filename, $scene, $page, $width); + if (!$result) { + return ['url' => '']; + } + $data = array('url' => http_host_com() . '/' . $result['url']); + return $data; + } + + /** + * Notes: + * Created on: 2022/3/21 16:16 + * Created by: dengbw + * @return bool + */ + function json_lists() + { + $page = $this->input->post('page'); + $size = $this->input->post('size'); + $status = $this->input->post('status'); + $brand_id = intval($this->input->post('brand_id')); + $where = array(); + $brand_id && $where["brand_id"] = $brand_id; + if (strlen($status) > 0) { + $where['status'] = $status; + } else { + $where['status > -1'] = null; + } + $total = $this->mdAutoIntroduce->count($where); + $lists = array(); + if ($total) { + $orderby = 'id desc'; + $select = 'id,brand_id, s_id'; + $res = $this->mdAutoIntroduce->select($where, $orderby, $page, $size, $select); + $map_brand = $map_series = []; + $brand_ids = array_unique(array_column($res, 'brand_id')); + if ($brand_ids) { + $str_ids = implode(',', $brand_ids); + $map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]); + } + $s_ids = array_unique(array_column($res, 's_id')); + if ($s_ids) { + $str_ids = implode(',', $s_ids); + $map_series = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]); + } + foreach ($res as $v) { + $brand_name = $map_brand[$v['brand_id']]; + $s_name = $map_series[$v['s_id']]; + $lists[] = array( + 'id' => $v['id'], + 'name' => "{$brand_name}-{$s_name}", + ); + } + } + $this->data = array('total' => $total, 'list' => $lists); + return $this->show_json(SYS_CODE_SUCCESS); + } } \ No newline at end of file diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php index 1d66eb77..23ae87aa 100755 --- a/admin/controllers/biz/store/Store.php +++ b/admin/controllers/biz/store/Store.php @@ -883,21 +883,27 @@ class Store extends HD_Controller $status = $this->input->post('status'); $page = $this->input->post('page'); $size = $this->input->post('size'); + $title = $this->input->post('title'); + $type = $this->input->post('type'); $where = array(); if (strlen($status) > 0) { $where['status'] = $status; } else { - $whre['status > -1'] = null; + $where['status > -1'] = null; } - if ($_SESSION['admin_info']['biz_id']) { - $biz_ids = implode(',', $_SESSION['admin_info']['biz_id']); - $where["id in ($biz_ids)"] = null; + if ($type) { + $where["type in({$type})"] = null; + } else { + if ($_SESSION['admin_info']['biz_id']) { + $biz_ids = implode(',', $_SESSION['admin_info']['biz_id']); + $where["id in ($biz_ids)"] = null; + } } $province_id && $where['province_id'] = $province_id; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; - + $title && $where["biz_name like '%{$title}%'"] = null; $total = $this->biz_model->count($where); $lists = array(); diff --git a/admin/views/auto/introduce/edit.php b/admin/views/auto/introduce/edit.php index 3e4d971d..d81a8018 100644 --- a/admin/views/auto/introduce/edit.php +++ b/admin/views/auto/introduce/edit.php @@ -1,7 +1,7 @@
-
+
@@ -10,7 +10,7 @@
- +
\ No newline at end of file + require(['clipboard'], function (Clipboard) { + var clipboard = new Clipboard('[data-clipboard-text]'); + clipboard.on('success', function (e) { + $.msg.success('复制成功'); + e.clearSelection(); + }); + clipboard.on('error', function (e) { + $.msg.error('复制失败'); + console.error('Action:', e.action); + console.error('Trigger:', e.trigger); + }); + }); + + \ No newline at end of file diff --git a/api/controllers/wxapp/liche/Auto.php b/api/controllers/wxapp/liche/Auto.php new file mode 100644 index 00000000..b8482065 --- /dev/null +++ b/api/controllers/wxapp/liche/Auto.php @@ -0,0 +1,97 @@ +login_white = array('get');//登录白名单 + } + + /** + * Notes:车型介绍 + * Created on: 2022/3/22 16:38 + * Created by: dengbw + * @return array + * @throws Exception + */ + protected function get_introduce() + { + $this->load->model('auto/auto_introduce_model', 'mdAutoIntroduce'); + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $id = intval($this->input_param('id')); + $re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1)); + if (!$re || empty($re)) { + throw new Exception('车型介绍不存在', API_CODE_FAIL); + } + $sign_up = $this->session['mobile'] ? 0 : 1; + $title = ''; + if ($re['s_id']) { + $re_b = $this->mdAutoBrand->get(['id' => $re['brand_id']]); + $re_b && $title = $re_b['name']; + $re_s = $this->mdAutoSeries->get(['id' => $re['s_id']]); + $re_s && $title = $title ? $title . '-' . $re_s['name'] : $title; + } + $data = array( + 'title' => $title . '_车型介绍', + "video" => $re['video'] ? build_qiniu_image_url($re['video'], 0, 0, 'video') : '', + 'content' => $re['content'], + 'sign_up' => $sign_up, + ); + return $data; + } + + /** + * Notes:车型介绍报名 + * Created on: 2021/11/26 11:05 + * Created by: dengbw + * @return mixed + * @throws Exception + */ + protected function put_introduce() + { + $biz_id = intval($this->input_param('biz_id')); + if (!$biz_id || !$this->session['mobile']) { + throw new Exception('参数错误', API_CODE_INVILD_PARAM); + } + $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); + $this->load->model("biz/biz_model", 'mdBiz'); + $re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]); + if (!$re_biz) { + throw new Exception('门店不存在!', API_CODE_FAIL); + } + $of_id = 1;//自然进店 + $add_data = [ + 'name' => $this->session['nickname'] ? $this->session['nickname'] : '', + 'mobile' => $this->session['mobile'], + 'biz_id' => $biz_id, + 'city_id' => $re_biz['city_id'], + 'county_id' => $re_biz['county_id'], + 'cf_title' => '自有资源', + 'of_id' => $of_id, + 'p_time' => date('Y-m-d H:i:s'), + 'c_time' => time() + ]; + $where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile']]; + $re_cus = $this->mdCustomers->get($where); + if ($re_cus) { + throw new Exception('报名成功了!', API_CODE_SUCCESS); + } + $id = $this->mdCustomers->add($add_data); + if (!$id) { + throw new Exception('预约报名失败!', API_CODE_FAIL); + } + throw new Exception('报名成功!', API_CODE_SUCCESS); + } + +} \ No newline at end of file