site.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 = table('mc_members')
  24. ->select(array('b.openid', 'a.avatar', 'b.nickname'))
  25. ->searchWithMappingFans()
  26. ->where(array(
  27. 'b.acid' => $_W['acid'],
  28. 'a.nickname' => safe_gpc_string($_GPC['nickname'])
  29. ))
  30. ->get();
  31. if (empty($user['openid'])) {
  32. itoast('没有找到昵称为 "' . $_GPC['nickname'] . '" 的用户', $this->createWebUrl('chatlog', array('acid' => $acid, 'nickname' => $_GPC['nickname'], 'openid' => $_GPC['openid'], 'starttime' => $_GPC['starttime'])), 'error');
  33. } else {
  34. if (!empty($user['avatar'])) {
  35. $avatar = tomedia($user['avatar']);
  36. $nickname = $user['nickname'];
  37. }
  38. }
  39. } else {
  40. $openid = safe_gpc_string($_GPC['openid']);
  41. $user = table('mc_members')
  42. ->select(array('b.openid', 'a.avatar', 'b.nickname'))
  43. ->searchWithMappingFans()
  44. ->where(array(
  45. 'b.uniacid' => $_W['uniacid'],
  46. 'b.openid' => $openid
  47. ))
  48. ->get();
  49. if (!empty($user['avatar'])) {
  50. $avatar = tomedia($user['avatar']);
  51. $nickname = $user['nickname'];
  52. }
  53. }
  54. if (empty($user['openid'])) {
  55. itoast('请输入粉丝昵称或者粉丝openid', referer(), 'error');
  56. }
  57. if ($acid > 0 && !empty($starttime) && !empty($endtime)) {
  58. $pindex = max(1, intval($_GPC['page']));
  59. $acc = WeAccount::createByUniacid();
  60. $params = array('openid' => trim($user['openid']), 'starttime' => $starttime, 'endtime' => $endtime, 'pageindex' => $pindex, 'pagesize' => 50);
  61. $logs = $acc->fetchChatLog($params);
  62. $next = 1;
  63. if (is_error($logs) || empty($logs['recordlist']) || (count($logs['recordlist']) < $params['pagesize'])) {
  64. $next = 0;
  65. }
  66. $codedata = array();
  67. $codedata[1000] = '创建未接入会话';
  68. $codedata[1001] = '接入会话';
  69. $codedata[1002] = '主动发起会话';
  70. $codedata[1004] = '关闭会话';
  71. $codedata[1005] = '抢接会话';
  72. $codedata[2001] = '公众号收到消息';
  73. $codedata[2002] = '客服发送消息';
  74. $codedata[2003] = '客服收到消息';
  75. }
  76. }
  77. include $this->template('chatlog');
  78. }
  79. }