Chatlog.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Chatlog extends Model
  5. {
  6. /*
  7. * 留言列表
  8. */
  9. public function getChatlogList($condition, $field = '*', $page = 0, $order = 'create_time desc', $limit = '')
  10. {
  11. if ($limit) {
  12. return db('chat_log')->where($condition)->field($field)->order($order)->page($page)->limit($limit)->select();
  13. } else {
  14. $res = db('chat_log')->where($condition)->field($field)->order($order)->paginate($page);
  15. $this->page_info = $res;
  16. return $res->items();
  17. }
  18. }
  19. //客服评价率统计
  20. public function chatlogcoRate($condition){
  21. $rateCount = db('chat_log')->where($condition)->count();
  22. $condition['comment'] = array('egt',3);
  23. $mydcount = db('chat_log')->where($condition)->count();
  24. if(empty($mydcount) || empty($rateCount)){
  25. return 0;
  26. }else{
  27. return $mydcount/$rateCount*100;
  28. }
  29. }
  30. //客服转化率
  31. public function chatlogConversion($condition){
  32. $condition['tob'] = 1;
  33. $condition['tob_value'] = array('in','2,3');
  34. $rateCount = db('chat_log')->where($condition)->count();
  35. $condition['tob_value'] = 2;
  36. $zhCount = db('chat_log')->where($condition)->count();
  37. if(empty($zhCount) || empty($rateCount)){
  38. return 0;
  39. }else{
  40. return $zhCount/$rateCount*100;
  41. }
  42. }
  43. //客服挽留率
  44. public function chatlogDetainment($condition){
  45. $condition['tob'] = 3;
  46. $rateCount = db('chat_log')->where($condition)->count();
  47. $condition['tob_value'] = 2;
  48. $wlCount = db('chat_log')->where($condition)->count();
  49. if(empty($wlCount) || empty($rateCount)){
  50. return 0;
  51. }else{
  52. return $wlCount/$rateCount*100;
  53. }
  54. }
  55. //访问的客户
  56. public function allvisitor($condition, $field = '*', $page = 0, $order = 'create_time desc', $limit = ''){
  57. if ($limit) {
  58. return db('chat_log')->distinct(true)->where($condition)->field($field)->order($order)->page($page)->limit($limit)->select();
  59. } else {
  60. $res = db('chat_log')->distinct(true)->where($condition)->field($field)->order($order)->paginate($page);
  61. $this->page_info = $res;
  62. return $res->items();
  63. }
  64. }
  65. //聊天用户信息(begin:开始时间,end:结束时间,kname:客服名字)
  66. public function chatdata($begin,$end,$kname,$sid){
  67. $map['create_time'] = array('between', array($begin, $end));
  68. $map['vid'] = $kname;
  69. $map['sid'] = $sid;
  70. $list = db('chat_log')->field('id,vid,create_time')->where($map)->select();
  71. return $list;
  72. }
  73. }