This commit is contained in:
yaosen 2024-06-24 20:58:23 +08:00
parent af6be7dcfb
commit 4cb91b32d0
16 changed files with 340 additions and 93 deletions

View File

@ -101,7 +101,7 @@ export const asyncRoutes = [
title: '客服在线列表', title: '客服在线列表',
roles: ['admin'] roles: ['admin']
} }
}, }/*,
{ {
path: 'shortcut', path: 'shortcut',
component: () => import('@/views/shortcut/shortcutContent.vue'), component: () => import('@/views/shortcut/shortcutContent.vue'),
@ -110,7 +110,7 @@ export const asyncRoutes = [
title: '快捷内容设置', title: '快捷内容设置',
roles: ['admin'] roles: ['admin']
} }
}/*, },
{ {
path: 'teams', path: 'teams',
component: () => import('@/views/admin/teams'), component: () => import('@/views/admin/teams'),
@ -132,7 +132,7 @@ export const asyncRoutes = [
meta: { meta: {
title: '订单管理', title: '订单管理',
icon: 'money', icon: 'money',
roles: ['order_index','editor'] roles: ['order_index', 'editor']
}, },
children: [ children: [
{ {
@ -141,7 +141,7 @@ export const asyncRoutes = [
name: 'OrderList', name: 'OrderList',
meta: { meta: {
title: '订单列表', title: '订单列表',
roles: ['order_pub','editor'] roles: ['order_pub', 'editor']
} }
}, },
/* { /* {
@ -159,7 +159,7 @@ export const asyncRoutes = [
name: 'OrderBack', name: 'OrderBack',
meta: { meta: {
title: '流转订单', title: '流转订单',
roles: ['order_back','editor'] roles: ['order_back', 'editor']
} }
} }
] ]
@ -173,7 +173,7 @@ export const asyncRoutes = [
meta: { meta: {
title: '日志记录', title: '日志记录',
icon: 'nested', icon: 'nested',
roles: ['follow_index','log_index','editor'] roles: ['follow_index', 'log_index', 'editor']
}, },
children: [ children: [
{ {
@ -182,7 +182,7 @@ export const asyncRoutes = [
name: 'Follow', name: 'Follow',
meta: { meta: {
title: '跟进记录', title: '跟进记录',
roles: ['follow_index','editor'] roles: ['follow_index', 'editor']
} }
}, },
{ {
@ -218,7 +218,7 @@ export const asyncRoutes = [
roles: ['data_index'] roles: ['data_index']
} }
}, },
{ /* {
path: 'online', path: 'online',
component: () => import('@/views/data/online'), component: () => import('@/views/data/online'),
name: 'Index', name: 'Index',
@ -235,7 +235,7 @@ export const asyncRoutes = [
title: '主播概况', title: '主播概况',
roles: ['data_anchor'] roles: ['data_anchor']
} }
}, },*/
{ {
path: 'sale', path: 'sale',
component: () => import('@/views/data/sale'), component: () => import('@/views/data/sale'),

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%"> <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
<el-table-column align="center" label="ID" width="80" prop="id" /> <el-table-column align="center" label="ID" width="60" prop="id" />
<el-table-column align="center" label="姓名" width="380" prop="name" /> <el-table-column align="center" label="姓名" width="80" prop="name" />
<el-table-column align="center" label="状态" width="100"> <el-table-column align="center" label="状态" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.isOnline === 0" type="border-card">下线</el-tag> <el-tag v-if="scope.row.isOnline === 0" type="border-card">下线</el-tag>
@ -10,25 +10,35 @@
<el-tag v-if="scope.row.isOnline === 2" type="info">没上线</el-tag> <el-tag v-if="scope.row.isOnline === 2" type="info">没上线</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="是否分单" width="100"> <!-- <el-table-column align="center" label="是否分单" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.isEndWork === 0" type="border-card"></el-tag> <el-tag v-if="scope.row.isEndWork === 0" type="border-card"></el-tag>
<el-tag v-if="scope.row.isEndWork === 1" type="success"></el-tag> <el-tag v-if="scope.row.isEndWork === 1" type="success"></el-tag>
</template> </template>
</el-table-column>-->
<el-table-column align="center" label="是否分单" width="100">
<template #default="scope">
<el-switch v-model="scope.row.isEndWork" :active-value="1" :inactive-value="0" @change="updateStatus(scope.row)" />
</template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="在线时长" width="380"> <el-table-column align="center" label="剩余限制订单数量" width="190">
<template #default="scope">
<el-input-number v-model="scope.row.order_num" :max="9999999" :min="0" class="small-input-number" style="width: 160px; height: 36px;" @change="updateStatus(scope.row)" />
</template>
</el-table-column>
<el-table-column align="center" label="在线时长" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
{{ Math.floor((scope.row.data ? scope.row.data.onlineTime : scope.row.onlineTime) / 3600) || '--' }} 分钟 {{ Math.floor((scope.row.data ? scope.row.data.onlineTime : scope.row.onlineTime) / 3600) || '--' }} 分钟
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="138px" align="center" label="上班时间"> <el-table-column width="138px" align="center" label="上班时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.last_follow | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> <span>{{ scope.row.start_work_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="138px" align="center" label="下班时间"> <el-table-column width="138px" align="center" label="下班时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.last_follow | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> <span>{{ scope.row.end_work_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -69,11 +79,16 @@ export default {
this.listLoading = true // /admin/admin/getOnlineList /admin/shortcutContent/list this.listLoading = true // /admin/admin/getOnlineList /admin/shortcutContent/list
this.$axios.get('/admin/admin/getOnlineList', { params: this.listQuery }).then(response => { this.$axios.get('/admin/admin/getOnlineList', { params: this.listQuery }).then(response => {
this.list = response.data this.list = response.data
console.log('====list==' + this.list)
this.listLoading = false this.listLoading = false
}).catch(() => { }).catch(() => {
this.listLoading = false this.listLoading = false
}) })
},
updateStatus(item) {
this.$axios.post('/admin/admin/editInfo', { id: item.id, order_num: item.order_num, is_order: item.isEndWork }).then(() => {
this.getOnlineList()
}).catch(() => {
})
} }
} }
} }

View File

@ -30,12 +30,16 @@
<el-button v-if="scope.row.self ==0 && scope.row.status == 0" type="success" size="small" icon="el-icon-close" @click="onRefuse(scope.row)"> <el-button v-if="scope.row.self ==0 && scope.row.status == 0" type="success" size="small" icon="el-icon-close" @click="onRefuse(scope.row)">
拒绝 拒绝
</el-button> </el-button>
<el-button v-if="scope.row.self ==3 && scope.row.status == 0" type="success" size="small" icon="el-icon-close" @click="onCancel(scope.row)">
取消
</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="转出" width="80" prop="outto.username" /> <el-table-column align="center" label="转出" width="80" prop="outto.username" />
<el-table-column align="center" label="转入" width="80" prop="into.username" /> <el-table-column align="center" label="转入" width="80" prop="into.username" />
<el-table-column align="center" label="申请者" width="80" prop="apply.username" />
<el-table-column align="center" label="订单号" width="220" prop="orders.sn" /> <el-table-column align="center" label="订单号" width="220" prop="orders.sn" />
<el-table-column align="center" label="产品" prop="orders.product_name" /> <el-table-column align="center" label="产品" prop="orders.product_name" />
@ -158,6 +162,15 @@ export default {
this.getList() this.getList()
}).catch(err => { }).catch(err => {
})
},
onCancel(item) {
this.$axios.post('/admin/order/backcancel', { id: item.id }).then(res => {
this.dialogVisible = false
this.item = {}
this.getList()
}).catch(err => {
}) })
} }
} }

View File

@ -74,9 +74,9 @@
<el-table-column align="center" fixed width="200" label="操作"> <el-table-column align="center" fixed width="200" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-button type="success" size="small" icon="el-icon-refresh" @click="onCirculation(scope.row)"> <el-button type="success" size="small" icon="el-icon-refresh" @click="onCirculation(scope.row)">
流转出 流转出
</el-button>--> </el-button>
<el-button :type="types[scope.row.order_status]" size="small" icon="el-icon-edit" @click="onInfo(scope.row)"> <el-button :type="types[scope.row.order_status]" size="small" icon="el-icon-edit" @click="onInfo(scope.row)">
跟进 跟进
</el-button> </el-button>
@ -248,7 +248,7 @@
<el-radio v-if="k > 0" v-model="item.status" :label="k" border>{{ v }}</el-radio> <el-radio v-if="k > 0" v-model="item.status" :label="k" border>{{ v }}</el-radio>
</template> </template>
</el-form-item> </el-form-item>
<!-- <el-form-item label="快捷跟进" style="width: 600px;"> <!-- <el-form-item label="快捷跟进" style="width: 600px;">
<el-select v-model="value" placeholder="请选择" @change="onChange"> <el-select v-model="value" placeholder="请选择" @change="onChange">
<el-form-item style="display: inline-flex;text-align: left;width: 770px;"> <el-form-item style="display: inline-flex;text-align: left;width: 770px;">
<el-option <el-option
@ -357,7 +357,6 @@
<el-dialog title="申请转出订单" :visible.sync="dialog3Visible"> <el-dialog title="申请转出订单" :visible.sync="dialog3Visible">
<el-form label-width="160px" :model="item3"> <el-form label-width="160px" :model="item3">
<el-input v-model="item3.os" disabled />
<el-form-item label="标题:"> <el-form-item label="标题:">
<el-input v-model="item3.product_name" disabled /> <el-input v-model="item3.product_name" disabled />
</el-form-item> </el-form-item>
@ -379,7 +378,7 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="onCirculationSave()"> </el-button> <el-button type="primary" @click="onCirculationSave(value)"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -490,22 +489,22 @@ export default {
this.$axios.get('/admin/admin/index', { params: { limit: 100, status: 1, is_order: 1 }}).then(response => { this.$axios.get('/admin/admin/index', { params: { limit: 100, status: 1, is_order: 1 }}).then(response => {
this.adminList = response.data.data this.adminList = response.data.data
this.listLoading = false this.listLoading = false
}).catch(err=>{ }).catch(err => {
}) })
}, },
onCirculation(item) { onCirculation(item) {
this.dialog3Visible = true this.dialog3Visible = true
this.item3 = { ...item, os: Number(item.os) } this.item3 = { ...item, os: Number(item.os) }
}, },
onCirculationSave() { onCirculationSave(to_admin_id) {
console.log('====os:' + JSON.stringify(this.item3)) this.$axios.post('/admin/order/back', { sn: this.item3.sn, os: this.item3.os, to_admin_id: to_admin_id }).then(res => {
/* this.$axios.post('/admin/order/back', this.item).then(res => { this.dialog3Visible = false
this.dialogVisible = false
this.item = {} this.item = {}
this.getList() this.getList()
console.log(this.dialog3Visible)
}).catch(err => { }).catch(err => {
})*/ })
}, },
onBack() { onBack() {
this.$axios.post('/admin/order/back', this.item).then(res => { this.$axios.post('/admin/order/back', this.item).then(res => {

View File

@ -15,7 +15,7 @@
<el-table-column align="center" fixed label="快捷内容" width="380" prop="content" /> <el-table-column align="center" fixed label="快捷内容" width="380" prop="content" />
<el-table-column align="center" label="排序" width="140"> <el-table-column align="center" label="排序" width="140">
<template #default="scope"> <template #default="scope">
<el-input-number v-model="scope.row.sort" :max="100" :min="0" class="small-input-number" @change="updateSort(scope.row)" style="width: 110px; height: 36px;" /> <el-input-number v-model="scope.row.sort" :max="100" :min="0" class="small-input-number" style="width: 110px; height: 36px;" @change="updateSort(scope.row)" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="状态" width="100"> <el-table-column align="center" label="状态" width="100">
@ -56,7 +56,7 @@
<el-input v-model="anchors.content" type="textarea" placeholder="请输入快捷内容" /> <el-input v-model="anchors.content" type="textarea" placeholder="请输入快捷内容" />
</el-form-item> </el-form-item>
<el-form-item label="排序"> <el-form-item label="排序">
<el-input-number class="aaas" v-model="anchors.sort" :max="100" :min="0" controls-position="right" /> <el-input-number v-model="anchors.sort" :max="100" :min="0" controls-position="right" />
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
<el-switch v-model="anchors.status" :active-value="1" :inactive-value="0" active-color="#13ce66" inactive-color="#ff4949" /> <el-switch v-model="anchors.status" :active-value="1" :inactive-value="0" active-color="#13ce66" inactive-color="#ff4949" />

View File

@ -159,14 +159,36 @@ class AdminController extends base
$list[$adminId]['onlineTime'] = 0; $list[$adminId]['onlineTime'] = 0;
$list[$adminId]['isOnline'] = 2; $list[$adminId]['isOnline'] = 2;
} }
Log::warning('===bug:',['bug'=> (!config('app.debug', true))]);
if ($user->is_order == 1 && $list[$adminId]['isOnline'] ==1 && empty(Redis::get("CRM:USER:ENDWORK:".$user->id)) && (!config('app.debug', true))){ if (!isset($list[$adminId]['isOnline'])){
$list[$adminId]['isOnline'] = 0;
}
// if ($user->is_order == 1 && $list[$adminId]['isOnline'] ==1){
if ($user->is_order == 1){
$list[$adminId]['isEndWork'] = 1;//是否分单 $list[$adminId]['isEndWork'] = 1;//是否分单
}else{ }else{
$list[$adminId]['isEndWork'] = 0; $list[$adminId]['isEndWork'] = 0;
} }
$list[$adminId]['start_work_time'] = $user->start_work_time;
$list[$adminId]['end_work_time'] = $user->end_work_time;
$list[$adminId]['order_num'] = $user->order_num;
} }
return $this->success(array_values($list)); return $this->success(array_values($list));
} }
public function editInfo(Request $request)
{
$post = $request->post();
if (empty($post['id'])) return $this->error(500, '参数错误');
try {
Admins::update($post);
}catch (\Exception $e){
return $this->error(2001,$e->getMessage());
}
return $this->success(true);
}
} }

View File

@ -0,0 +1,14 @@
<?php
namespace app\admin\controller;
use app\model\Citys;
use support\Request;
class CityController extends base
{
public function getCityList(Request $request){
$list = Citys::fieldRaw('city_id,city_name')->where('status','=',1)->order('sort','desc')->select();
return $this->success($list);
}
}

View File

@ -8,6 +8,7 @@ use app\model\Follows;
use app\model\Orders; use app\model\Orders;
use app\model\Logs; use app\model\Logs;
use stdClass; use stdClass;
use support\Log;
use support\Redis; use support\Redis;
use support\Request; use support\Request;
@ -31,7 +32,7 @@ class OrderController extends base
$status = $request->get('status', null); $status = $request->get('status', null);
$query = Orders::attimes($timetype, $times)->with(['admin','anchor'])->where($where) $query = Orders::attimes($timetype, $times)->with(['admin','anchor','backs'])->where($where)
->order('create_at','desc') ->order('create_at','desc')
->order('update_time','desc') ->order('update_time','desc')
->order('id','desc'); ->order('id','desc');
@ -294,7 +295,7 @@ class OrderController extends base
$sn = $request->get('sn'); $sn = $request->get('sn');
$status = $request->get('status',null); $status = $request->get('status',null);
$query = Backs::with(['into','outto','orders'])->where(function($query) use($request) { $query = Backs::with(['into','outto','orders','apply'])->where(function($query) use($request) {
$query->where('admin_id', $request->admin->id)->WhereOr('admin', $request->admin->id); $query->where('admin_id', $request->admin->id)->WhereOr('admin', $request->admin->id);
})->order('update_time','desc')->order('id','desc'); })->order('update_time','desc')->order('id','desc');
@ -309,8 +310,12 @@ class OrderController extends base
$backs = $query->paginate($request->get('limit',10)); $backs = $query->paginate($request->get('limit',10));
foreach($backs as &$back){ foreach($backs as &$back){
$back->self = 0; if ($back->admin_id == $request->admin->id || $back->admin == $request->admin->id){
if($back->admin_id == $request->admin->id) { $back->self = 0;
if($back->apply_id == $request->admin->id) {
$back->self = 3;
}
}else{
$back->self = 1; $back->self = 1;
} }
} }
@ -322,19 +327,22 @@ class OrderController extends base
public function back(Request $request) { public function back(Request $request) {
$sn = $request->post('sn'); $sn = $request->post('sn');
$os = $request->post('os'); $os = $request->post('os');
$to_admin_id = $request->post('to_admin_id');
$admin_id = empty($to_admin_id) ? $request->admin->id : $to_admin_id;
if(empty($sn)) return $this->error(2001, '提交单号'); if(empty($sn)) return $this->error(2001, '提交单号');
$item = Orders::where('sn', $sn)->where('os', $os)->find(); $item = Orders::where('sn', $sn)->where('os', $os)->find();
if(empty($item)) return $this->error(2002, '订单没有找到'); if(empty($item)) return $this->error(2002, '订单没有找到');
if($item->admin_id == $request->admin->id) return $this->error(2002, '订单已经在你的账号上,不需要再拉取!'); if($item->admin_id == $admin_id) return $this->error(2002, '订单已经在账号上,不需要再拉取!');
$back = Backs::create([ $back = Backs::create([
'order_id' => $item->id, 'order_id' => $item->id,
'admin_id' => $request->admin->id, 'admin_id' => $admin_id,
'admin' => $item->admin_id 'admin' => $item->admin_id,
'apply_id' => $request->admin->id
]); ]);
Logs::todo($item->id, $request->admin->id, 7); Logs::todo($item->id, $admin_id, 7);
if($back) { if($back) {
return $this->success($back); return $this->success($back);
@ -346,19 +354,22 @@ class OrderController extends base
public function toBack(Request $request) { public function toBack(Request $request) {
$sn = $request->post('sn'); $sn = $request->post('sn');
$os = $request->post('os'); $os = $request->post('os');
$to_admin_id = $request->post('to_admin_id');
$admin_id = empty($to_admin_id) ? $request->admin->id : $to_admin_id;
if(empty($sn)) return $this->error(2001, '提交单号'); if(empty($sn)) return $this->error(2001, '提交单号');
$item = Orders::where('sn', $sn)->where('os', $os)->find(); $item = Orders::where('sn', $sn)->where('os', $os)->find();
if(empty($item)) return $this->error(2002, '订单没有找到'); if(empty($item)) return $this->error(2002, '订单没有找到');
if($item->admin_id == $request->admin->id) return $this->error(2002, '订单已经在你的账号上,不需要再拉取!'); if($item->admin_id == $admin_id) return $this->error(2002, '订单已经在账号上,不需要再拉取!');
$back = Backs::create([ $back = Backs::create([
'order_id' => $item->id, 'order_id' => $item->id,
'admin_id' => $request->admin->id, 'admin_id' => $admin_id,
'admin' => $item->admin_id 'admin' => $item->admin_id,
'apply_id' => $request->admin->id
]); ]);
Logs::todo($item->id, $request->admin->id, 7); Logs::todo($item->id, $admin_id, 7);
if($back) { if($back) {
return $this->success($back); return $this->success($back);
@ -367,12 +378,20 @@ class OrderController extends base
} }
} }
/**
* 同意操作
* @param Request $request
* @return \support\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function backpass(Request $request) { public function backpass(Request $request) {
$id = $request->post('id', 0); $id = $request->post('id', 0);
$item = Backs::where('id', $id)->find(); $item = Backs::where('id', $id)->find();
if($item->status != 0) return $this->error(2004, '记录已经处理了.'); if($item->status != 0) return $this->error(2004, '记录已经处理了.');
if($item->admin != $request->admin->id) return $this->error(2005, '管理员错误'); if($item->admin != $request->admin->id && $item->admin != $item->apply_id) return $this->error(2005, '管理员错误');
try { try {
Backs::change($item); Backs::change($item);
@ -382,13 +401,21 @@ class OrderController extends base
} }
} }
/**
* 拒绝操作
* @param Request $request
* @return \support\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function backrefuse(Request $request) { public function backrefuse(Request $request) {
$id = $request->post('id', 0); $id = $request->post('id', 0);
$item = Backs::where('id', $id)->find(); $item = Backs::where('id', $id)->find();
if(empty($item)) return $this->error(2004, '记录没有找到.'); if(empty($item)) return $this->error(2004, '记录没有找到.');
if($item->status != 0) return $this->error(2004, '记录已经处理了.'); if($item->status != 0) return $this->error(2004, '记录已经处理了.');
if($item->admin != $request->admin->id) return $this->error(2005, '管理员错误'); if($item->admin != $request->admin->id && $item->admin != $item->apply_id) return $this->error(2005, '管理员错误');
try { try {
Backs::refuse($item); Backs::refuse($item);
@ -398,4 +425,29 @@ class OrderController extends base
} }
} }
/**
* 取消操作
* @param Request $request
* @return \support\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function backcancel(Request $request)
{
$id = $request->post('id', 0);
$item = Backs::where('id', $id)->find();
if(empty($item)) return $this->error(2004, '记录没有找到.');
if($item->status != 0) return $this->error(2004, '记录已经处理了.');
if($item->admin != $request->admin->id && $item->admin == $item->apply_id) return $this->error(2005, '管理员错误');
try {
Backs::cancel($item);
return $this->success('');
}catch(\Exception $e) {
return $this->error(2006, '确认失败了');
}
}
} }

View File

@ -0,0 +1,73 @@
<?php
namespace app\admin\controller;
use app\model\Qas;
use support\Request;
class QaController extends base
{
public function getQaList(Request $request)
{
$cityId = $request->get('city_id');
$limit = $request->get('limit', 10);
if (empty($cityId)) return $this->error(2001, 'city_id cannot be empty!');
$list = Qas::fieldRaw('city_id,title,content')->where('city_id', $cityId)->paginate($limit);
return $this->success($list);
}
public function getQaDetail(Request $request)
{
$cityId = $request->get('city_id');
// $id = $request->get('id');
if (empty($cityId)) return $this->error(2001, 'city_id cannot be empty!');
$data = Qas::fieldRaw('city_id,title,content')->where([/*'id' => $id, */'city_id' => $cityId])->find();
return $this->success($data);
}
public function addQa(Request $request)
{
$post = $request->post();
if (empty($post['city_id'])) return $this->error(2001, 'city_id data cannot be empty!');
if (empty($post['title'])) return $this->error(2001, 'title data cannot be empty!');
if (empty($post['content'])) return $this->error(2001, 'content data cannot be empty!');
try {
$data = Qas::create($post);
} catch (\Exception $e) {
return $this->error(2002, $e->getMessage());
}
return $this->success($data);
}
public function editQa(Request $request)
{
$post = $request->post();
if (empty($post['id'])) return $this->error(2001, 'id data cannot be empty!');
try {
$data = Qas::update($post);
} catch (\Exception $e) {
return $this->error(2002, $e->getMessage());
}
return $this->success($data);
}
public function delQa(Request $request)
{
$id = $request->get('id');
if (empty($id)) return $this->error(2001, 'id data cannot be empty!');
try {
$data = Qas::destroy($id);
} catch (\Exception $e) {
return $this->error(2002, $e->getMessage());
}
return $this->success($data);
}
}

View File

@ -1,4 +1,5 @@
<?php <?php
namespace app\admin\controller; namespace app\admin\controller;
use app\model\Admins; use app\model\Admins;
@ -6,40 +7,43 @@ use app\model\Orders;
use app\model\Works; use app\model\Works;
use support\Redis; use support\Redis;
use support\Request; use support\Request;
use function Symfony\Component\Translation\t;
class WorkController extends base class WorkController extends base
{ {
public function index(Request $request) { public function index(Request $request)
{
$admin_id = $request->get('id'); $admin_id = $request->get('id');
$admin = $request->get('username'); $admin = $request->get('username');
if($admin){ if ($admin) {
$admin_id = Admins::where('username', $admin)->value('id'); $admin_id = Admins::where('username', $admin)->value('id');
} }
$query = Works::with('admin')->where('status', 1)->order('start', 'desc'); $query = Works::with('admin')->where('status', 1)->order('start', 'desc');
if($admin_id) $query->where('admin_id', $admin_id); if ($admin_id) $query->where('admin_id', $admin_id);
$list = $query->paginate($request->get('limit', 30)); $list = $query->paginate($request->get('limit', 30));
return $this->success($list->append(['total','oss']),'', ['oss'=> Orders::OSS]); return $this->success($list->append(['total', 'oss']), '', ['oss' => Orders::OSS]);
} }
public function saves(Request $request) { public function saves(Request $request)
{
return ''; return '';
$admin_id = $request->post('admin_id'); $admin_id = $request->post('admin_id');
$dates = $request->post('dates'); $dates = $request->post('dates');
$time = $request->post('time'); $time = $request->post('time');
$oss = $request->post('oss',[]); $oss = $request->post('oss', []);
if(empty($dates)) return $this->error(2001, ''); if (empty($dates)) return $this->error(2001, '');
$timeS = strtotime($time[0]); $timeS = strtotime($time[0]);
$timeE = strtotime($time[1]); $timeE = strtotime($time[1]);
$timeL = $timeE - $timeS; $timeL = $timeE - $timeS;
foreach($dates as $date) { foreach ($dates as $date) {
$d = strtotime($date); $d = strtotime($date);
$dS = date('Y-m-d',$d).' '.date('H:i:s',$timeS); $dS = date('Y-m-d', $d) . ' ' . date('H:i:s', $timeS);
$dE = date('Y-m-d H:i:s', strtotime($dS) + $timeL); $dE = date('Y-m-d H:i:s', strtotime($dS) + $timeL);
$month = Date('Ym', $d); $month = Date('Ym', $d);
@ -50,26 +54,27 @@ class WorkController extends base
$works->start = $dS; $works->start = $dS;
$works->end = $dE; $works->end = $dE;
$works->status = 1; $works->status = 1;
$works->os = join(',',$oss); $works->os = join(',', $oss);
$works->save(); $works->save();
} }
return $this->success($date); return $this->success($date);
} }
public function save2(Request $request) { public function save2(Request $request)
{
$times = $request->post('times'); $times = $request->post('times');
if(!empty($times)) { if (!empty($times)) {
$times = $request->post('times'); $times = $request->post('times');
$os = $request->post('os'); $os = $request->post('os');
$start = strtotime($times[0]); $start = strtotime($times[0]);
$end = strtotime($times[1]); $end = strtotime($times[1]);
if(count($os) <= 0) return $this->error(2001, '请选择平台'); if (count($os) <= 0) return $this->error(2001, '请选择平台');
if($start >= $end) return $this->error(2001, '播放时间太短了'); if ($start >= $end) return $this->error(2001, '播放时间太短了');
if($end - $start <= 3600) return $this->error(2001, '时间太短了'); if ($end - $start <= 3600) return $this->error(2001, '时间太短了');
if(time() - $start > 3600*24 || time() - $end) return $this->error(2001, '时间太久远了,没有办法自己排班,找主管排吧'); if (time() - $start > 3600 * 24 || time() - $end) return $this->error(2001, '时间太久远了,没有办法自己排班,找主管排吧');
$os = join(',', $os); $os = join(',', $os);
@ -77,18 +82,18 @@ class WorkController extends base
'admin_id' => $request->admin->id, 'admin_id' => $request->admin->id,
'month' => date('Ym', $start), 'month' => date('Ym', $start),
'os' => $os, 'os' => $os,
'start' => date('Y-m-d H:i:s',$start), 'start' => date('Y-m-d H:i:s', $start),
'end' => date('Y-m-d H:i:s', $end), 'end' => date('Y-m-d H:i:s', $end),
'status' => 1, 'status' => 1,
]); ]);
return $this->success(null); return $this->success(null);
} }
if($request->admin->is_super == 0) return $this->error(2001, '管理员才可以添加'); if ($request->admin->is_super == 0) return $this->error(2001, '管理员才可以添加');
$all = $request->post(); $all = $request->post();
foreach($all as $a) { foreach ($all as $a) {
if(!isset($a['times'])) continue; if (!isset($a['times'])) continue;
$start = strtotime($a['times'][0]); $start = strtotime($a['times'][0]);
$end = strtotime($a['times'][1]); $end = strtotime($a['times'][1]);
@ -98,7 +103,7 @@ class WorkController extends base
'admin_id' => $a['id'], 'admin_id' => $a['id'],
'month' => date('Ym', $start), 'month' => date('Ym', $start),
'os' => $os, 'os' => $os,
'start' => date('Y-m-d H:i:s',$start), 'start' => date('Y-m-d H:i:s', $start),
'end' => date('Y-m-d H:i:s', $end), 'end' => date('Y-m-d H:i:s', $end),
'status' => 1, 'status' => 1,
]); ]);
@ -109,16 +114,17 @@ class WorkController extends base
/** /**
* @保存一天的时间 * @保存一天的时间
*/ */
public function save(Request $request) { public function save(Request $request)
{
$id = $request->post('id', 0); $id = $request->post('id', 0);
$date = $request->post('date'); $date = $request->post('date');
$oss = $request->post('oss'); $oss = $request->post('oss');
if($id) { if ($id) {
$item = Works::find($id); $item = Works::find($id);
} }
if(empty($item)) { if (empty($item)) {
return $this->error(2101); return $this->error(2101);
} }
@ -128,50 +134,59 @@ class WorkController extends base
$item->start = $start; $item->start = $start;
$item->end = $end; $item->end = $end;
$item->status = 1; $item->status = 1;
$item->os = join(',',$oss); $item->os = join(',', $oss);
$back = $item->save(); $back = $item->save();
if($back) if ($back)
return $this->success($item); return $this->success($item);
return $this->error(2003); return $this->error(2003);
} }
public function del(Request $request) { public function del(Request $request)
{
$id = $request->post('id', 0); $id = $request->post('id', 0);
if($id) { if ($id) {
$item = Works::find($id); $item = Works::find($id);
if($item){ if ($item) {
$item->status = 0; $item->status = 0;
$item->save(); $item->save();
return $this->success(null); return $this->success(null);
} }
}else{ } else {
return $this->error(2002,'没有提交ID'); return $this->error(2002, '没有提交ID');
} }
} }
public function anchor(Request $request) { public function anchor(Request $request)
$anchor = Admins::where('status', 1)->where('is_anchor',1)->select(); {
foreach($anchor as &$an) { $anchor = Admins::where('status', 1)->where('is_anchor', 1)->select();
foreach ($anchor as &$an) {
$an->os = []; $an->os = [];
} }
return $this->success($anchor->hidden(['password','remember_token'])); return $this->success($anchor->hidden(['password', 'remember_token']));
} }
public function endworks(Request $request) { public function endworks(Request $request)
Redis::set("CRM:USER:ENDWORK:".$request->admin->id,10*3600); {
// Redis::set("CRM:USER:ENDWORK:".$request->admin->id,10*3600);
Admins::update(['id' => $request->admin->id, 'is_order' => 0, 'end_work_time' => time()]);
return $this->success(null); return $this->success(null);
} }
public function startworks(Request $request) { public function startworks(Request $request)
Redis::del("CRM:USER:ENDWORK:".$request->admin->id); {
// Redis::del("CRM:USER:ENDWORK:" . $request->admin->id);
Admins::update(['id' => $request->admin->id, 'is_order' => 1,'start_work_time' => time()]);
return $this->success(null); return $this->success(null);
} }
public function getworkstatus(Request $request) { public function getworkstatus(Request $request)
$workstatus = Redis::get("CRM:USER:ENDWORK:".$request->admin->id); {
// $workstatus = Redis::get("CRM:USER:ENDWORK:" . $request->admin->id);
$data = Admins::where('id' , $request->admin->id)->find();
$workstatus = !$data->is_order;
return $this->success((bool)$workstatus); return $this->success((bool)$workstatus);
} }
} }

View File

@ -26,6 +26,7 @@ class SpiderMt extends Command
protected static $defaultDescription = '美团订单拉取器'; protected static $defaultDescription = '美团订单拉取器';
protected $_users = []; protected $_users = [];
protected $order_num = 99999999;
protected function configure() protected function configure()
{ {
@ -51,12 +52,23 @@ class SpiderMt extends Command
if (empty($ru)) continue; if (empty($ru)) continue;
} }
//过滤不分配订单的客服用户 //过滤不分配订单的客服用户
$isEndWork = Redis::get("CRM:USER:ENDWORK:" . $u->id); /*$isEndWork = Redis::get("CRM:USER:ENDWORK:" . $u->id);
if (empty($isEndWork)) { if (empty($isEndWork)) {
$_u = new stdClass(); $_u = new stdClass();
$_u->username = $u->id; $_u->username = $u->id;
$us[] = $_u; $us[] = $_u;
}*/
if ($u->order_num > 0){
$_u = new stdClass();
$_u->username = $u->id;
$us[] = $_u;
if ($u->order_num != $this->order_num){
Admins::where('id',$u->id)->decrement('order_num',1);
}
} }
$_u = new stdClass();
$_u->username = $u->id;
$us[] = $_u;
}; };
$this->_users = $us; $this->_users = $us;
return $this->_users; return $this->_users;

View File

@ -16,4 +16,5 @@ class Admins extends base
} }
return false; return false;
} }
} }

View File

@ -13,6 +13,10 @@ class Backs extends base
return $this->belongsTo(Admins::class, 'admin')->visible(['name','username','avatar']); return $this->belongsTo(Admins::class, 'admin')->visible(['name','username','avatar']);
} }
public function apply() {
return $this->belongsTo(Admins::class, 'apply_id')->visible(['name','username','avatar']);
}
public function orders(){ public function orders(){
return $this->belongsTo(Orders::class, 'order_id'); return $this->belongsTo(Orders::class, 'order_id');
} }
@ -36,4 +40,11 @@ class Backs extends base
Logs::todo($item->order_id, $item->admin, 9); //拒绝请求 Logs::todo($item->order_id, $item->admin, 9); //拒绝请求
}); });
} }
public static function cancel(Backs $item) {
Db::transaction(function() use ($item) {
Backs::where('id', $item->id)->where('status', 0)->update(['status' => 3]);
Logs::todo($item->order_id, $item->admin, 10); //拒绝请求
});
}
} }

View File

@ -0,0 +1,8 @@
<?php
namespace app\model;
class Citys extends base
{
}

View File

@ -103,6 +103,10 @@ class Orders extends base{
return $this->belongsTo(Admins::class, 'zhubo')->visible(['name','username','avatar']); return $this->belongsTo(Admins::class, 'zhubo')->visible(['name','username','avatar']);
} }
public function backs() {
return $this->hasOne(Backs::class, 'order_id')->visible(['status']);
}
public function follow() { public function follow() {
return $this->hasMany(Follows::class, 'order_id')->order('id','desc'); return $this->hasMany(Follows::class, 'order_id')->order('id','desc');
} }

View File

@ -0,0 +1,8 @@
<?php
namespace app\model;
class Qas extends base
{
}