407 lines
16 KiB
PHP
407 lines
16 KiB
PHP
<?php
|
|
/**
|
|
* Notes:私域通-直播
|
|
* Created on: 2022/05/07 13:38
|
|
* Created by: dengbw
|
|
*/
|
|
|
|
class Sytlive extends HD_Controller
|
|
{
|
|
private $statusAry = array(-1 => '已删除', 0 => '待审核', 1 => '已通过', 2 => '未通过');
|
|
private $app_id = 2;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('app/licheb/syt_live_model', 'mdSytLive');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
return $this->lists();
|
|
}
|
|
|
|
public function lists()
|
|
{
|
|
$params = $this->input->get();
|
|
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
|
$params['size'] = $params['size'] ? intval($params['size']) : 20;
|
|
$lists = array();
|
|
$where = array('status>' => -1);
|
|
$count = $this->mdSytLive->count($where);
|
|
if ($count) {
|
|
$this->load->library('MyEncryption');
|
|
$res = $this->mdSytLive->select($where, 'id desc', $params['page'], $params['size']);
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['title'] = $value['title'];
|
|
$setValue['session_id'] = $value['session_id'];
|
|
$setValue['s_time'] = $value['s_time'];
|
|
$setValue['e_time'] = $value['e_time'];
|
|
$setValue['c_time'] = date('Y-m-d H:i', $value['c_time']);
|
|
$setValue['status_name'] = $this->statusAry[$value['status']];
|
|
$url = http_host_com('home') . "/h5/syt/live?skey=" . $this->myencryption->base64url_encode("id=" . $value['id']);
|
|
$setValue['url'] = urlencode($url);
|
|
$lists[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['_title'] = '私域通-直播列表';
|
|
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
|
|
$this->data['lists'] = $lists;
|
|
$this->data['params'] = $params;
|
|
return $this->show_view('/app/licheb/syt/live_lists', true);
|
|
}
|
|
|
|
public function get()
|
|
{
|
|
$params = $this->input->get();
|
|
$id = intval($params['id']);
|
|
$status_list = $kpi_list = array();
|
|
$posters = array('imgs_url' => array(), 'imgs' => array());
|
|
$share_title = $remark = $rule = $bg_color = $btn_color = '';
|
|
if ($id > 0) {
|
|
$re = $this->mdSytLive->get(array('id' => $id));
|
|
if (!$re || empty($re)) {
|
|
return $this->show_json(SYS_CODE_FAIL, '活动不存在!');
|
|
}
|
|
$_title = '编辑私域通-直播';
|
|
$dataInfo['editType'] = 0;
|
|
$dataInfo['edit_url'] = '/app/licheb/sytlive/edit';
|
|
$dataInfo['brand_id'] = $re['brand_id'] ? explode(',', $re['brand_id']) : [];
|
|
$dataInfo['status'] = $re['status'];
|
|
$dataInfo['z_id'] = $re['z_id'];
|
|
if ($re['jsondata']) {
|
|
$jsondata = json_decode($re['jsondata'], true);
|
|
$share_title = $jsondata['share_title'] ? $jsondata['share_title'] : '';
|
|
$remark = $jsondata['remark'] ? $jsondata['remark'] : '';
|
|
$rule = $jsondata['rule'] ? $jsondata['rule'] : '';
|
|
$bg_color = $jsondata['bg_color'] ? $jsondata['bg_color'] : '';
|
|
$btn_color = $jsondata['btn_color'] ? $jsondata['btn_color'] : '';
|
|
if ($jsondata['posters']) {
|
|
foreach ($jsondata['posters'] as $key => $value) {
|
|
$posters['imgs_url'][] = array("value" => $value['url'], "src" => build_qiniu_image_url($value['url']));
|
|
$posters['imgs'][] = array("value" => $value['url'], "src" => build_qiniu_image_url($value['url'])
|
|
, "width" => $value['width'], "height" => $value['height']);
|
|
}
|
|
}
|
|
}
|
|
if ($re['z_id']) {
|
|
$re_t = $this->mdTopics->get(array('id' => $re['z_id']));
|
|
$dataInfo['z_title'] = $re_t['title'] ? $re_t['title'] : '';
|
|
}
|
|
$dataInfo['title'] = $re['title'];
|
|
$dataInfo['img'] = $re['img'] ? $re['img'] : '';
|
|
$dataInfo['img_url'] = $re['img'] ? build_qiniu_image_url($re['img']) : '';
|
|
$dataInfo['time'] = $re['s_time'] . " ~ " . $re['e_time'];
|
|
} else {
|
|
$_title = '新增私域通-直播';
|
|
$dataInfo['editType'] = 2;
|
|
$dataInfo['edit_url'] = '/app/licheb/sytlive/add';
|
|
$dataInfo['brand_id'] = [];
|
|
$dataInfo['status'] = 0;
|
|
$dataInfo['z_id'] = 0;
|
|
}
|
|
foreach ($this->statusAry as $key => $value) {
|
|
$status_list[] = array("id" => $key, "name" => $value);
|
|
}
|
|
$dataInfo['kpi_list'] = [];
|
|
$dataInfo['id'] = $id;
|
|
$dataInfo['share_title'] = $share_title;
|
|
$dataInfo['remark'] = $remark;
|
|
$dataInfo['rule'] = $rule;
|
|
$dataInfo['bg_color'] = $bg_color;
|
|
$dataInfo['btn_color'] = $btn_color;
|
|
$this->data['info'] = $dataInfo;
|
|
$this->data['status_list'] = $status_list;
|
|
$this->data['posters'] = $posters;
|
|
$this->data['_title'] = $_title;
|
|
return $this->show_view('/app/licheb/syt/live_edit', true);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$info = $this->input->post('info');
|
|
$checkData = $this->checkData($info);
|
|
if (!$checkData['code']) {
|
|
return $this->show_json($checkData['code'], $checkData['msg']);
|
|
}
|
|
$brand_id = $info['brand_id'] ? implode(',', $info['brand_id']) : 0;
|
|
$re = $this->mdSytLive->get(array("z_id" => $info['z_id'], "brand_id" => $brand_id));
|
|
if ($re) {
|
|
return $this->show_json(SYS_CODE_FAIL, '该活动已存在!');
|
|
}
|
|
$jsonkpi = json_encode($info['kpi_list'], JSON_UNESCAPED_UNICODE);
|
|
$json_data['share_title'] = $info['share_title'];
|
|
$json_data['remark'] = $info['remark'];
|
|
$json_data['rule'] = $info['rule'];
|
|
$json_data['bg_color'] = $info['bg_color'];
|
|
$json_data['btn_color'] = $info['btn_color'];
|
|
//海报
|
|
$posters = array();
|
|
if ($info['posters']) {
|
|
foreach ($info['posters'] as $key => $value) {
|
|
$posters[] = array('url' => $value['value'], 'width' => $value['width'], 'height' => $value['height']);
|
|
}
|
|
}
|
|
$json_data['posters'] = $posters;
|
|
$jsondata = json_encode($json_data, JSON_UNESCAPED_UNICODE);
|
|
$addData = array("brand_id" => $brand_id, "title" => $info['title'], "z_id" => $info['z_id'], "img" => $info['img']
|
|
, "jsonkpi" => $jsonkpi, "jsondata" => $jsondata, "status" => $info['status'], "c_time" => time());
|
|
if ($info['time']) {
|
|
$time = explode(' ~ ', $info['time']);
|
|
$addData['s_time'] = $time[0];
|
|
$addData['e_time'] = $time[1];
|
|
}
|
|
$id = $this->mdSytLive->add($addData);
|
|
if (!$id) {
|
|
return $this->show_json(SYS_CODE_FAIL, '新增活动失败!');
|
|
}
|
|
$this->data['type'] = 'add';
|
|
$this->data['id'] = $id;
|
|
return $this->show_json(SYS_CODE_SUCCESS, '新增活动成功!');
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$info = $this->input->post('info');
|
|
$checkData = $this->checkData($info);
|
|
if (!$checkData['code']) {
|
|
return $this->show_json($checkData['code'], $checkData['msg']);
|
|
}
|
|
if (!$info['id']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
|
|
}
|
|
$jsonkpi = json_encode($info['kpi_list'], JSON_UNESCAPED_UNICODE);
|
|
$json_data['share_title'] = $info['share_title'];
|
|
$json_data['remark'] = $info['remark'];
|
|
$json_data['rule'] = $info['rule'];
|
|
$json_data['bg_color'] = $info['bg_color'];
|
|
$json_data['btn_color'] = $info['btn_color'];
|
|
//海报
|
|
$posters = array();
|
|
if ($info['posters']) {
|
|
foreach ($info['posters'] as $key => $value) {
|
|
$posters[] = array('url' => $value['value'], 'width' => $value['width'], 'height' => $value['height']);
|
|
}
|
|
}
|
|
$json_data['posters'] = $posters;
|
|
$jsondata = json_encode($json_data, JSON_UNESCAPED_UNICODE);
|
|
$brand_id = $info['brand_id'] ? implode(',', $info['brand_id']) : 0;
|
|
$updateData = array("brand_id" => $brand_id, "title" => $info['title'], "z_id" => $info['z_id'], "img" => $info['img']
|
|
, "jsonkpi" => $jsonkpi, "jsondata" => $jsondata);
|
|
if ($info['time']) {
|
|
$time = explode(' ~ ', $info['time']);
|
|
$updateData['s_time'] = $time[0];
|
|
$updateData['e_time'] = $time[1];
|
|
}
|
|
$this->mdSytLive->update($updateData, array('id' => $info['id']));
|
|
$this->data['type'] = 'edit';
|
|
return $this->show_json(SYS_CODE_SUCCESS, '修改活动成功!');
|
|
}
|
|
|
|
/**
|
|
* Notes:修改商家状态
|
|
* Created on: 2020/8/24 11:12
|
|
* Created by: dengbw
|
|
* @return bool|void
|
|
*/
|
|
public function edit_status()
|
|
{
|
|
$info = $this->input->post('info');
|
|
if (!$info['id']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
|
|
}
|
|
$this->mdSytLive->update(array("status" => intval($info['status'])), array('id' => $info['id']));
|
|
return $this->show_json(SYS_CODE_SUCCESS, '操作成功!');
|
|
}
|
|
|
|
|
|
/**
|
|
* Notes:私域通-报名
|
|
* Created on: 2020/12/23 14:54
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function get_enroll_lists()
|
|
{
|
|
$params = $this->input->get();
|
|
if (!$params['a_id']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
|
|
}
|
|
$re = $this->mdSytLive->get(array('id' => $params['a_id']));
|
|
if (!$re || empty($re)) {
|
|
return $this->show_json(SYS_CODE_FAIL, '活动不存在!');
|
|
}
|
|
$res = $this->enrollSelect($params);
|
|
$lists = $res['lists'];
|
|
$count = $res['count'];
|
|
$params = $res['params'];
|
|
$this->data['_title'] = '私域通-[' . $re['title'] . ']报名';
|
|
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
|
|
$this->data['lists'] = $lists;
|
|
$this->data['params'] = $res['params'];
|
|
return $this->show_view('/app/hdy/syt/enroll_lists', true);
|
|
}
|
|
|
|
public function enrollSelect($params)
|
|
{
|
|
$this->load->model('app/syt/syt_activity_enroll_model', 'mdSytLiveEnroll');
|
|
$this->load->model('app/syt/syt_activity_team_model', 'mdSytLiveTeam');
|
|
$this->load->model('app/hdy/app_hdy_users_model', 'mdHdyUsers');
|
|
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
|
$params['size'] = $params['size'] ? intval($params['size']) : 20;
|
|
$params['a_id'] = intval($params['a_id']);
|
|
$lists = array();
|
|
$where = array('status' => 1, 'a_id' => $params['a_id']);
|
|
if ($params['nickname']) {
|
|
$where['nickname LIKE "%' . $params['nickname'] . '%"'] = null;
|
|
}
|
|
if ($params['mobile']) {
|
|
$where['mobile LIKE "%' . $params['mobile'] . '%"'] = null;
|
|
}
|
|
$count = $this->mdSytLiveEnroll->count($where);
|
|
if ($count) {
|
|
$res = $this->mdSytLiveEnroll->select($where, 'id desc', $params['page'], $params['size']);
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['nickname'] = $value['nickname'];
|
|
$setValue['mobile'] = $value['mobile'];
|
|
$cf_name = '-';
|
|
if ($value['cf_uid'] || $value['t_id']) {
|
|
if ($value['cf_uid']) {
|
|
$reUsers = $this->mdHdyUsers->get(array('id' => $value['cf_uid']));
|
|
$reUsers['nickname'] && $cf_name = $reUsers['nickname'];
|
|
} else {
|
|
$re_t = $this->mdSytLiveTeam->get(array('id' => $value['t_id']));
|
|
$re_t['name'] && $cf_name = $re_t['name'];
|
|
}
|
|
}
|
|
$setValue['cf_name'] = $cf_name;
|
|
$setValue['c_time'] = date('Y-m-d H:i', $value['c_time']);
|
|
$lists[] = $setValue;
|
|
}
|
|
}
|
|
$data['lists'] = $lists;
|
|
$data['count'] = $count;
|
|
$data['params'] = $params;
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Notes:检查新增/修改数据
|
|
* Created on: 2020/8/20 11:59
|
|
* Created by: dengbw
|
|
* @param $info
|
|
* @return array
|
|
*/
|
|
private function checkData($info)
|
|
{
|
|
$msg = '';
|
|
$code = SYS_CODE_FAIL;
|
|
if (!$info) {
|
|
$msg = '非法参数';
|
|
} else if (!$info['brand_id']) {
|
|
$msg = '请选择活动品牌';
|
|
} else if (!$info['z_id']) {
|
|
$msg = '请选择活动专题';
|
|
} else if (!$info['title']) {
|
|
$msg = '请输入活动标题';
|
|
} else if (!$info['time']) {
|
|
$msg = '请选择活动时间';
|
|
} else {
|
|
$code = SYS_CODE_SUCCESS;
|
|
}
|
|
return array('code' => $code, 'msg' => $msg);
|
|
}
|
|
|
|
public function del()
|
|
{
|
|
}
|
|
|
|
public function batch()
|
|
{
|
|
// TODO: Implement batch() method.
|
|
}
|
|
|
|
public function export()
|
|
{
|
|
$params = $this->input->get();
|
|
$params['page'] = 1;
|
|
$params['size'] = 10000;
|
|
$data = $indexs = array();
|
|
$res = $this->enrollSelect($params);
|
|
$fileName = '私域通报名';
|
|
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($data, $indexs, $fileName . "_" . date('YmdHis'));
|
|
}
|
|
|
|
public function get_topics()
|
|
{
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
|
|
$topicsList = array();
|
|
$where = array('status >' => -1, 'app_id' => $this->app_id);
|
|
$title = $this->input->post('title');
|
|
$title && $where['title like "%' . $title . '%"'] = null;
|
|
$count = $this->mdTopics->count($where);
|
|
if ($count) {
|
|
$res = $this->mdTopics->select($where, 'id desc', $page, $size);
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['title'] = $value['title'];
|
|
$topicsList[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['topicsList'] = $topicsList;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['topicsPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
private function get_biz_name($info)
|
|
{
|
|
$biz_name = '';
|
|
if ($info['biz_id']) {
|
|
$reBiz = $this->mdBiz->get(array('id' => $info['biz_id']), 'biz_name');
|
|
$biz_name = $reBiz['biz_name'];
|
|
} else if ($info['brand_id']) {
|
|
$reBrand = $this->mdBrand->get(array('id' => $info['brand_id']), 'brand_name');
|
|
$biz_name = $reBrand['brand_name'];
|
|
}
|
|
return $biz_name;
|
|
}
|
|
|
|
public function get_kpidata()
|
|
{
|
|
$this->load->model('app/syt/syt_activity_member_model', 'mdSytLiveMember');
|
|
$params = $this->input->get();
|
|
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
|
$params['size'] = $params['size'] ? intval($params['size']) : 10;
|
|
$where = array('status' => 1);
|
|
$res = $this->mdSytLiveMember->select($where, 'id asc', $params['page'], $params['size']);
|
|
foreach ($res as $key => $value) {
|
|
$this->mdSytKpiData->update(array("t_id" => $value['t_id']), array("a_id" => $value['a_id'], 'cf_uid' => $value['uid']));
|
|
}
|
|
print_r($res);
|
|
exit;
|
|
}
|
|
|
|
} |