SellerInstantMessage.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  11. * 网站地址: https://www.valimart.net/
  12. * ----------------------------------------------------------------------------
  13. *
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class SellerInstantMessage extends BaseSeller {
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/seller_instant_message.lang.php');
  21. }
  22. public function index() {
  23. $instant_message_model = model('instant_message');
  24. $f_name = trim(input('param.f_name'));
  25. $t_name = trim(input('param.t_name'));
  26. $time_add_from = input('param.add_time_from')?strtotime(input('param.add_time_from')):'';
  27. $time_add_to = input('param.add_time_to')?strtotime(input('param.add_time_to')):'';
  28. /**
  29. * 查询条件
  30. */
  31. $condition = array();
  32. if($f_name){
  33. $condition[]=array('instant_message_from_name','like','%'.$f_name.'%');
  34. }
  35. if($t_name){
  36. $condition[]=array('instant_message_to_name','like','%'.$t_name.'%');
  37. }
  38. if($time_add_from){
  39. $condition[]=array('instant_message_add_time','>=',$time_add_from);
  40. }
  41. if($time_add_to){
  42. $condition[]=array('instant_message_add_time','>=',$time_add_to);
  43. }
  44. $instant_message_open = input('param.instant_message_open');
  45. if (in_array($instant_message_open, array('0', '1', '2'))) {
  46. $condition[]=array('instant_message_open','=',$instant_message_open);
  47. }
  48. $member_id=$this->store_info['member_id'];
  49. $result = Db::name('InstantMessage')->where(function($query) use($member_id){
  50. $query->where(function($query) use($member_id){
  51. $query->where(array(array('instant_message_from_id','=',$member_id),array('instant_message_from_type','=',0)));
  52. })->whereOr(function($query) use($member_id){
  53. $query->where(array(array('instant_message_to_id','=',$member_id),array('instant_message_to_type','=',0)));
  54. });
  55. })->where($condition)->order('instant_message_id desc')->paginate(['list_rows'=>10,'query' => request()->param()],false);
  56. $instant_message_list=$result->items();
  57. foreach($instant_message_list as $key => $val){
  58. $instant_message_list[$key]=$instant_message_model->formatInstantMessage($val);
  59. }
  60. View::assign('instant_message_list', $instant_message_list);
  61. View::assign('show_page', $result->render());
  62. View::assign('search', $condition);
  63. /* 设置卖家当前菜单 */
  64. $this->setSellerCurMenu('seller_instant_message');
  65. /* 设置卖家当前栏目 */
  66. $this->setSellerCurItem('instant_message_list');
  67. return View::fetch($this->template_dir . 'index');
  68. }
  69. /**
  70. * 栏目菜单
  71. */
  72. function getSellerItemList() {
  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. }