加黑名单
This commit is contained in:
@@ -22,7 +22,6 @@ class Activity extends BaseController
|
||||
$this->load->model('market/Market_sylive_groups_model', 'mdSyliveGroups');
|
||||
$this->load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser');
|
||||
$this->load->model('market/Market_sylive_customer_model', 'mdSyliveCustomer');
|
||||
$this->load->model('market/Market_sylive_blacklist_model', 'mdSyliveBlacklist');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +61,7 @@ class Activity extends BaseController
|
||||
$dateRange = $v['timeStart'] != '0000-00-00 00:00:00' ? [$v['timeStart'], $v['timeEnd']] : '';
|
||||
$status = intval($v['status']);
|
||||
$activityId = intval($v['activityId']);
|
||||
$bgImg = $channelImg = $banner = $sharePhoto = $shareImg = $shareTitle = $pay = $bottoms = $showBlacklist = [];
|
||||
$bgImg = $channelImg = $banner = $sharePhoto = $shareImg = $shareTitle = $pay = $bottoms = [];
|
||||
$item = ['itemImg' => [], 'title' => '', 'introduction' => '', 'price' => '', 'stock' => '', 'dateRange' => ''];
|
||||
$coupon = ['img' => [], 'title' => '', 'rules' => '', 'price' => '', 'dateRange' => ''];
|
||||
$draw = ['bgImg' => [], 'sms' => '', 'screenDisplay' => 1, 'winNum' => [], 'winType' => []];
|
||||
@@ -182,18 +181,12 @@ class Activity extends BaseController
|
||||
$tag = $jsondata['visitTag'][$k2] ? $jsondata['visitTag'][$k2] : '';
|
||||
$visitTag[] = ['id' => $k2, 'title' => $v2, 'tag' => $tag];
|
||||
}
|
||||
if ($blacklist) {
|
||||
$res_bl = $this->mdSyliveBlacklist->select(['activityId' => $activityId], 'blacklistId desc', 0, 0, 'blacklistId,mobile');
|
||||
foreach ($res_bl as $k2 => $v2) {
|
||||
$showBlacklist[] = ['id' => $v2['blacklistId'], 'mobile' => $v2['mobile'], 'type' => 'show'];
|
||||
}
|
||||
}
|
||||
$list[] = [
|
||||
'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'pay' => $pay, 'organizationId' => $organizationId,
|
||||
'activityStart' => $activityStart, 'shareTitle' => $shareTitle, 'dateRange' => $dateRange, 'coupon' => $coupon, 'drawCode' => $v['drawCode'],
|
||||
'bgImg' => $bgImg, 'channelImg' => $channelImg, 'banner' => $banner, 'sharePhoto' => $sharePhoto, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url,
|
||||
'mchId' => $v['mchId'], 'protocolTitle' => $v['protocolTitle'], 'protocol' => $v['protocol'], 'serviceLink' => $serviceLink,
|
||||
'bottoms' => $bottoms, 'draw' => $draw, 'visitTag' => $visitTag, 'blacklist' => $blacklist, 'showBlacklist' => $showBlacklist,
|
||||
'bottoms' => $bottoms, 'draw' => $draw, 'visitTag' => $visitTag, 'blacklist' => $blacklist,
|
||||
'signBespeak' => $signBespeak, 'barrage' => $barrage, 'button' => $button,
|
||||
's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'groups' => $groups, 'createTime' => $v['createTime']];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
require_once APPPATH . 'controllers/api/BaseController.php';
|
||||
|
||||
/**
|
||||
* Notes:私域直播_黑名单管理
|
||||
* Created on: 2022/10/21 17:15
|
||||
* Created by: dengbw
|
||||
*/
|
||||
class Blacklist extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('market/Market_sylive_blacklist_model', 'mdSyliveBlacklist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:黑名单管理列表
|
||||
* Created on: 2022/9/20 14:48
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function page_get()
|
||||
{
|
||||
$activityId = intval($this->input_param('activityId'));
|
||||
$mobile = $this->input_param('mobile');
|
||||
$page = $this->input_param('page');
|
||||
$limit = $this->input_param('limit');
|
||||
$sort = $this->input_param('sort');
|
||||
$order = $this->input_param('order');
|
||||
!$page && $page = 1;
|
||||
!$limit && $limit = 10;
|
||||
$sort_order = 'blacklistId desc';
|
||||
if ($sort && $order) {
|
||||
$sort_order = $sort . ' ' . $order;
|
||||
}
|
||||
$where['blacklistId>'] = 0;
|
||||
$mobile && $where['mobile LIKE "%' . trim($mobile) . '%"'] = null;
|
||||
$activityId && $where['activityId'] = $activityId;
|
||||
$count = $this->mdSyliveBlacklist->count($where);
|
||||
$list = [];
|
||||
if ($count) {
|
||||
$res = $this->mdSyliveBlacklist->select($where, $sort_order, $page, $limit);
|
||||
foreach ($res as $v) {
|
||||
$list[] = ['blacklistId' => $v['blacklistId'], 'activityId' => $v['activityId'],
|
||||
'mobile' => $v['mobile'], 'createTime' => $v['createTime']];
|
||||
}
|
||||
}
|
||||
$date = ['list' => $list, 'count' => $count];
|
||||
$this->return_response_list($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:添加黑名单
|
||||
* Created on: 2022/10/21 16:46
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function index_post()
|
||||
{
|
||||
$activityId = intval($this->input_param('activityId'));
|
||||
$mobile = $this->input_param('mobile');
|
||||
if (!$activityId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
if (!$mobile) {
|
||||
$this->return_json('请输入手机号');
|
||||
}
|
||||
$re = $this->mdSyliveBlacklist->get(['activityId' => $activityId,'mobile' => $mobile]);
|
||||
if ($re) {
|
||||
$this->return_json('手机号已在黑名单中');
|
||||
}
|
||||
$addDate = ['activityId' => $activityId, 'mobile' => $mobile, 'createTime' => date('Y-m-d H:i:s')];
|
||||
$id = $this->mdSyliveBlacklist->add($addDate);
|
||||
if (!$id) {
|
||||
$this->return_json('添加黑名单失败');
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:修改黑名单
|
||||
* Created on: 2022/10/21 14:48
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function index_put()
|
||||
{
|
||||
$blacklistId = intval($this->input_param('blacklistId'));
|
||||
$mobile = $this->input_param('mobile');
|
||||
if (!$blacklistId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
if (!$mobile) {
|
||||
$this->return_json('请输入黑名单标题');
|
||||
}
|
||||
$upDate = ['mobile' => $mobile];
|
||||
$this->mdSyliveBlacklist->update($upDate, ['blacklistId' => $blacklistId]);
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:批量删除黑名单
|
||||
* Created on: 2022/10/21 17:11
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function batch_delete()
|
||||
{
|
||||
$ids = $this->input_param('ids');
|
||||
if (!$ids) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$str_ids = implode(',', $ids);
|
||||
if ($str_ids) {
|
||||
$this->mdSyliveBlacklist->delete(["blacklistId in($str_ids)" => null]);
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:导入黑名单
|
||||
* Created on: 2023/3/06 17:24
|
||||
* Created by: dengbw
|
||||
* @throws PHPExcel_Exception
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function import_post()
|
||||
{
|
||||
require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php';
|
||||
$res = $this->upload();
|
||||
if (!$res['code']) {
|
||||
return $this->return_json($res['message']);
|
||||
}
|
||||
$file = $res['path'];
|
||||
if ($res['file_ext'] == '.xls') {
|
||||
$reader = \PHPExcel_IOFactory::createReader('Excel5'); // 读取 excel 文档
|
||||
} elseif ($res['file_ext'] == '.xlsx') {
|
||||
$reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档
|
||||
} else {
|
||||
return $this->return_json('文件无法识别');
|
||||
}
|
||||
$PHPExcel = $reader->load($file); // 文档名称
|
||||
$objWorksheet = $PHPExcel->getActiveSheet();
|
||||
$rowCnt = $objWorksheet->getHighestRow(); //获取总行数
|
||||
if ($rowCnt > 800) {
|
||||
@unlink($file);
|
||||
$this->return_json('数据大于800请拆分多个表格导入');
|
||||
}
|
||||
$activityId = $_POST['activityId'];
|
||||
$addDate = [];
|
||||
for ($_row = 2; $_row <= $rowCnt; $_row++) { //读取内容
|
||||
$mobile = $objWorksheet->getCell('A' . $_row)->getValue();
|
||||
if ($mobile) {
|
||||
$re = $this->mdSyliveBlacklist->get(['activityId' => $activityId, 'mobile' => $mobile]);
|
||||
if (!$re) {
|
||||
$addDate[] = ['mobile' => $mobile, 'activityId' => $activityId, 'createTime' => date('Y-m-d H:i:s')];
|
||||
}
|
||||
}
|
||||
}
|
||||
$count = count($addDate);
|
||||
if ($count) {
|
||||
$this->mdSyliveBlacklist->add_batch($addDate);
|
||||
}
|
||||
@unlink($file);
|
||||
$this->return_response('', "成功新增{$count}个黑名单");
|
||||
}
|
||||
|
||||
private function upload()
|
||||
{
|
||||
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/';
|
||||
$config['allowed_types'] = '*';
|
||||
$config['max_size'] = 5120;
|
||||
$config['file_name'] = 'blacklist_' . time() . rand(1, 99999);
|
||||
$this->load->library('upload', $config);
|
||||
if (!$this->upload->do_upload('file')) {
|
||||
return ['code' => SYS_CODE_FAIL, 'message' => $this->upload->display_errors('', '')];
|
||||
} else {
|
||||
$data = $this->upload->data();
|
||||
return ['code' => SYS_CODE_SUCCESS, 'path' => $data['full_path'], 'file_ext' => $data['file_ext']];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user