diff --git a/admin/controllers/app/material/Template.php b/admin/controllers/app/material/Template.php index c48d2f27..c8a0544a 100644 --- a/admin/controllers/app/material/Template.php +++ b/admin/controllers/app/material/Template.php @@ -84,7 +84,7 @@ class Template extends HD_Controller if ($params['biz_name']) { $where['biz_id in (select id from lc_biz where biz_name like "%' . $params['biz_name'] . '%")'] = null; } - $count = $this->mdMaterialBiz->count($where,'distinct(biz_id)'); + $count = $this->mdMaterialBiz->count($where, 'distinct(biz_id)'); if ($count) { $fileds = "distinct(biz_id)"; $res = $this->mdMaterialBiz->select($where, "biz_id desc", $params['page'], $params['size'], $fileds); @@ -163,6 +163,7 @@ class Template extends HD_Controller $info['type'] = 4; $info['cover'] = array('value' => '', 'src' => ''); $info['moments'] = ''; + $info['tag_id'] = ''; $json_lists = $json_item = $brands = $pyqwa_list = array(); foreach ($this->mdTemplate->typeAry() as $key => $value) { $json_lists[$key] = array(); @@ -173,10 +174,11 @@ class Template extends HD_Controller if (!$re || empty($re)) { return $this->show_json(SYS_CODE_FAIL, '模板不存在!'); } - $moments = ''; + $moments = $tag_id = ''; if ($re['json_data']) { $json_data = json_decode($re['json_data'], true); $json_data['moments'] && $moments = $json_data['moments']; + $json_data['tag_id'] && $tag_id = $json_data['tag_id']; $lists = array(); foreach ($json_data['lists'] as $key => $value) { if ($re['type'] == 1) { @@ -213,6 +215,7 @@ class Template extends HD_Controller } $info = $re; $info['moments'] = $moments; + $info['tag_id'] = $tag_id; $info['cover'] = $info['cover'] ? array('value' => $info['cover'], 'src' => build_qiniu_image_url($info['cover'])) : array('value' => '', 'src' => ''); if ($info['brand_ids']) { @@ -227,6 +230,7 @@ class Template extends HD_Controller } $showInfo['statusAry'] = $this->mdTemplate->statusAry(); $showInfo['typeAry'] = $this->mdTemplate->typeAry(); + $showInfo['tagAry'] = $this->mdTemplate->tagAry(); $showInfo['brands'] = $brands; $showInfo['pyqwa_list'] = $pyqwa_list; $showInfo['json_lists'] = $json_lists; @@ -272,6 +276,7 @@ class Template extends HD_Controller } } $json_data['moments'] = $info['moments']; + $json_data['tag_id'] = $info['tag_id']; if ($info['lists']) { $lists = array(); foreach ($info['lists'] as $key => $value) { @@ -332,6 +337,7 @@ class Template extends HD_Controller } } $json_data['moments'] = $info['moments']; + $json_data['tag_id'] = $info['tag_id']; if ($info['lists']) { $lists = array(); foreach ($info['lists'] as $key => $value) { diff --git a/admin/views/app/material/template/edit.php b/admin/views/app/material/template/edit.php index 0748fc55..33cdfd84 100644 --- a/admin/views/app/material/template/edit.php +++ b/admin/views/app/material/template/edit.php @@ -31,9 +31,7 @@
@@ -51,6 +49,15 @@ +
+ +
+ +
+
@@ -195,7 +202,8 @@
-
+
login_white = array();//登录白名单 $this->check_status = array();//用户状态校验 $this->check_mobile = array();//需要手机号 - $this->check_headimg =array();//授权微信信息 + $this->check_headimg = array();//授权微信信息 $this->load->model('receiver/receiver_clues_model'); $this->load->model('receiver/receiver_clue_oplogs_model'); $this->load->model('receiver/order/receiver_orders_model'); $this->load->model('auto/auto_brand_model'); } - protected function get(){ + protected function get() + { $id = $this->input_param('id'); - if($id){ + if ($id) { return $this->detail($id); - }else{ + } else { return $this->lists(); } } - protected function post(){ + protected function post() + { $cf_id = 8; $name = $this->input_param('name'); $mobile = $this->input_param('mobile'); $brand_id = $this->input_param('brand_id'); $remark = $this->input_param('remark'); - if(!$mobile||!$name||!$brand_id){ + $intro_biz_id = intval($this->input_param('intro_biz_id')); + $intro_uid = intval($this->input_param('intro_uid')); + if (!$mobile || !$name || !$brand_id) { throw new Exception('参数错误', ERR_PARAMS_ERROR); } - if(!mobile_valid($mobile)){ + if (!mobile_valid($mobile)) { throw new Exception('手机号格式错误', ERR_PARAMS_ERROR); } - $row = $this->receiver_clues_model->get(['mobile'=>$mobile]); - if($row){ + $row = $this->receiver_clues_model->get(['mobile' => $mobile]); + if ($row) { throw new Exception('该手机号已报备', ERR_PARAMS_ERROR); } - $add_data = [ 'app_id' => $this->app_id, 'name' => $name, @@ -56,96 +62,149 @@ class Clues extends Wxapp{ 'brand_id' => $brand_id, 'recommend_id' => $this->session['uid'], 'cf_uid' => $this->session['uid'], - 'cf_id' => $cf_id, 'cf_platform' => 'wxapp', 'en_time' => date('Y-m-d H:i:s'), 'c_time' => time() ]; - $res = $this->receiver_clues_model->add($add_data); - if(is_numeric($res)){ - if($remark){ //添加日志 - $this->load->library('receiver/clues_entity'); - $this->clues_entity->add_log($res,$this->session['uid'],$this->session['nickname'],$remark); + //转介绍 + $re_biz = []; + if ($intro_biz_id || $intro_uid) { + $cf_id = 32; + $this->load->model("biz/biz_model", 'mdBiz'); + $re_biz = $this->mdBiz->get(['id' => $intro_biz_id, 'status' => 1]); + if (!$re_biz) { + throw new Exception('无此门店', ERR_PARAMS_ERROR); + } + $add_data['city_id'] = $re_biz['city_id'];//城市id + $add_data['county_id'] = $re_biz['county_id'];//区id + $add_data['status'] = 1;//已分配 + $add_data['status2'] = 1;//强意向 + } + $add_data['cf_id'] = $cf_id; + $id = $this->receiver_clues_model->add($add_data); + if (is_numeric($id)) { + $this->load->library('receiver/clues_entity'); + $this->load->library('receiver/customers_entity'); + $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); + if ($remark) { //添加日志 + $this->clues_entity->add_log($id, $this->session['uid'], $this->session['nickname'], $remark); + } + //转介绍 + if (($intro_biz_id || $intro_uid) && $re_biz) { + $clues_row = $add_data; + $add_data = [ + 'rid' => $id, + 'name' => $clues_row['name'], + 'mobile' => $clues_row['mobile'], + 'biz_id' => $re_biz['id'], + 'city_id' => $re_biz['city_id'], + 'county_id' => $re_biz['county_id'], + 'brand_id' => $clues_row['brand_id'], + 's_id' => 0, + 'if_driver' => 0, + 'cf_title' => '自有资源', + 'cf_id' => $clues_row['cf_id'], + 'p_time' => date('Y-m-d H:i:s'), + 'c_time' => $clues_row['c_time'], + 'level' => 'H', + 'admin_id' => $intro_uid, + ]; + $customers_id = $this->mdCustomers->add($add_data); + if ($customers_id) { + $content = "指定给【{$re_biz['biz_name']}】商家"; + if ($intro_uid) { + $this->load->model('app/licheb/app_licheb_users_model', 'mdUsers'); + $re_u = $this->mdUsers->get(['id' => $intro_uid]); + $re_u && $content = "指定给【{$re_biz['biz_name']}_{$re_u['uname']}】人"; + } + if ($remark) { + $this->customers_entity->add_log($customers_id, $this->session['uid'], $this->session['nickname'], $remark); + } + $this->customers_entity->add_log($customers_id, $this->session['uid'], $this->session['nickname'], '转介绍'); + $this->clues_entity->add_log($id, $this->session['uid'], $this->session['nickname'], $content); + } } throw new Exception('保存成功', API_CODE_SUCCESS); - }else{ + } else { throw new Exception('保存失败', ERR_PARAMS_ERROR); } } - protected function get_tabs(){ + protected function get_tabs() + { $uid = $this->session['uid']; $recommend_id = [$uid]; - $l_user = $this->app_user_model->select(['up_uid'=>$uid],'','','','id'); //下一级用户 - if($l_user){ - $l_user_ids = array_column($l_user,'id'); - $recommend_id = array_merge($l_user_ids,$recommend_id); + $l_user = $this->app_user_model->select(['up_uid' => $uid], '', '', '', 'id'); //下一级用户 + if ($l_user) { + $l_user_ids = array_column($l_user, 'id'); + $recommend_id = array_merge($l_user_ids, $recommend_id); } - $recommend_id_str = implode(',',$recommend_id); + $recommend_id_str = implode(',', $recommend_id); $where = [ 'app_id' => $this->app_id, "recommend_id in ($recommend_id_str)" => null, 'status' => 0 ]; - $count = $this->receiver_clues_model->count($where); + $count = $this->receiver_clues_model->count($where); $lists = [ - ['key' =>0 ,'name' => '全部','nums' => 0], - ['key' =>1 ,'name' => '待确认','nums' => $count], - ['key' =>2 ,'name' => '有效','nums' => 0], - ['key' =>3 ,'name' => '无效','nums' => 0], + ['key' => 0, 'name' => '全部', 'nums' => 0], + ['key' => 1, 'name' => '待确认', 'nums' => $count], + ['key' => 2, 'name' => '有效', 'nums' => 0], + ['key' => 3, 'name' => '无效', 'nums' => 0], ]; return $lists; } - private function lists(){ + private function lists() + { $uid = $this->session['uid']; $page = $this->input_param('page'); $size = $this->input_param('size'); $type = $this->input_param('type'); - !$type && $type = 0; + !$type && $type = 0; !$page && $page = 1; !$size && $size = 20; $list = []; - + $recommend_id = [$uid]; - $l_user = $this->app_user_model->select(['up_uid'=>$uid],'','','','id'); //下一级用户 - if($l_user){ - $l_user_ids = array_column($l_user,'id'); - $recommend_id = array_merge($l_user_ids,$recommend_id); + $l_user = $this->app_user_model->select(['up_uid' => $uid], '', '', '', 'id'); //下一级用户 + if ($l_user) { + $l_user_ids = array_column($l_user, 'id'); + $recommend_id = array_merge($l_user_ids, $recommend_id); } - $recommend_id_str = implode(',',$recommend_id); + $recommend_id_str = implode(',', $recommend_id); $where = [ 'app_id' => $this->app_id, "recommend_id in ($recommend_id_str)" => null ]; $total = $this->receiver_clues_model->count($where); //总数 - if($type==1){ //待确认 + if ($type == 1) { //待确认 $where["lc_receiver_orders.id is null"] = null; - $where["lc_receiver_clues.status !="] =3; - }elseif($type==2){ //有效 + $where["lc_receiver_clues.status !="] = 3; + } elseif ($type == 2) { //有效 $where['lc_receiver_orders.id >'] = 0; - }elseif($type==3){ + } elseif ($type == 3) { $where['lc_receiver_clues.status'] = 3; } - $count = $this->receiver_clues_model->selectClues($where,'','','',1); - if($count){ - $rows = $this->receiver_clues_model->selectClues($where,'id desc',$page,$size); - foreach($rows as $key=>$val){ - if($val['cf_uid']==$uid){ + $count = $this->receiver_clues_model->selectClues($where, '', '', '', 1); + if ($count) { + $rows = $this->receiver_clues_model->selectClues($where, 'id desc', $page, $size); + foreach ($rows as $key => $val) { + if ($val['cf_uid'] == $uid) { $cfrom = '自带客'; - }else{ - $user = $this->app_user_model->get(['id'=>$val['recommend_id']],'nickname'); + } else { + $user = $this->app_user_model->get(['id' => $val['recommend_id']], 'nickname'); $cfrom = "团队带客({$user['nickname']})"; } - if($val['status']==3){ //无效 + if ($val['status'] == 3) { //无效 $status_cor = "#666"; $status_cn = '无效'; - }elseif($val['o_id']){ //有效 + } elseif ($val['o_id']) { //有效 $status_cor = "#f9394d"; $status_cn = '有效'; - }else{ //待确认 + } else { //待确认 $status_cor = "#f9394d"; $status_cn = '待确认'; } @@ -158,7 +217,7 @@ class Clues extends Wxapp{ 'text' => $status_cn ], 'cfrom' => $cfrom, - 'c_time' => date('Y-m-d H:i:s',$val['c_time']), + 'c_time' => date('Y-m-d H:i:s', $val['c_time']), ]; } } @@ -171,24 +230,25 @@ class Clues extends Wxapp{ return $data; } - private function detail($id){ - $row = $this->receiver_clues_model->get(['id'=>$id]); - if(!$row){ + private function detail($id) + { + $row = $this->receiver_clues_model->get(['id' => $id]); + if (!$row) { throw new Exception('数据不存在', ERR_PARAMS_ERROR); } - $order = $this->receiver_orders_model->get(['clue_id'=>$row['id'],'status>='=>0]); - if($row['status']==3){ //无效 + $order = $this->receiver_orders_model->get(['clue_id' => $row['id'], 'status>=' => 0]); + if ($row['status'] == 3) { //无效 $status_cn = '无效'; - }elseif($order){ //有效 + } elseif ($order) { //有效 $status_cn = '有效'; - }else{ //待确认 + } else { //待确认 $status_cn = '待确认'; } - $brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name'); - if($row['recommend_id']!=$this->session['uid']){ - $user = $this->app_user_model->get(['id'=>$row['recommend_id']],'nickname'); + $brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name'); + if ($row['recommend_id'] != $this->session['uid']) { + $user = $this->app_user_model->get(['id' => $row['recommend_id']], 'nickname'); $cfrom = "团队带客({$user['nickname']})"; - }else{ + } else { $cfrom = '自带客'; } $mobile = mobile_asterisk($row['mobile']); @@ -198,13 +258,13 @@ class Clues extends Wxapp{ 'clue_id' => $row['id'], 'type!=' => 2 ]; - $log_rows = $this->receiver_clue_oplogs_model->select($where,'id desc',1,20,'id,log,c_time'); - if($log_rows){ - foreach($log_rows as $key=>$val){ + $log_rows = $this->receiver_clue_oplogs_model->select($where, 'id desc', 1, 20, 'id,log,c_time'); + if ($log_rows) { + foreach ($log_rows as $key => $val) { $logs[] = [ 'id' => $val['id'], 'log' => $val['log'], - 'c_time' => date('Y-m-d H:i:s',$val['c_time']) + 'c_time' => date('Y-m-d H:i:s', $val['c_time']) ]; } } @@ -215,37 +275,38 @@ class Clues extends Wxapp{ 'brand' => $brand['name'], 'cfrom' => $cfrom, 'status' => $status_cn, - 'c_time' => date('Y-m-d H:i:s',$row['c_time']), + 'c_time' => date('Y-m-d H:i:s', $row['c_time']), 'logs' => $logs, 'mlogs' => $mlogs ]; return $data; } - protected function get_lists(){ + protected function get_lists() + { $uid = $this->session['uid']; $page = $this->input_param('page'); $size = $this->input_param('size'); - !$type && $type = 0; + !$type && $type = 0; !$page && $page = 1; !$size && $size = 20; $list = []; - + $where = [ 'app_id' => $this->app_id, "recommend_id" => $uid ]; $count = $this->receiver_clues_model->count($where); //总数 - if($count){ - $rows = $this->receiver_clues_model->select($where,'id desc',$page,$size,'id,name,mobile,c_time'); - foreach($rows as $key=>$val){ + if ($count) { + $rows = $this->receiver_clues_model->select($where, 'id desc', $page, $size, 'id,name,mobile,c_time'); + foreach ($rows as $key => $val) { $list[] = [ 'id' => $val['id'], 'name' => $val['name'], 'mobile' => mobile_asterisk($val['mobile']), - 'c_time' => date('Y-m-d H:i:s',$val['c_time']), + 'c_time' => date('Y-m-d H:i:s', $val['c_time']), ]; } } @@ -256,4 +317,32 @@ class Clues extends Wxapp{ ]; return $data; } + + /** + * Notes:转介绍指定店/人 + * Created on: 2021/11/22 16:09 + * Created by: dengbw + * @return array + */ + protected function get_intro() + { + $province_id = 350; + $intro_city_id = intval($this->input_param('intro_city_id')); + $intro_biz_id = intval($this->input_param('intro_biz_id')); + if ($intro_city_id && $intro_biz_id) { + $this->load->model('app/licheb/app_licheb_users_model', 'mdUsers'); + $where = ['status' => 1, 'group_id<>' => 4, 'biz_id' => $intro_biz_id]; + $res = $this->mdUsers->select($where, 'id desc', 0, 0, 'id,uname as name'); + } else if ($intro_city_id) { + $this->load->model("biz/biz_model", 'mdBiz'); + $where = ['status' => 1, 'province_id' => $province_id, 'city_id' => $intro_city_id]; + $res = $this->mdBiz->select($where, 'id desc', 0, 0, 'id,biz_name as name'); + } else { + $this->load->model("area_model", 'mdArea'); + $where = ['province_id' => $province_id]; + $res = $this->mdArea->select($where, '', 0, 0, 'distinct(city_id) as id,city_name as name'); + } + $data['list'] = $res ? $res : []; + return $data; + } } diff --git a/api/controllers/wxapp/material/Biz.php b/api/controllers/wxapp/material/Biz.php index a9b7dafc..6715ad75 100644 --- a/api/controllers/wxapp/material/Biz.php +++ b/api/controllers/wxapp/material/Biz.php @@ -50,11 +50,16 @@ class Biz extends Wxapp //加店铺浏览 $where_s = ['app_id' => $this->app_id, 'biz_id' => $biz_id, 'day' => date('Y-m-d')]; $re_s = $this->mdBizStatistics->get($where_s); + $key = "biz_browse_num_{$this->myuid}_{$this->app_id}_{$biz_id}"; if ($re_s) { - $this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s); + if (!$this->app_redis->get($key)) { + $this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s); + $this->app_redis->save($key, 1, 24 * 3600);//有效期1天 + } } else { $where_s['browse_num'] = 1; $this->mdBizStatistics->add($where_s); + $this->app_redis->save($key, 1, 24 * 3600);//有效期1天 } $lists = [ [ @@ -169,7 +174,7 @@ class Biz extends Wxapp } /** - * Notes:预约报名 + * Notes:门店预约报名 * Created on: 2021/10/12 17:51 * Created by: dengbw * @throws Hd_exception @@ -205,8 +210,7 @@ class Biz extends Wxapp 'p_time' => date('Y-m-d H:i:s'), 'c_time' => time() ]; - $where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile'], 'cf_id' => $add_data['cf_id']]; - $t_id && $where['t_id'] = $t_id; + $where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile']]; $re_cus = $this->mdCustomers->get($where); if ($re_cus) { //throw new Hd_exception('您已经预约报名了', API_CODE_FAIL); diff --git a/api/controllers/wxapp/material/Home.php b/api/controllers/wxapp/material/Home.php index b12937d0..60170380 100644 --- a/api/controllers/wxapp/material/Home.php +++ b/api/controllers/wxapp/material/Home.php @@ -38,18 +38,25 @@ class Home extends Wxapp */ protected function get_tabs() { + $distribute = intval($this->input_param('distribute')); $list = array(); - //根据品牌做分类 - $brand_ids = 0; - if ($this->biz_id) {//查找门店授权品牌 - $re_b = $this->mdBiz->get(array('id' => $this->biz_id, 'status' => 1)); - if ($re_b['jsondata']) { - $jsondata = json_decode($re_b['jsondata'], true); - $jsondata['auto_brands'] && $brand_ids = implode($jsondata['auto_brands'], ','); + $res = []; + if ($distribute == 1) {//分销 + $res = $this->mdAutoBrand->select(array('status' => 1), "id desc", 0, 0, 'id,name'); + } else { + if ($this->biz_id) {//查找门店授权品牌 + $re_b = $this->mdBiz->get(array('id' => $this->biz_id, 'status' => 1)); + if ($re_b['jsondata']) { + $jsondata = json_decode($re_b['jsondata'], true); + if ($jsondata['auto_brands']) { + $brand_ids = implode($jsondata['auto_brands'], ','); + $res = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'id,name'); + } + } } } - if ($brand_ids) { - $res = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'id,name'); + //根据品牌做分类 + if ($res) { foreach ($res as $key => $value) { $brand_id = $value['id'] . ','; $where = array('app_id' => $this->app_id, 'type in(4,1)' => null, "brand_ids like '%{$brand_id}%'" => null, 'status' => 1); @@ -83,6 +90,7 @@ class Home extends Wxapp $size = $this->input_param('size'); $brand_id = intval($this->input_param('id')); $type = intval($this->input_param('type')); + $distribute = intval($this->input_param('distribute')); !$type && $type = 4; $lists = array(); $total = 0; @@ -96,17 +104,26 @@ class Home extends Wxapp $res = $this->mdTemplate->select($where, "id desc", $page, $size, $fileds); foreach ($res as $key2 => $value2) { $setValue = array(); - $moments = ''; - $re_biz = $this->mdMaterialBiz->get(array('app_id' => $this->app_id, 't_id' => $value2['id'], 'biz_id' => $this->biz_id)); $setValue['id'] = intval($value2['id']); $setValue['title'] = $value2['title']; $setValue['cover'] = $value2['cover'] ? build_qiniu_image_url($value2['cover']) : ''; - $setValue['if_add'] = $re_biz ? 1 : 0; + $moments = $tag = ''; if ($value2['json_data']) { $json_data = json_decode($value2['json_data'], true); $json_data['moments'] && $moments = $json_data['moments']; + $json_data['tag_id'] && $tag = $this->mdTemplate->tagAry()[$json_data['tag_id']]; } $setValue['moments'] = $moments; + if ($distribute == 1) { + $setValue['tag'] = $tag; + } else { + $if_add = 0; + if ($this->biz_id) { + $re_biz = $this->mdMaterialBiz->get(array('app_id' => $this->app_id, 't_id' => $value2['id'], 'biz_id' => $this->biz_id)); + $re_biz && $if_add = 1; + } + $setValue['if_add'] = $if_add; + } $lists[] = $setValue; } } diff --git a/api/controllers/wxapp/material/Topic.php b/api/controllers/wxapp/material/Topic.php index 7f1ed712..81bc084a 100644 --- a/api/controllers/wxapp/material/Topic.php +++ b/api/controllers/wxapp/material/Topic.php @@ -50,11 +50,16 @@ class Topic extends Wxapp //加店铺专题浏览 $where_s = ['app_id' => $this->app_id, 'biz_id' => $biz_id, 't_id' => $id, 'day' => date('Y-m-d')]; $re_s = $this->mdBizStatistics->get($where_s); + $key = "material_biz_browse_num_{$this->myuid}_{$this->app_id}_{$biz_id}_{$id}"; if ($re_s) { - $this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s); + if (!$this->app_redis->get($key)) { + $this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s); + $this->app_redis->save($key, 1, 24 * 3600);//有效期1天 + } } else { $where_s['browse_num'] = 1; $this->mdBizStatistics->add($where_s); + $this->app_redis->save($key, 1, 24 * 3600);//有效期1天 } } $lists = array(); @@ -87,4 +92,76 @@ class Topic extends Wxapp $this->data['lists'] = $lists; return $this->data; } + + /** + * Notes:专题预约报名 + * Created on: 2021/11/23 17:16 + * Created by: dengbw + * @throws Hd_exception + */ + protected function put() + { + $this->load->model('sys/sys_area_model'); + $this->load->model('receiver/receiver_clues_model', 'clues_model'); + $this->load->model('auto/auto_brand_model'); + $this->load->library('receiver/clues_entity'); + $recommend_id = intval($this->input_param('cf_uid')); //来源用户id 分销 + $biz_id = intval($this->input_param('biz_id')); + $t_id = intval($this->input_param('t_id')); + $city_id = $this->input_param('city_id'); + $lat = $this->input_param('lat'); + $lng = $this->input_param('lng'); + $cf_id = 1; + $brand_id = 0; + $recommend_id && $cf_id = 8; + $city_id && $city_row = $this->sys_area_model->get(['county_id' => $city_id], 'id,county_id,city_id'); + $re_t = $this->mdTemplate->get(['id' => $t_id]); + if ($re_t && $re_t['brand_ids']) { + $brand_ids = implode(',', $re_t['brand_ids']); + $brand_id = count($brand_ids) >= 2 ? $brand_ids[1] : $re_t['brand_ids']; + } + $row = $this->clues_model->get(['mobile' => $this->session['mobile']]); + if ($row) { + $update = ['en_time' => date('Y-m-d H:i:s')]; + $brand_id && $update['brand_id'] = $brand_id; + $this->clues_model->update($update, ['id' => $row['id']]); + //增加日志 + $uname = $this->session['nickname'] ? $this->session['nickname'] : '用户'; + $cf_title = $this->clues_entity->cf_title($cf_id); + $log_msg = '用户报名'; + $cf_title && $log_msg = "用户通过【{$cf_title}】报名"; + $this->clues_entity->add_log($row['id'], $this->session['uid'], $uname, $log_msg); + //throw new Exception('预约成功,不需要重复报名', API_CODE_FAIL); + throw new Hd_exception('预约报名成功了!', API_CODE_SUCCESS); + } + $jsondata['info'] = ['biz_id' => $biz_id ? $biz_id : '']; + $t_id && $jsondata['info']['t_id'] = $t_id; + $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' => 'wxapp', + '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; + $brand_id && $add_data['brand_id'] = $brand_id; + $city_row && $add_data['city_id'] = $city_row['city_id']; + $city_row && $add_data['county_id'] = $city_row['county_id']; + $lat && $add_data['lat'] = $lat; + $lng && $add_data['lng'] = $lng; + $id = $this->clues_model->add($add_data); + if ($id) { + $uname = $this->session['nickname'] ? $this->session['nickname'] : '用户'; + $cf_title = $this->clues_entity->cf_title($cf_id); + $log_msg = '用户报名'; + $cf_title && $log_msg = "用户通过【{$cf_title}】报名"; + $this->clues_entity->add_log($id, $this->session['uid'], $uname, $log_msg); + } + throw new Hd_exception('预约报名成功!', API_CODE_SUCCESS); + } } diff --git a/common/models/app/material/Material_template_model.php b/common/models/app/material/Material_template_model.php index 47f74804..7a0c7f5d 100644 --- a/common/models/app/material/Material_template_model.php +++ b/common/models/app/material/Material_template_model.php @@ -15,6 +15,11 @@ class Material_template_model extends HD_Model parent::__construct($this->table_name, 'default'); } + public function tagAry() + { + return array(1 => '蓄客', 2 => '转化'); + } + /** * Notes:素材分类 * Created on: 2021/9/15 10:25