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