129 lines
4.4 KiB
PHP
129 lines
4.4 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
require_once APPPATH . 'controllers/api/BaseController.php';
|
|
|
|
class Enroll extends BaseController
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('market/Market_sytopic_model', 'mSytopic');
|
|
$this->load->model('market/Market_sytopic_enroll_model', 'sytopic_enroll_model');
|
|
$this->load->model('market/market_sylive_user_model', 'user_model');
|
|
$this->load->library('MyEncryption');
|
|
}
|
|
|
|
public function page_get()
|
|
{
|
|
$limit = $this->input_param('limit');
|
|
!$limit && $limit = 10;
|
|
$data = $this->orderList($limit);
|
|
$this->return_response_list($data);
|
|
}
|
|
|
|
public function status_get()
|
|
{
|
|
$statusArray = $this->sytopic_enroll_model->statusCn();
|
|
$this->return_response_list($statusArray);
|
|
}
|
|
|
|
/**
|
|
* 修改状态
|
|
*/
|
|
public function status_put()
|
|
{
|
|
$id = $this->input_param('id');
|
|
$status = $this->input_param('status');
|
|
if (!$id) {
|
|
$this->return_json('参数错误');
|
|
}
|
|
$this->sytopic_enroll_model->update(['status' => $status], ['id' => $id]);
|
|
$this->return_response();
|
|
}
|
|
|
|
/**
|
|
* Notes:导出订单数据
|
|
*/
|
|
public function export_get()
|
|
{
|
|
$data = $this->orderList(20000);
|
|
$this->return_response_list($data);
|
|
}
|
|
|
|
/**
|
|
* 报名列表数据
|
|
*/
|
|
private function orderList($limit = '')
|
|
{
|
|
$page = $this->input_param('page');
|
|
$sort = $this->input_param('sort');
|
|
$order = $this->input_param('order');
|
|
$name = $this->input_param('name');
|
|
$mobile = $this->input_param('mobile');
|
|
$topicId = (int)$this->input_param('topicId');
|
|
$status = $this->input_param('status');
|
|
!$page && $page = 1;
|
|
$sort_order = 'id desc';
|
|
if ($sort && $order) {
|
|
$sort_order = $sort . ' ' . $order;
|
|
}
|
|
$list = [];
|
|
$where['status>='] = 0;
|
|
if ($name) {
|
|
$where['name'] = $name;
|
|
}
|
|
if ($mobile) {
|
|
$where['mobile'] = $mobile;
|
|
}
|
|
if ($topicId) {
|
|
$where['topicId'] = $topicId;
|
|
}
|
|
if(strlen($status)){
|
|
$where['status'] = (int)$status;
|
|
}
|
|
$count = $this->sytopic_enroll_model->count($where);
|
|
$columns = [];
|
|
if ($count) {
|
|
$statusCn = $this->sytopic_enroll_model->statusCn();
|
|
$res = $this->sytopic_enroll_model->select($where, $sort_order, $page, $limit);
|
|
$topicIds = array_column($res, 'topicId');
|
|
$topicIdsStr = implode(',', $topicIds);
|
|
$topicMap = [];
|
|
$topicIdsStr && $topicMap = $this->mSytopic->map('id', 'title', ["id in ({$topicIdsStr})" => null], '', '', '', 'id,title');
|
|
$channelUserIds = array_column($res, 'channelId');
|
|
$channelUserIdsStr = implode(',', array_unique($channelUserIds));
|
|
$channelUserMap = [];
|
|
$channelUserIdsStr && $channelUserMap = $this->user_model->map('userId', 'uname', ["userId in ({$channelUserIdsStr})" => null], '', '', '', 'userId,uname');
|
|
foreach ($res as $val) {
|
|
$tmp_data = [
|
|
'id' => $val['id'],
|
|
'name' => $val['name'],
|
|
'mobile' => $val['mobile'],
|
|
'enTime' => $val['enTime'],
|
|
'enrollDeal' => (int)$val['enrollDeal']
|
|
];
|
|
$tmp_data['channelName'] = $channelUserMap[$val['channelId']] ?: '';
|
|
$tmp_data['topicTitle'] = $topicMap[$val['topicId']] ?: '';
|
|
$tmp_data['status_cn'] = $statusCn[$val['status']];
|
|
if ($limit < 10000) {
|
|
$tmp_data['status'] = intval($val['status']);
|
|
}
|
|
$list[] = $tmp_data;
|
|
}
|
|
}
|
|
if ($limit >= 10000) {
|
|
$columns = ['ID', '姓名', '手机号', '留资时间', '来源人', '来源专题', '状态'];
|
|
}
|
|
return ['list' => $list, 'count' => $count, 'columns' => $columns];
|
|
}
|
|
|
|
/**
|
|
* 专题管理列表
|
|
*/
|
|
public function topicList_get(){
|
|
$lists = $this->mSytopic->select(['status>='=>0], 'id desc', 1, 10000,'id,title');
|
|
!$lists && $lists = [];
|
|
|
|
$this->return_response_list($lists);
|
|
}
|
|
} |