修改后台云信号码分配

This commit is contained in:
lcc
2024-09-04 11:08:28 +08:00
parent 5ff0378cb6
commit a252069f54
9 changed files with 446 additions and 11 deletions
+9 -6
View File
@@ -833,6 +833,7 @@ class Common extends CI_Controller
public function bind_mobile()
{
$this->load->model('sys/sys_admin_model');
$this->load->model('sys/sys_yx_mobiles_model');
$params = $this->input->get();
$id = intval($params['id']);
$type = $params['type'];
@@ -851,12 +852,14 @@ class Common extends CI_Controller
return $this->show_json(SYS_CODE_FAIL, '手机不存在!');
}
$mobile = $re['mobile'];
$cache = &load_cache('redis');
$xz_admin_phone = $cache->get('xz_admin_phone');
$middleNumber = '';
if ($xz_admin_phone) {
$middleNumber = $xz_admin_phone['admins'][$this->uid];
}
// $cache = &load_cache('redis');
// $xz_admin_phone = $cache->get('xz_admin_phone');
// $middleNumber = '';
// if ($xz_admin_phone) {
// $middleNumber = $xz_admin_phone['admins'][$this->uid];
// }
$yxMobiles = $this->sys_yx_mobiles_model->get(['admin_id' => $this->uid, 'status' => 1]);
$middleNumber = $yxMobiles['mobile'] ?: '';
if (!$middleNumber) {
return $this->show_json(SYS_CODE_FAIL, '还未分配号码不可使用');
}
+5 -4
View File
@@ -216,10 +216,11 @@ class Login extends CI_Controller
//退出
public function logout()
{
$domain = explode('.', $_SERVER['HTTP_HOST']);
array_shift($domain);
$domain = implode('.', $domain);
// $domain = explode('.', $_SERVER['HTTP_HOST']);
// array_shift($domain);
// $domain = implode('.', $domain);
$http_host = explode(':', $_SERVER['HTTP_HOST']);
$domain = $http_host[0];
$this->input->set_cookie(LOGIN_COOKIE, '', 0, $domain);
return $this->show_json(SYS_CODE_SUCCESS, '注销成功', '/login');
+4 -1
View File
@@ -647,13 +647,16 @@ class Customer extends HD_Controller
foreach ($rows_log as $key => $value) {
$rec_text = $rec_url = '';
if ($value['type'] == 2) {
$record = '';
if ($value['sub_type'] == Receiver_customer_oplogs_model::SUB_TYPE_XZ) {
$rec_row = $this->receiver_xz_model->get(['id' => $value['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
} else {
$rec_row = $this->receiver_yx_model->get(['id' => $value['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = get_yx_video($rec_row['rec_url']);
}
if ($rec_row['duration']) {
$rec_row['rec_url'] && $rec_url = $rec_row['rec_url'];
$record && $rec_url = $record;
!$rec_row['rec_url'] && $rec_text = '录音暂未生成';
} else {
$rec_text = '未接通';
+178
View File
@@ -0,0 +1,178 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Mobile extends HD_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('sys/sys_yx_mobiles_model');
$this->load->model('area_model');
$this->load->model('sys/sys_admin_model');
}
public function index()
{
return $this->lists();
}
public function lists($where = array(), $order = 'id desc', $page = 0, $size = 10)
{
$page = $this->input->post_get('page') ? $this->input->get('page') : 1;
$params = $this->input->get();
$where['status>='] = 0;
if ($params['mobile']) {
$where["mobile like '%{$params['mobile']}%'"] = null;
}
$count = $this->sys_yx_mobiles_model->count($where);
$lists = [];
if ($count) {
$rows = $this->sys_yx_mobiles_model->select($where, $order, $page, $size);
foreach ($rows as $row) {
$tmp = $row;
$city = $this->area_model->get(['city_id' => $row['city_id']]);
$tmp['province_name'] = $city['province_name'];
$tmp['city_name'] = $city['city_name'];
$admin = '';
if ($row['admin_id']) {
$admin = $this->sys_admin_model->get(['id' => $row['admin_id']]);
}
$tmp['admin_name'] = $admin ? $admin['username'] : '未绑定';
$lists[] = $tmp;
}
}
$this->data['pager'] = array('count' => '', 'curr' => $page, 'totle' => $count, 'total' => $count);
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['_title'] = '云信虚拟号管理';
$this->show_view('sys/yx/lists', true);
}
public function get()
{
$id = $this->input->get('id');
$row = [];
$url = 'add';
if ($id) {
$row = $this->sys_yx_mobiles_model->get(['id' => $id]);
$url = 'edit';
}
$this->data['url'] = $url;
$this->data['row'] = $row;
$this->show_view('sys/yx/edit');
}
public function add()
{
$input = $this->input->post();
if (!$input['mobile'] || !mobile_valid($input['mobile'])) {
return $this->show_json(SYS_CODE_FAIL, '请输入正确手机号');
}
if (!$input['city_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
$add = [
'mobile' => $input['mobile'],
'province_id' => $input['province_id'],
'city_id' => $input['city_id'],
'c_time' => time(),
];
$re = $this->sys_yx_mobiles_model->add($add);
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
}
public function edit()
{
$input = $this->input->post();
$row = $this->sys_yx_mobiles_model->get(['id' => $input['id']]);
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
if (!$input['mobile'] || !mobile_valid($input['mobile'])) {
return $this->show_json(SYS_CODE_FAIL, '请输入正确手机号');
}
if (!$input['city_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
$data = [
'mobile' => $input['mobile'],
'province_id' => $input['province_id'],
'city_id' => $input['city_id'],
];
$re = $this->sys_yx_mobiles_model->update($data, ['id' => $row['id']]);
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '保存失败');
}
}
public function batch()
{
}
public function export()
{
}
public function del()
{
}
/**
* 修改状态
* @return bool
*/
public function edit_status()
{
$id = $this->input->post('id');
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '提交失败');
}
$status = $this->input->post('status');
$update['status'] = $status;
$re = $this->sys_yx_mobiles_model->update($update, array('id' => $id));
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '操作失败');
}
}
public function edit_admin()
{
$id = $this->input->post_get('id');
$row = $this->sys_yx_mobiles_model->get(['id' => $id]);
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
if ($this->input->method() == 'post') {
$admin_id = (int)$this->input->post('admin_id');
$re = $this->sys_yx_mobiles_model->update(['admin_id' => $admin_id], array('id' => $id));
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '操作失败');
}
} else {
$where = [
'status' => 1,
"id not in (select admin_id from lc_sys_yx_mobiles where status>=0 and admin_id>0 and admin_id!={$row['admin_id']})" => null
];
$adminLists = $this->sys_admin_model->select($where, 'id desc', 0, 0, 'id,username,mobile');
$this->data['adminLists'] = $adminLists;
$this->data['row'] = $row;
$this->show_view('sys/yx/edit_admin');
}
}
}
+113
View File
@@ -0,0 +1,113 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/yx/mobile/<?= $url ?>" data-auto="true"
method="post" style="width: 90%;padding-top: 10px" onsubmit="return false">
<input type="hidden" v-model="row.id" name="id"/>
<div class="am-form-group">
<label class="am-para-label">手机号:</label>
<div class="am-para-input">
<input type="text" placeholder="输入手机号" v-model="row.mobile" name="mobile"/>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">城市:</label>
<div class="am-form-group am-para-inline w150">
<select name="province_id" v-model="province_id">
<option value="0">省份</option>
<option :value="v.id" v-for="(v,i) in provinceAry">{{v.name}}</option>
</select>
</div>
<div class="am-form-group am-para-inline w150">
<select name="city_id" v-model="city_id">
<option value="0">城市</option>
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<button class="am-btn ml20 am-btn-sm am-btn-success w100" style="margin-left: 3.5rem" type="submit">保存
</button>
</div>
</form>
<script>
vue_obj = new Vue({
el: '#vue-edit',
data: {
row: <?=$row ? json_encode($row, JSON_UNESCAPED_UNICODE) : '[]'?>,
province_id: <?=$row['province_id'] ? $row['province_id'] : 0?>,
city_id: <?=$row['city_id'] ? $row['city_id'] : 0?>,
provinceAry: [],
cityAry: []
},
mounted: function () {
this.init_provinces();
this.init_citys();
},
methods: {
init_provinces: function () {
var vm = this;
$.get('common/area', {}, function (response) {
if (response.code == 1) {
vm.provinceAry = response.data;
}
});
},
init_citys: function () {
var vm = this;
$.get('common/area', {id: vm.province_id, key: 'city', type: 1}, function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
});
}
},
watch: {
'province_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.cityAry = [];
that.city_id = '0';
} else {
$.get('common/area', {id: nv, key: 'city', type: 1}, function (response) {
if (response.code == 1) {
that.cityAry = response.data;
if (that.city_id > 0) {
var city_id = '0';
for (var i in that.cityAry) {
var city = that.cityAry[i];
if (city.id == that.city_id) {
city_id = city.id;
break;
}
}
that.city_id = city_id;
}
}
});
}
},
'city_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.countyAry = [];
that.county_id = '0';
} else {
$.get('common/area', {id: nv, key: 'county', type: 1}, function (response) {
if (response.code == 1) {
that.countyAry = response.data;
if (that.county_id > 0) {
var county_id = '0';
for (var i in that.countyAry) {
var county = that.countyAry[i];
if (county.id == that.county_id) {
county_id = county.id;
break;
}
}
that.county_id = county_id;
}
}
});
}
}
}
});
</script>
+31
View File
@@ -0,0 +1,31 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/yx/mobile/edit_admin" data-auto="true"
method="post" style="width: 90%;padding-top: 10px" onsubmit="return false">
<input type="hidden" v-model="row.id" name="id"/>
<div class="am-form-group">
<label class="am-para-label">管理员:</label>
<div class="am-form-group am-para-inline w300">
<select name="admin_id" v-model="row.admin_id">
<option value="0">选择管理员</option>
<option :value="v.id" v-for="(v,i) in adminLists">{{v.username}}({{v.mobile}})</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<button class="am-btn ml20 am-btn-sm am-btn-success w100" style="margin-left: 3.5rem" type="submit">保存
</button>
</div>
</form>
<script>
vue_obj = new Vue({
el: '#vue-edit',
data: {
row: <?=$row ? json_encode($row, JSON_UNESCAPED_UNICODE) : '[]'?>,
adminLists: <?=$adminLists ? json_encode($adminLists, JSON_UNESCAPED_UNICODE) : '[]'?>
},
mounted: function () {
},
methods: {},
watch: {}
});
</script>
+92
View File
@@ -0,0 +1,92 @@
<div class="coms-table-wrap">
<!-- no-border 去掉头部就有边控了-->
<div class="coms-table-hd clearfix no-border">
<form action="/sys/yx/mobile/lists" class="form-search" onsubmit="return false">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label">手机号</label>
<div class="am-para-inline w200">
<input type="text" value="<?= $mobile ?>" name="mobile"/>
</div>
</div>
<div class="am-form-group fl">
<button type="submit" class="am-btn ml20 am-btn-sm am-btn-success w100">搜索</button>
</div>
<div class="am-form-group fl">
<button type="button" data-modal="/sys/yx/mobile/get" data-title="新增"
class="add am-btn ml20 am-btn-sm am-btn-success w100">新增
</button>
</div>
<div class="am-form-group fr" style="font-size: 15px;padding-right: 20px;padding-top: 6px;">
共有<?= $pager['total'] ?>条数据
</div>
</div>
</form>
</div>
<div class="coms-table-bd">
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="8%"><span>ID</span></th>
<th width="20%"><span>手机号</span></th>
<th width="20%"><span>城市</span></th>
<th width="20%"><span>绑定管理员</span></th>
<th width="8%"><span>状态</span></th>
<th><span>操作</span></th>
</tr>
</thead>
<tbody>
<tr v-for="value in lists">
<!-- <td><input type="checkbox" /></td> -->
<td>{{value.id}}</td>
<td>{{value.mobile}}</td>
<td>{{value.province_name}}-{{value.city_name}}</td>
<td>{{value.admin_name}}</td>
<td>{{ value.status==1 ? '正常': '禁用'}}</td>
<td>
<a v-if="value.status == 1" @click="editStatus(value.id,0)"
class="am-btn am-btn-danger am-btn-xs">禁用</a>
<a v-else @click="editStatus(value.id,1)" class="am-btn am-btn-danger am-btn-xs">启用</a>
<a :data-modal="'/sys/yx/mobile/get?id='+value.id"
class="am-btn am-btn-primary am-btn-xs">修改</a>
<a :data-modal="'/sys/yx/mobile/edit_admin?id='+value.id"
class="am-btn am-btn-primary am-btn-xs">{{value.admin_id>0 ? '修改绑定管理员' :'绑定管理员'}}</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="coms-table-ft clearfix">
<div class="coms-pagination fr mr20">
<?php call_user_func_array('page_view', $this->data['pager']); ?>
</div>
</div>
<script type="text/javascript">
var modal = $('#add-new');
$('.add').on('click', function (e) {
var $target = $(e.target);
modal.modal();
});
var vm = new Vue({
el: '.coms-table-bd',
data: {
lists: JSON.parse('<?=json_encode($this->data['lists'])?>'),
},
methods: {
editStatus: function (index, status) {
$.post('sys/yx/mobile/edit_status', {id: index, status: status}, function (data) {
setTimeout(function () {
if (data.code == '1') {
layer.alert(data.msg, {icon: 1});
window.onhashchange.call();
} else {
layer.alert(data.msg, {icon: 2});
}
}, 500)
})
}
}
})
</script>
+1
View File
@@ -48,6 +48,7 @@ class Yxcall extends HD_Controller
'uname' => $admin['username'] ? $admin['username'] : '',
'type' => 2,//类型 0 普通 1短信 2电话
'log' => $row['id'],
'cf_platform' => 'admin',
'c_time' => time()
);
if ($row['cf_title'] == 'clues') {//线索拨打电话回调
@@ -0,0 +1,13 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Sys_yx_mobiles_model extends HD_Model
{
private $table_name = 'lc_sys_yx_mobiles';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}