其余文件
This commit is contained in:
102
app/admin/logic/kefu/KefuLangLogic.php
Normal file
102
app/admin/logic/kefu/KefuLangLogic.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\kefu;
|
||||
|
||||
use app\common\model\kefu\KefuLang;
|
||||
|
||||
/**
|
||||
* 客服术语逻辑层
|
||||
* Class KefuLangLogic
|
||||
* @package app\admin\logic\kefu
|
||||
*/
|
||||
class KefuLangLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @param $limit
|
||||
* @param $page
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
* @author cjhao
|
||||
* @date 2021/11/29 15:11
|
||||
*/
|
||||
public static function lists(int $limit,int $page)
|
||||
{
|
||||
$list = KefuLang::where(['shop_id' => 0])->order('sort asc')->paginate([
|
||||
'list_rows' => $limit,
|
||||
'page' => $page,
|
||||
]);
|
||||
return ['count' => $list->total(), 'lists' => $list->getCollection()];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 新增话术
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2021/11/29 15:54
|
||||
*/
|
||||
public static function add(array $post)
|
||||
{
|
||||
$kefu_lang = new KefuLang();
|
||||
$kefu_lang->title = $post['title'];
|
||||
$kefu_lang->content = $post['content'];
|
||||
$kefu_lang->sort = $post['sort'];
|
||||
return $kefu_lang->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑话术
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2021/11/29 15:59
|
||||
*/
|
||||
public static function edit(array $post){
|
||||
return KefuLang::update($post);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取话术
|
||||
* @param $id
|
||||
* @return array|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2021/11/29 16:02
|
||||
*/
|
||||
public static function detail(int $id){
|
||||
return KefuLang::where(['id'=>$id])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除话术
|
||||
* @param int $id
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2021/11/29 16:11
|
||||
*/
|
||||
public static function del(int $id){
|
||||
return KefuLang::destroy($id);
|
||||
}
|
||||
}
|
||||
231
app/admin/logic/kefu/KefuLogic.php
Normal file
231
app/admin/logic/kefu/KefuLogic.php
Normal file
@ -0,0 +1,231 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\kefu;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\logic\ChatLogic;
|
||||
use app\common\model\Admin;
|
||||
use app\common\model\Client_;
|
||||
use app\common\model\kefu\Kefu;
|
||||
use app\common\model\Role;
|
||||
use app\common\server\UrlServer;
|
||||
use app\kefuapi\logic\LoginLogic;
|
||||
|
||||
/**
|
||||
* 客服逻辑
|
||||
* Class KefuLogic
|
||||
* @package app\admin\logic\index
|
||||
*/
|
||||
class KefuLogic extends Logic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 客服列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2021/11/26 18:44
|
||||
*/
|
||||
public static function getLists($get)
|
||||
{
|
||||
$result = (new Kefu())->alias('k')
|
||||
->field("k.*,a.account")
|
||||
->join('admin a', 'a.id = k.admin_id')
|
||||
->where(['a.del' => 0, 'k.del' => 0, 'shop_id' => 0])
|
||||
->order('sort asc')->paginate([
|
||||
'list_rows' => $get['limit'],
|
||||
'page' => $get['page'],
|
||||
]);
|
||||
|
||||
foreach ($result as $value) {
|
||||
$value['avatar'] = empty($value['avatar']) ? "" : UrlServer::getFileUrl($value['avatar']);
|
||||
}
|
||||
|
||||
return ['count' => $result->total(), 'lists' => $result->getCollection()];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加客服
|
||||
* @param $post
|
||||
* @return Kefu|false|\think\Model
|
||||
* @author 段誉
|
||||
* @date 2021/11/27 10:43
|
||||
*/
|
||||
public static function add($post)
|
||||
{
|
||||
try {
|
||||
return (new Kefu())->insertKefu($post);
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑客服
|
||||
* @param $post
|
||||
* @return Kefu|false
|
||||
* @author 段誉
|
||||
* @date 2021/11/27 10:44
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
try {
|
||||
|
||||
if ($post['disable'] == 1) {
|
||||
ChatLogic::setChatDisable(0, $post['id']);
|
||||
}
|
||||
|
||||
return (new Kefu())->updateKefu($post['id'], $post);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @author 段誉
|
||||
* @date 2021/11/27 10:44
|
||||
*/
|
||||
public static function detail($id)
|
||||
{
|
||||
$detail = (new Kefu())->alias('k')
|
||||
->field("k.*, a.account, a.name")
|
||||
->join('admin a', 'a.id = k.admin_id')
|
||||
->where(['k.id' => $id, 'k.shop_id' => 0])
|
||||
->findOrEmpty();
|
||||
|
||||
$detail['avatar'] = !empty($detail['avatar']) ? UrlServer::getFileUrl($detail['avatar']) : '';
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除客服
|
||||
* @param $post
|
||||
* @return Kefu
|
||||
* @author 段誉
|
||||
* @date 2021/11/27 10:48
|
||||
*/
|
||||
public static function del($post)
|
||||
{
|
||||
return (new Kefu())->delKefu($post['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 管理员列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
* @author 段誉
|
||||
* @date 2021/11/26 18:00
|
||||
*/
|
||||
public static function getAdminLists($get)
|
||||
{
|
||||
// 角色名称
|
||||
$role_column = (new Role())->getNameColumn();
|
||||
|
||||
// 已有客服列表
|
||||
$kefu = (new Kefu())->where(['del' => 0, 'shop_id' => 0])->column("admin_id");
|
||||
|
||||
// 查询条件
|
||||
$where[] = ['del', '=', 0];
|
||||
$where[] = ['id', 'not in', $kefu];
|
||||
if (isset($get['role_id']) && $get['role_id'] != '') {
|
||||
$where[] = ['role_id', '=', $get['role_id']];
|
||||
}
|
||||
if (isset($get['name']) && $get['name'] != '') {
|
||||
$where[] = ['name', 'like', "%{$get['name']}%"];
|
||||
}
|
||||
|
||||
$result = (new Admin())->where($where)
|
||||
->hidden(['password', 'salt'])
|
||||
->paginate([
|
||||
'list_rows' => $get['limit'],
|
||||
'page' => $get['page'],
|
||||
]);
|
||||
|
||||
foreach ($result as $k => $item) {
|
||||
if ($item['root'] == 1) {
|
||||
$role = '超级管理员';
|
||||
} else {
|
||||
$role = $role_column[$item['role_id']] ?? '';
|
||||
}
|
||||
$result[$k]['role'] = $role;
|
||||
}
|
||||
return ['count' => $result->total(), 'lists' => $result->getCollection()];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置客服状态
|
||||
* @param $post
|
||||
* @return Kefu
|
||||
* @author 段誉
|
||||
* @date 2021/11/26 18:32
|
||||
*/
|
||||
public static function setStatus($post)
|
||||
{
|
||||
if ($post['disable'] == 1) {
|
||||
ChatLogic::setChatDisable(0, $post['id']);
|
||||
}
|
||||
return (new Kefu())->updateStatus($post['id'], $post['disable']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 返回登录链接
|
||||
* @param $id
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2021/12/15 19:52
|
||||
*/
|
||||
public static function login($id)
|
||||
{
|
||||
try{
|
||||
$kefu = (new Admin())->alias('a')
|
||||
->field(['k.id', 'k.nickname', 'k.avatar', 'k.shop_id', 'a.account'])
|
||||
->join('kefu k', 'a.id = k.admin_id')
|
||||
->where(['k.id' => $id, 'k.shop_id' => 0, 'k.del' => 0])
|
||||
->findOrEmpty()->toArray();
|
||||
|
||||
if(empty($kefu)) {
|
||||
throw new \Exception('该客服信息缺失');
|
||||
}
|
||||
|
||||
$token = LoginLogic::createSession($kefu['id'], $kefu['shop_id'], Client_::pc);
|
||||
|
||||
return request()->domain() . '/kefu?token='. $token;
|
||||
|
||||
} catch(\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user