site.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. class CustomModuleSite extends WeModuleSite {
  8. public function getTabUrls(){
  9. $urls = array();
  10. $urls[] = array('title' => '客服聊天记录', 'url' => $this->createWebUrl('chatlog'), 'do' => 'chatlog');
  11. return $urls;
  12. }
  13. public function doWebChatlog(){
  14. global $_GPC, $_W;
  15. load()->func('tpl');
  16. $starttime = empty($_GPC['starttime']) ? strtotime(date('Y-m-d')) : strtotime($_GPC['starttime']);
  17. if(!empty($_GPC['token'])) {
  18. unset($_GPC['token']);
  19. $avatar = '';
  20. $endtime = $starttime + 23 * 3600 + 3599;
  21. $acid = $_W['acid'];
  22. if(!empty($_GPC['nickname']) && empty($_GPC['openid'])) {
  23. $user = pdo_fetch('SELECT b.openid,a.avatar,b.nickname FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE b.acid = :acid AND a.nickname = :nickname', array(':nickname' => trim($_GPC['nickname']), ':acid' => $_W['acid']));
  24. if(empty($user['openid'])) {
  25. itoast('没有找到昵称为 "'. $_GPC['nickname'] .'" 的用户', $this->createWebUrl('chatlog', array('acid' => $acid, 'nickname' => $_GPC['nickname'], 'openid' => $_GPC['openid'], 'starttime' => $_GPC['starttime'])), 'error');
  26. } else {
  27. if(!empty($user['avatar'])) {
  28. $avatar = tomedia($user['avatar']);
  29. $nickname = $user['nickname'];
  30. }
  31. }
  32. } else {
  33. $openid = trim($_GPC['openid']);
  34. $user = pdo_fetch('SELECT b.openid,a.avatar,b.nickname FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE b.acid = :acid AND b.openid = :openid', array(':openid' => trim($_GPC['openid']), ':acid' => $_W['acid']));
  35. if(!empty($user['avatar'])) {
  36. $avatar = tomedia($user['avatar']);
  37. $nickname = $user['nickname'];
  38. }
  39. }
  40. if(empty($user['openid'])) {
  41. itoast('请输入粉丝昵称或者粉丝openid', referer(), 'error');
  42. }
  43. if($acid > 0 && !empty($starttime) && !empty($endtime)) {
  44. $pindex = max(1, intval($_GPC['page']));
  45. $acc = WeAccount::createByUniacid();
  46. $params = array('openid' => trim($user['openid']), 'starttime' => $starttime, 'endtime' => $endtime, 'pageindex' => $pindex, 'pagesize' => 50);
  47. $logs = $acc->fetchChatLog($params);
  48. $next = 1;
  49. if(is_error($logs) || empty($logs['recordlist']) || (count($logs['recordlist']) < $params['pagesize'])) {
  50. $next = 0;
  51. }
  52. $codedata = array();
  53. $codedata[1000] = '创建未接入会话';
  54. $codedata[1001] = '接入会话';
  55. $codedata[1002] = '主动发起会话';
  56. $codedata[1004] = '关闭会话';
  57. $codedata[1005] = '抢接会话';
  58. $codedata[2001] = '公众号收到消息';
  59. $codedata[2002] = '客服发送消息';
  60. $codedata[2003] = '客服收到消息';
  61. }
  62. }
  63. include $this->template('chatlog');
  64. }
  65. }