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.
108 lines
3.5 KiB
108 lines
3.5 KiB
9 months ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
|
||
|
namespace app\wap\controller;
|
||
|
|
||
|
use app\wap\model\store\StoreService;
|
||
|
use service\SystemConfigService;
|
||
|
use app\wap\model\user\User;
|
||
|
use service\JsonService;
|
||
|
use service\UtilService;
|
||
|
use think\Request;
|
||
|
|
||
|
/**客服控制器
|
||
|
* Class Service
|
||
|
* @package app\wap\controller
|
||
|
*/
|
||
|
class Service extends AuthController
|
||
|
{
|
||
|
/**微信客服列表
|
||
|
* @param Request $request
|
||
|
* @return mixed
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function service_list()
|
||
|
{
|
||
|
$customer_service_configuration = SystemConfigService::get('customer_service_configuration');
|
||
|
$service_url = SystemConfigService::get('service_url');
|
||
|
$kefu_token = SystemConfigService::get('kefu_token');
|
||
|
$this->assign([
|
||
|
'service_configuration' => $customer_service_configuration,
|
||
|
'service_url' => $service_url,
|
||
|
'kefu_token' => $kefu_token,
|
||
|
'userInfo' => json_encode($this->userInfo)
|
||
|
]);
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取微信客服
|
||
|
*/
|
||
|
public function get_service_list()
|
||
|
{
|
||
|
$where = UtilService::getMore([
|
||
|
['mer_id', ''],
|
||
|
['page', 1],
|
||
|
['limit', 10]
|
||
|
]);
|
||
|
$list = StoreService::get_weixin_service_list($where);
|
||
|
return JsonService::successful($list);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* crmeb客服token
|
||
|
*/
|
||
|
public function get_kefu_token()
|
||
|
{
|
||
|
$kefu_token = SystemConfigService::get('kefu_token');
|
||
|
$data['kefu_token'] = $kefu_token;
|
||
|
return JsonService::successful($data);
|
||
|
}
|
||
|
|
||
|
/**聊天
|
||
|
* @param Request $request
|
||
|
* @return mixed
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function service_ing(Request $request)
|
||
|
{
|
||
|
$params = Request::instance()->param();
|
||
|
$to_uid = $params['to_uid'];
|
||
|
if (!isset($to_uid) || empty($to_uid)) $this->failed('未获取到接收用户信息!');
|
||
|
if ($this->uid == $to_uid) $this->failed('您不能进行自言自语!');
|
||
|
|
||
|
//发送用户信息
|
||
|
$now_user = StoreService::where(['uid' => $this->uid])->find();
|
||
|
if (!$now_user) $now_user = $this->userInfo;
|
||
|
$this->assign('user', $now_user);
|
||
|
|
||
|
//接收用户信息
|
||
|
$to_user = StoreService::where(['uid' => $to_uid])->find();
|
||
|
if (!$to_user) $to_user = User::getUserData($to_uid);
|
||
|
if (!$to_user) $this->failed('未获取到接收用户信息!');
|
||
|
$this->assign(['to_user' => $to_user]);
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
|
||
|
/**聊天记录
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function service_new()
|
||
|
{
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
}
|