store_im.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * 聊天记录查询
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class store_imControl extends BaseSellerControl {
  10. public function __construct() {
  11. parent::__construct();
  12. $add_time_to = date("Y-m-d");
  13. $time_from = array();
  14. $time_from['7'] = strtotime($add_time_to)-60*60*24*7;
  15. $time_from['60'] = strtotime($add_time_to)-60*60*24*60;
  16. $add_time_from = date("Y-m-d",$time_from['60']);
  17. Tpl::output('minDate', $add_time_from);//只能查看2个月内数据
  18. Tpl::output('maxDate', $add_time_to);
  19. if (empty($_GET['add_time_from']) || $_GET['add_time_from'] < $add_time_from) {//默认显示7天内数据
  20. $_GET['add_time_from'] = date("Y-m-d",$time_from['7']);
  21. }
  22. if (empty($_GET['add_time_to']) || $_GET['add_time_to'] > $add_time_to) {
  23. $_GET['add_time_to'] = $add_time_to;
  24. }
  25. }
  26. /**
  27. * 查询页
  28. *
  29. */
  30. public function indexOp() {
  31. $model_seller = Model('seller');
  32. $condition = array();
  33. $condition['store_id'] = $_SESSION['store_id'];
  34. $seller_list = $model_seller->getSellerList($condition, '', 'seller_id asc');//账号列表
  35. Tpl::output('seller_list', $seller_list);
  36. $seller_id = $_SESSION['seller_id'];
  37. Tpl::output('seller_id', $seller_id);
  38. self::profile_menu('im','index');
  39. Tpl::showpage('store_chat.index');
  40. }
  41. /**
  42. * 聊天记录查看页
  43. *
  44. */
  45. public function get_chat_logOp() {
  46. $model_seller = Model('seller');
  47. $condition = array();
  48. $condition['store_id'] = $_SESSION['store_id'];
  49. $condition['seller_id'] = $_GET['seller_id'];
  50. $seller = $model_seller->getSellerInfo($condition);//账号
  51. Tpl::output('seller', $seller);
  52. if ($seller['member_id'] > 0) {//验证商家账号
  53. $model_chat = Model('web_chat');
  54. $condition['add_time_from'] = trim($_GET['add_time_from']);
  55. $condition['add_time_to'] = trim($_GET['add_time_to']);
  56. $condition['f_id'] = intval($seller['member_id']);
  57. $condition['t_id'] = intval($_GET['t_id']);
  58. $condition['t_msg'] = trim($_GET['msg_key']);
  59. $list = $model_chat->getLogFromList($condition,15);
  60. $list = array_reverse($list);
  61. Tpl::output('list', $list);
  62. Tpl::output('show_page',$model_chat->showpage());
  63. }
  64. Tpl::showpage('store_chat_log','null_layout');
  65. }
  66. /**
  67. * 最近联系人
  68. *
  69. */
  70. public function get_user_listOp() {
  71. $model_seller = Model('seller');
  72. $condition = array();
  73. $condition['store_id'] = $_SESSION['store_id'];
  74. $condition['seller_id'] = $_GET['seller_id'];
  75. $seller = $model_seller->getSellerInfo($condition);//账号
  76. $member_list = array();
  77. if ($seller['member_id'] > 0) {//验证商家账号
  78. $model_chat = Model('web_chat');
  79. $add_time_to = date("Y-m-d");
  80. $add_time_from = strtotime($add_time_to)-60*60*24*60;
  81. $add_time_to = strtotime($add_time_to);
  82. $condition = array();
  83. $condition['add_time'] = array('time',array($add_time_from,$add_time_to));
  84. $condition['f_id'] = $seller['member_id'];
  85. $member_list = $model_chat->getRecentList($condition,100,$member_list);
  86. $condition = array();
  87. $condition['add_time'] = array('time',array($add_time_from,$add_time_to));
  88. $condition['t_id'] = $seller['member_id'];
  89. $member_list = $model_chat->getRecentFromList($condition,100,$member_list);
  90. Tpl::output('list', $member_list);
  91. }
  92. Tpl::showpage('store_chat_user','null_layout');
  93. }
  94. /**
  95. * 小导航
  96. *
  97. * @param string $menu_type 导航类型
  98. * @param string $menu_key 当前导航的menu_key
  99. * @return
  100. */
  101. private function profile_menu($menu_type,$menu_key='') {
  102. $menu_array = array();
  103. switch ($menu_type) {
  104. case 'im':
  105. $menu_array = array(
  106. array('menu_key'=>'index','menu_name'=>'聊天记录查询', 'menu_url'=>'index.php?act=store_im&op=index')
  107. );
  108. break;
  109. }
  110. Tpl::output('member_menu',$menu_array);
  111. Tpl::output('menu_key',$menu_key);
  112. }
  113. }