You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
4.5 KiB
178 lines
4.5 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\kefu\controller;
|
|
|
|
use app\kefu\controller\AuthController;
|
|
use app\kefu\model\KefuModel;
|
|
use app\kefu\services\KefuChatService;
|
|
use service\FormBuilder as Form;
|
|
use service\JsonService as Json;
|
|
use service\UploadService as Upload;
|
|
use think\Request;
|
|
use think\Url;
|
|
use app\admin\model\article\ArticleCategory as ArticleCategoryModel;
|
|
use app\admin\model\article\Article as ArticleModel;
|
|
use app\admin\model\user\User;
|
|
use app\kefu\model\KefuUserRecordModel;
|
|
use app\kefu\model\user\UserGroupModel;
|
|
use think\Session;
|
|
use service\JwtService;
|
|
use app\kefu\services\KefuRecordService;
|
|
|
|
/**
|
|
* 文章分类管理 控制器
|
|
* */
|
|
class Dashboard extends AuthController
|
|
{
|
|
/**
|
|
* 白名单
|
|
*/
|
|
public static function WhiteList()
|
|
{
|
|
return [
|
|
'login',
|
|
'account_login'
|
|
];
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
if (request()->isMobile()) {
|
|
return $this->fetch("mobile_index");
|
|
}
|
|
|
|
return $this->fetch();
|
|
}
|
|
|
|
|
|
|
|
public function mobile_order($uid)
|
|
{
|
|
if (!request()->isMobile()) {
|
|
return $this->redirect(Url("index"));
|
|
}
|
|
|
|
$userInfo = User::get($uid);
|
|
|
|
$this->assign("userInfo", $userInfo);
|
|
|
|
return $this->fetch();
|
|
}
|
|
|
|
public function mobile_chat($uid)
|
|
{
|
|
if (!request()->isMobile()) {
|
|
return $this->redirect(Url("index"));
|
|
}
|
|
|
|
$userInfo = User::get($uid);
|
|
|
|
$this->assign("userInfo", $userInfo);
|
|
|
|
return $this->fetch();
|
|
}
|
|
|
|
|
|
public function login()
|
|
{
|
|
return $this->fetch();
|
|
}
|
|
|
|
public function account_login()
|
|
{
|
|
$params = request()->param();
|
|
|
|
$kefuAccount = (new KefuModel)->where("account", $params['account'])->find();
|
|
if (!$kefuAccount) return Json::fail("账号不存在!");
|
|
|
|
if (!$kefuAccount['status']) return Json::fail("账号已被禁用!");
|
|
|
|
$input_pwd = $params['password'];
|
|
if (md5($input_pwd) !== $kefuAccount['password']) return Json::fail("密码不正确!");
|
|
|
|
Session::set("kefuId", $kefuAccount["id"], "kefu");
|
|
|
|
return Json::successful("登录成功!");
|
|
}
|
|
|
|
public function logout()
|
|
{
|
|
Session::delete("kefuId", "kefu");
|
|
|
|
return Json::successful("退出登录成功!");
|
|
}
|
|
|
|
private function createToken($kefuId)
|
|
{
|
|
$tokenService = new JwtService("kefu");
|
|
|
|
return $tokenService->getToken((int)$kefuId);
|
|
}
|
|
|
|
public function get_token()
|
|
{
|
|
$token = $this->createToken($this->kefuId);
|
|
|
|
return Json::successful('ok', ['token' => $token]);
|
|
}
|
|
|
|
public function user_record($nickname = "", $is_tourist = 0)
|
|
{
|
|
$service = new KefuRecordService;
|
|
|
|
$data = $service->getRecordList($this->kefuId, $nickname, $is_tourist);
|
|
|
|
return Json::successful($data);
|
|
}
|
|
|
|
public function get_chat_list($uid, $upper_id, $is_tourist)
|
|
{
|
|
$service = new KefuChatService;
|
|
|
|
$data = $service->getChatList($this->kefuId, $uid, $upper_id, $is_tourist);
|
|
|
|
return Json::successful($data);
|
|
}
|
|
|
|
|
|
public function get_product_cart($uid, $store_name)
|
|
{
|
|
$carts = [];
|
|
|
|
return Json::successful($carts);
|
|
}
|
|
|
|
public function set_msg_isread($uid)
|
|
{
|
|
if (!$uid) return Json::fail("找不到用户!");
|
|
(new KefuUserRecordModel)->where([
|
|
'is_kefu_send' => 1,
|
|
'user_id' => $this->kefuId,
|
|
'to_uid' => $uid
|
|
])->update([
|
|
'mssage_num' => 0
|
|
]);
|
|
|
|
return Json::successful("更新成功!");
|
|
}
|
|
|
|
public function transfer_list()
|
|
{
|
|
$data = (new KefuModel)
|
|
->field('id, nickname, avatar, online')
|
|
->where('id', '<>', $this->kefuId)
|
|
->where('online', 1)
|
|
->select();
|
|
|
|
return Json::successful($data);
|
|
}
|
|
}
|
|
|