当前位置: 七九推 > IT编程>脚本编程>Python > 在线客服系统安装教程,附源码

在线客服系统安装教程,附源码

2022年06月23日 Python 我要评论
在线客服系统源码一套可私有化部署的免费开源客服系统,基于php+mysql开发,编译后的二进制文件可直接使用无需搭开发环境,下载zip解压即可

在线客服系统源码一套可私有化部署的免费开源客服系统,基于php+mysql开发,编译后的二进制文件可直接使用无需搭开发环境,下载zip解压即可,仅依赖MySQL数据库,是一个开箱即用的网页在线客服系统,致力于帮助广大开发者/中小站长快速整合私有客服功能

原理+安装教程 

在线客服系统是一套交互式沟通工具,使用它可以迅速缩小你的选择范围,联系多个供应商、客户等,也可以给你的企业一个关于用户体验的重大影响。

在线客服系统源码基本模块:

  1、用户注册登录系统:使用在线客服系统的第一步是注册表单,用户将在其中请求登录或注册选项。如果用户是新用户,则可以选择“注册”,然后输入所有这些详细信息以获得唯一的id和密码;

  2、用户信息几记录系统:注册完成后,用户将获得用户id和密码使用这些详细信息,他可以登录到应用程序和使用所有功能。用户可以选择更改密码。用户可以在线和离线查看可用用户列表并执行聊天操作;

  3、双向即时通讯聊天模块:在聊天模块下,用户可以查看在线和离线状态的可用用户列表。他可以选择用户并在接受后发送请求,他可以与用户聊天。用户将有更改字体和颜色的设置选项。用户可以输入一条消息,然后使用send按钮发送一条消息,该消息显示在上面的窗口下。用户可以一次与多个用户聊天,他可以查看以前的聊天记录和删除消息;

  4、多用户同时响应支持模块:客服可以同时接入不同的咨询请求,并可以甚至处理优先级。

  在线客服系统是当今一种新的与线上交流方式,它基本上是由在因特网上定期交换信息的人或一群人组成的。他们特别与那些有共同利益的人交流。该在线客服系统源码是一个基于web MySQL-Ajax的应用程序。对于系统的后端,使用了sqlserver,以便以后很容易检索。它就像信使一样,一个用户可以与其他用户聊天。此外,多个用户也可以在一个群中聊天。系统还会自动更新聊天记录。

  该系统基本上是搭载完善的在线聊天系统,供有兴趣交换信息的用户使用。它也将有助于那些与更多的人分享信息的用户。系统由管理员和用户两部分组成。系统的用户是可以登录系统的普通用户。相反,他们将被允许在他们之间交换信息。而且,他们可以根据自己的兴趣与一群人交流。

  然而,这个系统将是更有用的用户,因为他们可以加入小组聊天。系统也有一个管理员,他们可以添加和删除用户。此外,该系统还可以帮助用户寻找其他活跃的或在线或离线的用户,所有这些活动都与创建数据库chat和导入数据库中的SQL文件一起存储。

企业搭载在线客服系统源码的优势:

  1、获得良好的口碑传播:29%的消费者曾告诉朋友或同事在线客服的完美体验;

  2、实时聊天可以增加购买量:38%的消费者更愿意从公司购买,如果他们提供实时聊天支持;

  3、实时聊天可以提高客户忠诚度:如果提供实时聊天支持,51%的消费者更有可能继续留在公司或再次从公司购买产品。而且,他们很乐意花更多的钱!在每月在线消费在250-500美元之间的人中,63%的人最有可能从提供在线聊天服务的公司购买产品并对其忠诚。

代码:

/**
 *
 * 前台Pc端对话窗口.
 */
class Index extends Controller
{

    public function _initialize()
    {
        $basename = request()->root();
        if (pathinfo($basename, PATHINFO_EXTENSION) == 'php') {
            $basename = dirname($basename);
        }
        $this->assign('basename',$basename);
    }

    /**
     *
     * [home description]
     * @return [type] [description]
     */
    public function home()
    {
        $data = $this->request->request('',null,null);
        $data['business_id'] = $this->request->param('business_id');
        $data['groupid'] = $this->request->param('groupid');
        $data['special'] = $this->request->param('special');
        $data['theme'] = $this->request->param('theme','7571f9');
        if (isset($data['code']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
            try{
                $_SESSION['Custom'] = null;
                Cookie::delete('product_id');
                $wechat = WechatPlatform::get(['business_id' => $data['business_id']]);
                $appid = $wechat['app_id'];
                $appsecret = $wechat['app_secret'];
                $weixin = file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$appsecret&code={$data['code']}&grant_type=authorization_code");//通过code换取网页授权access_token
                $array = json_decode($weixin,true); //对JSON格式的字符串进行编码
                //{"errcode":40029,"errmsg":"invalid code"}
                if(!isset($array['access_token'])){
                    //说明没有获取到
//                        $this->error('公众号access_token获取失败','https://www.baidu.com/');
                    echo $array['errmsg'];
                    exit();
                }
                $info = file_get_contents("https://api.weixin.qq.com/sns/userinfo?access_token={$array['access_token']}&openid={$array['openid']}&lang=zh_CN");
                $infoarray = json_decode($info,true);
                $data['visiter_id'] = $infoarray['openid'];
                $common = new Common();
                $data['visiter_name'] = $common->remove_emoji($infoarray['nickname']);
                $data['avatar'] = $infoarray['headimgurl'];
                if (!isset($data['groupid'])) {
                    $data['groupid'] = 0;
                }

            }catch (Exception $exception) {
                $this->error($exception->getMessage());
            }
        }

        if (!isset($data['product'])) {
            $data['product'] = "";
        }

        if (!isset($data['special'])) {
            $data['special'] = "";
        }

        $str = 'theme='.$data['theme']."&visiter_id=" . $data['visiter_id'] . "&visiter_name=" . $data['visiter_name'] . "&avatar=" . $data['avatar'] . "&business_id=" . $data['business_id'] . "&groupid=" . $data['groupid'] . "&product=" . $data['product']."&special=" . $data['special'];

        $common = new Common();

        $newstr = $common->encrypt($str, 'E', 'QQ1500203929');

        $a = urlencode($newstr);

        $this->redirect(request()->root().'/index/index?code=' . $a);

    }

    /**
     * 对话窗口页面.
     *
     * @return mixed
     */
    public function index()
    {

        $sarr = parse_url(ahost);
        if ($sarr['scheme'] == 'https') {
            $state = true;
        } else {
            $state = false;
        }

        $app_key = app_key;
        $app_secret = app_secret;
        $app_id = app_id;
        $options = array(
            'encrypted' => $state
        );
        $host = ahost;
        $port = aport;

        $pusher = new Pusher(
            $app_key,
            $app_secret,
            $app_id,
            $options,
            $host,
            $port
        );

        $common = new Common();

        $is_mobile = $common->isMobile();

        $url = domain;

        if (isset($_SERVER['HTTP_REFERER'])) {
            $from_url = $_SERVER['HTTP_REFERER'];
        } else {
            $from_url = '';
        }


        $arr = $this->request->get();

        $data = $common->encrypt($arr['code'], 'D', 'QQ1500203929');

        if (!$data) {
            $this->redirect(request()->root().'/index/index/errors');
        }

        parse_str($data, $arr2);
        $special = isset($arr2['special']) ? $arr2['special']:null;

        if (!isset($arr2['visiter_id']) || !isset($arr2['visiter_name']) || !isset($arr2['product']) || !isset($arr2['groupid']) || !isset($arr2['business_id']) || !isset($arr2['avatar'])) {
            $this->redirect(request()->root().'/index/index/errors');
        }

        $theme=isset($arr2['theme'])?$arr2['theme']:'7571f9';
        if ($is_mobile) {
            $this->redirect(request()->root().'/mobile/index/home?theme=' . $theme . '&visiter_id=' . $arr2['visiter_id'] . '&visiter_name=' . $arr2['visiter_name'] . '&avatar=' . $arr2['avatar'] . '&business_id=' . $arr2['business_id'] . '&product=' . $arr2['product'] . '&groupid=' . $arr2['groupid']."&special=".$special);
        }


        $content = json_decode($arr2['product'], true);
        if (!$content) {
            $arr2['product'] = NULL;

        }
        $business_id = htmlspecialchars($arr2['business_id']);
        $visiter_id = htmlspecialchars($arr2['visiter_id']);
        if ($visiter_id === '') {
            if (empty($_SESSION['Custom']['visiter_id'])) {
                $visiter_id = bin2hex(pack('N', time()));
                $_SESSION['Custom']['visiter_id'] = $visiter_id;
            } else {
                $visiter_id = $_SESSION['Custom']['visiter_id'];
            }
        }

        // 判断是否访问过
        if ($visiter_id) {

            if (!isset($_COOKIE['product_id'])) {

                if ($arr2['product'] != NULL) {

                    $product = $arr2['product'];
                    $content = json_decode($arr2['product'], true);
                    if (isset($content['pid']) && isset($content['url']) && isset($content['img']) && isset($content['title']) && isset($content['info']) && isset($content['price'])) {
                        setcookie("product_id", $content['pid'], time() + 3600 * 12);
                        $arr2['timestamp'] = time();

                        $service = User::table('wolive_queue')->where(['visiter_id' => $visiter_id, 'business_id' => $business_id])->find();

                        if ($service) {
                            $service_id = $service['service_id'];
                        } else {
                            $service_id = 0;
                        }

                        $str = '<a href="' . $content['url'] . '" target="_blank" class="wolive_product">';
                        $str .= '<div class="wolive_img"><img src="' . $content['img'] . '" width="100px"></div>';
                        $str .= '<div class="wolive_head"><p class="wolive_info">' . $content['title'] . '</p><p class="wolive_price">' . $content['price'] . '</p>';
                        $str .= '<p class="wolive_info">' . $content['info'] . '</p>';
                        $str .= '</div></a>';


                        $mydata = ['service_id' => $service_id, 'visiter_id' => $visiter_id, 'content' => $str, 'timestamp' => time(), 'business_id' => $business_id, 'direction' => 'to_service'];

                        $pusher->trigger('kefu' . $service_id, 'cu-event', array('message' => $mydata));

                        $chats = User::table('wolive_chats')->insert($mydata);
                    }

                }
            } else {

                $pid = isset($_COOKIE['product_id']) ? $_COOKIE['product_id'] : '';

                if ($arr2['product'] != NULL) {
                    $product = $arr2['product'];
                    $content = json_decode($arr2['product'], true);

                    if (isset($content['pid']) && isset($content['url']) && isset($content['img']) && isset($content['title']) && isset($content['info']) && isset($content['price']) && $content['pid'] != $pid) {

                        $service = User::table('wolive_queue')->where(['visiter_id' => $visiter_id, 'business_id' => $business_id])->find();

                        if ($service) {
                            $service_id = $service['service_id'];
                        } else {
                            $service_id = 0;
                        }

                        $str = '<a href="' . $content['url'] . '" target="_blank" class="wolive_product">';
                        $str .= '<div class="wolive_img"><img src="' . $content['img'] . '" width="100px"></div>';
                        $str .= '<div class="wolive_head"><p class="wolive_info">' . $content['title'] . '</p><p class="wolive_price">' . $content['price'] . '</p>';
                        $str .= '<p class="wolive_info">' . $content['info'] . '</p>';
                        $str .= '</div></a>';

                        $mydata = ['service_id' => $service_id, 'visiter_id' => $visiter_id, 'content' => $str, 'timestamp' => time(), 'business_id' => $business_id, 'direction' => 'to_service'];

                        $pusher->trigger('kefu' . $service_id, 'cu-event', array('message' => $mydata));
                        $chats = User::table('wolive_chats')->insert($mydata);

                    }
                }
            }

        } else {

            if (!isset($_COOKIE['product_id'])) {

                if ($arr2['product'] != NULL) {
                    $product = $arr2['product'];
                    $content = json_decode($arr2['product'], true);
                    if (isset($content['pid']) && isset($content['url']) && isset($content['img']) && isset($content['title']) && isset($content['info']) && isset($content['price'])) {
                        setcookie("product_id", $content['pid'], time() + 3600 * 12);
                        $arr2['timestamp'] = time();

                        $service = User::table('wolive_queue')->where(['visiter_id' => $visiter_id, 'business_id' => $business_id])->find();

                        if ($service) {
                            $service_id = $service['service_id'];
                        } else {
                            $service_id = 0;
                        }

                        $str = '<a href="' . $content['url'] . '" target="_blank" class="wolive_product">';
                        $str .= '<div class="wolive_img"><img src="' . $content['img'] . '" width="100px"></div>';
                        $str .= '<div class="wolive_head"><p class="wolive_info">' . $content['title'] . '</p><p class="wolive_price">' . $content['price'] . '</p>';
                        $str .= '<p class="wolive_info">' . $content['info'] . '</p>';
                        $str .= '</div></a>';


                        $mydata = ['service_id' => $service_id, 'visiter_id' => $visiter_id, 'content' => $str, 'timestamp' => time(), 'business_id' => $business_id, 'direction' => 'to_service'];

                        $pusher->trigger('kefu' . $service_id, 'cu-event', array('message' => $mydata));

                        $chats = User::table('wolive_chats')->insert($mydata);
                    }

                }
            } else {

                if ($arr2['product'] != NULL) {


                    if ($arr2['visiter_id'] != $_SESSION['Custom']['visiter_id']) {

                        $product = $arr2['product'];
                        $content = json_decode($arr2['product'], true);

                        if (isset($content['pid']) && isset($content['url']) && isset($content['img']) && isset($content['title']) && isset($content['info']) && isset($content['price'])) {

                            $service = User::table('wolive_queue')->where(['visiter_id' => $visiter_id, 'business_id' => $business_id])->find();

                            if ($service) {
                                $service_id = $service['service_id'];
                            } else {
                                $service_id = 0;
                            }

                            $str = '<a href="' . $content['url'] . '" target="_blank" class="wolive_product">';
                            $str .= '<div class="wolive_img"><img src="' . $content['img'] . '" width="100px"></div>';
                            $str .= '<div class="wolive_head"><p class="wolive_info">' . $content['title'] . '</p><p class="wolive_price">' . $content['price'] . '</p><p>';
                            $str .= '<p class="wolive_info">' . $content['info'] . '</p>';
                            $str .= '</div></a>';


                            $mydata = ['service_id' => $service_id, 'visiter_id' => $visiter_id, 'content' => $str, 'timestamp' => time(), 'business_id' => $business_id, 'direction' => 'to_service'];

                            $pusher->trigger('kefu' . $service_id, 'cu-event', array('message' => $mydata));
                            $chats = User::table('wolive_chats')->insert($mydata);
                        }

                    } else {

                        $pid = $_COOKIE['product_id'];

                        $product = $arr2['product'];
                        $content = json_decode($arr2['product'], true);
                        // 判断是否是同个商品
                        if (isset($content['pid']) && isset($content['url']) && isset($content['img']) && isset($content['title']) && isset($content['info']) && isset($content['price']) && $content['pid'] != $pid) {

                            $service = User::table('wolive_queue')->where(['visiter_id' => $visiter_id, 'business_id' => $business_id])->find();

                            if ($service) {
                                $service_id = $service['service_id'];
                            } else {
                                $service_id = 0;
                            }

                            $str = '<a href="' . $content['url'] . '" target="_blank" class="wolive_product">';
                            $str .= '<div class="wolive_img"><img src="' . $content['img'] . '" width="100px"></div>';
                            $str .= '<div class="wolive_head"><p class="wolive_info">' . $content['title'] . '</p><p class="wolive_price">' . $content['price'] . '</p>';
                            $str .= '<p class="wolive_info">' . $content['info'] . '</p>';
                            $str .= '</div></a>';


                            $mydata = ['service_id' => $service_id, 'visiter_id' => $visiter_id, 'content' => $str, 'timestamp' => time(), 'business_id' => $business_id, 'direction' => 'to_service'];

                            $pusher->trigger('kefu' . $service_id, 'cu-event', array('message' => $mydata));
                            $chats = User::table('wolive_chats')->insert($mydata);
                        }
                    }

                }
            }
        }

        $channel = bin2hex($visiter_id . '/' . $business_id);
        $visiter_name = htmlspecialchars($arr2['visiter_name']);

        $avatar = htmlspecialchars($arr2['avatar']);

        if ($visiter_name == '') {
            $visiter_name = '游客' . $visiter_id;
        }

        $groupid = htmlspecialchars($arr2['groupid']);

        $app_key = app_key;
        $whost = whost;
        $arr = parse_url($whost);
        if ($arr['scheme'] == 'ws') {

            $port = 'wsPort';
            $value = 'false';
        } else {

            $value = 'true';
            $port = 'wssPort';
        }

        $business = User::table('wolive_business')->where('id', $business_id)->find();
        $rest = RestSetting::get(['business_id'=>$business_id]);
        $state = empty($rest) ? false : $rest->isOpen($business_id,$visiter_id) ;
        $this->assign('reststate', $state);
        $this->assign('restsetting',$rest);
        $this->assign('business_name',$business['business_name']);
        $this->assign("type", $business['video_state']);
        $this->assign("atype", $business['audio_state']);
        $this->assign('app_key', $app_key);
        $this->assign('whost', $arr['host']);
        $this->assign('value', $value);
        $this->assign('wport', wport);;
        $this->assign('port', $port);
        $this->assign('url', $url);
        $this->assign('groupid', $groupid);
        $this->assign('visiter', $visiter_name);
        $this->assign('business_id', $business_id);
        $this->assign('from_url', $from_url);
        $this->assign('channel', $channel);
        $this->assign('visiter_id', $visiter_id);
        $this->assign('avatar', $avatar);
        $this->assign('theme', $theme);
        $this->assign('special',$special);

        return $this->fetch();
    }

    /**
     * 404页面
     */

    public function errors()
    {
        return $this->fetch();
    }

    /**
     * 获取排队数量.
     *
     * @return mixed
     */
    public function getwaitnum()
    {
        $post = $this->request->post();
        $num = User::table('wolive_queue')->where('visiter_id', $post['visiter_id'])->where("service_id", 0)->count();
        return $num;
    }

    public function wechat()
    {
        $business_id = $this->request->param('business_id', '');
        $group_id = $this->request->param('groupid',0);
        $special = $this->request->param('special','');
        $theme = $this->request->param('theme','7571f9');
        if(empty($business_id)){
            abort(500);
        }
        $wechat = WechatPlatform::get(['business_id' => $business_id]);
        $APPID = $wechat['app_id'];
        $REDIRECT_URI = url('index/index/home',['business_id'=>$business_id,'groupid'=>$group_id,'special'=>$special,'theme'=>$theme],true,true);
        $scope = 'snsapi_userinfo';
        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $APPID . '&redirect_uri=' . urlencode($REDIRECT_URI) . '&response_type=code&scope=' . $scope . '&state=123#wechat_redirect';
        $this->redirect($url);
    }
}

在线客服系统源码安装方法:

  要运行此系统,必须安装虚拟服务器,即XAMPP在您的电脑上(对于Windows)。

  在XAMPP中启动Apache和MySQL之后,请执行以下步骤。

  第一步:提取文件

  第二步:复制主项目文件夹

  第三步:在xampp/htdocs中粘贴/

  第四步:打开浏览器并转到URL“localhost/phpmyadmin”

  第五步:然后,单击databases选项卡

  第六步:创建一个名为“tutorial_db”的数据库,然后单击import选项卡

  第7步:单击browse file并选择“tutorial_db.sql”文件,该文件位于“database”文件夹中

  第八步:创建数据库

  第九步:打开浏览器并转到URL“localhost/chat_project”

源码分享

https://yfi.lanzouj.com/iHN4A061ok5c

(0)
打赏 微信扫一扫 微信扫一扫

相关文章:

  • 使用Python轻松实现绘制词云图项目(附详细源码)

    项目背景虽然现在已经有很多现成的制作词云图的工具了,但一般存在以下几个问题:问题一:工具太多,眼花缭乱,质量参差不齐,选择困难症;问题二:大多词云工具或多或少有一些限制,自定义的空…

    2022年06月23日 脚本编程
  • 解决Django cors跨域问题

    解决Django cors跨域问题

    django cors跨域问题前后端分离项目中的跨域问题 即同源策略同源策略:同源策略/sop(same origin policy)是一种约定,由 netsc... [阅读全文]
  • Python pyecharts实时画图自定义可视化经纬度热力图

    背景在业务数据统计分析中基本都会涉及到各省区的分析,数据可视化是数据分析的一把利器,这些省区的数据一般会用地图可视化出来,这样一些规律可以被一面了然发现地图有很多可视化类型,比如:…

    2022年06月23日 脚本编程
  • python中wordcloud安装的方法小结

    正确安装python中的wordcloud(词云库)第一步:这里的√一定要勾选上。第二步:(检查是否有python的环境变量)那么python就会自动添加环境变量。第三…

    2022年06月23日 脚本编程
  • 一文轻松了解Python中类的继承

    一文轻松了解Python中类的继承

    1. 单继承继承的主要作用是实现代码的重用。继承使得子类拥有父类的方法和属性。直接来看一个例子吧。class animal:def eat(self):prin... [阅读全文]
  • 合格的攻击性白帽黑客应该具备的基本素质(1)

    合格的攻击性白帽黑客应该具备的基本素质(1)

    很多朋友总是在问: 黑客都需要什么技术呢?想成为一个黑客应该具备什么基础呢?等等诸如此类的问题 今天有时间࿰... [阅读全文]

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2022  七九推 保留所有权利. 粤ICP备17035492号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com