From 6ce84441191cbac52b073c9886e5fdd1a69f751f Mon Sep 17 00:00:00 2001 From: dengbw Date: Wed, 23 Mar 2022 11:06:00 +0800 Subject: [PATCH] introduce_322_2 --- admin/controllers/app/liche/Main.php | 11 +++++++++++ api/controllers/wxapp/liche/Auto.php | 27 +++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/admin/controllers/app/liche/Main.php b/admin/controllers/app/liche/Main.php index f73fd62b..19352844 100644 --- a/admin/controllers/app/liche/Main.php +++ b/admin/controllers/app/liche/Main.php @@ -129,6 +129,17 @@ class Main extends HD_Controller array('name' => '查看详情', 'url' => '/app/liche/order'), ), ); + + $this->load->model('auto/auto_introduce_model', 'mdAutoIntroduce'); + $value = $this->mdAutoIntroduce->count(["status<>-1" => null]); + $list[] = array( + 'title' => '车型介绍(条)', + 'value' => $value, + 'btns' => array( + array('name' => '查看详情', 'url' => '/auto/introduce'), + ), + ); + $conditions[] = array('icon' => 'am-icon-home', 'list' => $list); /*实时数据 end*/ diff --git a/api/controllers/wxapp/liche/Auto.php b/api/controllers/wxapp/liche/Auto.php index b8482065..686aa18e 100644 --- a/api/controllers/wxapp/liche/Auto.php +++ b/api/controllers/wxapp/liche/Auto.php @@ -61,14 +61,21 @@ class Auto extends Wxapp 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); + $id = intval($this->input_param('id')); + if (!$id || !$biz_id || !$this->session['mobile']) { + throw new Exception('参数错误', API_CODE_SUCCESS); } $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $this->load->model("biz/biz_model", 'mdBiz'); + $this->load->model('auto/auto_introduce_model', 'mdAutoIntroduce'); + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1)); + if (!$re || empty($re)) { + throw new Exception('车型介绍不存在', API_CODE_SUCCESS); + } $re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]); if (!$re_biz) { - throw new Exception('门店不存在!', API_CODE_FAIL); + throw new Exception('门店不存在!', API_CODE_SUCCESS); } $of_id = 1;//自然进店 $add_data = [ @@ -89,7 +96,19 @@ class Auto extends Wxapp } $id = $this->mdCustomers->add($add_data); if (!$id) { - throw new Exception('预约报名失败!', API_CODE_FAIL); + throw new Exception('预约报名失败!', API_CODE_SUCCESS); + } + $re_b = $this->mdAutoBrand->get(['id' => $re['brand_id']]); + if ($re_b['name']) { + $this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag'); + $this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata'); + $re_tag = $this->mdCustomerTag->get(['pid' => 1, 'name' => $re_b['name']]); + if ($re_tag) { + $re_tag_data = $this->mdCustomerTagdata->get(['c_id' => $id, 't_id' => $re_tag['id']]); + if (!$re_tag_data) {//添加客户标签 + $this->mdCustomerTagdata->add(['c_id' => $id, 't_id' => $re_tag['id'], 'c_time' => time()]); + } + } } throw new Exception('报名成功!', API_CODE_SUCCESS); }