InstantMessage.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. * ============================================================================
  12. * DSKMS多用户商城
  13. * ============================================================================
  14. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  15. * 网站地址: https://www.valimart.net/
  16. * ----------------------------------------------------------------------------
  17. *
  18. * ============================================================================
  19. * 控制器
  20. */
  21. class InstantMessage extends AdminControl {
  22. public function initialize() {
  23. parent::initialize();
  24. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/instant_message.lang.php');
  25. }
  26. /**
  27. * 商品管理
  28. */
  29. public function index() {
  30. $instant_message_model = model('instant_message');
  31. $f_name = trim(input('param.f_name'));
  32. $t_name = trim(input('param.t_name'));
  33. $time_add_from = input('param.add_time_from')?strtotime(input('param.add_time_from')):'';
  34. $time_add_to = input('param.add_time_to')?strtotime(input('param.add_time_to')):'';
  35. /**
  36. * 查询条件
  37. */
  38. $condition = array();
  39. if($f_name){
  40. $condition[]=array('instant_message_from_name','like','%'.$f_name.'%');
  41. }
  42. if($t_name){
  43. $condition[]=array('instant_message_to_name','like','%'.$t_name.'%');
  44. }
  45. if($time_add_from){
  46. $condition[]=array('instant_message_add_time','>=',$time_add_from);
  47. }
  48. if($time_add_to){
  49. $condition[]=array('instant_message_add_time','>=',$time_add_to);
  50. }
  51. $instant_message_open = input('param.instant_message_open');
  52. if (in_array($instant_message_open, array('0', '1', '2'))) {
  53. $condition[]=array('instant_message_open','=',$instant_message_open);
  54. }
  55. $instant_message_list = $instant_message_model->getInstantMessageList($condition, 10);
  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', $instant_message_model->page_info->render());
  61. View::assign('search', $condition);
  62. $this->setAdminCurItem('index');
  63. return View::fetch();
  64. }
  65. /**
  66. * 删除商品
  67. */
  68. public function del() {
  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. $config_model = model('config');
  85. if (!request()->isPost()) {
  86. $list_config = rkcache('config', true);
  87. View::assign('list_config', $list_config);
  88. $this->setAdminCurItem('setting');
  89. return View::fetch();
  90. } else {
  91. $update_array=array();
  92. $update_array['instant_message_gateway_url'] = input('param.instant_message_gateway_url');
  93. $update_array['instant_message_register_url'] = input('param.instant_message_register_url');
  94. $update_array['instant_message_open'] = input('param.instant_message_open');
  95. $result = $config_model->editConfig($update_array);
  96. if ($result) {
  97. dkcache('config');
  98. $this->log(lang('ds_setting') . lang('instant_message'), 1);
  99. $this->success(lang('ds_common_save_succ'));
  100. } else {
  101. $this->log(lang('ds_setting') . lang('instant_message'), 0);
  102. }
  103. }
  104. }
  105. /**
  106. * 获取卖家栏目列表,针对控制器下的栏目
  107. */
  108. protected function getAdminItemList() {
  109. $menu_array = array(
  110. array(
  111. 'name' => 'index',
  112. 'text' => lang('ds_list'),
  113. 'url' => url('InstantMessage/index')
  114. ),
  115. array(
  116. 'name' => 'setting',
  117. 'text' => lang('ds_setting'),
  118. 'url' => url('InstantMessage/setting')
  119. ),
  120. );
  121. return $menu_array;
  122. }
  123. }
  124. ?>