InstantMessage.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * 商品管理
  4. */
  5. namespace app\admin\controller;
  6. use think\facade\View;
  7. use think\facade\Db;
  8. use think\facade\Lang;
  9. use GatewayClient\Gateway;
  10. /**
  11. * DSKMS多用户商城
  12. *
  13. * ----------------------------------------------------------------------------
  14. *
  15. * 控制器
  16. */
  17. class InstantMessage extends AdminControl
  18. {
  19. public function initialize()
  20. {
  21. parent::initialize();
  22. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/instant_message.lang.php');
  23. }
  24. /**
  25. * 商品管理
  26. */
  27. public function index()
  28. {
  29. $instant_message_model = model('instant_message');
  30. $f_name = trim(input('param.f_name'));
  31. $t_name = trim(input('param.t_name'));
  32. $time_add_from = input('param.add_time_from') ? strtotime(input('param.add_time_from')) : '';
  33. $time_add_to = input('param.add_time_to') ? strtotime(input('param.add_time_to')) : '';
  34. /**
  35. * 查询条件
  36. */
  37. $condition = array();
  38. if ($f_name) {
  39. $condition[] = array('instant_message_from_name', 'like', '%' . $f_name . '%');
  40. }
  41. if ($t_name) {
  42. $condition[] = array('instant_message_to_name', 'like', '%' . $t_name . '%');
  43. }
  44. if ($time_add_from) {
  45. $condition[] = array('instant_message_add_time', '>=', $time_add_from);
  46. }
  47. if ($time_add_to) {
  48. $condition[] = array('instant_message_add_time', '>=', $time_add_to);
  49. }
  50. $instant_message_open = input('param.instant_message_open');
  51. if (in_array($instant_message_open, array('0', '1', '2'))) {
  52. $condition[] = array('instant_message_open', '=', $instant_message_open);
  53. }
  54. $instant_message_list = $instant_message_model->getInstantMessageList($condition, 10);
  55. foreach ($instant_message_list as $key => $val) {
  56. $instant_message_list[$key] = $instant_message_model->formatInstantMessage($val);
  57. }
  58. View::assign('instant_message_list', $instant_message_list);
  59. View::assign('show_page', $instant_message_model->page_info->render());
  60. View::assign('search', $condition);
  61. $this->setAdminCurItem('index');
  62. return View::fetch();
  63. }
  64. /**
  65. * 删除商品
  66. */
  67. public function del()
  68. {
  69. $instant_message_id = input('param.instant_message_id');
  70. $instant_message_id_array = ds_delete_param($instant_message_id);
  71. if ($instant_message_id_array == FALSE) {
  72. ds_json_encode('10001', lang('ds_common_op_fail'));
  73. }
  74. $condition = array();
  75. $condition[] = array('instant_message_id', 'in', $instant_message_id_array);
  76. model('instant_message')->delInstantMessage($condition);
  77. $this->log(lang('ds_del') . lang('instant_message') . ' ID:' . implode('、', $instant_message_id_array), 1);
  78. ds_json_encode('10000', lang('ds_common_op_succ'));
  79. }
  80. /*
  81. * 直播设置
  82. */
  83. public function setting()
  84. {
  85. $config_model = model('config');
  86. if (!request()->isPost()) {
  87. $list_config = rkcache('config', true);
  88. View::assign('list_config', $list_config);
  89. $this->setAdminCurItem('setting');
  90. return View::fetch();
  91. } else {
  92. $update_array = array();
  93. $update_array['instant_message_gateway_url'] = input('param.instant_message_gateway_url');
  94. $update_array['instant_message_register_url'] = input('param.instant_message_register_url');
  95. $update_array['instant_message_open'] = input('param.instant_message_open');
  96. $result = $config_model->editConfig($update_array);
  97. if ($result) {
  98. dkcache('config');
  99. $this->log(lang('ds_setting') . lang('instant_message'), 1);
  100. $this->success(lang('ds_common_save_succ'));
  101. } else {
  102. $this->log(lang('ds_setting') . lang('instant_message'), 0);
  103. }
  104. }
  105. }
  106. /**
  107. * 获取卖家栏目列表,针对控制器下的栏目
  108. */
  109. protected function getAdminItemList()
  110. {
  111. $menu_array = array(
  112. array(
  113. 'name' => 'index',
  114. 'text' => lang('ds_list'),
  115. 'url' => url('InstantMessage/index')
  116. ),
  117. array(
  118. 'name' => 'setting',
  119. 'text' => lang('ds_setting'),
  120. 'url' => url('InstantMessage/setting')
  121. ),
  122. );
  123. return $menu_array;
  124. }
  125. }