From b5814bef1a599027e67feca90ba218f32952f139 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 28 Mar 2023 11:11:31 +0800 Subject: [PATCH] admin_topic_328_2 --- admin/controllers/receiver/CluesCfrom.php | 60 +- admin/controllers/topics/Enroll.php | 293 +++------- admin/views/receiver/clues/lists.php | 8 +- admin/views/receiver/cluescfrom/edit.php | 17 +- admin/views/receiver/cluescfrom/lists.php | 577 ++++++++++++++------ admin/views/topics/edit.php | 6 +- admin/views/topics/lists.php | 5 +- admin/views/topics/lists_enroll.php | 205 +++++++ api/controllers/wxapp/liche/Topics.php | 30 +- common/models/topics/Topic_enroll_model.php | 17 + market/controllers/api/sylive/Live.php | 4 +- 11 files changed, 774 insertions(+), 448 deletions(-) create mode 100644 admin/views/topics/lists_enroll.php create mode 100644 common/models/topics/Topic_enroll_model.php diff --git a/admin/controllers/receiver/CluesCfrom.php b/admin/controllers/receiver/CluesCfrom.php index 591d2f7d..4e270938 100644 --- a/admin/controllers/receiver/CluesCfrom.php +++ b/admin/controllers/receiver/CluesCfrom.php @@ -4,13 +4,6 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class CluesCfrom extends HD_Controller { - private $tabAry = [ - 1 => ['title' => '客户标签', 'url' => '/receiver/tag'], - 2 => ['title' => '车主标签', 'url' => '/receiver/ownersTag'], - 3 => ['title' => '战败标签', 'url' => '/receiver/tag?tag_type=1'], - 4 => ['title' => '意向标签', 'url' => '/receiver/tag?tag_type=2'] - ]; - public function __construct() { parent::__construct(); @@ -35,17 +28,20 @@ class CluesCfrom extends HD_Controller $where['status'] = $params['status']; } if ($params['title']) { - $where['title'] = $params['title']; + $where["title like '%{$params['title']}%'"] = null; } $count = $this->mdCluesCfrom->count($where); if ($count) { - $res = $this->mdCluesCfrom->select($where, "c_time desc", $params['page'], $params['size']); + $res = $this->mdCluesCfrom->select($where, "sort desc,id desc", $params['page'], $params['size']); foreach ($res as $key => $value) { $setValue = []; $setValue['id'] = $value['id']; $setValue['name'] = $value['title']; + $setValue['sort'] = $value['sort']; + $setValue['status'] = $value['status']; + $setValue['status_name'] = $value['status'] == 1 ? '正常' : '禁用'; $options = ''; - $res_cfrom = $this->mdCluesCfrom->select(["status<>" => -1, 'pid' => $value['id']], "c_time desc", 0, 0, 'title'); + $res_cfrom = $this->mdCluesCfrom->select(["status<>" => -1, 'pid' => $value['id']], "sort desc,c_time desc", 1, 10, 'title'); $res_cfrom && $options = implode(',', array_column($res_cfrom, 'title')); $setValue['options'] = $options; $lists[] = $setValue; @@ -53,7 +49,7 @@ class CluesCfrom extends HD_Controller } $this->data['lists'] = $lists; $this->data['params'] = $params; - $this->data['_title'] = '线索来源列表'; + $this->data['_title'] = '线索来源'; $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count); return $this->show_view('receiver/cluescfrom/lists', true); } @@ -64,7 +60,7 @@ class CluesCfrom extends HD_Controller if (!$id) { return $this->show_json(SYS_CODE_FAIL, '参数错误!'); } - $res_tag = $this->mdCluesCfrom->select(["status" => 1, 'pid' => $id], "c_time desc", 0, 0, 'title as name'); + $res_tag = $this->mdCluesCfrom->select(["status" => 1, 'pid' => $id], "sort desc,id desc", 0, 0, 'id,title as name,sort,status'); $this->data['lists'] = $res_tag; return $this->show_json(SYS_CODE_SUCCESS); } @@ -80,11 +76,13 @@ class CluesCfrom extends HD_Controller return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } $name = $re['title']; + $sort = $re['sort']; } else { $url = "receiver/CluesCfrom/add"; + $sort = 50; $name = ''; } - $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'url' => $url]; + $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'url' => $url]; return $this->show_view('receiver/cluescfrom/edit'); } @@ -95,11 +93,11 @@ class CluesCfrom extends HD_Controller if (!$params['name']) { return $this->show_json(SYS_CODE_FAIL, '名称不能为空!'); } - $re = $this->mdCluesCfrom->get(['name' => $params['name'], 'pid' => 0, "status<>" => -1]); + $re = $this->mdCluesCfrom->get(['title' => $params['name'], 'pid' => 0, "status<>" => -1]); if ($re) { return $this->show_json(SYS_CODE_FAIL, '名称已存在了!'); } - $id = $this->mdCluesCfrom->add(['name' => $params['name'], 'c_time' => time()]); + $id = $this->mdCluesCfrom->add(['title' => $params['name'], 'sort' => $params['sort'], 'c_time' => time()]); if (!$id) { return $this->show_json(SYS_CODE_FAIL, '保存失败'); } @@ -116,11 +114,11 @@ class CluesCfrom extends HD_Controller if (!$params['name']) { return $this->show_json(SYS_CODE_FAIL, '请输入名称'); } - $re = $this->mdCluesCfrom->get(array('name' => $params['name'], 'pid' => 0, "status<>" => -1)); + $re = $this->mdCluesCfrom->get(array('title' => $params['name'], 'pid' => 0, "status<>" => -1)); if ($re && $re['id'] != $params['id']) { return $this->show_json(SYS_CODE_FAIL, '名称已存在了!'); } - $this->mdCluesCfrom->update(['name' => $params['name']], ['id' => $params['id']]); + $this->mdCluesCfrom->update(['title' => $params['name'], 'sort' => $params['sort']], ['id' => $params['id']]); return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } @@ -151,15 +149,15 @@ class CluesCfrom extends HD_Controller if (!$re) { return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } - $add_tag = $edit_tag = []; foreach ($options as $key => $value) { - $data = ['name' => $value['name'], 'status' => $value['status']]; + $sort = intval($value['sort']); + $data = ['title' => $value['name'], 'status' => $value['status'], 'sort' => $sort]; if ($value['name']) { if ($value['id']) {//修改 $this->mdCluesCfrom->update($data, ['id' => $value['id']]); } else {//新增 - $add_tag[] = ['name' => $value['name'], 'c_time' => time()]; $data['pid'] = $pid; + $data['c_time'] = time(); $this->mdCluesCfrom->add($data); } } @@ -178,6 +176,28 @@ class CluesCfrom extends HD_Controller return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } + /** + * Notes:获取分类信息 + * Created on: 2023/3/27 17:39 + * Created by: dengbw + * @return bool + */ + function json_get() + { + $id = $this->input->get('id'); + $where = [ + 'status' => 1, + 'pid' => 0 + ]; + $id && $where['pid'] = $id; + if ($this->role == 37) { + !$id && $where['id'] = 36; + } + $rows = $this->mdCluesCfrom->select($where, 'sort desc,id desc', '', '', 'id,title'); + $this->data['data'] = $rows; + return $this->show_json(SYS_CODE_SUCCESS); + } + //批量操作(默认修改状态) public function batch() { diff --git a/admin/controllers/topics/Enroll.php b/admin/controllers/topics/Enroll.php index e0acee04..eb8c4b87 100644 --- a/admin/controllers/topics/Enroll.php +++ b/admin/controllers/topics/Enroll.php @@ -1,22 +1,19 @@ '已失效', 0 => '未核销', 1 => '已核销'); - public function __construct() { parent::__construct(); $this->load->model('topics/topics_model', 'mdTopics'); - $this->load->model('topics/topic_modules_model', 'mdTopicModules'); - $this->load->model('topics/topic_module_enroll_model', 'mdModuleEnroll'); - $this->load->model('topics/topic_module_enrolldata_model', 'mdModuleEnrolldata'); + $this->load->model('topics/topic_enroll_model', 'mdEnroll'); + $this->load->model('receiver/receiver_clues_cfrom_model', 'mdCluesCfrom'); } public function index() @@ -29,182 +26,81 @@ Class Enroll extends HD_Controller $params = $this->input->get(); $params['page'] = $params['page'] ? intval($params['page']) : 1; $params['size'] = $params['size'] ? intval($params['size']) : 20; - $params['module_id'] = intval($params['module_id']); - + $params['id'] = intval($params['id']); $res = $this->dataSelect($params); - if ($res['code'] == 0) { - return $this->show_json(SYS_CODE_FAIL, $res['msg']); - } $lists = $res['lists']; $count = $res['count']; $this->data['params'] = $res['params']; - $this->data['_title'] = $res['title'] . '列表'; - $this->data['type'] = $res['type']; - $this->data['statusAry'] = $this->statusAry; + $this->data['_title'] = $res['title']; $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count); $this->data['lists'] = $lists; - return $this->show_view('topics/enroll/lists', true); - } - - /** - * 报名活动列表 - * @return bool - */ - public function lists_module() - { - $params = $this->input->get(); - $page = $params['page'] ? $params['page'] : 1; - $size = $params['size'] ? $params['size'] : 20; - - $app_id = $params['app_id']; - $search_ary = array("title" => "标题", "module_id" => "ID"); - - //根据应用获取模块 - $where = array('app_id' => $app_id); - $rows_topic = $this->mdTopics->select($where); - $module_ids = array(); - if ($rows_topic) { - foreach ($rows_topic as $v) { - if ($v['module_ids']) { - $ids = explode(',', $v['module_ids']); - if ($ids) { - $module_ids = array_merge($module_ids, $ids); - } - } - } - } - - $total = 0; - $lists = array(); - if ($module_ids) { - $str_ids = implode(',', $module_ids); - $where = array("module_id in ({$str_ids})" => null); - if ($params['search_v']) { - if ('title' == $params['search_k']) { - $where["m.title like '%{$params['search_v']}%'"] = null; - } else { - $where["m.{$params['search_k']}"] = $params['search_v']; - } - } - !$params['search_k'] && $params['search_k'] = 'title'; - - if (strlen($params['status']) > 0) { - $where['j.status'] = $params['status']; - } else { - $where['j.status>=0'] = null; - $params['status'] = ''; - } - - $total = $this->mdModuleEnroll->count_status($where); - if ($total) { - $orderby = 'id desc'; - $select = "module_id, title, es_time, ee_time, as_time, ae_time, j.status"; - $rows = $this->mdModuleEnroll->select_status($where, $orderby, $page, $size, $select); - foreach ($rows as $v) { - $lists[] = array( - 'id' => $v['module_id'], - 'title' => $v['title'], - 'e_time' => "{$v['es_time']}~{$v['ee_time']}", - 'a_time' => "{$v['as_time']}~{$v['ae_time']}", - 'status' => $v['status'], - 'statusion' => 1 == $v['status'] ? "正常" : "下架", - ); - } - } - } - - $this->data['params'] = $params; - $this->data['lists'] = $lists; - $this->data['search_ary'] = $search_ary; - $this->data['_title'] = '报名活动管理'; - $this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total); - - return $this->show_view('topics/enroll/lists_module', true); + return $this->show_view('topics/lists_enroll', true); } /** * Notes:查找报名数据 - * Created on: 2020/5/19 16:37 + * Created on: 2023/3/27 16:37 * Created by: dengbw * @param $params * @return array */ private function dataSelect($params) { - $where = $lists = array(); - $title = '活动报名'; - $type = 0; - if ($params['module_id']) { - $where['module_id'] = $params['module_id']; - $row_en = $this->mdModuleEnroll->get(array('module_id' => $params['module_id']), 'title,type'); - $title = $row_en['title']; - $type = $row_en['type']; - } else { - //根据应用获取报名列表 - $app_id = $params['app_id']; - $where_topic = array('app_id' => $app_id); - $rows_topic = $this->mdTopics->select($where_topic); - $module_ids = array(); - if ($rows_topic) { - foreach ($rows_topic as $v) { - if ($v['module_ids']) { - $ids = explode(',', $v['module_ids']); - if ($ids) { - $module_ids = array_merge($module_ids, $ids); - } - } - } - } - if ($module_ids) { - $str_ids = implode(',', $module_ids); - $where["module_id in ({$str_ids})"] = null; - } else { - $where['module_id'] = -1; - } - } - - if (status_verify($params['status'])) { - $where['status'] = $params['status']; - } else { - $params['status'] = -99; - } - - if ($params['name']) { - $where['name like "%' . $params['name'] . '%"'] = null; + $where['topics_id'] = $params['id']; + if ($params['nickname']) { + $where['nickname like "%' . $params['nickname'] . '%"'] = null; } if ($params['mobile']) { $where['mobile'] = $params['mobile']; } - if ($params['code']) { - $where['code'] = $params['code']; + if ($params['cfrom_id'] || $params['cfrom_id2']) { + if ($params['cfrom_id2']) { + $where['cf_id'] = $params['cfrom_id2']; + } else { + $cf_rows = $this->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id'); + $cf_ids = array_column($cf_rows, 'id'); + $cf_ids[] = $params['cfrom_id']; + $cf_str_ids = implode(',', array_filter($cf_ids)); + $cf_str_ids && $where["cf_id in ({$cf_str_ids})"] = null; + } } if ($params['time']) { $time = explode(' ~ ', $params['time']); $time[0] && $where["c_time >="] = strtotime($time[0] . ' 00:00:00'); $time[1] && $where["c_time <="] = strtotime($time[1] . ' 23:59:59'); } - $count = $this->mdModuleEnrolldata->count($where); + $lists = []; + $count = $this->mdEnroll->count($where); if ($count) { - $select = "id,module_id,name,mobile,code,status,c_time,jsondata"; - $lists = $this->mdModuleEnrolldata->select($where, "id desc", $params['page'], $params['size'], $select); - $map_module = array(); - if ($lists) { - $module_ids = array_unique(array_column($lists, 'module_id')); - $str_ids = implode(',', $module_ids); - $where_module = array("module_id in ({$str_ids})" => null); - $map_module = $this->mdModuleEnroll->map('module_id', '*', $where_module, '', 0, 0, 'module_id, title, descrip'); + $res = $this->mdEnroll->select($where, "id desc", $params['page'], $params['size']); + //获取来源 + $map_cf_pid = $cf_title_arr = []; + $cf_id_arr = array_unique(array_column($res, 'cf_id')); + if ($cf_id_arr) { + $cf_id_str = implode(',', $cf_id_arr); + $res_cfrom = $this->mdCluesCfrom->select(["id in({$cf_id_str})" => null], 'id desc', 0, 0, 'id,title,pid'); + $cf_pid_arr = array_unique(array_column($res_cfrom, 'pid')); + if ($cf_pid_arr) { + $cf_pid_str = implode(',', $cf_pid_arr); + $map_cf_pid = $this->mdCluesCfrom->map('id', 'title', ["id in({$cf_pid_str})" => null]); + } + foreach ($res_cfrom as $key => $val) { + $title = $val['title']; + if ($val['pid']) {//一级分类 + $map_cf_pid[$val['pid']] && $title = $map_cf_pid[$val['pid']] . '-' . $title; + } + $cf_title_arr[$val['id']] = $title; + } } - foreach ($lists as $key => $value) { - $json = json_decode($value['jsondata'], true); - $module = $map_module[$value['module_id']]; - $lists[$key]['c_time'] = date('Y-m-d H:i', $value['c_time']); - $lists[$key]['status_name'] = $this->statusAry[$value['status']]; - $lists[$key]['remark'] = $json['remark'] ? $json['remark'] : ''; - $lists[$key]['title'] = $module['descrip'] ? $module['descrip'] : $module['title']; + foreach ($res as $k => $v) { + $cf_name = $cf_title_arr[$v['cf_id']] ? $cf_title_arr[$v['cf_id']] : '-'; + $c_time = date('Y-m-d H:i', $v['c_time']); + $lists[] = ['id' => $v['id'],'nickname' => $v['nickname'], 'mobile' => $v['mobile'] + , 'cf_name' => $cf_name, 'c_time' => $c_time]; } } - $data['code'] = SYS_CODE_SUCCESS; - $data['type'] = $type; + $re = $this->mdTopics->get(['id' => $params['id']]); + $title = $re['title'] ? $re['title'] . '_报名列表' : '专题报名列表'; $data['title'] = $title; $data['lists'] = $lists; $data['count'] = $count; @@ -214,30 +110,6 @@ Class Enroll extends HD_Controller public function get() { - $id = intval($this->input->get('id')); - $module_id = intval($this->input->get('module_id')); - if (!$id || !$module_id) { - return $this->show_json(SYS_CODE_FAIL, '参数错误!'); - } - $re = $this->mdModuleEnrolldata->get(array("id" => $id)); - if (!$re || empty($re)) { - return $this->show_json(SYS_CODE_FAIL, '报名详情不存在!'); - } - $reEn = $this->mdModuleEnroll->get(array('module_id' => $module_id), 'enroll_json,type'); - $enroll_json = array(); - if ($reEn['enroll_json'] && $re['jsondata']) { - $enroll_json = json_decode($reEn['enroll_json'], true); - $jsondata = json_decode($re['jsondata'], true); - foreach ($enroll_json as $key => $value) { - $jsondata[$key] && $enroll_json[$key]['value'] = $jsondata[$key]; - } - } - $re['enroll_json'] = $enroll_json; - $re['type'] = $reEn['type']; - $re['c_time'] = date('Y-m-d H:i', $re['c_time']); - $re['status_name'] = $this->statusAry[$re['status']]; - $this->data['info'] = $re; - return $this->show_view('topics/enroll/edit'); } public function del() @@ -255,63 +127,22 @@ Class Enroll extends HD_Controller $params = $this->input->get(); $params['page'] = 1; $params['size'] = 10000; - $params['export'] = 1; - $data = $indexs = array(); + $data = $indexs = []; $res = $this->dataSelect($params); - if ($params['module_id']) { - if ($params['type'] == 1) { - $fileName = '活动报名用户'; - foreach ($res['lists'] as $key => $value) { - $temp['name'] = $value['name']; - $temp['mobile'] = $value['mobile']; - $temp['code'] = $value['code']; - $temp['status_name'] = $value['status_name']; - $temp['c_time'] = $value['c_time']; - $temp['remark'] = $value['remark']; - $data[] = $temp; - } - $indexs = [ - 'name' => '姓名', - 'mobile' => '手机号', - 'code' => '核销码', - 'status_name' => '状态', - 'c_time' => '报名时间', - "remark" => "备注", - ]; - } else { - $fileName = '报名用户'; - foreach ($res['lists'] as $key => $value) { - $temp['name'] = $value['name']; - $temp['mobile'] = $value['mobile']; - $temp['c_time'] = $value['c_time']; - $temp['remark'] = $value['remark']; - $data[] = $temp; - } - $indexs = [ - 'name' => '姓名', - 'mobile' => '手机号', - 'c_time' => '报名时间', - "remark" => "备注", - ]; - } - } else { - $fileName = '活动报名'; - foreach ($res['lists'] as $key => $value) { - $temp['title'] = $value['title']; - $temp['name'] = $value['name']; - $temp['mobile'] = $value['mobile']; - $temp['c_time'] = $value['c_time']; - $temp['remark'] = $value['remark']; - $data[] = $temp; - } - $indexs = [ - 'title' => '活动名称', - 'name' => '姓名', - 'mobile' => '手机号', - 'c_time' => '报名时间', - "remark" => "备注", - ]; + $fileName = $res['title']; + foreach ($res['lists'] as $key => $value) { + $temp['nickname'] = $value['nickname']; + $temp['mobile'] = $value['mobile']; + $temp['cf_name'] = $value['cf_name']; + $temp['c_time'] = $value['c_time']; + $data[] = $temp; } + $indexs = [ + 'nickname' => '昵称', + 'mobile' => '手机号', + "cf_name" => "来源", + 'c_time' => '报名时间', + ]; array_unshift($data, $indexs); $this->load->library('excel'); $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis')); diff --git a/admin/views/receiver/clues/lists.php b/admin/views/receiver/clues/lists.php index 445eab68..5a965e68 100644 --- a/admin/views/receiver/clues/lists.php +++ b/admin/views/receiver/clues/lists.php @@ -300,11 +300,11 @@ }, getCfroms: function () { var that = this - $.get('/receiver/clues/get_cfroms', function (result) { + $.get('/receiver/CluesCfrom/json_get', function (result) { that.cfroms = result.data.data }); if (that.cfrom_id > 0) { - $.get('/receiver/clues/get_cfroms', {'id': that.cfrom_id}, function (result) { + $.get('/receiver/CluesCfrom/json_get', {'id': that.cfrom_id}, function (result) { that.cfroms2 = result.data.data }); } @@ -350,9 +350,9 @@ var that = this; if (nv == '') { that.cfrom_id2 = 0; - that.cfroms = []; + that.cfroms2 = []; } else { - $.get('/receiver/clues/get_cfroms', {'id': nv}, function (result) { + $.get('/receiver/CluesCfrom/json_get', {'id': nv}, function (result) { that.cfroms2 = result.data.data; if (that.cfrom_id2 > 0) { var cfrom_id2 = '0'; diff --git a/admin/views/receiver/cluescfrom/edit.php b/admin/views/receiver/cluescfrom/edit.php index c73770c5..aac4c215 100644 --- a/admin/views/receiver/cluescfrom/edit.php +++ b/admin/views/receiver/cluescfrom/edit.php @@ -2,26 +2,15 @@ method="post" style="width: 90%;padding-top: 10px" onsubmit="return false">
- +
- -
-
-
- -
- +
- + 越大越靠前
diff --git a/admin/views/receiver/cluescfrom/lists.php b/admin/views/receiver/cluescfrom/lists.php index f120ea33..5a965e68 100644 --- a/admin/views/receiver/cluescfrom/lists.php +++ b/admin/views/receiver/cluescfrom/lists.php @@ -1,225 +1,470 @@ + +
+
+ +
+
-