Commit 51b98422 by 朱继来

Merge branch 'zjl_assign_20190812' into development

parents f586269c f2eb9d1f
......@@ -10,6 +10,8 @@ use App\Model\Pcb\PcbOrderModel;
use App\Model\Pcb\PcbPublicModel;
use App\Model\Pcb\PcbPurchaseModel;
use App\Model\Pcb\PcbServerModel;
use App\Model\KefuModel;
use App\Model\CmsModel;
class ApiController extends Controller
{
......@@ -89,4 +91,40 @@ class ApiController extends Controller
private function ApiSetOrderProduct($request){
echo (new PcbServerModel())->setOrdserProduct($request->user->userId,$request->input("purchase_id"));
}
// 获取客服池
public function ApiKefuList($request)
{
$KefuModel = new KefuModel;
$this->ExportLayui($KefuModel->lists($request));
}
// 新增客服
public function ApiAddKefu($request)
{
$KefuModel = new KefuModel;
$this->Export($KefuModel->add($request));
}
// 编辑客服
public function ApiEditKefu($request)
{
$KefuModel = new KefuModel;
$this->Export($KefuModel->edit($request));
}
// 删除客服
public function ApiDelKefu($request)
{
$KefuModel = new KefuModel;
$this->Export($KefuModel->del($request));
}
// 删除客服
public function ApiTopKefu($request)
{
$KefuModel = new KefuModel;
$this->Export($KefuModel->top($request));
}
}
......@@ -43,12 +43,15 @@ class WebController extends Controller
$menus = $perm->getPermMenu($menus, $request->user->userId);
}
$userPerms = $perm->getUserAllPerms($request->user->userId, $role); // 用户权限
$data = [
'header' => $request->user->header,
'uri' => $uri,
'username' => $username,
'useremail' => $useremail,
'menus' => $menus,
'userPerms' => $userPerms,
];
return $data;
......@@ -57,7 +60,7 @@ class WebController extends Controller
public function info(Request $request,$id=''){
$data=$this->getPageInfo($request);
$data['id']=$id;
return $this->$id($request, $data,$id );
return $this->$id($request, $data, $id);
}
private function PaymentDaysList($request,$data,$id){
......@@ -270,4 +273,11 @@ class WebController extends Controller
return view("Pcb",$data);
}
// 订单客服池
public function kefu($request, $data, $id)
{
$data['title'] = '客服池';
return view('web', $data);
}
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class KefuModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_kefu';
protected $primaryKey = 'id';
protected $guarded = ['id'];
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
/** * @param \DateTime|int $value * @return false|int * @author dividez */
public function fromDateTime($value)
{
return strtotime(parent::fromDateTime($value));
}
// 获取客服
public function lists($request, $export='')
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$field = ['id', 'sale_id', 'sale_name', 'email', 'status', 'operator_id', 'operator_name', 'create_time', 'update_time'];
$map['sale_name'] = $request->input('sale_name', ''); // 客服名称
$map['email'] = $request->input('email', ''); // 邮箱
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$list = $this->where(function($query) use ($map) {
// 客服名称
if ($map['sale_name']) {
$query->where('sale_name', 'like', $map['sale_name'].'%');
}
})->where(function($query) use ($map) {
// 邮箱
if ($map['email']) {
$query->where('email', '=', $map['email']);
}
})->where(function($query) use ($map) {
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
}
else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
}
else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
}
})
->select($field)
->orderBy('status', 'desc');
if ($export) {
$list = $list->get()->toArray();
if (empty($list)) {
echo '<script>alert("导出数据为空");history.go(-1);</script>';die;
}
return $list;
} else {
$list = $list->paginate($limit, ['*'], 'page', $page)->toArray();
return [0, '获取成功', $list['data'], $list['total']];
}
}
// 新增客服
public function add($request)
{
$email = $request->input('email');
$CmsModel = new CmsModel;
$sales = $CmsModel->where('email', $email)->select('userId', 'name', 'status')->first();
if (!$sales) return [1, '客服邮箱不存在'];
if ($sales->status == 4) return [1, '客服已离职'];
$exists = $this->where('email', $email)->first();
if ($exists) return [1, '客服已存在'];
$data['sale_id'] = $sales->userId;
$data['sale_name'] = $sales->name;
$data['email'] = $email;
$data['operator_id'] = $request->user->userId;
$data['operator_name'] = $request->user->name;
$count = $this->count(); // 客服池数量
if (!$count) $data['status'] = 1; // 待分配
$res = $this->create($data);
if ($res === false) return [1, '新增客服失败'];
return [0, '新增客服成功'];
}
// 编辑客服
public function edit($request)
{
$id = $request->input('id');
$email = $request->input('email');
$res = $this->where('id', $id)->update(['email'=>$email]);
if ($res === false) return [1, '更新客服失败'];
return [0, '更新客服成功'];
}
// 删除客服
public function del($request)
{
$id = $request->input('id');
$status = $request->input('status');
$res = $this->where('id', $id)->delete();
if ($res === false) return [1, '删除客服失败'];
if ($status == 1) {
$first = $this->select('id')->orderBy('id', 'asc')->first();
$res = $this->where('id', $first['id'])->update(['status'=>1]);
if ($res === false) return [1, '更新第一条客服状态失败'];
}
return [0, '删除客服成功'];
}
// 置顶客服
public function top($request)
{
$id = $request->input('id');
try {
DB::connection('order')->beginTransaction(); // 开启事务
DB::connection('order')->update('UPDATE lie_kefu SET status = 0');
$this->where('id', $id)->update(['status'=>1]);
DB::connection('order')->commit();
return [0, '置顶客服成功'];
} catch(Exception $e) {
DB::connection('order')->rollback();
return [1, '置顶客服失败,'.$e->getMessage()];
}
}
}
\ No newline at end of file
/**
* Created by ICHUNT on 2019-06-03.
*/
$(document).on('mouseenter','.preview',function(){
var url=$(this).data('url');
if(!url || url == 'undefined') return false;
return top.layer.tips('<img src="'+url+'" width="150px">',$(this),{tips:[3,"#fff"],time:0,shade:0});
});
$(document).on('mouseleave','.preview',function(){
return top.layer.close(layer.index);
});
/**
* 和PHP一样的时间戳格式化函数
* @param {string} format 格式
* @param {int} timestamp 要格式化的时间 默认为当前时间
* @return {string} 格式化的时间字符串
*/
function date(format, timestamp){
if(!timestamp) return '';
var a, jsdate=((timestamp) ? new Date(timestamp*1000) : new Date());
var pad = function(n, c){
if((n = n + "").length < c){
return new Array(++c - n.length).join("0") + n;
} else {
return n;
}
};
var txt_weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var txt_ordin = {1:"st", 2:"nd", 3:"rd", 21:"st", 22:"nd", 23:"rd", 31:"st"};
var txt_months = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var f = {
// Day
d: function(){return pad(f.j(), 2)},
D: function(){return f.l().substr(0,3)},
j: function(){return jsdate.getDate()},
l: function(){return txt_weekdays[f.w()]},
N: function(){return f.w() + 1},
S: function(){return txt_ordin[f.j()] ? txt_ordin[f.j()] : 'th'},
w: function(){return jsdate.getDay()},
z: function(){return (jsdate - new Date(jsdate.getFullYear() + "/1/1")) / 864e5 >> 0},
// Week
W: function(){
var a = f.z(), b = 364 + f.L() - a;
var nd2, nd = (new Date(jsdate.getFullYear() + "/1/1").getDay() || 7) - 1;
if(b <= 2 && ((jsdate.getDay() || 7) - 1) <= 2 - b){
return 1;
} else{
if(a <= 2 && nd >= 4 && a >= (6 - nd)){
nd2 = new Date(jsdate.getFullYear() - 1 + "/12/31");
return date("W", Math.round(nd2.getTime()/1000));
} else{
return (1 + (nd <= 3 ? ((a + nd) / 7) : (a - (7 - nd)) / 7) >> 0);
}
}
},
// Month
F: function(){return txt_months[f.n()]},
m: function(){return pad(f.n(), 2)},
M: function(){return f.F().substr(0,3)},
n: function(){return jsdate.getMonth() + 1},
t: function(){
var n;
if( (n = jsdate.getMonth() + 1) == 2 ){
return 28 + f.L();
} else{
if( n & 1 && n < 8 || !(n & 1) && n > 7 ){
return 31;
} else{
return 30;
}
}
},
// Year
L: function(){var y = f.Y();return (!(y & 3) && (y % 1e2 || !(y % 4e2))) ? 1 : 0},
//o not supported yet
Y: function(){return jsdate.getFullYear()},
y: function(){return (jsdate.getFullYear() + "").slice(2)},
// Time
a: function(){return jsdate.getHours() > 11 ? "pm" : "am"},
A: function(){return f.a().toUpperCase()},
B: function(){
// peter paul koch:
var off = (jsdate.getTimezoneOffset() + 60)*60;
var theSeconds = (jsdate.getHours() * 3600) + (jsdate.getMinutes() * 60) + jsdate.getSeconds() + off;
var beat = Math.floor(theSeconds/86.4);
if (beat > 1000) beat -= 1000;
if (beat < 0) beat += 1000;
if ((String(beat)).length == 1) beat = "00"+beat;
if ((String(beat)).length == 2) beat = "0"+beat;
return beat;
},
g: function(){return jsdate.getHours() % 12 || 12},
G: function(){return jsdate.getHours()},
h: function(){return pad(f.g(), 2)},
H: function(){return pad(jsdate.getHours(), 2)},
i: function(){return pad(jsdate.getMinutes(), 2)},
s: function(){return pad(jsdate.getSeconds(), 2)},
//u not supported yet
// Timezone
//e not supported yet
//I not supported yet
O: function(){
var t = pad(Math.abs(jsdate.getTimezoneOffset()/60*100), 4);
if (jsdate.getTimezoneOffset() > 0) t = "-" + t; else t = "+" + t;
return t;
},
P: function(){var O = f.O();return (O.substr(0, 3) + ":" + O.substr(3, 2))},
//T not supported yet
//Z not supported yet
// Full Date/Time
c: function(){return f.Y() + "-" + f.m() + "-" + f.d() + "T" + f.h() + ":" + f.i() + ":" + f.s() + f.P()},
//r not supported yet
U: function(){return Math.round(jsdate.getTime()/1000)}
};
return format.replace(/[\\]?([a-zA-Z])/g, function(t, s){
if( t!=s ){
// escaped
ret = s;
} else if( f[s] ){
// a date function exists
ret = f[s]();
} else{
// nothing special
ret = s;
}
return ret;
});
}
\ No newline at end of file
layui.use(['form', 'table', 'laydate'], function(){
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
laydate.render({
elem: '#begin_time' //指定元素
});
laydate.render({
elem: '#end_time' //指定元素
});
var renderTable = function () {
table.render({
id: 'list'
,elem: '#kefu'
,url: '/api/ApiKefuList' //数据接口
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,cols: [[ //表头
{title: '序号', type: 'numbers', fixed: 'left', width: 80}
,{field: 'sale_id', title: '客服ID', width: 200}
,{field: 'sale_name', title: '客服名称', width: 200}
,{field: 'email', title: '邮箱', width: 300}
,{field: 'operator_name', title: '操作人名称', width: 200}
,{field: 'status', title: '审核状态', templet: '#status', width: 200}
,{field: 'create_time', title: '创建时间', width: 200}
,{title: '操作', align:'center', fixed: 'right', toolbar: '#list_action', width: 218}
]]
,limit: 10
,limits: [10, 20, 50,]
});
};
renderTable();
form.on('submit(load)', function(data) {
//执行重载
table.reload('list', {
page: {
curr: 1
}
,where: data.field
});
return false;
});
$('.add').click(function() {
layer.open({
area: ['400px', '200px'],
title: '新增客服',
type: 1,
content: $('#kefu-action'),
btn: ['确认', '取消'],
yes: function(index) {
var email = $('.kefu-email').val();
if (!email) {
layer.tips('请输入邮箱', $('.kefu-email'));
return false;
}
$.ajax({
url : '/api/ApiAddKefu',
type: 'post',
data: {email: email},
dataType: 'json',
success: function(resp) {
if (resp.errcode == 0) {
layer.close(index);
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
return false;
}
layer.msg(resp.errmsg);
},
error: function(err) {
console.log(err)
}
})
layer.msg('新增客服中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
$('.kefu-email').val('');
})
// tool操作
table.on('tool(kefu)', function(obj){ //注:tool是工具条事件名,test是table原始容器的属性lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var url = '';
var title = '';
var content = '';
var datax = {};
datax.id = data.id;
if(layEvent === 'edit') {
url = '/api/ApiEditKefu';
title = '编辑客服';
content = $('#kefu-action');
} else if (layEvent === 'del') {
url = '/api/ApiDelKefu';
title = '删除客服';
content = '<div style="margin: 40px;">确定删除该客服吗?</div>';
datax.status = data.status;
} else if (layEvent === 'top') {
url = '/api/ApiTopKefu';
title = '置顶客服';
content = '<div style="margin: 40px;">确定置顶该客服吗?</div>';
}
layer.open({
area: ['400px', '200px'],
title: title,
type: 1,
content: content,
btn: ['确认', '取消'],
yes: function(index) {
if (layEvent == 'edit') {
var email = $('.kefu-email').val();
if (!email) {
layer.tips('请输入邮箱', $('.kefu-email'));
return false;
}
datax.email = email;
}
$.ajax({
url : url,
type: 'post',
data: datax,
dataType: 'json',
success: function(resp) {
if (resp.errcode == 0) {
layer.close(index);
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
return false;
}
layer.msg(resp.errmsg);
},
error: function(err) {
console.log(err)
}
})
layer.msg(title+'中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
if (layEvent == 'edit') {
$('.kefu-email').val(data.email);
}
});
});
\ No newline at end of file
<link href="/css/bootstrap.min.css" rel="stylesheet">
<link href="/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="/css/style.css" rel="stylesheet">
<style>
.well .form-group {
margin-right: 0px;
margin-left: 0px;
}
</style>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/inspinia.min.js"></script>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{config('website.webTitle')}} | {{$title}}</title>
<script>document.domain="{{ config('website.domain') }}";</script>
<link href="/js/layui/css/layui.css" rel="stylesheet">
<link href="/css/admin.css" rel="stylesheet">
@include('table.css')
<script src="/js/jquery-2.2.1.js"></script>
<style>
label{
box-sizing:content-box;
}
</style>
<script>
var k1='';
var k2='';
var UploadImgUrl='';
var exts='png|jpg|gif';
</script>
</head>
<body class="">
<div id="wrapper">
<!-- layouts.navigation -->
@include('layouts.navigation')
<div id="page-wrapper" class="gray-bg">
@include('layouts.header')
<div class="layui-col-md6 layui-col-space12" style="margin: 10px;width: 100%;height: 100%;padding-right: 20px">
<div class="layui-card">
<div class="layui-card-body" style="padding-top: 20px; padding-bottom: 30px;">
@include("web.$id")
</div>
</div>
</div>
</div>
</div>
@include('table.js')
<script src="/js/layui/layui.js"></script>
<script src="/js/web/common.js"></script>
@if(empty($into))
<script src="/js/web/{{$id}}.js?v={{time()}}"></script>
@endif
</body>
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">客服名称</label>
<div class="layui-input-inline">
<input type="text" name="sale_name" placeholder="客服名称" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">客服邮箱</label>
<div class="layui-input-inline">
<input type="text" name="email" placeholder="客服邮箱" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button lay-submit lay-filter="load" class="layui-btn" data-type="search">搜索</button>
@if (in_array('kefu_create', $userPerms))
<a class="layui-btn layui-btn-normal add">新增</a>
@endif
</div>
</div>
</form>
<table id="kefu" lay-filter="kefu"></table>
<style>
#kefu-action{ display: none; }
#kefu-action form{ margin-top: 40px; }
#kefu-action .layui-input-inline{ width: 240px; }
</style>
<div id="kefu-action">
<form class="layui-form">
<div class="layui-item">
<label class="layui-form-label">客服邮箱</label>
<div class="layui-input-inline">
<input type="text" name="kefu-email" placeholder="客服邮箱" autocomplete="off" class="layui-input kefu-email">
</div>
</div>
</div>
</div>
<script type="text/html" id="status">
@{{# if (d.status == 1) { }}
<div style="color:#DC143C;">待分配</div>
@{{# } else { }}
<div style="color:#ccc;">等待中</div>
@{{# } }}
</script>
<script type="text/html" id="list_action">
<?php if (in_array('kefu_edit', $userPerms)) { ?>
<a class="btn btn-xs btn-warning" lay-event="edit">编辑</a>
<?php } ?>
<?php if (in_array('kefu_delete', $userPerms)) { ?>
<a class="btn btn-xs btn-danger" lay-event="del">删除</a>
<?php } ?>
<?php if (in_array('kefu_top', $userPerms)) { ?>
@{{# if (d.status == 0) { }}
<a class="btn btn-xs btn-info" lay-event="top">置顶</a>
@{{# } }}
<?php } ?>
</script>
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">注册手机</label>
<div class="layui-input-inline">
<input type="text" name="mobile" placeholder="填写注册手机" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">认证状态</label>
<div class="layui-input-inline">
<select name="auth_status" lay-verify="" lay-search>
<option value=""></option>
@if (Config('params.auth_status'))
@foreach (Config('params.auth_status') as $k=>$v)
<option value="{{$k}}">{{$v}}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">账号状态</label>
<div class="layui-input-inline">
<select name="status" lay-verify="" lay-search>
<option value=""></option>
<option value="1">使用中</option>
<option value="2">已禁用</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">注册时间</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button lay-submit lay-filter="load" class="layui-btn" data-type="search">搜索</button>
<button type="button" class="layui-btn layui-btn-normal export">导出</button>
</div>
</div>
</form>
<table id="list" lay-filter="list"></table>
<script type="text/html" id="status">
@{{# if (d.status == 1) { }}
<div>使用中</div>
@{{# } else if (d.status == 2) { }}
<div style="color:#ccc;">已禁用</div>
@{{# } }}
</script>
<script type="text/html" id="list_action">
@{{# if (d.status == 1) { }}
<a class="btn btn-xs btn-danger" lay-event="forbidden">禁用</a>
@{{# } else if (d.status == 2) { }}
<a class="btn btn-xs btn-info" lay-event="restore">启用</a>
@{{# } }}
<a class="btn btn-xs btn-success" href="/web/editUser?user_id=@{{ d.user_id }}" target="_blank">编辑</a>
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment