InstantMessage.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. *
  15. * ----------------------------------------------------------------------------
  16. *
  17. * ============================================================================
  18. * 控制器
  19. */
  20. class InstantMessage extends AdminControl {
  21. public function initialize() {
  22. parent::initialize();
  23. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/instant_message.lang.php');
  24. }
  25. /**
  26. * 商品管理
  27. */
  28. public function index() {
  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. $instant_message_id = input('param.instant_message_id');
  69. $instant_message_id_array = ds_delete_param($instant_message_id);
  70. if ($instant_message_id_array == FALSE) {
  71. ds_json_encode('10001', lang('ds_common_op_fail'));
  72. }
  73. $condition = array();
  74. $condition[] = array('instant_message_id','in', $instant_message_id_array);
  75. model('instant_message')->delInstantMessage($condition);
  76. $this->log(lang('ds_del') . lang('instant_message') . ' ID:' . implode('、', $instant_message_id_array), 1);
  77. ds_json_encode('10000', lang('ds_common_op_succ'));
  78. }
  79. /*
  80. * 直播设置
  81. */
  82. public function setting() {
  83. $config_model = model('config');
  84. if (!request()->isPost()) {
  85. $list_config = rkcache('config', true);
  86. View::assign('list_config', $list_config);
  87. $this->setAdminCurItem('setting');
  88. return View::fetch();
  89. } else {
  90. $update_array=array();
  91. $update_array['instant_message_gateway_url'] = input('param.instant_message_gateway_url');
  92. $update_array['instant_message_register_url'] = input('param.instant_message_register_url');
  93. $update_array['instant_message_open'] = input('param.instant_message_open');
  94. $result = $config_model->editConfig($update_array);
  95. if ($result) {
  96. dkcache('config');
  97. $this->log(lang('ds_setting') . lang('instant_message'), 1);
  98. $this->success(lang('ds_common_save_succ'));
  99. } else {
  100. $this->log(lang('ds_setting') . lang('instant_message'), 0);
  101. }
  102. }
  103. }
  104. /**
  105. * 获取卖家栏目列表,针对控制器下的栏目
  106. */
  107. protected function getAdminItemList() {
  108. $menu_array = array(
  109. array(
  110. 'name' => 'index',
  111. 'text' => lang('ds_list'),
  112. 'url' => url('InstantMessage/index')
  113. ),
  114. array(
  115. 'name' => 'setting',
  116. 'text' => lang('ds_setting'),
  117. 'url' => url('InstantMessage/setting')
  118. ),
  119. );
  120. return $menu_array;
  121. }
  122. }