1016 lines
41 KiB
PHP
1016 lines
41 KiB
PHP
<?php
|
|
/**
|
|
* Notes:专题管理
|
|
* Created on: 2020/2/9 12:45
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
require_once(dirname(__DIR__) . '/AppBase.php');
|
|
|
|
Class Topics extends AppBase
|
|
{
|
|
private $statusAry = array('0' => '下架', '1' => '上架');
|
|
private $moduleAry = array(
|
|
array('name' => '文本模块', 'tag' => 'text'),
|
|
array('name' => '广告模块', 'tag' => 'ad'),
|
|
array('name' => '报名模块', 'tag' => 'enroll'),
|
|
array("name" => "按钮模块", "tag" => "button")
|
|
);
|
|
|
|
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_text_model', 'mdModuleText');
|
|
$this->load->model('topics/topic_module_ad_model', 'mdModuleAd');
|
|
$this->load->model('topics/topic_module_enroll_model', 'mdModuleEnroll');
|
|
$this->load->model('topics/topic_module_enrolldata_model', 'mdModuleEnrolldata');
|
|
$this->load->model('topics/topic_module_button_model', 'mdModuleButton');
|
|
$this->load->model('topics/topic_user_log_model', 'mdUserLog');
|
|
$this->load->model("sys/sys_admin_model", 'mdSysAdmin');
|
|
}
|
|
|
|
/**
|
|
* 调用所有函数前
|
|
* @param $method
|
|
* @return mixed
|
|
*/
|
|
function _remap($method)
|
|
{
|
|
return $this->$method();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
return $this->lists();
|
|
}
|
|
|
|
public function lists()
|
|
{
|
|
$params = $this->input->get();
|
|
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
|
$size = 20;
|
|
$where = array();
|
|
$lists = array();
|
|
$statusAry = $this->statusAry;
|
|
if ($params['status'] || $params['status'] == '0') {
|
|
$where['status'] = $params['status'];
|
|
} else {
|
|
$params['status'] = -99;
|
|
$where['status > -1'] = null;
|
|
}
|
|
if ($params['app_id']) {
|
|
$where['app_id'] = $params['app_id'];
|
|
}
|
|
if ($params['title']) {
|
|
$where['title like "%' . $params['title'] . '%"'] = null;
|
|
}
|
|
$res = $this->mdTopics->select($where, "id desc", $params['page'], $size);
|
|
$count = $this->mdTopics->count($where);
|
|
if ($res) {
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['title'] = $value['title'];
|
|
if ($value['status'] == 0) {
|
|
$setValue['che_status'] = 1;
|
|
$setValue['che_status_name'] = $this->statusAry[1];
|
|
} else {
|
|
$setValue['che_status'] = 0;
|
|
$setValue['che_status_name'] = $this->statusAry[0];
|
|
}
|
|
$setValue['status_name'] = $statusAry[$value['status']];
|
|
$setValue['c_time'] = date('Y-m-d H:i', $value['c_time']);
|
|
$lists[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['appList'] = $this->app_list();
|
|
$this->data['_title'] = '专题列表';
|
|
$this->data['statusAry'] = $statusAry;
|
|
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $params['page'], 'totle' => $count);
|
|
$this->data['lists'] = $lists;
|
|
$this->data['params'] = $params;
|
|
return $this->show_view('topics/lists', true);
|
|
}
|
|
|
|
/**
|
|
* 访问用户概况
|
|
* @return bool
|
|
*/
|
|
public function lists_userc()
|
|
{
|
|
$params = $this->input->get();
|
|
$id = $params['id'];
|
|
$where = array('tid' => $id);
|
|
|
|
if ($params['time']) {
|
|
list($s_time, $e_time) = explode(" ~ ", $params['time']);
|
|
$s_time = strtotime($s_time . ' 00:00:00');
|
|
$e_time = strtotime($e_time . ' 23:59:59');
|
|
$where["c_time > {$s_time}"] = null;
|
|
$where["c_time < {$e_time}"] = null;
|
|
}
|
|
|
|
$lists = array();
|
|
|
|
$select = "cf_suid, count(id) as row_num";
|
|
$this->mdUserLog->db->group_by('cf_suid');
|
|
$rows = $this->mdUserLog->select($where, "cf_suid desc", 0, 0, $select);
|
|
$map_admin = array();
|
|
if ($rows) {
|
|
$uids = array_diff(array_column($rows, "cf_suid"), array(0));
|
|
$uids && $uids = array_unique($uids);
|
|
$map_coupon = array();
|
|
if ($uids) {
|
|
$ids_str = implode(',', $uids);
|
|
$where_admin = array("id in ({$ids_str})" => null);
|
|
$select = "id, username, mobile";
|
|
$map_admin = $this->mdSysAdmin->map('id', "*", $where_admin, 'id desc', 0, 0, $select);
|
|
}
|
|
$sum_view = 0;
|
|
$sum_couponc = 0;
|
|
foreach ($rows as $v) {
|
|
$cf_suid = $v["cf_suid"];
|
|
$admin = $map_admin[$cf_suid];
|
|
$mobile = $admin ? $admin['mobile'] : "";
|
|
$mobile && 1 != $this->role && $mobile = substr_replace($mobile, "*****", 3, 5);
|
|
$viewc = intval($v['row_num']);
|
|
$couponc = intval($map_coupon[$cf_suid]);
|
|
$sum_view += $viewc;
|
|
$sum_couponc += $couponc;
|
|
$lists[] = array(
|
|
"id" => $cf_suid,
|
|
"uname" => $admin ? $admin['username'] : (0 == $cf_suid ? "其他" : ""),
|
|
"mobile" => $mobile,
|
|
"count" => $viewc,
|
|
"couponc" => $couponc,
|
|
);
|
|
}
|
|
$lists[] = array("id" => "+", "uname" => "合计", "count" => $sum_view, "couponc" => $sum_couponc);
|
|
}
|
|
|
|
$total = count($lists);
|
|
|
|
$this->data['_title'] = '专题访问用户概况';
|
|
$this->data['pager'] = array('count' => ceil($total / 20), 'curr' => 1, 'totle' => $total);
|
|
$this->data['lists'] = $lists;
|
|
$this->data['params'] = $params;
|
|
return $this->show_view('topics/lists_userc', true);
|
|
}
|
|
|
|
/**
|
|
* 按天统计
|
|
* @return bool
|
|
*/
|
|
public function lists_by_day()
|
|
{
|
|
$params = $this->input->get();
|
|
$id = $params['id'];
|
|
$page = intval($params['page']) ?: 1;
|
|
$size = intval($params['size']) ?: 10;
|
|
|
|
$where = array();
|
|
$where['tid'] = $id;
|
|
if ($params['time']) {
|
|
list($s_time, $e_time) = explode(" ~ ", $params['time']);
|
|
$s_time = strtotime($s_time . ' 00:00:00');
|
|
$e_time = strtotime($e_time . ' 23:59:59');
|
|
$where["c_time > {$s_time}"] = null;
|
|
$where["c_time < {$e_time}"] = null;
|
|
} else {
|
|
$where['c_time > UNIX_TIMESTAMP(DATE_SUB(DATE_FORMAT(NOW(),\'%Y-%m-%d\'),INTERVAL 7 day))'] = null;
|
|
}
|
|
|
|
$select = "tid, count(id) as doc_count, count(distinct app_uid) as doc_count_uid, FROM_UNIXTIME(c_time, '%Y-%m-%d') as date";
|
|
$this->mdUserLog->db->group_by("FROM_UNIXTIME(c_time, '%Y-%m-%d')");
|
|
$rows = $this->mdUserLog->select($where, "FROM_UNIXTIME(c_time, '%Y-%m-%d') desc", $page, $size, $select);
|
|
//debug_log("[debug] ".$this->mdUserLog->db->last_query(), __FUNCTION__ );
|
|
$lists = array();
|
|
//debug_log("[debug] ".var_export($rows,1), __FUNCTION__ );
|
|
if ($rows) {
|
|
foreach ($rows as $v) {
|
|
$lists[] = array(
|
|
"date" => $v['date'],
|
|
"count" => intval($v['doc_count']),
|
|
"count_uid" => intval($v['doc_count_uid']), //访问用户数
|
|
);
|
|
}
|
|
}
|
|
|
|
$this->mdUserLog->db->group_by("FROM_UNIXTIME(c_time, '%Y-%m-%d')");
|
|
$countList = $this->mdUserLog->select($where, "FROM_UNIXTIME(c_time, '%Y-%m-%d') desc", 0, 0, $select);
|
|
if ($countList) {
|
|
$sum_view = 0;
|
|
$sum_view_uid = 0;
|
|
foreach ($countList as $v) {
|
|
$sum_view += intval($v['doc_count']);
|
|
$sum_view_uid += intval($v['doc_count_uid']);
|
|
}
|
|
$lists[] = array("date" => "合计", "count" => $sum_view, "count_uid" => $sum_view_uid);
|
|
}
|
|
$total = count($countList);
|
|
$topicInfo = $this->mdTopics->get(array('id' => $id), 'title');
|
|
$this->data['_title'] = $topicInfo['title'] . '-按天统计';
|
|
$this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total);
|
|
$this->data['lists'] = $lists;
|
|
$this->data['params'] = $params;
|
|
return $this->show_view('topics/lists_by_day', true);
|
|
}
|
|
|
|
/**
|
|
* 访问用户列表
|
|
* @return bool
|
|
*/
|
|
public function lists_user()
|
|
{
|
|
$params = $this->input->get();
|
|
$id = $params['id'];
|
|
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
|
|
$size = 20;
|
|
|
|
$this->load->library('entity/user_entity');
|
|
|
|
$where = array('tid' => $id);
|
|
$lists = array();
|
|
|
|
$searchTpAry = array('uname' => '用户姓名', 'mobile' => '用户手机号', 'suid' => "源头用户ID", 'sname' => '源头用户姓名', "smobile" => "源头手机号");
|
|
|
|
$row_topic = $this->mdTopics->get(array('id' => $id));
|
|
$app_id = $row_topic['app_id'];
|
|
$this->user_entity->init($app_id);
|
|
if ($params['search_tp'] && isset($params['title'])) {
|
|
$where_user = array();
|
|
$where_admin = array();
|
|
switch ($params['search_tp']) {
|
|
case "uname":
|
|
$where_user["uname like '%{$params['title']}%'"] = null;
|
|
break;
|
|
case "sname":
|
|
$where_admin["uname like '%{$params['title']}%'"] = null;
|
|
break;
|
|
case "mobile":
|
|
$where_user['mobile'] = $params['title'];
|
|
break;
|
|
case "smobile":
|
|
$where_admin['mobile'] = $params['title'];
|
|
break;
|
|
case "suid":
|
|
$where['cf_suid'] = $params['title'];
|
|
break;
|
|
}
|
|
|
|
if ($where_user) {
|
|
$rows_user = $this->user_entity->select($where_user);
|
|
$ids_str = $rows_user ? implode(',', array_column($rows_user, 'id')) : "-1";
|
|
$where["app_uid in ({$ids_str})"] = null;
|
|
}
|
|
if ($where_admin) {
|
|
$select = "id";
|
|
$row_admin = $this->mdSysAdmin->select($where_admin, 'id desc', 0, 0, $select);
|
|
$ids_str = $row_admin ? implode(',', array_column($row_admin, 'id')) : "-1";
|
|
$where["cf_suid in ({$ids_str})"] = null;
|
|
}
|
|
}
|
|
|
|
if ($params['time']) {
|
|
list($s_time, $e_time) = explode(" ~ ", $params['time']);
|
|
$s_time = strtotime($s_time . ' 00:00:00');
|
|
$e_time = strtotime($e_time . ' 23:59:59');
|
|
$where["c_time > {$s_time}"] = null;
|
|
$where["c_time < {$e_time}"] = null;
|
|
}
|
|
$total = $this->mdUserLog->count($where);
|
|
if ($total) {
|
|
$select = "id, app_uid, cf_suid, c_time";
|
|
$rows = $this->mdUserLog->select($where, 'id desc', $page, $size, $select);
|
|
$map_user = array();
|
|
$map_admin = array();
|
|
if ($rows) {
|
|
//获取用户信息
|
|
$uids = array_column($rows, "app_uid");
|
|
$uids = array_diff($uids, array(0));
|
|
$uids && $uids = array_unique($uids);
|
|
if ($uids) {
|
|
$ids_str = implode(',', $uids);
|
|
$where_user = array("id in({$ids_str})" => null);
|
|
$select_u = "id, nickname as uname, mobile";
|
|
if ($app_id == 2 || $app_id == 1 || $app_id == 5) {
|
|
$select_u = "id, uname, mobile";
|
|
}
|
|
$map_user = $this->user_entity->map('id', "*", $where_user, 'id desc', 0, 0, $select_u);
|
|
}
|
|
//获取管理员信息
|
|
$suids = array_column($rows, "cf_suid");
|
|
$suids = array_diff($suids, array(0));
|
|
$suids && $suids = array_unique($suids);
|
|
if ($suids) {
|
|
$ids_str = implode(',', $suids);
|
|
$where_admin = array("id in({$ids_str})" => null);
|
|
$select = "id, username, mobile";
|
|
$map_admin = $this->mdSysAdmin->map('id', "*", $where_admin, 'id desc', 0, 0, $select);
|
|
}
|
|
foreach ($rows as $v) {
|
|
$user = $map_user[$v['app_uid']];
|
|
$amdin = $map_admin[$v['cf_suid']];
|
|
$mobile = $user ? $user['mobile'] : "";
|
|
$smobile = $amdin ? $amdin['mobile'] : "";
|
|
$smobile && 1 != $this->role && $smobile = substr_replace($smobile, "*****", 3, 5);
|
|
$lists[] = array(
|
|
"id" => $v['id'],
|
|
"uname" => $user ? $user['uname'] : "",
|
|
"mobile" => $mobile,
|
|
"suname" => $amdin ? $amdin['username'] : "",
|
|
"smobile" => $smobile,
|
|
"c_time" => date('Y-m-d H:i:s', $v['c_time']),
|
|
);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
$this->data['_title'] = '专题访问用户';
|
|
$this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total);
|
|
$this->data['ary']['searchTpAry'] = $searchTpAry;
|
|
$this->data['lists'] = $lists;
|
|
$this->data['params'] = $params;
|
|
return $this->show_view('topics/lists_user', true);
|
|
}
|
|
|
|
public function get()
|
|
{
|
|
$id = intval($this->input->get('id'));
|
|
$app_id = intval($this->input->get('app_id'));
|
|
!$app_id && $app_id = $this->app_id;
|
|
if ($id > 0) {
|
|
$re = $this->mdTopics->get(array('id' => $id));
|
|
if (!$re || empty($re)) {
|
|
return $this->show_json(SYS_CODE_FAIL, '专题不存在!');
|
|
}
|
|
$re['bg_img_url'] = build_qiniu_image_url($re['bg_img']);
|
|
$info = $re;
|
|
$json = $info['jsondata'] ? json_decode($info['jsondata'], true) : '';
|
|
$info['cf_id'] = $json['cf_id'] ? $json['cf_id'] : "";
|
|
$info['mp_app_id'] = $json['mp_app_id'] ? $json['mp_app_id'] : "";
|
|
$info['ebiz'] = $json['ebiz'] ? $json['ebiz'] : "";
|
|
$_title = '编辑专题';
|
|
$edit_url = '/topics/topics/edit';
|
|
} else {
|
|
$_title = '新增专题';
|
|
$edit_url = '/topics/topics/add';
|
|
$info['id'] = $id;
|
|
$info['app_id'] = $app_id;
|
|
$info['cf_id'] = "";
|
|
$info['mp_app_id'] = "";
|
|
$info['ebiz'] = 0;
|
|
}
|
|
$info['spm'] = $this->input->get('spm');
|
|
$info['edit_url'] = $edit_url;
|
|
$info['moduleAry'] = $this->moduleAry;
|
|
$this->data['info'] = $info;
|
|
$this->data['_title'] = $_title;
|
|
return $this->show_view('topics/edit', true);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$app_id = $this->input->post('app_id');
|
|
if (!$app_id) {
|
|
return $this->show_json(SYS_CODE_FAIL, '非法参数');
|
|
}
|
|
$spm = $this->input->post('spm');
|
|
$title = $this->input->post('title');
|
|
if (!$title) {
|
|
return $this->show_json(SYS_CODE_FAIL, '请输入专题名称');
|
|
}
|
|
$bg_color = $this->input->post('bg_color');
|
|
$bg_img = $this->input->post('bg_img');
|
|
|
|
$dataItems['app_id'] = $app_id;
|
|
$dataItems['title'] = $title;
|
|
$dataItems['bg_color'] = $bg_color;
|
|
$dataItems['bg_img'] = $bg_img;
|
|
$dataItems['status'] = 1;
|
|
$dataItems['c_time'] = time();
|
|
$id = $this->mdTopics->add($dataItems);
|
|
if (!$id) {
|
|
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
|
}
|
|
return $this->show_json(SYS_CODE_SUCCESS, '添加成功!', '#/topics/topics/get?id=' . $id . '&spm=' . $spm);
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if (!$id) {
|
|
return $this->show_json(SYS_CODE_FAIL, '非法参数');
|
|
}
|
|
$title = $this->input->post('title');
|
|
if (!$title) {
|
|
return $this->show_json(SYS_CODE_FAIL, '请输入专题名称');
|
|
}
|
|
$bg_color = $this->input->post('bg_color');
|
|
$bg_img = $this->input->post('bg_img');
|
|
$dataItems['title'] = $title;
|
|
$dataItems['bg_color'] = $bg_color;
|
|
$dataItems['bg_img'] = $bg_img;
|
|
$re = $this->mdTopics->update($dataItems, array('id' => $id));
|
|
if (!$re) {
|
|
return $this->show_json(SYS_CODE_FAIL, '修改失败');
|
|
}
|
|
return $this->show_json(SYS_CODE_SUCCESS, '修改成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:获取模块列表
|
|
* Created on: 2020/2/10 19:01
|
|
* Created by: dengbw
|
|
*/
|
|
public function get_module()
|
|
{
|
|
$page_id = $this->input->get('page_id');
|
|
$moduleList = array();
|
|
$re = $this->mdTopics->get(array('id' => $page_id), 'app_id,module_ids');
|
|
if ($re['module_ids']) {
|
|
$where['status>-1'] = null;
|
|
$where['id in (' . $re['module_ids'] . ')'] = null;
|
|
$resM = $this->mdTopicModules->select($where, 'sort DESC', 0, 0, 'id,type,sort');
|
|
foreach ($resM as $key => $value) {
|
|
$style = 'none';//none,block(隐藏,显示content富文本)
|
|
$title = $mdModule = '';
|
|
switch ($value['type']) {
|
|
case "text":
|
|
$title = '文本模块';
|
|
$mdModule = $this->mdModuleText;
|
|
$style = 'block';
|
|
break;
|
|
case "ad":
|
|
$title = '广告模块';
|
|
$mdModule = $this->mdModuleAd;
|
|
break;
|
|
case "enroll":
|
|
$title = '报名模块';
|
|
$mdModule = $this->mdModuleEnroll;
|
|
$style = 'block';
|
|
break;
|
|
case "button":
|
|
$title = '按钮模块';
|
|
$mdModule = $this->mdModuleButton;
|
|
break;
|
|
default:
|
|
}
|
|
if ($mdModule) {
|
|
$re = $mdModule->get(array('module_id' => $value['id']), 'title');
|
|
if ($re) {
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['page_id'] = $page_id;
|
|
$setValue['name'] = $re['title'] ? $re['title'] : $title;
|
|
$setValue['tag'] = $value['type'];
|
|
$setValue['order_view'] = $value['sort'];
|
|
$setValue['style'] = $style;
|
|
$moduleList[] = $setValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$this->data = $moduleList;
|
|
return $this->show_json(SYS_CODE_SUCCESS, '获取成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:保存添加模块
|
|
* Created on: 2020/2/10 18:06
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_add_module()
|
|
{
|
|
$page_id = intval($this->input->post('page_id'));
|
|
$add_sys_shop_module = $this->input->post('add_sys_shop_module');
|
|
$reT = $this->mdTopics->get(array('id' => $page_id), 'module_ids');
|
|
if (!$reT) {
|
|
return $this->show_json(SYS_CODE_FAIL, '添加失败!');
|
|
}
|
|
$module_ids = $reT['module_ids'];
|
|
$sort = 100;
|
|
if ($module_ids) {
|
|
$where['status>-1'] = null;
|
|
$where['id in (' . $module_ids . ')'] = null;
|
|
$reM = $this->mdTopicModules->min('sort', $where);//获取最小排序
|
|
if ($reM['sort']) {
|
|
$sort = $reM['sort'] - 1;
|
|
}
|
|
}
|
|
$dataM['sort'] = $sort;
|
|
$dataM['type'] = $add_sys_shop_module['tag'];
|
|
$dataM['status'] = 1;
|
|
//添加模块
|
|
$mid = $this->mdTopicModules->add($dataM);
|
|
if ($mid <= 0) {
|
|
return $this->show_json(SYS_CODE_FAIL, '添加失败!');
|
|
}
|
|
//添加各模块
|
|
$dataI['module_id'] = $mid;
|
|
$dataI['title'] = $add_sys_shop_module['name'];
|
|
if ($add_sys_shop_module['tag'] == 'text') {
|
|
$this->mdModuleText->add($dataI);
|
|
} else if ($add_sys_shop_module['tag'] == 'ad') {
|
|
$this->mdModuleAd->add($dataI);
|
|
} else if ($add_sys_shop_module['tag'] == 'enroll') {
|
|
$this->mdModuleEnroll->add($dataI);
|
|
} elseif ($add_sys_shop_module['tag'] == 'button') {
|
|
$this->mdModuleButton->add($dataI);
|
|
} elseif ($add_sys_shop_module['tag'] == 'countdown') {
|
|
$this->mdModuleCountdown->add($dataI);
|
|
}
|
|
//更新专题
|
|
$module_ids = $module_ids ? $module_ids . ',' . $mid : $mid;
|
|
$this->mdTopics->update(array('module_ids' => $module_ids), array('id' => $page_id));
|
|
return $this->show_json(SYS_CODE_SUCCESS, '添加成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:保存模块排序
|
|
* Created on: 2020/2/21 15:59
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_sort_module()
|
|
{
|
|
$module_list = $this->input->post('module_list');
|
|
if (!$module_list) {
|
|
return $this->show_json(SYS_CODE_FAIL, '排序失败!');
|
|
}
|
|
foreach ($module_list as $key => $value) {
|
|
$this->mdTopicModules->update(array('sort' => $value['order_view']), array('id' => $value['id']));
|
|
}
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:软删除已保存的模块
|
|
* Created on: 2020/2/11 14:36
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_delete_module()
|
|
{
|
|
$id = intval($this->input->post('id'));
|
|
if (!$id) {
|
|
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
|
|
}
|
|
$this->mdTopicModules->update(array('status' => -1), array('id' => $id));
|
|
return $this->show_json(SYS_CODE_SUCCESS, '删除成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:获取文本模块信息
|
|
* Created on: 2020/2/13 12:48
|
|
* Created by: dengbw
|
|
*/
|
|
public function get_text_setting()
|
|
{
|
|
$module_id = intval($this->input->get('module_id'));
|
|
$re = $this->mdModuleText->get(array('module_id' => $module_id));
|
|
$setting = array();
|
|
$status = 0;
|
|
$module_title = $module_desc = $module_content = $bg_img = $bg_color = "";
|
|
$title_img = $title_bgcolor = $title_color = $border_color = "";
|
|
if ($re) {
|
|
$reM = $this->mdTopicModules->get(array('id' => $module_id), 'status, jsondata');
|
|
$json_topic = json_decode($reM['jsondata'], true);
|
|
$status = $reM ? $reM['status'] : 0;
|
|
$module_title = $re['title'];
|
|
$module_desc = $re['descrip'];
|
|
$module_content = $re['content'];
|
|
$title_img = strval($json_topic['title_img']);
|
|
$title_bgcolor = strval($json_topic['title_bgcolor']);
|
|
$title_color = strval($json_topic['title_color']);
|
|
$bg_img = strval($json_topic['bg_img']);
|
|
$bg_color = strval($json_topic['bg_color']);
|
|
$border_color = strval($json_topic['border_color']);
|
|
}
|
|
$setting['status'] = $status;
|
|
$setting['module_title'] = $module_title;
|
|
$setting["module_title_img"] = strval($title_img);
|
|
$setting["module_title_img_url"] = $title_img ? build_qiniu_image_url($title_img) : "";
|
|
$setting["module_title_bgcolor"] = strval($title_bgcolor);
|
|
$setting["module_title_color"] = strval($title_color);
|
|
$setting['module_desc'] = $module_desc;
|
|
$setting['module_content'] = $module_content;
|
|
$setting['module_bg_img'] = $bg_img;
|
|
$setting['module_bg_img_url'] = $bg_img ? build_qiniu_image_url($bg_img) : "";
|
|
$setting['module_bg_color'] = $bg_color;
|
|
$setting["module_border_color"] = strval($border_color);
|
|
$this->data['setting'] = $setting;
|
|
return $this->show_json(SYS_CODE_SUCCESS, '获取成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:保存文本模块
|
|
* Created on: 2020/2/13 12:35
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_save_text()
|
|
{
|
|
$save_data = $this->input->post('save_data');
|
|
if (!$save_data['module_id']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
|
|
}
|
|
|
|
$row_text = $this->mdModuleText->get(array('module_id' => $save_data['module_id']));
|
|
|
|
$dataI['title'] = $save_data['setting']['module_title'];
|
|
$dataI['descrip'] = $save_data['setting']['module_desc'];
|
|
$dataI['content'] = $save_data['setting']['module_content'];
|
|
$this->mdModuleText->update($dataI, array('module_id' => $save_data['module_id']));
|
|
//更新其他参数
|
|
$title_img = $save_data['setting']['module_title_img'];
|
|
$title_bgcolor = $save_data['setting']['module_title_bgcolor'];
|
|
$title_color = $save_data['setting']['module_title_color'];
|
|
$border_color = $save_data['setting']['module_border_color'];
|
|
$bg_img = $save_data['setting']['module_bg_img'];
|
|
$bg_color = $save_data['setting']['module_bg_color'];
|
|
$where = array('id' => $save_data['module_id']);
|
|
$row_topic = $this->mdTopicModules->get($where);
|
|
$json = json_decode($row_topic['jsondata'], true);
|
|
if ($title_img) {
|
|
$json['title_img'] = $title_img;
|
|
} else {
|
|
unset($json['title_img']);
|
|
}
|
|
if ($title_bgcolor) {
|
|
$json['title_bgcolor'] = $title_bgcolor;
|
|
} else {
|
|
unset($json['title_bgcolor']);
|
|
}
|
|
if ($title_color) {
|
|
$json['title_color'] = $title_color;
|
|
} else {
|
|
unset($json['title_color']);
|
|
}
|
|
if ($border_color) {
|
|
$json['border_color'] = $border_color;
|
|
} else {
|
|
unset($json['border_color']);
|
|
}
|
|
if ($bg_img) {
|
|
$json['bg_img'] = $bg_img;
|
|
} else {
|
|
unset($json['bg_img']);
|
|
}
|
|
if ($bg_color) {
|
|
$json['bg_color'] = $bg_color;
|
|
} else {
|
|
unset($json['bg_color']);
|
|
}
|
|
$upd = array('status' => $save_data['setting']['status'], "jsondata" => json_encode($json, JSON_UNESCAPED_UNICODE));
|
|
$this->mdTopicModules->update($upd, $where);
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:获取广告信息
|
|
* Created on: 2020/5/12 22:48
|
|
* Created by: dengbw
|
|
*/
|
|
public function get_ad_setting()
|
|
{
|
|
$module_id = intval($this->input->get('module_id'));
|
|
$re = $this->mdModuleAd->get(array('module_id' => $module_id));
|
|
$setting = $list = array();
|
|
if ($re) {
|
|
$reM = $this->mdTopicModules->get(array('id' => $module_id), 'status, jsondata');
|
|
$json_topic = json_decode($reM['jsondata'], true);
|
|
$setting = array(
|
|
"module_title_img" => strval($json_topic['title_img']),
|
|
"module_title_img_url" => $json_topic['title_img'] ? build_qiniu_image_url($json_topic['title_img']) : "",
|
|
"module_title_bgcolor" => strval($json_topic['title_bgcolor']),
|
|
"module_title_color" => strval($json_topic['title_color']),
|
|
"module_bg_img" => strval($json_topic['bg_img']),
|
|
"module_bg_img_url" => $json_topic['bg_img'] ? build_qiniu_image_url($json_topic['bg_img']) : "",
|
|
"module_bg_color" => strval($json_topic['bg_color']),
|
|
"module_border_color" => strval($json_topic['border_color']),
|
|
);
|
|
$setting['status'] = $reM ? $reM['status'] : 0;
|
|
$setting['module_title'] = $re['title'];
|
|
$setting['module_desc'] = $re['descrip'];
|
|
$setting['style'] = $re['style'];
|
|
$img_json = $re['img_json'] ? json_decode($re['img_json'], true) : array();
|
|
foreach ($img_json as $key => $value) {
|
|
$setValue = $value;
|
|
$setValue['img_url'] = build_qiniu_image_url($value['img'], 690, 390);
|
|
$setValue['order_view'] = $value['order_view'] ? $value['order_view'] : 50;
|
|
$setValue['jump_type'] = intval($value['jump_type']);
|
|
$list[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['setting'] = $setting;
|
|
$this->data['ad_list'] = $list;
|
|
return $this->show_json(SYS_CODE_SUCCESS, '获取成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:保存广告模块
|
|
* Created on: 2020/5/12 12:35
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_save_ad()
|
|
{
|
|
$save_data = $this->input->post('save_data');
|
|
if (!$save_data['module_id']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
|
|
}
|
|
|
|
$dataI['title'] = $save_data['setting']['module_title'];
|
|
$dataI['descrip'] = $save_data['setting']['module_desc'];
|
|
$dataI['style'] = $save_data['setting']['style'];
|
|
$dataI['img_json'] = $save_data['ads'] ? json_encode($save_data['ads'], JSON_UNESCAPED_UNICODE) : null;
|
|
$this->mdModuleAd->update($dataI, array('module_id' => $save_data['module_id']));
|
|
|
|
//更新其他参数
|
|
$title_img = $save_data['setting']['module_title_img'];
|
|
$title_bgcolor = $save_data['setting']['module_title_bgcolor'];
|
|
$title_color = $save_data['setting']['module_title_color'];
|
|
$border_color = $save_data['setting']['module_border_color'];
|
|
$bg_img = $save_data['setting']['module_bg_img'];
|
|
$bg_color = $save_data['setting']['module_bg_color'];
|
|
$where = array('id' => $save_data['module_id']);
|
|
$row_topic = $this->mdTopicModules->get($where);
|
|
$json = json_decode($row_topic['jsondata'], true);
|
|
if ($title_img) {
|
|
$json['title_img'] = $title_img;
|
|
} else {
|
|
unset($json['title_img']);
|
|
}
|
|
if ($title_bgcolor) {
|
|
$json['title_bgcolor'] = $title_bgcolor;
|
|
} else {
|
|
unset($json['title_bgcolor']);
|
|
}
|
|
if ($title_color) {
|
|
$json['title_color'] = $title_color;
|
|
} else {
|
|
unset($json['title_color']);
|
|
}
|
|
if ($border_color) {
|
|
$json['border_color'] = $border_color;
|
|
} else {
|
|
unset($json['border_color']);
|
|
}
|
|
if ($bg_img) {
|
|
$json['bg_img'] = $bg_img;
|
|
} else {
|
|
unset($json['bg_img']);
|
|
}
|
|
if ($bg_color) {
|
|
$json['bg_color'] = $bg_color;
|
|
} else {
|
|
unset($json['bg_color']);
|
|
}
|
|
$upd = array('status' => $save_data['setting']['status'], "jsondata" => json_encode($json, JSON_UNESCAPED_UNICODE));
|
|
$this->mdTopicModules->update($upd, $where);
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:获取报名信息
|
|
* Created on: 2020/5/12 22:48
|
|
* Created by: dengbw
|
|
*/
|
|
public function get_enroll_setting()
|
|
{
|
|
$module_id = intval($this->input->get('module_id'));
|
|
$re = $this->mdModuleEnroll->get(array('module_id' => $module_id));
|
|
$setting = $list = array();
|
|
if ($re) {
|
|
$reM = $this->mdTopicModules->get(array('id' => $module_id), 'status, jsondata');
|
|
$json_topic = json_decode($reM['jsondata'], true);
|
|
$setting['status'] = $reM ? $reM['status'] : 0;
|
|
$setting['module_title'] = $re['title'];
|
|
$setting['module_desc'] = $re['descrip'];
|
|
$setting['module_banner'] = $re['banner'];
|
|
$setting['module_banner_url'] = $re['banner'] ? build_qiniu_image_url($re['banner']) : '';
|
|
$setting['module_limit_num'] = $re['limit_num'];
|
|
$setting['module_type'] = $re['type'];
|
|
$setting['module_content'] = $re['content'];
|
|
$setting['module_title_img'] = strval($json_topic['title_img']);
|
|
$setting['module_title_img_url'] = $json_topic['title_img'] ? build_qiniu_image_url($json_topic['title_img']) : "";
|
|
|
|
//设置黑名单,风格
|
|
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : array();
|
|
$setting['user_black'] = intval($jsondata['user_black']);
|
|
$setting['style'] = intval($jsondata['style']);
|
|
$setting['show_type'] = intval($jsondata['show_type']);
|
|
$setting['if_code'] = intval($jsondata['if_code']);
|
|
$setting['if_module'] = intval($jsondata['if_module']);
|
|
$time = '';
|
|
if ($re['type'] == 1) {
|
|
if ($re['as_time'] != '0000-00-00 00:00:00') {
|
|
$time = $re['as_time'] . " ~ " . $re['ae_time'];
|
|
}
|
|
$this->load->model('biz/biz_model', 'mdBiz');
|
|
$ids = 0;
|
|
$resBiz = $this->mdModuleEnrollbiz->select(array('module_id' => $module_id), 'id desc', 0, 0, 'biz_id');
|
|
$resBiz && $ids = implode(',', array_column($resBiz, 'biz_id'));
|
|
$where["id in ({$ids})"] = null;
|
|
$res = $this->mdBiz->select($where, ' field(id,' . $ids . ')', 0, 0, 'id,biz_name');
|
|
if ($res) {
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['name'] = $value['biz_name'];
|
|
$list[] = $setValue;
|
|
}
|
|
}
|
|
}
|
|
$etime = '';
|
|
if ($re['es_time'] != '0000-00-00 00:00:00') {
|
|
$etime = $re['es_time'] . " ~ " . $re['ee_time'];
|
|
}
|
|
$setting['module_time'] = $time;//核销时间
|
|
$setting['module_etime'] = $etime;//报名时间
|
|
}
|
|
$this->data['setting'] = $setting;
|
|
$this->data['goods'] = $list;
|
|
return $this->show_json(SYS_CODE_SUCCESS, '获取成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:保存报名模块
|
|
* Created on: 2020/5/12 12:35
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_save_enroll()
|
|
{
|
|
$save_data = $this->input->post('save_data');
|
|
$module_id = $save_data['module_id'];
|
|
if (!$module_id) {
|
|
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
|
|
}
|
|
$dataI['title'] = $save_data['setting']['module_title'];
|
|
$dataI['descrip'] = $save_data['setting']['module_desc'];
|
|
$dataI['banner'] = $save_data['setting']['module_banner'];
|
|
$dataI['content'] = $save_data['setting']['module_content'];
|
|
$dataI['limit_num'] = intval($save_data['setting']['module_limit_num']);
|
|
$dataI['type'] = $save_data['setting']['module_type'];
|
|
//报名时间
|
|
$es_time = $ee_time = '0000-00-00 00:00:00';
|
|
if ($save_data['setting']['module_etime']) {
|
|
$module_time = explode(' ~ ', $save_data['setting']['module_etime']);
|
|
$es_time = $module_time[0];
|
|
$ee_time = $module_time[1];
|
|
}
|
|
//核销时间
|
|
$as_time = $ae_time = '0000-00-00 00:00:00';
|
|
if ($save_data['setting']['module_time']) {
|
|
$module_time = explode(' ~ ', $save_data['setting']['module_time']);
|
|
$as_time = $module_time[0];
|
|
$ae_time = $module_time[1];
|
|
}
|
|
//核销商家
|
|
if ($dataI['type'] == 1) {
|
|
$dataI['as_time'] = $as_time;
|
|
$dataI['ae_time'] = $ae_time;
|
|
$addBiz = array();
|
|
if ($save_data['enrolls']) {
|
|
foreach ($save_data['enrolls'] as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['module_id'] = $module_id;
|
|
$setValue['biz_id'] = $value['id'];
|
|
$addBiz[] = $setValue;
|
|
}
|
|
}
|
|
$this->mdModuleEnrollbiz->delete(array("module_id" => $module_id));
|
|
$addBiz && $this->mdModuleEnrollbiz->add_batch($addBiz);
|
|
}
|
|
$dataI['es_time'] = $es_time;
|
|
$dataI['ee_time'] = $ee_time;
|
|
|
|
//jsondata
|
|
$row = $this->mdModuleEnroll->get(array('module_id' => $save_data['module_id']));
|
|
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
|
|
if (0 == $save_data['setting']['user_black']) {//不限制黑名单
|
|
unset($jsondata['user_black']);
|
|
} else {
|
|
$jsondata['user_black'] = 1;
|
|
}
|
|
if (0 == $save_data['setting']['style']) {
|
|
unset($jsondata['style']);
|
|
} else {
|
|
$jsondata['style'] = 1;
|
|
}
|
|
$jsondata['show_type'] = $save_data['setting']['show_type'];
|
|
$jsondata['if_code'] = $save_data['setting']['if_code'];
|
|
$jsondata['if_module'] = $save_data['setting']['if_module'];
|
|
$dataI['jsondata'] = $jsondata ? json_encode($jsondata, JSON_UNESCAPED_UNICODE) : null;
|
|
|
|
//更新其他参数
|
|
$where = array('id' => $save_data['module_id']);
|
|
$row_topic = $this->mdTopicModules->get($where);
|
|
$json = json_decode($row_topic['jsondata'], true);
|
|
$title_img = $save_data['setting']['module_title_img'];
|
|
if ($title_img) {
|
|
$json['title_img'] = $title_img;
|
|
} else {
|
|
unset($json['title_img']);
|
|
}
|
|
|
|
//$enroll_json['gender'] = array("name" => '性别', "field" => 'radio', "values" => array('男', '女'));
|
|
$enroll_json['remark'] = array("name" => '备注', "field" => 'textarea');
|
|
$dataI['enroll_json'] = json_encode($enroll_json);
|
|
$this->mdModuleEnroll->update($dataI, array('module_id' => $save_data['module_id']));
|
|
$this->mdTopicModules->update(array('status' => $save_data['setting']['status'], "jsondata" => json_encode($json, JSON_UNESCAPED_UNICODE)
|
|
), array('id' => $save_data['module_id']));
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:获取按扭模块信息
|
|
* Created on: 2020/10/20 12:48
|
|
* Created by: dengbw
|
|
*/
|
|
public function get_button_setting()
|
|
{
|
|
$module_id = intval($this->input->get('module_id'));
|
|
$re_btn = $this->mdModuleButton->get(array('module_id' => $module_id));
|
|
$setting = $jsondata = array();
|
|
$status = $module_type = 0;
|
|
$module_title = $module_descrip = "";
|
|
if ($re_btn) {
|
|
$reM = $this->mdTopicModules->get(array('id' => $module_id));
|
|
$status = intval($reM['status']);
|
|
$module_title = $re_btn['title'];
|
|
$module_type = intval($re_btn['type']);
|
|
$module_descrip = $re_btn['descrip'];
|
|
if ($re_btn['jsondata']) {
|
|
$jsondata = json_decode($re_btn['jsondata'], true);
|
|
$jsondata['img_url'] = $jsondata['img'] ? build_qiniu_image_url($jsondata['img']) : "";
|
|
}
|
|
}
|
|
$setting['status'] = $status;
|
|
$setting['module_title'] = $module_title;
|
|
$setting['module_type'] = $module_type;
|
|
$setting['module_descrip'] = $module_descrip;
|
|
$setting['module_jsondata'] = $jsondata;
|
|
$this->data['setting'] = $setting;
|
|
return $this->show_json(SYS_CODE_SUCCESS, '获取成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:保存按扭模块
|
|
* Created on: 2020/10/20 12:35
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_save_button()
|
|
{
|
|
$save_data = $this->input->post('save_data');
|
|
if (!$save_data['module_id']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
|
|
}
|
|
$dataI['title'] = $save_data['setting']['module_title'];
|
|
$dataI['type'] = $save_data['setting']['module_type'];
|
|
$dataI['descrip'] = $save_data['setting']['module_descrip'];
|
|
$module_jsondata = $save_data['setting']['module_jsondata'];
|
|
unset($module_jsondata['img_url']);
|
|
$dataI['jsondata'] = json_encode($module_jsondata, JSON_UNESCAPED_UNICODE);
|
|
$this->mdModuleButton->update($dataI, array('module_id' => $save_data['module_id']));
|
|
$where = array('id' => $save_data['module_id']);
|
|
$upd = array('status' => $save_data['setting']['status']);
|
|
$this->mdTopicModules->update($upd, $where);
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
|
|
}
|
|
|
|
|
|
/**
|
|
* Notes:修改状态 0下架,1正常
|
|
* Created on: 2019/12/3 15:48
|
|
* Created by: dengbw
|
|
*/
|
|
public function edit_status()
|
|
{
|
|
$id = intval($this->input->post('id'));
|
|
$status = intval($this->input->post('status'));
|
|
$where['id'] = $id;
|
|
$data['status'] = $status;
|
|
$re = $this->mdTopics->update($data, $where);
|
|
if (!$re) {
|
|
return $this->show_json(SYS_CODE_FAIL, '修改失败');
|
|
}
|
|
return $this->show_json(SYS_CODE_SUCCESS, '修改成功!');
|
|
}
|
|
|
|
public function del()
|
|
{
|
|
// TODO: Implement del() method.
|
|
}
|
|
|
|
|
|
public function batch()
|
|
{
|
|
}
|
|
|
|
public function export()
|
|
{
|
|
// TODO: Implement export() method.
|
|
}
|
|
|
|
} |