SellerInstantMessage.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. use think\facade\Db;
  6. /**
  7. * DSO2O多用户商城
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * 控制器
  12. */
  13. class SellerInstantMessage extends BaseSeller
  14. {
  15. public function initialize()
  16. {
  17. parent::initialize();
  18. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/seller_instant_message.lang.php');
  19. }
  20. public function index()
  21. {
  22. $instant_message_model = model('instant_message');
  23. $f_name = trim(input('param.f_name'));
  24. $t_name = trim(input('param.t_name'));
  25. $time_add_from = input('param.add_time_from') ? strtotime(input('param.add_time_from')) : '';
  26. $time_add_to = input('param.add_time_to') ? strtotime(input('param.add_time_to')) : '';
  27. /**
  28. * 查询条件
  29. */
  30. $condition = array();
  31. if ($f_name) {
  32. $condition[] = array('instant_message_from_name', 'like', '%' . $f_name . '%');
  33. }
  34. if ($t_name) {
  35. $condition[] = array('instant_message_to_name', 'like', '%' . $t_name . '%');
  36. }
  37. if ($time_add_from) {
  38. $condition[] = array('instant_message_add_time', '>=', $time_add_from);
  39. }
  40. if ($time_add_to) {
  41. $condition[] = array('instant_message_add_time', '>=', $time_add_to);
  42. }
  43. $instant_message_open = input('param.instant_message_open');
  44. if (in_array($instant_message_open, array('0', '1', '2'))) {
  45. $condition[] = array('instant_message_open', '=', $instant_message_open);
  46. }
  47. $member_id = $this->store_info['member_id'];
  48. $result = Db::name('InstantMessage')->where(function ($query) use ($member_id) {
  49. $query->where(function ($query) use ($member_id) {
  50. $query->where(array(array('instant_message_from_id', '=', $member_id), array('instant_message_from_type', '=', 0)));
  51. })->whereOr(function ($query) use ($member_id) {
  52. $query->where(array(array('instant_message_to_id', '=', $member_id), array('instant_message_to_type', '=', 0)));
  53. });
  54. })->where($condition)->order('instant_message_id desc')->paginate(['list_rows' => 10, 'query' => request()->param()], false);
  55. $instant_message_list = $result->items();
  56. foreach ($instant_message_list as $key => $val) {
  57. $instant_message_list[$key] = $instant_message_model->formatInstantMessage($val);
  58. }
  59. View::assign('instant_message_list', $instant_message_list);
  60. View::assign('show_page', $result->render());
  61. View::assign('search', $condition);
  62. /* 设置卖家当前菜单 */
  63. $this->setSellerCurMenu('seller_instant_message');
  64. /* 设置卖家当前栏目 */
  65. $this->setSellerCurItem('instant_message_list');
  66. return View::fetch($this->template_dir . 'index');
  67. }
  68. /**
  69. * 栏目菜单
  70. */
  71. function getSellerItemList()
  72. {
  73. $menu_array[] = array(
  74. 'name' => 'instant_message_list',
  75. 'text' => lang('chat_query'),
  76. 'url' => url('seller_instant_message/index'),
  77. );
  78. return $menu_array;
  79. }
  80. }