SellerInstantMessage.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * 网站地址: http://www.csdeshang.com
  12. * ----------------------------------------------------------------------------
  13. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  14. * 不允许对程序代码以任何形式任何目的的再发布。
  15. * ============================================================================
  16. * 控制器
  17. */
  18. class SellerInstantMessage extends BaseSeller {
  19. public function initialize() {
  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. $instant_message_model = model('instant_message');
  25. $f_name = trim(input('param.f_name'));
  26. $t_name = trim(input('param.t_name'));
  27. $time_add_from = input('param.add_time_from')?strtotime(input('param.add_time_from')):'';
  28. $time_add_to = input('param.add_time_to')?strtotime(input('param.add_time_to')):'';
  29. /**
  30. * 查询条件
  31. */
  32. $condition = array();
  33. if($f_name){
  34. $condition[]=array('instant_message_from_name','like','%'.$f_name.'%');
  35. }
  36. if($t_name){
  37. $condition[]=array('instant_message_to_name','like','%'.$t_name.'%');
  38. }
  39. if($time_add_from){
  40. $condition[]=array('instant_message_add_time','>=',$time_add_from);
  41. }
  42. if($time_add_to){
  43. $condition[]=array('instant_message_add_time','>=',$time_add_to);
  44. }
  45. $instant_message_open = input('param.instant_message_open');
  46. if (in_array($instant_message_open, array('0', '1', '2'))) {
  47. $condition[]=array('instant_message_open','=',$instant_message_open);
  48. }
  49. $member_id=$this->store_info['member_id'];
  50. $result = Db::name('InstantMessage')->where(function($query) use($member_id){
  51. $query->where(function($query) use($member_id){
  52. $query->where(array(array('instant_message_from_id','=',$member_id),array('instant_message_from_type','=',0)));
  53. })->whereOr(function($query) use($member_id){
  54. $query->where(array(array('instant_message_to_id','=',$member_id),array('instant_message_to_type','=',0)));
  55. });
  56. })->where($condition)->order('instant_message_id desc')->paginate(['list_rows'=>10,'query' => request()->param()],false);
  57. $instant_message_list=$result->items();
  58. foreach($instant_message_list as $key => $val){
  59. $instant_message_list[$key]=$instant_message_model->formatInstantMessage($val);
  60. }
  61. View::assign('instant_message_list', $instant_message_list);
  62. View::assign('show_page', $result->render());
  63. View::assign('search', $condition);
  64. /* 设置卖家当前菜单 */
  65. $this->setSellerCurMenu('seller_instant_message');
  66. /* 设置卖家当前栏目 */
  67. $this->setSellerCurItem('instant_message_list');
  68. return View::fetch($this->template_dir . 'index');
  69. }
  70. /**
  71. * 栏目菜单
  72. */
  73. function getSellerItemList() {
  74. $menu_array[] = array(
  75. 'name' => 'instant_message_list',
  76. 'text' => lang('chat_query'),
  77. 'url' => url('seller_instant_message/index'),
  78. );
  79. return $menu_array;
  80. }
  81. }