| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\common\model;
- use think\Model;
- class Chatlog extends Model
- {
- /*
- * 留言列表
- */
- public function getChatlogList($condition, $field = '*', $page = 0, $order = 'create_time desc', $limit = '')
- {
- if ($limit) {
- return db('chat_log')->where($condition)->field($field)->order($order)->page($page)->limit($limit)->select();
- } else {
- $res = db('chat_log')->where($condition)->field($field)->order($order)->paginate($page);
- $this->page_info = $res;
- return $res->items();
- }
- }
- //客服评价率统计
- public function chatlogcoRate($condition){
- $rateCount = db('chat_log')->where($condition)->count();
- $condition['comment'] = array('egt',3);
- $mydcount = db('chat_log')->where($condition)->count();
- if(empty($mydcount) || empty($rateCount)){
- return 0;
- }else{
- return $mydcount/$rateCount*100;
- }
- }
- //客服转化率
- public function chatlogConversion($condition){
- $condition['tob'] = 1;
- $condition['tob_value'] = array('in','2,3');
- $rateCount = db('chat_log')->where($condition)->count();
- $condition['tob_value'] = 2;
- $zhCount = db('chat_log')->where($condition)->count();
- if(empty($zhCount) || empty($rateCount)){
- return 0;
- }else{
- return $zhCount/$rateCount*100;
- }
- }
- //客服挽留率
- public function chatlogDetainment($condition){
- $condition['tob'] = 3;
- $rateCount = db('chat_log')->where($condition)->count();
- $condition['tob_value'] = 2;
- $wlCount = db('chat_log')->where($condition)->count();
- if(empty($wlCount) || empty($rateCount)){
- return 0;
- }else{
- return $wlCount/$rateCount*100;
- }
- }
- //访问的客户
- public function allvisitor($condition, $field = '*', $page = 0, $order = 'create_time desc', $limit = ''){
- if ($limit) {
- return db('chat_log')->distinct(true)->where($condition)->field($field)->order($order)->page($page)->limit($limit)->select();
- } else {
- $res = db('chat_log')->distinct(true)->where($condition)->field($field)->order($order)->paginate($page);
- $this->page_info = $res;
- return $res->items();
- }
- }
- //聊天用户信息(begin:开始时间,end:结束时间,kname:客服名字)
- public function chatdata($begin,$end,$kname,$sid){
- $map['create_time'] = array('between', array($begin, $end));
- $map['vid'] = $kname;
- $map['sid'] = $sid;
- $list = db('chat_log')->field('id,vid,create_time')->where($map)->select();
-
- return $list;
- }
- }
|